@arcgis/core 4.31.0 → 4.31.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.
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/02a41ff83a28a574da3b.js +1 -0
- package/assets/esri/core/workers/chunks/034b842fd1e57a663e63.js +1 -0
- package/assets/esri/core/workers/chunks/11fa84fa7fa78e61c4cb.js +1 -0
- package/assets/esri/core/workers/chunks/2ddd67ec7b364e20135c.js +1 -0
- package/assets/esri/core/workers/chunks/{e298b561933737eda0ad.js → 388dc6d50e16930aa66f.js} +1 -1
- package/assets/esri/core/workers/chunks/3f8ea858575bab03d3aa.js +1 -0
- package/assets/esri/core/workers/chunks/48db492f15074a799d28.js +1 -0
- package/assets/esri/core/workers/chunks/49cf9642f3827384127f.js +1 -0
- package/assets/esri/core/workers/chunks/50781ca6c2526b0dd73f.js +1 -0
- package/assets/esri/core/workers/chunks/511cc9f1b61318385915.js +1 -0
- package/assets/esri/core/workers/chunks/650047df195a8ac3e41e.js +1 -0
- package/assets/esri/core/workers/chunks/666663e1257ceea08f75.js +1 -0
- package/assets/esri/core/workers/chunks/{188371b682afa56bed28.js → 69c5caef30d08a5086a3.js} +1 -1
- package/assets/esri/core/workers/chunks/6e37f4ec5a5c606efacb.js +1 -0
- package/assets/esri/core/workers/chunks/6ebd25845c4c3b65f612.js +1 -0
- package/assets/esri/core/workers/chunks/{72c5fd68179af3ab163f.js → 79e95e979108e2550961.js} +1 -1
- package/assets/esri/core/workers/chunks/7bbe8df83ecac2546af7.js +1 -0
- package/assets/esri/core/workers/chunks/7e6f5f04ac11e5ec9101.js +1 -0
- package/assets/esri/core/workers/chunks/8a3787ba111d669f2955.js +1 -0
- package/assets/esri/core/workers/chunks/8c5acb0a8c0a216fa9a8.js +1 -0
- package/assets/esri/core/workers/chunks/8e0e857e59e9fbc4a4b1.js +1 -0
- package/assets/esri/core/workers/chunks/{871312317726e9776953.js → 8eec36cb9c9bdb40eab2.js} +1 -1
- package/assets/esri/core/workers/chunks/{cfa12f6d165e1b06abfb.js → 973560d8883c77f35f79.js} +1 -1
- package/assets/esri/core/workers/chunks/9857b195487aa6ff6b16.js +1 -0
- package/assets/esri/core/workers/chunks/a84212e50fb7e1a82bb4.js +1 -0
- package/assets/esri/core/workers/chunks/ac9681ebbae83b6d8c8a.js +1 -0
- package/assets/esri/core/workers/chunks/{0efcf69bc0ed843f1c20.js → af2f48911f984a911d3d.js} +1 -1
- package/assets/esri/core/workers/chunks/c1315c5610326a98811b.js +1 -0
- package/assets/esri/core/workers/chunks/c5ddaa5d8ac5eec949cf.js +1 -0
- package/assets/esri/core/workers/chunks/ce49d6c0becb9c39ceec.js +1 -0
- package/assets/esri/core/workers/chunks/d0093ec96d21ee7fcb27.js +1 -0
- package/assets/esri/core/workers/chunks/ed2f3f32f21960305cd9.js +1 -0
- package/assets/esri/core/workers/chunks/ed3fb3ea29a2be226322.js +1 -0
- package/assets/esri/core/workers/chunks/f3550d82fd8328953ca6.js +1 -0
- package/assets/esri/core/workers/chunks/f717ca7c2581c31de7a6.js +1 -0
- package/assets/esri/core/workers/chunks/fe684aaa9dfddf1c5b22.js +1 -0
- package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_en.json +1 -1
- package/chunks/Viewshed.glsl.js +2 -1
- package/core/uuid.js +1 -1
- package/geometry/operators/containsOperator.js +1 -1
- package/geometry/operators/crossesOperator.js +1 -1
- package/geometry/operators/disjointOperator.js +1 -1
- package/geometry/operators/equalsOperator.js +1 -1
- package/geometry/operators/gx/operatorIntersection.js +1 -1
- package/geometry/operators/intersectsOperator.js +1 -1
- package/geometry/operators/overlapsOperator.js +1 -1
- package/geometry/operators/relateOperator.js +1 -1
- package/geometry/operators/touchesOperator.js +1 -1
- package/geometry/operators/withinOperator.js +1 -1
- package/interfaces.d.ts +2 -2
- package/kernel.js +1 -1
- package/layers/orientedImagery/transformations/rectifyMapPoint.js +1 -1
- package/layers/save/featureLayerUtils.js +1 -1
- package/layers/save/mediaLayerUtils.js +1 -1
- package/layers/save/utils.js +1 -1
- package/layers/support/featureLayerUtils.js +1 -1
- package/package.json +1 -1
- package/smartMapping/raster/renderers/classBreaks.js +1 -1
- package/smartMapping/renderers/color.js +1 -1
- package/smartMapping/renderers/dotDensity.js +1 -1
- package/smartMapping/renderers/pieChart.js +1 -1
- package/smartMapping/renderers/predominance.js +1 -1
- package/smartMapping/renderers/relationship.js +1 -1
- package/smartMapping/renderers/size.js +1 -1
- package/smartMapping/renderers/support/regenerateUtils.js +1 -1
- package/smartMapping/renderers/support/rendererUtils.js +1 -1
- package/smartMapping/renderers/type.js +1 -1
- package/smartMapping/renderers/univariateColorSize.js +1 -1
- package/support/revision.js +1 -1
- package/symbols/cim/animationUtils.js +1 -1
- package/symbols/cim/cimAnalyzer.js +1 -1
- package/views/2d/engine/imagery/processor/bandArithmeticProcessor.js +1 -1
- package/views/2d/engine/webgl/Painter.js +1 -1
- package/views/2d/engine/webgl/effects/BlendEffect.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/blend/BlendTechnique.js +1 -1
- package/views/2d/engine/webgl/shaders/sources/shaderRepository.js +1 -1
- package/views/2d/layers/MediaLayerView2D.js +1 -1
- package/views/2d/layers/TileLayerView2D.js +1 -1
- package/views/2d/layers/features/FeatureContainer.js +1 -1
- package/views/2d/layers/features/RenderState.js +1 -1
- package/views/2d/layers/features/processor/FeatureUpdateStrategy.js +1 -1
- package/views/2d/layers/features/support/AttributeStore.js +1 -1
- package/views/2d/layers/features/support/DisplayIdGenerator.js +1 -1
- package/views/3d/layers/i3s/featureEditing.js +1 -1
- package/views/3d/layers/support/FeatureTileMeasurements3D.js +1 -1
- package/views/3d/layers/support/FeatureTileTree3D.js +1 -1
- package/views/3d/state/ViewStateManager.js +1 -1
- package/views/3d/support/cameraUtils.js +1 -1
- package/views/3d/support/viewpointUtils.js +1 -1
- package/views/interactive/snapping/featureSources/featureServiceSource/FeatureServiceTiledFetcher.js +1 -1
- package/views/webgl/FramebufferObject.js +1 -1
- package/views/webgl/TextureDescriptor.js +1 -1
- package/widgets/FeatureTable/FeatureTableViewModel.js +1 -1
- package/widgets/FeatureTable/Grid/Grid.js +1 -1
- package/widgets/FeatureTable/Grid/GridViewModel.js +1 -1
- package/widgets/FeatureTable.js +1 -1
- package/widgets/Print/PrintViewModel.js +1 -1
- package/widgets/Print.js +1 -1
- package/widgets/support/GridControls/GridControlsViewModel.js +1 -1
- package/widgets/support/GridControls.js +1 -1
- package/widgets/support/SnappingControls.js +1 -1
- package/assets/esri/core/workers/chunks/0e292550c6e214dd160b.js +0 -1
- package/assets/esri/core/workers/chunks/125433d1c1c31f29cb62.js +0 -1
- package/assets/esri/core/workers/chunks/1ab8dff1ffd2cfc606a3.js +0 -1
- package/assets/esri/core/workers/chunks/1d6c66dfeb646b2d38d0.js +0 -1
- package/assets/esri/core/workers/chunks/1f7fe71d80378b5d2acc.js +0 -1
- package/assets/esri/core/workers/chunks/214b0b234c46f1c163a2.js +0 -1
- package/assets/esri/core/workers/chunks/3645401eaceae7ca194f.js +0 -1
- package/assets/esri/core/workers/chunks/38216a3288fa3af5fa32.js +0 -1
- package/assets/esri/core/workers/chunks/4cd3c861e33366f15af8.js +0 -1
- package/assets/esri/core/workers/chunks/5af2ea57ac8c62258128.js +0 -1
- package/assets/esri/core/workers/chunks/6417fc06bbff9852426f.js +0 -1
- package/assets/esri/core/workers/chunks/6c94ce65a5399de9a0cd.js +0 -1
- package/assets/esri/core/workers/chunks/7114bcb1de727ba596be.js +0 -1
- package/assets/esri/core/workers/chunks/787e8fad19dcc5d84dd9.js +0 -1
- package/assets/esri/core/workers/chunks/837471fcf383a0f4b6ff.js +0 -1
- package/assets/esri/core/workers/chunks/877e9181a3ec40b1231a.js +0 -1
- package/assets/esri/core/workers/chunks/8a232508b7fe011154ab.js +0 -1
- package/assets/esri/core/workers/chunks/8d2aa1e054cee14df379.js +0 -1
- package/assets/esri/core/workers/chunks/9189d24f71e2e706821e.js +0 -1
- package/assets/esri/core/workers/chunks/94451bca86ccdf05974c.js +0 -1
- package/assets/esri/core/workers/chunks/9cfaf1cbbb1d6453e939.js +0 -1
- package/assets/esri/core/workers/chunks/a3767791456281861b49.js +0 -1
- package/assets/esri/core/workers/chunks/a68a141bec952373ab6f.js +0 -1
- package/assets/esri/core/workers/chunks/ab6eaa3ae2e233f91a5e.js +0 -1
- package/assets/esri/core/workers/chunks/aedb2e7cd5b3300da5fa.js +0 -1
- package/assets/esri/core/workers/chunks/b045413c44239f597cc3.js +0 -1
- package/assets/esri/core/workers/chunks/b6044b20fb38524a268f.js +0 -1
- package/assets/esri/core/workers/chunks/cca72ca3a4f90b45c2ce.js +0 -1
- package/assets/esri/core/workers/chunks/d497b6443353efc80417.js +0 -1
- package/assets/esri/core/workers/chunks/da1687d68cfe20e4f069.js +0 -1
- package/assets/esri/core/workers/chunks/f1313389eeb7a2350db3.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.31/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../../Camera.js";import{Cyclical as t}from"../../../core/Cyclical.js";import n from"../../../core/Logger.js";import{deg2rad as r,rad2deg as o,asinClamped as i}from"../../../core/mathUtils.js";import{throwIfAborted as a}from"../../../core/promiseUtils.js";import{h as c,g as s,l,j as u,F as f,c as m}from"../../../chunks/vec32.js";import{clone as p,create as d}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as h}from"../../../geometry/ellipsoidUtils.js";import y from"../../../geometry/Point.js";import{projectWithZConversion as g,project as v}from"../../../geometry/projection.js";import w from"../../../geometry/SpatialReference.js";import{projectPointToVector as R,projectPointToVectorAsync as T}from"../../../geometry/projection/projectPointToVector.js";import{projectVectorToPoint as x,projectVectorToPointAsync as S}from"../../../geometry/projection/projectVectorToPoint.js";import{projectVectorToVector as M}from"../../../geometry/projection/projectVectorToVector.js";import{ViewingMode as j}from"../../ViewingMode.js";import{cameraOnContentAlongViewDirection as C}from"../camera/intersectionUtils.js";import{c as z}from"../../../chunks/cameraUtilsPlanar.js";import{c as A}from"../../../chunks/cameraUtilsSpherical.js";import{getGreatCircleSpanAt as b}from"./earthUtils.js";import{getElevationAtPoint as U}from"./ElevationProvider.js";import{isSpatialReferenceSupported as L}from"../../support/spatialReferenceSupport.js";const D=()=>n.getLogger("esri.views.3d.support.cameraUtils"),P=39.37,H=96,O=H*P,E=1,F=8,G=5,I=1,J={heading:0,tilt:0},q=d(),k=new t(-20037508.342788905,20037508.342788905),V=new t(-180,180);var X;function K(e){return e.spatialReference??w.WGS84}function W({state:e}){return e.isGlobal?A:z}function Y(e,t,n,r,o){return W(e).headingTiltToDirectionUp(t,n,r,o)}function N(e,t){if(null==t)return null;const n=e.renderSpatialReference,o=W(e).headingTiltToDirectionUp,i=d();if(!R(t.position,i,n))return null;const a=o(i,t.heading,t.tilt);c(a.direction,a.direction,e.state.camera.distance),s(a.direction,a.direction,i);const l=C(e,i,a.direction,a.up);return l.fov=r(t.fov),l.row=t.layout.row,l.rows=t.layout.rows,l.column=t.layout.column,l.columns=t.layout.columns,l}!function(e){e[e.LOCKED=0]="LOCKED",e[e.ADJUST=1]="ADJUST"}(X||(X={}));const Z=d();function B(t,n,r){const i=t.renderSpatialReference,a=ue(t,n.eye,n.viewForward,n.up,J);let c=K(t);return M(n.eye,i,Z,c)||(c=w.WGS84,M(n.eye,i,Z,c)),null==r?r=new e(new y(Z,c),a.heading,a.tilt,o(n.fov)):(r.position.x=Z[0],r.position.y=Z[1],r.position.z=Z[2],r.position.spatialReference=c,r.heading=a.heading,r.tilt=a.tilt,r.fov=o(n.fov)),r.layout.row=n.row,r.layout.rows=n.rows,r.layout.column=n.column,r.layout.columns=n.columns,r}function Q(e,t){const{camera:n}=e.state,{unitInMeters:r}=e.renderCoordsHelper;return n.width/2/n.pixelRatio/(H*P/(t/=r))/Math.tan(n.fovX/2)}function $(e,t){const{camera:n}=e.state,{unitInMeters:r}=e.renderCoordsHelper,o=t*Math.tan(n.fovX/2),i=n.width/2/n.pixelRatio;return O/(i/o)*r}function _(e,t,n,r){const o=r.levelAtScale(t),i=te(ue(e,n.eye,n.viewForward,n.up).tilt),a=Math.max(o-i,0);return r.scaleAtLevel(a)}function ee(e,t,n){const r=n.levelAtScale(e),o=te(t);return n.scaleAtLevel(r+o)}function te(e){return 2*((e>90?180-e:e)/90)**2}function ne(e,t,n){const r=e.basemapTerrain?.tilingScheme;if(!r)return 0;if(null==n){const t=e.pointsOfInterest?.cameraOnSurface?.renderLocation;n=(t&&e.renderCoordsHelper?.getAltitude(t))??0}const o=h(e.spatialReference).radius,i=e.state.viewingMode===j.Local?t.eye[2]:l(t.eye)-o;return _(e,$(e,Math.abs(i-n)),t,r)}function re(e,t,n){const r=N(e,t);return r?ne(e,r,n):0}const oe=1,ie=100;function ae(e,t,n,a){if(0===t)return 0;const c=u(n.eye,a),s=e.basemapTerrain?.tilingScheme;if(!s)return D().error("#scaleToTargetDistance()","Cannot compute distance from scale without a tiling scheme"),c;const f=e.pointsOfInterest?.cameraOnSurface?.renderLocation,m=(f&&e.renderCoordsHelper?.getAltitude(f))??0;let p=c;if(e.state.viewingMode===j.Local){const o=ue(e,n.eye,n.viewForward,n.up).tilt,i=Q(e,ee(t,o,s))-Math.abs(n.eye[2]-m),a=n.eye[2]<m,c=i/Math.cos(r(o));p=a?p-c:p+c}else{let f=1/0,d=0;const y=ue(e,n.eye,n.viewForward,n.up);let g=he(e,y.heading,y.tilt,a,c,X.ADJUST);if(!g)return p;const v=h(e.spatialReference).radius,w=l(n.eye)<v+m;for(;f>oe&&d<ie;){const c=l(g.eye),h=w?180-g.tilt:g.tilt,R=r(h),T=Math.sin(R)*c,x=Math.cos(R)*c,S=Q(e,ee(t,g.tilt,s)),M=w?v+m-S:v+m+S,j=i(T/M),C=Math.cos(j)*M-x,z=u(g.eye,a);p=w?z-C:z+C,g=he(e,y.heading,y.tilt,a,p,X.ADJUST);const A=Ee(e,g,o(n.fov));if(!g||!A)return p;const b=re(e,A,m);f=Math.abs(t-b),++d}}return p}async function ce(e,t,n,r,o,i){const c=await le(e,t,e.state.camera.distance,r,o,i);a(i);const s=N(e,c);if(!s)return r;const l=d();e.renderCoordsHelper.toRenderCoords(t,l);return le(e,t,ae(e,n,s,l),r,o,i)}function se(e,t,n,r,o,i){return Ee(e,he(e,r.heading,r.tilt,t,n,o),r.fov,i)}async function le(e,t,n,r,o,i){const c=await ye(e,r.heading,r.tilt,t,n,o,i);return a(i),Fe(e,c,r.fov,i)}function ue(e,t,n,r,o){return W(e).directionToHeadingTilt(t,n,r,o)}function fe(e,t){return!!(e.basemapTerrain&&e.renderCoordsHelper.fromRenderCoords(t,q,e.spatialReference)&&e.elevationProvider&&(U(e.elevationProvider,q)??0)>q[2]-I)}async function me(e,t,n){if(fe(e,t))return!0;const{elevationProvider:r,spatialReference:o,renderCoordsHelper:i}=e;if(null==r||!i.fromRenderCoords(t,q,o))return!1;const[c,s,l]=q,u=await r.queryElevation(c,s,l,o,"ground",n)??0;return a(n),u>l-I}async function pe(e,t,n){const r=d();if(null==t)return m(r,e.state.camera.center);if(t instanceof y){const{renderSpatialReference:o,basemapTerrain:i,elevationProvider:c}=e,s=t.spatialReference;if(await T(t,r,o,0,{signal:n}),a(n),null==t.z&&null!=i&&null!=c){const o=await c.queryElevation(t.x,t.y,t.z??0,s,"ground",n);a(n),null!=o&&e.renderCoordsHelper.setAltitude(r,o)}return r}return m(r,t)}function de(e,t){const n=d();if(null==t)return m(n,e.state.camera.center);if(t instanceof y){if(!R(t,n,e.renderSpatialReference))return null;const{basemapTerrain:r,elevationProvider:o}=e;if(null==t.z&&null!=r&&null!=o){const r=U(o,t);null!=r&&e.renderCoordsHelper.setAltitude(n,r)}return n}return m(n,t)}function he(e,t,n,r,o,i){return ge(e,t,n,r instanceof y?r:null,de(e,r),o,i)}async function ye(e,t,n,r,o,i,c){const s=r instanceof y?r:null,l=await pe(e,r,c);return a(c),ve(e,t,n,s,l,o,i,c)}function ge(e,t,n,r,o,i,a){if(null==o)return null;if(!r&&(r=new y({spatialReference:K(e)}),!x(o,e.renderSpatialReference,r)))return null;const c=we(e,t,n,o,i,a);if(Re(e,n,a)&&fe(e,c.eye)){const{tilt:a,mode:c}=Te(e,n,o,i);return ge(e,t,a,r,o,i,c)}return xe(c,o)}async function ve(e,t,n,r,o,i,c,s){r||(r=new y({spatialReference:K(e)}),await S(o,e.renderSpatialReference,r,{signal:s})||(r=null)),a(s);const l=we(e,t,n,o,i,c);if(Re(e,n,c)&&await me(e,l.eye,s)){a(s);const{tilt:c,mode:l}=Te(e,n,o,i);return ve(e,t,c,r,o,i,l,s)}return xe(l,o)}function we(e,t,n,r,o,i){const a=Ue(e,t,n,r,o=Math.max(o,e.state.constraints.minimumPoiDistance),i);return(0,W(e).eyeForCenterWithHeadingTilt)(r,o,a.heading,a.tilt)}function Re(e,t,n){const r=e.map.ground.navigationConstraint;return n===X.ADJUST&&e.state.isGlobal&&t>0&&(null==r||"stay-above"===r.type)}function Te(e,t,n,r){const o=He(e,n,r,Pe(e,r,t,n));return{tilt:o,mode:t-o<1?X.LOCKED:X.ADJUST}}function xe(e,t){return{...e,center:p(t)}}function Se(e,t){const{state:n,spatialReference:r}=e,o=t.spatialReference;return n.isGlobal&&L(o,j.Global)||n.isLocal&&r.equals(o)}function Me(e,t){let n,r,o;if(e.state.isGlobal){const e=new y(t.xmin,t.ymin,t.spatialReference),i=new y(t.xmax,t.ymax,t.spatialReference),a=t.spatialReference.isGeographic?V:k;n=new y({x:a.center(e.x,i.x),y:(i.y+e.y)/2,z:null!=t.zmax&&null!=t.zmin?(t.zmax+t.zmin)/2:void 0,spatialReference:t.spatialReference});const c=h(t.spatialReference),s=b(n,e,i);r=s.lon,o=s.lat,a.diff(e.x,i.x)>a.range/2&&(r+=c.halfCircumference),r=Math.min(r,c.halfCircumference),o=Math.min(o,c.halfCircumference)}else{const i=e.renderSpatialReference??t.spatialReference;i.equals(t.spatialReference)||(t=v(t,i)),r=t.xmax-t.xmin,o=t.ymax-t.ymin;const a=null!=t.zmax&&null!=t.zmin?(t.zmax+t.zmin)/2:void 0;n=new y({x:t.xmin+.5*r,y:t.ymin+.5*o,z:a,spatialReference:i})}const i=null!=t.zmax&&null!=t.zmin?t.zmax-t.zmin:0,a=e.state.camera,c=1/Math.tan(a.fovX/2),s=1/Math.tan(a.fovY/2),l=1/Math.tan(a.fov/2);return{center:n,distance:Math.max(.5*r*c,.5*o*s,.5*i*l)/E}}async function je(e,t,n,r,o,i){const c=Se(e,t)?t:await g(t,e.spatialReference,{signal:i});a(i);const{center:s,distance:l}=Me(e,c),u=await ye(e,n,r,s,l,o,i);return a(i),Fe(e,u,e.camera.fov,i)}function Ce(e,t,n,r,o,i){let a;try{a=Se(e,t)?t:v(t,e.spatialReference)}catch(u){return null}const{center:c,distance:s}=Me(e,a),l=he(e,n,r,c,s,o);return null==l?null:Ee(e,l,e.camera.fov,i)}function ze(e,t,n){const r=e.renderSpatialReference,o=new y({spatialReference:K(e)});if(!x(n,r,o))return null;const i=Math.tan(t.fovX/2),a=Math.tan(t.fovY/2),c=f(t.eye,n),s=2*c*i*E,l=2*c*a*E;return W(e).toExtent(e,o,s,l)}function Ae(e,t){return W(e).toArea(e,t)}function be(e,t,n){const r=e.pointsOfInterest.centerOnSurfaceFrequent.distance;if(Math.log(n/r)/Math.LN2>F)return!0;const o=t,i=e.pointsOfInterest.centerOnSurfaceFrequent.renderLocation;return u(o,i)/(Math.tan(.5*e.state.camera.fov)*r)>G}function Ue(e,t,n,r,o,i){let a=0;return i===X.ADJUST&&be(e,r,o)?(t=0,a=De(e,o,n,r)):a=Oe(e,r,o,n),a=e.state.constraints.clampTilt(o,a),{heading:t,tilt:n=He(e,r,o,a)}}const Le=.7;function De(e,t,n,r){const o=Oe(e,r,t,n);if(!e.state.constraints.tilt)return o;const i=e.state.constraints.tilt(t);i.max=Math.min(i.max,.5*Math.PI);const a=i.min*(1-Le)+i.max*Le;return Math.min(o,a)}function Pe(e,t,n,r){let o=Oe(e,r,t,n);if(!e.state.constraints.tilt)return o;const i=e.state.constraints.tilt(t);return o=Math.min(o,.5*Math.PI),i.min*(1-Le)+o*Le}function He(e,t,n,r){return W(e).lookAtTiltToEyeTilt(r,t,n)}function Oe(e,t,n,r){return W(e).eyeTiltToLookAtTilt(r,t,n)}function Ee(t,n,r,o){if(null==n)return null;const i=t.renderSpatialReference,a=new y({spatialReference:K(t)});return x(n.eye,i,a)?(o??=new e,o.position=a,o.heading=n.heading,o.tilt=n.tilt,o.fov=r,o):null}async function Fe(t,n,r,o){const i=t.renderSpatialReference,c=new y({spatialReference:K(t)});return await S(n.eye,i,c,{signal:o}),a(o),new e(c,n.heading,n.tilt,r)}function Ge(e,t){const n=e.basemapTerrain?.tilingScheme;if(n)return n.levelAtScale(t);D().error("#scaleToZoom()","Cannot compute zoom from scale without a tiling scheme")}function Ie(e,t){const n=e.basemapTerrain?.tilingScheme;if(n)return n.scaleAtLevel(t);D().error("#zoomToScale()","Cannot compute scale from zoom without a tiling scheme")}export{X as OrientationMode,_ as applyTiltAdjustToScale,ue as directionToHeadingTilt,$ as distanceToScale,re as externalCameraToScale,N as externalToInternal,le as fromCenterDistanceAsync,se as fromCenterDistanceSync,ce as fromCenterScale,je as fromExtentAsync,Ce as fromExtentSync,ye as getObserverForPointAtDistanceAsync,he as getObserverForPointAtDistanceSync,K as getViewSR,Y as headingTiltToDirectionUp,ne as internalCameraToScale,B as internalToExternal,ee as removeTiltAdjustFromScale,oe as scaleErrorThreshold,Q as scaleToDistance,ae as scaleToTargetDistance,Ge as scaleToZoom,Ae as toArea,ze as toExtent,Ie as zoomToScale};
|
|
5
|
+
import e from"../../../Camera.js";import{Cyclical as t}from"../../../core/Cyclical.js";import n from"../../../core/Logger.js";import{deg2rad as r,rad2deg as i,asinClamped as o}from"../../../core/mathUtils.js";import{throwIfAborted as a}from"../../../core/promiseUtils.js";import{h as c,g as l,l as s,j as u,F as f,c as m}from"../../../chunks/vec32.js";import{clone as p,create as d}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as h}from"../../../geometry/ellipsoidUtils.js";import y from"../../../geometry/Point.js";import{projectWithZConversion as g,project as v}from"../../../geometry/projection.js";import w from"../../../geometry/SpatialReference.js";import{projectPointToVector as R,projectPointToVectorAsync as T}from"../../../geometry/projection/projectPointToVector.js";import{projectVectorToPoint as x,projectVectorToPointAsync as S}from"../../../geometry/projection/projectVectorToPoint.js";import{projectVectorToVector as M}from"../../../geometry/projection/projectVectorToVector.js";import{ViewingMode as j}from"../../ViewingMode.js";import{cameraOnContentAlongViewDirection as C}from"../camera/intersectionUtils.js";import{c as z}from"../../../chunks/cameraUtilsPlanar.js";import{c as A}from"../../../chunks/cameraUtilsSpherical.js";import{getGreatCircleSpanAt as b}from"./earthUtils.js";import{getElevationAtPoint as U}from"./ElevationProvider.js";import{isSpatialReferenceSupported as L}from"../../support/spatialReferenceSupport.js";const D=()=>n.getLogger("esri.views.3d.support.cameraUtils"),P=39.37,H=96,O=H*P,E=1,G=8,F=5,I=1,J={heading:0,tilt:0},q=d(),k=new t(-20037508.342788905,20037508.342788905),V=new t(-180,180);var X;function K(e){return e.spatialReference??w.WGS84}function W({state:e}){return e.isGlobal?A:z}function Y(e,t,n,r,i){return W(e).headingTiltToDirectionUp(t,n,r,i)}function N(e,t){if(null==t)return null;const n=e.renderSpatialReference,i=W(e).headingTiltToDirectionUp,o=d();if(!R(t.position,o,n))return null;const a=i(o,t.heading,t.tilt);c(a.direction,a.direction,e.state.camera.distance),l(a.direction,a.direction,o);const s=C(e,o,a.direction,a.up);return s.fov=r(t.fov),s.row=t.layout.row,s.rows=t.layout.rows,s.column=t.layout.column,s.columns=t.layout.columns,s}!function(e){e[e.LOCKED=0]="LOCKED",e[e.ADJUST=1]="ADJUST"}(X||(X={}));const Z=d();function B(t,n,r){const o=t.renderSpatialReference,a=ue(t,n.eye,n.viewForward,n.up,J);let c=K(t);return M(n.eye,o,Z,c)||(c=w.WGS84,M(n.eye,o,Z,c)),null==r?r=new e(new y(Z,c),a.heading,a.tilt,i(n.fov)):(r.position.x=Z[0],r.position.y=Z[1],r.position.z=Z[2],r.position.spatialReference=c,r.heading=a.heading,r.tilt=a.tilt,r.fov=i(n.fov)),r.layout.row=n.row,r.layout.rows=n.rows,r.layout.column=n.column,r.layout.columns=n.columns,r}function Q(e,t){const{camera:n}=e.state,{unitInMeters:r}=e.renderCoordsHelper;return n.width/2/n.pixelRatio/(H*P/(t/=r))/Math.tan(n.fovX/2)}function $(e,t){const{camera:n}=e.state,{unitInMeters:r}=e.renderCoordsHelper,i=t*Math.tan(n.fovX/2),o=n.width/2/n.pixelRatio;return O/(o/i)*r}function _(e,t,n,r){const i=r.levelAtScale(t),o=te(ue(e,n.eye,n.viewForward,n.up).tilt),a=Math.max(i-o,0);return r.scaleAtLevel(a)}function ee(e,t,n){const r=n.levelAtScale(e),i=te(t);return n.scaleAtLevel(r+i)}function te(e){return 2*((e>90?180-e:e)/90)**2}function ne(e,t,n){const r=e.basemapTerrain?.tilingScheme;if(!r)return 0;if(null==n){const t=e.pointsOfInterest?.cameraOnSurface?.renderLocation;n=(t&&e.renderCoordsHelper?.getAltitude(t))??0}const i=h(e.spatialReference).radius,o=e.state.viewingMode===j.Local?t.eye[2]:s(t.eye)-i;return _(e,$(e,Math.abs(o-n)),t,r)}function re(e,t,n){const r=N(e,t);return r?ne(e,r,n):0}const ie=1,oe=100;function ae(e,t,n,a,c){if(0===t)return 0;const l=u(n.eye,a),f=e.basemapTerrain?.tilingScheme;if(!f)return D().error("#scaleToTargetDistance()","Cannot compute distance from scale without a tiling scheme"),l;let m=l;const p=ue(e,n.eye,n.viewForward,n.up),d=p.tilt>90;if(e.state.viewingMode===j.Local){const i=(Q(e,ee(t,p.tilt,f))-Math.abs(n.eye[2]-c[2]))/Math.cos(r(p.tilt));m=d?m-i:m+i}else{let y=1/0,g=0,v=he(e,p.heading,p.tilt,a,l,X.ADJUST);if(!v)return m;const w=s(c);for(;y>ie&&g<oe;){const c=s(v.eye),l=d?180-v.tilt:v.tilt,R=r(l),T=Math.sin(R)*c,x=Math.cos(R)*c,S=Q(e,ee(t,v.tilt,f)),M=d?w-S:w+S,j=o(T/M),C=Math.cos(j)*M-x,z=u(v.eye,a);m=d?z-C:z+C,v=he(e,p.heading,p.tilt,a,m,X.ADJUST);const A=Ee(e,v,i(n.fov));if(!v||!A)return m;const b=re(e,A,w-h(e.spatialReference).radius);y=Math.abs(t-b),++g}}return m}async function ce(e,t,n,r,i,o){return se(e,t,Q(e,n),r,i,o)}function le(e,t,n,r,i,o){return Ee(e,he(e,r.heading,r.tilt,t,n,i),r.fov,o)}async function se(e,t,n,r,i,o){const c=await ye(e,r.heading,r.tilt,t,n,i,o);return a(o),Ge(e,c,r.fov,o)}function ue(e,t,n,r,i){return W(e).directionToHeadingTilt(t,n,r,i)}function fe(e,t){return!!(e.basemapTerrain&&e.renderCoordsHelper.fromRenderCoords(t,q,e.spatialReference)&&e.elevationProvider&&(U(e.elevationProvider,q)??0)>q[2]-I)}async function me(e,t,n){if(fe(e,t))return!0;const{elevationProvider:r,spatialReference:i,renderCoordsHelper:o}=e;if(null==r||!o.fromRenderCoords(t,q,i))return!1;const[c,l,s]=q,u=await r.queryElevation(c,l,s,i,"ground",n)??0;return a(n),u>s-I}async function pe(e,t,n){const r=d();if(null==t)return m(r,e.state.camera.center);if(t instanceof y){const{renderSpatialReference:i,basemapTerrain:o,elevationProvider:c}=e,l=t.spatialReference;if(await T(t,r,i,0,{signal:n}),a(n),null==t.z&&null!=o&&null!=c){const i=await c.queryElevation(t.x,t.y,t.z??0,l,"ground",n);a(n),null!=i&&e.renderCoordsHelper.setAltitude(r,i)}return r}return m(r,t)}function de(e,t){const n=d();if(null==t)return m(n,e.state.camera.center);if(t instanceof y){if(!R(t,n,e.renderSpatialReference))return null;const{basemapTerrain:r,elevationProvider:i}=e;if(null==t.z&&null!=r&&null!=i){const r=U(i,t);null!=r&&e.renderCoordsHelper.setAltitude(n,r)}return n}return m(n,t)}function he(e,t,n,r,i,o){return ge(e,t,n,r instanceof y?r:null,de(e,r),i,o)}async function ye(e,t,n,r,i,o,c){const l=r instanceof y?r:null,s=await pe(e,r,c);return a(c),ve(e,t,n,l,s,i,o,c)}function ge(e,t,n,r,i,o,a){if(null==i)return null;if(!r&&(r=new y({spatialReference:K(e)}),!x(i,e.renderSpatialReference,r)))return null;const c=we(e,t,n,i,o,a);if(Re(e,n,a)&&fe(e,c.eye)){const{tilt:a,mode:c}=Te(e,n,i,o);return ge(e,t,a,r,i,o,c)}return xe(c,i)}async function ve(e,t,n,r,i,o,c,l){r||(r=new y({spatialReference:K(e)}),await S(i,e.renderSpatialReference,r,{signal:l})||(r=null)),a(l);const s=we(e,t,n,i,o,c);if(Re(e,n,c)&&await me(e,s.eye,l)){a(l);const{tilt:c,mode:s}=Te(e,n,i,o);return ve(e,t,c,r,i,o,s,l)}return xe(s,i)}function we(e,t,n,r,i,o){const a=Ue(e,t,n,r,i=Math.max(i,e.state.constraints.minimumPoiDistance),o);return(0,W(e).eyeForCenterWithHeadingTilt)(r,i,a.heading,a.tilt)}function Re(e,t,n){const r=e.map.ground.navigationConstraint;return n===X.ADJUST&&e.state.isGlobal&&t>0&&(null==r||"stay-above"===r.type)}function Te(e,t,n,r){const i=He(e,n,r,Pe(e,r,t,n));return{tilt:i,mode:t-i<1?X.LOCKED:X.ADJUST}}function xe(e,t){return{...e,center:p(t)}}function Se(e,t){const{state:n,spatialReference:r}=e,i=t.spatialReference;return n.isGlobal&&L(i,j.Global)||n.isLocal&&r.equals(i)}function Me(e,t){let n,r,i;if(e.state.isGlobal){const e=new y(t.xmin,t.ymin,t.spatialReference),o=new y(t.xmax,t.ymax,t.spatialReference),a=t.spatialReference.isGeographic?V:k;n=new y({x:a.center(e.x,o.x),y:(o.y+e.y)/2,z:null!=t.zmax&&null!=t.zmin?(t.zmax+t.zmin)/2:void 0,spatialReference:t.spatialReference});const c=h(t.spatialReference),l=b(n,e,o);r=l.lon,i=l.lat,a.diff(e.x,o.x)>a.range/2&&(r+=c.halfCircumference),r=Math.min(r,c.halfCircumference),i=Math.min(i,c.halfCircumference)}else{const o=e.renderSpatialReference??t.spatialReference;o.equals(t.spatialReference)||(t=v(t,o)),r=t.xmax-t.xmin,i=t.ymax-t.ymin;const a=null!=t.zmax&&null!=t.zmin?(t.zmax+t.zmin)/2:void 0;n=new y({x:t.xmin+.5*r,y:t.ymin+.5*i,z:a,spatialReference:o})}const o=null!=t.zmax&&null!=t.zmin?t.zmax-t.zmin:0,a=e.state.camera,c=1/Math.tan(a.fovX/2),l=1/Math.tan(a.fovY/2),s=1/Math.tan(a.fov/2);return{center:n,distance:Math.max(.5*r*c,.5*i*l,.5*o*s)/E}}async function je(e,t,n,r,i,o){const c=Se(e,t)?t:await g(t,e.spatialReference,{signal:o});a(o);const{center:l,distance:s}=Me(e,c),u=await ye(e,n,r,l,s,i,o);return a(o),Ge(e,u,e.camera.fov,o)}function Ce(e,t,n,r,i,o){let a;try{a=Se(e,t)?t:v(t,e.spatialReference)}catch(u){return null}const{center:c,distance:l}=Me(e,a),s=he(e,n,r,c,l,i);return null==s?null:Ee(e,s,e.camera.fov,o)}function ze(e,t,n){const r=e.renderSpatialReference,i=new y({spatialReference:K(e)});if(!x(n,r,i))return null;const o=Math.tan(t.fovX/2),a=Math.tan(t.fovY/2),c=f(t.eye,n),l=2*c*o*E,s=2*c*a*E;return W(e).toExtent(e,i,l,s)}function Ae(e,t){return W(e).toArea(e,t)}function be(e,t,n){const r=e.pointsOfInterest.centerOnSurfaceFrequent.distance;if(Math.log(n/r)/Math.LN2>G)return!0;const i=t,o=e.pointsOfInterest.centerOnSurfaceFrequent.renderLocation;return u(i,o)/(Math.tan(.5*e.state.camera.fov)*r)>F}function Ue(e,t,n,r,i,o){let a=0;return o===X.ADJUST&&be(e,r,i)?(t=0,a=De(e,i,n,r)):a=Oe(e,r,i,n),a=e.state.constraints.clampTilt(i,a),{heading:t,tilt:n=He(e,r,i,a)}}const Le=.7;function De(e,t,n,r){const i=Oe(e,r,t,n);if(!e.state.constraints.tilt)return i;const o=e.state.constraints.tilt(t);o.max=Math.min(o.max,.5*Math.PI);const a=o.min*(1-Le)+o.max*Le;return Math.min(i,a)}function Pe(e,t,n,r){let i=Oe(e,r,t,n);if(!e.state.constraints.tilt)return i;const o=e.state.constraints.tilt(t);return i=Math.min(i,.5*Math.PI),o.min*(1-Le)+i*Le}function He(e,t,n,r){return W(e).lookAtTiltToEyeTilt(r,t,n)}function Oe(e,t,n,r){return W(e).eyeTiltToLookAtTilt(r,t,n)}function Ee(t,n,r,i){if(null==n)return null;const o=t.renderSpatialReference,a=new y({spatialReference:K(t)});return x(n.eye,o,a)?(i??=new e,i.position=a,i.heading=n.heading,i.tilt=n.tilt,i.fov=r,i):null}async function Ge(t,n,r,i){const o=t.renderSpatialReference,c=new y({spatialReference:K(t)});return await S(n.eye,o,c,{signal:i}),a(i),new e(c,n.heading,n.tilt,r)}function Fe(e,t){const n=e.basemapTerrain?.tilingScheme;if(n)return n.levelAtScale(t);D().error("#scaleToZoom()","Cannot compute zoom from scale without a tiling scheme")}function Ie(e,t){const n=e.basemapTerrain?.tilingScheme;if(n)return n.scaleAtLevel(t);D().error("#zoomToScale()","Cannot compute scale from zoom without a tiling scheme")}export{X as OrientationMode,_ as applyTiltAdjustToScale,ue as directionToHeadingTilt,$ as distanceToScale,re as externalCameraToScale,N as externalToInternal,se as fromCenterDistanceAsync,le as fromCenterDistanceSync,ce as fromCenterScale,je as fromExtentAsync,Ce as fromExtentSync,ye as getObserverForPointAtDistanceAsync,he as getObserverForPointAtDistanceSync,K as getViewSR,Y as headingTiltToDirectionUp,ne as internalCameraToScale,B as internalToExternal,ee as removeTiltAdjustFromScale,ie as scaleErrorThreshold,Q as scaleToDistance,ae as scaleToTargetDistance,Fe as scaleToZoom,Ae as toArea,ze as toExtent,Ie as zoomToScale};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.31/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import t from"../../../Camera.js";import"../../../geometry.js";import e from"../../../Graphic.js";import n from"../../../Viewpoint.js";import{result as r}from"../../../core/asyncUtils.js";import"../../../core/has.js";import{cyclicalDegrees as a}from"../../../core/Cyclical.js";import o from"../../../core/Error.js";import{throwIfAborted as i}from"../../../core/promiseUtils.js";import{fromMat4 as s,transpose as c}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{create as l}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{create as m}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{h as u,g as f,j as p,c as g,d as y,i as h,q as d}from"../../../chunks/vec32.js";import{create as w}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{projectWithZConversion as x,tryProjectWithZConversion as j}from"../../../geometry/projection.js";import{computeTranslationToOriginAndRotation as v}from"../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{projectPointToVectorAsync as R}from"../../../geometry/projection/projectPointToVector.js";import{projectVectorToPoint as b}from"../../../geometry/projection/projectVectorToPoint.js";import{projectVectorToVector as z}from"../../../geometry/projection/projectVectorToVector.js";import{create as G,center as S,toRect as B,isPoint as T,empty as M,expandWithVec3 as Z,expandWithAABB as A,width as E,height as F,depth as C}from"../../../geometry/support/aaBoundingBox.js";import{create as O,isPoint as P}from"../../../geometry/support/aaBoundingRect.js";import{intersectsPoint as D}from"../../../geometry/support/frustum.js";import{getResolutionInMetersForScale as U}from"../../../geometry/support/scaleUtils.js";import{cameraOnContentAlongViewDirection as V}from"../camera/intersectionUtils.js";import{getViewSR as k,fromExtentAsync as I,internalToExternal as J,OrientationMode as K,fromCenterDistanceAsync as L,externalToInternal as N,scaleToTargetDistance as q,fromExtentSync as H,fromCenterDistanceSync as W,internalCameraToScale as Y,externalCameraToScale as X,fromCenterScale as _,directionToHeadingTilt as Q,zoomToScale as $}from"./cameraUtils.js";import{getElevationAtPoint as tt}from"./ElevationProvider.js";import et from"../../../geometry/Point.js";import nt from"../../../geometry/Extent.js";import rt from"../../../geometry/SpatialReference.js";import at from"../../../geometry/Geometry.js";import ot from"../../../geometry/Multipoint.js";const it=.66;function st(t){return 360-a.normalize(t)}function ct(t){return a.normalize(360-t)}function lt(t,e,n){const r=e.camera;if(null!=r)return ut(r,k(t));const{targetGeometry:a}=e;if(null==a)return null;const{camera:o,mode:i}=pt(t,e.rotation,n);if("point"===a.type)return gt(t,e,a,o,i);const s=a.extent;return null==s?null:H(t,s,o.heading,o.tilt,i)}async function mt(t,e,n,r){const a=e.camera;if(null!=a)return ft(a,k(t),r);const{targetGeometry:o}=e;if(null==o)throw new Error("Viewpoint has no targetGeometry!");const{camera:i,mode:s}=pt(t,e.rotation,n);if("point"===o.type)return yt(t,e,o,i,s,r);const c=o.extent;if(null==c)throw new Error("Target geometry has no extent!");return I(t,c,i.heading,i.tilt,s,r)}function ut(t,e){const n=t.position;let r;try{r=j(n,e)}catch(o){return null}if(!r)return null;const a=t.clone();return a.position=r.clone(),a}async function ft(t,e,n){const r=t.position,a=await x(r,e,{signal:n});i(n);const o=t.clone();return o.position=a.clone(),o}function pt(t,e,n){const r=J(t,t.state.camera);let a=K.ADJUST;return null!=e&&(r.heading=st(e),a=K.LOCKED),null!=n&&(r.tilt=n),{camera:r,mode:a}}function gt(t,e,n,r,a){const o=t.spatialReference;let i;try{i=j(n.clone(),o)}catch(m){return null}if(!i)return null;let s=t.state.camera.distance;const c=W(t,i,s,r,a),l=null!=e.scale?N(t,c):null;if(l){const n=w();return t.renderCoordsHelper.toRenderCoords(i,n),s=q(t,e.scale,l,n),W(t,i,s,r,a)}return c}async function yt(t,e,n,r,a,o){const s=t.spatialReference,c=await x(n.clone(),s,{signal:o});i(o);let l=t.state.camera.distance;const m=await L(t,c,l,r,a,o);i(o);const u=null!=e.scale?N(t,m):null;if(u){const n=w();return t.renderCoordsHelper.toRenderCoords(c,n),l=q(t,e.scale,u,n),L(t,c,l,r,a,o)}return m}function ht(t,e,r=null){return null==r&&(r=new n),vt(t,null,e.clone(),r)}async function dt(e,r,a){const i=Ct(e,r);if(!i)throw new o("viewpointutils-create:no-target","Missing target for creating viewpoint");const s=new t({fov:e.camera.fov}),c=new n({camera:s});if(i.target instanceof n){return Ot(await Gt(e,i.target,i,a,c))}if(i.target instanceof t)return Ot(await St(e,i.target,a,c));const l=null!=i.scale||null!=i.zoom;if(i.target instanceof nt){const t=i.target.xmin===i.target.xmax||i.target.ymin===i.target.ymax;return Ot(l||t?await Tt(e,i,i.target.center,s,a,c):await At(e,i,i.target,s,a,c))}const m=new Dt,u=l?xt(e,i):void 0;if(await zt(e,i.target,u,m,a),isFinite(m.boundingBox[0])){let t;if(S(m.boundingBox,Ut),Ht.x=Ut[0],Ht.y=Ut[1],Ht.z=Ut[2],Ht.spatialReference=e.spatialReference,isFinite(Ht.z)&&m.hasZ?t=T(m.boundingBox):(Ht.z=void 0,t=P(B(m.boundingBox,Jt))),l||t)return Ot(await Tt(e,i,Ht,s,a,c));const n=Pt(e,m.screenSpaceObjects);return Ot(await Ft(e,i,Ht,m.boundingBox,n,s,a,c))}return i.position?Ot(await Mt(e,i,s,c,a)):Ot(await Zt(e,i,s,a,c))}function wt(t,e){return null==e.scale&&null!=e.zoom?$(t,e.zoom):e.scale}function xt(t,e){const n=wt(t,e);return n?U(n):void 0}function jt(t,e){let n=!1;return null!=e.heading?(t.heading=e.heading,n=!0):null!=e.rotation&&(t.heading=st(e.rotation),n=!0),null!=e.tilt&&(t.tilt=e.tilt,n=!0),null!=e.fov&&(t.fov=e.fov),n}function vt(t,e,n,r){const a=t.spatialReference||rt.WGS84;if(e??=N(t,n),null==e)return r;const o=new et({spatialReference:a});return b(e.center,t.renderSpatialReference,o)?(r.targetGeometry=o,r.scale=Y(t,e),r.rotation=ct(n.heading),r.camera=n,r):r}async function Rt(t,e,n,r){const a=()=>new o("viewpointutils:invalid-geometry","The target is missing a valid geometry");if(!e)throw a();"mesh"===e.type&&(e=e.extent);const i=t.basemapTerrain.spatialReference;if(!e.hasZ&&t.basemapTerrain){let n;switch(e.type){case"point":n=e;break;case"multipoint":case"polyline":n=e.extent?.center;break;case"extent":n=e.center;break;case"polygon":n=e.centroid}null!=n&&i&&t.elevationProvider?(n=await x(n,i,{signal:r}),Ut[2]=tt(t.elevationProvider,n)??0):Ut[2]=0}const s=Wt[e.type],c=new Array;if(s(e,e.hasZ?t=>{c.push([t[0],t[1],t[2]])}:t=>{c.push([t[0],t[1]])},Ut),0===c.length)throw a();const l=e.spatialReference,m=t.spatialReference,u=await x(new ot({spatialReference:l,hasZ:e.hasZ,hasM:!1,points:c}),m,{signal:r});if(e.hasZ&&(n.hasZ=!0),e.hasZ)for(const[o,f,p]of u.points)Ut[0]=o,Ut[1]=f,Ut[2]=p,Z(n.boundingBox,Ut);else for(const[o,f]of u.points)Ut[0]=o,Ut[1]=f,Z(n.boundingBox,Ut)}async function bt(t,e,n,a,o){const i=await r(t.whenViewForGraphic(e));if(!1===i.ok||null==i.value||!("whenGraphicBounds"in i.value))return void await Rt(t,e.geometry,a,o);const s=i.value,c=await r(s.whenGraphicBounds(e,{minDemResolution:n}));if(!1===c.ok||!c.value)return void await Rt(t,e.geometry,a,o);const{screenSpaceObjects:l,boundingBox:m}=c.value;A(a.boundingBox,m),l&&l.forEach((t=>{a.screenSpaceObjects.push(t)})),isFinite(m[2])&&(a.hasZ=!0)}async function zt(t,n,r,a,o){if(Array.isArray(n)&&2===n.length){const e=n[0],r=n[1];if("number"==typeof e&&"number"==typeof r)return Ht.x=e,Ht.y=r,Ht.z=void 0,Ht.spatialReference=t.spatialReference?.isGeographic?t.spatialReference:rt.WGS84,void await Rt(t,Ht,a,o)}n&&"map"in n&&"function"==typeof n.map?await Promise.allSettled(n.map((e=>zt(t,e,r,a,o)))):n instanceof at?await Rt(t,n,a,o):n instanceof e&&await bt(t,n,r,a,o)}async function Gt(t,e,n,r,a){if(e.camera)return St(t,e.camera,r,a);a.scale=e.scale,a.rotation=e.rotation,a.targetGeometry=null!=e.targetGeometry?e.targetGeometry.clone():null,a.camera=null,null!=n.heading?a.rotation=ct(n.heading):null!=n.rotation&&(a.rotation=n.rotation);const o=wt(t,n);return null!=o&&(a.scale=o),a.camera=await mt(t,a,n.tilt,r),a}async function St(t,e,n,r){const a=t.spatialReference,o=await x(e.position,a,{signal:n}),i=e.clone();return i.position=o,vt(t,null,i,r)}async function Bt(t,e,n,r,a,o,i){const s=t.renderSpatialReference;return await R(e,Nt,s,0,{signal:i}),await R(n,Lt,s,0,{signal:i}),o.targetGeometry=new et(e),a.position=new et(n),y(Kt,Nt,Lt),Q(t,Lt,Kt,r.up,a),o.scale=X(t,a),o.rotation=ct(a.heading),o.camera=a,o}async function Tt(t,e,n,r,a,o){o.targetGeometry=n.clone();const i=V(t);if(e.position)return Bt(t,o.targetGeometry,e.position,i,r,o,a);if(e.zoomFactor){const n=i.distance/e.zoomFactor,r=u(Ut,i.viewForward,-n);i.eye=f(Ut,i.center,r),o.scale=Y(t,i)}J(t,i,r);const s=jt(r,e)?K.LOCKED:K.ADJUST;if(!e.zoomFactor){const n=wt(t,e);if(null==n){await R(o.targetGeometry,Ut,t.renderSpatialReference,0,{signal:a});const e=D(i.frustum,Ut)?p(i.eye,Ut):i.distance;o.camera=await L(t,o.targetGeometry,e,r,s),o.scale=X(t,o.camera)}else o.scale=n,o.camera=await _(t,o.targetGeometry,o.scale,r,s,a)}return o}async function Mt(t,e,n,r,a){const o=V(t);g(Kt,o.viewForward),Q(t,o.eye,Kt,o.up,qt);const i=t.spatialReference,{position:s}=e;if(s){const t=await x(s,i,{signal:a});n.position=t}else n.position=new et;return n.heading=null!=e.heading?e.heading:qt.heading,n.tilt=null!=e.tilt?e.tilt:qt.tilt,vt(t,null,n,r)}async function Zt(t,e,n,r,a){if(null!=e.heading||null!=e.rotation||null!=e.scale||null!=e.tilt||null!=e.zoom||null!=e.zoomFactor){const o=V(t),{spatialReference:i,renderSpatialReference:s}=t,c=new et({spatialReference:i});return b(o.center,s,c)?Tt(t,e,c,n,r,a):a}return a.scale=t.scale,a.camera=t.camera.clone(),jt(a.camera,e),a}async function At(t,e,n,r,a,o){o.targetGeometry=n.clone();const i=V(t);J(t,i,r);const s=jt(r,e)?K.LOCKED:K.ADJUST;return o.camera=await I(t,n,r.heading,r.tilt,s,a),o}function Et(t,e,n,r,a){let o=0;null!=n.z?o=n.z:t.basemapTerrain&&t.elevationProvider&&(o=tt(t.elevationProvider,n)),h(Ut,n.x,n.y,o),v(t.spatialReference,Ut,Vt,t.renderSpatialReference),s(kt,Vt),c(kt,kt),M(It);const i=[[0,1,2],[3,1,2],[0,4,2],[3,4,2],[0,1,5],[3,1,5],[0,4,5],[3,4,5]];for(let s=0;s<i.length;s++){const e=i[s];let n=r[e[2]];isFinite(n)||(n=o),h(Ut,r[e[0]],r[e[1]],n),z(Ut,t.spatialReference,Ut,t.renderSpatialReference),Z(It,d(Ut,Ut,kt))}const l=E(It),m=F(It),u=C(It),f=1/Math.tan(e.fovX/2),p=1/Math.tan(e.fovY/2),g=.5*Math.sqrt(l*l+u*u)*Math.max(p,f)+.5*m,y=.5*m*p+.5*Math.max(l,u);return Math.max(g,y)/a}async function Ft(t,e,n,r,a,o,i,s){s.targetGeometry=n.clone();const c=V(t),l=Et(t,c,n,r,a);J(t,c,o);const m=jt(o,e)?K.LOCKED:K.ADJUST;return s.camera=await L(t,s.targetGeometry,l,o,m,i),s.scale=X(t,s.camera),s}function Ct(t,e){if(!e||!t.spatialReference)return null;const n={target:void 0};return"declaredClass"in e||Array.isArray(e)?n.target=e:(Object.assign(n,e),!n.target&&"center"in e&&e.center&&(n.target=e.center)),n}function Ot(t){return null!=t?.camera&&(t.rotation=ct(t.camera.heading)),t}function Pt(t,e){const n=it;if(!e.length)return n;let r=Number.NEGATIVE_INFINITY;for(let a=0;a<e.length;a++){const t=e[a].screenSpaceBoundingRect;r=Math.max(r,Math.abs(t[0]),Math.abs(t[1]),Math.abs(t[2]),Math.abs(t[3]))}return n-r/Math.min(t.width,t.height)*2}class Dt{constructor(){this.hasZ=!1,this.boundingBox=M(),this.screenSpaceObjects=new Array}}const Ut=w(),Vt=m(),kt=l(),It=G(),Jt=O(),Kt=w(),Lt=w(),Nt=w(),qt={heading:0,tilt:0},Ht=new et,Wt={point(t,e,n){n[0]=t.x,n[1]=t.y,null!=t.z&&(n[2]=t.z),e(n)},polygon(t,e,n){const r=t.hasZ;for(let a=0;a<t.rings.length;a++){const o=t.rings[a];for(let t=0;t<o.length;t++)n[0]=o[t][0],n[1]=o[t][1],r&&(n[2]=o[t][2]),e(n)}},polyline(t,e,n){const r=t.hasZ;for(let a=0;a<t.paths.length;a++){const o=t.paths[a];for(let t=0;t<o.length;t++)n[0]=o[t][0],n[1]=o[t][1],r&&(n[2]=o[t][2]),e(n)}},multipoint(t,e,n){const r=t.points,a=t.hasZ;for(let o=0;o<r.length;o++)n[0]=r[o][0],n[1]=r[o][1],a&&(n[2]=r[o][2]),e(n)},extent(t,e,n){null!=t.zmin&&null!=t.zmax?(e(h(n,t.xmin,t.ymin,t.zmin)),e(h(n,t.xmax,t.ymin,t.zmin)),e(h(n,t.xmin,t.ymax,t.zmin)),e(h(n,t.xmax,t.ymax,t.zmin)),e(h(n,t.xmin,t.ymin,t.zmax)),e(h(n,t.xmax,t.ymin,t.zmax)),e(h(n,t.xmin,t.ymax,t.zmax)),e(h(n,t.xmax,t.ymax,t.zmax))):(e(h(n,t.xmin,t.ymin,n[2])),e(h(n,t.xmax,t.ymin,n[2])),e(h(n,t.xmin,t.ymax,n[2])),e(h(n,t.xmax,t.ymax,n[2])))}};export{dt as create,ht as fromCamera,mt as toCameraAsync,lt as toCameraSync};
|
|
5
|
+
import t from"../../../Camera.js";import"../../../geometry.js";import e from"../../../Graphic.js";import n from"../../../Viewpoint.js";import{result as a}from"../../../core/asyncUtils.js";import"../../../core/has.js";import{cyclicalDegrees as r}from"../../../core/Cyclical.js";import o from"../../../core/Error.js";import{throwIfAborted as i}from"../../../core/promiseUtils.js";import{fromMat4 as s,transpose as c}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{create as l}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{create as m}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{h as u,g as f,j as p,c as g,d as y,i as h,q as d}from"../../../chunks/vec32.js";import{create as w}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{projectWithZConversion as x,tryProjectWithZConversion as j}from"../../../geometry/projection.js";import{computeTranslationToOriginAndRotation as v}from"../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{projectPointToVectorAsync as b}from"../../../geometry/projection/projectPointToVector.js";import{projectVectorToPoint as R}from"../../../geometry/projection/projectVectorToPoint.js";import{projectVectorToVector as z}from"../../../geometry/projection/projectVectorToVector.js";import{create as G,center as S,toRect as B,isPoint as T,empty as M,expandWithVec3 as Z,expandWithAABB as A,width as E,height as F,depth as O}from"../../../geometry/support/aaBoundingBox.js";import{create as P,isPoint as D}from"../../../geometry/support/aaBoundingRect.js";import{intersectsPoint as U}from"../../../geometry/support/frustum.js";import{getResolutionInMetersForScale as V}from"../../../geometry/support/scaleUtils.js";import{cameraOnContentAlongViewDirection as C}from"../camera/intersectionUtils.js";import{getViewSR as k,fromExtentAsync as I,internalToExternal as J,OrientationMode as K,scaleToDistance as L,fromCenterDistanceAsync as N,fromExtentSync as q,fromCenterDistanceSync as W,externalToInternal as Y,distanceToScale as X,fromCenterScale as _,directionToHeadingTilt as H,zoomToScale as Q}from"./cameraUtils.js";import{getElevationAtPoint as $}from"./ElevationProvider.js";import tt from"../../../geometry/Point.js";import et from"../../../geometry/Extent.js";import nt from"../../../geometry/SpatialReference.js";import at from"../../../geometry/Geometry.js";import rt from"../../../geometry/Multipoint.js";const ot=.66;function it(t){return 360-r.normalize(t)}function st(t){return r.normalize(360-t)}function ct(t,e,n){const a=e.camera;if(null!=a)return mt(a,k(t));const{targetGeometry:r}=e;if(null==r)return null;const{camera:o,mode:i}=ft(t,e.rotation,n);if("point"===r.type)return pt(t,e,r,o,i);const s=r.extent;return null==s?null:q(t,s,o.heading,o.tilt,i)}async function lt(t,e,n,a){const r=e.camera;if(null!=r)return ut(r,k(t),a);const{targetGeometry:o}=e;if(null==o)throw new Error("Viewpoint has no targetGeometry!");const{camera:i,mode:s}=ft(t,e.rotation,n);if("point"===o.type)return gt(t,e,o,i,s,a);const c=o.extent;if(null==c)throw new Error("Target geometry has no extent!");return I(t,c,i.heading,i.tilt,s,a)}function mt(t,e){const n=t.position;let a;try{a=j(n,e)}catch(o){return null}if(!a)return null;const r=t.clone();return r.position=a.clone(),r}async function ut(t,e,n){const a=t.position,r=await x(a,e,{signal:n});i(n);const o=t.clone();return o.position=r.clone(),o}function ft(t,e,n){const a=J(t,t.state.camera);let r=K.ADJUST;return null!=e&&(a.heading=it(e),r=K.LOCKED),null!=n&&(a.tilt=n),{camera:a,mode:r}}function pt(t,e,n,a,r){const o=t.spatialReference;let i;try{i=j(n.clone(),o)}catch(c){return null}if(!i)return null;const s=null!=e.scale?L(t,e.scale):t.state.camera.distance;return W(t,i,s,a,r)}async function gt(t,e,n,a,r,o){const s=t.spatialReference,c=await x(n.clone(),s,{signal:o});i(o);const l=null!=e.scale?L(t,e.scale):t.state.camera.distance;return N(t,c,l,a,r,o)}function yt(t,e,a=null){return null==a&&(a=new n),jt(t,null,e.clone(),a)}async function ht(e,a,r){const i=Ft(e,a);if(!i)throw new o("viewpointutils-create:no-target","Missing target for creating viewpoint");const s=new t({fov:e.camera.fov}),c=new n({camera:s});if(i.target instanceof n){return Ot(await zt(e,i.target,i,r,c))}if(i.target instanceof t)return Ot(await Gt(e,i.target,r,c));const l=null!=i.scale||null!=i.zoom;if(i.target instanceof et){const t=i.target.xmin===i.target.xmax||i.target.ymin===i.target.ymax;return Ot(l||t?await Bt(e,i,i.target.center,s,r,c):await Zt(e,i,i.target,s,r,c))}const m=new Dt,u=l?wt(e,i):void 0;if(await Rt(e,i.target,u,m,r),isFinite(m.boundingBox[0])){let t;if(S(m.boundingBox,Ut),qt.x=Ut[0],qt.y=Ut[1],qt.z=Ut[2],qt.spatialReference=e.spatialReference,isFinite(qt.z)&&m.hasZ?t=T(m.boundingBox):(qt.z=void 0,t=D(B(m.boundingBox,It))),l||t)return Ot(await Bt(e,i,qt,s,r,c));const n=Pt(e,m.screenSpaceObjects);return Ot(await Et(e,i,qt,m.boundingBox,n,s,r,c))}return i.position?Ot(await Tt(e,i,s,c,r)):Ot(await Mt(e,i,s,r,c))}function dt(t,e){return null==e.scale&&null!=e.zoom?Q(t,e.zoom):e.scale}function wt(t,e){const n=dt(t,e);return n?V(n):void 0}function xt(t,e){let n=!1;return null!=e.heading?(t.heading=e.heading,n=!0):null!=e.rotation&&(t.heading=it(e.rotation),n=!0),null!=e.tilt&&(t.tilt=e.tilt,n=!0),null!=e.fov&&(t.fov=e.fov),n}function jt(t,e,n,a){const r=t.spatialReference||nt.WGS84;if(e??=Y(t,n),null==e)return a;const o=new tt({spatialReference:r});return R(e.center,t.renderSpatialReference,o)?(a.targetGeometry=o,a.scale=X(t,e.distance),a.rotation=st(n.heading),a.camera=n,a):a}async function vt(t,e,n,a){const r=()=>new o("viewpointutils:invalid-geometry","The target is missing a valid geometry");if(!e)throw r();"mesh"===e.type&&(e=e.extent);const i=t.basemapTerrain.spatialReference;if(!e.hasZ&&t.basemapTerrain){let n;switch(e.type){case"point":n=e;break;case"multipoint":case"polyline":n=e.extent?.center;break;case"extent":n=e.center;break;case"polygon":n=e.centroid}null!=n&&i&&t.elevationProvider?(n=await x(n,i,{signal:a}),Ut[2]=$(t.elevationProvider,n)??0):Ut[2]=0}const s=Wt[e.type],c=new Array;if(s(e,e.hasZ?t=>{c.push([t[0],t[1],t[2]])}:t=>{c.push([t[0],t[1]])},Ut),0===c.length)throw r();const l=e.spatialReference,m=t.spatialReference,u=await x(new rt({spatialReference:l,hasZ:e.hasZ,hasM:!1,points:c}),m,{signal:a});if(e.hasZ&&(n.hasZ=!0),e.hasZ)for(const[o,f,p]of u.points)Ut[0]=o,Ut[1]=f,Ut[2]=p,Z(n.boundingBox,Ut);else for(const[o,f]of u.points)Ut[0]=o,Ut[1]=f,Z(n.boundingBox,Ut)}async function bt(t,e,n,r,o){const i=await a(t.whenViewForGraphic(e));if(!1===i.ok||null==i.value||!("whenGraphicBounds"in i.value))return void await vt(t,e.geometry,r,o);const s=i.value,c=await a(s.whenGraphicBounds(e,{minDemResolution:n}));if(!1===c.ok||!c.value)return void await vt(t,e.geometry,r,o);const{screenSpaceObjects:l,boundingBox:m}=c.value;A(r.boundingBox,m),l&&l.forEach((t=>{r.screenSpaceObjects.push(t)})),isFinite(m[2])&&(r.hasZ=!0)}async function Rt(t,n,a,r,o){if(Array.isArray(n)&&2===n.length){const e=n[0],a=n[1];if("number"==typeof e&&"number"==typeof a)return qt.x=e,qt.y=a,qt.z=void 0,qt.spatialReference=t.spatialReference?.isGeographic?t.spatialReference:nt.WGS84,void await vt(t,qt,r,o)}n&&"map"in n&&"function"==typeof n.map?await Promise.allSettled(n.map((e=>Rt(t,e,a,r,o)))):n instanceof at?await vt(t,n,r,o):n instanceof e&&await bt(t,n,a,r,o)}async function zt(t,e,n,a,r){if(e.camera)return Gt(t,e.camera,a,r);r.scale=e.scale,r.rotation=e.rotation,r.targetGeometry=null!=e.targetGeometry?e.targetGeometry.clone():null,r.camera=null,null!=n.heading?r.rotation=st(n.heading):null!=n.rotation&&(r.rotation=n.rotation);const o=dt(t,n);return null!=o&&(r.scale=o),r.camera=await lt(t,r,n.tilt,a),r}async function Gt(t,e,n,a){const r=t.spatialReference,o=await x(e.position,r,{signal:n}),i=e.clone();return i.position=o,jt(t,null,i,a)}async function St(t,e,n,a,r,o,i){const s=t.renderSpatialReference;return await b(e,Lt,s,0,{signal:i}),await b(n,Kt,s,0,{signal:i}),o.targetGeometry=new tt(e),r.position=new tt(n),y(Jt,Lt,Kt),H(t,Kt,Jt,a.up,r),o.scale=X(t,p(Kt,Lt)),o.rotation=st(r.heading),o.camera=r,o}async function Bt(t,e,n,a,r,o){o.targetGeometry=n.clone();const i=C(t);if(e.position)return St(t,o.targetGeometry,e.position,i,a,o,r);if(e.zoomFactor){const n=i.distance/e.zoomFactor,a=u(Ut,i.viewForward,-n);i.eye=f(Ut,i.center,a),o.scale=X(t,n)}J(t,i,a);const s=xt(a,e)?K.LOCKED:K.ADJUST;if(!e.zoomFactor){const n=dt(t,e);if(null==n){await b(o.targetGeometry,Ut,t.renderSpatialReference,0,{signal:r});const e=U(i.frustum,Ut)?p(i.eye,Ut):i.distance;o.camera=await N(t,o.targetGeometry,e,a,s),o.scale=X(t,e)}else o.scale=n,o.camera=await _(t,o.targetGeometry,o.scale,a,s,r)}return o}async function Tt(t,e,n,a,r){const o=C(t);g(Jt,o.viewForward),H(t,o.eye,Jt,o.up,Nt);const i=t.spatialReference,{position:s}=e;if(s){const t=await x(s,i,{signal:r});n.position=t}else n.position=new tt;return n.heading=null!=e.heading?e.heading:Nt.heading,n.tilt=null!=e.tilt?e.tilt:Nt.tilt,jt(t,null,n,a)}async function Mt(t,e,n,a,r){if(null!=e.heading||null!=e.rotation||null!=e.scale||null!=e.tilt||null!=e.zoom||null!=e.zoomFactor){const o=C(t),{spatialReference:i,renderSpatialReference:s}=t,c=new tt({spatialReference:i});return R(o.center,s,c)?Bt(t,e,c,n,a,r):r}return r.scale=t.scale,r.camera=t.camera.clone(),xt(r.camera,e),r}async function Zt(t,e,n,a,r,o){o.targetGeometry=n.clone();const i=C(t);J(t,i,a);const s=xt(a,e)?K.LOCKED:K.ADJUST;return o.camera=await I(t,n,a.heading,a.tilt,s,r),o}function At(t,e,n,a,r){let o=0;null!=n.z?o=n.z:t.basemapTerrain&&t.elevationProvider&&(o=$(t.elevationProvider,n)),h(Ut,n.x,n.y,o),v(t.spatialReference,Ut,Vt,t.renderSpatialReference),s(Ct,Vt),c(Ct,Ct),M(kt);const i=[[0,1,2],[3,1,2],[0,4,2],[3,4,2],[0,1,5],[3,1,5],[0,4,5],[3,4,5]];for(let s=0;s<i.length;s++){const e=i[s];let n=a[e[2]];isFinite(n)||(n=o),h(Ut,a[e[0]],a[e[1]],n),z(Ut,t.spatialReference,Ut,t.renderSpatialReference),Z(kt,d(Ut,Ut,Ct))}const l=E(kt),m=F(kt),u=O(kt),f=1/Math.tan(e.fovX/2),p=1/Math.tan(e.fovY/2),g=.5*Math.sqrt(l*l+u*u)*Math.max(p,f)+.5*m,y=.5*m*p+.5*Math.max(l,u);return Math.max(g,y)/r}async function Et(t,e,n,a,r,o,i,s){s.targetGeometry=n.clone();const c=C(t),l=At(t,c,n,a,r);J(t,c,o);const m=xt(o,e)?K.LOCKED:K.ADJUST;return s.camera=await N(t,s.targetGeometry,l,o,m,i),s.scale=X(t,l),s}function Ft(t,e){if(!e||!t.spatialReference)return null;const n={target:void 0};return"declaredClass"in e||Array.isArray(e)?n.target=e:(Object.assign(n,e),!n.target&&"center"in e&&e.center&&(n.target=e.center)),n}function Ot(t){return null!=t?.camera&&(t.rotation=st(t.camera.heading)),t}function Pt(t,e){const n=ot;if(!e.length)return n;let a=Number.NEGATIVE_INFINITY;for(let r=0;r<e.length;r++){const t=e[r].screenSpaceBoundingRect;a=Math.max(a,Math.abs(t[0]),Math.abs(t[1]),Math.abs(t[2]),Math.abs(t[3]))}return n-a/Math.min(t.width,t.height)*2}class Dt{constructor(){this.hasZ=!1,this.boundingBox=M(),this.screenSpaceObjects=new Array}}const Ut=w(),Vt=m(),Ct=l(),kt=G(),It=P(),Jt=w(),Kt=w(),Lt=w(),Nt={heading:0,tilt:0},qt=new tt,Wt={point(t,e,n){n[0]=t.x,n[1]=t.y,null!=t.z&&(n[2]=t.z),e(n)},polygon(t,e,n){const a=t.hasZ;for(let r=0;r<t.rings.length;r++){const o=t.rings[r];for(let t=0;t<o.length;t++)n[0]=o[t][0],n[1]=o[t][1],a&&(n[2]=o[t][2]),e(n)}},polyline(t,e,n){const a=t.hasZ;for(let r=0;r<t.paths.length;r++){const o=t.paths[r];for(let t=0;t<o.length;t++)n[0]=o[t][0],n[1]=o[t][1],a&&(n[2]=o[t][2]),e(n)}},multipoint(t,e,n){const a=t.points,r=t.hasZ;for(let o=0;o<a.length;o++)n[0]=a[o][0],n[1]=a[o][1],r&&(n[2]=a[o][2]),e(n)},extent(t,e,n){null!=t.zmin&&null!=t.zmax?(e(h(n,t.xmin,t.ymin,t.zmin)),e(h(n,t.xmax,t.ymin,t.zmin)),e(h(n,t.xmin,t.ymax,t.zmin)),e(h(n,t.xmax,t.ymax,t.zmin)),e(h(n,t.xmin,t.ymin,t.zmax)),e(h(n,t.xmax,t.ymin,t.zmax)),e(h(n,t.xmin,t.ymax,t.zmax)),e(h(n,t.xmax,t.ymax,t.zmax))):(e(h(n,t.xmin,t.ymin,n[2])),e(h(n,t.xmax,t.ymin,n[2])),e(h(n,t.xmin,t.ymax,n[2])),e(h(n,t.xmax,t.ymax,n[2])))}};export{ht as create,yt as fromCamera,lt as toCameraAsync,ct as toCameraSync};
|
package/views/interactive/snapping/featureSources/featureServiceSource/FeatureServiceTiledFetcher.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.31/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../../../chunks/tslib.es6.js";import t from"../../../../../core/Accessor.js";import{equals as i}from"../../../../../core/arrayUtils.js";import{createTask as s}from"../../../../../core/asyncUtils.js";import r from"../../../../../core/Logger.js";import{throwIfAbortError as o}from"../../../../../core/promiseUtils.js";import{sync as n,when as a}from"../../../../../core/reactiveUtils.js";import{union as l,equals as u,isSubsetOf as d,difference as c}from"../../../../../core/SetUtils.js";import{property as h}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/has.js";import{subclass as p}from"../../../../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as f}from"../../../../../core/support/UpdatingHandles.js";import y from"../../../../../geometry/Extent.js";import{toExtent as m}from"../../../../../geometry/support/aaBoundingRect.js";import{unquantizeOptimizedFeatureSet as _,convertFromFeatureSet as g}from"../../../../../layers/graphics/featureConversionUtils.js";import{isHostedAgolService as F}from"../../../../../layers/support/arcgisLayerUrl.js";import{OptimizedFeatureSetParserContext as T}from"../../../../../rest/query/operations/pbfOptimizedFeatureSet.js";import{executeQueryForExtent as b,executeQueryPBF as v,executeQuery as P}from"../../../../../rest/query/operations/query.js";import I from"../../../../../rest/support/Query.js";import{StateType as O,PendingFeatureTile as S}from"./PendingFeatureTile.js";let C=class extends t{get _minimumVerticesPerFeature(){switch(this.store?.featureStore.geometryType){case"esriGeometryPoint":case"esriGeometryMultipoint":return 1;case"esriGeometryPolygon":return 4;case"esriGeometryPolyline":return 2}}get _mandatoryOutFields(){const e=new Set;return this.objectIdField&&e.add(this.objectIdField),this.globalIdField&&e.add(this.globalIdField),e}set outFields(e){const t=this._get("outFields"),i=l(e,this._mandatoryOutFields);u(i,t)||(this._set("outFields",i),d(i,t)||this.refresh())}get outFields(){return this._get("outFields")??this._mandatoryOutFields}set filter(e){const t=this._get("filter"),i=this._filterProperties(e);JSON.stringify(t)!==JSON.stringify(i)&&this._set("filter",i)}set customParameters(e){const t=this._get("customParameters");JSON.stringify(t)!==JSON.stringify(e)&&this._set("customParameters",e)}get _configuration(){return{filter:this.filter,customParameters:this.customParameters,tileInfo:this.tileInfo,tileSize:this.tileSize}}set tileInfo(e){const t=this._get("tileInfo");t!==e&&(null!=e&&null!=t&&JSON.stringify(e)===JSON.stringify(t)||(this._set("tileInfo",e),this.store.tileInfo=e))}set tileSize(e){this._get("tileSize")!==e&&this._set("tileSize",e)}get updating(){return this._updatingHandles.updating}get hasZ(){return this.store.featureStore.hasZ}constructor(e){super(e),this.suspended=!0,this._historicMoment=null,this.tilesOfInterest=[],this.availability=0,this._pendingTiles=new Map,this._updatingHandles=new f}initialize(){this._initializeFetchExtent(),this._updatingHandles.add((()=>this._configuration),(()=>this.refresh())),this._updatingHandles.add((()=>this.tilesOfInterest),((e,t)=>{i(e,t,(({id:e},{id:t})=>e===t))||this._process()}),n),this.addHandles(a((()=>!this.suspended),(()=>this._process())))}destroy(){this._pendingTiles.forEach((e=>this._deletePendingTile(e))),this._pendingTiles.clear(),this.store.destroy(),this.tilesOfInterest.length=0,this._updatingHandles.destroy()}refresh(){this.store.refresh(),this._pendingTiles.forEach((e=>this._deletePendingTile(e))),this._process()}async handleEdits(e){if(e.historicMoment&&(this._historicMoment=e.historicMoment),!e.addedFeatures.length&&!e.updatedFeatures.length&&!e.deletedFeatures.length)return;for(const s of this._pendingTiles.values())s.reset();const t={...e,deletedFeatures:e.deletedFeatures.map((({objectId:e,globalId:t})=>e&&-1!==e?e:this._lookupObjectIdByGlobalId(t)))},i=s((async e=>{try{await this.store.processEdits(t,((e,t)=>this._queryFeaturesById(e,t)),e),this._processPendingTiles()}catch(i){o(i),r.getLogger(this).warn("Failed to apply edits",i)}}));this.addHandles(i),await this._updatingHandles.addPromise(i.promise)}setHistoricMoment(e){e?.getTime()!==this._historicMoment?.getTime()&&(this._historicMoment=e,this.refresh())}_initializeFetchExtent(){if(!this.capabilities.query.supportsExtent||!F(this.url))return;const e=s((async e=>{try{const t=await b(this.url,new I({where:"1=1",outSpatialReference:this.spatialReference,cacheHint:this.capabilities.query.supportsCacheHint??void 0}),{query:this._configuration.customParameters,signal:e});this.store.extent=y.fromJSON(t.data?.extent)}catch(t){o(t),r.getLogger(this).warn("Failed to fetch data extent",t)}}));this._updatingHandles.addPromise(e.promise.then((()=>this._process()))),this.addHandles(e)}get debugInfo(){return{numberOfFeatures:this.store.featureStore.numFeatures,tilesOfInterest:this.tilesOfInterest,pendingTiles:Array.from(this._pendingTiles.values()).map((e=>e.debugInfo)),storedTiles:this.store.debugInfo}}_process(){this._markTilesNotAlive(),this._createPendingTiles(),this._deletePendingTiles(),this._processPendingTiles()}_markTilesNotAlive(){for(const e of this._pendingTiles.values())e.alive=!1}_createPendingTiles(){if(this.suspended)return;const e=this._collectMissingTilesInfo();if(this._setAvailability(null==e?1:e.coveredArea/e.fullArea),null!=e)for(const{data:t,resolution:i}of e.missingTiles){const e=this._pendingTiles.get(t.id);e?(e.resolution=i,e.alive=!0):this._createPendingTile(t,i)}}_collectMissingTilesInfo(){let e=null;for(let t=this.tilesOfInterest.length-1;t>=0;t--){const i=this.tilesOfInterest[t],s=this.store.process(i,((e,t)=>this._verifyTileComplexity(e,t)),this.outFields);null==e?e=s:e.prepend(s)}return e}_deletePendingTiles(){for(const e of this._pendingTiles.values())e.alive||this._deletePendingTile(e)}_processPendingTiles(){const e={fetchCount:(e,t)=>this._fetchCount(e,t),fetchFeatures:(e,t,i)=>this._fetchFeatures(e,t,i),finish:(e,t)=>this._finishPendingTile(e,t),resume:()=>this._processPendingTiles()};if(this._ensureFetchAllCounts(e))for(const t of this._pendingTiles.values())this._verifyTileComplexity(this.store.getFeatureCount(t.data),t.resolution)&&this._updatingHandles.addPromise(t.process(e))}_verifyTileComplexity(e,t){return this._verifyVertexComplexity(e)&&this._verifyFeatureDensity(e,t)}_verifyVertexComplexity(e){return e*this._minimumVerticesPerFeature<w}_verifyFeatureDensity(e,t){if(null==this.tileInfo)return!1;const i=this.tileSize*t;return e*(q/(i*i))<M}_ensureFetchAllCounts(e){let t=!0;for(const i of this._pendingTiles.values())i.state.type<O.FETCHED_COUNT&&this._updatingHandles.addPromise(i.process(e)),i.state.type<=O.FETCH_COUNT&&(t=!1);return t}_finishPendingTile(e,t){this.store.add(e.data,t),this._deletePendingTile(e),this._updateAvailability()}_updateAvailability(){const e=this._collectMissingTilesInfo();this._setAvailability(null==e?1:e.coveredArea/e.fullArea)}_setAvailability(e){this._set("availability",e)}_createPendingTile(e,t){const i=new S(e,t);return this._pendingTiles.set(e.id,i),i}_deletePendingTile(e){e.reset(),this._pendingTiles.delete(e.data.id)}async _fetchCount(e,t){return this.store.fetchCount(e.data,this.url,this._createCountQuery(e),{query:this.customParameters,timeout:x,signal:t})}async _fetchFeatures(e,t,i){let s=0;const r=[];let o=0,n=t;for(;;){const a=this._createFeaturesQuery(e),l=this._setPagingParameters(a,s,n),{features:u,exceededTransferLimit:d}=await this._queryFeatures(a,i);l&&(s+=a.num),o+=u.length;for(const e of u)r.push(e);if(n=t-o,!l||!d||n<=0)return r}}_filterProperties(e){return null==e?{where:"1=1",gdbVersion:void 0,timeExtent:void 0}:{where:e.where||"1=1",timeExtent:e.timeExtent,gdbVersion:e.gdbVersion}}_lookupObjectIdByGlobalId(e){const t=this.globalIdField,i=this.objectIdField;if(null==t)throw new Error("Expected globalIdField to be defined");let s=null;if(this.store.featureStore.forEach((r=>{e===r.attributes[t]&&(s=r.objectId??r.attributes[i])})),null==s)throw new Error(`Expected to find a feature with globalId ${e}`);return s}_queryFeaturesById(e,t){const i=this._createFeaturesQuery();return i.objectIds=e,this._queryFeatures(i,t)}_queryFeatures(e,t){return this.capabilities.query.supportsFormatPBF?this._queryFeaturesPBF(e,t):this._queryFeaturesJSON(e,t)}async _queryFeaturesPBF(e,t){const{sourceSpatialReference:i}=this,{data:s}=await v(this.url,e,new T({sourceSpatialReference:i}),{query:this._configuration.customParameters,timeout:x,signal:t});return _(s)}async _queryFeaturesJSON(e,t){const{sourceSpatialReference:i}=this,{data:s}=await P(this.url,e,i,{query:this._configuration.customParameters,timeout:x,signal:t});return g(s,this.objectIdField)}_createCountQuery(e){const t=this._createBaseQuery(e);return this.capabilities.query.supportsCacheHint&&(t.cacheHint=!0),t}_createFeaturesQuery(e=null){const t=this._createBaseQuery(e),i=null!=e?.data?this.store.getAttributesForTile(e?.data?.id):null,s=l(c(this.outFields,i??new Set),this._mandatoryOutFields);return t.outFields=Array.from(s),t.returnGeometry=!0,null!=e&&(this.capabilities.query.supportsResultType?t.resultType="tile":this.capabilities.query.supportsCacheHint&&(t.cacheHint=!0)),t}_createBaseQuery(e){const t=new I({returnZ:this.hasZ,returnM:!1,historicMoment:this._historicMoment,geometry:null!=this.tileInfo&&null!=e?m(e.data.extent,this.tileInfo.spatialReference):void 0}),i=this._configuration.filter;return null!=i&&(t.where=i.where,t.gdbVersion=i.gdbVersion,t.timeExtent=i.timeExtent),t.outSpatialReference=this.spatialReference,t}_setPagingParameters(e,t,i){if(!this.capabilities.query.supportsPagination)return!1;const{supportsMaxRecordCountFactor:s,supportsCacheHint:r,tileMaxRecordCount:o,maxRecordCount:n,supportsResultType:a}=this.capabilities.query,l=s?I.MAX_MAX_RECORD_COUNT_FACTOR:1,u=l*((a||r)&&o?o:n||j);return e.start=t,s?(e.maxRecordCountFactor=Math.min(l,Math.ceil(i/u)),e.num=Math.min(i,e.maxRecordCountFactor*u)):e.num=Math.min(i,u),!0}};e([h({constructOnly:!0})],C.prototype,"url",void 0),e([h({constructOnly:!0})],C.prototype,"objectIdField",void 0),e([h({constructOnly:!0})],C.prototype,"globalIdField",void 0),e([h({constructOnly:!0})],C.prototype,"capabilities",void 0),e([h({constructOnly:!0})],C.prototype,"sourceSpatialReference",void 0),e([h({constructOnly:!0})],C.prototype,"spatialReference",void 0),e([h({constructOnly:!0})],C.prototype,"store",void 0),e([h({readOnly:!0})],C.prototype,"_minimumVerticesPerFeature",null),e([h()],C.prototype,"_mandatoryOutFields",null),e([h()],C.prototype,"outFields",null),e([h()],C.prototype,"suspended",void 0),e([h()],C.prototype,"_historicMoment",void 0),e([h()],C.prototype,"filter",null),e([h()],C.prototype,"customParameters",null),e([h({readOnly:!0})],C.prototype,"_configuration",null),e([h()],C.prototype,"tileInfo",null),e([h()],C.prototype,"tileSize",null),e([h()],C.prototype,"tilesOfInterest",void 0),e([h({readOnly:!0})],C.prototype,"updating",null),e([h({readOnly:!0})],C.prototype,"availability",void 0),e([h()],C.prototype,"hasZ",null),C=e([p("esri.views.interactive.snapping.featureSources.featureServiceSource.FeatureServiceTiledFetcher")],C);const j=2e3,x=6e5,w=1e6,q=25,M=1;export{C as FeatureServiceTiledFetcher};
|
|
5
|
+
import{_ as e}from"../../../../../chunks/tslib.es6.js";import t from"../../../../../core/Accessor.js";import{equals as i}from"../../../../../core/arrayUtils.js";import{createTask as s}from"../../../../../core/asyncUtils.js";import r from"../../../../../core/Logger.js";import{throwIfAbortError as o}from"../../../../../core/promiseUtils.js";import{sync as n,when as a}from"../../../../../core/reactiveUtils.js";import{union as l,equals as u,isSubsetOf as d,difference as c}from"../../../../../core/SetUtils.js";import{normalizeGlobalID as h}from"../../../../../core/uuid.js";import{property as p}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/has.js";import{subclass as f}from"../../../../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as m}from"../../../../../core/support/UpdatingHandles.js";import y from"../../../../../geometry/Extent.js";import{toExtent as _}from"../../../../../geometry/support/aaBoundingRect.js";import{unquantizeOptimizedFeatureSet as g,convertFromFeatureSet as F}from"../../../../../layers/graphics/featureConversionUtils.js";import{isHostedAgolService as T}from"../../../../../layers/support/arcgisLayerUrl.js";import{OptimizedFeatureSetParserContext as b}from"../../../../../rest/query/operations/pbfOptimizedFeatureSet.js";import{executeQueryForExtent as v,executeQueryPBF as P,executeQuery as I}from"../../../../../rest/query/operations/query.js";import O from"../../../../../rest/support/Query.js";import{StateType as S,PendingFeatureTile as j}from"./PendingFeatureTile.js";let C=class extends t{get _minimumVerticesPerFeature(){switch(this.store?.featureStore.geometryType){case"esriGeometryPoint":case"esriGeometryMultipoint":return 1;case"esriGeometryPolygon":return 4;case"esriGeometryPolyline":return 2}}get _mandatoryOutFields(){const e=new Set;return this.objectIdField&&e.add(this.objectIdField),this.globalIdField&&e.add(this.globalIdField),e}set outFields(e){const t=this._get("outFields"),i=l(e,this._mandatoryOutFields);u(i,t)||(this._set("outFields",i),d(i,t)||this.refresh())}get outFields(){return this._get("outFields")??this._mandatoryOutFields}set filter(e){const t=this._get("filter"),i=this._filterProperties(e);JSON.stringify(t)!==JSON.stringify(i)&&this._set("filter",i)}set customParameters(e){const t=this._get("customParameters");JSON.stringify(t)!==JSON.stringify(e)&&this._set("customParameters",e)}get _configuration(){return{filter:this.filter,customParameters:this.customParameters,tileInfo:this.tileInfo,tileSize:this.tileSize}}set tileInfo(e){const t=this._get("tileInfo");t!==e&&(null!=e&&null!=t&&JSON.stringify(e)===JSON.stringify(t)||(this._set("tileInfo",e),this.store.tileInfo=e))}set tileSize(e){this._get("tileSize")!==e&&this._set("tileSize",e)}get updating(){return this._updatingHandles.updating}get hasZ(){return this.store.featureStore.hasZ}constructor(e){super(e),this.suspended=!0,this._historicMoment=null,this.tilesOfInterest=[],this.availability=0,this._pendingTiles=new Map,this._updatingHandles=new m}initialize(){this._initializeFetchExtent(),this._updatingHandles.add((()=>this._configuration),(()=>this.refresh())),this._updatingHandles.add((()=>this.tilesOfInterest),((e,t)=>{i(e,t,(({id:e},{id:t})=>e===t))||this._process()}),n),this.addHandles(a((()=>!this.suspended),(()=>this._process())))}destroy(){this._pendingTiles.forEach((e=>this._deletePendingTile(e))),this._pendingTiles.clear(),this.store.destroy(),this.tilesOfInterest.length=0,this._updatingHandles.destroy()}refresh(){this.store.refresh(),this._pendingTiles.forEach((e=>this._deletePendingTile(e))),this._process()}async handleEdits(e){if(e.historicMoment&&(this._historicMoment=e.historicMoment),!e.addedFeatures.length&&!e.updatedFeatures.length&&!e.deletedFeatures.length)return;for(const s of this._pendingTiles.values())s.reset();const t={...e,deletedFeatures:e.deletedFeatures.map((({objectId:e,globalId:t})=>e&&-1!==e?e:this._lookupObjectIdByGlobalId(t)))},i=s((async e=>{try{await this.store.processEdits(t,((e,t)=>this._queryFeaturesById(e,t)),e),this._processPendingTiles()}catch(i){o(i),r.getLogger(this).warn("Failed to apply edits",i)}}));this.addHandles(i),await this._updatingHandles.addPromise(i.promise)}setHistoricMoment(e){e?.getTime()!==this._historicMoment?.getTime()&&(this._historicMoment=e,this.refresh())}_initializeFetchExtent(){if(!this.capabilities.query.supportsExtent||!T(this.url))return;const e=s((async e=>{try{const t=await v(this.url,new O({where:"1=1",outSpatialReference:this.spatialReference,cacheHint:this.capabilities.query.supportsCacheHint??void 0}),{query:this._configuration.customParameters,signal:e});this.store.extent=y.fromJSON(t.data?.extent)}catch(t){o(t),r.getLogger(this).warn("Failed to fetch data extent",t)}}));this._updatingHandles.addPromise(e.promise.then((()=>this._process()))),this.addHandles(e)}get debugInfo(){return{numberOfFeatures:this.store.featureStore.numFeatures,tilesOfInterest:this.tilesOfInterest,pendingTiles:Array.from(this._pendingTiles.values()).map((e=>e.debugInfo)),storedTiles:this.store.debugInfo}}_process(){this._markTilesNotAlive(),this._createPendingTiles(),this._deletePendingTiles(),this._processPendingTiles()}_markTilesNotAlive(){for(const e of this._pendingTiles.values())e.alive=!1}_createPendingTiles(){if(this.suspended)return;const e=this._collectMissingTilesInfo();if(this._setAvailability(null==e?1:e.coveredArea/e.fullArea),null!=e)for(const{data:t,resolution:i}of e.missingTiles){const e=this._pendingTiles.get(t.id);e?(e.resolution=i,e.alive=!0):this._createPendingTile(t,i)}}_collectMissingTilesInfo(){let e=null;for(let t=this.tilesOfInterest.length-1;t>=0;t--){const i=this.tilesOfInterest[t],s=this.store.process(i,((e,t)=>this._verifyTileComplexity(e,t)),this.outFields);null==e?e=s:e.prepend(s)}return e}_deletePendingTiles(){for(const e of this._pendingTiles.values())e.alive||this._deletePendingTile(e)}_processPendingTiles(){const e={fetchCount:(e,t)=>this._fetchCount(e,t),fetchFeatures:(e,t,i)=>this._fetchFeatures(e,t,i),finish:(e,t)=>this._finishPendingTile(e,t),resume:()=>this._processPendingTiles()};if(this._ensureFetchAllCounts(e))for(const t of this._pendingTiles.values())this._verifyTileComplexity(this.store.getFeatureCount(t.data),t.resolution)&&this._updatingHandles.addPromise(t.process(e))}_verifyTileComplexity(e,t){return this._verifyVertexComplexity(e)&&this._verifyFeatureDensity(e,t)}_verifyVertexComplexity(e){return e*this._minimumVerticesPerFeature<q}_verifyFeatureDensity(e,t){if(null==this.tileInfo)return!1;const i=this.tileSize*t;return e*(M/(i*i))<H}_ensureFetchAllCounts(e){let t=!0;for(const i of this._pendingTiles.values())i.state.type<S.FETCHED_COUNT&&this._updatingHandles.addPromise(i.process(e)),i.state.type<=S.FETCH_COUNT&&(t=!1);return t}_finishPendingTile(e,t){this.store.add(e.data,t),this._deletePendingTile(e),this._updateAvailability()}_updateAvailability(){const e=this._collectMissingTilesInfo();this._setAvailability(null==e?1:e.coveredArea/e.fullArea)}_setAvailability(e){this._set("availability",e)}_createPendingTile(e,t){const i=new j(e,t);return this._pendingTiles.set(e.id,i),i}_deletePendingTile(e){e.reset(),this._pendingTiles.delete(e.data.id)}async _fetchCount(e,t){return this.store.fetchCount(e.data,this.url,this._createCountQuery(e),{query:this.customParameters,timeout:w,signal:t})}async _fetchFeatures(e,t,i){let s=0;const r=[];let o=0,n=t;for(;;){const a=this._createFeaturesQuery(e),l=this._setPagingParameters(a,s,n),{features:u,exceededTransferLimit:d}=await this._queryFeatures(a,i);l&&(s+=a.num),o+=u.length;for(const e of u)r.push(e);if(n=t-o,!l||!d||n<=0)return r}}_filterProperties(e){return null==e?{where:"1=1",gdbVersion:void 0,timeExtent:void 0}:{where:e.where||"1=1",timeExtent:e.timeExtent,gdbVersion:e.gdbVersion}}_lookupObjectIdByGlobalId(e){const t=this.globalIdField,i=this.objectIdField;if(null==t)throw new Error("Expected globalIdField to be defined");let s=null;const r=e?h(e):e;if(this.store.featureStore.forEach((e=>{r===h(e.attributes[t])&&(s=e.objectId??e.attributes[i])})),null==s)throw new Error(`Expected to find a feature with globalId ${e}`);return s}_queryFeaturesById(e,t){const i=this._createFeaturesQuery();return i.objectIds=e,this._queryFeatures(i,t)}_queryFeatures(e,t){return this.capabilities.query.supportsFormatPBF?this._queryFeaturesPBF(e,t):this._queryFeaturesJSON(e,t)}async _queryFeaturesPBF(e,t){const{sourceSpatialReference:i}=this,{data:s}=await P(this.url,e,new b({sourceSpatialReference:i}),{query:this._configuration.customParameters,timeout:w,signal:t});return g(s)}async _queryFeaturesJSON(e,t){const{sourceSpatialReference:i}=this,{data:s}=await I(this.url,e,i,{query:this._configuration.customParameters,timeout:w,signal:t});return F(s,this.objectIdField)}_createCountQuery(e){const t=this._createBaseQuery(e);return this.capabilities.query.supportsCacheHint&&(t.cacheHint=!0),t}_createFeaturesQuery(e=null){const t=this._createBaseQuery(e),i=null!=e?.data?this.store.getAttributesForTile(e?.data?.id):null,s=l(c(this.outFields,i??new Set),this._mandatoryOutFields);return t.outFields=Array.from(s),t.returnGeometry=!0,null!=e&&(this.capabilities.query.supportsResultType?t.resultType="tile":this.capabilities.query.supportsCacheHint&&(t.cacheHint=!0)),t}_createBaseQuery(e){const t=new O({returnZ:this.hasZ,returnM:!1,historicMoment:this._historicMoment,geometry:null!=this.tileInfo&&null!=e?_(e.data.extent,this.tileInfo.spatialReference):void 0}),i=this._configuration.filter;return null!=i&&(t.where=i.where,t.gdbVersion=i.gdbVersion,t.timeExtent=i.timeExtent),t.outSpatialReference=this.spatialReference,t}_setPagingParameters(e,t,i){if(!this.capabilities.query.supportsPagination)return!1;const{supportsMaxRecordCountFactor:s,supportsCacheHint:r,tileMaxRecordCount:o,maxRecordCount:n,supportsResultType:a}=this.capabilities.query,l=s?O.MAX_MAX_RECORD_COUNT_FACTOR:1,u=l*((a||r)&&o?o:n||x);return e.start=t,s?(e.maxRecordCountFactor=Math.min(l,Math.ceil(i/u)),e.num=Math.min(i,e.maxRecordCountFactor*u)):e.num=Math.min(i,u),!0}};e([p({constructOnly:!0})],C.prototype,"url",void 0),e([p({constructOnly:!0})],C.prototype,"objectIdField",void 0),e([p({constructOnly:!0})],C.prototype,"globalIdField",void 0),e([p({constructOnly:!0})],C.prototype,"capabilities",void 0),e([p({constructOnly:!0})],C.prototype,"sourceSpatialReference",void 0),e([p({constructOnly:!0})],C.prototype,"spatialReference",void 0),e([p({constructOnly:!0})],C.prototype,"store",void 0),e([p({readOnly:!0})],C.prototype,"_minimumVerticesPerFeature",null),e([p()],C.prototype,"_mandatoryOutFields",null),e([p()],C.prototype,"outFields",null),e([p()],C.prototype,"suspended",void 0),e([p()],C.prototype,"_historicMoment",void 0),e([p()],C.prototype,"filter",null),e([p()],C.prototype,"customParameters",null),e([p({readOnly:!0})],C.prototype,"_configuration",null),e([p()],C.prototype,"tileInfo",null),e([p()],C.prototype,"tileSize",null),e([p()],C.prototype,"tilesOfInterest",void 0),e([p({readOnly:!0})],C.prototype,"updating",null),e([p({readOnly:!0})],C.prototype,"availability",void 0),e([p()],C.prototype,"hasZ",null),C=e([f("esri.views.interactive.snapping.featureSources.featureServiceSource.FeatureServiceTiledFetcher")],C);const x=2e3,w=6e5,q=1e6,M=25,H=1;export{C as FeatureServiceTiledFetcher};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.31/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import"../../core/has.js";import t from"../../core/Logger.js";import{disposeMaybe as e}from"../../core/maybe.js";import{BufferObject as i}from"./BufferObject.js";import{webglDebugEnabled as r}from"./checkWebGLError.js";import{ResourceType as s,ColorAttachment as h,PixelFormat as n,PixelType as o,DepthStencilAttachment as c,FramebufferTarget as a,TextureType as u,Usage as _,BufferType as f,RenderbufferFormat as l}from"./enums.js";import{GLObjectType as T}from"./GLObjectType.js";import{Renderbuffer as d}from"./Renderbuffer.js";import{Texture as m}from"./Texture.js";const p=()=>t.getLogger("esri.views.webgl.FramebufferObject");class E{constructor(t,e,i=null){this._context=t,this._glName=null,this._colorAttachments=new Map,this._depthStencilBuffer=null,this._depthStencilTexture=null,this._initialized=!1,t.instanceCounter.increment(s.FramebufferObject,this);const r=x(e)?e:new m(this._context,e);if(this._colorAttachments.set(h.COLOR_ATTACHMENT0,r),this._validateTextureDescriptor(r.descriptor),this._validateColorAttachmentPoint(h.COLOR_ATTACHMENT0),null!=i)if(b(i))this._depthStencilTexture=x(i)?i:new m(this._context,i),this._validateTextureDescriptor(this._depthStencilTexture.descriptor);else{const t=g(i)?i:new d(this._context,i);this._depthStencilBuffer=t,this._validateRenderBufferDescriptor(t.descriptor)}}dispose(){if(0===this._colorAttachments.size&&!this._glName)return;const t=this._context.getBoundFramebufferObject();if(this._colorAttachments.forEach(((t,e)=>this.detachColorTexture(e)?.dispose())),this.detachDepthStencilBuffer()?.dispose(),this.detachDepthStencilTexture()?.dispose(),this._glName){this._context.gl.deleteFramebuffer(this._glName),this._glName=null}this._context.bindFramebuffer(t),this._context.instanceCounter.decrement(s.FramebufferObject,this)}get glName(){return this._glName}get colorTexture(){return this._colorAttachments.get(h.COLOR_ATTACHMENT0)}get depthStencil(){return this._depthStencilTexture||this._depthStencilBuffer}get depthStencilTexture(){return this._depthStencilTexture}get width(){const t=this._colorAttachments.get(h.COLOR_ATTACHMENT0);return t?.descriptor?.width??0}get height(){const t=this._colorAttachments.get(h.COLOR_ATTACHMENT0);return t?.descriptor?.height??0}get usedMemory(){return[...this._colorAttachments].reduce(((t,[e,i])=>t+i.usedMemory),this.depthStencil?.usedMemory??0)}getColorTexture(t){const e=this._colorAttachments.get(t);return e&&x(e)?e:null}get colorAttachments(){return[...this._colorAttachments.keys()]}attachColorTexture(t,e=h.COLOR_ATTACHMENT0){if(!t)return;this._validateColorAttachmentPoint(e);const i=t.descriptor;this._validateTextureDescriptor(i),this.detachColorTexture(e)?.dispose(),this._initialized&&(this._context.bindFramebuffer(this),this._framebufferTexture2D(t.glName,e)),this._colorAttachments.set(e,t)}detachColorTexture(t=h.COLOR_ATTACHMENT0){const e=this._colorAttachments.get(t);if(e){if(this._initialized){const e=this._context.getBoundFramebufferObject();this._context.bindFramebuffer(this),this._framebufferTexture2D(null,t),this._context.bindFramebuffer(e)}return this._colorAttachments.delete(t),e}}setColorTextureTarget(t,e=h.COLOR_ATTACHMENT0){const i=this._colorAttachments.get(e);i&&this._framebufferTexture2D(i.glName,e,t)}attachDepthStencil(t){if(t)switch(t.type){case T.Texture:return this._attachDepthStencilTexture(t);case T.RenderBuffer:return this._attachDepthStencilBuffer(t)}}_attachDepthStencilTexture(t){if(null==t)return;const e=t.descriptor;e.pixelFormat!==n.DEPTH_STENCIL&&e.pixelFormat!==n.DEPTH24_STENCIL8&&console.error("Depth/Stencil texture must have a pixel type of DEPTH_STENCIL!"),e.dataType!==o.UNSIGNED_INT_24_8&&console.error("Depth/Stencil texture must have data type of UNSIGNED_INT_24_8!"),this._validateTextureDescriptor(e),this._disposeDepthStencilAttachments(),this._initialized&&(this._context.bindFramebuffer(this),this._framebufferTexture2D(t.glName,c)),this._depthStencilTexture?.dispose(),this._depthStencilTexture=t}detachDepthStencilTexture(){const t=this._depthStencilTexture;if(t&&this._initialized){const t=this._context.getBoundFramebufferObject();this._context.bindFramebuffer(this),this._framebufferTexture2D(null,c),this._context.bindFramebuffer(t)}return this._depthStencilTexture=null,t}_attachDepthStencilBuffer(t){if(null==t)return;const e=t.descriptor;if(this._validateRenderBufferDescriptor(e),this._disposeDepthStencilAttachments(),this._initialized){this._context.bindFramebuffer(this);const i=this._context.gl,r=this._getGLAttachmentPoint(e);i.framebufferRenderbuffer(a.FRAMEBUFFER,r,i.RENDERBUFFER,t.glName)}this._depthStencilBuffer=t}detachDepthStencilBuffer(){const t=this._depthStencilBuffer;if(t&&this._initialized){const e=this._context.getBoundFramebufferObject();this._context.bindFramebuffer(this);const i=this._context.gl,r=this._getGLAttachmentPoint(t.descriptor);i.framebufferRenderbuffer(a.FRAMEBUFFER,r,i.RENDERBUFFER,null),this._context.bindFramebuffer(e)}return this._depthStencilBuffer=null,t}copyToTexture(t,e,i,r,s,h,n){(t<0||e<0||s<0||h<0)&&console.error("Offsets cannot be negative!"),(i<=0||r<=0)&&console.error("Copy width and height must be greater than zero!");const o=n.descriptor;n.descriptor.target!==u.TEXTURE_2D&&console.error("Texture target must be TEXTURE_2D!"),(null==o?.width||null==o?.height||t+i>this.width||e+r>this.height||s+i>o.width||h+r>o.height)&&console.error("Bad dimensions, the current input values will attempt to read or copy out of bounds!");const c=this._context,a=c.bindTexture(n,m.TEXTURE_UNIT_FOR_UPDATES);c.setActiveTexture(m.TEXTURE_UNIT_FOR_UPDATES),c.bindFramebuffer(this),c.gl.copyTexSubImage2D(u.TEXTURE_2D,0,s,h,t,e,i,r),c.bindTexture(a,m.TEXTURE_UNIT_FOR_UPDATES)}readPixels(t,e,i,r,s,h,n){(i<=0||r<=0)&&console.error("Copy width and height must be greater than zero!"),n||console.error("Target memory is not initialized!"),this._context.bindFramebuffer(this),this._context.gl.readPixels(t,e,i,r,s,h,n)}async readPixelsAsync(t,e,r,s,h,n,o){const{gl:c}=this._context,a=i.createPixelPack(this._context,_.STREAM_READ,o.byteLength);this._context.bindBuffer(a),this._context.bindFramebuffer(this),c.readPixels(t,e,r,s,h,n,0),this._context.unbindBuffer(f.PIXEL_PACK_BUFFER),await a.getSubDataAsync(o),a.dispose()}resize(t,e){if(this.width===t&&this.height===e)return;const i={width:t,height:e};A(i,this._context.parameters.maxTextureSize),this._colorAttachments.forEach((t=>t.resize(i.width,i.height))),this._depthStencilTexture?.resize(i.width,i.height),this._initialized&&(A(i,this._context.parameters.maxRenderbufferSize),this._depthStencilBuffer?.resize(i.width,i.height),this._context.getBoundFramebufferObject()===this&&this._context.bindFramebuffer(null),this._initialized=!1)}initializeAndBind(t=a.FRAMEBUFFER){const e=this._context.gl;if(this._initialized)return void e.bindFramebuffer(t,this.glName);this._glName&&e.deleteFramebuffer(this._glName);const i=e.createFramebuffer();if(e.bindFramebuffer(t,i),this._colorAttachments.forEach(((e,i)=>this._framebufferTexture2D(e.glName,i,S(e),t))),this._depthStencilBuffer){const i=this._getGLAttachmentPoint(this._depthStencilBuffer.descriptor);e.framebufferRenderbuffer(t,i,e.RENDERBUFFER,this._depthStencilBuffer.glName)}else this._depthStencilTexture&&this._framebufferTexture2D(this._depthStencilTexture.glName,e.DEPTH_STENCIL_ATTACHMENT,S(this._depthStencilTexture),t);if(r()){e.checkFramebufferStatus(t)!==e.FRAMEBUFFER_COMPLETE&&console.error("Framebuffer is incomplete!")}this._glName=i,this._initialized=!0}_framebufferTexture2D(t,e=h.COLOR_ATTACHMENT0,i=u.TEXTURE_2D,r=a.FRAMEBUFFER,s=0){this._context.gl.framebufferTexture2D(r,e,i,t,s)}_disposeDepthStencilAttachments(){const t=this._context.gl;if(this._depthStencilBuffer){if(this._initialized){this._context.bindFramebuffer(this);const e=this._getGLAttachmentPoint(this._depthStencilBuffer.descriptor);t.framebufferRenderbuffer(a.FRAMEBUFFER,e,t.RENDERBUFFER,null)}this._depthStencilBuffer=e(this._depthStencilBuffer)}this._depthStencilTexture&&(this._initialized&&(this._context.bindFramebuffer(this),this._framebufferTexture2D(null,t.DEPTH_STENCIL_ATTACHMENT)),this._depthStencilTexture=e(this._depthStencilTexture))}_validateTextureDescriptor(t){t.target!==u.TEXTURE_2D&&t.target!==u.TEXTURE_CUBE_MAP&&console.error("Texture type must be TEXTURE_2D or TEXTURE_CUBE_MAP!"),A(t,this._context.parameters.maxTextureSize),this._validateBufferDimensions(t)}_validateRenderBufferDescriptor(t){A(t,this._context.parameters.maxRenderbufferSize),this._validateBufferDimensions(t)}_validateBufferDimensions(t){t.width<=0&&(t.width=this.width),t.height<=0&&(t.height=this.height),this.width>0&&this.height>0&&(this.width===t.width&&this.height===t.height||console.error("Attachment size must match framebuffer size!"))}_getGLAttachmentPoint(t){switch(t.internalFormat){case l.DEPTH_COMPONENT16:case l.DEPTH_COMPONENT24:case l.DEPTH_COMPONENT32F:return this._context.gl.DEPTH_ATTACHMENT;case l.DEPTH24_STENCIL8:case l.DEPTH32F_STENCIL8:case l.DEPTH_STENCIL:return this._context.gl.DEPTH_STENCIL_ATTACHMENT;case l.STENCIL_INDEX8:return this._context.gl.STENCIL_ATTACHMENT}}_validateColorAttachmentPoint(e){if(-1===E._MAX_COLOR_ATTACHMENTS){const{gl:t}=this._context;E._MAX_COLOR_ATTACHMENTS=t.getParameter(t.MAX_COLOR_ATTACHMENTS)}const i=e-h.COLOR_ATTACHMENT0;i+1>E._MAX_COLOR_ATTACHMENTS&&t.getLogger("esri.views.webgl.FrameBufferObject").error("esri.FrameBufferObject",`illegal attachment point for color attachment: ${i+1}. Implementation supports up to ${E._MAX_COLOR_ATTACHMENTS} color attachments`)}}function x(t){return null!=t&&"type"in t&&t.type===T.Texture}function g(t){return null!=t&&"type"in t&&t.type===T.RenderBuffer}function b(t){return x(t)||null!=t&&"pixelFormat"in t}function A(t,e){const i=Math.max(t.width,t.height);if(i>e){p().warn(`Resizing FBO attachment size ${t.width}x${t.height} to device limit ${e}`);const r=e/i;return t.width=Math.round(t.width*r),t.height=Math.round(t.height*r),!1}return!0}function S(t){return t.descriptor.target===u.TEXTURE_CUBE_MAP?u.TEXTURE_CUBE_MAP_POSITIVE_X:u.TEXTURE_2D}E._MAX_COLOR_ATTACHMENTS=-1;export{E as FramebufferObject,A as ensureAttachmentMaxSize};
|
|
5
|
+
import"../../core/has.js";import t from"../../core/Logger.js";import{disposeMaybe as e}from"../../core/maybe.js";import{BufferObject as i}from"./BufferObject.js";import{webglDebugEnabled as r}from"./checkWebGLError.js";import{ResourceType as s,ColorAttachment as n,PixelFormat as h,PixelType as o,DepthStencilAttachment as c,FramebufferTarget as a,TextureType as u,Usage as _,BufferType as f,RenderbufferFormat as l}from"./enums.js";import{GLObjectType as T}from"./GLObjectType.js";import{Renderbuffer as d}from"./Renderbuffer.js";import{Texture as m}from"./Texture.js";const p=()=>t.getLogger("esri.views.webgl.FramebufferObject");class x{constructor(t,e,i=null){this._context=t,this._glName=null,this._colorAttachments=new Map,this._depthStencilBuffer=null,this._depthStencilTexture=null,this._initialized=!1,t.instanceCounter.increment(s.FramebufferObject,this);const r=E(e)?e:new m(this._context,e);if(this._colorAttachments.set(n.COLOR_ATTACHMENT0,r),this._validateTextureDescriptor(r.descriptor),this._validateColorAttachmentPoint(n.COLOR_ATTACHMENT0),null!=i)if(b(i))this._depthStencilTexture=E(i)?i:new m(this._context,i),this._validateTextureDescriptor(this._depthStencilTexture.descriptor);else{const t=g(i)?i:new d(this._context,i);this._depthStencilBuffer=t,this._validateRenderBufferDescriptor(t.descriptor)}}dispose(){if(0===this._colorAttachments.size&&!this._glName)return;const t=this._context.getBoundFramebufferObject();if(this._colorAttachments.forEach(((t,e)=>this.detachColorTexture(e)?.dispose())),this.detachDepthStencilBuffer()?.dispose(),this.detachDepthStencilTexture()?.dispose(),this._glName){this._context.gl.deleteFramebuffer(this._glName),this._glName=null}this._context.bindFramebuffer(t),this._context.instanceCounter.decrement(s.FramebufferObject,this)}get glName(){return this._glName}get colorTexture(){return this._colorAttachments.get(n.COLOR_ATTACHMENT0)}get depthStencil(){return this._depthStencilTexture||this._depthStencilBuffer}get depthStencilTexture(){return this._depthStencilTexture}get width(){const t=this._colorAttachments.get(n.COLOR_ATTACHMENT0);return t?.descriptor?.width??0}get height(){const t=this._colorAttachments.get(n.COLOR_ATTACHMENT0);return t?.descriptor?.height??0}get usedMemory(){return[...this._colorAttachments].reduce(((t,[e,i])=>t+i.usedMemory),this.depthStencil?.usedMemory??0)}getColorTexture(t){const e=this._colorAttachments.get(t);return e&&E(e)?e:null}get colorAttachments(){return[...this._colorAttachments.keys()]}attachColorTexture(t,e=n.COLOR_ATTACHMENT0){if(!t)return;this._validateColorAttachmentPoint(e);const i=t.descriptor;this._validateTextureDescriptor(i),this.detachColorTexture(e)?.dispose(),this._initialized&&(this._context.bindFramebuffer(this),this._framebufferTexture2D(t.glName,e)),this._colorAttachments.set(e,t)}detachColorTexture(t=n.COLOR_ATTACHMENT0){const e=this._colorAttachments.get(t);if(e){if(this._initialized){const e=this._context.getBoundFramebufferObject();this._context.bindFramebuffer(this),this._framebufferTexture2D(null,t),this._context.bindFramebuffer(e)}return this._colorAttachments.delete(t),e}}setColorTextureTarget(t,e=n.COLOR_ATTACHMENT0){const i=this._colorAttachments.get(e);i&&this._framebufferTexture2D(i.glName,e,t)}attachDepthStencil(t){if(t)switch(t.type){case T.Texture:return this._attachDepthStencilTexture(t);case T.RenderBuffer:return this._attachDepthStencilBuffer(t)}}_attachDepthStencilTexture(t){if(null==t)return;const e=t.descriptor;e.pixelFormat!==h.DEPTH_STENCIL&&e.pixelFormat!==h.DEPTH24_STENCIL8&&console.error("Depth/Stencil texture must have a pixel type of DEPTH_STENCIL!"),e.dataType!==o.UNSIGNED_INT_24_8&&console.error("Depth/Stencil texture must have data type of UNSIGNED_INT_24_8!"),this._validateTextureDescriptor(e),this._disposeDepthStencilAttachments(),this._initialized&&(this._context.bindFramebuffer(this),this._framebufferTexture2D(t.glName,c)),this._depthStencilTexture?.dispose(),this._depthStencilTexture=t}detachDepthStencilTexture(){const t=this._depthStencilTexture;if(t&&this._initialized){const t=this._context.getBoundFramebufferObject();this._context.bindFramebuffer(this),this._framebufferTexture2D(null,c),this._context.bindFramebuffer(t)}return this._depthStencilTexture=null,t}_attachDepthStencilBuffer(t){if(null==t)return;const e=t.descriptor;if(this._validateRenderBufferDescriptor(e),this._disposeDepthStencilAttachments(),this._initialized){this._context.bindFramebuffer(this);const i=this._context.gl,r=this._getGLAttachmentPoint(e);i.framebufferRenderbuffer(a.FRAMEBUFFER,r,i.RENDERBUFFER,t.glName)}this._depthStencilBuffer=t}detachDepthStencilBuffer(){const t=this._depthStencilBuffer;if(t&&this._initialized){const e=this._context.getBoundFramebufferObject();this._context.bindFramebuffer(this);const i=this._context.gl,r=this._getGLAttachmentPoint(t.descriptor);i.framebufferRenderbuffer(a.FRAMEBUFFER,r,i.RENDERBUFFER,null),this._context.bindFramebuffer(e)}return this._depthStencilBuffer=null,t}copyToTexture(t,e,i,r,s,n,h){(t<0||e<0||s<0||n<0)&&console.error("Offsets cannot be negative!"),(i<=0||r<=0)&&console.error("Copy width and height must be greater than zero!");const o=h.descriptor;h.descriptor.target!==u.TEXTURE_2D&&console.error("Texture target must be TEXTURE_2D!"),(null==o?.width||null==o?.height||t+i>this.width||e+r>this.height||s+i>o.width||n+r>o.height)&&console.error("Bad dimensions, the current input values will attempt to read or copy out of bounds!");const c=this._context,a=c.bindTexture(h,m.TEXTURE_UNIT_FOR_UPDATES);c.setActiveTexture(m.TEXTURE_UNIT_FOR_UPDATES),c.bindFramebuffer(this),c.gl.copyTexSubImage2D(u.TEXTURE_2D,0,s,n,t,e,i,r),c.bindTexture(a,m.TEXTURE_UNIT_FOR_UPDATES)}readPixels(t,e,i,r,s,n,h){(i<=0||r<=0)&&console.error("Copy width and height must be greater than zero!"),h||console.error("Target memory is not initialized!"),this._context.bindFramebuffer(this),this._context.gl.readPixels(t,e,i,r,s,n,h)}async readPixelsAsync(t,e,r,s,n,h,o){const{gl:c}=this._context,a=i.createPixelPack(this._context,_.STREAM_READ,o.byteLength);this._context.bindBuffer(a);const u=this._context.getBoundFramebufferObject();this._context.bindFramebuffer(this),c.readPixels(t,e,r,s,n,h,0),this._context.unbindBuffer(f.PIXEL_PACK_BUFFER),this._context.bindFramebuffer(u),await a.getSubDataAsync(o),a.dispose()}resize(t,e){if(this.width===t&&this.height===e)return;const i={width:t,height:e};A(i,this._context.parameters.maxTextureSize),this._colorAttachments.forEach((t=>t.resize(i.width,i.height))),this._depthStencilTexture?.resize(i.width,i.height),this._initialized&&(A(i,this._context.parameters.maxRenderbufferSize),this._depthStencilBuffer?.resize(i.width,i.height),this._context.getBoundFramebufferObject()===this&&this._context.bindFramebuffer(null),this._initialized=!1)}initializeAndBind(t=a.FRAMEBUFFER){const e=this._context.gl;if(this._initialized)return void e.bindFramebuffer(t,this.glName);this._glName&&e.deleteFramebuffer(this._glName);const i=e.createFramebuffer();if(e.bindFramebuffer(t,i),this._colorAttachments.forEach(((e,i)=>this._framebufferTexture2D(e.glName,i,S(e),t))),this._depthStencilBuffer){const i=this._getGLAttachmentPoint(this._depthStencilBuffer.descriptor);e.framebufferRenderbuffer(t,i,e.RENDERBUFFER,this._depthStencilBuffer.glName)}else this._depthStencilTexture&&this._framebufferTexture2D(this._depthStencilTexture.glName,e.DEPTH_STENCIL_ATTACHMENT,S(this._depthStencilTexture),t);if(r()){e.checkFramebufferStatus(t)!==e.FRAMEBUFFER_COMPLETE&&console.error("Framebuffer is incomplete!")}this._glName=i,this._initialized=!0}_framebufferTexture2D(t,e=n.COLOR_ATTACHMENT0,i=u.TEXTURE_2D,r=a.FRAMEBUFFER,s=0){this._context.gl.framebufferTexture2D(r,e,i,t,s)}_disposeDepthStencilAttachments(){const t=this._context.gl;if(this._depthStencilBuffer){if(this._initialized){this._context.bindFramebuffer(this);const e=this._getGLAttachmentPoint(this._depthStencilBuffer.descriptor);t.framebufferRenderbuffer(a.FRAMEBUFFER,e,t.RENDERBUFFER,null)}this._depthStencilBuffer=e(this._depthStencilBuffer)}this._depthStencilTexture&&(this._initialized&&(this._context.bindFramebuffer(this),this._framebufferTexture2D(null,t.DEPTH_STENCIL_ATTACHMENT)),this._depthStencilTexture=e(this._depthStencilTexture))}_validateTextureDescriptor(t){t.target!==u.TEXTURE_2D&&t.target!==u.TEXTURE_CUBE_MAP&&console.error("Texture type must be TEXTURE_2D or TEXTURE_CUBE_MAP!"),A(t,this._context.parameters.maxTextureSize),this._validateBufferDimensions(t)}_validateRenderBufferDescriptor(t){A(t,this._context.parameters.maxRenderbufferSize),this._validateBufferDimensions(t)}_validateBufferDimensions(t){t.width<=0&&(t.width=this.width),t.height<=0&&(t.height=this.height),this.width>0&&this.height>0&&(this.width===t.width&&this.height===t.height||console.error("Attachment size must match framebuffer size!"))}_getGLAttachmentPoint(t){switch(t.internalFormat){case l.DEPTH_COMPONENT16:case l.DEPTH_COMPONENT24:case l.DEPTH_COMPONENT32F:return this._context.gl.DEPTH_ATTACHMENT;case l.DEPTH24_STENCIL8:case l.DEPTH32F_STENCIL8:case l.DEPTH_STENCIL:return this._context.gl.DEPTH_STENCIL_ATTACHMENT;case l.STENCIL_INDEX8:return this._context.gl.STENCIL_ATTACHMENT}}_validateColorAttachmentPoint(e){if(-1===x._MAX_COLOR_ATTACHMENTS){const{gl:t}=this._context;x._MAX_COLOR_ATTACHMENTS=t.getParameter(t.MAX_COLOR_ATTACHMENTS)}const i=e-n.COLOR_ATTACHMENT0;i+1>x._MAX_COLOR_ATTACHMENTS&&t.getLogger("esri.views.webgl.FrameBufferObject").error("esri.FrameBufferObject",`illegal attachment point for color attachment: ${i+1}. Implementation supports up to ${x._MAX_COLOR_ATTACHMENTS} color attachments`)}}function E(t){return null!=t&&"type"in t&&t.type===T.Texture}function g(t){return null!=t&&"type"in t&&t.type===T.RenderBuffer}function b(t){return E(t)||null!=t&&"pixelFormat"in t}function A(t,e){const i=Math.max(t.width,t.height);if(i>e){p().warn(`Resizing FBO attachment size ${t.width}x${t.height} to device limit ${e}`);const r=e/i;return t.width=Math.round(t.width*r),t.height=Math.round(t.height*r),!1}return!0}function S(t){return t.descriptor.target===u.TEXTURE_CUBE_MAP?u.TEXTURE_CUBE_MAP_POSITIVE_X:u.TEXTURE_2D}x._MAX_COLOR_ATTACHMENTS=-1;export{x as FramebufferObject,A as ensureAttachmentMaxSize};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.31/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{TextureType as t,PixelFormat as i,PixelType as h,TextureSamplingMode as s,TextureWrapMode as a}from"./enums.js";import{getBytesPerElementFormat as
|
|
5
|
+
import{TextureType as t,PixelFormat as i,PixelType as h,TextureSamplingMode as s,TextureWrapMode as a}from"./enums.js";import{getBytesPerElementFormat as e}from"./Util.js";class p{constructor(e=0,p=e){this.width=e,this.height=p,this.target=t.TEXTURE_2D,this.pixelFormat=i.RGBA,this.dataType=h.UNSIGNED_BYTE,this.samplingMode=s.LINEAR,this.wrapMode=a.REPEAT,this.maxAnisotropy=1,this.flipped=!1,this.hasMipmap=!1,this.isOpaque=!1,this.unpackAlignment=4,this.preMultiplyAlpha=!1,this.depth=1,this.isImmutable=!1}}function r(i){return i.width<=0||i.height<=0?0:Math.round(i.width*i.height*(i.hasMipmap?4/3:1)*(null==i.internalFormat?4:e(i.internalFormat))*(i.target===t.TEXTURE_CUBE_MAP?6:1))}export{p as TextureDescriptor,r as estimateMemory};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.31/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../chunks/tslib.es6.js";import"../../intl.js";import{isSome as t}from"../../core/arrayUtils.js";import i from"../../core/Collection.js";import{referenceSetter as s}from"../../core/collectionUtils.js";import{deprecatedFunction as l}from"../../core/deprecate.js";import o from"../../core/Error.js";import n from"../../core/Handles.js";import a from"../../core/Logger.js";import{debounce as r,ignoreAbortErrors as h,createResolver as d}from"../../core/promiseUtils.js";import{watch as m,initial as c,on as p}from"../../core/reactiveUtils.js";import{property as u}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import{subclass as g}from"../../core/accessorSupport/decorators/subclass.js";import{getLowerCaseDefaultHiddenFields as b}from"../../layers/support/fieldUtils.js";import{getSubtypesFromLayer as f,isSubtypeGroupLayer as y}from"../../layers/support/layerUtils.js";import{createFieldInfos as w}from"../../support/popupUtils.js";import T from"../../tables/AttributeTableTemplate.js";import{highlightsSupported as _}from"../../views/support/layerViewUtils.js";import{isSelectableLayer as I}from"../../views/support/selectionUtils.js";import C from"./ActionColumn.js";import v from"./AttachmentsColumn.js";import E from"./FieldColumn.js";import A from"./RelationshipColumn.js";import F from"./Grid/Column.js";import j from"./Grid/Grid.js";import S from"./Grid/GridViewModel.js";import R from"./Grid/GroupColumn.js";import x from"./support/AttachmentsColumnTemplate.js";import U from"./support/AttachmentsViewOptions.js";import{isAttachmentsColumn as O,isRelationshipColumn as V}from"./support/columnUtils.js";import{downloadAttachmentInfo as P,exportToCSV as W}from"./support/exportUtils.js";import z from"./support/FeatureStore.js";import B from"./support/FieldColumnTemplate.js";import L from"./support/RelationshipColumnTemplate.js";import Z from"./support/TableTemplate.js";import{findRelationship as G,uniqueColumnNames as k,hasColumnForField as N,findField as M,isIFeatureTableSupportedLayerWithAttachments as H,isIFeatureTableSupportedLayerWithRelationships as $,getRelationshipIdsToShow as D}from"./support/tableUtils.js";import"../support/widgetUtils.js";import{messageBundle as q}from"../support/decorators/messageBundle.js";import{onLocaleChange as Q}from"../../intl/locale.js";import{substitute as K}from"../../intl/substitute.js";import{fetchMessageBundle as J}from"../../intl/messages.js";const X="80px";let Y=class extends S{constructor(e){super(e),this._debounceRefresh=r((()=>this._refresh())),this._highlights=new n,this.actionColumnConfig=null,this.attachmentsViewOptions=new U,this.attributeTableTemplate=null,this.autoRefreshEnabled=!0,this.columns=new i,this.dataProvider=async(e,t)=>{const{layer:i,store:s}=this;if(!t)return;if(!i||!s)return void(t&&t([]));await i.load();const{objectIds:l}=this;if(this.filterBySelectionEnabled&&!this.highlightIds.length||1===l.length&&-1===l.items[0])return void t([]);"loaded"!==s.state&&"loading"!==s.state&&await s.load();const o=this.paginationEnabled?this.pageIndex:e.page,n=await s.fetchItems({...e,page:o});t&&t(n)},this.editingEnabled=!1,this.grid=null,this.highlightEnabled=!0,this.itemIdPath="objectId",this.messages=null,this.messagesCommon=null,this.messagesUnits=null,this.messagesURIUtils=null,this.prompt=null,this.relatedTables=new i,this.relationshipColumnConfigs=null,this.selectionSource="table",this.showRelatedTableCallback=null,this.store=null,this.tableController=null,this.tableParent=null,this.tableTemplate=null,this.tableTemplateOverride=null,this._onLayerRefresh=this._onLayerRefresh.bind(this),this._onShowPromptCallback=this._onShowPromptCallback.bind(this),this._set("store",new z),this._set("grid",new j({itemIdPath:this.itemIdPath,viewModel:this}))}initialize(){const e=async()=>{this.messages=await J("esri/widgets/FeatureTable/t9n/FeatureTable"),this.messagesCommon=await J("esri/t9n/common"),this.messagesUnits=await J("esri/core/t9n/Units"),this.messagesURIUtils=await J("esri/widgets/support/t9n/uriUtils")};e(),this.addHandles([Q((()=>{e(),this._generateColumns()})),m((()=>[this.messages,this.messagesCommon,this.messagesURIUtils]),(()=>{const e=this.messages;this.grid&&(this.grid.messages=e),this.allColumns.forEach((t=>{t.messages=e,t.messagesCommon=this.messagesCommon,t.messagesURIUtils=this.messagesURIUtils})),this.refreshCellContent()}),c),p((()=>this.highlightIds),"change",(e=>this._onHighlightIdsChange(e)),{onListenerAdd:()=>this._syncSelection(),onListenerRemove:()=>this._highlights.removeAll()}),m((()=>this.attachmentsEnabled),(()=>this.layer?.loaded&&this._generateColumns())),m((()=>this._viewSelection),(()=>{this._viewSelectionReady&&(this.highlightIds.items=this._viewSelection)})),m((()=>[this._tableHighlightsReady,this._viewSelectionReady]),(()=>this._syncSelection())),m((()=>this.layer),(async(e,t)=>{const i=this.grid;i&&(i.clearSort(),e&&t&&await this.reset()),this.goToPage(0),this._drainColumns(),this.store.layer=e,e&&(e.loaded?this._onLayerLoad():e.load().catch((()=>{})))})),m((()=>this.layer?.loaded),(e=>e&&this._onLayerLoad())),m((()=>this.store.state),(e=>{"loaded"===e&&(this.scrollToTop(),this.refreshCellContent())})),m((()=>this._effectiveTableTemplate),(()=>{this.scrollLeft(),this.layer?.loaded&&this._generateColumns()})),m((()=>this.editingEnabled),(e=>{this.editableColumns.forEach((t=>t.tableEditingEnabled=e)),this.refreshCellContent()})),m((()=>this.timeZone??this.view?.timeZone),(()=>this.refreshCellContent())),m((()=>this.layer?.definitionExpression),((e,t)=>(e||t)&&"loaded"===this.store.state&&this.reset())),m((()=>this.layer?.timeExtent),((e,t)=>(e||t)&&!this.timeExtent&&"loaded"===this.store.state&&this.reset())),p((()=>this.layer),"refresh",(e=>this._onLayerRefresh(e))),p((()=>this.grid),["cell-click","cell-dblclick","cell-pointerover","cell-pointerout","cell-keydown","column-reorder"],(({index:e,item:t,native:i,path:s,type:l})=>{const o=t?.feature,n=o?.getObjectId(),a="cell-keydown"===l&&i&&i instanceof KeyboardEvent&&"Enter"===i.key;this.emit(l,{feature:o,index:e,native:i,type:l,fieldName:s??void 0,objectId:n}),(a||"cell-click"===l)&&this._onCellInteraction(n)})),m((()=>this.actionColumnConfig),(e=>{const{actionColumn:t,columns:i}=this;t?e?t.set(e):i.remove(t):e&&i.length&&i.add(this._generateActionColumn(),!1!==e.frozenToEnd?void 0:this._getIndexOfFirstFrozenToEndColumn())})),m((()=>this.relatedRecordsEnabled),(()=>this.layer?.loaded&&this._generateColumns())),p((()=>this.objectIds),"change",(()=>this._onObjectIdsChange()),{onListenerAdd:()=>this._onObjectIdsChange()}),m((()=>[this.paginationEnabled,this.pageIndex]),(()=>this.refreshPageCache())),m((()=>this.activeSortOrders),(e=>this.store.sortOrders=e)),m((()=>this.pageCount),(()=>{this.pageIndex>=this.pageCount&&this.goToPage(0)})),m((()=>this.state),(e=>{"disabled"===e&&this.relatedTables.length&&this.drainRelatedTables()})),p((()=>this.tableParent?.highlightIds),"change",(({added:e})=>{const{relationshipConfig:t}=this,i=e[0];if(null==i||!t)return;const{relatedLayer:s,relationshipId:l}=t;this.relationshipConfig={objectId:i,relatedLayer:s,relationshipId:l}})),p((()=>this.tableParent),"cell-click",(e=>{const{tableParent:t}=this,{objectId:i}=e;t&&null!=i&&t.highlightIds.add(i)})),m((()=>this.attachmentsViewOptions.objectId),((e,t)=>{null!=e?null==t&&this.showAttachmentsView({objectId:e}):this.hideAttachmentsView()}))])}destroy(){this._drainColumns(),this._highlights.removeAll(),this._highlights.destroy(),this.grid?.destroy(),this.columns.destroyed||this.columns.destroy(),this.layer=null,this.view=null}get _defaultHiddenFields(){return b(this.layer)}get _effectiveTableTemplate(){return this.tableTemplateOverride||this.tableTemplate}get _effectiveAttributeTableTemplate(){return this.attributeTableTemplate||this.layer?.attributeTableTemplate}get _highlightableLayerView(){const e=this.layerView;return _(e)?e:null}get _relationshipInfos(){return this.store.relationshipInfos}get _selectionManager(){const{view:e}=this;return!e||e.destroyed?null:e.selectionManager?.sources?.length?e.selectionManager:null}get _selectableLayer(){const{layer:e}=this;return I(e)&&this._selectionManager?.sources.includes(e)?e:null}get _subtypes(){return f(this.layer)}get _tableHighlightsReady(){return!("table"!==this.selectionSource||!this.highlightEnabled||!this._highlightableLayerView)}get _viewSelection(){const{_selectableLayer:e}=this;return e?this._selectionManager?.getSelection(e)??[]:[]}get _viewSelectionReady(){return!(!this.layer||"view"!==this.selectionSource||!this._selectionManager)}get allRelatedTablesVisible(){return!!(this.relatedRecordsEnabled&&this.relatedTables.length&&this.showAllRelatedTables)}get activeFilters(){const{filterGeometry:e,objectIds:t,filterBySelectionEnabled:s,highlightIds:l}=this,o=new i;return e&&o.push({type:"geometry",geometry:e}),s?o.push({type:"selection",objectIds:l.toArray()}):t.length&&o.push({type:"objectId",objectIds:t.toArray()}),o}get activeSortOrders(){return this.grid?.sortOrders?this.grid.sortOrders.map((({path:e,direction:t})=>({fieldName:e,direction:t}))).filter((e=>e.fieldName&&e.direction)):[]}get attachmentsEnabled(){return this.store.attachmentsEnabled}set attachmentsEnabled(e){this.store.attachmentsEnabled=e}get clearPrompt(){return()=>this.prompt=null}set clearPrompt(e){this._overrideIfSome("clearPrompt",e)}get filterGeometry(){return this.store.filterGeometry}set filterGeometry(e){this.store.filterGeometry=e}get filterBySelectionEnabled(){return!!this._get("filterBySelectionEnabled")}set filterBySelectionEnabled(e){const{objectIds:t}=this,i=t.length;e?(i&&(t.removeAll(),this._logWarning("Selection filter has been applied with an objectID filter. Object ID filter has been removed.")),this.filterGeometry&&this._logWarning("Selection filter has been applied with a geometry filter. Results may appear inconsistent"),this._syncObjectIdsWithStore(this.highlightIds.toArray())):i||this._syncObjectIdsWithStore(null),this._set("filterBySelectionEnabled",e)}get hiddenFields(){return this._get("hiddenFields")??new i}set hiddenFields(e){this._set("hiddenFields",s(e,this._get("hiddenFields"),i))}get initialSize(){return this.store.initialSize}set initialSize(e){this.store.initialSize=e}get isQueryingOrSyncing(){const{store:e}=this;return e?.syncing||e?.querying||this.relatedTables.some((e=>!!e.isQueryingOrSyncing))}get isSyncingAttachments(){return this.store.syncingAttachmentEdits||this.relatedTables.some((e=>!!e.isSyncingAttachments))}get layer(){return this._get("layer")}set layer(e){this.drainRelatedTables(),this._set("layer",e)}get layerView(){return this.store.layerView}get outFields(){return this.store.outFields}set outFields(e){this.store.outFields=e}get relatedRecordsEnabled(){return this.store.relatedRecordsEnabled}set relatedRecordsEnabled(e){this.store.relatedRecordsEnabled=e}get relatedTable(){return this.relatedTables.at(-1)}get relationship(){const e=this.relationshipConfig?.relationshipId;return null==e?null:this.relationships?.find((({id:t})=>t===e))}get relationshipConfig(){return this.store.relationshipConfig}set relationshipConfig(e){this.highlightIds.removeAll(),this.objectIds.removeAll(),this.filterBySelectionEnabled=!1,this.store.relationshipConfig=e}get relationships(){return this.store.relationships}get returnGeometryEnabled(){return this.store.returnGeometry}set returnGeometryEnabled(e){this.store.returnGeometry=e}get returnMEnabled(){return this.store.returnM}set returnMEnabled(e){this.store.returnM=e}get returnZEnabled(){return this.store.returnZ}set returnZEnabled(e){this.store.returnZ=e}get showAllRelatedTables(){return this._get("showAllRelatedTables")}set showAllRelatedTables(e){const{relatedTable:t}=this;this._set("showAllRelatedTables",e),t&&(e?this._showAllRelatedTables(t):this._hideAllRelatedTables(t))}get showPrompt(){return e=>{this.prompt?.cancel?.(),this.prompt=e}}set showPrompt(e){this._overrideIfSome("showPrompt",e)}get supportsAttachments(){return this.store.supportsAttachments}get supportsAddAttachments(){const{store:{supportsAddingAttachments:e,supportsEditing:t}}=this;return this.editingEnabled&&t&&e}get supportsDeleteAttachments(){const{store:{supportsDeletingAttachments:e,supportsEditing:t}}=this;return this.editingEnabled&&t&&e}get supportsResizeAttachments(){return this.store.supportsResizeAttachments}get supportsUpdateAttachments(){const{store:{supportsUpdateAttachments:e,supportsEditing:t}}=this;return this.editingEnabled&&t&&e}get timeExtent(){return this.store.timeExtent}set timeExtent(e){this.store.timeExtent=e}get timeZone(){return this._get("timeZone")}set timeZone(e){this.allColumns.forEach((t=>t.tableTimeZone=e)),this._set("timeZone",e)}get view(){return this.store.view}set view(e){this.store.view=e,this.fieldColumns.forEach((t=>t.view=e)),this.refreshCellContent()}async addAttachment(e,t){const{attachmentsViewOptions:i,store:s}=this,l=i.objectId===e;await s.addAttachment(e,t).catch((e=>{l&&e&&"object"==typeof e&&"error"in e&&e.error instanceof o&&(this._logWarning(`Unable to add attachment. ${e.error.name} ${e.error.message}`),i.error=e.error)})),l&&!i.error&&(i.onEditComplete(),i.attachmentInfos=await s.getAttachmentsByObjectId(e,!0)),this.refreshCellContent()}async deleteAttachments(e,t){const{attachmentsViewOptions:i,store:s}=this,l=i.objectId===e;await s.deleteAttachments(e,t).catch((e=>{l&&e&&"object"==typeof e&&"error"in e&&e.error instanceof o&&(this._logWarning(`Unable to delete attachment(s). ${e.error.name} ${e.error.message}`),i.error=e.error)})),l&&!i.error&&(i.onEditComplete(),i.attachmentInfos=await s.getAttachmentsByObjectId(e,!0)),this.refreshCellContent()}collapseRelatedTable(e,t){const{relatedLayer:s,objectId:l,relationshipId:o}=t,{objectIdField:n}=s,a=G(s,o),r=s.displayField||a?.keyField||n;e.set({highlightIds:new i([l]),multipleSelectionEnabled:!1,tableTemplateOverride:this._getTableTemplateForRelatedTableView(e,r,o)});const h=e.hiddenFields;h.includes(k.action)||h.add(k.action),h.includes(k.attachments)||h.add(k.attachments),e.scrollLeft()}async deleteSelection(){const e=this.highlightIds.toArray();if(!e?.length)return;const{deleteFeatureResults:t}=await this.store.deleteRowsByObjectId(e),i=t.filter((e=>!e.error)).map((e=>e.objectId));i.length&&(this.highlightIds.removeMany(i),await this.refresh())}async downloadAttachmentById(e,t){const i=(await this.store.getAttachmentsByObjectId(e,!0)).find((e=>e.id===t));P(i)}drainRelatedTables(){this.relatedTables.drain((e=>e.destroy())),this.set({multipleSelectionEnabled:!0,relationshipColumnConfigs:null,showAllRelatedTables:!1,tableTemplateOverride:null}),this.hiddenFields.removeMany([k.action,k.attachments])}drainRelatedTablesAboveIndex(e){const{relatedTables:t}=this,i=t.slice(e+1);t.removeMany(i).forEach((e=>e.destroy()));const s=t.at(-1);s&&(s.attachmentsViewOptions.objectId=null,this.allRelatedTablesVisible?this._showAllRelatedTables(s):this._hideAllRelatedTables(s))}async exportSelectionToCSV(e){const{highlightIds:t,layer:i,outFields:s}=this;i&&t.length?await W({layer:i,objectIds:t.toArray(),outFields:s,includeGeometry:e}):this._logWarning("Export failed.")}filterBySelection(){this.filterBySelectionEnabled?this._logWarning("Property 'filterBySelectionEnabled' is already 'true'. This method has no effect."):(l(a.getLogger(this),"`FeatureTable.filterBySelection` is deprecated in favor of 'filterBySelectionEnabled' and 'objectIds'",{replacement:"FeatureTable.filterBySelectionEnabled or FeatureTable.objectIds",version:"4.30",warnOnce:!0}),this.objectIds.addMany(this.highlightIds.toArray()))}getObjectIdIndex(e){return this.store.getItemIndexByObjectId(e)}getValue(e,t){const i=this.store.getItemByObjectId(e);return i?.feature?.attributes[t]}getVirtualPageIndex(){return this.grid?.getVirtualPageIndex()??0}goToPage(e){if(null==e||!Number.isInteger(e))return void this._logWarning("Invalid 'page' parameter provided to 'goToPage()'. Current page will remain the same.");const{pageCount:t}=this;(e>=t||-1===e)&&(e=t-1),e<-1&&(e=0),e!==this.pageIndex&&(this.pageIndex=e),this.paginationEnabled||this.scrollToIndex(e*this.pageSize)}hideAttachmentsView(){this.attachmentsViewOptions.objectId=null,this.set({relationshipColumnConfigs:null,multipleSelectionEnabled:!0,tableTemplateOverride:null}),this.hiddenFields.remove(k.action)}nextPage(){const e=this.paginationEnabled?this.pageIndex:this.getVirtualPageIndex();this.goToPage(e+1)}previousPage(){const e=this.paginationEnabled?this.pageIndex:this.getVirtualPageIndex();this.goToPage(e-1)}async refresh(){return this.relatedTables.forEach((async e=>await e.refresh())),h(this._debounceRefresh())}refreshCellContent(){this.grid?.requestContentUpdate()}refreshPageCache(){this.grid?.refreshPageCache()}async reset(){this.goToPage(0),await(this.grid?.reset())}scrollLeft(){this.grid?.scrollLeft(0)}scrollToBottom(){this.grid?.scrollToBottom()}scrollToIndex(e){this.grid?.scrollToIndex(e)}scrollToRow(e){const t=this.store.getItemIndexByObjectId(e);t>-1?this.grid?.scrollToIndex(t):this._logWarning("Row not found. Associated data may not be loaded yet.")}scrollToTop(){this.grid?.scrollToTop()}async saveAttachmentsViewForm(){const{attachmentId:e,form:t,objectId:i}=this.attachmentsViewOptions;null!=i&&t&&(null!=e?await this.updateAttachment(i,e,t):await this.addAttachment(i,t))}async showAttachmentsView({objectId:e}){const{attachmentsViewOptions:t,hiddenFields:s,layer:l}=this;if(!this.attachmentsEnabled||!l)return void this._logWarning("The 'attachmentsEnabled' property is currently false.");await l.load();const o=l.displayField||l.objectIdField,n=await this.store.getAttachmentsByObjectId(e,!0),a=this.store.getItemIndexByObjectId(e);t.set({attachmentInfos:n,mode:n.length?"list":"file",objectId:e}),this.set({highlightIds:new i([e]),multipleSelectionEnabled:!1,relationshipColumnConfigs:[],tableTemplateOverride:this._getTableTemplateForAttachmentsView(o)}),s.includes(k.action)||s.add(k.action),null!=a&&this.scrollToIndex(a)}clearSelectionFilter(){l(a.getLogger(this),"`FeatureTable.clearSelectionFilter` is deprecated in favor of 'filterBySelectionEnabled' and 'objectIds'",{replacement:"FeatureTable.filterBySelectionEnabled or FeatureTable.objectIds",version:"4.30",warnOnce:!0}),this.objectIds.removeAll()}async updateAttachment(e,t,i){const{attachmentsViewOptions:s,store:l}=this,n=s.objectId===e;await l.updateAttachment(e,t,i).catch((e=>{n&&e&&"object"==typeof e&&"error"in e&&e.error instanceof o&&(this._logWarning(`Unable to update attachment. ${e.error.name} ${e.error.message}`),s.error=e.error)})),n&&!s.error&&(s.onEditComplete(),s.attachmentInfos=await l.getAttachmentsByObjectId(e,!0)),this.refreshCellContent()}async zoomToSelection(){const{layer:e,view:t}=this,i=this.highlightIds.toArray();if(!e||!t||!i.length)return;const s=e.createQuery();s.objectIds=i,s.returnGeometry=!0;const l=await e.queryFeatures(s);try{await t.goTo(l.features)}catch(o){"AbortError"!==o.name&&console.error(o)}}async _refresh(){await this.store.refresh();const e=this.highlightIds.toArray();if(e.length){(await this.store.verifyFeaturesByObjectId(e)).forEach(((t,i)=>{t||this.highlightIds.remove(e[i])}))}this.refreshPageCache();const t=this.attachmentsViewOptions;null!=t?.objectId&&(t.attachmentInfos=await this.store.getAttachmentsByObjectId(t.objectId,!0))}async _onLayerLoad(){const{layer:e,pageSize:t}=this;if(!e)return;e.parent&&y(e.parent)&&await e.parent.loadAll();const i=e.capabilities.query?.maxRecordCount,s=i&&i<t,l=s?i:t;s&&(this._logWarning("The value for 'pageSize' has been adjusted due to the provided layer's max record count."),this.pageSize=l),this.grid?.set("pageSize",l),this.store.load(),this._generateColumns()}_onLayerRefresh(e){this.autoRefreshEnabled&&e.dataChanged&&this.refresh()}_generateColumns(){this._drainColumns();const{_effectiveTableTemplate:e,_effectiveAttributeTableTemplate:t}=this,i=e?.columnTemplates,s=this._generateColumnsFromColumnTemplates(i)??this._generateColumnsFromAttributeTableTemplate(t)??this._generateDefaultFieldColumns();s.length&&(this.attachmentsEnabled&&!s.some((e=>O(e)))&&s.push(this._generateDefaultAttachmentsColumn()),this.relatedRecordsEnabled&&this._relationshipInfos.length&&!s.some((e=>V(e)))&&s.push(...this._generateDefaultRelationshipColumns()),this.actionColumnConfig&&s.push(this._generateActionColumn()),s.sort(((e,t)=>e.frozen&&t.frozen||e.frozenToEnd&&t.frozenToEnd?0:e.frozen||t.frozenToEnd?-1:0)),this.columns.addMany(s))}_generateColumnsFromAttributeTableTemplate(e){const{layer:i}=this;if(!e||!i)return null;const{elements:s,orderByFields:l}=e,o=w(i),n=[];n.push(...this._generateColumnsFromAttributeTableElements(s,l));const a=o.map((e=>{if(!e.fieldName||N(e.fieldName,n))return null;const{fieldName:t}=e,s=M(i,t);return s?this._generateDefaultFieldColumn(s,{hidden:!0,orderByFields:l}):(this._logTemplateWarning("A valid 'field' could not be found for the provided template."),null)})).filter(t);return n.push(...a),this.attachmentsEnabled&&H(i)&&!n.some((e=>O(e)))&&n.push(this._generateDefaultAttachmentsColumn({hidden:!0})),this.relatedRecordsEnabled&&$(i)&&i.relationships?.forEach((({id:e},t)=>{const i=this._relationshipInfos.find((t=>t.relationshipId===e));i&&!n.some((t=>V(t)&&t.relationshipId===e))&&n.push(this._generateDefaultRelationshipColumn({hidden:!0,info:i,index:t}))})),n.length?n:null}_generateColumnsFromAttributeTableElements(e,t){const{layer:i}=this;return i?e?.map(((e,i)=>{switch(e.type){case"field":return this._createFieldColumnFromElement({element:e,orderByFields:t});case"group":return this._createGroupColumnFromElement({element:e,orderByFields:t});case"attachment":return this._createAttachmentColumnFromElement({element:e,index:i});case"relationship":return this._createRelationshipColumnFromElement({element:e,index:i})}})).filter((e=>!!e))??[]:[]}_createFieldColumnFromElement(e){const{layer:t}=this;if(!t)return null;const{element:i,orderByFields:s}=e,{fieldName:l}=i;if(null==l)return this._logTemplateWarning("A valid 'fieldName' must be provided."),null;const o=M(t,l);if(!o)return this._logTemplateWarning("A valid 'field' could not be found for the provided template."),null;const{description:n,label:a}=i,r=s?.findIndex((({field:e})=>e&&e===l))??-1,h=r>-1?s?.at(r)?.order:void 0,d=r>-1?r:null,{editingEnabled:m,grid:c,messages:p,messagesCommon:u,messagesURIUtils:g,store:b,timeZone:f,view:y}=this;return new E({description:n,direction:h,field:o,fieldName:l,grid:c,initialSortPriority:d,label:a,layer:t,messages:p,messagesCommon:u,messagesURIUtils:g,store:b,tableEditingEnabled:m,tableTimeZone:f,view:y,onShowPromptCallback:this._onShowPromptCallback})}_createGroupColumnFromElement(e){const{element:t,orderByFields:i}=e,{description:s,label:l}=t;if(!l)return this._logTemplateWarning("Group columns require a label."),null;if(!t.elements.length)return this._logTemplateWarning("Group columns require child columns."),null;const{grid:o,messages:n,messagesCommon:a,messagesURIUtils:r,store:h,timeZone:d}=this;return new R({columns:this._generateColumnsFromAttributeTableElements(t.elements,i),description:s,grid:o,label:l,messages:n,messagesCommon:a,messagesURIUtils:r,store:h,tableTimeZone:d})}_createAttachmentColumnFromElement(e){if(!this.attachmentsEnabled)return void this._logTemplateWarning("The 'attachmentsEnabled' property is currently false.");const{element:t,index:i}=e,{description:s,label:l}=t,{grid:o,layer:n,messages:a,messagesCommon:r,messagesURIUtils:h,store:d,timeZone:m}=this;return new v({description:s,fieldName:`${k.attachments}-${i}`,grid:o,label:l,layer:n,messages:a,messagesCommon:r,messagesURIUtils:h,store:d,tableTimeZone:m,onShowAttachments:e=>this._onShowAttachments(e)})}_createRelationshipColumnFromElement(e){if(!this.relatedRecordsEnabled)return void this._logTemplateWarning("Relationship columns require related records to be enabled on the table.");const{element:t,index:i}=e,{description:s,label:l,relationshipId:o}=t,n=this._relationshipInfos.find((e=>e.relationshipId===o));if(!n)return this._logTemplateWarning("Unable to find valid related layer target based on the provided relationship id."),null;const{grid:a,messages:r,messagesCommon:h,messagesURIUtils:d,store:m,timeZone:c}=this;return new A({description:s,fieldName:`${k.relationship}-${o}-${i}`,grid:a,label:l,messages:r,messagesCommon:h,messagesURIUtils:d,relationshipId:o,store:m,tableTimeZone:c,layer:n.relatedLayer,relatedLayer:n.layer,showRelatedTableCallback:e=>this._onShowRelatedTable(e)})}_generateColumnsFromColumnTemplates(e){const{editingEnabled:t,grid:i,layer:s,messages:l,messagesCommon:o,messagesURIUtils:n,store:a,timeZone:r,view:h}=this;if(!e?.length||!s)return null;const d=[];return e.forEach(((e,m)=>{const{autoWidth:c,description:p,direction:u,flexGrow:g,fieldName:b,formatFunction:f,frozen:y,frozenToEnd:w,icon:T,initialSortPriority:_,invalid:I,label:C,menuConfig:v,resizable:A,sortable:j,textAlign:S,textWrap:x,timeZone:U,type:O,width:V}=e;if(!O)return void this._logTemplateWarning("Property 'type' is missing from the provided template.");if(y&&w)return void this._logTemplateWarning("Properties 'frozen' and 'frozenToEnd' cannot both be true for the same column.");const P=!1===e.visible;if("group"===O){if(!e.columnTemplates?.length)return void this._logTemplateWarning("Group columns must contain column templates.");if(!e.label)return void this._logTemplateWarning("Group columns require a label.");const t=this._generateColumnsFromColumnTemplates(e.columnTemplates),s=P||this._isFieldHidden(e.label);d.push(new R({autoWidth:c,columns:t,description:p,flexGrow:g,frozen:y,frozenToEnd:w,grid:i,hidden:s,icon:T,invalid:I,label:C,menuConfig:v,messages:l,messagesCommon:o,messagesURIUtils:n,resizable:A,tableTimeZone:r,textAlign:S,textWrap:x,timeZone:U,width:V}))}else if("attachment"===O){if(!this.attachmentsEnabled)return void this._logTemplateWarning("Attachment columns require attachments to be enabled on the table.");d.push(this._generateAttachmentsColumnFromTemplate(e,m))}else if("relationship"===O){if(!this.relatedRecordsEnabled)return void this._logTemplateWarning("Relationship columns require related records to be enabled on the table.");const{relationshipId:t}=e;if(null==t)return void this._logTemplateWarning("Property 'relationshipId' is missing from the provided template.");const i=this._relationshipInfos.find((e=>e.relationshipId===t));if(!i)return void this._logTemplateWarning("Unable to find valid related layer target based on the provided relationship id.");d.push(this._generateRelationshipColumnFromTemplate(i,e,m))}else if(!b)return void this._logTemplateWarning("Value for 'fieldName' property was missing from the provided template.");const W=P||this._isFieldHidden(b);if("column"===O)d.push(new F({autoWidth:c,description:p,direction:u,fieldName:b,flexGrow:g,formatFunction:f,frozen:y,frozenToEnd:w,grid:i,hidden:W,icon:T,initialSortPriority:_,invalid:I,label:C,menuConfig:v,messages:l,messagesCommon:o,messagesURIUtils:n,resizable:A,sortable:j,tableTimeZone:r,textAlign:S,textWrap:x,timeZone:U,width:V}));else if("field"===O){const m=M(s,e.fieldName);if(!m)return void this._logTemplateWarning("A valid 'field' could not be found for the provided template.");const{editable:b,required:F}=e;d.push(new E({autoWidth:c,description:p,direction:u,editable:b,field:m,fieldName:m.name,flexGrow:g,formatFunction:f,frozen:y,frozenToEnd:w,grid:i,hidden:W,icon:T,initialSortPriority:_,invalid:I,label:C,layer:s,messages:l,messagesCommon:o,messagesURIUtils:n,menuConfig:v,required:F,resizable:A,sortable:j,store:a,tableEditingEnabled:t,tableTimeZone:r,template:e,textAlign:S,textWrap:x,timeZone:U,width:V,view:h,onShowPromptCallback:this._onShowPromptCallback}))}})),d.length?d:null}_generateDefaultFieldColumns(){return this.layer?.fields?.map((e=>this._generateDefaultFieldColumn(e))).filter(t)??[]}_generateDefaultFieldColumn(e,t){const{editingEnabled:i,grid:s,layer:l,messages:o,messagesCommon:n,messagesURIUtils:a,store:r,timeZone:h,view:d}=this,m=t?.orderByFields;if(!e.visible||"geometry"===e.type)return null;const c=e.name,p=m?.findIndex((e=>e.field&&e.field===c)),u=null!=p?m?.at(p)?.order:null,g=null!=p&&p>-1?p:void 0;return new E({direction:u,field:e,fieldName:c,grid:s,hidden:t?.hidden||this._isFieldHidden(c),initialSortPriority:g,layer:l,messages:o,messagesCommon:n,messagesURIUtils:a,store:r,tableEditingEnabled:i,tableTimeZone:h,view:d,onShowPromptCallback:this._onShowPromptCallback})}_generateAttachmentsColumnFromTemplate(e,t){const{grid:i,layer:s,messages:l,messagesCommon:o,messagesURIUtils:n,store:a,timeZone:r}=this,{attachmentsViewEnabled:h,autoWidth:d,description:m,flexGrow:c,fieldName:p,formatFunction:u,frozen:g,frozenToEnd:b,icon:f,invalid:y,label:w,menuConfig:T,resizable:_,textAlign:I,textWrap:C,thumbnailAppearance:E,thumbnailCount:A,thumbnailIconScale:F,thumbnailsEnabled:j,timeZone:S,width:R}=e;return new v({attachmentsViewEnabled:h,autoWidth:d,description:m,fieldName:`${k.attachments}-${t}`,flexGrow:c,formatFunction:u,frozen:g,frozenToEnd:b,grid:i,hidden:!1===e.visible||this._isFieldHidden(w)||this._isFieldHidden(p),icon:f,invalid:y,label:w,layer:s,menuConfig:T,messages:l,messagesCommon:o,messagesURIUtils:n,resizable:_,store:a,tableTimeZone:r,textAlign:I,textWrap:C,thumbnailAppearance:E,thumbnailCount:A,thumbnailIconScale:F,thumbnailsEnabled:j,timeZone:S,width:R,onShowAttachments:e=>this._onShowAttachments(e)})}_generateDefaultAttachmentsColumn(e){const{grid:t,layer:i,messages:s,messagesCommon:l,messagesURIUtils:o,store:n,timeZone:a}=this,r=k.attachments;return new v({fieldName:r,grid:t,hidden:e?.hidden||this._isFieldHidden(r),layer:i,messages:s,messagesCommon:l,messagesURIUtils:o,store:n,tableTimeZone:a,onShowAttachments:e=>this._onShowAttachments(e)})}_generateRelationshipColumnFromTemplate(e,t,i){const{grid:s,messages:l,messagesCommon:o,messagesURIUtils:n,store:a,timeZone:r}=this,{autoWidth:h,collapsed:d,description:m,flexGrow:c,fieldName:p,formatFunction:u,frozen:g,frozenToEnd:b,icon:f,invalid:y,label:w,menuConfig:T,relationshipId:_,resizable:I,textAlign:C,textWrap:v,timeZone:E,width:F}=t;return new A({autoWidth:h,collapsed:d,description:m,fieldName:`${k.relationship}-${_}-${i}`,flexGrow:c,formatFunction:u,frozen:g,frozenToEnd:b,grid:s,hidden:!1===t.visible||this._isFieldHidden(w)||this._isFieldHidden(p),icon:f,invalid:y,label:w,menuConfig:T,messages:l,messagesCommon:o,messagesURIUtils:n,relationshipId:_,resizable:I,store:a,tableTimeZone:r,textAlign:C,textWrap:v,timeZone:E,width:F,layer:e.relatedLayer,relatedLayer:e.layer,showRelatedTableCallback:e=>this._onShowRelatedTable(e)})}_generateDefaultRelationshipColumns(){const{_relationshipInfos:e,relationshipColumnConfigs:t}=this,i=[];return e?.length?(t?t.forEach(((t,s)=>{const{relationshipId:l}=t,o=e.find((e=>e.relationshipId===l));o&&i.push(this._generateDefaultRelationshipColumn({config:t,index:s,info:o}))})):e.forEach(((e,t)=>i.push(this._generateDefaultRelationshipColumn({index:t,info:e})))),i):i}_generateDefaultRelationshipColumn(e){const{config:t,hidden:i,index:s,info:l}=e,{grid:o,messages:n,messagesCommon:a,messagesURIUtils:r}=this,{relationshipId:h}=l;return new A({...t,fieldName:`${k.relationship}-${h}-${s}`,grid:o,hidden:i,messages:n,messagesCommon:a,messagesURIUtils:r,layer:l.relatedLayer,relatedLayer:l.layer,relationshipId:h,showRelatedTableCallback:e=>this._onShowRelatedTable(e)})}_generateActionColumn(){return new C({hidden:this._isFieldHidden(k.action),...this.actionColumnConfig})}_isFieldHidden(e){const t=e?.toLowerCase();return(this.hiddenFields??this._defaultHiddenFields).some((e=>e.toLowerCase()===t))}_addTableHighlight(e){const{_highlightableLayerView:t,layer:i}=this;if(t&&i){const s=this.store.getItemByObjectId(e),l=s?.feature??e;this._highlights.add(t.highlight(l),`${i.id}-${e}`)}}_removeTableHighlight(e){const{layer:t}=this;t&&this._highlights.remove(`${t.id}-${e}`)}_syncSelection(){this._highlights.removeAll(),this._tableHighlightsReady?this.highlightIds.forEach((e=>this._addTableHighlight(e))):this._viewSelectionReady&&(this.highlightIds.items=this._viewSelection)}_appendToViewSelection(e){const{_selectableLayer:t}=this;t&&this._selectionManager?.appendToSelection(t,e)}_removeFromViewSelection(e){const{_selectableLayer:t}=this;t&&this._selectionManager?.removeFromSelection(t,e)}async _onHighlightIdsChange(e){const{added:t,removed:i}=e,{attachmentsViewOptions:s}=this;if(this._tableHighlightsReady?(i.forEach((e=>this._removeTableHighlight(e))),t.forEach((e=>this._addTableHighlight(e)))):this._viewSelectionReady&&(this._removeFromViewSelection(i),this._appendToViewSelection(t)),this.filterBySelectionEnabled&&this._syncObjectIdsWithStore(this.highlightIds.toArray()),null!=s.objectId){const e=this.highlightIds.at(0);if(null!=e){const t=await this.store.getAttachmentsByObjectId(e,!0);s.set({attachmentInfos:t,objectId:e,mode:t.length?"list":"file"})}}}_onShowRelatedTable(e){const{highlightIds:t}=this,{objectId:i}=e;t.removeAll(),t.add(i),this.showRelatedTableCallback?this.showRelatedTableCallback(e):this.emit("show-related-table",e)}_onObjectIdsChange(){const e=this.objectIds.toArray();e.length&&this.filterBySelectionEnabled&&(this.filterBySelectionEnabled=!1,this._logWarning("Object ID filter was applied while a selection filter was applied. Selection filter has been removed.")),this._syncObjectIdsWithStore(e)}_syncObjectIdsWithStore(e){this.store.objectIds=e,this.refreshPageCache()}_drainColumns(){this.columns.drain((e=>!e.destroyed&&e.destroy()))}_showAllRelatedTables(e){const t=e.layer;if(!t)return;const i=t.displayField||t.objectIdField;e.set({relationshipColumnConfigs:[],tableTemplateOverride:this._getTableTemplateForShowAllTablesView(e,i)});const s=e.hiddenFields;s.includes(k.action)||s.add(k.action),s.includes(k.attachments)||s.add(k.attachments)}_hideAllRelatedTables(e){const{layer:t,relationship:i}=e;if(t&&null!=i?.id)if(null!=e.attachmentsViewOptions.objectId){const t=e.layer?.displayField||e.layer?.objectIdField||"";e.set({multipleSelectionEnabled:!1,relationshipColumnConfigs:[],showAllRelatedTables:!1,tableTemplateOverride:this._getTableTemplateForAttachmentsView(t)})}else e.set({multipleSelectionEnabled:!0,relationshipColumnConfigs:D(t,i.id),showAllRelatedTables:!1,tableTemplateOverride:null}),e.hiddenFields.removeMany([k.action,k.attachments])}_getTableTemplateForRelatedTableView(e,t,i){return new Z({columnTemplates:[new B({fieldName:t,editable:!1,menuConfig:{selectionMode:"single",icon:"chevron-down",items:this._extractFieldColumnInfosFromTableTemplate(e.viewModel).map((([s,l])=>({selected:s===t,label:l||s,clickFunction:()=>{e.tableTemplateOverride=this._getTableTemplateForRelatedTableView(e,s,i)}})))},resizable:!1}),new L({autoWidth:!1,collapsed:!0,flexGrow:0,label:"",resizable:!1,relationshipId:i,width:X})]})}_getTableTemplateForShowAllTablesView(e,t){const i=[new B({fieldName:t,editable:!1,menuConfig:{selectionMode:"single",icon:"chevron-down",items:this._extractFieldColumnInfosFromTableTemplate(e.viewModel).map((([i,s])=>({selected:i===t,label:s||i,clickFunction:()=>{e.tableTemplateOverride=this._getTableTemplateForShowAllTablesView(e,i)}})))},resizable:!1})];return null!=e.attachmentsViewOptions.objectId&&i.push(new x({attachmentsViewEnabled:!1,autoWidth:!1,flexGrow:0,label:"",resizable:!1,thumbnailsEnabled:!1,width:X})),new Z({columnTemplates:i})}async _onShowPromptCallback(e){const{column:t,objectId:i,oldValue:s,value:l}=e,{_subtypes:o,layer:n}=this;if(!n||!o.length)return void t.cancel();const a=o.find((e=>e.code===l));if(!a)return void t.cancel();const r=d(),h=this._createSubtypeEditPrompt(s,a,r),m=!!n.parent;try{this.showPrompt(h);const e=await r.promise,s=[{fieldName:t.fieldName,value:l}];switch(e){case"update-fields":for(const[e,t]of Object.entries(a.defaultValues))null!=t&&s.push({fieldName:e,value:t});await t.updateItems({objectId:i,updates:s}),m&&this.refresh();break;case"keep-existing":await t.updateItems({objectId:i,updates:s}),m&&this.refresh();break;case"undo":t.cancel()}}finally{this.clearPrompt()}}_createSubtypeEditPrompt(e,t,i){const{_subtypes:s,messages:l,messagesCommon:o}=this,n=s.find((t=>t.code===e))?.name??`${e}`;let a="update-fields";const r=[{label:l.subtypes.useDefaultValuesOption,value:"update-fields"},{label:l.subtypes.keepCurrentValuesOption,value:"keep-existing"}];return{context:"info",title:l.subtypes.changeWarningTitle,message:K(l.subtypes.changeWarning,{originalType:n,newType:t.name}),radios:r,defaultRadioSelection:"update-fields",onRadioSelection:e=>{a=e},actions:{primary:{label:o.apply,action:()=>i.resolve(a),type:"positive"},secondary:{label:o.cancel,type:"neutral",action:()=>i.resolve("undo")}},cancel:()=>i.reject()}}_onShowAttachments({objectId:e}){this.attachmentsViewOptions.objectId=e}_getTableTemplateForAttachmentsView(e){return new Z({columnTemplates:[new B({fieldName:e,editable:!1,menuConfig:{selectionMode:"single",icon:"chevron-down",items:this._extractFieldColumnInfosFromTableTemplate(this).map((([t,i])=>({selected:t===e,label:i||t,clickFunction:()=>{this.tableTemplateOverride=this._getTableTemplateForAttachmentsView(t)}})))},resizable:!1}),new x({attachmentsViewEnabled:!1,autoWidth:!1,flexGrow:0,label:"",resizable:!1,thumbnailsEnabled:!1,width:X})]})}_extractFieldColumnInfosFromTableTemplate(e){const t=e??this,{layer:i,tableTemplate:s}=t;return s?s.columnTemplates.filter((({type:e})=>"field"===e||"column"===e)).map((({fieldName:e,label:t})=>[e,t])):i?.fields.map((e=>[e.name,e.alias]))??[]}_getIndexOfFirstFrozenToEndColumn(){const e=this.columns.findIndex((e=>e.frozenToEnd));return e>-1?e:void 0}_logWarning(e,t){t?a.getLogger(this).warnOnce(e):a.getLogger(this).warn(e)}_logTemplateWarning(e){this._logWarning(`${e} Skipped generating a column using the provided template.`,!0)}_onCellInteraction(e){null!=e&&null!=this.attachmentsViewOptions.objectId&&this.highlightIds.add(e)}};e([u()],Y.prototype,"_defaultHiddenFields",null),e([u()],Y.prototype,"_effectiveTableTemplate",null),e([u()],Y.prototype,"_effectiveAttributeTableTemplate",null),e([u()],Y.prototype,"_highlights",void 0),e([u()],Y.prototype,"_highlightableLayerView",null),e([u()],Y.prototype,"_relationshipInfos",null),e([u()],Y.prototype,"_selectionManager",null),e([u()],Y.prototype,"_selectableLayer",null),e([u()],Y.prototype,"_subtypes",null),e([u()],Y.prototype,"_tableHighlightsReady",null),e([u()],Y.prototype,"_viewSelection",null),e([u()],Y.prototype,"_viewSelectionReady",null),e([u()],Y.prototype,"actionColumnConfig",void 0),e([u()],Y.prototype,"allRelatedTablesVisible",null),e([u()],Y.prototype,"activeFilters",null),e([u({readOnly:!0})],Y.prototype,"activeSortOrders",null),e([u()],Y.prototype,"attachmentsEnabled",null),e([u()],Y.prototype,"attachmentsViewOptions",void 0),e([u({type:T})],Y.prototype,"attributeTableTemplate",void 0),e([u()],Y.prototype,"autoRefreshEnabled",void 0),e([u()],Y.prototype,"clearPrompt",null),e([u({readOnly:!0})],Y.prototype,"columns",void 0),e([u()],Y.prototype,"dataProvider",void 0),e([u()],Y.prototype,"editingEnabled",void 0),e([u()],Y.prototype,"filterGeometry",null),e([u()],Y.prototype,"filterBySelectionEnabled",null),e([u({readOnly:!0})],Y.prototype,"grid",void 0),e([u()],Y.prototype,"hiddenFields",null),e([u()],Y.prototype,"highlightEnabled",void 0),e([u()],Y.prototype,"initialSize",null),e([u()],Y.prototype,"isQueryingOrSyncing",null),e([u()],Y.prototype,"isSyncingAttachments",null),e([u({readOnly:!0})],Y.prototype,"itemIdPath",void 0),e([u()],Y.prototype,"layer",null),e([u()],Y.prototype,"layerView",null),e([u()],Y.prototype,"messages",void 0),e([u(),q("esri/t9n/common")],Y.prototype,"messagesCommon",void 0),e([u(),q("esri/core/t9n/Units")],Y.prototype,"messagesUnits",void 0),e([u(),q("esri/widgets/support/t9n/uriUtils")],Y.prototype,"messagesURIUtils",void 0),e([u()],Y.prototype,"outFields",null),e([u()],Y.prototype,"prompt",void 0),e([u()],Y.prototype,"relatedRecordsEnabled",null),e([u()],Y.prototype,"relatedTable",null),e([u()],Y.prototype,"relatedTables",void 0),e([u()],Y.prototype,"relationship",null),e([u()],Y.prototype,"relationshipColumnConfigs",void 0),e([u()],Y.prototype,"relationshipConfig",null),e([u()],Y.prototype,"relationships",null),e([u()],Y.prototype,"returnGeometryEnabled",null),e([u()],Y.prototype,"returnMEnabled",null),e([u()],Y.prototype,"returnZEnabled",null),e([u()],Y.prototype,"selectionSource",void 0),e([u()],Y.prototype,"showAllRelatedTables",null),e([u()],Y.prototype,"showPrompt",null),e([u()],Y.prototype,"showRelatedTableCallback",void 0),e([u({readOnly:!0,type:z})],Y.prototype,"store",void 0),e([u()],Y.prototype,"supportsAttachments",null),e([u()],Y.prototype,"supportsAddAttachments",null),e([u()],Y.prototype,"supportsDeleteAttachments",null),e([u()],Y.prototype,"supportsResizeAttachments",null),e([u()],Y.prototype,"supportsUpdateAttachments",null),e([u()],Y.prototype,"tableController",void 0),e([u()],Y.prototype,"tableParent",void 0),e([u({type:Z})],Y.prototype,"tableTemplate",void 0),e([u()],Y.prototype,"tableTemplateOverride",void 0),e([u()],Y.prototype,"timeExtent",null),e([u()],Y.prototype,"timeZone",null),e([u()],Y.prototype,"view",null),Y=e([g("esri.widgets.FeatureTable.FeatureTableViewModel")],Y);const ee=Y;export{ee as default};
|
|
5
|
+
import{_ as e}from"../../chunks/tslib.es6.js";import"../../intl.js";import{isSome as t}from"../../core/arrayUtils.js";import i from"../../core/Collection.js";import{referenceSetter as s}from"../../core/collectionUtils.js";import{deprecatedFunction as l}from"../../core/deprecate.js";import o from"../../core/Error.js";import n from"../../core/Handles.js";import a from"../../core/Logger.js";import{debounce as r,ignoreAbortErrors as h,createResolver as d}from"../../core/promiseUtils.js";import{watch as m,initial as c,on as p}from"../../core/reactiveUtils.js";import{property as u}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import{subclass as g}from"../../core/accessorSupport/decorators/subclass.js";import{getLowerCaseDefaultHiddenFields as b}from"../../layers/support/fieldUtils.js";import{getSubtypesFromLayer as f,isSubtypeGroupLayer as y}from"../../layers/support/layerUtils.js";import{createFieldInfos as w}from"../../support/popupUtils.js";import T from"../../tables/AttributeTableTemplate.js";import{highlightsSupported as _}from"../../views/support/layerViewUtils.js";import{isSelectableLayer as I}from"../../views/support/selectionUtils.js";import C from"./ActionColumn.js";import v from"./AttachmentsColumn.js";import E from"./FieldColumn.js";import A from"./RelationshipColumn.js";import F from"./Grid/Column.js";import j from"./Grid/Grid.js";import S from"./Grid/GridViewModel.js";import R from"./Grid/GroupColumn.js";import x from"./support/AttachmentsColumnTemplate.js";import U from"./support/AttachmentsViewOptions.js";import{isAttachmentsColumn as O,isRelationshipColumn as V}from"./support/columnUtils.js";import{downloadAttachmentInfo as P,exportToCSV as W}from"./support/exportUtils.js";import z from"./support/FeatureStore.js";import B from"./support/FieldColumnTemplate.js";import L from"./support/RelationshipColumnTemplate.js";import Z from"./support/TableTemplate.js";import{findRelationship as G,uniqueColumnNames as k,hasColumnForField as N,findField as M,isIFeatureTableSupportedLayerWithAttachments as H,isIFeatureTableSupportedLayerWithRelationships as $,getRelationshipIdsToShow as D}from"./support/tableUtils.js";import"../support/widgetUtils.js";import{messageBundle as q}from"../support/decorators/messageBundle.js";import{onLocaleChange as Q}from"../../intl/locale.js";import{substitute as K}from"../../intl/substitute.js";import{fetchMessageBundle as J}from"../../intl/messages.js";const X="80px";let Y=class extends S{constructor(e){super(e),this._debounceRefresh=r((()=>this._refresh())),this._highlights=new n,this.actionColumnConfig=null,this.attachmentsViewOptions=new U,this.attributeTableTemplate=null,this.autoRefreshEnabled=!0,this.columns=new i,this.dataProvider=async(e,t)=>{const{layer:i,store:s}=this;if(!t)return;if(!i||!s)return void(t&&t([]));await i.load();const{objectIds:l}=this;if(this.filterBySelectionEnabled&&!this.highlightIds.length||1===l.length&&-1===l.items[0])return void t([]);"loaded"!==s.state&&"loading"!==s.state&&await s.load();const o=this.paginationEnabled?this.pageIndex:e.page,n=await s.fetchItems({...e,page:o});t&&t(n)},this.editingEnabled=!1,this.grid=null,this.highlightEnabled=!0,this.itemIdPath="objectId",this.messages=null,this.messagesCommon=null,this.messagesUnits=null,this.messagesURIUtils=null,this.prompt=null,this.relatedTables=new i,this.relationshipColumnConfigs=null,this.selectionSource="table",this.showRelatedTableCallback=null,this.store=null,this.tableController=null,this.tableParent=null,this.tableTemplate=null,this.tableTemplateOverride=null,this._onLayerRefresh=this._onLayerRefresh.bind(this),this._onShowPromptCallback=this._onShowPromptCallback.bind(this),this._set("store",new z),this._set("grid",new j({itemIdPath:this.itemIdPath,viewModel:this}))}initialize(){const e=async()=>{this.messages=await J("esri/widgets/FeatureTable/t9n/FeatureTable"),this.messagesCommon=await J("esri/t9n/common"),this.messagesUnits=await J("esri/core/t9n/Units"),this.messagesURIUtils=await J("esri/widgets/support/t9n/uriUtils")};e(),this.addHandles([Q((()=>{e(),this._generateColumns()})),m((()=>[this.messages,this.messagesCommon,this.messagesURIUtils]),(()=>{const e=this.messages;this.grid&&(this.grid.messages=e),this.allColumns.forEach((t=>{t.messages=e,t.messagesCommon=this.messagesCommon,t.messagesURIUtils=this.messagesURIUtils})),this.refreshCellContent()}),c),p((()=>this.highlightIds),"change",(e=>this._onHighlightIdsChange(e)),{onListenerAdd:()=>this._syncSelection(),onListenerRemove:()=>this._highlights.removeAll()}),m((()=>this.attachmentsEnabled),(()=>this.layer?.loaded&&this._generateColumns())),m((()=>this._viewSelection),(()=>{this._viewSelectionReady&&(this.highlightIds.items=this._viewSelection)})),m((()=>[this._tableHighlightsReady,this._viewSelectionReady]),(()=>this._syncSelection())),m((()=>this.layer),(async(e,t)=>{const i=this.grid;i&&(i.clearSort(),e&&t&&await this.reset()),this.goToPage(0),this._drainColumns(),this.store.layer=e,e&&(e.loaded?this._onLayerLoad():e.load().catch((()=>{})))})),m((()=>this.layer?.loaded),(e=>e&&this._onLayerLoad())),m((()=>this.store.state),(e=>{"loaded"===e&&(this.scrollToTop(),this.refreshCellContent())})),m((()=>this._effectiveTableTemplate),(()=>{this.scrollLeft(),this.layer?.loaded&&this._generateColumns()})),m((()=>this.editingEnabled),(e=>{this.editableColumns.forEach((t=>t.tableEditingEnabled=e)),this.refreshCellContent()})),m((()=>this.timeZone??this.view?.timeZone),(()=>this.refreshCellContent())),m((()=>this.layer?.definitionExpression),((e,t)=>(e||t)&&"loaded"===this.store.state&&this.reset())),m((()=>this.layer?.timeExtent),((e,t)=>(e||t)&&!this.timeExtent&&"loaded"===this.store.state&&this.reset())),p((()=>this.layer),"refresh",(e=>this._onLayerRefresh(e))),p((()=>this.grid),["cell-click","cell-dblclick","cell-pointerover","cell-pointerout","cell-keydown","column-reorder"],(({index:e,item:t,native:i,path:s,type:l})=>{const o=t?.feature,n=o?.getObjectId(),a="cell-keydown"===l&&i&&i instanceof KeyboardEvent&&"Enter"===i.key;this.emit(l,{feature:o,index:e,native:i,type:l,fieldName:s??void 0,objectId:n}),(a||"cell-click"===l)&&this._onCellInteraction(n)})),m((()=>this.actionColumnConfig),(e=>{const{actionColumn:t,columns:i}=this;t?e?t.set(e):i.remove(t):e&&i.length&&i.add(this._generateActionColumn(),!1!==e.frozenToEnd?void 0:this._getIndexOfFirstFrozenToEndColumn())})),m((()=>this.relatedRecordsEnabled),(()=>this.layer?.loaded&&this._generateColumns())),p((()=>this.objectIds),"change",(()=>this._onObjectIdsChange()),{onListenerAdd:()=>this._onObjectIdsChange()}),m((()=>[this.paginationEnabled,this.pageIndex]),(()=>this.refreshPageCache())),m((()=>this.activeSortOrders),(e=>this.store.sortOrders=e)),m((()=>this.pageCount),(()=>{this.pageIndex>=this.pageCount&&this.goToPage(0)})),m((()=>this.state),(e=>{"disabled"===e&&this.relatedTables.length&&this.drainRelatedTables()})),p((()=>this.tableParent?.highlightIds),"change",(({added:e})=>{const{relationshipConfig:t}=this,i=e[0];if(null==i||!t)return;const{relatedLayer:s,relationshipId:l}=t;this.relationshipConfig={objectId:i,relatedLayer:s,relationshipId:l}})),p((()=>this.tableParent),"cell-click",(e=>{const{tableParent:t}=this,{objectId:i}=e;t&&null!=i&&t.highlightIds.add(i)})),m((()=>this.attachmentsViewOptions.objectId),((e,t)=>{null!=e?null==t&&this.showAttachmentsView({objectId:e}):this.hideAttachmentsView()}))])}destroy(){this._drainColumns(),this._highlights.removeAll(),this._highlights.destroy(),this.grid?.destroy(),this.columns.destroyed||this.columns.destroy(),this.layer=null,this.view=null}get _defaultHiddenFields(){return b(this.layer)}get _effectiveTableTemplate(){return this.tableTemplateOverride||this.tableTemplate}get _effectiveAttributeTableTemplate(){return this.attributeTableTemplate||this.layer?.attributeTableTemplate}get _highlightableLayerView(){const e=this.layerView;return _(e)?e:null}get _relationshipInfos(){return this.store.relationshipInfos}get _selectionManager(){const{view:e}=this;return!e||e.destroyed?null:e.selectionManager?.sources?.length?e.selectionManager:null}get _selectableLayer(){const{layer:e}=this;return I(e)&&this._selectionManager?.sources.includes(e)?e:null}get _subtypes(){return f(this.layer)}get _tableHighlightsReady(){return!("table"!==this.selectionSource||!this.highlightEnabled||!this._highlightableLayerView)}get _viewSelection(){const{_selectableLayer:e}=this;return e?this._selectionManager?.getSelection(e)??[]:[]}get _viewSelectionReady(){return!(!this.layer||"view"!==this.selectionSource||!this._selectionManager)}get allRelatedTablesVisible(){return!!(this.relatedRecordsEnabled&&this.relatedTables.length&&this.showAllRelatedTables)}get activeFilters(){const{filterGeometry:e,objectIds:t,filterBySelectionEnabled:s,highlightIds:l}=this,o=new i;return e&&o.push({type:"geometry",geometry:e}),s?o.push({type:"selection",objectIds:l.toArray()}):t.length&&o.push({type:"objectId",objectIds:t.toArray()}),o}get activeSortOrders(){return this.grid?.sortOrders?this.grid.sortOrders.map((({path:e,direction:t})=>({fieldName:e,direction:t}))).filter((e=>e.fieldName&&e.direction)):[]}get attachmentsEnabled(){return this.store.attachmentsEnabled}set attachmentsEnabled(e){this.store.attachmentsEnabled=e}get clearPrompt(){return()=>this.prompt=null}set clearPrompt(e){this._overrideIfSome("clearPrompt",e)}get filterGeometry(){return this.store.filterGeometry}set filterGeometry(e){this.store.filterGeometry=e}get filterBySelectionEnabled(){return!!this._get("filterBySelectionEnabled")}set filterBySelectionEnabled(e){const{objectIds:t}=this,i=t.length;e?(i&&(t.removeAll(),this._logWarning("Selection filter has been applied with an objectID filter. Object ID filter has been removed.")),this.filterGeometry&&this._logWarning("Selection filter has been applied with a geometry filter. Results may appear inconsistent"),this._syncObjectIdsWithStore(this.highlightIds.toArray())):i||this._syncObjectIdsWithStore(null),this._set("filterBySelectionEnabled",e)}get hiddenFields(){return this._get("hiddenFields")??new i}set hiddenFields(e){this._set("hiddenFields",s(e,this._get("hiddenFields"),i))}get initialSize(){return this.store.initialSize}set initialSize(e){this.store.initialSize=e}get isQueryingOrSyncing(){const{store:e}=this;return e?.syncing||e?.querying||this.relatedTables.some((e=>!!e.isQueryingOrSyncing))}get isSyncingAttachments(){return this.store.syncingAttachmentEdits||this.relatedTables.some((e=>!!e.isSyncingAttachments))}get layer(){return this._get("layer")}set layer(e){this._highlights.removeAll(),this.drainRelatedTables(),this._set("layer",e)}get layerView(){return this.store.layerView}get outFields(){return this.store.outFields}set outFields(e){this.store.outFields=e}get relatedRecordsEnabled(){return this.store.relatedRecordsEnabled}set relatedRecordsEnabled(e){this.store.relatedRecordsEnabled=e}get relatedTable(){return this.relatedTables.at(-1)}get relationship(){const e=this.relationshipConfig?.relationshipId;return null==e?null:this.relationships?.find((({id:t})=>t===e))}get relationshipConfig(){return this.store.relationshipConfig}set relationshipConfig(e){this.highlightIds.removeAll(),this.objectIds.removeAll(),this.filterBySelectionEnabled=!1,this.store.relationshipConfig=e}get relationships(){return this.store.relationships}get returnGeometryEnabled(){return this.store.returnGeometry}set returnGeometryEnabled(e){this.store.returnGeometry=e}get returnMEnabled(){return this.store.returnM}set returnMEnabled(e){this.store.returnM=e}get returnZEnabled(){return this.store.returnZ}set returnZEnabled(e){this.store.returnZ=e}get showAllRelatedTables(){return this._get("showAllRelatedTables")}set showAllRelatedTables(e){const{relatedTable:t}=this;this._set("showAllRelatedTables",e),t&&(e?this._showAllRelatedTables(t):this._hideAllRelatedTables(t))}get showPrompt(){return e=>{this.prompt?.cancel?.(),this.prompt=e}}set showPrompt(e){this._overrideIfSome("showPrompt",e)}get supportsAttachments(){return this.store.supportsAttachments}get supportsAddAttachments(){const{store:{supportsAddingAttachments:e,supportsEditing:t}}=this;return this.editingEnabled&&t&&e}get supportsDeleteAttachments(){const{store:{supportsDeletingAttachments:e,supportsEditing:t}}=this;return this.editingEnabled&&t&&e}get supportsResizeAttachments(){return this.store.supportsResizeAttachments}get supportsUpdateAttachments(){const{store:{supportsUpdateAttachments:e,supportsEditing:t}}=this;return this.editingEnabled&&t&&e}get timeExtent(){return this.store.timeExtent}set timeExtent(e){this.store.timeExtent=e}get timeZone(){return this._get("timeZone")}set timeZone(e){this.allColumns.forEach((t=>t.tableTimeZone=e)),this._set("timeZone",e)}get view(){return this.store.view}set view(e){this.store.view=e,this.fieldColumns.forEach((t=>t.view=e)),this.refreshCellContent()}async addAttachment(e,t){const{attachmentsViewOptions:i,store:s}=this,l=i.objectId===e;await s.addAttachment(e,t).catch((e=>{l&&e&&"object"==typeof e&&"error"in e&&e.error instanceof o&&(this._logWarning(`Unable to add attachment. ${e.error.name} ${e.error.message}`),i.error=e.error)})),l&&!i.error&&(i.onEditComplete(),i.attachmentInfos=await s.getAttachmentsByObjectId(e,!0)),this.refreshCellContent()}async deleteAttachments(e,t){const{attachmentsViewOptions:i,store:s}=this,l=i.objectId===e;await s.deleteAttachments(e,t).catch((e=>{l&&e&&"object"==typeof e&&"error"in e&&e.error instanceof o&&(this._logWarning(`Unable to delete attachment(s). ${e.error.name} ${e.error.message}`),i.error=e.error)})),l&&!i.error&&(i.onEditComplete(),i.attachmentInfos=await s.getAttachmentsByObjectId(e,!0)),this.refreshCellContent()}collapseRelatedTable(e,t){const{relatedLayer:s,objectId:l,relationshipId:o}=t,{objectIdField:n}=s,a=G(s,o),r=s.displayField||a?.keyField||n;e.set({highlightIds:new i([l]),multipleSelectionEnabled:!1,tableTemplateOverride:this._getTableTemplateForRelatedTableView(e,r,o)});const h=e.hiddenFields;h.includes(k.action)||h.add(k.action),h.includes(k.attachments)||h.add(k.attachments),e.scrollLeft()}async deleteSelection(){const e=this.highlightIds.toArray();if(!e?.length)return;const{deleteFeatureResults:t}=await this.store.deleteRowsByObjectId(e),i=t.filter((e=>!e.error)).map((e=>e.objectId));i.length&&(this.highlightIds.removeMany(i),await this.refresh())}async downloadAttachmentById(e,t){const i=(await this.store.getAttachmentsByObjectId(e,!0)).find((e=>e.id===t));P(i)}drainRelatedTables(){this.relatedTables.drain((e=>e.destroy())),this.set({multipleSelectionEnabled:!0,relationshipColumnConfigs:null,showAllRelatedTables:!1,tableTemplateOverride:null}),this.hiddenFields.removeMany([k.action,k.attachments])}drainRelatedTablesAboveIndex(e){const{relatedTables:t}=this,i=t.slice(e+1);t.removeMany(i).forEach((e=>e.destroy()));const s=t.at(-1);s&&(s.attachmentsViewOptions.objectId=null,this.allRelatedTablesVisible?this._showAllRelatedTables(s):this._hideAllRelatedTables(s))}async exportSelectionToCSV(e){const{highlightIds:t,layer:i,outFields:s}=this;i&&t.length?await W({layer:i,objectIds:t.toArray(),outFields:s,includeGeometry:e}):this._logWarning("Export failed.")}filterBySelection(){this.filterBySelectionEnabled?this._logWarning("Property 'filterBySelectionEnabled' is already 'true'. This method has no effect."):(l(a.getLogger(this),"`FeatureTable.filterBySelection` is deprecated in favor of 'filterBySelectionEnabled' and 'objectIds'",{replacement:"FeatureTable.filterBySelectionEnabled or FeatureTable.objectIds",version:"4.30",warnOnce:!0}),this.objectIds.addMany(this.highlightIds.toArray()))}getObjectIdIndex(e){return this.store.getItemIndexByObjectId(e)}getValue(e,t){const i=this.store.getItemByObjectId(e);return i?.feature?.attributes[t]}getVirtualPageIndex(){return this.grid?.getVirtualPageIndex()??0}goToPage(e){if(null==e||!Number.isInteger(e))return void this._logWarning("Invalid 'page' parameter provided to 'goToPage()'. Current page will remain the same.");const{pageCount:t}=this;(e>=t||-1===e)&&(e=t-1),e<-1&&(e=0),e!==this.pageIndex&&(this.pageIndex=e),this.paginationEnabled||this.scrollToIndex(e*this.pageSize)}hideAttachmentsView(){this.attachmentsViewOptions.objectId=null,this.set({relationshipColumnConfigs:null,multipleSelectionEnabled:!0,tableTemplateOverride:null}),this.hiddenFields.remove(k.action)}nextPage(){const e=this.paginationEnabled?this.pageIndex:this.getVirtualPageIndex();this.goToPage(e+1)}previousPage(){const e=this.paginationEnabled?this.pageIndex:this.getVirtualPageIndex();this.goToPage(e-1)}async refresh(){return this.relatedTables.forEach((async e=>await e.refresh())),h(this._debounceRefresh())}refreshCellContent(){this.grid?.requestContentUpdate()}refreshPageCache(){this.grid?.refreshPageCache()}async reset(){this.goToPage(0),await(this.grid?.reset())}scrollLeft(){this.grid?.scrollLeft(0)}scrollToBottom(){this.grid?.scrollToBottom()}scrollToIndex(e){this.grid?.scrollToIndex(e)}scrollToRow(e){const t=this.store.getItemIndexByObjectId(e);t>-1?this.grid?.scrollToIndex(t):this._logWarning("Row not found. Associated data may not be loaded yet.")}scrollToTop(){this.grid?.scrollToTop()}async saveAttachmentsViewForm(){const{attachmentId:e,form:t,objectId:i}=this.attachmentsViewOptions;null!=i&&t&&(null!=e?await this.updateAttachment(i,e,t):await this.addAttachment(i,t))}async showAttachmentsView({objectId:e}){const{attachmentsViewOptions:t,hiddenFields:s,layer:l}=this;if(!this.attachmentsEnabled||!l)return void this._logWarning("The 'attachmentsEnabled' property is currently false.");await l.load();const o=l.displayField||l.objectIdField,n=await this.store.getAttachmentsByObjectId(e,!0),a=this.store.getItemIndexByObjectId(e);t.set({attachmentInfos:n,mode:n.length?"list":"file",objectId:e}),this.set({highlightIds:new i([e]),multipleSelectionEnabled:!1,relationshipColumnConfigs:[],tableTemplateOverride:this._getTableTemplateForAttachmentsView(o)}),s.includes(k.action)||s.add(k.action),null!=a&&this.scrollToIndex(a)}clearSelectionFilter(){l(a.getLogger(this),"`FeatureTable.clearSelectionFilter` is deprecated in favor of 'filterBySelectionEnabled' and 'objectIds'",{replacement:"FeatureTable.filterBySelectionEnabled or FeatureTable.objectIds",version:"4.30",warnOnce:!0}),this.objectIds.removeAll()}async updateAttachment(e,t,i){const{attachmentsViewOptions:s,store:l}=this,n=s.objectId===e;await l.updateAttachment(e,t,i).catch((e=>{n&&e&&"object"==typeof e&&"error"in e&&e.error instanceof o&&(this._logWarning(`Unable to update attachment. ${e.error.name} ${e.error.message}`),s.error=e.error)})),n&&!s.error&&(s.onEditComplete(),s.attachmentInfos=await l.getAttachmentsByObjectId(e,!0)),this.refreshCellContent()}async zoomToSelection(){const{layer:e,view:t}=this,i=this.highlightIds.toArray();if(!e||!t||!i.length)return;const s=e.createQuery();s.objectIds=i,s.returnGeometry=!0;const l=await e.queryFeatures(s);try{await t.goTo(l.features)}catch(o){"AbortError"!==o.name&&console.error(o)}}async _refresh(){await this.store.refresh();const e=this.highlightIds.toArray();if(e.length){(await this.store.verifyFeaturesByObjectId(e)).forEach(((t,i)=>{t||this.highlightIds.remove(e[i])}))}this.refreshPageCache();const t=this.attachmentsViewOptions;null!=t?.objectId&&(t.attachmentInfos=await this.store.getAttachmentsByObjectId(t.objectId,!0))}async _onLayerLoad(){const{layer:e,pageSize:t}=this;if(!e)return;e.parent&&y(e.parent)&&await e.parent.loadAll();const i=e.capabilities.query?.maxRecordCount,s=i&&i<t,l=s?i:t;s&&(this._logWarning("The value for 'pageSize' has been adjusted due to the provided layer's max record count."),this.pageSize=l),this.grid?.set("pageSize",l),this.store.load(),this._generateColumns()}_onLayerRefresh(e){this.autoRefreshEnabled&&e.dataChanged&&this.refresh()}_generateColumns(){this._drainColumns();const{_effectiveTableTemplate:e,_effectiveAttributeTableTemplate:t}=this,i=e?.columnTemplates,s=this._generateColumnsFromColumnTemplates(i)??this._generateColumnsFromAttributeTableTemplate(t)??this._generateDefaultFieldColumns();s.length&&(this.attachmentsEnabled&&!s.some((e=>O(e)))&&s.push(this._generateDefaultAttachmentsColumn()),this.relatedRecordsEnabled&&this._relationshipInfos.length&&!s.some((e=>V(e)))&&s.push(...this._generateDefaultRelationshipColumns()),this.actionColumnConfig&&s.push(this._generateActionColumn()),s.sort(((e,t)=>e.frozen&&t.frozen||e.frozenToEnd&&t.frozenToEnd?0:e.frozen||t.frozenToEnd?-1:0)),this.columns.addMany(s))}_generateColumnsFromAttributeTableTemplate(e){const{layer:i}=this;if(!e||!i)return null;const{elements:s,orderByFields:l}=e,o=w(i),n=[];n.push(...this._generateColumnsFromAttributeTableElements(s,l));const a=o.map((e=>{if(!e.fieldName||N(e.fieldName,n))return null;const{fieldName:t}=e,s=M(i,t);return s?this._generateDefaultFieldColumn(s,{hidden:!0,orderByFields:l}):(this._logTemplateWarning("A valid 'field' could not be found for the provided template."),null)})).filter(t);return n.push(...a),this.attachmentsEnabled&&H(i)&&!n.some((e=>O(e)))&&n.push(this._generateDefaultAttachmentsColumn({hidden:!0})),this.relatedRecordsEnabled&&$(i)&&i.relationships?.forEach((({id:e},t)=>{const i=this._relationshipInfos.find((t=>t.relationshipId===e));i&&!n.some((t=>V(t)&&t.relationshipId===e))&&n.push(this._generateDefaultRelationshipColumn({hidden:!0,info:i,index:t}))})),n.length?n:null}_generateColumnsFromAttributeTableElements(e,t){const{layer:i}=this;return i?e?.map(((e,i)=>{switch(e.type){case"field":return this._createFieldColumnFromElement({element:e,orderByFields:t});case"group":return this._createGroupColumnFromElement({element:e,orderByFields:t});case"attachment":return this._createAttachmentColumnFromElement({element:e,index:i});case"relationship":return this._createRelationshipColumnFromElement({element:e,index:i})}})).filter((e=>!!e))??[]:[]}_createFieldColumnFromElement(e){const{layer:t}=this;if(!t)return null;const{element:i,orderByFields:s}=e,{fieldName:l}=i;if(null==l)return this._logTemplateWarning("A valid 'fieldName' must be provided."),null;const o=M(t,l);if(!o)return this._logTemplateWarning("A valid 'field' could not be found for the provided template."),null;const{description:n,label:a}=i,r=s?.findIndex((({field:e})=>e&&e===l))??-1,h=r>-1?s?.at(r)?.order:void 0,d=r>-1?r:null,{editingEnabled:m,grid:c,messages:p,messagesCommon:u,messagesURIUtils:g,store:b,timeZone:f,view:y}=this;return new E({description:n,direction:h,field:o,fieldName:l,grid:c,initialSortPriority:d,label:a,layer:t,messages:p,messagesCommon:u,messagesURIUtils:g,store:b,tableEditingEnabled:m,tableTimeZone:f,view:y,onShowPromptCallback:this._onShowPromptCallback})}_createGroupColumnFromElement(e){const{element:t,orderByFields:i}=e,{description:s,label:l}=t;if(!l)return this._logTemplateWarning("Group columns require a label."),null;if(!t.elements.length)return this._logTemplateWarning("Group columns require child columns."),null;const{grid:o,messages:n,messagesCommon:a,messagesURIUtils:r,store:h,timeZone:d}=this;return new R({columns:this._generateColumnsFromAttributeTableElements(t.elements,i),description:s,grid:o,label:l,messages:n,messagesCommon:a,messagesURIUtils:r,store:h,tableTimeZone:d})}_createAttachmentColumnFromElement(e){if(!this.attachmentsEnabled)return void this._logTemplateWarning("The 'attachmentsEnabled' property is currently false.");const{element:t,index:i}=e,{description:s,label:l}=t,{grid:o,layer:n,messages:a,messagesCommon:r,messagesURIUtils:h,store:d,timeZone:m}=this;return new v({description:s,fieldName:`${k.attachments}-${i}`,grid:o,label:l,layer:n,messages:a,messagesCommon:r,messagesURIUtils:h,store:d,tableTimeZone:m,onShowAttachments:e=>this._onShowAttachments(e)})}_createRelationshipColumnFromElement(e){if(!this.relatedRecordsEnabled)return void this._logTemplateWarning("Relationship columns require related records to be enabled on the table.");const{element:t,index:i}=e,{description:s,label:l,relationshipId:o}=t,n=this._relationshipInfos.find((e=>e.relationshipId===o));if(!n)return this._logTemplateWarning("Unable to find valid related layer target based on the provided relationship id."),null;const{grid:a,messages:r,messagesCommon:h,messagesURIUtils:d,store:m,timeZone:c}=this;return new A({description:s,fieldName:`${k.relationship}-${o}-${i}`,grid:a,label:l,messages:r,messagesCommon:h,messagesURIUtils:d,relationshipId:o,store:m,tableTimeZone:c,layer:n.relatedLayer,relatedLayer:n.layer,showRelatedTableCallback:e=>this._onShowRelatedTable(e)})}_generateColumnsFromColumnTemplates(e){const{editingEnabled:t,grid:i,layer:s,messages:l,messagesCommon:o,messagesURIUtils:n,store:a,timeZone:r,view:h}=this;if(!e?.length||!s)return null;const d=[];return e.forEach(((e,m)=>{const{autoWidth:c,description:p,direction:u,flexGrow:g,fieldName:b,formatFunction:f,frozen:y,frozenToEnd:w,icon:T,initialSortPriority:_,invalid:I,label:C,menuConfig:v,resizable:A,sortable:j,textAlign:S,textWrap:x,timeZone:U,type:O,width:V}=e;if(!O)return void this._logTemplateWarning("Property 'type' is missing from the provided template.");if(y&&w)return void this._logTemplateWarning("Properties 'frozen' and 'frozenToEnd' cannot both be true for the same column.");const P=!1===e.visible;if("group"===O){if(!e.columnTemplates?.length)return void this._logTemplateWarning("Group columns must contain column templates.");if(!e.label)return void this._logTemplateWarning("Group columns require a label.");const t=this._generateColumnsFromColumnTemplates(e.columnTemplates),s=P||this._isFieldHidden(e.label);d.push(new R({autoWidth:c,columns:t,description:p,flexGrow:g,frozen:y,frozenToEnd:w,grid:i,hidden:s,icon:T,invalid:I,label:C,menuConfig:v,messages:l,messagesCommon:o,messagesURIUtils:n,resizable:A,tableTimeZone:r,textAlign:S,textWrap:x,timeZone:U,width:V}))}else if("attachment"===O){if(!this.attachmentsEnabled)return void this._logTemplateWarning("Attachment columns require attachments to be enabled on the table.");d.push(this._generateAttachmentsColumnFromTemplate(e,m))}else if("relationship"===O){if(!this.relatedRecordsEnabled)return void this._logTemplateWarning("Relationship columns require related records to be enabled on the table.");const{relationshipId:t}=e;if(null==t)return void this._logTemplateWarning("Property 'relationshipId' is missing from the provided template.");const i=this._relationshipInfos.find((e=>e.relationshipId===t));if(!i)return void this._logTemplateWarning("Unable to find valid related layer target based on the provided relationship id.");d.push(this._generateRelationshipColumnFromTemplate(i,e,m))}else if(!b)return void this._logTemplateWarning("Value for 'fieldName' property was missing from the provided template.");const W=P||this._isFieldHidden(b);if("column"===O)d.push(new F({autoWidth:c,description:p,direction:u,fieldName:b,flexGrow:g,formatFunction:f,frozen:y,frozenToEnd:w,grid:i,hidden:W,icon:T,initialSortPriority:_,invalid:I,label:C,menuConfig:v,messages:l,messagesCommon:o,messagesURIUtils:n,resizable:A,sortable:j,tableTimeZone:r,textAlign:S,textWrap:x,timeZone:U,width:V}));else if("field"===O){const m=M(s,e.fieldName);if(!m)return void this._logTemplateWarning("A valid 'field' could not be found for the provided template.");const{editable:b,required:F}=e;d.push(new E({autoWidth:c,description:p,direction:u,editable:b,field:m,fieldName:m.name,flexGrow:g,formatFunction:f,frozen:y,frozenToEnd:w,grid:i,hidden:W,icon:T,initialSortPriority:_,invalid:I,label:C,layer:s,messages:l,messagesCommon:o,messagesURIUtils:n,menuConfig:v,required:F,resizable:A,sortable:j,store:a,tableEditingEnabled:t,tableTimeZone:r,template:e,textAlign:S,textWrap:x,timeZone:U,width:V,view:h,onShowPromptCallback:this._onShowPromptCallback}))}})),d.length?d:null}_generateDefaultFieldColumns(){return this.layer?.fields?.map((e=>this._generateDefaultFieldColumn(e))).filter(t)??[]}_generateDefaultFieldColumn(e,t){const{editingEnabled:i,grid:s,layer:l,messages:o,messagesCommon:n,messagesURIUtils:a,store:r,timeZone:h,view:d}=this,m=t?.orderByFields;if(!e.visible||"geometry"===e.type)return null;const c=e.name,p=m?.findIndex((e=>e.field&&e.field===c)),u=null!=p?m?.at(p)?.order:null,g=null!=p&&p>-1?p:void 0;return new E({direction:u,field:e,fieldName:c,grid:s,hidden:t?.hidden||this._isFieldHidden(c),initialSortPriority:g,layer:l,messages:o,messagesCommon:n,messagesURIUtils:a,store:r,tableEditingEnabled:i,tableTimeZone:h,view:d,onShowPromptCallback:this._onShowPromptCallback})}_generateAttachmentsColumnFromTemplate(e,t){const{grid:i,layer:s,messages:l,messagesCommon:o,messagesURIUtils:n,store:a,timeZone:r}=this,{attachmentsViewEnabled:h,autoWidth:d,description:m,flexGrow:c,fieldName:p,formatFunction:u,frozen:g,frozenToEnd:b,icon:f,invalid:y,label:w,menuConfig:T,resizable:_,textAlign:I,textWrap:C,thumbnailAppearance:E,thumbnailCount:A,thumbnailIconScale:F,thumbnailsEnabled:j,timeZone:S,width:R}=e;return new v({attachmentsViewEnabled:h,autoWidth:d,description:m,fieldName:`${k.attachments}-${t}`,flexGrow:c,formatFunction:u,frozen:g,frozenToEnd:b,grid:i,hidden:!1===e.visible||this._isFieldHidden(w)||this._isFieldHidden(p),icon:f,invalid:y,label:w,layer:s,menuConfig:T,messages:l,messagesCommon:o,messagesURIUtils:n,resizable:_,store:a,tableTimeZone:r,textAlign:I,textWrap:C,thumbnailAppearance:E,thumbnailCount:A,thumbnailIconScale:F,thumbnailsEnabled:j,timeZone:S,width:R,onShowAttachments:e=>this._onShowAttachments(e)})}_generateDefaultAttachmentsColumn(e){const{grid:t,layer:i,messages:s,messagesCommon:l,messagesURIUtils:o,store:n,timeZone:a}=this,r=k.attachments;return new v({fieldName:r,grid:t,hidden:e?.hidden||this._isFieldHidden(r),layer:i,messages:s,messagesCommon:l,messagesURIUtils:o,store:n,tableTimeZone:a,onShowAttachments:e=>this._onShowAttachments(e)})}_generateRelationshipColumnFromTemplate(e,t,i){const{grid:s,messages:l,messagesCommon:o,messagesURIUtils:n,store:a,timeZone:r}=this,{autoWidth:h,collapsed:d,description:m,flexGrow:c,fieldName:p,formatFunction:u,frozen:g,frozenToEnd:b,icon:f,invalid:y,label:w,menuConfig:T,relationshipId:_,resizable:I,textAlign:C,textWrap:v,timeZone:E,width:F}=t;return new A({autoWidth:h,collapsed:d,description:m,fieldName:`${k.relationship}-${_}-${i}`,flexGrow:c,formatFunction:u,frozen:g,frozenToEnd:b,grid:s,hidden:!1===t.visible||this._isFieldHidden(w)||this._isFieldHidden(p),icon:f,invalid:y,label:w,menuConfig:T,messages:l,messagesCommon:o,messagesURIUtils:n,relationshipId:_,resizable:I,store:a,tableTimeZone:r,textAlign:C,textWrap:v,timeZone:E,width:F,layer:e.relatedLayer,relatedLayer:e.layer,showRelatedTableCallback:e=>this._onShowRelatedTable(e)})}_generateDefaultRelationshipColumns(){const{_relationshipInfos:e,relationshipColumnConfigs:t}=this,i=[];return e?.length?(t?t.forEach(((t,s)=>{const{relationshipId:l}=t,o=e.find((e=>e.relationshipId===l));o&&i.push(this._generateDefaultRelationshipColumn({config:t,index:s,info:o}))})):e.forEach(((e,t)=>i.push(this._generateDefaultRelationshipColumn({index:t,info:e})))),i):i}_generateDefaultRelationshipColumn(e){const{config:t,hidden:i,index:s,info:l}=e,{grid:o,messages:n,messagesCommon:a,messagesURIUtils:r}=this,{relationshipId:h}=l;return new A({...t,fieldName:`${k.relationship}-${h}-${s}`,grid:o,hidden:i,messages:n,messagesCommon:a,messagesURIUtils:r,layer:l.relatedLayer,relatedLayer:l.layer,relationshipId:h,showRelatedTableCallback:e=>this._onShowRelatedTable(e)})}_generateActionColumn(){return new C({hidden:this._isFieldHidden(k.action),...this.actionColumnConfig})}_isFieldHidden(e){const t=e?.toLowerCase();return(this.hiddenFields??this._defaultHiddenFields).some((e=>e.toLowerCase()===t))}_addTableHighlight(e){const{_highlightableLayerView:t,layer:i}=this;if(t&&i){const s=this.store.getItemByObjectId(e),l=s?.feature??e;this._highlights.add(t.highlight(l),`${i.id}-${e}`)}}_removeTableHighlight(e){const{layer:t}=this;t&&this._highlights.remove(`${t.id}-${e}`)}_syncSelection(){this._highlights.removeAll(),this._tableHighlightsReady?this.highlightIds.forEach((e=>this._addTableHighlight(e))):this._viewSelectionReady&&(this.highlightIds.items=this._viewSelection)}_appendToViewSelection(e){const{_selectableLayer:t}=this;t&&this._selectionManager?.appendToSelection(t,e)}_removeFromViewSelection(e){const{_selectableLayer:t}=this;t&&this._selectionManager?.removeFromSelection(t,e)}async _onHighlightIdsChange(e){const{added:t,removed:i}=e,{attachmentsViewOptions:s}=this;if(this._tableHighlightsReady?(i.forEach((e=>this._removeTableHighlight(e))),t.forEach((e=>this._addTableHighlight(e)))):this._viewSelectionReady&&(this._removeFromViewSelection(i),this._appendToViewSelection(t)),this.filterBySelectionEnabled&&this._syncObjectIdsWithStore(this.highlightIds.toArray()),null!=s.objectId){const e=this.highlightIds.at(0);if(null!=e){const t=await this.store.getAttachmentsByObjectId(e,!0);s.set({attachmentInfos:t,objectId:e,mode:t.length?"list":"file"})}}}_onShowRelatedTable(e){const{highlightIds:t}=this,{objectId:i}=e;t.removeAll(),t.add(i),this.showRelatedTableCallback?this.showRelatedTableCallback(e):this.emit("show-related-table",e)}_onObjectIdsChange(){const e=this.objectIds.toArray();e.length&&this.filterBySelectionEnabled&&(this.filterBySelectionEnabled=!1,this._logWarning("Object ID filter was applied while a selection filter was applied. Selection filter has been removed.")),this._syncObjectIdsWithStore(e)}_syncObjectIdsWithStore(e){this.store.objectIds=e,this.refreshPageCache()}_drainColumns(){this.columns.drain((e=>!e.destroyed&&e.destroy()))}_showAllRelatedTables(e){const t=e.layer;if(!t)return;const i=t.displayField||t.objectIdField;e.set({relationshipColumnConfigs:[],tableTemplateOverride:this._getTableTemplateForShowAllTablesView(e,i)});const s=e.hiddenFields;s.includes(k.action)||s.add(k.action),s.includes(k.attachments)||s.add(k.attachments)}_hideAllRelatedTables(e){const{layer:t,relationship:i}=e;if(t&&null!=i?.id)if(null!=e.attachmentsViewOptions.objectId){const t=e.layer?.displayField||e.layer?.objectIdField||"";e.set({multipleSelectionEnabled:!1,relationshipColumnConfigs:[],showAllRelatedTables:!1,tableTemplateOverride:this._getTableTemplateForAttachmentsView(t)})}else e.set({multipleSelectionEnabled:!0,relationshipColumnConfigs:D(t,i.id),showAllRelatedTables:!1,tableTemplateOverride:null}),e.hiddenFields.removeMany([k.action,k.attachments])}_getTableTemplateForRelatedTableView(e,t,i){return new Z({columnTemplates:[new B({fieldName:t,editable:!1,menuConfig:{selectionMode:"single",icon:"chevron-down",items:this._extractFieldColumnInfosFromTableTemplate(e.viewModel).map((([s,l])=>({selected:s===t,label:l||s,clickFunction:()=>{e.tableTemplateOverride=this._getTableTemplateForRelatedTableView(e,s,i)}})))},resizable:!1}),new L({autoWidth:!1,collapsed:!0,flexGrow:0,label:"",resizable:!1,relationshipId:i,width:X})]})}_getTableTemplateForShowAllTablesView(e,t){const i=[new B({fieldName:t,editable:!1,menuConfig:{selectionMode:"single",icon:"chevron-down",items:this._extractFieldColumnInfosFromTableTemplate(e.viewModel).map((([i,s])=>({selected:i===t,label:s||i,clickFunction:()=>{e.tableTemplateOverride=this._getTableTemplateForShowAllTablesView(e,i)}})))},resizable:!1})];return null!=e.attachmentsViewOptions.objectId&&i.push(new x({attachmentsViewEnabled:!1,autoWidth:!1,flexGrow:0,label:"",resizable:!1,thumbnailsEnabled:!1,width:X})),new Z({columnTemplates:i})}async _onShowPromptCallback(e){const{column:t,objectId:i,oldValue:s,value:l}=e,{_subtypes:o,layer:n}=this;if(!n||!o.length)return void t.cancel();const a=o.find((e=>e.code===l));if(!a)return void t.cancel();const r=d(),h=this._createSubtypeEditPrompt(s,a,r),m=!!n.parent;try{this.showPrompt(h);const e=await r.promise,s=[{fieldName:t.fieldName,value:l}];switch(e){case"update-fields":for(const[e,t]of Object.entries(a.defaultValues))null!=t&&s.push({fieldName:e,value:t});await t.updateItems({objectId:i,updates:s}),m&&this.refresh();break;case"keep-existing":await t.updateItems({objectId:i,updates:s}),m&&this.refresh();break;case"undo":t.cancel()}}finally{this.clearPrompt()}}_createSubtypeEditPrompt(e,t,i){const{_subtypes:s,messages:l,messagesCommon:o}=this,n=s.find((t=>t.code===e))?.name??`${e}`;let a="update-fields";const r=[{label:l.subtypes.useDefaultValuesOption,value:"update-fields"},{label:l.subtypes.keepCurrentValuesOption,value:"keep-existing"}];return{context:"info",title:l.subtypes.changeWarningTitle,message:K(l.subtypes.changeWarning,{originalType:n,newType:t.name}),radios:r,defaultRadioSelection:"update-fields",onRadioSelection:e=>{a=e},actions:{primary:{label:o.apply,action:()=>i.resolve(a),type:"positive"},secondary:{label:o.cancel,type:"neutral",action:()=>i.resolve("undo")}},cancel:()=>i.reject()}}_onShowAttachments({objectId:e}){this.attachmentsViewOptions.objectId=e}_getTableTemplateForAttachmentsView(e){return new Z({columnTemplates:[new B({fieldName:e,editable:!1,menuConfig:{selectionMode:"single",icon:"chevron-down",items:this._extractFieldColumnInfosFromTableTemplate(this).map((([t,i])=>({selected:t===e,label:i||t,clickFunction:()=>{this.tableTemplateOverride=this._getTableTemplateForAttachmentsView(t)}})))},resizable:!1}),new x({attachmentsViewEnabled:!1,autoWidth:!1,flexGrow:0,label:"",resizable:!1,thumbnailsEnabled:!1,width:X})]})}_extractFieldColumnInfosFromTableTemplate(e){const t=e??this,{layer:i,tableTemplate:s}=t;return s?s.columnTemplates.filter((({type:e})=>"field"===e||"column"===e)).map((({fieldName:e,label:t})=>[e,t])):i?.fields.map((e=>[e.name,e.alias]))??[]}_getIndexOfFirstFrozenToEndColumn(){const e=this.columns.findIndex((e=>e.frozenToEnd));return e>-1?e:void 0}_logWarning(e,t){t?a.getLogger(this).warnOnce(e):a.getLogger(this).warn(e)}_logTemplateWarning(e){this._logWarning(`${e} Skipped generating a column using the provided template.`,!0)}_onCellInteraction(e){null!=e&&null!=this.attachmentsViewOptions.objectId&&this.highlightIds.add(e)}};e([u()],Y.prototype,"_defaultHiddenFields",null),e([u()],Y.prototype,"_effectiveTableTemplate",null),e([u()],Y.prototype,"_effectiveAttributeTableTemplate",null),e([u()],Y.prototype,"_highlights",void 0),e([u()],Y.prototype,"_highlightableLayerView",null),e([u()],Y.prototype,"_relationshipInfos",null),e([u()],Y.prototype,"_selectionManager",null),e([u()],Y.prototype,"_selectableLayer",null),e([u()],Y.prototype,"_subtypes",null),e([u()],Y.prototype,"_tableHighlightsReady",null),e([u()],Y.prototype,"_viewSelection",null),e([u()],Y.prototype,"_viewSelectionReady",null),e([u()],Y.prototype,"actionColumnConfig",void 0),e([u()],Y.prototype,"allRelatedTablesVisible",null),e([u()],Y.prototype,"activeFilters",null),e([u({readOnly:!0})],Y.prototype,"activeSortOrders",null),e([u()],Y.prototype,"attachmentsEnabled",null),e([u()],Y.prototype,"attachmentsViewOptions",void 0),e([u({type:T})],Y.prototype,"attributeTableTemplate",void 0),e([u()],Y.prototype,"autoRefreshEnabled",void 0),e([u()],Y.prototype,"clearPrompt",null),e([u({readOnly:!0})],Y.prototype,"columns",void 0),e([u()],Y.prototype,"dataProvider",void 0),e([u()],Y.prototype,"editingEnabled",void 0),e([u()],Y.prototype,"filterGeometry",null),e([u()],Y.prototype,"filterBySelectionEnabled",null),e([u({readOnly:!0})],Y.prototype,"grid",void 0),e([u()],Y.prototype,"hiddenFields",null),e([u()],Y.prototype,"highlightEnabled",void 0),e([u()],Y.prototype,"initialSize",null),e([u()],Y.prototype,"isQueryingOrSyncing",null),e([u()],Y.prototype,"isSyncingAttachments",null),e([u({readOnly:!0})],Y.prototype,"itemIdPath",void 0),e([u()],Y.prototype,"layer",null),e([u()],Y.prototype,"layerView",null),e([u()],Y.prototype,"messages",void 0),e([u(),q("esri/t9n/common")],Y.prototype,"messagesCommon",void 0),e([u(),q("esri/core/t9n/Units")],Y.prototype,"messagesUnits",void 0),e([u(),q("esri/widgets/support/t9n/uriUtils")],Y.prototype,"messagesURIUtils",void 0),e([u()],Y.prototype,"outFields",null),e([u()],Y.prototype,"prompt",void 0),e([u()],Y.prototype,"relatedRecordsEnabled",null),e([u()],Y.prototype,"relatedTable",null),e([u()],Y.prototype,"relatedTables",void 0),e([u()],Y.prototype,"relationship",null),e([u()],Y.prototype,"relationshipColumnConfigs",void 0),e([u()],Y.prototype,"relationshipConfig",null),e([u()],Y.prototype,"relationships",null),e([u()],Y.prototype,"returnGeometryEnabled",null),e([u()],Y.prototype,"returnMEnabled",null),e([u()],Y.prototype,"returnZEnabled",null),e([u()],Y.prototype,"selectionSource",void 0),e([u()],Y.prototype,"showAllRelatedTables",null),e([u()],Y.prototype,"showPrompt",null),e([u()],Y.prototype,"showRelatedTableCallback",void 0),e([u({readOnly:!0,type:z})],Y.prototype,"store",void 0),e([u()],Y.prototype,"supportsAttachments",null),e([u()],Y.prototype,"supportsAddAttachments",null),e([u()],Y.prototype,"supportsDeleteAttachments",null),e([u()],Y.prototype,"supportsResizeAttachments",null),e([u()],Y.prototype,"supportsUpdateAttachments",null),e([u()],Y.prototype,"tableController",void 0),e([u()],Y.prototype,"tableParent",void 0),e([u({type:Z})],Y.prototype,"tableTemplate",void 0),e([u()],Y.prototype,"tableTemplateOverride",void 0),e([u()],Y.prototype,"timeExtent",null),e([u()],Y.prototype,"timeZone",null),e([u()],Y.prototype,"view",null),Y=e([g("esri.widgets.FeatureTable.FeatureTableViewModel")],Y);const ee=Y;export{ee 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.31/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../chunks/tslib.es6.js";import"@vaadin/grid/vaadin-grid.js";import"@vaadin/grid/vaadin-grid-column-group.js";import"@vaadin/grid/vaadin-grid-selection-column.js";import"@vaadin/grid/vaadin-grid-sorter.js";import{isSome as t}from"../../../core/arrayUtils.js";import{on as i}from"../../../core/events.js";import{assertIsSome as r}from"../../../core/maybe.js";import{on as n,watch as o}from"../../../core/reactiveUtils.js";import{property as l}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import{subclass as s}from"../../../core/accessorSupport/decorators/subclass.js";import d from"../../Widget.js";import a from"./GridViewModel.js";import{globalCss as h}from"../../support/globalCss.js";import"../../support/widgetUtils.js";import{messageBundle as u}from"../../support/decorators/messageBundle.js";import{tsx as c}from"../../support/jsxFactory.js";const m="esri-grid",g="compact column-borders",p={base:m,content:`${m}__content`,grid:`${m}__grid`},_={sort:["Enter"," "]};let f=class extends d{constructor(e,t){super(e,t),this._columnElements=[],this._grid=null,this.itemIdPath=null,this.messages=null,this.selectionColumnEnabled=!0,this.viewModel=new a,this._onSelectedItemsChange=this._onSelectedItemsChange.bind(this)}initialize(){this.addHandles([this.columns.on("before-changes",(()=>this.renderNow())),this.columns.on("change",(()=>this.onColumnChange())),n((()=>this.highlightIds),"before-add",(({target:e})=>{!this.multipleSelectionEnabled&&e.length&&e.removeAll()})),this.rowHighlightIds.on("change",(()=>this.generateCellPartNames())),o((()=>this.effectiveSize),(()=>this._updateGridSize())),o((()=>this.viewModel.editing),(()=>{this.generateCellPartNames(),this.requestContentUpdate()})),o((()=>this.store?.state),((e,t)=>{"ready"!==e||"loaded"!==t&&"error"!==t||this.refreshPageCache()})),n((()=>this._table),"scroll",(()=>this.viewModel.closeColumnMenus())),n((()=>this._table),"scrollend",(()=>{this.paginationEnabled||(this.pageIndex=this.getVirtualPageIndex())})),o((()=>this.multipleSelectionEnabled),(e=>{!e&&this.highlightIds.length>1&&this.highlightIds.removeAll()}))])}destroy(){this.resetColumns(),this.columns.destroyed||this.columns.destroy()}resetColumns(){this.columns.drain((e=>!e.destroyed&&e.destroy()))}get _editInfos(){return this.viewModel.editableColumns.map((e=>e.editInfo)).filter(t)}get _columnRendering(){return this.columnPerformanceModeEnabled?"lazy":"eager"}get _selectedItems(){const{highlightIds:e,store:t}=this;return e.toArray().map((e=>t?.getItemByObjectId(e)??{objectId:e}))}get _table(){return this._grid?.$?.table}get cellPartNameGenerator(){return this.viewModel.cellPartNameGenerator}set cellPartNameGenerator(e){this.viewModel.cellPartNameGenerator=e}get columns(){return this.viewModel.columns}set columns(e){this.viewModel.columns=e}get columnPerformanceModeEnabled(){return this.viewModel.columnPerformanceModeEnabled}set columnPerformanceModeEnabled(e){this.viewModel.columnPerformanceModeEnabled=e}get columnReorderingEnabled(){return this.viewModel.columnReorderingEnabled}set columnReorderingEnabled(e){this.viewModel.columnReorderingEnabled=e}get pageIndex(){return this.viewModel.pageIndex}set pageIndex(e){this.viewModel.pageIndex=e}get dataProvider(){return this.viewModel.dataProvider}set dataProvider(e){this.viewModel.dataProvider=e}get effectiveSize(){return this.viewModel.effectiveSize}get highlightIds(){return this.viewModel.highlightIds}set highlightIds(e){this.viewModel.highlightIds=e}get isEditingActive(){return!!this._editInfos.length}get isReady(){return!!this._grid}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get multipleSelectionEnabled(){return this.viewModel.multipleSelectionEnabled}set multipleSelectionEnabled(e){this.viewModel.multipleSelectionEnabled=e}get multiSortEnabled(){return this.viewModel.multiSortEnabled}set multiSortEnabled(e){this.viewModel.multiSortEnabled=e}get pageSize(){return this.viewModel.pageSize}set pageSize(e){this.viewModel.pageSize=e}get paginationEnabled(){return this.viewModel.paginationEnabled}set paginationEnabled(e){this.viewModel.paginationEnabled=e}get rowDetailsRenderer(){return this.viewModel.rowDetailsRenderer}set rowDetailsRenderer(e){this.viewModel.rowDetailsRenderer=e}get rowHighlightIds(){return this.viewModel.rowHighlightIds}set rowHighlightIds(e){this.viewModel.rowHighlightIds=e}get size(){return this.viewModel.size}get sortOrders(){return this._grid?._sorters?this._grid._sorters.filter((e=>!!e&&e.path)).map((({direction:e,path:t})=>({direction:e,path:t}))):[]}get store(){return this.viewModel.store}set store(e){this.viewModel.store=e}addSorter(e){this._grid?.__updateSorter(e,!1,!1),this.notifyChange("sortOrders")}getColumnProps(e,t){const{id:i}=this,{autoWidth:r,direction:n,fieldName:o,flexGrow:l,frozen:s,frozenToEnd:d,hidden:a,label:h,resizable:u,textAlign:c,width:m}=e,g=`${i}_${o}_${t}`,{renderFunction:p,footerRenderFunction:_,headerRenderFunction:f}=e,v=_?(e,t)=>_({root:e,column:t}):void 0,w=f?(e,t)=>f({root:e,column:t}):void 0,C=p?(e,t,i)=>p({root:e,column:t,rowData:i}):void 0;let b="";return e.direction&&(b+=" direction"),e.invalid&&(b+=" invalid"),{footerRenderer:v,headerRenderer:w,renderer:C,autoWidth:r,direction:n,flexGrow:l,frozen:s,frozenToEnd:d,headerPartName:b,hidden:a,key:g,resizable:u,bind:this,"data-fieldName":o,header:h,path:o,"text-align":c,width:"number"==typeof m?`${m}px`:m,afterCreate:this._afterColumnCreate,afterRemoved:this._afterColumnRemoved}}clearSelection(){this._clearSelection(),this.scheduleRender()}clearSort(){let e=!1;if(this._grid){if(this._grid._sorters?.length&&(this._grid._sorters.forEach((e=>{e._order=null,e.direction=null})),e=!0),this.columns.length){this.columns.some((e=>!!e.direction))&&(this.columns.forEach((e=>e.direction=null)),e=!0)}e&&(this.notifyChange("sortOrders"),this.scheduleRender())}}findColumn(e){return this.viewModel.findColumn(e)}generateCellPartNames(){this._grid?.generateCellPartNames()}getFirstVisibleRowIndex(){return this._grid?._firstVisibleIndex||0}getVirtualPageIndex(){return Math.floor(this.getFirstVisibleRowIndex()/this.pageSize)}getLastVisibleRowIndex(){return this._grid?._lastVisibleIndex||0}getVisibleItemsCount(){return this._grid?._visibleItemsCount||0}getRowContainingNode(e){try{return this._grid?._getRowContainingNode(e)}catch{return null}}getSlotElementByName(e){return this._grid?.shadowRoot?.querySelector(`slot[name='${e}']`)??null}hasSorter(e){return this._grid?._sorters?.includes(e)||!1}hideColumn(e){this.viewModel.hideColumn(e)}recalculateColumnWidths(){this._grid?.recalculateColumnWidths()}async reset(){this._clearSelection(),await(this.store?.reset()),this.scrollToTop()}refreshPageCache(){this._grid?.clearCache()}requestContentUpdate(){this._grid?.requestContentUpdate()}selectRows(e){const{itemIdPath:t}=this,i=e?.filter((e=>!this.highlightIds.includes(e[t]))),r=i.map((e=>e[t]));r.length&&(this.multipleSelectionEnabled||(this.highlightIds.removeAll(),r.splice(1)),this.highlightIds.addMany(r))}deselectRows(e){const{itemIdPath:t}=this,i=e?.map((e=>e[t]))||[];i.length&&this.highlightIds.removeMany(i)}showColumn(e){this.viewModel.showColumn(e)}sort({path:e,direction:t}){this.viewModel.sortColumn(e,t),this.notifyChange("sortOrders")}scrollToIndex(e){this._grid?.isConnected&&this._grid?.scrollToIndex(e)}scrollToTop(){this.scrollToIndex(0)}scrollToBottom(){this.scrollToIndex(1/0)}scrollLeft(e){const{_table:t}=this;t&&(t.scrollLeft=e)}toggleColumnVisibility(e){this.viewModel.toggleColumnVisibility(e)}onColumnChange(){this._columnElements.forEach((e=>{this._applyRenderersToColumnElement(e)})),this.requestContentUpdate()}render(){return c("div",{bind:this,class:this.classes(p.base,h.widget)},c("div",{bind:this,class:p.content},this._renderGrid()))}_renderGrid(){return c("vaadin-grid",{afterCreate:this._afterGridCreate,afterUpdate:this._afterGridUpdate,bind:this,cellPartNameGenerator:this.cellPartNameGenerator,class:p.grid,columnRendering:this._columnRendering,columnReorderingAllowed:this.columnReorderingEnabled,dataProvider:this.dataProvider,id:`${this.id}_grid`,itemIdPath:this.itemIdPath,multiSort:this.multiSortEnabled,pageSize:this.pageSize,ref:"grid",rowDetailsRenderer:this.rowDetailsRenderer,selectedItems:this._selectedItems,size:this.effectiveSize},this._renderAllColumns())}_renderAllColumns(){return"disabled"!==this.viewModel.state&&this.columns.length?[this._renderSelectionColumn(),this._renderColumns()]:null}_renderSelectionColumn(){return c("vaadin-grid-selection-column",{_selectAllHidden:!0,autoWidth:!1,bind:this,dragSelect:!0,frozen:!0,hidden:!this.selectionColumnEnabled,selectAll:!1,sortable:!1,textAlign:"center"})}_renderColumns(){return Array.from(this.columns,((e,t)=>"columns"in e?this._renderGroupColumn(e,t):c("vaadin-grid-column",{...this.getColumnProps(e,t)}))).filter(t)}_renderGroupColumn(e,t){const i=this.getColumnProps(e,t);if(i.hidden||!e.columns)return null;const r=e.columns.filter((({hidden:e})=>!e));return r.length?c("vaadin-grid-column-group",{...i},r.map((e=>c("vaadin-grid-column",{...this.getColumnProps(e,t)})))):null}_afterGridCreate(e){const t=this._grid=e;t.setAttribute("theme",g),customElements.whenDefined("vaadin-grid").then((()=>{this._appendStyles(),this._addGridEventListeners()})),t.__updateSorter=(e,i,r)=>{const n=t._sorters,o=!n.includes(e);if(!e.direction&&o)return;e._order=null;const{multiSort:l,multiSortOnShiftClick:s,multiSortPriority:d}=t,a=n.filter((t=>t!==e));l&&(!s||!r)||s&&i?null!=e._initialOrder?(o?n[e._initialOrder]=e:n.splice(e._initialOrder,0,e),e._initialOrder=null):t._sorters="append"===d?[...a,e]:[e,...a]:(e.direction||s)&&(t._sorters=e.direction?[e]:[],a.forEach((e=>{e._order=null,e.direction=null})))},t.__removeSorters=e=>{if(0===e.length)return;const i=new Set(e.filter((e=>!e.direction)));t._sorters=t._sorters.filter((e=>!i.has(e))),t.__applySorters()}}_appendStyles(){const e=this._grid?.shadowRoot,t=document.createElement("style");e&&(t.textContent='\n #items [part~="row"][editing],\n #items [part~="row"][editing][selected] {\n z-index: 2;\n }\n\n #items [part~="editing"],\n #items [part~="editing"][selected] {\n z-index: 3;\n }\n\n [frozen], [frozen-to-end] {\n z-index: 4;\n }\n\n [last-frozen] {\n overflow: visible;\n }\n\n [part~=\'cell\'] ::slotted(vaadin-grid-cell-content) {\n align-items: center;\n box-sizing: border-box !important;\n height: 100%;\n line-height: 2em;\n min-height: 40px;\n }\n\n #items [part~="text-wrap"] {\n text-wrap: wrap;\n }\n ',e.appendChild(t))}_afterGridUpdate(e){this._grid||(this._grid=e)}_afterColumnCreate(e){this._columnElements.push(e)}_afterColumnRemoved(e){const t=this._columnElements.indexOf(e,0);t>-1&&this._columnElements.splice(t,1)}_updateGridSize(){this._grid&&(this._grid.size=this.effectiveSize,this.scheduleRender())}_addGridEventListeners(){const e=this._grid;r(e),this.addHandles([i(e,["click","dblclick","keydown","pointerover","pointerout"],(e=>this._onGridInteraction(e))),i(e,"selected-items-changed",this._onSelectedItemsChange),i(e,"sorter-changed",(()=>this.notifyChange("sortOrders"))),i(e,"column-resize",(e=>{const t=e.detail.resizedColumn,i=t.getAttribute("data-fieldName"),r=this.findColumn(i);r?.set({width:t.width})})),i(e,"column-reorder",(()=>this._onColumnOrderChange()))])}_onGridInteraction(e){const t=this._grid;if(r(t),("pointerover"===e.type||"pointerout"===e.type)&&e.relatedTarget!==t){const{target:t,relatedTarget:i}=e;if(!this._isGridCellContentNode(t)||!this._isGridCellContentNode(i))return}let i=null;try{i=t.getEventContext(e)}catch(a){}if(!i)return;const{column:n,index:o,item:l,section:s}=i;if(!s)return;if("header"===s&&"keydown"===e.type&&n?.path){const t=e.key;_.sort.includes(t)&&this.findColumn(n.path)?.sort()}const d=`cell-${e.type}`;this.emit(d,{type:d,context:i,index:o,item:l,native:e,path:n?.path??void 0})}_isGridCellContentNode(e){return!!(e&&e instanceof HTMLElement&&"vaadin-grid-cell-content"===e.localName)}_onColumnOrderChange(){const e=this._grid;r(e);const t=e._getColumnsInOrder(0),i=[],n=(this.viewModel.groupColumns.length?e._getColumnsInOrder(1):t).map((e=>e.getAttribute("data-fieldName")));t?.forEach((e=>{const t=e.getAttribute("data-fieldName");if(null!=t){const e=this.findColumn(t);i.push(t),e&&"columns"in e&&e.columns?.length&&e.columns.sort(((e,t)=>n.indexOf(e.fieldName)>n.indexOf(t.fieldName)?1:-1))}})),this.columns.sort(((e,t)=>i.indexOf(e.fieldName)>i.indexOf(t.fieldName)?1:-1)),this.notifyChange("sortOrders"),this.emit("column-reorder",{type:"column-reorder"})}_clearSelection(){this.highlightIds.removeAll()}_onSelectedItemsChange(e){const{highlightIds:t,itemIdPath:i}=this,r=e.detail.value.map((e=>e[i])),n=r.filter((e=>!t.includes(e)));if(!this.multipleSelectionEnabled&&n.length&&t.length)t.removeAll(),t.add(n[0]);else{const e=t.filter((e=>!r.includes(e)));t.removeMany(e),t.addMany(n)}}_applyRenderersToColumnElement(e){const t=e?.path,i=null!=t?this.findColumn(t):void 0;if(i)try{const{renderFunction:t,footerRenderFunction:r,headerRenderFunction:n}=i;t&&"renderer"in e&&(e.renderer=(e,i,r)=>t({root:e,column:i,rowData:r})),r&&(e.footerRenderer=(e,t)=>r({root:e,column:t})),n&&(e.headerRenderer=(e,t)=>n({root:e,column:t}))}catch(r){}}};e([l()],f.prototype,"_editInfos",null),e([l()],f.prototype,"_columnElements",void 0),e([l()],f.prototype,"_columnRendering",null),e([l()],f.prototype,"_selectedItems",null),e([l()],f.prototype,"_grid",void 0),e([l()],f.prototype,"_table",null),e([l()],f.prototype,"cellPartNameGenerator",null),e([l()],f.prototype,"columns",null),e([l()],f.prototype,"columnPerformanceModeEnabled",null),e([l()],f.prototype,"columnReorderingEnabled",null),e([l()],f.prototype,"pageIndex",null),e([l()],f.prototype,"dataProvider",null),e([l()],f.prototype,"effectiveSize",null),e([l()],f.prototype,"highlightIds",null),e([l()],f.prototype,"isEditingActive",null),e([l()],f.prototype,"isReady",null),e([l()],f.prototype,"itemIdPath",void 0),e([l()],f.prototype,"label",null),e([l(),u("esri/widgets/FeatureTable/t9n/FeatureTable")],f.prototype,"messages",void 0),e([l()],f.prototype,"multipleSelectionEnabled",null),e([l()],f.prototype,"multiSortEnabled",null),e([l()],f.prototype,"pageSize",null),e([l()],f.prototype,"paginationEnabled",null),e([l()],f.prototype,"rowDetailsRenderer",null),e([l()],f.prototype,"rowHighlightIds",null),e([l()],f.prototype,"selectionColumnEnabled",void 0),e([l()],f.prototype,"size",null),e([l({readOnly:!0})],f.prototype,"sortOrders",null),e([l()],f.prototype,"store",null),e([l()],f.prototype,"viewModel",void 0),f=e([s("esri.widgets.FeatureTable.Grid.Grid")],f);const v=f;export{v as default};
|
|
5
|
+
import{_ as e}from"../../../chunks/tslib.es6.js";import"@vaadin/grid/vaadin-grid.js";import"@vaadin/grid/vaadin-grid-column-group.js";import"@vaadin/grid/vaadin-grid-selection-column.js";import"@vaadin/grid/vaadin-grid-sorter.js";import{isSome as t}from"../../../core/arrayUtils.js";import{on as i}from"../../../core/events.js";import{assertIsSome as r}from"../../../core/maybe.js";import{on as n,watch as o}from"../../../core/reactiveUtils.js";import{property as l}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import{subclass as s}from"../../../core/accessorSupport/decorators/subclass.js";import d from"../../Widget.js";import a from"./GridViewModel.js";import{globalCss as h}from"../../support/globalCss.js";import"../../support/widgetUtils.js";import{messageBundle as u}from"../../support/decorators/messageBundle.js";import{tsx as c}from"../../support/jsxFactory.js";const m="esri-grid",g="compact column-borders",p={base:m,content:`${m}__content`,grid:`${m}__grid`},f={sort:["Enter"," "]};let _=class extends d{constructor(e,t){super(e,t),this._columnElements=[],this._grid=null,this.itemIdPath=null,this.messages=null,this.selectionColumnEnabled=!0,this.viewModel=new a,this._onSelectedItemsChange=this._onSelectedItemsChange.bind(this)}initialize(){this.addHandles([this.columns.on("before-changes",(()=>this.renderNow())),this.columns.on("change",(()=>this.onColumnChange())),n((()=>this.highlightIds),"before-add",(({target:e})=>{!this.multipleSelectionEnabled&&e.length&&e.removeAll()})),this.rowHighlightIds.on("change",(()=>this.generateCellPartNames())),o((()=>this.effectiveSize),(()=>this._updateGridSize())),o((()=>this.viewModel.editing),(()=>{this.generateCellPartNames(),this.requestContentUpdate()})),o((()=>this.store?.state),((e,t)=>{"ready"!==e||"loaded"!==t&&"error"!==t||this.refreshPageCache()})),n((()=>this._table),"scroll",(()=>this.viewModel.closeColumnMenus())),n((()=>this._table),"scrollend",(()=>{this.paginationEnabled||(this.pageIndex=this.getVirtualPageIndex())})),o((()=>this.multipleSelectionEnabled),(e=>{!e&&this.highlightIds.length>1&&this.highlightIds.removeAll()}))])}destroy(){this.resetColumns(),this.columns.destroyed||this.columns.destroy()}resetColumns(){this.columns.drain((e=>!e.destroyed&&e.destroy()))}get _editInfos(){return this.viewModel.editableColumns.map((e=>e.editInfo)).filter(t)}get _columnRendering(){return this.columnPerformanceModeEnabled?"lazy":"eager"}get _selectedItems(){const{highlightIds:e,store:t}=this;return e.toArray().map((e=>t?.getItemByObjectId(e)??{objectId:e}))}get _table(){return this._grid?.$?.table}get cellPartNameGenerator(){return this.viewModel.cellPartNameGenerator}set cellPartNameGenerator(e){this.viewModel.cellPartNameGenerator=e}get columns(){return this.viewModel.columns}set columns(e){this.viewModel.columns=e}get columnPerformanceModeEnabled(){return this.viewModel.columnPerformanceModeEnabled}set columnPerformanceModeEnabled(e){this.viewModel.columnPerformanceModeEnabled=e}get columnReorderingEnabled(){return this.viewModel.columnReorderingEnabled}set columnReorderingEnabled(e){this.viewModel.columnReorderingEnabled=e}get pageIndex(){return this.viewModel.pageIndex}set pageIndex(e){this.viewModel.pageIndex=e}get dataProvider(){return this.viewModel.dataProvider}set dataProvider(e){this.viewModel.dataProvider=e}get effectiveSize(){return this.viewModel.effectiveSize}get hasInvalidColumnConfiguration(){return this.viewModel.hasInvalidColumnConfiguration}get highlightIds(){return this.viewModel.highlightIds}set highlightIds(e){this.viewModel.highlightIds=e}get isEditingActive(){return!!this._editInfos.length}get isReady(){return!!this._grid}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get multipleSelectionEnabled(){return this.viewModel.multipleSelectionEnabled}set multipleSelectionEnabled(e){this.viewModel.multipleSelectionEnabled=e}get multiSortEnabled(){return this.viewModel.multiSortEnabled}set multiSortEnabled(e){this.viewModel.multiSortEnabled=e}get pageSize(){return this.viewModel.pageSize}set pageSize(e){this.viewModel.pageSize=e}get paginationEnabled(){return this.viewModel.paginationEnabled}set paginationEnabled(e){this.viewModel.paginationEnabled=e}get rowDetailsRenderer(){return this.viewModel.rowDetailsRenderer}set rowDetailsRenderer(e){this.viewModel.rowDetailsRenderer=e}get rowHighlightIds(){return this.viewModel.rowHighlightIds}set rowHighlightIds(e){this.viewModel.rowHighlightIds=e}get size(){return this.viewModel.size}get sortOrders(){return this._grid?._sorters?this._grid._sorters.filter((e=>!!e&&e.path)).map((({direction:e,path:t})=>({direction:e,path:t}))):[]}get store(){return this.viewModel.store}set store(e){this.viewModel.store=e}addSorter(e){this._grid?.__updateSorter(e,!1,!1),this.notifyChange("sortOrders")}getColumnProps(e,t){const{id:i}=this,{autoWidth:r,direction:n,fieldName:o,flexGrow:l,frozen:s,frozenToEnd:d,hidden:a,label:h,resizable:u,textAlign:c,width:m}=e,g=`${i}_${o}_${t}`,{renderFunction:p,footerRenderFunction:f,headerRenderFunction:_}=e,v=f?(e,t)=>f({root:e,column:t}):void 0,C=_?(e,t)=>_({root:e,column:t}):void 0,w=p?(e,t,i)=>p({root:e,column:t,rowData:i}):void 0;let b="";return e.direction&&(b+=" direction"),e.invalid&&(b+=" invalid"),{footerRenderer:v,headerRenderer:C,renderer:w,autoWidth:r,direction:n,flexGrow:l,frozen:s,frozenToEnd:d,headerPartName:b,key:g,resizable:u,bind:this,"data-fieldName":o,header:h,hidden:this.hasInvalidColumnConfiguration||a,path:o,"text-align":c,width:"number"==typeof m?`${m}px`:m,afterCreate:this._afterColumnCreate,afterRemoved:this._afterColumnRemoved}}clearSelection(){this._clearSelection(),this.scheduleRender()}clearSort(){let e=!1;if(this._grid){if(this._grid._sorters?.length&&(this._grid._sorters.forEach((e=>{e._order=null,e.direction=null})),e=!0),this.columns.length){this.columns.some((e=>!!e.direction))&&(this.columns.forEach((e=>e.direction=null)),e=!0)}e&&(this.notifyChange("sortOrders"),this.scheduleRender())}}findColumn(e){return this.viewModel.findColumn(e)}generateCellPartNames(){this._grid?.generateCellPartNames()}getFirstVisibleRowIndex(){return this._grid?._firstVisibleIndex||0}getVirtualPageIndex(){return Math.floor(this.getFirstVisibleRowIndex()/this.pageSize)}getLastVisibleRowIndex(){return this._grid?._lastVisibleIndex||0}getVisibleItemsCount(){return this._grid?._visibleItemsCount||0}getRowContainingNode(e){try{return this._grid?._getRowContainingNode(e)}catch{return null}}getSlotElementByName(e){return this._grid?.shadowRoot?.querySelector(`slot[name='${e}']`)??null}hasSorter(e){return this._grid?._sorters?.includes(e)||!1}hideColumn(e){this.viewModel.hideColumn(e)}recalculateColumnWidths(){this._grid?.recalculateColumnWidths()}async reset(){this._clearSelection(),await(this.store?.reset()),this.scrollToTop()}refreshPageCache(){this._grid?.clearCache()}requestContentUpdate(){this._grid?.requestContentUpdate()}selectRows(e){const{itemIdPath:t}=this,i=e?.filter((e=>!this.highlightIds.includes(e[t]))),r=i.map((e=>e[t]));r.length&&(this.multipleSelectionEnabled||(this.highlightIds.removeAll(),r.splice(1)),this.highlightIds.addMany(r))}deselectRows(e){const{itemIdPath:t}=this,i=e?.map((e=>e[t]))||[];i.length&&this.highlightIds.removeMany(i)}showColumn(e){this.viewModel.showColumn(e)}sort({path:e,direction:t}){this.viewModel.sortColumn(e,t),this.notifyChange("sortOrders")}scrollToIndex(e){this._grid?.isConnected&&this._grid?.scrollToIndex(e)}scrollToTop(){this.scrollToIndex(0)}scrollToBottom(){this.scrollToIndex(1/0)}scrollLeft(e){const{_table:t}=this;t&&(t.scrollLeft=e)}toggleColumnVisibility(e){this.viewModel.toggleColumnVisibility(e)}onColumnChange(){this._columnElements.forEach((e=>{this._applyRenderersToColumnElement(e)})),this.requestContentUpdate()}render(){return c("div",{bind:this,class:this.classes(p.base,h.widget)},c("div",{bind:this,class:p.content},this._renderGrid()))}_renderGrid(){return c("vaadin-grid",{afterCreate:this._afterGridCreate,afterUpdate:this._afterGridUpdate,bind:this,cellPartNameGenerator:this.cellPartNameGenerator,class:p.grid,columnRendering:this._columnRendering,columnReorderingAllowed:this.columnReorderingEnabled,dataProvider:this.dataProvider,id:`${this.id}_grid`,itemIdPath:this.itemIdPath,multiSort:this.multiSortEnabled,pageSize:this.pageSize,ref:"grid",rowDetailsRenderer:this.rowDetailsRenderer,selectedItems:this._selectedItems,size:this.effectiveSize},this._renderAllColumns())}_renderAllColumns(){return"disabled"!==this.viewModel.state&&this.columns.length?[this._renderSelectionColumn(),this._renderColumns()]:null}_renderSelectionColumn(){return c("vaadin-grid-selection-column",{_selectAllHidden:!0,autoWidth:!1,bind:this,dragSelect:!0,frozen:!0,hidden:this.hasInvalidColumnConfiguration||!this.selectionColumnEnabled,selectAll:!1,sortable:!1,textAlign:"center"})}_renderColumns(){return Array.from(this.columns,((e,t)=>"columns"in e?this._renderGroupColumn(e,t):c("vaadin-grid-column",{...this.getColumnProps(e,t)}))).filter(t)}_renderGroupColumn(e,t){const i=this.getColumnProps(e,t);if(i.hidden||!e.columns)return null;const r=e.columns.filter((({hidden:e})=>!e));return r.length?c("vaadin-grid-column-group",{...i},r.map((e=>c("vaadin-grid-column",{...this.getColumnProps(e,t)})))):null}_afterGridCreate(e){const t=this._grid=e;t.setAttribute("theme",g),customElements.whenDefined("vaadin-grid").then((()=>{this._appendStyles(),this._addGridEventListeners()})),t.__updateSorter=(e,i,r)=>{const n=t._sorters,o=!n.includes(e);if(!e.direction&&o)return;e._order=null;const{multiSort:l,multiSortOnShiftClick:s,multiSortPriority:d}=t,a=n.filter((t=>t!==e));l&&(!s||!r)||s&&i?null!=e._initialOrder?(o?n[e._initialOrder]=e:n.splice(e._initialOrder,0,e),e._initialOrder=null):t._sorters="append"===d?[...a,e]:[e,...a]:(e.direction||s)&&(t._sorters=e.direction?[e]:[],a.forEach((e=>{e._order=null,e.direction=null})))},t.__removeSorters=e=>{if(0===e.length)return;const i=new Set(e.filter((e=>!e.direction)));t._sorters=t._sorters.filter((e=>!i.has(e))),t.__applySorters()}}_appendStyles(){const e=this._grid?.shadowRoot,t=document.createElement("style");e&&(t.textContent='\n #items [part~="row"][editing],\n #items [part~="row"][editing][selected] {\n z-index: 2;\n }\n\n #items [part~="editing"],\n #items [part~="editing"][selected] {\n z-index: 3;\n }\n\n [frozen], [frozen-to-end] {\n z-index: 4;\n }\n\n [last-frozen] {\n overflow: visible;\n }\n\n [part~=\'cell\'] ::slotted(vaadin-grid-cell-content) {\n align-items: center;\n box-sizing: border-box !important;\n height: 100%;\n line-height: 2em;\n min-height: 40px;\n }\n\n #items [part~="text-wrap"] {\n text-wrap: wrap;\n }\n ',e.appendChild(t))}_afterGridUpdate(e){this._grid||(this._grid=e)}_afterColumnCreate(e){this._columnElements.push(e)}_afterColumnRemoved(e){const t=this._columnElements.indexOf(e,0);t>-1&&this._columnElements.splice(t,1)}_updateGridSize(){this._grid&&(this._grid.size=this.effectiveSize,this.scheduleRender())}_addGridEventListeners(){const e=this._grid;r(e),this.addHandles([i(e,["click","dblclick","keydown","pointerover","pointerout"],(e=>this._onGridInteraction(e))),i(e,"selected-items-changed",this._onSelectedItemsChange),i(e,"sorter-changed",(()=>this.notifyChange("sortOrders"))),i(e,"column-resize",(e=>{const t=e.detail.resizedColumn,i=t.getAttribute("data-fieldName"),r=this.findColumn(i);r?.set({width:t.width})})),i(e,"column-reorder",(()=>this._onColumnOrderChange()))])}_onGridInteraction(e){const t=this._grid;if(r(t),("pointerover"===e.type||"pointerout"===e.type)&&e.relatedTarget!==t){const{target:t,relatedTarget:i}=e;if(!this._isGridCellContentNode(t)||!this._isGridCellContentNode(i))return}let i=null;try{i=t.getEventContext(e)}catch(a){}if(!i)return;const{column:n,index:o,item:l,section:s}=i;if(!s)return;if("header"===s&&"keydown"===e.type&&n?.path){const t=e.key;f.sort.includes(t)&&this.findColumn(n.path)?.sort()}const d=`cell-${e.type}`;this.emit(d,{type:d,context:i,index:o,item:l,native:e,path:n?.path??void 0})}_isGridCellContentNode(e){return!!(e&&e instanceof HTMLElement&&"vaadin-grid-cell-content"===e.localName)}_onColumnOrderChange(){const e=this._grid;r(e);const t=e._getColumnsInOrder(0),i=[],n=(this.viewModel.groupColumns.length?e._getColumnsInOrder(1):t).map((e=>e.getAttribute("data-fieldName")));t?.forEach((e=>{const t=e.getAttribute("data-fieldName");if(null!=t){const e=this.findColumn(t);i.push(t),e&&"columns"in e&&e.columns?.length&&e.columns.sort(((e,t)=>n.indexOf(e.fieldName)>n.indexOf(t.fieldName)?1:-1))}})),this.columns.sort(((e,t)=>i.indexOf(e.fieldName)>i.indexOf(t.fieldName)?1:-1)),this.notifyChange("sortOrders"),this.emit("column-reorder",{type:"column-reorder"})}_clearSelection(){this.highlightIds.removeAll()}_onSelectedItemsChange(e){const{highlightIds:t,itemIdPath:i}=this,r=e.detail.value.map((e=>e[i])),n=r.filter((e=>!t.includes(e)));if(!this.multipleSelectionEnabled&&n.length&&t.length)t.removeAll(),t.add(n[0]);else{const e=t.filter((e=>!r.includes(e)));t.removeMany(e),t.addMany(n)}}_applyRenderersToColumnElement(e){const t=e?.path,i=null!=t?this.findColumn(t):void 0;if(i)try{const{renderFunction:t,footerRenderFunction:r,headerRenderFunction:n}=i;t&&"renderer"in e&&(e.renderer=(e,i,r)=>t({root:e,column:i,rowData:r})),r&&(e.footerRenderer=(e,t)=>r({root:e,column:t})),n&&(e.headerRenderer=(e,t)=>n({root:e,column:t}))}catch(r){}}};e([l()],_.prototype,"_editInfos",null),e([l()],_.prototype,"_columnElements",void 0),e([l()],_.prototype,"_columnRendering",null),e([l()],_.prototype,"_selectedItems",null),e([l()],_.prototype,"_grid",void 0),e([l()],_.prototype,"_table",null),e([l()],_.prototype,"cellPartNameGenerator",null),e([l()],_.prototype,"columns",null),e([l()],_.prototype,"columnPerformanceModeEnabled",null),e([l()],_.prototype,"columnReorderingEnabled",null),e([l()],_.prototype,"pageIndex",null),e([l()],_.prototype,"dataProvider",null),e([l()],_.prototype,"effectiveSize",null),e([l()],_.prototype,"hasInvalidColumnConfiguration",null),e([l()],_.prototype,"highlightIds",null),e([l()],_.prototype,"isEditingActive",null),e([l()],_.prototype,"isReady",null),e([l()],_.prototype,"itemIdPath",void 0),e([l()],_.prototype,"label",null),e([l(),u("esri/widgets/FeatureTable/t9n/FeatureTable")],_.prototype,"messages",void 0),e([l()],_.prototype,"multipleSelectionEnabled",null),e([l()],_.prototype,"multiSortEnabled",null),e([l()],_.prototype,"pageSize",null),e([l()],_.prototype,"paginationEnabled",null),e([l()],_.prototype,"rowDetailsRenderer",null),e([l()],_.prototype,"rowHighlightIds",null),e([l()],_.prototype,"selectionColumnEnabled",void 0),e([l()],_.prototype,"size",null),e([l({readOnly:!0})],_.prototype,"sortOrders",null),e([l()],_.prototype,"store",null),e([l()],_.prototype,"viewModel",void 0),_=e([s("esri.widgets.FeatureTable.Grid.Grid")],_);const v=_;export{v as default};
|