@arcgis/core 4.32.0-next.20250220 → 4.32.0-next.20250221

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 (110) hide show
  1. package/arcade/featureSetUtils.js +1 -1
  2. package/arcade/functions/featuresetbase.js +1 -1
  3. package/assets/esri/core/workers/RemoteClient.js +1 -1
  4. package/assets/esri/core/workers/chunks/37323e58dbec303f5054.js +1 -0
  5. package/assets/esri/core/workers/chunks/{7b07410fe98015b80c74.js → 5341b86c2fb5347393c5.js} +1 -1
  6. package/assets/esri/core/workers/chunks/60d5cbfa9e1c6b3c98df.js +1 -0
  7. package/assets/esri/core/workers/chunks/{a5acbdb8347a809a26c0.js → 610c3249fe81e370af8c.js} +1 -1
  8. package/assets/esri/core/workers/chunks/{d98c78e89d70ad0b8628.js → 6ab476f696290d190c6c.js} +1 -1
  9. package/assets/esri/core/workers/chunks/7292bb19b73f601d891b.js +1 -0
  10. package/assets/esri/core/workers/chunks/78c066e8fe167d4ab817.js +1 -0
  11. package/assets/esri/core/workers/chunks/80744ad7f7656ef918db.js +1 -0
  12. package/assets/esri/core/workers/chunks/8bbe8df40df2b8e54562.js +1 -0
  13. package/assets/esri/core/workers/chunks/caf410ed75c40b3703eb.js +1 -0
  14. package/assets/esri/core/workers/chunks/df506c4f81affce248c4.js +1 -0
  15. package/assets/esri/core/workers/chunks/{4be39bc2d2edd94bdb75.js → e481e7d508274bc83c70.js} +1 -1
  16. package/assets/esri/core/workers/chunks/eefa1dfeb63ce965bb40.js +1 -0
  17. package/assets/esri/core/workers/chunks/fd8790291348fb7ead55.js +1 -0
  18. package/assets/esri/themes/base/widgets/_ItemList.scss +14 -0
  19. package/assets/esri/themes/dark/main.css +1 -1
  20. package/assets/esri/themes/light/main.css +1 -1
  21. package/assets/esri/themes/light/view.css +1 -1
  22. package/core/sql/AggregateFunctions.js +1 -1
  23. package/core/sql/DateOnly.js +1 -1
  24. package/core/sql/SqlInterval.js +1 -1
  25. package/core/sql/SqlTimestampOffset.js +1 -1
  26. package/core/sql/TimeOnly.js +1 -1
  27. package/core/sql/WhereClause.js +1 -1
  28. package/core/sql/WhereGrammar.js +1 -1
  29. package/core/sql/sqlCompareUtils.js +1 -1
  30. package/core/sql/sqlDateParsingUtils.js +1 -1
  31. package/editing/sharedTemplates/SharedTemplate.js +1 -1
  32. package/editing/sharedTemplates/SharedTemplateMetadata.js +1 -1
  33. package/editing/sharedTemplates/SharedTemplateProvider.js +1 -1
  34. package/editing/sharedTemplates/executor/support/createServiceEdit.js +1 -1
  35. package/editing/sharedTemplates/support/sharedTemplateErrors.js +1 -1
  36. package/editing/sharedTemplates/templateDefinitions/FeatureTemplateDefinition.js +1 -1
  37. package/editing/sharedTemplates/templateDefinitions/GroupTemplateDefinition.js +1 -1
  38. package/editing/sharedTemplates/templateDefinitions/PresetTemplateDefinition.js +1 -1
  39. package/editing/sharedTemplates/templateDefinitions/TemplateDefinitionBase.js +1 -1
  40. package/editing/sharedTemplates/templateDefinitions/parts/FeatureTemplateRelationshipPart.js +1 -1
  41. package/editing/sharedTemplates/templateDefinitions/parts/GroupTemplatePart.js +1 -1
  42. package/editing/sharedTemplates/templateDefinitions/parts/TemplatePartBase.js +1 -1
  43. package/interfaces.d.ts +448 -63
  44. package/layers/RouteLayer.js +1 -1
  45. package/layers/orientedImagery/core/coverageUtils.js +1 -1
  46. package/layers/orientedImagery/transformations/imageToWorld.js +1 -1
  47. package/layers/orientedImagery/transformations/rectifyMapPoint.js +1 -1
  48. package/layers/orientedImagery/transformations/utils.js +1 -1
  49. package/layers/orientedImagery/transformations/worldToImage.js +1 -1
  50. package/layers/support/Relationship.js +1 -1
  51. package/networks/RulesTable.js +1 -1
  52. package/package.json +1 -1
  53. package/rest/support/PointBarrier.js +1 -1
  54. package/support/revision.js +1 -1
  55. package/symbols/cim/fitVectorMarker.js +1 -1
  56. package/undoredo/support/Services.js +1 -1
  57. package/views/2d/AnimationManager.js +1 -1
  58. package/views/2d/layers/RouteLayerView2D.js +1 -1
  59. package/views/2d/layers/features/sources/FeatureCache.js +1 -1
  60. package/views/2d/layers/features/sources/FeatureSourceQueryInfo.js +1 -1
  61. package/views/2d/layers/features/sources/strategies/support/snapshotUtils.js +5 -0
  62. package/views/2d/layers/features/support/whereUtils.js +1 -1
  63. package/views/View.js +1 -1
  64. package/views/animation/easing.js +1 -1
  65. package/widgets/Directions.js +1 -1
  66. package/widgets/Editor/AddAssociationWorkflow.js +1 -1
  67. package/widgets/Editor/CreateFeaturesWorkflow.js +1 -1
  68. package/widgets/Editor/CreateFeaturesWorkflowData.js +1 -1
  69. package/widgets/Editor/Edits.js +1 -1
  70. package/widgets/Editor/UpdateWorkflow.js +1 -1
  71. package/widgets/Editor/components/PendingFeatureList.js +1 -1
  72. package/widgets/Editor/workflowUtils.js +1 -1
  73. package/widgets/Editor.js +1 -1
  74. package/widgets/FeatureForm/FeatureFormUtilityNetworkAssociations/AssociationDetails.js +1 -1
  75. package/widgets/FeatureForm/FeatureFormUtilityNetworkAssociations/FeatureFormUtilityNetworkAssociationList.js +1 -1
  76. package/widgets/FeatureForm/FeatureFormUtilityNetworkAssociations/UtilityNetworkAssociationItemList.js +1 -1
  77. package/widgets/FeatureForm/FeatureFormUtilityNetworkAssociations/UtilityNetworkAssociationSettings.js +1 -1
  78. package/widgets/FeatureForm/FeatureFormUtilityNetworkAssociations/VisibleElements.js +5 -0
  79. package/widgets/FeatureForm/UtilityNetworkAssociationAddAssociationViewModel.js +1 -1
  80. package/widgets/FeatureForm/UtilityNetworkAssociationInput.js +1 -1
  81. package/widgets/FeatureForm/VisibleElements.js +5 -0
  82. package/widgets/FeatureForm/featureFormUtils.js +1 -1
  83. package/widgets/FeatureForm.js +1 -1
  84. package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
  85. package/widgets/OrientedImageryViewer/adapters/sketch/DataCaptureAdapter.js +5 -0
  86. package/widgets/OrientedImageryViewer/adapters/view/SceneViewAdapter.js +1 -1
  87. package/widgets/OrientedImageryViewer/components/ImageOverlays.js +1 -1
  88. package/widgets/OrientedImageryViewer/components/ImageViewerViewModel.js +1 -1
  89. package/widgets/OrientedImageryViewer/components/OverlayLayersListViewModel.js +1 -1
  90. package/widgets/OrientedImageryViewer/constants.js +1 -1
  91. package/widgets/OrientedImageryViewer/dataCaptureUtils.js +5 -0
  92. package/widgets/OrientedImageryViewer/symbols.js +1 -1
  93. package/widgets/OrientedImageryViewer.js +1 -1
  94. package/widgets/support/FilterCondition.js +1 -1
  95. package/widgets/support/GoTo.js +1 -1
  96. package/widgets/support/UtilityNetworkAssociations/FeatureUtilityNetworkAssociationsViewModel.js +1 -1
  97. package/widgets/support/goToUtils.js +1 -1
  98. package/widgets/support/symbolPreviewUtils.js +1 -1
  99. package/assets/esri/core/workers/chunks/10ca2107c99fab6bcc3b.js +0 -1
  100. package/assets/esri/core/workers/chunks/122ed10cac9f192e1eec.js +0 -1
  101. package/assets/esri/core/workers/chunks/1b3a52ce3e8e5be4d196.js +0 -1
  102. package/assets/esri/core/workers/chunks/35e4af82a08b4eadbfab.js +0 -1
  103. package/assets/esri/core/workers/chunks/6f007703662e714b2f0a.js +0 -1
  104. package/assets/esri/core/workers/chunks/8232a2c4bdc3011bb9e3.js +0 -1
  105. package/assets/esri/core/workers/chunks/8b8579d81728cb35bb29.js +0 -1
  106. package/assets/esri/core/workers/chunks/934857de20f6f5c15188.js +0 -1
  107. package/assets/esri/core/workers/chunks/b8fae500c69ca2cff62a.js +0 -1
  108. package/assets/esri/core/workers/chunks/ebe832bd57a316364ca1.js +0 -1
  109. package/widgets/OrientedImageryViewer/adapters/sketch/DigitizationAdapter.js +0 -5
  110. package/widgets/OrientedImageryViewer/digitizationUtils.js +0 -5
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.32/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../chunks/tslib.es6.js";import t from"../config.js";import r from"../Graphic.js";import o from"../PopupTemplate.js";import i from"../core/Collection.js";import s from"../core/Error.js";import n from"../core/Logger.js";import{MultiOriginJSONMixin as l}from"../core/MultiOriginJSONSupport.js";import{setDeepValue as a}from"../core/object.js";import{isAbortError as u}from"../core/promiseUtils.js";import{on as p}from"../core/reactiveUtils.js";import{convertUnit as c}from"../core/unitUtils.js";import{urlToObject as m}from"../core/urlUtils.js";import{property as y}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/RandomLCG.js";import{reader as f}from"../core/accessorSupport/decorators/reader.js";import{subclass as d}from"../core/accessorSupport/decorators/subclass.js";import{writer as h}from"../core/accessorSupport/decorators/writer.js";import{updateOrigins as w}from"../core/accessorSupport/originUtils.js";import S from"../geometry/Extent.js";import g from"../geometry/Multipoint.js";import{initializeProjection as b,project as v}from"../geometry/projection.js";import B from"../geometry/SpatialReference.js";import{wgs84 as P}from"../geometry/support/spatialReferenceUtils.js";import N from"./Layer.js";import{BlendLayer as _}from"./mixins/BlendLayer.js";import{OperationalLayer as j}from"./mixins/OperationalLayer.js";import{PortalLayer as L}from"./mixins/PortalLayer.js";import{ScaleRangeLayer as I}from"./mixins/ScaleRangeLayer.js";import{sanitizeUrl as C}from"./support/arcgisLayerUrl.js";import D from"./support/RouteSymbols.js";import R from"../portal/Portal.js";import O from"../portal/PortalItem.js";import{typeKeyword as k}from"../portal/support/portalItemUtils.js";import{read as F}from"../renderers/support/jsonUtils.js";import{fetchServiceDescription as x}from"../rest/networkService.js";import{solve as T}from"../rest/route.js";import A from"../rest/support/DirectionLine.js";import G from"../rest/support/DirectionPoint.js";import J from"../rest/support/PointBarrier.js";import M from"../rest/support/PolygonBarrier.js";import U from"../rest/support/PolylineBarrier.js";import q from"../rest/support/RouteInfo.js";import E from"../rest/support/RouteParameters.js";import W from"../rest/support/RouteSettings.js";import V from"../rest/support/Stop.js";function z(e){return e.length?e:null}function K(e){switch(e){case"esriGeometryPoint":return{type:"esriSMS",style:"esriSMSCircle",size:12,color:[0,0,0,0],outline:K("esriGeometryPolyline")};case"esriGeometryPolyline":return{type:"esriSLS",style:"esriSLSSolid",width:1,color:[0,0,0,0]};case"esriGeometryPolygon":return{type:"esriSFS",style:"esriSFSNull",outline:K("esriGeometryPolyline")}}}function H(e){return"layers"in e}function Q(e){return"esri.rest.support.FeatureSet"===e.declaredClass}function Y(e){return"esri.rest.support.NetworkFeatureSet"===e.declaredClass}function Z(e,t,r){const o=t.networkDataset?.networkAttributes,i=o?.filter((({usageType:e})=>"cost"===e))??[],n=r.travelMode??t.defaultTravelMode;if(null==n)return void ue().warn("route-layer:missing-travel-mode","The routing service must have a default travel mode or one must be specified in the route parameter.");const{timeAttributeName:l,distanceAttributeName:a}=n,u=i.find((({name:e})=>e===l)),p=i.find((({name:e})=>e===a)),c=r.travelMode?.impedanceAttributeName??r.impedanceAttribute??t.impedance,m=u?.units,y=p?.units;if(!m||!y)throw new s("routelayer:unknown-impedance-units","the units of either the distance or time impedance are unknown");const f=r.directionsLanguage??t.directionsLanguage,d=r.accumulateAttributes??t.accumulateAttributeNames??[],h=new Set(i.filter((({name:e})=>e===l||e===a||e===c||null!=e&&d.includes(e))).map((({name:e})=>e))),w=e=>{for(const t in e)h.has(t)||delete e[t]};for(const s of e.pointBarriers)null!=s.costs&&(s.addedCost=s.costs[c]??0,w(s.costs));for(const s of e.polygonBarriers)null!=s.costs&&(s.scaleFactor=s.costs[c]??1,w(s.costs));for(const s of e.polylineBarriers)null!=s.costs&&(s.scaleFactor=s.costs[c]??1,w(s.costs));const{routeInfo:S}=e,{findBestSequence:g,preserveFirstStop:b,preserveLastStop:v,startTimeIsUTC:B,timeWindowsAreUTC:P}=r;S.analysisSettings=new W({accumulateAttributes:d,directionsLanguage:f,findBestSequence:g,preserveFirstStop:b,preserveLastStop:v,startTimeIsUTC:B,timeWindowsAreUTC:P,travelMode:n}),S.totalDuration=X(S.totalCosts?.[l]??0,m),S.totalDistance=ee(S.totalCosts?.[a]??0,y),S.totalLateDuration=X(S.totalViolations?.[l]??0,m),S.totalWaitDuration=X(S.totalWait?.[l]??0,m),null!=S.totalCosts&&w(S.totalCosts),null!=S.totalViolations&&w(S.totalViolations),null!=S.totalWait&&w(S.totalWait);for(const s of e.stops)null!=s.serviceCosts&&(s.serviceDuration=X(s.serviceCosts[l]??0,m),s.serviceDistance=ee(s.serviceCosts[a]??0,y),w(s.serviceCosts)),null!=s.cumulativeCosts&&(s.cumulativeDuration=X(s.cumulativeCosts[l]??0,m),s.cumulativeDistance=ee(s.cumulativeCosts[a]??0,y),w(s.cumulativeCosts)),null!=s.violations&&(s.lateDuration=X(s.violations[l]??0,m),w(s.violations)),null!=s.wait&&(s.waitDuration=X(s.wait[l]??0,m),w(s.wait))}async function $(e){const t=B.WGS84;return await b(e.spatialReference,t),v(e,t)}function X(e,t){switch(t){case"seconds":return e/60;case"hours":return 60*e;case"days":return 60*e*24;default:return e}}function ee(e,t){return"decimal-degrees"===t||"points"===t||"unknown"===t?e:c(e,t,"meters")}function te(e){const{attributes:t,geometry:r,popupTemplate:o,symbol:i}=e.toGraphic().toJSON();return{attributes:t,geometry:r,popupInfo:o,symbol:i}}const re=i.ofType(A),oe=i.ofType(G),ie=i.ofType(J),se=i.ofType(M),ne=i.ofType(U),le=i.ofType(V),ae="esri.layers.RouteLayer",ue=()=>n.getLogger(ae);let pe=class extends(_(I(j(L(l(N)))))){constructor(e){super(e),this._cachedServiceDescription=null,this._featureCollection=null,this._type="Feature Collection",this.checksum=null,this.defaultSymbols=new D,this.directionLines=null,this.directionPoints=null,this.featureCollectionType="route",this.legendEnabled=!1,this.maxScale=0,this.minScale=0,this.pointBarriers=new ie,this.polygonBarriers=new se,this.polylineBarriers=new ne,this.routeInfo=null,this.spatialReference=B.WGS84,this.stops=new le,this.type="route";const t=()=>{this._setStopSymbol(this.stops)};this.addHandles(p((()=>this.stops),"change",t,{sync:!0,onListenerAdd:t}))}writeFeatureCollectionWebmap(e,t,r,o){const i=[this._writePolygonBarriers(),this._writePolylineBarriers(),this._writePointBarriers(),this._writeRouteInfo(),this._writeDirectionLines(),this._writeDirectionPoints(),this._writeStops()].filter((e=>!!e)),s=i.map(((e,t)=>t)),n="web-map"===o.origin?"featureCollection.layers":"layers";a(n,i,t),t.opacity=this.opacity,t.visibility=this.visible,t.visibleLayers=s}readDirectionLines(e,t){return this._getNetworkFeatures(t,"DirectionLines",(e=>A.fromGraphic(e)))}readDirectionPoints(e,t){return this._getNetworkFeatures(t,"DirectionPoints",(e=>G.fromGraphic(e)))}get fullExtent(){const e=new S({xmin:-180,ymin:-90,xmax:180,ymax:90,spatialReference:B.WGS84});if(null!=this.routeInfo?.geometry)return this.routeInfo.geometry.extent??e;if(null==this.stops)return e;const t=this.stops.filter((e=>null!=e.geometry));if(t.length<2)return e;const{spatialReference:r}=t.at(0).geometry;if(null==r)return e;const o=t.toArray().map((e=>{const t=e.geometry;return[t.x,t.y]}));return new g({points:o,spatialReference:r}).extent}readMaxScale(e,t){const r=H(t)?t.layers:t.featureCollection?.layers,o=r?.find((e=>null!=e.layerDefinition.maxScale));return o?.layerDefinition.maxScale??0}readMinScale(e,t){const r=H(t)?t.layers:t.featureCollection?.layers,o=r?.find((e=>null!=e.layerDefinition.minScale));return o?.layerDefinition.minScale??0}readPointBarriers(e,t){return this._getNetworkFeatures(t,"Barriers",(e=>J.fromGraphic(e)))}readPolygonBarriers(e,t){return this._getNetworkFeatures(t,"PolygonBarriers",(e=>M.fromGraphic(e)))}readPolylineBarriers(e,t){return this._getNetworkFeatures(t,"PolylineBarriers",(e=>U.fromGraphic(e)))}readRouteInfo(e,t){return this._getNetworkFeatures(t,"RouteInfo",(e=>q.fromGraphic(e))).at(0)??null}readSpatialReference(e,t){const r=H(t)?t.layers:t.featureCollection?.layers;if(!r?.length)return B.WGS84;const{layerDefinition:o,featureSet:i}=r[0],s=i.features[0],n=s?.geometry?.spatialReference??i.spatialReference??o.spatialReference??o.extent.spatialReference??P;return B.fromJSON(n)}readStops(e,t){return this._getNetworkFeatures(t,"Stops",(e=>V.fromGraphic(e)),(e=>this._setStopSymbol(e)))}get title(){return this.routeInfo?.name??"Route"}set title(e){this._overrideIfSome("title",e)}get url(){return t.routeServiceUrl}set url(e){null!=e?this._set("url",C(e,ue())):this._set("url",t.routeServiceUrl)}load(e){return this.addResolvingPromise(this.loadFromPortal({supportedTypes:["Feature Collection"]},e)),Promise.resolve(this)}removeAll(){this.removeResult(),this.pointBarriers.removeAll(),this.polygonBarriers.removeAll(),this.polylineBarriers.removeAll(),this.stops.removeAll()}removeResult(){null!=this.directionLines&&(this.directionLines.removeAll(),this._set("directionLines",null)),null!=this.directionPoints&&(this.directionPoints.removeAll(),this._set("directionPoints",null)),null!=this.routeInfo&&this._set("routeInfo",null)}async save(){await this.load();const{fullExtent:e,portalItem:t}=this;if(!t)throw new s("routelayer:portal-item-not-set","save() requires to the layer to have a portal item");if(!t.id)throw new s("routelayer:portal-item-not-saved","Please use saveAs() first to save the routelayer");if("Feature Collection"!==t.type)throw new s("routelayer:portal-item-wrong-type",'Portal item needs to have type "Feature Collection"');if(null==this.routeInfo)throw new s("routelayer:route-unsolved","save() requires a solved route");const{portal:r}=t;await r.signIn(),r.user||await t.reload();const{itemUrl:o,itemControl:i}=t;if("admin"!==i&&"update"!==i)throw new s("routelayer:insufficient-permissions","To save this layer, you need to be the owner or an administrator of your organization");const n={messages:[],origin:"portal-item",portal:r,url:o?m(o):void 0,writtenProperties:[]},l=this.write(void 0,n);return t.extent=await $(e),t.title=this.title,await t.update({data:l}),t}async saveAs(e,t={}){if(await this.load(),null==this.routeInfo)throw new s("routelayer:route-unsolved","saveAs() requires a solved route");const r=O.from(e).clone();r.extent??=await $(this.fullExtent),r.id=null,r.portal??=R.getDefault(),r.title??=this.title,r.type="Feature Collection",r.typeKeywords=["Data","Feature Collection",k.MULTI_LAYER,"Route Layer"];const{portal:o}=r,i={messages:[],origin:"portal-item",portal:o,url:null,writtenProperties:[]};await o.signIn();const n=t?.folder,l=this.write(void 0,i);return await o.user.addItem({item:r,folder:n,data:l}),this.portalItem=r,w(i),i.portalItem=r,r}async solve(e,t){const r=e?.stops??this.stops,o=e?.pointBarriers??z(this.pointBarriers),n=e?.polylineBarriers??z(this.polylineBarriers),l=e?.polygonBarriers??z(this.polygonBarriers);if(null==r)throw new s("routelayer:undefined-stops","the route layer must have stops defined in the route parameters.");if((Q(r)||Y(r))&&r.features.length<2||i.isCollection(r)&&r.length<2)throw new s("routelayer:insufficent-stops","the route layer must have two or more stops to solve a route.");if(i.isCollection(r))for(const i of r)i.routeName=null;const a=e?.apiKey,{checksum:p,url:c}=this,m=await this._getServiceDescription(c,a,t),y=e?.travelMode??m.defaultTravelMode,f=e?.accumulateAttributes??[];null!=y&&(f.push(y.distanceAttributeName),y.timeAttributeName&&f.push(y.timeAttributeName));const d={accumulateAttributes:f,checksum:p,directionsOutputType:"featuresets",ignoreInvalidLocations:!0,pointBarriers:o,polylineBarriers:n,polygonBarriers:l,returnBarriers:!!o,returnDirections:!0,returnPolygonBarriers:!!l,returnPolylineBarriers:!!n,returnRoutes:!0,returnStops:!0,stops:r},h=E.from(e??{});let w;h.set(d);try{w=await T(c,h,t)}catch(g){throw u(g)?g:new s("routelayer:failed-route-request","the routing request failed",{error:g})}const S=this._toRouteLayerSolution(w);return this._isOverridden("title")||(this.title=S.routeInfo.name??"Route"),Z(S,m,h),S}update(e){const{checksum:t,directionLines:r,directionPoints:o,pointBarriers:i,polygonBarriers:s,polylineBarriers:n,routeInfo:l,stops:a}=e;this.set({stops:a,checksum:t,pointBarriers:i,polylineBarriers:n,polygonBarriers:s}),this._set("directionLines",r),this._set("directionPoints",o),this._set("routeInfo",l),null!=l.geometry&&(this.spatialReference=l.geometry.spatialReference)}_getNetworkFeatures(e,t,s,n){const l=H(e)?e.layers:e.featureCollection?.layers,a=l?.find((e=>e.layerDefinition.name===t));if(null==a)return new i;const{layerDefinition:u,popupInfo:p,featureSet:c}=a,m=u.drawingInfo.renderer,{features:y}=c,f=c.spatialReference??u.spatialReference??u.extent.spatialReference??P,d=m&&F(m),h=B.fromJSON(f),w=y.map((e=>{const i=r.fromJSON(e);null!=i.geometry&&null!=e.geometry&&null==e.geometry.spatialReference&&(i.geometry.spatialReference=h);const n=s(i);return n.symbol??=d?.getSymbol(i)??this._getNetworkSymbol(t),n.popupTemplate??=p&&o.fromJSON(p),n}));return n&&w.some((({symbol:e})=>!e))&&n(w),new i(w)}_getNetworkSymbol(e){switch(e){case"Barriers":return this.defaultSymbols.pointBarriers;case"DirectionPoints":return this.defaultSymbols.directionPoints;case"DirectionLines":return this.defaultSymbols.directionLines;case"PolylineBarriers":return this.defaultSymbols.polylineBarriers;case"PolygonBarriers":return this.defaultSymbols.polygonBarriers;case"RouteInfo":return this.defaultSymbols.routeInfo;case"Stops":return null}}async _getServiceDescription(e,t,r){if(null!=this._cachedServiceDescription&&this._cachedServiceDescription.url===e)return this._cachedServiceDescription.serviceDescription;const o=await x(e,t,r);return this._cachedServiceDescription={serviceDescription:o,url:e},o}_setStopSymbol(e){if(!e||0===e.length)return;if(null==this.defaultSymbols.stops)return;if(e.every((({symbol:e})=>null!=e)))return;const{first:t,last:r,middle:o,unlocated:i,waypoint:s,break:n}=this.defaultSymbols.stops;if(null==this.routeInfo||1===e.length)return void e.forEach(((i,s)=>{switch(s){case 0:i.symbol=t;break;case e.length-1:i.symbol=r;break;default:i.symbol=o}}));const l=e.map((({sequence:e})=>e)).filter((e=>null!=e)),a=Math.min(...l),u=Math.max(...l);for(const p of e)p.sequence!==a?p.sequence!==u?"ok"===p.status||"not-located-on-closest"===p.status?"waypoint"!==p.locationType?"break"!==p.locationType?p.symbol=o:p.symbol=n:p.symbol=s:p.symbol=i:p.symbol=r:p.symbol=t}_toRouteLayerSolution(e){const{checksum:t,routeResults:r}=e,o=r[0].stops?.map((e=>V.fromJSON(e.toJSON())));this._setStopSymbol(o);const i=new le(o),s=new se(e.polygonBarriers?.map((e=>{const t=M.fromJSON(e.toJSON());return t.symbol=this.defaultSymbols.polygonBarriers,t}))),n=new ne(e.polylineBarriers?.map((e=>{const t=U.fromJSON(e.toJSON());return t.symbol=this.defaultSymbols.polylineBarriers,t}))),l=new ie(e.pointBarriers?.map((e=>{const t=J.fromJSON(e.toJSON());return t.symbol=this.defaultSymbols.pointBarriers,t}))),a=r[0].route?.toJSON(),u=q.fromJSON(a);u.symbol=this.defaultSymbols.routeInfo;const p=new oe(r[0].directionPoints?.features.map((e=>{const t=G.fromJSON(e.toJSON());return t.symbol=this.defaultSymbols.directionPoints,t})));return{checksum:t,directionLines:new re(r[0].directionLines?.features.map((e=>{const t=A.fromJSON(e.toJSON());return t.symbol=this.defaultSymbols.directionLines,t}))),directionPoints:p,pointBarriers:l,polygonBarriers:s,polylineBarriers:n,routeInfo:u,stops:i}}_writeDirectionLines(){return this._writeNetworkFeatures(this.directionLines,this.defaultSymbols.directionLines,"esriGeometryPolyline",A.fields,"DirectionLines","Direction Lines")}_writeDirectionPoints(){return this._writeNetworkFeatures(this.directionPoints,this.defaultSymbols.directionPoints,"esriGeometryPoint",G.fields,"DirectionPoints","Direction Points")}_writeNetworkFeatures(e,t,r,o,i,s){if(!e?.length)return null;const n=this.spatialReference.toJSON(),{fullExtent:l,maxScale:a,minScale:u}=this;return{featureSet:{features:e.toArray().map((e=>te(e))),geometryType:r,spatialReference:n},layerDefinition:{capabilities:"Query,Update,Editing",drawingInfo:{renderer:{type:"simple",symbol:null!=t?t.toJSON():K(r)}},extent:l.toJSON(),fields:o,geometryType:r,hasM:!1,hasZ:!1,maxScale:a,minScale:u,name:i,objectIdField:"ObjectID",spatialReference:n,title:s,type:"Feature Layer",typeIdField:""}}}_writePointBarriers(){return this._writeNetworkFeatures(this.pointBarriers,this.defaultSymbols.pointBarriers,"esriGeometryPoint",J.fields,"Barriers","Point Barriers")}_writePolygonBarriers(){return this._writeNetworkFeatures(this.polygonBarriers,this.defaultSymbols.polygonBarriers,"esriGeometryPolygon",M.fields,"PolygonBarriers","Polygon Barriers")}_writePolylineBarriers(){return this._writeNetworkFeatures(this.polylineBarriers,this.defaultSymbols.polylineBarriers,"esriGeometryPolyline",U.fields,"PolylineBarriers","Line Barriers")}_writeRouteInfo(){return this._writeNetworkFeatures(null!=this.routeInfo?new i([this.routeInfo]):null,this.defaultSymbols.routeInfo,"esriGeometryPolyline",q.fields,"RouteInfo","Route Details")}_writeStops(){const e=this._writeNetworkFeatures(this.stops,null,"esriGeometryPoint",V.fields,"Stops","Stops");if(null==e)return null;const{stops:t}=this.defaultSymbols,r=t?.first?.toJSON(),o=t?.middle?.toJSON(),i=t?.last?.toJSON();return e.layerDefinition.drawingInfo.renderer={type:"uniqueValue",field1:"Sequence",defaultSymbol:o,uniqueValueInfos:[{value:"1",symbol:r,label:"First Stop"},{value:`${this.stops.length}`,symbol:i,label:"Last Stop"}]},e}};e([y({readOnly:!0,json:{read:!1,origins:{"portal-item":{write:{allowNull:!0,ignoreOrigin:!0}},"web-map":{write:{overridePolicy(){return{allowNull:!0,ignoreOrigin:null==this.portalItem}}}}}}})],pe.prototype,"_featureCollection",void 0),e([h(["web-map","portal-item"],"_featureCollection")],pe.prototype,"writeFeatureCollectionWebmap",null),e([y({readOnly:!0,json:{read:!1,origins:{"web-map":{write:{target:"type",overridePolicy(){return{ignoreOrigin:null!=this.portalItem}}}}}}})],pe.prototype,"_type",void 0),e([y({type:String})],pe.prototype,"checksum",void 0),e([y({nonNullable:!0,type:D})],pe.prototype,"defaultSymbols",void 0),e([y({readOnly:!0})],pe.prototype,"directionLines",void 0),e([f(["web-map","portal-item"],"directionLines",["layers","featureCollection.layers"])],pe.prototype,"readDirectionLines",null),e([y({readOnly:!0})],pe.prototype,"directionPoints",void 0),e([f(["web-map","portal-item"],"directionPoints",["layers","featureCollection.layers"])],pe.prototype,"readDirectionPoints",null),e([y({readOnly:!0,json:{read:!1,origins:{"web-map":{write:{ignoreOrigin:!0}}}}})],pe.prototype,"featureCollectionType",void 0),e([y({readOnly:!0})],pe.prototype,"fullExtent",null),e([y({json:{origins:{"web-map":{name:"featureCollection.showLegend"}},write:!0}})],pe.prototype,"legendEnabled",void 0),e([y({type:["show","hide"]})],pe.prototype,"listMode",void 0),e([y({type:Number,nonNullable:!0,json:{write:!1}})],pe.prototype,"maxScale",void 0),e([f(["web-map","portal-item"],"maxScale",["layers","featureCollection.layers"])],pe.prototype,"readMaxScale",null),e([y({type:Number,nonNullable:!0,json:{write:!1}})],pe.prototype,"minScale",void 0),e([f(["web-map","portal-item"],"minScale",["layers","featureCollection.layers"])],pe.prototype,"readMinScale",null),e([y({type:["ArcGISFeatureLayer"],value:"ArcGISFeatureLayer"})],pe.prototype,"operationalLayerType",void 0),e([y({nonNullable:!0,type:i.ofType(J)})],pe.prototype,"pointBarriers",void 0),e([f(["web-map","portal-item"],"pointBarriers",["layers","featureCollection.layers"])],pe.prototype,"readPointBarriers",null),e([y({nonNullable:!0,type:i.ofType(M)})],pe.prototype,"polygonBarriers",void 0),e([f(["web-map","portal-item"],"polygonBarriers",["layers","featureCollection.layers"])],pe.prototype,"readPolygonBarriers",null),e([y({nonNullable:!0,type:i.ofType(U)})],pe.prototype,"polylineBarriers",void 0),e([f(["web-map","portal-item"],"polylineBarriers",["layers","featureCollection.layers"])],pe.prototype,"readPolylineBarriers",null),e([y({readOnly:!0})],pe.prototype,"routeInfo",void 0),e([f(["web-map","portal-item"],"routeInfo",["layers","featureCollection.layers"])],pe.prototype,"readRouteInfo",null),e([y({type:B})],pe.prototype,"spatialReference",void 0),e([f(["web-map","portal-item"],"spatialReference",["layers","featureCollection.layers"])],pe.prototype,"readSpatialReference",null),e([y({nonNullable:!0,type:i.ofType(V)})],pe.prototype,"stops",void 0),e([f(["web-map","portal-item"],"stops",["layers","featureCollection.layers"])],pe.prototype,"readStops",null),e([y()],pe.prototype,"title",null),e([y({readOnly:!0,json:{read:!1}})],pe.prototype,"type",void 0),e([y()],pe.prototype,"url",null),pe=e([d(ae)],pe);const ce=pe;export{ce as default};
5
+ import{_ as e}from"../chunks/tslib.es6.js";import t from"../config.js";import r from"../Graphic.js";import o from"../PopupTemplate.js";import i from"../core/Collection.js";import s from"../core/Error.js";import n from"../core/Logger.js";import{MultiOriginJSONMixin as a}from"../core/MultiOriginJSONSupport.js";import{setDeepValue as l}from"../core/object.js";import{isAbortError as u}from"../core/promiseUtils.js";import{on as p}from"../core/reactiveUtils.js";import{convertUnit as c}from"../core/unitUtils.js";import{urlToObject as m}from"../core/urlUtils.js";import{property as y}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/RandomLCG.js";import{reader as f}from"../core/accessorSupport/decorators/reader.js";import{subclass as d}from"../core/accessorSupport/decorators/subclass.js";import{writer as h}from"../core/accessorSupport/decorators/writer.js";import{updateOrigins as w}from"../core/accessorSupport/originUtils.js";import g from"../geometry/Extent.js";import S from"../geometry/Multipoint.js";import{initializeProjection as b,project as v}from"../geometry/projection.js";import B from"../geometry/SpatialReference.js";import{wgs84 as I}from"../geometry/support/spatialReferenceUtils.js";import P from"./Layer.js";import{BlendLayer as j}from"./mixins/BlendLayer.js";import{OperationalLayer as N}from"./mixins/OperationalLayer.js";import{PortalLayer as D}from"./mixins/PortalLayer.js";import{ScaleRangeLayer as C}from"./mixins/ScaleRangeLayer.js";import{sanitizeUrl as _}from"./support/arcgisLayerUrl.js";import L from"./support/RouteSymbols.js";import O from"../portal/Portal.js";import R from"../portal/PortalItem.js";import{typeKeyword as T}from"../portal/support/portalItemUtils.js";import{read as F}from"../renderers/support/jsonUtils.js";import{fetchServiceDescription as A}from"../rest/networkService.js";import{solve as k}from"../rest/route.js";import x from"../rest/support/DirectionLine.js";import G from"../rest/support/DirectionPoint.js";import J from"../rest/support/PointBarrier.js";import M from"../rest/support/PolygonBarrier.js";import E from"../rest/support/PolylineBarrier.js";import U from"../rest/support/RouteInfo.js";import W from"../rest/support/RouteParameters.js";import q from"../rest/support/RouteSettings.js";import V from"../rest/support/Stop.js";function Y(e){if(!e.length)return;const t=e.toArray(),r=t.map((({objectId:e})=>e)).filter((e=>null!=e));let o=Math.max(...r,0);for(const i of t)null==i.objectId&&(i.objectId=++o)}function Z(e,t){return!!e.length&&e.length===t.length&&z(e)&&z(t)}function z(e){return e.every((({objectId:e})=>null!=e))}function K(e){return e.length?e:null}function X(e){switch(e){case"esriGeometryPoint":return{type:"esriSMS",style:"esriSMSCircle",size:12,color:[0,0,0,0],outline:X("esriGeometryPolyline")};case"esriGeometryPolyline":return{type:"esriSLS",style:"esriSLSSolid",width:1,color:[0,0,0,0]};case"esriGeometryPolygon":return{type:"esriSFS",style:"esriSFSNull",outline:X("esriGeometryPolyline")}}}function H(e){return"layers"in e}function Q(e){return"esri.rest.support.FeatureSet"===e.declaredClass}function $(e){return"esri.rest.support.NetworkFeatureSet"===e.declaredClass}function ee(e,t,r){const o=t.networkDataset?.networkAttributes,i=o?.filter((({usageType:e})=>"cost"===e))??[],n=r.travelMode??t.defaultTravelMode;if(null==n)return void he().warn("route-layer:missing-travel-mode","The routing service must have a default travel mode or one must be specified in the route parameter.");const{timeAttributeName:a,distanceAttributeName:l}=n,u=i.find((({name:e})=>e===a)),p=i.find((({name:e})=>e===l)),c=r.travelMode?.impedanceAttributeName??r.impedanceAttribute??t.impedance,m=u?.units,y=p?.units;if(!m||!y)throw new s("routelayer:unknown-impedance-units","the units of either the distance or time impedance are unknown");const f=r.directionsLanguage??t.directionsLanguage,d=r.accumulateAttributes??t.accumulateAttributeNames??[],h=new Set(i.filter((({name:e})=>e===a||e===l||e===c||null!=e&&d.includes(e))).map((({name:e})=>e))),w=e=>{for(const t in e)h.has(t)||delete e[t]};for(const s of e.pointBarriers)null!=s.costs&&(s.addedCost=s.costs[c]??0,w(s.costs));for(const s of e.polygonBarriers)null!=s.costs&&(s.scaleFactor=s.costs[c]??1,w(s.costs));for(const s of e.polylineBarriers)null!=s.costs&&(s.scaleFactor=s.costs[c]??1,w(s.costs));const{routeInfo:g}=e,{findBestSequence:S,preserveFirstStop:b,preserveLastStop:v,startTimeIsUTC:B,timeWindowsAreUTC:I}=r;g.analysisSettings=new q({accumulateAttributes:d,directionsLanguage:f,findBestSequence:S,preserveFirstStop:b,preserveLastStop:v,startTimeIsUTC:B,timeWindowsAreUTC:I,travelMode:n}),g.totalDuration=ne(g.totalCosts?.[a]??0,m),g.totalDistance=ae(g.totalCosts?.[l]??0,y),g.totalLateDuration=ne(g.totalViolations?.[a]??0,m),g.totalWaitDuration=ne(g.totalWait?.[a]??0,m),null!=g.totalCosts&&w(g.totalCosts),null!=g.totalViolations&&w(g.totalViolations),null!=g.totalWait&&w(g.totalWait);for(const s of e.stops)null!=s.serviceCosts&&(s.serviceDuration=ne(s.serviceCosts[a]??0,m),s.serviceDistance=ae(s.serviceCosts[l]??0,y),w(s.serviceCosts)),null!=s.cumulativeCosts&&(s.cumulativeDuration=ne(s.cumulativeCosts[a]??0,m),s.cumulativeDistance=ae(s.cumulativeCosts[l]??0,y),w(s.cumulativeCosts)),null!=s.violations&&(s.lateDuration=ne(s.violations[a]??0,m),w(s.violations)),null!=s.wait&&(s.waitDuration=ne(s.wait[a]??0,m),w(s.wait))}function te(e,t){for(const r of e){const e=t.find((e=>e.objectId===r.objectId));e&&(e.addedCost=r.addedCost,e.barrierType=r.barrierType,e.costs=r.costs,e.curbApproach=r.curbApproach,e.fullEdge=r.fullEdge,e.geometry=r.geometry,e.name=r.name,e.sideOfEdge=r.sideOfEdge,e.sourceId=r.sourceId,e.sourceOid=r.sourceOid,e.status=r.status,e.symbol=r.symbol)}}function re(e,t){for(const r of e){const e=t.find((e=>e.objectId===r.objectId));e&&(e.barrierType=r.barrierType,e.costs=r.costs,e.geometry=r.geometry,e.name=r.name,e.scaleFactor=r.scaleFactor,e.symbol=r.symbol)}}function oe(e,t){for(const r of e){const e=t.find((e=>e.objectId===r.objectId));e&&(e.barrierType=r.barrierType,e.costs=r.costs,e.geometry=r.geometry,e.name=r.name,e.scaleFactor=r.scaleFactor,e.symbol=r.symbol)}}function ie(e,t){for(const r of e){const e=t.find((e=>e.objectId===r.objectId));e&&(e.arriveCurbApproach=r.arriveCurbApproach,e.arriveTime=r.arriveTime,e.arriveTimeOffset=r.arriveTimeOffset,e.cumulativeCosts=r.cumulativeCosts,e.cumulativeDistance=r.cumulativeDistance,e.cumulativeDuration=r.cumulativeDuration,e.curbApproach=r.curbApproach,e.departCurbApproach=r.departCurbApproach,e.departTime=r.departTime,e.departTimeOffset=r.departTimeOffset,e.distanceToNetworkInMeters=r.distanceToNetworkInMeters,e.geometry=r.geometry,e.lateDuration=r.lateDuration,e.name=r.name,e.navLatency=r.navLatency,e.posAlong=r.posAlong,e.routeName=r.routeName,e.serviceCosts=r.serviceCosts,e.serviceDistance=r.serviceDistance,e.serviceDuration=r.serviceDuration,e.sequence=r.sequence,e.sideOfEdge=r.sideOfEdge,e.snapX=r.snapX,e.snapY=r.snapY,e.snapZ=r.snapZ,e.sourceId=r.sourceId,e.sourceOid=r.sourceOid,e.status=r.status,e.symbol=r.symbol,e.timeWindowEnd=r.timeWindowEnd,e.timeWindowStart=r.timeWindowStart,e.violations=r.violations,e.waitDuration=r.waitDuration,e.wait=r.wait)}}async function se(e){const t=B.WGS84;return await b(e.spatialReference,t),v(e,t)}function ne(e,t){switch(t){case"seconds":return e/60;case"hours":return 60*e;case"days":return 60*e*24;default:return e}}function ae(e,t){return"decimal-degrees"===t||"points"===t||"unknown"===t?e:c(e,t,"meters")}function le(e){const{attributes:t,geometry:r,popupTemplate:o,symbol:i}=e.toGraphic().toJSON();return{attributes:t,geometry:r,popupInfo:o,symbol:i}}const ue=i.ofType(x),pe=i.ofType(G),ce=i.ofType(J),me=i.ofType(M),ye=i.ofType(E),fe=i.ofType(V),de="esri.layers.RouteLayer",he=()=>n.getLogger(de);let we=class extends(j(C(N(D(a(P)))))){constructor(e){super(e),this._cachedServiceDescription=null,this._featureCollection=null,this._type="Feature Collection",this.checksum=null,this.defaultSymbols=new L,this.directionLines=null,this.directionPoints=null,this.featureCollectionType="route",this.legendEnabled=!1,this.maxScale=0,this.minScale=0,this.pointBarriers=new ce,this.polygonBarriers=new me,this.polylineBarriers=new ye,this.routeInfo=null,this.spatialReference=B.WGS84,this.stops=new fe,this.type="route";const t=()=>{this._setStopSymbol(this.stops)};this.addHandles(p((()=>this.stops),"change",t,{sync:!0,onListenerAdd:t}))}writeFeatureCollectionWebmap(e,t,r,o){const i=[this._writePolygonBarriers(),this._writePolylineBarriers(),this._writePointBarriers(),this._writeRouteInfo(),this._writeDirectionLines(),this._writeDirectionPoints(),this._writeStops()].filter((e=>!!e)),s=i.map(((e,t)=>t)),n="web-map"===o.origin?"featureCollection.layers":"layers";l(n,i,t),t.opacity=this.opacity,t.visibility=this.visible,t.visibleLayers=s}readDirectionLines(e,t){return this._getNetworkFeatures(t,"DirectionLines",(e=>x.fromGraphic(e)))}readDirectionPoints(e,t){return this._getNetworkFeatures(t,"DirectionPoints",(e=>G.fromGraphic(e)))}get fullExtent(){const e=new g({xmin:-180,ymin:-90,xmax:180,ymax:90,spatialReference:B.WGS84});if(null!=this.routeInfo?.geometry)return this.routeInfo.geometry.extent??e;if(null==this.stops)return e;const t=this.stops.filter((e=>null!=e.geometry));if(t.length<2)return e;const{spatialReference:r}=t.at(0).geometry;if(null==r)return e;const o=t.toArray().map((e=>{const t=e.geometry;return[t.x,t.y]}));return new S({points:o,spatialReference:r}).extent}readMaxScale(e,t){const r=H(t)?t.layers:t.featureCollection?.layers,o=r?.find((e=>null!=e.layerDefinition.maxScale));return o?.layerDefinition.maxScale??0}readMinScale(e,t){const r=H(t)?t.layers:t.featureCollection?.layers,o=r?.find((e=>null!=e.layerDefinition.minScale));return o?.layerDefinition.minScale??0}readPointBarriers(e,t){return this._getNetworkFeatures(t,"Barriers",(e=>J.fromGraphic(e)))}readPolygonBarriers(e,t){return this._getNetworkFeatures(t,"PolygonBarriers",(e=>M.fromGraphic(e)))}readPolylineBarriers(e,t){return this._getNetworkFeatures(t,"PolylineBarriers",(e=>E.fromGraphic(e)))}readRouteInfo(e,t){return this._getNetworkFeatures(t,"RouteInfo",(e=>U.fromGraphic(e))).at(0)??null}readSpatialReference(e,t){const r=H(t)?t.layers:t.featureCollection?.layers;if(!r?.length)return B.WGS84;const{layerDefinition:o,featureSet:i}=r[0],s=i.features[0],n=s?.geometry?.spatialReference??i.spatialReference??o.spatialReference??o.extent.spatialReference??I;return B.fromJSON(n)}readStops(e,t){return this._getNetworkFeatures(t,"Stops",(e=>V.fromGraphic(e)),(e=>this._setStopSymbol(e)))}get title(){return this.routeInfo?.name??"Route"}set title(e){this._overrideIfSome("title",e)}get url(){return t.routeServiceUrl}set url(e){null!=e?this._set("url",_(e,he())):this._set("url",t.routeServiceUrl)}load(e){return this.addResolvingPromise(this.loadFromPortal({supportedTypes:["Feature Collection"]},e)),Promise.resolve(this)}removeAll(){this.removeResult(),this.pointBarriers.removeAll(),this.polygonBarriers.removeAll(),this.polylineBarriers.removeAll(),this.stops.removeAll()}removeResult(){null!=this.directionLines&&(this.directionLines.removeAll(),this._set("directionLines",null)),null!=this.directionPoints&&(this.directionPoints.removeAll(),this._set("directionPoints",null)),null!=this.routeInfo&&this._set("routeInfo",null)}async save(){await this.load();const{fullExtent:e,portalItem:t}=this;if(!t)throw new s("routelayer:portal-item-not-set","save() requires to the layer to have a portal item");if(!t.id)throw new s("routelayer:portal-item-not-saved","Please use saveAs() first to save the routelayer");if("Feature Collection"!==t.type)throw new s("routelayer:portal-item-wrong-type",'Portal item needs to have type "Feature Collection"');if(null==this.routeInfo)throw new s("routelayer:route-unsolved","save() requires a solved route");const{portal:r}=t;await r.signIn(),r.user||await t.reload();const{itemUrl:o,itemControl:i}=t;if("admin"!==i&&"update"!==i)throw new s("routelayer:insufficient-permissions","To save this layer, you need to be the owner or an administrator of your organization");const n={messages:[],origin:"portal-item",portal:r,url:o?m(o):void 0,writtenProperties:[]},a=this.write(void 0,n);return t.extent=await se(e),t.title=this.title,await t.update({data:a}),t}async saveAs(e,t={}){if(await this.load(),null==this.routeInfo)throw new s("routelayer:route-unsolved","saveAs() requires a solved route");const r=R.from(e).clone();r.extent??=await se(this.fullExtent),r.id=null,r.portal??=O.getDefault(),r.title??=this.title,r.type="Feature Collection",r.typeKeywords=["Data","Feature Collection",T.MULTI_LAYER,"Route Layer"];const{portal:o}=r,i={messages:[],origin:"portal-item",portal:o,url:null,writtenProperties:[]};await o.signIn();const n=t?.folder,a=this.write(void 0,i);return await o.user.addItem({item:r,folder:n,data:a}),this.portalItem=r,w(i),i.portalItem=r,r}async solve(e,t){Y(this.stops),Y(this.pointBarriers),Y(this.polylineBarriers),Y(this.polygonBarriers);const r=e?.stops??this.stops,o=e?.pointBarriers??K(this.pointBarriers),n=e?.polylineBarriers??K(this.polylineBarriers),a=e?.polygonBarriers??K(this.polygonBarriers);if(null==r)throw new s("routelayer:undefined-stops","the route layer must have stops defined in the route parameters.");if((Q(r)||$(r))&&r.features.length<2||i.isCollection(r)&&r.length<2)throw new s("routelayer:insufficent-stops","the route layer must have two or more stops to solve a route.");if(i.isCollection(r))for(const i of r)i.routeName=null;const l=e?.apiKey,{checksum:p,url:c}=this,m=await this._getServiceDescription(c,l,t),y=e?.travelMode??m.defaultTravelMode,f=e?.accumulateAttributes??[];y&&(f.push(y.distanceAttributeName),y.timeAttributeName&&f.push(y.timeAttributeName));const d={accumulateAttributes:f,checksum:p,directionsOutputType:"featuresets",ignoreInvalidLocations:!0,pointBarriers:o,polylineBarriers:n,polygonBarriers:a,preserveObjectID:!0,returnBarriers:!!o,returnDirections:!0,returnPolygonBarriers:!!a,returnPolylineBarriers:!!n,returnRoutes:!0,returnStops:!0,stops:r},h=W.from(e??{});let w;h.set(d);try{w=await k(c,h,t)}catch(S){throw u(S)?S:new s("routelayer:failed-route-request","the routing request failed",{error:S})}const g=this._toRouteLayerSolution(w);return this._isOverridden("title")||(this.title=g.routeInfo.name??"Route"),ee(g,m,h),g}update(e){const{checksum:t,directionLines:r,directionPoints:o,pointBarriers:i,polygonBarriers:s,polylineBarriers:n,routeInfo:a,stops:l}=e;Z(l,this.stops)?ie(l,this.stops):this.set({stops:l}),Z(i,this.pointBarriers)?te(i,this.pointBarriers):this.set({pointBarriers:i}),Z(n,this.polylineBarriers)?re(n,this.polylineBarriers):this.set({polylineBarriers:n}),Z(s,this.polygonBarriers)?oe(s,this.polygonBarriers):this.set({polygonBarriers:s}),this.set({checksum:t}),this._set("directionLines",r),this._set("directionPoints",o),this._set("routeInfo",a),null!=a.geometry&&(this.spatialReference=a.geometry.spatialReference)}_getNetworkFeatures(e,t,s,n){const a=H(e)?e.layers:e.featureCollection?.layers,l=a?.find((e=>e.layerDefinition.name===t));if(null==l)return new i;const{layerDefinition:u,popupInfo:p,featureSet:c}=l,m=u.drawingInfo.renderer,{features:y}=c,f=c.spatialReference??u.spatialReference??u.extent.spatialReference??I,d=m&&F(m),h=B.fromJSON(f),w=y.map((e=>{const i=r.fromJSON(e);null!=i.geometry&&null!=e.geometry&&null==e.geometry.spatialReference&&(i.geometry.spatialReference=h);const n=s(i);return n.symbol??=d?.getSymbol(i)??this._getNetworkSymbol(t),n.popupTemplate??=p&&o.fromJSON(p),n}));return n&&w.some((({symbol:e})=>!e))&&n(w),new i(w)}_getNetworkSymbol(e){switch(e){case"Barriers":return this.defaultSymbols.pointBarriers;case"DirectionPoints":return this.defaultSymbols.directionPoints;case"DirectionLines":return this.defaultSymbols.directionLines;case"PolylineBarriers":return this.defaultSymbols.polylineBarriers;case"PolygonBarriers":return this.defaultSymbols.polygonBarriers;case"RouteInfo":return this.defaultSymbols.routeInfo;case"Stops":return null}}async _getServiceDescription(e,t,r){if(null!=this._cachedServiceDescription&&this._cachedServiceDescription.url===e)return this._cachedServiceDescription.serviceDescription;const o=await A(e,t,r);return this._cachedServiceDescription={serviceDescription:o,url:e},o}_setStopSymbol(e){if(!e||!e.length||!this.defaultSymbols.stops||e.every((({symbol:e})=>!!e)))return;const{first:t,last:r,middle:o,unlocated:i,waypoint:s,break:n}=this.defaultSymbols.stops;if(null==this.routeInfo||1===e.length)return void e.forEach(((i,s)=>{switch(s){case 0:i.symbol=t;break;case e.length-1:i.symbol=r;break;default:i.symbol=o}}));const a=e.map((({sequence:e})=>e)).filter((e=>null!=e)),l=Math.min(...a),u=Math.max(...a);for(const p of e)p.sequence!==l?p.sequence!==u?"ok"===p.status||"not-located-on-closest"===p.status?"waypoint"!==p.locationType?"break"!==p.locationType?p.symbol=o:p.symbol=n:p.symbol=s:p.symbol=i:p.symbol=r:p.symbol=t}_toRouteLayerSolution(e){const{checksum:t,routeResults:r}=e,o=r[0].stops?.map((e=>V.fromJSON(e.toJSON())));this._setStopSymbol(o);const i=new fe(o),s=new me(e.polygonBarriers?.map((e=>{const t=M.fromJSON(e.toJSON());return t.symbol=this.defaultSymbols.polygonBarriers,t}))),n=new ye(e.polylineBarriers?.map((e=>{const t=E.fromJSON(e.toJSON());return t.symbol=this.defaultSymbols.polylineBarriers,t}))),a=new ce(e.pointBarriers?.map((e=>{const t=J.fromJSON(e.toJSON());return t.symbol=this.defaultSymbols.pointBarriers,t}))),l=r[0].route?.toJSON(),u=U.fromJSON(l);u.symbol=this.defaultSymbols.routeInfo;const p=new pe(r[0].directionPoints?.features.map((e=>{const t=G.fromJSON(e.toJSON());return t.symbol=this.defaultSymbols.directionPoints,t})));return{checksum:t,directionLines:new ue(r[0].directionLines?.features.map((e=>{const t=x.fromJSON(e.toJSON());return t.symbol=this.defaultSymbols.directionLines,t}))),directionPoints:p,pointBarriers:a,polygonBarriers:s,polylineBarriers:n,routeInfo:u,stops:i}}_writeDirectionLines(){return this._writeNetworkFeatures(this.directionLines,this.defaultSymbols.directionLines,"esriGeometryPolyline",x.fields,"DirectionLines","Direction Lines")}_writeDirectionPoints(){return this._writeNetworkFeatures(this.directionPoints,this.defaultSymbols.directionPoints,"esriGeometryPoint",G.fields,"DirectionPoints","Direction Points")}_writeNetworkFeatures(e,t,r,o,i,s){if(!e?.length)return null;const n=this.spatialReference.toJSON(),{fullExtent:a,maxScale:l,minScale:u}=this;return{featureSet:{features:e.toArray().map((e=>le(e))),geometryType:r,spatialReference:n},layerDefinition:{capabilities:"Query,Update,Editing",drawingInfo:{renderer:{type:"simple",symbol:null!=t?t.toJSON():X(r)}},extent:a.toJSON(),fields:o,geometryType:r,hasM:!1,hasZ:!1,maxScale:l,minScale:u,name:i,objectIdField:"ObjectID",spatialReference:n,title:s,type:"Feature Layer",typeIdField:""}}}_writePointBarriers(){return this._writeNetworkFeatures(this.pointBarriers,this.defaultSymbols.pointBarriers,"esriGeometryPoint",J.fields,"Barriers","Point Barriers")}_writePolygonBarriers(){return this._writeNetworkFeatures(this.polygonBarriers,this.defaultSymbols.polygonBarriers,"esriGeometryPolygon",M.fields,"PolygonBarriers","Polygon Barriers")}_writePolylineBarriers(){return this._writeNetworkFeatures(this.polylineBarriers,this.defaultSymbols.polylineBarriers,"esriGeometryPolyline",E.fields,"PolylineBarriers","Line Barriers")}_writeRouteInfo(){return this._writeNetworkFeatures(null!=this.routeInfo?new i([this.routeInfo]):null,this.defaultSymbols.routeInfo,"esriGeometryPolyline",U.fields,"RouteInfo","Route Details")}_writeStops(){const e=this._writeNetworkFeatures(this.stops,null,"esriGeometryPoint",V.fields,"Stops","Stops");if(null==e)return null;const{stops:t}=this.defaultSymbols,r=t?.first?.toJSON(),o=t?.middle?.toJSON(),i=t?.last?.toJSON();return e.layerDefinition.drawingInfo.renderer={type:"uniqueValue",field1:"Sequence",defaultSymbol:o,uniqueValueInfos:[{value:"1",symbol:r,label:"First Stop"},{value:`${this.stops.length}`,symbol:i,label:"Last Stop"}]},e}};e([y({readOnly:!0,json:{read:!1,origins:{"portal-item":{write:{allowNull:!0,ignoreOrigin:!0}},"web-map":{write:{overridePolicy(){return{allowNull:!0,ignoreOrigin:null==this.portalItem}}}}}}})],we.prototype,"_featureCollection",void 0),e([h(["web-map","portal-item"],"_featureCollection")],we.prototype,"writeFeatureCollectionWebmap",null),e([y({readOnly:!0,json:{read:!1,origins:{"web-map":{write:{target:"type",overridePolicy(){return{ignoreOrigin:null!=this.portalItem}}}}}}})],we.prototype,"_type",void 0),e([y({type:String})],we.prototype,"checksum",void 0),e([y({nonNullable:!0,type:L})],we.prototype,"defaultSymbols",void 0),e([y({readOnly:!0})],we.prototype,"directionLines",void 0),e([f(["web-map","portal-item"],"directionLines",["layers","featureCollection.layers"])],we.prototype,"readDirectionLines",null),e([y({readOnly:!0})],we.prototype,"directionPoints",void 0),e([f(["web-map","portal-item"],"directionPoints",["layers","featureCollection.layers"])],we.prototype,"readDirectionPoints",null),e([y({readOnly:!0,json:{read:!1,origins:{"web-map":{write:{ignoreOrigin:!0}}}}})],we.prototype,"featureCollectionType",void 0),e([y({readOnly:!0})],we.prototype,"fullExtent",null),e([y({json:{origins:{"web-map":{name:"featureCollection.showLegend"}},write:!0}})],we.prototype,"legendEnabled",void 0),e([y({type:["show","hide"]})],we.prototype,"listMode",void 0),e([y({type:Number,nonNullable:!0,json:{write:!1}})],we.prototype,"maxScale",void 0),e([f(["web-map","portal-item"],"maxScale",["layers","featureCollection.layers"])],we.prototype,"readMaxScale",null),e([y({type:Number,nonNullable:!0,json:{write:!1}})],we.prototype,"minScale",void 0),e([f(["web-map","portal-item"],"minScale",["layers","featureCollection.layers"])],we.prototype,"readMinScale",null),e([y({type:["ArcGISFeatureLayer"],value:"ArcGISFeatureLayer"})],we.prototype,"operationalLayerType",void 0),e([y({nonNullable:!0,type:i.ofType(J)})],we.prototype,"pointBarriers",void 0),e([f(["web-map","portal-item"],"pointBarriers",["layers","featureCollection.layers"])],we.prototype,"readPointBarriers",null),e([y({nonNullable:!0,type:i.ofType(M)})],we.prototype,"polygonBarriers",void 0),e([f(["web-map","portal-item"],"polygonBarriers",["layers","featureCollection.layers"])],we.prototype,"readPolygonBarriers",null),e([y({nonNullable:!0,type:i.ofType(E)})],we.prototype,"polylineBarriers",void 0),e([f(["web-map","portal-item"],"polylineBarriers",["layers","featureCollection.layers"])],we.prototype,"readPolylineBarriers",null),e([y({readOnly:!0})],we.prototype,"routeInfo",void 0),e([f(["web-map","portal-item"],"routeInfo",["layers","featureCollection.layers"])],we.prototype,"readRouteInfo",null),e([y({type:B})],we.prototype,"spatialReference",void 0),e([f(["web-map","portal-item"],"spatialReference",["layers","featureCollection.layers"])],we.prototype,"readSpatialReference",null),e([y({nonNullable:!0,type:i.ofType(V)})],we.prototype,"stops",void 0),e([f(["web-map","portal-item"],"stops",["layers","featureCollection.layers"])],we.prototype,"readStops",null),e([y()],we.prototype,"title",null),e([y({readOnly:!0,json:{read:!1}})],we.prototype,"type",void 0),e([y()],we.prototype,"url",null),we=e([d(de)],we);const ge=we;export{ge as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.32/esri/copyright.txt for details.
4
4
  */
