@arcgis/core 6.0.0-next.30 → 6.0.0-next.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/00d1c99779bd91b1d10e.js +1 -0
- package/assets/esri/core/workers/chunks/0694c7bcfe71692e2ccf.js +1 -0
- package/assets/esri/core/workers/chunks/{e2c6cd8dac01e129ccfe.js → 0e445ec3523de9f2dfa2.js} +1 -1
- package/assets/esri/core/workers/chunks/0f6c0d42100c21367e5c.js +1 -0
- package/assets/esri/core/workers/chunks/16cda273927ab0a39544.js +1 -0
- package/assets/esri/core/workers/chunks/1a3f71c4d97c36050030.js +1 -0
- package/assets/esri/core/workers/chunks/{0b4481b57a611b15f65c.js → 1eaf8bfdd3765a90ccc2.js} +1 -1
- package/assets/esri/core/workers/chunks/{8ca2bb3c0551bb1898b6.js → 3fdcc383bbd9cf0d274c.js} +1 -1
- package/assets/esri/core/workers/chunks/{fefdd10bdd5a4c8d8ed0.js → 4741fac6b6b4202a97c5.js} +1 -1
- package/assets/esri/core/workers/chunks/{ad21757d78e372fa2ed6.js → 4a979fce1c971b614a18.js} +1 -1
- package/assets/esri/core/workers/chunks/4d8833f48348cbbcc947.js +1 -0
- package/assets/esri/core/workers/chunks/{865cebc5c982c040ab6f.js → 55a9eaeb152a3abada67.js} +1 -1
- package/assets/esri/core/workers/chunks/572aec57593a08b8045b.js +1 -0
- package/assets/esri/core/workers/chunks/6029773458ab98600f67.js +1 -0
- package/assets/esri/core/workers/chunks/6b5c073dddd89d06ed80.js +1 -0
- package/assets/esri/core/workers/chunks/7cc9d7a88b64e25fce14.js +1 -0
- package/assets/esri/core/workers/chunks/7e211d8a8ad6c6a7cf3e.js +1 -0
- package/assets/esri/core/workers/chunks/{64b360625c68cb863a08.js → 84940d8e14caf5a27e04.js} +1 -1
- package/assets/esri/core/workers/chunks/{c90388932a7825d9d933.js → 85de980c5b296ec69323.js} +1 -1
- package/assets/esri/core/workers/chunks/89dc49e784f7ba3b93ea.js +1 -0
- package/assets/esri/core/workers/chunks/{9d40786c5ceface786ba.js → 8a485130781b49dbf608.js} +1 -1
- package/assets/esri/core/workers/chunks/8d13f11d0bcc8d3a4bdf.js +1 -0
- package/assets/esri/core/workers/chunks/8da2a10318f49d0dc73a.js +1 -0
- package/assets/esri/core/workers/chunks/8e6276ddd8d094c61f08.js +1 -0
- package/assets/esri/core/workers/chunks/{1dc6f093028530a492e6.js → 90ba0af9690dc32b2958.js} +1 -1
- package/assets/esri/core/workers/chunks/{71f792a20077aa739f87.js → a607541959169741a943.js} +1 -1
- package/assets/esri/core/workers/chunks/b2d6b1ac9fbb50c7c8ab.js +1 -0
- package/assets/esri/core/workers/chunks/b657363113f4a37e634b.js +1 -0
- package/assets/esri/core/workers/chunks/b9cb92858a576eb6aa06.js +1 -0
- package/assets/esri/core/workers/chunks/{4419732baf3459a80e6d.js → ceb2d5b0a23f0ab81f68.js} +1 -1
- package/assets/esri/core/workers/chunks/{7030a4d0714a35995a58.js → d09d8cd43e846d467827.js} +1 -1
- package/assets/esri/core/workers/chunks/{12b84262dedc6b393136.js → d9a240a3c6bf85124474.js} +1 -1
- package/assets/esri/core/workers/chunks/{8f008eedb11685ee2048.js → e096c1d9d53af74d3207.js} +1 -1
- package/assets/esri/core/workers/chunks/e30fdde253e5521473a2.js +1 -0
- package/assets/esri/core/workers/chunks/e4e2edfdc85dd14e66d4.js +1 -0
- package/assets/esri/core/workers/chunks/{ba4520ddcb6a49988da6.js → f21edbfdcab111d8a6cd.js} +1 -1
- package/assets/esri/core/workers/chunks/f4d91d470ca5fea0bd26.js +1 -0
- package/assets/esri/core/workers/chunks/f717005e14a7e9141df7.js +1 -0
- package/assets/esri/core/workers/chunks/f75eec2cbc541eec9712.js +1 -0
- package/assets/esri/core/workers/chunks/{b5eff28cf482d920b9ea.js → f7fb6cb7f08c16384443.js} +1 -1
- package/assets/esri/core/workers/chunks/fcc3902d6d9eda6f09f5.js +1 -0
- package/assets/esri/core/workers/chunks/{28a821de9dbf10324033.js → fd031150d3a7f896e6b3.js} +1 -1
- package/assets/esri/core/workers/chunks/{cc97e4fd0dacad970a23.js → ffaaa388773e60869df0.js} +1 -1
- package/config.js +1 -1
- package/core/scheduling.js +1 -1
- package/geometry/Mesh.d.ts +2 -125
- package/geometry/Mesh.js +1 -1
- package/geometry/support/meshErrors.js +1 -1
- package/geometry/support/plane.js +1 -1
- package/geometry/support/polygonUtils.js +1 -1
- package/interfaces.d.ts +0 -3
- package/kernel.js +1 -1
- package/layers/SceneLayer.js +1 -1
- package/layers/graphics/controllers/I3SOnDemandController.js +1 -1
- package/layers/knowledgeGraph/KnowledgeGraphLayerDataManager.js +1 -1
- package/layers/mixins/ArcGISImageService.js +1 -1
- package/layers/raster/functions/rasterProjectionHelper.js +1 -1
- package/layers/support/featureLayerUtils.js +1 -1
- package/package.json +2 -2
- package/support/arcadeUtils.js +1 -1
- package/views/2d/engine/webgl/SpriteMosaic.js +1 -1
- package/views/2d/layers/ImageryLayerView2D.js +1 -1
- package/views/3d/analysis/LineOfSight/LineOfSightConfiguration.js +1 -1
- package/views/3d/analysis/LineOfSight/LineOfSightEditTool.js +1 -1
- package/views/3d/analysis/LineOfSight/LineOfSightItemTool.js +1 -1
- package/views/3d/analysis/LineOfSight/LineOfSightManipulators.js +1 -1
- package/views/3d/environment/SunLighting.d.ts +10 -8
- package/views/3d/environment/VirtualLighting.d.ts +10 -8
- package/views/3d/layers/graphics/Graphics3DPathSymbolLayer.js +1 -1
- package/views/3d/support/renderInfoUtils/polygon.js +1 -1
- package/views/3d/terrain/PatchGeometryFactory.js +1 -1
- package/views/3d/terrain/PlanarPatch.js +1 -1
- package/views/3d/terrain/SphericalPatch.js +1 -1
- package/views/3d/webgl-engine/lib/Path.js +1 -1
- package/views/3d/webgl-engine/lib/PathBuilder.js +1 -1
- package/views/3d/webgl-engine/lib/PathExtruder.js +1 -1
- package/views/3d/webgl-engine/lib/PathGeometry.js +1 -1
- package/views/3d/webgl-engine/lib/pathGeometryUtils.js +1 -1
- package/views/interactive/snapping/FeatureSnappingEngine.js +1 -1
- package/views/support/TextureCompressionWorker.js +1 -1
- package/views/webgl/Texture.js +1 -1
- package/webscene/Environment.d.ts +1 -1
- package/widgets/BatchAttributeForm/BatchAttributeFormViewModel.js +1 -1
- package/widgets/BatchAttributeForm/expressions/ExpressionsManager.js +1 -1
- package/widgets/BatchAttributeForm/inputs/RelationshipElementInput.js +1 -1
- package/widgets/BatchAttributeForm/inputs/support/createBatchFormInputs.js +1 -1
- package/widgets/BatchAttributeForm.js +1 -1
- package/widgets/FeatureForm.js +1 -1
- package/assets/esri/core/workers/chunks/02335385b1476fe322eb.js +0 -1
- package/assets/esri/core/workers/chunks/07b726a46864501b90a0.js +0 -1
- package/assets/esri/core/workers/chunks/189321d88026bd7e6d3e.js +0 -1
- package/assets/esri/core/workers/chunks/18d47ab571b613fbe719.js +0 -1
- package/assets/esri/core/workers/chunks/1967b9c96045a5802d08.js +0 -1
- package/assets/esri/core/workers/chunks/199a7f97916679e0257c.js +0 -1
- package/assets/esri/core/workers/chunks/1d96fbad881a7d14a950.js +0 -1
- package/assets/esri/core/workers/chunks/2cd60fd062d954322c1f.js +0 -1
- package/assets/esri/core/workers/chunks/2d3e0e4442dbc6ec6def.js +0 -1
- package/assets/esri/core/workers/chunks/2f5d014d6a72108b0b3a.js +0 -1
- package/assets/esri/core/workers/chunks/3105336a05f38a95ebea.js +0 -1
- package/assets/esri/core/workers/chunks/4fb2fcc95f852bf8f86c.js +0 -1
- package/assets/esri/core/workers/chunks/59bc55880e6fd8ce20c0.js +0 -1
- package/assets/esri/core/workers/chunks/5f787809b74eed7b9a91.js +0 -1
- package/assets/esri/core/workers/chunks/6a7de221cea4426cb490.js +0 -1
- package/assets/esri/core/workers/chunks/7a0b4dc0cda190367a39.js +0 -1
- package/assets/esri/core/workers/chunks/7d3f7940815fa5dc244e.js +0 -1
- package/assets/esri/core/workers/chunks/999c23da883eb11cb29e.js +0 -1
- package/assets/esri/core/workers/chunks/9bc3afe7013ef4ae737b.js +0 -1
- package/assets/esri/core/workers/chunks/bab1d010970d98c25470.js +0 -1
- package/assets/esri/core/workers/chunks/c4f78a481f43cfae7b63.js +0 -1
- package/assets/esri/core/workers/chunks/dcf6024dc19428ff2b9d.js +0 -1
- package/assets/esri/core/workers/chunks/ee0dc906cc7979080329.js +0 -1
- package/assets/esri/core/workers/chunks/f0d0ed155275c2e6d3da.js +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
-
import{floatSubArray as e}from"../../../../geometry/support/FloatArray.js";import{newHalfFloatArray as t}from"../../../../geometry/support/HalfFloatArray.js";import{newIndexArray as n}from"../../../../geometry/support/Indices.js";import{newShortArray as r}from"../../../../geometry/support/ShortArray.js";import{pathNumProfilesPerJoin as i,pathNumJoinSubdivisions as a}from"../../layers/graphics/Graphics3DPathSymbolLayerConstants.js";import{compressNormal as o,encodeInt16 as s}from"./Normals.js";import{PathEvaluator as c}from"./PathEvaluator.js";import{encodePathVertexInfo as l}from"./PathVertexInfo.js";class u{constructor(o,s,l,u,d){this.path=o,this.profile=s,this.extruder=l,this.cap=u,this._extrusionVertexCount=0,this._extrusionFrameCount=0;let f=this.path.
|
|
2
|
+
import{floatSubArray as e}from"../../../../geometry/support/FloatArray.js";import{newHalfFloatArray as t}from"../../../../geometry/support/HalfFloatArray.js";import{newIndexArray as n}from"../../../../geometry/support/Indices.js";import{newShortArray as r}from"../../../../geometry/support/ShortArray.js";import{pathNumProfilesPerJoin as i,pathNumJoinSubdivisions as a}from"../../layers/graphics/Graphics3DPathSymbolLayerConstants.js";import{compressNormal as o,encodeInt16 as s}from"./Normals.js";import{PathEvaluator as c}from"./PathEvaluator.js";import{encodePathVertexInfo as l}from"./PathVertexInfo.js";class u{constructor(o,s,l,u,d){this.path=o,this.profile=s,this.extruder=l,this.cap=u,this._extrusionVertexCount=0,this._extrusionFrameCount=0;let f=this.path.numVertices-2;this.numExtrusionProfiles=i*f+2,this.numVerticesTotal=s.vertices.length*this.numExtrusionProfiles,this.numExtrusionFrames=this.path.numVertices;let p=this.cap.numVertices;this.startCapGeometryVertexOffset=this.numVerticesTotal,this.numVerticesTotal+=p,this.endCapGeometryVertexOffset=this.numVerticesTotal,this.numVerticesTotal+=p,this.profileRightAxes=r(this.numExtrusionFrames*2),this.profileUpAxes=r(this.numExtrusionFrames*2);let m=d===1;this.profileRotationFrameUpAxes=m?r(this.numExtrusionFrames*2):null,this.pathMaxStretchDistances=t(this.numExtrusionFrames),this.profileRotations=r(this.numExtrusionFrames),this.framePositionIndices=n(this.numExtrusionFrames),this.pathVertexInfos=new Uint32Array(this.numVerticesTotal),this.positions=e(o.positions,o.offset,o.numVertices*3);let h=l.join===2;this._numJoinTriangles=s.joinTriangleBudgets[d][l.join];let g=2*s.numSegments*(h?a:1);this._compressed=this._numJoinTriangles<g;let _=2*s.numSegments*(f+1)+this._numJoinTriangles*f;this.vertexIndices=n(_*3+2*this.cap.numIndices,this.numVerticesTotal),this._rebuildGeometry(),this._buildTopology(),this.evaluator=new c(this,s,l,u.type,d)}emitVertexDescriptor(e){let t=this._extrusionVertexCount;this.pathVertexInfos[t]=l(e),++this._extrusionVertexCount}emitExtrusionFrame(e,t){let{frame:n,rotationFrameUp:r,rotationAngle:i,maxStretchDistance:a}=e,c=this._extrusionFrameCount;return o(this.profileRightAxes,c,n.right[0],n.right[1],n.right[2]),o(this.profileUpAxes,c,n.up[0],n.up[1],n.up[2]),this.profileRotations[c]=s(i/Math.PI),this.profileRotationFrameUpAxes&&o(this.profileRotationFrameUpAxes,c,r[0],r[1],r[2]),this.pathMaxStretchDistances[c]=a,this.framePositionIndices[c]=t,this._extrusionFrameCount++}_rebuildGeometry(){this._extrusionVertexCount=0,this._extrusionFrameCount=0;let{path:e}=this,{numVertices:t}=e,{profile:n}=this;this._updatePositions();for(let n=0;n<t;++n)this.emitExtrusionFrame(e.getVertex(n),n);for(let e=0;e<n.vertices.length;++e)this.emitVertexDescriptor({frameIndex:0,sourceIndex:e,subdivision:0,type:1,capSide:0});let r=(e,t,n)=>{this.emitVertexDescriptor({frameIndex:e,sourceIndex:t,subdivision:n,type:0,capSide:0})};for(let e=1;e<t-1;++e)this.extruder.extrude(e,this.profile,r);let i=t-1;for(let e=0;e<n.vertices.length;++e)this.emitVertexDescriptor({frameIndex:i,sourceIndex:e,subdivision:0,type:1,capSide:1});this.cap.rebuildCapGeometry((e,t,n)=>this.emitVertexDescriptor({frameIndex:0,sourceIndex:e,subdivision:t,type:n,capSide:0})),this.cap.rebuildCapGeometry((e,t,n)=>this.emitVertexDescriptor({frameIndex:i,sourceIndex:e,subdivision:t,type:n,capSide:1}))}_updatePositions(){let{positions:e,offset:t,numVertices:n}=this.path;if(!Array.isArray(e))return;let r=n*3,i=this.positions;for(let n=0;n<r;++n)i[n]=e[t+n]}_buildTopology(){let e=this.profile.vertices.length*(this.numExtrusionProfiles-1),{vertexIndices:t}=this,n=0,r=(e,r,i)=>{t[n++]=e,t[n++]=r,t[n++]=i};this.extruder.buildTopology(this.path,this.profile,0,this.profileRotationFrameUpAxes!=null,this._compressed,this._numJoinTriangles,(e,t)=>{for(let n=0;n<this.profile.numSegments;++n){let i=this.profile.indices[n*2],a=this.profile.indices[n*2+1];r(e+i,t+i,t+a),r(e+i,t+a,e+a)}},r),this.cap.buildTopology(r,0,this.startCapGeometryVertexOffset,0),this.cap.buildTopology(r,1,this.endCapGeometryVertexOffset,e)}onPathChanged(){this._rebuildGeometry(),this._buildTopology()}}export{u as PathBuilder};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
-
import{create as e}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{pathNumProfilesPerJoin as t,pathNumJoinSubdivisions as n}from"../../layers/graphics/Graphics3DPathSymbolLayerConstants.js";import{constructPathRotationRight as r,needsJoinSubdivisions as i}from"./pathGeometryUtils.js";class a{constructor(e){this.join=e,this.cutoffAngle=this.join===0?.8*Math.PI:0}extrude(e,n,r){for(let i=0;i<t;++i)for(let t=0;t<n.vertices.length;++t)r(e,t,i)}buildTopology(e,t,n,r,i,a,o,s){i?this._buildCompressedTopology(e,t,n,r,a,o,s):this._buildFixedTopology(e,t,n,o)}_buildCompressedTopology(e,r,i,a,o,s,c){let l=r.vertices.length,u=this.join===2?n:1,d=Array(l).fill(!1),f=i;for(let i=1;i<e.
|
|
2
|
+
import{create as e}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{pathNumProfilesPerJoin as t,pathNumJoinSubdivisions as n}from"../../layers/graphics/Graphics3DPathSymbolLayerConstants.js";import{constructPathRotationRight as r,needsJoinSubdivisions as i}from"./pathGeometryUtils.js";class a{constructor(e){this.join=e,this.cutoffAngle=this.join===0?.8*Math.PI:0}extrude(e,n,r){for(let i=0;i<t;++i)for(let t=0;t<n.vertices.length;++t)r(e,t,i)}buildTopology(e,t,n,r,i,a,o,s){i?this._buildCompressedTopology(e,t,n,r,a,o,s):this._buildFixedTopology(e,t,n,o)}_buildCompressedTopology(e,r,i,a,o,s,c){let l=r.vertices.length,u=this.join===2?n:1,d=Array(l).fill(!1),f=i;for(let i=1;i<e.numVertices-1;++i){let p=l*(1+(i-1)*t);s(f,p),this._classifyJoinVertices(e.getVertex(i),r,a,d);let m=o-r.indices.reduce((e,t)=>e+(d[t]?0:u),0);this._emitCompressedJoinTopology(r,p,d,c);for(let e=0;e<m;++e)c(p,p,p);f=p+n*l}let p=l*(1+(e.numVertices-2)*t);s(f,p)}_buildFixedTopology(e,r,i,a){let o=r.vertices.length,s=this.join===2,c=+!s,l=s?n:2,u=i;for(let r=1;r<e.numVertices-1;++r){let e=o*(1+(r-1)*t);a(u,e);for(let t=c;t<l;++t){let n=e+t*o;a(n,n+o)}u=e+n*o}let d=o*(1+(e.numVertices-2)*t);a(u,d)}_classifyJoinVertices(e,t,n,a){let s=e.rotationAngle,c=r(o,e.frame,e.rotationFrameUp,n);for(let e=0;e<a.length;++e){let n=t.vertices[e];a[e]=!i(n,c,s)}}_emitCompressedJoinTopology(e,t,r,i){let a=e.vertices.length,o=this.join===2,s=+!o,c=o?n:2;for(let n=0;n<e.numSegments;++n){let o=e.indices[n*2],l=e.indices[n*2+1];if(!(r[o]&&r[l]))for(let e=s;e<c;++e){let n=t+e*a,s=n+a,c=n+o,u=s+o,d=s+l,f=n+l;r[o]||i(c,u,d),r[l]||i(c,d,f)}}}}const o=e();export{a as PathExtruder};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
-
import{clamp as e}from"../../../../core/mathUtils.js";import{baseObjectMemory as t,
|
|
2
|
+
import{clamp as e}from"../../../../core/mathUtils.js";import{baseObjectMemory as t,integerArrayElementBytes as n,estimateArrayMemory as r}from"../../../../core/memoryEstimations.js";import{set as i,copy as a,exactEquals as o}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{create as s,clone as c}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{newFloatArray as l}from"../../../../geometry/support/FloatArray.js";import{getContinuousIndexArray as u,getZeroIndexArray as d}from"../../../../geometry/support/Indices.js";import{addOlidAttribute as f}from"../../layers/graphics/olidUtils.js";import{Attribute as p}from"./Attribute.js";import{Geometry as m}from"./Geometry.js";import{pathVertexInfoPacking as h}from"./PathVertexInfo.js";import{createPositionReader as g}from"./PositionReader.js";class _ extends m{constructor(e,n,r,i){let{vertexIndices:a,framePositionIndices:o,numExtrusionFrames:c}=n,l=u(c),m=d(c),h=[[`position`,new p(n.positions,o,3,!0)],[`profileRight`,new p(n.profileRightAxes,l,2,!0)],[`profileUp`,new p(n.profileUpAxes,l,2,!0)],[`profileRotation`,new p(n.profileRotations,l,1,!0)],[`pathMaxStretchDistance`,new p(n.pathMaxStretchDistances,l,1,!0)],[`pathVertexInfo`,new p(n.pathVertexInfos,a,1,!0)]];n.profileRotationFrameUpAxes&&h.push([`pathRotationUp`,new p(n.profileRotationFrameUpAxes,l,2,!0)]),r.sizeAttributeValue!=null&&h.push([`sizeFeatureAttribute`,new p([r.sizeAttributeValue],m,1,!0)]),r.size!=null&&h.push([`size`,new p([...r.size],m,2,!0)]),r.colorAttributeValue!=null&&h.push([`colorFeatureAttribute`,new p([r.colorAttributeValue],m,1,!0)]),r.color!=null&&h.push([`color`,new p([...r.color],m,4,!0)]),r.opacityAttributeValue!=null&&h.push([`opacityFeatureAttribute`,new p([r.opacityAttributeValue],m,1,!0)]),r.opacity!=null&&h.push([`opacity`,new p([r.opacity],m,1,!0)]),i!=null&&f(h,i,m),super(e,h,null,0),this.builder=n,this.visualVariablesState=r,this._positionCacheMemory=0,this._lastSize=s(),this._usedMemory=3*t}computeBufferMemory(e){let t=super.computeBufferMemory(e),{builder:r}=this;t+=e.arrayMemory(r.framePositionIndices,n,!0),t+=e.arrayMemory(r.vertexIndices,n,!0);let{path:i}=r;t+=e.arrayMemory(i.positions)+e.arrayMemory(i.positionsES)+e.arrayMemory(i.origin),t+=e.arrayMemory(i.directions)+e.arrayMemory(i.frames)+e.arrayMemory(i.minSiblingLengths);let a=i.getVertex(0);return t+=e.arrayMemory(a.vLeft)+e.arrayMemory(a.vRight),t+=e.arrayMemory(a.frame.up)+e.arrayMemory(a.frame.right),t}get indexCount(){return this.attributes.get(`pathVertexInfo`)?.indices.length??0}get readPrimitivePosition(){if(this._invalidateOnSizeChange(),this._readPrimitivePosition==null){let{builder:e,size:t}=this,{vertexIndices:n,numVerticesTotal:i,evaluator:a}=e,o=l(i*3);for(let e=0;e<i;++e)a.evaluateVertexPosition(o,t,e,e);this._readPrimitivePosition=g(o,n,3),this._positionCacheMemory=r(o,8),this._usedMemory+=this._positionCacheMemory,this.notifyMemoryChange?.(this._positionCacheMemory)}return this._readPrimitivePosition}_invalidateReadPrimitivePosition(){super._invalidateReadPrimitivePosition();let e=this._positionCacheMemory;this._positionCacheMemory=0,this._usedMemory-=e,e&&this.notifyMemoryChange?.(-e)}onPathChanged(){this.builder.onPathChanged(),this.invalidateBoundingInfo(),i(this._lastSize,-1,-1),this._invalidateReadPrimitivePosition()}get size(){let{parameters:t}=this.material,n=c(t.size);if(t.vvSize){let{offset:r,factor:i,minSize:a,maxSize:o,fallback:s}=t.vvSize,c=this.visualVariablesState.sizeAttributeValue??NaN;Number.isNaN(c)?(n[0]*=s[0],n[1]*=s[2]):(n[0]*=e(r[0]+c*i[0],a[0],o[0]),n[1]*=e(r[2]+c*i[2],a[2],o[2]))}else t.hasPathSize&&this.visualVariablesState.size&&a(n,this.visualVariablesState.size);return n}_computePrimitivePositionIndices(){let e=this.attributes.get(`pathVertexInfo`),t=this.attributes.get(`position`);if(e&&t){let n=t.indices,r=e.indices,i=e.data,a=h.getField(0);return r.map(t=>n[a.get(i[e.stride*t])])}return t?.indices??null}get boundingInfo(){return this._invalidateOnSizeChange(),super.boundingInfo}_invalidateOnSizeChange(){let{size:e}=this;o(e,this._lastSize)||(a(this._lastSize,e),this.invalidateBoundingInfo(),this._invalidateReadPrimitivePosition())}}function v(e){return e instanceof _}export{_ as PathGeometry,v as isPathGeometry};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
-
import{set as e,exactEquals as t,dot as n,length as r}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{ZEROS as i}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{dot as a,scale as o,add as s,normalize as c,copy as l,set as u,length as d,cross as f}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as p}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as m,fromPositionAndNormal as h,intersectRay as g}from"../../../../geometry/support/plane.js";import{wrap as _}from"../../../../geometry/support/ray.js";import{makeOrthoBasisDirUpFallback as v}from"./GeometryUtil.js";function y(e,t){let n=
|
|
2
|
+
import{set as e,exactEquals as t,dot as n,length as r}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{ZEROS as i}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{dot as a,scale as o,add as s,normalize as c,copy as l,set as u,length as d,cross as f}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as p}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as m,fromPositionAndNormal as h,intersectRay as g}from"../../../../geometry/support/plane.js";import{wrap as _}from"../../../../geometry/support/ray.js";import{makeOrthoBasisDirUpFallback as v}from"./GeometryUtil.js";function y(e,t){let n=e.numVertices,r=.99619469809,i=p(),a=p(),o=p(),y=p(),b=p(),x=p(),S=m(),C=e.getVertex(0);l(a,t),u(i,0,1,0),v(C.vRight,a,i,i,o,a,r),e.setFrame(0,a,o);let T=e.positions,E=e.offset;for(let t=1;t<n;++t){C=e.getVertex(t),s(b,C.vLeft,C.vRight);let n=d(b);n>0?(n=1/Math.sqrt(n),b[0]*=n,b[1]*=n,b[2]*=n):(b[0]=C.vRight[0],b[1]=C.vRight[1],b[2]=C.vRight[2]),x[0]=T[E]+a[0],x[1]=T[E+1]+a[1],x[2]=T[E+2]+a[2],E+=3;let l=u(w,T[E],T[E+1],T[E+2]);h(l,b,S),g(S,_(x,C.vLeft),y)?(y[0]-=T[E],y[1]-=T[E+1],y[2]-=T[E+2],c(a,y),f(o,b,a),c(o,o)):v(b,a,o,i,o,a,r),e.setFrame(t,a,o)}}const b=.001;function x(t,n,r,i){if(!i)return e(t,1,0);let l=a(r,n.up),u=a(r,n.right);return o(w,n.right,l),o(T,n.up,-u),s(w,w,T),c(w,w),e(t,a(w,n.right),a(w,n.up))}function S(e,t,i,a=0){return n(e,t)*Math.sign(i)>=-a*r(e)}function C(e,n,r){return r!==0&&!t(e,i)&&S(e,n,r,b)}const w=p(),T=p();export{b as classificationTolerance,y as computeMinimumRotationTangentFrame,x as constructPathRotationRight,S as isOuterJoinVertex,C as needsJoinSubdivisions};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import t from"../../../core/Accessor.js";import{isSome as n}from"../../../core/arrayUtils.js";import{destroyHandle as r}from"../../../core/handleUtils.js";import"../../../core/has.js";import{mapCollectionAsync as i}from"../../../core/mapCollectionUtils.js";import{allSettledValues as a,throwIfAborted as o,onAbort as s}from"../../../core/promiseUtils.js";import{watch as c,sync as l}from"../../../core/reactiveUtils.js";import{getMetersPerUnitForSR as u,getMetersPerVerticalUnitForSR as d}from"../../../core/units.js";import{property as f,subclass as p}from"../../../core/accessorSupport/decorators.js";import{squaredDistance as m}from"../../../core/libs/gl-matrix-2/math/vec2.js";import{copy as h,squaredDistance as g}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{create as _}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getEpsilon as v}from"../../../core/libs/gl-matrix-2/math/common.js";import{UpdatingHandles as y}from"../../../core/support/UpdatingHandles.js";import{absoluteHeightElevationInfo as b}from"../../../support/elevationInfoUtils.js";import{VerticalHalfPlaneConstraint as x,isLine as S,isDrapedLine as C}from"../sketch/constraints.js";import{fromAnyMapPoint as w,asVec2 as T,markAsTarget as E}from"../sketch/normalizedPoint.js";import{FeatureSnappingSourceInfo as D}from"./FeatureSnappingSourceInfo.js";import{sortCandidatesInPlace as O}from"./snappingUtils.js";import{DrapedEdgeSnappingCandidate as k}from"./candidates/DrapedEdgeSnappingCandidate.js";import{EdgeSnappingCandidate as A}from"./candidates/EdgeSnappingCandidate.js";import{FeatureSnappingCandidate as j}from"./candidates/FeatureSnappingCandidate.js";import{RightAngleSnappingCandidate as M}from"./candidates/RightAngleSnappingCandidate.js";import{vectorToScreenPoint as N}from"../support/viewUtils.js";import{screenDistance as P}from"../../../core/screenUtils.js";let F=class extends t{get updating(){return this._snappingSources.some(e=>e?.valid==null||e.valid===!0&&e.snappingSource?.updating===!0)||this._updatingHandles.updating}constructor(e){super(e),this.options=null,this._domain=1,this._updatingHandles=new y,this._sourceModules={featureService:{module:null,loader:null},featureCollection:{module:null,loader:null},graphics:{module:null,loader:null},notes:{module:null,loader:null},scene:{module:null,loader:null}}}initialize(){let e=i(()=>this.options?._effectiveFeatureSources,(e,t)=>this._createSourceInfo(e,t));this._snappingSources=e,this.addHandles([r(e),c(()=>({rulesEnabled:!!this.options?.attributeRulesEnabled,sources:this._snappingSources.filter(n)}),({rulesEnabled:e,sources:t})=>{for(let n of t)n.attributeRulesEnabled=e},l)])}destroy(){this._set(`options`,null),this._updatingHandles.destroy()}async fetchCandidates(e,t,n,r){if(!(t&this._domain)||this.options==null||!this.options.effectiveFeatureEnabled)return[];let i=[],s=this._computeScreenSizeDistanceParameters(e,n);for(let t of this._snappingSources){if(!t?.valid||!t.snappingSource?.layerSource?.enabled||t.layerView?.suspended)continue;let a=t.getFetchCandidatesParameters(e,n,s);for(let e of a)i.push(t.snappingSource.fetchCandidates(e,r).then(e=>this._processCandidatesFromSource(t,e,n)))}let c=(await a(i)).flat();return this._addRightAngleCandidates(c,e,s,n),o(r),O(e,c),c}_addRightAngleCandidates(e,t,n,r){let i=r.vertexHandle==null?r.editGeometryOperations!=null&&r.editGeometryOperations.data.type===`polygon`?r.editGeometryOperations.data.parts[0]?.getFirstVertex()?.pos:null:r.vertexHandle.rightSegment?.rightVertex?.pos,a=r.vertexHandle==null?r.editGeometryOperations
|
|
2
|
+
import{__decorate as e}from"tslib";import t from"../../../core/Accessor.js";import{isSome as n}from"../../../core/arrayUtils.js";import{destroyHandle as r}from"../../../core/handleUtils.js";import"../../../core/has.js";import{mapCollectionAsync as i}from"../../../core/mapCollectionUtils.js";import{allSettledValues as a,throwIfAborted as o,onAbort as s}from"../../../core/promiseUtils.js";import{watch as c,sync as l}from"../../../core/reactiveUtils.js";import{getMetersPerUnitForSR as u,getMetersPerVerticalUnitForSR as d}from"../../../core/units.js";import{property as f,subclass as p}from"../../../core/accessorSupport/decorators.js";import{squaredDistance as m}from"../../../core/libs/gl-matrix-2/math/vec2.js";import{copy as h,squaredDistance as g}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{create as _}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getEpsilon as v}from"../../../core/libs/gl-matrix-2/math/common.js";import{UpdatingHandles as y}from"../../../core/support/UpdatingHandles.js";import{absoluteHeightElevationInfo as b}from"../../../support/elevationInfoUtils.js";import{VerticalHalfPlaneConstraint as x,isLine as S,isDrapedLine as C}from"../sketch/constraints.js";import{fromAnyMapPoint as w,asVec2 as T,markAsTarget as E}from"../sketch/normalizedPoint.js";import{FeatureSnappingSourceInfo as D}from"./FeatureSnappingSourceInfo.js";import{sortCandidatesInPlace as O}from"./snappingUtils.js";import{DrapedEdgeSnappingCandidate as k}from"./candidates/DrapedEdgeSnappingCandidate.js";import{EdgeSnappingCandidate as A}from"./candidates/EdgeSnappingCandidate.js";import{FeatureSnappingCandidate as j}from"./candidates/FeatureSnappingCandidate.js";import{RightAngleSnappingCandidate as M}from"./candidates/RightAngleSnappingCandidate.js";import{vectorToScreenPoint as N}from"../support/viewUtils.js";import{screenDistance as P}from"../../../core/screenUtils.js";let F=class extends t{get updating(){return this._snappingSources.some(e=>e?.valid==null||e.valid===!0&&e.snappingSource?.updating===!0)||this._updatingHandles.updating}constructor(e){super(e),this.options=null,this._domain=1,this._updatingHandles=new y,this._sourceModules={featureService:{module:null,loader:null},featureCollection:{module:null,loader:null},graphics:{module:null,loader:null},notes:{module:null,loader:null},scene:{module:null,loader:null}}}initialize(){let e=i(()=>this.options?._effectiveFeatureSources,(e,t)=>this._createSourceInfo(e,t));this._snappingSources=e,this.addHandles([r(e),c(()=>({rulesEnabled:!!this.options?.attributeRulesEnabled,sources:this._snappingSources.filter(n)}),({rulesEnabled:e,sources:t})=>{for(let n of t)n.attributeRulesEnabled=e},l)])}destroy(){this._set(`options`,null),this._updatingHandles.destroy()}async fetchCandidates(e,t,n,r){if(!(t&this._domain)||this.options==null||!this.options.effectiveFeatureEnabled)return[];let i=[],s=this._computeScreenSizeDistanceParameters(e,n);for(let t of this._snappingSources){if(!t?.valid||!t.snappingSource?.layerSource?.enabled||t.layerView?.suspended)continue;let a=t.getFetchCandidatesParameters(e,n,s);for(let e of a)i.push(t.snappingSource.fetchCandidates(e,r).then(e=>this._processCandidatesFromSource(t,e,n)))}let c=(await a(i)).flat();return this._addRightAngleCandidates(c,e,s,n),o(r),O(e,c),c}_addRightAngleCandidates(e,t,n,r){let i=r.vertexHandle==null?r.editGeometryOperations!=null&&r.editGeometryOperations.data.type===`polygon`?r.editGeometryOperations.data.parts[0]?.getFirstVertex()?.pos:null:r.vertexHandle.rightSegment?.rightVertex?.pos,a=r.vertexHandle==null?r.editGeometryOperations!=null&&(r.editGeometryOperations.data.type===`polyline`||r.editGeometryOperations.data.type===`polygon`)?r.editGeometryOperations.data.parts[0]?.getLastVertex()?.pos:null:r.vertexHandle.leftSegment?.leftVertex?.pos,{view:o}=this,s=w(i,o,r),c=w(a,o,r),l=e.length;for(let r=0;r<l;r++)this._addRightAngleCandidate(e[r],c,t,n,e),this._addRightAngleCandidate(e[r],s,t,n,e)}_addRightAngleCandidate(e,t,n,r,i){if(t==null||!I(e))return;let a=e.constraint.closestTo(t),o=(a[0]-n[0])/r.x,s=(a[1]-n[1])/r.y,{start:c,end:l}=e.constraint;if(o*o+s*s<=1){let n=m(T(a),T(c))>m(T(a),T(l))?c:l,r=new M({targetPoint:E(a),otherVertex:t,otherVertexType:0,previousVertex:n,constraint:new x(t,a),objectId:e.objectId,isDraped:e.isDraped,domain:1});i.push(r)}}_computeScreenSizeDistanceParameters(e,t){let n=this.options==null?0:this.options.distance*(t.pointer===`touch`?this.options.touchSensitivityMultiplier:1);return this.view==null?{x:n,y:n,z:n,distance:n}:this.view.type===`2d`?(n*=this.view.resolution,{x:n,y:n,z:n,distance:n}):this._computeScreenSizeDistanceParameters3D(e,n,this.view,t)}_computeScreenSizeDistanceParameters3D(e,t,n,r){let{spatialReference:i}=r;n.renderCoordsHelper.toRenderCoords(e,i,z);let a=n.state.camera.computeScreenPixelSizeAt(z),o=a*n.renderCoordsHelper.unitInMeters,s=o/u(i),c=o/d(i),l=t*s,f=t*c,p=N(e,i,b,n),m=p?R(p,e,s,0,0,n,r):0,h=p?R(p,e,0,s,0,n,r):0,g=p?R(p,e,0,0,c,n,r):0;return{x:m===0?0:l/m,y:h===0?0:l/h,z:g===0?0:f/g,distance:a*t}}_processCandidatesFromSource(e,t,n){let r=[];for(let i of t)e.snappingSource&&!this._candidateIsExcluded(e.snappingSource,i,n.excludeFeature)&&(i instanceof j&&(i.layer=e.layer),r.push(i));return r}_candidateIsExcluded(e,t,n){if(n==null)return!1;let r=this._getCandidateObjectId(t);if(r==null)return!1;let i=e.layerSource.layer;return i.type===`graphics`?n.uid===r:n.sourceLayer!==i||!n.attributes||!(`objectIdField`in i)?!1:n.attributes[i.objectIdField]===r}_getCandidateObjectId(e){return e instanceof j?e.objectId:null}async _createSourceInfo(e,t){let n=e.layer;n.loaded||(await n.load(),o(t));let{view:r}=this,i=await this._createFeatureSnappingSourceType(e,t);return o(t),i==null?new D({}):new D({snappingSource:i,view:r,layer:n})}_handleSourceAbort(e,t){let n=s(t,()=>e.destroy());return n&&e.addHandles(n),e}async _createFeatureSnappingSourceType(e,t){switch(e.layer.type){case`feature`:case`geojson`:case`csv`:case`oriented-imagery`:case`subtype-group`:case`wfs`:return this._createFeatureSnappingSourceFeatureLayer(e,t);case`graphics`:case`sketch`:return this._createFeatureSnappingSourceGraphicsLayer(e,t);case`map-notes`:return this._createFeatureSnappingSourceMapNotesLayer(e,t);case`scene`:case`building-scene`:return this._createFeatureSnappingSourceSceneLayer(e,t)}return null}async _createFeatureSnappingSourceSceneLayer(e,t){let{view:n}=this;if(n==null||n.type!==`3d`)return null;let r=await this._getSourceModule(`scene`);return o(t),this._handleSourceAbort(new r.SceneLayerSnappingSource({layerSource:e,view:n}),t)}async _createFeatureSnappingSourceFeatureLayer(e,t){switch(e.layer.source?.type){case`feature-layer`:case`oriented-imagery`:{let n=await this._getSourceModule(`featureService`);return o(t),this._handleSourceAbort(new n.FeatureServiceSnappingSource({spatialReference:this.spatialReference,view:this.view,layerSource:e}),t)}case`memory`:case`csv`:case`geojson`:case`wfs`:{if(e.layer.geometryType===`mesh`)return null;let n=await this._getSourceModule(`featureCollection`);return o(t),this._handleSourceAbort(new n.FeatureCollectionSnappingSource({layerSource:e,view:this.view}),t)}}return null}async _createFeatureSnappingSourceGraphicsLayer(e,t){let n=await this._getSourceModule(`graphics`);return o(t),this._handleSourceAbort(new n.GraphicsSnappingSource({getGraphicsLayers:()=>[e.layer],spatialReference:this.spatialReference,view:this.view,layerSource:e}),t)}async _createFeatureSnappingSourceMapNotesLayer(e,t){let n=await this._getSourceModule(`notes`);return o(t),this._handleSourceAbort(new n.GraphicsSnappingSource({getGraphicsLayers:()=>e.layer.sublayers?.toArray()??[],spatialReference:this.spatialReference,view:this.view,layerSource:e}),t)}async _getSourceModule(e){let t=this._sourceModules[e];if(t.loader==null){let t=this._loadSourceModule(e),n={module:null,loader:t};this._sourceModules[e]=n;let r=await t,i={module:r,loader:t};return this._sourceModules[e]=i,r}return t.module==null?t.loader:t.module}_loadSourceModule(e){let t=this._updatingHandles;switch(e){case`featureService`:return t.addPromise(import(`./featureSources/FeatureServiceSnappingSource.js`));case`featureCollection`:return t.addPromise(import(`./featureSources/FeatureCollectionSnappingSource.js`));case`graphics`:return t.addPromise(import(`./featureSources/GraphicsSnappingSource.js`));case`notes`:return t.addPromise(import(`./featureSources/GraphicsSnappingSource.js`));case`scene`:return t.addPromise(import(`./featureSources/SceneLayerSnappingSource.js`))}}get test(){}};e([f({constructOnly:!0})],F.prototype,`spatialReference`,void 0),e([f({constructOnly:!0})],F.prototype,`view`,void 0),e([f()],F.prototype,`options`,void 0),e([f({readOnly:!0})],F.prototype,`updating`,null),e([f()],F.prototype,`_snappingSources`,void 0),F=e([p(`esri.views.interactive.snapping.FeatureSnappingEngine`)],F);function I(e){let t=e instanceof A||e instanceof k,n=S(e.constraint)||C(e.constraint);return t&&n&&!L(e.constraint)}function L({start:e,end:t}){let n=g(e,t),r=m(T(e),T(t));return n<v()||r/n<V}function R(e,t,n,r,i,a,{spatialReference:o}){let s=h(B,t);s[0]+=n,s[1]+=r,s[2]+=i;let c=N(s,o,b,a);return c?P(c,e):1/0}const z=_(),B=_(),V=1e-4;export{F as FeatureSnappingEngine};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
-
import{getBasisEncoder as e,destroyBasisEncoder as t}from"../../libs/basisu/BasisUEncoder.js";import{getDXTEncoder as n,destroyDXTEncoder as r}from"../../libs/dxtEncoder/DXTEncoder.js";import{CompressedTextureFormat as i}from"../webgl/enums.js";let a=null,o,s=null,c;class l{constructor(e,t){this.internalFormat=e,this.compressedTexture=t}}function u(){a=null,o=null,s=null,c=null,t(),r()}async function d(e){let t=e.data instanceof ImageBitmap?e.data:null,n;n=e.data instanceof ImageBitmap?g(e.data):_(e.data,e.width,e.height,e.components,e.needsFlip);try{let t=e.preMultiplyAlpha&&!e.isOpaque;if(e.hasS3TC){s||await p();let r=s?.encode(n,e.width,e.height,t);if(r){let e=S(r,!0),t=[r.buffer];return{result:new l(e?.internalFormat??null,e?.textureData??null),transferList:t}}return{result:new l(null,null)}}if(e.hasETC){if(a||await f(),t&&!s&&await p(),t){let t=new Uint8ClampedArray(n.length);s?.premultiply(new Uint8Array(n),e.width,e.height,t),n=t}let r=m(n,e.width,e.height,e.hasMipmap,void 0,void 0,!1,!1,e.isOpaque),i=r?h(r):null,o=i?.compressedTexture?.levels.map(e=>e.buffer)||[];return{result:new l(i?.internalFormat??null,i?.compressedTexture??null),transferList:o}}return{result:new l(null,null)}}finally{t?.close()}}async function f(){a||(a=await(o??=e()),o=null)}async function p(){s||(s=await(c??=n()),c=null)}function m(e,t,n,r,i=255,o=0,s=!1,c=!1,l=!1){if(!a)return null;let u=new a.BasisEncoder;u.setPerceptual(!c),u.setCheckForAlpha(!l),u.setForceAlpha(!1),u.setRenormalize(c),u.setMipGen(r),u.setMipSRGB(!c),u.setCreateKTX2File(!0),u.setKTX2AndBasisSRGBTransferFunc(!c),u.setQualityLevel(i),u.setETC1SCompressionLevel(o);let d=new Uint8Array(e.byteLength);try{u.setSliceSourceImage(0,new Uint8Array(e),t,n,s);let r=u.encode(d);if(!r)return null;let i=new Uint8Array(d.buffer,0,r),o=new a.KTX2File(new Uint8Array(i));try{if(!o.isValid())return null}finally{o.close(),o.delete()}return i}finally{u.delete()}}function h(e){if(!a)return new l(null,null);let t=new a.KTX2File(new Uint8Array(e));try{if(!t.startTranscoding())return new l(null,null);let[e,n]=t.getHasAlpha()?[1,i.COMPRESSED_RGBA8_ETC2_EAC]:[0,i.COMPRESSED_RGB8_ETC2],r=t.getLevels(),a=[];for(let n=0;n<r;n++){let r=new Uint8Array(t.getImageTranscodedSizeInBytes(n,0,0,e));if(!t.transcodeImage(r,n,0,0,e,0,-1,-1))return new l(null,null);a.push(r)}return{internalFormat:n,compressedTexture:{type:`compressed`,levels:a}}}finally{t.close(),t.delete()}}function g(e){let t=new OffscreenCanvas(e.width,e.height),n=t.getContext(`2d
|
|
2
|
+
import{getBasisEncoder as e,destroyBasisEncoder as t}from"../../libs/basisu/BasisUEncoder.js";import{getDXTEncoder as n,destroyDXTEncoder as r}from"../../libs/dxtEncoder/DXTEncoder.js";import{CompressedTextureFormat as i}from"../webgl/enums.js";let a=null,o,s=null,c;class l{constructor(e,t){this.internalFormat=e,this.compressedTexture=t}}function u(){a=null,o=null,s=null,c=null,t(),r()}async function d(e){let t=e.data instanceof ImageBitmap?e.data:null,n;n=e.data instanceof ImageBitmap?g(e.data):_(e.data,e.width,e.height,e.components,e.needsFlip);try{let t=e.preMultiplyAlpha&&!e.isOpaque;if(e.hasS3TC){s||await p();let r=s?.encode(n,e.width,e.height,t);if(r){let e=S(r,!0),t=[r.buffer];return{result:new l(e?.internalFormat??null,e?.textureData??null),transferList:t}}return{result:new l(null,null)}}if(e.hasETC){if(a||await f(),t&&!s&&await p(),t){let t=new Uint8ClampedArray(n.length);s?.premultiply(new Uint8Array(n),e.width,e.height,t),n=t}let r=m(n,e.width,e.height,e.hasMipmap,void 0,void 0,!1,!1,e.isOpaque),i=r?h(r):null,o=i?.compressedTexture?.levels.map(e=>e.buffer)||[];return{result:new l(i?.internalFormat??null,i?.compressedTexture??null),transferList:o}}return{result:new l(null,null)}}finally{t?.close()}}async function f(){a||(a=await(o??=e()),o=null)}async function p(){s||(s=await(c??=n()),c=null)}function m(e,t,n,r,i=255,o=0,s=!1,c=!1,l=!1){if(!a)return null;let u=new a.BasisEncoder;u.setPerceptual(!c),u.setCheckForAlpha(!l),u.setForceAlpha(!1),u.setRenormalize(c),u.setMipGen(r),u.setMipSRGB(!c),u.setCreateKTX2File(!0),u.setKTX2AndBasisSRGBTransferFunc(!c),u.setQualityLevel(i),u.setETC1SCompressionLevel(o);let d=new Uint8Array(e.byteLength);try{u.setSliceSourceImage(0,new Uint8Array(e),t,n,s);let r=u.encode(d);if(!r)return null;let i=new Uint8Array(d.buffer,0,r),o=new a.KTX2File(new Uint8Array(i));try{if(!o.isValid())return null}finally{o.close(),o.delete()}return i}finally{u.delete()}}function h(e){if(!a)return new l(null,null);let t=new a.KTX2File(new Uint8Array(e));try{if(!t.startTranscoding())return new l(null,null);let[e,n]=t.getHasAlpha()?[1,i.COMPRESSED_RGBA8_ETC2_EAC]:[0,i.COMPRESSED_RGB8_ETC2],r=t.getLevels(),a=[];for(let n=0;n<r;n++){let r=new Uint8Array(t.getImageTranscodedSizeInBytes(n,0,0,e));if(!t.transcodeImage(r,n,0,0,e,0,-1,-1))return new l(null,null);a.push(r)}return{internalFormat:n,compressedTexture:{type:`compressed`,levels:a}}}finally{t.close(),t.delete()}}function g(e){let t=new OffscreenCanvas(e.width,e.height),n=t.getContext(`2d`,{willReadFrequently:!0});return n.drawImage(e,0,0),n.getImageData(0,0,t.width,t.height).data}function _(e,t,n,r,i){let a=new Uint8ClampedArray(e).subarray(0,t*n*r);if(!i)return a;let o=new Uint8ClampedArray(a.length),s=t*r;for(let e=0;e<n;e++){let t=e*s,r=(n-e-1)*s;o.set(a.subarray(t,t+s),r)}return o}function v(e){return e.charCodeAt(0)+(e.charCodeAt(1)<<8)+(e.charCodeAt(2)<<16)+(e.charCodeAt(3)<<24)}const y=v(`DXT1`),b=v(`DXT3`),x=v(`DXT5`);function S(e,t){let n=new Int32Array(e.buffer,e.byteOffset,31),r=n[21],a,o;switch(r){case y:a=8,o=i.COMPRESSED_RGB_S3TC_DXT1_EXT;break;case b:a=16,o=i.COMPRESSED_RGBA_S3TC_DXT3_EXT;break;case x:a=16,o=i.COMPRESSED_RGBA_S3TC_DXT5_EXT;break;default:return null}let s=1,c=n[4],l=n[3];(c&3||l&3)&&(c=c+3&-4,l=l+3&-4);let u=c,d=l;n[2]&131072&&t!==!1&&(s=Math.max(1,n[7]));let f,p,m=e.byteOffset+n[1]+4,h=[];for(let t=0;t<s;++t)p=(c+3>>2)*(l+3>>2)*a,f=new Uint8Array(e.buffer,m,p),h.push(f),m+=p,c=Math.max(1,c>>1),l=Math.max(1,l>>1);return{textureData:{type:`compressed`,levels:h},internalFormat:o,width:u,height:d}}export{l as TextureCompressionWorkerOutput,d as compress,m as compressRGBADataToKTX2,h as createTextureDataKTX2,u as destroy,f as initializeBasisEncoder,p as initializeDXTEncoder};
|
package/views/webgl/Texture.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
-
import e from"../../core/Error.js";import has from"../../core/has.js";import t from"../../core/Logger.js";import{abortMaybe as n}from"../../core/maybe.js";import{hasValue as r}from"../../core/object.js";import{throwIfAborted as i,isAbortError as a}from"../../core/promiseUtils.js";import{checkWebGLError as o}from"./checkWebGLError.js";import{ResourceType as s,CompressedTextureFormat as c}from"./enums.js";import{estimateMemory as l}from"./TextureDescriptor.js";import{isCompressedData as u,deriveInternalFormat as d,isTexImageSource as f,is3DTarget as p,validateTexture as m,isCompressedFormat as h,getDimensions as g,isSizedPixelFormat as _,calcMipmapLevels as v}from"./textureUtils.js";import{ValidatedTextureDescriptor as y}from"./ValidatedTextureDescriptor.js";const b=!!has(`esri-tests-disable-gpu-memory-measurements`),x=()=>t.getLogger(`esri/views/webgl/Texture`);class S{static{this.TEXTURE_UNIT_FOR_UPDATES=0}static{this.compressionWorkerHandle=null}constructor(t,n=null,r=null){if(this.type=1,this._glName=null,this._samplingModeDirty=!1,this._wrapModeDirty=!1,this._shadowFilterDirty=!1,this._wasImmutablyAllocated=!1,`context`in t)this._descriptor=t,r=n;else{let r=y.validate(t,n);if(!r)throw new e(`texture:invalid-descriptor`,`Texture descriptor invalid`);this._descriptor=r}this._descriptor.target===34067?this._setDataCubeMap(r):this.setData(r)}get glName(){return this._glName}get descriptor(){return this._descriptor}get usedMemory(){return b?0:l(this._descriptor)}get isDirty(){return this._samplingModeDirty||this._wrapModeDirty||this._shadowFilterDirty}get hasWebGLTextureObject(){return!!this._glName}dispose(){this.abortCompression(),this.hasWebGLTextureObject&&this._descriptor.context?.gl&&(this._descriptor.context.instanceCounter.decrement(s.Texture,this),this._descriptor.context.unbindTexture(this),this._descriptor.context.gl.deleteTexture(this._glName),this._glName=null)}release(){this.dispose()}[Symbol.dispose](){this.dispose()}resize(t,n){let r=this._descriptor;if(r.width!==t||r.height!==n){if(this._wasImmutablyAllocated)throw new e(`texture:immutable-resize`,`Immutable textures can't be resized!`);r.width=t,r.height=n,this._descriptor.target===34067?this._setDataCubeMap(null):this.setData(null)}}enableCompression(e){this._descriptor.compress=e}disableCompression(){this._descriptor.compress=void 0}setData(e){this.abortCompression(),!u(e)&&this._descriptor.internalFormat&&r(c,this._descriptor.internalFormat)&&(this._descriptor.internalFormat=void 0),this._setData(e),!u(e)&&this._descriptor.compress&&this._compressOnWorker(e)}updateData(t,n,r,i,a,o,s=0){o||x().error(`An attempt to use uninitialized data!`),this.hasWebGLTextureObject||x().error(`An attempt to update uninitialized texture!`);let c=this._descriptor;c.internalFormat=d(c);let{context:l,pixelFormat:p,dataType:m,target:h,isImmutable:g}=c;if(g&&!this._wasImmutablyAllocated)throw new e(`texture:uninitialized`,`Cannot update immutable texture before allocation!`);let _=l.bindTexture(this,S.TEXTURE_UNIT_FOR_UPDATES,!0);(n<0||r<0||n+i>c.width||r+a>c.height)&&x().error(`An attempt to update out of bounds of the texture!`),this._configurePixelStorage();let{gl:v}=l;s&&(i&&a||x().warn("Must pass width and height if `UNPACK_SKIP_ROWS` is used"),v.pixelStorei(v.UNPACK_SKIP_ROWS,s)),f(o)?v.texSubImage2D(h,t,n,r,i,a,p,m,o):u(o)?v.compressedTexSubImage2D(h,t,n,r,i,a,c.internalFormat,o.levels[t]):v.texSubImage2D(h,t,n,r,i,a,p,m,o),s&&v.pixelStorei(v.UNPACK_SKIP_ROWS,0),l.bindTexture(_,S.TEXTURE_UNIT_FOR_UPDATES)}updateData3D(t,n,r,i,a,o,s,c){c||x().error(`An attempt to use uninitialized data!`),this.hasWebGLTextureObject||x().error(`An attempt to update an uninitialized texture!`);let l=this._descriptor;l.internalFormat=d(l);let{context:f,pixelFormat:m,dataType:h,isImmutable:g,target:_}=l;if(g&&!this._wasImmutablyAllocated)throw new e(`texture:uninitialized`,`Cannot update immutable texture before allocation!`);p(_)||x().warn(`Attempting to set 3D texture data on a non-3D texture`);let v=f.bindTexture(this,S.TEXTURE_UNIT_FOR_UPDATES);f.setActiveTexture(S.TEXTURE_UNIT_FOR_UPDATES),(n<0||r<0||i<0||n+a>l.width||r+o>l.height||i+s>l.depth)&&x().error(`An attempt to update out of bounds of the texture!`),this._configurePixelStorage();let{gl:y}=f;if(u(c))c=c.levels[t],y.compressedTexSubImage3D(_,t,n,r,i,a,o,s,l.internalFormat,c);else{let e=c;y.texSubImage3D(_,t,n,r,i,a,o,s,m,h,e)}f.bindTexture(v,S.TEXTURE_UNIT_FOR_UPDATES)}generateMipmap(){let t=this._descriptor;if(t.width===0||t.height===0)return;if(!t.hasMipmap){if(this._wasImmutablyAllocated)throw new e(`texture:immutable-change`,`Cannot add mipmaps to immutable texture after allocation`);t.hasMipmap=!0,this._samplingModeDirty=!0,m(t)}t.samplingMode===9729?(this._samplingModeDirty=!0,t.samplingMode=9985):t.samplingMode===9728&&(this._samplingModeDirty=!0,t.samplingMode=9984);let n=this._descriptor.context.bindTexture(this,S.TEXTURE_UNIT_FOR_UPDATES);this._descriptor.context.setActiveTexture(S.TEXTURE_UNIT_FOR_UPDATES),this._descriptor.context.gl.generateMipmap(t.target),this._descriptor.context.bindTexture(n,S.TEXTURE_UNIT_FOR_UPDATES)}clearMipmap(){let t=this._descriptor;if(t.hasMipmap){if(this._wasImmutablyAllocated)throw new e(`texture:immutable-change`,`Cannot delete mipmaps to immutable texture after allocation`);t.hasMipmap=!1,this._samplingModeDirty=!0,m(t)}t.samplingMode===9985?(this._samplingModeDirty=!0,t.samplingMode=9729):t.samplingMode===9984&&(this._samplingModeDirty=!0,t.samplingMode=9728)}setSamplingMode(e){e!==this._descriptor.samplingMode&&(this._descriptor.samplingMode=e,this._samplingModeDirty=!0)}setWrapMode(e){e!==this._descriptor.wrapMode&&(this._descriptor.wrapMode=e,m(this._descriptor),this._wrapModeDirty=!0)}setShadowFiltering(e){e!==this._descriptor.linearFilterDepth&&(this._descriptor.linearFilterDepth=this._descriptor.compareEnabled=e,this.setSamplingMode(e?9729:9728),m(this._descriptor),this._shadowFilterDirty=!0)}applyChanges(){this._samplingModeDirty&&=(this._applySamplingMode(),!1),this._wrapModeDirty&&=(this._applyWrapMode(),!1),this._shadowFilterDirty&&=(this._applyShadowMode(),!1)}abortCompression(){this._compressionAbortController=n(this._compressionAbortController)}_setData(t,n){let r=this._descriptor,i=r.context?.gl;if(!i)return;o(i),this.hasWebGLTextureObject||(this._glName=i.createTexture(),r.context.instanceCounter.increment(s.Texture,this)),m(r);let a=r.context.bindTexture(this,S.TEXTURE_UNIT_FOR_UPDATES);r.context.setActiveTexture(S.TEXTURE_UNIT_FOR_UPDATES),this._configurePixelStorage(),o(i);let c=n??r.target,l=p(c);if(f(t))this._setDataFromTexImageSource(t,c);else{let{width:n,height:a,depth:s}=r;if(n==null||a==null)throw new e(`texture:missing-size`,`Width and height must be specified!`);if(l&&s==null)throw new e(`texture:missing-depth`,`Depth must be specified!`);if(r.internalFormat=d(r),r.isImmutable&&!this._wasImmutablyAllocated&&this._texStorage(c,r.internalFormat,r.hasMipmap,n,a,s),u(t)){if(!h(r.internalFormat))throw new e(`texture:format-mismatch`,`Attempting to use compressed data with an uncompressed format!`);this._setDataFromCompressedSource(t,r.internalFormat,c)}else this._texImage(c,0,r.internalFormat,n,a,s,t),o(i),r.hasMipmap&&this.generateMipmap()}this._applySamplingMode(),this._applyWrapMode(),this._applyAnisotropicFilteringParameters(),this._applyShadowMode(),o(i),r.context.bindTexture(a,S.TEXTURE_UNIT_FOR_UPDATES)}_setDataCubeMap(e=null){for(let t=34069;t<=34074;t++)this._setData(e,t)}_configurePixelStorage(){let e=this._descriptor.context.gl,{unpackAlignment:t,flipped:n,preMultiplyAlpha:r}=this._descriptor;e.pixelStorei(e.UNPACK_ALIGNMENT,t),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,+!!n),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,+!!r)}_setDataFromTexImageSource(e,t){let{gl:n}=this._descriptor.context,r=this._descriptor;r.internalFormat=d(r);let i=p(t),{width:a,height:s,depth:c}=g(e);r.width&&r.height,r.width||=a,r.height||=s,i&&r.depth,i&&(r.depth=c),r.isImmutable&&!this._wasImmutablyAllocated&&this._texStorage(t,r.internalFormat,r.hasMipmap,a,s,c),this._texImage(t,0,r.internalFormat,a,s,c,e),o(n),r.hasMipmap&&(this.generateMipmap(),o(n))}_setDataFromCompressedSource(e,t,n){let r=this._descriptor,{width:i,height:a,depth:o}=r,s=e.levels,c=v(n,i,a,o),l=Math.min(c,s.length)-1;this._descriptor.context.gl.texParameteri(r.target,33085,l),this._forEachMipmapLevel((e,r,i,a)=>{let o=s[Math.min(e,s.length-1)];this._compressedTexImage(n,e,t,r,i,a,o)},l)}_texStorage(t,n,r,i,a,o){let{gl:s}=this._descriptor.context;if(!_(n)&&!h(n))throw new e(`texture:missing-format`,`Immutable textures must have a sized or compressed internal format`);if(!this._descriptor.isImmutable)return;let c=r?v(t,i,a,o):1;if(p(t)){if(o==null)throw new e(`texture:missing-depth`,`Missing depth dimension for 3D texture upload`);s.texStorage3D(t,c,n,i,a,o)}else s.texStorage2D(t,c,n,i,a);this._wasImmutablyAllocated=!0}_texImage(t,n,r,i,a,o,s){let c=this._descriptor.context.gl,l=p(t),{isImmutable:u,pixelFormat:d,dataType:f}=this._descriptor;if(u){if(s!=null){let r=s;if(l){if(o==null)throw new e(`texture:missing-depth`,`Missing depth dimension for 3D texture upload`);c.texSubImage3D(t,n,0,0,0,i,a,o,d,f,r)}else c.texSubImage2D(t,n,0,0,i,a,d,f,r)}}else{let u=s;if(l){if(o==null)throw new e(`texture:missing-depth`,`Missing depth dimension for 3D texture upload`);c.texImage3D(t,n,r,i,a,o,0,d,f,u)}else c.texImage2D(t,n,r,i,a,0,d,f,u)}}_compressedTexImage(t,n,r,i,a,o,s){let c=this._descriptor.context.gl,l=p(t);if(this._descriptor.isImmutable){if(s!=null){if(l){if(o==null)throw new e(`texture:missing-depth`,`Missing depth dimension for 3D texture upload`);c.compressedTexSubImage3D(t,n,0,0,0,i,a,o,r,s)}else c.compressedTexSubImage2D(t,n,0,0,i,a,r,s)}}else if(l){if(o==null)throw new e(`texture:missing-depth`,`Missing depth dimension for 3D texture upload`);c.compressedTexImage3D(t,n,r,i,a,o,0,s)}else c.compressedTexImage2D(t,n,r,i,a,0,s)}async _compressOnWorker(e){let{width:t,height:n,context:r,flipped:o,preMultiplyAlpha:s,hasMipmap:c,compress:l}=this._descriptor;if(!l)return;let{compressionTracker:u,compressionCallback:d,preserveSourceBitmap:f}=l,{compressedTextureETC:p,compressedTextureS3TC:m}=r.capabilities;if(!S.compressionWorkerHandle?.isCompressible(e,this._descriptor)||!p&&!m)return;this.abortCompression();let h=new AbortController;this._compressionAbortController=h,u?.increment();let g,_=!1,v=!1;try{e instanceof ImageBitmap?f?(g=await createImageBitmap(e),i(h),v=!0):g=e:e instanceof Uint8Array?(g=e.buffer,_=this.descriptor.flipped):(g=await createImageBitmap(e,{imageOrientation:o?`flipY`:`none`}),i(h),v=!0);let r={data:g,width:t,height:n,needsFlip:_,components:this._descriptor.pixelFormat===6408?4:3,preMultiplyAlpha:s,isOpaque:this._descriptor.isOpaque,hasMipmap:c,hasETC:!!p,hasS3TC:!!m},a=await S.compressionWorkerHandle.invoke(r,h.signal,1);if(i(h),a.compressedTexture&&this.hasWebGLTextureObject){let e=this.usedMemory;this._descriptor.internalFormat=a.internalFormat,this._setData(a.compressedTexture),d?.(e-this.usedMemory)}}catch(e){a(e)||x().error(`Texture compression failed!`)}finally{u?.decrement(),this._compressionAbortController?.signal.aborted&&(this._compressionAbortController=null),v&&g instanceof ImageBitmap&&g.close()}}_forEachMipmapLevel(t,n=1/0){let{width:r,height:i,depth:a,hasMipmap:o,target:s}=this._descriptor,c=s===32879;if(r==null||i==null||c&&a==null)throw new e(`texture:missing-size`,`Missing texture dimensions for mipmap calculation`);for(let e=0;t(e,r,i,a),!(!o||r===1&&i===1&&(!c||a===1)||e>=n);++e)r=Math.max(1,r>>1),i=Math.max(1,i>>1),c&&(a=Math.max(1,a>>1))}_applySamplingMode(){let e=this._descriptor,t=e.context?.gl,n=e.samplingMode,r=e.samplingMode;n===9985||n===9987?(n=9729,e.hasMipmap||(r=9729)):(n===9984||n===9986)&&(n=9728,e.hasMipmap||(r=9728)),t.texParameteri(e.target,t.TEXTURE_MAG_FILTER,n),t.texParameteri(e.target,t.TEXTURE_MIN_FILTER,r)}_applyWrapMode(){let e=this._descriptor,t=e.context?.gl;typeof e.wrapMode==`number`?(t.texParameteri(e.target,t.TEXTURE_WRAP_S,e.wrapMode),t.texParameteri(e.target,t.TEXTURE_WRAP_T,e.wrapMode)):(t.texParameteri(e.target,t.TEXTURE_WRAP_S,e.wrapMode.s),t.texParameteri(e.target,t.TEXTURE_WRAP_T,e.wrapMode.t))}_applyShadowMode(){let e=this._descriptor,t=e.context?.gl,n=e.compareEnabled?t.COMPARE_REF_TO_TEXTURE:t.NONE;t.texParameteri(e.target,t.TEXTURE_COMPARE_MODE,n),e.compareEnabled&&t.texParameteri(e.target,t.TEXTURE_COMPARE_FUNC,t.GREATER),o(t)}_applyAnisotropicFilteringParameters(){let e=this._descriptor,t=e.context.capabilities.textureFilterAnisotropic;t&&e.context.gl.texParameterf(e.target,t.TEXTURE_MAX_ANISOTROPY,e.maxAnisotropy??1)}}export{S as default};
|
|
2
|
+
import e from"../../core/Error.js";import has from"../../core/has.js";import t from"../../core/Logger.js";import{abortMaybe as n}from"../../core/maybe.js";import{hasValue as r}from"../../core/object.js";import{throwIfAborted as i,isAbortError as a}from"../../core/promiseUtils.js";import{checkWebGLError as o}from"./checkWebGLError.js";import{ResourceType as s,CompressedTextureFormat as c}from"./enums.js";import{estimateMemory as l}from"./TextureDescriptor.js";import{isCompressedData as u,deriveInternalFormat as d,isTexImageSource as f,is3DTarget as p,validateTexture as m,isCompressedFormat as h,getDimensions as g,isSizedPixelFormat as _,calcMipmapLevels as v}from"./textureUtils.js";import{ValidatedTextureDescriptor as y}from"./ValidatedTextureDescriptor.js";const b=!!has(`esri-tests-disable-gpu-memory-measurements`),x=()=>t.getLogger(`esri/views/webgl/Texture`);class S{static{this.TEXTURE_UNIT_FOR_UPDATES=0}static{this.compressionWorkerHandle=null}constructor(t,n=null,r=null){if(this.type=1,this._glName=null,this._samplingModeDirty=!1,this._wrapModeDirty=!1,this._shadowFilterDirty=!1,this._wasImmutablyAllocated=!1,`context`in t)this._descriptor=t,r=n;else{let r=y.validate(t,n);if(!r)throw new e(`texture:invalid-descriptor`,`Texture descriptor invalid`);this._descriptor=r}this._descriptor.target===34067?this._setDataCubeMap(r):this.setData(r)}get glName(){return this._glName}get descriptor(){return this._descriptor}get usedMemory(){return b?0:l(this._descriptor)}get isDirty(){return this._samplingModeDirty||this._wrapModeDirty||this._shadowFilterDirty}get hasWebGLTextureObject(){return!!this._glName}dispose(){this.abortCompression(),this.hasWebGLTextureObject&&this._descriptor.context?.gl&&(this._descriptor.context.instanceCounter.decrement(s.Texture,this),this._descriptor.context.unbindTexture(this),this._descriptor.context.gl.deleteTexture(this._glName),this._glName=null)}release(){this.dispose()}[Symbol.dispose](){this.dispose()}resize(t,n){let r=this._descriptor;if(r.width!==t||r.height!==n){if(this._wasImmutablyAllocated)throw new e(`texture:immutable-resize`,`Immutable textures can't be resized!`);r.width=t,r.height=n,this._descriptor.target===34067?this._setDataCubeMap(null):this.setData(null)}}enableCompression(e){this._descriptor.compress=e}disableCompression(){this._descriptor.compress=void 0}setData(e){this.abortCompression(),!u(e)&&this._descriptor.internalFormat&&r(c,this._descriptor.internalFormat)&&(this._descriptor.internalFormat=void 0),this._setData(e),!u(e)&&this._descriptor.compress&&this._compressOnWorker(e)}updateData(t,n,r,i,a,o,s=0){o||x().error(`An attempt to use uninitialized data!`),this.hasWebGLTextureObject||x().error(`An attempt to update uninitialized texture!`);let c=this._descriptor;c.internalFormat=d(c);let{context:l,pixelFormat:p,dataType:m,target:h,isImmutable:g}=c;if(g&&!this._wasImmutablyAllocated)throw new e(`texture:uninitialized`,`Cannot update immutable texture before allocation!`);let _=l.bindTexture(this,S.TEXTURE_UNIT_FOR_UPDATES,!0);(n<0||r<0||n+i>c.width||r+a>c.height)&&x().error(`An attempt to update out of bounds of the texture!`),this._configurePixelStorage();let{gl:v}=l;s&&(i&&a||x().warn("Must pass width and height if `UNPACK_SKIP_ROWS` is used"),v.pixelStorei(v.UNPACK_SKIP_ROWS,s)),f(o)?v.texSubImage2D(h,t,n,r,i,a,p,m,o):u(o)?v.compressedTexSubImage2D(h,t,n,r,i,a,c.internalFormat,o.levels[t]):v.texSubImage2D(h,t,n,r,i,a,p,m,o),s&&v.pixelStorei(v.UNPACK_SKIP_ROWS,0),l.bindTexture(_,S.TEXTURE_UNIT_FOR_UPDATES)}updateData3D(t,n,r,i,a,o,s,c){c||x().error(`An attempt to use uninitialized data!`),this.hasWebGLTextureObject||x().error(`An attempt to update an uninitialized texture!`);let l=this._descriptor;l.internalFormat=d(l);let{context:f,pixelFormat:m,dataType:h,isImmutable:g,target:_}=l;if(g&&!this._wasImmutablyAllocated)throw new e(`texture:uninitialized`,`Cannot update immutable texture before allocation!`);p(_)||x().warn(`Attempting to set 3D texture data on a non-3D texture`);let v=f.bindTexture(this,S.TEXTURE_UNIT_FOR_UPDATES);f.setActiveTexture(S.TEXTURE_UNIT_FOR_UPDATES),(n<0||r<0||i<0||n+a>l.width||r+o>l.height||i+s>l.depth)&&x().error(`An attempt to update out of bounds of the texture!`),this._configurePixelStorage();let{gl:y}=f;if(u(c))c=c.levels[t],y.compressedTexSubImage3D(_,t,n,r,i,a,o,s,l.internalFormat,c);else{let e=c;y.texSubImage3D(_,t,n,r,i,a,o,s,m,h,e)}f.bindTexture(v,S.TEXTURE_UNIT_FOR_UPDATES)}generateMipmap(){let t=this._descriptor;if(t.width===0||t.height===0)return;if(!t.hasMipmap){if(this._wasImmutablyAllocated)throw new e(`texture:immutable-change`,`Cannot add mipmaps to immutable texture after allocation`);t.hasMipmap=!0,this._samplingModeDirty=!0,m(t)}t.samplingMode===9729?(this._samplingModeDirty=!0,t.samplingMode=9985):t.samplingMode===9728&&(this._samplingModeDirty=!0,t.samplingMode=9984);let n=this._descriptor.context.bindTexture(this,S.TEXTURE_UNIT_FOR_UPDATES);this._descriptor.context.setActiveTexture(S.TEXTURE_UNIT_FOR_UPDATES),this._descriptor.context.gl.generateMipmap(t.target),this._descriptor.context.bindTexture(n,S.TEXTURE_UNIT_FOR_UPDATES)}clearMipmap(){let t=this._descriptor;if(t.hasMipmap){if(this._wasImmutablyAllocated)throw new e(`texture:immutable-change`,`Cannot delete mipmaps to immutable texture after allocation`);t.hasMipmap=!1,this._samplingModeDirty=!0,m(t)}t.samplingMode===9985?(this._samplingModeDirty=!0,t.samplingMode=9729):t.samplingMode===9984&&(this._samplingModeDirty=!0,t.samplingMode=9728)}setSamplingMode(e){e!==this._descriptor.samplingMode&&(this._descriptor.samplingMode=e,this._samplingModeDirty=!0)}setWrapMode(e){e!==this._descriptor.wrapMode&&(this._descriptor.wrapMode=e,m(this._descriptor),this._wrapModeDirty=!0)}setShadowFiltering(e){e!==this._descriptor.linearFilterDepth&&(this._descriptor.linearFilterDepth=this._descriptor.compareEnabled=e,this.setSamplingMode(e?9729:9728),m(this._descriptor),this._shadowFilterDirty=!0)}applyChanges(){this._samplingModeDirty&&=(this._applySamplingMode(),!1),this._wrapModeDirty&&=(this._applyWrapMode(),!1),this._shadowFilterDirty&&=(this._applyShadowMode(),!1)}abortCompression(){this._compressionAbortController=n(this._compressionAbortController)}_setData(t,n){let r=this._descriptor,i=r.context?.gl;if(!i)return;o(i),this.hasWebGLTextureObject||(this._glName=i.createTexture(),r.context.instanceCounter.increment(s.Texture,this)),m(r);let a=r.context.bindTexture(this,S.TEXTURE_UNIT_FOR_UPDATES);r.context.setActiveTexture(S.TEXTURE_UNIT_FOR_UPDATES),this._configurePixelStorage(),o(i);let c=n??r.target,l=p(c);if(f(t))this._setDataFromTexImageSource(t,c);else{let{width:n,height:a,depth:s}=r;if(n==null||a==null)throw new e(`texture:missing-size`,`Width and height must be specified!`);if(l&&s==null)throw new e(`texture:missing-depth`,`Depth must be specified!`);if(r.internalFormat=d(r),r.isImmutable&&!this._wasImmutablyAllocated&&this._texStorage(c,r.internalFormat,r.hasMipmap,n,a,s),u(t)){if(!h(r.internalFormat))throw new e(`texture:format-mismatch`,`Attempting to use compressed data with an uncompressed format!`);this._setDataFromCompressedSource(t,r.internalFormat,c)}else this._texImage(c,0,r.internalFormat,n,a,s,t),o(i),r.hasMipmap&&this.generateMipmap()}this._applySamplingMode(),this._applyWrapMode(),this._applyAnisotropicFilteringParameters(),this._applyShadowMode(),o(i),r.context.bindTexture(a,S.TEXTURE_UNIT_FOR_UPDATES)}_setDataCubeMap(e=null){for(let t=34069;t<=34074;t++)this._setData(e,t)}_configurePixelStorage(){let e=this._descriptor.context.gl,{unpackAlignment:t,flipped:n,preMultiplyAlpha:r}=this._descriptor;e.pixelStorei(e.UNPACK_ALIGNMENT,t),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,+!!n),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,+!!r)}_setDataFromTexImageSource(e,t){let{gl:n}=this._descriptor.context,r=this._descriptor;r.internalFormat=d(r);let i=p(t),{width:a,height:s,depth:c}=g(e);r.width&&r.height,r.width||=a,r.height||=s,i&&r.depth,i&&(r.depth=c),r.isImmutable&&!this._wasImmutablyAllocated&&this._texStorage(t,r.internalFormat,r.hasMipmap,a,s,c),this._texImage(t,0,r.internalFormat,a,s,c,e),o(n),r.hasMipmap&&(this.generateMipmap(),o(n))}_setDataFromCompressedSource(e,t,n){let r=this._descriptor,{width:i,height:a,depth:o}=r,s=e.levels,c=v(n,i,a,o),l=Math.min(c,s.length)-1;this._descriptor.context.gl.texParameteri(r.target,33085,l),this._forEachMipmapLevel((e,r,i,a)=>{let o=s[Math.min(e,s.length-1)];this._compressedTexImage(n,e,t,r,i,a,o)},l)}_texStorage(t,n,r,i,a,o){let{gl:s}=this._descriptor.context;if(!_(n)&&!h(n))throw new e(`texture:missing-format`,`Immutable textures must have a sized or compressed internal format`);if(!this._descriptor.isImmutable)return;let c=r?v(t,i,a,o):1;if(p(t)){if(o==null)throw new e(`texture:missing-depth`,`Missing depth dimension for 3D texture upload`);s.texStorage3D(t,c,n,i,a,o)}else s.texStorage2D(t,c,n,i,a);this._wasImmutablyAllocated=!0}_texImage(t,n,r,i,a,o,s){let c=this._descriptor.context.gl,l=p(t),{isImmutable:u,pixelFormat:d,dataType:f}=this._descriptor;if(u){if(s!=null){let r=s;if(l){if(o==null)throw new e(`texture:missing-depth`,`Missing depth dimension for 3D texture upload`);c.texSubImage3D(t,n,0,0,0,i,a,o,d,f,r)}else c.texSubImage2D(t,n,0,0,i,a,d,f,r)}}else{let u=s;if(l){if(o==null)throw new e(`texture:missing-depth`,`Missing depth dimension for 3D texture upload`);c.texImage3D(t,n,r,i,a,o,0,d,f,u)}else c.texImage2D(t,n,r,i,a,0,d,f,u)}}_compressedTexImage(t,n,r,i,a,o,s){let c=this._descriptor.context.gl,l=p(t);if(this._descriptor.isImmutable){if(s!=null){if(l){if(o==null)throw new e(`texture:missing-depth`,`Missing depth dimension for 3D texture upload`);c.compressedTexSubImage3D(t,n,0,0,0,i,a,o,r,s)}else c.compressedTexSubImage2D(t,n,0,0,i,a,r,s)}}else if(l){if(o==null)throw new e(`texture:missing-depth`,`Missing depth dimension for 3D texture upload`);c.compressedTexImage3D(t,n,r,i,a,o,0,s)}else c.compressedTexImage2D(t,n,r,i,a,0,s)}async _compressOnWorker(e){let{width:t,height:n,context:r,flipped:o,preMultiplyAlpha:s,hasMipmap:c,compress:l}=this._descriptor;if(!l)return;let{compressionTracker:u,compressionCallback:d,preserveSourceBitmap:f}=l,{compressedTextureETC:p,compressedTextureS3TC:m}=r.capabilities;if(!S.compressionWorkerHandle?.isCompressible(e,this._descriptor)||!p&&!m)return;this.abortCompression();let h=new AbortController;this._compressionAbortController=h,u?.increment();let g,_=!1,v=!1;try{e instanceof ImageBitmap?f?(g=await createImageBitmap(e),i(h),v=!0):g=e:e instanceof Uint8Array?(g=e.buffer,_=this.descriptor.flipped):(g=await createImageBitmap(e,{imageOrientation:o?`flipY`:`none`}),i(h),v=!0);let r={data:g,width:t,height:n,needsFlip:_,components:this._descriptor.pixelFormat===6408?4:3,preMultiplyAlpha:s,isOpaque:this._descriptor.isOpaque,hasMipmap:c,hasETC:!!p,hasS3TC:!!m},a=await S.compressionWorkerHandle.invoke(r,h.signal,1);if(i(h),a.compressedTexture&&this.hasWebGLTextureObject){let e=this.usedMemory;this._descriptor.internalFormat=a.internalFormat,this._setData(a.compressedTexture),d?.(e-this.usedMemory)}}catch(e){a(e)||x().error(`Texture compression failed!`)}finally{u?.decrement(),this._compressionAbortController?.signal.aborted&&(this._compressionAbortController=null),v&&g instanceof ImageBitmap&&g.close()}}_forEachMipmapLevel(t,n=1/0){let{width:r,height:i,depth:a,hasMipmap:o,target:s}=this._descriptor,c=s===32879;if(r==null||i==null||c&&a==null)throw new e(`texture:missing-size`,`Missing texture dimensions for mipmap calculation`);for(let e=0;t(e,r,i,a),!(!o||r===1&&i===1&&(!c||a===1)||e>=n);++e)r=Math.max(1,r>>1),i=Math.max(1,i>>1),c&&(a=Math.max(1,a>>1))}_applySamplingMode(){let e=this._descriptor,t=e.context?.gl,n=e.samplingMode,r=e.samplingMode;n===9985||n===9987?(n=9729,e.hasMipmap||(r=9729)):(n===9984||n===9986)&&(n=9728,e.hasMipmap||(r=9728)),t.texParameteri(e.target,t.TEXTURE_MAG_FILTER,n),t.texParameteri(e.target,t.TEXTURE_MIN_FILTER,r),e.maxMipLevel!=null&&t.texParameteri(e.target,t.TEXTURE_MAX_LEVEL,e.maxMipLevel)}_applyWrapMode(){let e=this._descriptor,t=e.context?.gl;typeof e.wrapMode==`number`?(t.texParameteri(e.target,t.TEXTURE_WRAP_S,e.wrapMode),t.texParameteri(e.target,t.TEXTURE_WRAP_T,e.wrapMode)):(t.texParameteri(e.target,t.TEXTURE_WRAP_S,e.wrapMode.s),t.texParameteri(e.target,t.TEXTURE_WRAP_T,e.wrapMode.t))}_applyShadowMode(){let e=this._descriptor,t=e.context?.gl,n=e.compareEnabled?t.COMPARE_REF_TO_TEXTURE:t.NONE;t.texParameteri(e.target,t.TEXTURE_COMPARE_MODE,n),e.compareEnabled&&t.texParameteri(e.target,t.TEXTURE_COMPARE_FUNC,t.GREATER),o(t)}_applyAnisotropicFilteringParameters(){let e=this._descriptor,t=e.context.capabilities.textureFilterAnisotropic;t&&e.context.gl.texParameterf(e.target,t.TEXTURE_MAX_ANISOTROPY,e.maxAnisotropy??1)}}export{S as default};
|
|
@@ -72,7 +72,7 @@ export default class Environment extends JSONSupport {
|
|
|
72
72
|
get lighting(): SunLighting | VirtualLighting;
|
|
73
73
|
set lighting(value: (SunLightingProperties & { type?: "sun" }) | (VirtualLightingProperties & { type: "virtual" }));
|
|
74
74
|
/**
|
|
75
|
-
* Indicates whether stars
|
|
75
|
+
* Indicates whether the deep-sky background, which contains stars and the Milky Way, is enabled.
|
|
76
76
|
*
|
|
77
77
|
* @default true
|
|
78
78
|
*/
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import{pushIfSome as t}from"../../core/arrayUtils.js";import{createTask as n}from"../../core/asyncUtils.js";import r from"../../core/Collection.js";import i from"../../core/Error.js";import{EventedAccessor as a}from"../../core/Evented.js";import o from"../../core/Logger.js";import{getOrCreateMapValue as s}from"../../core/MapUtils.js";import{destroyMaybe as c,abortMaybe as l}from"../../core/maybe.js";import{throwIfAborted as u,whenOrAbort as ee,ignoreAbortErrors as d,isAbortError as f}from"../../core/promiseUtils.js";import p from"../../core/ReactiveMap.js";import{on as te,sync as m,watch as h,syncAndInitial as g,initial as _,whenOnce as v}from"../../core/reactiveUtils.js";import{property as y,subclass as b}from"../../core/accessorSupport/decorators.js";import{UpdatingHandles as ne}from"../../core/support/UpdatingHandles.js";import x from"../../geometry/SpatialReference.js";import{getGraphicLayer as S}from"../../graphic/graphicOriginUtils.js";import{isSubtypeGroupLayer as C,isSubtypeSublayer as w,isFeatureLayer as re,getSubtypesFromLayer as ie}from"../../layers/support/layerUtils.js";import{system as T}from"../../time/constants.js";import{getAttachmentKey as E}from"./attachmentUtils.js";import{getLayerTimeZone as D,getEffectiveTimeZone as O,createReactiveGraphic as k,isAttributeFormSupportedLayerWithAttachments as A,layerSupportsAttachments as j,queryAttachmentsForElements as M}from"./batchAttributeFormUtils.js";import{ReactiveContingentValuesManager as N}from"./ReactiveContingentValuesManager.js";import{parseFormTemplateString as P}from"./stringUtils.js";import{ValueChangeTransaction as F}from"./ValueChangeTransaction.js";import{ArcadeExecutorProvider as I}from"./expressions/ArcadeExecutorProvider.js";import{ExpressionsManager as L}from"./expressions/ExpressionsManager.js";import{ExpressionsModel as R}from"./expressions/ExpressionsModel.js";import z from"./inputs/BatchFormInputs.js";import{createBatchFormInputsFromBatchFormTemplate as B,mergeBatchFormInputsFromNewTemplate as V}from"./inputs/support/createBatchFormInputs.js";import{isGroupInput as H,isFieldInput as U}from"./inputs/support/inputUtils.js";import W from"./templates/BatchFormTemplate.js";import{createBatchFormTemplate as G}from"./templates/support/createBatchFormTemplate.js";import{isExcludedFromSharedForm as K,isGroupElementTemplate as q}from"./templates/support/templateUtils.js";import{ContingentValuesManager as J,isLayerWithContingentValues as Y}from"../support/ContingentValuesManager.js";import{isEmptyValue as X}from"../support/forms/formUtils.js";function ae(e,t){return e?.find(e=>e.layer===t)}let Z=class extends a{constructor(e){super(e),this._attachmentCache=new p,this.activeFeatureIndex=-1,this.attachmentsEnabled=!1,this.callbacks=null,this.disabled=!1,this.editType=`NA`,this.features=new r,this._hasAsyncArcadeExpressions=!1,this.highlightHelper=null,this.maximumFeatureCount=2e3,this.maximumFeatureCountWithComplexForms=50,this.pageStack=[],this.readOnly=!1,this.pendingSubtypeChoice=null,this.spatialReference=null,this.submitHasBeenAttempted=!1,this.view=null,this.userHasChangedValues=!1,this.layerInfos=null,this._arcadeExecutorProvider=new I,this._activeAssociation=null,this._activeAssociationsInput=null,this._activeRelationshipInput=null,this._ownContingentValuesManager=null,this._activeFormInputsByElementId=new Map,this._emptyForm=new z({inputs:[]}),this._emptyFormTemplate=new W({elements:[]}),this._featureFormMap=new p,this._prepareTask=null,this._layerTemplateUpdateTask=null,this._syncAttachmentsTask=null,this._reactiveGraphicLookup=new p,this._updatingHandles=new ne,this._submitTask=null,this._layerTemplateMap=new p,this._workingFeatures=new r,this._expressionsManager=new L({arcadeContext:{editType:`NA`,spatialReference:null,map:null,timeZone:T}}),this._getExternalErrorForFeature=(e,t)=>this._reactiveContingentValuesManager.getViolationTypeForField(e,t),this._getFieldValueOptionsForFeature=e=>this._reactiveContingentValuesManager.getAndWatchFieldValueOptions(e),this._requestDeferredExpressionEvaluation=async({features:e,getExecutor:t})=>this._valueChangeTransaction(n=>this._expressionsManager.requestDeferredExecution(e,t,n),`user`),this.sharedForm=this._emptyForm,this.sharedFormTemplate=this._emptyFormTemplate}initialize(){this.contingentValuesManager||=this._ownContingentValuesManager=new J,this.addHandles([te(()=>this.features,`after-changes`,()=>{this.goHome(),this.notifyChange(`layers`),this._prepare()},m),h(()=>[this.attachmentsEnabled,this.features,this.map,this.timeZone,this.editType],()=>this._prepare(),m),h(()=>this.activeForm,()=>{this.goHome(),this._activeFormInputsByElementId.clear(),this._syncAttachments()},m),h(()=>this.activeFeature,()=>{this.goHome()},m),h(()=>this.page,e=>{let t=[...this.pageStack];if(!t.includes(e))t.push(e);else for(;t.length&&t.at(-1)!==e;)t.pop();this.pageStack=t},g),h(()=>this.contingentValuesManager,e=>{c(this._reactiveContingentValuesManager),this._reactiveContingentValuesManager=new N({manager:e})},_)]),this._prepare()}destroy(){this._prepareTask=l(this._prepareTask),this.pendingSubtypeChoice?.reject(),this._layerTemplateUpdateTask=l(this._layerTemplateUpdateTask),this._syncAttachmentsTask=l(this._syncAttachmentsTask),this._workingFeatures.destroyAll(),c(this._expressionsManager),c(this._reactiveContingentValuesManager),this._updatingHandles.destroy(),this._reactiveGraphicLookup=new p,this._emptyForm.destroy(),this._emptyFormTemplate.destroy(),this._ownContingentValuesManager=c(this._ownContingentValuesManager),this.highlightHelper?.removeAll()}get activeFeature(){let e=this.activeFeatureIndex;return e<0?null:this.features.at(e)}get activeForm(){if(this.mode===`batch`)return this.sharedForm;let e=this._workingFeatures.at(this.activeFeatureIndex);if(!e)return this._emptyForm;let t=this._featureFormMap.get(e);if(t)return t;let n=this._makeBatchFormInputsForFeature(e);return n!==this._emptyForm&&this._featureFormMap.set(e,n),n}get activeLayer(){let{activeFeature:e}=this;return e?S(e)??null:null}get activeAssociation(){return this._activeAssociation}get activeAssociationsInput(){return this._activeAssociationsInput}get activeAssociationType(){return this.activeAssociationsInput?.activeAssociationType}get activeRelationshipInput(){return this._activeRelationshipInput}get calculating(){return this._expressionsManager.calculating}get expressionsManager(){return this._expressionsManager}get canGoBack(){return this.pageStack.length>1}get expressionEvaluationFailed(){return this._expressionsManager.expressionEvaluationFailed}get hasNonActiveInvalidFeatures(){if(this.mode===`batch`)return!1;let{activeFeature:e}=this;return this.invalidFeatures.some(t=>t!==e)}get hasAsyncArcadeExpressions(){return this._hasAsyncArcadeExpressions}get hasTooManyFeatures(){return this._workingFeatures.length>this.maximumFeatureCount}get hasTooManyComplexFeatures(){return this._workingFeatures.length>this.maximumFeatureCountWithComplexForms&&this.hasAsyncArcadeExpressions}get invalidFeatures(){return this.sharedForm.invalidFeatures}get hasVisibleInputs(){return this.visibleInputs.length>0}get hasLayersWithContingentValues(){let e=this.contingentValuesManager;for(let t of this.layers)if(e.getFieldsWithContingentValues(t).size>0)return!0;return!1}get formDescription(){return this._computeFormHeaderField(this.activeForm?.description)}get formTitle(){return this._computeFormHeaderField(this.activeForm?.title)}get effectiveTimeZone(){let{activeLayer:e,timeZone:t}=this;if(!e)return t??`system`;let n=D(e);return O(t,n)}get visibleInputs(){return this.activeForm.inputs.filter(e=>e.visible)}get map(){return this.view?.map??null}set map(e){this._override(`map`,e)}get noVisibleElementsReason(){if(this.hasVisibleInputs)return null;if(this.activeForm.inputs.length===0)return`noElements`;let e=new Set;for(let t of this.activeForm.inputs)switch(t.visibilityCode){case`hidden:not-in-all-layers`:case`hidden:no-domain-in-common`:e.add(`noElementsInCommon`);break;case`hidden:field-definition`:case`hidden:group-visibility-expression:all-features`:case`hidden:visibility-expression:all-features`:e.add(`allElementsHidden`);break;case`hidden:group-visibility-expression:some-features`:case`hidden:visibility-expression:some-features`:return`elementsHiddenInSome`}return e.has(`allElementsHidden`)?`allElementsHidden`:`noElementsInCommon`}get page(){return this.showingSelectedAttachmentReplacePage&&this.selectedAttachmentDetails?`replacing-attachment`:this.selectedAttachmentDetails?`viewing-attachment-details`:this.selectedAttachmentAddInput?`adding-attachments`:this.selectedAttachmentListInput?`viewing-attachments`:this.activeAssociationsInput?.associatedLayer?`viewing-associated-features`:this.activeAssociationsInput?`viewing-associated-layers`:this.activeRelationshipInput?.showAllRelatedRecords?`viewing-related-records`:this.activeRelationshipInput?.showAllCategories?`viewing-related-categories`:`default`}get subtypes(){let e=this.activeLayer;return C(e)||w(e)||re(e)?ie(e):[]}get status(){let e=this._prepareTask;return e==null?`not-loaded`:e.finished?e.error==null?`loaded`:`failed`:`loading`}get timeZone(){return this.view?.timeZone??null}set timeZone(e){this._overrideIfSome(`timeZone`,e)}get updating(){return this._updatingHandles.updating||this.calculating}get valid(){return this.sharedForm.valid&&Array.from(this._featureFormMap.values()).every(e=>e.valid)}get layers(){return Array.from(this._layersSet)}get mode(){return this.activeFeatureIndex>-1?`single`:`batch`}submit(){if(this.submitHasBeenAttempted=!0,this.sharedForm.touchAll(),this._featureFormMap.forEach(e=>e.touchAll()),this.validateContingentValues(this._workingFeatures),!this._hasPendingAttachmentHydration)return this._emitSubmit(),Promise.resolve();if(this._submitTask)return this._submitTask.promise;let e=n(async()=>{await Promise.all(this._allAttachmentInputs.map(e=>e.waitForPendingAttachmentUpdateData())),this._emitSubmit()});return this._submitTask=e,e.promise.finally(()=>{this._submitTask===e&&(this._submitTask=null)}),e.promise}get selectedAttachment(){return this._get(`selectedAttachment`)??null}set selectedAttachment(e){this.showingSelectedAttachmentReplacePage=!1,this._set(`selectedAttachment`,e),e!=null&&(this.selectedAttachmentAddElementId=null)}get selectedAttachmentAddElementId(){return this._get(`selectedAttachmentAddElementId`)??null}set selectedAttachmentAddElementId(e){this.showingSelectedAttachmentReplacePage=!1,this._set(`selectedAttachmentAddElementId`,e),e!=null&&(this.selectedAttachment=null,this.selectedAttachmentListElementId=null)}get selectedAttachmentListElementId(){return this._get(`selectedAttachmentListElementId`)??null}set selectedAttachmentListElementId(e){this._set(`selectedAttachmentListElementId`,e),e!=null&&(this.selectedAttachment=null,this.selectedAttachmentAddElementId=null)}get selectedAttachmentListInput(){let e=this.selectedAttachmentListElementId,t=this.activeForm;if(!e||!t)return null;let n=t.allAttachmentElementInputs.find(t=>t.template.elementId===e)||null;return n?.attachments.length?n:null}get showingSelectedAttachmentReplacePage(){return this._get(`showingSelectedAttachmentReplacePage`)??!1}set showingSelectedAttachmentReplacePage(e){this._set(`showingSelectedAttachmentReplacePage`,e&&this.selectedAttachmentDetails!=null)}get selectedAttachmentAddInput(){let e=this.selectedAttachmentAddElementId,t=this.activeForm;return!e||!t?null:t.allAttachmentElementInputs.find(t=>t.template.elementId===e)||null}get selectedAttachmentDetails(){let e=this.selectedAttachment,t=this.activeForm;if(!e||!t)return null;let n=t.allAttachmentElementInputs.find(t=>t.template.elementId===e.elementId);if(!n)return null;let r=n.attachments.findIndex(t=>E(t)===e.attachmentKey);return r===-1?null:{attachment:n.attachments[r],input:n}}get _allAttachmentInputs(){let e=[...this.sharedForm.allAttachmentElementInputs];for(let t of this._featureFormMap.values())e.push(...t.allAttachmentElementInputs);return e}get _hasPendingAttachmentHydration(){return this._allAttachmentInputs.some(e=>e.hasPendingAttachmentUpdateData)}get _layersSet(){let e=new Set;for(let t of this._workingFeatures){let n=S(t.plainGraphic);n&&e.add(n)}return e}applyStashedAttachmentEdits(e){let t=this._allAttachmentInputs;for(let n of e){let e=t.find(e=>e.label===n.label&&e.attachmentKeyword===n.keywords);e&&e.applyStashedEdits(n)}}findFieldInput(e){if(e==null)return;let t=this._activeFormInputsByElementId;if(t.has(e))return t.get(e);let n=this.activeForm.allFieldInputs.find(t=>t.template.elementId===e);if(n!==void 0)return t.set(e,n),n}getFirstVisibleInvalidFieldInput(){if(this.hasVisibleInputs&&!this.activeForm.valid)for(let e of this.visibleInputs){if(H(e)){let t=e.inputs.find(e=>U(e)&&!e.valid);if(t)return{input:t,groupInput:e}}if(U(e)&&!e.valid)return{input:e}}}getFieldInputValue(e){return this.findFieldInput(e)?.value}getValues(e){let t=this._reactiveGraphicLookup.get(e);if(!t)throw new i(`feature-not-found`,`The given feature is not present in the BatchAttributeForm`);return{...t.attributes}}async goBack(){switch(this.page){case`replacing-attachment`:this.setShowingSelectedAttachmentReplacePage(!1);return;case`viewing-attachment-details`:this.setSelectedAttachment(null);return;case`adding-attachments`:this.setSelectedAttachmentAddElementId(null);return;case`viewing-attachments`:this.setSelectedAttachmentListElementId(null);return;case`viewing-associated-features`:this.setActiveAssociationsLayer(null);return;case`viewing-associated-layers`:this.setActiveAssociationsInput(null);return;case`viewing-related-categories`:case`viewing-related-records`:this.clearActiveRelationshipCategoryOrInput();return;default:return}}async goHome(){this.setShowingSelectedAttachmentReplacePage(!1),this.setSelectedAttachment(null),this.setSelectedAttachmentAddElementId(null),this.setSelectedAttachmentListElementId(null),this.setActiveAssociationsLayer(null),this.setActiveAssociationsInput(null),this.clearAllRelationshipSettings()}notifyGeometriesChanged(e){let t=[];for(let n of e){let e=this._reactiveGraphicLookup.get(n);e&&(t.push(e),e.geometry=n.geometry)}this._updatingHandles.consumePromise(this._valueChangeTransaction(async e=>this._expressionsManager.runGeometryDependentExpressions(t,e),`user`))}async overrideOriginalFeature(e,t){await this._prepareTask?.promise;let n=this._reactiveGraphicLookup.get(e);n&&(n.original=t,this._updatingHandles.consumePromise(this._valueChangeTransaction(e=>this._expressionsManager.runOriginalFeatureDependentExpressions(n,e),`expression`)))}async setFieldInputValue(e,t){let{fieldName:n}=e;await this._updatingHandles.addPromise(this._valueChangeTransaction(async r=>{for(let i of e.features)r.setValue(i,n,t)},`user`,e))}async setFieldInputValuePerFeature(e,t){await this._updatingHandles.addPromise(this._valueChangeTransaction(async n=>{for(let[r,i]of t)n.setValue(r,e.fieldName,i);n.hasChanges&&(e.userHasChangedValue=!0)},`user`,e))}async setValueForFieldName(e,t,n){await this._updatingHandles.addPromise(this._valueChangeTransaction(async r=>{for(let i of n){let n=this._reactiveGraphicLookup.get(i);n&&r.setValue(n,e,t)}},`user`,e))}async setValuePerFeatureForFieldName(e,t){await this._updatingHandles.addPromise(this._valueChangeTransaction(async n=>{for(let[r,i]of t){let t=this._reactiveGraphicLookup.get(r);t&&n.setValue(t,e,i)}},`user`,e))}async setFieldValue(e,t){let n=this.activeForm.allFieldInputs.find(t=>t.fieldName===e);if(n==null)throw new i(`no-field-input-found`,`Cannot set the value of FieldInput with field name: ${e} because none was found in the active form`);await this.setFieldInputValue(n,t)}async setValue(e,t){let n=this.findFieldInput(e);if(n==null)throw new i(`no-FieldInput-found`,`Cannot set the value of FieldInput with ID: ${e} because none was found in the active form`);await this.setFieldInputValue(n,t)}async applySubtypeDefaults(e){let{defaultValues:t}=e,{allFieldInputs:n}=this.activeForm;await this._updatingHandles.addPromise(this._valueChangeTransaction(async e=>{for(let r of n){let{fieldName:n}=r,i=t[n];if(i!=null)for(let t of r.features)e.setValue(t,n,i)}},`user`))}async handleSubtypeChanged(e){let t=this._workingFeatures.at(e);if(t)return this._updatingHandles.addPromise(this._handleSubtypeChanged(t))}async stageAddAttachments(e,t){if(t.length===0)return[];let n=this._findAttachmentInput(e);if(!n)return[];let r=await this._updatingHandles.addPromise(n.stageAddAttachments(t,this._expressionsManager.arcadeContext));return r.length===0||(this.userHasChangedValues=!0,this._emitAttachmentsChange(n)),r}stageDeleteAttachment(e,t){let n=this._findAttachmentInput(e);if(!n)return;let r=this._findAttachment(n,t);r&&(n.stageDeleteAttachment(r),this.userHasChangedValues=!0,this._emitAttachmentsChange(n))}async stageRenameAttachment(e,t,n){let r=this._findAttachmentInput(e);if(!r)return;let i=this._findAttachment(r,t);i&&(r.stageRenameAttachment(i,n.trim()),this.userHasChangedValues=!0,await r.ensureStagedUpdateData(i),this._emitAttachmentsChange(r))}async stageReplaceAttachment(e,t,n){let r=this._findAttachmentInput(e);if(!r)return!1;let i=this._findAttachment(r,t);return!i||!await this._updatingHandles.addPromise(r.stageReplaceAttachment(i,n,this._expressionsManager.arcadeContext))?!1:(this.userHasChangedValues=!0,this._emitAttachmentsChange(r),!0)}clearAttachmentChanges(e){let t=this._findAttachmentInput(e);t&&(t.clearAttachmentChanges(),this._emitAttachmentsChange(t))}setActiveAssociation(e){this._activeAssociation=e}setActiveAssociationsInput(e){this._activeAssociationsInput=e}setActiveAssociationsLayer(e){this._activeAssociationsInput?.setAssociatedLayer(e)}setActiveAssociationType(e){this._activeAssociationsInput?.setActiveAssociationType(e)}setActiveRelationshipInput(e){e||this._activeRelationshipInput?.setActiveCategory(null),this._activeRelationshipInput=e}setActiveRelationshipCategory(e,t){t.setActiveCategory(e),this.setActiveRelationshipInput(t)}clearAllRelationshipSettings(){let e=this.activeRelationshipInput;e&&(e.setActiveCategory(null),e.setShowAllCategories(!1),e.setShowAllRelatedRecords(!1),this._activeRelationshipInput=null)}clearActiveRelationshipCategoryOrInput(){let e=this.activeRelationshipInput;e&&(e.showAllRelatedRecords?e.showAllCategories?e.setActiveCategory(null):this.setActiveRelationshipInput(null):e.showAllCategories&&(e.setShowAllCategories(!1),this.setActiveRelationshipInput(null)))}resetAttachmentChanges(e,t){let n=this._findAttachmentInput(e);if(!n||!n.editable)return;let r=this._findAttachment(n,t);r&&(n.discardStagedEdits(r),this._emitAttachmentsChange(n))}setSelectedAttachment(e){this.selectedAttachment=e??null}setShowingSelectedAttachmentReplacePage(e){this.showingSelectedAttachmentReplacePage=e}setSelectedAttachmentAddElementId(e){this.selectedAttachmentAddElementId=e??null}setSelectedAttachmentListElementId(e){this.selectedAttachmentListElementId=e??null}userChangesHaveMadeFeatureInvalid(e){return!!this._reactiveGraphicLookup.get(e)?.userChangesHaveMadeInvalid}validate(){return!1}validateContingentValues(e,t=!1){if(t&&!this.submitHasBeenAttempted)for(let t of e)this._reactiveContingentValuesManager.validateContingenciesForNonNullFields(t);else for(let t of e)this._reactiveContingentValuesManager.validateContingencyConstraints(t,{includeIncompleteViolations:!0})}_makeBatchFormInputsForFeature(e){let t=this._layerTemplateMap.get(e.layer);return t?B(t,{allFeatures:new r([e]),expressionsManager:this._expressionsManager,requestDeferredExpressionEvaluation:this._requestDeferredExpressionEvaluation,getExternalErrorForFeature:this._getExternalErrorForFeature,getFieldValueOptionsForFeature:this._getFieldValueOptionsForFeature,map:this.map}):this._emptyForm}async _ensureLayerTemplate(e,t){let{_layersSet:n,contingentValuesManager:r}=this,i=e.layer,a=!1;for(let e of this._layerTemplateMap.keys())n.has(e)||(this._layerTemplateMap.delete(e),this._expressionsManager.layerExpressionsModelMap.delete(e),r.resetOptionsForLayer(e),Y(e)&&r.resetViolationsForLayer(e),a=!0);this._layerTemplateMap.has(i)||(await this._prepareLayer(i,t),u(t),r.layers.add(i),a=!0),a&&(this._prepareSharedFormTemplate(),V(this.sharedForm,this.sharedFormTemplate,{allFeatures:this._workingFeatures,expressionsManager:this._expressionsManager,getFieldValueOptionsForFeature:this._getFieldValueOptionsForFeature,requestDeferredExpressionEvaluation:this._requestDeferredExpressionEvaluation,map:this.map}),this._recomputeHasAsyncArcadeExpressions(),await v(()=>!r.updating,t))}_recomputeHasAsyncArcadeExpressions(){this._hasAsyncArcadeExpressions=!1;for(let e of this._expressionsManager.layerExpressionsModelMap.values())for(let t of e.arcadeExecutorUses.keys())if(t.isAsync){this._hasAsyncArcadeExpressions=!0;return}}_computeFormHeaderField(e){let{activeFeature:t,activeLayer:n}=this;return!e||!n||!t?null:P({attributes:t?.attributes,label:e,layer:n,timeZone:this.effectiveTimeZone})}_makeSubmitResults(){let e=new Map;for(let[n,r]of this._reactiveGraphicLookup){let i=[],a=[],o=this._featureFormMap.get(r)?.allAttachmentElementInputs??[];for(let e of o)t(i,e.toSubmitEdits()),e.valid||a.push(e.template.elementId);e.set(n,{feature:n,values:{...r.attributes},invalidFields:[],attachmentEdits:i,invalidAttachmentElementIds:a})}for(let t of this.sharedForm.allFieldInputs)for(let n of t.invalidFeatures)e.get(n)?.invalidFields.push(t.fieldName);return Array.from(e.values())}async _handleSubtypeChanged(e){let t=e.layer;if(this.contingentValuesManager.resetOptionsForFeature(t,e.plainGraphic),Y(t)&&this.contingentValuesManager.resetViolationsForFeature(t,e.plainGraphic),!w(t))return;let r=t.parent?.findSublayerForFeature(e.plainGraphic);if(!r)return;this._layerTemplateUpdateTask=l(this._layerTemplateUpdateTask);let i=n(async t=>{u(t),e.source.sourceLayer=r,e.source.origin=r.graphicOrigin,await this._ensureLayerTemplate(e,t),u(t),this._featureFormMap.get(e)?.destroy(),this._featureFormMap.set(e,this._makeBatchFormInputsForFeature(e)),await ee(this._valueChangeTransaction(t=>this._expressionsManager.runAllExpressions([e],t),`user`),t),u(t)});this._layerTemplateUpdateTask=i,await d(this._updatingHandles.addPromise(i.promise))}_emitSubmit(){this.emit(`submit`,{name:`submit`,results:this._makeSubmitResults(),valid:this.valid})}_findAttachmentInput(e){let t=this.activeForm.allAttachmentElementInputs.find(t=>t.template.elementId===e);return t||o.getLogger(this).error(`Attachment input not found for elementId '${e}'`),t}_findAttachment(e,t){let n=e.findAttachment(t);return n||o.getLogger(this).error(`Attachment '${t}' not found for attachment element '${e.template.elementId}'`),n}_makeAttachmentEdits(e){let n=[];for(let r of e.allAttachmentElementInputs)t(n,r.toSubmitEdits());return n}_emitAttachmentsChange(e){let t=e.single.feature;if(!t)return;let n=this._featureFormMap.get(t);this.emit(`attachments-change`,{name:`attachments-change`,feature:t.source,attachmentEdits:this._makeAttachmentEdits(n??this.activeForm),valid:this.valid})}async _valueChangeTransaction(e,t,n){let r=typeof n==`string`?n:n?.fieldName,i=new F(this,t,r);if(await e(i),t===`user`&&await this._expressionsManager.runExpressionsDependentOnChangedFields(i),await i.close(),i.hasChanges&&n){let e=typeof n==`string`?this.activeForm.allFieldInputs.find(e=>e.fieldName===n):n;e&&(e.userHasChangedValue=!0)}}_prepare(){this.pendingSubtypeChoice?.reject(),this._hasAsyncArcadeExpressions=!1,this._prepareTask=l(this._prepareTask),this._layerTemplateUpdateTask=l(this._layerTemplateUpdateTask),this._layerTemplateMap.clear(),this._updateWorkingFeatures(),c(this._expressionsManager),this.userHasChangedValues=!1,this._expressionsManager=new L({arcadeContext:{editType:this.editType,spatialReference:this.spatialReference??x.WebMercator,map:this.map,timeZone:this.timeZone||`system`}});let{layers:e}=this;if(e.length===0)return;let t=n(async t=>{try{u(t),this._updateWorkingFeatures(),this.contingentValuesManager.layers.addMany(e),await Promise.all(e.map(e=>e.load()));for(let n of e)await this._prepareLayer(n,t);if(this.hasTooManyComplexFeatures)throw new i(`too-many-features-with-complex-forms`,`There are too many features to load into the form with the configured complexity`);if(this.hasTooManyFeatures)throw new i(`too-many-features`,`There are too many features to load into the form.`);this._prepareSharedFormTemplate(),this.sharedForm=B(this.sharedFormTemplate,{allFeatures:this._workingFeatures,expressionsManager:this._expressionsManager,getExternalErrorForFeature:this._getExternalErrorForFeature,getFieldValueOptionsForFeature:this._getFieldValueOptionsForFeature,map:this.map,requestDeferredExpressionEvaluation:this._requestDeferredExpressionEvaluation}),await this._valueChangeTransaction(async e=>await this._expressionsManager.runAllExpressions(this._workingFeatures.toArray(),e),`expression`),await v(()=>!this.contingentValuesManager.updating)}catch(e){throw f(e)||o.getLogger(this).error(`Failed preparing form`,e),e}});this._updatingHandles.consumePromise(t.promise),this._prepareTask=t}async _prepareLayer(e,t){let n=ae(this.layerInfos,e),r=await G(e,{arcadeExecutorProvider:this._arcadeExecutorProvider,formTimeZone:this.timeZone,attachmentsEnabled:this.attachmentsEnabled},n?.formTemplate);u(t),this._layerTemplateMap.set(e,r);let i=r.getExpressionExecutorsForLayer(e);if(this._expressionsManager.layerExpressionsModelMap.set(e,new R({preserveFieldValuesWhenHidden:r.preserveFieldValuesWhenHidden,executorMap:i,fieldsIndex:e.fieldsIndex})),!this._hasAsyncArcadeExpressions){for(let e of i.values())if(e&&(this._hasAsyncArcadeExpressions=(e.editableExpression?.isAsync||e.requiredExpression?.isAsync||e.valueExpression?.isAsync||e.visibilityExpression?.isAsync)===!0,this._hasAsyncArcadeExpressions))break}}_prepareSharedFormTemplate(){let e=new Map;for(let t of this._layerTemplateMap.values())for(let n of t.elements){if(K(n))continue;let t=n.clone();q(t)&&(t.elements=t.elements.filter(e=>!K(e)));let{elementId:r}=t;e.has(r)?e.get(r).foldIn(t):e.set(r,t)}this.sharedFormTemplate=new W({elements:Array.from(e.values())})}_updateWorkingFeatures(){this._workingFeatures.destroyAll(),this._reactiveContingentValuesManager.reset();for(let e of this._featureFormMap.values())e.destroy();this._featureFormMap.clear(),this._attachmentCache.clear();let{features:e}=this;if(this._reactiveGraphicLookup=new p,e.length!==0){this._workingFeatures.addMany(e.map(k));for(let e of this._workingFeatures)this._reactiveGraphicLookup.set(e.source,e)}}async _syncAttachments(){let{activeFeature:e,activeLayer:t,activeForm:r}=this;if(!e||!r||!A(t)||!j(t))return;let i=e.getObjectId();if(i==null)return;let a=this._attachmentCache.get(t),o=r.allAttachmentElementInputs;if(!o.length)return;let c=n(async e=>{let n;if(a){let e=a.get(i);e&&(n=e)}n||(n=await M(t,i,o,e),s(this._attachmentCache,t,()=>new p).set(i,n));for(let e of o)e.applyFetchedAttachments(se(e,n))});this._syncAttachmentsTask=c,await d(c.promise)}get test(){return{expressionsManager:this._expressionsManager,reactiveGraphicLookup:this._reactiveGraphicLookup,syncAttachmentsTask:this._syncAttachmentsTask,arcadeExecutorProvider:this._arcadeExecutorProvider,requestDeferredExpressionEvaluation:this._requestDeferredExpressionEvaluation}}};e([y()],Z.prototype,`_attachmentCache`,void 0),e([y({readOnly:!0})],Z.prototype,`activeFeature`,null),e([y()],Z.prototype,`activeFeatureIndex`,void 0),e([y({readOnly:!0})],Z.prototype,`activeForm`,null),e([y({readOnly:!0})],Z.prototype,`activeLayer`,null),e([y()],Z.prototype,`activeAssociation`,null),e([y()],Z.prototype,`activeAssociationsInput`,null),e([y()],Z.prototype,`activeAssociationType`,null),e([y()],Z.prototype,`activeRelationshipInput`,null),e([y()],Z.prototype,`attachmentsEnabled`,void 0),e([y()],Z.prototype,`callbacks`,void 0),e([y()],Z.prototype,`disabled`,void 0),e([y()],Z.prototype,`calculating`,null),e([y()],Z.prototype,`canGoBack`,null),e([y()],Z.prototype,`contingentValuesManager`,void 0),e([y()],Z.prototype,`editType`,void 0),e([y()],Z.prototype,`features`,void 0),e([y()],Z.prototype,`expressionEvaluationFailed`,null),e([y()],Z.prototype,`hasNonActiveInvalidFeatures`,null),e([y()],Z.prototype,`hasAsyncArcadeExpressions`,null),e([y()],Z.prototype,`_hasAsyncArcadeExpressions`,void 0),e([y()],Z.prototype,`invalidFeatures`,null),e([y()],Z.prototype,`hasVisibleInputs`,null),e([y()],Z.prototype,`hasLayersWithContingentValues`,null),e([y()],Z.prototype,`formDescription`,null),e([y()],Z.prototype,`formTitle`,null),e([y()],Z.prototype,`effectiveTimeZone`,null),e([y()],Z.prototype,`highlightHelper`,void 0),e([y()],Z.prototype,`maximumFeatureCount`,void 0),e([y()],Z.prototype,`maximumFeatureCountWithComplexForms`,void 0),e([y()],Z.prototype,`visibleInputs`,null),e([y()],Z.prototype,`map`,null),e([y()],Z.prototype,`noVisibleElementsReason`,null),e([y()],Z.prototype,`page`,null),e([y()],Z.prototype,`pageStack`,void 0),e([y()],Z.prototype,`readOnly`,void 0),e([y()],Z.prototype,`pendingSubtypeChoice`,void 0),e([y()],Z.prototype,`subtypes`,null),e([y()],Z.prototype,`spatialReference`,void 0),e([y()],Z.prototype,`submitHasBeenAttempted`,void 0),e([y()],Z.prototype,`timeZone`,null),e([y()],Z.prototype,`view`,void 0),e([y()],Z.prototype,`updating`,null),e([y()],Z.prototype,`valid`,null),e([y()],Z.prototype,`layers`,null),e([y()],Z.prototype,`mode`,null),e([y()],Z.prototype,`sharedForm`,void 0),e([y()],Z.prototype,`sharedFormTemplate`,void 0),e([y()],Z.prototype,`selectedAttachment`,null),e([y()],Z.prototype,`selectedAttachmentAddElementId`,null),e([y()],Z.prototype,`selectedAttachmentListElementId`,null),e([y()],Z.prototype,`selectedAttachmentListInput`,null),e([y()],Z.prototype,`showingSelectedAttachmentReplacePage`,null),e([y()],Z.prototype,`selectedAttachmentAddInput`,null),e([y()],Z.prototype,`selectedAttachmentDetails`,null),e([y()],Z.prototype,`userHasChangedValues`,void 0),e([y()],Z.prototype,`layerInfos`,void 0),e([y()],Z.prototype,`_arcadeExecutorProvider`,void 0),e([y()],Z.prototype,`_activeAssociation`,void 0),e([y()],Z.prototype,`_activeAssociationsInput`,void 0),e([y()],Z.prototype,`_activeRelationshipInput`,void 0),e([y()],Z.prototype,`_prepareTask`,void 0),e([y()],Z.prototype,`_reactiveGraphicLookup`,void 0),e([y()],Z.prototype,`_allAttachmentInputs`,null),e([y()],Z.prototype,`_hasPendingAttachmentHydration`,null),e([y()],Z.prototype,`_layerTemplateMap`,void 0),e([y()],Z.prototype,`_layersSet`,null),e([y()],Z.prototype,`_workingFeatures`,void 0),e([y()],Z.prototype,`_expressionsManager`,void 0),Z=e([b(`esri.widgets.BatchAttributeForm.BatchAttributeFormViewModel`)],Z);const oe=Z;function Q(e){return e!=null&&e.trim().length>0}function $(e,t){let n=e.keywords;return Q(n)&&n.toLowerCase()===t}function se(e,t){let n=e.input?.type===`attachment`?e.input.attachmentAssociationType:`exact`,r=e.attachmentKeyword;if(n===`any`)return t;if(n===`exactOrNone`){if(X(r))return t.filter(e=>!Q(e.keywords));let e=r.toLowerCase();return t.filter(t=>!Q(t.keywords)||$(t,e))}if(X(r))return t;let i=r.toLowerCase();return t.filter(e=>$(e,i))}export{oe as default};
|
|
2
|
+
import{__decorate as e}from"tslib";import{pushIfSome as t}from"../../core/arrayUtils.js";import{createTask as n}from"../../core/asyncUtils.js";import r from"../../core/Collection.js";import i from"../../core/Error.js";import{EventedAccessor as a}from"../../core/Evented.js";import o from"../../core/Logger.js";import{getOrCreateMapValue as s}from"../../core/MapUtils.js";import{destroyMaybe as c,abortMaybe as l}from"../../core/maybe.js";import{throwIfAborted as u,whenOrAbort as ee,ignoreAbortErrors as d,isAbortError as f}from"../../core/promiseUtils.js";import p from"../../core/ReactiveMap.js";import{on as te,sync as m,watch as h,syncAndInitial as g,initial as _,whenOnce as v}from"../../core/reactiveUtils.js";import{property as y,subclass as b}from"../../core/accessorSupport/decorators.js";import{UpdatingHandles as ne}from"../../core/support/UpdatingHandles.js";import x from"../../geometry/SpatialReference.js";import{getGraphicLayer as S}from"../../graphic/graphicOriginUtils.js";import{isSubtypeGroupLayer as C,isSubtypeSublayer as w,isFeatureLayer as re,getSubtypesFromLayer as ie}from"../../layers/support/layerUtils.js";import{system as T}from"../../time/constants.js";import{getAttachmentKey as E}from"./attachmentUtils.js";import{getLayerTimeZone as D,getEffectiveTimeZone as O,createReactiveGraphic as k,isAttributeFormSupportedLayerWithAttachments as A,layerSupportsAttachments as j,queryAttachmentsForElements as M}from"./batchAttributeFormUtils.js";import{ReactiveContingentValuesManager as N}from"./ReactiveContingentValuesManager.js";import{parseFormTemplateString as P}from"./stringUtils.js";import{ValueChangeTransaction as F}from"./ValueChangeTransaction.js";import{ArcadeExecutorProvider as I}from"./expressions/ArcadeExecutorProvider.js";import{ExpressionsManager as L}from"./expressions/ExpressionsManager.js";import{ExpressionsModel as R}from"./expressions/ExpressionsModel.js";import z from"./inputs/BatchFormInputs.js";import{createBatchFormInputsFromBatchFormTemplate as B,mergeBatchFormInputsFromNewTemplate as V}from"./inputs/support/createBatchFormInputs.js";import{isGroupInput as H,isFieldInput as U}from"./inputs/support/inputUtils.js";import W from"./templates/BatchFormTemplate.js";import{createBatchFormTemplate as G}from"./templates/support/createBatchFormTemplate.js";import{isExcludedFromSharedForm as K,isGroupElementTemplate as q}from"./templates/support/templateUtils.js";import{ContingentValuesManager as J,isLayerWithContingentValues as Y}from"../support/ContingentValuesManager.js";import{isEmptyValue as X}from"../support/forms/formUtils.js";function ae(e,t){return e?.find(e=>e.layer===t)}let Z=class extends a{constructor(e){super(e),this._attachmentCache=new p,this.activeFeatureIndex=-1,this.attachmentsEnabled=!1,this.callbacks=null,this.disabled=!1,this.editType=`NA`,this.features=new r,this._hasAsyncArcadeExpressions=!1,this.highlightHelper=null,this.maximumFeatureCount=2e3,this.maximumFeatureCountWithComplexForms=50,this.pageStack=[],this.readOnly=!1,this.pendingSubtypeChoice=null,this.spatialReference=null,this.submitHasBeenAttempted=!1,this.view=null,this.userHasChangedValues=!1,this.layerInfos=null,this._arcadeExecutorProvider=new I,this._activeAssociation=null,this._activeAssociationsInput=null,this._activeRelationshipInput=null,this._ownContingentValuesManager=null,this._activeFormInputsByElementId=new Map,this._emptyForm=new z({inputs:[]}),this._emptyFormTemplate=new W({elements:[]}),this._featureFormMap=new p,this._prepareTask=null,this._layerTemplateUpdateTask=null,this._syncAttachmentsTask=null,this._reactiveGraphicLookup=new p,this._updatingHandles=new ne,this._submitTask=null,this._layerTemplateMap=new p,this._workingFeatures=new r,this._expressionsManager=new L({arcadeContext:{editType:`NA`,spatialReference:null,map:null,timeZone:T}}),this._getExternalErrorForFeature=(e,t)=>this._reactiveContingentValuesManager.getViolationTypeForField(e,t),this._getFieldValueOptionsForFeature=e=>this._reactiveContingentValuesManager.getAndWatchFieldValueOptions(e),this._requestDeferredExpressionEvaluation=async({features:e,getExecutor:t})=>this._valueChangeTransaction(n=>this._expressionsManager.requestDeferredExecution(e,t,n),`user`),this._executeFeatureSetDependentExpressions=async e=>this._updatingHandles.addPromise(this._valueChangeTransaction(t=>this._expressionsManager.runFeatureSetDependentExpressions(e,t),`user`)),this.sharedForm=this._emptyForm,this.sharedFormTemplate=this._emptyFormTemplate}initialize(){this.contingentValuesManager||=this._ownContingentValuesManager=new J,this.addHandles([te(()=>this.features,`after-changes`,()=>{this.goHome(),this.notifyChange(`layers`),this._prepare()},m),h(()=>[this.attachmentsEnabled,this.features,this.map,this.timeZone,this.editType],()=>this._prepare(),m),h(()=>this.activeForm,()=>{this.goHome(),this._activeFormInputsByElementId.clear(),this._syncAttachments()},m),h(()=>this.activeFeature,()=>{this.goHome()},m),h(()=>this.page,e=>{let t=[...this.pageStack];if(!t.includes(e))t.push(e);else for(;t.length&&t.at(-1)!==e;)t.pop();this.pageStack=t},g),h(()=>this.contingentValuesManager,e=>{c(this._reactiveContingentValuesManager),this._reactiveContingentValuesManager=new N({manager:e})},_)]),this._prepare()}destroy(){this._prepareTask=l(this._prepareTask),this.pendingSubtypeChoice?.reject(),this._layerTemplateUpdateTask=l(this._layerTemplateUpdateTask),this._syncAttachmentsTask=l(this._syncAttachmentsTask),this._workingFeatures.destroyAll(),c(this._expressionsManager),c(this._reactiveContingentValuesManager),this._updatingHandles.destroy(),this._reactiveGraphicLookup=new p,this._emptyForm.destroy(),this._emptyFormTemplate.destroy(),this._ownContingentValuesManager=c(this._ownContingentValuesManager),this.highlightHelper?.removeAll()}get activeFeature(){let e=this.activeFeatureIndex;return e<0?null:this.features.at(e)}get activeForm(){if(this.mode===`batch`)return this.sharedForm;let e=this._workingFeatures.at(this.activeFeatureIndex);if(!e)return this._emptyForm;let t=this._featureFormMap.get(e);if(t)return t;let n=this._makeBatchFormInputsForFeature(e);return n!==this._emptyForm&&this._featureFormMap.set(e,n),n}get activeLayer(){let{activeFeature:e}=this;return e?S(e)??null:null}get activeAssociation(){return this._activeAssociation}get activeAssociationsInput(){return this._activeAssociationsInput}get activeAssociationType(){return this.activeAssociationsInput?.activeAssociationType}get activeRelationshipInput(){return this._activeRelationshipInput}get calculating(){return this._expressionsManager.calculating}get expressionsManager(){return this._expressionsManager}get canGoBack(){return this.pageStack.length>1}get expressionEvaluationFailed(){return this._expressionsManager.expressionEvaluationFailed}get hasNonActiveInvalidFeatures(){if(this.mode===`batch`)return!1;let{activeFeature:e}=this;return this.invalidFeatures.some(t=>t!==e)}get hasAsyncArcadeExpressions(){return this._hasAsyncArcadeExpressions}get hasTooManyFeatures(){return this._workingFeatures.length>this.maximumFeatureCount}get hasTooManyComplexFeatures(){return this._workingFeatures.length>this.maximumFeatureCountWithComplexForms&&this.hasAsyncArcadeExpressions}get invalidFeatures(){return this.sharedForm.invalidFeatures}get hasVisibleInputs(){return this.visibleInputs.length>0}get hasLayersWithContingentValues(){let e=this.contingentValuesManager;for(let t of this.layers)if(e.getFieldsWithContingentValues(t).size>0)return!0;return!1}get formDescription(){return this._computeFormHeaderField(this.activeForm?.description)}get formTitle(){return this._computeFormHeaderField(this.activeForm?.title)}get effectiveTimeZone(){let{activeLayer:e,timeZone:t}=this;if(!e)return t??`system`;let n=D(e);return O(t,n)}get visibleInputs(){return this.activeForm.inputs.filter(e=>e.visible)}get map(){return this.view?.map??null}set map(e){this._override(`map`,e)}get noVisibleElementsReason(){if(this.hasVisibleInputs)return null;if(this.activeForm.inputs.length===0)return`noElements`;let e=new Set;for(let t of this.activeForm.inputs)switch(t.visibilityCode){case`hidden:not-in-all-layers`:case`hidden:no-domain-in-common`:e.add(`noElementsInCommon`);break;case`hidden:field-definition`:case`hidden:group-visibility-expression:all-features`:case`hidden:visibility-expression:all-features`:e.add(`allElementsHidden`);break;case`hidden:group-visibility-expression:some-features`:case`hidden:visibility-expression:some-features`:return`elementsHiddenInSome`}return e.has(`allElementsHidden`)?`allElementsHidden`:`noElementsInCommon`}get page(){return this.showingSelectedAttachmentReplacePage&&this.selectedAttachmentDetails?`replacing-attachment`:this.selectedAttachmentDetails?`viewing-attachment-details`:this.selectedAttachmentAddInput?`adding-attachments`:this.selectedAttachmentListInput?`viewing-attachments`:this.activeAssociationsInput?.associatedLayer?`viewing-associated-features`:this.activeAssociationsInput?`viewing-associated-layers`:this.activeRelationshipInput?.showAllRelatedRecords?`viewing-related-records`:this.activeRelationshipInput?.showAllCategories?`viewing-related-categories`:`default`}get subtypes(){let e=this.activeLayer;return C(e)||w(e)||re(e)?ie(e):[]}get status(){let e=this._prepareTask;return e==null?`not-loaded`:e.finished?e.error==null?`loaded`:`failed`:`loading`}get timeZone(){return this.view?.timeZone??null}set timeZone(e){this._overrideIfSome(`timeZone`,e)}get updating(){return this._updatingHandles.updating||this.calculating}get valid(){return this.sharedForm.valid&&Array.from(this._featureFormMap.values()).every(e=>e.valid)}get layers(){return Array.from(this._layersSet)}get mode(){return this.activeFeatureIndex>-1?`single`:`batch`}submit(){if(this.submitHasBeenAttempted=!0,this.sharedForm.touchAll(),this._featureFormMap.forEach(e=>e.touchAll()),this.validateContingentValues(this._workingFeatures),!this._hasPendingAttachmentHydration)return this._emitSubmit(),Promise.resolve();if(this._submitTask)return this._submitTask.promise;let e=n(async()=>{await Promise.all(this._allAttachmentInputs.map(e=>e.waitForPendingAttachmentUpdateData())),this._emitSubmit()});return this._submitTask=e,e.promise.finally(()=>{this._submitTask===e&&(this._submitTask=null)}),e.promise}get selectedAttachment(){return this._get(`selectedAttachment`)??null}set selectedAttachment(e){this.showingSelectedAttachmentReplacePage=!1,this._set(`selectedAttachment`,e),e!=null&&(this.selectedAttachmentAddElementId=null)}get selectedAttachmentAddElementId(){return this._get(`selectedAttachmentAddElementId`)??null}set selectedAttachmentAddElementId(e){this.showingSelectedAttachmentReplacePage=!1,this._set(`selectedAttachmentAddElementId`,e),e!=null&&(this.selectedAttachment=null,this.selectedAttachmentListElementId=null)}get selectedAttachmentListElementId(){return this._get(`selectedAttachmentListElementId`)??null}set selectedAttachmentListElementId(e){this._set(`selectedAttachmentListElementId`,e),e!=null&&(this.selectedAttachment=null,this.selectedAttachmentAddElementId=null)}get selectedAttachmentListInput(){let e=this.selectedAttachmentListElementId,t=this.activeForm;if(!e||!t)return null;let n=t.allAttachmentElementInputs.find(t=>t.template.elementId===e)||null;return n?.attachments.length?n:null}get showingSelectedAttachmentReplacePage(){return this._get(`showingSelectedAttachmentReplacePage`)??!1}set showingSelectedAttachmentReplacePage(e){this._set(`showingSelectedAttachmentReplacePage`,e&&this.selectedAttachmentDetails!=null)}get selectedAttachmentAddInput(){let e=this.selectedAttachmentAddElementId,t=this.activeForm;return!e||!t?null:t.allAttachmentElementInputs.find(t=>t.template.elementId===e)||null}get selectedAttachmentDetails(){let e=this.selectedAttachment,t=this.activeForm;if(!e||!t)return null;let n=t.allAttachmentElementInputs.find(t=>t.template.elementId===e.elementId);if(!n)return null;let r=n.attachments.findIndex(t=>E(t)===e.attachmentKey);return r===-1?null:{attachment:n.attachments[r],input:n}}get _allAttachmentInputs(){let e=[...this.sharedForm.allAttachmentElementInputs];for(let t of this._featureFormMap.values())e.push(...t.allAttachmentElementInputs);return e}get _hasPendingAttachmentHydration(){return this._allAttachmentInputs.some(e=>e.hasPendingAttachmentUpdateData)}get _layersSet(){let e=new Set;for(let t of this._workingFeatures){let n=S(t.plainGraphic);n&&e.add(n)}return e}applyStashedAttachmentEdits(e){let t=this._allAttachmentInputs;for(let n of e){let e=t.find(e=>e.label===n.label&&e.attachmentKeyword===n.keywords);e&&e.applyStashedEdits(n)}}findFieldInput(e){if(e==null)return;let t=this._activeFormInputsByElementId;if(t.has(e))return t.get(e);let n=this.activeForm.allFieldInputs.find(t=>t.template.elementId===e);if(n!==void 0)return t.set(e,n),n}getFirstVisibleInvalidFieldInput(){if(this.hasVisibleInputs&&!this.activeForm.valid)for(let e of this.visibleInputs){if(H(e)){let t=e.inputs.find(e=>U(e)&&!e.valid);if(t)return{input:t,groupInput:e}}if(U(e)&&!e.valid)return{input:e}}}getFieldInputValue(e){return this.findFieldInput(e)?.value}getValues(e){let t=this._reactiveGraphicLookup.get(e);if(!t)throw new i(`feature-not-found`,`The given feature is not present in the BatchAttributeForm`);return{...t.attributes}}async goBack(){switch(this.page){case`replacing-attachment`:this.setShowingSelectedAttachmentReplacePage(!1);return;case`viewing-attachment-details`:this.setSelectedAttachment(null);return;case`adding-attachments`:this.setSelectedAttachmentAddElementId(null);return;case`viewing-attachments`:this.setSelectedAttachmentListElementId(null);return;case`viewing-associated-features`:this.setActiveAssociationsLayer(null);return;case`viewing-associated-layers`:this.setActiveAssociationsInput(null);return;case`viewing-related-categories`:case`viewing-related-records`:this.clearActiveRelationshipCategoryOrInput();return;default:return}}async goHome(){this.setShowingSelectedAttachmentReplacePage(!1),this.setSelectedAttachment(null),this.setSelectedAttachmentAddElementId(null),this.setSelectedAttachmentListElementId(null),this.setActiveAssociationsLayer(null),this.setActiveAssociationsInput(null),this.clearAllRelationshipSettings()}notifyGeometriesChanged(e){let t=[];for(let n of e){let e=this._reactiveGraphicLookup.get(n);e&&(t.push(e),e.geometry=n.geometry)}this._updatingHandles.consumePromise(this._valueChangeTransaction(async e=>this._expressionsManager.runGeometryDependentExpressions(t,e),`user`))}async overrideOriginalFeature(e,t){await this._prepareTask?.promise;let n=this._reactiveGraphicLookup.get(e);n&&(n.original=t,this._updatingHandles.consumePromise(this._valueChangeTransaction(e=>this._expressionsManager.runOriginalFeatureDependentExpressions(n,e),`expression`)))}async setFieldInputValue(e,t){let{fieldName:n}=e;await this._updatingHandles.addPromise(this._valueChangeTransaction(async r=>{for(let i of e.features)r.setValue(i,n,t)},`user`,e))}async setFieldInputValuePerFeature(e,t){await this._updatingHandles.addPromise(this._valueChangeTransaction(async n=>{for(let[r,i]of t)n.setValue(r,e.fieldName,i);n.hasChanges&&(e.userHasChangedValue=!0)},`user`,e))}async setValueForFieldName(e,t,n){await this._updatingHandles.addPromise(this._valueChangeTransaction(async r=>{for(let i of n){let n=this._reactiveGraphicLookup.get(i);n&&r.setValue(n,e,t)}},`user`,e))}async setValuePerFeatureForFieldName(e,t){await this._updatingHandles.addPromise(this._valueChangeTransaction(async n=>{for(let[r,i]of t){let t=this._reactiveGraphicLookup.get(r);t&&n.setValue(t,e,i)}},`user`,e))}async setFieldValue(e,t){let n=this.activeForm.allFieldInputs.find(t=>t.fieldName===e);if(n==null)throw new i(`no-field-input-found`,`Cannot set the value of FieldInput with field name: ${e} because none was found in the active form`);await this.setFieldInputValue(n,t)}async setValue(e,t){let n=this.findFieldInput(e);if(n==null)throw new i(`no-FieldInput-found`,`Cannot set the value of FieldInput with ID: ${e} because none was found in the active form`);await this.setFieldInputValue(n,t)}async applySubtypeDefaults(e){let{defaultValues:t}=e,{allFieldInputs:n}=this.activeForm;await this._updatingHandles.addPromise(this._valueChangeTransaction(async e=>{for(let r of n){let{fieldName:n}=r,i=t[n];if(i!=null)for(let t of r.features)e.setValue(t,n,i)}},`user`))}async handleSubtypeChanged(e){let t=this._workingFeatures.at(e);if(t)return this._updatingHandles.addPromise(this._handleSubtypeChanged(t))}async stageAddAttachments(e,t){if(t.length===0)return[];let n=this._findAttachmentInput(e);if(!n)return[];let r=await this._updatingHandles.addPromise(n.stageAddAttachments(t,this._expressionsManager.arcadeContext));return r.length===0||(this.userHasChangedValues=!0,this._emitAttachmentsChange(n)),r}stageDeleteAttachment(e,t){let n=this._findAttachmentInput(e);if(!n)return;let r=this._findAttachment(n,t);r&&(n.stageDeleteAttachment(r),this.userHasChangedValues=!0,this._emitAttachmentsChange(n))}async stageRenameAttachment(e,t,n){let r=this._findAttachmentInput(e);if(!r)return;let i=this._findAttachment(r,t);i&&(r.stageRenameAttachment(i,n.trim()),this.userHasChangedValues=!0,await r.ensureStagedUpdateData(i),this._emitAttachmentsChange(r))}async stageReplaceAttachment(e,t,n){let r=this._findAttachmentInput(e);if(!r)return!1;let i=this._findAttachment(r,t);return!i||!await this._updatingHandles.addPromise(r.stageReplaceAttachment(i,n,this._expressionsManager.arcadeContext))?!1:(this.userHasChangedValues=!0,this._emitAttachmentsChange(r),!0)}clearAttachmentChanges(e){let t=this._findAttachmentInput(e);t&&(t.clearAttachmentChanges(),this._emitAttachmentsChange(t))}setActiveAssociation(e){this._activeAssociation=e}setActiveAssociationsInput(e){this._activeAssociationsInput=e}setActiveAssociationsLayer(e){this._activeAssociationsInput?.setAssociatedLayer(e)}setActiveAssociationType(e){this._activeAssociationsInput?.setActiveAssociationType(e)}setActiveRelationshipInput(e){e||this._activeRelationshipInput?.setActiveCategory(null),this._activeRelationshipInput=e}setActiveRelationshipCategory(e,t){t.setActiveCategory(e),this.setActiveRelationshipInput(t)}clearAllRelationshipSettings(){let e=this.activeRelationshipInput;e&&(e.setActiveCategory(null),e.setShowAllCategories(!1),e.setShowAllRelatedRecords(!1),this._activeRelationshipInput=null)}clearActiveRelationshipCategoryOrInput(){let e=this.activeRelationshipInput;e&&(e.showAllRelatedRecords?e.showAllCategories?e.setActiveCategory(null):this.setActiveRelationshipInput(null):e.showAllCategories&&(e.setShowAllCategories(!1),this.setActiveRelationshipInput(null)))}resetAttachmentChanges(e,t){let n=this._findAttachmentInput(e);if(!n||!n.editable)return;let r=this._findAttachment(n,t);r&&(n.discardStagedEdits(r),this._emitAttachmentsChange(n))}setSelectedAttachment(e){this.selectedAttachment=e??null}setShowingSelectedAttachmentReplacePage(e){this.showingSelectedAttachmentReplacePage=e}setSelectedAttachmentAddElementId(e){this.selectedAttachmentAddElementId=e??null}setSelectedAttachmentListElementId(e){this.selectedAttachmentListElementId=e??null}userChangesHaveMadeFeatureInvalid(e){return!!this._reactiveGraphicLookup.get(e)?.userChangesHaveMadeInvalid}validate(){return!1}validateContingentValues(e,t=!1){if(t&&!this.submitHasBeenAttempted)for(let t of e)this._reactiveContingentValuesManager.validateContingenciesForNonNullFields(t);else for(let t of e)this._reactiveContingentValuesManager.validateContingencyConstraints(t,{includeIncompleteViolations:!0})}_makeBatchFormInputsForFeature(e){let t=this._layerTemplateMap.get(e.layer);return t?B(t,{allFeatures:new r([e]),expressionsManager:this._expressionsManager,requestDeferredExpressionEvaluation:this._requestDeferredExpressionEvaluation,executeFeatureSetDependentExpressions:this._executeFeatureSetDependentExpressions,getExternalErrorForFeature:this._getExternalErrorForFeature,getFieldValueOptionsForFeature:this._getFieldValueOptionsForFeature,map:this.map}):this._emptyForm}async _ensureLayerTemplate(e,t){let{_layersSet:n,contingentValuesManager:r}=this,i=e.layer,a=!1;for(let e of this._layerTemplateMap.keys())n.has(e)||(this._layerTemplateMap.delete(e),this._expressionsManager.layerExpressionsModelMap.delete(e),r.resetOptionsForLayer(e),Y(e)&&r.resetViolationsForLayer(e),a=!0);this._layerTemplateMap.has(i)||(await this._prepareLayer(i,t),u(t),r.layers.add(i),a=!0),a&&(this._prepareSharedFormTemplate(),V(this.sharedForm,this.sharedFormTemplate,{allFeatures:this._workingFeatures,expressionsManager:this._expressionsManager,getFieldValueOptionsForFeature:this._getFieldValueOptionsForFeature,requestDeferredExpressionEvaluation:this._requestDeferredExpressionEvaluation,executeFeatureSetDependentExpressions:this._executeFeatureSetDependentExpressions,map:this.map}),this._recomputeHasAsyncArcadeExpressions(),await v(()=>!r.updating,t))}_recomputeHasAsyncArcadeExpressions(){this._hasAsyncArcadeExpressions=!1;for(let e of this._expressionsManager.layerExpressionsModelMap.values())for(let t of e.arcadeExecutorUses.keys())if(t.isAsync){this._hasAsyncArcadeExpressions=!0;return}}_computeFormHeaderField(e){let{activeFeature:t,activeLayer:n}=this;return!e||!n||!t?null:P({attributes:t?.attributes,label:e,layer:n,timeZone:this.effectiveTimeZone})}_makeSubmitResults(){let e=new Map;for(let[n,r]of this._reactiveGraphicLookup){let i=[],a=[],o=this._featureFormMap.get(r)?.allAttachmentElementInputs??[];for(let e of o)t(i,e.toSubmitEdits()),e.valid||a.push(e.template.elementId);e.set(n,{feature:n,values:{...r.attributes},invalidFields:[],attachmentEdits:i,invalidAttachmentElementIds:a})}for(let t of this.sharedForm.allFieldInputs)for(let n of t.invalidFeatures)e.get(n)?.invalidFields.push(t.fieldName);return Array.from(e.values())}async _handleSubtypeChanged(e){let t=e.layer;if(this.contingentValuesManager.resetOptionsForFeature(t,e.plainGraphic),Y(t)&&this.contingentValuesManager.resetViolationsForFeature(t,e.plainGraphic),!w(t))return;let r=t.parent?.findSublayerForFeature(e.plainGraphic);if(!r)return;this._layerTemplateUpdateTask=l(this._layerTemplateUpdateTask);let i=n(async t=>{u(t),e.source.sourceLayer=r,e.source.origin=r.graphicOrigin,await this._ensureLayerTemplate(e,t),u(t),this._featureFormMap.get(e)?.destroy(),this._featureFormMap.set(e,this._makeBatchFormInputsForFeature(e)),await ee(this._valueChangeTransaction(t=>this._expressionsManager.runAllExpressions([e],t),`user`),t),u(t)});this._layerTemplateUpdateTask=i,await d(this._updatingHandles.addPromise(i.promise))}_emitSubmit(){this.emit(`submit`,{name:`submit`,results:this._makeSubmitResults(),valid:this.valid})}_findAttachmentInput(e){let t=this.activeForm.allAttachmentElementInputs.find(t=>t.template.elementId===e);return t||o.getLogger(this).error(`Attachment input not found for elementId '${e}'`),t}_findAttachment(e,t){let n=e.findAttachment(t);return n||o.getLogger(this).error(`Attachment '${t}' not found for attachment element '${e.template.elementId}'`),n}_makeAttachmentEdits(e){let n=[];for(let r of e.allAttachmentElementInputs)t(n,r.toSubmitEdits());return n}_emitAttachmentsChange(e){let t=e.single.feature;if(!t)return;let n=this._featureFormMap.get(t);this.emit(`attachments-change`,{name:`attachments-change`,feature:t.source,attachmentEdits:this._makeAttachmentEdits(n??this.activeForm),valid:this.valid})}async _valueChangeTransaction(e,t,n){let r=typeof n==`string`?n:n?.fieldName,i=new F(this,t,r);if(await e(i),t===`user`&&await this._expressionsManager.runExpressionsDependentOnChangedFields(i),await i.close(),i.hasChanges&&n){let e=typeof n==`string`?this.activeForm.allFieldInputs.find(e=>e.fieldName===n):n;e&&(e.userHasChangedValue=!0)}}_prepare(){this.pendingSubtypeChoice?.reject(),this._hasAsyncArcadeExpressions=!1,this._prepareTask=l(this._prepareTask),this._layerTemplateUpdateTask=l(this._layerTemplateUpdateTask),this._layerTemplateMap.clear(),this._updateWorkingFeatures(),c(this._expressionsManager),this.userHasChangedValues=!1,this._expressionsManager=new L({arcadeContext:{editType:this.editType,spatialReference:this.spatialReference??x.WebMercator,map:this.map,timeZone:this.timeZone||`system`}});let{layers:e}=this;if(e.length===0)return;let t=n(async t=>{try{u(t),this._updateWorkingFeatures(),this.contingentValuesManager.layers.addMany(e),await Promise.all(e.map(e=>e.load()));for(let n of e)await this._prepareLayer(n,t);if(this.hasTooManyComplexFeatures)throw new i(`too-many-features-with-complex-forms`,`There are too many features to load into the form with the configured complexity`);if(this.hasTooManyFeatures)throw new i(`too-many-features`,`There are too many features to load into the form.`);this._prepareSharedFormTemplate(),this.sharedForm=B(this.sharedFormTemplate,{allFeatures:this._workingFeatures,expressionsManager:this._expressionsManager,getExternalErrorForFeature:this._getExternalErrorForFeature,getFieldValueOptionsForFeature:this._getFieldValueOptionsForFeature,map:this.map,requestDeferredExpressionEvaluation:this._requestDeferredExpressionEvaluation,executeFeatureSetDependentExpressions:this._executeFeatureSetDependentExpressions}),await this._valueChangeTransaction(async e=>await this._expressionsManager.runAllExpressions(this._workingFeatures.toArray(),e),`expression`),await v(()=>!this.contingentValuesManager.updating)}catch(e){throw f(e)||o.getLogger(this).error(`Failed preparing form`,e),e}});this._updatingHandles.consumePromise(t.promise),this._prepareTask=t}async _prepareLayer(e,t){let n=ae(this.layerInfos,e),r=await G(e,{arcadeExecutorProvider:this._arcadeExecutorProvider,formTimeZone:this.timeZone,attachmentsEnabled:this.attachmentsEnabled},n?.formTemplate);u(t),this._layerTemplateMap.set(e,r);let i=r.getExpressionExecutorsForLayer(e);if(this._expressionsManager.layerExpressionsModelMap.set(e,new R({preserveFieldValuesWhenHidden:r.preserveFieldValuesWhenHidden,executorMap:i,fieldsIndex:e.fieldsIndex})),!this._hasAsyncArcadeExpressions){for(let e of i.values())if(e&&(this._hasAsyncArcadeExpressions=(e.editableExpression?.isAsync||e.requiredExpression?.isAsync||e.valueExpression?.isAsync||e.visibilityExpression?.isAsync)===!0,this._hasAsyncArcadeExpressions))break}}_prepareSharedFormTemplate(){let e=new Map;for(let t of this._layerTemplateMap.values())for(let n of t.elements){if(K(n))continue;let t=n.clone();q(t)&&(t.elements=t.elements.filter(e=>!K(e)));let{elementId:r}=t;e.has(r)?e.get(r).foldIn(t):e.set(r,t)}this.sharedFormTemplate=new W({elements:Array.from(e.values())})}_updateWorkingFeatures(){this._workingFeatures.destroyAll(),this._reactiveContingentValuesManager.reset();for(let e of this._featureFormMap.values())e.destroy();this._featureFormMap.clear(),this._attachmentCache.clear();let{features:e}=this;if(this._reactiveGraphicLookup=new p,e.length!==0){this._workingFeatures.addMany(e.map(k));for(let e of this._workingFeatures)this._reactiveGraphicLookup.set(e.source,e)}}async _syncAttachments(){let{activeFeature:e,activeLayer:t,activeForm:r}=this;if(!e||!r||!A(t)||!j(t))return;let i=e.getObjectId();if(i==null)return;let a=this._attachmentCache.get(t),o=r.allAttachmentElementInputs;if(!o.length)return;let c=n(async e=>{let n;if(a){let e=a.get(i);e&&(n=e)}n||(n=await M(t,i,o,e),s(this._attachmentCache,t,()=>new p).set(i,n));for(let e of o)e.applyFetchedAttachments(se(e,n))});this._syncAttachmentsTask=c,await d(c.promise)}get test(){return{expressionsManager:this._expressionsManager,reactiveGraphicLookup:this._reactiveGraphicLookup,syncAttachmentsTask:this._syncAttachmentsTask,arcadeExecutorProvider:this._arcadeExecutorProvider,requestDeferredExpressionEvaluation:this._requestDeferredExpressionEvaluation,executeAsyncExpressions:this._executeFeatureSetDependentExpressions}}};e([y()],Z.prototype,`_attachmentCache`,void 0),e([y({readOnly:!0})],Z.prototype,`activeFeature`,null),e([y()],Z.prototype,`activeFeatureIndex`,void 0),e([y({readOnly:!0})],Z.prototype,`activeForm`,null),e([y({readOnly:!0})],Z.prototype,`activeLayer`,null),e([y()],Z.prototype,`activeAssociation`,null),e([y()],Z.prototype,`activeAssociationsInput`,null),e([y()],Z.prototype,`activeAssociationType`,null),e([y()],Z.prototype,`activeRelationshipInput`,null),e([y()],Z.prototype,`attachmentsEnabled`,void 0),e([y()],Z.prototype,`callbacks`,void 0),e([y()],Z.prototype,`disabled`,void 0),e([y()],Z.prototype,`calculating`,null),e([y()],Z.prototype,`canGoBack`,null),e([y()],Z.prototype,`contingentValuesManager`,void 0),e([y()],Z.prototype,`editType`,void 0),e([y()],Z.prototype,`features`,void 0),e([y()],Z.prototype,`expressionEvaluationFailed`,null),e([y()],Z.prototype,`hasNonActiveInvalidFeatures`,null),e([y()],Z.prototype,`hasAsyncArcadeExpressions`,null),e([y()],Z.prototype,`_hasAsyncArcadeExpressions`,void 0),e([y()],Z.prototype,`invalidFeatures`,null),e([y()],Z.prototype,`hasVisibleInputs`,null),e([y()],Z.prototype,`hasLayersWithContingentValues`,null),e([y()],Z.prototype,`formDescription`,null),e([y()],Z.prototype,`formTitle`,null),e([y()],Z.prototype,`effectiveTimeZone`,null),e([y()],Z.prototype,`highlightHelper`,void 0),e([y()],Z.prototype,`maximumFeatureCount`,void 0),e([y()],Z.prototype,`maximumFeatureCountWithComplexForms`,void 0),e([y()],Z.prototype,`visibleInputs`,null),e([y()],Z.prototype,`map`,null),e([y()],Z.prototype,`noVisibleElementsReason`,null),e([y()],Z.prototype,`page`,null),e([y()],Z.prototype,`pageStack`,void 0),e([y()],Z.prototype,`readOnly`,void 0),e([y()],Z.prototype,`pendingSubtypeChoice`,void 0),e([y()],Z.prototype,`subtypes`,null),e([y()],Z.prototype,`spatialReference`,void 0),e([y()],Z.prototype,`submitHasBeenAttempted`,void 0),e([y()],Z.prototype,`timeZone`,null),e([y()],Z.prototype,`view`,void 0),e([y()],Z.prototype,`updating`,null),e([y()],Z.prototype,`valid`,null),e([y()],Z.prototype,`layers`,null),e([y()],Z.prototype,`mode`,null),e([y()],Z.prototype,`sharedForm`,void 0),e([y()],Z.prototype,`sharedFormTemplate`,void 0),e([y()],Z.prototype,`selectedAttachment`,null),e([y()],Z.prototype,`selectedAttachmentAddElementId`,null),e([y()],Z.prototype,`selectedAttachmentListElementId`,null),e([y()],Z.prototype,`selectedAttachmentListInput`,null),e([y()],Z.prototype,`showingSelectedAttachmentReplacePage`,null),e([y()],Z.prototype,`selectedAttachmentAddInput`,null),e([y()],Z.prototype,`selectedAttachmentDetails`,null),e([y()],Z.prototype,`userHasChangedValues`,void 0),e([y()],Z.prototype,`layerInfos`,void 0),e([y()],Z.prototype,`_arcadeExecutorProvider`,void 0),e([y()],Z.prototype,`_activeAssociation`,void 0),e([y()],Z.prototype,`_activeAssociationsInput`,void 0),e([y()],Z.prototype,`_activeRelationshipInput`,void 0),e([y()],Z.prototype,`_prepareTask`,void 0),e([y()],Z.prototype,`_reactiveGraphicLookup`,void 0),e([y()],Z.prototype,`_allAttachmentInputs`,null),e([y()],Z.prototype,`_hasPendingAttachmentHydration`,null),e([y()],Z.prototype,`_layerTemplateMap`,void 0),e([y()],Z.prototype,`_layersSet`,null),e([y()],Z.prototype,`_workingFeatures`,void 0),e([y()],Z.prototype,`_expressionsManager`,void 0),Z=e([b(`esri.widgets.BatchAttributeForm.BatchAttributeFormViewModel`)],Z);const oe=Z;function Q(e){return e!=null&&e.trim().length>0}function $(e,t){let n=e.keywords;return Q(n)&&n.toLowerCase()===t}function se(e,t){let n=e.input?.type===`attachment`?e.input.attachmentAssociationType:`exact`,r=e.attachmentKeyword;if(n===`any`)return t;if(n===`exactOrNone`){if(X(r))return t.filter(e=>!Q(e.keywords));let e=r.toLowerCase();return t.filter(t=>!Q(t.keywords)||$(t,e))}if(X(r))return t;let i=r.toLowerCase();return t.filter(e=>$(e,i))}export{oe as default};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import t from"../../../core/Accessor.js";import n from"../../../core/Error.js";import r from"../../../core/Logger.js";import{getOrCreateMapValue as i}from"../../../core/MapUtils.js";import{whenOrAbort as a,settleWithPromise as o}from"../../../core/promiseUtils.js";import s from"../../../core/ReactiveMap.js";import{addMany as c,first as l}from"../../../core/SetUtils.js";import{property as u,subclass as d}from"../../../core/accessorSupport/decorators.js";import{makeArcadeContext as f,castArcadeValue as p,isDeferredExpressionType as m}from"./expressionUtils.js";import{makeUseId as h}from"../inputs/support/inputUtils.js";import{isFieldElementTemplate as g,isGroupElementTemplate as _}from"../templates/support/templateUtils.js";let v=null;const y=()=>r.getLogger(`esri.widgets.BatchAttributeForm.expressions.ExpressionsManager`);let b=class extends t{constructor(e){super(e),this.calculating=!1,this.arcadeContext=null,this._abortController=new AbortController,this.layerExpressionsModelMap=new Map,this.outcomes=new s,this.expressionEvaluationFailed=!1}destroy(){this.abort()}abort(){this._abortController.abort()}async runAllExpressions(e,t){return this._evaluateSpecifiedExecutorsForEachFeature(e,S,t)}async requestDeferredExecution(e,t,n){return this._evaluateSpecifiedExecutorsForEachFeature(e,(e,n)=>{let r=t(n);return r?[r]:[]},n,!0)}async
|
|
2
|
+
import{__decorate as e}from"tslib";import t from"../../../core/Accessor.js";import n from"../../../core/Error.js";import r from"../../../core/Logger.js";import{getOrCreateMapValue as i}from"../../../core/MapUtils.js";import{whenOrAbort as a,settleWithPromise as o}from"../../../core/promiseUtils.js";import s from"../../../core/ReactiveMap.js";import{addMany as c,first as l}from"../../../core/SetUtils.js";import{property as u,subclass as d}from"../../../core/accessorSupport/decorators.js";import{makeArcadeContext as f,castArcadeValue as p,isDeferredExpressionType as m}from"./expressionUtils.js";import{makeUseId as h}from"../inputs/support/inputUtils.js";import{isFieldElementTemplate as g,isGroupElementTemplate as _}from"../templates/support/templateUtils.js";let v=null;const y=()=>r.getLogger(`esri.widgets.BatchAttributeForm.expressions.ExpressionsManager`);let b=class extends t{constructor(e){super(e),this.calculating=!1,this.arcadeContext=null,this._abortController=new AbortController,this.layerExpressionsModelMap=new Map,this.outcomes=new s,this.expressionEvaluationFailed=!1}destroy(){this.abort()}abort(){this._abortController.abort()}async runAllExpressions(e,t){return this._evaluateSpecifiedExecutorsForEachFeature(e,S,t)}async requestDeferredExecution(e,t,n){return this._evaluateSpecifiedExecutorsForEachFeature(e,(e,n)=>{let r=t(n);return r?[r]:[]},n,!0)}async runFeatureSetDependentExpressions(e,t){return this._evaluateSpecifiedExecutorsForEachFeature(e,C,t)}async runGeometryDependentExpressions(e,t){return this._evaluateSpecifiedExecutorsForEachFeature(e,w,t)}async runOriginalFeatureDependentExpressions(e,t){return this._evaluateSpecifiedExecutorsForEachFeature([e],T,t)}async runExpressionsDependentOnChangedFields(e){try{this.calculating=!0;let t=Array.from(e.changes).map(([t,n])=>this.runExpressionsDependentOnChangedFieldsForFeature([...n.keys()],t,e));k(await Promise.allSettled(t))}catch(e){y().error(e),this.expressionEvaluationFailed=!0}finally{this.calculating=!1}}async runExpressionsDependentOnChangedFieldsForFeature(e,t,n){if(this._abortController.signal.aborted)return;let r=this.layerExpressionsModelMap.get(t.layer);if(!r||r.components.length===0)return;let i=D(r,e);i.length!==0&&await this.evaluateAffectedExecutors([...i],t,r,n)}async evaluateAffectedExecutors(e,t,n,r,o=!1){let c=new Map,l=i(this.outcomes,t,()=>new s);for(let r of e){if(!o){let e=F(r,l,n);e&&(e.invalidated=!0)}let e=n.dependencyGraphComponents.get(r);e&&i(c,e,()=>this.createSccEvaluator({scc:e,feature:t,evaluatorMap:c,expressionModel:n}))}let u=[...c.values()],d={transaction:r,previousOutcomes:new s,isDeferred:o},f=u.map(e=>e.evaluate(d));k(await a(Promise.allSettled(f),this._abortController))}createSccEvaluator({scc:e,feature:t,evaluatorMap:n,expressionModel:r}){let a=i(this.outcomes,t,()=>new s),o=new x(e,t,this.arcadeContext,r,a,this._abortController);for(let a of e.adjacencyList)i(n,a,()=>this.createSccEvaluator({scc:a,feature:t,evaluatorMap:n,expressionModel:r})).dependencies.push(o);return o}async _evaluateSpecifiedExecutorsForEachFeature(e,t,n,r=!1){r||(this.calculating=!0);try{let i=[];for(let a of e){let{layer:e}=a,o=this.layerExpressionsModelMap.get(e);o&&o.components.length!==0&&i.push(this.evaluateAffectedExecutors(t(o,e),a,o,n,r))}k(await a(Promise.allSettled(i),this._abortController))}catch(e){y().error(e),this.expressionEvaluationFailed=!0}finally{this.calculating=!1}}};e([u()],b.prototype,`calculating`,void 0),e([u({constructOnly:!0})],b.prototype,`arcadeContext`,void 0),e([u()],b.prototype,`_abortController`,void 0),e([u()],b.prototype,`layerExpressionsModelMap`,void 0),e([u()],b.prototype,`outcomes`,void 0),e([u()],b.prototype,`expressionEvaluationFailed`,void 0),b=e([d(`esri.widgets.BatchAttributeForm.expressions.ExpressionsManager`)],b);class x{constructor(e,t,n,r,i,a){this.scc=e,this.feature=t,this.arcadeContextInfo=n,this.expressionsModel=r,this.outcomes=i,this._abortController=a,this._resolver=null,this.dependencies=[]}get baseContext(){return f(this.arcadeContextInfo,this.feature,this._abortController.signal)}evaluate(e){return this._resolver||(this._resolver=Promise.withResolvers(),o(this._resolver,this._evaluate(e))),this._resolver.promise}async _evaluate(e){v===null&&(v=await import(`../../../arcade/languageUtils.js`));let t=[],n=this.dependencies.map(t=>t.evaluate(e));k(await a(Promise.allSettled(n),this._abortController));let{executors:r}=this.scc;if(r.size===1?await this._evaluateSingleExecutorComponent({context:e,executor:l(r),errorsToReport:t}):await this._evaluateMultiExecutorComponent({context:e,errorsToReport:t}),t.length>0)throw O(t)}async _evaluateMultiExecutorComponent({context:e,errorsToReport:t}){let{transaction:n}=e,r=new Map,i=!0,a=0;for(;i&&a<3;){i=!1,a++;for(let a of this.scc.executors){let o=this._findOutcome(a)??{status:`not-run`,invalidated:!0};o.invalidated||=this._invalidatedSinceCheckpoint(a,n,r.get(a)),this._shouldEvaluate(a,o,e)&&(i=!0,r.set(a,n.currentCheckpoint),await this._performEvaluation({context:e,executor:a,errorsToReport:t}))}}}async _evaluateSingleExecutorComponent({context:e,executor:t,errorsToReport:n}){let r=this._findOutcome(t)??{status:`not-run`,invalidated:!0};r.invalidated||=this._invalidatedSinceCheckpoint(t,e.transaction),this._shouldEvaluate(t,r,e)&&await this._performEvaluation({context:e,executor:t,errorsToReport:n})}async _performEvaluation({context:e,executor:t,errorsToReport:r}){let{variables:i,executeContext:a}=this.baseContext,o=null,s=null;try{o=t.isAsync?await t.executeAsync(i,a):t.execute(i,a),s={result:o,status:`success`}}catch(e){s={error:e,status:`error`}}let{transaction:c,previousOutcomes:l}=e,{outcomes:u}=this,d=this.expressionsModel.arcadeExecutorUses.get(t)??[];for(let t of d){let n=h(t),r=u.get(n);r&&l.set(n,r),u.set(h(t),s);let i=this.expressionsModel.elementTemplateMap.get(t.elementId);switch(t.executorPurpose){case`editableExpression`:if(s.result===!1&&r?.result!==!1){let e=u.get(h({elementId:i.elementId,executorPurpose:`valueExpression`}));if(e){let{fieldName:t}=i,n=E(this.feature,t),r=p(e.result,n,this.arcadeContextInfo.timeZone,v);c.setValue(this.feature,t,r)}}break;case`valueExpression`:{if(s?.status===`error`)continue;let e=i.getExpressionExecutorsForLayer(this.feature.layer),t=!0;if(e?.editableExpression&&(t=u.get(h({elementId:i.elementId,executorPurpose:`editableExpression`}))?.result===!1),t){let e=i.fieldName,t=this.feature.getAttribute(e)??null;try{let n=E(this.feature,e),r=p(s.result,n,this.arcadeContextInfo.timeZone,v);r!==t&&c.setValue(this.feature,e,r)}catch(t){y().error(`Failed to set calculated value for field '${e}'`,t)}}}break;case`visibilityExpression`:!this.expressionsModel.preserveFieldValuesWhenHidden&&r?.result===!0&&s.result===!1&&c.originActor===`user`&&A(i,this.feature,u,e)}}if(s?.status===`error`){let e=new Set;for(let t of d){let n=this.expressionsModel.elementTemplateMap.get(t.elementId);if(n)switch(t.executorPurpose){case`editableExpression`:e.add(n.label+` - Editable expression`);break;case`requiredExpression`:e.add(n.label+` - Required expression`);break;case`valueExpression`:e.add(n.label+` - Value expression`);break;case`visibilityExpression`:e.add(n.label+` - Visibility expression`)}}r.push(e.size>0?new n(`expression-evaluation-failed`,`Arcade evaluation failed (`+[...e].join(`,`)+`)`):new n(`expression-evaluation-failed`,`Arcade evaluation failed `))}}_invalidatedSinceCheckpoint(e,t,n=-1){let r=t.changesForFeature(this.feature);return!r||r.size===0?!1:this.scc.getFieldsReferenced(e).values().some(e=>r.has(e)&&r.get(e)>n)}_shouldEvaluate(e,t,{isDeferred:n}){return this._abortController.signal.aborted||I(this.expressionsModel.arcadeExecutorUses.get(e))&&!n?!1:!!t.invalidated}_findOutcome(e){return F(e,this.outcomes,this.expressionsModel)}}function S(e){return Array.from(e.dependencyGraphComponents.keys())}function C(e){return Array.from(e.dependencyGraphComponents.keys().filter(e=>e.syntaxTree.usesFeatureSet))}function w(e){return Array.from(e.geometryReferences)}function T(e){return Array.from(e.originalFeatureReferences)}function E(e,t){let r=e.layer.fieldsIndex.get(t);if(!r)throw new n(`field-not-found`,`Field '${t}' not found on layer.`);return r}function D(e,t){let n=new Set;for(let r of t)c(n,e.fieldReferencesMap.get(r));return Array.from(n)}function O(e){return AggregateError(e,`One or more expression executions failed. First error message: ${e[0].message}`)}function k(e){let t=[],n=new Set;for(let r of e){if(r.status===`fulfilled`)continue;let e=r.reason instanceof AggregateError?r.reason.errors:[r.reason];for(let r of e)n.has(r)||(n.add(r),t.push(r))}if(t.length>0)throw O(t)}function A(e,t,n,r){g(e)?j(e,t,n,r):_(e)&&M(e,t,n,r)}function j(e,t,n,r){let{group:i}=e;(!i||P(i,n,r.previousOutcomes))&&N(t,e,r)}function M(e,t,n,r){for(let i of e.elements)g(i)&&P(i,n,r.previousOutcomes)&&N(t,i,r)}function N(e,{fieldName:t},n){n.transaction.setValue(e,t,null)}function P(e,t,n){let r=h({elementId:e.elementId,executorPurpose:`visibilityExpression`}),i=n.get(r)??t.get(r);return!i||!!i.result}function F(e,t,n){let r=n.arcadeExecutorUses.get(e);if(r)for(let e of r){let n=t.get(h(e));if(n)return n}}function I(e){return e?.every(e=>m(e.executorPurpose))??!1}export{b as ExpressionsManager};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import{destroyMaybe as t}from"../../../core/maybe.js";import{on as n}from"../../../core/reactiveUtils.js";import{property as r,subclass as i}from"../../../core/accessorSupport/decorators.js";import{isSubtypeGroupLayer as a,getEffectiveLayerCapabilities as o}from"../../../layers/support/layerUtils.js";import{isRelatableFeatureSupportedLayer as s}from"../../../popup/support/featureUtils.js";import{getComputedAttributes as c,parseFormTemplateString as l}from"../stringUtils.js";import u from"./EditableInput.js";import d from"./SingleFeatureInputAdapter.js";import f from"../../Feature/FeatureRelationship/FeatureRelationshipViewModel.js";let p=class extends u{constructor(e){super(e),this._relationshipVM=new f,this._showAllCategories=!1,this._showAllRelatedRecords=!1,this.group=null,this.map=null,this.single=new d({input:this}),this.type=`relationship`}initialize(){this._setRelationshipVMProps(),this.addHandles([n(()=>this.relatedLayer,`edits`,()=>this._relationshipVM?.refresh())])}destroy(){t(this._relationshipVM)}get activeCategory(){return this._relationshipVM.activeCategory}get allCategories(){let{relatedLayer:e,_relationshipVM:t}=this;if(!a(e))return;let n=t?.categories,r=(e.subtypes??[]).map(({code:e,name:t})=>{let r=n?.find(e=>e.name===t);return{name:t,count:r?.count??0,value:r?.value??e}});return r.length?r:null}get categories(){return this.showAllEnabled?this.allCategories:this.allCategories?.slice(0,this.displayCount)}get canAddRelatedFeature(){let{editable:e,relatedFeatureCount:t,relationship:n}=this;if(!n||!this.loaded||!this._relatedLayerAllowsAdds||this.allCategories?.length&&!this.activeCategory)return!1;let{cardinality:r,role:i}=n;return r===`one-to-one`&&t>0||r===`many-to-many`||r===`one-to-many`&&i===`destination`&&t>0?!1:e}get displayCount(){return this.template.displayCount}get displayType(){return this.template.displayType}get editable(){return this._relatedLayerAllowsEdits?this._evaluatedEditableExpression??!0:!1}get feature(){return this.single.feature}get relatedFeatureCount(){return this._relationshipVM?.featureCount??0}get label(){return this.activeCategory?.name?this.activeCategory.name:this._computeStringLiteralText(this.template.label)}get layer(){return this.single.layer}get loaded(){return this._relationshipVM?.state!==`loading`}get orderByFields(){return this.template.orderByFields}get originHasValidKey(){let e=this.feature?.layer.fieldsIndex.get(this.relationship?.keyField)?.name;return!!e&&this.feature?.getAttribute(e)!=null}get relationship(){return this._relationshipVM?.relationship}get relationshipId(){return this.template.relationshipId}get relatedFeatureInfos(){let{_relationshipVM:e,effectiveTimeZone:t}=this;if(!e?.relatedFeatures?.length||!e?.relatedLayer)return[];let{itemDescriptionFieldName:n,relatedFeatures:r,relatedLayer:i}=e,a=i?.formTemplate?.title||void 0;return r.map(e=>{let r;if(n){let a=e.getAttribute(n),o=i.fieldsIndex.get(n);if(o){let e=c({fields:[o],layer:i,values:[a],timeZone:t})[n];e!=null&&(r=e.toString())}}let o=a?l({attributes:e.attributes,label:a,layer:i,timeZone:t}):void 0;return{feature:e,description:r,title:o}}).toArray()}get relatedLayer(){return this._relationshipVM?.relatedLayer}get relatedLayerIsTable(){return!!this.relatedLayer?.isTable}get showAllEnabled(){return this._relationshipVM.showAllEnabled}get showAllActionVisible(){return!this.showAllEnabled&&this.relatedFeatureCount>0&&this.relatedFeatureCount>this.displayCount}get showAllCategories(){return this._showAllCategories}get showAllCategoriesVisible(){let e=this.allCategories?.length??0;return!this.showAllEnabled&&e>0&&e>this.displayCount}get showAllRelatedRecords(){return this._showAllRelatedRecords}get updating(){return this._relationshipVM?.state===`loading`||this._relationshipVM?.state===`querying`}incrementPage(){this._relationshipVM&&this._relationshipVM.featurePage++}setActiveCategory(e){this._relationshipVM.activeCategory=e,this.setShowAllRelatedRecords(!!e)}setShowAllCategories(e){this._showAllCategories=e,this._showAllRelatedRecords||this._setShowAllEnabled(e)}setShowAllRelatedRecords(e){this._showAllRelatedRecords=e,this._showAllCategories||this._setShowAllEnabled(e)}get _relatedLayerAllowsAdds(){let{relatedLayer:e}=this;return!e||!this._relatedLayerAllowsEdits?!1:!!o(e)?.operations?.supportsAdd}get _relatedLayerAllowsEdits(){let{relatedLayer:e}=this;return e?!!o(e)?.operations?.supportsEditing:!1}_setRelationshipVMProps(){let{displayCount:e,feature:t,layer:n,orderByFields:r,map:i,relationshipId:a,showAllEnabled:o}=this;t&&n&&s(n)&&this._relationshipVM.set({displayCount:e,graphic:t.plainGraphic,layer:n,map:i,orderByFields:r,relationshipId:a,showAllEnabled:o})}_setShowAllEnabled(e){this._relationshipVM.showAllEnabled=e}};e([r()],p.prototype,`_relationshipVM`,void 0),e([r()],p.prototype,`_showAllCategories`,void 0),e([r()],p.prototype,`_showAllRelatedRecords`,void 0),e([r()],p.prototype,`activeCategory`,null),e([r()],p.prototype,`allCategories`,null),e([r()],p.prototype,`categories`,null),e([r()],p.prototype,`canAddRelatedFeature`,null),e([r()],p.prototype,`displayCount`,null),e([r()],p.prototype,`displayType`,null),e([r()],p.prototype,`editable`,null),e([r()],p.prototype,`feature`,null),e([r()],p.prototype,`group`,void 0),e([r()],p.prototype,`label`,null),e([r()],p.prototype,`layer`,null),e([r()],p.prototype,`loaded`,null),e([r()],p.prototype,`map`,void 0),e([r()],p.prototype,`orderByFields`,null),e([r()],p.prototype,`originHasValidKey`,null),e([r()],p.prototype,`relationship`,null),e([r()],p.prototype,`relationshipId`,null),e([r()],p.prototype,`relatedFeatureInfos`,null),e([r()],p.prototype,`relatedLayer`,null),e([r()],p.prototype,`relatedLayerIsTable`,null),e([r({readOnly:!0})],p.prototype,`single`,void 0),e([r()],p.prototype,`showAllEnabled`,null),e([r()],p.prototype,`showAllActionVisible`,null),e([r()],p.prototype,`showAllCategories`,null),e([r()],p.prototype,`showAllCategoriesVisible`,null),e([r()],p.prototype,`showAllRelatedRecords`,null),e([r({readOnly:!0})],p.prototype,`type`,void 0),e([r()],p.prototype,`updating`,null),e([r()],p.prototype,`_relatedLayerAllowsAdds`,null),e([r()],p.prototype,`_relatedLayerAllowsEdits`,null),p=e([i(`esri.widgets.BatchAttributeForm.inputs.RelationshipElementInput`)],p);const m=p;export{m as default};
|
|
2
|
+
import{__decorate as e}from"tslib";import{destroyMaybe as t}from"../../../core/maybe.js";import{on as n}from"../../../core/reactiveUtils.js";import{property as r,subclass as i}from"../../../core/accessorSupport/decorators.js";import{isSubtypeGroupLayer as a,getEffectiveLayerCapabilities as o}from"../../../layers/support/layerUtils.js";import{isRelatableFeatureSupportedLayer as s}from"../../../popup/support/featureUtils.js";import{getComputedAttributes as c,parseFormTemplateString as l}from"../stringUtils.js";import u from"./EditableInput.js";import d from"./SingleFeatureInputAdapter.js";import f from"../../Feature/FeatureRelationship/FeatureRelationshipViewModel.js";let p=class extends u{constructor(e){super(e),this._relationshipVM=new f,this._showAllCategories=!1,this._showAllRelatedRecords=!1,this.executeFeatureSetDependentExpressions=null,this.group=null,this.map=null,this.single=new d({input:this}),this.type=`relationship`}initialize(){this._setRelationshipVMProps(),this.addHandles([n(()=>this.relatedLayer,`edits`,()=>{this._relationshipVM?.refresh(),this.executeFeatureSetDependentExpressions?.(this.features.toArray())})])}destroy(){t(this._relationshipVM)}get activeCategory(){return this._relationshipVM.activeCategory}get allCategories(){let{relatedLayer:e,_relationshipVM:t}=this;if(!a(e))return;let n=t?.categories,r=(e.subtypes??[]).map(({code:e,name:t})=>{let r=n?.find(e=>e.name===t);return{name:t,count:r?.count??0,value:r?.value??e}});return r.length?r:null}get categories(){return this.showAllEnabled?this.allCategories:this.allCategories?.slice(0,this.displayCount)}get canAddRelatedFeature(){let{editable:e,relatedFeatureCount:t,relationship:n}=this;if(!n||!this.loaded||!this._relatedLayerAllowsAdds||this.allCategories?.length&&!this.activeCategory)return!1;let{cardinality:r,role:i}=n;return r===`one-to-one`&&t>0||r===`many-to-many`||r===`one-to-many`&&i===`destination`&&t>0?!1:e}get displayCount(){return this.template.displayCount}get displayType(){return this.template.displayType}get editable(){return this._relatedLayerAllowsEdits?this._evaluatedEditableExpression??!0:!1}get feature(){return this.single.feature}get relatedFeatureCount(){return this._relationshipVM?.featureCount??0}get label(){return this.activeCategory?.name?this.activeCategory.name:this._computeStringLiteralText(this.template.label)}get layer(){return this.single.layer}get loaded(){return this._relationshipVM?.state!==`loading`}get orderByFields(){return this.template.orderByFields}get originHasValidKey(){let e=this.feature?.layer.fieldsIndex.get(this.relationship?.keyField)?.name;return!!e&&this.feature?.getAttribute(e)!=null}get relationship(){return this._relationshipVM?.relationship}get relationshipId(){return this.template.relationshipId}get relatedFeatureInfos(){let{_relationshipVM:e,effectiveTimeZone:t}=this;if(!e?.relatedFeatures?.length||!e?.relatedLayer)return[];let{itemDescriptionFieldName:n,relatedFeatures:r,relatedLayer:i}=e,a=i?.formTemplate?.title||void 0;return r.map(e=>{let r;if(n){let a=e.getAttribute(n),o=i.fieldsIndex.get(n);if(o){let e=c({fields:[o],layer:i,values:[a],timeZone:t})[n];e!=null&&(r=e.toString())}}let o=a?l({attributes:e.attributes,label:a,layer:i,timeZone:t}):void 0;return{feature:e,description:r,title:o}}).toArray()}get relatedLayer(){return this._relationshipVM?.relatedLayer}get relatedLayerIsTable(){return!!this.relatedLayer?.isTable}get showAllEnabled(){return this._relationshipVM.showAllEnabled}get showAllActionVisible(){return!this.showAllEnabled&&this.relatedFeatureCount>0&&this.relatedFeatureCount>this.displayCount}get showAllCategories(){return this._showAllCategories}get showAllCategoriesVisible(){let e=this.allCategories?.length??0;return!this.showAllEnabled&&e>0&&e>this.displayCount}get showAllRelatedRecords(){return this._showAllRelatedRecords}get updating(){return this._relationshipVM?.state===`loading`||this._relationshipVM?.state===`querying`}incrementPage(){this._relationshipVM&&this._relationshipVM.featurePage++}setActiveCategory(e){this._relationshipVM.activeCategory=e,this.setShowAllRelatedRecords(!!e)}setShowAllCategories(e){this._showAllCategories=e,this._showAllRelatedRecords||this._setShowAllEnabled(e)}setShowAllRelatedRecords(e){this._showAllRelatedRecords=e,this._showAllCategories||this._setShowAllEnabled(e)}get _relatedLayerAllowsAdds(){let{relatedLayer:e}=this;return!e||!this._relatedLayerAllowsEdits?!1:!!o(e)?.operations?.supportsAdd}get _relatedLayerAllowsEdits(){let{relatedLayer:e}=this;return e?!!o(e)?.operations?.supportsEditing:!1}_setRelationshipVMProps(){let{displayCount:e,feature:t,layer:n,orderByFields:r,map:i,relationshipId:a,showAllEnabled:o}=this;t&&n&&s(n)&&this._relationshipVM.set({displayCount:e,graphic:t.plainGraphic,layer:n,map:i,orderByFields:r,relationshipId:a,showAllEnabled:o})}_setShowAllEnabled(e){this._relationshipVM.showAllEnabled=e}};e([r()],p.prototype,`_relationshipVM`,void 0),e([r()],p.prototype,`_showAllCategories`,void 0),e([r()],p.prototype,`_showAllRelatedRecords`,void 0),e([r()],p.prototype,`activeCategory`,null),e([r()],p.prototype,`allCategories`,null),e([r()],p.prototype,`categories`,null),e([r()],p.prototype,`canAddRelatedFeature`,null),e([r()],p.prototype,`displayCount`,null),e([r()],p.prototype,`displayType`,null),e([r()],p.prototype,`editable`,null),e([r()],p.prototype,`executeFeatureSetDependentExpressions`,void 0),e([r()],p.prototype,`feature`,null),e([r()],p.prototype,`group`,void 0),e([r()],p.prototype,`label`,null),e([r()],p.prototype,`layer`,null),e([r()],p.prototype,`loaded`,null),e([r()],p.prototype,`map`,void 0),e([r()],p.prototype,`orderByFields`,null),e([r()],p.prototype,`originHasValidKey`,null),e([r()],p.prototype,`relationship`,null),e([r()],p.prototype,`relationshipId`,null),e([r()],p.prototype,`relatedFeatureInfos`,null),e([r()],p.prototype,`relatedLayer`,null),e([r()],p.prototype,`relatedLayerIsTable`,null),e([r({readOnly:!0})],p.prototype,`single`,void 0),e([r()],p.prototype,`showAllEnabled`,null),e([r()],p.prototype,`showAllActionVisible`,null),e([r()],p.prototype,`showAllCategories`,null),e([r()],p.prototype,`showAllCategoriesVisible`,null),e([r()],p.prototype,`showAllRelatedRecords`,null),e([r({readOnly:!0})],p.prototype,`type`,void 0),e([r()],p.prototype,`updating`,null),e([r()],p.prototype,`_relatedLayerAllowsAdds`,null),e([r()],p.prototype,`_relatedLayerAllowsEdits`,null),p=e([i(`esri.widgets.BatchAttributeForm.inputs.RelationshipElementInput`)],p);const m=p;export{m as default};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
-
import e from"../../../../core/Error.js";import t from"../AttachmentElementInput.js";import n from"../BatchFormInputs.js";import r from"../FieldInput.js";import i from"../GroupInput.js";import a from"../RelationshipElementInput.js";import o from"../TextElementInput.js";import s from"../UtilityNetworkAssociationsElementInput.js";import{isMultipleChoiceController as c}from"./controllerUtils.js";import{hashGroupElementTemplateWithoutChildren as l}from"../../templates/support/hashElementTemplate.js";import{isFieldElementTemplate as u,isGroupElementTemplate as d,isRelationshipElementTemplate as f,isTextElementTemplate as p,isAttachmentElementTemplate as m,isUtilityNetworkAssociationsElementTemplate as h}from"../../templates/support/templateUtils.js";function g(e,t){let r=new n({inputs:e.elements.map(e=>S(e,t)),template:e});return x(r),r}function _(e,t,n){let r=g(t,n),{mergedInputs:i}=v(e.inputs,r.inputs,e.staleInputs);e.template=t,e.inputs=i,x(e)}function v(e,t,n){let r=new Set,i=[],a=new Map(e.map(e=>[b(e),e]));for(let e of t){let t=b(e);r.add(t);let o=a.get(t);if(o){y(o,e),i.push(o),e.destroy();continue}let s=n.get(t);s?(y(s,e),i.push(s),n.delete(t),e.destroy()):i.push(e)}for(let t of e){let e=b(t);r.has(e)||n.set(e,t)}return{mergedInputs:i}}function y(e,t){if(e.features=t.features,e.existsInAllLayers=t.existsInAllLayers,e instanceof r&&t instanceof r&&e.template.foldIn(t.template),e.type!==`group`||t.type!==`group`)return;let{mergedInputs:n}=v(e.inputs,t.inputs,e.staleInputs);e.inputs=n;for(let t of n)t.group=e}function b(e){return e.type===`group`?l(e.template):e.template.elementId}function x(e){let t=e.allFieldInputs,n=new Set(t.map(e=>e.fieldName));for(let e of t){let t=c(e.inputController)?e.inputController:null,r=t?.otherChoiceFieldName;if(!r)continue;let i=e.layers[0]?.getField(r)?.name??r;n.has(i)&&(t.shouldShowOtherChoice=!1)}}function S(n,c){let{allFeatures:l,expressionsManager:g,getFieldValueOptionsForFeature:_,getExternalErrorForFeature:v,map:y,requestDeferredExpressionEvaluation:b}=c,
|
|
2
|
+
import e from"../../../../core/Error.js";import t from"../AttachmentElementInput.js";import n from"../BatchFormInputs.js";import r from"../FieldInput.js";import i from"../GroupInput.js";import a from"../RelationshipElementInput.js";import o from"../TextElementInput.js";import s from"../UtilityNetworkAssociationsElementInput.js";import{isMultipleChoiceController as c}from"./controllerUtils.js";import{hashGroupElementTemplateWithoutChildren as l}from"../../templates/support/hashElementTemplate.js";import{isFieldElementTemplate as u,isGroupElementTemplate as d,isRelationshipElementTemplate as f,isTextElementTemplate as p,isAttachmentElementTemplate as m,isUtilityNetworkAssociationsElementTemplate as h}from"../../templates/support/templateUtils.js";function g(e,t){let r=new n({inputs:e.elements.map(e=>S(e,t)),template:e});return x(r),r}function _(e,t,n){let r=g(t,n),{mergedInputs:i}=v(e.inputs,r.inputs,e.staleInputs);e.template=t,e.inputs=i,x(e)}function v(e,t,n){let r=new Set,i=[],a=new Map(e.map(e=>[b(e),e]));for(let e of t){let t=b(e);r.add(t);let o=a.get(t);if(o){y(o,e),i.push(o),e.destroy();continue}let s=n.get(t);s?(y(s,e),i.push(s),n.delete(t),e.destroy()):i.push(e)}for(let t of e){let e=b(t);r.has(e)||n.set(e,t)}return{mergedInputs:i}}function y(e,t){if(e.features=t.features,e.existsInAllLayers=t.existsInAllLayers,e instanceof r&&t instanceof r&&e.template.foldIn(t.template),e.type!==`group`||t.type!==`group`)return;let{mergedInputs:n}=v(e.inputs,t.inputs,e.staleInputs);e.inputs=n;for(let t of n)t.group=e}function b(e){return e.type===`group`?l(e.template):e.template.elementId}function x(e){let t=e.allFieldInputs,n=new Set(t.map(e=>e.fieldName));for(let e of t){let t=c(e.inputController)?e.inputController:null,r=t?.otherChoiceFieldName;if(!r)continue;let i=e.layers[0]?.getField(r)?.name??r;n.has(i)&&(t.shouldShowOtherChoice=!1)}}function S(n,c){let{allFeatures:l,expressionsManager:g,getFieldValueOptionsForFeature:_,getExternalErrorForFeature:v,map:y,requestDeferredExpressionEvaluation:b,executeFeatureSetDependentExpressions:x}=c,C=new Set(n.layers),w=l.filter(e=>C.has(e.layer)),T=w.length===l.length;if(u(n))return new r({existsInAllLayers:T,features:w,template:n,expressionsManager:g,getExternalErrorForFeature:v,getFieldValueOptionsForFeature:_,requestDeferredExpressionEvaluation:b});if(d(n)){let e=n.elements.map(e=>S(e,c));return new i({existsInAllLayers:T,features:w,inputs:e,template:n,expressionsManager:g})}if(f(n))return new a({existsInAllLayers:T,features:w,map:y,template:n,expressionsManager:g,executeFeatureSetDependentExpressions:x});if(p(n))return new o({existsInAllLayers:T,features:w,template:n,expressionsManager:g});if(m(n))return new t({existsInAllLayers:T,features:w,template:n,expressionsManager:g});if(h(n))return new s({existsInAllLayers:T,features:w,template:n,expressionsManager:g,map:y});throw new e(`batch-attribute-form:unsupported-element-template`,`The type of form element template provided is not supported`)}export{g as createBatchFormInputsFromBatchFormTemplate,_ as mergeBatchFormInputsFromNewTemplate};
|