@arcgis/core 5.0.0-next.10 → 5.0.0-next.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/analysis/VolumeMeasurement/volumeMeasurementConfiguration.js +1 -1
  2. package/applications/KnowledgeStudio/resourceSerializationUtils.js +1 -1
  3. package/assets/esri/core/workers/RemoteClient.js +1 -1
  4. package/assets/esri/core/workers/chunks/092d72caf3269e696d1c.js +1 -0
  5. package/assets/esri/core/workers/chunks/{066a0ea67688361e85a5.js → 4291681d067ebdf86e73.js} +1 -1
  6. package/assets/esri/core/workers/chunks/655beaf83e9845a02334.js +1 -0
  7. package/assets/esri/core/workers/chunks/6cf391b5ed7351601a2a.js +1 -0
  8. package/assets/esri/core/workers/chunks/8cd03b54b2859b52fb81.js +1 -0
  9. package/assets/esri/core/workers/chunks/b193de09e005b0976a6a.js +1 -0
  10. package/assets/esri/core/workers/chunks/{4fb5f1c671892001a4fd.js → b6853c6a25eaabc9a7f6.js} +1 -1
  11. package/assets/esri/core/workers/chunks/{8ce608013b353155ee5a.js → f57401a759f420596b2c.js} +1 -1
  12. package/assets/esri/libs/parquet/pkg/bundle_bg.wasm +0 -0
  13. package/assets/esri/rest/knowledgeGraph/wasmInterface/arcgis-knowledge-client-core-simd.wasm +0 -0
  14. package/assets/esri/rest/knowledgeGraph/wasmInterface/arcgis-knowledge-client-core.wasm +0 -0
  15. package/assets/esri/themes/base/widgets/_FeatureTable.scss +2 -0
  16. package/assets/esri/themes/dark/main.css +1 -1
  17. package/assets/esri/themes/light/main.css +1 -1
  18. package/assets/esri/themes/light/view.css +1 -1
  19. package/chunks/arcgis-knowledge-client-core-simd.js +1 -1
  20. package/chunks/arcgis-knowledge-client-core.js +1 -1
  21. package/config.js +1 -1
  22. package/interfaces.d.ts +24 -4
  23. package/kernel.js +1 -1
  24. package/layers/KnowledgeGraphLayer.js +1 -1
  25. package/layers/LinkChartLayer.js +1 -1
  26. package/layers/knowledgeGraph/KnowledgeGraphSublayer.js +1 -1
  27. package/layers/support/fieldFormatUtils.js +1 -1
  28. package/package.json +1 -1
  29. package/support/revision.js +1 -1
  30. package/views/2d/layers/features/processor/FeatureUpdateStrategy.js +1 -1
  31. package/views/2d/layers/features/sources/strategies/chunks/Overrides.js +1 -1
  32. package/views/3d/analysis/Slice/SliceTool.js +1 -1
  33. package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementCutFillComputation.js +1 -1
  34. package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementCutFillController.js +1 -1
  35. package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementCutFillVisualization.js +1 -1
  36. package/views/3d/support/flow/geometryUtils.js +1 -1
  37. package/views/3d/webgl-engine/lib/CutFillDepth.js +1 -1
  38. package/views/draw/support/tooltipUtils.js +1 -1
  39. package/views/interactive/tooltip/components/TooltipEditableField.js +1 -1
  40. package/views/interactive/tooltip/fields/TooltipField.js +1 -1
  41. package/views/interactive/tooltip/infos/TooltipInfoWithCoordinates.js +1 -1
  42. package/views/support/euclideanLengthMeasurementUtils.js +1 -1
  43. package/widgets/TimeSlider.js +1 -1
  44. package/assets/esri/core/workers/chunks/57e04e2d8721bbdc029a.js +0 -1
  45. package/assets/esri/core/workers/chunks/8d9d3797c6d62fdfff9d.js +0 -1
  46. package/assets/esri/core/workers/chunks/9f21436016ff7a899e79.js +0 -1
  47. package/assets/esri/core/workers/chunks/a5a67216e0d0cee95a55.js +0 -1
  48. package/assets/esri/core/workers/chunks/d48af7bc06b4bb176534.js +0 -1
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import{serializationUtilsModuleWrapper as t}from"../applications/KnowledgeStudio/resourceSerializationUtils.js";import a from"../core/Collection.js";import i from"../core/Error.js";import n from"../core/Logger.js";import{getOrCreateMapValue as o}from"../core/MapUtils.js";import{MultiOriginJSONMixin as s}from"../core/MultiOriginJSONSupport.js";import{throwIfAborted as r,isAbortError as l,createAbortError as h}from"../core/promiseUtils.js";import{watch as d,sync as p}from"../core/reactiveUtils.js";import{property as c}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/RandomLCG.js";import{subclass as u}from"../core/accessorSupport/decorators/subclass.js";import{idToName as y}from"../core/accessorSupport/PropertyOrigin.js";import g from"../geometry/Extent.js";import m from"../geometry/Point.js";import f from"../geometry/Polyline.js";import{polygonCentroidPoint as w}from"../geometry/support/centroid.js";import L from"./Layer.js";import{convertFromGeometry as b}from"./graphics/featureConversionUtils.js";import{systemOidFieldName as M,systemOriginIdFieldName as k,systemDestinationIdFieldName as C,systemLayoutGeometryFieldName as T,systemAggregationCountFieldName as N}from"./knowledgeGraph/constants.js";import{IdealEdgeLengthTypeOptions as D}from"./knowledgeGraph/IdealEdgeLengthTypeOptions.js";import{KnowledgeGraphLayerDataManager as x}from"./knowledgeGraph/KnowledgeGraphLayerDataManager.js";import v from"./knowledgeGraph/KnowledgeGraphSublayer.js";import{createCapabilitiesFromKnowledgeGraph as I,initializeLayersFromClientData as E}from"./knowledgeGraph/layerUtils.js";import S from"./knowledgeGraph/SessionMemoryStorage.js";import{convertLayoutTypeToWebSupportedFormat as _,getRelationshipEndNodeIds as A}from"./knowledgeGraph/supportUtils.js";import{BlendLayer as R}from"./mixins/BlendLayer.js";import{OperationalLayer as j}from"./mixins/OperationalLayer.js";import{ScaleRangeLayer as G}from"./mixins/ScaleRangeLayer.js";import{url as z}from"./support/commonProperties.js";import{LCChronologicalLayout as O,LCSimpleLayout as P,LCSmartTreeLayout as F,LCRadialTreeLayout as B,LCHierarchicalLayout as U,LCCommunityLayout as Q,LCForceDirectedLayout as W,load as $}from"../libs/linkchartlayout/LinkChartLayout.js";import{fetchKnowledgeGraph as H}from"../rest/knowledgeGraphService.js";let K=class extends(j(R(G(s(L))))){constructor(e){if(super(e),this.url=null,this.dataPreloadedInLocalCache=!1,this.initializationLinkChartConfig=null,this.membershipModified=!0,this._currentLinkChartConfig={layoutMode:"organic-standard"},this._graphTypeLookup=new Map,this.dataManager=null,this.knowledgeGraph=null,this.layers=new(a.ofType(v)),this.entityLinkChartDiagramLookup=new Map,this.relationshipLinkChartDiagramLookup=new Map,this.linkChartExtent=new g({xmin:-1e-7,ymin:-1e-7,xmax:1e-7,ymax:1e-7}),this.memberEntityTypes=null,this.memberRelationshipTypes=null,this.operationalLayerType="LinkChartLayer",this.sublayerIdsCache=new Map,this.tables=new(a.ofType(v)),this.type="link-chart",this.chronologicalAuxiliaryGraphics=null,this._originalInclusionList=e?.initializationInclusionModeDefinition,e?.dataPreloadedInLocalCache&&!e?.initializationInclusionModeDefinition)throw new i("knowledge-graph:linkchart-layer-constructor","If creating a link chart composite layer and configured that data is already loaded in the cache, you must specify an inclusion list so the Composite Layer knows what records belong to it");this.addHandles(d(()=>this.layers.concat(this.tables),(e,t)=>this._handleSublayersChange(e,t),p))}normalizeCtorArgs(e){if(!e)return{};const{url:t,title:a,dataPreloadedInLocalCache:i,initializationLinkChartConfig:n}=e;return{url:t,title:a,dataPreloadedInLocalCache:i,initializationLinkChartConfig:n}}_initializeLayerProperties(e){if(!this.title&&this.url){const e=this.url.split("/");this.title=e[e.length-2]}const t=new Set;let a=[],o=[];if(e.inclusionModeDefinition&&(!e.inclusionModeDefinition.namedTypeDefinitions||e.inclusionModeDefinition.namedTypeDefinitions.size<1))throw new i("knowledge-graph:composite-layer-constructor","If an explicit inclusion definition is defined, at least one namedTypeDefinition must also be defined");e.inclusionModeDefinition?.generateAllSublayers?(a=e.knowledgeGraph.dataModel.entityTypes??[],o=e.knowledgeGraph.dataModel.relationshipTypes??[]):e.inclusionModeDefinition?.namedTypeDefinitions&&e.inclusionModeDefinition?.namedTypeDefinitions.size>0?e.inclusionModeDefinition?.namedTypeDefinitions.forEach((i,s)=>{const r=this._graphTypeLookup.get(s);if(!r)return n.getLogger(this).warn(`A named type, ${s}, was in the inclusion list that wasn't in the data model and will be removed`),void e.inclusionModeDefinition?.namedTypeDefinitions.delete(s);"relationship"===r.type?t.has(s)||(t.add(s),o.push(r)):"entity"===r.type?t.has(s)||(t.add(s),a.push(r)):(n.getLogger(this).warn(`A named type, ${s}, was in the inclusion list that wasn't properly modeled and will be removed`),e.inclusionModeDefinition?.namedTypeDefinitions.delete(s))}):(a=e.knowledgeGraph.dataModel.entityTypes??[],o=e.knowledgeGraph.dataModel.relationshipTypes??[]);const s=new x({knowledgeGraph:e.knowledgeGraph,inclusionModeDefinition:e.inclusionModeDefinition});this.knowledgeGraph=e.knowledgeGraph,this.memberEntityTypes=a,this.memberRelationshipTypes=o,this.dataManager=s}load(e){const a=async()=>{const e=[],t=[];this.loadLayerAssumingLocalCache(),this._layersLoadedFromAuthoritativeItem()||await E(this),this.dataManager.inclusionModeDefinition&&(this.dataManager.inclusionModeDefinition.generateAllSublayers=!1),this.dataManager.inclusionModeDefinition?.namedTypeDefinitions.forEach(e=>{e.useAllData=!1}),await this._initializeDiagram(),this.layers.forEach(a=>{t.push(a.refreshCachedQueryEngine()),e.push(new Promise(e=>{a.on("layerview-create",()=>{e(null)})}))}),this.tables.forEach(e=>{t.push(e.refreshCachedQueryEngine())}),await Promise.all(t)};return this.addResolvingPromise(new Promise(i=>{H(this.url).then(async n=>{n.dataModel.entityTypes?.forEach(e=>{e.name&&this._graphTypeLookup.set(e.name,e)}),n.dataModel.relationshipTypes?.forEach(e=>{e.name&&this._graphTypeLookup.set(e.name,e)});const s=this.linkChart?.linkChartProperties;if(6===s?.originIdOf("entitiesUrl")&&(this.membershipModified=!1,this._originalInclusionList=await t.fetchAndConvertSerializedLinkChart({entitiesUrl:s?.entitiesUrl,relationshipsUrl:s?.relationshipsUrl}),this._alignLayersDataModelAndInclusionDefinition(n.dataModel),this.initializationLinkChartConfig={layoutSettings:s?.layoutSettings??void 0,layoutMode:_(s.layoutType)}),this._initializeLayerProperties({knowledgeGraph:n,inclusionModeDefinition:this._originalInclusionList}),this.dataManager.inclusionModeDefinition?.namedTypeDefinitions?.size||(this.dataManager.inclusionModeDefinition={generateAllSublayers:!1,namedTypeDefinitions:new Map},this.dataManager.knowledgeGraph.dataModel.entityTypes?.forEach(e=>{e.name&&this.dataManager.inclusionModeDefinition?.namedTypeDefinitions.set(e.name,{useAllData:!0})}),this.dataManager.knowledgeGraph.dataModel.relationshipTypes?.forEach(e=>{e.name&&this.dataManager.inclusionModeDefinition?.namedTypeDefinitions.set(e.name,{useAllData:!0})})),this.dataPreloadedInLocalCache){const e=S.getInstance();for(const[t,a]of this.dataManager.inclusionModeDefinition?.namedTypeDefinitions??[])for(const i of a.members?.values()??[]){const a=e.readFromStoreById(`${t}__${i.id}`);if(a){o(this.dataManager.sublayerCaches,t,()=>new Map).set(i.id,a)}}await a()}else{const t="geographic-organic-standard"===this.initializationLinkChartConfig?.layoutMode;this.addResolvingPromise(this.dataManager.refreshCacheContent(void 0,!1,t,!0).then(async()=>{r(e),await a()}))}i(null)})})),Promise.resolve(this)}set initializationInclusionModeDefinition(e){"loaded"!==this.loadStatus&&"failed"!==this.loadStatus?this._set("initializationInclusionModeDefinition",e):n.getLogger(this).error("#initializationInclusionModeDefinition","initializationInclusionModeDefinition cannot be changed after the layer is loaded.")}get linkChart(){return this.parent}get sublayerCapabilities(){return I(this.knowledgeGraph)}async addRecords(e,t){let a=[];t?.cascadeAddRelationshipEndNodes&&this.dataManager.knowledgeGraph.dataModel&&(a=await A(e,this.dataManager.knowledgeGraph));const i=e.concat(a).filter(e=>!this.sublayerIdsCache.get(e.typeName)?.has(e.id));i.length>0&&(this.membershipModified=!0),await this._handleNewRecords(i,t)}async createSublayerForNamedType(e){await this.load();const t=this._graphTypeLookup.get(e);if(!t)throw new i("knowledge-graph:missing-type","The specified type does not exist in the knowledge graph.");if(this.dataManager.sublayerCaches.has(e))throw new i("knowledge-graph:duplicate-type","The specified type already exists as a sublayer.");this.dataManager.sublayerCaches.set(e,new Map),o(this.sublayerIdsCache,e,()=>new Set);const a=this._createSublayer(t);return"entity"===t.type?this.dataManager.entityTypeNames.add(e):this.dataManager.relationshipTypeNames.add(e),this.dataManager.inclusionModeDefinition?.namedTypeDefinitions?.set(e,{useAllData:!1,members:new Map}),a.geometryType?this.layers.push(a):this.tables.push(a),await E(this,[e]),this._refreshNamedTypes(),a}async removeRecords(e,{cascadeRemoveRelationships:t=!0,recalculateLayout:a=!1,overrideMembershipCheck:i=!1}={cascadeRemoveRelationships:!0,recalculateLayout:!1,overrideMembershipCheck:!1}){let n=[];for(const r of e)(i||!1===this.dataManager.inclusionModeDefinition?.namedTypeDefinitions?.get(r.typeName)?.useAllData&&this.dataManager.inclusionModeDefinition?.namedTypeDefinitions?.get(r.typeName)?.members?.has(r.id))&&n.push(r);if(t){const e=new Set,t=[];for(const a of n)if(this.dataManager.nodeConnectionsLookup.has(a.id))for(const t of this.dataManager.nodeConnectionsLookup.get(a.id))e.add(t);for(const a of e)if(this.dataManager.memberIdTypeLookup.has(a))for(const e of this.dataManager.memberIdTypeLookup.get(a))this.dataManager.relationshipTypeNames.has(e)&&t.push({id:a,typeName:e});n=n.concat(t)}this.dataManager.removeFromLayer(n);for(const r of n)this.sublayerIdsCache.get(r.typeName)?.delete(r.id),this.dataManager.relationshipTypeNames.has(r.typeName)?this.relationshipLinkChartDiagramLookup.delete(r.id):this.entityLinkChartDiagramLookup.delete(r.id);const o=a?void 0:this.getCurrentNodeLocations();await this._calculateLayoutWithSublayerTimeInfo(this._currentLinkChartConfig.layoutMode,{layoutSettings:this._currentLinkChartConfig.layoutSettings,lockedNodeLocations:o}),n.length>0&&(this.membershipModified=!0);const s=[];return this.layers.forEach(e=>{s.push(e.refreshCachedQueryEngine())}),await Promise.all(s),this._refreshNamedTypes(),n}async expand(e,t){let a=[];try{const i=await this.dataManager.getConnectedRecordIds(e,t?.relationshipTypeNames,t);a=i.filter(e=>!this.sublayerIdsCache.get(e.typeName)?.has(e.id)),await this._handleNewRecords(a,t),i.length>0&&(this.membershipModified=!0),r(t?.signal)}catch(i){throw l(i)&&a.length>0&&await this.removeRecords(a,{overrideMembershipCheck:!0}),i}return{records:a}}loadLayerAssumingLocalCache(){const e=[...this.memberRelationshipTypes,...this.memberEntityTypes];this.layers.length||0===this.originIdOf("tables")?0===this.originIdOf("layers")?this._createSublayers(e,this.layers,e=>!!e.geometryType):this._updateSublayers(e,this.layers):this.layers=new a,this.tables.length||0===this.originIdOf("layers")?0===this.originIdOf("tables")?this._createSublayers(e,this.tables,e=>!e.geometryType):this._updateSublayers(e,this.tables):this.tables=new a,this.dataManager.inclusionModeDefinition?.namedTypeDefinitions?.forEach((e,t)=>{const a=o(this.sublayerIdsCache,t,()=>new Set);e.members?.forEach(({id:e,linkChartLocation:i})=>{if(a.add(e),i){const a="coords"in i&&"lengths"in i?i:b(i);this.dataManager.relationshipTypeNames.has(t)?this.relationshipLinkChartDiagramLookup.set(e,a):this.entityLinkChartDiagramLookup.set(e,a)}})})}async calculateLinkChartLayout(e="organic-standard",t){const a=[],s=[],l=[];this.dataManager.sublayerCaches.forEach((e,t)=>{this.dataManager.entityTypeNames.has(t)?e.forEach(e=>{a.push({typeName:t,feature:e})}):this.dataManager.relationshipTypeNames.has(t)&&e.forEach(e=>{s.push({typeName:t,feature:e})})}),this.entityLinkChartDiagramLookup=new Map,this.relationshipLinkChartDiagramLookup=new Map;const d=new Map,p=new Map,c=new Map,u=new Map,y=new Uint8Array(a.length),L=new Float64Array(a.length),D=new Float64Array(a.length),x=new Float64Array(a.length),v=new Float64Array(a.length),I=new Uint32Array(s.length),E=new Uint32Array(s.length),S=new Float64Array(s.length),_=new Float64Array(s.length),A=[],R="organic-standard";let j=!1;const G=new g({xmin:-1e-7,ymin:-1e-7,xmax:1e-7,ymax:1e-7});let z,H="organic-standard",K=0,J=0;const V=O.apply;switch(H="geographic-organic-standard"===e?R:e,H){case"organic-standard":z=W.apply;break;case"organic-community":z=Q.apply;break;case"hierarchical-bottom-to-top":z=U.apply;break;case"radial-root-centric":z=B.apply;break;case"tree-left-to-right":z=F.apply;break;default:z=P.apply}let q=!1;a.forEach(({typeName:a,feature:i})=>{if("chronological-mono-timeline"!==e&&"chronological-multi-timeline"!==e&&t?.lockedNodeLocations?.has(i.attributes[M])){"geographic-organic-standard"===e&&this.dataManager.geographicLookup.has(a)?y[K]=2:y[K]=0;const n=t.lockedNodeLocations.get(i.attributes[M]);L[K]=n.x,D[K]=n.y}else if("geographic-organic-standard"===e&&this.dataManager.geographicLookup.has(a)){y[K]=2;let e=null;const t=i.attributes[this.dataManager.geographicLookup.get(a).name],n=this.dataManager.geographicLookup.get(a)?.geometryType;switch(n){case"esriGeometryPoint":L[K]=t?.x,D[K]=t?.y;break;case"esriGeometryPolygon":{const a=w(t);e=a?m.fromJSON(a):null,null!=e?.x&&null!=e?.y?(L[K]=e.x,D[K]=e.y):y[K]=1;break}case"esriGeometryPolyline":case"esriGeometryMultipoint":e=t?.extent?.center,null!=e?.x&&null!=e?.y?(L[K]=e.x,D[K]=e.y):y[K]=1;break;default:y[K]=1}(null==L[K]||null==D[K]||Number.isNaN(L[K])||Number.isNaN(D[K]))&&(y[K]=1,L[K]=0,D[K]=0)}else if("chronological-mono-timeline"===e||"chronological-multi-timeline"===e){!q&&t?.lockedNodeLocations?.has(i.attributes[M])&&(q=!0);const e=t?.timeInfoByTypeName?.get(a),n=e?.startField,o=n&&e?.startField?i.attributes[n]:null;x[K]=o?new Date(o).getTime():NaN;const s=e?.endField,r=s&&e?.endField?i.attributes[s]:null;v[K]=r?new Date(r).getTime():NaN,L[K]=0,D[K]=0,y[K]=1}else y[K]=1,L[K]=0,D[K]=0;u.set(i.attributes[M],K),A[K]={feature:i,typeName:a},K++}),q&&n.getLogger(this).warn("Locked node locations are not supported for chronological layout at this time. Requested node locations were ignored");let X=!1;const Y=new Map;s.forEach(a=>{const i=a.feature.attributes[k],n=a.feature.attributes[C],o=u.get(i),s=u.get(n),r=t?.timeInfoByTypeName?.get(a.typeName),h=t?.timeInfoByTypeName?r?.startField:null,d=h?a.feature.attributes[h]:null,p=r?.endField,c=p?a.feature.attributes[p]:null;if(void 0!==o&&void 0!==s){let t=i+"-"+n;"chronological-mono-timeline"!==e&&"chronological-multi-timeline"!==e||(t=t+"-"+d+"-"+c);const r=Y.get(t),h=r?.has(a.typeName);h||(I[J]=o,E[J]=s,"chronological-mono-timeline"!==e&&"chronological-multi-timeline"!==e||(S[J]=d?new Date(d).getTime():NaN,_[J]=c?new Date(c).getTime():NaN),void 0===r?Y.set(t,new Map([[a.typeName,J]])):r.set(a.typeName,J),J++),l.push(a)}else X=!0,this.relationshipLinkChartDiagramLookup.set(i,null)}),X&&n.getLogger(this).warn("A relationship is a member of this layer that has either origin or destination entity nodes that are not members. The diagram geometry will be set to null");const Z=this._validateOrganicLayoutSettings(e,t?.layoutSettings?.organicLayoutSettings),ee=this._convertValidatedOrganicSettingsToCalculationSettings(Z);await $();let te=1,ae=null;if("chronological-mono-timeline"===e||"chronological-multi-timeline"===e){let a;({status:te,links:ae,graphics:a}=V(()=>t?.signal?.aborted??!1,y,L,D,x,v,I.subarray(0,J),E.subarray(0,J),S.subarray(0,J),_.subarray(0,J),"chronological-multi-timeline"===e,t?.layoutSettings?.chronologicalLayoutSettings)),0===te&&(this.chronologicalAuxiliaryGraphics=a)}else({status:te,links:ae}=z(()=>t?.signal?.aborted??!1,y,L,D,I.subarray(0,J),E.subarray(0,J),ee.computationBudgetTime,ee.idealEdgeLengthMultiplier,ee.repulsionRadiusMultiplier));if(r(t?.signal),1===te)throw new i("knowledge-graph:layout-failed","Attempting to arrange the records in the specified layout failed");if(2===te)throw h();for(let i=0;i<A.length;i++){if(D[i]>84.9999?D[i]=84.9999:D[i]<-84.9999&&(D[i]=-84.9999),L[i]>179.9999?L[i]=179.9999:L[i]<-179.9999&&(L[i]=-179.9999),A[i].feature.attributes[T]=new m(L[i],D[i]),d.has(A[i].typeName)){const e=d.get(A[i].typeName);e?.set(A[i].feature.attributes[M],A[i].feature)}else{const e=new Map;e.set(A[i].feature.attributes[M],A[i].feature),d.set(A[i].typeName,e)}c.set(A[i].feature.attributes[M],A[i].feature);const e=b(A[i].feature.attributes[T]);this.entityLinkChartDiagramLookup.set(A[i].feature.attributes[M],A[i].feature.attributes[T]?e:null);const t=o(this.dataManager.inclusionModeDefinition.namedTypeDefinitions,A[i].typeName,()=>({useAllData:!1,members:new Map}));o(t.members,A[i].feature.attributes[M],()=>({id:A[i].feature.attributes[M],linkChartLocation:void 0})).linkChartLocation=A[i].feature.attributes[T];const{x:a,y:n}=A[i].feature.attributes[T];if(j)G.xmin=Math.min(G.xmin,a),G.xmax=Math.max(G.xmax,a),G.ymin=Math.min(G.ymin,n),G.ymax=Math.max(G.ymax,n);else{const e=1e-7;G.xmin=a-e,G.xmax=a+e,G.ymin=n-e,G.ymax=n+e,j=!0}}if(this.linkChartExtent.xmin=G.xmin,this.linkChartExtent.xmax=G.xmax,this.linkChartExtent.ymin=G.ymin,this.linkChartExtent.ymax=G.ymax,!ae)throw new i("knowledge-graph:layout-failed","Attempting to retrieve link geometry from diagram engine failed");const ie=new Map,ne=new Map,oe=new Map,se=new Set;for(let i=0;i<l.length;i++){const a=[],s=l[i],r=s.feature.attributes[k],h=s.feature.attributes[C];let d=r+"-"+h;if("chronological-mono-timeline"===e||"chronological-multi-timeline"===e){const e=t?.timeInfoByTypeName?.get(s.typeName),a=t?.timeInfoByTypeName?e?.startField:null,i=a?s.feature.attributes[a]:null,n=e?.endField;d+="-"+i+"-"+(n?s.feature.attributes[n]:null)}const y=Y.get(d).get(s.typeName),g=0===y?0:ae?.vertexEndIndex[y-1];if(!se.has(y)){if(se.add(y),2===ae.types[y]){const e=[ae.vertices[2*g],ae.vertices[2*g+1]],t=[ae.vertices[2*(g+1)],ae.vertices[2*(g+1)+1]],i=[.5*(e[0]+t[0]),.5*(e[1]+t[1])],n=[i[0]-e[0],i[1]-e[1]],o=[i[0]+n[1],i[1]-n[0]],s=[i[0]-n[1],i[1]+n[0]];a.push(e),a.push(o),a.push(t),a.push(s),a.push(e)}else{if(0!==ae.types[y]){n.getLogger(this).warn("A relationship generated an unsupported link geometry type. It will not be rendered");continue}for(let e=g;e<ae.vertexEndIndex[y];e++)a.push([ae.vertices[2*e],ae.vertices[2*e+1]])}if("chronological-mono-timeline"!==e&&"chronological-multi-timeline"!==e){const e=A[u.get(r)]?.feature.attributes[T],t=A[u.get(h)]?.feature.attributes[T];a[0][0]===e.x&&a[0][1]===e.y||(a[0]=[e.x,e.y]),a[a.length-1][0]===t.x&&a[a.length-1][1]===t.y||(a[a.length-1]=[t.x,t.y])}for(let e=1;e<a.length-1;e++)a[e][1]>85.5?a[e][1]=85.5:a[e][1]<-85.5&&(a[e][1]=-85.5),a[e][0]>179.9999?a[e][0]=179.9999:a[e][0]<-179.9999&&(a[e][0]=-179.9999);ie.has(d)?ie.get(d).push(a):ie.set(d,[a])}const m=ie.get(d);ne.has(d)||(ne.set(d,new Map),oe.set(d,new Map));const w=ne.get(d),L=oe.get(d);w.has(s.typeName)||(w.set(s.typeName,m.shift()),L.set(s.typeName,0));const N=w.get(s.typeName);L.set(s.typeName,L.get(s.typeName)+1);const D=new f({paths:[N]});if(s.feature.attributes[T]=D,p.has(s.typeName)){const e=p.get(s.typeName);e?.set(s.feature.attributes[M],s.feature)}else{const e=new Map;e.set(s.feature.attributes[M],s.feature),p.set(s.typeName,e)}c.set(s.feature.attributes[M],s.feature);const x=b(s.feature.attributes[T]);this.relationshipLinkChartDiagramLookup.set(s.feature.attributes[M],s.feature.attributes[T]?x:null);const v=o(this.dataManager.inclusionModeDefinition.namedTypeDefinitions,s.typeName,()=>({useAllData:!1,members:new Map}));o(v.members,s.feature.attributes[M],()=>({id:s.feature.attributes[M],linkChartLocation:void 0})).linkChartLocation=x}for(const i of l)i.feature.attributes[N]=oe.get(i.feature.attributes[k]+"-"+i.feature.attributes[C])?.get(i.typeName)??null;return this._currentLinkChartConfig={layoutMode:e,layoutSettings:t?.layoutSettings?.clone()},{nodes:d,links:p,idMap:c}}async applyNewLinkChartLayout(e="organic-standard",t){const a=[];await this._calculateLayoutWithSublayerTimeInfo(e,t),this.layers.forEach(e=>{a.push(e.refreshCachedQueryEngine())}),this.membershipModified=!0,await Promise.all(a),this._refreshNamedTypes()}getCurrentNodeLocations(){const e=new Map;for(const[t,a]of this.dataManager.inclusionModeDefinition?.namedTypeDefinitions.entries()??[])this.dataManager.relationshipTypeNames.has(t)||a?.members?.forEach(t=>{const a=t.linkChartLocation;let i;const n=t.id;a&&(i="x"in a?{x:a.x,y:a.y}:{x:a.coords[0],y:a.coords[1]},e.set(n,new m({x:i.x,y:i.y})))});return e}async refreshLinkChartCache(e){await this.dataManager.refreshCacheContent(e);const t=[];this.layers.forEach(e=>{t.push(e.refreshCachedQueryEngine())}),await Promise.all(t),this._refreshNamedTypes()}async connectBetweenEntities(e,t){if(!e.length)return{records:[]};let a=[];try{let i=[];for(const e of this.dataManager.relationshipTypeNames){const t=this.sublayerIdsCache.get(e);t&&(i=i.concat(Array.from(t.keys())))}a=await this.dataManager.getRelationshipsBetweenNodes(e,i,t),await this._handleNewRecords(a,t),r(t)}catch(i){throw l(i)&&this.removeRecords(a),i}return{records:a}}async connectFromEntities(e,t){if(!e.length)return{records:[]};let a=[];try{let i=[];for(const e of this.dataManager.relationshipTypeNames){const t=this.sublayerIdsCache.get(e);t&&(i=i.concat(Array.from(t.keys())))}let n=[];for(const e of this.dataManager.entityTypeNames){const t=this.sublayerIdsCache.get(e);t&&(n=n.concat(Array.from(t)))}a=await this.dataManager.getRelationshipsFromNodes(e,n,i,t),await this._handleNewRecords(a,t),a.length>0&&(this.membershipModified=!0),r(t)}catch(i){throw l(i)&&this.removeRecords(a),i}return{records:a}}getCurrentLayout(){return this._currentLinkChartConfig.layoutMode}async _calculateLayoutWithSublayerTimeInfo(e="organic-standard",t){const a=new Map;this.layers.forEach(e=>{a.set(e.objectType.name,e.timeInfo)}),await this.calculateLinkChartLayout(e,{timeInfoByTypeName:a,...t}),this.linkChart?.handleChronologicalOverlay()}async _handleNewRecords(e,t){const a=new Set,i=[],n=this.layers.concat(this.tables);for(const r of e){if(!this._graphTypeLookup.has(r.typeName))continue;!1===n.some(e=>e.objectType.name===r.typeName)&&(this.dataManager.sublayerCaches.set(r.typeName,new Map),a.add(r.typeName));o(this.sublayerIdsCache,r.typeName,()=>new Set).add(r.id),i.push(r)}this.dataManager.addToLayer(i);for(const o of a){const e=this._graphTypeLookup.get(o);if(e){const t=this._createSublayer(e);"entity"===e.type?this.dataManager.entityTypeNames.add(o):this.dataManager.relationshipTypeNames.add(o),t.geometryType?this.layers.push(t):this.tables.push(t)}}await E(this,Array.from(a),t),await this.dataManager.refreshCacheContent(e.map(e=>e.id),void 0,void 0,void 0,t);const s={layoutSettings:this._currentLinkChartConfig.layoutSettings,lockedNodeLocations:new Map};for(const[o,r]of this.entityLinkChartDiagramLookup.entries())r&&s.lockedNodeLocations.set(o,new m(r.coords[0],r.coords[1]));await this.applyNewLinkChartLayout(this._currentLinkChartConfig.layoutMode,s)}_createSublayers(e,t,a){e.forEach(e=>{const i=this._createSublayer(e);a(i)&&t.push(i),this._updateSublayerCaches(e)})}_updateSublayers(e,t){t.forEach(t=>{t.parentCompositeLayer=this;const a=e.find(e=>e.type===t.graphType&&e.name===t.graphTypeName);a&&(t.objectType=a,t.read({title:a.name},{origin:"service"}),this._updateSublayerCaches(a))})}_updateSublayerCaches({name:e}){if(!e)return;const t=this.dataManager.sublayerCaches;t.has(e)||t.set(e,new Map)}_layersLoadedFromAuthoritativeItem(){const e=this.originIdOf("layers");return e>=3&&e<7}async _initializeDiagram(){this.initializationLinkChartConfig?this.initializationLinkChartConfig.doNotRecalculateLayout?(this.dataManager.inclusionModeDefinition?.namedTypeDefinitions?.forEach((e,t)=>{e?.members?.forEach(e=>{const a=e.linkChartLocation;let i;const n=e.id;if(!a)return;i="x"in a?{x:a.x,y:a.y}:{x:a.coords[0],y:a.coords[1]};const o=b(i);this.dataManager.relationshipTypeNames.has(t)?this.relationshipLinkChartDiagramLookup.set(n,o):this.entityLinkChartDiagramLookup.set(n,o),this.linkChartExtent.xmin>i.x&&(this.linkChartExtent.xmin=i.x),this.linkChartExtent.xmax<i.x&&(this.linkChartExtent.xmax=i.x),this.linkChartExtent.ymin>i.y&&(this.linkChartExtent.ymin=i.y),this.linkChartExtent.ymax<i.y&&(this.linkChartExtent.ymax=i.y)})}),this.memberRelationshipTypes.forEach(e=>{e.name&&this.dataManager.sublayerCaches.get(e.name)?.forEach(e=>{const t=this.relationshipLinkChartDiagramLookup.get(e.attributes[k]),a=this.relationshipLinkChartDiagramLookup.get(e.attributes[C]);if(t&&a){const i=b(new f({paths:[[[t.coords[0],t.coords[1]],[a.coords[0],a.coords[1]]]]}));this.relationshipLinkChartDiagramLookup.set(e.attributes[M],i)}else this.relationshipLinkChartDiagramLookup.set(e.attributes[M],null)})})):await this._calculateLayoutWithSublayerTimeInfo(this.initializationLinkChartConfig.layoutMode,{lockedNodeLocations:this.getCurrentNodeLocations(),...this.initializationLinkChartConfig}):await this._calculateLayoutWithSublayerTimeInfo("organic-standard",{lockedNodeLocations:this.getCurrentNodeLocations()})}_refreshNamedTypes(){for(const e of this.layers)e.emit("refresh",{dataChanged:!0});for(const e of this.tables)e.emit("refresh",{dataChanged:!0})}_validateOrganicLayoutSettings(e,t){const a=e=>"number"==typeof e&&!isNaN(e),i=e=>a(e)&&e>=1,o=e=>a(e)&&e>=1,s=e=>Object.values(D).includes(e),r=e=>a(e)&&e>=0,l={};if(!new Set(["organic-standard","organic-community","geographic-organic-standard","chronological-multi-timeline","chronological-mono-timeline"]).has(e)||!t)return l;const{computationBudgetTime:h,autoRepulsionRadius:d,repulsionRadiusMultiplier:p,absoluteIdealEdgeLength:c,multiplicativeIdealEdgeLength:u,idealEdgeLengthType:y}=t;return o(h)?l.computationBudgetTime=h:h&&n.getLogger(this).warn("Invalid layout computationBudgetTime setting, will revert to default setting"),l.autoRepulsionRadius=d,!d&&i(p)?l.repulsionRadiusMultiplier=p:d||(l.autoRepulsionRadius=!0,n.getLogger(this).warn("Invalid layout repulsionRadiusMultiplier setting, will revert to default setting")),"geographic-organic-standard"===e&&(s(y)?l.idealEdgeLengthType=y:void 0!==y&&n.getLogger(this).warn('Invalid layout idealEdgeLengthType setting, will revert to "multiplier" setting'),"absolute-value"===y&&r(c)?l.absoluteIdealEdgeLength=c:"absolute-value"===y&&void 0!==c?n.getLogger(this).warn("Invalid layout idealEdgeLength setting, will revert to default setting"):"multiplier"===y&&r(u)?l.multiplicativeIdealEdgeLength=u:"multiplier"===y&&void 0!==u&&n.getLogger(this).warn("Invalid layout idealEdgeLength setting, will revert to default setting")),l}_convertValidatedOrganicSettingsToCalculationSettings(e){let t=e.idealEdgeLengthType===D.ABSOLUTE?e.absoluteIdealEdgeLength:e.multiplicativeIdealEdgeLength;return e.idealEdgeLengthType===D.ABSOLUTE&&(void 0===t?t=-1:t*=-1),{computationBudgetTime:e.computationBudgetTime??void 0,repulsionRadiusMultiplier:e.repulsionRadiusMultiplier&&!e.autoRepulsionRadius?e.repulsionRadiusMultiplier:void 0,idealEdgeLengthMultiplier:t}}_createSublayer(e){return new v({objectType:e,parentCompositeLayer:this,graphType:e.type})}_handleSublayersChange(e,t){t&&(t.forEach(e=>{e.parent=null}),this.removeHandles("sublayers-owner")),e&&(e.forEach(e=>{e.parent=this}),this.addHandles([e.on("after-add",({item:e})=>{e.parent=this}),e.on("after-remove",({item:e})=>{e.parent=null})],"sublayers-owner"))}_alignLayersDataModelAndInclusionDefinition(e){const t=new Set((e.entityTypes??[]).map(e=>e.name).concat((e.relationshipTypes??[]).map(e=>e.name))),i=new Set((e.entityTypes??[]).map(e=>e.name)),o=new Set((e.relationshipTypes??[]).map(e=>e.name));if(this.layers){for(const a of this.layers)!a.graphType&&t.has(a.graphTypeName)&&(a.graphType=i.has(a.graphTypeName)?"entity":"relationship");const e=this.layers.filter(e=>t.has(e.graphTypeName)&&("entity"===e.graphType?i.has(e.graphTypeName):o.has(e.graphTypeName)));this.setAtOrigin("layers",e,y(this.originIdOf("layers")))}else this.layers=new a;if(this.layers&&this._originalInclusionList){const e=new Set(this._originalInclusionList.namedTypeDefinitions.keys()),t=this.tables?.map(e=>e.graphTypeName)??[],a=this.layers.map(e=>e.graphTypeName).concat(t);for(const n of a)e.has(n)||this._originalInclusionList.namedTypeDefinitions.set(n,{useAllData:!1,members:new Map});const i=[];for(const o of this._originalInclusionList.namedTypeDefinitions.keys())a.includes(o)||(n.getLogger(this).warn(`A named type, ${o}, was in the serialized feature collection but did not have a sublayer config in the item, so will be removed`),i.push(o));for(const n of i)this._originalInclusionList.namedTypeDefinitions.delete(n)}}};e([c(z)],K.prototype,"url",void 0),e([c()],K.prototype,"dataPreloadedInLocalCache",void 0),e([c()],K.prototype,"initializationLinkChartConfig",void 0),e([c()],K.prototype,"membershipModified",void 0),e([c()],K.prototype,"dataManager",void 0),e([c()],K.prototype,"initializationInclusionModeDefinition",null),e([c()],K.prototype,"knowledgeGraph",void 0),e([c({type:a.ofType(v),json:{write:{ignoreOrigin:!0}}})],K.prototype,"layers",void 0),e([c({readOnly:!0})],K.prototype,"linkChart",null),e([c()],K.prototype,"entityLinkChartDiagramLookup",void 0),e([c()],K.prototype,"relationshipLinkChartDiagramLookup",void 0),e([c()],K.prototype,"linkChartExtent",void 0),e([c()],K.prototype,"memberEntityTypes",void 0),e([c()],K.prototype,"memberRelationshipTypes",void 0),e([c({type:["LinkChartLayer"]})],K.prototype,"operationalLayerType",void 0),e([c()],K.prototype,"sublayerCapabilities",null),e([c()],K.prototype,"sublayerIdsCache",void 0),e([c({type:a.ofType(v),json:{write:{ignoreOrigin:!0}}})],K.prototype,"tables",void 0),e([c({json:{read:!1}})],K.prototype,"type",void 0),e([c({json:{read:!1}})],K.prototype,"chronologicalAuxiliaryGraphics",void 0),K=e([u("esri.layers.LinkChartLayer")],K);const J=K;export{J as default};
5
+ import{__decorate as e}from"tslib";import{serializationUtilsModuleWrapper as t}from"../applications/KnowledgeStudio/resourceSerializationUtils.js";import a from"../core/Collection.js";import i from"../core/Error.js";import n from"../core/Logger.js";import{getOrCreateMapValue as o}from"../core/MapUtils.js";import{MultiOriginJSONMixin as s}from"../core/MultiOriginJSONSupport.js";import{throwIfAborted as r,isAbortError as l,createAbortError as h}from"../core/promiseUtils.js";import{watch as d,sync as p}from"../core/reactiveUtils.js";import{property as c}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/RandomLCG.js";import{subclass as u}from"../core/accessorSupport/decorators/subclass.js";import{idToName as y}from"../core/accessorSupport/PropertyOrigin.js";import g from"../geometry/Extent.js";import m from"../geometry/Point.js";import f from"../geometry/Polyline.js";import{polygonCentroidPoint as w}from"../geometry/support/centroid.js";import L from"./Layer.js";import{convertFromGeometry as b}from"./graphics/featureConversionUtils.js";import{systemOidFieldName as M,systemOriginIdFieldName as k,systemDestinationIdFieldName as C,systemLayoutGeometryFieldName as T,systemAggregationCountFieldName as N}from"./knowledgeGraph/constants.js";import{IdealEdgeLengthTypeOptions as D}from"./knowledgeGraph/IdealEdgeLengthTypeOptions.js";import{KnowledgeGraphLayerDataManager as x}from"./knowledgeGraph/KnowledgeGraphLayerDataManager.js";import v from"./knowledgeGraph/KnowledgeGraphSublayer.js";import{createCapabilitiesFromKnowledgeGraph as I,initializeLayersFromClientData as E}from"./knowledgeGraph/layerUtils.js";import S from"./knowledgeGraph/SessionMemoryStorage.js";import{convertLayoutTypeToWebSupportedFormat as _,getRelationshipEndNodeIds as A}from"./knowledgeGraph/supportUtils.js";import{BlendLayer as R}from"./mixins/BlendLayer.js";import{OperationalLayer as j}from"./mixins/OperationalLayer.js";import{ScaleRangeLayer as G}from"./mixins/ScaleRangeLayer.js";import{url as z}from"./support/commonProperties.js";import{LCChronologicalLayout as O,LCSimpleLayout as P,LCSmartTreeLayout as F,LCRadialTreeLayout as B,LCHierarchicalLayout as U,LCCommunityLayout as Q,LCForceDirectedLayout as W,load as $}from"../libs/linkchartlayout/LinkChartLayout.js";import{fetchKnowledgeGraph as H}from"../rest/knowledgeGraphService.js";let K=class extends(j(R(G(s(L))))){constructor(e){if(super(e),this.url=null,this.dataPreloadedInLocalCache=!1,this.initializationLinkChartConfig=null,this.membershipModified=!0,this._currentLinkChartConfig={layoutMode:"organic-standard"},this._graphTypeLookup=new Map,this.dataManager=null,this.knowledgeGraph=null,this.layers=new(a.ofType(v)),this.entityLinkChartDiagramLookup=new Map,this.relationshipLinkChartDiagramLookup=new Map,this.linkChartExtent=new g({xmin:-1e-7,ymin:-1e-7,xmax:1e-7,ymax:1e-7}),this.memberEntityTypes=null,this.memberRelationshipTypes=null,this.operationalLayerType="LinkChartLayer",this.sublayerIdsCache=new Map,this.tables=new(a.ofType(v)),this.type="link-chart",this.chronologicalAuxiliaryGraphics=null,this._originalInclusionList=e?.initializationInclusionModeDefinition,e?.dataPreloadedInLocalCache&&!e?.initializationInclusionModeDefinition)throw new i("knowledge-graph:linkchart-layer-constructor","If creating a link chart composite layer and configured that data is already loaded in the cache, you must specify an inclusion list so the Composite Layer knows what records belong to it");this.addHandles(d(()=>this.layers.concat(this.tables),(e,t)=>this._handleSublayersChange(e,t),p))}normalizeCtorArgs(e){if(!e)return{};const{url:t,title:a,dataPreloadedInLocalCache:i,initializationLinkChartConfig:n}=e;return{url:t,title:a,dataPreloadedInLocalCache:i,initializationLinkChartConfig:n}}_initializeLayerProperties(e){if(!this.title&&this.url){const e=this.url.split("/");this.title=e[e.length-2]}const t=new Set;let a=[],o=[];if(e.inclusionModeDefinition&&(!e.inclusionModeDefinition.namedTypeDefinitions||e.inclusionModeDefinition.namedTypeDefinitions.size<1))throw new i("knowledge-graph:composite-layer-constructor","If an explicit inclusion definition is defined, at least one namedTypeDefinition must also be defined");e.inclusionModeDefinition?.generateAllSublayers?(a=e.knowledgeGraph.dataModel.entityTypes??[],o=e.knowledgeGraph.dataModel.relationshipTypes??[]):e.inclusionModeDefinition?.namedTypeDefinitions&&e.inclusionModeDefinition?.namedTypeDefinitions.size>0?e.inclusionModeDefinition?.namedTypeDefinitions.forEach((i,s)=>{const r=this._graphTypeLookup.get(s);if(!r)return n.getLogger(this).warn(`A named type, ${s}, was in the inclusion list that wasn't in the data model and will be removed`),void e.inclusionModeDefinition?.namedTypeDefinitions.delete(s);"relationship"===r.type?t.has(s)||(t.add(s),o.push(r)):"entity"===r.type?t.has(s)||(t.add(s),a.push(r)):(n.getLogger(this).warn(`A named type, ${s}, was in the inclusion list that wasn't properly modeled and will be removed`),e.inclusionModeDefinition?.namedTypeDefinitions.delete(s))}):(a=e.knowledgeGraph.dataModel.entityTypes??[],o=e.knowledgeGraph.dataModel.relationshipTypes??[]);const s=new x({knowledgeGraph:e.knowledgeGraph,inclusionModeDefinition:e.inclusionModeDefinition});this.knowledgeGraph=e.knowledgeGraph,this.memberEntityTypes=a,this.memberRelationshipTypes=o,this.dataManager=s}load(e){const a=async()=>{const e=[],t=[];this.loadLayerAssumingLocalCache(),this._layersLoadedFromAuthoritativeItem()||await E(this),this.dataManager.inclusionModeDefinition&&(this.dataManager.inclusionModeDefinition.generateAllSublayers=!1),this.dataManager.inclusionModeDefinition?.namedTypeDefinitions.forEach(e=>{e.useAllData=!1}),await this._initializeDiagram(),this.layers.forEach(a=>{t.push(a.refreshCachedQueryEngine()),e.push(new Promise(e=>{a.on("layerview-create",()=>{e(null)})}))}),this.tables.forEach(e=>{t.push(e.refreshCachedQueryEngine())}),await Promise.all(t)};return this.addResolvingPromise(new Promise(i=>{H(this.url).then(async n=>{n.dataModel.entityTypes?.forEach(e=>{e.name&&this._graphTypeLookup.set(e.name,e)}),n.dataModel.relationshipTypes?.forEach(e=>{e.name&&this._graphTypeLookup.set(e.name,e)});const s=this.linkChart?.linkChartProperties;if(6===s?.originIdOf("entitiesUrl")&&(this.membershipModified=!1,this._originalInclusionList=await t.fetchAndConvertSerializedLinkChart({entitiesUrl:s?.entitiesUrl,relationshipsUrl:s?.relationshipsUrl},{signal:e?.signal}),this._alignLayersDataModelAndInclusionDefinition(n.dataModel),this.initializationLinkChartConfig={layoutSettings:s?.layoutSettings??void 0,layoutMode:_(s.layoutType)}),this._initializeLayerProperties({knowledgeGraph:n,inclusionModeDefinition:this._originalInclusionList}),this.dataManager.inclusionModeDefinition?.namedTypeDefinitions?.size||(this.dataManager.inclusionModeDefinition={generateAllSublayers:!1,namedTypeDefinitions:new Map},this.dataManager.knowledgeGraph.dataModel.entityTypes?.forEach(e=>{e.name&&this.dataManager.inclusionModeDefinition?.namedTypeDefinitions.set(e.name,{useAllData:!0})}),this.dataManager.knowledgeGraph.dataModel.relationshipTypes?.forEach(e=>{e.name&&this.dataManager.inclusionModeDefinition?.namedTypeDefinitions.set(e.name,{useAllData:!0})})),this.dataPreloadedInLocalCache){const e=S.getInstance();for(const[t,a]of this.dataManager.inclusionModeDefinition?.namedTypeDefinitions??[])for(const i of a.members?.values()??[]){const a=e.readFromStoreById(`${t}__${i.id}`);if(a){o(this.dataManager.sublayerCaches,t,()=>new Map).set(i.id,a)}}await a()}else{const t="geographic-organic-standard"===this.initializationLinkChartConfig?.layoutMode;this.addResolvingPromise(this.dataManager.refreshCacheContent(void 0,!1,t,!0).then(async()=>{r(e),await a()}))}i(null)})})),Promise.resolve(this)}set initializationInclusionModeDefinition(e){"loaded"!==this.loadStatus&&"failed"!==this.loadStatus?this._set("initializationInclusionModeDefinition",e):n.getLogger(this).error("#initializationInclusionModeDefinition","initializationInclusionModeDefinition cannot be changed after the layer is loaded.")}get linkChart(){return this.parent}get sublayerCapabilities(){return I(this.knowledgeGraph)}async addRecords(e,t){let a=[];t?.cascadeAddRelationshipEndNodes&&this.dataManager.knowledgeGraph.dataModel&&(a=await A(e,this.dataManager.knowledgeGraph));const i=e.concat(a).filter(e=>!this.sublayerIdsCache.get(e.typeName)?.has(e.id));i.length>0&&(this.membershipModified=!0),await this._handleNewRecords(i,t)}async createSublayerForNamedType(e){await this.load();const t=this._graphTypeLookup.get(e);if(!t)throw new i("knowledge-graph:missing-type","The specified type does not exist in the knowledge graph.");if(this.dataManager.sublayerCaches.has(e))throw new i("knowledge-graph:duplicate-type","The specified type already exists as a sublayer.");this.dataManager.sublayerCaches.set(e,new Map),o(this.sublayerIdsCache,e,()=>new Set);const a=this._createSublayer(t);return"entity"===t.type?this.dataManager.entityTypeNames.add(e):this.dataManager.relationshipTypeNames.add(e),this.dataManager.inclusionModeDefinition?.namedTypeDefinitions?.set(e,{useAllData:!1,members:new Map}),a.geometryType?this.layers.push(a):this.tables.push(a),await E(this,[e]),this._refreshNamedTypes(),a}async removeRecords(e,{cascadeRemoveRelationships:t=!0,recalculateLayout:a=!1,overrideMembershipCheck:i=!1}={cascadeRemoveRelationships:!0,recalculateLayout:!1,overrideMembershipCheck:!1}){let n=[];for(const r of e)(i||!1===this.dataManager.inclusionModeDefinition?.namedTypeDefinitions?.get(r.typeName)?.useAllData&&this.dataManager.inclusionModeDefinition?.namedTypeDefinitions?.get(r.typeName)?.members?.has(r.id))&&n.push(r);if(t){const e=new Set,t=[];for(const a of n)if(this.dataManager.nodeConnectionsLookup.has(a.id))for(const t of this.dataManager.nodeConnectionsLookup.get(a.id))e.add(t);for(const a of e)if(this.dataManager.memberIdTypeLookup.has(a))for(const e of this.dataManager.memberIdTypeLookup.get(a))this.dataManager.relationshipTypeNames.has(e)&&t.push({id:a,typeName:e});n=n.concat(t)}this.dataManager.removeFromLayer(n);for(const r of n)this.sublayerIdsCache.get(r.typeName)?.delete(r.id),this.dataManager.relationshipTypeNames.has(r.typeName)?this.relationshipLinkChartDiagramLookup.delete(r.id):this.entityLinkChartDiagramLookup.delete(r.id);const o=a?void 0:this.getCurrentNodeLocations();await this._calculateLayoutWithSublayerTimeInfo(this._currentLinkChartConfig.layoutMode,{layoutSettings:this._currentLinkChartConfig.layoutSettings,lockedNodeLocations:o}),n.length>0&&(this.membershipModified=!0);const s=[];return this.layers.forEach(e=>{s.push(e.refreshCachedQueryEngine())}),await Promise.all(s),this._refreshNamedTypes(),n}async expand(e,t){let a=[];try{const i=await this.dataManager.getConnectedRecordIds(e,t?.relationshipTypeNames,t);a=i.filter(e=>!this.sublayerIdsCache.get(e.typeName)?.has(e.id)),await this._handleNewRecords(a,t),i.length>0&&(this.membershipModified=!0),r(t?.signal)}catch(i){throw l(i)&&a.length>0&&await this.removeRecords(a,{overrideMembershipCheck:!0}),i}return{records:a}}loadLayerAssumingLocalCache(){const e=[...this.memberRelationshipTypes,...this.memberEntityTypes];this.layers.length||0===this.originIdOf("tables")?0===this.originIdOf("layers")?this._createSublayers(e,this.layers,e=>!!e.geometryType):this._updateSublayers(e,this.layers):this.layers=new a,this.tables.length||0===this.originIdOf("layers")?0===this.originIdOf("tables")?this._createSublayers(e,this.tables,e=>!e.geometryType):this._updateSublayers(e,this.tables):this.tables=new a,this.dataManager.inclusionModeDefinition?.namedTypeDefinitions?.forEach((e,t)=>{const a=o(this.sublayerIdsCache,t,()=>new Set);e.members?.forEach(({id:e,linkChartLocation:i})=>{if(a.add(e),i){const a="coords"in i&&"lengths"in i?i:b(i);this.dataManager.relationshipTypeNames.has(t)?this.relationshipLinkChartDiagramLookup.set(e,a):this.entityLinkChartDiagramLookup.set(e,a)}})})}async calculateLinkChartLayout(e="organic-standard",t){const a=[],s=[],l=[];this.dataManager.sublayerCaches.forEach((e,t)=>{this.dataManager.entityTypeNames.has(t)?e.forEach(e=>{a.push({typeName:t,feature:e})}):this.dataManager.relationshipTypeNames.has(t)&&e.forEach(e=>{s.push({typeName:t,feature:e})})}),this.entityLinkChartDiagramLookup=new Map,this.relationshipLinkChartDiagramLookup=new Map;const d=new Map,p=new Map,c=new Map,u=new Map,y=new Uint8Array(a.length),L=new Float64Array(a.length),D=new Float64Array(a.length),x=new Float64Array(a.length),v=new Float64Array(a.length),I=new Uint32Array(s.length),E=new Uint32Array(s.length),S=new Float64Array(s.length),_=new Float64Array(s.length),A=[],R="organic-standard";let j=!1;const G=new g({xmin:-1e-7,ymin:-1e-7,xmax:1e-7,ymax:1e-7});let z,H="organic-standard",K=0,J=0;const V=O.apply;switch(H="geographic-organic-standard"===e?R:e,H){case"organic-standard":z=W.apply;break;case"organic-community":z=Q.apply;break;case"hierarchical-bottom-to-top":z=U.apply;break;case"radial-root-centric":z=B.apply;break;case"tree-left-to-right":z=F.apply;break;default:z=P.apply}let q=!1;a.forEach(({typeName:a,feature:i})=>{if("chronological-mono-timeline"!==e&&"chronological-multi-timeline"!==e&&t?.lockedNodeLocations?.has(i.attributes[M])){"geographic-organic-standard"===e&&this.dataManager.geographicLookup.has(a)?y[K]=2:y[K]=0;const n=t.lockedNodeLocations.get(i.attributes[M]);L[K]=n.x,D[K]=n.y}else if("geographic-organic-standard"===e&&this.dataManager.geographicLookup.has(a)){y[K]=2;let e=null;const t=i.attributes[this.dataManager.geographicLookup.get(a).name],n=this.dataManager.geographicLookup.get(a)?.geometryType;switch(n){case"esriGeometryPoint":L[K]=t?.x,D[K]=t?.y;break;case"esriGeometryPolygon":{const a=w(t);e=a?m.fromJSON(a):null,null!=e?.x&&null!=e?.y?(L[K]=e.x,D[K]=e.y):y[K]=1;break}case"esriGeometryPolyline":case"esriGeometryMultipoint":e=t?.extent?.center,null!=e?.x&&null!=e?.y?(L[K]=e.x,D[K]=e.y):y[K]=1;break;default:y[K]=1}(null==L[K]||null==D[K]||Number.isNaN(L[K])||Number.isNaN(D[K]))&&(y[K]=1,L[K]=0,D[K]=0)}else if("chronological-mono-timeline"===e||"chronological-multi-timeline"===e){!q&&t?.lockedNodeLocations?.has(i.attributes[M])&&(q=!0);const e=t?.timeInfoByTypeName?.get(a),n=e?.startField,o=n&&e?.startField?i.attributes[n]:null;x[K]=o?new Date(o).getTime():NaN;const s=e?.endField,r=s&&e?.endField?i.attributes[s]:null;v[K]=r?new Date(r).getTime():NaN,L[K]=0,D[K]=0,y[K]=1}else y[K]=1,L[K]=0,D[K]=0;u.set(i.attributes[M],K),A[K]={feature:i,typeName:a},K++}),q&&n.getLogger(this).warn("Locked node locations are not supported for chronological layout at this time. Requested node locations were ignored");let X=!1;const Y=new Map;s.forEach(a=>{const i=a.feature.attributes[k],n=a.feature.attributes[C],o=u.get(i),s=u.get(n),r=t?.timeInfoByTypeName?.get(a.typeName),h=t?.timeInfoByTypeName?r?.startField:null,d=h?a.feature.attributes[h]:null,p=r?.endField,c=p?a.feature.attributes[p]:null;if(void 0!==o&&void 0!==s){let t=i+"-"+n;"chronological-mono-timeline"!==e&&"chronological-multi-timeline"!==e||(t=t+"-"+d+"-"+c);const r=Y.get(t),h=r?.has(a.typeName);h||(I[J]=o,E[J]=s,"chronological-mono-timeline"!==e&&"chronological-multi-timeline"!==e||(S[J]=d?new Date(d).getTime():NaN,_[J]=c?new Date(c).getTime():NaN),void 0===r?Y.set(t,new Map([[a.typeName,J]])):r.set(a.typeName,J),J++),l.push(a)}else X=!0,this.relationshipLinkChartDiagramLookup.set(i,null)}),X&&n.getLogger(this).warn("A relationship is a member of this layer that has either origin or destination entity nodes that are not members. The diagram geometry will be set to null");const Z=this._validateOrganicLayoutSettings(e,t?.layoutSettings?.organicLayoutSettings),ee=this._convertValidatedOrganicSettingsToCalculationSettings(Z);await $();let te=1,ae=null;if("chronological-mono-timeline"===e||"chronological-multi-timeline"===e){let a;({status:te,links:ae,graphics:a}=V(()=>t?.signal?.aborted??!1,y,L,D,x,v,I.subarray(0,J),E.subarray(0,J),S.subarray(0,J),_.subarray(0,J),"chronological-multi-timeline"===e,t?.layoutSettings?.chronologicalLayoutSettings)),0===te&&(this.chronologicalAuxiliaryGraphics=a)}else({status:te,links:ae}=z(()=>t?.signal?.aborted??!1,y,L,D,I.subarray(0,J),E.subarray(0,J),ee.computationBudgetTime,ee.idealEdgeLengthMultiplier,ee.repulsionRadiusMultiplier));if(r(t?.signal),1===te)throw new i("knowledge-graph:layout-failed","Attempting to arrange the records in the specified layout failed");if(2===te)throw h();for(let i=0;i<A.length;i++){if(D[i]>84.9999?D[i]=84.9999:D[i]<-84.9999&&(D[i]=-84.9999),L[i]>179.9999?L[i]=179.9999:L[i]<-179.9999&&(L[i]=-179.9999),A[i].feature.attributes[T]=new m(L[i],D[i]),d.has(A[i].typeName)){const e=d.get(A[i].typeName);e?.set(A[i].feature.attributes[M],A[i].feature)}else{const e=new Map;e.set(A[i].feature.attributes[M],A[i].feature),d.set(A[i].typeName,e)}c.set(A[i].feature.attributes[M],A[i].feature);const e=b(A[i].feature.attributes[T]);this.entityLinkChartDiagramLookup.set(A[i].feature.attributes[M],A[i].feature.attributes[T]?e:null);const t=o(this.dataManager.inclusionModeDefinition.namedTypeDefinitions,A[i].typeName,()=>({useAllData:!1,members:new Map}));o(t.members,A[i].feature.attributes[M],()=>({id:A[i].feature.attributes[M],linkChartLocation:void 0})).linkChartLocation=A[i].feature.attributes[T];const{x:a,y:n}=A[i].feature.attributes[T];if(j)G.xmin=Math.min(G.xmin,a),G.xmax=Math.max(G.xmax,a),G.ymin=Math.min(G.ymin,n),G.ymax=Math.max(G.ymax,n);else{const e=1e-7;G.xmin=a-e,G.xmax=a+e,G.ymin=n-e,G.ymax=n+e,j=!0}}if(this.linkChartExtent.xmin=G.xmin,this.linkChartExtent.xmax=G.xmax,this.linkChartExtent.ymin=G.ymin,this.linkChartExtent.ymax=G.ymax,!ae)throw new i("knowledge-graph:layout-failed","Attempting to retrieve link geometry from diagram engine failed");const ie=new Map,ne=new Map,oe=new Map,se=new Set;for(let i=0;i<l.length;i++){const a=[],s=l[i],r=s.feature.attributes[k],h=s.feature.attributes[C];let d=r+"-"+h;if("chronological-mono-timeline"===e||"chronological-multi-timeline"===e){const e=t?.timeInfoByTypeName?.get(s.typeName),a=t?.timeInfoByTypeName?e?.startField:null,i=a?s.feature.attributes[a]:null,n=e?.endField;d+="-"+i+"-"+(n?s.feature.attributes[n]:null)}const y=Y.get(d).get(s.typeName),g=0===y?0:ae?.vertexEndIndex[y-1];if(!se.has(y)){if(se.add(y),2===ae.types[y]){const e=[ae.vertices[2*g],ae.vertices[2*g+1]],t=[ae.vertices[2*(g+1)],ae.vertices[2*(g+1)+1]],i=[.5*(e[0]+t[0]),.5*(e[1]+t[1])],n=[i[0]-e[0],i[1]-e[1]],o=[i[0]+n[1],i[1]-n[0]],s=[i[0]-n[1],i[1]+n[0]];a.push(e),a.push(o),a.push(t),a.push(s),a.push(e)}else{if(0!==ae.types[y]){n.getLogger(this).warn("A relationship generated an unsupported link geometry type. It will not be rendered");continue}for(let e=g;e<ae.vertexEndIndex[y];e++)a.push([ae.vertices[2*e],ae.vertices[2*e+1]])}if("chronological-mono-timeline"!==e&&"chronological-multi-timeline"!==e){const e=A[u.get(r)]?.feature.attributes[T],t=A[u.get(h)]?.feature.attributes[T];a[0][0]===e.x&&a[0][1]===e.y||(a[0]=[e.x,e.y]),a[a.length-1][0]===t.x&&a[a.length-1][1]===t.y||(a[a.length-1]=[t.x,t.y])}for(let e=1;e<a.length-1;e++)a[e][1]>85.5?a[e][1]=85.5:a[e][1]<-85.5&&(a[e][1]=-85.5),a[e][0]>179.9999?a[e][0]=179.9999:a[e][0]<-179.9999&&(a[e][0]=-179.9999);ie.has(d)?ie.get(d).push(a):ie.set(d,[a])}const m=ie.get(d);ne.has(d)||(ne.set(d,new Map),oe.set(d,new Map));const w=ne.get(d),L=oe.get(d);w.has(s.typeName)||(w.set(s.typeName,m.shift()),L.set(s.typeName,0));const N=w.get(s.typeName);L.set(s.typeName,L.get(s.typeName)+1);const D=new f({paths:[N]});if(s.feature.attributes[T]=D,p.has(s.typeName)){const e=p.get(s.typeName);e?.set(s.feature.attributes[M],s.feature)}else{const e=new Map;e.set(s.feature.attributes[M],s.feature),p.set(s.typeName,e)}c.set(s.feature.attributes[M],s.feature);const x=b(s.feature.attributes[T]);this.relationshipLinkChartDiagramLookup.set(s.feature.attributes[M],s.feature.attributes[T]?x:null);const v=o(this.dataManager.inclusionModeDefinition.namedTypeDefinitions,s.typeName,()=>({useAllData:!1,members:new Map}));o(v.members,s.feature.attributes[M],()=>({id:s.feature.attributes[M],linkChartLocation:void 0})).linkChartLocation=x}for(const i of l)i.feature.attributes[N]=oe.get(i.feature.attributes[k]+"-"+i.feature.attributes[C])?.get(i.typeName)??null;return this._currentLinkChartConfig={layoutMode:e,layoutSettings:t?.layoutSettings?.clone()},{nodes:d,links:p,idMap:c}}async applyNewLinkChartLayout(e="organic-standard",t){const a=[];await this._calculateLayoutWithSublayerTimeInfo(e,t),this.layers.forEach(e=>{a.push(e.refreshCachedQueryEngine())}),this.membershipModified=!0,await Promise.all(a),this._refreshNamedTypes()}getCurrentNodeLocations(){const e=new Map;for(const[t,a]of this.dataManager.inclusionModeDefinition?.namedTypeDefinitions.entries()??[])this.dataManager.relationshipTypeNames.has(t)||a?.members?.forEach(t=>{const a=t.linkChartLocation;let i;const n=t.id;a&&(i="x"in a?{x:a.x,y:a.y}:{x:a.coords[0],y:a.coords[1]},e.set(n,new m({x:i.x,y:i.y})))});return e}async refreshLinkChartCache(e){await this.dataManager.refreshCacheContent(e);const t=[];this.layers.forEach(e=>{t.push(e.refreshCachedQueryEngine())}),await Promise.all(t),this._refreshNamedTypes()}async connectBetweenEntities(e,t){if(!e.length)return{records:[]};let a=[];try{let i=[];for(const e of this.dataManager.relationshipTypeNames){const t=this.sublayerIdsCache.get(e);t&&(i=i.concat(Array.from(t.keys())))}a=await this.dataManager.getRelationshipsBetweenNodes(e,i,t),await this._handleNewRecords(a,t),r(t)}catch(i){throw l(i)&&this.removeRecords(a),i}return{records:a}}async connectFromEntities(e,t){if(!e.length)return{records:[]};let a=[];try{let i=[];for(const e of this.dataManager.relationshipTypeNames){const t=this.sublayerIdsCache.get(e);t&&(i=i.concat(Array.from(t.keys())))}let n=[];for(const e of this.dataManager.entityTypeNames){const t=this.sublayerIdsCache.get(e);t&&(n=n.concat(Array.from(t)))}a=await this.dataManager.getRelationshipsFromNodes(e,n,i,t),await this._handleNewRecords(a,t),a.length>0&&(this.membershipModified=!0),r(t)}catch(i){throw l(i)&&this.removeRecords(a),i}return{records:a}}getCurrentLayout(){return this._currentLinkChartConfig.layoutMode}async _calculateLayoutWithSublayerTimeInfo(e="organic-standard",t){const a=new Map;this.layers.forEach(e=>{a.set(e.objectType.name,e.timeInfo)}),await this.calculateLinkChartLayout(e,{timeInfoByTypeName:a,...t}),this.linkChart?.handleChronologicalOverlay()}async _handleNewRecords(e,t){const a=new Set,i=[],n=this.layers.concat(this.tables);for(const r of e){if(!this._graphTypeLookup.has(r.typeName))continue;!1===n.some(e=>e.objectType.name===r.typeName)&&(this.dataManager.sublayerCaches.set(r.typeName,new Map),a.add(r.typeName));o(this.sublayerIdsCache,r.typeName,()=>new Set).add(r.id),i.push(r)}this.dataManager.addToLayer(i);for(const o of a){const e=this._graphTypeLookup.get(o);if(e){const t=this._createSublayer(e);"entity"===e.type?this.dataManager.entityTypeNames.add(o):this.dataManager.relationshipTypeNames.add(o),t.geometryType?this.layers.push(t):this.tables.push(t)}}await E(this,Array.from(a),t),await this.dataManager.refreshCacheContent(e.map(e=>e.id),void 0,void 0,void 0,t);const s={layoutSettings:this._currentLinkChartConfig.layoutSettings,lockedNodeLocations:new Map};for(const[o,r]of this.entityLinkChartDiagramLookup.entries())r&&s.lockedNodeLocations.set(o,new m(r.coords[0],r.coords[1]));await this.applyNewLinkChartLayout(this._currentLinkChartConfig.layoutMode,s)}_createSublayers(e,t,a){e.forEach(e=>{const i=this._createSublayer(e);a(i)&&t.push(i),this._updateSublayerCaches(e)})}_updateSublayers(e,t){t.forEach(t=>{t.parentCompositeLayer=this;const a=e.find(e=>e.type===t.graphType&&e.name===t.graphTypeName);a&&(t.objectType=a,t.read({title:a.name},{origin:"service"}),this._updateSublayerCaches(a))})}_updateSublayerCaches({name:e}){if(!e)return;const t=this.dataManager.sublayerCaches;t.has(e)||t.set(e,new Map)}_layersLoadedFromAuthoritativeItem(){const e=this.originIdOf("layers");return e>=3&&e<7}async _initializeDiagram(){this.initializationLinkChartConfig?this.initializationLinkChartConfig.doNotRecalculateLayout?(this.dataManager.inclusionModeDefinition?.namedTypeDefinitions?.forEach((e,t)=>{e?.members?.forEach(e=>{const a=e.linkChartLocation;let i;const n=e.id;if(!a)return;i="x"in a?{x:a.x,y:a.y}:{x:a.coords[0],y:a.coords[1]};const o=b(i);this.dataManager.relationshipTypeNames.has(t)?this.relationshipLinkChartDiagramLookup.set(n,o):this.entityLinkChartDiagramLookup.set(n,o),this.linkChartExtent.xmin>i.x&&(this.linkChartExtent.xmin=i.x),this.linkChartExtent.xmax<i.x&&(this.linkChartExtent.xmax=i.x),this.linkChartExtent.ymin>i.y&&(this.linkChartExtent.ymin=i.y),this.linkChartExtent.ymax<i.y&&(this.linkChartExtent.ymax=i.y)})}),this.memberRelationshipTypes.forEach(e=>{e.name&&this.dataManager.sublayerCaches.get(e.name)?.forEach(e=>{const t=this.relationshipLinkChartDiagramLookup.get(e.attributes[k]),a=this.relationshipLinkChartDiagramLookup.get(e.attributes[C]);if(t&&a){const i=b(new f({paths:[[[t.coords[0],t.coords[1]],[a.coords[0],a.coords[1]]]]}));this.relationshipLinkChartDiagramLookup.set(e.attributes[M],i)}else this.relationshipLinkChartDiagramLookup.set(e.attributes[M],null)})})):await this._calculateLayoutWithSublayerTimeInfo(this.initializationLinkChartConfig.layoutMode,{lockedNodeLocations:this.getCurrentNodeLocations(),...this.initializationLinkChartConfig}):await this._calculateLayoutWithSublayerTimeInfo("organic-standard",{lockedNodeLocations:this.getCurrentNodeLocations()})}_refreshNamedTypes(){for(const e of this.layers)e.emit("refresh",{dataChanged:!0});for(const e of this.tables)e.emit("refresh",{dataChanged:!0})}_validateOrganicLayoutSettings(e,t){const a=e=>"number"==typeof e&&!isNaN(e),i=e=>a(e)&&e>=1,o=e=>a(e)&&e>=1,s=e=>Object.values(D).includes(e),r=e=>a(e)&&e>=0,l={};if(!new Set(["organic-standard","organic-community","geographic-organic-standard","chronological-multi-timeline","chronological-mono-timeline"]).has(e)||!t)return l;const{computationBudgetTime:h,autoRepulsionRadius:d,repulsionRadiusMultiplier:p,absoluteIdealEdgeLength:c,multiplicativeIdealEdgeLength:u,idealEdgeLengthType:y}=t;return o(h)?l.computationBudgetTime=h:h&&n.getLogger(this).warn("Invalid layout computationBudgetTime setting, will revert to default setting"),l.autoRepulsionRadius=d,!d&&i(p)?l.repulsionRadiusMultiplier=p:d||(l.autoRepulsionRadius=!0,n.getLogger(this).warn("Invalid layout repulsionRadiusMultiplier setting, will revert to default setting")),"geographic-organic-standard"===e&&(s(y)?l.idealEdgeLengthType=y:void 0!==y&&n.getLogger(this).warn('Invalid layout idealEdgeLengthType setting, will revert to "multiplier" setting'),"absolute-value"===y&&r(c)?l.absoluteIdealEdgeLength=c:"absolute-value"===y&&void 0!==c?n.getLogger(this).warn("Invalid layout idealEdgeLength setting, will revert to default setting"):"multiplier"===y&&r(u)?l.multiplicativeIdealEdgeLength=u:"multiplier"===y&&void 0!==u&&n.getLogger(this).warn("Invalid layout idealEdgeLength setting, will revert to default setting")),l}_convertValidatedOrganicSettingsToCalculationSettings(e){let t=e.idealEdgeLengthType===D.ABSOLUTE?e.absoluteIdealEdgeLength:e.multiplicativeIdealEdgeLength;return e.idealEdgeLengthType===D.ABSOLUTE&&(void 0===t?t=-1:t*=-1),{computationBudgetTime:e.computationBudgetTime??void 0,repulsionRadiusMultiplier:e.repulsionRadiusMultiplier&&!e.autoRepulsionRadius?e.repulsionRadiusMultiplier:void 0,idealEdgeLengthMultiplier:t}}_createSublayer(e){return new v({objectType:e,parentCompositeLayer:this,graphType:e.type})}_handleSublayersChange(e,t){t&&(t.forEach(e=>{e.parent=null}),this.removeHandles("sublayers-owner")),e&&(e.forEach(e=>{e.parent=this}),this.addHandles([e.on("after-add",({item:e})=>{e.parent=this}),e.on("after-remove",({item:e})=>{e.parent=null})],"sublayers-owner"))}_alignLayersDataModelAndInclusionDefinition(e){const t=new Set((e.entityTypes??[]).map(e=>e.name).concat((e.relationshipTypes??[]).map(e=>e.name))),i=new Set((e.entityTypes??[]).map(e=>e.name)),o=new Set((e.relationshipTypes??[]).map(e=>e.name));if(this.layers){for(const a of this.layers)!a.graphType&&t.has(a.graphTypeName)&&(a.graphType=i.has(a.graphTypeName)?"entity":"relationship");const e=this.layers.filter(e=>t.has(e.graphTypeName)&&("entity"===e.graphType?i.has(e.graphTypeName):o.has(e.graphTypeName)));this.setAtOrigin("layers",e,y(this.originIdOf("layers")))}else this.layers=new a;if(this.layers&&this._originalInclusionList){const e=new Set(this._originalInclusionList.namedTypeDefinitions.keys()),t=this.tables?.map(e=>e.graphTypeName)??[],a=this.layers.map(e=>e.graphTypeName).concat(t);for(const n of a)e.has(n)||this._originalInclusionList.namedTypeDefinitions.set(n,{useAllData:!1,members:new Map});const i=[];for(const o of this._originalInclusionList.namedTypeDefinitions.keys())a.includes(o)||(n.getLogger(this).warn(`A named type, ${o}, was in the serialized feature collection but did not have a sublayer config in the item, so will be removed`),i.push(o));for(const n of i)this._originalInclusionList.namedTypeDefinitions.delete(n)}}};e([c(z)],K.prototype,"url",void 0),e([c()],K.prototype,"dataPreloadedInLocalCache",void 0),e([c()],K.prototype,"initializationLinkChartConfig",void 0),e([c()],K.prototype,"membershipModified",void 0),e([c()],K.prototype,"dataManager",void 0),e([c()],K.prototype,"initializationInclusionModeDefinition",null),e([c()],K.prototype,"knowledgeGraph",void 0),e([c({type:a.ofType(v),json:{write:{ignoreOrigin:!0}}})],K.prototype,"layers",void 0),e([c({readOnly:!0})],K.prototype,"linkChart",null),e([c()],K.prototype,"entityLinkChartDiagramLookup",void 0),e([c()],K.prototype,"relationshipLinkChartDiagramLookup",void 0),e([c()],K.prototype,"linkChartExtent",void 0),e([c()],K.prototype,"memberEntityTypes",void 0),e([c()],K.prototype,"memberRelationshipTypes",void 0),e([c({type:["LinkChartLayer"]})],K.prototype,"operationalLayerType",void 0),e([c()],K.prototype,"sublayerCapabilities",null),e([c()],K.prototype,"sublayerIdsCache",void 0),e([c({type:a.ofType(v),json:{write:{ignoreOrigin:!0}}})],K.prototype,"tables",void 0),e([c({json:{read:!1}})],K.prototype,"type",void 0),e([c({json:{read:!1}})],K.prototype,"chronologicalAuxiliaryGraphics",void 0),K=e([u("esri.layers.LinkChartLayer")],K);const J=K;export{J as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import t from"../../PopupTemplate.js";import r from"../../core/Error.js";import{clone as i}from"../../core/lang.js";import o from"../../core/Logger.js";import{MultiOriginJSONMixin as s}from"../../core/MultiOriginJSONSupport.js";import"../../core/workers/workers.js";import{property as n}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import{subclass as a}from"../../core/accessorSupport/decorators/subclass.js";import{writer as p}from"../../core/accessorSupport/decorators/writer.js";import l from"../../geometry/Extent.js";import y from"../../geometry/Point.js";import d from"../../geometry/Polygon.js";import u from"../../geometry/Polyline.js";import{initializeProjection as m,project as h}from"../../geometry/projectionUtils.js";import c from"../../geometry/SpatialReference.js";import{wgs84 as g}from"../../geometry/support/spatialReferenceUtils.js";import{featureGeometryTypeKebabDictionary as f}from"../../geometry/support/typeUtils.js";import b from"../../graphic/KnowledgeGraphGraphicOrigin.js";import j from"../../graphic/LinkChartGraphicOrigin.js";import w from"../Layer.js";import T from"../graphics/data/FeatureStore.js";import{QueryEngine as v}from"../graphics/data/QueryEngine.js";import{createDrawingInfo as I}from"../graphics/sources/support/clientSideDefaults.js";import{systemOidFieldName as O,systemAggregationCountFieldName as E,systemIsSpatialFieldName as S,systemLayoutGeometryFieldName as x,systemOriginIdFieldName as L,systemDestinationIdFieldName as N}from"./constants.js";import{KnowledgeGraphSublayerBase as _}from"./KnowledgeGraphSublayerBase.js";import{createCapabilitiesFromKnowledgeGraph as F,createDefaultKGSLFormTemplate as R,getDisplayLabelProperty as C,getLinkChartDefaultLabelingInfo as k,getMapDefaultLabelingInfo as Q,getKGSublayerSymbolColor as M,getDefaultLCRelationshipSublayerSymbol as P,createDefaultKGSLFeatureTemplates as G,convertLayerEditsToGraphEdits as D,convertGraphEditsResultToFeatureEdits as J}from"./layerUtils.js";import{BlendLayer as q,blendModeProperty as U,effectProperty as A}from"../mixins/BlendLayer.js";import{DisplayFilteredLayer as B,displayFilterEnabledProperty as Z,displayFilterInfoProperty as K}from"../mixins/DisplayFilteredLayer.js";import{FeatureEffectLayer as V,featureEffectProperty as H}from"../mixins/FeatureEffectLayer.js";import{FeatureReductionLayer as W}from"../mixins/FeatureReductionLayer.js";import{OrderedLayer as Y,orderByProperty as z}from"../mixins/OrderedLayer.js";import{RefreshableLayer as X}from"../mixins/RefreshableLayer.js";import{ScaleRangeLayer as $}from"../mixins/ScaleRangeLayer.js";import{TemporalLayer as ee,useViewTimeProperty as te}from"../mixins/TemporalLayer.js";import{legendEnabled as re,maxScale as ie,minScale as oe,opacity as se,popupEnabled as ne}from"../support/commonProperties.js";import{featureReductionProperty as ae}from"../support/featureReductionUtils.js";import pe from"../support/Field.js";import{fixRendererFields as le,fixTimeInfoFields as ye}from"../support/fieldUtils.js";import de from"../support/LabelClass.js";import{reader as ue}from"../support/labelingInfo.js";import me from"../support/TimeInfo.js";import he from"../../renderers/SimpleRenderer.js";import{fromJSON as ce}from"../../renderers/support/jsonUtils.js";import{rendererTypes as ge}from"../../renderers/support/typeUtils.js";import{executeApplyEdits as fe}from"../../rest/knowledgeGraphService.js";import be from"../../rest/support/FeatureSet.js";import je from"../../rest/support/Query.js";import{createPopupTemplate as we}from"../../support/popupUtils.js";import{applyColorToSymbol as Te}from"../../symbols/support/utils.js";import ve from"../../core/workers/RemoteClient.js";function Ie(e){if(!e.json)return e;e.json.write=Oe(e.json.write);const t=e.json.origins;if(!t)return e;let r;for(r in t){const e=t[r];e&&(e.write=Oe(e.write))}return e}function Oe(e){return"object"==typeof e&&e?(!1!==e.enabled&&(e.overridePolicy=Ee(e)),e):!0===e?Se():e}function Ee(e){const{target:t,writer:r,overridePolicy:i,...o}=e;return function(e,t){const r=xe.call(this,e,t);return r.enabled?{...o,...r}:r}}function Se(){return{overridePolicy:xe}}function xe(e,t){const r=!!this.geometryType;let i={enabled:r};return r&&(i={...i,...Le.call(this,e,t)}),i}function Le(e,t){return{ignoreOrigin:this.originIdOf(t)>0}}let Ne=class extends(_(B(W(V(q(Y(ee($(X(s(w))))))))))){constructor(e){super(e),this.blendMode="normal",this.charts=null,this.definitionExpression=null,this.displayFilterEnabled=!0,this.displayFilterInfo=null,this.effect=null,this.elevationInfo=null,this.featureEffect=null,this.graphType=null,this.labelsVisible=!0,this.layerType=null,this.legendEnabled=!0,this.maxScale=0,this.minScale=0,this.objectIdField=O,this.objectType=null,this.opacity=1,this.orderBy=null,this.parent=null,this.parentCompositeLayer=null,this.persistenceEnabled=!0,this.popupEnabled=!0,this.popupTemplate=null,this.refreshInterval=0,this.source={openPorts:()=>this.load().then(()=>{const e=new MessageChannel;return new ve(e.port1,{channel:e,client:{queryFeatures:(e,t={})=>{const r=je.fromJSON(e);return this.queryFeaturesJSON(r,t)}}}),[e.port2]})},this.type="knowledge-graph-sublayer",this.useViewTime=!0,this.visible=!0}get capabilities(){return this.parent?this.parent.sublayerCapabilities:F(null)}get userHasUpdateItemPrivileges(){return!!this.parent?.userHasUpdateItemPrivileges}get editingEnabled(){return this._isOverridden("editingEnabled")?this._get("editingEnabled"):this.capabilities.operations.supportsEditing}set editingEnabled(e){this._overrideIfSome("editingEnabled",e)}get isTable(){return"link-chart"!==this.parentCompositeLayer.type&&null==this.geometryFieldName}get defaultPopupTemplate(){return this.createPopupTemplate()}set featureReduction(e){const t=this._normalizeFeatureReduction(e);this._set("featureReduction",t)}get fields(){const e=[];return this.objectType?.properties?.forEach(t=>{const r="esriFieldTypeOID"===t.fieldType?"esriFieldTypeInteger":t.fieldType;e.push(pe.fromJSON({name:t.name,type:r,alias:t.alias,defaultValue:t.defaultValue,editable:t.editable,nullable:t.nullable}))}),e.push(pe.fromJSON({name:this.objectIdField,type:"esriFieldTypeString",alias:this.objectIdField,editable:!1}),pe.fromJSON({name:E,type:"esriFieldTypeInteger",alias:E,editable:!1}),pe.fromJSON({name:S,type:"esriFieldTypeInteger",alias:S,editable:!1})),e}get formTemplate(){return this._isOverridden("formTemplate")?this._get("formTemplate"):R(this)}set formTemplate(e){this._overrideIfSome("formTemplate",e)}get geometryType(){if("link-chart"===this.parentCompositeLayer?.type)return"relationship"===this.graphType?"polyline":"point";const e=this.parentCompositeLayer?.dataManager.geographicLookup.get(this.objectType?.name),t=e?.geometryType;return t&&"esriGeometryNull"!==t?f.fromJSON(t):null}get geometryFieldName(){if("link-chart"===this.parentCompositeLayer?.type)return x;const e=this.parentCompositeLayer?.dataManager.geographicLookup.get(this.objectType?.name);return e?.name??null}get graphicOrigin(){if(!this.parent)return null;switch(this.parent.type){case"knowledge-graph":return new b(this.parent,this);case"link-chart":return new j(this.parent,this)}}get graphTypeName(){return this.objectType?.name}set graphTypeName(e){this._set("graphTypeName",e)}get hasM(){const e=this.parentCompositeLayer?.dataManager.geographicLookup.get(this.objectType?.name),t=e?.name,r=t?this.objectType?.properties?.[t]:null;return r?.hasM??!1}get hasZ(){const e=this.parentCompositeLayer?.dataManager.geographicLookup.get(this.objectType?.name),t=e?.name,r=t?this.objectType?.properties?.[t]:null;return r?.hasZ??!1}set labelingInfo(e){this._set("labelingInfo",e)}get labelingInfo(){if(this._isOverridden("labelingInfo"))return this._get("labelingInfo");if(!this.objectType||!this.parentCompositeLayer||!this.graphTypeName)return null;const e=this.objectType.properties?C(this.objectType.properties):"ESRI__ID";return"link-chart"===this.parentCompositeLayer.type?k(this.graphType,this.graphTypeName,e):Q(this.graphTypeName,this.geometryType,e)}set renderer(e){le(e,this.fieldsIndex),this._set("renderer",e)}get renderer(){if(this._isOverridden("renderer"))return this._get("renderer");const e=this.parentCompositeLayer?.dataManager?.knowledgeGraph?.dataModel,t=[...e?.entityTypes??[],...e?.relationshipTypes??[]].map(e=>e.name).indexOf(this.graphTypeName),r=M(t);if("link-chart"===this.parentCompositeLayer?.type){if("relationship"===this.graphType)return new he({type:"simple",symbol:P(r)});const e=ce(I(f.toJSON("point")).renderer);return Te(e.symbol,r),e}const i=ce(I(f.toJSON(this.geometryType)).renderer);return Te(i.symbol,r),i}get spatialReference(){return this.parentCompositeLayer?.dataManager?.knowledgeGraph?.dataModel?.spatialReference??c.WGS84}get templates(){return this._isOverridden("templates")?this._get("templates"):G(this)}set templates(e){this._overrideIfSome("templates",e)}set timeInfo(e){this._set("timeInfo",e)}get title(){return this._isOverridden("title")?this._get("title"):this.graphTypeName}set title(e){this._set("title",e)}writeTitle(e,t){t.title=e??"Layer"}createPopupTemplate(e){return we(this,e)}createQuery(){return new je({where:"1=1",outFields:["*"]})}getField(e){return this.fieldsIndex.get(e)}getFieldDomain(e,t){return null}async queryFeatures(e,t){await this.load();const{resolvedQuery:r,queryEngine:i}=await this._setupQueryObjects(e),o=this.graphicOrigin,s=be.fromJSON(await i.executeQuery(r.toJSON(),t?.signal));return s.features.forEach(e=>{e.sourceLayer=this,e.origin=o}),s}async queryFeaturesJSON(e,t){await this.load();const{resolvedQuery:r,queryEngine:i}=await this._setupQueryObjects(e);return await i.executeQuery(r.toJSON(),t?.signal)}async queryFeatureCount(e,t){await this.load();const{resolvedQuery:r,queryEngine:i}=await this._setupQueryObjects(e);return i.executeQueryForCount(r.toJSON(),t?.signal)}async queryExtent(e={},t){await this.load();const r={...e,returnGeometry:!0},{resolvedQuery:i,queryEngine:o}=await this._setupQueryObjects(r),s=await o.executeQueryForExtent(i.toJSON(),t?.signal);let n;return n=null!=s.extent?.xmin&&null!=s.extent?.xmax&&null!=s.extent?.ymin&&null!=s.extent?.ymax?new l(s.extent):new l,{count:s.count,extent:n}}async queryObjectIds(e,t){await this.load();const r=je.from(e);let i;if("link-chart"===this.parentCompositeLayer.type&&this._cachedQueryEngine)i=this._cachedQueryEngine;else{const e=await this.parentCompositeLayer.dataManager.getData(r,this,t);i=this.loadQueryEngine(e)}return await i.executeQueryForIds(r.toJSON(),t?.signal)}async applyEdits(e){if(!this.parentCompositeLayer.dataManager.knowledgeGraph)throw new r("knowledge-graph-sublayer:no-knowledge-graph","ApplyEdits cannot be executed because the parent does not have a Knowledge Graph model. This is usually caused by the layer not yet being loaded");const t=await D(e,this);t.options={cascadeDelete:!0,cascadeProvenanceDelete:!!this.parent?.knowledgeGraph.serviceDefinition.supportsProvenance||void 0};const i=await fe(this.parentCompositeLayer.dataManager.knowledgeGraph,t),o=J(i,this.graphTypeName),s={addedFeatures:o.addFeatureResults,updatedFeatures:o.updateFeatureResults,deletedFeatures:o.deleteFeatureResults,addedAttachments:o.addAttachmentResults,deletedAttachments:o.deleteAttachmentResults,updatedAttachments:o.updateAttachmentResults,exceededTransferLimit:!1,historicMoment:new Date,edits:void 0};return this.emit("edits",s),this.emit("apply-edits",{result:Promise.resolve(s)}),"link-chart"===this.parentCompositeLayer.type&&await this.parentCompositeLayer.refreshLinkChartCache([...s.addedFeatures.map(e=>e.globalId),...s.updatedFeatures.map(e=>e.globalId),...s.deletedFeatures.map(e=>e.globalId)]),o}loadQueryEngine(e){const t=new T({geometryType:f.toJSON(this.geometryType),hasM:this.hasM,hasZ:this.hasZ}),r=new v({fieldsIndex:this.fieldsIndex.toJSON(),geometryType:f.toJSON(this.geometryType),hasM:this.hasM,hasZ:this.hasZ,featureIdInfo:{type:"object-id",fieldName:this.objectIdField},spatialReference:this.spatialReference.toJSON(),timeInfo:this.timeInfo?.toJSON(),featureStore:t});return r.featureStore.addMany(e),r}async refreshCachedQueryEngine(){const e=await this.parentCompositeLayer.dataManager.getData(new je({where:"1=1",outFields:[O]}),this);this._cachedQueryEngine=this.loadQueryEngine(e)}load(e){return this.addResolvingPromise(this.parent.load(e).then(()=>ye(this.timeInfo,this.fieldsIndex))),Promise.resolve(this)}async _setupQueryObjects(e,t){const r=je.from(e),i=r.geometry;if(i&&!i.spatialReference?.isWGS84&&(await m(i.spatialReference,g),r.geometry=h(i instanceof d||i instanceof u||i instanceof y?i:i.extent,g)),"link-chart"===this.parentCompositeLayer.type&&this._cachedQueryEngine)return{resolvedQuery:r,queryEngine:this._cachedQueryEngine};const o=await this.parentCompositeLayer.dataManager.getData(r,this,t);return{resolvedQuery:r,queryEngine:this.loadQueryEngine(o)}}};function _e(e,t,r){const i=[["ESRI__AGGREGATION_COUNT",E],["ESRI__ORIGIN_ID",L],["ESRI__DESTINATION_ID",N],["ESRI__LAYOUT_GEOMETRY",x]];try{for(const t of e)for(const[e,r]of i)t.labelExpression=t.labelExpression?.replaceAll(e,r),t.labelExpressionInfo?.expression&&(t.labelExpressionInfo.expression=t.labelExpressionInfo.expression.replaceAll(e,r))}catch(s){o.getLogger(this).warn("Error updating labelingInfo",s)}return ue(e,t,r)}e([n(Ie(i(U)))],Ne.prototype,"blendMode",void 0),e([n({readOnly:!0})],Ne.prototype,"capabilities",null),e([n({readOnly:!0})],Ne.prototype,"userHasUpdateItemPrivileges",null),e([n({type:Boolean})],Ne.prototype,"editingEnabled",null),e([n()],Ne.prototype,"isTable",null),e([n({json:{origins:{"web-scene":{write:!1}},write:Se()}})],Ne.prototype,"charts",void 0),e([n({readOnly:!0})],Ne.prototype,"defaultPopupTemplate",null),e([n({type:String,json:{origins:{service:{read:!1}},name:"layerDefinition.definitionExpression",write:{ignoreOrigin:!0}}})],Ne.prototype,"definitionExpression",void 0),e([n(Ie(i(Z)))],Ne.prototype,"displayFilterEnabled",void 0),e([n(Ie(i(K)))],Ne.prototype,"displayFilterInfo",void 0),e([n(Ie(i(A)))],Ne.prototype,"effect",void 0),e([n()],Ne.prototype,"elevationInfo",void 0),e([n(Ie(i(H)))],Ne.prototype,"featureEffect",void 0),e([n(Ie(i(ae)))],Ne.prototype,"featureReduction",null),e([n()],Ne.prototype,"fields",null),e([n()],Ne.prototype,"formTemplate",null),e([n()],Ne.prototype,"geometryType",null),e([n()],Ne.prototype,"geometryFieldName",null),e([n({readOnly:!0})],Ne.prototype,"graphicOrigin",null),e([n({type:["entity","relationship"],nonNullable:!0,json:{write:{isRequired:!0,ignoreOrigin:!0}}})],Ne.prototype,"graphType",void 0),e([n({type:String,nonNullable:!0,json:{write:{isRequired:!0,ignoreOrigin:!0}}})],Ne.prototype,"graphTypeName",null),e([n()],Ne.prototype,"hasM",null),e([n()],Ne.prototype,"hasZ",null),e([n({type:String,json:{origins:{service:{read:!1},"portal-item":{read:!1}},write:{ignoreOrigin:!0}}})],Ne.prototype,"id",void 0),e([n({type:Boolean,value:!0,nonNullable:!0,json:{name:"showLabels",default:!1,write:{overridePolicy(){return{enabled:!!this.geometryType,alwaysWriteDefaults:!0,ignoreOrigin:!0}}}}})],Ne.prototype,"labelsVisible",void 0),e([n({type:[de],json:{name:"layerDefinition.drawingInfo.labelingInfo",read:_e,write:Se()}})],Ne.prototype,"labelingInfo",null),e([n({readOnly:!0,json:{read:!1,write:{writer(e,t){switch(this.parentCompositeLayer?.type){case"link-chart":t.layerType="LinkChartSubLayer";break;case"knowledge-graph":t.layerType=this.geometryType?"KnowledgeGraphSubLayer":"KnowledgeGraphSubTable"}},isRequired:!0,ignoreOrigin:!0,writerEnsuresNonNull:!0}}})],Ne.prototype,"layerType",void 0),e([n(Ie(i(re)))],Ne.prototype,"legendEnabled",void 0),e([n(Ie(i(ie)))],Ne.prototype,"maxScale",void 0),e([n(Ie(i(oe)))],Ne.prototype,"minScale",void 0),e([n()],Ne.prototype,"objectIdField",void 0),e([n()],Ne.prototype,"objectType",void 0),e([n(Ie(i(se)))],Ne.prototype,"opacity",void 0),e([n(Ie(i(z)))],Ne.prototype,"orderBy",void 0),e([n({clonable:!1})],Ne.prototype,"parent",void 0),e([n()],Ne.prototype,"parentCompositeLayer",void 0),e([n(Ie(i(ne)))],Ne.prototype,"popupEnabled",void 0),e([n({type:t,json:{name:"popupInfo",write:{ignoreOrigin:!0}}})],Ne.prototype,"popupTemplate",void 0),e([n({type:Number,json:{write:{overridePolicy:Le}}})],Ne.prototype,"refreshInterval",void 0),e([n({types:ge,json:{name:"layerDefinition.drawingInfo.renderer",write:Se()}})],Ne.prototype,"renderer",null),e([n()],Ne.prototype,"source",void 0),e([n()],Ne.prototype,"spatialReference",null),e([n()],Ne.prototype,"templates",null),e([n({type:me,json:{name:"layerDefinition.timeInfo",write:{overridePolicy:Le},origins:{"web-document":{name:"layerDefinition.timeInfo",read:!0,write:{overridePolicy:Le}},"portal-item":{name:"layerDefinition.timeInfo",read:!0,write:{overridePolicy:Le}}}}})],Ne.prototype,"timeInfo",null),e([n({type:String,json:{write:{isRequired:!0,ignoreOrigin:!0,writerEnsuresNonNull:!0}}})],Ne.prototype,"title",null),e([p("title")],Ne.prototype,"writeTitle",null),e([n({json:{read:!1}})],Ne.prototype,"type",void 0),e([n(Ie(i(te)))],Ne.prototype,"useViewTime",void 0),e([n({type:Boolean,json:{name:"visibility",write:Se()}})],Ne.prototype,"visible",void 0),Ne=e([a("esri.layers.knowledgeGraph.KnowledgeGraphSublayer")],Ne);export{Ne as default};
5
+ import{__decorate as e}from"tslib";import t from"../../PopupTemplate.js";import r from"../../core/Error.js";import{clone as i}from"../../core/lang.js";import o from"../../core/Logger.js";import{MultiOriginJSONMixin as s}from"../../core/MultiOriginJSONSupport.js";import"../../core/workers/workers.js";import{property as n}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import{subclass as a}from"../../core/accessorSupport/decorators/subclass.js";import{writer as p}from"../../core/accessorSupport/decorators/writer.js";import l from"../../geometry/Extent.js";import y from"../../geometry/Point.js";import d from"../../geometry/Polygon.js";import u from"../../geometry/Polyline.js";import{initializeProjection as m,project as h}from"../../geometry/projectionUtils.js";import c from"../../geometry/SpatialReference.js";import{wgs84 as g}from"../../geometry/support/spatialReferenceUtils.js";import{featureGeometryTypeKebabDictionary as f}from"../../geometry/support/typeUtils.js";import b from"../../graphic/KnowledgeGraphGraphicOrigin.js";import j from"../../graphic/LinkChartGraphicOrigin.js";import w from"../Layer.js";import T from"../graphics/data/FeatureStore.js";import{QueryEngine as v}from"../graphics/data/QueryEngine.js";import{createDrawingInfo as I}from"../graphics/sources/support/clientSideDefaults.js";import{systemOidFieldName as O,systemAggregationCountFieldName as E,systemIsSpatialFieldName as S,systemLayoutGeometryFieldName as x,systemOriginIdFieldName as L,systemDestinationIdFieldName as N}from"./constants.js";import{KnowledgeGraphSublayerBase as _}from"./KnowledgeGraphSublayerBase.js";import{createCapabilitiesFromKnowledgeGraph as F,createDefaultKGSLFormTemplate as R,getDisplayLabelProperty as C,getLinkChartDefaultLabelingInfo as k,getMapDefaultLabelingInfo as Q,getKGSublayerSymbolColor as M,getDefaultLCRelationshipSublayerSymbol as P,createDefaultKGSLFeatureTemplates as G,convertLayerEditsToGraphEdits as D,convertGraphEditsResultToFeatureEdits as J}from"./layerUtils.js";import{BlendLayer as q,blendModeProperty as U,effectProperty as A}from"../mixins/BlendLayer.js";import{DisplayFilteredLayer as B,displayFilterEnabledProperty as Z,displayFilterInfoProperty as K}from"../mixins/DisplayFilteredLayer.js";import{FeatureEffectLayer as V,featureEffectProperty as H}from"../mixins/FeatureEffectLayer.js";import{FeatureReductionLayer as W}from"../mixins/FeatureReductionLayer.js";import{OrderedLayer as Y,orderByProperty as z}from"../mixins/OrderedLayer.js";import{RefreshableLayer as X}from"../mixins/RefreshableLayer.js";import{ScaleRangeLayer as $}from"../mixins/ScaleRangeLayer.js";import{TemporalLayer as ee,useViewTimeProperty as te}from"../mixins/TemporalLayer.js";import{legendEnabled as re,maxScale as ie,minScale as oe,opacity as se,popupEnabled as ne}from"../support/commonProperties.js";import{featureReductionProperty as ae}from"../support/featureReductionUtils.js";import pe from"../support/Field.js";import{fixRendererFields as le,fixTimeInfoFields as ye}from"../support/fieldUtils.js";import de from"../support/LabelClass.js";import{reader as ue}from"../support/labelingInfo.js";import me from"../support/TimeInfo.js";import he from"../../renderers/SimpleRenderer.js";import{fromJSON as ce}from"../../renderers/support/jsonUtils.js";import{rendererTypes as ge}from"../../renderers/support/typeUtils.js";import{executeApplyEdits as fe}from"../../rest/knowledgeGraphService.js";import be from"../../rest/support/FeatureSet.js";import je from"../../rest/support/Query.js";import{createPopupTemplate as we}from"../../support/popupUtils.js";import{applyColorToSymbol as Te}from"../../symbols/support/utils.js";import ve from"../../core/workers/RemoteClient.js";function Ie(e){if(!e.json)return e;e.json.write=Oe(e.json.write);const t=e.json.origins;if(!t)return e;let r;for(r in t){const e=t[r];e&&(e.write=Oe(e.write))}return e}function Oe(e){return"object"==typeof e&&e?(!1!==e.enabled&&(e.overridePolicy=Ee(e)),e):!0===e?Se():e}function Ee(e){const{target:t,writer:r,overridePolicy:i,...o}=e;return function(e,t){const r=xe.call(this,e,t);return r.enabled?{...o,...r}:r}}function Se(){return{overridePolicy:xe}}function xe(e,t){const r=!!this.geometryType;let i={enabled:r};return r&&(i={...i,...Le.call(this,e,t)}),i}function Le(e,t){return{ignoreOrigin:this.originIdOf(t)>0}}let Ne=class extends(_(B(W(V(q(Y(ee($(X(s(w))))))))))){constructor(e){super(e),this.blendMode="normal",this.charts=null,this.definitionExpression=null,this.displayFilterEnabled=!0,this.displayFilterInfo=null,this.effect=null,this.elevationInfo=null,this.featureEffect=null,this.graphType=null,this.labelsVisible=!0,this.layerType=null,this.legendEnabled=!0,this.maxScale=0,this.minScale=0,this.objectIdField=O,this.objectType=null,this.opacity=1,this.orderBy=null,this.parent=null,this.parentCompositeLayer=null,this.persistenceEnabled=!0,this.popupEnabled=!0,this.popupTemplate=null,this.refreshInterval=0,this.source={openPorts:()=>this.load().then(()=>{const e=new MessageChannel;return new ve(e.port1,{channel:e,client:{queryFeatures:(e,t={})=>{const r=je.fromJSON(e);return this.queryFeaturesJSON(r,t)}}}),[e.port2]})},this.type="knowledge-graph-sublayer",this.useViewTime=!0,this.visible=!0}get capabilities(){return this.parent?this.parent.sublayerCapabilities:F(null)}get userHasUpdateItemPrivileges(){return!!this.parent?.userHasUpdateItemPrivileges}get editingEnabled(){return this._isOverridden("editingEnabled")?this._get("editingEnabled"):this.capabilities.operations.supportsEditing}set editingEnabled(e){this._overrideIfSome("editingEnabled",e)}get isTable(){return"link-chart"!==this.parentCompositeLayer?.type&&null==this.geometryFieldName}get defaultPopupTemplate(){return this.createPopupTemplate()}set featureReduction(e){const t=this._normalizeFeatureReduction(e);this._set("featureReduction",t)}get fields(){const e=[];return this.objectType?.properties?.forEach(t=>{const r="esriFieldTypeOID"===t.fieldType?"esriFieldTypeInteger":t.fieldType;e.push(pe.fromJSON({name:t.name,type:r,alias:t.alias,defaultValue:t.defaultValue,editable:t.editable,nullable:t.nullable}))}),e.push(pe.fromJSON({name:this.objectIdField,type:"esriFieldTypeString",alias:this.objectIdField,editable:!1}),pe.fromJSON({name:E,type:"esriFieldTypeInteger",alias:E,editable:!1}),pe.fromJSON({name:S,type:"esriFieldTypeInteger",alias:S,editable:!1})),e}get formTemplate(){return this._isOverridden("formTemplate")?this._get("formTemplate"):R(this)}set formTemplate(e){this._overrideIfSome("formTemplate",e)}get geometryType(){if("link-chart"===this.parentCompositeLayer?.type)return"relationship"===this.graphType?"polyline":"point";const e=this.parentCompositeLayer?.dataManager.geographicLookup.get(this.objectType?.name),t=e?.geometryType;return t&&"esriGeometryNull"!==t?f.fromJSON(t):null}get geometryFieldName(){if("link-chart"===this.parentCompositeLayer?.type)return x;const e=this.parentCompositeLayer?.dataManager.geographicLookup.get(this.objectType?.name);return e?.name??null}get graphicOrigin(){if(!this.parent)return null;switch(this.parent.type){case"knowledge-graph":return new b(this.parent,this);case"link-chart":return new j(this.parent,this)}}get graphTypeName(){return this.objectType?.name}set graphTypeName(e){this._set("graphTypeName",e)}get hasM(){const e=this.parentCompositeLayer?.dataManager.geographicLookup.get(this.objectType?.name),t=e?.name,r=t?this.objectType?.properties?.[t]:null;return r?.hasM??!1}get hasZ(){const e=this.parentCompositeLayer?.dataManager.geographicLookup.get(this.objectType?.name),t=e?.name,r=t?this.objectType?.properties?.[t]:null;return r?.hasZ??!1}set labelingInfo(e){this._set("labelingInfo",e)}get labelingInfo(){if(this._isOverridden("labelingInfo"))return this._get("labelingInfo");if(!this.objectType||!this.parentCompositeLayer||!this.graphTypeName)return null;const e=this.objectType.properties?C(this.objectType.properties):"ESRI__ID";return"link-chart"===this.parentCompositeLayer.type?k(this.graphType,this.graphTypeName,e):Q(this.graphTypeName,this.geometryType,e)}set renderer(e){le(e,this.fieldsIndex),this._set("renderer",e)}get renderer(){if(this._isOverridden("renderer"))return this._get("renderer");const e=this.parentCompositeLayer?.dataManager?.knowledgeGraph?.dataModel,t=[...e?.entityTypes??[],...e?.relationshipTypes??[]].map(e=>e.name).indexOf(this.graphTypeName),r=M(t);if("link-chart"===this.parentCompositeLayer?.type){if("relationship"===this.graphType)return new he({type:"simple",symbol:P(r)});const e=ce(I(f.toJSON("point")).renderer);return Te(e.symbol,r),e}const i=ce(I(f.toJSON(this.geometryType)).renderer);return Te(i.symbol,r),i}get spatialReference(){return this.parentCompositeLayer?.dataManager?.knowledgeGraph?.dataModel?.spatialReference??c.WGS84}get templates(){return this._isOverridden("templates")?this._get("templates"):G(this)}set templates(e){this._overrideIfSome("templates",e)}set timeInfo(e){this._set("timeInfo",e)}get title(){return this._isOverridden("title")?this._get("title"):this.graphTypeName}set title(e){this._set("title",e)}writeTitle(e,t){t.title=e??"Layer"}createPopupTemplate(e){return we(this,e)}createQuery(){return new je({where:"1=1",outFields:["*"]})}getField(e){return this.fieldsIndex.get(e)}getFieldDomain(e,t){return null}async queryFeatures(e,t){await this.load();const{resolvedQuery:r,queryEngine:i}=await this._setupQueryObjects(e),o=this.graphicOrigin,s=be.fromJSON(await i.executeQuery(r.toJSON(),t?.signal));return s.features.forEach(e=>{e.sourceLayer=this,e.origin=o}),s}async queryFeaturesJSON(e,t){await this.load();const{resolvedQuery:r,queryEngine:i}=await this._setupQueryObjects(e);return await i.executeQuery(r.toJSON(),t?.signal)}async queryFeatureCount(e,t){await this.load();const{resolvedQuery:r,queryEngine:i}=await this._setupQueryObjects(e);return i.executeQueryForCount(r.toJSON(),t?.signal)}async queryExtent(e={},t){await this.load();const r={...e,returnGeometry:!0},{resolvedQuery:i,queryEngine:o}=await this._setupQueryObjects(r),s=await o.executeQueryForExtent(i.toJSON(),t?.signal);let n;return n=null!=s.extent?.xmin&&null!=s.extent?.xmax&&null!=s.extent?.ymin&&null!=s.extent?.ymax?new l(s.extent):new l,{count:s.count,extent:n}}async queryObjectIds(e,t){await this.load();const r=je.from(e);let i;if("link-chart"===this.parentCompositeLayer.type&&this._cachedQueryEngine)i=this._cachedQueryEngine;else{const e=await this.parentCompositeLayer.dataManager.getData(r,this,t);i=this.loadQueryEngine(e)}return await i.executeQueryForIds(r.toJSON(),t?.signal)}async applyEdits(e){if(!this.parentCompositeLayer.dataManager.knowledgeGraph)throw new r("knowledge-graph-sublayer:no-knowledge-graph","ApplyEdits cannot be executed because the parent does not have a Knowledge Graph model. This is usually caused by the layer not yet being loaded");const t=await D(e,this);t.options={cascadeDelete:!0,cascadeProvenanceDelete:!!this.parent?.knowledgeGraph.serviceDefinition.supportsProvenance||void 0};const i=await fe(this.parentCompositeLayer.dataManager.knowledgeGraph,t),o=J(i,this.graphTypeName),s={addedFeatures:o.addFeatureResults,updatedFeatures:o.updateFeatureResults,deletedFeatures:o.deleteFeatureResults,addedAttachments:o.addAttachmentResults,deletedAttachments:o.deleteAttachmentResults,updatedAttachments:o.updateAttachmentResults,exceededTransferLimit:!1,historicMoment:new Date,edits:void 0};return this.emit("edits",s),this.emit("apply-edits",{result:Promise.resolve(s)}),"link-chart"===this.parentCompositeLayer.type&&await this.parentCompositeLayer.refreshLinkChartCache([...s.addedFeatures.map(e=>e.globalId),...s.updatedFeatures.map(e=>e.globalId),...s.deletedFeatures.map(e=>e.globalId)]),o}loadQueryEngine(e){const t=new T({geometryType:f.toJSON(this.geometryType),hasM:this.hasM,hasZ:this.hasZ}),r=new v({fieldsIndex:this.fieldsIndex.toJSON(),geometryType:f.toJSON(this.geometryType),hasM:this.hasM,hasZ:this.hasZ,featureIdInfo:{type:"object-id",fieldName:this.objectIdField},spatialReference:this.spatialReference.toJSON(),timeInfo:this.timeInfo?.toJSON(),featureStore:t});return r.featureStore.addMany(e),r}async refreshCachedQueryEngine(){const e=await this.parentCompositeLayer.dataManager.getData(new je({where:"1=1",outFields:[O]}),this);this._cachedQueryEngine=this.loadQueryEngine(e)}load(e){return this.addResolvingPromise(this.parent.load(e).then(()=>ye(this.timeInfo,this.fieldsIndex))),Promise.resolve(this)}async _setupQueryObjects(e,t){const r=je.from(e),i=r.geometry;if(i&&!i.spatialReference?.isWGS84&&(await m(i.spatialReference,g),r.geometry=h(i instanceof d||i instanceof u||i instanceof y?i:i.extent,g)),"link-chart"===this.parentCompositeLayer.type&&this._cachedQueryEngine)return{resolvedQuery:r,queryEngine:this._cachedQueryEngine};const o=await this.parentCompositeLayer.dataManager.getData(r,this,t);return{resolvedQuery:r,queryEngine:this.loadQueryEngine(o)}}};function _e(e,t,r){const i=[["ESRI__AGGREGATION_COUNT",E],["ESRI__ORIGIN_ID",L],["ESRI__DESTINATION_ID",N],["ESRI__LAYOUT_GEOMETRY",x]];try{for(const t of e)for(const[e,r]of i)t.labelExpression=t.labelExpression?.replaceAll(e,r),t.labelExpressionInfo?.expression&&(t.labelExpressionInfo.expression=t.labelExpressionInfo.expression.replaceAll(e,r))}catch(s){o.getLogger(this).warn("Error updating labelingInfo",s)}return ue(e,t,r)}e([n(Ie(i(U)))],Ne.prototype,"blendMode",void 0),e([n({readOnly:!0})],Ne.prototype,"capabilities",null),e([n({readOnly:!0})],Ne.prototype,"userHasUpdateItemPrivileges",null),e([n({type:Boolean})],Ne.prototype,"editingEnabled",null),e([n()],Ne.prototype,"isTable",null),e([n({json:{origins:{"web-scene":{write:!1}},write:Se()}})],Ne.prototype,"charts",void 0),e([n({readOnly:!0})],Ne.prototype,"defaultPopupTemplate",null),e([n({type:String,json:{origins:{service:{read:!1}},name:"layerDefinition.definitionExpression",write:{ignoreOrigin:!0}}})],Ne.prototype,"definitionExpression",void 0),e([n(Ie(i(Z)))],Ne.prototype,"displayFilterEnabled",void 0),e([n(Ie(i(K)))],Ne.prototype,"displayFilterInfo",void 0),e([n(Ie(i(A)))],Ne.prototype,"effect",void 0),e([n()],Ne.prototype,"elevationInfo",void 0),e([n(Ie(i(H)))],Ne.prototype,"featureEffect",void 0),e([n(Ie(i(ae)))],Ne.prototype,"featureReduction",null),e([n()],Ne.prototype,"fields",null),e([n()],Ne.prototype,"formTemplate",null),e([n()],Ne.prototype,"geometryType",null),e([n()],Ne.prototype,"geometryFieldName",null),e([n({readOnly:!0})],Ne.prototype,"graphicOrigin",null),e([n({type:["entity","relationship"],nonNullable:!0,json:{write:{isRequired:!0,ignoreOrigin:!0}}})],Ne.prototype,"graphType",void 0),e([n({type:String,nonNullable:!0,json:{write:{isRequired:!0,ignoreOrigin:!0}}})],Ne.prototype,"graphTypeName",null),e([n()],Ne.prototype,"hasM",null),e([n()],Ne.prototype,"hasZ",null),e([n({type:String,json:{origins:{service:{read:!1},"portal-item":{read:!1}},write:{ignoreOrigin:!0}}})],Ne.prototype,"id",void 0),e([n({type:Boolean,value:!0,nonNullable:!0,json:{name:"showLabels",default:!1,write:{overridePolicy(){return{enabled:!!this.geometryType,alwaysWriteDefaults:!0,ignoreOrigin:!0}}}}})],Ne.prototype,"labelsVisible",void 0),e([n({type:[de],json:{name:"layerDefinition.drawingInfo.labelingInfo",read:_e,write:Se()}})],Ne.prototype,"labelingInfo",null),e([n({readOnly:!0,json:{read:!1,write:{writer(e,t){switch(this.parentCompositeLayer?.type){case"link-chart":t.layerType="LinkChartSubLayer";break;case"knowledge-graph":t.layerType=this.geometryType?"KnowledgeGraphSubLayer":"KnowledgeGraphSubTable"}},isRequired:!0,ignoreOrigin:!0,writerEnsuresNonNull:!0}}})],Ne.prototype,"layerType",void 0),e([n(Ie(i(re)))],Ne.prototype,"legendEnabled",void 0),e([n(Ie(i(ie)))],Ne.prototype,"maxScale",void 0),e([n(Ie(i(oe)))],Ne.prototype,"minScale",void 0),e([n()],Ne.prototype,"objectIdField",void 0),e([n()],Ne.prototype,"objectType",void 0),e([n(Ie(i(se)))],Ne.prototype,"opacity",void 0),e([n(Ie(i(z)))],Ne.prototype,"orderBy",void 0),e([n({clonable:!1})],Ne.prototype,"parent",void 0),e([n()],Ne.prototype,"parentCompositeLayer",void 0),e([n(Ie(i(ne)))],Ne.prototype,"popupEnabled",void 0),e([n({type:t,json:{name:"popupInfo",write:{ignoreOrigin:!0}}})],Ne.prototype,"popupTemplate",void 0),e([n({type:Number,json:{write:{overridePolicy:Le}}})],Ne.prototype,"refreshInterval",void 0),e([n({types:ge,json:{name:"layerDefinition.drawingInfo.renderer",write:Se()}})],Ne.prototype,"renderer",null),e([n()],Ne.prototype,"source",void 0),e([n()],Ne.prototype,"spatialReference",null),e([n()],Ne.prototype,"templates",null),e([n({type:me,json:{name:"layerDefinition.timeInfo",write:{overridePolicy:Le},origins:{"web-document":{name:"layerDefinition.timeInfo",read:!0,write:{overridePolicy:Le}},"portal-item":{name:"layerDefinition.timeInfo",read:!0,write:{overridePolicy:Le}}}}})],Ne.prototype,"timeInfo",null),e([n({type:String,json:{write:{isRequired:!0,ignoreOrigin:!0,writerEnsuresNonNull:!0}}})],Ne.prototype,"title",null),e([p("title")],Ne.prototype,"writeTitle",null),e([n({json:{read:!1}})],Ne.prototype,"type",void 0),e([n(Ie(i(te)))],Ne.prototype,"useViewTime",void 0),e([n({type:Boolean,json:{name:"visibility",write:Se()}})],Ne.prototype,"visible",void 0),Ne=e([a("esri.layers.knowledgeGraph.KnowledgeGraphSublayer")],Ne);export{Ne as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import t from"./DateTimeFieldFormat.js";import e from"./FieldFormat.js";import{isNumericField as n,isDateField as r,isDateOnlyField as o,isTimeOnlyField as a,isTimestampOffsetField as u}from"./fieldUtils.js";import i from"./NumberFieldFormat.js";import s from"../../popup/support/FieldInfoFormat.js";const l={base:e,key:"type",errorContext:"field-configuration-field-format",typeMap:{"date-time":t,number:i}};function c(t,e){const{dateFormat:n}=t;if(!e)return n?f(t):h(t);if(!m(e))return;const r={hour12:"always"};switch(e.type){case"integer":case"small-integer":case"big-integer":case"long":return d(t);case"single":case"double":return h(t);case"date":case"timestamp-offset":return n?f(t):I(e,r);case"date-only":return n?y(t):I(e);case"time-only":return n?g(t):I(e,r)}}function m(t){return n(t)||r(t)||o(t)||a(t)||u(t)}function d(t){return new i({useGrouping:t.digitSeparator?"always":"never"})}function h(t){const e=d(t);return e.maximumFractionDigits=e.minimumFractionDigits=t.places??2,e}function f(e){return new t({dateStyle:p(e),year:$(e),month:w(e),timeStyle:S(e),hour12:F(e)})}function y(e){return new t({dateStyle:p(e),year:$(e),month:w(e)})}function g(e){return new t({timeStyle:S(e),hour12:F(e)})}function p(t){const{dateFormat:e}=t;return e?e.startsWith("short-date")?"short":e.startsWith("day-short-month-year")?"medium":e.startsWith("long-month-day-year")?"long":e.startsWith("long-date")?"full":null:null}function F(t){return t.dateFormat?.endsWith("-24")?"never":"always"}function w(t){switch(t.dateFormat){case"short-month-year":return"short";case"long-month-year":return"long";default:return null}}function S(t){const{dateFormat:e}=t;return e?e.includes("short-time")?"short":e.includes("long-time")?"medium":null:null}function $(t){switch(t.dateFormat){case"short-month-year":case"long-month-year":case"year":return"numeric";default:return null}}function b(t,e){const n="number"===t.type,r="date-time"===t.type;if(!e)return n?x(t):r?j(t):null;if(m(e))switch(e.type){case"integer":case"small-integer":case"big-integer":case"long":return n?D(t):null;case"single":case"double":return n?x(t):null;case"date":case"timestamp-offset":return r?j(t):null;case"date-only":return r?v(t):null;case"time-only":return r?G(t):null}}function D(t){return new s({digitSeparator:"never"!==t.useGrouping})}function x(t){const e=D(t);return e.places=t.maximumFractionDigits,e}function j(t){let e;const n=W(t),r=k(t),o="never"===t.hour12?"24":null,a="numeric"===t.year?"year":null,u=C(t);return n&&r&&o?e=`${n}-${r}-${o}`:n&&r?e=`${n}-${r}`:n?e=n:a&&u?e=`${u}-${a}`:a&&(e=a),e?new s({dateFormat:e}):null}function v(t){let e;const n=W(t),r="numeric"===t.year?"year":null,o=C(t);return n?e=n:r&&o?e=`${o}-${r}`:r&&(e=r),e?new s({dateFormat:e}):null}function G(t){let e;const n=k(t),r="never"===t.hour12?"24":null;return n&&r?e=`short-date-${n}-${r}`:n&&(e=`short-date-${n}`),e?new s({dateFormat:e}):null}function W(t){switch(t.dateStyle){case"short":return"short-date";case"medium":return"day-short-month-year";case"long":return"long-month-day-year";case"full":return"long-date";default:return}}function k(t){return t.timeStyle&&("short"===t.timeStyle?"short-time":"long-time")}function C(t){switch(t.month){case"short":return"short-month";case"long":return"long-month";default:return}}function I(e,n){if(!m(e))return;const r=n?.useGrouping??"auto",o=n?.hour12??"auto";switch(e.type){case"integer":case"small-integer":case"big-integer":case"long":return new i({maximumFractionDigits:0,minimumFractionDigits:0,useGrouping:r});case"single":case"double":return new i({maximumFractionDigits:2,minimumFractionDigits:0,useGrouping:r});case"date":case"timestamp-offset":return new t({dateStyle:"short",timeStyle:"short",hour12:o});case"date-only":return new t({dateStyle:"short"});case"time-only":return new t({timeStyle:"short",hour12:o})}}export{I as defaultFieldFormat,c as fieldFormatFromFieldInfoFormat,b as fieldInfoFormatFromFieldFormat,l as formatTypes,m as isFormattableField};
5
+ import t from"./DateTimeFieldFormat.js";import e from"./FieldFormat.js";import{isNumericField as n,isDateField as r,isDateOnlyField as o,isTimeOnlyField as a,isTimestampOffsetField as u}from"./fieldUtils.js";import i from"./NumberFieldFormat.js";import s from"../../popup/support/FieldInfoFormat.js";const l={base:e,key:"type",errorContext:"field-configuration-field-format",typeMap:{"date-time":t,number:i}};function c(t,e){const{dateFormat:n}=t;if(!e)return n?f(t):h(t);if(!m(e))return;const r={hour12:"always"};switch(e.type){case"integer":case"small-integer":case"big-integer":case"long":return d(t);case"single":case"double":return h(t);case"date":case"timestamp-offset":return n?f(t):I(e,r);case"date-only":return n?y(t):I(e);case"time-only":return n?g(t):I(e,r)}}function m(t){return n(t)||r(t)||o(t)||a(t)||u(t)}function d(t){return new i({useGrouping:t.digitSeparator?"always":"never"})}function h(t){const e=d(t),{places:n}=t;return e.minimumFractionDigits=n??0,e.maximumFractionDigits=n??2,e}function f(e){return new t({dateStyle:p(e),year:$(e),month:w(e),timeStyle:S(e),hour12:F(e)})}function y(e){return new t({dateStyle:p(e),year:$(e),month:w(e)})}function g(e){return new t({timeStyle:S(e),hour12:F(e)})}function p(t){const{dateFormat:e}=t;return e?e.startsWith("short-date")?"short":e.startsWith("day-short-month-year")?"medium":e.startsWith("long-month-day-year")?"long":e.startsWith("long-date")?"full":null:null}function F(t){return t.dateFormat?.endsWith("-24")?"never":"always"}function w(t){switch(t.dateFormat){case"short-month-year":return"short";case"long-month-year":return"long";default:return null}}function S(t){const{dateFormat:e}=t;return e?e.includes("short-time")?"short":e.includes("long-time")?"medium":null:null}function $(t){switch(t.dateFormat){case"short-month-year":case"long-month-year":case"year":return"numeric";default:return null}}function b(t,e){const n="number"===t.type,r="date-time"===t.type;if(!e)return n?x(t):r?j(t):null;if(m(e))switch(e.type){case"integer":case"small-integer":case"big-integer":case"long":return n?D(t):null;case"single":case"double":return n?x(t):null;case"date":case"timestamp-offset":return r?j(t):null;case"date-only":return r?v(t):null;case"time-only":return r?G(t):null}}function D(t){return new s({digitSeparator:"never"!==t.useGrouping})}function x(t){const e=D(t);return e.places=t.maximumFractionDigits,e}function j(t){let e;const n=W(t),r=k(t),o="never"===t.hour12?"24":null,a="numeric"===t.year?"year":null,u=C(t);return n&&r&&o?e=`${n}-${r}-${o}`:n&&r?e=`${n}-${r}`:n?e=n:a&&u?e=`${u}-${a}`:a&&(e=a),e?new s({dateFormat:e}):null}function v(t){let e;const n=W(t),r="numeric"===t.year?"year":null,o=C(t);return n?e=n:r&&o?e=`${o}-${r}`:r&&(e=r),e?new s({dateFormat:e}):null}function G(t){let e;const n=k(t),r="never"===t.hour12?"24":null;return n&&r?e=`short-date-${n}-${r}`:n&&(e=`short-date-${n}`),e?new s({dateFormat:e}):null}function W(t){switch(t.dateStyle){case"short":return"short-date";case"medium":return"day-short-month-year";case"long":return"long-month-day-year";case"full":return"long-date";default:return}}function k(t){return t.timeStyle&&("short"===t.timeStyle?"short-time":"long-time")}function C(t){switch(t.month){case"short":return"short-month";case"long":return"long-month";default:return}}function I(e,n){if(!m(e))return;const r=n?.useGrouping??"auto",o=n?.hour12??"auto";switch(e.type){case"integer":case"small-integer":case"big-integer":case"long":return new i({minimumFractionDigits:0,maximumFractionDigits:0,useGrouping:r});case"single":case"double":return new i({minimumFractionDigits:0,maximumFractionDigits:2,useGrouping:r});case"date":case"timestamp-offset":return new t({dateStyle:"short",timeStyle:"short",hour12:o});case"date-only":return new t({dateStyle:"short"});case"time-only":return new t({timeStyle:"short",hour12:o})}}export{I as defaultFieldFormat,c as fieldFormatFromFieldInfoFormat,b as fieldInfoFormatFromFieldFormat,l as formatTypes,m as isFormattableField};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcgis/core",
3
- "version": "5.0.0-next.10",
3
+ "version": "5.0.0-next.11",
4
4
  "homepage": "https://js.arcgis.com",
5
5
  "description": "ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API",
6
6
  "keywords": [
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- const b="20251009",e="6b5d9c7148888d699b656f0e4b57992284e62296";export{b as buildDate,e as commitHash};
5
+ const c="20251010",e="6c1d6e8ad18fe09b44de6bfb0c377a21737c617c";export{c as buildDate,e as commitHash};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import has from"../../../../../core/has.js";import{AProcessorStrategy as e,ASendState as t}from"./AProcessorStrategy.js";import{FeatureTileUpdateMessage as s,FeatureTileAppendMessage as r}from"../sources/FeatureSourceMessage.js";import{OverrideChunk as o}from"../sources/strategies/chunks/Overrides.js";import{createArcadeEvaluationOptions as a}from"../support/arcadeUtils.js";import{FeatureSetReaderJSON as n}from"../support/FeatureSetReaderJSON.js";class d extends t{}class i extends e{constructor(e,t,s,r){super(e,t,r),this._arcadeContextInfo=s,this.handledChunks=new Set,this.handledChunksForIdCreation=new Set,this.handledChunksForAttributeData=new Set,this._streamLayerDeferredObjectIdsToRemove=[]}destroy(){super.destroy();for(const e of this._source.chunks())this._cleanupChunkIds(e)}invalidateAttributeData(e){this.handledChunksForAttributeData.clear(),this._arcadeContextInfo=e,null!=this._evalOptions&&(this._evalOptions=a(this._evalOptions.$view.scale,e))}onSubscribe(e){super.onSubscribe(e),this._evalOptions=e.tile.createArcadeEvaluationOptions(this._arcadeContextInfo)}createState(e){return new d(e)}get aggregateQueryEngine(){return null}displayMap(e,t,s){const r=new Map(e.map(e=>[t(e),e])),o=[];for(const a of this._source.chunks()){const e=a.reader.getCursor();for(;e.next();){const t=e.getObjectId(),a=e.getDisplayId(),n=r.get(t);if(null!=n){const e=s(a,n,t);o.push(e),r.delete(t)}}}return o}getDisplayFeatures(e){const t=new Set(e),s=new Set,r=[];for(const o of this._source.chunks()){const e=o.reader.getCursor();for(;e.next();){const o=e.getObjectId(),a=e.getDisplayId();t.has(a)&&!s.has(o)&&(r.push({...e.readLegacyFeatureWorldSpace(),displayId:a}),s.add(o))}}return{features:r,aggregates:[],tracks:[]}}async*applyOverrideUpdate(e){const t=[];for(const s of e.modified){const e=this._attributeStore.createDisplayIdForObjectId(s.objectId);s.displayId=e,t.push(e)}const r=n.fromOptimizedFeatures(e.modified,this._source.metadata).getCursor();for(;r.next();)this._attributeStore.setAttributeData(r.getDisplayId(),r,this._evalOptions,this._sqlOptions);const a=[];for(const s of e.removed){const e=this._attributeStore.getDisplayIdForObjectId(s);null!=e&&a.push(e)}has("esri-2d-update-debug")&&console.debug("FeatureUpdateStrategy.applyLocalEdit",{message:e,modifiedDisplayIds:t,removedDisplayIds:a});const d=o.fromFeatures(e.modified,this._source.metadata);this.handledChunks.add(d.chunkId),this.handledChunksForAttributeData.add(d.chunkId),this.handledChunksForIdCreation.add(d.chunkId);for(const o of this._sendStates.values())o.handledChunks.add(d.chunkId),yield new s(o.subscription,null,t,!1,d.queryInfo);for(const o of this._sendStates.values()){const e=d.getTileReader(o.subscription.tile);yield new s(o.subscription,e,a,!1,d.queryInfo)}for(const s of e.removed)this._attributeStore.releaseDisplayIdForObjectId(s)}async*updateChunks(){if(this._source.chunks().length){this._updateAttributeData();for(const e of this._sendStates.values())yield*this._update(e)}}removeChunks(e){for(const t of e)this.handledChunks.delete(t.chunkId),this.handledChunksForAttributeData.delete(t.chunkId),this._cleanupChunkIds(t)}afterUpdateChunks(){for(const e of this._streamLayerDeferredObjectIdsToRemove)this._attributeStore.releaseDisplayIdForObjectId(e);this._streamLayerDeferredObjectIdsToRemove=[]}_cleanupChunkIds(e){if(this.handledChunksForIdCreation.has(e.chunkId)){const t=e.reader.getCursor();for(;t.next();){const e=t.getObjectId();this._source.isStream?this._streamLayerDeferredObjectIdsToRemove.push(e):this._attributeStore.releaseDisplayIdForObjectId(e)}this.handledChunksForIdCreation.delete(e.chunkId)}}_updateAttributeData(){for(const e of this._source.chunks()){const{chunkId:t,reader:s}=e;if(!this.handledChunksForIdCreation.has(t)){this.handledChunksForIdCreation.add(t);const e=s.getCursor();for(;e.next();){const t=this._attributeStore.createDisplayIdForObjectId(e.getObjectId());e.setDisplayId(t)}}}for(const e of this._source.chunks())if(this._attributeStore.referencesScale()||!this.handledChunksForAttributeData.has(e.chunkId)){this.handledChunksForAttributeData.add(e.chunkId);const t=e.reader.getCursor();for(;t.next();){const e=t.getDisplayId();this._attributeStore.setAttributeData(e,t,this._evalOptions,this._sqlOptions)}}}*_update(e){const{subscription:t,handledChunks:s}=e;for(const o of this._source.chunks()){const{chunkId:a}=o;if(s.has(a)||!this.handledChunksForIdCreation.has(a)||!this.handledChunksForAttributeData.has(a))continue;s.add(a);const n=o.getTileReader(t.tile);n&&(yield new r(e.subscription,n,!1,o.end,o.queryInfo))}}}export{d as DefaultSendState,i as FeatureUpdateStrategy};
5
+ import has from"../../../../../core/has.js";import{AProcessorStrategy as e,ASendState as t}from"./AProcessorStrategy.js";import{FeatureTileUpdateMessage as s,FeatureTileAppendMessage as r}from"../sources/FeatureSourceMessage.js";import{OverrideChunk as a}from"../sources/strategies/chunks/Overrides.js";import{createArcadeEvaluationOptions as o}from"../support/arcadeUtils.js";import{FeatureSetReaderJSON as n}from"../support/FeatureSetReaderJSON.js";class d extends t{}class i extends e{constructor(e,t,s,r){super(e,t,r),this._arcadeContextInfo=s,this.handledChunks=new Set,this.handledChunksForIdCreation=new Set,this.handledChunksForAttributeData=new Set,this._streamLayerDeferredObjectIdsToRemove=[]}destroy(){super.destroy();for(const e of this._source.chunks())this._cleanupChunkIds(e)}invalidateAttributeData(e){this.handledChunksForAttributeData.clear(),this._arcadeContextInfo=e,null!=this._evalOptions&&(this._evalOptions=o(this._evalOptions.$view.scale,e))}onSubscribe(e){super.onSubscribe(e),this._evalOptions=e.tile.createArcadeEvaluationOptions(this._arcadeContextInfo)}createState(e){return new d(e)}get aggregateQueryEngine(){return null}displayMap(e,t,s){const r=new Map(e.map(e=>[t(e),e])),a=[];for(const o of this._source.chunks()){const e=o.reader.getCursor();for(;e.next();){const t=e.getObjectId(),o=e.getDisplayId(),n=r.get(t);if(null!=n){const e=s(o,n,t);a.push(e),r.delete(t)}}}return a}getDisplayFeatures(e){const t=new Set(e),s=new Set,r=[];for(const a of this._source.chunks()){const e=a.reader.getCursor();for(;e.next();){const a=e.getObjectId(),o=e.getDisplayId();t.has(o)&&!s.has(a)&&(r.push({...e.readLegacyFeatureWorldSpace(),displayId:o}),s.add(a))}}return{features:r,aggregates:[],tracks:[]}}async*applyOverrideUpdate(e){const t=[];for(const s of e.modified.values()){const e=this._attributeStore.createDisplayIdForObjectId(s.objectId);s.displayId=e,t.push(e)}const r=n.fromOptimizedFeatures(Array.from(e.modified.values()),this._source.metadata).getCursor();for(;r.next();)this._attributeStore.setAttributeData(r.getDisplayId(),r,this._evalOptions,this._sqlOptions);const o=[];for(const s of e.removed){const e=this._attributeStore.getDisplayIdForObjectId(s);null!=e&&o.push(e)}has("esri-2d-update-debug")&&console.debug("FeatureUpdateStrategy.applyLocalEdit",{message:e,modifiedDisplayIds:t,removedDisplayIds:o});const d=a.fromFeatures(Array.from(e.modified.values()),this._source.metadata);this.handledChunks.add(d.chunkId),this.handledChunksForAttributeData.add(d.chunkId),this.handledChunksForIdCreation.add(d.chunkId);for(const a of this._sendStates.values())a.handledChunks.add(d.chunkId),yield new s(a.subscription,null,t,!1,d.queryInfo);for(const a of this._sendStates.values()){const e=d.getTileReader(a.subscription.tile);yield new s(a.subscription,e,o,!1,d.queryInfo)}for(const s of e.removed)this._attributeStore.releaseDisplayIdForObjectId(s)}async*updateChunks(){if(this._source.chunks().length){this._updateAttributeData();for(const e of this._sendStates.values())yield*this._update(e)}}removeChunks(e){for(const t of e)this.handledChunks.delete(t.chunkId),this.handledChunksForAttributeData.delete(t.chunkId),this._cleanupChunkIds(t)}afterUpdateChunks(){for(const e of this._streamLayerDeferredObjectIdsToRemove)this._attributeStore.releaseDisplayIdForObjectId(e);this._streamLayerDeferredObjectIdsToRemove=[]}_cleanupChunkIds(e){if(this.handledChunksForIdCreation.has(e.chunkId)){const t=e.reader.getCursor();for(;t.next();){const e=t.getObjectId();this._source.isStream?this._streamLayerDeferredObjectIdsToRemove.push(e):this._attributeStore.releaseDisplayIdForObjectId(e)}this.handledChunksForIdCreation.delete(e.chunkId)}}_updateAttributeData(){for(const e of this._source.chunks()){const{chunkId:t,reader:s}=e;if(!this.handledChunksForIdCreation.has(t)){this.handledChunksForIdCreation.add(t);const e=s.getCursor();for(;e.next();){const t=this._attributeStore.createDisplayIdForObjectId(e.getObjectId());e.setDisplayId(t)}}}for(const e of this._source.chunks())if(this._attributeStore.referencesScale()||!this.handledChunksForAttributeData.has(e.chunkId)){this.handledChunksForAttributeData.add(e.chunkId);const t=e.reader.getCursor();for(;t.next();){const e=t.getDisplayId();this._attributeStore.setAttributeData(e,t,this._evalOptions,this._sqlOptions)}}}*_update(e){const{subscription:t,handledChunks:s}=e;for(const a of this._source.chunks()){const{chunkId:o}=a;if(s.has(o)||!this.handledChunksForIdCreation.has(o)||!this.handledChunksForAttributeData.has(o))continue;s.add(o);const n=a.getTileReader(t.tile);n&&(yield new r(e.subscription,n,!1,a.end,a.queryInfo))}}}export{d as DefaultSendState,i as FeatureUpdateStrategy};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{parseWhereClause as e}from"../../../../../../../core/sql.js";import{ASourceChunk as t}from"./ASourceChunk.js";import{FeatureSetReaderJSON as s}from"../../../support/FeatureSetReaderJSON.js";const r=1e4,i=1e3;class n{static async create(t){const{metadata:s,definitionExpression:r}=t,i=r?await e(r,s.fieldsIndex):null;return new n(s,i,r)}constructor(e,t,s){this.metadata=e,this._clause=t,this._definitionExpression=s}get hash(){return this._definitionExpression}testFeature(e){return null==this._clause||this._clause.testFeature(e)}}class a{constructor(){this.modified=[],this.removed=[]}modify(e){this.modified.push(e)}remove(e){this.removed.push(e)}get isEmpty(){return 0===this.modified.length&&0===this.removed.length}applyWhereClause(e){const t=new a;for(const s of this.modified)e.testFeature(s)?t.modified.push(s):t.removed.push(s.objectId);for(const s of this.removed)t.removed.push(s);return t}}class o extends t{constructor(e){super(),this._reader=e,this.chunkId="override",this.normalizedChunkId="override"}static fromFeatures(e,t){const r=s.fromOptimizedFeatures(e,t);return new o(r)}get reader(){return this._reader}get queryInfo(){return{}}get first(){return!1}get end(){return!1}get isTiled(){return!1}getTileReader(e){if(!this._reader.getSize())return null;const t=this.queryFeaturesInBounds(e.bounds);return t.setTransformForDisplay(e.transform),t}}class d{constructor(e,t){this.inner=e,this.isWeak=t,this.lastWeak=null}get isStrong(){return!this.isWeak}}class h{constructor(e){this._parameters=e,this._overrides=new Map,this._update=new a,this._lastCleanup=0}update(e){this._parameters=e}hasOverride(e){return this._overrides.has(e)}onChunkInsert(e){if(this._overrides.size){const t=e.reader.getCursor();for(;t.next();){const e=t.getObjectId(),s=this._overrides.get(e);if(s?.lastWeak&&(s.lastWeak=null),s?.isWeak){const e=t.readOptimizedFeatureWorldSpace();s.inner=e,this._update.modify(e),this.invalidate()}}}e.registerOverrides(this)}apply(e,t){const{updateWeak:s,removeWeak:r,update:i,remove:n,release:a}=e.commands;this.invalidate();for(const o of s){const e=new d(o,!0),t=this._overrides.get(o.objectId);t?.isStrong?t.lastWeak=e:(this._overrides.set(o.objectId,e),this._update.modify(o))}for(const o of i){const e=new d(o,!1),t=this._overrides.get(o.objectId);e.lastWeak=t?.isWeak?t:t?.lastWeak??null,this._overrides.set(o.objectId,e),this._update.modify(o)}for(const o of r){const e=new d(null,!0),t=this._overrides.get(o);t?.isStrong?t.lastWeak=e:(this._overrides.set(o,e),this._update.remove(o))}for(const o of n){const e=new d(null,!1),t=this._overrides.get(o);e.lastWeak=t?.isWeak?t:t?.lastWeak??null,this._overrides.set(o,e),this._update.remove(o)}if(a.length){const e=new Set;for(const t of a){const s=this._overrides.get(t);s?.lastWeak?(this._overrides.set(t,s.lastWeak),null==s.lastWeak.inner?this._update.remove(t):this._update.modify(s.lastWeak.inner)):s&&!s.isWeak&&(this._overrides.delete(t),e.add(t))}t.forEachUnsafe(t=>{const s=t.getObjectId();e.has(s)&&(this._update.modify(t.readOptimizedFeatureWorldSpace()),e.delete(s))});for(const t of e.values())this._update.remove(t)}}clearWeakOverrides(){for(const[e,t]of this._overrides.entries())t.isWeak&&this._overrides.delete(e);this.invalidate()}cleanup(e){if(this._overrides.size<r)return;const t=performance.now();if(t-this._lastCleanup<i)return;this._lastCleanup=t;const s=this._getWeakDeletions();if(!(s.size<r)){for(const t of e){const e=t.reader.withoutOverrides().getCursor();for(;e.next();){const t=e.getObjectId();s.delete(t)}}for(const e of s)this._overrides.delete(e);s.size&&this.invalidate()}}takeOverrideUpdate(){const e=this._update;return e.isEmpty?null:(this._update=new a,e.applyWhereClause(this._parameters))}asChunk(){const e=this._parameters;if(this._lastOverrideParametersHash!==e.hash&&(this._lastOverrideParametersHash=e.hash,this._chunk=null),!this._chunk){const t=[];for(const s of this._overrides.values())null!=s.inner&&e.testFeature(s.inner)&&t.push(s.inner);this._chunk=o.fromFeatures(t,e.metadata)}return this._chunk}invalidate(){this._chunk=null}putWeakObjectIdsFromGlobalIds(e,t,s){for(const[r,i]of this._overrides.entries()){if(i.isWeak&&null!=i.inner){const n=i.inner.attributes[s];n&&t.has(n)&&!e.has(n)&&e.set(n,r);continue}if(null!=i.lastWeak&&null!=i.lastWeak.inner){const n=i.lastWeak.inner.attributes[s];n&&t.has(n)&&!e.has(n)&&e.set(n,r)}}}_getWeakDeletions(){const e=new Set;for(const[t,s]of this._overrides.entries())s.isWeak&&null==s.inner&&e.add(t);return e}}export{o as OverrideChunk,n as OverrideParameters,h as OverrideState,a as OverrideUpdate};
5
+ import{parseWhereClause as e}from"../../../../../../../core/sql.js";import{ASourceChunk as t}from"./ASourceChunk.js";import{FeatureSetReaderJSON as s}from"../../../support/FeatureSetReaderJSON.js";const r=1e4,i=1e3;class o{static async create(t){const{metadata:s,definitionExpression:r}=t,i=r?await e(r,s.fieldsIndex):null;return new o(s,i,r)}constructor(e,t,s){this.metadata=e,this._clause=t,this._definitionExpression=s}get hash(){return this._definitionExpression}testFeature(e){return null==this._clause||this._clause.testFeature(e)}}class a{constructor(){this.modified=new Map,this.removed=new Set}modify(e){this.modified.set(e.objectId,e),this.removed.has(e.objectId)&&this.removed.delete(e.objectId)}remove(e){this.modified.delete(e),this.removed.add(e)}get isEmpty(){return 0===this.modified.size&&0===this.removed.size}applyWhereClause(e){const t=new a;for(const[s,r]of this.modified)e.testFeature(r)?t.modified.set(s,r):t.removed.add(r.objectId);for(const s of this.removed)t.removed.add(s);return t}}class n extends t{constructor(e){super(),this._reader=e,this.chunkId="override",this.normalizedChunkId="override"}static fromFeatures(e,t){const r=s.fromOptimizedFeatures(e,t);return new n(r)}get reader(){return this._reader}get queryInfo(){return{}}get first(){return!1}get end(){return!1}get isTiled(){return!1}getTileReader(e){if(!this._reader.getSize())return null;const t=this.queryFeaturesInBounds(e.bounds);return t.setTransformForDisplay(e.transform),t}}class d{constructor(e,t){this.inner=e,this.isWeak=t,this.lastWeak=null}get isStrong(){return!this.isWeak}}class h{constructor(e){this._parameters=e,this._overrides=new Map,this._update=new a,this._lastCleanup=0}update(e){this._parameters=e}hasOverride(e){return this._overrides.has(e)}onChunkInsert(e){if(this._overrides.size){const t=e.reader.getCursor();for(;t.next();){const e=t.getObjectId(),s=this._overrides.get(e);if(s?.lastWeak&&(s.lastWeak=null),s?.isWeak){const e=t.readOptimizedFeatureWorldSpace();s.inner=e,this._update.modify(e),this.invalidate()}}}e.registerOverrides(this)}apply(e,t){const{updateWeak:s,removeWeak:r,update:i,remove:o,release:a}=e.commands;this.invalidate();for(const n of s){const e=new d(n,!0),t=this._overrides.get(n.objectId);t?.isStrong?t.lastWeak=e:(this._overrides.set(n.objectId,e),this._update.modify(n))}for(const n of i){const e=new d(n,!1),t=this._overrides.get(n.objectId);e.lastWeak=t?.isWeak?t:t?.lastWeak??null,this._overrides.set(n.objectId,e),this._update.modify(n)}for(const n of r){const e=new d(null,!0),t=this._overrides.get(n);t?.isStrong?t.lastWeak=e:(this._overrides.set(n,e),this._update.remove(n))}for(const n of o){const e=new d(null,!1),t=this._overrides.get(n);e.lastWeak=t?.isWeak?t:t?.lastWeak??null,this._overrides.set(n,e),this._update.remove(n)}if(a.length){const e=new Set;for(const t of a){const s=this._overrides.get(t);s?.lastWeak?(this._overrides.set(t,s.lastWeak),null==s.lastWeak.inner?this._update.remove(t):this._update.modify(s.lastWeak.inner)):s&&!s.isWeak&&(this._overrides.delete(t),e.add(t))}t.forEachUnsafe(t=>{const s=t.getObjectId();e.has(s)&&(this._update.modify(t.readOptimizedFeatureWorldSpace()),e.delete(s))});for(const t of e.values())this._update.remove(t)}}clearWeakOverrides(){for(const[e,t]of this._overrides.entries())t.isWeak&&this._overrides.delete(e);this.invalidate()}cleanup(e){if(this._overrides.size<r)return;const t=performance.now();if(t-this._lastCleanup<i)return;this._lastCleanup=t;const s=this._getWeakDeletions();if(!(s.size<r)){for(const t of e){const e=t.reader.withoutOverrides().getCursor();for(;e.next();){const t=e.getObjectId();s.delete(t)}}for(const e of s)this._overrides.delete(e);s.size&&this.invalidate()}}takeOverrideUpdate(){const e=this._update;return e.isEmpty?null:(this._update=new a,e.applyWhereClause(this._parameters))}asChunk(){const e=this._parameters;if(this._lastOverrideParametersHash!==e.hash&&(this._lastOverrideParametersHash=e.hash,this._chunk=null),!this._chunk){const t=[];for(const s of this._overrides.values())null!=s.inner&&e.testFeature(s.inner)&&t.push(s.inner);this._chunk=n.fromFeatures(t,e.metadata)}return this._chunk}invalidate(){this._chunk=null}putWeakObjectIdsFromGlobalIds(e,t,s){for(const[r,i]of this._overrides.entries()){if(i.isWeak&&null!=i.inner){const o=i.inner.attributes[s];o&&t.has(o)&&!e.has(o)&&e.set(o,r);continue}if(null!=i.lastWeak&&null!=i.lastWeak.inner){const o=i.lastWeak.inner.attributes[s];o&&t.has(o)&&!e.has(o)&&e.set(o,r)}}}_getWeakDeletions(){const e=new Set;for(const[t,s]of this._overrides.entries())s.isWeak&&null==s.inner&&e.add(t);return e}}export{n as OverrideChunk,o as OverrideParameters,h as OverrideState,a as OverrideUpdate};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as t}from"tslib";import e from"../../../../analysis/SlicePlane.js";import{clock as i}from"../../../../core/clock.js";import{destroyMaybe as a,removeMaybe as s}from"../../../../core/maybe.js";import{watch as n,sync as r,when as l,syncAndInitial as o}from"../../../../core/reactiveUtils.js";import{addFrameTask as h}from"../../../../core/scheduling.js";import{createScreenPoint as p,screenPointObjectToArray as u}from"../../../../core/screenUtils.js";import{property as c}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/Logger.js";import"../../../../core/RandomLCG.js";import{subclass as d}from"../../../../core/accessorSupport/decorators/subclass.js";import{fromRotation as _,fromScaling as v,multiply as m}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{f as P,b as y,d as w,h as g,g as f,t as M,n as D,j as V}from"../../../../chunks/vec32.js";import{create as b,clone as T}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{clone as S,ZEROS as k}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{a as x,d as j,n as E,f as C}from"../../../../chunks/boundedPlane.js";import{signedDistance as H,create as R,intersectRay as I,getNormal as z}from"../../../../geometry/support/plane.js";import{create as O}from"../../../../geometry/support/ray.js";import{sv3d as G,sm4d as U,sv2d as K}from"../../../../geometry/support/vectorStacks.js";import{getSliceableContainer as B}from"../../../../graphic/getSliceableContainer.js";import{getRotateHeadingTexture as A,getTiltRotateTexture as F}from"../images/Factory.js";import{ResizeManipulator as L}from"./ResizeManipulator.js";import{RotateManipulator as q}from"./RotateManipulator.js";import{getOutlineColor as N,planeColor as J}from"./settings.js";import{ShiftManipulator as Q}from"./ShiftManipulator.js";import{pointerMoveTimerMs as W,planePreviewOutlineWidth as X,forceVerticalModifier as Y,forceHorizontalModifier as Z,previewFadeDurationSeconds as $,previewFadeDotThreshold as tt,initialDepthOffsetFrac as et}from"./sliceToolConfig.js";import{createGridVisualElement as it,createOutlineVisualElement as at,planeToShape as st,createRotatePlane as nt,resizePlane as rt,calculatePlaneHalfSize as lt,createPlane as ot,DidPointerMoveRecentlyFlag as ht,calculateBoundedPlaneTranslateRotate as pt,updateShiftRestartHandle as ut,updateRotateHeadingHandle as ct,updateRotateTiltHandle as dt,updateResizeHandle as _t,createShiftPlane as vt}from"./sliceToolUtils.js";import{calculateInputRotationTransform as mt}from"../../interactive/manipulatorUtils.js";import{screenToRenderPlane as Pt}from"../../interactive/editingTools/dragEventPipeline3D.js";import{fromScreenNormalized as yt}from"../../support/geometryUtils/ray.js";import{AnalysisToolBase as wt}from"../../../interactive/AnalysisToolBase.js";import{createManipulatorDragEventPipeline as gt}from"../../../interactive/dragEventPipeline.js";import{newToolIntersector as ft}from"../../../interactive/ToolIntersector.js";import{createScreenPointFromEvent as Mt}from"../../../support/screenUtils.js";var Dt;let Vt=class extends wt{static{Dt=this}constructor(t){super(t),this._clock=i,this._previewPlaneOpacity=1,this.removeIncompleteOnCancel=!1,this._mode="none",this.shiftManipulator=null,this.rotateHeadingManipulator=null,this.rotateTiltManipulator=null,this.resizeManipulators=null,this._frameTask=null,this._pointerMoveTimerMs=W,this._prevPointerMoveTimeout=null,this._previewPlaneGridVisualElement=null,this._previewPlaneOutlineVisualElement=null,this._startPlane=x(),this._previewPlane=null,this._activeKeyModifiers={},this._lastCursorPosition=p(),this._resizeHandles=[{direction:[1,0]},{direction:[1,1]},{direction:[0,1]},{direction:[-1,1]},{direction:[-1,0]},{direction:[-1,-1]},{direction:[0,-1]},{direction:[1,-1]}],this._intersector=ft(t.view.state.viewingMode)}initialize(){if(null==this.analysis)throw new Error("SliceTool requires valid analysis, but null was provided.");const t=t=>{this._updateManipulatorsInteractive(t),t.grabbing||(null!=this.analysisViewData.plane&&j(this.analysisViewData.plane,this._startPlane),this.inputState=null)},e=new Q(this.view,1);this.shiftManipulator=e,this.manipulators.add(e),this.addHandles([this._createShiftDragPipeline(e),e.events.on("grab-changed",i=>{this._onShiftGrab(i),t(e)})]);const i=!this.view.stage?.renderView.renderingContext.driverTest.svgPremultipliesAlpha.result,a=new q(this.view,(t,e)=>A(this.view.stage.textures,{accentColor:t,contrastColor:e,preMultiplyAlpha:i}));this.rotateHeadingManipulator=a,this.manipulators.add(a),this.addHandles([this._createRotateHeadingDragPipeline(a),a.events.on("grab-changed",e=>{this._onRotateHeadingGrab(e),t(a)})]);const s=new q(this.view,(t,e)=>F(this.view.stage.textures,{accentColor:t,contrastColor:e,preMultiplyAlpha:i}));this.rotateTiltManipulator=s,this.manipulators.add(s),this.addHandles([this._createRotateTiltDragPipeline(s),s.events.on("grab-changed",e=>{this._onRotateTiltGrab(e),t(s)})]),this.resizeManipulators=this._resizeHandles.map((e,i)=>{const a=new L(this.view,e);return this.addHandles([this._createResizeDragPipeline(a),a.events.on("grab-changed",e=>{this._onResizeGrab(e,i),t(a)})]),a}),this.manipulators.addMany(this.resizeManipulators),this._previewPlaneGridVisualElement=it(this.view),this._previewPlaneOutlineVisualElement=at(this.view),this._previewPlaneOutlineVisualElement.width=X,this.addHandles(n(()=>[this.analysisViewData.plane,this.analysis.tiltEnabled],()=>this._updateManipulators(),r)),this.addHandles([l(()=>"sliced"===this.state,()=>{this.finishToolCreation(),this.stop()},o),n(()=>this.view.state.camera,()=>this._onCameraChange())])}destroy(){this._removeFrameTask(),this._clearPointerMoveTimeout(),this._previewPlaneOutlineVisualElement=a(this._previewPlaneOutlineVisualElement),this._previewPlaneGridVisualElement=a(this._previewPlaneGridVisualElement)}get state(){const t=!!this.analysisViewData.plane,e=!!this.inputState;return t?t&&e?"slicing":t&&!e?"sliced":"ready":"ready"}get cursor(){return this.active?this._placingSlicePlane||"exclude"===this.mode?"crosshair":null!=this._creatingPointerId?"grabbing":null:null}set analysis(t){if(null==t)throw new Error("SliceTool requires valid analysis, but null was provided.");this.removeHandles("analysis"),this._set("analysis",t)}get mode(){return this._mode}static{this.disableEngineLayers=!1}get inputState(){return this._get("inputState")}set inputState(t){this._set("inputState",t),this.analysisViewData.showGrid=null!=t&&"resize"===t.type,this._updateMaterials()}get _placingSlicePlane(){return this.active&&!this.inputState&&"place"===this._mode}get _creatingPointerId(){return null!=this.inputState&&"shift"===this.inputState.type?this.inputState.creatingPointerId:null}start(t){this._finishToolCreationIfValid(),this._mode=t,this.active||(this.view.activeTool=this)}stop(){this.active&&(this.view.activeTool=null)}onActivate(){this._finishToolCreationIfValid(),"none"===this._mode&&null==this.analysisViewData.plane&&(this._mode="place")}onDeactivate(){this._mode="none",this._updatePreviewPlane(null)}onShow(){this._updateVisibility(!0)}onHide(){this._updateVisibility(!1)}_updateVisibility(t){this._updateManipulators(),t||this._clearPointerMoveTimeout()}onInputEvent(t){switch(t.type){case"pointer-drag":if(!Tt(t))return;this._placingSlicePlane?this._onClickPlacePlane(t)&&t.stopPropagation():this._onPointerDrag(t)&&t.stopPropagation();break;case"pointer-move":this._onPointerMove(t);break;case"pointer-up":this._onPointerUp(t)&&t.stopPropagation();break;case"immediate-click":if(!Tt(t))return;"exclude"===this._mode?t.defer(async()=>{await this._onClickExcludeLayer(t)&&t.stopPropagation()}):this._onClickPlacePlane(t)&&t.stopPropagation();break;case"drag":this.inputState&&t.stopPropagation();break;case"key-down":this._onKeyDown(t)&&t.stopPropagation();break;case"key-up":this._onKeyUp(t)&&t.stopPropagation()}}onEditableChange(){this.analysisViewData.editable=this.internallyEditable}_onPointerDrag(t){const e=this.inputState;if(t.pointerId===this._creatingPointerId&&null!=e&&"shift"===e.type){const i=Mt(t);return this.shiftManipulator.events.emit("drag",{action:e.hasBeenDragged?"update":"start",pointerType:t.pointerType,start:i,screenPoint:i}),e.hasBeenDragged=!0,!0}return!1}_onPointerMove(t){this._lastCursorPosition.x=t.x,this._lastCursorPosition.y=t.y,this._resetPointerMoveTimeout(),"touch"!==t.pointerType&&this._updatePreviewPlane(Mt(t),this._activeKeyModifiers)}_onCameraChange(){this._updatePreviewPlane(this._lastCursorPosition,this._activeKeyModifiers),this._updateManipulators()}_onPointerUp(t){if(t.pointerId===this._creatingPointerId&&null!=this.analysisViewData.plane){const e=Mt(t);return this.shiftManipulator.events.emit("drag",{action:"end",start:e,screenPoint:e}),j(this.analysisViewData.plane,this._startPlane),this.inputState=null,!0}return!1}_onClickPlacePlane(t){if(!this._placingSlicePlane)return!1;const i=Mt(t),a=x();if(this._pickPlane(i,!1,this._activeKeyModifiers,a)){if("pointer-drag"===t.type){const e=yt(this.view.state.camera,i,kt);this.inputState=bt(e,t.pointerId,a.origin,a)}return j(a,this._startPlane),this.analysis.shape=st(a,this.view,this.view.spatialReference,new e),"pointer-drag"!==t.type&&this.stop(),!0}return!1}async _onClickExcludeLayer(t){if("exclude"!==this.mode)return!1;const e=await this.view.hitTest(Mt(t)),i=e.results.at(0);if(i){const t="graphic"===i.type&&i.graphic;if(t){const e=B(t.origin)??t.sourceLayer??t.layer;e&&"subtype-sublayer"!==e.type&&this.analysis.excludedLayers.push(e)}}else e.ground.layer?this.analysis.excludedLayers.push(e.ground.layer):this.analysis.excludeGroundSurface=!0;return this.stop(),!0}_onKeyDown(t){return(t.key===Y||t.key===Z)&&(this._activeKeyModifiers[t.key]=!0,null!=this._previewPlane&&this._updatePreviewPlane(this._lastCursorPosition,this._activeKeyModifiers),!0)}_onKeyUp(t){return!(t.key!==Y&&t.key!==Z||!this._activeKeyModifiers[t.key])&&(delete this._activeKeyModifiers[t.key],null!=this._previewPlane&&this._updatePreviewPlane(this._lastCursorPosition,this._activeKeyModifiers),!0)}_onShiftGrab(t){if("start"!==t.action||null==this.analysisViewData.plane||!t.screenPoint)return;const e=yt(this.view.state.camera,t.screenPoint,kt);j(this.analysisViewData.plane,this._startPlane),this.inputState=bt(e,null,this.shiftManipulator.renderLocation,this.analysisViewData.plane)}_createShiftDragPipeline(t){return gt(t,(t,e,i)=>{const a=this.inputState;if(null==a||"shift"!==a.type)return;const s=null!=this.analysisViewData.plane?j(this.analysisViewData.plane,x()):null;e.next(Pt(this.view,a.shiftPlane)).next(this._shiftDragAdjustSensitivity(a)).next(this._shiftDragUpdatePlane(a)),i.next(()=>{null!=s&&this._updateBoundedPlane(s)})})}_shiftDragAdjustSensitivity(t){return e=>{if(null==this.analysisViewData.plane)return null;const i=.001,a=Math.min((1-Math.abs(P(E(this.analysisViewData.plane),e.ray.direction)/y(e.ray.direction)))/i,1),s=-H(this._startPlane.plane,e.renderEnd),n=-H(this._startPlane.plane,t.startPoint);return t.depth=t.depth*(1-a)+s*a-n,e}}_shiftDragUpdatePlane(t){return()=>{if(null==this.analysisViewData.plane)return;const e=w(G.get(),this._startPlane.origin),i=w(G.get(),E(this._startPlane));g(i,i,-t.depth),f(i,i,e);const a=C(i,this.analysisViewData.plane.basis1,this.analysisViewData.plane.basis2,x());this._updateBoundedPlane(a)}}_onRotateHeadingGrab(t){if("start"!==t.action||null==this.analysisViewData.plane||!t.screenPoint)return;const e=nt(this.analysisViewData.plane,this.view.renderCoordsHelper,1,R()),i=yt(this.view.state.camera,t.screenPoint,kt),a=b();I(e,i,a)&&(j(this.analysisViewData.plane,this._startPlane),this.inputState={type:"rotate",rotatePlane:e,startPoint:a})}_createRotateHeadingDragPipeline(t){return gt(t,(t,e,i)=>{const a=this.inputState;if(null==a||"rotate"!==a.type)return;const s=null!=this.analysisViewData.plane?j(this.analysisViewData.plane,x()):null;e.next(Pt(this.view,a.rotatePlane)).next(this._rotateDragRenderPlaneToRotate(a)).next(this._rotateDragUpdatePlaneFromRotate()),i.next(()=>{null!=s&&this._updateBoundedPlane(s)})})}_onRotateTiltGrab(t){if("start"!==t.action||null==this.analysisViewData.plane||!t.screenPoint)return;const e=nt(this.analysisViewData.plane,this.view.renderCoordsHelper,2,R()),i=yt(this.view.state.camera,t.screenPoint,kt),a=b();I(e,i,a)&&(j(this.analysisViewData.plane,this._startPlane),this.inputState={type:"rotate",rotatePlane:e,startPoint:a})}_createRotateTiltDragPipeline(t){return gt(t,(t,e,i)=>{const a=this.inputState;if(null==a||"rotate"!==a.type)return;const s=null!=this.analysisViewData.plane?j(this.analysisViewData.plane,x()):null;e.next(Pt(this.view,a.rotatePlane)).next(this._rotateDragRenderPlaneToRotate(a)).next(this._rotateDragUpdatePlaneFromRotate()),i.next(()=>{null!=s&&this._updateBoundedPlane(s)})})}_rotateDragRenderPlaneToRotate(t){return e=>{if(null==this.analysisViewData.plane)return null;const i=z(t.rotatePlane),a=mt(t.startPoint,e.renderEnd,this.analysisViewData.plane.origin,i);return{...e,rotateAxis:i,rotateAngle:a}}}_rotateDragUpdatePlaneFromRotate(){return t=>{if(null==this.analysisViewData.plane)return;const e=_(U.get(),t.rotateAngle,t.rotateAxis);if(null==e)return;const i=M(G.get(),this._startPlane.basis1,e),a=M(G.get(),this._startPlane.basis2,e),s=C(this.analysisViewData.plane.origin,i,a,x());this._updateBoundedPlane(s)}}_onResizeGrab(t,e){if("start"!==t.action||null==this.analysisViewData.plane||!t.screenPoint)return;const i=yt(this.view.state.camera,t.screenPoint,kt),a=G.get();I(this.analysisViewData.plane.plane,i,a)&&(j(this.analysisViewData.plane,this._startPlane),this.inputState={type:"resize",activeHandleIdx:e,startPoint:T(a)})}_createResizeDragPipeline(t){return gt(t,(t,e,i)=>{const a=this.inputState;if(null==a||"resize"!==a.type||null==this.analysisViewData.plane)return;const s=j(this.analysisViewData.plane,x());e.next(Pt(this.view,this.analysisViewData.plane.plane)).next(this._resizeDragUpdatePlane(a)),i.next(()=>{this._updateBoundedPlane(s)})})}_resizeDragUpdatePlane(t){return e=>{if(null==this.analysisViewData.plane)return;const i=this._resizeHandles[t.activeHandleIdx],a=rt(i,t.startPoint,e.renderEnd,this.view.state.camera,this._startPlane,j(this.analysisViewData.plane));this._updateBoundedPlane(a)}}_updateBoundedPlane(t){const e=this.analysisViewData;if(null==e)throw new Error("valid internal object expected");e.plane=t}_updatePreviewPlane(t,e={}){if("exclude"===this.mode)return;let i=this._previewPlane;if(this._previewPlane=null,null==t)return this._removeFrameTask(),void this._updateManipulators();if(this.active){const a=null!=i?i:x();if(i=null!=i?j(i,St):null,this._pickPlane(t,!0,e,a)){const t=tt;let e=!1;null!=i&&(e=P(z(i.plane),z(a.plane))<t||P(D(G.get(),i.basis1),D(G.get(),a.basis1))<t),e&&(this._previewPlaneOpacity=0),this._previewPlane=a}}null!=this._previewPlane&&null==this._frameTask&&0===this._previewPlaneOpacity?this._frameTask=h({update:({deltaTime:t})=>{this._previewPlaneOpacity=Math.min(this._previewPlaneOpacity+t/(1e3*$),1),this._updateManipulators(),1===this._previewPlaneOpacity&&this._removeFrameTask()}}):null==this._previewPlane&&null!=this._frameTask?this._removeFrameTask():null!=this._previewPlane&&this._updateManipulators()}_removeFrameTask(){this._frameTask=s(this._frameTask)}_pickMinResult(t){const e=u(t,K.get());return this.view.sceneIntersectionHelper.intersectToolIntersectorScreen(e,this._intersector),this._intersector.results.min}_pickPlane(t,e,i,a){const s=this._pickMinResult(t),n=G.get();if(!s.getIntersectionPoint(n))return!1;const r=s.getTransformedNormal(G.get()),l=this.view.state.camera;P(r,l.viewForward)>0&&g(r,r,-1);const o=lt(n,l),h=(e?1:-1)*o*et,p=g(G.get(),r,h);f(p,p,n);const u=this.analysis.tiltEnabled?3:0,c=i[Y]?2:i[Z]?1:u;return ot(p,r,o,o,l,c,this.view.renderCoordsHelper,a),!0}_clearPointerMoveTimeout(){this._prevPointerMoveTimeout=s(this._prevPointerMoveTimeout)}_resetPointerMoveTimeout(){this._clearPointerMoveTimeout(),this.shiftManipulator.state|=ht,this.rotateHeadingManipulator.state|=ht,this.rotateTiltManipulator.state|=ht,this._prevPointerMoveTimeout=this._clock.setTimeout(()=>{this.shiftManipulator.state&=~ht,this.rotateHeadingManipulator.state&=~ht,this.rotateTiltManipulator.state&=~ht},this._pointerMoveTimerMs)}_updateManipulators(){if(Dt.disableEngineLayers)return;let t,e,i=!1;if(null!=this.analysisViewData.plane)t=this.analysisViewData.plane,e=this._previewPlane??t,i=!1;else{if(null==this._previewPlane)return this._setManipulatorVisibility(!1),void this._setPreviewPlaneVisibility(!1);e=t=this._previewPlane,i=!0}if(this._setManipulatorVisibility(!i),!i){const e=pt(t,U.get());ut(this.shiftManipulator,e,t,this.view.state.camera),ct(this.rotateHeadingManipulator,e,t,this.view.renderCoordsHelper),dt(this.rotateTiltManipulator,e,t),this.resizeManipulators.forEach((i,a)=>_t(i,this._resizeHandles[a],e,t))}this._setPreviewPlaneVisibility(!this._creatingPointerId&&(i||"place"===this._mode)),this._updatePreviewPlaneTransform(e),this._updateMaterials()}_setManipulatorVisibility(t){this.shiftManipulator.available=t,this.rotateHeadingManipulator.available=t,this.rotateTiltManipulator.available=t&&this.analysis.tiltEnabled,this.resizeManipulators.forEach(e=>e.available=t)}_updatePreviewPlaneTransform(t){const e=pt(t,U.get()),i=V(G.get(),y(t.basis1),y(t.basis2),1),a=v(U.get(),i),s=m(a,e,a);this._previewPlaneOutlineVisualElement.transform=s,this._previewPlaneGridVisualElement.transform=s}_setPreviewPlaneVisibility(t){const e=this._previewPlaneOutlineVisualElement,i=this._previewPlaneGridVisualElement;t&&(e.attached=!0,i.attached=!0),e.visible=t,i.visible=t}_updateMaterials(){const t=N(this.view.effectiveTheme);t[3]*=this._previewPlaneOpacity;const e=S(J);e[3]*=this._previewPlaneOpacity,this._previewPlaneOutlineVisualElement.color=t,this._previewPlaneGridVisualElement.backgroundColor=e,this._previewPlaneGridVisualElement.gridColor=k}_updateManipulatorsInteractive(t){if(!t.grabbing)return this.shiftManipulator.interactive=!0,this.rotateHeadingManipulator.interactive=!0,this.rotateTiltManipulator.interactive=!0,void this.resizeManipulators.forEach(t=>{t.interactive=!0});this.shiftManipulator.interactive=this.shiftManipulator===t,this.rotateHeadingManipulator.interactive=this.rotateHeadingManipulator===t,this.rotateTiltManipulator.interactive=this.rotateTiltManipulator===t,this.resizeManipulators.forEach(e=>{e.interactive=e===t})}_finishToolCreationIfValid(){this.analysis.valid&&this.finishToolCreation()}get test(){return{plane:this.analysisViewData.plane,setPointerMoveTimerMs:t=>{this._pointerMoveTimerMs=t}}}};function bt(t,e,i,a){const s=vt(i,E(a),t.direction,R()),n=b();return I(s,t,n)?{type:"shift",creatingPointerId:e,hasBeenDragged:!1,shiftPlane:s,depth:0,startPoint:n}:null}function Tt(t){return"mouse"!==t.pointerType||0===t.button}t([c()],Vt.prototype,"_clock",void 0),t([c({constructOnly:!0})],Vt.prototype,"view",void 0),t([c()],Vt.prototype,"analysisViewData",void 0),t([c({readOnly:!0})],Vt.prototype,"state",null),t([c({readOnly:!0})],Vt.prototype,"cursor",null),t([c()],Vt.prototype,"analysis",null),t([c()],Vt.prototype,"removeIncompleteOnCancel",void 0),t([c()],Vt.prototype,"_mode",void 0),t([c()],Vt.prototype,"mode",null),t([c({value:null})],Vt.prototype,"inputState",null),t([c()],Vt.prototype,"_placingSlicePlane",null),t([c()],Vt.prototype,"_creatingPointerId",null),Vt=Dt=t([d("esri.views.3d.analysis.Slice.SliceTool")],Vt);const St=x(),kt=O();export{Vt as default};
5
+ import{__decorate as t}from"tslib";import e from"../../../../analysis/SlicePlane.js";import{clock as i}from"../../../../core/clock.js";import{destroyMaybe as a,removeMaybe as s}from"../../../../core/maybe.js";import{watch as n,sync as r,when as l,syncAndInitial as o}from"../../../../core/reactiveUtils.js";import{addFrameTask as h}from"../../../../core/scheduling.js";import{createScreenPoint as p,screenPointObjectToArray as u}from"../../../../core/screenUtils.js";import{property as c}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/Logger.js";import"../../../../core/RandomLCG.js";import{subclass as d}from"../../../../core/accessorSupport/decorators/subclass.js";import{fromRotation as _,fromScaling as v,multiply as m}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{f as y,b as P,d as w,h as f,g,t as M,n as V,j as b}from"../../../../chunks/vec32.js";import{create as D,clone as T}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{clone as k,ZEROS as S}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{a as x,d as j,n as E,f as C}from"../../../../chunks/boundedPlane.js";import{signedDistance as H,create as R,intersectRay as z,getNormal as O}from"../../../../geometry/support/plane.js";import{create as G}from"../../../../geometry/support/ray.js";import{sv3d as U,sm4d as I,sv2d as K}from"../../../../geometry/support/vectorStacks.js";import{getSliceableContainer as A}from"../../../../graphic/getSliceableContainer.js";import{getRotateHeadingTexture as F,getTiltRotateTexture as L}from"../images/Factory.js";import{ResizeManipulator as B}from"./ResizeManipulator.js";import{RotateManipulator as q}from"./RotateManipulator.js";import{getOutlineColor as N,planeColor as J}from"./settings.js";import{ShiftManipulator as Q}from"./ShiftManipulator.js";import{pointerMoveTimerMs as W,planePreviewOutlineWidth as X,forceVerticalModifier as Y,forceHorizontalModifier as Z,previewFadeDurationSeconds as $,previewFadeDotThreshold as tt,initialDepthOffsetFrac as et}from"./sliceToolConfig.js";import{createGridVisualElement as it,createOutlineVisualElement as at,planeToShape as st,createRotatePlane as nt,resizePlane as rt,calculatePlaneHalfSize as lt,createPlane as ot,DidPointerMoveRecentlyFlag as ht,calculateBoundedPlaneTranslateRotate as pt,updateShiftRestartHandle as ut,updateRotateHeadingHandle as ct,updateRotateTiltHandle as dt,updateResizeHandle as _t,createShiftPlane as vt}from"./sliceToolUtils.js";import{calculateInputRotationTransform as mt}from"../../interactive/manipulatorUtils.js";import{screenToRenderPlane as yt}from"../../interactive/editingTools/dragEventPipeline3D.js";import{fromScreenNormalized as Pt}from"../../support/geometryUtils/ray.js";import{AnalysisToolBase as wt}from"../../../interactive/AnalysisToolBase.js";import{createManipulatorDragEventPipeline as ft}from"../../../interactive/dragEventPipeline.js";import{newToolIntersector as gt}from"../../../interactive/ToolIntersector.js";import{createScreenPointFromEvent as Mt}from"../../../support/screenUtils.js";var Vt;let bt=class extends wt{static{Vt=this}constructor(t){super(t),this._clock=i,this._previewPlaneOpacity=1,this.removeIncompleteOnCancel=!1,this._mode="none",this.shiftManipulator=null,this.rotateHeadingManipulator=null,this.rotateTiltManipulator=null,this.resizeManipulators=null,this._frameTask=null,this._pointerMoveTimerMs=W,this._prevPointerMoveTimeout=null,this._previewPlaneGridVisualElement=null,this._previewPlaneOutlineVisualElement=null,this._startPlane=x(),this._previewPlane=null,this._activeKeyModifiers={},this._lastCursorPosition=p(),this._resizeHandles=[{direction:[1,0]},{direction:[1,1]},{direction:[0,1]},{direction:[-1,1]},{direction:[-1,0]},{direction:[-1,-1]},{direction:[0,-1]},{direction:[1,-1]}],this._intersector=gt(t.view.state.viewingMode)}initialize(){if(null==this.analysis)throw new Error("SliceTool requires valid analysis, but null was provided.");const t=t=>{this._updateManipulatorsInteractive(t),t.grabbing||(null!=this.analysisViewData.plane&&j(this.analysisViewData.plane,this._startPlane),this.inputState=null)},e=new Q(this.view,1);this.shiftManipulator=e,this.manipulators.add(e),this.addHandles([this._createShiftDragPipeline(e),e.events.on("grab-changed",i=>{this._onShiftGrab(i),t(e)})]);const i=!this.view.stage?.renderView.renderingContext.driverTest.svgPremultipliesAlpha.result,a=new q(this.view,(t,e)=>F(this.view.stage.textures,{accentColor:t,contrastColor:e,preMultiplyAlpha:i}));this.rotateHeadingManipulator=a,this.manipulators.add(a),this.addHandles([this._createRotateHeadingDragPipeline(a),a.events.on("grab-changed",e=>{this._onRotateHeadingGrab(e),t(a)})]);const s=new q(this.view,(t,e)=>L(this.view.stage.textures,{accentColor:t,contrastColor:e,preMultiplyAlpha:i}));this.rotateTiltManipulator=s,this.manipulators.add(s),this.addHandles([this._createRotateTiltDragPipeline(s),s.events.on("grab-changed",e=>{this._onRotateTiltGrab(e),t(s)})]),this.resizeManipulators=this._resizeHandles.map((e,i)=>{const a=new B(this.view,e);return this.addHandles([this._createResizeDragPipeline(a),a.events.on("grab-changed",e=>{this._onResizeGrab(e,i),t(a)})]),a}),this.manipulators.addMany(this.resizeManipulators),this._previewPlaneGridVisualElement=it(this.view),this._previewPlaneOutlineVisualElement=at(this.view),this._previewPlaneOutlineVisualElement.width=X,this.addHandles(n(()=>[this.analysisViewData.plane,this.analysis.tiltEnabled],()=>this._updateManipulators(),r)),this.addHandles([l(()=>"sliced"===this.state,()=>{this.finishToolCreation(),this.stop()},o),n(()=>this.view.state.camera,()=>this._onCameraChange())])}destroy(){this._removeFrameTask(),this._clearPointerMoveTimeout(),this._previewPlaneOutlineVisualElement=a(this._previewPlaneOutlineVisualElement),this._previewPlaneGridVisualElement=a(this._previewPlaneGridVisualElement)}get state(){const t=!!this.analysisViewData.plane,e=!!this.inputState;return t?t&&e?"slicing":t&&!e?"sliced":"ready":"ready"}get cursor(){return this.active&&(this._placingSlicePlane||"exclude"===this.mode)?"crosshair":null}set analysis(t){if(null==t)throw new Error("SliceTool requires valid analysis, but null was provided.");this.removeHandles("analysis"),this._set("analysis",t)}get mode(){return this._mode}static{this.disableEngineLayers=!1}get inputState(){return this._get("inputState")}set inputState(t){this._set("inputState",t),this.analysisViewData.showGrid=null!=t&&"resize"===t.type,this._updateMaterials()}get _placingSlicePlane(){return this.active&&!this.inputState&&"place"===this._mode}start(t){this._finishToolCreationIfValid(),this._mode=t,this.active||(this.view.activeTool=this)}stop(){this.active&&(this.view.activeTool=null)}onActivate(){this._finishToolCreationIfValid(),"none"===this._mode&&null==this.analysisViewData.plane&&(this._mode="place")}onDeactivate(){this._mode="none",this._updatePreviewPlane(null)}onShow(){this._updateVisibility(!0)}onHide(){this._updateVisibility(!1)}_updateVisibility(t){this._updateManipulators(),t||this._clearPointerMoveTimeout()}onInputEvent(t){switch(t.type){case"pointer-move":this._onPointerMove(t);break;case"immediate-click":if(!Tt(t))return;"exclude"===this._mode?t.defer(async()=>{await this._onClickExcludeLayer(t)&&t.stopPropagation()}):this._onClickPlacePlane(t)&&t.stopPropagation();break;case"drag":this.inputState&&t.stopPropagation();break;case"key-down":this._onKeyDown(t)&&t.stopPropagation();break;case"key-up":this._onKeyUp(t)&&t.stopPropagation()}}onEditableChange(){this.analysisViewData.editable=this.internallyEditable}_onPointerMove(t){this._lastCursorPosition.x=t.x,this._lastCursorPosition.y=t.y,this._resetPointerMoveTimeout(),"touch"!==t.pointerType&&this._updatePreviewPlane(Mt(t),this._activeKeyModifiers)}_onCameraChange(){this._updatePreviewPlane(this._lastCursorPosition,this._activeKeyModifiers),this._updateManipulators()}_onClickPlacePlane(t){if(!this._placingSlicePlane)return!1;const i=Mt(t),a=x();return!!this._pickPlane(i,!1,this._activeKeyModifiers,a)&&(j(a,this._startPlane),this.analysis.shape=st(a,this.view,this.view.spatialReference,new e),this.stop(),!0)}async _onClickExcludeLayer(t){if("exclude"!==this.mode)return!1;const e=await this.view.hitTest(Mt(t)),i=e.results.at(0);if(i){const t="graphic"===i.type&&i.graphic;if(t){const e=A(t.origin)??t.sourceLayer??t.layer;e&&"subtype-sublayer"!==e.type&&this.analysis.excludedLayers.push(e)}}else e.ground.layer?this.analysis.excludedLayers.push(e.ground.layer):this.analysis.excludeGroundSurface=!0;return this.stop(),!0}_onKeyDown(t){return(t.key===Y||t.key===Z)&&(this._activeKeyModifiers[t.key]=!0,null!=this._previewPlane&&this._updatePreviewPlane(this._lastCursorPosition,this._activeKeyModifiers),!0)}_onKeyUp(t){return!(t.key!==Y&&t.key!==Z||!this._activeKeyModifiers[t.key])&&(delete this._activeKeyModifiers[t.key],null!=this._previewPlane&&this._updatePreviewPlane(this._lastCursorPosition,this._activeKeyModifiers),!0)}_onShiftGrab(t){if("start"!==t.action||null==this.analysisViewData.plane||!t.screenPoint)return;const e=Pt(this.view.state.camera,t.screenPoint,St);j(this.analysisViewData.plane,this._startPlane),this.inputState=Dt(e,this.shiftManipulator.renderLocation,this.analysisViewData.plane)}_createShiftDragPipeline(t){return ft(t,(t,e,i)=>{const a=this.inputState;if(null==a||"shift"!==a.type)return;const s=null!=this.analysisViewData.plane?j(this.analysisViewData.plane,x()):null;e.next(yt(this.view,a.shiftPlane)).next(this._shiftDragAdjustSensitivity(a)).next(this._shiftDragUpdatePlane(a)),i.next(()=>{null!=s&&this._updateBoundedPlane(s)})})}_shiftDragAdjustSensitivity(t){return e=>{if(null==this.analysisViewData.plane)return null;const i=.001,a=Math.min((1-Math.abs(y(E(this.analysisViewData.plane),e.ray.direction)/P(e.ray.direction)))/i,1),s=-H(this._startPlane.plane,e.renderEnd),n=-H(this._startPlane.plane,t.startPoint);return t.depth=t.depth*(1-a)+s*a-n,e}}_shiftDragUpdatePlane(t){return()=>{if(null==this.analysisViewData.plane)return;const e=w(U.get(),this._startPlane.origin),i=w(U.get(),E(this._startPlane));f(i,i,-t.depth),g(i,i,e);const a=C(i,this.analysisViewData.plane.basis1,this.analysisViewData.plane.basis2,x());this._updateBoundedPlane(a)}}_onRotateHeadingGrab(t){if("start"!==t.action||null==this.analysisViewData.plane||!t.screenPoint)return;const e=nt(this.analysisViewData.plane,this.view.renderCoordsHelper,1,R()),i=Pt(this.view.state.camera,t.screenPoint,St),a=D();z(e,i,a)&&(j(this.analysisViewData.plane,this._startPlane),this.inputState={type:"rotate",rotatePlane:e,startPoint:a})}_createRotateHeadingDragPipeline(t){return ft(t,(t,e,i)=>{const a=this.inputState;if(null==a||"rotate"!==a.type)return;const s=null!=this.analysisViewData.plane?j(this.analysisViewData.plane,x()):null;e.next(yt(this.view,a.rotatePlane)).next(this._rotateDragRenderPlaneToRotate(a)).next(this._rotateDragUpdatePlaneFromRotate()),i.next(()=>{null!=s&&this._updateBoundedPlane(s)})})}_onRotateTiltGrab(t){if("start"!==t.action||null==this.analysisViewData.plane||!t.screenPoint)return;const e=nt(this.analysisViewData.plane,this.view.renderCoordsHelper,2,R()),i=Pt(this.view.state.camera,t.screenPoint,St),a=D();z(e,i,a)&&(j(this.analysisViewData.plane,this._startPlane),this.inputState={type:"rotate",rotatePlane:e,startPoint:a})}_createRotateTiltDragPipeline(t){return ft(t,(t,e,i)=>{const a=this.inputState;if(null==a||"rotate"!==a.type)return;const s=null!=this.analysisViewData.plane?j(this.analysisViewData.plane,x()):null;e.next(yt(this.view,a.rotatePlane)).next(this._rotateDragRenderPlaneToRotate(a)).next(this._rotateDragUpdatePlaneFromRotate()),i.next(()=>{null!=s&&this._updateBoundedPlane(s)})})}_rotateDragRenderPlaneToRotate(t){return e=>{if(null==this.analysisViewData.plane)return null;const i=O(t.rotatePlane),a=mt(t.startPoint,e.renderEnd,this.analysisViewData.plane.origin,i);return{...e,rotateAxis:i,rotateAngle:a}}}_rotateDragUpdatePlaneFromRotate(){return t=>{if(null==this.analysisViewData.plane)return;const e=_(I.get(),t.rotateAngle,t.rotateAxis);if(null==e)return;const i=M(U.get(),this._startPlane.basis1,e),a=M(U.get(),this._startPlane.basis2,e),s=C(this.analysisViewData.plane.origin,i,a,x());this._updateBoundedPlane(s)}}_onResizeGrab(t,e){if("start"!==t.action||null==this.analysisViewData.plane||!t.screenPoint)return;const i=Pt(this.view.state.camera,t.screenPoint,St),a=U.get();z(this.analysisViewData.plane.plane,i,a)&&(j(this.analysisViewData.plane,this._startPlane),this.inputState={type:"resize",activeHandleIdx:e,startPoint:T(a)})}_createResizeDragPipeline(t){return ft(t,(t,e,i)=>{const a=this.inputState;if(null==a||"resize"!==a.type||null==this.analysisViewData.plane)return;const s=j(this.analysisViewData.plane,x());e.next(yt(this.view,this.analysisViewData.plane.plane)).next(this._resizeDragUpdatePlane(a)),i.next(()=>{this._updateBoundedPlane(s)})})}_resizeDragUpdatePlane(t){return e=>{if(null==this.analysisViewData.plane)return;const i=this._resizeHandles[t.activeHandleIdx],a=rt(i,t.startPoint,e.renderEnd,this.view.state.camera,this._startPlane,j(this.analysisViewData.plane));this._updateBoundedPlane(a)}}_updateBoundedPlane(t){const e=this.analysisViewData;if(null==e)throw new Error("valid internal object expected");e.plane=t}_updatePreviewPlane(t,e={}){if("exclude"===this.mode)return;let i=this._previewPlane;if(this._previewPlane=null,null==t)return this._removeFrameTask(),void this._updateManipulators();if(this.active){const a=null!=i?i:x();if(i=null!=i?j(i,kt):null,this._pickPlane(t,!0,e,a)){const t=tt;let e=!1;null!=i&&(e=y(O(i.plane),O(a.plane))<t||y(V(U.get(),i.basis1),V(U.get(),a.basis1))<t),e&&(this._previewPlaneOpacity=0),this._previewPlane=a}}null!=this._previewPlane&&null==this._frameTask&&0===this._previewPlaneOpacity?this._frameTask=h({update:({deltaTime:t})=>{this._previewPlaneOpacity=Math.min(this._previewPlaneOpacity+t/(1e3*$),1),this._updateManipulators(),1===this._previewPlaneOpacity&&this._removeFrameTask()}}):null==this._previewPlane&&null!=this._frameTask?this._removeFrameTask():null!=this._previewPlane&&this._updateManipulators()}_removeFrameTask(){this._frameTask=s(this._frameTask)}_pickMinResult(t){const e=u(t,K.get());return this.view.sceneIntersectionHelper.intersectToolIntersectorScreen(e,this._intersector),this._intersector.results.min}_pickPlane(t,e,i,a){const s=this._pickMinResult(t),n=U.get();if(!s.getIntersectionPoint(n))return!1;const r=s.getTransformedNormal(U.get()),l=this.view.state.camera;y(r,l.viewForward)>0&&f(r,r,-1);const o=lt(n,l),h=(e?1:-1)*o*et,p=f(U.get(),r,h);g(p,p,n);const u=this.analysis.tiltEnabled?3:0,c=i[Y]?2:i[Z]?1:u;return ot(p,r,o,o,l,c,this.view.renderCoordsHelper,a),!0}_clearPointerMoveTimeout(){this._prevPointerMoveTimeout=s(this._prevPointerMoveTimeout)}_resetPointerMoveTimeout(){this._clearPointerMoveTimeout(),this.shiftManipulator.state|=ht,this.rotateHeadingManipulator.state|=ht,this.rotateTiltManipulator.state|=ht,this._prevPointerMoveTimeout=this._clock.setTimeout(()=>{this.shiftManipulator.state&=~ht,this.rotateHeadingManipulator.state&=~ht,this.rotateTiltManipulator.state&=~ht},this._pointerMoveTimerMs)}_updateManipulators(){if(Vt.disableEngineLayers)return;let t,e,i=!1;if(null!=this.analysisViewData.plane)t=this.analysisViewData.plane,e=this._previewPlane??t,i=!1;else{if(null==this._previewPlane)return this._setManipulatorVisibility(!1),void this._setPreviewPlaneVisibility(!1);e=t=this._previewPlane,i=!0}if(this._setManipulatorVisibility(!i),!i){const e=pt(t,I.get());ut(this.shiftManipulator,e,t,this.view.state.camera),ct(this.rotateHeadingManipulator,e,t,this.view.renderCoordsHelper),dt(this.rotateTiltManipulator,e,t),this.resizeManipulators.forEach((i,a)=>_t(i,this._resizeHandles[a],e,t))}this._setPreviewPlaneVisibility(i||"place"===this._mode),this._updatePreviewPlaneTransform(e),this._updateMaterials()}_setManipulatorVisibility(t){this.shiftManipulator.available=t,this.rotateHeadingManipulator.available=t,this.rotateTiltManipulator.available=t&&this.analysis.tiltEnabled,this.resizeManipulators.forEach(e=>e.available=t)}_updatePreviewPlaneTransform(t){const e=pt(t,I.get()),i=b(U.get(),P(t.basis1),P(t.basis2),1),a=v(I.get(),i),s=m(a,e,a);this._previewPlaneOutlineVisualElement.transform=s,this._previewPlaneGridVisualElement.transform=s}_setPreviewPlaneVisibility(t){const e=this._previewPlaneOutlineVisualElement,i=this._previewPlaneGridVisualElement;t&&(e.attached=!0,i.attached=!0),e.visible=t,i.visible=t}_updateMaterials(){const t=N(this.view.effectiveTheme);t[3]*=this._previewPlaneOpacity;const e=k(J);e[3]*=this._previewPlaneOpacity,this._previewPlaneOutlineVisualElement.color=t,this._previewPlaneGridVisualElement.backgroundColor=e,this._previewPlaneGridVisualElement.gridColor=S}_updateManipulatorsInteractive(t){if(!t.grabbing)return this.shiftManipulator.interactive=!0,this.rotateHeadingManipulator.interactive=!0,this.rotateTiltManipulator.interactive=!0,void this.resizeManipulators.forEach(t=>{t.interactive=!0});this.shiftManipulator.interactive=this.shiftManipulator===t,this.rotateHeadingManipulator.interactive=this.rotateHeadingManipulator===t,this.rotateTiltManipulator.interactive=this.rotateTiltManipulator===t,this.resizeManipulators.forEach(e=>{e.interactive=e===t})}_finishToolCreationIfValid(){this.analysis.valid&&this.finishToolCreation()}get test(){return{plane:this.analysisViewData.plane,setPointerMoveTimerMs:t=>{this._pointerMoveTimerMs=t}}}};function Dt(t,e,i){const a=vt(e,E(i),t.direction,R()),s=D();return z(a,t,s)?{type:"shift",shiftPlane:a,depth:0,startPoint:s}:null}function Tt(t){return"mouse"!==t.pointerType||0===t.button}t([c()],bt.prototype,"_clock",void 0),t([c({constructOnly:!0})],bt.prototype,"view",void 0),t([c()],bt.prototype,"analysisViewData",void 0),t([c({readOnly:!0})],bt.prototype,"state",null),t([c({readOnly:!0})],bt.prototype,"cursor",null),t([c()],bt.prototype,"analysis",null),t([c()],bt.prototype,"removeIncompleteOnCancel",void 0),t([c()],bt.prototype,"_mode",void 0),t([c()],bt.prototype,"mode",null),t([c({value:null})],bt.prototype,"inputState",null),t([c()],bt.prototype,"_placingSlicePlane",null),bt=Vt=t([d("esri.views.3d.analysis.Slice.SliceTool")],bt);const kt=x(),St=G();export{bt as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import{volumeMeasurementConfiguration as r}from"../../../../analysis/VolumeMeasurement/volumeMeasurementConfiguration.js";import t from"../../../../core/Accessor.js";import{property as o}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/Logger.js";import"../../../../core/RandomLCG.js";import{subclass as n}from"../../../../core/accessorSupport/decorators/subclass.js";import{j as s}from"../../../../chunks/vec32.js";import{create as i}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as a,fromExtent as c,width as p,height as d,expand as l}from"../../../../geometry/support/aaBoundingRect.js";import{vectorCoordinates as m}from"../../../../geometry/support/coordinateSystem.js";let u=class extends t{constructor(e){super(e),this.rawResult=null}get localOriginRenderSpace(){const{extent:e,localOrigin:r,renderCoordsHelper:t}=this,o=i();return t.toRenderCoords(r,e.spatialReference,o),o}get cameraPositionRenderSpace(){const{localOriginRenderSpace:e,renderCoordsHelper:r}=this,t=i(),o=1/r.unitInMeters;return r.setAltitude(t,R*o,e),t}get boundingRect(){const{extent:e,renderCoordsHelper:r}=this,t=a();return 2===r.viewingMode?c(e,t):(this._expandBoundingRect(e.xmin,e.ymin,t),this._expandBoundingRect(e.xmax,e.ymin,t),this._expandBoundingRect(e.xmin,e.ymax,t),this._expandBoundingRect(e.xmax,e.ymax,t)),t}get cameraDimensions(){const{boundingRect:e}=this;return{width:p(e),height:d(e)}}get cameraNearFar(){const{renderCoordsHelper:{unitInMeters:e}}=this,r=1/e;return{near:x*r,far:y*r}}get upVector(){return this.renderCoordsHelper.worldBasisAtPosition(this.cameraPositionRenderSpace,2,i())}get northVector(){return this.renderCoordsHelper.worldBasisAtPosition(this.cameraPositionRenderSpace,1,i())}get eastVector(){return this.renderCoordsHelper.worldBasisAtPosition(this.cameraPositionRenderSpace,0,i())}_expandBoundingRect(e,r,t){const{extent:o,eastVector:n,northVector:i,upVector:a,renderCoordsHelper:c}=this,p=o.center.z??0;s(g,e,r,p),c.toRenderCoords(g,o.spatialReference,g),m(g,n,i,a,h),l(t,h,t)}};e([o()],u.prototype,"renderCoordsHelper",void 0),e([o()],u.prototype,"extent",void 0),e([o()],u.prototype,"localOrigin",void 0),e([o()],u.prototype,"localOriginRenderSpace",null),e([o()],u.prototype,"cameraPositionRenderSpace",null),e([o()],u.prototype,"boundingRect",null),e([o()],u.prototype,"cameraDimensions",null),e([o()],u.prototype,"upVector",null),e([o()],u.prototype,"northVector",null),e([o()],u.prototype,"eastVector",null),e([o()],u.prototype,"rawResult",void 0),u=e([n("esri.views.3d.analysis.VolumeMeasurement.VolumeMeasurementCutFillComputation")],u);const g=i(),h=i(),R=r.maxTargetElevation,x=0,y=r.maxTargetElevation-r.minTargetElevation;export{u as VolumeMeasurementCutFillComputation};
5
+ import{__decorate as e}from"tslib";import{volumeMeasurementConfiguration as r}from"../../../../analysis/VolumeMeasurement/volumeMeasurementConfiguration.js";import t from"../../../../core/Accessor.js";import{property as o}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/Logger.js";import"../../../../core/RandomLCG.js";import{subclass as n}from"../../../../core/accessorSupport/decorators/subclass.js";import{j as s}from"../../../../chunks/vec32.js";import{create as i}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as a,fromExtent as c,width as p,height as d,expand as l}from"../../../../geometry/support/aaBoundingRect.js";import{vectorCoordinates as m}from"../../../../geometry/support/coordinateSystem.js";let u=class extends t{constructor(e){super(e),this.rawResult=null}get localOriginRenderSpace(){const{extent:e,localOrigin:r,renderCoordsHelper:t}=this,o=i();return t.toRenderCoords(r,e.spatialReference,o),o}get cameraPositionRenderSpace(){const{localOriginRenderSpace:e,renderCoordsHelper:r}=this,t=i(),o=1/r.unitInMeters;return r.setAltitude(t,R*o,e),t}get boundingRect(){const{extent:e,renderCoordsHelper:r}=this,t=a();return 2===r.viewingMode?c(e,t):(this._expandBoundingRect(e.xmin,e.ymin,t),this._expandBoundingRect(e.xmax,e.ymin,t),this._expandBoundingRect(e.xmin,e.ymax,t),this._expandBoundingRect(e.xmax,e.ymax,t)),t}get cameraDimensions(){const{boundingRect:e}=this;return{width:p(e),height:d(e)}}get cameraNearFar(){const{renderCoordsHelper:{unitInMeters:e}}=this,r=1/e;return{near:x*r,far:y*r}}get upVector(){return this.renderCoordsHelper.worldBasisAtPosition(this.cameraPositionRenderSpace,2,i())}get northVector(){return this.renderCoordsHelper.worldBasisAtPosition(this.cameraPositionRenderSpace,1,i())}get eastVector(){return this.renderCoordsHelper.worldBasisAtPosition(this.cameraPositionRenderSpace,0,i())}_expandBoundingRect(e,r,t){const{extent:o,eastVector:n,northVector:i,upVector:a,renderCoordsHelper:c}=this,p=o.center.z??0;s(g,e,r,p),c.toRenderCoords(g,o.spatialReference,g),m(g,n,i,a,h),l(t,h,t)}};e([o()],u.prototype,"renderCoordsHelper",void 0),e([o()],u.prototype,"extent",void 0),e([o()],u.prototype,"localOrigin",void 0),e([o()],u.prototype,"localOriginRenderSpace",null),e([o()],u.prototype,"cameraPositionRenderSpace",null),e([o()],u.prototype,"boundingRect",null),e([o()],u.prototype,"cameraDimensions",null),e([o()],u.prototype,"upVector",null),e([o()],u.prototype,"northVector",null),e([o()],u.prototype,"eastVector",null),e([o()],u.prototype,"rawResult",void 0),u=e([n("esri.views.3d.analysis.VolumeMeasurement.VolumeMeasurementCutFillComputation")],u);const g=i(),h=i(),R=r.maxTargetElevation,x=0,y=r.targetElevationRange;export{u as VolumeMeasurementCutFillComputation};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import{volumeMeasurementConfiguration as t}from"../../../../analysis/VolumeMeasurement/volumeMeasurementConfiguration.js";import r from"../../../../core/Accessor.js";import o from"../../../../core/Logger.js";import{destroyMaybe as i}from"../../../../core/maybe.js";import{initial as n,watch as s,when as a,syncAndInitial as l,sync as p}from"../../../../core/reactiveUtils.js";import{createScreenPointArray as u}from"../../../../core/screenUtils.js";import{property as m}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/RandomLCG.js";import{subclass as c}from"../../../../core/accessorSupport/decorators/subclass.js";import{e as d}from"../../../../chunks/earcut.js";import{create as h}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{j as y,x as g}from"../../../../chunks/vec32.js";import{fromValues as _,create as f}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{UpdatingHandles as v}from"../../../../core/support/UpdatingHandles.js";import{projectOrLoad as j}from"../../../../geometry/projectionUtils.js";import{computeTranslationToOriginAndRotation as w}from"../../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{projectBoundingRect as E}from"../../../../geometry/projection/projectBoundingRect.js";import{empty as x,create as G,expand as R,width as b,height as L,fromExtent as V,intersects as T}from"../../../../geometry/support/aaBoundingRect.js";import{newDoubleArray as C}from"../../../../geometry/support/DoubleArray.js";import{t as M}from"../../../../chunks/vec3.js";import H from"../../../../symbols/support/ElevationInfo.js";import{logFailedGeometryProjectionError as P}from"../support/projectionUtils.js";import{VolumeMeasurementCutFillComputation as O}from"./VolumeMeasurementCutFillComputation.js";import{VolumeMeasurementDistanceTooCloseError as U,VolumeMeasurementDistanceTooFarError as D,VolumeMeasurementPerimeterTooLargeError as A,VolumeMeasurementUnsupportedCoordinateSystemError as S,VolumeMeasurementUnsupportedLayerTransparencyError as F}from"./volumeMeasurementErrors.js";import I from"./VolumeMeasurementResult.js";import{getRawResult as k}from"./volumeMeasurementUtils.js";import{ElevationContext as N}from"../../layers/graphics/ElevationContext.js";import{getElevationAtPoint as z}from"../../support/ElevationProvider.js";import{polygonToRenderInfo as W}from"../../support/renderInfoUtils/polygon.js";import{CutFillDepth as B,TargetGeometry as q}from"../../webgl-engine/lib/CutFillDepth.js";import{euclideanDirectDistance as J}from"../../../support/euclideanLengthMeasurementUtils.js";let K=class extends r{constructor(e){super(e),this._getElevationProvider=()=>this.view.elevationProvider,this._updatingHandles=new v,this._computationValue=null}initialize(){const e=this.view;this._renderer=new B({view:e}),this._updatingHandles.add(()=>({computation:this._computation,renderGeometry:this._renderGeometry}),({computation:e,renderGeometry:t})=>{e&&t&&(this._renderer.setup(e,t),this._renderer.start())},n),this.addHandles([this._createElevationUpdateHandle(),s(()=>this._targetGeometry,e=>this.analysisViewData.targetGeometry=e,l),s(()=>this._elevationAlignedGeometry,e=>this.analysisViewData.elevationAlignedGeometry=e,l),s(()=>({computation:this._computation,extent:this._projectedGeometry?.extent,localOrigin:this._renderGeometry?.localOrigin}),({computation:e,extent:t,localOrigin:r})=>{e&&t&&r&&(e.extent=t,e.localOrigin=r)},p),a(()=>this._renderer.done,()=>this._updateResult())])}destroy(){this._updatingHandles.destroy(),this._renderer.destroy()}get _projectedGeometry(){if(!this.analysis.valid)return null;const e=this.analysis.geometry,t=j(e,this.view.spatialReference);return t.pending?(this._updatingHandles.addPromise(t.pending),null):(e&&!t.geometry&&P(this.analysis,e.spatialReference,o.getLogger(this)),t.geometry)}get _elevationAlignedGeometry(){const e=this._projectedGeometry;if(!e)return null;const t=e.clone();return Q(this._getElevationProvider(),t),t}get _targetGeometry(){const e=this._elevationAlignedGeometry;if(!e)return null;const t=this.analysis.measureType,{effectiveTargetElevation:r}=this.analysisViewData;if("stockpile"===t||null==r)return e;const o=e.clone();return o.rings[0].forEach(e=>e[2]=r),o}get _renderGeometry(){const e=this._targetGeometry;if(!e)return null;const t=this._projectedGeometry?.extent;if(!t)return null;const{elevationProvider:r,renderCoordsHelper:o}=this.view;if(!r||!o)return null;const i=W(e,r,o,N.fromElevationInfo(new H({mode:"absolute-height"}))),{polygons:n}=i,s=n[0],a=d(s.position,s.holeIndices,3),l=C(3*s.count),p=h(),u=h(),m=_(t.center.x,t.center.y,0);return w(t.spatialReference,m,p,o.spatialReference),u[12]=-p[12],u[13]=-p[13],u[14]=-p[14],M(l,s.position,u),new q(m,l,a)}get updating(){return this._renderer.updating||this._updatingHandles.updating}get result(){const e=this._computation?.rawResult;return e?new I({measureType:this.analysis.measureType,rawResult:e,unit:this.analysisViewData.effectiveDisplayUnits.volume}):null}get error(){return this._unsupportedCoordinateSystemError??this._unsupportedLayerTransparencyError??this._perimeterTooLargeError??this._tooNearFarError}get _tooNearFarError(){const e=this._renderGeometry;if(!e)return null;const{view:r}=this,{camera:o}=r.state,{positions:i,localOrigin:n}=e;r.renderCoordsHelper.toRenderCoords(n,r.spatialReference,re),x(oe);for(let t=0;t<i.length;t+=3)o.projectToScreen(y(te,i[t]+re[0],i[t+1]+re[1],i[t+2]+re[2]),ie),R(oe,ie,oe);const s=b(oe),a=L(oe),{maxVolumeExtentSizeVw:l,minVolumeExtentSizePixels:p}=t;return s>o.width/o.pixelRatio*l||a>o.height/o.pixelRatio*l?new U:Math.max(s,a)<p?new D:null}get _perimeterTooLargeError(){return this._perimeterTooLargeLocalError??this._perimeterTooLargeGlobalError}get _perimeterTooLargeLocalError(){const{spatialReference:e,state:{isLocal:r}}=this.view;if(!r||!e.isWebMercator)return null;const o=this._perimeter,{maxPerimeterLocalWebMercator:i}=t;return null!=o&&o>i?new A:null}get _perimeterTooLargeGlobalError(){if(!this.view.state.isGlobal)return null;const e=this._perimeter,{maxPerimeterGlobal:r}=t;return null!=e&&e>r?new A:null}get _unsupportedCoordinateSystemError(){return this.view.state.isLocal&&this.view.spatialReference.isGeographic?new S:null}get _unsupportedLayerTransparencyError(){return(this.view.map?.ground.opacity??1)<1?new F:null}get _perimeter(){const e=this._renderGeometry?.positions,t=e?Y(Z(e)):null;return null!=t?t/this.view.renderCoordsHelper.unitInMeters:null}get _enabled(){return!this.error}get _computation(){const e=this._projectedGeometry?.extent;if(!e||!this._enabled)return this._computationValue=i(this._computationValue),null;if(this._computationValue)return this._computationValue;const t=this._renderGeometry?.localOrigin;if(!t)return null;const{renderCoordsHelper:r}=this.view;return this._computationValue=new O({extent:e,localOrigin:t,renderCoordsHelper:r}),this._computationValue}_createElevationUpdateHandle(){const e=e=>{const t=this._projectedGeometry?.extent;"ground"===e.context&&t&&(E(e.extent,e.spatialReference,$,this.view.spatialReference),V(t,ee),T($,ee)&&(this._getElevationProvider=()=>this.view.elevationProvider))};return this.view.elevationProvider.on("elevation-change",t=>e(t))}_updateResult(){if(!this._computation)return;const{spatialReference:e,viewingMode:t}=this.view,{extent:r,boundingRect:o,cameraNearFar:{near:i,far:n}}=this._computation,{width:s,height:a}=this._renderer;let l,p;"local"===t&&e.isWebMercator?({width:l,height:p}=X(r)):(l=b(o),p=L(o));const u=l/s*(p/a),m=this._renderer.getDepth(),c=e=>e*(n-i)+i,d=c(m.cut)*u,h=c(m.fill)*u;this._computation.rawResult=k(Math.abs(d),h)}};function Q(e,t){t.rings[0].forEach(t=>{t[2]=z(e,t,"ground")??0})}function X(e){const t=J([e.xmin,e.ymin,0],[e.xmax,e.ymin,0],e.spatialReference),r=J([e.xmin,e.ymin,0],[e.xmin,e.ymax,0],e.spatialReference);return{width:t?.value??0,height:r?.value??0}}function Y(e){if(!e)return null;let t=null,r=null,o=0;for(const i of e)t||(t=[i[0],i[1],i[2]??0]),r?o+=g(r,i):r=[0,0,0],r[0]=i[0],r[1]=i[1],r[2]=i[2];return t&&r&&(o+=g(r,t)),Math.sqrt(o)}function*Z(e){const t=f();for(let r=0;r<e.length;r+=3)t[0]=e[r],t[1]=e[r+1],t[2]=e[r+2],yield t}e([m()],K.prototype,"_projectedGeometry",null),e([m()],K.prototype,"_getElevationProvider",void 0),e([m()],K.prototype,"_elevationAlignedGeometry",null),e([m()],K.prototype,"_targetGeometry",null),e([m()],K.prototype,"_renderGeometry",null),e([m({constructOnly:!0})],K.prototype,"analysis",void 0),e([m({constructOnly:!0})],K.prototype,"analysisViewData",void 0),e([m({constructOnly:!0})],K.prototype,"view",void 0),e([m()],K.prototype,"updating",null),e([m()],K.prototype,"result",null),e([m()],K.prototype,"error",null),e([m()],K.prototype,"_tooNearFarError",null),e([m()],K.prototype,"_perimeterTooLargeError",null),e([m()],K.prototype,"_perimeterTooLargeLocalError",null),e([m()],K.prototype,"_perimeterTooLargeGlobalError",null),e([m()],K.prototype,"_unsupportedCoordinateSystemError",null),e([m()],K.prototype,"_unsupportedLayerTransparencyError",null),e([m()],K.prototype,"_perimeter",null),e([m()],K.prototype,"_enabled",null),e([m()],K.prototype,"_renderer",void 0),e([m({readOnly:!0})],K.prototype,"_updatingHandles",void 0),e([m()],K.prototype,"_computation",null),K=e([c("esri.views.3d.analysis.VolumeMeasurement.VolumeMeasurementCutFillController")],K);const $=x(),ee=x(),te=f(),re=f(),oe=G(),ie=u();export{K as VolumeMeasurementCutFillController};
5
+ import{__decorate as e}from"tslib";import{volumeMeasurementConfiguration as t}from"../../../../analysis/VolumeMeasurement/volumeMeasurementConfiguration.js";import r from"../../../../core/Accessor.js";import o from"../../../../core/Logger.js";import{destroyMaybe as i}from"../../../../core/maybe.js";import{initial as n,watch as s,when as a,syncAndInitial as l,sync as p}from"../../../../core/reactiveUtils.js";import{createScreenPointArray as u}from"../../../../core/screenUtils.js";import{property as m}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/RandomLCG.js";import{subclass as c}from"../../../../core/accessorSupport/decorators/subclass.js";import{e as d}from"../../../../chunks/earcut.js";import{create as h}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{j as g,x as y}from"../../../../chunks/vec32.js";import{fromValues as _,create as f}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{UpdatingHandles as v}from"../../../../core/support/UpdatingHandles.js";import{projectOrLoad as j}from"../../../../geometry/projectionUtils.js";import{computeTranslationToOriginAndRotation as w}from"../../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{projectBoundingRect as E}from"../../../../geometry/projection/projectBoundingRect.js";import{empty as x,create as G,expand as R,width as b,height as L,fromExtent as V,intersects as T}from"../../../../geometry/support/aaBoundingRect.js";import{newDoubleArray as M}from"../../../../geometry/support/DoubleArray.js";import{t as C}from"../../../../chunks/vec3.js";import H from"../../../../symbols/support/ElevationInfo.js";import{logFailedGeometryProjectionError as O}from"../support/projectionUtils.js";import{VolumeMeasurementCutFillComputation as P}from"./VolumeMeasurementCutFillComputation.js";import{VolumeMeasurementDistanceTooCloseError as U,VolumeMeasurementDistanceTooFarError as I,VolumeMeasurementPerimeterTooLargeError as A,VolumeMeasurementUnsupportedCoordinateSystemError as D,VolumeMeasurementUnsupportedLayerTransparencyError as S}from"./volumeMeasurementErrors.js";import F from"./VolumeMeasurementResult.js";import{getRawResult as k}from"./volumeMeasurementUtils.js";import{ElevationContext as N}from"../../layers/graphics/ElevationContext.js";import{getElevationAtPoint as z}from"../../support/ElevationProvider.js";import{polygonToRenderInfo as W}from"../../support/renderInfoUtils/polygon.js";import{CutFillDepth as B,TargetGeometryRenderInfo as q}from"../../webgl-engine/lib/CutFillDepth.js";import{euclideanDirectDistance as J}from"../../../support/euclideanLengthMeasurementUtils.js";let K=class extends r{constructor(e){super(e),this._getElevationProvider=()=>this.view.elevationProvider,this._updatingHandles=new v,this._computationValue=null}initialize(){const e=this.view;this._renderer=new B({view:e}),this._updatingHandles.add(()=>({computation:this._computation,renderGeometry:this._targetGeometryRenderInfo}),({computation:e,renderGeometry:t})=>{e&&t&&(this._renderer.setup(e,t),this._renderer.start())},n),this.addHandles([this._createElevationUpdateHandle(),s(()=>this._targetGeometry,e=>this.analysisViewData.targetGeometry=e,l),s(()=>this._elevationAlignedGeometry,e=>this.analysisViewData.elevationAlignedGeometry=e,l),s(()=>({computation:this._computation,extent:this._projectedGeometry?.extent,localOrigin:this._localOrigin}),({computation:e,extent:t,localOrigin:r})=>{e&&t&&r&&(e.extent=t,e.localOrigin=r)},p),a(()=>this._renderer.done,()=>this._updateResult())])}destroy(){this._updatingHandles.destroy(),this._renderer.destroy()}get _projectedGeometry(){if(!this.analysis.valid)return null;const e=this.analysis.geometry,t=j(e,this.view.spatialReference);return t.pending?(this._updatingHandles.addPromise(t.pending),null):(e&&!t.geometry&&O(this.analysis,e.spatialReference,o.getLogger(this)),t.geometry)}get _localOrigin(){const e=this._projectedGeometry?.extent;return e?_(e.center.x,e.center.y,0):null}get _elevationAlignedGeometry(){const e=this._projectedGeometry;if(!e)return null;const t=e.clone();return Q(this._getElevationProvider(),t),t}get _targetGeometry(){const e=this._elevationAlignedGeometry;if(!e)return null;const t=this.analysis.measureType,{effectiveTargetElevation:r}=this.analysisViewData;if("stockpile"===t||null==r)return e;const o=e.clone();return o.rings[0].forEach(e=>e[2]=r),o}get _targetGeometryRenderInfo(){const e=this._targetGeometry,t=this._projectedGeometry?.extent,r=this._localOrigin;if(!e||!t||!r)return null;const{elevationProvider:o,renderCoordsHelper:i}=this.view,n=W(e,o,i,N.fromElevationInfo(new H({mode:"absolute-height"}))),{polygons:s}=n,a=s[0],l=d(a.position,a.holeIndices,3),p=M(3*a.count),u=h(),m=h();return w(t.spatialReference,r,u,i.spatialReference),m[12]=-u[12],m[13]=-u[13],m[14]=-u[14],C(p,a.position,m),new q(p,l)}get updating(){return this._renderer.updating||this._updatingHandles.updating}get result(){const e=this._computation?.rawResult;return e?new F({measureType:this.analysis.measureType,rawResult:e,unit:this.analysisViewData.effectiveDisplayUnits.volume}):null}get error(){return this._unsupportedCoordinateSystemError??this._unsupportedLayerTransparencyError??this._perimeterTooLargeError??this._tooNearFarError}get _tooNearFarError(){const e=this._elevationAlignedGeometry;if(!e)return null;const{view:r}=this,{elevationProvider:o,renderCoordsHelper:i}=r,{camera:n}=r.state,s=W(e,o,i,N.fromElevationInfo(new H({mode:"absolute-height"}))),{polygons:a}=s,l=a[0].position;x(re);for(let t=0;t<l.length;t+=3)n.projectToScreen(g(te,l[t],l[t+1],l[t+2]),oe),R(re,oe,re);const p=b(re),u=L(re),{maxVolumeExtentSizeVw:m,minVolumeExtentSizePixels:c}=t;return p>n.width/n.pixelRatio*m||u>n.height/n.pixelRatio*m?new U:Math.max(p,u)<c?new I:null}get _perimeterTooLargeError(){return this._perimeterTooLargeLocalError??this._perimeterTooLargeGlobalError}get _perimeterTooLargeLocalError(){const{spatialReference:e,state:{isLocal:r}}=this.view;if(!r||!e.isWebMercator)return null;const o=this._perimeter,{maxPerimeterLocalWebMercator:i}=t;return null!=o&&o>i?new A:null}get _perimeterTooLargeGlobalError(){if(!this.view.state.isGlobal)return null;const e=this._perimeter,{maxPerimeterGlobal:r}=t;return null!=e&&e>r?new A:null}get _unsupportedCoordinateSystemError(){return this.view.state.isLocal&&this.view.spatialReference.isGeographic?new D:null}get _unsupportedLayerTransparencyError(){return(this.view.map?.ground.opacity??1)<1?new S:null}get _perimeter(){const e=this._targetGeometryRenderInfo?.positions,t=e?Y(Z(e)):null;return null!=t?t/this.view.renderCoordsHelper.unitInMeters:null}get _enabled(){return!this.error}get _computation(){const e=this._projectedGeometry?.extent;if(!e||!this._enabled)return this._computationValue=i(this._computationValue),null;if(this._computationValue)return this._computationValue;const t=this._localOrigin;if(!t)return null;const{renderCoordsHelper:r}=this.view;return this._computationValue=new P({extent:e,localOrigin:t,renderCoordsHelper:r}),this._computationValue}_createElevationUpdateHandle(){const e=e=>{const t=this._projectedGeometry?.extent;"ground"===e.context&&t&&(E(e.extent,e.spatialReference,$,this.view.spatialReference),V(t,ee),T($,ee)&&(this._getElevationProvider=()=>this.view.elevationProvider))};return this.view.elevationProvider.on("elevation-change",t=>e(t))}_updateResult(){if(!this._computation)return;const{spatialReference:e,viewingMode:t}=this.view,{extent:r,boundingRect:o,cameraNearFar:{near:i,far:n}}=this._computation,{width:s,height:a}=this._renderer;let l,p;"local"===t&&e.isWebMercator?({width:l,height:p}=X(r)):(l=b(o),p=L(o));const u=l/s*(p/a),m=this._renderer.getDepth(),c=e=>e*(n-i)+i,d=c(m.cut)*u,h=c(m.fill)*u;this._computation.rawResult=k(Math.abs(d),h)}};function Q(e,t){t.rings[0].forEach(t=>{t[2]=z(e,t,"ground")??0})}function X(e){const t=J([e.xmin,e.ymin,0],[e.xmax,e.ymin,0],e.spatialReference),r=J([e.xmin,e.ymin,0],[e.xmin,e.ymax,0],e.spatialReference);return{width:t?.value??0,height:r?.value??0}}function Y(e){if(!e)return null;let t=null,r=null,o=0;for(const i of e)t||(t=[i[0],i[1],i[2]??0]),r?o+=y(r,i):r=[0,0,0],r[0]=i[0],r[1]=i[1],r[2]=i[2];return t&&r&&(o+=y(r,t)),Math.sqrt(o)}function*Z(e){const t=f();for(let r=0;r<e.length;r+=3)t[0]=e[r],t[1]=e[r+1],t[2]=e[r+2],yield t}e([m()],K.prototype,"_projectedGeometry",null),e([m()],K.prototype,"_localOrigin",null),e([m()],K.prototype,"_getElevationProvider",void 0),e([m()],K.prototype,"_elevationAlignedGeometry",null),e([m()],K.prototype,"_targetGeometry",null),e([m()],K.prototype,"_targetGeometryRenderInfo",null),e([m({constructOnly:!0})],K.prototype,"analysis",void 0),e([m({constructOnly:!0})],K.prototype,"analysisViewData",void 0),e([m({constructOnly:!0})],K.prototype,"view",void 0),e([m()],K.prototype,"updating",null),e([m()],K.prototype,"result",null),e([m()],K.prototype,"error",null),e([m()],K.prototype,"_tooNearFarError",null),e([m()],K.prototype,"_perimeterTooLargeError",null),e([m()],K.prototype,"_perimeterTooLargeLocalError",null),e([m()],K.prototype,"_perimeterTooLargeGlobalError",null),e([m()],K.prototype,"_unsupportedCoordinateSystemError",null),e([m()],K.prototype,"_unsupportedLayerTransparencyError",null),e([m()],K.prototype,"_perimeter",null),e([m()],K.prototype,"_enabled",null),e([m()],K.prototype,"_renderer",void 0),e([m({readOnly:!0})],K.prototype,"_updatingHandles",void 0),e([m()],K.prototype,"_computation",null),K=e([c("esri.views.3d.analysis.VolumeMeasurement.VolumeMeasurementCutFillController")],K);const $=x(),ee=x(),te=f(),re=G(),oe=u();export{K as VolumeMeasurementCutFillController};