5
- import{throwIfAborted as e}from"../../../core/promiseUtils.js";import{create as t}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{zeros as r}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{transpose as n}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{a,g as o}from"../../../chunks/vec32.js";import i from"../../../geometry/Circle.js";import c from"../../../geometry/Mesh.js";import s from"../../../geometry/Multipoint.js";import f from"../../../geometry/Polygon.js";import{projectWithZConversion as l}from"../../../geometry/projection.js";import m from"../../../geometry/SpatialReference.js";import{earth as u}from"../../../geometry/support/Ellipsoid.js";import h from"../../../geometry/support/MeshComponent.js";import{MeshVertexAttributes as p}from"../../../geometry/support/MeshVertexAttributes.js";import{intersectRay as y,create as g,fromArray as x}from"../../../geometry/support/plane.js";import{isWebMercator as d}from"../../../geometry/support/spatialReferenceUtils.js";import{getWebMercatorScalingFactor as w,createRotationMatrixFromHPR as M,transformMat3 as R,scaleAndAddWithFactor as j,scaleWithFactor as v,computeHFOVAndVFOV as P,projectiveTransform as D}from"../transformations/utils.js";const b=Math.PI/180;function A(e){return e.isSpherical?H(e):I(e)}function I(e){const{horizontalFieldOfView:t,verticalFieldOfView:r,geometry:n,cameraHeading:a}=e,o=w(n.y,n.spatialReference);let i=e.cameraPitch,c=e.cameraRoll??0,s=150;t>150&&(i=90,c=0,s=5);const l=Math.ceil(t/s),m=z(l,a,t);let u=e.farDistance?e.farDistance*o:e.cameraHeight*o/Math.cos(i*b);e.cameraPitch+r/2>=90&&(u=(e.farDistance||20)*o);const h=new f({spatialReference:n?.spatialReference});h.imageID=e.objectId;let p=null;for(const f of m)p=V(f,i,e.cameraHeight,n,u,o,r,t,l,h,c,e.nearDistance);return p.imageID=e.objectId,{polygon:h,frustum:p}}function z(e,t,r){const n=[];if(e%2==0)for(let a=0;a<e/2;a++)n.push(t-r/e*(a+.5),t+r/e*(a+.5));else{n.push(t);for(let a=1;a<e/2;a++)n.push(t-r/e*a,t+r/e*a)}return n.sort(),n}function V(e,i,c,s,f,l,m,u,h,p,y=0,g=0){const x=n(t(),M([e,i,y??0])),d=q({cameraHeight:c,cameraPitch:i,farDistance:f,location:s,horizontalFieldOfView:u,nearDistance:g,verticalFieldOfView:m},x),w=R([0,0,-1],x),{x:P,y:D}=s,A=j([P,D,c],w,f,l),I=2*Math.tan(m*b/2)*f,z=2*Math.tan(u/h*b/2)*f,V=R([0,1,0],x),H=R([1,0,0],x),O=v(V,I/2,l),S=v(H,z/2,l),C=a(r(),O,S),U=o(r(),O,S),E=F([o(r(),A,C),o(r(),A,U),a(r(),A,C),a(r(),A,U)],c,s,l);return E.push(E[0]),p.addRing(E),d}function F(e,t,r,n){return e.map((e=>C(e,t,r,n)))}function H(e){const{geometry:t,farDistance:r,objectId:n,nearDistance:a,cameraHeight:o}=e,s=w(t.y,t.spatialReference),f=new i({center:t.clone(),radius:r*s});if(f.imageID=n,a){const e=new i({center:t.clone(),radius:a*s});f.addRing(e.rings[0])}const l=t.clone();l.z=o-r*s;const m=c.createSphere(l,{size:2*r*s});return m.imageID=n,{polygon:f,frustum:m}}function O(e,t){return e.contains(t)}function S(e,t){return Math.sign(e)!==Math.sign(t)}function q(e,t,n){const{cameraHeight:i,cameraPitch:s,farDistance:f,location:l,horizontalFieldOfView:m,nearDistance:u,verticalFieldOfView:h}=e,y=E(l),g=s+h/2>=90==!1,x=2*Math.tan(h*b/2)*u,d=2*Math.tan(m*b/2)*u,w=2*Math.tan(h*b/2)*f,M=2*Math.tan(m*b/2)*f;let P,D;D=[0,0,-1],D=R(D,t),P=j([l.x,l.y,i],D,f,y),g&&(P[2]=0);const A=j([l.x,l.y,i],D,u,y);let I=[0,1,0];I=R(I,t);let z=[1,0,0];z=R(z,t);let V=[],F=[];u?(F=[{faces:[4,0,3,4,7,3]},{faces:[5,1,2,5,6,2]},{faces:[4,0,1,4,5,1]},{faces:[6,2,3,6,7,3]}],V=V.concat(o(r(),A,a(r(),v(I,x/2,y),v(z,d/2,y)))),V=V.concat(o(r(),A,o(r(),v(I,x/2,y),v(z,d/2,y)))),V=V.concat(a(r(),A,a(r(),v(I,x/2,y),v(z,d/2,y)))),V=V.concat(a(r(),A,o(r(),v(I,x/2,y),v(z,d/2,y))))):(V=[l.x,l.y,i],F=[{faces:[0,1,2,0,2,3,0,3,4,0,4,1]}]),V=V.concat(o(r(),P,a(r(),v(I,w/2,y),v(z,M/2,y)))),V=V.concat(o(r(),P,o(r(),v(I,w/2,y),v(z,M/2,y)))),V=V.concat(a(r(),P,a(r(),v(I,w/2,y),v(z,M/2,y)))),V=V.concat(a(r(),P,o(r(),v(I,w/2,y),v(z,M/2,y))));const H=new p({position:Float64Array.from(V)});return new c({vertexAttributes:H,components:F,spatialReference:l.spatialReference})}function C(e,t,n,o){{const i=Math.sqrt((e[2]-t)**2+(Math.sqrt((e[0]-n.x)**2+(e[1]-n.y)**2)/o)**2)*o,c=v(a(r(),[e[0],e[1],e[2]],[n.x,n.y,t]),1/i,1/o),s=t/(t-e[2]),f={x:(1-s)*n.x+s*e[0],y:(1-s)*n.y+s*e[1],z:(1-s)*t+s*e[2]},l=Math.sqrt((f.z-t)**2+(Math.sqrt((f.x-n.x)**2+(f.y-n.y)**2)/o)**2)*o,m=v(a(r(),[f.x,f.y,f.z],[n.x,n.y,t]),1/l,1/o);return S(c[0],m[0])&&S(c[1],m[1])&&S(c[2],m[2])||e[2]>=0?[e[0],e[1],0]:[f.x,f.y,f.z]}}function U(e){const{spatialReference:t,x:r,y:n}=e.geometry,{cameraHeading:a,cameraPitch:o,farDistance:i,nearDistance:c}=e,s=E(e.geometry),l=new f({spatialReference:t}),m=Math.abs(1.44*i*s);let u=Math.abs(1.44*c*s);(o<20||null==a)&&(u=m);const h=[];return h[0]={x:r+m*Math.sin((a-45)*b),y:n+m*Math.cos((a-45)*b)},h[1]={x:r+m*Math.sin((a+45)*b),y:n+m*Math.cos((a+45)*b)},h[2]={x:r+u*Math.sin((a+135)*b),y:n+u*Math.cos((a+135)*b)},h[3]={x:r+u*Math.sin((a+225)*b),y:n+u*Math.cos((a+225)*b)},l.addRing([[h[0].x,h[0].y,0],[h[1].x,h[1].y,0],[h[2].x,h[2].y,0],[h[3].x,h[3].y,0],[h[0].x,h[0].y,0]]),l}function E(e){return e&&d(e?.spatialReference)?1/Math.cos(Math.PI/2-2*Math.atan(Math.exp(-1*e.y/u.radius))):1}function k(e,t){const n=1+t/100;if("esri.geometry.Circle"===e.declaredClass){const{radius:t,center:r}=e,a=new i({radius:t*n,center:r});return e.rings.length>1&&a.addRing(e.rings[1]),a}if("esri.geometry.Polygon"===e.declaredClass){const t=new f({spatialReference:e.spatialReference}),o=e.centroid;if(o){const i=[];for(let t=0;t<e.rings[0].length;t++){const c=Math.sqrt((o.x-e.rings[0][t][0])**2+(o.y-e.rings[0][t][1])**2),s=v(a(r(),[e.rings[0][t][0],e.rings[0][t][1],0],[o.x,o.y,0]),1/c,1),f=j([o.x,o.y,0],s,c*n,1);i.push({x:f[0],y:f[1]})}t.addRing([[i[0].x,i[0].y,0],[i[1].x,i[1].y,0],[i[2].x,i[2].y,0],[i[3].x,i[3].y,0],[i[0].x,i[0].y,0]])}return t}return e}async function L(e,t,r){const{cameraHeight:n,cameraLocation:a,cameraPitch:o,frustumVertices:i,horizontalFieldOfView:c,imageHeight:s,imageWidth:f,inSRS:l,outSRS:u,verticalFieldOfView:h,cameraRoll:p,options:y}=r,g=new m(l),x=new m(u),d=P(c,h,p??0),w=i.length>15;return o+d.vfov/2>=90?await K(i,e,f,s,g,x,w,y):await W(i,e,t,a,n,w,g,x,y)}async function W(e,t,r,n,a,o,i,s,f){const l=B(e,t,r,n,a);if(!l)return;const{farPlane:m,nearPlane:u}=l,h=await N([...u?.vertexPositions??e.slice(0,3),...m.vertexPositions],i,s,f),y=Z(h);return new c({vertexAttributes:new p({position:h}),components:Y(o?T(y,!0):X(y,!0)),spatialReference:s})}function B(e,t,r,n,a){const o=Q(e),i=Q(e,"near");if(!o)return;const c=t.length;for(let s=0;s<c;s++){const e=Array.from(r[s]),t=[e[0]-n[0],e[1]-n[1],e[2]-(n[2]??a)];J(n,t,s,i),G(n,t,s,o)}return{farPlane:o,nearPlane:i}}function G(e,t,n,a){const{coefficients:o,vertexPositions:i}=a,c=r();y(o,{origin:e,direction:t},c)&&i.splice(3*n,3,...c)}function J(e,t,n,a){if(!a)return;const o=r();y(a.coefficients,{origin:e,direction:t},o)&&a.vertexPositions.splice(3*n,3,...o)}async function K(e,t,r,n,a,o,i,s){let f,l=i?new Array:[e[0],e[1],e[2]],m=new Array;for(const c of t)i?(f=D([c[0],c[1],1],[[0,0,1],[r,0,1],[r,n,1],[0,n,1]],[[e[0],e[1],e[2]],[e[3],e[4],e[5]],[e[6],e[7],e[8]],[e[9],e[10],e[11]]]),l=l.concat(...f),f=D([c[0],c[1],1],[[0,0,1],[r,0,1],[r,n,1],[0,n,1]],[[e[12],e[13],e[14]],[e[15],e[16],e[17]],[e[18],e[19],e[20]],[e[21],e[22],e[23]]]),m=m.concat(...f)):(f=D([c[0],c[1],1],[[0,0,1],[r,0,1],[r,n,1],[0,n,1]],[[e[3],e[4],e[5]],[e[6],e[7],e[8]],[e[9],e[10],e[11]],[e[12],e[13],e[14]]]),l=l.concat(...f));l=l.concat(m);const u=await N(l,a,o,s),h=Z(u);return new c({vertexAttributes:new p({position:u}),components:Y(i?T(h,!0):X(h,!0)),spatialReference:o})}async function N(t,r,n,a){if(r.equals(n))return t;const o=t.reduce(((e,t,r)=>{const n=Math.floor(r/3);return e[n]||(e[n]=new Array),e[n].push(t),e}),new Array),{points:i}=await l(new s(o,r),n,a);return e(a),i.flat()}function Q(e,t="far"){const r=g();let n;switch(t){case"far":if(n=Array.from(15===e.length?e.slice(3):e.slice(12)),x(r,n,!0))return{coefficients:r,vertexPositions:n};break;case"near":if(n=Array.from(e.slice(0,12)),15===e.length||!x(r,n,!0))return;return{coefficients:r,vertexPositions:n}}}const T=(e,t=!1)=>{if(t&&e-2<=4||e<=4||e%2!=0)throw new Error("Invalid number of vertices");const r=[],n=e/2,a=Math.round((t?e-2:e)/2);for(let o=0;o<a;o++){const a=o+n,i=t?a+1:a,c=i%e,s=(t?a:i+1)%e;r.push({faces:new Uint32Array([o,s,c,o,o+1,c])})}return r};function X(e,t=!1){if(e<3||t&&e-1<3)throw new Error("Invalid number of vertices");const r=[],n=t?e-2:e-1;for(let a=0;a<n;a++)r.push({faces:new Uint32Array([0,a+1,a+2])});return r}const Y=e=>e.map((e=>new h(e))),Z=e=>e.length/3;export{O as checkIfPolygonContainsSelectedPoint,U as computePolygonForInspection,A as createCoveragePolygon,F as limitZToGround,N as projectVertices,k as resizePolygon,L as updateFrustum};
5
+ import{throwIfAborted as e}from"../../../core/promiseUtils.js";import{create as t}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{zeros as r}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{transpose as n}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{a,g as o}from"../../../chunks/vec32.js";import i from"../../../geometry/Circle.js";import c from"../../../geometry/Mesh.js";import s from"../../../geometry/Multipoint.js";import f from"../../../geometry/Polygon.js";import{projectWithZConversion as l}from"../../../geometry/projection.js";import m from"../../../geometry/SpatialReference.js";import{earth as u}from"../../../geometry/support/Ellipsoid.js";import h from"../../../geometry/support/MeshComponent.js";import{MeshVertexAttributes as p}from"../../../geometry/support/MeshVertexAttributes.js";import{intersectRay as y,create as g,fromArray as x}from"../../../geometry/support/plane.js";import{isWebMercator as d}from"../../../geometry/support/spatialReferenceUtils.js";import{getWebMercatorScalingFactor as w,createRotationMatrixFromHPR as M,transformMat3 as R,scaleAndAddWithFactor as j,scaleWithFactor as v,computeHFOVAndVFOV as P,projectiveTransform as D}from"../transformations/utils.js";const b=Math.PI/180;function A(e){return e.isSpherical?H(e):I(e)}function I(e){const{horizontalFieldOfView:t,verticalFieldOfView:r,geometry:n,cameraHeading:a}=e,o=w(n.y,n.spatialReference);let i=e.cameraPitch,c=e.cameraRoll??0,s=150;t>150&&(i=90,c=0,s=5);const l=Math.ceil(t/s),m=z(l,a,t);let u=e.farDistance?e.farDistance*o:e.cameraHeight*o/Math.cos(i*b);e.cameraPitch+r/2>=90&&(u=(e.farDistance||20)*o);const h=new f({spatialReference:n?.spatialReference});h.imageID=e.objectId;let p=null;for(const f of m)p=V(f,i,e.cameraHeight,n,u,o,r,t,l,h,c,e.nearDistance);return p.imageID=e.objectId,{polygon:h,frustum:p}}function z(e,t,r){const n=[];if(e%2==0)for(let a=0;a<e/2;a++)n.push(t-r/e*(a+.5),t+r/e*(a+.5));else{n.push(t);for(let a=1;a<e/2;a++)n.push(t-r/e*a,t+r/e*a)}return n.sort(),n}function V(e,i,c,s,f,l,m,u,h,p,y=0,g=0){const x=n(t(),M([e,i,y??0])),d=q({cameraHeight:c,cameraPitch:i,farDistance:f,location:s,horizontalFieldOfView:u,nearDistance:g,verticalFieldOfView:m},x),w=R([0,0,-1],x),{x:P,y:D}=s,A=j([P,D,c],w,f,l),I=2*Math.tan(m*b/2)*f,z=2*Math.tan(u/h*b/2)*f,V=R([0,1,0],x),H=R([1,0,0],x),O=v(V,I/2,l),S=v(H,z/2,l),C=a(r(),O,S),U=o(r(),O,S),E=F([o(r(),A,C),o(r(),A,U),a(r(),A,C),a(r(),A,U)],c,s,l);return E.push(E[0]),p.addRing(E),d}function F(e,t,r,n){return e.map((e=>C(e,t,r,n)))}function H(e){const{geometry:t,farDistance:r,objectId:n,nearDistance:a,cameraHeight:o}=e,s=w(t.y,t.spatialReference),f=new i({center:t.clone(),radius:r*s});if(f.imageID=n,a){const e=new i({center:t.clone(),radius:a*s});f.addRing(e.rings[0])}const l=t.clone();l.z=o-r*s;const m=c.createSphere(l,{size:2*r*s});return m.imageID=n,{polygon:f,frustum:m}}function O(e,t){return e.contains(t)}function S(e,t){return Math.sign(e)!==Math.sign(t)}function q(e,t,n){const{cameraHeight:i,cameraPitch:s,farDistance:f,location:l,horizontalFieldOfView:m,nearDistance:u,verticalFieldOfView:h}=e,y=E(l),g=s+h/2>=90==!1,x=2*Math.tan(h*b/2)*u,d=2*Math.tan(m*b/2)*u,w=2*Math.tan(h*b/2)*f,M=2*Math.tan(m*b/2)*f;let P,D;D=[0,0,-1],D=R(D,t),P=j([l.x,l.y,i],D,f,y),g&&(P[2]=0);const A=j([l.x,l.y,i],D,u,y);let I=[0,1,0];I=R(I,t);let z=[1,0,0];z=R(z,t);let V=[],F=[];u?(F=[{faces:[4,0,3,4,7,3]},{faces:[5,1,2,5,6,2]},{faces:[4,0,1,4,5,1]},{faces:[6,2,3,6,7,3]}],V=V.concat(o(r(),A,a(r(),v(I,x/2,y),v(z,d/2,y)))),V=V.concat(o(r(),A,o(r(),v(I,x/2,y),v(z,d/2,y)))),V=V.concat(a(r(),A,a(r(),v(I,x/2,y),v(z,d/2,y)))),V=V.concat(a(r(),A,o(r(),v(I,x/2,y),v(z,d/2,y))))):(V=[l.x,l.y,i],F=[{faces:[0,1,2,0,2,3,0,3,4,0,4,1]}]),V=V.concat(o(r(),P,a(r(),v(I,w/2,y),v(z,M/2,y)))),V=V.concat(o(r(),P,o(r(),v(I,w/2,y),v(z,M/2,y)))),V=V.concat(a(r(),P,a(r(),v(I,w/2,y),v(z,M/2,y)))),V=V.concat(a(r(),P,o(r(),v(I,w/2,y),v(z,M/2,y))));const H=new p({position:Float64Array.from(V)});return new c({vertexAttributes:H,components:F,spatialReference:l.spatialReference})}function C(e,t,n,o){{const i=Math.sqrt((e[2]-t)**2+(Math.sqrt((e[0]-n.x)**2+(e[1]-n.y)**2)/o)**2)*o,c=v(a(r(),[e[0],e[1],e[2]],[n.x,n.y,t]),1/i,1/o),s=t/(t-e[2]),f={x:(1-s)*n.x+s*e[0],y:(1-s)*n.y+s*e[1],z:(1-s)*t+s*e[2]},l=Math.sqrt((f.z-t)**2+(Math.sqrt((f.x-n.x)**2+(f.y-n.y)**2)/o)**2)*o,m=v(a(r(),[f.x,f.y,f.z],[n.x,n.y,t]),1/l,1/o);return S(c[0],m[0])&&S(c[1],m[1])&&S(c[2],m[2])||e[2]>=0?[e[0],e[1],0]:[f.x,f.y,f.z]}}function U(e){const{spatialReference:t,x:r,y:n}=e.geometry,{cameraHeading:a,cameraPitch:o,farDistance:i,nearDistance:c}=e,s=E(e.geometry),l=new f({spatialReference:t}),m=Math.abs(1.44*i*s);let u=Math.abs(1.44*c*s);(o<20||null==a)&&(u=m);const h=[];return h[0]={x:r+m*Math.sin((a-45)*b),y:n+m*Math.cos((a-45)*b)},h[1]={x:r+m*Math.sin((a+45)*b),y:n+m*Math.cos((a+45)*b)},h[2]={x:r+u*Math.sin((a+135)*b),y:n+u*Math.cos((a+135)*b)},h[3]={x:r+u*Math.sin((a+225)*b),y:n+u*Math.cos((a+225)*b)},l.addRing([[h[0].x,h[0].y,0],[h[1].x,h[1].y,0],[h[2].x,h[2].y,0],[h[3].x,h[3].y,0],[h[0].x,h[0].y,0]]),l}function E(e){return e&&d(e?.spatialReference)?1/Math.cos(Math.PI/2-2*Math.atan(Math.exp(-1*e.y/u.radius))):1}function k(e,t){const n=1+t/100;if("esri.geometry.Circle"===e.declaredClass){const{radius:t,center:r}=e,a=new i({radius:t*n,center:r});return e.rings.length>1&&a.addRing(e.rings[1]),a}if("esri.geometry.Polygon"===e.declaredClass){const t=new f({spatialReference:e.spatialReference}),o=e.centroid;if(o){const i=[];for(let t=0;t<e.rings[0].length;t++){const c=Math.sqrt((o.x-e.rings[0][t][0])**2+(o.y-e.rings[0][t][1])**2),s=v(a(r(),[e.rings[0][t][0],e.rings[0][t][1],0],[o.x,o.y,0]),1/c,1),f=j([o.x,o.y,0],s,c*n,1);i.push({x:f[0],y:f[1]})}t.addRing([[i[0].x,i[0].y,0],[i[1].x,i[1].y,0],[i[2].x,i[2].y,0],[i[3].x,i[3].y,0],[i[0].x,i[0].y,0]])}return t}return e}async function L(e,t,r){const{cameraHeight:n,cameraLocation:a,cameraPitch:o,frustumVertices:i,horizontalFieldOfView:c,imageHeight:s,imageWidth:f,inSRS:l,outSRS:u,verticalFieldOfView:h,cameraRoll:p,options:y}=r,g=new m(l),x=new m(u),d=P(c,h,p??0),w=i.length>15;return o+d.vfov/2>=90?await K(i,e,f,s,g,x,w,y):await W(i,e,t,a,n,w,g,x,y)}async function W(e,t,r,n,a,o,i,s,f){const l=B(e,t,r,n,a);if(!l)return;const{farPlane:m,nearPlane:u}=l,h=await N([...u?.vertexPositions??e.slice(0,3),...m.vertexPositions],i,s,f),y=Z(h);return new c({vertexAttributes:new p({position:h}),components:Y(o?T(y,!0):X(y,!0)),spatialReference:s})}function B(e,t,r,n,a){const o=Q(e),i=Q(e,"near");if(!o)return;const c=t.length;for(let s=0;s<c;s++){const e=Array.from(r[s]),t=[e[0]-n[0],e[1]-n[1],e[2]-(n[2]??a)];J(n,t,s,i),G(n,t,s,o)}return{farPlane:o,nearPlane:i}}function G(e,t,n,a){const{coefficients:o,vertexPositions:i}=a,c=r();y(o,{origin:e,direction:t},c)&&i.splice(3*n,3,...c)}function J(e,t,n,a){if(!a)return;const o=r();y(a.coefficients,{origin:e,direction:t},o)&&a.vertexPositions.splice(3*n,3,...o)}async function K(e,t,r,n,a,o,i,s){let f,l=i?new Array:[e[0],e[1],e[2]],m=new Array;for(const c of t)i?(f=D([c[0],c[1],1],[[0,0,1],[r,0,1],[r,n,1],[0,n,1]],[[e[0],e[1],e[2]],[e[3],e[4],e[5]],[e[6],e[7],e[8]],[e[9],e[10],e[11]]]),l=l.concat(...f),f=D([c[0],c[1],1],[[0,0,1],[r,0,1],[r,n,1],[0,n,1]],[[e[12],e[13],e[14]],[e[15],e[16],e[17]],[e[18],e[19],e[20]],[e[21],e[22],e[23]]]),m=m.concat(...f)):(f=D([c[0],c[1],1],[[0,0,1],[r,0,1],[r,n,1],[0,n,1]],[[e[3],e[4],e[5]],[e[6],e[7],e[8]],[e[9],e[10],e[11]],[e[12],e[13],e[14]]]),l=l.concat(...f));l=l.concat(m);const u=await N(l,a,o,s),h=Z(u);return new c({vertexAttributes:new p({position:u}),components:Y(i?T(h,!0):X(h,!0)),spatialReference:o})}async function N(t,r,n,a){if(r.equals(n))return t;const o=t.reduce(((e,t,r)=>{const n=Math.floor(r/3);return e[n]||(e[n]=new Array),e[n].push(t),e}),new Array),{points:i}=await l(new s(o,r),n,a);return e(a),i.flat()}function Q(e,t="far"){const r=g();let n;switch(t){case"far":if(n=Array.from(15===e.length?e.slice(3):e.slice(12)),x(r,n,!1))return{coefficients:r,vertexPositions:n};break;case"near":if(n=Array.from(e.slice(0,12)),15===e.length||!x(r,n,!1))return;return{coefficients:r,vertexPositions:n}}}const T=(e,t=!1)=>{if(t&&e-2<=4||e<=4||e%2!=0)throw new Error("Invalid number of vertices");const r=[],n=e/2,a=Math.round((t?e-2:e)/2);for(let o=0;o<a;o++){const a=o+n,i=t?a+1:a,c=i%e,s=(t?a:i+1)%e;r.push({faces:new Uint32Array([o,s,c,o,o+1,c])})}return r};function X(e,t=!1){if(e<3||t&&e-1<3)throw new Error("Invalid number of vertices");const r=[],n=t?e-2:e-1;for(let a=0;a<n;a++)r.push({faces:new Uint32Array([0,a+1,a+2])});return r}const Y=e=>e.map((e=>new h(e))),Z=e=>e.length/3;export{O as checkIfPolygonContainsSelectedPoint,U as computePolygonForInspection,A as createCoveragePolygon,F as limitZToGround,N as projectVertices,k as resizePolygon,L as updateFrustum};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.32/esri/copyright.txt for details.
4
4
  */
5
- import{isArrayLike as e}from"../../../core/arrayUtils.js";import{clone as r,zeros as a}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{a as t}from"../../../chunks/vec32.js";import i from"../../../geometry/Point.js";import{fromPoints as o,fromValues as n}from"../../../geometry/support/ray.js";import{l as c,j as s}from"../../../chunks/sphere.js";import{isElevationSource as f}from"../core/ElevationSourceDefinitions.js";import{rectifyMapPoint as m,rectifyMapPointPanoramic as l}from"./rectifyMapPoint.js";import{or as p,isUpdateElevationWithElevationSource as y,isElevationSampler as u,scaleWithFactor as h,scaleAndAddWithFactor as d,computeNewReferenceCoordinates as g,projectiveTransform as w,validatePixelsToTransform as v,validateRotationMatrix as x,getWebMercatorScalingFactor as j,computeFarplaneVertices as A,computeHFOVAndVFOV as P,vecToPoint as R,hasAngles as V,convertPixelToHeadingPitch as F,convertHeadingPitchToSphereVertex as M,reducerFn as T}from"./utils.js";import{worldToImage as b}from"./worldToImage.js";import{defaultImageSphereCenter as L}from"../../../widgets/PanoramicViewer/constants.js";async function O(e,r,a){const{verticalFieldOfView:t,imageBoundaries:i,scalingFactor:o,farPlaneVertices:n,cameraLocation:c,pixelsToTransform:s,vecToPoint:f}=z(e,r),m=new Array;return await E(s,n,i,f,r,m,c,o,t,a),Array.isArray(e)?m:m[0]}async function E(e,r,a,t,i,o,n,c,s,f){for(const l of e){let e=q(r,a,l,t,i);f&&p(u(f.elevationSample),y(f))&&(e=await m(t(e),{x:l[0],y:l[1]},{...i,...f,farPlaneVertices:r.map(t)})),o.push(t(k(e,n,c,i.averageElevation,i.cameraPitch,s)))}}function k(e,i,o,n,c,s){let f=r(e);const m=Math.sqrt((e[2]-i[2])**2+(Math.sqrt((e[0]-i[0])**2+(e[1]-i[1])**2)/o)**2)*o,l=h(t(a(),e,i),1/m,1/o);if(S(e[2],n,c,s)){const e=Math.abs((i[2]-n)/-l[2])*o;f=d(i,l,e,o)}else f[2]=n;return f}function S(e,r,a,t){return e<r||a+t/2<90}function q(e,r,a,t,i){let o=null;const n=9;let c,s=0,f=e,m=r;for(;s<=n;){const e=D(a,m,f,i);if(c=e.error,o=e.transformedPoint,p(c<=1,s===n))break;f=g(f,c,a,r),m=B(f,t,i),s++}return o}function B(e,r,a){return b(e.map(r),a).map((({x:e,y:r})=>[e,r,1]))}function D(e,r,a,t){const{cameraLocation:o}=t,n=w(e,r,a),{x:c,y:s}=b(new i(n,o.spatialReference),t);return{transformedPoint:n,error:H(e,[c,s,1])}}function H(e,r){return Math.abs(e[0]-r[0])+Math.abs(e[1]-r[1])}function z(r,a){const t=e(r)||"items"in r?r:[r],{cameraLocation:o,rotationMatrix:n}=a;if(v(t,o),x(n),9!==n?.length)throw new Error("Rotation matrix is not provided or is not a valid 3x3 matrix");const c=j(o.y,o.spatialReference),s=A({...a,scalingFactor:c}),f=b(s.map((e=>new i(e,o.spatialReference))),a),{vfov:m}=P(a.horizontalFieldOfView,a.verticalFieldOfView,a.cameraRoll);return{cameraLocation:o.toArray(),imageBoundaries:f.map((({x:e,y:r})=>[e,r,1])),verticalFieldOfView:m,farPlaneVertices:s,scalingFactor:c,pixelsToTransform:t.map((e=>[e.x,e.y,1])),vecToPoint:R(o.spatialReference)}}async function I(e,r,t){const{averageElevation:m,cameraHeading:p,cameraLocation:y,farDistance:h,imageHeight:d,imageWidth:g,verticalFieldOfView:w}=r,v=j(y.y,y.spatialReference),x=new Array,[A,P,R]=y.toArray(),b=c([A,P,R??0],h*v),O=L.toArray(),E=Array.isArray(e)?e:[e];for(const c of E){let e,j;if(V(c))e=c.heading,j=c.pitch;else{const r=F({x:c.x,y:c.y},g,d);e=r.heading,j=r.pitch}e=(e+p)%360;const L=o([O[0],O[1],O[2]],M(e,j)),E=n([A,P,R??0],L.direction);let S=a();s(b,E,S),t&&(f(t)||u(t.elevationSample))&&j+w/2<90&&(S=await l(new i(S,y.spatialReference),{heading:e,pitch:j},{...r,...t,farPlaneVertices:T(h,h).map((([e,r])=>new i([y.x+e,y.y+r],y.spatialReference)))})),S=k(S,y.toArray(),v,m,j,w),x.push(new i(S,y.spatialReference))}return Array.isArray(e)?x:x[0]}export{O as imageToWorld,I as imageToWorldPanoramic};
5
+ import{isArrayLike as e}from"../../../core/arrayUtils.js";import{clone as r,zeros as a}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{a as t}from"../../../chunks/vec32.js";import i from"../../../geometry/Point.js";import{fromPoints as o,fromValues as n}from"../../../geometry/support/ray.js";import{l as c,j as s}from"../../../chunks/sphere.js";import{isElevationSource as f}from"../core/ElevationSourceDefinitions.js";import{rectifyMapPoint as m,rectifyMapPointPanoramic as l}from"./rectifyMapPoint.js";import{or as p,isUpdateElevationWithElevationSource as y,isElevationSampler as u,scaleWithFactor as h,scaleAndAddWithFactor as d,computeNewReferenceCoordinates as g,projectiveTransform as w,validatePixelsToTransform as v,validateRotationMatrix as x,getWebMercatorScalingFactor as j,computeFarplaneVertices as A,computeHFOVAndVFOV as P,vecToPoint as R,hasAngles as V,convertPixelToHeadingPitch as F,convertHeadingPitchToSphereVertex as M,reducerFn as T}from"./utils.js";import{worldToImage as b}from"./worldToImage.js";import{defaultImageSphereCenter as L}from"../../../widgets/PanoramicViewer/constants.js";async function O(e,r,a){const{verticalFieldOfView:t,imageBoundaries:i,scalingFactor:o,farPlaneVertices:n,cameraLocation:c,pixelsToTransform:s,vecToPoint:f}=z(e,r),m=new Array;return await E(s,n,i,f,r,m,c,o,t,a),Array.isArray(e)?m:m[0]}async function E(e,a,t,i,o,n,c,s,f,l){for(const h of e){const e=q(a,t,h,i,o);let d=r(e);l&&p(u(l.elevationSample),y(l))&&(d=await m(i(e),{x:h[0],y:h[1]},{...o,...l,farPlaneVertices:a.map(i)})),n.push(i(k(d,c,s,o.averageElevation,o.cameraPitch,f)))}}function k(e,i,o,n,c,s){let f=r(e);const m=Math.sqrt((e[2]-i[2])**2+(Math.sqrt((e[0]-i[0])**2+(e[1]-i[1])**2)/o)**2)*o,l=h(t(a(),e,i),1/m,1/o);if(S(e[2],n,c,s)){const e=Math.abs((i[2]-n)/-l[2])*o;f=d(i,l,e,o)}else f[2]=n;return f}function S(e,r,a,t){return e<r||a+t/2<90}function q(e,r,a,t,i){let o=null;const n=9;let c,s=0,f=e,m=r;for(;s<=n;){const e=D(a,m,f,i);if(c=e.error,o=e.transformedPoint,p(c<=1,s===n))break;f=g(f,c,a,r),m=B(f,t,i),s++}return o}function B(e,r,a){return b(e.map(r),a).map((({x:e,y:r})=>[e,r,1]))}function D(e,r,a,t){const{cameraLocation:o}=t,n=w(e,r,a),{x:c,y:s}=b(new i(n,o.spatialReference),t);return{transformedPoint:n,error:H(e,[c,s,1])}}function H(e,r){return Math.abs(e[0]-r[0])+Math.abs(e[1]-r[1])}function z(r,a){const t=e(r)||"items"in r?r:[r],{cameraLocation:o,rotationMatrix:n}=a;if(v(t,o),x(n),9!==n?.length)throw new Error("Rotation matrix is not provided or is not a valid 3x3 matrix");const c=j(o.y,o.spatialReference),s=A({...a,scalingFactor:c}),f=b(s.map((e=>new i(e,o.spatialReference))),a),{vfov:m}=P(a.horizontalFieldOfView,a.verticalFieldOfView,a.cameraRoll);return{cameraLocation:o.toArray(),imageBoundaries:f.map((({x:e,y:r})=>[e,r,1])),verticalFieldOfView:m,farPlaneVertices:s,scalingFactor:c,pixelsToTransform:t.map((e=>[e.x,e.y,1])),vecToPoint:R(o.spatialReference)}}async function I(e,r,t){const{averageElevation:m,cameraHeading:p,cameraLocation:y,farDistance:h,imageHeight:d,imageWidth:g,verticalFieldOfView:w}=r,v=j(y.y,y.spatialReference),x=new Array,[A,P,R]=y.toArray(),b=c([A,P,R??0],h*v),O=L.toArray(),E=Array.isArray(e)?e:[e];for(const c of E){let e,j;if(V(c))e=c.heading,j=c.pitch;else{const r=F({x:c.x,y:c.y},g,d);e=r.heading,j=r.pitch}e=(e+p)%360;const L=o([O[0],O[1],O[2]],M(e,j)),E=n([A,P,R??0],L.direction);let S=a();s(b,E,S),t&&(f(t)||u(t.elevationSample))&&j+w/2<90&&(S=await l(new i(S,y.spatialReference),{heading:e,pitch:j},{...r,...t,farPlaneVertices:T(h,h).map((([e,r])=>new i([y.x+e,y.y+r],y.spatialReference)))})),S=k(S,y.toArray(),v,m,j,w),x.push(new i(S,y.spatialReference))}return Array.isArray(e)?x:x[0]}export{O as imageToWorld,I as imageToWorldPanoramic};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.32/esri/copyright.txt for details.
4
4
  */
5
- import{deepClone as e}from"../../../arcade/deepClone.js";import"../../../core/Error.js";import"../../../core/has.js";import"../../../core/Logger.js";import{create as t}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import r from"../../../geometry/Point.js";import a from"../../../geometry/Polygon.js";import{fromPoints as n,intersectLine as o}from"../../../geometry/support/plane.js";import i from"./updateElevation.js";import{pointToArray as c,or as s}from"./utils.js";import{worldToImage as p,worldToImagePanoramic as f}from"./worldToImage.js";async function m(e,a,i,p=h){const{cameraLocation:f,farPlaneVertices:m}=i,l=c(f),w=new Array;await u(m,i,w);let b=n(w[0],w[1],w[2]),j=e.clone();for(let h=0;h<p;h++){const e=t();if(!o(b,l,c(j),e))break;let p=0,m=null;if(({error:p,imagePoint:m,pointWithZ:j}=await y(a,new r(e,f.spatialReference),i)),p<=1)break;const[h,u]=g(f.spatialReference,w);if(s(h<=1,u<=1))break;w.splice(0,w.length,...await x(h,u,new r(e,f.spatialReference),i)),b=n(w[0],w[1],w[2])}return c(j)}async function l(e,a,i,p=h){const{cameraLocation:f,farPlaneVertices:m}=i,l=c(f),w=new Array;await u(m,i,w);let y=n(w[0],w[1],w[2]),j=e.clone();for(let h=0;h<p;h++){const e=t();if(!o(y,l,c(j),e))break;let p,m=0;if(({error:m,imagePoint:p,pointWithZ:j}=await b(a,new r(e,f.spatialReference),i)),m<=1)break;const[h,u]=g(f.spatialReference,w);if(s(h<=1,u<=1))break;w.splice(0,w.length,...await x(h,u,new r(e,f.spatialReference),i)),y=n(w[0],w[1],w[2])}return c(j)}const h=10,w=10;function g(e,t){const r=new a({spatialReference:e});r.addRing(t);return[r.extent?.width?r.extent.width/w:1,r.extent?.height?r.extent.height/w:1]}async function u(t,r,a){const n=e(t),o=await i(n,r);a.push(...o.map(c))}async function y(e,t,r){const a=await i(t,r),n=p(a,r);return{error:j(n,e),imagePoint:n,pointWithZ:a}}async function b(e,t,r){const a=await i(t,r),n=f(a,r);return{error:d(n,e),imagePoint:n,pointWithZ:a}}const j=(e,t)=>Math.abs(e.x-t.x)+Math.abs(e.y-t.y),d=(e,t)=>Math.abs(e.heading-t.heading)+Math.abs(e.pitch-t.pitch);async function x(e,t,a,n){const o=[[-e,-t],[e,-t],[e,t],[-e,t]].map((([e,t])=>new r([a.x+e,a.y+t],a.spatialReference)));return i(o,n).then((e=>e.map((e=>e.toArray()))))}export{m as rectifyMapPoint,l as rectifyMapPointPanoramic};
5
+ import{deepClone as e}from"../../../arcade/deepClone.js";import"../../../core/Error.js";import"../../../core/has.js";import"../../../core/Logger.js";import{create as t}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import r from"../../../geometry/Point.js";import a from"../../../geometry/Polygon.js";import{fromPoints as n,intersectLine as o}from"../../../geometry/support/plane.js";import i from"./updateElevation.js";import{pointToArray as c,or as s}from"./utils.js";import{worldToImage as p,worldToImagePanoramic as f}from"./worldToImage.js";async function m(e,a,i,p=h){const{cameraLocation:f,farPlaneVertices:m}=i,l=c(f),w=new Array;await u(m,i,w);let b=n(w[0],w[1],w[2]),j=e.clone();for(let h=0;h<p;h++){const p=t();if(!o(b,l,c(e),p))break;let m=0,h=null;if(({error:m,imagePoint:h,pointWithZ:j}=await y(a,new r(p,f.spatialReference),i)),m<=1)break;const[u,d]=g(f.spatialReference,w);if(s(u<=1,d<=1))break;w.splice(0,w.length,...await x(u,d,new r(p,f.spatialReference),i)),b=n(w[0],w[1],w[2])}return c(j)}async function l(e,a,i,p=h){const{cameraLocation:f,farPlaneVertices:m}=i,l=c(f),w=new Array;await u(m,i,w);let y=n(w[0],w[1],w[2]),j=e.clone();for(let h=0;h<p;h++){const p=t();if(!o(y,l,c(e),p))break;let m,h=0;if(({error:h,imagePoint:m,pointWithZ:j}=await b(a,new r(p,f.spatialReference),i)),h<=1)break;const[u,d]=g(f.spatialReference,w);if(s(u<=1,d<=1))break;w.splice(0,w.length,...await x(u,d,new r(p,f.spatialReference),i)),y=n(w[0],w[1],w[2])}return c(j)}const h=10,w=10;function g(e,t){const r=new a({spatialReference:e});r.addRing(t);return[r.extent?.width?r.extent.width/w:1,r.extent?.height?r.extent.height/w:1]}async function u(t,r,a){const n=e(t),o=await i(n,r);a.push(...o.map(c))}async function y(e,t,r){const a=await i(t,r),n=p(a,r);return{error:j(n,e),imagePoint:n,pointWithZ:a}}async function b(e,t,r){const a=await i(t,r),n=f(a,r);return{error:d(n,e),imagePoint:n,pointWithZ:a}}const j=(e,t)=>Math.abs(e.x-t.x)+Math.abs(e.y-t.y),d=(e,t)=>Math.abs(e.heading-t.heading)+Math.abs(e.pitch-t.pitch);async function x(e,t,a,n){const o=[[-e,-t],[e,-t],[e,t],[-e,t]].map((([e,t])=>new r([a.x+e,a.y+t],a.spatialReference)));return i(o,n).then((e=>e.map((e=>e.toArray()))))}export{m as rectifyMapPoint,l as rectifyMapPointPanoramic};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.32/esri/copyright.txt for details.
4
4
  */
5
- import t from"../../../core/Error.js";import n from"../../../core/JSONSupport.js";import{deg2rad as a,rad2deg as i}from"../../../core/mathUtils.js";import{create as e}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{create as o,fromValues as r}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{fromArray as c}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{zeros as s}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{multiply as l,transpose as f}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{invertOrIdentity as h,mul as u}from"../../../core/libs/gl-matrix-2/math/mat4.js";import{a as m,g as p}from"../../../chunks/vec32.js";import M from"../../../geometry/Point.js";import{projectWithZConversion as g}from"../../../geometry/projection.js";import{earth as v}from"../../../geometry/support/Ellipsoid.js";import{isWebMercator as d}from"../../../geometry/support/spatialReferenceUtils.js";import{a as x}from"../../../chunks/vec3.js";import{isElevationSource as w,isConstantElevation as y,ConstantElevation as O}from"../core/ElevationSourceDefinitions.js";import{getElevationSampler as b}from"./updateElevationUtils.js";import{isNumber as j}from"../../../support/guards.js";import{defaultImageSphereSize as E}from"../../../widgets/PanoramicViewer/constants.js";function S(t,n,a){const[i,e,r,c]=n,[s,l,f,m]=a;z(i,e,r,c);const p=z(s,l,f,m),M=V(i,e,r,c),g=V(s,l,f,m),v=h(o(),M),d=u(o(),v,g),[x,w,y,O]=P(t,d);return[x/O,w/O,p?0:y/O]}function z(t,n,a,i){return 0===t[2]&&0===n[2]&&0===a[2]&&0===i[2]&&(t[2]=n[2]=a[2]=i[2]=1,!0)}function F(t){return 0===t?1:t}function P(t,n){const[a,i,e]=t,o=[0,0,0,0];return o[0]=a*n[0]+i*n[1]+e*n[2]+n[3],o[1]=a*n[4]+i*n[5]+e*n[6]+n[7],o[2]=a*n[8]+i*n[9]+e*n[10]+n[11],o[3]=F(a*n[12]+i*n[13]+e*n[14]+n[15]),o}function V(t,n,a,i){const e=D(c([...i,1]),h(new Array(16),r(t[0],n[0],a[0],0,t[1],n[1],a[1],0,t[2],n[2],a[2],0,1,1,1,1))),s=e[0],l=e[1],f=e[2],u=o();return u[0]=s*t[0],u[1]=l*n[0],u[2]=f*a[0],u[3]=0,u[4]=s*t[1],u[5]=l*n[1],u[6]=f*a[1],u[7]=0,u[8]=s*t[2],u[9]=l*n[2],u[10]=f*a[2],u[11]=0,u[12]=s,u[13]=l,u[14]=f,u[15]=1,u}function C(t,n,a,i,e=s()){return e[0]=t[0]+n[0]*a,e[1]=t[1]+n[1]*a,e[2]=t[2]+n[2]*(a/i),e}function R(t,n,a){const i=s();return i[0]=t[0]*n,i[1]=t[1]*n,i[2]=t[2]*(n/a),i}function L(t,n){const[a,i,e]=t,o=s();return o[0]=a*n[0]+i*n[3]+e*n[6],o[1]=a*n[1]+i*n[4]+e*n[7],o[2]=a*n[2]+i*n[5]+e*n[8],o}function D(t,n){const[a,i,e,o]=t,r=new Array(4);return r[0]=a*n[0]+i*n[1]+e*n[2]+o*n[3],r[1]=a*n[4]+i*n[5]+e*n[6]+o*n[7],r[2]=a*n[8]+i*n[9]+e*n[10]+o*n[11],r[3]=a*n[12]+i*n[13]+e*n[14]+o*n[15],r}function I(n,i,o,r=!0){if(!Number.isFinite(n))throw new t("InvalidRotationAngle","Please specify a valid angle for rotation");const c=o*(r?a(n):n),s=Math.cos(c),l=Math.sin(c),f=e();switch(i){case 0:f[4]=s,f[5]=-l,f[7]=l,f[8]=s;break;case 1:f[0]=s,f[2]=l,f[6]=-l,f[8]=s;break;case 2:f[0]=s,f[1]=-l,f[3]=l,f[4]=s;break;default:throw new t("InvalidRotationAxis","Please specify either 0, 1 or 2 for X, Y or Z axis respectively")}return f}const N={HPR:[[2,-1],[0,1],[2,-1]],OPK:[[0,1],[1,1],[2,1]]};function H(n,a,i=!0){if(3!==n?.length||3!==a?.length)throw new t("InvalidRotationAngles","Please specify three angles with config for rotation");const o=e();for(let t=0;t<3;t++){const[e,r]=a[t],c=I(n[t],e,r,i);l(o,c,o)}return o}function q(t,n=!0){return H(t,N.OPK,n)}function k(t,n=!0){return H(t,N.HPR,n)}function A(t,n,i){const e=Math.sin(a(i)),o=Math.cos(a(i)),r=[[t,0],[t,n],[0,n]];r.forEach(((t,n)=>{r[n]=[o*t[0]-e*t[1],e*t[0]+o*t[1]]}));const c={xmin:Math.min(0,r[0][0],r[1][0],r[2][0]),xmax:Math.max(0,r[0][0],r[1][0],r[2][0]),ymin:Math.min(0,r[0][1],r[1][1],r[2][1]),ymax:Math.max(0,r[0][1],r[1][1],r[2][1])};return{hfov:Math.abs(c.xmax-c.xmin),vfov:Math.abs(c.ymax-c.ymin)}}function K(t,n){const i=a(t[1]),e=a(t[0]),o=t[2],[r,c,s,l]=n,f=a(r),h=a(c),u=s/Math.sqrt(1-l*Math.sin(f)**2),m=e-h,p=s/Math.sqrt(1-l*Math.sin(f)**2),M=l*(u*Math.sin(f)-p*Math.sin(i));return[(p+o)*Math.cos(i)*Math.sin(m),(p+o)*(Math.sin(i)*Math.cos(f)-Math.sin(f)*Math.cos(f)*Math.cos(m))+M*Math.cos(f),(p+o)*(Math.sin(i)*Math.sin(f)+Math.cos(f)*Math.cos(i)*Math.cos(m))-u+M*Math.sin(f)]}function W(t,n){const e=Number(t[0]),o=Number(t[1]),r=Number(t[2]),[c,s,l,f]=n,h=a(c),u=a(s),m=l/Math.sqrt(1-f*Math.sin(h)**2),p=e/m,M=o/m,g=r/m,v=Math.cos(h)-Math.sin(h)*M+Math.cos(h)*g,d=Math.sin(h)+Math.cos(h)*M+Math.sin(h)*g,x=Math.sqrt(v**2+p**2),w=f*m*Math.sin(h),y=(t,n=5)=>{if(0===n)return t;const a=y(t,n-1);return Math.atan(d/x-(w-f*(l/Math.sqrt(1-f*Math.sin(a)**2))*Math.sin(a))/(m*x))},O=y(h),b=Math.atan(e/(m*v))+u,j=i(O);return[i(b),j,e/(Math.cos(O)*Math.sin(b-u))-l/Math.sqrt(1-f*Math.sin(O)**2)]}function U(t,n,a){const i=360/n,e=180/a;return{heading:(t.x-n/2)*i,pitch:90-(t.y-a/2)*e}}function T(t,n,a,i=E/2){const{heading:e,pitch:o}=X(t,i);return J(e,o,n,a)}function J(t,n,a,i){return{x:a/2+t/(360/a),y:i-n/(180/i),heading:t,pitch:n}}function X(t,n){const a=i(Math.acos(-t.z/n));return{heading:i(Math.atan2(t.x,t.y)),pitch:a}}function Y(t,n,i=E/2){return[i*(Math.sin(a(t))*Math.sin(a(n))),i*(Math.cos(a(t))*Math.sin(a(n))),i*Math.cos(a(180-n))]}async function Z(t,n,a){const e=await g(n,t.spatialReference,a);let o=i(Math.atan2(e.y-t.y,e.x-t.x));return o=o>=0&&o<=90?90-o:o>90&&o<=180?360-o+90:90+Math.abs(o),o}function $(t,n,a){const i=Math.cos(a),e=Math.sin(a),o=[1,0,0,1,0,0],r=o[0]*i+o[2]*e,c=o[1]*i+o[3]*e,s=-o[0]*e+o[2]*i,l=-o[1]*e+o[3]*i;o[0]=r,o[1]=c,o[2]=s,o[3]=l;return[t*o[0]+n*o[2]+o[4],t*o[1]+n*o[3]+o[5]]}const B=t=>t.toArray(),G=(...t)=>t.some((t=>t));function Q(t,n){if(G(0===t.length,t.some((({x:t,y:n})=>G(null==t,null==n))),!n.hasZ))throw new Error("Input pixels must have x, y and camera location must have z value")}function _(t,n){if(t.some((t=>null==t.z))||null==n.z)throw new Error("Input points and camera location must have z value")}function tt(t){if(9!==t?.length)throw new Error("Rotation matrix is not provided or is not a valid 3x3 matrix")}function nt(t,n){return d(n)?1/Math.cos(Math.PI/2-2*Math.atan(Math.exp(-1*t/v.radius))):1}const at=t=>n=>new M(n,t),it=t=>null!=t&&"queryExtent"in t;function et(t,n,a,i){return[[-n,-n],[+n,-n],[+n,+n],[-n,+n]].map((([n,e])=>S(x(s(),a,[n,e,0]),i,t)))}function ot({a0:t,a1:n,a2:a,b0:i,b1:e,b2:o},r,c,s){const l=[t??r/2-.5,n,a??0,i??c/2-.5,e??0,o].map(rt);return null!=s&&ct(l)?{affines:l,focalLength:s}:{affines:[r/2-.5,1,0,c/2-.5,0,-1]}}function rt(t,n){if(null==t)return null;const a=parseFloat(`${t}`);return isNaN(a)?null:a}function ct(t){return null!=t[1]&&null!=t[5]}function st(t,n,a){const{cameraHeight:i,cameraPitch:e,cameraRoll:o,elevation:r,farDistance:c,horizontalFieldOfView:s,location:l,verticalFieldOfView:f}=t,h=r??(l.z??0)-i;return{...ht(t,n,a),averageElevation:h,cameraPitch:e,cameraRoll:o??0,farDistance:c,horizontalFieldOfView:s,verticalFieldOfView:f}}function lt(t,n,a,i){return xt(i)?q([i.omega,i.phi,i.kappa]):wt(i)?k([i.heading,i.pitch,i.roll]):k([t,n,a??0])}function ft(t,n,a){const{cameraHeading:i,cameraHeight:e,elevation:o,farDistance:r,horizontalFieldOfView:c,location:s,verticalFieldOfView:l}=t;return{averageElevation:o??(s.z??0)-e,cameraLocation:s,cameraHeading:i,farDistance:r,horizontalFieldOfView:c,imageHeight:a,imageWidth:n,verticalFieldOfView:l}}function ht(t,n,a){const{a0:i,a1:e,a2:o,b0:r,b1:c,b2:s,cameraHeading:l,cameraOrientation:f,cameraPitch:h,cameraRoll:u,focalLength:m,horizontalFieldOfView:p,location:M,matrix:g,principalX:v,principalY:d,radial:x,tangential:w,verticalFieldOfView:y}=t,{affines:O,focalLength:b}=ot({a0:i,a1:e,a2:o,b0:r,b1:c,b2:s},n,a,m),j=g??lt(l,h,u,f),E=null!=v&&null!=d?[v,d]:void 0;return{affineTransformations:f?.affineTransformations??O,cameraLocation:M.clone(),focalLength:f?.focalLength??b,horizontalFieldOfView:p,imageHeight:a,imageWidth:n,principalOffsetPoint:f?.principalOffsetPoint??E,radialDistortionCoefficients:f?.radialDistortionCoefficients??x,rotationMatrix:j,tangentialDistortionCoefficients:f?.tangentialDistortionCoefficients??w,verticalFieldOfView:y}}const ut=t=>null!=t&&"elevationSample"in t&&null!=t.elevationSample,mt=t=>w(t?.elevationSource)&&null!=t?.extent,pt=t=>y(t?.elevationSource),Mt=async(t,a)=>null!=a&&(ut(a)||pt(a))?a:mt(a)?{elevationSample:await b({...n.isSerializable(a.elevationSource)?a.elevationSource.toJSON():a.elevationSource,extent:a.extent}),elevationSource:new O({constantElevation:t})}:{elevationSource:new O({constantElevation:t})},gt=t=>j(t?.heading)&&j(t?.pitch),vt=(t,n)=>[[-t,-n],[t,-n],[t,n],[-t,n]];function dt(t){const{cameraLocation:n,farDistance:i,horizontalFieldOfView:o,rotationMatrix:r,scalingFactor:c,verticalFieldOfView:l}=t,h=e();f(h,r);const u=2*Math.tan(a(l)/2)*i*c,M=2*Math.tan(a(o)/2)*i*c,g=L([0,0,-1],h),v=C([n.x,n.y,n.z],g,t.farDistance*c,c),d=L([0,1,0],h),x=L([1,0,0],h),w=R(d,u/2,c),y=R(x,M/2,c),O=m(s(),w,y),b=p(s(),w,y);return[p(s(),v,O),p(s(),v,b),m(s(),v,O),m(s(),v,b)]}const xt=t=>2===t?.type,wt=t=>1===t?.type;function yt(t,n,a){if("panoramic"===t){const[t,i]=a;return T({x:n.x,y:n.y,z:n.z},t,i)}return{x:n.x+.5,y:.5-n.y}}var Ot;!function(t){t[t.CLOCKWISE=-1]="CLOCKWISE",t[t.COUNTERCLOCKWISE=1]="COUNTERCLOCKWISE"}(Ot||(Ot={}));export{dt as computeFarplaneVertices,A as computeHFOVAndVFOV,et as computeNewReferenceCoordinates,Y as convertHeadingPitchToSphereVertex,J as convertOrientationToPixelLocation,U as convertPixelToHeadingPitch,X as convertSphereVertexToOrientation,T as convertSphereVertexToPixelLocation,H as createRotationMatrix,k as createRotationMatrixFromHPR,q as createRotationMatrixFromOPK,K as geographicToLTP,ot as getAffinesAndFocalLength,ft as getImageToWorldPanoramicProperties,st as getImageToWorldProperties,Z as getInitialAngle,Mt as getUpdateElevationProps,nt as getWebMercatorScalingFactor,ht as getWorldToImageProperties,gt as hasAngles,wt as hasHeadingPitchRoll,xt as hasOmegaPhiKappa,it as isElevationSampler,ut as isUpdateElevationWithElevationSampler,mt as isUpdateElevationWithElevationSource,pt as isUpdateUsingConstantElevation,ct as isValidAffines,V as linearEquationSolve,W as ltpToGeographic,G as or,B as pointToArray,S as projectiveTransform,vt as reducerFn,$ as rotatePixel,C as scaleAndAddWithFactor,R as scaleWithFactor,yt as transformGraphicCoordinatesToPixel,L as transformMat3,D as transformMat4,Q as validatePixelsToTransform,_ as validatePointsToTransform,tt as validateRotationMatrix,at as vecToPoint};
5
+ import t from"../../../core/Error.js";import n from"../../../core/JSONSupport.js";import{deg2rad as a,rad2deg as i}from"../../../core/mathUtils.js";import{create as e}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{create as o,fromValues as r}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{fromArray as c}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{zeros as s}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{multiply as l,transpose as f}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{invertOrIdentity as h,mul as u}from"../../../core/libs/gl-matrix-2/math/mat4.js";import{a as m,g as p}from"../../../chunks/vec32.js";import M from"../../../geometry/Point.js";import{projectWithZConversion as g}from"../../../geometry/projection.js";import{earth as v}from"../../../geometry/support/Ellipsoid.js";import{isWebMercator as d}from"../../../geometry/support/spatialReferenceUtils.js";import{a as x}from"../../../chunks/vec3.js";import{isElevationSource as w,isConstantElevation as y,ConstantElevation as O}from"../core/ElevationSourceDefinitions.js";import{getElevationSampler as b}from"./updateElevationUtils.js";import{isNumber as j}from"../../../support/guards.js";import{defaultImageSphereSize as E}from"../../../widgets/PanoramicViewer/constants.js";function S(t,n,a){const[i,e,r,c]=n,[s,l,f,m]=a;z(i,e,r,c);const p=z(s,l,f,m),M=V(i,e,r,c),g=V(s,l,f,m),v=h(o(),M),d=u(o(),v,g),[x,w,y,O]=P(t,d);return[x/O,w/O,p?0:y/O]}function z(t,n,a,i){return 0===t[2]&&0===n[2]&&0===a[2]&&0===i[2]&&(t[2]=n[2]=a[2]=i[2]=1,!0)}function F(t){return 0===t?1:t}function P(t,n){const[a,i,e]=t,o=[0,0,0,0];return o[0]=a*n[0]+i*n[1]+e*n[2]+n[3],o[1]=a*n[4]+i*n[5]+e*n[6]+n[7],o[2]=a*n[8]+i*n[9]+e*n[10]+n[11],o[3]=F(a*n[12]+i*n[13]+e*n[14]+n[15]),o}function V(t,n,a,i){const e=D(c([...i,1]),h(new Array(16),r(t[0],n[0],a[0],0,t[1],n[1],a[1],0,t[2],n[2],a[2],0,1,1,1,1))),s=e[0],l=e[1],f=e[2],u=o();return u[0]=s*t[0],u[1]=l*n[0],u[2]=f*a[0],u[3]=0,u[4]=s*t[1],u[5]=l*n[1],u[6]=f*a[1],u[7]=0,u[8]=s*t[2],u[9]=l*n[2],u[10]=f*a[2],u[11]=0,u[12]=s,u[13]=l,u[14]=f,u[15]=1,u}function C(t,n,a,i,e=s()){return e[0]=t[0]+n[0]*a,e[1]=t[1]+n[1]*a,e[2]=t[2]+n[2]*(a/i),e}function R(t,n,a){const i=s();return i[0]=t[0]*n,i[1]=t[1]*n,i[2]=t[2]*(n/a),i}function L(t,n){const[a,i,e]=t,o=s();return o[0]=a*n[0]+i*n[3]+e*n[6],o[1]=a*n[1]+i*n[4]+e*n[7],o[2]=a*n[2]+i*n[5]+e*n[8],o}function D(t,n){const[a,i,e,o]=t,r=new Array(4);return r[0]=a*n[0]+i*n[1]+e*n[2]+o*n[3],r[1]=a*n[4]+i*n[5]+e*n[6]+o*n[7],r[2]=a*n[8]+i*n[9]+e*n[10]+o*n[11],r[3]=a*n[12]+i*n[13]+e*n[14]+o*n[15],r}function I(n,i,o,r=!0){if(!Number.isFinite(n))throw new t("InvalidRotationAngle","Please specify a valid angle for rotation");const c=o*(r?a(n):n),s=Math.cos(c),l=Math.sin(c),f=e();switch(i){case 0:f[4]=s,f[5]=-l,f[7]=l,f[8]=s;break;case 1:f[0]=s,f[2]=l,f[6]=-l,f[8]=s;break;case 2:f[0]=s,f[1]=-l,f[3]=l,f[4]=s;break;default:throw new t("InvalidRotationAxis","Please specify either 0, 1 or 2 for X, Y or Z axis respectively")}return f}const N={HPR:[[2,-1],[0,1],[2,-1]],OPK:[[0,1],[1,1],[2,1]]};function H(n,a,i=!0){if(3!==n?.length||3!==a?.length)throw new t("InvalidRotationAngles","Please specify three angles with config for rotation");const o=e();for(let t=0;t<3;t++){const[e,r]=a[t],c=I(n[t],e,r,i);l(o,c,o)}return o}function q(t,n=!0){return H(t,N.OPK,n)}function k(t,n=!0){return H(t,N.HPR,n)}function A(t,n,i){const e=Math.sin(a(i)),o=Math.cos(a(i)),r=[[t,0],[t,n],[0,n]];r.forEach(((t,n)=>{r[n]=[o*t[0]-e*t[1],e*t[0]+o*t[1]]}));const c={xmin:Math.min(0,r[0][0],r[1][0],r[2][0]),xmax:Math.max(0,r[0][0],r[1][0],r[2][0]),ymin:Math.min(0,r[0][1],r[1][1],r[2][1]),ymax:Math.max(0,r[0][1],r[1][1],r[2][1])};return{hfov:Math.abs(c.xmax-c.xmin),vfov:Math.abs(c.ymax-c.ymin)}}function K(t,n){const i=a(t[1]),e=a(t[0]),o=t[2],[r,c,s,l]=n,f=a(r),h=a(c),u=s/Math.sqrt(1-l*Math.sin(f)**2),m=e-h,p=s/Math.sqrt(1-l*Math.sin(f)**2),M=l*(u*Math.sin(f)-p*Math.sin(i));return[(p+o)*Math.cos(i)*Math.sin(m),(p+o)*(Math.sin(i)*Math.cos(f)-Math.sin(f)*Math.cos(f)*Math.cos(m))+M*Math.cos(f),(p+o)*(Math.sin(i)*Math.sin(f)+Math.cos(f)*Math.cos(i)*Math.cos(m))-u+M*Math.sin(f)]}function W(t,n){const e=Number(t[0]),o=Number(t[1]),r=Number(t[2]),[c,s,l,f]=n,h=a(c),u=a(s),m=l/Math.sqrt(1-f*Math.sin(h)**2),p=e/m,M=o/m,g=r/m,v=Math.cos(h)-Math.sin(h)*M+Math.cos(h)*g,d=Math.sin(h)+Math.cos(h)*M+Math.sin(h)*g,x=Math.sqrt(v**2+p**2),w=f*m*Math.sin(h),y=(t,n=5)=>{if(0===n)return t;const a=y(t,n-1);return Math.atan(d/x-(w-f*(l/Math.sqrt(1-f*Math.sin(a)**2))*Math.sin(a))/(m*x))},O=y(h),b=Math.atan(e/(m*v))+u,j=i(O);return[i(b),j,e/(Math.cos(O)*Math.sin(b-u))-l/Math.sqrt(1-f*Math.sin(O)**2)]}function U(t,n,a){const i=360/n,e=180/a;return{heading:(t.x-n/2)*i,pitch:90-(t.y-a/2)*e}}function T(t,n,a,i=E/2){const{heading:e,pitch:o}=X(t,i);return J(e,o,n,a)}function J(t,n,a,i){return{x:a/2+t/(360/a),y:i-n/(180/i),heading:t,pitch:n}}function X(t,n){const a=i(Math.acos(-t.z/n));return{heading:i(Math.atan2(t.x,t.y)),pitch:a}}function Y(t,n,i=E/2){return[i*(Math.sin(a(t))*Math.sin(a(n))),i*(Math.cos(a(t))*Math.sin(a(n))),i*Math.cos(a(180-n))]}async function Z(t,n,a){const e=await g(n,t.spatialReference,a);let o=i(Math.atan2(e.y-t.y,e.x-t.x));return o=o>=0&&o<=90?90-o:o>90&&o<=180?360-o+90:90+Math.abs(o),o}function $(t,n,a){const i=Math.cos(a),e=Math.sin(a),o=[1,0,0,1,0,0],r=o[0]*i+o[2]*e,c=o[1]*i+o[3]*e,s=-o[0]*e+o[2]*i,l=-o[1]*e+o[3]*i;o[0]=r,o[1]=c,o[2]=s,o[3]=l;return[t*o[0]+n*o[2]+o[4],t*o[1]+n*o[3]+o[5]]}const B=t=>t.toArray(),G=(...t)=>t.some((t=>t));function Q(t,n){if(G(0===t.length,t.some((({x:t,y:n})=>G(null==t,null==n))),!n.hasZ))throw new Error("Input pixels must have x, y and camera location must have z value")}function _(t,n){if(t.some((t=>null==t.z))||null==n.z)throw new Error("Input points and camera location must have z value")}function tt(t){if(9!==t?.length)throw new Error("Rotation matrix is not provided or is not a valid 3x3 matrix")}function nt(t,n){return d(n)?1/Math.cos(Math.PI/2-2*Math.atan(Math.exp(-1*t/v.radius))):1}const at=t=>n=>new M(n,t),it=t=>null!=t&&"queryExtent"in t;function et(t,n,a,i){return[[-n,-n],[+n,-n],[+n,+n],[-n,+n]].map((([n,e])=>S(x(s(),a,[n,e,0]),i,t)))}function ot({a0:t,a1:n,a2:a,b0:i,b1:e,b2:o},r,c,s){const l=[t??r/2-.5,n,a??0,i??c/2-.5,e??0,o].map(rt);return null!=s&&ct(l)?{affines:l,focalLength:s}:{affines:[r/2-.5,1,0,c/2-.5,0,-1]}}function rt(t,n){if(null==t)return null;const a=parseFloat(`${t}`);return isNaN(a)?null:a}function ct(t){return null!=t[1]&&null!=t[5]}function st(t,n,a){const{cameraHeight:i,cameraPitch:e,cameraRoll:o,elevation:r,farDistance:c,horizontalFieldOfView:s,location:l,verticalFieldOfView:f}=t,h=r??(l.z??0)-i;return{...ht(t,n,a),averageElevation:h,cameraPitch:e,cameraRoll:o??0,farDistance:c,horizontalFieldOfView:s,verticalFieldOfView:f}}function lt(t,n,a,i){return xt(i)?q([i.omega,i.phi,i.kappa]):wt(i)?k([i.heading,i.pitch,i.roll]):k([t,n,a??0])}function ft(t,n,a){const{cameraHeading:i,cameraHeight:e,elevation:o,farDistance:r,horizontalFieldOfView:c,location:s,verticalFieldOfView:l}=t;return{averageElevation:o??(s.z??0)-e,cameraLocation:s,cameraHeading:i,farDistance:r,horizontalFieldOfView:c,imageHeight:a,imageWidth:n,verticalFieldOfView:l}}function ht(t,n,a){const{a0:i,a1:e,a2:o,b0:r,b1:c,b2:s,cameraHeading:l,cameraOrientation:f,cameraPitch:h,cameraRoll:u,focalLength:m,horizontalFieldOfView:p,location:M,matrix:g,principalX:v,principalY:d,radial:x,tangential:w,verticalFieldOfView:y}=t,{affines:O,focalLength:b}=ot({a0:i,a1:e,a2:o,b0:r,b1:c,b2:s},n,a,m),j=g??lt(l,h,u,f),E=null!=v&&null!=d?[v,d]:void 0;return{affineTransformations:f?.affineTransformations??O,cameraLocation:M.clone(),focalLength:f?.focalLength??b,horizontalFieldOfView:p,imageHeight:a,imageWidth:n,principalOffsetPoint:f?.principalOffsetPoint??E,radialDistortionCoefficients:f?.radialDistortionCoefficients??x,rotationMatrix:j,tangentialDistortionCoefficients:f?.tangentialDistortionCoefficients??w,verticalFieldOfView:y}}const ut=t=>null!=t&&"elevationSample"in t&&null!=t.elevationSample,mt=t=>w(t?.elevationSource)&&null!=t?.extent,pt=t=>y(t?.elevationSource),Mt=async(t,a)=>null!=a&&(ut(a)||pt(a))?a:mt(a)?{elevationSample:await b({...n.isSerializable(a.elevationSource)?a.elevationSource.toJSON():a.elevationSource,extent:a.extent}),elevationSource:new O({constantElevation:t})}:{elevationSource:new O({constantElevation:t})},gt=t=>j(t?.heading)&&j(t?.pitch),vt=(t,n)=>[[-t,-n],[t,-n],[t,n],[-t,n]];function dt(t){const{cameraLocation:n,farDistance:i,horizontalFieldOfView:o,rotationMatrix:r,scalingFactor:c,verticalFieldOfView:l}=t,h=e();f(h,r);const u=2*Math.tan(a(l)/2)*i*c,M=2*Math.tan(a(o)/2)*i*c,g=L([0,0,-1],h),v=C([n.x,n.y,n.z],g,t.farDistance*c,c),d=L([0,1,0],h),x=L([1,0,0],h),w=R(d,u/2,c),y=R(x,M/2,c),O=m(s(),w,y),b=p(s(),w,y);return[p(s(),v,O),p(s(),v,b),m(s(),v,O),m(s(),v,b)]}const xt=t=>2===t?.type,wt=t=>1===t?.type;function yt(t){return(t+360)%360}function Ot(t,n,a){if("panoramic"===t){const[t,i]=a;return T({x:n.x,y:n.y,z:n.z},t,i)}return{x:n.x+.5,y:.5-n.y}}var bt;!function(t){t[t.CLOCKWISE=-1]="CLOCKWISE",t[t.COUNTERCLOCKWISE=1]="COUNTERCLOCKWISE"}(bt||(bt={}));export{dt as computeFarplaneVertices,A as computeHFOVAndVFOV,et as computeNewReferenceCoordinates,Y as convertHeadingPitchToSphereVertex,J as convertOrientationToPixelLocation,U as convertPixelToHeadingPitch,X as convertSphereVertexToOrientation,T as convertSphereVertexToPixelLocation,H as createRotationMatrix,k as createRotationMatrixFromHPR,q as createRotationMatrixFromOPK,K as geographicToLTP,ot as getAffinesAndFocalLength,ft as getImageToWorldPanoramicProperties,st as getImageToWorldProperties,Z as getInitialAngle,Mt as getUpdateElevationProps,nt as getWebMercatorScalingFactor,ht as getWorldToImageProperties,gt as hasAngles,wt as hasHeadingPitchRoll,xt as hasOmegaPhiKappa,it as isElevationSampler,ut as isUpdateElevationWithElevationSampler,mt as isUpdateElevationWithElevationSource,pt as isUpdateUsingConstantElevation,ct as isValidAffines,V as linearEquationSolve,W as ltpToGeographic,yt as normalizeHeading,G as or,B as pointToArray,S as projectiveTransform,vt as reducerFn,$ as rotatePixel,C as scaleAndAddWithFactor,R as scaleWithFactor,Ot as transformGraphicCoordinatesToPixel,L as transformMat3,D as transformMat4,Q as validatePixelsToTransform,_ as validatePointsToTransform,tt as validateRotationMatrix,at as vecToPoint};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.32/esri/copyright.txt for details.
4
4
  */
5
- import{rad2deg as t,deg2rad as a}from"../../../core/mathUtils.js";import{create as r}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{a as o,j as n}from"../../../chunks/vec32.js";import{webMercatorToGeographic as e}from"../../../geometry/support/webMercatorUtils.js";import{convertOrientationToPixelLocation as i,validatePointsToTransform as c,validateRotationMatrix as s,getWebMercatorScalingFactor as f}from"./utils.js";function m(t,a){const{cameraLocation:r,pointsToTransform:o,scalingFactor:n}=h(t,a.cameraLocation,a.rotationMatrix),e=new Array;return u(o,e,{...a,cameraLocation:r,scalingFactor:n,...A(a)}),Array.isArray(t)?e:e[0]}function l(t,a,r){return m(t?a.map((t=>e(t))):a,r).map((t=>({...t,z:1})))}function u(t,a,n){const{affineTransformations:e,cameraLocation:i,focalLengthX:c,focalLengthY:s,principalOffsetPoint:f,radialDistortionCoefficients:m,rotationMatrix:l,scalingFactor:u,tangentialDistortionCoefficients:p}=n;for(const h of t){const t=r();o(t,h,i),t[0]=t[0]/u,t[1]=t[1]/u;const n=-c*((l[0]*t[0]+l[3]*t[1]+l[6]*t[2])/(l[2]*t[0]+l[5]*t[1]+l[8]*t[2])),g=-s*((l[1]*t[0]+l[4]*t[1]+l[7]*t[2])/(l[2]*t[0]+l[5]*t[1]+l[8]*t[2])),y=n*n+g*g;let L=0,A=0,T=0,b=0,d=0,w=0,M=0;m&&(L=m[0]??0,A=m[1]??0,T=m[2]??0),p&&(b=p[0],d=p[1]),f&&(w=f[0]??0,M=f[1]??0);const j=1+L*y+A*y*y+T*y*y*y;let F=n*j+b*(y+2*n**2)+2*d*n*g,N=g*j+d*(y+2*g**2)+2*b*n*g;F+=w,N+=M;const x=Number(e[0])+Number(e[1])*F+Number(e[2])*N,v=Number(e[3])+Number(e[4])*F+Number(e[5])*N;a.push({x,y:v})}}function p(a,r){const{cameraHeading:o,imageHeight:e,imageWidth:c}=r,{cameraLocation:s,pointsToTransform:f}=g(a,r.cameraLocation),m=new Array;for(const l of f){const a=n(s,l),r=(t(Math.atan2(l[0]-s[0],l[1]-s[1]))-o)%360,f=t(Math.acos((s[2]-l[2])/a));m.push(i(r,f,c,e))}return Array.isArray(a)?m:m[0]}function h(t,a,r){const o=Array.isArray(t)||"items"in t?t:[t];c(o,a),y(o,a),s(r);const n=f(a.y,a.spatialReference);return{pointsToTransform:o.map((t=>t.toArray())),scalingFactor:n,cameraLocation:a.toArray()}}function g(t,a){const r=Array.isArray(t)||"items"in t?t:[t];return c(r,a),y(r,a),{pointsToTransform:r.map((t=>t.toArray())),cameraLocation:a.toArray()}}function y(t,a){if(t.some((t=>!t.spatialReference.equals(a.spatialReference))))throw new Error("Input points and camera location must have the same spatial reference")}function L(t){return null!=t?.focalLength}function A(t){if(L(t))return{focalLengthX:t.focalLength,focalLengthY:t.focalLength};const{imageWidth:r,imageHeight:o,horizontalFieldOfView:n,verticalFieldOfView:e}=t;return{focalLengthX:r/(2*Math.tan(a(n)/2)),focalLengthY:o/(2*Math.tan(a(e)/2))}}export{m as worldToImage,p as worldToImagePanoramic,l as worldToImageWithLTPFlag};
5
+ import{rad2deg as t,deg2rad as a}from"../../../core/mathUtils.js";import{create as r}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{a as o,j as n}from"../../../chunks/vec32.js";import{webMercatorToGeographic as e}from"../../../geometry/support/webMercatorUtils.js";import{normalizeHeading as i,convertOrientationToPixelLocation as c,validatePointsToTransform as s,validateRotationMatrix as f,getWebMercatorScalingFactor as m}from"./utils.js";function l(t,a){const{cameraLocation:r,pointsToTransform:o,scalingFactor:n}=g(t,a.cameraLocation,a.rotationMatrix),e=new Array;return p(o,e,{...a,cameraLocation:r,scalingFactor:n,...T(a)}),Array.isArray(t)?e:e[0]}function u(t,a,r){return l(t?a.map((t=>e(t))):a,r).map((t=>({...t,z:1})))}function p(t,a,n){const{affineTransformations:e,cameraLocation:i,focalLengthX:c,focalLengthY:s,principalOffsetPoint:f,radialDistortionCoefficients:m,rotationMatrix:l,scalingFactor:u,tangentialDistortionCoefficients:p}=n;for(const h of t){const t=r();o(t,h,i),t[0]=t[0]/u,t[1]=t[1]/u;const n=-c*((l[0]*t[0]+l[3]*t[1]+l[6]*t[2])/(l[2]*t[0]+l[5]*t[1]+l[8]*t[2])),g=-s*((l[1]*t[0]+l[4]*t[1]+l[7]*t[2])/(l[2]*t[0]+l[5]*t[1]+l[8]*t[2])),y=n*n+g*g;let L=0,A=0,T=0,b=0,d=0,w=0,M=0;m&&(L=m[0]??0,A=m[1]??0,T=m[2]??0),p&&(b=p[0],d=p[1]),f&&(w=f[0]??0,M=f[1]??0);const j=1+L*y+A*y*y+T*y*y*y;let F=n*j+b*(y+2*n**2)+2*d*n*g,N=g*j+d*(y+2*g**2)+2*b*n*g;F+=w,N+=M;const x=Number(e[0])+Number(e[1])*F+Number(e[2])*N,v=Number(e[3])+Number(e[4])*F+Number(e[5])*N;a.push({x,y:v})}}function h(a,r){const{cameraHeading:o,imageHeight:e,imageWidth:s}=r,{cameraLocation:f,pointsToTransform:m}=y(a,r.cameraLocation),l=new Array;for(const u of m){const a=n(f,u),r=i(t(Math.atan2(u[0]-f[0],u[1]-f[1]))-o),m=t(Math.acos((f[2]-u[2])/a));l.push(c(r,m,s,e))}return Array.isArray(a)?l:l[0]}function g(t,a,r){const o=Array.isArray(t)||"items"in t?t:[t];s(o,a),L(o,a),f(r);const n=m(a.y,a.spatialReference);return{pointsToTransform:o.map((t=>t.toArray())),scalingFactor:n,cameraLocation:a.toArray()}}function y(t,a){const r=Array.isArray(t)||"items"in t?t:[t];return s(r,a),L(r,a),{pointsToTransform:r.map((t=>t.toArray())),cameraLocation:a.toArray()}}function L(t,a){if(t.some((t=>!t.spatialReference.equals(a.spatialReference))))throw new Error("Input points and camera location must have the same spatial reference")}function A(t){return null!=t?.focalLength}function T(t){if(A(t))return{focalLengthX:t.focalLength,focalLengthY:t.focalLength};const{imageWidth:r,imageHeight:o,horizontalFieldOfView:n,verticalFieldOfView:e}=t;return{focalLengthX:r/(2*Math.tan(a(n)/2)),focalLengthY:o/(2*Math.tan(a(e)/2))}}export{l as worldToImage,h as worldToImagePanoramic,u as worldToImageWithLTPFlag};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.32/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import o from"../../core/Clonable.js";import{JSONMap as r}from"../../core/jsonMap.js";import t from"../../core/JSONSupport.js";import{property as i}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as s}from"../../core/accessorSupport/decorators/subclass.js";const n=new r({esriRelCardinalityOneToOne:"one-to-one",esriRelCardinalityOneToMany:"one-to-many",esriRelCardinalityManyToMany:"many-to-many"}),a=new r({esriRelRoleOrigin:"origin",esriRelRoleDestination:"destination"});let l=class extends(o.ClonableMixin(t)){constructor(e){super(e),this.cardinality=null,this.composite=null,this.id=null,this.keyField=null,this.keyFieldInRelationshipTable=null,this.name=null,this.relatedTableId=null,this.relationshipTableId=null,this.role=null}};e([i({json:{read:n.read,write:n.write}})],l.prototype,"cardinality",void 0),e([i({json:{read:!0,write:!0}})],l.prototype,"composite",void 0),e([i({json:{read:!0,write:!0}})],l.prototype,"id",void 0),e([i({json:{read:!0,write:!0}})],l.prototype,"keyField",void 0),e([i({json:{read:!0,write:!0}})],l.prototype,"keyFieldInRelationshipTable",void 0),e([i({json:{read:!0,write:!0}})],l.prototype,"name",void 0),e([i({json:{read:!0,write:!0}})],l.prototype,"relatedTableId",void 0),e([i({json:{read:!0,write:!0}})],l.prototype,"relationshipTableId",void 0),e([i({json:{read:a.read,write:a.write}})],l.prototype,"role",void 0),l=e([s("esri.layers.support.Relationship")],l);const p=l;export{p as default};
5
+ import{_ as o}from"../../chunks/tslib.es6.js";import e from"../../core/Clonable.js";import{JSONMap as r}from"../../core/jsonMap.js";import t from"../../core/JSONSupport.js";import{property as i}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as s}from"../../core/accessorSupport/decorators/subclass.js";const a=new r({esriRelCardinalityOneToOne:"one-to-one",esriRelCardinalityOneToMany:"one-to-many",esriRelCardinalityManyToMany:"many-to-many"}),n=new r({esriRelRoleOrigin:"origin",esriRelRoleDestination:"destination"});let l=class extends(e.ClonableMixin(t)){constructor(o){super(o),this.cardinality=null,this.catalogId=null,this.composite=null,this.id=null,this.keyField=null,this.keyFieldInRelationshipTable=null,this.name=null,this.relatedTableId=null,this.relationshipTableId=null,this.role=null}};o([i({json:{read:a.read,write:a.write}})],l.prototype,"cardinality",void 0),o([i({json:{name:"catalogID"}})],l.prototype,"catalogId",void 0),o([i({json:{read:!0,write:!0}})],l.prototype,"composite",void 0),o([i({json:{read:!0,write:!0}})],l.prototype,"id",void 0),o([i({json:{read:!0,write:!0}})],l.prototype,"keyField",void 0),o([i({json:{read:!0,write:!0}})],l.prototype,"keyFieldInRelationshipTable",void 0),o([i({json:{read:!0,write:!0}})],l.prototype,"name",void 0),o([i({json:{read:!0,write:!0}})],l.prototype,"relatedTableId",void 0),o([i({json:{read:!0,write:!0}})],l.prototype,"relationshipTableId",void 0),o([i({json:{read:n.read,write:n.write}})],l.prototype,"role",void 0),l=o([s("esri.layers.support.Relationship")],l);const p=l;export{p as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.32/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../chunks/tslib.es6.js";import r from"../request.js";import t from"../core/JSONSupport.js";import o from"../core/Loadable.js";import{property as s}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/Logger.js";import"../core/RandomLCG.js";import{subclass as u}from"../core/accessorSupport/decorators/subclass.js";import{isSubtypeSublayer as a,isFeatureLayer as n}from"../layers/support/layerUtils.js";import{RuleType as i}from"./support/typeUtils.js";let c=class extends(t.JSONSupportMixin(o)){constructor(e){super(e),this.rulesCategorized={attachment:[],containment:[],connectivity:[]},this.request=r}initialize(){}async load(e){const r=this.rulesLayer.load(e).then((()=>this._initializeRulesTable()));return this.addResolvingPromise(r),this}getFeaturesCanAssociateWithClause(e,r,t){return this._getWhereClauseForCompatibleFeatures(e,r,t)}getFeaturesCanAssociateWith(e,r,t){return null==this._getFeatureSourceLayerId(e)?[]:r.filter((r=>this.canAssociateFeatures(e,r,t)))}canAssociateFeatures(e,r,t){const[o,s]=this._getFeatureAssetCodes(e),u=this._getFeatureSourceLayerId(e),[a,n]=this._getFeatureAssetCodes(r),i=this._getFeatureSourceLayerId(r);return null!=u&&null!=i&&t.some((e=>{const{type:r,direction:t}=e;return this._getRulesForAssociationType(r).some((e=>{const c=this._getRuleFieldValuesForAssociation(e,r,t);return c?.some((e=>u===e?.ruleLayerIdForSource&&o===e?.ruleAssetGroupCodeForSource&&s===e?.ruleAssetTypeCodeForSource&&i===e?.ruleLayerIdForTarget&&a===e?.ruleAssetGroupCodeForTarget&&n===e?.ruleAssetTypeCodeForTarget))}))}))}getLayersCanAssociateWith(e,r,t){return null==this._getFeatureSourceLayerId(e)?[]:r.filter((r=>this.canAssociateFeatureToLayer(e,r,t)))}canAssociateFeatureToLayer(e,r,t){const o=a(r)?r.parent:r;if(!o)return!1;const s=o.layerId,u=a(r)?r.subtypeCode:null,[n,i]=this._getFeatureAssetCodes(e),c=this._getFeatureSourceLayerId(e);return null!=c&&t.some((e=>{const{type:r,direction:t}=e;return this._getRulesForAssociationType(r).some((e=>{const o=this._getRuleFieldValuesForAssociation(e,r,t);return o?.some((e=>c===e?.ruleLayerIdForSource&&n===e?.ruleAssetGroupCodeForSource&&i===e?.ruleAssetTypeCodeForSource&&s===e?.ruleLayerIdForTarget&&(null==u||u===e?.ruleAssetGroupCodeForTarget)))}))}))}getFeatureSQL(e,r){const t=e.layerId.toString(),o=e.fieldsIndex?.normalizeFieldName("assetGroup"),s=e.fieldsIndex?.normalizeFieldName("assetType"),u=o?r.attributes[o]:null,a=s?r.attributes[s]:null,n=this.rulesHash[t];if(n){const e=n.assetGroupHash[u];if(e){return e.assetTypeHash[a]||null}}return null}async _initializeRulesTable(){const e={};let r;!function(e){e[e.from=0]="from",e[e.to=1]="to",e[e.via=2]="via"}(r||(r={}));const t=[{networkSourceId:"fromNetworkSource",assetGroupId:"fromAssetGroup",assetTypeId:"fromAssetType"},{networkSourceId:"toNetworkSource",assetGroupId:"toAssetGroup",assetTypeId:"toAssetType"},{networkSourceId:"viaNetworkSource",assetGroupId:"viaAssetGroup",assetTypeId:"viaAssetType"}];this.rulesCategorized={attachment:[],containment:[],connectivity:[]};for(const o of this.rules){if(o.ruleType===i.RTAttachment){this.rulesCategorized.attachment.push(o);continue}if(o.ruleType===i.RTContainment){this.rulesCategorized.containment.push(o);continue}if(o.ruleType===i.RTJunctionJunctionConnectivity){this.rulesCategorized.connectivity.push(o);continue}this.rulesCategorized.connectivity.push(o);let s=[[r.from,r.to],[r.to,r.from]];o.ruleType===i.RTEdgeJunctionEdgeConnectivity&&(s=[[r.from,r.via],[r.via,r.from],[r.to,r.via],[r.via,r.to]]);for(const u of s){const s=u.shift(),a=u.shift();let n=!1;switch(o.ruleType){case i.RTEdgeJunctionEdgeConnectivity:n=s===r.from||s===r.to;break;case i.RTJunctionEdgeConnectivity:n=s===r.to}const c=t[s],d=o[c.networkSourceId]?.layerId.toString()??"",l=o[c.assetGroupId]?.assetGroupCode?.toString(),p=o[c.assetTypeId],y=p?.assetTypeCode?.toString(),T=t[a],C=o[T.networkSourceId]?.layerId.toString()??"",A=o[T.assetGroupId]?.assetGroupCode?.toString(),F=o[T.assetTypeId],g=F?.assetTypeCode?.toString(),m=e[d]??{assetGroupHash:{}};if(!(l&&y&&A&&g))continue;const S=m.assetGroupHash[l]??{assetTypeHash:{}},f=S.assetTypeHash[y]??{};if(f[C]=f[C]??{},n){f[d]=f[d]??{};const e=`(assetgroup = ${l} AND assettype = ${y})`;"esriNECPEndVertex"===F?.connectivityPolicy?f[d].endVertex=f[d]?.endVertex?`${f[d].endVertex}`:`${e}`:f[d].anyVertex=f[d].anyVertex?`${f[d].anyVertex}`:`${e}`}const G=`(assetgroup = ${A} AND assettype = ${g})`;"esriNECPEndVertex"===F?.connectivityPolicy?f[C].endVertex=f[C]?.endVertex?`${f[C].endVertex} OR ${G}`:`${G}`:f[C].anyVertex=f[C]?.anyVertex?`${f[C].anyVertex} OR ${G}`:`${G}`,S.assetTypeHash[y]=f,m.assetGroupHash[l]=S,e[d]=m}}this._set("rulesHash",e)}_getRuleFieldValuesForAssociation(e,r,t="from"){switch(r){case"attachment":case"containment":return"from"===t?[{ruleLayerIdForSource:e.fromNetworkSource?.layerId,ruleAssetGroupCodeForSource:e.fromAssetGroup?.assetGroupCode,ruleAssetTypeCodeForSource:e.fromAssetType?.assetTypeCode,ruleLayerIdForTarget:e.toNetworkSource?.layerId,ruleAssetGroupCodeForTarget:e.toAssetGroup?.assetGroupCode,ruleAssetTypeCodeForTarget:e.toAssetType?.assetTypeCode}]:[{ruleLayerIdForSource:e.toNetworkSource?.layerId,ruleAssetGroupCodeForSource:e.toAssetGroup?.assetGroupCode,ruleAssetTypeCodeForSource:e.toAssetType?.assetTypeCode,ruleLayerIdForTarget:e.fromNetworkSource?.layerId,ruleAssetGroupCodeForTarget:e.fromAssetGroup?.assetGroupCode,ruleAssetTypeCodeForTarget:e.fromAssetType?.assetTypeCode}];case"connectivity":case"junction-junction-connectivity":return[{ruleLayerIdForSource:e.fromNetworkSource?.layerId,ruleAssetGroupCodeForSource:e.fromAssetGroup?.assetGroupCode,ruleAssetTypeCodeForSource:e.fromAssetType?.assetTypeCode,ruleLayerIdForTarget:e.toNetworkSource?.layerId,ruleAssetGroupCodeForTarget:e.toAssetGroup?.assetGroupCode,ruleAssetTypeCodeForTarget:e.toAssetType?.assetTypeCode},{ruleLayerIdForSource:e.toNetworkSource?.layerId,ruleAssetGroupCodeForSource:e.toAssetGroup?.assetGroupCode,ruleAssetTypeCodeForSource:e.toAssetType?.assetTypeCode,ruleLayerIdForTarget:e.fromNetworkSource?.layerId,ruleAssetGroupCodeForTarget:e.fromAssetGroup?.assetGroupCode,ruleAssetTypeCodeForTarget:e.fromAssetType?.assetTypeCode}];case"junction-edge-from-connectivity":case"junction-edge-midspan-connectivity":case"junction-edge-to-connectivity":return e.ruleType===i.RTEdgeJunctionEdgeConnectivity?[{ruleLayerIdForSource:e.fromNetworkSource?.layerId,ruleAssetGroupCodeForSource:e.fromAssetGroup?.assetGroupCode,ruleAssetTypeCodeForSource:e.fromAssetType?.assetTypeCode,ruleLayerIdForTarget:e.viaNetworkSource?.layerId,ruleAssetGroupCodeForTarget:e.viaAssetGroup?.assetGroupCode,ruleAssetTypeCodeForTarget:e.viaAssetType?.assetTypeCode},{ruleLayerIdForSource:e.viaNetworkSource?.layerId,ruleAssetGroupCodeForSource:e.viaAssetGroup?.assetGroupCode,ruleAssetTypeCodeForSource:e.viaAssetType?.assetTypeCode,ruleLayerIdForTarget:e.fromNetworkSource?.layerId,ruleAssetGroupCodeForTarget:e.fromAssetGroup?.assetGroupCode,ruleAssetTypeCodeForTarget:e.fromAssetType?.assetTypeCode},{ruleLayerIdForSource:e.toNetworkSource?.layerId,ruleAssetGroupCodeForSource:e.toAssetGroup?.assetGroupCode,ruleAssetTypeCodeForSource:e.toAssetType?.assetTypeCode,ruleLayerIdForTarget:e.viaNetworkSource?.layerId,ruleAssetGroupCodeForTarget:e.viaAssetGroup?.assetGroupCode,ruleAssetTypeCodeForTarget:e.viaAssetType?.assetTypeCode},{ruleLayerIdForSource:e.viaNetworkSource?.layerId,ruleAssetGroupCodeForSource:e.viaAssetGroup?.assetGroupCode,ruleAssetTypeCodeForSource:e.viaAssetType?.assetTypeCode,ruleLayerIdForTarget:e.toNetworkSource?.layerId,ruleAssetGroupCodeForTarget:e.toAssetGroup?.assetGroupCode,ruleAssetTypeCodeForTarget:e.toAssetType?.assetTypeCode}]:[{ruleLayerIdForSource:e.fromNetworkSource?.layerId,ruleAssetGroupCodeForSource:e.fromAssetGroup?.assetGroupCode,ruleAssetTypeCodeForSource:e.fromAssetType?.assetTypeCode,ruleLayerIdForTarget:e.toNetworkSource?.layerId,ruleAssetGroupCodeForTarget:e.toAssetGroup?.assetGroupCode,ruleAssetTypeCodeForTarget:e.toAssetType?.assetTypeCode},{ruleLayerIdForSource:e.toNetworkSource?.layerId,ruleAssetGroupCodeForSource:e.toAssetGroup?.assetGroupCode,ruleAssetTypeCodeForSource:e.toAssetType?.assetTypeCode,ruleLayerIdForTarget:e.fromNetworkSource?.layerId,ruleAssetGroupCodeForTarget:e.fromAssetGroup?.assetGroupCode,ruleAssetTypeCodeForTarget:e.fromAssetType?.assetTypeCode}];default:return[]}}_getWhereClauseForCompatibleFeatures(e,r,t){const o=new Map,[s,u]=this._getAssetFieldNames(e.sourceLayer),[n,i]=this._getFeatureAssetCodes(e),c=this._getFeatureSourceLayerId(e),d=a(r)?r.parent:r;t.forEach((e=>{const{type:r,direction:t}=e;this._getRulesForAssociationType(r).forEach((e=>{this._getRuleFieldValuesForAssociation(e,r,t).forEach((e=>{if(null!=e.ruleAssetGroupCodeForTarget&&null!=e.ruleAssetTypeCodeForTarget&&c===e?.ruleLayerIdForSource&&n===e?.ruleAssetGroupCodeForSource&&i===e?.ruleAssetTypeCodeForSource&&d.layerId===e?.ruleLayerIdForTarget){const r=o.get(e.ruleAssetGroupCodeForTarget)??new Set;r.add(e.ruleAssetTypeCodeForTarget),o.set(e.ruleAssetGroupCodeForTarget,r)}}))}))}));let l=[];return this._mergeAssetCodes(o).forEach(((e,r)=>l.push(`${s} IN (${r}) AND ${u} IN (${Array.from(e).sort().join(", ")})`))),l.length>1&&(l=l.map((e=>`(${e})`))),l.join(" OR ")}_getRulesForAssociationType(e){const{rulesCategorized:r}=this;switch(e){case"attachment":return r.attachment;case"containment":return r.containment;case"connectivity":case"junction-junction-connectivity":return r.connectivity.filter((e=>e.ruleType===i.RTJunctionJunctionConnectivity));case"junction-edge-from-connectivity":case"junction-edge-midspan-connectivity":case"junction-edge-to-connectivity":return r.connectivity.filter((e=>e.ruleType===i.RTJunctionEdgeConnectivity||e.ruleType===i.RTEdgeJunctionEdgeConnectivity));default:return[]}}_getFeatureSourceLayerId(e){const{sourceLayer:r}=e;let t;return n(r)?t=r.layerId:a(r)&&(t=r.parent?.layerId),t??null}_getAssetFieldNames(e){if(!e||!("fieldsIndex"in e))return[null,null];return[e.fieldsIndex.normalizeFieldName("assetGroup")??null,e.fieldsIndex.normalizeFieldName("assetType")??null]}_getFeatureAssetCodes(e){const[r,t]=this._getAssetFieldNames(e.sourceLayer);return[r?e.attributes[r]:null,t?e.attributes[t]:null]}_areSetsEqual(e,r){if(e.size!==r.size)return!1;for(const t of e)if(!r.has(t))return!1;return!0}_mergeAssetCodes(e){const r=new Map,t=new Set;for(const[o,s]of e){const u=new Set([o]);for(const[r,n]of e)o!==r&&!t.has(r)&&this._areSetsEqual(s,n)&&(u.add(r),t.add(r));const a=Array.from(u).sort().join(", ");r.set(a,s)}return r}};e([s({constructOnly:!0})],c.prototype,"rulesLayer",void 0),e([s({constructOnly:!0})],c.prototype,"rules",void 0),e([s({readOnly:!0})],c.prototype,"rulesHash",void 0),e([s()],c.prototype,"rulesCategorized",void 0),e([s({constructOnly:!0})],c.prototype,"request",void 0),c=e([u("esri.networks.RulesTable")],c);const d=c;export{d as default};
5
+ import{_ as e}from"../chunks/tslib.es6.js";import r from"../request.js";import t from"../core/JSONSupport.js";import o from"../core/Loadable.js";import{property as s}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/Logger.js";import"../core/RandomLCG.js";import{subclass as u}from"../core/accessorSupport/decorators/subclass.js";import{isSubtypeSublayer as a,isFeatureLayer as n}from"../layers/support/layerUtils.js";import{RuleType as i}from"./support/typeUtils.js";let d=class extends(t.JSONSupportMixin(o)){constructor(e){super(e),this.rulesCategorized={attachment:[],containment:[],connectivity:[]},this.request=r}initialize(){}async load(e){const r=this.rulesLayer.load(e).then((()=>this._initializeRulesTable()));return this.addResolvingPromise(r),this}getFeaturesCanAssociateWithClause(e,r,t){return this._getWhereClauseForCompatibleFeatures(e,r,t)}getFeaturesCanAssociateWith(e,r,t){return null==this._getFeatureSourceLayerId(e)?[]:r.filter((r=>this.canAssociateFeatures(e,r,t)))}canAssociateFeatures(e,r,t){const[o,s]=this._getFeatureAssetCodes(e),u=this._getFeatureSourceLayerId(e),[a,n]=this._getFeatureAssetCodes(r),i=this._getFeatureSourceLayerId(r);return null!=u&&null!=i&&t.some((e=>{const{type:r,direction:t}=e;return this._getRulesForAssociationType(r).some((e=>{const d=this._getRuleFieldValuesForAssociation(e,r,t);return d?.some((e=>u===e?.ruleLayerIdForSource&&o===e?.ruleAssetGroupCodeForSource&&s===e?.ruleAssetTypeCodeForSource&&i===e?.ruleLayerIdForTarget&&a===e?.ruleAssetGroupCodeForTarget&&n===e?.ruleAssetTypeCodeForTarget))}))}))}getLayersCanAssociateWith(e,r,t){return null==this._getFeatureSourceLayerId(e)?[]:r.filter((r=>this.canAssociateFeatureToLayer(e,r,t)))}canAssociateFeatureToLayer(e,r,t){const o=a(r)?r.parent:r;if(!o)return!1;const s=o.layerId,u=a(r)?r.subtypeCode:null,[n,i]=this._getFeatureAssetCodes(e),d=this._getFeatureSourceLayerId(e);return null!=d&&t.some((e=>{const{type:r,direction:t}=e;return this._getRulesForAssociationType(r).some((e=>{const o=this._getRuleFieldValuesForAssociation(e,r,t);return o?.some((e=>d===e?.ruleLayerIdForSource&&n===e?.ruleAssetGroupCodeForSource&&i===e?.ruleAssetTypeCodeForSource&&s===e?.ruleLayerIdForTarget&&(null==u||u===e?.ruleAssetGroupCodeForTarget)))}))}))}getFeatureSQL(e,r){const t=e.layerId.toString(),o=e.fieldsIndex?.normalizeFieldName("assetGroup"),s=e.fieldsIndex?.normalizeFieldName("assetType"),u=o?r.attributes[o]:null,a=s?r.attributes[s]:null,n=this.rulesHash[t];if(n){const e=n.assetGroupHash[u];if(e){return e.assetTypeHash[a]||null}}return null}async _initializeRulesTable(){const e={};let r;!function(e){e[e.from=0]="from",e[e.to=1]="to",e[e.via=2]="via"}(r||(r={}));const t=[{networkSourceId:"fromNetworkSource",assetGroupId:"fromAssetGroup",assetTypeId:"fromAssetType"},{networkSourceId:"toNetworkSource",assetGroupId:"toAssetGroup",assetTypeId:"toAssetType"},{networkSourceId:"viaNetworkSource",assetGroupId:"viaAssetGroup",assetTypeId:"viaAssetType"}];this.rulesCategorized={attachment:[],containment:[],connectivity:[]};for(const o of this.rules){if(o.ruleType===i.RTAttachment){this.rulesCategorized.attachment.push(o);continue}if(o.ruleType===i.RTContainment){this.rulesCategorized.containment.push(o);continue}if(o.ruleType===i.RTJunctionJunctionConnectivity){this.rulesCategorized.connectivity.push(o);continue}this.rulesCategorized.connectivity.push(o);let s=[[r.from,r.to],[r.to,r.from]];o.ruleType===i.RTEdgeJunctionEdgeConnectivity&&(s=[[r.from,r.via],[r.via,r.from],[r.to,r.via],[r.via,r.to]]);for(const u of s){const s=u.shift(),a=u.shift();let n=!1;switch(o.ruleType){case i.RTEdgeJunctionEdgeConnectivity:n=s===r.from||s===r.to;break;case i.RTJunctionEdgeConnectivity:n=s===r.to}const d=t[s],c=o[d.networkSourceId]?.layerId.toString()??"",l=o[d.assetGroupId]?.assetGroupCode?.toString(),p=o[d.assetTypeId],y=p?.assetTypeCode?.toString(),T=t[a],C=o[T.networkSourceId]?.layerId.toString()??"",A=o[T.assetGroupId]?.assetGroupCode?.toString(),F=o[T.assetTypeId],g=F?.assetTypeCode?.toString(),m=e[c]??{assetGroupHash:{}};if(!(l&&y&&A&&g))continue;const S=m.assetGroupHash[l]??{assetTypeHash:{}},f=S.assetTypeHash[y]??{};if(f[C]=f[C]??{},n){f[c]=f[c]??{};const e=`(assetgroup = ${l} AND assettype = ${y})`;"esriNECPEndVertex"===F?.connectivityPolicy?f[c].endVertex=f[c]?.endVertex?`${f[c].endVertex}`:`${e}`:f[c].anyVertex=f[c].anyVertex?`${f[c].anyVertex}`:`${e}`}const G=`(assetgroup = ${A} AND assettype = ${g})`;"esriNECPEndVertex"===F?.connectivityPolicy?f[C].endVertex=f[C]?.endVertex?`${f[C].endVertex} OR ${G}`:`${G}`:f[C].anyVertex=f[C]?.anyVertex?`${f[C].anyVertex} OR ${G}`:`${G}`,S.assetTypeHash[y]=f,m.assetGroupHash[l]=S,e[c]=m}}this._set("rulesHash",e)}_getRuleFieldValuesForAssociation(e,r,t="from"){switch(r){case"attachment":case"containment":return"from"===t?[{ruleLayerIdForSource:e.fromNetworkSource?.layerId,ruleAssetGroupCodeForSource:e.fromAssetGroup?.assetGroupCode,ruleAssetTypeCodeForSource:e.fromAssetType?.assetTypeCode,ruleLayerIdForTarget:e.toNetworkSource?.layerId,ruleAssetGroupCodeForTarget:e.toAssetGroup?.assetGroupCode,ruleAssetTypeCodeForTarget:e.toAssetType?.assetTypeCode}]:[{ruleLayerIdForSource:e.toNetworkSource?.layerId,ruleAssetGroupCodeForSource:e.toAssetGroup?.assetGroupCode,ruleAssetTypeCodeForSource:e.toAssetType?.assetTypeCode,ruleLayerIdForTarget:e.fromNetworkSource?.layerId,ruleAssetGroupCodeForTarget:e.fromAssetGroup?.assetGroupCode,ruleAssetTypeCodeForTarget:e.fromAssetType?.assetTypeCode}];case"connectivity":case"junction-junction-connectivity":return[{ruleLayerIdForSource:e.fromNetworkSource?.layerId,ruleAssetGroupCodeForSource:e.fromAssetGroup?.assetGroupCode,ruleAssetTypeCodeForSource:e.fromAssetType?.assetTypeCode,ruleLayerIdForTarget:e.toNetworkSource?.layerId,ruleAssetGroupCodeForTarget:e.toAssetGroup?.assetGroupCode,ruleAssetTypeCodeForTarget:e.toAssetType?.assetTypeCode},{ruleLayerIdForSource:e.toNetworkSource?.layerId,ruleAssetGroupCodeForSource:e.toAssetGroup?.assetGroupCode,ruleAssetTypeCodeForSource:e.toAssetType?.assetTypeCode,ruleLayerIdForTarget:e.fromNetworkSource?.layerId,ruleAssetGroupCodeForTarget:e.fromAssetGroup?.assetGroupCode,ruleAssetTypeCodeForTarget:e.fromAssetType?.assetTypeCode}];case"junction-edge-from-connectivity":case"junction-edge-midspan-connectivity":case"junction-edge-to-connectivity":return e.ruleType===i.RTEdgeJunctionEdgeConnectivity?[{ruleLayerIdForSource:e.fromNetworkSource?.layerId,ruleAssetGroupCodeForSource:e.fromAssetGroup?.assetGroupCode,ruleAssetTypeCodeForSource:e.fromAssetType?.assetTypeCode,ruleLayerIdForTarget:e.viaNetworkSource?.layerId,ruleAssetGroupCodeForTarget:e.viaAssetGroup?.assetGroupCode,ruleAssetTypeCodeForTarget:e.viaAssetType?.assetTypeCode},{ruleLayerIdForSource:e.viaNetworkSource?.layerId,ruleAssetGroupCodeForSource:e.viaAssetGroup?.assetGroupCode,ruleAssetTypeCodeForSource:e.viaAssetType?.assetTypeCode,ruleLayerIdForTarget:e.fromNetworkSource?.layerId,ruleAssetGroupCodeForTarget:e.fromAssetGroup?.assetGroupCode,ruleAssetTypeCodeForTarget:e.fromAssetType?.assetTypeCode},{ruleLayerIdForSource:e.toNetworkSource?.layerId,ruleAssetGroupCodeForSource:e.toAssetGroup?.assetGroupCode,ruleAssetTypeCodeForSource:e.toAssetType?.assetTypeCode,ruleLayerIdForTarget:e.viaNetworkSource?.layerId,ruleAssetGroupCodeForTarget:e.viaAssetGroup?.assetGroupCode,ruleAssetTypeCodeForTarget:e.viaAssetType?.assetTypeCode},{ruleLayerIdForSource:e.viaNetworkSource?.layerId,ruleAssetGroupCodeForSource:e.viaAssetGroup?.assetGroupCode,ruleAssetTypeCodeForSource:e.viaAssetType?.assetTypeCode,ruleLayerIdForTarget:e.toNetworkSource?.layerId,ruleAssetGroupCodeForTarget:e.toAssetGroup?.assetGroupCode,ruleAssetTypeCodeForTarget:e.toAssetType?.assetTypeCode}]:[{ruleLayerIdForSource:e.fromNetworkSource?.layerId,ruleAssetGroupCodeForSource:e.fromAssetGroup?.assetGroupCode,ruleAssetTypeCodeForSource:e.fromAssetType?.assetTypeCode,ruleLayerIdForTarget:e.toNetworkSource?.layerId,ruleAssetGroupCodeForTarget:e.toAssetGroup?.assetGroupCode,ruleAssetTypeCodeForTarget:e.toAssetType?.assetTypeCode},{ruleLayerIdForSource:e.toNetworkSource?.layerId,ruleAssetGroupCodeForSource:e.toAssetGroup?.assetGroupCode,ruleAssetTypeCodeForSource:e.toAssetType?.assetTypeCode,ruleLayerIdForTarget:e.fromNetworkSource?.layerId,ruleAssetGroupCodeForTarget:e.fromAssetGroup?.assetGroupCode,ruleAssetTypeCodeForTarget:e.fromAssetType?.assetTypeCode}];default:return[]}}_getWhereClauseForCompatibleFeatures(e,r,t){const o=new Map,[s,u]=this._getAssetFieldNames(e.sourceLayer),[n,i]=this._getFeatureAssetCodes(e),d=this._getFeatureSourceLayerId(e),c=a(r)?r.parent:r,l=a(r)?r.subtypeCode:null;t.forEach((e=>{const{type:r,direction:t}=e;this._getRulesForAssociationType(r).forEach((e=>{this._getRuleFieldValuesForAssociation(e,r,t).forEach((e=>{if(null!=e.ruleAssetGroupCodeForTarget&&null!=e.ruleAssetTypeCodeForTarget&&d===e?.ruleLayerIdForSource&&n===e?.ruleAssetGroupCodeForSource&&i===e?.ruleAssetTypeCodeForSource&&c.layerId===e?.ruleLayerIdForTarget&&(null==l||l===e?.ruleAssetGroupCodeForTarget)){const r=o.get(e.ruleAssetGroupCodeForTarget)??new Set;r.add(e.ruleAssetTypeCodeForTarget),o.set(e.ruleAssetGroupCodeForTarget,r)}}))}))}));let p=[];return this._mergeAssetCodes(o).forEach(((e,r)=>p.push(`${s} IN (${r}) AND ${u} IN (${Array.from(e).sort().join(", ")})`))),p.length>1&&(p=p.map((e=>`(${e})`))),p.join(" OR ")}_getRulesForAssociationType(e){const{rulesCategorized:r}=this;switch(e){case"attachment":return r.attachment;case"containment":return r.containment;case"connectivity":case"junction-junction-connectivity":return r.connectivity.filter((e=>e.ruleType===i.RTJunctionJunctionConnectivity));case"junction-edge-from-connectivity":case"junction-edge-midspan-connectivity":case"junction-edge-to-connectivity":return r.connectivity.filter((e=>e.ruleType===i.RTJunctionEdgeConnectivity||e.ruleType===i.RTEdgeJunctionEdgeConnectivity));default:return[]}}_getFeatureSourceLayerId(e){const{sourceLayer:r}=e;let t;return n(r)?t=r.layerId:a(r)&&(t=r.parent?.layerId),t??null}_getAssetFieldNames(e){if(!e||!("fieldsIndex"in e))return[null,null];return[e.fieldsIndex.normalizeFieldName("assetGroup")??null,e.fieldsIndex.normalizeFieldName("assetType")??null]}_getFeatureAssetCodes(e){const[r,t]=this._getAssetFieldNames(e.sourceLayer);return[r?e.attributes[r]:null,t?e.attributes[t]:null]}_areSetsEqual(e,r){if(e.size!==r.size)return!1;for(const t of e)if(!r.has(t))return!1;return!0}_mergeAssetCodes(e){const r=new Map,t=new Set;for(const[o,s]of e){const u=new Set([o]);for(const[r,n]of e)o!==r&&!t.has(r)&&this._areSetsEqual(s,n)&&(u.add(r),t.add(r));const a=Array.from(u).sort().join(", ");r.set(a,s)}return r}};e([s({constructOnly:!0})],d.prototype,"rulesLayer",void 0),e([s({constructOnly:!0})],d.prototype,"rules",void 0),e([s({readOnly:!0})],d.prototype,"rulesHash",void 0),e([s()],d.prototype,"rulesCategorized",void 0),e([s({constructOnly:!0})],d.prototype,"request",void 0),d=e([u("esri.networks.RulesTable")],d);const c=d;export{c as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcgis/core",
3
- "version": "4.32.0-next.20250220",
3
+ "version": "4.32.0-next.20250221",
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/4.32/esri/copyright.txt for details.
4
4
  */
5
- import{_ as t}from"../../chunks/tslib.es6.js";import e from"../../Graphic.js";import r from"../../PopupTemplate.js";import s from"../../core/Clonable.js";import o from"../../core/JSONSupport.js";import{property as p}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{reader as a}from"../../core/accessorSupport/decorators/reader.js";import{subclass as i}from"../../core/accessorSupport/decorators/subclass.js";import{writer as l}from"../../core/accessorSupport/decorators/writer.js";import u from"../../geometry/Point.js";import{getPrefixedProperties as d,setPrefixedProperties as n,toKebabImpedanceAttributes as m,fromKebabImpedanceAttributes as c}from"../route/utils.js";import{barrierTypeJsonMap as y,curbApproachJsonMap as b,fullEdgeJsonMap as h,statusJsonMap as j,sideOfEdgeJsonMap as g}from"./networkEnums.js";import{symbolTypes as f}from"../../symbols/support/typeUtils.js";var C;let S=C=class extends(s.ClonableMixin(o)){constructor(t){super(t),this.addedCost=null,this.barrierType=null,this.costs=null,this.curbApproach=null,this.fullEdge=null,this.geometry=null,this.name=null,this.objectId=null,this.popupTemplate=null,this.sideOfEdge=null,this.sourceId=null,this.sourceOid=null,this.status=null,this.symbol=null,this.type="point-barrier"}readCosts(t,e){return d(e.attributes,"Attr_")}writeCosts(t,e){n(t,e,"Attr_")}static fromGraphic(t){return new C({addedCost:t.attributes.AddedCost??null,barrierType:null!=t.attributes.BarrierType?y.fromJSON(t.attributes.BarrierType):null,costs:null!=t.attributes.Costs?m(JSON.parse(t.attributes.Costs)):null,curbApproach:null!=t.attributes.CurbApproach?b.fromJSON(t.attributes.CurbApproach):null,fullEdge:null!=t.attributes.FullEdge?h.fromJSON(t.attributes.FullEdge):null,geometry:t.geometry,name:t.attributes.Name??null,objectId:t.attributes.ObjectID??t.attributes.__OBJECTID,popupTemplate:t.popupTemplate,status:null!=t.attributes.Status?j.fromJSON(t.attributes.Status):null,symbol:t.symbol})}toGraphic(){const t={ObjectID:this.objectId,AddedCost:this.addedCost,BarrierType:null!=this.barrierType?y.toJSON(this.barrierType):null,Costs:null!=this.costs?JSON.stringify(c(this.costs)):null,CurbApproach:null!=this.curbApproach?b.toJSON(this.curbApproach):null,FullEdge:null!=this.fullEdge?h.toJSON(this.fullEdge):null,Name:this.name,Status:null!=this.status?j.toJSON(this.status):null};return new e({geometry:this.geometry,attributes:t,symbol:this.symbol,popupTemplate:this.popupTemplate})}};S.fields=[{name:"ObjectID",alias:"ObjectID",type:"esriFieldTypeOID"},{name:"AddedCost",alias:"Added Cost",type:"esriFieldTypeDouble"},{name:"BarrierType",alias:"Barrier Type",type:"esriFieldTypeInteger"},{name:"Costs",alias:"Costs",type:"esriFieldTypeString"},{name:"CurbApproach",alias:"Curb Approach",type:"esriFieldTypeInteger"},{name:"FullEdge",alias:"Full Edge",type:"esriFieldTypeInteger"},{name:"Name",alias:"Name",type:"esriFieldTypeString"},{name:"Status",alias:"Status",type:"esriFieldTypeInteger"}],t([p()],S.prototype,"addedCost",void 0),t([p({type:y.apiValues,json:{name:"attributes.BarrierType",read:{reader:y.read},write:{writer:y.write}}})],S.prototype,"barrierType",void 0),t([p()],S.prototype,"costs",void 0),t([a("costs",["attributes"])],S.prototype,"readCosts",null),t([l("costs")],S.prototype,"writeCosts",null),t([p({constructOnly:!0,type:b.apiValues,json:{read:{source:"attributes.CurbApproach",reader:b.read}}})],S.prototype,"curbApproach",void 0),t([p({type:h.apiValues,json:{name:"attributes.FullEdge",read:{reader:h.read},write:{writer:h.write}}})],S.prototype,"fullEdge",void 0),t([p({type:u,json:{write:!0}})],S.prototype,"geometry",void 0),t([p({json:{name:"attributes.Name"}})],S.prototype,"name",void 0),t([p({json:{name:"attributes.ObjectID"}})],S.prototype,"objectId",void 0),t([p({type:r})],S.prototype,"popupTemplate",void 0),t([p({type:g.apiValues,json:{read:{source:"attributes.SideOfEdge",reader:g.read}}})],S.prototype,"sideOfEdge",void 0),t([p({json:{read:{source:"attributes.SourceID"}}})],S.prototype,"sourceId",void 0),t([p({json:{read:{source:"attributes.SourceOID"}}})],S.prototype,"sourceOid",void 0),t([p({type:j.apiValues,json:{read:{source:"attributes.Status",reader:j.read}}})],S.prototype,"status",void 0),t([p({types:f})],S.prototype,"symbol",void 0),t([p({readOnly:!0,json:{read:!1}})],S.prototype,"type",void 0),S=C=t([i("esri.rest.support.PointBarrier")],S);const T=S;export{T as default};
5
+ import{_ as t}from"../../chunks/tslib.es6.js";import e from"../../Graphic.js";import r from"../../PopupTemplate.js";import s from"../../core/Clonable.js";import o from"../../core/JSONSupport.js";import{property as p}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{reader as a}from"../../core/accessorSupport/decorators/reader.js";import{subclass as i}from"../../core/accessorSupport/decorators/subclass.js";import{writer as l}from"../../core/accessorSupport/decorators/writer.js";import u from"../../geometry/Point.js";import{getPrefixedProperties as d,setPrefixedProperties as n,toKebabImpedanceAttributes as m,fromKebabImpedanceAttributes as c}from"../route/utils.js";import{barrierTypeJsonMap as y,curbApproachJsonMap as b,fullEdgeJsonMap as h,statusJsonMap as j,sideOfEdgeJsonMap as g}from"./networkEnums.js";import{symbolTypes as f}from"../../symbols/support/typeUtils.js";var C;let S=C=class extends(s.ClonableMixin(o)){constructor(t){super(t),this.addedCost=null,this.barrierType=null,this.costs=null,this.curbApproach=null,this.fullEdge=null,this.geometry=null,this.name=null,this.objectId=null,this.popupTemplate=null,this.sideOfEdge=null,this.sourceId=null,this.sourceOid=null,this.status=null,this.symbol=null,this.type="point-barrier"}readCosts(t,e){return d(e.attributes,"Attr_")}writeCosts(t,e){n(t,e,"Attr_")}static fromGraphic(t){return new C({addedCost:t.attributes.AddedCost??null,barrierType:null!=t.attributes.BarrierType?y.fromJSON(t.attributes.BarrierType):null,costs:null!=t.attributes.Costs?m(JSON.parse(t.attributes.Costs)):null,curbApproach:null!=t.attributes.CurbApproach?b.fromJSON(t.attributes.CurbApproach):null,fullEdge:null!=t.attributes.FullEdge?h.fromJSON(t.attributes.FullEdge):null,geometry:t.geometry,name:t.attributes.Name??null,objectId:t.attributes.ObjectID??t.attributes.__OBJECTID,popupTemplate:t.popupTemplate,status:null!=t.attributes.Status?j.fromJSON(t.attributes.Status):null,symbol:t.symbol})}toGraphic(){const t={ObjectID:this.objectId,AddedCost:this.addedCost,BarrierType:null!=this.barrierType?y.toJSON(this.barrierType):null,Costs:null!=this.costs?JSON.stringify(c(this.costs)):null,CurbApproach:null!=this.curbApproach?b.toJSON(this.curbApproach):null,FullEdge:null!=this.fullEdge?h.toJSON(this.fullEdge):null,Name:this.name,Status:null!=this.status?j.toJSON(this.status):null};return new e({geometry:this.geometry,attributes:t,symbol:this.symbol,popupTemplate:this.popupTemplate})}};S.fields=[{name:"ObjectID",alias:"ObjectID",type:"esriFieldTypeOID"},{name:"AddedCost",alias:"Added Cost",type:"esriFieldTypeDouble"},{name:"BarrierType",alias:"Barrier Type",type:"esriFieldTypeInteger"},{name:"Costs",alias:"Costs",type:"esriFieldTypeString"},{name:"CurbApproach",alias:"Curb Approach",type:"esriFieldTypeInteger"},{name:"FullEdge",alias:"Full Edge",type:"esriFieldTypeInteger"},{name:"Name",alias:"Name",type:"esriFieldTypeString"},{name:"Status",alias:"Status",type:"esriFieldTypeInteger"}],t([p()],S.prototype,"addedCost",void 0),t([p({type:y.apiValues,json:{name:"attributes.BarrierType",read:{reader:y.read},write:{writer:y.write}}})],S.prototype,"barrierType",void 0),t([p()],S.prototype,"costs",void 0),t([a("costs",["attributes"])],S.prototype,"readCosts",null),t([l("costs")],S.prototype,"writeCosts",null),t([p({type:b.apiValues,json:{read:{source:"attributes.CurbApproach",reader:b.read}}})],S.prototype,"curbApproach",void 0),t([p({type:h.apiValues,json:{name:"attributes.FullEdge",read:{reader:h.read},write:{writer:h.write}}})],S.prototype,"fullEdge",void 0),t([p({type:u,json:{write:!0}})],S.prototype,"geometry",void 0),t([p({json:{name:"attributes.Name"}})],S.prototype,"name",void 0),t([p({json:{name:"attributes.ObjectID"}})],S.prototype,"objectId",void 0),t([p({type:r})],S.prototype,"popupTemplate",void 0),t([p({type:g.apiValues,json:{read:{source:"attributes.SideOfEdge",reader:g.read}}})],S.prototype,"sideOfEdge",void 0),t([p({json:{read:{source:"attributes.SourceID"}}})],S.prototype,"sourceId",void 0),t([p({json:{read:{source:"attributes.SourceOID"}}})],S.prototype,"sourceOid",void 0),t([p({type:j.apiValues,json:{read:{source:"attributes.Status",reader:j.read}}})],S.prototype,"status",void 0),t([p({types:f})],S.prototype,"symbol",void 0),t([p({readOnly:!0,json:{read:!1}})],S.prototype,"type",void 0),S=C=t([i("esri.rest.support.PointBarrier")],S);const T=S;export{T as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.32/esri/copyright.txt for details.
4
4
  */
5
- const c="20250220",e="71616d8254750d2e57a843e30cb2d9c84c5e2949";export{c as buildDate,e as commitHash};
5
+ const a="20250221",e="3ca577b0e78f3664d7834460a4a93251216fed70";export{a 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/4.32/esri/copyright.txt for details.
4
4
  */
5
- import{clone as m}from"../../core/lang.js";import{getExtent as e}from"./SDFHelper.js";import{CIMEffectHelper as r}from"./effects/CIMEffectHelper.js";const a=.01;function t(t,f){if(!t.frame)return t;const{markerGraphics:n}=t;if(!n||0===n.length)return t;let o=0,s=0,i=0,x=0;for(const m of n){const{geometry:a,symbol:t}=m;if(!a||!t||!("symbolLayers"in t))continue;const{symbolLayers:n}=t;if(n)for(const m of n){const{effects:t}=m,n=r.applyEffects(t,a,f),c=e(n);c&&(o=Math.min(o,c[0]),s=Math.min(s,c[1]),i=Math.max(i,c[2]),x=Math.max(x,c[3]))}}const{xmin:c,ymin:y,xmax:p,ymax:h}=t.frame,l=(p-c)/2,M=(h-y)/2,u=(p+c)/2,b=(h+y)/2,g=(u-o)/l,j=(i-u)/l,E=(b-s)/M,F=(x-b)/M,H=Math.max(Math.max(g,j),Math.max(E,F));return H<=1+a?t:(t=m(t)).frame?(t.frame.xmin=(t.frame.xmin-u)*H+u,t.frame.ymin=(t.frame.ymin-b)*H+b,t.frame.xmax=(t.frame.xmax-u)*H+u,t.frame.ymax=(t.frame.ymax-b)*H+b,!1!==t.respectFrame&&(t.size*=H),t):t}export{t as fitVectorMarker};
5
+ import{clone as m}from"../../core/lang.js";import{getExtent as e}from"./SDFHelper.js";import{CIMEffectHelper as r}from"./effects/CIMEffectHelper.js";const a=.01;function t(t,f){if(!t.frame)return t;const{markerGraphics:n}=t;if(!n||0===n.length)return t;let o=0,s=0,i=0,c=0;for(const m of n){const{geometry:a,symbol:t}=m;if(!a||!t||!("symbolLayers"in t))continue;const{symbolLayers:n}=t;if(n)for(const m of n){const{effects:t}=m,n=r.applyEffects(t,a,f),x=e(n);x&&(o=Math.min(o,x[0]),s=Math.min(s,x[1]),i=Math.max(i,x[2]),c=Math.max(c,x[3]))}}const{xmin:x,ymin:y,xmax:p,ymax:h}=t.frame,l=(p-x)/2,M=(h-y)/2,u=(p+x)/2,b=(h+y)/2;if(l<=0||M<=0)return t;const g=(u-o)/l,j=(i-u)/l,E=(b-s)/M,F=(c-b)/M,H=Math.max(Math.max(g,j),Math.max(E,F));return H<=1+a?t:(t=m(t)).frame?(t.frame.xmin=(t.frame.xmin-u)*H+u,t.frame.ymin=(t.frame.ymin-b)*H+b,t.frame.xmax=(t.frame.xmax-u)*H+u,t.frame.ymax=(t.frame.ymax-b)*H+b,!1!==t.respectFrame&&(t.size*=H),t):t}export{t as fitVectorMarker};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.32/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import{id as i}from"../../kernel.js";import r from"../../core/Collection.js";import s from"../../core/Error.js";import n from"../../core/Evented.js";import t from"../../core/Loadable.js";import o from"../../core/Logger.js";import{getOrCreateMapValue as a}from"../../core/MapUtils.js";import d from"../../core/Promise.js";import{debounce as c,throwIfAborted as v}from"../../core/promiseUtils.js";import l from"../../core/ReactiveMap.js";import{watch as p,whenOnce as u}from"../../core/reactiveUtils.js";import{normalize as f}from"../../core/urlUtils.js";import{property as m}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{subclass as h}from"../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as g}from"../../core/support/UpdatingHandles.js";import{parse as w}from"../../layers/support/arcgisLayerUrl.js";import{isSubtypeGroupLayer as y,isFeatureLayer as S}from"../../layers/support/layerUtils.js";import I from"../../portal/Portal.js";import{hasUserTypeExtension as _}from"../../portal/support/utils.js";import b from"../../rest/featureService/FeatureService.js";import{ServiceVersionInfo as L}from"./ServiceVersionInfo.js";import V from"../../versionManagement/VersionManagementService.js";function U(e){return!e||0===e.trim().length}const A=new Map;function T(e){return a(A,e,(()=>{const i=new j({view:e});return e.addHandles({remove(){A.delete(e),i.destroy()}}),i.load().catch((e=>{o.getLogger("esri.views.Services").error("Failed to load service metadata",e)})),i}))}let j=class extends(t.LoadableMixin(d.EsriPromiseMixin(n.EventedAccessor))){constructor(e){super(e),this._updatingHandles=new g,this.items=new r,this.tablesAndLayersLookup=new l,this.additionalLayers=new r,this._debouncedCheckAndUpdateServiceInfos=c((async()=>{const e=[];for(const i of this.items){if(0===i.layersAndTables.length)continue;const r=i.layersAndTables.getItemAt(0);r?.gdbVersion!==i.versionInfo?.versionIdentifier.name&&e.push(i)}0!==e.length&&(await u((()=>!this.updating)),await this._updateVersionInfos(e))})),this._debouncedLayersChanged=c((async()=>{const e=this._detectNewLayersAndTables();0!==e.length&&(await u((()=>!this._updatingHandles.updating)),await this._updatingHandles.addPromise((async()=>{for(const i of e)if("feature"===i.type||"subtype-group"===i.type){if(!i.url)continue;const e=w(i.url).url.path,r=this._findServiceInfo(e);r?(this.tablesAndLayersLookup.set(i,r),i.isTable?r.tables.push(i):r.layers.push(i)):await this._addServiceInfo(e,i)}})()))})),this._processed=new Set}destroy(){this._set("view",null),this.items.removeAll(),this.tablesAndLayersLookup.clear()}async load(e){return v(e),this.addHandles([p((()=>this._allLayersAndTables),(()=>{this._debouncedLayersChanged().catch((e=>{o.getLogger(this).warn("Failed to update service info",e)}))})),p((()=>this.items.map((e=>e.layersAndTables.map((e=>e.gdbVersion??"")).join(",")))),(()=>{this.checkAndUpdateServiceInfos().catch((e=>{o.getLogger(this).warn("Failed to update service info",e)}))}))]),this.addResolvingPromise(this._debouncedLayersChanged()),this}get updating(){return"loading"===this.loadStatus||this._updatingHandles.updating}checkAndUpdateServiceInfos(){return this._debouncedCheckAndUpdateServiceInfos()}changeVersion(e,i,r){return this._updatingHandles.addPromise((async()=>{await this._changeVersionInternal(e,i,r)})())}createVersion(e){return this._updatingHandles.addPromise((async()=>{const i=e.featureServerUrl,r=this._findServiceInfo(i);if(!r?.versionService)throw new s("services:no-version-management-service");const n=r.hasAdvancedEditingUserTypeExtension,t=r.loggedInServiceUser.toUpperCase(),o=U(e.ownerName)?t:e.ownerName?.trim().toUpperCase();if(o!==t){if(r.featureServiceVersion<=11.1)throw new s("services:versioning-api-error");if(!n)throw new s("services:no-advanced-editing-user-type-extension")}if("SDE"===o?.toUpperCase()&&"DEFAULT"===e.versionName.toUpperCase())throw new s("services:no-valid-version-name");{const i=await r.versionService.getVersionInfos();if(i?.find((i=>i.versionIdentifier.name.toUpperCase()===(o+"."+e.versionName).toUpperCase()||i.versionIdentifier.name.toUpperCase()===(t+"."+e.versionName).toUpperCase())))throw new s("services:no-valid-version-name")}const a=await r.versionService.createVersion({versionName:e.versionName,access:o!==t?"public":e.access,description:e.description});if(o!==t){const{guid:i,name:s}=a.versionIdentifier;await r.versionService.alterVersion({guid:i,name:s},{ownerName:o,access:e.access})}e.switchToVersion&&await this._changeVersionInternal(i,a.versionIdentifier.name,a.versionIdentifier.guid),this.emit("version-created",{versionIdentifier:a.versionIdentifier,versionManagementService:r.versionService})})())}deleteVersion(e,i,r){return this._updatingHandles.addPromise((async()=>{const n=this._findServiceInfo(e);if(!n?.versionService)throw new s("services:no-version-management-service");if(n.featureServiceVersion<=11.1)throw new s("services:versioning-api-error");if(!n.hasAdvancedEditingUserTypeExtension)throw new s("services:no-advanced-editing-user-type-extension");const t={name:i,guid:r};await n.versionService.deleteVersion(t)&&(await this._updateVersionInfo(n),this.emit("version-deleted",{versionIdentifier:t,versionManagementService:n.versionService}))})())}startEditing(e){return this._updatingHandles.addPromise((async()=>{const i=this._findServiceInfo(e);if(!i?.versionService)throw new s("services:no-version-management-service");if(!i.hasAdvancedEditingUserTypeExtension)throw new s("services:no-advanced-editing-user-type-extension");const r=i.versionInfo?.versionIdentifier??{name:i.versionService.defaultVersionIdentifier.name,guid:i.versionService.defaultVersionIdentifier.guid};let n=!0;("none"!==i.versionService.getLockType(r)||(n=await i.versionService.startReading(r),n))&&(n=await i.versionService.startEditing(r),i.updateLockType())})())}finishEditing(e,i){return this._updatingHandles.addPromise((async()=>{const r=this._findServiceInfo(e);if(!r?.versionService)throw new s("services:no-version-management-service");if(!r.hasAdvancedEditingUserTypeExtension)throw new s("services:no-advanced-editing-user-type-extension");const n=r.versionInfo?.versionIdentifier??{name:r.versionService.defaultVersionIdentifier.name,guid:r.versionService.defaultVersionIdentifier.guid},t=r.versionService.getLockType(n);if("none"!==t)return"read"===t?(await r.versionService.stopReading(n),void r.updateLockType()):"edit"===t?(await r.versionService.stopEditing(n,i),await r.versionService.stopReading(n),void r.updateLockType()):void 0})())}async _changeVersionInternal(e,i,r){const n=this._findServiceInfo(e);if(!n?.versionService)throw new s("services:no-version-management-service");const t=n.versionInfo?.versionIdentifier??{name:n.versionService.defaultVersionIdentifier.name,guid:n.versionService.defaultVersionIdentifier.guid},o={name:i,guid:r};await n.versionService.changeVersion(this.view?.map,t,o)&&await this._updateVersionInfo(n)}async _updateVersionInfo(e){const i=e.versionService;if(!i)return;if(0===e.layersAndTables.length)return;const r=e.layersAndTables.getItemAt(0)?.gdbVersion,s=r?await i.getVersionIdentifierFromName(r):i.defaultVersionIdentifier;e.versionInfo=await i.getVersionInfoExtended(s)}_findServiceInfo(e){return this.items.find((i=>i.featureService.url===e))??null}_removeFeatureService(e){this.items.remove(e)}async _findPortal(e){const r=i?.findServerInfo(e??"");if(!r?.owningSystemUrl)return null;const s=`${r.owningSystemUrl}/sharing/rest`,n=I.getDefault();if(n?.loaded&&f(n.restUrl)===f(s))return n;return new I({authMode:"immediate",url:r.owningSystemUrl}).load()}_updateVersionInfos(e){return this._updatingHandles.addPromise((async()=>{for(const i of e)await this._updateVersionInfo(i).catch((e=>{o.getLogger(this).error("Failed to update version details",e)}))})())}async _addServiceInfo(e,i){const s=new b({url:e});await s.load();const n=await this._findPortal(e),t=n?.user?.username;let o=!1;t&&(o=await _(n,t,"advediting"));let a=null;s.versionManagementServiceUrl&&(a=new V({url:s.versionManagementServiceUrl}),await a.load());const d=i.isTable?[]:[i],c=i.isTable?[i]:[],v=new L({loggedInServiceUser:t??"",hasAdvancedEditingUserTypeExtension:o,versionInfo:null,lockType:"none",canEditVersionedData:!0,canCreateVersion:!0,featureService:s,versionService:a,layers:new r(d),tables:new r(c)});return a&&await this._updateVersionInfo(v),this.items.push(v),this.tablesAndLayersLookup.set(i,v),i.isTable?v.tables.push(i):v.layers.push(i),v}get _allLayersAndTables(){return[...this.view.map.allLayers,...this.view.map.allTables,...this.additionalLayers]}_detectNewLayersAndTables(){const e=new Set(this._allLayersAndTables),i=[];for(const r of e)"feature"!==r.type&&"subtype-group"!==r.type||this._processed.has(r)||i.push(r);for(const r of this._processed)if(!e.has(r)&&(y(r)||S(r))){const e=this.tablesAndLayersLookup.get(r);if(!e)continue;this.tablesAndLayersLookup.delete(r),r.isTable?e.tables.remove(r):e.layers.remove(r),0===e.layersAndTables.length&&this._removeFeatureService(e)}return this._processed=e,i}};e([m({constructOnly:!0})],j.prototype,"view",void 0),e([m()],j.prototype,"items",void 0),e([m()],j.prototype,"tablesAndLayersLookup",void 0),e([m()],j.prototype,"additionalLayers",void 0),e([m()],j.prototype,"updating",null),e([m()],j.prototype,"_allLayersAndTables",null),j=e([h("esri.undoredo.support.Services")],j);export{j as Services,T as getServices};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import{id as i}from"../../kernel.js";import r from"../../core/Collection.js";import s from"../../core/Error.js";import n from"../../core/Evented.js";import t from"../../core/Loadable.js";import o from"../../core/Logger.js";import{getOrCreateMapValue as a}from"../../core/MapUtils.js";import d from"../../core/Promise.js";import{debounce as c,throwIfAborted as v}from"../../core/promiseUtils.js";import l from"../../core/ReactiveMap.js";import{watch as p,whenOnce as u}from"../../core/reactiveUtils.js";import{normalize as f}from"../../core/urlUtils.js";import{property as m}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{subclass as h}from"../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as g}from"../../core/support/UpdatingHandles.js";import{parse as w}from"../../layers/support/arcgisLayerUrl.js";import{isSubtypeGroupLayer as y,isFeatureLayer as S}from"../../layers/support/layerUtils.js";import I from"../../portal/Portal.js";import{hasUserTypeExtension as _}from"../../portal/support/utils.js";import b from"../../rest/featureService/FeatureService.js";import{ServiceVersionInfo as L}from"./ServiceVersionInfo.js";import V from"../../versionManagement/VersionManagementService.js";function U(e){return!e||0===e.trim().length}const A=new Map;function T(e){return a(A,e,(()=>{const i=new j({view:e});return e.addHandles({remove(){A.delete(e),i.destroy()}}),i.load().catch((e=>{o.getLogger("esri.views.Services").error("Failed to load service metadata",e)})),i}))}let j=class extends(t.LoadableMixin(d.EsriPromiseMixin(n.EventedAccessor))){constructor(e){super(e),this._updatingHandles=new g,this.items=new r,this.tablesAndLayersLookup=new l,this.additionalLayers=new r,this._debouncedCheckAndUpdateServiceInfos=c((async()=>{const e=[];for(const i of this.items){if(0===i.layersAndTables.length)continue;const r=i.layersAndTables.getItemAt(0);r?.gdbVersion!==i.versionInfo?.versionIdentifier.name&&e.push(i)}0!==e.length&&(await u((()=>!this.updating)),await this._updateVersionInfos(e))})),this._debouncedLayersChanged=c((async()=>{const e=this._detectNewLayersAndTables();0!==e.length&&(await u((()=>!this._updatingHandles.updating)),await this._updatingHandles.addPromise((async()=>{const i=new Set;for(const s of e)if("feature"===s.type||"subtype-group"===s.type){if(!s.url)continue;const e=w(s.url).url.path,n=this._findServiceInfo(e);if(n)this.tablesAndLayersLookup.set(s,n),s.isTable?n.tables.push(s):n.layers.push(s);else if(!i.has(e))try{await this._addServiceInfo(e,s)}catch(r){o.getLogger(this).error(`Failed to load feature service: ${e}`,r)}finally{i.add(e)}}})()))})),this._processed=new Set}destroy(){this._set("view",null),this.items.removeAll(),this.tablesAndLayersLookup.clear()}async load(e){return v(e),this.addHandles([p((()=>this._allLayersAndTables),(()=>{this._debouncedLayersChanged().catch((e=>{o.getLogger(this).warn("Failed to update service info",e)}))})),p((()=>this.items.map((e=>e.layersAndTables.map((e=>e.gdbVersion??"")).join(",")))),(()=>{this.checkAndUpdateServiceInfos().catch((e=>{o.getLogger(this).warn("Failed to update service info",e)}))}))]),this.addResolvingPromise(this._debouncedLayersChanged()),this}get updating(){return"loading"===this.loadStatus||this._updatingHandles.updating}checkAndUpdateServiceInfos(){return this._debouncedCheckAndUpdateServiceInfos()}changeVersion(e,i,r){return this._updatingHandles.addPromise((async()=>{await this._changeVersionInternal(e,i,r)})())}createVersion(e){return this._updatingHandles.addPromise((async()=>{const i=e.featureServerUrl,r=this._findServiceInfo(i);if(!r?.versionService)throw new s("services:no-version-management-service");const n=r.hasAdvancedEditingUserTypeExtension,t=r.loggedInServiceUser.toUpperCase(),o=U(e.ownerName)?t:e.ownerName?.trim().toUpperCase();if(o!==t){if(r.featureServiceVersion<=11.1)throw new s("services:versioning-api-error");if(!n)throw new s("services:no-advanced-editing-user-type-extension")}if("SDE"===o?.toUpperCase()&&"DEFAULT"===e.versionName.toUpperCase())throw new s("services:no-valid-version-name");{const i=await r.versionService.getVersionInfos();if(i?.find((i=>i.versionIdentifier.name.toUpperCase()===(o+"."+e.versionName).toUpperCase()||i.versionIdentifier.name.toUpperCase()===(t+"."+e.versionName).toUpperCase())))throw new s("services:no-valid-version-name")}const a=await r.versionService.createVersion({versionName:e.versionName,access:o!==t?"public":e.access,description:e.description});if(o!==t){const{guid:i,name:s}=a.versionIdentifier;await r.versionService.alterVersion({guid:i,name:s},{ownerName:o,access:e.access})}e.switchToVersion&&await this._changeVersionInternal(i,a.versionIdentifier.name,a.versionIdentifier.guid),this.emit("version-created",{versionIdentifier:a.versionIdentifier,versionManagementService:r.versionService})})())}deleteVersion(e,i,r){return this._updatingHandles.addPromise((async()=>{const n=this._findServiceInfo(e);if(!n?.versionService)throw new s("services:no-version-management-service");if(n.featureServiceVersion<=11.1)throw new s("services:versioning-api-error");if(!n.hasAdvancedEditingUserTypeExtension)throw new s("services:no-advanced-editing-user-type-extension");const t={name:i,guid:r};await n.versionService.deleteVersion(t)&&(await this._updateVersionInfo(n),this.emit("version-deleted",{versionIdentifier:t,versionManagementService:n.versionService}))})())}startEditing(e){return this._updatingHandles.addPromise((async()=>{const i=this._findServiceInfo(e);if(!i?.versionService)throw new s("services:no-version-management-service");if(!i.hasAdvancedEditingUserTypeExtension)throw new s("services:no-advanced-editing-user-type-extension");const r=i.versionInfo?.versionIdentifier??{name:i.versionService.defaultVersionIdentifier.name,guid:i.versionService.defaultVersionIdentifier.guid};let n=!0;("none"!==i.versionService.getLockType(r)||(n=await i.versionService.startReading(r),n))&&(n=await i.versionService.startEditing(r),i.updateLockType())})())}finishEditing(e,i){return this._updatingHandles.addPromise((async()=>{const r=this._findServiceInfo(e);if(!r?.versionService)throw new s("services:no-version-management-service");if(!r.hasAdvancedEditingUserTypeExtension)throw new s("services:no-advanced-editing-user-type-extension");const n=r.versionInfo?.versionIdentifier??{name:r.versionService.defaultVersionIdentifier.name,guid:r.versionService.defaultVersionIdentifier.guid},t=r.versionService.getLockType(n);if("none"!==t)return"read"===t?(await r.versionService.stopReading(n),void r.updateLockType()):"edit"===t?(await r.versionService.stopEditing(n,i),await r.versionService.stopReading(n),void r.updateLockType()):void 0})())}async _changeVersionInternal(e,i,r){const n=this._findServiceInfo(e);if(!n?.versionService)throw new s("services:no-version-management-service");const t=n.versionInfo?.versionIdentifier??{name:n.versionService.defaultVersionIdentifier.name,guid:n.versionService.defaultVersionIdentifier.guid},o={name:i,guid:r};await n.versionService.changeVersion(this.view?.map,t,o)&&await this._updateVersionInfo(n)}async _updateVersionInfo(e){const i=e.versionService;if(!i)return;if(0===e.layersAndTables.length)return;const r=e.layersAndTables.getItemAt(0)?.gdbVersion,s=r?await i.getVersionIdentifierFromName(r):i.defaultVersionIdentifier;e.versionInfo=await i.getVersionInfoExtended(s)}_findServiceInfo(e){return this.items.find((i=>i.featureService.url===e))??null}_removeFeatureService(e){this.items.remove(e)}async _findPortal(e){const r=i?.findServerInfo(e??"");if(!r?.owningSystemUrl)return null;const s=`${r.owningSystemUrl}/sharing/rest`,n=I.getDefault();if(n?.loaded&&f(n.restUrl)===f(s))return n;return new I({authMode:"immediate",url:r.owningSystemUrl}).load()}_updateVersionInfos(e){return this._updatingHandles.addPromise((async()=>{for(const i of e)await this._updateVersionInfo(i).catch((e=>{o.getLogger(this).error("Failed to update version details",e)}))})())}async _addServiceInfo(e,i){const s=new b({url:e});await s.load();const n=await this._findPortal(e),t=n?.user?.username;let o=!1;t&&(o=await _(n,t,"advediting"));let a=null;s.versionManagementServiceUrl&&(a=new V({url:s.versionManagementServiceUrl}),await a.load());const d=i.isTable?[]:[i],c=i.isTable?[i]:[],v=new L({loggedInServiceUser:t??"",hasAdvancedEditingUserTypeExtension:o,versionInfo:null,lockType:"none",canEditVersionedData:!0,canCreateVersion:!0,featureService:s,versionService:a,layers:new r(d),tables:new r(c)});return a&&await this._updateVersionInfo(v),this.items.push(v),this.tablesAndLayersLookup.set(i,v),i.isTable?v.tables.push(i):v.layers.push(i),v}get _allLayersAndTables(){return[...this.view.map.allLayers,...this.view.map.allTables,...this.additionalLayers]}_detectNewLayersAndTables(){const e=new Set(this._allLayersAndTables),i=[];for(const r of e)"feature"!==r.type&&"subtype-group"!==r.type||this._processed.has(r)||i.push(r);for(const r of this._processed)if(!e.has(r)&&(y(r)||S(r))){const e=this.tablesAndLayersLookup.get(r);if(!e)continue;this.tablesAndLayersLookup.delete(r),r.isTable?e.tables.remove(r):e.layers.remove(r),0===e.layersAndTables.length&&this._removeFeatureService(e)}return this._processed=e,i}};e([m({constructOnly:!0})],j.prototype,"view",void 0),e([m()],j.prototype,"items",void 0),e([m()],j.prototype,"tablesAndLayersLookup",void 0),e([m()],j.prototype,"additionalLayers",void 0),e([m()],j.prototype,"updating",null),e([m()],j.prototype,"_allLayersAndTables",null),j=e([h("esri.undoredo.support.Services")],j);export{j as Services,T as getServices};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.32/esri/copyright.txt for details.
4
4
  */
5
- import{_ as t}from"../../chunks/tslib.es6.js";import i from"../../Viewpoint.js";import e from"../../core/Accessor.js";import"../../core/has.js";import{removeMaybe as n}from"../../core/maybe.js";import{addFrameTask as s}from"../../core/scheduling.js";import{createScreenPoint as o}from"../../core/screenUtils.js";import{Milliseconds as a}from"../../core/time.js";import{property as r}from"../../core/accessorSupport/decorators/property.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as p}from"../../core/accessorSupport/decorators/subclass.js";import{create as m}from"../../core/libs/gl-matrix-2/factories/vec2f64.js";import h from"../../geometry/Point.js";import u from"../ViewAnimation.js";import c from"./PaddedViewState.js";import{easingFunctions as d,parse as w}from"./unitBezier.js";import{copy as _}from"./viewpointUtils.js";import{Camera as l}from"./pointToPoint/Camera.js";import{Animation as f}from"../animation/pointToPoint/Animation.js";import{defaultSettings2D as v}from"../animation/pointToPoint/Settings.js";const g=2e3,j=64;class y{constructor(t){this._view=t,this._animation=new f((()=>new l(this._view))),this._current=new l(this._view)}get _source(){return this._animation.definition.source}get _target(){return this._animation.definition.target}get duration(){return this._animation.time}get animation(){return this._animation}update(t,i,e={}){_(this._current.viewpoint,t),_(this._source.viewpoint,t),_(this._target.viewpoint,i),this._animation.update(this._source,this._target,e)}applyRatio(t,i){this._animation.cameraAt(i,this._current),_(t,this._current.viewpoint)}}let T=class extends e{constructor(t){super(t),this._animation=null,this._destinationViewState=new c,this.updateFunction=null,this.easing=d.ease,this.viewpoint=new i({targetGeometry:new h,scale:0,rotation:0}),this._updateTask=s({postRender:this._postRender.bind(this)}),this._updateTask.pause(),this._transition=new y(t.view)}destroy(){this._updateTask=n(this._updateTask)}get animation(){return this._animation}set animation(t){this._animation=t,this.view.animation=t}animate(t,i,e){this.stop();const n=this.viewpoint;_(n,i);const s=("string"==typeof e?.easing?w(e.easing):e?.easing)||this.easing,o=t.target;this._transition.update(this.viewpoint,o,{apex:{maximumDistance:Math.min(Math.min(i.scale,o.scale)*j,this.view.constraints.effectiveMinScale),desiredSlope:5e-8},duration:e?.duration,maxDuration:"auto"===e?.animationMode?a(1/0):e?.maxDuration??v.maxDuration,speedFactor:e?.speedFactor,easing:"function"==typeof s?t=>s(t):void 0}),"auto"===e?.animationMode&&(this._destinationViewState.copy(this.view.state),this._destinationViewState.viewpoint=o,x(this._transition.animation,e,this.view.state,this._destinationViewState)||this._transition.update(this.viewpoint,o,{duration:a(0)}));const r=()=>{this.animation===t&&this._updateTask&&("finished"===t.state&&(this._transition.applyRatio(this.viewpoint,1),this.view.state&&(this.view.state.viewpoint=this.viewpoint.clone())),this.animation=null,this.updateFunction=null)};return t.when(r,r),this._startTime=performance.now(),this._updateTask.resume(),this.animation=t,t}animateContinuous(t,i){this.stop(),this.updateFunction=i,this.viewpoint=t;const e=new u({target:t.clone()}),n=()=>{this.animation===e&&this._updateTask&&(this.animation=null,this.updateFunction=null)};return e.when(n,n),this._startTime=performance.now(),this._updateTask.resume(),this.animation=e,e}stop(){this.animation&&(this.animation.stop(),this.animation=null,this.updateFunction=null)}_postRender(t){const i=this.animation;if(i&&i.state!==u.State.STOPPED){if(this.updateFunction)this.updateFunction(this.viewpoint,t.deltaTime),this.animation?.update(this.viewpoint);else{const t=performance.now()-this._startTime,i=this._transition.duration,e=i>0?t/i:1,n=e>=1;this._transition.applyRatio(this.viewpoint,e),n&&this.animation?.finish()}this.view.state&&(this.view.state.viewpoint=this.viewpoint.clone())}else this._updateTask.pause()}};function x(t,i,e,n){if(null!=i?.duration)return!0;const{time:s,isLinear:a}=t,r=i?.speedFactor||1;if(s>(i?.maxDuration??v.maxDuration/r))return!1;if(a){const t=1.5,i=m(),a=o(...n.toScreen(i,...e.center)),p=o(...e.toScreen(i,...n.center)),h=null!=p&&p.x>-1*e.size[0]&&p.x<(t+.5)*e.size[0]&&p.y>-1*e.size[1]&&p.y<(t+.5)*e.size[1],u=null!=a&&a.x>-1*n.size[0]&&a.x<(t+.5)*n.size[0]&&a.y>-1*n.size[1]&&a.y<(t+.5)*n.size[1];if(s>g/r&&!h&&!u)return!1}return!0}t([r()],T.prototype,"easing",void 0),t([r()],T.prototype,"view",void 0),t([r()],T.prototype,"viewpoint",void 0),T=t([p("esri.views.2d.AnimationManager")],T);const S=T;export{S as default};
5
+ import{_ as t}from"../../chunks/tslib.es6.js";import i from"../../Viewpoint.js";import e from"../../core/Accessor.js";import"../../core/has.js";import{removeMaybe as n}from"../../core/maybe.js";import{addFrameTask as s}from"../../core/scheduling.js";import{createScreenPoint as o}from"../../core/screenUtils.js";import{Milliseconds as a}from"../../core/time.js";import{property as r}from"../../core/accessorSupport/decorators/property.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as m}from"../../core/accessorSupport/decorators/subclass.js";import{create as p}from"../../core/libs/gl-matrix-2/factories/vec2f64.js";import h from"../../geometry/Point.js";import u from"../ViewAnimation.js";import c from"./PaddedViewState.js";import{copy as d}from"./viewpointUtils.js";import{Camera as w}from"./pointToPoint/Camera.js";import{EasingFunctions as _}from"../animation/easing.js";import{Animation as l}from"../animation/pointToPoint/Animation.js";import{defaultSettings2D as v}from"../animation/pointToPoint/Settings.js";const f=2e3,g=64;class j{constructor(t){this._view=t,this._animation=new l((()=>new w(this._view))),this._current=new w(this._view)}get _source(){return this._animation.definition.source}get _target(){return this._animation.definition.target}get duration(){return this._animation.time}get animation(){return this._animation}update(t,i,e={}){d(this._current.viewpoint,t),d(this._source.viewpoint,t),d(this._target.viewpoint,i),this._animation.update(this._source,this._target,e)}applyRatio(t,i){this._animation.cameraAt(i,this._current),d(t,this._current.viewpoint)}}let y=class extends e{constructor(t){super(t),this._animation=null,this._destinationViewState=new c,this.updateFunction=null,this.easing=_.ease,this.viewpoint=new i({targetGeometry:new h,scale:0,rotation:0}),this._updateTask=s({postRender:this._postRender.bind(this)}),this._updateTask.pause(),this._transition=new j(t.view)}destroy(){this._updateTask=n(this._updateTask)}get animation(){return this._animation}set animation(t){this._animation=t,this.view.animation=t}animate(t,i,e){this.stop();const n=this.viewpoint;d(n,i);const s=t.target;this._transition.update(this.viewpoint,s,{apex:{maximumDistance:Math.min(Math.min(i.scale,s.scale)*g,this.view.constraints.effectiveMinScale),desiredSlope:5e-8},duration:e?.duration,maxDuration:"auto"===e?.animationMode?a(1/0):e?.maxDuration??v.maxDuration,speedFactor:e?.speedFactor,easing:("string"==typeof e?.easing?_[e.easing]:e?.easing)||this.easing}),"auto"===e?.animationMode&&(this._destinationViewState.copy(this.view.state),this._destinationViewState.viewpoint=s,T(this._transition.animation,e,this.view.state,this._destinationViewState)||this._transition.update(this.viewpoint,s,{duration:a(0)}));const o=()=>{this.animation===t&&this._updateTask&&("finished"===t.state&&(this._transition.applyRatio(this.viewpoint,1),this.view.state&&(this.view.state.viewpoint=this.viewpoint.clone())),this.animation=null,this.updateFunction=null)};return t.when(o,o),this._startTime=performance.now(),this._updateTask.resume(),this.animation=t,t}animateContinuous(t,i){this.stop(),this.updateFunction=i,this.viewpoint=t;const e=new u({target:t.clone()}),n=()=>{this.animation===e&&this._updateTask&&(this.animation=null,this.updateFunction=null)};return e.when(n,n),this._startTime=performance.now(),this._updateTask.resume(),this.animation=e,e}stop(){this.animation&&(this.animation.stop(),this.animation=null,this.updateFunction=null)}_postRender(t){const i=this.animation;if(i&&i.state!==u.State.STOPPED){if(this.updateFunction)this.updateFunction(this.viewpoint,t.deltaTime),this.animation?.update(this.viewpoint);else{const t=performance.now()-this._startTime,i=this._transition.duration,e=i>0?t/i:1,n=e>=1;this._transition.applyRatio(this.viewpoint,e),n&&this.animation?.finish()}this.view.state&&(this.view.state.viewpoint=this.viewpoint.clone())}else this._updateTask.pause()}};function T(t,i,e,n){if(null!=i?.duration)return!0;const{time:s,isLinear:a}=t,r=i?.speedFactor||1;if(s>(i?.maxDuration??v.maxDuration/r))return!1;if(a){const t=1.5,i=p(),a=o(...n.toScreen(i,...e.center)),m=o(...e.toScreen(i,...n.center)),h=null!=m&&m.x>-1*e.size[0]&&m.x<(t+.5)*e.size[0]&&m.y>-1*e.size[1]&&m.y<(t+.5)*e.size[1],u=null!=a&&a.x>-1*n.size[0]&&a.x<(t+.5)*n.size[0]&&a.y>-1*n.size[1]&&a.y<(t+.5)*n.size[1];if(s>f/r&&!h&&!u)return!1}return!0}t([r()],y.prototype,"easing",void 0),t([r()],y.prototype,"view",void 0),t([r()],y.prototype,"viewpoint",void 0),y=t([m("esri.views.2d.AnimationManager")],y);const x=y;export{x as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.32/esri/copyright.txt for details.
4
4
  */
5
- import{_ as t}from"../../../chunks/tslib.es6.js";import{isSome as e}from"../../../core/arrayUtils.js";import i from"../../../core/Collection.js";import r from"../../../core/CollectionFlattener.js";import{makeHandle as s}from"../../../core/handleUtils.js";import{watch as o,initial as a,syncAndInitial as n}from"../../../core/reactiveUtils.js";import{property as h}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import{subclass as p}from"../../../core/accessorSupport/decorators/subclass.js";import c from"../../../rest/support/DirectionLine.js";import l from"../../../rest/support/DirectionPoint.js";import d from"../../../rest/support/PointBarrier.js";import u from"../../../rest/support/PolygonBarrier.js";import g from"../../../rest/support/PolylineBarrier.js";import _ from"../../../rest/support/RouteInfo.js";import m from"../../../rest/support/Stop.js";import{LayerView2DMixin as w}from"./LayerView2D.js";import y from"./graphics/GraphicContainer.js";import f from"./graphics/GraphicsView2D.js";import v from"../../layers/LayerView.js";const I=["route-info","direction-line","direction-point","polygon-barrier","polyline-barrier","point-barrier","stop"],k={graphic:null,property:null,oldValue:null,newValue:null};function j(t){return t instanceof c||t instanceof l||t instanceof d||t instanceof u||t instanceof g||t instanceof _||t instanceof m}function M(t){return i.isCollection(t)&&t.length&&j(t.at(0))}function V(t){return Array.isArray(t)&&t.length>0&&j(t[0])}const F=new Set(["default"]);let G=class extends(w(v)){constructor(){super(...arguments),this._graphics=new i,this._highlightIds=new Map,this._networkFeatureMap=new Map,this._networkGraphicMap=new Map,this._interaction=null,this._loadInteractionPromise=null,this.interactive=!1}get _routeItems(){return new r({getCollections:()=>null==this.layer||this.destroyed?[]:[null!=this.layer.routeInfo?new i([this.layer.routeInfo]):null,this.layer.directionLines,this.layer.directionPoints,this.layer.polygonBarriers,this.layer.polylineBarriers,this.layer.pointBarriers,this.layer.stops]})}initialize(){this.addHandles(o((()=>{const{interactive:t,suspended:e}=this;return{interactive:t,suspended:e}}),(({interactive:t,suspended:e})=>{const i=t&&!e;i&&this._getInteractionLoadPromise().then((t=>{t.enabled=this.interactive&&!this.suspended})),this._interaction&&(this._interaction.enabled=i)}),n)),this._updatingHandles.addOnCollectionChange((()=>this._routeItems),(t=>this._routeItemsChanged(t)),a)}destroy(){this._networkFeatureMap.clear(),this._networkGraphicMap.clear(),this._graphics.removeAll(),this._get("_routeItems")?.destroy()}attach(){this._createGraphicsView()}detach(){this._destroyGraphicsView(),this._interaction?.enabled&&(this._interaction.enabled=!1)}get selectedNetworkFeatures(){return this._interaction?.selectedNetworkFeatures??null}async create(t){if(!this.interactive)return;return(await this._getInteractionLoadPromise()).create(t)}async fetchPopupFeaturesAtLocation(t,e){return this._graphicsView.hitTest(t).filter((({popupTemplate:t})=>!!t))}highlight(t){let i;i=j(t)?[this._getNetworkFeatureUid(t)]:V(t)?t.map((t=>this._getNetworkFeatureUid(t))):M(t)?t.map((t=>this._getNetworkFeatureUid(t))).toArray():[t.uid];const r=i.filter(e);return r.length?(this._addHighlight(r),s((()=>this._removeHighlight(r)))):s()}async hitTest(t,i){if(this.suspended)return null;const r=this._graphicsView.hitTest(t).filter(e).map((t=>this._networkGraphicMap.get(t)));if(!r.length)return null;const{layer:s}=this;return r.reverse().map((e=>({type:"route",layer:s,mapPoint:t,networkFeature:e})))}isUpdating(){return this._graphicsView.updating}moveEnd(){}remove(t){this._interaction?.remove(t)}update(t){this._graphicsView.processUpdate(t)}viewChange(){this._graphicsView.viewChange()}_addHighlight(t){for(const e of t)if(this._highlightIds.has(e)){const t=this._highlightIds.get(e);this._highlightIds.set(e,t+1)}else this._highlightIds.set(e,1);this._updateHighlight()}_createGraphic(t){const e=t.toGraphic();return e.layer=this.layer,e.sourceLayer=this.layer,e}_createGraphicsView(){const t=this.view,e=()=>this.requestUpdate(),i=new y(t.featuresTilingScheme);this._graphicsView=new f({container:i,graphics:this._graphics,requestUpdateCallback:e,view:t}),this.container.addChild(i),this._updateHighlight()}_destroyGraphicsView(){this.container.removeChild(this._graphicsView.container),this._graphicsView.destroy()}_getDrawOrder(t){const e=this._networkGraphicMap.get(t);return I.indexOf(e.type)}_getInteractionLoadPromise(){return this._loadInteractionPromise||(this._loadInteractionPromise=this._loadInteraction(),this._updatingHandles.addPromise(this._loadInteractionPromise)),this._loadInteractionPromise}_getNetworkFeatureUid(t){return this._networkFeatureMap.has(t)?this._networkFeatureMap.get(t).uid:null}async _loadInteraction(){const{layer:t,view:e}=this,{RouteLayerInteraction:i}=await import("./support/RouteLayerInteraction.js");return this._interaction=new i({view:e,layer:t}),this._interaction}_removeHighlight(t){for(const e of t)if(this._highlightIds.has(e)){const t=this._highlightIds.get(e)-1;0===t?this._highlightIds.delete(e):this._highlightIds.set(e,t)}this._updateHighlight()}_routeItemsChanged(t){if(t.removed.length){this._graphics.removeMany(t.removed.map((t=>{const e=this._networkFeatureMap.get(t);return this._networkFeatureMap.delete(t),this._networkGraphicMap.delete(e),e})));for(const e of t.removed)this.removeHandles(e)}if(t.added.length){this._graphics.addMany(t.added.map((t=>{const e=this._createGraphic(t);return null==e.symbol?null:(this._networkFeatureMap.set(t,e),this._networkGraphicMap.set(e,t),e)})).filter(e));for(const e of t.added)this.addHandles([o((()=>e.geometry),((t,i)=>{this._updateGraphic(e,"geometry",t,i)})),o((()=>e.symbol),((t,i)=>{this._updateGraphic(e,"symbol",t,i)}))],e);this._graphics.sort(((t,e)=>this._getDrawOrder(t)-this._getDrawOrder(e)))}}_updateGraphic(t,e,i,r){if(!this._networkFeatureMap.has(t)){const e=this._createGraphic(t);return this._networkFeatureMap.set(t,e),this._networkGraphicMap.set(e,t),void this._graphics.add(e)}const s=this._networkFeatureMap.get(t);s[e]=i,k.graphic=s,k.property=e,k.oldValue=r,k.newValue=i,this._graphicsView.graphicUpdateHandler(k)}_updateHighlight(){const t=Array.from(this._highlightIds.keys()),e=this._getHighlightBits(F.values());this._graphicsView.setHighlight(t.map((t=>({objectId:t,highlightFlags:e}))))}};t([h()],G.prototype,"_graphics",void 0),t([h()],G.prototype,"_routeItems",null),t([h()],G.prototype,"_interaction",void 0),t([h()],G.prototype,"interactive",void 0),t([h({readOnly:!0})],G.prototype,"selectedNetworkFeatures",null),G=t([p("esri.views.2d.layers.RouteLayerView2D")],G);const H=G;export{H as default};
5
+ import{_ as t}from"../../../chunks/tslib.es6.js";import{isSome as e}from"../../../core/arrayUtils.js";import i from"../../../core/Collection.js";import r from"../../../core/CollectionFlattener.js";import{makeHandle as s}from"../../../core/handleUtils.js";import{watch as o,initial as a,syncAndInitial as n}from"../../../core/reactiveUtils.js";import{property as h}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import{subclass as p}from"../../../core/accessorSupport/decorators/subclass.js";import c from"../../../rest/support/DirectionLine.js";import l from"../../../rest/support/DirectionPoint.js";import d from"../../../rest/support/PointBarrier.js";import u from"../../../rest/support/PolygonBarrier.js";import g from"../../../rest/support/PolylineBarrier.js";import _ from"../../../rest/support/RouteInfo.js";import m from"../../../rest/support/Stop.js";import{LayerView2DMixin as w}from"./LayerView2D.js";import y from"./graphics/GraphicContainer.js";import f from"./graphics/GraphicsView2D.js";import v from"../../layers/LayerView.js";const I=["route-info","direction-line","direction-point","polygon-barrier","polyline-barrier","point-barrier","stop"],k={graphic:null,property:null,oldValue:null,newValue:null};function M(t){return t instanceof c||t instanceof l||t instanceof d||t instanceof u||t instanceof g||t instanceof _||t instanceof m}function j(t){return i.isCollection(t)&&t.length&&M(t.at(0))}function F(t){return Array.isArray(t)&&t.length>0&&M(t[0])}const V=new Set(["default"]);let G=class extends(w(v)){constructor(){super(...arguments),this._graphics=new i,this._highlightIds=new Map,this._networkFeatureMap=new Map,this._networkGraphicMap=new Map,this._interaction=null,this._loadInteractionPromise=null,this.interactive=!1}get _routeItems(){return new r({getCollections:()=>null==this.layer||this.destroyed?[]:[null!=this.layer.routeInfo?new i([this.layer.routeInfo]):null,this.layer.directionLines,this.layer.directionPoints,this.layer.polygonBarriers,this.layer.polylineBarriers,this.layer.pointBarriers,this.layer.stops]})}initialize(){this.addHandles(o((()=>{const{interactive:t,suspended:e}=this;return{interactive:t,suspended:e}}),(({interactive:t,suspended:e})=>{const i=t&&!e;i&&this._getInteractionLoadPromise().then((t=>{t.enabled=this.interactive&&!this.suspended})),this._interaction&&(this._interaction.enabled=i)}),n)),this._updatingHandles.addOnCollectionChange((()=>this._routeItems),(t=>this._routeItemsChanged(t)),a)}destroy(){this._networkFeatureMap.clear(),this._networkGraphicMap.clear(),this._graphics.removeAll(),this._get("_routeItems")?.destroy()}attach(){this._createGraphicsView()}detach(){this._destroyGraphicsView(),this._interaction?.enabled&&(this._interaction.enabled=!1)}get selectedNetworkFeatures(){return this._interaction?.selectedNetworkFeatures??null}async create(t){if(!this.interactive)return;return(await this._getInteractionLoadPromise()).create(t)}async fetchPopupFeaturesAtLocation(t,e){return this._graphicsView.hitTest(t).filter((({popupTemplate:t})=>!!t))}highlight(t){let i;i=M(t)?[this._getNetworkFeatureUid(t)]:F(t)?t.map((t=>this._getNetworkFeatureUid(t))):j(t)?t.map((t=>this._getNetworkFeatureUid(t))).toArray():[t.uid];const r=i.filter(e);return r.length?(this._addHighlight(r),s((()=>this._removeHighlight(r)))):s()}async hitTest(t,i){if(this.suspended)return null;const r=this._graphicsView.hitTest(t).filter(e).map((t=>this._networkGraphicMap.get(t)));if(!r.length)return null;const{layer:s}=this;return r.reverse().map((e=>({type:"route",layer:s,mapPoint:t,networkFeature:e})))}isUpdating(){return this._graphicsView.updating}moveEnd(){}remove(t){this._interaction?.remove(t)}update(t){this._graphicsView.processUpdate(t)}viewChange(){this._graphicsView.viewChange()}_addHighlight(t){for(const e of t)if(this._highlightIds.has(e)){const t=this._highlightIds.get(e);this._highlightIds.set(e,t+1)}else this._highlightIds.set(e,1);this._updateHighlight()}_createGraphic(t){const e=t.toGraphic();return e.layer=this.layer,e.sourceLayer=this.layer,e}_createGraphicsView(){const t=this.view,e=()=>this.requestUpdate(),i=new y(t.featuresTilingScheme);this._graphicsView=new f({container:i,graphics:this._graphics,requestUpdateCallback:e,view:t}),this.container.addChild(i),this._updateHighlight()}_destroyGraphicsView(){this.container.removeChild(this._graphicsView.container),this._graphicsView.destroy()}_getDrawOrder(t){const e=this._networkGraphicMap.get(t);return I.indexOf(e.type)}_getInteractionLoadPromise(){return this._loadInteractionPromise||(this._loadInteractionPromise=this._loadInteraction(),this._updatingHandles.addPromise(this._loadInteractionPromise)),this._loadInteractionPromise}_getNetworkFeatureUid(t){return this._networkFeatureMap.has(t)?this._networkFeatureMap.get(t).uid:null}async _loadInteraction(){const{layer:t,view:e}=this,{RouteLayerInteraction:i}=await import("./support/RouteLayerInteraction.js");return this._interaction=new i({view:e,layer:t}),this._interaction}_removeHighlight(t){for(const e of t)if(this._highlightIds.has(e)){const t=this._highlightIds.get(e)-1;0===t?this._highlightIds.delete(e):this._highlightIds.set(e,t)}this._updateHighlight()}_routeItemsChanged(t){if(t.removed.length){this._graphics.removeMany(t.removed.map((t=>{const e=this._networkFeatureMap.get(t);return this._networkFeatureMap.delete(t),this._networkGraphicMap.delete(e),e})));for(const e of t.removed)this.removeHandles(e)}if(t.added.length){this._graphics.addMany(t.added.map((t=>{const e=this._createGraphic(t);return null==e.symbol?null:(this._networkFeatureMap.set(t,e),this._networkGraphicMap.set(e,t),e)})).filter(e));for(const e of t.added)this.addHandles([o((()=>e.geometry),((t,i)=>{this._updateGraphic(e,"geometry",t,i)})),o((()=>e.symbol),((t,i)=>{this._updateGraphic(e,"symbol",t,i)})),o((()=>e.popupTemplate),(t=>{this._networkFeatureMap.has(e)&&(this._networkFeatureMap.get(e).popupTemplate=t)}))],e);this._graphics.sort(((t,e)=>this._getDrawOrder(t)-this._getDrawOrder(e)))}}_updateGraphic(t,e,i,r){if(!this._networkFeatureMap.has(t)){const e=this._createGraphic(t);return this._networkFeatureMap.set(t,e),this._networkGraphicMap.set(e,t),void this._graphics.add(e)}const s=this._networkFeatureMap.get(t);s[e]=i,k.graphic=s,k.property=e,k.oldValue=r,k.newValue=i,this._graphicsView.graphicUpdateHandler(k)}_updateHighlight(){const t=Array.from(this._highlightIds.keys()),e=this._getHighlightBits(V.values());this._graphicsView.setHighlight(t.map((t=>({objectId:t,highlightFlags:e}))))}};t([h()],G.prototype,"_graphics",void 0),t([h()],G.prototype,"_routeItems",null),t([h()],G.prototype,"_interaction",void 0),t([h()],G.prototype,"interactive",void 0),t([h({readOnly:!0})],G.prototype,"selectedNetworkFeatures",null),G=t([p("esri.views.2d.layers.RouteLayerView2D")],G);const H=G;export{H as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.32/esri/copyright.txt for details.
4
4
  */
5
- import"../../../../../core/has.js";import{debounce as t}from"../../../../../core/promiseUtils.js";import{FeatureSnapshotSourceChunk as e}from"./strategies/chunks/FeatureSnapshotSourceChunk.js";class s{constructor(s,h,i,o){this.store=s,this.queryInfo=h,this._options=i,this._fetch=o,this._nextBatch=new Set,this._fetchFeatures=t((async()=>{if(0===this._nextBatch.size||this._options.signal?.aborted)return;const t=Array.from(this._nextBatch);this._nextBatch.clear();try{const s=this.queryInfo.createQuery({objectIds:t,outFields:["*"],cacheHint:!0}),h="cache."+t.join(","),i=await this._fetch(s,this._options,{chunkId:h}),o=new e(i,s.inner.toJSON(),0,!1);o.chunkId=h,this.store.insert(o)}catch(s){}}))}prepareCacheUpdate(t,e){if(e)for(const s of e)this._nextBatch.delete(s);for(const s of t)this._nextBatch.add(s)}applyCacheUpdate(){return 0===this._nextBatch.size||this._options.signal?.aborted?null:this._fetchFeatures().catch((()=>{}))}}export{s as FeatureCache};
5
+ import t from"../../../../../core/Error.js";import"../../../../../core/has.js";import e from"../../../../../core/Logger.js";import{debounce as r}from"../../../../../core/promiseUtils.js";import{generateUUID as s}from"../../../../../core/uuid.js";import{fetchPages as i}from"./strategies/support/snapshotUtils.js";const o=8e3;class h{constructor(h,a,c,n){this.store=h,this.queryInfo=a,this._options=c,this._fetch=n,this._nextBatch=new Set,this._fetchFeatures=r((async()=>{if(0===this._nextBatch.size||this._options.signal?.aborted)return;const r=Array.from(this._nextBatch);this._nextBatch.clear(),r.length>o&&e.getLogger("esri.views.2d.layers.FeatureLayerView2D").warn(new t("highlight-too-many-features",`highlight is limited to ${o} features on large layers configured with a display filter to avoid performance issues`));const h=this.queryInfo.objectIdsQueryPageSize,a=Math.ceil(o/h),c=Math.min(a,Math.ceil(r.length/h)),n=Array.from({length:c},((t,e)=>{const s=e*h,i=Math.min(s+h,r.length);return{num:e,query:this.queryInfo.createObjectIdsQuery(r.slice(s,i))}}));try{await i({chunkPrefix:"cache."+s(),fetch:this._fetch},this.store,n,this._options)}catch(f){}}))}prepareCacheUpdate(t,e){if(e)for(const r of e)this._nextBatch.delete(r);for(const r of t)this._nextBatch.add(r)}applyCacheUpdate(){return 0===this._nextBatch.size||this._options.signal?.aborted?null:this._fetchFeatures().catch((()=>{}))}}export{h as FeatureCache};