@arcgis/core 4.34.0-next.52 → 4.34.0-next.54

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 (139) hide show
  1. package/applications/Components/formatUtils.d.ts +3 -0
  2. package/applications/Components/formatUtils.js +5 -0
  3. package/assets/esri/core/workers/RemoteClient.js +1 -1
  4. package/assets/esri/core/workers/chunks/{35fc8a64674005b1d1d7.js → 0a4357af5b8c0532b439.js} +1 -1
  5. package/assets/esri/core/workers/chunks/{e58336aafe8c95bb6831.js → 0eb728cee6e40cb30c01.js} +1 -1
  6. package/assets/esri/core/workers/chunks/{b87ed14fde381f79bc9f.js → 17776d9d3558d45ea7b5.js} +1 -1
  7. package/assets/esri/core/workers/chunks/23f54b49742098def8ae.js +1 -0
  8. package/assets/esri/core/workers/chunks/2efa4d8fe5454f8b2a05.js +1 -0
  9. package/assets/esri/core/workers/chunks/{a69e885336eb5d2729fd.js → 3505988ce3839cdbbc98.js} +1 -1
  10. package/assets/esri/core/workers/chunks/{46ab551bd19e52e73649.js → 3800764932a1c32cb29f.js} +1 -1
  11. package/assets/esri/core/workers/chunks/3c57b2e13628b5c1f6de.js +1 -0
  12. package/assets/esri/core/workers/chunks/435169b455fd2846799b.js +1 -0
  13. package/assets/esri/core/workers/chunks/{77493aa2118d462612a0.js → 43bd338bb0de375b9bb7.js} +1 -1
  14. package/assets/esri/core/workers/chunks/{5a016dcd3192d42d363e.js → 5fc414fc2cfc68828c5b.js} +1 -1
  15. package/assets/esri/core/workers/chunks/{ecd673eccf89643df07a.js → 659f7e99b2d524ef53fb.js} +2 -2
  16. package/assets/esri/core/workers/chunks/69e6000044bfb03776ac.js +1 -0
  17. package/assets/esri/core/workers/chunks/{037bc400257bc13b3ec8.js → 772e81e9162e2240a7a6.js} +1 -1
  18. package/assets/esri/core/workers/chunks/813efde41e90e652b7db.js +1 -0
  19. package/assets/esri/core/workers/chunks/82404ff7c298493ff6f4.js +1 -0
  20. package/assets/esri/core/workers/chunks/{f1de768b0a6d345f7e39.js → 8f6ff09e7d2f01b79faf.js} +1 -1
  21. package/assets/esri/core/workers/chunks/9639a6f6fab52a501bf7.js +1 -0
  22. package/assets/esri/core/workers/chunks/{cfa8b17cf1349f6ed355.js → 9e9be7f6ea32957f1088.js} +1 -1
  23. package/assets/esri/core/workers/chunks/9fef330b241f958b55df.js +1 -0
  24. package/assets/esri/core/workers/chunks/aab349d4624b78ef429f.js +1 -0
  25. package/assets/esri/core/workers/chunks/b9f5672093727c6f92c9.js +1 -0
  26. package/assets/esri/core/workers/chunks/bcc233a86e01ff1eac16.js +1 -0
  27. package/assets/esri/core/workers/chunks/cac060a187f3a27a19ba.js +1 -0
  28. package/assets/esri/core/workers/chunks/cda27c0fafd687dfa72e.js +1 -0
  29. package/assets/esri/core/workers/chunks/{82a390be9500b629f6bc.js → d0bf1fc6e3c198bc565d.js} +1 -1
  30. package/assets/esri/core/workers/chunks/dd120d562b63618e71c0.js +1 -0
  31. package/assets/esri/core/workers/chunks/dd2b5f115d156b5b212e.js +1 -0
  32. package/assets/esri/core/workers/chunks/e28d3ed65c3a76a044c8.js +1 -0
  33. package/assets/esri/core/workers/chunks/{fb4950995f6780f6c22a.js → ee0286b5f5475f2d853f.js} +1 -1
  34. package/assets/esri/core/workers/chunks/{c5b2a261d8c216ca4a10.js → f8505bf69795f5293a79.js} +1 -1
  35. package/assets/esri/core/workers/chunks/fae6030a81cb91a91b69.js +1 -0
  36. package/assets/esri/core/workers/chunks/ff7962063d132c1ec814.js +1 -0
  37. package/assets/esri/themes/base/widgets/_FloorFilter.scss +23 -19
  38. package/assets/esri/themes/dark/main.css +1 -1
  39. package/assets/esri/themes/light/main.css +1 -1
  40. package/assets/esri/themes/light/view.css +1 -1
  41. package/config.js +1 -1
  42. package/geometry/operators/json/graphicBufferOperator.js +5 -0
  43. package/geometry/support/coordinateSystem.js +1 -1
  44. package/interfaces.d.ts +93 -185
  45. package/kernel.js +1 -1
  46. package/layers/KMLLayer.js +1 -1
  47. package/layers/graphics/controllers/I3SOnDemandController.js +1 -1
  48. package/layers/graphics/data/QueryEngine.js +1 -1
  49. package/layers/graphics/sources/WFSSourceWorker.js +1 -1
  50. package/layers/graphics/sources/geojson/GeoJSONSourceWorker.js +1 -1
  51. package/layers/graphics/sources/support/CSVSourceWorker.js +1 -1
  52. package/layers/graphics/sources/support/MemorySourceWorker.js +1 -1
  53. package/layers/support/ElevationQuery.js +1 -1
  54. package/layers/support/ExportImageParameters.js +1 -1
  55. package/networks/UtilityNetwork.js +1 -1
  56. package/networks/support/typeUtils.js +1 -1
  57. package/package.json +3 -3
  58. package/portal/Portal.js +1 -1
  59. package/renderers/support/rasterRendererHelper.js +1 -1
  60. package/renderers/support/utils.js +1 -1
  61. package/rest/featureService/FeatureService.js +1 -1
  62. package/rest/networks/support/Circuit.js +5 -0
  63. package/rest/networks/support/CircuitSection.js +1 -1
  64. package/rest/networks/support/Subcircuit.js +1 -1
  65. package/rest/print.js +1 -1
  66. package/support/revision.js +1 -1
  67. package/symbols/cim/CIMEffects.js +1 -1
  68. package/symbols/cim/effects/EffectOffset.js +1 -1
  69. package/views/2d/analysisViewModuleImportUtils.js +5 -0
  70. package/views/2d/engine/webgl/shaderGraph/techniques/labels/LabelMeshWriter.js +1 -1
  71. package/views/2d/input/MapViewInputManager.js +1 -1
  72. package/views/2d/layers/LayerView2D.js +1 -1
  73. package/views/3d/analysis/Dimension/LengthDimensionSubTool.js +1 -1
  74. package/views/3d/analysis/ElevationProfile/HoveredPointsVisualization.js +1 -1
  75. package/views/3d/analysis/LineOfSight/LineOfSightRayIntersector.js +1 -1
  76. package/views/3d/analysis/Viewshed/FieldOfViewManipulation.js +1 -1
  77. package/views/3d/analysisViewModuleImportUtils.js +5 -0
  78. package/views/3d/input/SceneInputManager.js +1 -1
  79. package/views/3d/interactive/editingTools/draw/DrawGraphicTool3D.js +1 -1
  80. package/views/3d/interactive/editingTools/manipulations/MoveManipulation.js +1 -1
  81. package/views/3d/interactive/editingTools/reshape/ReshapeOperation.js +1 -1
  82. package/views/3d/interactive/measurementTools/areaMeasurement3D/AreaMeasurement3DTool.js +1 -1
  83. package/views/3d/layers/PointCloudLayerView3D.js +1 -1
  84. package/views/3d/layers/graphics/Graphics3DCore.js +1 -1
  85. package/views/3d/terrain/TerrainSurface.js +1 -1
  86. package/views/3d/webgl-engine/effects/highlight/ShadowHighlight.js +1 -1
  87. package/views/3d/webgl-engine/lib/Octree.js +1 -1
  88. package/views/SceneView.js +1 -1
  89. package/views/ToolViewManager.js +1 -1
  90. package/views/View.js +1 -1
  91. package/views/View2D.js +1 -1
  92. package/views/draw/Draw.js +1 -1
  93. package/views/draw/DrawGraphicTool.js +1 -1
  94. package/views/draw/DrawOperation.js +1 -1
  95. package/views/draw/LegacyDrawManipulator.js +1 -1
  96. package/views/draw/support/Box.js +1 -1
  97. package/views/draw/support/GraphicMover.js +1 -1
  98. package/views/draw/support/Reshape.js +1 -1
  99. package/views/input/InputManager.js +1 -1
  100. package/views/input/handlers/LatestPointer.js +1 -1
  101. package/views/interactive/InteractiveToolBase.js +1 -1
  102. package/views/interactive/ToolViewManagerManipulatorState.js +1 -1
  103. package/views/interactive/Tooltip.js +1 -1
  104. package/views/interactive/snapping/featureSources/GraphicsSnappingSource.js +1 -1
  105. package/views/interactive/snapping/featureSources/featureServiceSource/FeatureServiceSnappingSourceWorker.js +1 -1
  106. package/views/layers/support/popupUtils.js +1 -1
  107. package/views/support/AnalysisViewManager.js +5 -0
  108. package/views/support/PromiseQueue.js +5 -0
  109. package/views/support/Scheduler.js +1 -1
  110. package/widgets/Feature/FeatureViewModel.js +1 -1
  111. package/widgets/FeatureTable/Grid/support/ButtonMenu.js +1 -1
  112. package/widgets/FloorFilter/css.js +1 -1
  113. package/widgets/FloorFilter.js +1 -1
  114. package/widgets/HistogramRangeSlider.js +1 -1
  115. package/widgets/Sketch/SketchViewModel.js +1 -1
  116. package/widgets/support/ItemList.js +1 -1
  117. package/assets/esri/core/workers/chunks/0874b88d5ae7c2b78b3b.js +0 -1
  118. package/assets/esri/core/workers/chunks/0c129b78e5cfe96795e1.js +0 -1
  119. package/assets/esri/core/workers/chunks/1a3a4c2c642899be37a0.js +0 -1
  120. package/assets/esri/core/workers/chunks/2b75212c31145cc07d16.js +0 -1
  121. package/assets/esri/core/workers/chunks/37a97e690786814bf0b3.js +0 -1
  122. package/assets/esri/core/workers/chunks/48e64f99720907017778.js +0 -1
  123. package/assets/esri/core/workers/chunks/4c6862ad3af947c704f7.js +0 -1
  124. package/assets/esri/core/workers/chunks/4d544e3e19ce07c2c195.js +0 -1
  125. package/assets/esri/core/workers/chunks/781b59ba0cabe78bc122.js +0 -1
  126. package/assets/esri/core/workers/chunks/8c1bd9bcfc59497de3b5.js +0 -1
  127. package/assets/esri/core/workers/chunks/8cc700da2ac58849a708.js +0 -1
  128. package/assets/esri/core/workers/chunks/9b7fee0adffeee8d45ae.js +0 -1
  129. package/assets/esri/core/workers/chunks/9d30fed26e0d84ef893b.js +0 -1
  130. package/assets/esri/core/workers/chunks/b29f0b32787edb4e75cf.js +0 -1
  131. package/assets/esri/core/workers/chunks/b877142a275188a16e17.js +0 -1
  132. package/assets/esri/core/workers/chunks/c87bb42f825c39f9cce3.js +0 -1
  133. package/assets/esri/core/workers/chunks/cc0cb4906e4419f7c4a9.js +0 -1
  134. package/assets/esri/core/workers/chunks/f667096ea325f690c4a6.js +0 -1
  135. package/assets/esri/core/workers/chunks/f9f94b5efa9a64cdb407.js +0 -1
  136. package/layers/graphics/data/executeQueryForSnapping.js +0 -5
  137. package/layers/support/PromiseQueue.js +0 -5
  138. package/views/3d/analysis/AnalysisViewManager3D.js +0 -5
  139. /package/assets/esri/core/workers/chunks/{ecd673eccf89643df07a.js.LICENSE.txt → 659f7e99b2d524ef53fb.js.LICENSE.txt} +0 -0
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import t from"../Graphic.js";import{getOrCreateMapValue as r}from"../core/MapUtils.js";import{watch as s}from"../core/reactiveUtils.js";import{property as o}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/Logger.js";import"../core/RandomLCG.js";import{subclass as i}from"../core/accessorSupport/decorators/subclass.js";import a from"../layers/FeatureLayer.js";import{queryAllJSON as n}from"../layers/support/featureQueryAll.js";import l from"./Network.js";import u from"./RulesTable.js";import m from"./support/NamedTraceConfiguration.js";import{getAssociationsTableFields as d}from"./support/networkFieldUtils.js";import c from"./support/NetworkSystemLayers.js";import y from"./support/TerminalConfiguration.js";import p from"./support/TraceJobInfo.js";import{AssociationTypeEnum as f,associationTypeKebabDict as h}from"./support/typeUtils.js";import{doesRuleAllowAssociation as I}from"./support/utils.js";import b from"../rest/networks/support/TelecomNetworkElement.js";import g from"../rest/support/Query.js";let w=class extends l{constructor(e){super(e),this.sharedNamedTraceConfigurations=[],this.type="utility",this._circuitManagerMap=new Map,this._terminalById=new Map,this._unitIdentifierManager=null}initialize(){this.addHandles(s(()=>[this.gdbVersion,this.historicMoment],()=>{this.networkSystemLayers.associationsTable&&(this.networkSystemLayers.associationsTable.gdbVersion!==this.gdbVersion&&(this.networkSystemLayers.associationsTable.gdbVersion=this.gdbVersion),this.networkSystemLayers.associationsTable.historicMoment!==this.historicMoment&&(this.networkSystemLayers.associationsTable.historicMoment=this.historicMoment))}))}get _rulesLayer(){const{gdbVersion:e,historicMoment:t}=this,r=this.networkSystemLayers.rulesTableUrl;return new a({url:r,gdbVersion:e,historicMoment:t})}get _utilityLayerList(){const e=new Set;return this.dataElement?.domainNetworks?.map(t=>{t?.edgeSources?.map(({layerId:t,sourceId:r})=>{this._layerIdBySourceId.set(r,t),this._sourceIdByLayerId.set(t,r),e.add(t)}),t?.junctionSources?.map(({layerId:t,sourceId:r})=>{this._layerIdBySourceId.set(r,t),this._sourceIdByLayerId.set(t,r),e.add(t)})}),e}get serviceTerritoryFeatureLayerId(){return this.dataElement?.serviceTerritoryFeatureLayerId??null}get networkSystemLayers(){return new c({rulesTableId:this.sourceJSON?.systemLayers.rulesTableId,rulesTableUrl:this.sourceJSON?`${this.featureServiceUrl}/${this.sourceJSON?.systemLayers.rulesTableId}`:null,subnetworksTableId:this.sourceJSON?.systemLayers.subnetworksTableId,subnetworksTableUrl:this.sourceJSON?`${this.featureServiceUrl}/${this.sourceJSON?.systemLayers.subnetworksTableId}`:null,dirtyAreasLayerId:this.sourceJSON?.systemLayers.dirtyAreasLayerId,dirtyAreasLayerUrl:this.sourceJSON?`${this.featureServiceUrl}/${this.sourceJSON?.systemLayers.dirtyAreasLayerId}`:null,associationsTableId:this.sourceJSON?.systemLayers.associationsTableId,associationsTableUrl:this.sourceJSON?`${this.featureServiceUrl}/${this.sourceJSON?.systemLayers.associationsTableId}`:null})}get terminalConfigurations(){return this.dataElement?.terminalConfigurations.map(e=>y.fromJSON(e))||[]}get domainNetworkNames(){return this.dataElement?.domainNetworks.map(e=>e.domainNetworkName)||[]}get hasTelecomNetwork(){return this.dataElement?.domainNetworks.some(e=>e.isTelecomNetwork)??!1}get associationsTable(){return this.networkSystemLayers.associationsTable}async load(e){return this.addResolvingPromise(this._load(e)),this}async _load(e){await super._load(e),await Promise.all([this._loadNamedTraceConfigurationsFromNetwork(e),this.networkSystemLayers.loadAssociationsTable(e)])}getTerminalConfiguration(e){let t=null,r=null;const s=e.sourceLayer;let o=null;if("feature"===s?.type){if(o=s.layerId,null===o)return null}else{if("subtype-sublayer"!==s?.type)return null;if(o=s?.parent?.layerId??null,null===o)return null}const i=e.attributes;if(null==i)return null;for(const l of Object.keys(i))"ASSETGROUP"===l.toUpperCase()&&(t=e.getAttribute(l)),"ASSETTYPE"===l.toUpperCase()&&(r=e.getAttribute(l));if(!this.dataElement)return null;let a=null;const n=this.dataElement.domainNetworks;for(const l of n){const e=l.junctionSources?.find(e=>e.layerId===o);if(e){const s=e.assetGroups?.find(e=>e.assetGroupCode===t);if(s){const e=s.assetTypes?.find(e=>e.assetTypeCode===r);if(e?.isTerminalConfigurationSupported){a=e.terminalConfigurationId;break}}}}if(null!=a){const e=this.dataElement.terminalConfigurations,t=e?.find(e=>e.terminalConfigurationId===a);return t?y.fromJSON(t):null}return null}getTierNames(e){const t=this.dataElement?.domainNetworks.find(t=>t.domainNetworkName===e);return t?.tiers?.map(e=>e.name)||[]}async getRulesTable(){const e=this._rulesLayer;e.loaded||await e.load();const t=this.dataElement?.domainNetworks;if(!t)return null;const r=t.flatMap(e=>[...e.edgeSources||[],...e.junctionSources||[]]),s=(await this._queryRulesTable(e)).map(t=>this._hydrateRuleInfo(e,r,t));return new u({rulesLayer:e,rules:s})}async getCircuitManager(e){if(!this.hasTelecomNetwork)return null;const t=this.dataElement?.domainNetworks.find(t=>t.domainNetworkName===e&&t.isTelecomNetwork);if(!t)return null;const{default:s}=await import("./CircuitManager.js");return r(this._circuitManagerMap,e,()=>new s({utilityNetwork:this,telecomDomainNetwork:t}))}async getUnitIdentifierManager(){if(!this.hasTelecomNetwork)return null;if(this._unitIdentifierManager)return this._unitIdentifierManager;const{default:e}=await import("./UnitIdentifierManager.js");return this._unitIdentifierManager=new e({utilityNetwork:this}),this._unitIdentifierManager}getTerminalById(e){if(!this.dataElement||null==e)return null;const t=this._terminalById.get(e);return null!=t?t:(this.terminalConfigurations.forEach(e=>{e.terminals.forEach(e=>{this._terminalById.set(e.id,e)})}),this._terminalById.get(e))}isUtilityLayer(e){return"layerId"in e?null!=e.layerId&&this._utilityLayerList.has(e.layerId)&&(e.url?.startsWith(this.featureServiceUrl)??!1):!("subtype-sublayer"!==e.type||!e.parent)&&(this._utilityLayerList.has(e.parent.layerId)&&(e.parent.url?.startsWith(this.featureServiceUrl)??!1))}async queryAssociations(e,t){const[{queryAssociations:r},{default:s}]=await Promise.all([import("../rest/networks/queryAssociations.js"),import("../rest/networks/support/QueryAssociationsParameters.js")]),o=s.from(e);o.gdbVersion=this.gdbVersion,o.moment=this.historicMoment;return(await r(this.networkServiceUrl,o,t)).associations}async synthesizeAssociationGeometries(e){const[{synthesizeAssociationGeometries:t},{default:r}]=await Promise.all([import("../rest/networks/synthesizeAssociationGeometries.js"),import("../rest/networks/support/SynthesizeAssociationGeometriesParameters.js")]),s=r.from(e);return s.gdbVersion=this.gdbVersion,s.moment=this.historicMoment,t(this.networkServiceUrl,s)}async trace(e){const[{trace:t},{default:r}]=await Promise.all([import("../rest/networks/trace.js"),import("../rest/networks/support/TraceParameters.js")]),s=r.from(e);return s.gdbVersion=this.gdbVersion,s.moment=this.historicMoment,t(this.networkServiceUrl,s)}async submitTraceJob(e){const[{submitTraceJob:t},{default:r}]=await Promise.all([import("../rest/networks/trace.js"),import("../rest/networks/support/TraceParameters.js")]),s=r.from(e);s.gdbVersion=this.gdbVersion,s.moment=this.historicMoment;const o=await t(this.networkServiceUrl,s);return new p({statusUrl:o})}async canAddAssociation(e){const t=await this.getRulesTable();if(!t)return!1;const{fromNetworkElement:r,toNetworkElement:s}=e;if(!r||!s)return!1;await t.load();let o=null;switch(e.associationType){case"containment":o=t.rulesCategorized.containment;break;case"attachment":o=t.rulesCategorized.attachment;break;default:o=t.rulesCategorized.connectivity}return o.some(e=>I(e,r,s))}generateAddAssociations(e){const{associationsTable:r}=this.networkSystemLayers,{fromNetworkSourceId:s,fromGlobalId:o,fromTerminalId:i,fromFirstUnit:a,fromNumUnits:n,toNetworkSourceId:l,toGlobalId:u,toTerminalId:m,toFirstUnit:c,toNumUnits:y,associationType:p,isContentVisible:h,percentAlong:I,globalId:g}=d(r);return{addFeatures:e.map(e=>{const r=new t({attributes:{[s]:e.fromNetworkElement?.networkSourceId,[o]:e.fromNetworkElement?.globalId,[i]:e.fromNetworkElement?.terminalId,[l]:e.toNetworkElement?.networkSourceId,[u]:e.toNetworkElement?.globalId,[m]:e.toNetworkElement?.terminalId,[p]:f[e.associationType],[h]:null==e.isContentVisible?void 0:e.isContentVisible?1:0,[I]:e.percentAlong,[g]:e.globalId}});return e.fromNetworkElement instanceof b&&(r.attributes[a]=e.fromNetworkElement?.firstUnit,r.attributes[n]=e.fromNetworkElement?.numUnits),e.toNetworkElement instanceof b&&(r.attributes[c]=e.toNetworkElement?.firstUnit,r.attributes[y]=e.toNetworkElement?.numUnits),r}),id:this.networkSystemLayers.associationsTableId,identifierFields:{globalIdField:r?.globalIdField??"globalid",objectIdField:r?.objectIdField??"objectid"}}}generateDeleteAssociations(e){const{associationsTable:t,associationsTableId:r}=this.networkSystemLayers,s={id:r,identifierFields:{globalIdField:t?.globalIdField??"globalid",objectIdField:t?.objectIdField??"objectid"}};if(-8===this.dataElement?.schemaGeneration){const t=this._generateDeleteTelecomAssociationPayload(e);return{...s,deleteAssociations:t}}const o=e.map(e=>({globalId:e.globalId}));return{...s,deleteFeatures:o}}async loadAssociationsTable(){return this.networkSystemLayers.loadAssociationsTable()}async _loadNamedTraceConfigurationsFromNetwork(e){if(0===this.sharedNamedTraceConfigurations?.length)return;const t=this.sharedNamedTraceConfigurations.map(e=>e.globalId),r=await this.queryNamedTraceConfigurations({globalIds:t},e);for(const s of this.sharedNamedTraceConfigurations){const e=r?.find(e=>e.globalId===s.globalId);if(e){const t=e.write({},{origin:"service"});s.read(t,{origin:"service"})}}}_hydrateRuleInfo(e,t,r){const s=e.fieldsIndex,o=s.get("RULETYPE"),i=s.get("CREATIONDATE"),a=s.get("FROMNETWORKSOURCEID"),n=s.get("FROMASSETGROUP"),l=s.get("FROMASSETTYPE"),u=s.get("FROMTERMINALID"),m=s.get("TONETWORKSOURCEID"),d=s.get("TOASSETGROUP"),c=s.get("TOASSETTYPE"),y=s.get("TOTERMINALID"),p=s.get("VIANETWORKSOURCEID"),f=s.get("VIAASSETGROUP"),h=s.get("VIAASSETTYPE"),I=s.get("VIATERMINALID"),b=r.attributes[o.name],g=new Date(r.attributes[i.name]),w=[{networkSourceId:r.attributes[a.name],assetGroupId:r.attributes[n.name],assetTypeId:r.attributes[l.name],terminalId:r.attributes[u.name]},{networkSourceId:r.attributes[m.name],assetGroupId:r.attributes[d.name],assetTypeId:r.attributes[c.name],terminalId:r.attributes[y.name]},{networkSourceId:r.attributes[p.name],assetGroupId:r.attributes[f.name],assetTypeId:r.attributes[h.name],terminalId:r.attributes[I.name]}],T={ruleType:b,creationDate:g};for(const k of[0,1,2]){if(5!==b&&2===k)continue;const e=w[k],r=t.find(t=>t.sourceId===e.networkSourceId),s=r?.assetGroups.find(t=>t.assetGroupCode===e.assetGroupId),o=s?.assetTypes.find(t=>t.assetTypeCode===e.assetTypeId),i=this._getTerminal(o,e);let a="";switch(k){case 0:a="from";break;case 1:a="to";break;case 2:a="via"}T[`${a}NetworkSource`]=r,T[`${a}AssetGroup`]=s,T[`${a}AssetType`]=o,T[`${a}Terminal`]=i?.toJSON()}return T}_getTerminal(e,t){const r=e?.terminalConfigurationId,s=this.terminalConfigurations?.find(e=>e.id===r);return s?.terminals?.find(e=>e.id===t.terminalId)??null}async _queryRulesTable(e){const{gdbVersion:t,historicMoment:r}=this,s=new g({where:"1=1",outFields:["*"],gdbVersion:t,historicMoment:r});return(await n(e,s)).features}_generateDeleteTelecomAssociationPayload(e){return e.map(e=>({globalId:e.globalId??"{00000000-0000-0000-0000-000000000000}",associationType:h.toJSON(e.associationType),fromSourceId:e.fromNetworkElement.networkSourceId,fromGlobalId:e.fromNetworkElement.globalId,fromTerminalId:e.fromNetworkElement.terminalId,toSourceId:e.toNetworkElement.networkSourceId,toGlobalId:e.toNetworkElement.globalId,toTerminalId:e.toNetworkElement.terminalId}))}};e([o({readOnly:!0})],w.prototype,"_rulesLayer",null),e([o({type:[m],json:{origins:{"web-map":{read:{source:"traceConfigurations"},write:{target:"traceConfigurations"}},service:{read:{source:"traceConfigurations"}}},read:!1}})],w.prototype,"sharedNamedTraceConfigurations",void 0),e([o({type:["utility"],readOnly:!0,json:{read:!1,write:!1}})],w.prototype,"type",void 0),e([o({readOnly:!0})],w.prototype,"serviceTerritoryFeatureLayerId",null),e([o({readOnly:!0})],w.prototype,"networkSystemLayers",null),e([o({readOnly:!0})],w.prototype,"terminalConfigurations",null),e([o({readOnly:!0})],w.prototype,"domainNetworkNames",null),e([o({readOnly:!0})],w.prototype,"hasTelecomNetwork",null),e([o({readOnly:!0,json:{read:!1}})],w.prototype,"associationsTable",null),w=e([i("esri.networks.UtilityNetwork")],w);const T=w;export{T as default};
5
+ import{__decorate as e}from"tslib";import t from"../Graphic.js";import{unique as r}from"../core/arrayUtils.js";import s from"../core/Error.js";import{getOrCreateMapValue as o}from"../core/MapUtils.js";import{watch as i}from"../core/reactiveUtils.js";import{property as a}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/Logger.js";import{subclass as n}from"../core/accessorSupport/decorators/subclass.js";import l from"../layers/FeatureLayer.js";import{queryAllJSON as u}from"../layers/support/featureQueryAll.js";import d from"./Network.js";import m from"./RulesTable.js";import c from"./support/NamedTraceConfiguration.js";import{getAssociationsTableFields as y}from"./support/networkFieldUtils.js";import h from"./support/NetworkSystemLayers.js";import p from"./support/TerminalConfiguration.js";import f from"./support/TraceJobInfo.js";import{AssociationTypeEnum as I,associationTypeKebabDict as w}from"./support/typeUtils.js";import{doesRuleAllowAssociation as g}from"./support/utils.js";import b from"../rest/networks/support/TelecomNetworkElement.js";import T from"../rest/support/Query.js";let k=class extends d{constructor(e){super(e),this.sharedNamedTraceConfigurations=[],this.type="utility",this._circuitManagerMap=new Map,this._terminalById=new Map,this._unitIdentifierManager=null}initialize(){this.addHandles(i(()=>[this.gdbVersion,this.historicMoment],()=>{this.networkSystemLayers.associationsTable&&(this.networkSystemLayers.associationsTable.gdbVersion!==this.gdbVersion&&(this.networkSystemLayers.associationsTable.gdbVersion=this.gdbVersion),this.networkSystemLayers.associationsTable.historicMoment!==this.historicMoment&&(this.networkSystemLayers.associationsTable.historicMoment=this.historicMoment))}))}get _rulesLayer(){const{gdbVersion:e,historicMoment:t}=this,r=this.networkSystemLayers.rulesTableUrl;return new l({url:r,gdbVersion:e,historicMoment:t})}get _utilityLayerList(){const e=new Set;return this.dataElement?.domainNetworks?.map(t=>{t?.edgeSources?.map(({layerId:t,sourceId:r})=>{this._layerIdBySourceId.set(r,t),this._sourceIdByLayerId.set(t,r),e.add(t)}),t?.junctionSources?.map(({layerId:t,sourceId:r})=>{this._layerIdBySourceId.set(r,t),this._sourceIdByLayerId.set(t,r),e.add(t)})}),e}get serviceTerritoryFeatureLayerId(){return this.dataElement?.serviceTerritoryFeatureLayerId??null}get networkSystemLayers(){return new h({rulesTableId:this.sourceJSON?.systemLayers.rulesTableId,rulesTableUrl:this.sourceJSON?`${this.featureServiceUrl}/${this.sourceJSON?.systemLayers.rulesTableId}`:null,subnetworksTableId:this.sourceJSON?.systemLayers.subnetworksTableId,subnetworksTableUrl:this.sourceJSON?`${this.featureServiceUrl}/${this.sourceJSON?.systemLayers.subnetworksTableId}`:null,dirtyAreasLayerId:this.sourceJSON?.systemLayers.dirtyAreasLayerId,dirtyAreasLayerUrl:this.sourceJSON?`${this.featureServiceUrl}/${this.sourceJSON?.systemLayers.dirtyAreasLayerId}`:null,associationsTableId:this.sourceJSON?.systemLayers.associationsTableId,associationsTableUrl:this.sourceJSON?`${this.featureServiceUrl}/${this.sourceJSON?.systemLayers.associationsTableId}`:null})}get terminalConfigurations(){return this.dataElement?.terminalConfigurations.map(e=>p.fromJSON(e))||[]}get domainNetworkNames(){return this.dataElement?.domainNetworks.map(e=>e.domainNetworkName)||[]}get hasTelecomNetwork(){return this.dataElement?.domainNetworks.some(e=>e.isTelecomNetwork)??!1}get associationsTable(){return this.networkSystemLayers.associationsTable}async load(e){return this.addResolvingPromise(this._load(e)),this}async _load(e){await super._load(e),await Promise.all([this._loadNamedTraceConfigurationsFromNetwork(e),this.networkSystemLayers.loadAssociationsTable(e)])}getTerminalConfiguration(e){let t=null,r=null;const s=e.sourceLayer;let o=null;if("feature"===s?.type){if(o=s.layerId,null===o)return null}else{if("subtype-sublayer"!==s?.type)return null;if(o=s?.parent?.layerId??null,null===o)return null}const i=e.attributes;if(null==i)return null;for(const l of Object.keys(i))"ASSETGROUP"===l.toUpperCase()&&(t=e.getAttribute(l)),"ASSETTYPE"===l.toUpperCase()&&(r=e.getAttribute(l));if(!this.dataElement)return null;let a=null;const n=this.dataElement.domainNetworks;for(const l of n){const e=l.junctionSources?.find(e=>e.layerId===o);if(e){const s=e.assetGroups?.find(e=>e.assetGroupCode===t);if(s){const e=s.assetTypes?.find(e=>e.assetTypeCode===r);if(e?.isTerminalConfigurationSupported){a=e.terminalConfigurationId;break}}}}if(null!=a){const e=this.dataElement.terminalConfigurations,t=e?.find(e=>e.terminalConfigurationId===a);return t?p.fromJSON(t):null}return null}getTierNames(e){const t=this.dataElement?.domainNetworks.find(t=>t.domainNetworkName===e);return t?.tiers?.map(e=>e.name)||[]}async getRulesTable(){const e=this._rulesLayer;e.loaded||await e.load();const t=this.dataElement?.domainNetworks;if(!t)return null;const r=t.flatMap(e=>[...e.edgeSources||[],...e.junctionSources||[]]),s=(await this._queryRulesTable(e)).map(t=>this._hydrateRuleInfo(e,r,t));return new m({rulesLayer:e,rules:s})}async getCircuitManager(e){if(!this.hasTelecomNetwork)return null;const t=this.dataElement?.domainNetworks.find(t=>t.domainNetworkName===e&&t.isTelecomNetwork);if(!t)return null;const{default:r}=await import("./CircuitManager.js");return o(this._circuitManagerMap,e,()=>new r({utilityNetwork:this,telecomDomainNetwork:t}))}async getUnitIdentifierManager(){if(!this.hasTelecomNetwork)return null;if(this._unitIdentifierManager)return this._unitIdentifierManager;const{default:e}=await import("./UnitIdentifierManager.js");return this._unitIdentifierManager=new e({utilityNetwork:this}),this._unitIdentifierManager}getTerminalById(e){if(!this.dataElement||null==e)return null;const t=this._terminalById.get(e);return null!=t?t:(this.terminalConfigurations.forEach(e=>{e.terminals.forEach(e=>{this._terminalById.set(e.id,e)})}),this._terminalById.get(e))}isUtilityLayer(e){return"layerId"in e?null!=e.layerId&&this._utilityLayerList.has(e.layerId)&&(e.url?.startsWith(this.featureServiceUrl)??!1):!("subtype-sublayer"!==e.type||!e.parent)&&(this._utilityLayerList.has(e.parent.layerId)&&(e.parent.url?.startsWith(this.featureServiceUrl)??!1))}async queryAssociations(e,t){const[{queryAssociations:r},{default:s}]=await Promise.all([import("../rest/networks/queryAssociations.js"),import("../rest/networks/support/QueryAssociationsParameters.js")]),o=s.from(e);o.gdbVersion=this.gdbVersion,o.moment=this.historicMoment;return(await r(this.networkServiceUrl,o,t)).associations}async synthesizeAssociationGeometries(e){const[{synthesizeAssociationGeometries:t},{default:r}]=await Promise.all([import("../rest/networks/synthesizeAssociationGeometries.js"),import("../rest/networks/support/SynthesizeAssociationGeometriesParameters.js")]),s=r.from(e);return s.gdbVersion=this.gdbVersion,s.moment=this.historicMoment,t(this.networkServiceUrl,s)}async trace(e){const[{trace:t},{default:r}]=await Promise.all([import("../rest/networks/trace.js"),import("../rest/networks/support/TraceParameters.js")]),s=r.from(e);return s.gdbVersion=this.gdbVersion,s.moment=this.historicMoment,t(this.networkServiceUrl,s)}async submitTraceJob(e){const[{submitTraceJob:t},{default:r}]=await Promise.all([import("../rest/networks/trace.js"),import("../rest/networks/support/TraceParameters.js")]),s=r.from(e);s.gdbVersion=this.gdbVersion,s.moment=this.historicMoment;const o=await t(this.networkServiceUrl,s);return new f({statusUrl:o})}async canAddAssociation(e){const t=await this.getRulesTable();if(!t)return!1;const{fromNetworkElement:r,toNetworkElement:s}=e;if(!r||!s)return!1;await t.load();let o=null;switch(e.associationType){case"containment":o=t.rulesCategorized.containment;break;case"attachment":o=t.rulesCategorized.attachment;break;default:o=t.rulesCategorized.connectivity}return o.some(e=>g(e,r,s))}generateAddAssociations(e){const{associationsTable:r}=this.networkSystemLayers,{fromNetworkSourceId:s,fromGlobalId:o,fromTerminalId:i,fromFirstUnit:a,fromNumUnits:n,toNetworkSourceId:l,toGlobalId:u,toTerminalId:d,toFirstUnit:m,toNumUnits:c,associationType:h,isContentVisible:p,percentAlong:f,globalId:w}=y(r);return{addFeatures:e.map(e=>{const r=new t({attributes:{[s]:e.fromNetworkElement?.networkSourceId,[o]:e.fromNetworkElement?.globalId,[i]:e.fromNetworkElement?.terminalId,[l]:e.toNetworkElement?.networkSourceId,[u]:e.toNetworkElement?.globalId,[d]:e.toNetworkElement?.terminalId,[h]:I[e.associationType],[p]:null==e.isContentVisible?void 0:e.isContentVisible?1:0,[f]:e.percentAlong,[w]:e.globalId}});return e.fromNetworkElement instanceof b&&(r.attributes[a]=e.fromNetworkElement?.firstUnit,r.attributes[n]=e.fromNetworkElement?.numUnits),e.toNetworkElement instanceof b&&(r.attributes[m]=e.toNetworkElement?.firstUnit,r.attributes[c]=e.toNetworkElement?.numUnits),r}),id:this.networkSystemLayers.associationsTableId,identifierFields:{globalIdField:r?.globalIdField??"globalid",objectIdField:r?.objectIdField??"objectid"}}}generateDeleteAssociations(e){const{associationsTable:t,associationsTableId:r}=this.networkSystemLayers,s={id:r,identifierFields:{globalIdField:t?.globalIdField??"globalid",objectIdField:t?.objectIdField??"objectid"}};if(-8===this.dataElement?.schemaGeneration){const t=this._generateDeleteTelecomAssociationPayload(e);return{...s,deleteAssociations:t}}const o=e.map(e=>({globalId:e.globalId}));return{...s,deleteFeatures:o}}generateCombineNetworkElements(e){return{id:this._ensureSingleSourceIdAsValidLayerId(e),combineGroupedObjects:[{globalIds:e.map(e=>e.globalId)}]}}generateDivideNetworkElements(e,t){return{id:this._ensureSingleSourceIdAsValidLayerId([e]),divideGroupedObjects:[{globalId:e.globalId,numUnits:t}]}}async loadAssociationsTable(){return this.networkSystemLayers.loadAssociationsTable()}async _loadNamedTraceConfigurationsFromNetwork(e){if(0===this.sharedNamedTraceConfigurations?.length)return;const t=this.sharedNamedTraceConfigurations.map(e=>e.globalId),r=await this.queryNamedTraceConfigurations({globalIds:t},e);for(const s of this.sharedNamedTraceConfigurations){const e=r?.find(e=>e.globalId===s.globalId);if(e){const t=e.write({},{origin:"service"});s.read(t,{origin:"service"})}}}_hydrateRuleInfo(e,t,r){const s=e.fieldsIndex,o=s.get("RULETYPE"),i=s.get("CREATIONDATE"),a=s.get("FROMNETWORKSOURCEID"),n=s.get("FROMASSETGROUP"),l=s.get("FROMASSETTYPE"),u=s.get("FROMTERMINALID"),d=s.get("TONETWORKSOURCEID"),m=s.get("TOASSETGROUP"),c=s.get("TOASSETTYPE"),y=s.get("TOTERMINALID"),h=s.get("VIANETWORKSOURCEID"),p=s.get("VIAASSETGROUP"),f=s.get("VIAASSETTYPE"),I=s.get("VIATERMINALID"),w=r.attributes[o.name],g=new Date(r.attributes[i.name]),b=[{networkSourceId:r.attributes[a.name],assetGroupId:r.attributes[n.name],assetTypeId:r.attributes[l.name],terminalId:r.attributes[u.name]},{networkSourceId:r.attributes[d.name],assetGroupId:r.attributes[m.name],assetTypeId:r.attributes[c.name],terminalId:r.attributes[y.name]},{networkSourceId:r.attributes[h.name],assetGroupId:r.attributes[p.name],assetTypeId:r.attributes[f.name],terminalId:r.attributes[I.name]}],T={ruleType:w,creationDate:g};for(const k of[0,1,2]){if(5!==w&&2===k)continue;const e=b[k],r=t.find(t=>t.sourceId===e.networkSourceId),s=r?.assetGroups.find(t=>t.assetGroupCode===e.assetGroupId),o=s?.assetTypes.find(t=>t.assetTypeCode===e.assetTypeId),i=this._getTerminal(o,e);let a="";switch(k){case 0:a="from";break;case 1:a="to";break;case 2:a="via"}T[`${a}NetworkSource`]=r,T[`${a}AssetGroup`]=s,T[`${a}AssetType`]=o,T[`${a}Terminal`]=i?.toJSON()}return T}_getTerminal(e,t){const r=e?.terminalConfigurationId,s=this.terminalConfigurations?.find(e=>e.id===r);return s?.terminals?.find(e=>e.id===t.terminalId)??null}async _queryRulesTable(e){const{gdbVersion:t,historicMoment:r}=this,s=new T({where:"1=1",outFields:["*"],gdbVersion:t,historicMoment:r});return(await u(e,s)).features}_generateDeleteTelecomAssociationPayload(e){return e.map(e=>({globalId:e.globalId??"{00000000-0000-0000-0000-000000000000}",associationType:w.toJSON(e.associationType),fromSourceId:e.fromNetworkElement.networkSourceId,fromGlobalId:e.fromNetworkElement.globalId,fromTerminalId:e.fromNetworkElement.terminalId,toSourceId:e.toNetworkElement.networkSourceId,toGlobalId:e.toNetworkElement.globalId,toTerminalId:e.toNetworkElement.terminalId}))}_ensureSingleSourceIdAsValidLayerId(e){const t=r(e.map(e=>e.networkSourceId));if(t.length>1)throw new s("utility-network:invalid-source-id","'networkSourceId' is not valid. Ensure that all network elements have the same 'networkSourceId' and that it corresponds to a valid layer in the utility network.");const o=t[0],i=this.getLayerIdBySourceId(o);if(null==i)throw new s("utility-network:invalid-source-id","'networkSourceId' is not valid. Ensure that all network elements have the same 'networkSourceId' and that it corresponds to a valid layer in the utility network.");return i}};e([a({readOnly:!0})],k.prototype,"_rulesLayer",null),e([a({type:[c],json:{origins:{"web-map":{read:{source:"traceConfigurations"},write:{target:"traceConfigurations"}},service:{read:{source:"traceConfigurations"}}},read:!1}})],k.prototype,"sharedNamedTraceConfigurations",void 0),e([a({type:["utility"],readOnly:!0,json:{read:!1,write:!1}})],k.prototype,"type",void 0),e([a({readOnly:!0})],k.prototype,"serviceTerritoryFeatureLayerId",null),e([a({readOnly:!0})],k.prototype,"networkSystemLayers",null),e([a({readOnly:!0})],k.prototype,"terminalConfigurations",null),e([a({readOnly:!0})],k.prototype,"domainNetworkNames",null),e([a({readOnly:!0})],k.prototype,"hasTelecomNetwork",null),e([a({readOnly:!0,json:{read:!1}})],k.prototype,"associationsTable",null),k=e([n("esri.networks.UtilityNetwork")],k);const S=k;export{S 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.34/esri/copyright.txt for details.
4
4
  */
5
- import{JSONMap as n}from"../../core/jsonMap.js";const t=new n({Physical:"physical",Virtual:"virtual"}),o=new n({"Start and end":"start-and-end",Start:"start",Midspan:"midspan",End:"end"}),i=new n({connected:"connected",upstream:"upstream",downstream:"downstream",shortestPath:"shortest-path",subnetwork:"subnetwork",subnetworkController:"subnetwork-controller",loops:"loops",isolation:"isolation",path:"path",circuit:"circuit"}),e=new n({junctionJunctionConnectivity:"junction-junction-connectivity",connectivity:"connectivity",attachment:"attachment",containment:"containment",junctionEdgeFromConnectivity:"junction-edge-from-connectivity",junctionEdgeMidspanConnectivity:"junction-edge-midspan-connectivity",junctionEdgeToConnectivity:"junction-edge-to-connectivity"}),c={connectivity:1,"junction-junction-connectivity":1,containment:2,attachment:3,"junction-edge-from-connectivity":4,"junction-edge-midspan-connectivity":5,"junction-edge-to-connectivity":6},a=new n({normal:"normal",rebuild:"rebuild",forceRebuild:"force-rebuild"});export{c as AssociationTypeEnum,o as CircuitSectionRoleKebabDict,t as CircuitTypeKebabDict,e as associationTypeKebabDict,i as traceTypeKebabDict,a as validationTypeKebabDict};
5
+ import{JSONMap as n}from"../../core/jsonMap.js";const t=new n({Clean:"clean",Dirty:"dirty"}),i=new n({Physical:"physical",Virtual:"virtual"}),e=new n({"Start and end":"start-and-end",Start:"start",Midspan:"midspan",End:"end"}),o=new n({connected:"connected",upstream:"upstream",downstream:"downstream",shortestPath:"shortest-path",subnetwork:"subnetwork",subnetworkController:"subnetwork-controller",loops:"loops",isolation:"isolation",path:"path",circuit:"circuit"}),c=new n({junctionJunctionConnectivity:"junction-junction-connectivity",connectivity:"connectivity",attachment:"attachment",containment:"containment",junctionEdgeFromConnectivity:"junction-edge-from-connectivity",junctionEdgeMidspanConnectivity:"junction-edge-midspan-connectivity",junctionEdgeToConnectivity:"junction-edge-to-connectivity"}),a={connectivity:1,"junction-junction-connectivity":1,containment:2,attachment:3,"junction-edge-from-connectivity":4,"junction-edge-midspan-connectivity":5,"junction-edge-to-connectivity":6},r=new n({normal:"normal",rebuild:"rebuild",forceRebuild:"force-rebuild"});export{a as AssociationTypeEnum,e as CircuitSectionRoleKebabDict,t as CircuitStatusKebabDict,i as CircuitTypeKebabDict,c as associationTypeKebabDict,o as traceTypeKebabDict,r as validationTypeKebabDict};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcgis/core",
3
- "version": "4.34.0-next.52",
3
+ "version": "4.34.0-next.54",
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": [
@@ -21,9 +21,9 @@
21
21
  "@esri/arcgis-html-sanitizer": "~4.1.0",
22
22
  "@esri/calcite-components": "^3.2.1",
23
23
  "@vaadin/grid": "~24.8.4",
24
- "@zip.js/zip.js": "~2.7.69",
24
+ "@zip.js/zip.js": "~2.7.72",
25
25
  "luxon": "~3.7.1",
26
- "marked": "~16.1.1",
26
+ "marked": "~16.1.2",
27
27
  "tslib": "^2.8.1"
28
28
  },
29
29
  "type": "module"
package/portal/Portal.js CHANGED
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import t from"../config.js";import{id as r}from"../kernel.js";import o from"../request.js";import s from"../core/Error.js";import{JSONSupportMixin as a}from"../core/JSONSupport.js";import{Loadable as i}from"../core/Loadable.js";import{destroyMaybe as l,removeMaybe as u}from"../core/maybe.js";import{throwIfAborted as n,isAborted as p,createAbortError as h,throwIfAbortError as d}from"../core/promiseUtils.js";import{property as c}from"../core/accessorSupport/decorators/property.js";import{ensureType as y}from"../core/accessorSupport/ensureType.js";import"../core/has.js";import"../core/RandomLCG.js";import{reader as m}from"../core/accessorSupport/decorators/reader.js";import{subclass as f}from"../core/accessorSupport/decorators/subclass.js";import v from"../geometry/Extent.js";import{getLocale as S}from"../intl/locale.js";import{ensureDefaultPortalInstance as P}from"./portalDefault.js";import g from"./PortalGroup.js";import O from"./PortalQueryParams.js";import B from"./PortalQueryResult.js";import D from"./PortalUser.js";import{isApiKeyApplicable as G,hasBasemapStylesApiKey as _}from"../support/apiKeyUtils.js";var U;let M;const Q={PortalGroup:()=>Promise.resolve({default:g}),PortalItem:()=>import("./PortalItem.js"),PortalUser:()=>Promise.resolve({default:D})};let C=class extends(a(i)){static{U=this}static{this.AUTH_MODE_ANONYMOUS="anonymous"}static{this.AUTH_MODE_AUTO="auto"}static{this.AUTH_MODE_IMMEDIATE="immediate"}static{this.AUTH_MODE_NO_PROMPT="no-prompt"}constructor(e){super(e),this._esriIdCredentialCreateHandle=null,this.access=null,this.allSSL=!1,this.authMode="auto",this.authorizedCrossOriginDomains=null,this.basemapGalleryGroupQuery=null,this.basemapGalleryGroupQuery3D=null,this.bingKey=null,this.canListApps=!1,this.canListData=!1,this.canListPreProvisionedItems=!1,this.canProvisionDirectPurchase=!1,this.canSearchPublic=!0,this.canShareBingPublic=!1,this.canSharePublic=!1,this.canSignInArcGIS=!1,this.canSignInIDP=!1,this.colorSetsGroupQuery=null,this.commentsEnabled=!1,this.created=null,this.culture=null,this.customBaseUrl=null,this.default3DBasemapQuery=null,this.defaultBasemap=null,this.defaultDevBasemap=null,this.defaultExtent=null,this.defaultVectorBasemap=null,this.description=null,this.devBasemapGalleryGroupQuery=null,this.eueiEnabled=null,this.featuredGroups=null,this.featuredItemsGroupQuery=null,this.galleryTemplatesGroupQuery=null,this.layoutGroupQuery=null,this.livingAtlasGroupQuery=null,this.hasCategorySchema=!1,this.hasClassificationSchema=!1,this.helperServices=null,this.homePageFeaturedContent=null,this.homePageFeaturedContentCount=null,this.httpPort=null,this.httpsPort=null,this.id=null,this.ipCntryCode=null,this.isPortal=!1,this.isReadOnly=!1,this.layerTemplatesGroupQuery=null,this.maxTokenExpirationMinutes=null,this.modified=null,this.name=null,this.portalHostname=null,this.portalMode=null,this.portalProperties=null,this.region=null,this.recycleBinEnabled=!1,this.rotatorPanels=null,this.showHomePageDescription=!1,this.sourceJSON=null,this.supportsHostedServices=!1,this.symbolSetsGroupQuery=null,this.templatesGroupQuery=null,this.units=null,this.url=t.portalUrl,this.urlKey=null,this.user=null,this.use3dBasemaps=!0,this.useDefault3dBasemap=!1,this.useStandardizedQuery=!1,this.useVectorBasemaps=!1,this.vectorBasemapGalleryGroupQuery=null}normalizeCtorArgs(e){return"string"==typeof e?{url:e}:e}destroy(){b.unregister(this),this.defaultBasemap=l(this.defaultBasemap),this.defaultDevBasemap=l(this.defaultDevBasemap),this.defaultVectorBasemap=l(this.defaultVectorBasemap),this._esriIdCredentialCreateHandle=u(this._esriIdCredentialCreateHandle)}readAuthorizedCrossOriginDomains(e){if(e)for(const r of e)t.request.trustedServers.includes(r)||t.request.trustedServers.push(r);return e}readDefaultBasemap(e){return this._readBasemap(e)}readDefaultDevBasemap(e){return this._readBasemap(e)}readDefaultVectorBasemap(e){return this._readBasemap(e)}get extraQuery(){const e=this.user?.orgId,t=!e||this.canSearchPublic;return this.id&&!t?` AND orgid:${this.id}`:null}get hasAPIKey(){return G(this.restUrl)}get isOrganization(){return!!this.access}get itemPageUrl(){return this.url?`${this.url}/home/item.html`:null}get loaded(){return super.loaded}get restUrl(){let e=this.url;if(e){const t=e.indexOf("/sharing");e=t>0?e.slice(0,t):this.url.replace(/\/+$/,""),e+="/sharing/rest"}return e}get thumbnailUrl(){const e=this.restUrl,t=this.thumbnail;return e&&t?this._normalizeSSL(e+"/portals/self/resources/"+t):null}readUrlKey(e){return e?e.toLowerCase():e}readUser(e){let t=null;return e&&(t=D.fromJSON(e),t.portal=this),t}load(e){const t=import("../Basemap.js").then(({default:t})=>{n(e),M=t}).then(()=>this.sourceJSON?this.sourceJSON:this.fetchSelf(this.authMode,!1,e)).then(e=>{if(!this.hasAPIKey&&r){const e=r;this.credential=e.findCredential(this.restUrl),this.credential||this.authMode!==U.AUTH_MODE_AUTO&&this.authMode!==U.AUTH_MODE_NO_PROMPT||(this._esriIdCredentialCreateHandle?.remove(),this._esriIdCredentialCreateHandle=e.on("credential-create",w(new WeakRef(this))),b.register(this,this._esriIdCredentialCreateHandle,this))}this.sourceJSON=e,this.read(e)});return this.addResolvingPromise(t),Promise.resolve(this)}async createElevationLayers(){await this.load();const e=this._getHelperService("defaultElevationLayers"),t=(await import("../layers/ElevationLayer.js")).default;return e?e.map(e=>new t({id:e.id,url:e.url})):[]}async fetchBasemaps(e,t){const r=await this._fetchBasemaps(e,t);if(!0===t?.include3d&&!1!==this.use3dBasemaps){const o=await this._fetchBasemaps3D(e,t);r.unshift(...o)}return r}async fetchDefault3DBasemap(e){if(!this.useDefault3dBasemap||!this.default3DBasemapQuery||"none"===this.default3DBasemapQuery)return null;const t=new O;t.query=this.default3DBasemapQuery,t.disableExtraQuery=!0;const r=(await this.queryItems(t,e)).results.find(e=>"Web Scene"===e.type);return r?new M({portalItem:r}):null}fetchCategorySchema(e){return this.hasCategorySchema?this.request(this.restUrl+"/portals/self/categorySchema",e).then(e=>e.categorySchema):p(e)?Promise.reject(h()):Promise.resolve([])}async fetchClassificationSchema(e){return this.hasClassificationSchema?this.request(this.restUrl+"/portals/self/classification/classificationSchema",e).then(e=>e.classificationSchema):null}fetchFeaturedGroups(e){const t=this.featuredGroups,r=new O({num:100,sortField:"title"});if(t?.length){const o=[];for(const e of t)o.push(`(title:"${e.title}" AND owner:${e.owner})`);return r.query=o.join(" OR "),this.queryGroups(r,e).then(e=>e.results)}return p(e)?Promise.reject(h()):Promise.resolve([])}fetchRegions(e){const t=this.user?.culture||this.culture||S();return this.request(this.restUrl+"/portals/regions",{...e,query:{culture:t}})}fetchSettings(e){const t=this.user?.culture||this.culture||S();return this.request(this.restUrl+"/portals/self/settings",{...e,query:{culture:t}})}static getDefault(){return P(()=>new U)}queryGroups(e,t){return this.queryPortal("/community/groups",e,"PortalGroup",t)}queryItems(e,t){return this.queryPortal("/search",e,"PortalItem",t)}queryUsers(e,t){return e.sortField||(e.sortField="username"),this.queryPortal("/community/users",e,"PortalUser",t)}fetchSelf(e=this.authMode,t=!1,r){const o=this.restUrl+"/portals/self",s={authMode:e,query:{culture:S().toLowerCase()},withCredentials:!0,...r};return"auto"===s.authMode&&(s.authMode="no-prompt"),t&&(s.query.default=!0),this.request(o,s)}queryPortal(e,t,r,o){const s=y(O,t),a=t=>this.request(this.restUrl+e,{...s.toRequestOptions(this),...o}).then(e=>{const r=s.clone();return r.start=e.nextStart,new B({nextQueryParams:r,queryParams:s,total:e.total,results:U._resultsToTypedArray(t,{portal:this},e,o)})}).then(e=>Promise.all(e.results.map(t=>"function"==typeof t.when?t.when():e)).then(()=>e,t=>(d(t),e)));return r&&Q[r]?Q[r]().then(({default:e})=>(n(o),a(e))):a()}signIn(){if(this.hasAPIKey)return this.load().then(()=>{if(!this.user)throw new s("portal:not-authenticated","Unable to authenticate user. Portal.user is missing")});if(this.authMode===U.AUTH_MODE_ANONYMOUS||this.authMode===U.AUTH_MODE_NO_PROMPT&&!r)return Promise.reject(new s("portal:invalid-auth-mode",`Current "authMode"' is "${this.authMode}"`));if("failed"===this.loadStatus)return Promise.reject(this.loadError);const e=e=>Promise.resolve().then(()=>"not-loaded"===this.loadStatus?(e||(this.authMode="immediate"),this.load().then(()=>null)):"loading"===this.loadStatus?this.load().then(()=>this.credential?null:(this.credential=e,this.fetchSelf("immediate"))):this.user&&this.credential===e?null:(this.credential=e,this.fetchSelf("immediate"))).then(e=>{e&&(this.sourceJSON=e,this.read(e))});return r?r.getCredential(this.restUrl,{prompt:this.authMode!==U.AUTH_MODE_NO_PROMPT}).then(t=>e(t)):e(this.credential)}normalizeUrl(e){const t=this.credential?.token;return this._normalizeSSL(t?e+(e.includes("?")?"&":"?")+"token="+t:e)}requestToTypedArray(e,t,r){return this.request(e,t).then(e=>{const t=U._resultsToTypedArray(r,{portal:this},e);return Promise.all(t.map(t=>"function"==typeof t.when?t.when():e)).then(()=>t,()=>t)})}request(e,t={}){const r={f:"json",...t.query},{authMode:s=(this.authMode===U.AUTH_MODE_ANONYMOUS||this.authMode===U.AUTH_MODE_NO_PROMPT?this.authMode:"auto"),body:a=null,cacheBust:i=!1,method:l="auto",responseType:u="json",signal:n}=t,p={authMode:s,body:a,cacheBust:i,method:l,query:r,responseType:u,timeout:0,signal:n};return t.withCredentials&&(p.withCredentials=!0),o(this._normalizeSSL(e),p).then(e=>e.data)}toJSON(){throw new s("internal:not-yet-implemented","Portal.toJSON is not yet implemented")}static fromJSON(e){if(!e)return null;if(e.declaredClass)throw new Error("JSON object is already hydrated");return new U({sourceJSON:e})}_getHelperService(e){const t=this.helperServices&&this.helperServices[e];if(!t)throw new s("portal:service-not-found",`The \`helperServices\` do not include an entry named "${e}"`);return t}async _fetchBasemaps(e,t){const r=new O;r.query=e||(_()?this.devBasemapGalleryGroupQuery:this.useVectorBasemaps?this.vectorBasemapGalleryGroupQuery:this.basemapGalleryGroupQuery),r.disableExtraQuery=!0;const o=await this.queryGroups(r,t);if(!o.total)return[];const s=o.results[0];r.num=100,r.query='type:"Web Map" -type:"Web Application"',r.sortField=s.sortField||"name",r.sortOrder=s.sortOrder||"desc";const a=await s.queryItems(r,t);if(!a.total)return[];return a.results.filter(e=>"Web Map"===e.type).map(e=>new M({portalItem:e}))}async _fetchBasemaps3D(e,t){const r=e||this.basemapGalleryGroupQuery3D;if(!r)return[];if(_())return[];const o=new O({query:r,disableExtraQuery:!0}),s=await this.queryGroups(o,t);if(!s.total)return[];const a=s.results[0];o.num=100,o.query='type:"Web Scene"',o.sortField=a.sortField||"name",o.sortOrder=a.sortOrder||"desc";const i=await a.queryItems(o,t);if(!i.total)return[];return i.results.filter(e=>"Web Scene"===e.type).map(e=>new M({portalItem:e}))}_normalizeSSL(e){return e.replace(/^http:/i,"https:").replace(":7080",":7443")}_readBasemap(e){if(e){const t=M.fromJSON(e);return t.portalItem={portal:this},t}return null}static _resultsToTypedArray(e,t,r,o){let s;if(r){const a=null!=o?o.signal:null;s=r.listings||r.notifications||r.userInvitations||r.tags||r.items||r.groups||r.comments||r.provisions||r.results||r.relatedItems||r,(e||t)&&(s=s.map(r=>{const o=Object.assign(e?e.fromJSON(r):r,t);return"function"==typeof o.load&&o.load(a),o}))}else s=[];return s}};e([c()],C.prototype,"access",void 0),e([c()],C.prototype,"allSSL",void 0),e([c()],C.prototype,"authMode",void 0),e([c()],C.prototype,"authorizedCrossOriginDomains",void 0),e([m("authorizedCrossOriginDomains")],C.prototype,"readAuthorizedCrossOriginDomains",null),e([c()],C.prototype,"basemapGalleryGroupQuery",void 0),e([c({json:{name:"3DBasemapGalleryGroupQuery"}})],C.prototype,"basemapGalleryGroupQuery3D",void 0),e([c()],C.prototype,"bingKey",void 0),e([c()],C.prototype,"canListApps",void 0),e([c()],C.prototype,"canListData",void 0),e([c()],C.prototype,"canListPreProvisionedItems",void 0),e([c()],C.prototype,"canProvisionDirectPurchase",void 0),e([c()],C.prototype,"canSearchPublic",void 0),e([c()],C.prototype,"canShareBingPublic",void 0),e([c()],C.prototype,"canSharePublic",void 0),e([c()],C.prototype,"canSignInArcGIS",void 0),e([c()],C.prototype,"canSignInIDP",void 0),e([c()],C.prototype,"colorSetsGroupQuery",void 0),e([c()],C.prototype,"commentsEnabled",void 0),e([c({type:Date})],C.prototype,"created",void 0),e([c()],C.prototype,"credential",void 0),e([c()],C.prototype,"culture",void 0),e([c()],C.prototype,"currentVersion",void 0),e([c()],C.prototype,"customBaseUrl",void 0),e([c()],C.prototype,"default3DBasemapQuery",void 0),e([c()],C.prototype,"defaultBasemap",void 0),e([m("defaultBasemap")],C.prototype,"readDefaultBasemap",null),e([c()],C.prototype,"defaultDevBasemap",void 0),e([m("defaultDevBasemap")],C.prototype,"readDefaultDevBasemap",null),e([c({type:v})],C.prototype,"defaultExtent",void 0),e([c()],C.prototype,"defaultVectorBasemap",void 0),e([m("defaultVectorBasemap")],C.prototype,"readDefaultVectorBasemap",null),e([c()],C.prototype,"description",void 0),e([c()],C.prototype,"devBasemapGalleryGroupQuery",void 0),e([c()],C.prototype,"eueiEnabled",void 0),e([c({readOnly:!0})],C.prototype,"extraQuery",null),e([c()],C.prototype,"featuredGroups",void 0),e([c()],C.prototype,"featuredItemsGroupQuery",void 0),e([c()],C.prototype,"galleryTemplatesGroupQuery",void 0),e([c()],C.prototype,"layoutGroupQuery",void 0),e([c()],C.prototype,"livingAtlasGroupQuery",void 0),e([c({readOnly:!0})],C.prototype,"hasAPIKey",null),e([c()],C.prototype,"hasCategorySchema",void 0),e([c()],C.prototype,"hasClassificationSchema",void 0),e([c()],C.prototype,"helpBase",void 0),e([c()],C.prototype,"helperServices",void 0),e([c()],C.prototype,"helpMap",void 0),e([c()],C.prototype,"homePageFeaturedContent",void 0),e([c()],C.prototype,"homePageFeaturedContentCount",void 0),e([c()],C.prototype,"httpPort",void 0),e([c()],C.prototype,"httpsPort",void 0),e([c()],C.prototype,"id",void 0),e([c()],C.prototype,"ipCntryCode",void 0),e([c({readOnly:!0})],C.prototype,"isOrganization",null),e([c()],C.prototype,"isPortal",void 0),e([c()],C.prototype,"isReadOnly",void 0),e([c({readOnly:!0})],C.prototype,"itemPageUrl",null),e([c()],C.prototype,"layerTemplatesGroupQuery",void 0),e([c()],C.prototype,"maxTokenExpirationMinutes",void 0),e([c({type:Date})],C.prototype,"modified",void 0),e([c()],C.prototype,"name",void 0),e([c()],C.prototype,"portalHostname",void 0),e([c()],C.prototype,"portalMode",void 0),e([c()],C.prototype,"portalProperties",void 0),e([c()],C.prototype,"region",void 0),e([c()],C.prototype,"recycleBinEnabled",void 0),e([c({readOnly:!0})],C.prototype,"restUrl",null),e([c()],C.prototype,"rotatorPanels",void 0),e([c()],C.prototype,"showHomePageDescription",void 0),e([c()],C.prototype,"sourceJSON",void 0),e([c()],C.prototype,"staticImagesUrl",void 0),e([c({json:{name:"2DStylesGroupQuery"}})],C.prototype,"stylesGroupQuery2d",void 0),e([c({json:{name:"stylesGroupQuery"}})],C.prototype,"stylesGroupQuery3d",void 0),e([c()],C.prototype,"supportsHostedServices",void 0),e([c()],C.prototype,"symbolSetsGroupQuery",void 0),e([c()],C.prototype,"templatesGroupQuery",void 0),e([c()],C.prototype,"thumbnail",void 0),e([c({readOnly:!0})],C.prototype,"thumbnailUrl",null),e([c()],C.prototype,"units",void 0),e([c()],C.prototype,"url",void 0),e([c()],C.prototype,"urlKey",void 0),e([m("urlKey")],C.prototype,"readUrlKey",null),e([c()],C.prototype,"user",void 0),e([m("user")],C.prototype,"readUser",null),e([c()],C.prototype,"use3dBasemaps",void 0),e([c()],C.prototype,"useDefault3dBasemap",void 0),e([c()],C.prototype,"useStandardizedQuery",void 0),e([c()],C.prototype,"useVectorBasemaps",void 0),e([c()],C.prototype,"vectorBasemapGalleryGroupQuery",void 0),C=U=e([f("esri.portal.Portal")],C);const b=new FinalizationRegistry(e=>{e.remove()});function w(e){const t=r;return()=>{const r=e.deref();r&&t.findCredential(r.restUrl)&&r.signIn().catch(()=>{})}}export{C as default};
5
+ import{__decorate as e}from"tslib";import t from"../config.js";import{id as r}from"../kernel.js";import o from"../request.js";import s from"../core/Error.js";import{JSONSupportMixin as a}from"../core/JSONSupport.js";import{Loadable as i}from"../core/Loadable.js";import{destroyMaybe as l,removeMaybe as u}from"../core/maybe.js";import{throwIfAborted as n,isAborted as p,createAbortError as h,throwIfAbortError as d}from"../core/promiseUtils.js";import{property as c}from"../core/accessorSupport/decorators/property.js";import{ensureType as y}from"../core/accessorSupport/ensureType.js";import"../core/has.js";import"../core/RandomLCG.js";import{reader as m}from"../core/accessorSupport/decorators/reader.js";import{subclass as f}from"../core/accessorSupport/decorators/subclass.js";import v from"../geometry/Extent.js";import{getLocale as S}from"../intl/locale.js";import{ensureDefaultPortalInstance as P}from"./portalDefault.js";import g from"./PortalGroup.js";import O from"./PortalQueryParams.js";import B from"./PortalQueryResult.js";import D from"./PortalUser.js";import{isApiKeyApplicable as G,hasBasemapStylesApiKey as _}from"../support/apiKeyUtils.js";var U;let M;const Q={PortalGroup:()=>Promise.resolve({default:g}),PortalItem:()=>import("./PortalItem.js"),PortalUser:()=>Promise.resolve({default:D})};let C=class extends(a(i)){static{U=this}static{this.AUTH_MODE_ANONYMOUS="anonymous"}static{this.AUTH_MODE_AUTO="auto"}static{this.AUTH_MODE_IMMEDIATE="immediate"}static{this.AUTH_MODE_NO_PROMPT="no-prompt"}constructor(e){super(e),this._esriIdCredentialCreateHandle=null,this.access=null,this.allSSL=!1,this.authMode="auto",this.authorizedCrossOriginDomains=null,this.basemapGalleryGroupQuery=null,this.basemapGalleryGroupQuery3D=null,this.bingKey=null,this.canListApps=!1,this.canListData=!1,this.canListPreProvisionedItems=!1,this.canProvisionDirectPurchase=!1,this.canSearchPublic=!0,this.canShareBingPublic=!1,this.canSharePublic=!1,this.canSignInArcGIS=!1,this.canSignInIDP=!1,this.colorSetsGroupQuery=null,this.commentsEnabled=!1,this.created=null,this.culture=null,this.customBaseUrl=null,this.default3DBasemapQuery=null,this.defaultBasemap=null,this.defaultDevBasemap=null,this.defaultExtent=null,this.defaultVectorBasemap=null,this.description=null,this.devBasemapGalleryGroupQuery=null,this.eueiEnabled=null,this.featuredGroups=null,this.featuredItemsGroupQuery=null,this.galleryTemplatesGroupQuery=null,this.layoutGroupQuery=null,this.livingAtlasGroupQuery=null,this.hasCategorySchema=!1,this.hasClassificationSchema=!1,this.helperServices=null,this.homePageFeaturedContent=null,this.homePageFeaturedContentCount=null,this.httpPort=null,this.httpsPort=null,this.id=null,this.ipCntryCode=null,this.isPortal=!1,this.isReadOnly=!1,this.layerTemplatesGroupQuery=null,this.maxTokenExpirationMinutes=null,this.modified=null,this.name=null,this.portalHostname=null,this.portalMode=null,this.portalProperties=null,this.region=null,this.recycleBinEnabled=!1,this.rotatorPanels=null,this.showHomePageDescription=!1,this.sourceJSON=null,this.supportsHostedServices=!1,this.symbolSetsGroupQuery=null,this.templatesGroupQuery=null,this.units=null,this.url=t.portalUrl,this.urlKey=null,this.user=null,this.use3dBasemaps=!0,this.useDefault3dBasemap=!1,this.useStandardizedQuery=!1,this.useVectorBasemaps=!1,this.vectorBasemapGalleryGroupQuery=null}normalizeCtorArgs(e){return"string"==typeof e?{url:e}:e}destroy(){b.unregister(this),this.defaultBasemap=l(this.defaultBasemap),this.defaultDevBasemap=l(this.defaultDevBasemap),this.defaultVectorBasemap=l(this.defaultVectorBasemap),this._esriIdCredentialCreateHandle=u(this._esriIdCredentialCreateHandle)}readAuthorizedCrossOriginDomains(e){if(e)for(const r of e)t.request.trustedServers.includes(r)||t.request.trustedServers.push(r);return e}readDefaultBasemap(e){return this._readBasemap(e)}readDefaultDevBasemap(e){return this._readBasemap(e)}readDefaultVectorBasemap(e){return this._readBasemap(e)}get extraQuery(){const e=this.user?.orgId,t=!e||this.canSearchPublic;return this.id&&!t?` AND orgid:${this.id}`:null}get hasAPIKey(){return G(this.restUrl)}get isOrganization(){return!!this.access}get itemPageUrl(){return this.url?`${this.url}/home/item.html`:null}get loaded(){return super.loaded}get restUrl(){let e=this.url;if(e){const t=e.indexOf("/sharing");e=t>0?e.slice(0,t):this.url.replace(/\/+$/,""),e+="/sharing/rest"}return e}get thumbnailUrl(){const e=this.restUrl,t=this.thumbnail;return e&&t?this._normalizeSSL(e+"/portals/self/resources/"+t):null}readUrlKey(e){return e?e.toLowerCase():e}readUser(e){let t=null;return e&&(t=D.fromJSON(e),t.portal=this),t}load(e){const t=import("../Basemap.js").then(({default:t})=>{n(e),M=t}).then(()=>this.sourceJSON?this.sourceJSON:this.fetchSelf(this.authMode,!1,e)).then(e=>{if(!this.hasAPIKey&&r){const e=r;this.credential=e.findCredential(this.restUrl),this.credential||this.authMode!==U.AUTH_MODE_AUTO&&this.authMode!==U.AUTH_MODE_NO_PROMPT||(this._esriIdCredentialCreateHandle?.remove(),this._esriIdCredentialCreateHandle=e.on("credential-create",w(new WeakRef(this))),b.register(this,this._esriIdCredentialCreateHandle,this))}this.sourceJSON=e,this.read(e)});return this.addResolvingPromise(t),Promise.resolve(this)}async createElevationLayers(){await this.load();const e=this._getHelperService("defaultElevationLayers"),t=(await import("../layers/ElevationLayer.js")).default;return e?e.map(e=>new t({id:e.id,url:e.url})):[]}async fetchBasemaps(e,t){const r=await this._fetchBasemaps(e,t);if(!0===t?.include3d&&!1!==this.use3dBasemaps){const o=await this._fetchBasemaps3D(e,t);r.unshift(...o)}return r}async fetchDefault3DBasemap(e){if(!this.useDefault3dBasemap||!this.default3DBasemapQuery||"none"===this.default3DBasemapQuery)return null;const t=new O;t.query=this.default3DBasemapQuery,t.disableExtraQuery=!0;const r=(await this.queryItems(t,e)).results.find(e=>"Web Scene"===e.type);return r?new M({portalItem:r}):null}fetchCategorySchema(e){return this.hasCategorySchema?this.request(this.restUrl+"/portals/self/categorySchema",e).then(e=>e.categorySchema):p(e)?Promise.reject(h()):Promise.resolve([])}async fetchClassificationSchema(e){return this.hasClassificationSchema?this.request(this.restUrl+"/portals/self/classification/classificationSchema",e).then(e=>e.classificationSchema):null}fetchFeaturedGroups(e){const t=this.featuredGroups,r=new O({num:100,sortField:"title"});if(t?.length){const o=[];for(const e of t)o.push(`(title:"${e.title}" AND owner:${e.owner})`);return r.query=o.join(" OR "),this.queryGroups(r,e).then(e=>e.results)}return p(e)?Promise.reject(h()):Promise.resolve([])}fetchRegions(e){const t=this.user?.culture||this.culture||S();return this.request(this.restUrl+"/portals/regions",{...e,query:{culture:t}})}fetchSettings(e){const t=this.user?.culture||this.culture||S();return this.request(this.restUrl+"/portals/self/settings",{...e,query:{culture:t}})}static getDefault(){return P(()=>new U)}queryGroups(e,t){return this.queryPortal("/community/groups",e,"PortalGroup",t)}queryItems(e,t){return this.queryPortal("/search",e,"PortalItem",t)}queryUsers(e,t){return e.sortField||(e.sortField="username"),this.queryPortal("/community/users",e,"PortalUser",t)}fetchSelf(e=this.authMode,t=!1,r){const o=this.restUrl+"/portals/self",s={authMode:e,query:{culture:S().toLowerCase()},withCredentials:!0,...r};return"auto"===s.authMode&&(s.authMode="no-prompt"),t&&(s.query.default=!0),this.request(o,s)}queryPortal(e,t,r,o){const s=y(O,t),a=t=>this.request(this.restUrl+e,{...s.toRequestOptions(this),...o}).then(e=>{const r=s.clone();return r.start=e.nextStart,new B({nextQueryParams:r,queryParams:s,total:e.total,results:U._resultsToTypedArray(t,{portal:this},e,o)})}).then(e=>Promise.all(e.results.map(t=>"function"==typeof t.when?t.when():e)).then(()=>e,t=>(d(t),e)));return r&&Q[r]?Q[r]().then(({default:e})=>(n(o),a(e))):a()}signIn(){if(this.hasAPIKey)return this.load().then(()=>{if(!this.user)throw new s("portal:not-authenticated","Unable to authenticate user. Portal.user is missing")});if(this.authMode===U.AUTH_MODE_ANONYMOUS||this.authMode===U.AUTH_MODE_NO_PROMPT&&!r)return Promise.reject(new s("portal:invalid-auth-mode",`Current "authMode"' is "${this.authMode}"`));if("failed"===this.loadStatus)return Promise.reject(this.loadError);const e=e=>Promise.resolve().then(()=>"not-loaded"===this.loadStatus?(e||(this.authMode="immediate"),this.load().then(()=>null)):"loading"===this.loadStatus?this.load().then(()=>this.credential?null:(this.credential=e,this.fetchSelf("immediate"))):this.user&&this.credential===e?null:(this.credential=e,this.fetchSelf("immediate"))).then(e=>{e&&(this.sourceJSON=e,this.read(e))});return r?r.getCredential(this.restUrl,{prompt:this.authMode!==U.AUTH_MODE_NO_PROMPT}).then(t=>e(t)):e(this.credential)}normalizeUrl(e){const t=this.credential?.token;return this._normalizeSSL(t?e+(e.includes("?")?"&":"?")+"token="+t:e)}requestToTypedArray(e,t,r){return this.request(e,t).then(e=>{const t=U._resultsToTypedArray(r,{portal:this},e);return Promise.all(t.map(t=>"function"==typeof t.when?t.when():e)).then(()=>t,()=>t)})}request(e,t={}){const r={f:"json",...t.query},{authMode:s=(this.authMode===U.AUTH_MODE_ANONYMOUS||this.authMode===U.AUTH_MODE_NO_PROMPT?this.authMode:"auto"),body:a=null,cacheBust:i=!1,method:l="auto",responseType:u="json",signal:n}=t,p={authMode:s,body:a,cacheBust:i,method:l,query:r,responseType:u,timeout:0,signal:n};return t.withCredentials&&(p.withCredentials=!0),o(this._normalizeSSL(e),p).then(e=>e.data)}toJSON(){throw new s("internal:not-yet-implemented","Portal.toJSON is not yet implemented")}static fromJSON(e){if(!e)return null;if(e.declaredClass)throw new Error("JSON object is already hydrated");return new U({sourceJSON:e})}_getHelperService(e){const t=this.helperServices?.[e];if(!t)throw new s("portal:service-not-found",`The \`helperServices\` do not include an entry named "${e}"`);return t}async _fetchBasemaps(e,t){const r=new O;r.query=e||(_()?this.devBasemapGalleryGroupQuery:this.useVectorBasemaps?this.vectorBasemapGalleryGroupQuery:this.basemapGalleryGroupQuery),r.disableExtraQuery=!0;const o=await this.queryGroups(r,t);if(!o.total)return[];const s=o.results[0];r.num=100,r.query='type:"Web Map" -type:"Web Application"',r.sortField=s.sortField||"name",r.sortOrder=s.sortOrder||"desc";const a=await s.queryItems(r,t);if(!a.total)return[];return a.results.filter(e=>"Web Map"===e.type).map(e=>new M({portalItem:e}))}async _fetchBasemaps3D(e,t){const r=e||this.basemapGalleryGroupQuery3D;if(!r)return[];if(_())return[];const o=new O({query:r,disableExtraQuery:!0}),s=await this.queryGroups(o,t);if(!s.total)return[];const a=s.results[0];o.num=100,o.query='type:"Web Scene"',o.sortField=a.sortField||"name",o.sortOrder=a.sortOrder||"desc";const i=await a.queryItems(o,t);if(!i.total)return[];return i.results.filter(e=>"Web Scene"===e.type).map(e=>new M({portalItem:e}))}_normalizeSSL(e){return e.replace(/^http:/i,"https:").replace(":7080",":7443")}_readBasemap(e){if(e){const t=M.fromJSON(e);return t.portalItem={portal:this},t}return null}static _resultsToTypedArray(e,t,r,o){let s;if(r){const a=null!=o?o.signal:null;s=r.listings||r.notifications||r.userInvitations||r.tags||r.items||r.groups||r.comments||r.provisions||r.results||r.relatedItems||r,(e||t)&&(s=s.map(r=>{const o=Object.assign(e?e.fromJSON(r):r,t);return"function"==typeof o.load&&o.load(a),o}))}else s=[];return s}};e([c()],C.prototype,"access",void 0),e([c()],C.prototype,"allSSL",void 0),e([c()],C.prototype,"authMode",void 0),e([c()],C.prototype,"authorizedCrossOriginDomains",void 0),e([m("authorizedCrossOriginDomains")],C.prototype,"readAuthorizedCrossOriginDomains",null),e([c()],C.prototype,"basemapGalleryGroupQuery",void 0),e([c({json:{name:"3DBasemapGalleryGroupQuery"}})],C.prototype,"basemapGalleryGroupQuery3D",void 0),e([c()],C.prototype,"bingKey",void 0),e([c()],C.prototype,"canListApps",void 0),e([c()],C.prototype,"canListData",void 0),e([c()],C.prototype,"canListPreProvisionedItems",void 0),e([c()],C.prototype,"canProvisionDirectPurchase",void 0),e([c()],C.prototype,"canSearchPublic",void 0),e([c()],C.prototype,"canShareBingPublic",void 0),e([c()],C.prototype,"canSharePublic",void 0),e([c()],C.prototype,"canSignInArcGIS",void 0),e([c()],C.prototype,"canSignInIDP",void 0),e([c()],C.prototype,"colorSetsGroupQuery",void 0),e([c()],C.prototype,"commentsEnabled",void 0),e([c({type:Date})],C.prototype,"created",void 0),e([c()],C.prototype,"credential",void 0),e([c()],C.prototype,"culture",void 0),e([c()],C.prototype,"currentVersion",void 0),e([c()],C.prototype,"customBaseUrl",void 0),e([c()],C.prototype,"default3DBasemapQuery",void 0),e([c()],C.prototype,"defaultBasemap",void 0),e([m("defaultBasemap")],C.prototype,"readDefaultBasemap",null),e([c()],C.prototype,"defaultDevBasemap",void 0),e([m("defaultDevBasemap")],C.prototype,"readDefaultDevBasemap",null),e([c({type:v})],C.prototype,"defaultExtent",void 0),e([c()],C.prototype,"defaultVectorBasemap",void 0),e([m("defaultVectorBasemap")],C.prototype,"readDefaultVectorBasemap",null),e([c()],C.prototype,"description",void 0),e([c()],C.prototype,"devBasemapGalleryGroupQuery",void 0),e([c()],C.prototype,"eueiEnabled",void 0),e([c({readOnly:!0})],C.prototype,"extraQuery",null),e([c()],C.prototype,"featuredGroups",void 0),e([c()],C.prototype,"featuredItemsGroupQuery",void 0),e([c()],C.prototype,"galleryTemplatesGroupQuery",void 0),e([c()],C.prototype,"layoutGroupQuery",void 0),e([c()],C.prototype,"livingAtlasGroupQuery",void 0),e([c({readOnly:!0})],C.prototype,"hasAPIKey",null),e([c()],C.prototype,"hasCategorySchema",void 0),e([c()],C.prototype,"hasClassificationSchema",void 0),e([c()],C.prototype,"helpBase",void 0),e([c()],C.prototype,"helperServices",void 0),e([c()],C.prototype,"helpMap",void 0),e([c()],C.prototype,"homePageFeaturedContent",void 0),e([c()],C.prototype,"homePageFeaturedContentCount",void 0),e([c()],C.prototype,"httpPort",void 0),e([c()],C.prototype,"httpsPort",void 0),e([c()],C.prototype,"id",void 0),e([c()],C.prototype,"ipCntryCode",void 0),e([c({readOnly:!0})],C.prototype,"isOrganization",null),e([c()],C.prototype,"isPortal",void 0),e([c()],C.prototype,"isReadOnly",void 0),e([c({readOnly:!0})],C.prototype,"itemPageUrl",null),e([c()],C.prototype,"layerTemplatesGroupQuery",void 0),e([c()],C.prototype,"maxTokenExpirationMinutes",void 0),e([c({type:Date})],C.prototype,"modified",void 0),e([c()],C.prototype,"name",void 0),e([c()],C.prototype,"portalHostname",void 0),e([c()],C.prototype,"portalMode",void 0),e([c()],C.prototype,"portalProperties",void 0),e([c()],C.prototype,"region",void 0),e([c()],C.prototype,"recycleBinEnabled",void 0),e([c({readOnly:!0})],C.prototype,"restUrl",null),e([c()],C.prototype,"rotatorPanels",void 0),e([c()],C.prototype,"showHomePageDescription",void 0),e([c()],C.prototype,"sourceJSON",void 0),e([c()],C.prototype,"staticImagesUrl",void 0),e([c({json:{name:"2DStylesGroupQuery"}})],C.prototype,"stylesGroupQuery2d",void 0),e([c({json:{name:"stylesGroupQuery"}})],C.prototype,"stylesGroupQuery3d",void 0),e([c()],C.prototype,"supportsHostedServices",void 0),e([c()],C.prototype,"symbolSetsGroupQuery",void 0),e([c()],C.prototype,"templatesGroupQuery",void 0),e([c()],C.prototype,"thumbnail",void 0),e([c({readOnly:!0})],C.prototype,"thumbnailUrl",null),e([c()],C.prototype,"units",void 0),e([c()],C.prototype,"url",void 0),e([c()],C.prototype,"urlKey",void 0),e([m("urlKey")],C.prototype,"readUrlKey",null),e([c()],C.prototype,"user",void 0),e([m("user")],C.prototype,"readUser",null),e([c()],C.prototype,"use3dBasemaps",void 0),e([c()],C.prototype,"useDefault3dBasemap",void 0),e([c()],C.prototype,"useStandardizedQuery",void 0),e([c()],C.prototype,"useVectorBasemaps",void 0),e([c()],C.prototype,"vectorBasemapGalleryGroupQuery",void 0),C=U=e([f("esri.portal.Portal")],C);const b=new FinalizationRegistry(e=>{e.remove()});function w(e){const t=r;return()=>{const r=e.deref();r&&t.findCredential(r.restUrl)&&r.signIn().catch(()=>{})}}export{C as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../Color.js";import{getMetersPerUnitForSR as t}from"../../core/unitUtils.js";import n from"../../layers/support/Field.js";import{isFunctionRaster as a}from"../../layers/support/rasterDatasets/datasetUtils.js";import r from"../ClassBreaksRenderer.js";import l from"../FlowRenderer.js";import s from"../RasterColormapRenderer.js";import o from"../RasterShadedReliefRenderer.js";import i from"../RasterStretchRenderer.js";import u from"../UniqueValueRenderer.js";import m from"../VectorFieldRenderer.js";import c from"./AuthoringInfo.js";import f from"./ClassBreakInfo.js";import{convertColorRampToColormap as p,predefinedJsonColorRamps as d}from"./colorRampUtils.js";import{isVectorFieldRendererSupported as b,isColormapRendererSupported as h,isUVRendererSupported as g,isClassBreaksSupported as v,isShadedReliefRendererSupported as y,isFlowRendererSupported as w}from"./rasterRendererChecks.js";import C from"./UniqueValueInfo.js";import x from"../visualVariables/ColorVariable.js";import M from"../visualVariables/SizeVariable.js";import R from"../visualVariables/support/ColorStop.js";import j from"../../rest/support/ClassBreaksDefinition.js";import{createGenerateRendererClassBreaks as V}from"../../rest/support/generateRendererUtils.js";import T from"../../rest/support/MultipartColorRamp.js";import S from"../../symbols/SimpleFillSymbol.js";const I=.25,k=T.fromJSON({type:"multipart",colorRamps:[{fromColor:[0,0,255],toColor:[0,255,255]},{fromColor:[0,255,255],toColor:[255,255,0]},{fromColor:[255,255,0],toColor:[255,0,0]}]}),F=T.fromJSON(d[0]),L=new Set(["scientific","standard-time","vector-uv","vector-magdir","vector-u","vector-v","vector-magnitude","vector-direction"]);function q(e){return e.presetRenderers?.find(({method:t,value:n})=>"raster-function-template"===t?n===e.rasterFunctionName:"variable"===t&&n===e.variableName)}function B(e,t){const{attributeTable:n,colormap:a}=e;if(b(e)){const t=$(e);if(null!=t)return t}if(t?.rasterFunctionColorRamp){const n=U(e,t);return n.colorRamp=t.rasterFunctionColorRamp,n}if(null!=a){const t=K(e);if(null!=t)return t}if(null!=n){const t=P(e);if(null!=t)return t}return U(e,t)}function E(e,t=!1){const n=["raster-stretch"];return h(e,t)&&n.push("raster-colormap"),g(e)&&n.push("unique-value"),v(e,t)&&n.push("class-breaks"),y(e)&&n.push("raster-shaded-relief"),b(e)&&n.push("vector-field"),w(e)&&n.push("flow"),n}function z(e){return a(e)&&"Colormap"===e.rasterFunction.functionName?e.rasterFunction.colorRamp:void 0}function N(e,t,n){const a=["nearest","bilinear","cubic","majority"],r=n?.toLowerCase().replace("bicubic","cubic"),l=a.find(e=>e===r);if("Map"===t)return l??"bilinear";if("standard-time"===e.dataType)return l??"nearest";return"thematic"===e.dataType||e.attributeTable||e.colormap?"nearest"===l||"majority"===l?l:"nearest":l??"bilinear"}function U(e,t){e=W(e,t?.variableName);const{bandCount:n}=e;let{bandIds:a,stretchType:r}=t||{};a?.some(e=>e>=n)&&(a=null);let l=e.statistics,s=e.histograms;n>1?(a=a?.length?a:D(e),l=null==l?null:a?.map(e=>l[e]),s=null==s?null:a?.map(e=>s[e])):a=[0],null==r&&(r=J(e)),t?.includeStatisticsInStretch&&("percent-clip"===r||"histogram-equalization"===r)&&e.statistics?.length&&(r="min-max");let o=!1;switch(r){case"none":o=!1;break;case"percent-clip":o=!s?.length;break;default:o=!l?.length}const{dataType:u}=e,m=1===a?.length&&L.has(u)?k:null,c=new i({stretchType:r,dynamicRangeAdjustment:o,colorRamp:m,outputMin:0,outputMax:255,gamma:1===a?.length?[1]:[1,1,1],useGamma:!1});return"percent-clip"===r?c.maxPercent=c.minPercent=I:"standard-deviation"===r&&(c.numberOfStandardDeviations=2),o||null==e.multidimensionalInfo&&!t?.includeStatisticsInStretch||("percent-clip"===r?c.histograms=s:"min-max"!==r&&"standard-deviation"!==r||(c.customStatistics=l?.map(e=>({...e})))),c}function W(e,t){const{multidimensionalInfo:n}=e;if(!t||!n)return e;const a=n.variables.find(e=>e.name===t);if(!a)return e;if(e=e.clone(),a){const{statistics:t,histograms:n}=a;t?.length&&(e.statistics=t.map(e=>({min:e.min,max:e.max,avg:e.avg,stddev:e.stddev}))),n?.length&&(e.histograms=n)}return e}function D(e){const t=e.bandCount;if(1===t)return null;if(2===t)return[0];const{bandInfos:n}=e;let a;if(n.length===t){const{red:e,green:t,blue:r,nir:l}=A(n);null!=e&&null!=t&&null!=r?a=[e,t,r]:null!=l&&null!=e&&null!=t&&(a=[l,e,t])}return!a&&t>=3&&(a=[0,1,2]),a}function O(e,t){const n=e.bandInfos.map(({name:e})=>e);return t?.length?t.map(e=>n[e]):n}function A(e){const t={};for(let n=0;n<e.length;n++){const a=e[n],r=a.name.toLowerCase();if("red"===r)t.red=n;else if("green"===r)t.green=n;else if("blue"===r)t.blue=n;else if("nearinfrared"===r||"nearinfrared_1"===r||"nir"===r)t.nir=n;else if(a.maxWavelength&&a.minWavelength){const e=a.minWavelength,r=a.maxWavelength;null==t.blue&&e>=410&&e<=480&&r>=480&&r<=540?t.blue=n:null==t.green&&e>=490&&e<=560&&r>=560&&r<=610?t.green=n:null==t.red&&e>=595&&e<=670&&r>=660&&r<=730?t.red=n:null==t.nir&&e>=700&&e<=860&&r>=800&&r<=950&&(t.nir=n)}}return t}function J(e){let t="percent-clip";const{pixelType:n,dataType:a,histograms:r,statistics:l,multidimensionalInfo:s}=e,o=L.has(a)||"generic"===a&&null!=s;return"u8"!==n||"processed"!==a&&null!=r&&null!=l?"u8"===n||"elevation"===a||o?t="min-max":null!=r?t="percent-clip":null!=l&&(t="min-max"):t="none",t}function P(t,n,a,r){if(!g(t,n))return null;const{attributeTable:l,statistics:s}=t,o=G(l,n),i=H(l,"red"),m=H(l,"green"),f=H(l,"blue"),d=new c,b=[],h=new Set,v=!!(i&&m&&f);if(null!=l)l.features.forEach(t=>{const n=t.attributes[o.name];if(!h.has(t.attributes[o.name])&&null!=n){h.add(n);const a=v&&("single"===i.type||"double"===i.type)&&("single"===m.type||"double"===m.type)&&("single"===f.type||"double"===f.type)&&!l.features.some(e=>e.attributes[i.name]>1||e.attributes[m.name]>1||e.attributes[f.name]>1),r=a?255:1;b.push(new C({value:t.attributes[o.name],label:t.attributes[o.name]+"",symbol:new S({style:"solid",outline:null,color:new e(v?[t.attributes[i.name]*r,t.attributes[m.name]*r,t.attributes[f.name]*r,1]:[0,0,0,0])})}))}});else if(s?.[0])for(let u=s[0].min;u<=s[0].max;u++)b.push(new C({value:u,label:u.toString(),symbol:new S({style:"solid",outline:null,color:new e([0,0,0,0])})}));if(b.sort((e,t)=>e.value&&"string"==typeof e.value.valueOf()?0:e.value>t.value?1:-1),!v){const t=p(F,{numColors:b.length});b.forEach((n,a)=>n.symbol.color=new e(t[a].slice(1,4))),d.colorRamp=F}if(a||r){const t=a||p(r,{numColors:b.length}).map(e=>e.slice(1));b.forEach((n,a)=>n.symbol.color=new e(t[a])),d.colorRamp=r}return new u({field:o.name,uniqueValueInfos:b,authoringInfo:d})}function G(e,t,a){let r;return null!=e?(r=t?e.fields.find(e=>t.toLowerCase()===e.name.toLowerCase()):_(e.fields),r||(a||(r=e.fields.find(e=>"string"===e.type)),r||(r=H(e,"value")))):r=new n({name:"value"}),r}function _(e){let t;for(let n=0;n<e.length;n++){const a=e[n].name.toLowerCase();if("string"===e[n].type){if(a.startsWith("class")){t=e[n];break}null==t&&(a.endsWith("name")||a.endsWith("type"))&&(t=e[n])}}return t}function H(e,t){return null==e?null:e.fields.find(e=>e.name.toLowerCase()===t)}function K(e){if(!h(e))return null;let t;const{attributeTable:n,colormap:a}=e;if(null!=n){const e=H(n,"value"),a=G(n,null,!0);"string"===a.type&&(t={},n.features.forEach(n=>{const r=n.attributes;t[r[e.name]]=a?r[a.name]:r[e.name]}))}return s.createFromColormap(a,t)}function Q(e,n="traditional"){if(!y(e))return null;const{extent:a}=e,r=a.width*t(a.spatialReference);return new o({hillshadeType:n,scalingType:r>5e6?"adjusted":"none"})}function X(e,t){e=W(e,t?.variableName);const{attributeTable:n}=e;if(!v(e))return null;const a=null!=e.histograms?e.histograms[0]:null,l=null!=t?.numClasses&&isFinite(t?.numClasses)?t.numClasses:5,s=new c({classificationMethod:t?.classificationMethod,colorRamp:t?.colorRamp});let o=t?.field||"value";const i=[],u=[],m=1e3,d=null!=n,b=d&&n.fields.find(e=>"count"===e.name.toLowerCase()),h=d?n.fields.find(e=>e.name.toLowerCase()===o.toLowerCase()):void 0;if(h&&d){o=h.name;const e=n.features.length;let t=0;n.features.forEach(n=>t+=(b?n.attributes[b.name]:50)/e),n.features.forEach(n=>{const a=n.attributes[h.name],r=b?n.attributes[b.name]:50;if(r>0){u.push(r);const n=Math.max(1,Math.round(r/e/t*m));for(let e=0;e<n;e++)i.push(a)}})}else{const{pixelType:t}=e,r=(a.max-a.min)/a.size,l=t.includes("s")||t.includes("u"),s=l&&1===r?Math.floor(a.min+.5):a.min,o=l&&1===r?Math.floor(a.max-.5):a.max,c=a.size;let f,p=0;a.counts.forEach(e=>p+=e/c),a.counts.forEach((e,t)=>{if(e>0){u.push(e);const l=Math.max(1,Math.round(e/c/p*m));f=d?n.features[t].attributes[h.name]:0===t?s:t===c-1?o:a.min+r*(t+.5);for(let e=0;e<l;e++)i.push(f)}})}const g=t?.classificationMethod||"natural-breaks";let y=t?.definedInterval;"defined-interval"!==g||y||(y=Y(e,h,l));const w=V({values:i,valueFrequency:u,normalizationTotal:null,definition:new j({classificationMethod:g,breakCount:l,definedInterval:y})});let C=t?.colors;if(!C){const e=t?.colorRamp||k;s.colorRamp=e;const n=p(e,{numColors:w.classBreaks.length,interpolateAlpha:!0});C=n.map(e=>e.slice(1))}const x=w.classBreaks.map((e,t)=>new f({minValue:e.minValue,maxValue:e.maxValue,label:e.label,symbol:new S({color:C[t]})}));return new r({field:o,classBreakInfos:x,authoringInfo:s})}function Y(e,t,n){let a=0,r=0;if(null!=e.attributeTable){const n=e.attributeTable;a=r=n.features[0].attributes[t.name],n.features.forEach(e=>{const n=e.attributes[t.name];n<a&&(a=n),n>r&&(r=n)})}else if(null!=e.histograms){const t=e.histograms;a=t[0].min,r=t[0].max}return(r-a)/n}const Z=new Map([["m/s","meter-per-second"],["km/h","kilometer-per-hour"],["knots","knots"],["ft/s","feet-per-second"],["mph","mile-per-hour"]]);function $(e){if(!b(e))return null;let t;if(null!=e.statistics&&e.statistics.length&&("vector-magdir"===e.dataType||"vector-uv"===e.dataType)){const{minMagnitude:n,maxMagnitude:a}=ae(e.dataType,e.statistics);t=[new M({field:"Magnitude",minSize:10,maxSize:40,minDataValue:n,maxDataValue:a})]}const n=null!=e.multidimensionalInfo?Z.get(e.multidimensionalInfo.variables[0].unit):void 0,a=new m({visualVariables:t,inputUnit:n,rotationType:"geographic"});return a.visualVariables=[...a.sizeVariables,...a.rotationVariables],a}function ee(e){return{color:e.symbolLayers[0].material?.color,type:"esriSFS",style:"esriSFSSolid"}}function te(e){if("uniqueValue"===e.type){const t=e.uniqueValueInfos,n=t?.[0].symbol;return n?.symbolLayers?.length&&(e.uniqueValueInfos=t?.map(e=>({value:e.value,label:e.label,symbol:e.symbol?ee(e.symbol):null}))),e}if("classBreaks"===e.type){const t=e.classBreakInfos,n=t[0].symbol;return n?.symbolLayers?.length&&(e.classBreakInfos=t.map(e=>({classMinValue:e.classMinValue,classMaxValue:e.classMaxValue,label:e.label,symbol:e.symbol?ee(e.symbol):null}))),e}return e}function ne(t){if(!w(t))return null;let n;if(null!=t.statistics&&t.statistics.length>0&&("vector-magdir"===t.dataType||"vector-uv"===t.dataType)){const{minMagnitude:a,maxMagnitude:r}=ae(t.dataType,t.statistics);n=[new x({field:"Magnitude",stops:[new R({value:a,color:new e("#1020c0")}),new R({value:r,color:new e("#c02010")})]})]}return new l({visualVariables:n})}function ae(e,t){let n,a;if("vector-magdir"===e)n=t[0].min,a=t[0].max;else{const e=t[0].min,r=t[0].max,l=t[1].min,s=t[1].max;n=0,a=Math.max(Math.abs(e),Math.abs(l),Math.abs(r),Math.abs(s))}return{minMagnitude:n,maxMagnitude:a}}export{X as createClassBreaksRenderer,K as createColormapRenderer,B as createDefaultRenderer,ne as createFlowRenderer,Q as createShadedReliefRenderer,U as createStretchRenderer,P as createUVRenderer,$ as createVectorFieldRenderer,ae as estimateMagnitudeRange,O as getBandNames,G as getClassField,D as getDefaultBandCombination,N as getDefaultInterpolation,Y as getDefinedInterval,H as getField,z as getFunctionColorRamp,E as getSupportedRendererTypes,W as getVariableRasterInfo,A as getWellKnownBandIndexes,q as matchPresetRenderer,te as normalizeRendererJSON};
5
+ import e from"../../Color.js";import{getMetersPerUnitForSR as t}from"../../core/unitUtils.js";import n from"../../layers/support/Field.js";import{isFunctionRaster as a}from"../../layers/support/rasterDatasets/datasetUtils.js";import r from"../ClassBreaksRenderer.js";import l from"../FlowRenderer.js";import s from"../RasterColormapRenderer.js";import o from"../RasterShadedReliefRenderer.js";import i from"../RasterStretchRenderer.js";import u from"../UniqueValueRenderer.js";import m from"../VectorFieldRenderer.js";import c from"./AuthoringInfo.js";import f from"./ClassBreakInfo.js";import{convertColorRampToColormap as p,predefinedJsonColorRamps as d}from"./colorRampUtils.js";import{isVectorFieldRendererSupported as b,isColormapRendererSupported as h,isUVRendererSupported as g,isClassBreaksSupported as v,isShadedReliefRendererSupported as y,isFlowRendererSupported as w}from"./rasterRendererChecks.js";import C from"./UniqueValueInfo.js";import x from"../visualVariables/ColorVariable.js";import M from"../visualVariables/SizeVariable.js";import R from"../visualVariables/support/ColorStop.js";import j from"../../rest/support/ClassBreaksDefinition.js";import{createGenerateRendererClassBreaks as V}from"../../rest/support/generateRendererUtils.js";import T from"../../rest/support/MultipartColorRamp.js";import S from"../../symbols/SimpleFillSymbol.js";const I=.25,k=T.fromJSON({type:"multipart",colorRamps:[{fromColor:[0,0,255],toColor:[0,255,255]},{fromColor:[0,255,255],toColor:[255,255,0]},{fromColor:[255,255,0],toColor:[255,0,0]}]}),F=T.fromJSON(d[0]),L=new Set(["scientific","standard-time","vector-uv","vector-magdir","vector-u","vector-v","vector-magnitude","vector-direction"]);function q(e){return e.presetRenderers?.find(({method:t,value:n})=>"raster-function-template"===t?n===e.rasterFunctionName:"variable"===t&&n===e.variableName)}function B(e,t){const{attributeTable:n,colormap:a}=e;if(b(e)){const t=te(e);if(null!=t)return t}if(t?.rasterFunctionColorRamp){const n=U(e,t);return n.colorRamp=t.rasterFunctionColorRamp,n}if(null!=a){const t=X(e);if(null!=t)return t}if(null!=n){const t=_(e);if(null!=t)return t}return U(e,t)}function E(e,t=!1){const n=["raster-stretch"];return h(e,t)&&n.push("raster-colormap"),g(e)&&n.push("unique-value"),v(e,t)&&n.push("class-breaks"),y(e)&&n.push("raster-shaded-relief"),b(e)&&n.push("vector-field"),w(e)&&n.push("flow"),n}function z(e){return a(e)&&"Colormap"===e.rasterFunction.functionName?e.rasterFunction.colorRamp:void 0}function N(e,t,n){const a=["nearest","bilinear","cubic","majority"],r=n?.toLowerCase().replace("bicubic","cubic"),l=a.find(e=>e===r);if("Map"===t)return l??"bilinear";if("standard-time"===e.dataType)return l??"nearest";return"thematic"===e.dataType||e.attributeTable||e.colormap?"nearest"===l||"majority"===l?l:"nearest":l??"bilinear"}function U(e,t){e=D(e,t?.variableName);const{bandCount:n}=e;let{bandIds:a,stretchType:r}=t||{};a?.some(e=>e>=n)&&(a=null);let l=e.statistics,s=e.histograms;n>1?(a=a?.length?a:W(e),l=null==l?null:a?.map(e=>l[e]),s=null==s?null:a?.map(e=>s[e])):a=[0],null==r&&(r=G(e)),t?.includeStatisticsInStretch&&("percent-clip"===r||"histogram-equalization"===r)&&e.statistics?.length&&(r="min-max");let o=!1;switch(r){case"none":o=!1;break;case"percent-clip":o=!s?.length;break;default:o=!l?.length}const{dataType:u}=e,m=1===a?.length&&L.has(u)?k:null,c=new i({stretchType:r,dynamicRangeAdjustment:o,colorRamp:m,outputMin:0,outputMax:255,gamma:1===a?.length?[1]:[1,1,1],useGamma:!1});return"percent-clip"===r?c.maxPercent=c.minPercent=I:"standard-deviation"===r&&(c.numberOfStandardDeviations=2),o||null==e.multidimensionalInfo&&!t?.includeStatisticsInStretch||("percent-clip"===r?c.histograms=s:"min-max"!==r&&"standard-deviation"!==r||(c.customStatistics=l?.map(e=>({...e})))),c}function D(e,t){const{multidimensionalInfo:n}=e;if(!t||!n)return e;const a=n.variables.find(e=>e.name===t);if(!a)return e;if(e=e.clone(),a){const{statistics:t,histograms:n}=a;t?.length&&(e.statistics=t.map(e=>({min:e.min,max:e.max,avg:e.avg,stddev:e.stddev}))),n?.length&&(e.histograms=n)}return e}function W(e){const t=e.bandCount;if(1===t)return null;if(2===t)return[0];const{bandInfos:n}=e;let a;if(n.length===t){const{red:e,green:t,blue:r,nir:l}=A(n);null!=e&&null!=t&&null!=r?a=[e,t,r]:null!=l&&null!=e&&null!=t&&(a=[l,e,t])}return!a&&t>=3&&(a=[0,1,2]),a}function O(e,t){const n=e.bandInfos.map(({name:e})=>e);return t?.length?t.map(e=>n[e]):n}function A(e){const t={};for(let n=0;n<e.length;n++){const a=e[n].name.toLowerCase();"red"===a?t.red=n:"green"===a?t.green=n:"blue"===a?t.blue=n:"nearinfrared"!==a&&"nearinfrared_1"!==a&&"nir"!==a||(t.nir=n)}if(null==t.blue||null==t.green||null==t.red||null==t.nir){const n=P(e);if(t.blue??=J(n,480),t.green??=J(n,550),t.red??=J(n,660),null==t.nir){const a=P(e,800);t.nir=J(a,810)??J(n,810)}}return t}function J(e,t,n=60){let a,r=n;for(const l of e){const e=Math.abs(l.wavelength-t);e<=r&&(r=e,a=l.index)}return a}function P(e,t){return e.map(({name:e,minWavelength:n,maxWavelength:a},r)=>{if(/thermal/i.test(e)||/pan/i.test(e))return null;if(null!=t&&null!=a&&a<t)return null;return{wavelength:null!=n&&null!=a?(n+a)/2:n??a??0,index:r}}).filter(e=>null!=e)}function G(e){let t="percent-clip";const{pixelType:n,dataType:a,histograms:r,statistics:l,multidimensionalInfo:s}=e,o=L.has(a)||"generic"===a&&null!=s;return"u8"!==n||"processed"!==a&&null!=r&&null!=l?"u8"===n||"elevation"===a||o?t="min-max":null!=r?t="percent-clip":null!=l&&(t="min-max"):t="none",t}function _(t,n,a,r){if(!g(t,n))return null;const{attributeTable:l,statistics:s}=t,o=H(l,n),i=Q(l,"red"),m=Q(l,"green"),f=Q(l,"blue"),d=new c,b=[],h=new Set,v=!!(i&&m&&f);if(null!=l)l.features.forEach(t=>{const n=t.attributes[o.name];if(!h.has(t.attributes[o.name])&&null!=n){h.add(n);const a=v&&("single"===i.type||"double"===i.type)&&("single"===m.type||"double"===m.type)&&("single"===f.type||"double"===f.type)&&!l.features.some(e=>e.attributes[i.name]>1||e.attributes[m.name]>1||e.attributes[f.name]>1),r=a?255:1;b.push(new C({value:t.attributes[o.name],label:t.attributes[o.name]+"",symbol:new S({style:"solid",outline:null,color:new e(v?[t.attributes[i.name]*r,t.attributes[m.name]*r,t.attributes[f.name]*r,1]:[0,0,0,0])})}))}});else if(s?.[0])for(let u=s[0].min;u<=s[0].max;u++)b.push(new C({value:u,label:u.toString(),symbol:new S({style:"solid",outline:null,color:new e([0,0,0,0])})}));if(b.sort((e,t)=>e.value&&"string"==typeof e.value.valueOf()?0:e.value>t.value?1:-1),!v){const t=p(F,{numColors:b.length});b.forEach((n,a)=>n.symbol.color=new e(t[a].slice(1,4))),d.colorRamp=F}if(a||r){const t=a||p(r,{numColors:b.length}).map(e=>e.slice(1));b.forEach((n,a)=>n.symbol.color=new e(t[a])),d.colorRamp=r}return new u({field:o.name,uniqueValueInfos:b,authoringInfo:d})}function H(e,t,a){let r;return null!=e?(r=t?e.fields.find(e=>t.toLowerCase()===e.name.toLowerCase()):K(e.fields),r||(a||(r=e.fields.find(e=>"string"===e.type)),r||(r=Q(e,"value")))):r=new n({name:"value"}),r}function K(e){let t;for(let n=0;n<e.length;n++){const a=e[n].name.toLowerCase();if("string"===e[n].type){if(a.startsWith("class")){t=e[n];break}null==t&&(a.endsWith("name")||a.endsWith("type"))&&(t=e[n])}}return t}function Q(e,t){return null==e?null:e.fields.find(e=>e.name.toLowerCase()===t)}function X(e){if(!h(e))return null;let t;const{attributeTable:n,colormap:a}=e;if(null!=n){const e=Q(n,"value"),a=H(n,null,!0);"string"===a.type&&(t={},n.features.forEach(n=>{const r=n.attributes;t[r[e.name]]=a?r[a.name]:r[e.name]}))}return s.createFromColormap(a,t)}function Y(e,n="traditional"){if(!y(e))return null;const{extent:a}=e,r=a.width*t(a.spatialReference);return new o({hillshadeType:n,scalingType:r>5e6?"adjusted":"none"})}function Z(e,t){e=D(e,t?.variableName);const{attributeTable:n}=e;if(!v(e))return null;const a=null!=e.histograms?e.histograms[0]:null,l=null!=t?.numClasses&&isFinite(t?.numClasses)?t.numClasses:5,s=new c({classificationMethod:t?.classificationMethod,colorRamp:t?.colorRamp});let o=t?.field||"value";const i=[],u=[],m=1e3,d=null!=n,b=d&&n.fields.find(e=>"count"===e.name.toLowerCase()),h=d?n.fields.find(e=>e.name.toLowerCase()===o.toLowerCase()):void 0;if(h&&d){o=h.name;const e=n.features.length;let t=0;n.features.forEach(n=>t+=(b?n.attributes[b.name]:50)/e),n.features.forEach(n=>{const a=n.attributes[h.name],r=b?n.attributes[b.name]:50;if(r>0){u.push(r);const n=Math.max(1,Math.round(r/e/t*m));for(let e=0;e<n;e++)i.push(a)}})}else{const{pixelType:t}=e,r=(a.max-a.min)/a.size,l=t.includes("s")||t.includes("u"),s=l&&1===r?Math.floor(a.min+.5):a.min,o=l&&1===r?Math.floor(a.max-.5):a.max,c=a.size;let f,p=0;a.counts.forEach(e=>p+=e/c),a.counts.forEach((e,t)=>{if(e>0){u.push(e);const l=Math.max(1,Math.round(e/c/p*m));f=d?n.features[t].attributes[h.name]:0===t?s:t===c-1?o:a.min+r*(t+.5);for(let e=0;e<l;e++)i.push(f)}})}const g=t?.classificationMethod||"natural-breaks";let y=t?.definedInterval;"defined-interval"!==g||y||(y=$(e,h,l));const w=V({values:i,valueFrequency:u,normalizationTotal:null,definition:new j({classificationMethod:g,breakCount:l,definedInterval:y})});let C=t?.colors;if(!C){const e=t?.colorRamp||k;s.colorRamp=e;const n=p(e,{numColors:w.classBreaks.length,interpolateAlpha:!0});C=n.map(e=>e.slice(1))}const x=w.classBreaks.map((e,t)=>new f({minValue:e.minValue,maxValue:e.maxValue,label:e.label,symbol:new S({color:C[t]})}));return new r({field:o,classBreakInfos:x,authoringInfo:s})}function $(e,t,n){let a=0,r=0;if(null!=e.attributeTable){const n=e.attributeTable;a=r=n.features[0].attributes[t.name],n.features.forEach(e=>{const n=e.attributes[t.name];n<a&&(a=n),n>r&&(r=n)})}else if(null!=e.histograms){const t=e.histograms;a=t[0].min,r=t[0].max}return(r-a)/n}const ee=new Map([["m/s","meter-per-second"],["km/h","kilometer-per-hour"],["knots","knots"],["ft/s","feet-per-second"],["mph","mile-per-hour"]]);function te(e){if(!b(e))return null;let t;if(null!=e.statistics&&e.statistics.length&&("vector-magdir"===e.dataType||"vector-uv"===e.dataType)){const{minMagnitude:n,maxMagnitude:a}=le(e.dataType,e.statistics);t=[new M({field:"Magnitude",minSize:10,maxSize:40,minDataValue:n,maxDataValue:a})]}const n=null!=e.multidimensionalInfo?ee.get(e.multidimensionalInfo.variables[0].unit):void 0,a=new m({visualVariables:t,inputUnit:n,rotationType:"geographic"});return a.visualVariables=[...a.sizeVariables,...a.rotationVariables],a}function ne(e){return{color:e.symbolLayers[0].material?.color,type:"esriSFS",style:"esriSFSSolid"}}function ae(e){if("uniqueValue"===e.type){const t=e.uniqueValueInfos,n=t?.[0].symbol;return n?.symbolLayers?.length&&(e.uniqueValueInfos=t?.map(e=>({value:e.value,label:e.label,symbol:e.symbol?ne(e.symbol):null}))),e}if("classBreaks"===e.type){const t=e.classBreakInfos,n=t[0].symbol;return n?.symbolLayers?.length&&(e.classBreakInfos=t.map(e=>({classMinValue:e.classMinValue,classMaxValue:e.classMaxValue,label:e.label,symbol:e.symbol?ne(e.symbol):null}))),e}return e}function re(t){if(!w(t))return null;let n;if(null!=t.statistics&&t.statistics.length>0&&("vector-magdir"===t.dataType||"vector-uv"===t.dataType)){const{minMagnitude:a,maxMagnitude:r}=le(t.dataType,t.statistics);n=[new x({field:"Magnitude",stops:[new R({value:a,color:new e("#1020c0")}),new R({value:r,color:new e("#c02010")})]})]}return new l({visualVariables:n})}function le(e,t){let n,a;if("vector-magdir"===e)n=t[0].min,a=t[0].max;else{const e=t[0].min,r=t[0].max,l=t[1].min,s=t[1].max;n=0,a=Math.max(Math.abs(e),Math.abs(l),Math.abs(r),Math.abs(s))}return{minMagnitude:n,maxMagnitude:a}}export{Z as createClassBreaksRenderer,X as createColormapRenderer,B as createDefaultRenderer,re as createFlowRenderer,Y as createShadedReliefRenderer,U as createStretchRenderer,_ as createUVRenderer,te as createVectorFieldRenderer,le as estimateMagnitudeRange,O as getBandNames,H as getClassField,W as getDefaultBandCombination,N as getDefaultInterpolation,$ as getDefinedInterval,Q as getField,z as getFunctionColorRamp,E as getSupportedRendererTypes,D as getVariableRasterInfo,A as getWellKnownBandIndexes,q as matchPresetRenderer,ae as normalizeRendererJSON};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{unique as e,isSome as l}from"../../core/arrayUtils.js";import t from"../../core/Logger.js";import{getOrCreateMapValue as i}from"../../core/MapUtils.js";import{convertDateFormatToIntlOptions as o,formatDate as a}from"../../intl/date.js";import{isTimeOnlyField as n}from"../../layers/support/fieldUtils.js";import{format as s,round as r}from"./numberUtils.js";import u from"../visualVariables/support/ColorStop.js";import{isAnyDateField as f,formatAnyDate as d}from"../../smartMapping/support/utils.js";import{getColorFromSymbol as p}from"../../symbols/support/utils.js";import{getRampStops as m}from"../../widgets/Legend/support/colorRampUtils.js";import{getHeatmapRampStops as c}from"../../widgets/Legend/support/heatmapRampUtils.js";const y=()=>t.getLogger("esri.renderers.support.utils"),g={lt:"<",gt:">",pct:"%",ld:"–"},h={millisecond:0,second:1,minute:2,hour:3,day:4,month:5,year:6},b={millisecond:"long-month-day-year-long-time",second:"long-month-day-year-long-time",minute:"long-month-day-year-short-time",hour:"long-month-day-year-short-time",day:"long-month-day-year",month:"long-month-day-year",year:"year"},v=o("short-date");async function w(e,l,t){i(e,l,()=>[]).push(...t)}async function x(l){const t=new Map;if(!l)return t;if("visualVariables"in l&&l.visualVariables)for(const e of l.visualVariables)if(D(e)){const l=(await m(e)??[]).map(e=>e.color);await w(t,e.field||e.valueExpression,l)}if("heatmap"===l.type){const e=c(l).map(e=>e.color);await w(t,l.field||l.valueExpression,e)}else if("pie-chart"===l.type){for(const e of l.attributes)await w(t,e.field||e.valueExpression,[e.color]);await w(t,"default",[l?.othersCategory?.color,p(l.backgroundFillSymbol,null)])}else if("dot-density"===l.type){for(const e of l.attributes)await w(t,e.field||e.valueExpression,[e.color]);await w(t,"default",[l.backgroundColor])}else if("unique-value"===l.type)if("predominance"===l.authoringInfo?.type)for(const e of l.uniqueValueInfos??[])await w(t,e.value.toString(),[p(e.symbol,null)]);else{const e=(l.uniqueValueInfos??[]).map(e=>p(e.symbol,null)),{field:i,field2:o,field3:a,valueExpression:n}=l;(i||n)&&await w(t,i||n,e),o&&await w(t,o,e),a&&await w(t,a,e)}else if("class-breaks"===l.type){const e=l.classBreakInfos.map(e=>p(e.symbol,null)),{field:i,valueExpression:o}=l;await w(t,i??o,e)}else"simple"===l.type&&await w(t,"default",[p(l.symbol,null)]);return"defaultSymbol"in l&&l.defaultSymbol&&await w(t,"default",[p(l.defaultSymbol,null)]),t.forEach((l,i)=>{const o=e(l.filter(Boolean),(e,l)=>JSON.stringify(e)===JSON.stringify(l));t.set(i,o)}),t}async function V(e,l,t){const o=i(e,l,()=>new Map);for(const i of t)o.set(i.value,i.color)}async function E(e){const l=new Map;if(!e)return l;if("unique-value"!==e.type||e.authoringInfo?.type)if("class-breaks"===e.type){const t=e.classBreakInfos.map(e=>({value:e.minValue,color:p(e.symbol,null)})).reverse(),{field:i,valueExpression:o}=e;await V(l,i??o,t)}else"simple"===e.type&&await V(l,"default",[{value:"default",color:p(e.symbol,null)}]);else{const t=(e.uniqueValueInfos??[]).map(e=>({value:e.value,color:p(e.symbol,null)})),{field:i,field2:o,field3:a,valueExpression:n,fieldDelimiter:s}=e,r=[i,o,a].filter(Boolean).join(s||"");(r||n)&&await V(l,r||n,t)}if("defaultSymbol"in e&&e.defaultSymbol&&await V(l,"default",[{value:"default",color:p(e.defaultSymbol,null)}]),"visualVariables"in e&&e.visualVariables){const t=e.visualVariables.filter(e=>"color"===e.type);for(const e of t){const t=await m(e)??[];await V(l,e.field||e.valueExpression,t)}}return l}function F(e,l,t){let i="";return 0===l?i=g.lt+" ":l===t&&(i=g.gt+" "),i+e}function z(e){const{values:l,colors:t,labelIndexes:i,isDate:o}=e;return l.map((e,n)=>{let r=null;if(!i||i.includes(n)){const t=o?a(e):s(e);t&&(r=F(t,n,l.length-1))}return new u({value:e,color:t[n],label:r})})}function S(e){let l=e.minValue,t=e.maxValue;const i=e.isFirstBreak?"":g.gt+" ",o="percent-of-total"===e.normalizationType?g.pct:"";return l=null==l?"":s(l),t=null==t?"":s(t),i+l+o+" "+g.ld+" "+t+o}function k(e){const l=e.classBreakInfos,t=e.normalizationType;let i=[];if(l?.length)if("standard-deviation"!==e.classificationMethod)if(e.round){i.push(l[0].minValue);for(const e of l)i.push(e.maxValue);i=r(i),l.forEach((e,l)=>{e.label=S({minValue:0===l?i[0]:i[l],maxValue:i[l+1],isFirstBreak:0===l,normalizationType:t})})}else l.forEach((e,l)=>{e.label=S({minValue:e.minValue,maxValue:e.maxValue,isFirstBreak:0===l,normalizationType:t})});else y().warn("setLabelsForClassBreaks","cannot set labels for class breaks generated using 'standard-deviation' method.")}function j(e){const l=e.map(e=>new Date(e)),t=l.length;let i=1/0,o=null;for(let a=0;a<t-1;a++){const e=l[a];let n=1/0,s=null;for(let i=a+1;i<t;i++){const t=l[i],o=(e.getFullYear()!==t.getFullYear()?"year":e.getMonth()!==t.getMonth()&&"month")||e.getDate()!==t.getDate()&&"day"||e.getHours()!==t.getHours()&&"hour"||e.getMinutes()!==t.getMinutes()&&"minute"||e.getSeconds()!==t.getSeconds()&&"second"||"millisecond",a=h[o];a<n&&(n=a,s=o)}n<i&&(i=n,o=s)}return o}function I(e){const{value:l,domain:t,fieldInfo:i,dateFormatOptions:o}=e;let a=String(l);const r=t&&"codedValues"in t&&t.codedValues?t.getName(l):null;return r?a=r:null!=l&&i&&(f(i)||n(i))?a=d(l,o??{fieldType:i.type}):"number"==typeof l&&(a=s(l)),a}function M(e,l){return"normalizationField"in e&&e.normalizationField?q(e.field,e.normalizationField):"field"in e&&e.field?B(e.field):"valueExpression"in e&&e.valueExpression?T(e.valueExpression,e.valueExpressionTitle,l):null}function B(e){return{type:"field",field:e}}function q(e,l){return{type:"normalized-field",field:e,normalizationField:l}}function T(e,l,t){return{type:"expression",expression:e,title:l,returnType:t}}function U(t,i){const o=[];if("class-breaks"===t.type||"heatmap"===t.type)o.push(M(t,"number"));else if("unique-value"===t.type){const e=t.authoringInfo;if(e&&"relationship"===e.type){if(e.field1&&e.field2){const l=e.field1.field,t=e.field2.field,i=e.field1.normalizationField,a=e.field2.normalizationField;o.push(M({field:l,normalizationField:i})),o.push(M({field:t,normalizationField:a}))}}else{const e=t.uniqueValueInfos?.[0];let l=null;if(e?.value){const t=typeof e.value;"string"!==t&&"number"!==t||(l=t)}o.push(M(t,l)),[t.field2,t.field3].forEach(e=>e&&o.push(B(e)))}}else"attributes"in t&&t.attributes?.forEach(e=>o.push(M(e,"number")));const a=i?i(t):"visualVariables"in t?t.visualVariables:null;return a&&a.forEach(e=>o.push(M(e,"number"))),e(o.filter(l),(e,l)=>"field"===e.type&&"field"===l.type?e.field===l.field:"normalized-field"===e.type&&"normalized-field"===l.type?e.field===l.field&&e.normalizationField===l.normalizationField:"expression"===e.type&&"expression"===l.type&&e.expression===l.expression)}function D(e){return"color"===e.type}export{j as calculateDateFormatInterval,S as createClassBreakLabel,z as createColorStops,I as createUniqueValueLabel,b as dateFormatIntervalOptions,M as getAttribute,U as getAttributes,E as getColorsForRendererValues,x as getColorsFromRenderer,k as setLabelsForClassBreaks,v as timelineDateFormatOptions};
5
+ import{unique as e,isSome as l}from"../../core/arrayUtils.js";import t from"../../core/Logger.js";import{getOrCreateMapValue as i}from"../../core/MapUtils.js";import{convertDateFormatToIntlOptions as o,formatDate as a}from"../../intl/date.js";import{isTimeOnlyField as n}from"../../layers/support/fieldUtils.js";import{format as s,round as r}from"./numberUtils.js";import u from"../visualVariables/support/ColorStop.js";import{isAnyDateField as f,formatAnyDate as d}from"../../smartMapping/support/utils.js";import{getColorFromSymbol as p}from"../../symbols/support/utils.js";import{getRampStops as m}from"../../widgets/Legend/support/colorRampUtils.js";import{getHeatmapRampStops as c}from"../../widgets/Legend/support/heatmapRampUtils.js";const y=()=>t.getLogger("esri.renderers.support.utils"),g={lt:"<",gt:">",pct:"%",ld:"–"},h={millisecond:0,second:1,minute:2,hour:3,day:4,month:5,year:6},b={millisecond:"long-month-day-year-long-time",second:"long-month-day-year-long-time",minute:"long-month-day-year-short-time",hour:"long-month-day-year-short-time",day:"long-month-day-year",month:"long-month-day-year",year:"year"},v=o("short-date");async function w(e,l,t){i(e,l,()=>[]).push(...t)}async function x(l){const t=new Map;if(!l)return t;if("visualVariables"in l&&l.visualVariables)for(const e of l.visualVariables)if(D(e)){const l=(await m(e)??[]).map(e=>e.color);await w(t,e.field||e.valueExpression,l)}if("heatmap"===l.type){const e=c(l).map(e=>e.color);await w(t,l.field||l.valueExpression,e)}else if("pie-chart"===l.type){for(const e of l.attributes)await w(t,e.field||e.valueExpression,[e.color]);await w(t,"default",[l?.othersCategory?.color,p(l.backgroundFillSymbol,null)])}else if("dot-density"===l.type){for(const e of l.attributes)await w(t,e.field||e.valueExpression,[e.color]);await w(t,"default",[l.backgroundColor])}else if("unique-value"===l.type)if("predominance"===l.authoringInfo?.type)for(const e of l.uniqueValueInfos??[])await w(t,e.value.toString(),[p(e.symbol,null)]);else{const e=(l.uniqueValueInfos??[]).map(e=>p(e.symbol,null)),{field:i,field2:o,field3:a,valueExpression:n}=l;(i||n)&&await w(t,i||n,e),o&&await w(t,o,e),a&&await w(t,a,e)}else if("class-breaks"===l.type){const e=l.classBreakInfos.map(e=>p(e.symbol,null)),{field:i,valueExpression:o}=l;await w(t,i??o,e)}else"simple"===l.type&&await w(t,"default",[p(l.symbol,null)]);return"defaultSymbol"in l&&l.defaultSymbol&&await w(t,"default",[p(l.defaultSymbol,null)]),t.forEach((l,i)=>{const o=e(l.filter(Boolean),(e,l)=>JSON.stringify(e)===JSON.stringify(l));t.set(i,o)}),t}async function V(e,l,t){const o=i(e,l,()=>new Map);for(const i of t)o.set(i.value,i.color)}async function E(e){const l=new Map;if(!e)return l;if("unique-value"!==e.type||e.authoringInfo?.type)if("class-breaks"===e.type){const t=e.classBreakInfos.map(e=>({value:e.minValue,color:p(e.symbol,null)})).reverse(),{field:i,valueExpression:o}=e;await V(l,i??o,t)}else"simple"===e.type&&await V(l,"default",[{value:"default",color:p(e.symbol,null)}]);else{const t=(e.uniqueValueInfos??[]).map(e=>({value:e.value,color:p(e.symbol,null)})),{field:i,field2:o,field3:a,valueExpression:n,fieldDelimiter:s}=e,r=[i,o,a].filter(Boolean).join(s||"");(r||n)&&await V(l,r||n,t)}if("defaultSymbol"in e&&e.defaultSymbol&&await V(l,"default",[{value:"default",color:p(e.defaultSymbol,null)}]),"visualVariables"in e&&e.visualVariables){const t=e.visualVariables.filter(e=>"color"===e.type);for(const e of t){const t=await m(e)??[];await V(l,e.field||e.valueExpression,t)}}return l}function F(e,l,t){let i="";return 0===l?i=g.lt+" ":l===t&&(i=g.gt+" "),i+e}function z(e){const{values:l,colors:t,labelIndexes:i,isDate:o}=e;return l.map((e,n)=>{let r=null;if(!i||i.includes(n)){const t=o?a(e):s(e);t&&(r=F(t,n,l.length-1))}return new u({value:e,color:t[n],label:r})})}function S(e){let l=e.minValue,t=e.maxValue;const i=e.isFirstBreak?"":g.gt+" ",o="percent-of-total"===e.normalizationType?g.pct:"";return l=null==l?"":s(l),t=null==t?"":s(t),i+l+o+" "+g.ld+" "+t+o}function k(e){const l=e.classBreakInfos,t=e.normalizationType;let i=[];if(l?.length)if("standard-deviation"!==e.classificationMethod)if(e.round){i.push(l[0].minValue);for(const e of l)i.push(e.maxValue);i=r(i),l.forEach((e,l)=>{e.label=S({minValue:0===l?i[0]:i[l],maxValue:i[l+1],isFirstBreak:0===l,normalizationType:t})})}else l.forEach((e,l)=>{e.label=S({minValue:e.minValue,maxValue:e.maxValue,isFirstBreak:0===l,normalizationType:t})});else y().warn("setLabelsForClassBreaks","cannot set labels for class breaks generated using 'standard-deviation' method.")}function j(e){const l=e.map(e=>new Date(e)),t=l.length;let i=1/0,o=null;for(let a=0;a<t-1;a++){const e=l[a];let n=1/0,s=null;for(let i=a+1;i<t;i++){const t=l[i],o=(e.getFullYear()!==t.getFullYear()?"year":e.getMonth()!==t.getMonth()&&"month")||e.getDate()!==t.getDate()&&"day"||e.getHours()!==t.getHours()&&"hour"||e.getMinutes()!==t.getMinutes()&&"minute"||e.getSeconds()!==t.getSeconds()&&"second"||"millisecond",a=h[o];a<n&&(n=a,s=o)}n<i&&(i=n,o=s)}return o}function I(e){const{value:l,domain:t,fieldInfo:i,dateFormatOptions:o}=e;let a=String(l);const r=t&&"codedValues"in t&&t.codedValues?t.getName(l):null;return r?a=r:null!=l&&i&&(f(i)||n(i))?a=d(l,o??{fieldType:i.type}):"number"==typeof l&&(a=s(l)),a}function M(e,l){return"normalizationField"in e&&e.normalizationField?q(e.field,e.normalizationField):"field"in e&&e.field?B(e.field):"valueExpression"in e&&e.valueExpression?T(e.valueExpression,e.valueExpressionTitle,l):null}function B(e){return{type:"field",field:e}}function q(e,l){return{type:"normalized-field",field:e,normalizationField:l}}function T(e,l,t){return{type:"expression",expression:e,title:l,returnType:t}}function U(t,i){const o=[];if("class-breaks"===t.type||"heatmap"===t.type)o.push(M(t,"number"));else if("unique-value"===t.type){const e=t.authoringInfo;if(e&&"relationship"===e.type){if(e.field1&&e.field2){const l=e.field1.field,t=e.field2.field,i=e.field1.normalizationField,a=e.field2.normalizationField;o.push(M({field:l,normalizationField:i})),o.push(M({field:t,normalizationField:a}))}}else{const e=t.uniqueValueInfos?.[0];let l=null;if(e?.value){const t=typeof e.value;"string"!==t&&"number"!==t||(l=t)}o.push(M(t,l)),[t.field2,t.field3].forEach(e=>e&&o.push(B(e)))}}else"attributes"in t&&t.attributes?.forEach(e=>o.push(M(e,"number")));const a=i?i(t):"visualVariables"in t?t.visualVariables:null;return a?.forEach(e=>o.push(M(e,"number"))),e(o.filter(l),(e,l)=>"field"===e.type&&"field"===l.type?e.field===l.field:"normalized-field"===e.type&&"normalized-field"===l.type?e.field===l.field&&e.normalizationField===l.normalizationField:"expression"===e.type&&"expression"===l.type&&e.expression===l.expression)}function D(e){return"color"===e.type}export{j as calculateDateFormatInterval,S as createClassBreakLabel,z as createColorStops,I as createUniqueValueLabel,b as dateFormatIntervalOptions,M as getAttribute,U as getAttributes,E as getColorsForRendererValues,x as getColorsFromRenderer,k as setLabelsForClassBreaks,v as timelineDateFormatOptions};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import t from"../../config.js";import{id as s}from"../../kernel.js";import r from"../../request.js";import{isSome as i}from"../../core/arrayUtils.js";import a from"../../core/Error.js";import{IdentifiableMixin as o}from"../../core/Identifiable.js";import{JSONSupportMixin as n}from"../../core/JSONSupport.js";import{clone as l}from"../../core/lang.js";import{Loadable as u}from"../../core/Loadable.js";import{throwIfAborted as d,throwIfAbortError as p}from"../../core/promiseUtils.js";import{property as c}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import{reader as m}from"../../core/accessorSupport/decorators/reader.js";import{subclass as y}from"../../core/accessorSupport/decorators/subclass.js";import h from"../../geometry/SpatialReference.js";import{getFeatureJSON as f,getFeatureIds as b,getAttachmentEditsJSON as g,isProtectedOrPrivateVersionError as v,unpackEditResultData as j,createEditedFeatures as S}from"../../layers/graphics/applyEditsUtils.js";import{checkEditingCapabilities as E,normalizeEdits as O,normalizeGeometries as R}from"../../layers/graphics/editingSupport.js";import{emitApplyEditsEvent as A}from"../../layers/mixins/EditBusLayer.js";import{ensureCredentialIfSignedIn as w}from"../../layers/support/featureLayerUtils.js";import{getOwningPortalUrl as F}from"../../layers/support/layerUtils.js";import{getFeatureLayerCapabilities as I}from"../../layers/support/serviceCapabilitiesUtils.js";import U from"../../portal/PortalItem.js";import{getUserPrivileges as C}from"../../portal/support/portalItemUtils.js";import{isSecureProxyService as T}from"../../portal/support/urlUtils.js";import{parseUrl as D,asValidOptions as P,encode as V}from"../utils.js";import{unapplyEditsZUnitScaling as G}from"../query/operations/editsZScale.js";import{readBoolean as k,readNumber as N}from"../support/jsonUtils.js";import{isSafeToEditVersion as L,isVersionInEditSession as M,currentSessionId as _}from"../../versionManagement/support/versionManagementUtils.js";function x(e,t){const s=t.id;return{id:s,name:t.name,url:`${e}/${s}`,type:t.type||"Table"}}function Q(e){return{data:J(e),sync:B(e),operations:q(e.capabilities,e),query:W(e),editing:H(e)}}function J(e){return{isDataVersioned:k(e,"hasVersionedData",!1),isDataBranchVersioned:k(e,"hasBranchVersionedData",!1)}}function q(e,t){const s=e?e.toLowerCase().split(",").map(e=>e.trim()):[],r=s.includes("query"),i=s.includes("editing")&&!t.datesInUnknownTimezone;let a=i&&s.includes("create"),o=i&&s.includes("delete"),n=i&&s.includes("update");return i&&!(a||o||n)&&(a=o=n=!0),{supportsAdd:a,supportsDelete:o,supportsEditing:i,supportsChangeTracking:s.includes("changetracking"),supportsQuery:r,supportsQueryDataElements:k(t,"supportsQueryDataElements",!1),supportsQueryDomains:k(t,"supportsQueryDomains",!1),supportsQueryContingentValues:k(t,"supportsQueryContingentValues",!1),supportsSync:s.includes("sync"),supportsUpdate:n}}function W(e){return{maxRecordCountFactor:N(e,"maxRecordCountFactor",void 0),maxRecordCount:N(e,"maxRecordCount",void 0)}}function H(e){const t=e?.advancedEditingCapabilities;return{supportsAsyncApplyEdits:k(t,"supportsAsyncApplyEdits",!1),supportsGlobalId:k(e,"supportsApplyEditsWithGlobalIds",!1),supportsReturnServiceEditsInSourceSpatialReference:k(t,"supportsReturnServiceEditsInSourceSR",!1),supportsSharedTemplates:k(e,"supportsSharedTemplates",!1)||k(e,"hasSharedTemplates",!1),supportsSplit:k(t,"supportsSplit",!1)}}function B(e){const t=e?.syncCapabilities,s=t?.supportedSyncDataOptions;return{supportsAsync:k(t,"supportsAsync",!1),supportedSyncDataOptions:{annotations:!(1&~s),dimensions:!(2&~s),contingentValues:!(4&~s),attributeRules:!(8&~s),utilityNetworkSystem:!(16&~s),annotationFullModel:!(32&~s),include3DObjects:!(64&~s),utilityNetworkMissingLayers:!(128&~s),preserveTrueCurves:!(256&~s)}}}let $=class extends(n(o(u))){constructor(e){super(e),this.url=null,this.sourceJSON=null,this.userHasFullEditingPrivileges=!1,this.userHasUpdateItemPrivileges=!1,this.userTypeExtensions=[],this.layerInfos=null,this.tableInfos=null,this.capabilities=null}read(e,t){this.sourceJSON=e,super.read(e,t)}get utilityNetworkUrl(){if(this.sourceJSON)for(const e of this.sourceJSON.layers)if("Utility Network Layer"===e.type)return`${this.url}/${e.id}`;return null}get versionManagementServiceUrl(){return this.sourceJSON?.hasBranchVersionedData&&!T(this.url)?this.url.replace(/\/FeatureServer/i,"/VersionManagementServer"):null}readLayerInfos(e,t){return(t.layers||[]).map(e=>{const{type:t,geometryType:s}=e;return{...x(this.url,e),type:t||"Feature Layer",geometryType:s}})}readTableInfos(e,t){return(t.tables||[]).map(e=>x(this.url,e))}readCapabilities(e,t){return Q(t)}get effectiveCapabilities(){const e=this.capabilities;if(!e)return null;const t=l(e),{operations:s}=t;return this.userHasUpdateItemPrivileges?(s.supportsAdd=s.supportsDelete=s.supportsEditing=s.supportsQuery=s.supportsUpdate=!0,t):(this.userHasFullEditingPrivileges&&s.supportsEditing&&(s.supportsAdd=s.supportsDelete=s.supportsUpdate=!0),t)}get loaded(){return super.loaded}load(e){return this.addResolvingPromise(this._fetchService(this.url,e).then(()=>this._setUserPrivileges(e))),Promise.resolve(this)}async fetchAllLayersAndTables(e){return await this.load(e),this._fetchLayersAndTablesPromise||=this._fetchLayersAndTables(this.url),d(e),this._fetchLayersAndTablesPromise}async applyEdits(e,t){let s=null;try{const{results:r,edits:i,editedFeatures:a}=await this._internalApplyEdits(e,t),o=e=>e.filter(e=>!e.error).map(l);let n=0;return r.map(e=>{s=A(this.url,e.id,t?.gdbVersion,!0);const r={edits:i[n],addedFeatures:o(e.addFeatureResults),updatedFeatures:o(e.updateFeatureResults),deletedFeatures:o(e.deleteFeatureResults),addedAttachments:o(e.addAttachmentResults),updatedAttachments:o(e.updateAttachmentResults),deletedAttachments:o(e.deleteAttachmentResults),exceededTransferLimit:!1,historicMoment:e.editMoment?new Date(e.editMoment):null};n+=1,a.length>0&&(r.editedFeatures=a),s.resolve(r),s=null}),r}catch(r){throw s&&s.reject(r),r}}async _setUserPrivileges(e){if(t.userPrivilegesApplied)try{const{features:{fullEdit:t},content:{updateItem:s}}=await this._fetchUserPrivileges(this.sourceJSON.serviceItemId,e);this._set("userHasFullEditingPrivileges",t),this._set("userHasUpdateItemPrivileges",s)}catch(s){p(s)}}async _fetchUserPrivileges(e,t){const r=!0,i=!1,a=!1;if(!e)return{features:{edit:r,fullEdit:i},content:{updateItem:a}};let o,n,l;try{o=await F(this.url,t)}catch(u){p(u)}try{const e=null!=t?t.signal:null;n=await(s?.getCredential(`${o}/sharing`,{prompt:!1,signal:e}))}catch(u){p(u)}if(!n)return{features:{edit:r,fullEdit:i},content:{updateItem:a}};try{if(l=new U({id:e,portal:{url:o}}),await l.load(t),l.portal.user)return C(l)}catch(u){p(u)}return{features:{edit:r,fullEdit:i},content:{updateItem:a}}}async _internalApplyEdits(e,t){await w(this.url);const s=t?.globalIdUsed??!1,a=h.fromJSON(this.sourceJSON.spatialReference),{edits:o,options:n}=await this._processApplyEditsParams(e,t),l=await Promise.all(o.map(async e=>{const t=e.addFeatures?.map(e=>f({spatialReference:a},e,null))??[],r=(await Promise.all(t)).filter(i),o=r.length>0?r:null,n=e.updateFeatures?.map(e=>f({spatialReference:a},e,null))??[],l=(await Promise.all(n)).filter(i),u=l.length>0?l:null,d=b(e.identifierFields,e.deleteFeatures,s),p=d.length>0?d:null;G(o,u,a);const c=await g(e.identifierFields,e);let m=null;if(c){m={adds:c.adds.length>0?c.adds:void 0,updates:c.updates.length>0?c.updates:void 0,deletes:c.deletes.length>0?c.deletes:void 0}}const y={};return e.deleteAssociations&&(y.deleteAssociations=e.deleteAssociations),e.combineGroupedObjects&&(y.combineGroupedObjects=e.combineGroupedObjects),e.divideGroupedObjects&&(y.divideGroupedObjects=e.divideGroupedObjects),{id:e.id,adds:o,updates:u,deletes:p,attachments:m,...y}})),u={gdbVersion:n?.gdbVersion,rollbackOnFailure:!0,useGlobalIds:s,returnEditMoment:!0,honorSequenceOfEdits:n?.honorSequenceOfEdits,usePreviousEditMoment:n?.usePreviousEditMoment,returnServiceEditsInSourceSR:!1,returnServiceEditsOption:"originalAndCurrentFeatures",async:!1};await L(this.url,t?.gdbVersion,!0);const d=M(this.url,t?.gdbVersion||null);u.edits=JSON.stringify(l);const p=D(this.url),c=P(p.query,{query:V({...u,f:"json"}),method:"post"});let m;d&&(c.authMode="immediate",c.query.sessionId=_);try{m=await r(this.url+"/applyEdits",c)}catch(y){if(!v(y))throw y;c.authMode="immediate",m=await r(this.url+"/applyEdits",c)}return{...z(m),edits:o}}async _processApplyEditsParams(e,t){const s={...t,usingFeatureServiceEndpoint:!0,usingTelecomOperations:e.some(e=>e.deleteAssociations||e.combineGroupedObjects||e.divideGroupedObjects)};return{edits:await Promise.all(e.map(async e=>{const t=this.effectiveCapabilities,r=e&&(e.addFeatures||e.updateFeatures||e.deleteFeatures),i=e&&(e.addAttachments||e.updateAttachments||e.deleteAttachments);if(E(e,t,s,!!r,!!i,"feature-service"),!t.data.isDataVersioned&&s?.gdbVersion)throw new a("feature-service:invalid-parameter","'gdbVersion' is applicable only if the layer supports versioned data. See: 'capabilities.data.isDataVersioned'");const o=O(e,t,"feature-service"),n={};e.deleteAssociations&&(n.deleteAssociations=e.deleteAssociations),e.combineGroupedObjects&&(n.combineGroupedObjects=e.combineGroupedObjects),e.divideGroupedObjects&&(n.divideGroupedObjects=e.divideGroupedObjects);const l=await R(o);return{id:e.id,...l,...n,identifierFields:e.identifierFields}})),options:s}}async _fetchService(e,t){if(this.sourceJSON)return void this.read(this.sourceJSON,{url:D(e)});const s=await r(e,{responseType:"json",query:{f:"json"},...t});this.read(s.data,{url:D(e)})}async _fetchLayersAndTables(e){const t=`${e}/layers`,s=await r(t,{responseType:"json",query:{f:"json"}});return{layers:s.data.layers.map(e=>{const{type:t,geometryType:s}=e,r=x(this.url,e),i=I(e,r.url);return{...r,type:t||"Feature Layer",geometryType:s,capabilities:i}}),tables:s.data.tables.map(e=>{const t=x(this.url,e),s=I(e,t.url);return{...t,capabilities:s}})}}};function z(e){const t=e.data,s=[];return{results:t.map(e=>{const t={addResults:e.addResults??[],updateResults:e.updateResults??[],deleteResults:e.deleteResults??[],attachments:e.attachments,editMoment:e.editMoment},r=j(t),i=e.editedFeatures,a=i?.spatialReference?new h({wkid:i?.spatialReference.wkid,wkt:i?.spatialReference.wkt,latestWkid:i?.spatialReference.latestWkid,latestVcsWkid:i?.spatialReference.latestVcsWkid,vcsWkid:i?.spatialReference.vcsWkid}):null,o=i?S(i,a):null;o&&s.push({layerId:e.id,editedFeatures:o});const n={};return e.divideGroupedObjectResults&&(n.divideGroupedObjectResults=e.divideGroupedObjectResults),e.combineGroupedObjectResults&&(n.combineGroupedObjectResults=e.combineGroupedObjectResults),{id:e.id,editedFeatures:o,...r,...n}}),editedFeatures:s}}e([c()],$.prototype,"url",void 0),e([c()],$.prototype,"sourceJSON",void 0),e([c()],$.prototype,"userHasFullEditingPrivileges",void 0),e([c()],$.prototype,"userHasUpdateItemPrivileges",void 0),e([c({readOnly:!0})],$.prototype,"utilityNetworkUrl",null),e([c({readOnly:!0})],$.prototype,"versionManagementServiceUrl",null),e([c()],$.prototype,"userTypeExtensions",void 0),e([c({json:{read:{source:["layers"]}}})],$.prototype,"layerInfos",void 0),e([m("layerInfos",["layers"])],$.prototype,"readLayerInfos",null),e([c({json:{read:{source:["tables"]}}})],$.prototype,"tableInfos",void 0),e([m("tableInfos",["tables"])],$.prototype,"readTableInfos",null),e([c({readOnly:!0,json:{read:{source:["hasVersionedData","hasSharedTemplates","hasBranchVersionedData","capabilities","supportsQueryDataElements","supportsQueryDomains","supportsQueryContingentValues","maxRecordCountFactor","maxRecordCount","advancedEditingCapabilities","supportsApplyEditsWithGlobalIds","syncCapabilities","datesInUnknownTimezone"]}}})],$.prototype,"capabilities",void 0),e([m("capabilities",["hasVersionedData","hasSharedTemplates","hasBranchVersionedData","capabilities","supportsQueryDataElements","supportsQueryDomains","supportsQueryContingentValues","maxRecordCountFactor","maxRecordCount","advancedEditingCapabilities","supportsApplyEditsWithGlobalIds","syncCapabilities","datesInUnknownTimezone"])],$.prototype,"readCapabilities",null),e([c({readOnly:!0})],$.prototype,"effectiveCapabilities",null),$=e([y("esri.rest.featureService.FeatureService")],$);const Z=$;export{Z as default};
5
+ import{__decorate as e}from"tslib";import t from"../../config.js";import{id as s}from"../../kernel.js";import r from"../../request.js";import{isSome as i}from"../../core/arrayUtils.js";import a from"../../core/Error.js";import{IdentifiableMixin as o}from"../../core/Identifiable.js";import{JSONSupportMixin as n}from"../../core/JSONSupport.js";import{clone as l}from"../../core/lang.js";import{Loadable as d}from"../../core/Loadable.js";import{throwIfAborted as u,throwIfAbortError as p}from"../../core/promiseUtils.js";import{property as c}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import{reader as m}from"../../core/accessorSupport/decorators/reader.js";import{subclass as y}from"../../core/accessorSupport/decorators/subclass.js";import h from"../../geometry/SpatialReference.js";import{getFeatureJSON as f,getFeatureIds as b,getAttachmentEditsJSON as g,isProtectedOrPrivateVersionError as v,unpackEditResultData as j,createEditedFeatures as S}from"../../layers/graphics/applyEditsUtils.js";import{checkEditingCapabilities as E,normalizeEdits as I,normalizeGeometries as O}from"../../layers/graphics/editingSupport.js";import{emitApplyEditsEvent as F}from"../../layers/mixins/EditBusLayer.js";import{ensureCredentialIfSignedIn as R}from"../../layers/support/featureLayerUtils.js";import{getOwningPortalUrl as A}from"../../layers/support/layerUtils.js";import{getFeatureLayerCapabilities as w}from"../../layers/support/serviceCapabilitiesUtils.js";import T from"../../portal/PortalItem.js";import{getUserPrivileges as U}from"../../portal/support/portalItemUtils.js";import{isSecureProxyService as C}from"../../portal/support/urlUtils.js";import{parseUrl as D,asValidOptions as P,encode as V}from"../utils.js";import{unapplyEditsZUnitScaling as G}from"../query/operations/editsZScale.js";import{readBoolean as k,readNumber as _}from"../support/jsonUtils.js";import{isSafeToEditVersion as x,isVersionInEditSession as L,currentSessionId as M}from"../../versionManagement/support/versionManagementUtils.js";function N(e,t){const s=t.id;return{id:s,name:t.name,url:`${e}/${s}`,type:t.type||"Table"}}function Q(e){return{data:J(e),sync:B(e),operations:q(e.capabilities,e),query:W(e),editing:H(e)}}function J(e){return{isDataVersioned:k(e,"hasVersionedData",!1),isDataBranchVersioned:k(e,"hasBranchVersionedData",!1)}}function q(e,t){const s=e?e.toLowerCase().split(",").map(e=>e.trim()):[],r=s.includes("query"),i=s.includes("editing")&&!t.datesInUnknownTimezone;let a=i&&s.includes("create"),o=i&&s.includes("delete"),n=i&&s.includes("update");return i&&!(a||o||n)&&(a=o=n=!0),{supportsAdd:a,supportsDelete:o,supportsEditing:i,supportsChangeTracking:s.includes("changetracking"),supportsQuery:r,supportsQueryDataElements:k(t,"supportsQueryDataElements",!1),supportsQueryDomains:k(t,"supportsQueryDomains",!1),supportsQueryContingentValues:k(t,"supportsQueryContingentValues",!1),supportsSync:s.includes("sync"),supportsUpdate:n}}function W(e){return{maxRecordCountFactor:_(e,"maxRecordCountFactor",void 0),maxRecordCount:_(e,"maxRecordCount",void 0)}}function H(e){const t=e?.advancedEditingCapabilities;return{supportsAsyncApplyEdits:k(t,"supportsAsyncApplyEdits",!1),supportsGlobalId:k(e,"supportsApplyEditsWithGlobalIds",!1),supportsReturnServiceEditsInSourceSpatialReference:k(t,"supportsReturnServiceEditsInSourceSR",!1),supportsSharedTemplates:k(e,"supportsSharedTemplates",!1)||k(e,"hasSharedTemplates",!1),supportsSplit:k(t,"supportsSplit",!1)}}function B(e){const t=e?.syncCapabilities,s=t?.supportedSyncDataOptions;return{supportsAsync:k(t,"supportsAsync",!1),supportedSyncDataOptions:{annotations:!(1&~s),dimensions:!(2&~s),contingentValues:!(4&~s),attributeRules:!(8&~s),utilityNetworkSystem:!(16&~s),annotationFullModel:!(32&~s),include3DObjects:!(64&~s),utilityNetworkMissingLayers:!(128&~s),preserveTrueCurves:!(256&~s)}}}let $=class extends(n(o(d))){constructor(e){super(e),this.url=null,this.sourceJSON=null,this.userHasFullEditingPrivileges=!1,this.userHasUpdateItemPrivileges=!1,this.userTypeExtensions=[],this.layerInfos=null,this.tableInfos=null,this.capabilities=null,this._layerTableIndex=new Map}read(e,t){this.sourceJSON=e,super.read(e,t)}get utilityNetworkUrl(){if(this.sourceJSON)for(const e of this.sourceJSON.layers)if("Utility Network Layer"===e.type)return`${this.url}/${e.id}`;return null}get versionManagementServiceUrl(){return this.sourceJSON?.hasBranchVersionedData&&!C(this.url)?this.url.replace(/\/FeatureServer/i,"/VersionManagementServer"):null}readLayerInfos(e,t){return(t.layers||[]).map(e=>{const{type:t,geometryType:s}=e;return{...N(this.url,e),type:t||"Feature Layer",geometryType:s}})}readTableInfos(e,t){return(t.tables||[]).map(e=>N(this.url,e))}readCapabilities(e,t){return Q(t)}get effectiveCapabilities(){const e=this.capabilities;if(!e)return null;const t=l(e),{operations:s}=t;return this.userHasUpdateItemPrivileges?(s.supportsAdd=s.supportsDelete=s.supportsEditing=s.supportsQuery=s.supportsUpdate=!0,t):(this.userHasFullEditingPrivileges&&s.supportsEditing&&(s.supportsAdd=s.supportsDelete=s.supportsUpdate=!0),t)}get loaded(){return super.loaded}load(e){return this.addResolvingPromise(this._fetchService(this.url,e).then(()=>this._setUserPrivileges(e))),Promise.resolve(this)}async fetchAllLayersAndTables(e){return await this.load(e),this._fetchLayersAndTablesPromise||=this._fetchLayersAndTables(this.url),u(e),this._fetchLayersAndTablesPromise}async applyEdits(e,t){let s=null;try{const{results:r,edits:i,editedFeatures:a}=await this._internalApplyEdits(e,t),o=e=>e.filter(e=>!e.error).map(l);let n=0;return r.map(e=>{s=F(this.url,e.id,t?.gdbVersion,!0);const r={edits:i[n],addedFeatures:o(e.addFeatureResults),updatedFeatures:o(e.updateFeatureResults),deletedFeatures:o(e.deleteFeatureResults),addedAttachments:o(e.addAttachmentResults),updatedAttachments:o(e.updateAttachmentResults),deletedAttachments:o(e.deleteAttachmentResults),exceededTransferLimit:!1,historicMoment:e.editMoment?new Date(e.editMoment):null};n+=1,a.length>0&&(r.editedFeatures=a),s.resolve(r),s=null}),r}catch(r){throw s&&s.reject(r),r}}async _setUserPrivileges(e){if(t.userPrivilegesApplied)try{const{features:{fullEdit:t},content:{updateItem:s}}=await this._fetchUserPrivileges(this.sourceJSON.serviceItemId,e);this._set("userHasFullEditingPrivileges",t),this._set("userHasUpdateItemPrivileges",s)}catch(s){p(s)}}async _fetchUserPrivileges(e,t){const r=!0,i=!1,a=!1;if(!e)return{features:{edit:r,fullEdit:i},content:{updateItem:a}};let o,n,l;try{o=await A(this.url,t)}catch(d){p(d)}try{const e=null!=t?t.signal:null;n=await(s?.getCredential(`${o}/sharing`,{prompt:!1,signal:e}))}catch(d){p(d)}if(!n)return{features:{edit:r,fullEdit:i},content:{updateItem:a}};try{if(l=new T({id:e,portal:{url:o}}),await l.load(t),l.portal.user)return U(l)}catch(d){p(d)}return{features:{edit:r,fullEdit:i},content:{updateItem:a}}}async _internalApplyEdits(e,t){await R(this.url);const s=t?.globalIdUsed??!1,a=h.fromJSON(this.sourceJSON.spatialReference),{edits:o,options:n}=await this._processApplyEditsParams(e,t),l=await Promise.all(o.map(async e=>{const t=e.addFeatures?.map(e=>f({spatialReference:a},e,null))??[],r=(await Promise.all(t)).filter(i),o=r.length>0?r:null,n=e.updateFeatures?.map(e=>f({spatialReference:a},e,null))??[],l=(await Promise.all(n)).filter(i),d=l.length>0?l:null,u=b(e.identifierFields,e.deleteFeatures,s),p=u.length>0?u:null;G(o,d,a);const c=await g(e.identifierFields,e);let m=null;if(c){m={adds:c.adds.length>0?c.adds:void 0,updates:c.updates.length>0?c.updates:void 0,deletes:c.deletes.length>0?c.deletes:void 0}}const y={};return e.deleteAssociations&&(y.deleteAssociations=e.deleteAssociations),e.combineGroupedObjects&&(y.combineGroupedObjects=e.combineGroupedObjects),e.divideGroupedObjects&&(y.divideGroupedObjects=e.divideGroupedObjects),{id:e.id,adds:o,updates:d,deletes:p,attachments:m,...y}})),d={gdbVersion:n?.gdbVersion,rollbackOnFailure:!0,useGlobalIds:s,returnEditMoment:!0,honorSequenceOfEdits:n?.honorSequenceOfEdits,usePreviousEditMoment:n?.usePreviousEditMoment,returnServiceEditsInSourceSR:!1,returnServiceEditsOption:"originalAndCurrentFeatures",async:!1};await x(this.url,t?.gdbVersion,!0);const u=L(this.url,t?.gdbVersion||null);d.edits=JSON.stringify(l);const p=D(this.url),c=P(p.query,{query:V({...d,f:"json"}),method:"post"});let m;u&&(c.authMode="immediate",c.query.sessionId=M);try{m=await r(this.url+"/applyEdits",c)}catch(y){if(!v(y))throw y;c.authMode="immediate",m=await r(this.url+"/applyEdits",c)}return{...z(m),edits:o}}async _processApplyEditsParams(e,t){const s={...t,usingFeatureServiceEndpoint:!0,usingTelecomOperations:e.some(e=>e.deleteAssociations||e.combineGroupedObjects||e.divideGroupedObjects)};return{edits:await Promise.all(e.map(async e=>{const t=this.effectiveCapabilities,r=e&&(e.addFeatures||e.updateFeatures||e.deleteFeatures),i=e&&(e.addAttachments||e.updateAttachments||e.deleteAttachments);if(E(e,t,s,!!r,!!i,"feature-service"),!t.data.isDataVersioned&&s?.gdbVersion)throw new a("feature-service:invalid-parameter","'gdbVersion' is applicable only if the layer supports versioned data. See: 'capabilities.data.isDataVersioned'");const o=I(e,t,"feature-service"),n={};if(e.deleteAssociations&&(n.deleteAssociations=e.deleteAssociations),e.combineGroupedObjects&&(n.combineGroupedObjects=e.combineGroupedObjects),e.divideGroupedObjects&&(n.divideGroupedObjects=e.divideGroupedObjects),!e.identifierFields){await this.fetchAllLayersAndTables();const t=this._layerTableIndex.get(e.id);t&&(e.identifierFields={globalIdField:t.globalIdField,objectIdField:t.objectIdField})}const l=await O(o);return{id:e.id,...l,...n,identifierFields:e.identifierFields}})),options:s}}async _fetchService(e,t){if(this.sourceJSON)return void this.read(this.sourceJSON,{url:D(e)});const s=await r(e,{responseType:"json",query:{f:"json"},...t});this.read(s.data,{url:D(e)})}async _fetchLayersAndTables(e){const t=`${e}/layers`,s=await r(t,{responseType:"json",query:{f:"json"}});return{layers:s.data.layers.map(e=>{const{type:t,geometryType:s}=e,r=N(this.url,e),i=w(e,r.url);return this._layerTableIndex.set(e.id,e),{...r,type:t||"Feature Layer",geometryType:s,capabilities:i}}),tables:s.data.tables.map(e=>{const t=N(this.url,e),s=w(e,t.url);return this._layerTableIndex.set(e.id,e),{...t,capabilities:s}})}}};function z(e){const t=e.data,s=[];return{results:t.map(e=>{const t={addResults:e.addResults??[],updateResults:e.updateResults??[],deleteResults:e.deleteResults??[],attachments:e.attachments,editMoment:e.editMoment},r=j(t),i=e.editedFeatures,a=i?.spatialReference?new h({wkid:i?.spatialReference.wkid,wkt:i?.spatialReference.wkt,latestWkid:i?.spatialReference.latestWkid,latestVcsWkid:i?.spatialReference.latestVcsWkid,vcsWkid:i?.spatialReference.vcsWkid}):null,o=i?S(i,a):null;o&&s.push({layerId:e.id,editedFeatures:o});const n={};return e.divideGroupedObjectResults&&(n.divideGroupedObjectResults=e.divideGroupedObjectResults),e.combineGroupedObjectResults&&(n.combineGroupedObjectResults=e.combineGroupedObjectResults),{id:e.id,editedFeatures:o,...r,...n}}),editedFeatures:s}}e([c()],$.prototype,"url",void 0),e([c()],$.prototype,"sourceJSON",void 0),e([c()],$.prototype,"userHasFullEditingPrivileges",void 0),e([c()],$.prototype,"userHasUpdateItemPrivileges",void 0),e([c({readOnly:!0})],$.prototype,"utilityNetworkUrl",null),e([c({readOnly:!0})],$.prototype,"versionManagementServiceUrl",null),e([c()],$.prototype,"userTypeExtensions",void 0),e([c({json:{read:{source:["layers"]}}})],$.prototype,"layerInfos",void 0),e([m("layerInfos",["layers"])],$.prototype,"readLayerInfos",null),e([c({json:{read:{source:["tables"]}}})],$.prototype,"tableInfos",void 0),e([m("tableInfos",["tables"])],$.prototype,"readTableInfos",null),e([c({readOnly:!0,json:{read:{source:["hasVersionedData","hasSharedTemplates","hasBranchVersionedData","capabilities","supportsQueryDataElements","supportsQueryDomains","supportsQueryContingentValues","maxRecordCountFactor","maxRecordCount","advancedEditingCapabilities","supportsApplyEditsWithGlobalIds","syncCapabilities","datesInUnknownTimezone"]}}})],$.prototype,"capabilities",void 0),e([m("capabilities",["hasVersionedData","hasSharedTemplates","hasBranchVersionedData","capabilities","supportsQueryDataElements","supportsQueryDomains","supportsQueryContingentValues","maxRecordCountFactor","maxRecordCount","advancedEditingCapabilities","supportsApplyEditsWithGlobalIds","syncCapabilities","datesInUnknownTimezone"])],$.prototype,"readCapabilities",null),e([c({readOnly:!0})],$.prototype,"effectiveCapabilities",null),$=e([y("esri.rest.featureService.FeatureService")],$);const Z=$;export{Z as default};
@@ -0,0 +1,5 @@
1
+ /*
2
+ All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
+ See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
+ */
5
+ import{__decorate as t}from"tslib";import{isSome as o}from"../../../core/arrayUtils.js";import{JSONSupport as e}from"../../../core/JSONSupport.js";import s from"../../../core/Logger.js";import{watch as i,initial as r}from"../../../core/reactiveUtils.js";import{property as n}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import{reader as c}from"../../../core/accessorSupport/decorators/reader.js";import{subclass as a}from"../../../core/accessorSupport/decorators/subclass.js";import{writer as p}from"../../../core/accessorSupport/decorators/writer.js";import{CircuitTypeKebabDict as l,CircuitStatusKebabDict as u}from"../../../networks/support/typeUtils.js";import d from"./CircuitLocation.js";import h from"./CircuitSection.js";import y from"./Subcircuit.js";let m=class extends e{constructor(t){super(t),this._sectionIdLookup=new Map,this.circuitType="physical",this.globalId=null,this.isDeleted=!1,this.lastExportedTime=null,this.lastVerifiedTime=null,this.name=null,this.sections=null,this.startLocation=null,this.status="dirty",this.stopLocation=null,this.subcircuits=[]}initialize(){this.addHandles([i(()=>this.sections,t=>{this._sectionIdLookup.clear(),null!=t&&Array.from(t.keys()).forEach(t=>this._sectionIdLookup.set(t.sectionId,t))},r)])}normalizeCtorArgs(t){if(void 0===t)return t;const{name:o,startLocation:e,stopLocation:i,sections:r}=t;return(e||i)&&r?(delete t.startLocation,delete t.stopLocation,s.getLogger(this).warn("Cannot instantiate Circuit with both start/stop locations and sections.",`Circuit '${o}' was defaulted to having sections only.`)):(e&&!i||!e&&i)&&!r&&s.getLogger(this).warn(`Non-sectioned circuit '${o}' must have both start and stop locations.`,"Create/alter operations involving this circuit will fail unless both are populated."),t}get isSectioned(){return null==this.startLocation&&null==this.stopLocation&&null!=this.sections}readSections(t,e){const{sectionOrder:s,sections:i}=e,r=new Map;if(null==s||null==i)return r;i.forEach(t=>{this._sectionIdLookup.set(t.sectionId,h.fromJSON(t))});for(const[n,c]of Object.entries(s)){const t=Number(n),e=this._sectionIdLookup.get(t);if(null==e)continue;const s=c.map(t=>this._sectionIdLookup.get(t)).filter(o);r.set(e,s)}return r}writeSections(t,o){const e={},s=[];t?.forEach((t,o)=>{const i=o.sectionId.toString(),r=t.map(t=>t.sectionId);e[i]=r,s.push(o.toJSON())}),o.sectionOrder=e,o.sections=s}getSectionById(t){return this._sectionIdLookup.get(t)??null}setStartStopLocations(t,o){this.startLocation=t,this.stopLocation=o,this.sections=null}setSections(t){this.sections=t,this.startLocation=null,this.stopLocation=null}};t([n({type:l.apiValues,json:{type:l.jsonValues,read:l.read,write:l.write}})],m.prototype,"circuitType",void 0),t([n({type:String,json:{write:!0}})],m.prototype,"globalId",void 0),t([n({type:Boolean,readOnly:!0})],m.prototype,"isDeleted",void 0),t([n({type:Boolean,json:{write:!0},readOnly:!0})],m.prototype,"isSectioned",null),t([n({type:Date,json:{read:{reader:t=>"number"==typeof t?new Date(t):null}},readOnly:!0})],m.prototype,"lastExportedTime",void 0),t([n({type:Date,json:{read:{reader:t=>"number"==typeof t?new Date(t):null}},readOnly:!0})],m.prototype,"lastVerifiedTime",void 0),t([n({type:String,json:{write:!0}})],m.prototype,"name",void 0),t([n({json:{read:{source:["sectionOrder","sections"]},write:!0}})],m.prototype,"sections",void 0),t([c("sections")],m.prototype,"readSections",null),t([p("sections")],m.prototype,"writeSections",null),t([n({type:d,json:{write:!0}})],m.prototype,"startLocation",void 0),t([n({type:u.apiValues,json:{type:u.jsonValues,read:u.read}})],m.prototype,"status",void 0),t([n({type:d,json:{write:!0}})],m.prototype,"stopLocation",void 0),t([n({type:[y],json:{write:!0}})],m.prototype,"subcircuits",void 0),m=t([a("esri.rest.networks.support.Circuit")],m);const f=m;export{f 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.34/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as t}from"tslib";import{JSONSupport as o}from"../../../core/JSONSupport.js";import{property as r}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as e}from"../../../core/accessorSupport/decorators/subclass.js";import{CircuitSectionRoleKebabDict as s,CircuitTypeKebabDict as i}from"../../../networks/support/typeUtils.js";import p from"./CircuitLocation.js";import c from"./CircuitPath.js";import a from"./Subcircuit.js";let n=class extends o{constructor(t){super(t),this.sectionId=null,this.role="start-and-end",this.sectionType="physical",this.startLocation=null,this.stopLocation=null,this.subcircuit=null,this.path=null}};t([r({type:Number,json:{write:!0}})],n.prototype,"sectionId",void 0),t([r({type:s.apiValues,json:{type:s.jsonValues,read:s.read},readOnly:!0})],n.prototype,"role",void 0),t([r({type:i.apiValues,json:{type:i.jsonValues,read:i.read,write:i.write}})],n.prototype,"sectionType",void 0),t([r({type:p,json:{write:!0}})],n.prototype,"startLocation",void 0),t([r({type:p,json:{write:!0}})],n.prototype,"stopLocation",void 0),t([r({type:a,json:{write:!0}})],n.prototype,"subcircuit",void 0),t([r({type:c,readOnly:!0})],n.prototype,"path",void 0),n=t([e("esri.rest.networks.support.CircuitSection")],n);const u=n;export{u as default};
5
+ import{__decorate as t}from"tslib";import{JSONSupport as o}from"../../../core/JSONSupport.js";import i from"../../../core/Logger.js";import{property as r}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/RandomLCG.js";import{subclass as s}from"../../../core/accessorSupport/decorators/subclass.js";import{CircuitSectionRoleKebabDict as e,CircuitTypeKebabDict as a}from"../../../networks/support/typeUtils.js";import n from"./CircuitLocation.js";import c from"./CircuitPath.js";import p from"./Subcircuit.js";let u=class extends o{constructor(t){super(t),this.sectionId=null,this.role="start-and-end",this.sectionType="physical",this.startLocation=null,this.stopLocation=null,this.subcircuit=null,this.path=null}normalizeCtorArgs(t){if(void 0===t)return t;const{sectionId:o,startLocation:r,stopLocation:s,subcircuit:e}=t;return(r||s)&&e?(delete t.startLocation,delete t.stopLocation,i.getLogger(this).warn("Cannot instantiate CircuitSection with both start/stop locations and subcircuit.",`CircuitSection with ID '${o}' was defaulted to having a subcircuit only.`)):(r&&!s||!r&&s)&&!e&&i.getLogger(this).warn(`CircuitSection with ID '${o}' must have both start and stop locations.`,"Create/alter operations involving this section will fail unless both are populated."),t}setStartStopLocations(t,o){this.startLocation=t,this.stopLocation=o,this.subcircuit=null}setSubcircuit(t){this.subcircuit=t,this.startLocation=null,this.stopLocation=null}};t([r({type:Number,json:{write:!0}})],u.prototype,"sectionId",void 0),t([r({type:e.apiValues,json:{type:e.jsonValues,read:e.read},readOnly:!0})],u.prototype,"role",void 0),t([r({type:a.apiValues,json:{type:a.jsonValues,read:a.read,write:a.write}})],u.prototype,"sectionType",void 0),t([r({type:n,json:{write:!0}})],u.prototype,"startLocation",void 0),t([r({type:n,json:{write:!0}})],u.prototype,"stopLocation",void 0),t([r({type:p,json:{write:!0}})],u.prototype,"subcircuit",void 0),t([r({type:c,readOnly:!0})],u.prototype,"path",void 0),u=t([s("esri.rest.networks.support.CircuitSection")],u);const l=u;export{l 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.34/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as o}from"tslib";import{JSONSupport as r}from"../../../core/JSONSupport.js";import{property as t}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as e}from"../../../core/accessorSupport/decorators/subclass.js";let s=class extends r{constructor(o){super(o),this.name=null,this.globalId=null,this.providerId=null,this.consumerId=null,this.isReserved=!1}};o([t({type:String,json:{write:!0}})],s.prototype,"name",void 0),o([t({type:String,json:{write:!0}})],s.prototype,"globalId",void 0),o([t({type:String,readOnly:!0})],s.prototype,"providerId",void 0),o([t({type:String,readOnly:!0})],s.prototype,"consumerId",void 0),o([t({type:Boolean,json:{write:!0}})],s.prototype,"isReserved",void 0),s=o([e("esri.rest.networks.support.Subcircuit")],s);const p=s;export{p as default};
5
+ import{__decorate as o}from"tslib";import{JSONSupport as r}from"../../../core/JSONSupport.js";import{property as t}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as e}from"../../../core/accessorSupport/decorators/subclass.js";let s=class extends r{constructor(o){super(o),this.name=null,this.globalId=null,this.providerId=null,this.consumerId=null,this.isReserved=!1}};o([t({type:String,json:{write:!0}})],s.prototype,"name",void 0),o([t({type:String,json:{write:!0}})],s.prototype,"globalId",void 0),o([t({type:String})],s.prototype,"providerId",void 0),o([t({type:String})],s.prototype,"consumerId",void 0),o([t({type:Boolean,json:{write:!0}})],s.prototype,"isReserved",void 0),s=o([e("esri.rest.networks.support.Subcircuit")],s);const p=s;export{p as default};
package/rest/print.js CHANGED
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{id as e}from"../kernel.js";import t from"../request.js";import{JSONMap as a}from"../core/jsonMap.js";import{createScreenPoint as i,pt2px as r,px2pt as n}from"../core/screenUtils.js";import{dataComponents as o,normalize as s}from"../core/urlUtils.js";import l from"../geometry/Polygon.js";import{collectLabelingFields as c}from"../layers/support/fieldUtils.js";import{getFloorFilterClause as u}from"../layers/support/floorFilterUtils.js";import{getSizeRangeAtScale as y}from"../renderers/visualVariables/support/visualVariableUtils.js";import{asValidOptions as p,findToken as f}from"./utils.js";import{execute as d}from"./geoprocessor/execute.js";import{submitJob as m}from"./geoprocessor/submitJob.js";import{formatJsonMap as g}from"./support/fileFormat.js";import{toJSON as h}from"./support/layoutTemplate.js";import{getVisibleLayerViews as b,isScreenshotRequired as w,isBingMapsLayer as S,isBlendLayer as x,getCopyright as I,getSelectionSymbol as v,createPointLayer as D,createPolygonLayer as T,createPolylineLayer as L,createMultipointLayer as O,getContextBoundingBox as E}from"./support/printTaskUtils.js";import P from"./support/PrintTemplate.js";import{toJSON as M}from"./support/reportTemplate.js";const V={Feet:"ft",Kilometers:"km",Meters:"m",Miles:"mi"},F=new a({esriFeet:"Feet",esriKilometers:"Kilometers",esriMeters:"Meters",esriMiles:"Miles"}),k=new a({esriExecutionTypeSynchronous:"sync",esriExecutionTypeAsynchronous:"async"}),N=new Map;async function R(e,t,a){const i=await U(e,a),r=await _(t,i);if("sync"===await J(e,a)){const{results:t}=await d(e,r,void 0,a);return t?.[0]?.value}const n=await m(e,r,void 0,a);await n.waitForJobCompletion({interval:t.updateDelay});const{value:o}=await n.fetchResultData("Output_File",null,a);return o}async function U(e,a){const i=$(e),r=N.get(i)??{gpServerUrl:i,legendLayerNameMap:{},legendLayers:[]};return r.gpMetadata??=(await t(i,p({f:"json"},a))).data,r.cimVersion=r.gpMetadata.cimVersion,N.set(i,r),r}async function J(e,t){return we(await U(e,t))}async function j(e,a){const i=await U(e,a),r=i.gpMetadata.tasks,n=i.gpServerUrl;return i.taskInfos||(i.taskInfos={},await Promise.all(r?.map(async e=>{const r=(await t(`${n}/${e}`,p({f:"json"},a))).data,o=r.name.startsWith("GetLayoutTemplatesInfo")?"GetLayoutTemplatesInfo":r.name.startsWith("ExportWebMap")?"ExportWebMap":null;o&&(i.taskInfos[o]??=r)})??[])),i.taskInfos}async function A(e,t,a){return(await j(e,a))[t]??null}async function C(e,t,a){const i=await A(e,t,a);return i?.executionType?k.fromJSON(i.executionType):"sync"}async function _(t,a){a=a||{is11xService:!1,legendLayerNameMap:{},legendLayers:[]};const i=t.template||new P;null==i.showLabels&&(i.showLabels=!0);const r=i.exportOptions;let n;const o=h(i.layout);if(r){if(n={dpi:r.dpi},"map_only"===o?.toLowerCase()||""===o){const{width:e,height:t}=r;n.outputSize=null!=e&&null!=t?[e,t]:void 0}}const s=i.layoutOptions;let l;if(s){let e,t;"Miles"===s.scalebarUnit||"Kilometers"===s.scalebarUnit?(e="Kilometers",t="Miles"):"Meters"!==s.scalebarUnit&&"Feet"!==s.scalebarUnit||(e="Meters",t="Feet"),l={titleText:s.titleText,authorText:s.authorText,copyrightText:s.copyrightText,customTextElements:s.customTextElements,elementOverrides:s.elementOverrides,scaleBarOptions:e||t?{metricUnit:F.toJSON(e)??void 0,metricLabel:e?V[e]:void 0,nonMetricUnit:F.toJSON(t)??void 0,nonMetricLabel:t?V[t]:void 0}:void 0}}let c=null;s?.legendLayers&&(c=s.legendLayers.map(e=>{const t=e.layerId;a.legendLayerNameMap[t]=e.title;const i={id:t};return e.subLayerIds&&(i.subLayerIds=e.subLayerIds),i}));const u=await z(t,i,a);if(u.operationalLayers){const e=new RegExp("[\\u4E00-\\u9FFF\\u0E00-\\u0E7F\\u0900-\\u097F\\u3040-\\u309F\\u30A0-\\u30FF\\u31F0-\\u31FF]"),t=/[\u0600-\u06FF]/,a=a=>{const i=a.text,r=a.font,n=r?.family?.toLowerCase();i&&r&&("arial"===n||"arial unicode ms"===n)&&(r.family=e.test(i)?"Arial Unicode MS":"Arial","normal"!==r.style&&t.test(i)&&(r.family="Arial Unicode MS"))};for(const i of u.operationalLayers)if(i.featureCollection?.layers)for(const e of i.featureCollection.layers){if(e.layerDefinition?.drawingInfo?.renderer?.symbol){const t=e.layerDefinition.drawingInfo.renderer;"esriTS"===t.symbol.type&&a(t.symbol)}if(e.featureSet?.features)for(const t of e.featureSet.features)t.symbol&&"esriTS"===t.symbol.type&&a(t.symbol)}}t.outSpatialReference&&(u.mapOptions.spatialReference=t.outSpatialReference.toJSON()),Object.assign(u,{exportOptions:n,layoutOptions:l||{}}),Object.assign(u.layoutOptions,{legendOptions:{operationalLayers:null!=c?c:a.legendLayers.slice()}}),a.legendLayers.length=0,N.set(a.gpServerUrl,a);const y={Web_Map_as_JSON:JSON.stringify(u),Format:g.toJSON(i.format),Layout_Template:o,Layout_Item_ID:void 0,Report_Template:M(i.report),Report_Item_ID:void 0};if(i.layoutItem){delete y.Layout_Template;const t=i.layoutItem;await t.load(),"public"!==t.access&&e&&await e.getCredential(a.gpServerUrl),y.Layout_Item_ID=JSON.stringify({id:t.id})}if(i.reportItem){delete y.Report_Template;const t=i.reportItem;await t.load(),"public"!==t.access&&e&&await e.getCredential(a.gpServerUrl),y.Report_Item_ID=JSON.stringify({id:t.id})}return t.extraParameters&&Object.assign(y,t.extraParameters),y}async function z(e,t,a){const i=e.view;let r=i.spatialReference;const n={operationalLayers:await W(i,t,a)};t.includeTables&&(n.tables=await se(i));let o=e.extent||a.ssExtent||i.extent;if(r?.isWrappable&&(o=o.clone()._normalize(!0),r=o.spatialReference),n.mapOptions={extent:o&&o.toJSON(),spatialReference:r&&r.toJSON(),showAttribution:t.attributionVisible},a.ssExtent=null,i.background&&(n.background=i.background.toJSON()),i.rotation&&(n.mapOptions.rotation=-i.rotation),t.scalePreserved&&(n.mapOptions.scale=t.outScale||i.scale),null!=i.timeExtent){const e=null!=i.timeExtent.start?i.timeExtent.start.getTime():null,t=null!=i.timeExtent.end?i.timeExtent.end.getTime():null;n.mapOptions.time=[e,t]}return t.reportOptions&&(n.reportOptions=t.reportOptions),n}function $(e){let t=e;const a=t.lastIndexOf("/GPServer/");return a>0&&(t=t.slice(0,a+9)),t}async function W(e,t,a){const i=[],r={layerView:null,printTemplate:t,view:e};let n=0;t.scalePreserved&&(n=t.outScale||e.scale);const o=b(e,n);for(const s of o){const e=s.layer;if(!e.loaded||"layers"in e)continue;let t;r.layerView=s,t=w(s)?await re(e,r,a):S(e)?q(e):"csv"===e?.type?await K(e,r,a):"catalog-footprint"===e?.type?await B(e,r,a):"feature"===e?.type?await Q(e,r,a):"geojson"===e?.type?await H(e,r,a):"graphics"===e?.type?await X(e,r,a):"imagery"===e?.type?Y(e,a):"imagery-tile"===e?.type?await Z(e,r,a):"kml"===e?.type?await ee(e,r,a):"map-image"===e?.type?te(e,r,a):"map-notes"===e?.type?await ae(r,a):"open-street-map"===e?.type?ie():"stream"===e?.type?await ne(e,r,a):"subtype-group"===e?.type?await oe(e,a):"tile"===e?.type?le(e,a):"vector-tile"===e?.type?await ce(e,r,a):"web-tile"===e?.type?ue(e):"wfs"===e?.type?await ye(e,r,a):"wms"===e?.type?pe(e,a):"wmts"===e?.type?fe(e):await re(e,r,a),t&&(Array.isArray(t)?i.push(...t):(t.id=e.id,t.title=a.legendLayerNameMap[e.id]||e.title,t.opacity=s.fullOpacity,t.minScale=e.minScale||0,t.maxScale=e.maxScale||0,x(e)&&e.blendMode&&"normal"!==e.blendMode&&(t.blendMode=e.blendMode),i.push(t)))}if(n)for(const s of i)s.minScale=0,s.maxScale=0;if(e.graphics?.length){const r=await G(null,e.graphics,t,a);r&&i.push(r)}return i}function q(e){return{culture:e.culture,key:e.key,type:"BingMaps"+("aerial"===e.style?"Aerial":"hybrid"===e.style?"Hybrid":"Road")}}async function B(e,{layerView:t,printTemplate:a},i){if(parseFloat(i.cimVersion)<3.1){return G(e,await he(t),a,i)}const r=e.parent,n={id:(o=be(r,"web-map")).id,url:o.url,layerType:o.layerType,customParameters:o.customParameters,dynamicGroupLayer:{visibility:!1},footprintLayer:o.footprintLayer,layerDefinition:o.layerDefinition};var o;return de(n,r),n}async function K(e,t,a){e.legendEnabled&&a.legendLayers.push({id:e.id});const i=t.layerView,r=t.printTemplate;if(!(i.filter||e.portalItem&&"public"!==e.portalItem.access)){const t=be(e,"web-map");return t.type="CSV",delete t.popupInfo,delete t.layerType,t.showLabels=r.showLabels&&e.labelsVisible,t}return G(e,await he(i),r,a)}async function G(e,t,a,i){let r;const n=T(),o=L(),s=D(),u=O(),y=D();if(y.layerDefinition.name="textLayer",delete y.layerDefinition.drawingInfo,e){if("esri.layers.FeatureLayer"===e.declaredClass||"esri.layers.StreamLayer"===e.declaredClass?n.layerDefinition.name=o.layerDefinition.name=s.layerDefinition.name=u.layerDefinition.name=i.legendLayerNameMap[e.id]||e.arcgisProps?.title||e.title:"esri.layers.GraphicsLayer"===e.declaredClass&&(t=e.graphics.items),e.renderer){const t=e.renderer.toJSON(),a=n.layerDefinition.drawingInfo;a&&(a.renderer=t);const i=o.layerDefinition.drawingInfo;i&&(i.renderer=t);const r=s.layerDefinition.drawingInfo;r&&(r.renderer=t);const l=u.layerDefinition.drawingInfo;l&&(l.renderer=t)}if(a.showLabels&&e.labelsVisible&&"function"==typeof e.write){const t=be(e,"web-map"),a=t.layerDefinition?.drawingInfo?.labelingInfo;if(a){r=!0;const e=n.layerDefinition.drawingInfo;e&&(e.labelingInfo=a);const t=o.layerDefinition.drawingInfo;t&&(t.labelingInfo=a);const i=s.layerDefinition.drawingInfo;i&&(i.labelingInfo=a);const l=u.layerDefinition.drawingInfo;l&&(l.labelingInfo=a)}}}let p;e?.renderer||r||(delete n.layerDefinition.drawingInfo,delete o.layerDefinition.drawingInfo,delete s.layerDefinition.drawingInfo,delete u.layerDefinition.drawingInfo);const f=e?.fieldsIndex,d=e?.renderer;if(f){const t=new Set;r&&await c(t,e),d&&"function"==typeof d.collectRequiredFields&&await d.collectRequiredFields(t,f),p=Array.from(t);const a=f.fields.map(e=>e.toJSON());n.layerDefinition.fields=a,o.layerDefinition.fields=a,s.layerDefinition.fields=a,u.layerDefinition.fields=a}const m=t?.length;let g;for(let c=0;c<m;c++){const e=t[c]||t.at(c);if(!1!==e.visible&&e.geometry){if(g=e.toJSON(),g.hasOwnProperty("popupTemplate")&&delete g.popupTemplate,g.geometry?.z&&delete g.geometry.z,g.symbol&&(g.symbol.angle||delete g.symbol.angle,Se(g.symbol)?g.symbol=await me(g.symbol,i):g.symbol.text&&delete g.attributes),(!a||!a.forceFeatureAttributes)&&p?.length){const e={};for(const t of p)g.attributes?.hasOwnProperty(t)&&(e[t]=g.attributes[t]);g.attributes=e}"polygon"===e.geometry.type?n.featureSet.features.push(g):"polyline"===e.geometry.type?o.featureSet.features.push(g):"point"===e.geometry.type?g.symbol?.text?y.featureSet.features.push(g):s.featureSet.features.push(g):"multipoint"===e.geometry.type?u.featureSet.features.push(g):"extent"===e.geometry.type&&(g.geometry=l.fromExtent(e.geometry).toJSON(),n.featureSet.features.push(g))}}const h=[n,o,u,s,y].filter(e=>e.featureSet.features.length>0);for(const l of h){const e=l.featureSet.features.every(e=>e.symbol);if(e&&(!a||!a.forceFeatureAttributes))for(const t of l.featureSet.features)delete t.attributes;e&&delete l.layerDefinition.drawingInfo,l.layerDefinition.drawingInfo?.renderer&&await ge(l.layerDefinition.drawingInfo.renderer,i)}return h.length?{featureCollection:{layers:h},showLabels:r}:null}async function Q(e,t,a){let i;const r=e.renderer,n=parseFloat(a.cimVersion);if("binning"===e.featureReduction?.type||"cluster"===e.featureReduction?.type&&(n<2.9||"pie-chart"===e.featureReduction.renderer?.type)||"pie-chart"===r?.type&&n<3.1||"dot-density"===r?.type&&n<2.6)return re(e,t,a);e.legendEnabled&&a.legendLayers.push({id:e.id});const o=t.layerView,{printTemplate:s,view:l}=t,c="feature-layer"!==e.source?.type&&"ogc-feature"!==e.source?.type;if(o.filter||c||!r||"field"in r&&null!=r.field&&!e.getField(r.field)){const t=await he(o);i=await G(e,t,s,a)}else{if(i={id:(p=be(e)).id,title:p.title,url:p.url,layerType:p.layerType,customParameters:p.customParameters,layerDefinition:p.layerDefinition,charts:s.includeCharts?p.charts:void 0},s.attributionVisible&&(i.credits=I(e)),i.showLabels=s.showLabels&&e.labelsVisible,de(i,e),delete i.layerDefinition?.featureReduction?.disablePopup,delete i.layerDefinition?.featureReduction?.popupInfo,o.displayFilterEnabled||delete i.layerDefinition?.displayFilterInfo,i.layerDefinition?.drawingInfo?.renderer&&(delete i.layerDefinition.minScale,delete i.layerDefinition.maxScale,await ge(i.layerDefinition.drawingInfo.renderer,a),"visualVariables"in r&&r.visualVariables?.[0])){const e=r.visualVariables[0];if("size"===e.type&&e.maxSize&&"number"!=typeof e.maxSize&&e.minSize&&"number"!=typeof e.minSize){const t=y(e,l.scale);i.layerDefinition.drawingInfo.renderer.visualVariables[0].minSize=t.minSize,i.layerDefinition.drawingInfo.renderer.visualVariables[0].maxSize=t.maxSize}}const t=u(o);if(t&&(i.layerDefinition??={},i.layerDefinition.definitionExpression=i.layerDefinition.definitionExpression?`(${i.layerDefinition.definitionExpression}) AND (${t})`:t),e.gdbVersion&&(i.layerDefinition??={},i.layerDefinition.gdbVersion=e.gdbVersion),o.hasHighlight&&"highlightIds"in o){const t=o;i.selectionObjectIds=t.highlightIds,i.selectionSymbol=v(e.geometryType,t.highlightOptions??l.highlightOptions)}}var p;return i}async function H(e,t,a){if("binning"===e.featureReduction?.type||"cluster"===e.featureReduction?.type)return re(e,t,a);e.legendEnabled&&a.legendLayers.push({id:e.id});return G(e,await he(t.layerView),t.printTemplate,a)}async function X(e,{printTemplate:t},a){return G(e,null,t,a)}function Y(e,t){e.legendEnabled&&t.legendLayers.push({id:e.id});const a={layerType:(i=be(e)).layerType,customParameters:i.customParameters};var i;return a.bandIds=e.bandIds,a.compressionQuality=e.compressionQuality,a.format=e.format,a.interpolation=e.interpolation,(e.mosaicRule||e.definitionExpression)&&(a.mosaicRule=e.exportImageServiceParameters.mosaicRule.toJSON()),e.rasterFunction&&(a.renderingRule=e.rasterFunction.toJSON()),e.renderer&&(a.layerDefinition??={},a.layerDefinition.drawingInfo??={},a.layerDefinition.drawingInfo.renderer=e.renderer.toJSON()),de(a,e),a}async function Z(e,t,a){if("flow"===e.renderer?.type)return re(e,t,a);e.legendEnabled&&a.legendLayers.push({id:e.id});const i={bandIds:(r=be(e)).bandIds,customParameters:r.customParameters,interpolation:r.interpolation,layerDefinition:r.layerDefinition};var r;return i.layerType="ArcGISImageServiceLayer",de(i,e),i}async function ee(e,t,a){const i=t.printTemplate;if(!e.portalItem||"public"===e.portalItem.access){const t=be(e,"web-map");return t.type="kml",delete t.layerType,t.url=s(e.url),t}const r=[],n=t.layerView,o="data:image/png;base64,";n.allVisibleMapImages.forEach((t,a)=>{const i={id:`${e.id}_image${a}`,type:"image",title:e.id,minScale:e.minScale||0,maxScale:e.maxScale||0,opacity:n.fullOpacity,extent:t.extent};t.href.startsWith(o)?i.imageData=t.href.slice(o.length):i.url=t.href,r.push(i)});const l=[...n.allVisiblePoints.items,...n.allVisiblePolylines.items,...n.allVisiblePolygons.items],c={id:e.id,...await G(null,l,i,a)};return r.push(c),r}function te(e,{printTemplate:t,view:a},i){let r;const n={id:e.id,subLayerIds:[]};let o=[];const s=a.scale,l=e=>{const t=0===s,a=0===e.minScale||s<=e.minScale,i=0===e.maxScale||s>=e.maxScale;if(e.visible&&(t||a&&i))if(e.sublayers)e.sublayers.forEach(l);else{const t=e.toExportImageJSON(),a={id:e.id,name:e.title,layerDefinition:{definitionExpression:t.definitionExpression,drawingInfo:t.drawingInfo,orderBy:t.orderBy,source:t.source}};o.unshift(a),n.subLayerIds.push(e.id)}};var c;return e.sublayers&&e.sublayers.forEach(l),o.length&&(o=o.map(({id:e,name:t,layerDefinition:a})=>({id:e,name:t,layerDefinition:a})),r={layerType:(c=be(e)).layerType,customParameters:c.customParameters},r.layers=o,r.visibleLayers=e.capabilities?.exportMap?.supportsDynamicLayers?void 0:n.subLayerIds,t.attributionVisible&&(r.credits=I(e)),e.gdbVersion&&(r.gdbVersion=e.gdbVersion),de(r,e),e.legendEnabled&&i.legendLayers.push(n)),r}async function ae({layerView:e,printTemplate:t},a){const i=[],r=e.layer;if(null!=r.featureCollections)for(const n of r.featureCollections){const e=await G(n,n.source,t,a);e&&i.push(...e.featureCollection.layers)}else if(null!=r.sublayers)for(const n of r.sublayers){const e=await G(null,n.graphics,t,a);e&&i.push(...e.featureCollection.layers)}return{featureCollection:{layers:i}}}function ie(){return{type:"OpenStreetMap"}}async function re(e,{printTemplate:t,view:a},r){const n={type:"image"},s={format:"png",ignoreBackground:!0,ignorePadding:!0,layers:[e]};0!==a.rotation&&(s.rotation=0);const l=r.ssExtent||a.state.extent.clone();let c=96,u=!0,y=!0;if(t.exportOptions){const e=t.exportOptions;null!=e.dpi&&e.dpi>0&&(c=e.dpi),null!=e.width&&e.width>0&&(u=e.width%2==a.width%2),null!=e.height&&e.height>0&&(y=e.height%2==a.height%2)}if("map-only"===t.layout&&t.scalePreserved&&(!t.outScale||t.outScale===a.scale)&&96===c&&(!u||!y)&&a.state.extent.equals(a.extent)&&(s.area={x:0,y:0,width:a.width,height:a.height},u||(s.area.width-=1),y||(s.area.height-=1),!r.ssExtent)){const e=a.toMap(i(s.area.width,s.area.height));l.ymin=e.y,l.xmax=e.x,r.ssExtent=l}n.extent=l.clone()._normalize(!0).toJSON();const p=await a.takeScreenshot(s);return n.imageData=o(p.dataUrl)?.data,n}async function ne(e,{layerView:t,printTemplate:a},i){e.legendEnabled&&i.legendLayers.push({id:e.id});return G(e,await he(t),a,i)}async function oe(e,t){if(e.legendEnabled)for(const r of e.sublayers)r.legendEnabled&&t.legendLayers.push({id:r.id});const a={customParameters:(i=be(e)).customParameters,effect:i.effect,layerDefinition:i.layerDefinition,layerType:i.layerType,layers:i.layers,url:i.url};var i;if(de(a,e),Array.isArray(a.layers)){for(const e of a.layers)delete e.popupInfo;a.token&&a.layers.length>0&&(a.layers[a.layers.length-1].token=a.token,delete a.token)}return a}async function se(e){const t=[],a=[];for(const i of e.map.allTables)"feature"!==i.type||i.loaded||a.push(i.load());a.length&&await Promise.allSettled(a);for(const i of e.map.allTables)if("feature"===i.type&&i.loaded&&i.isTable&&"feature-layer"===i.source?.type){const e=(e=>({id:e.id,title:e.title,customParameters:e.customParameters,layerDefinition:{definitionExpression:e.layerDefinition?.definitionExpression},url:e.url}))(be(i));de(e,i),t.push(e)}return t.length?t:void 0}function le(e,t){e.legendEnabled&&t.legendLayers.push({id:e.id});const a={layerType:(i=be(e)).layerType,customParameters:i.customParameters};var i;return de(a,e),a}async function ce(e,t,a){const i=t.layerView;if(e.serviceUrl&&e.styleUrl&&!i.spriteSourceChanged&&!i.styleChanged){const t=f(e.styleUrl,e.apiKey),i=f(e.serviceUrl,e.apiKey);if(!t&&!i||"2.1.0"!==a.cimVersion){const a={type:"VectorTileLayer"};return a.styleUrl=s(e.styleUrl),a.token=t,i!==t&&(a.additionalTokens=[{url:e.serviceUrl,token:i}]),a}}return re(e,t,a)}function ue(e){const t=e.urlTemplate?.replace(/\${/g,"{"),a={type:"WebTiledLayer",urlTemplate:t,credits:e.copyright};return e.subDomains&&e.subDomains.length>0&&(a.subDomains=e.subDomains),a}async function ye(e,t,a){return parseFloat(a.cimVersion)<3.5?re(e,t,a):(e.legendEnabled&&a.legendLayers.push({id:e.id}),{layerType:(i=be(e,"web-map")).layerType,layerDefinition:i.layerDefinition,url:i.url,wfsInfo:i.wfsInfo});var i}function pe(e,t){let a;const i=[],r=e=>{e.visible&&(e.sublayers?e.sublayers.forEach(r):e.name&&i.unshift(e.name))};return e.sublayers&&e.sublayers.forEach(r),i.length&&(e.legendEnabled&&t.legendLayers.push({id:e.id,subLayerIds:i}),a={type:"wms",customLayerParameters:e.customLayerParameters,customParameters:e.customParameters,transparentBackground:e.imageTransparency,visibleLayers:i,url:s(e.url),version:e.version}),a}function fe(e){const t=e.activeLayer;return{type:"wmts",customLayerParameters:e.customLayerParameters,customParameters:e.customParameters,format:t.imageFormat,layer:t.id,style:t.styleId,tileMatrixSet:t.tileMatrixSetId,url:s(e.url)}}function de(e,t){t.url&&(e.url=s(e.url||t.url),e.token=f(e.url,t.apiKey))}async function me(e,a){a.canvas||(a.canvas=document.createElement("canvas"));const i=1024;a.canvas.width=i,a.canvas.height=i;const o=a.canvas.getContext("2d");let s,l;if(e.path){const t=new Path2D(e.path);t.closePath(),o.fillStyle=Array.isArray(e.color)?`rgba(${e.color[0]},${e.color[1]},${e.color[2]},${e.color[3]/255})`:"rgb(0,0,0)",o.fill(t);const a=E(o);if(!a)return null;o.clearRect(0,0,i,i);const n=r(e.size)/Math.max(a.width,a.height);o.scale(n,n);const c=i/n,u=c/2-a.width/2-a.x,y=c/2-a.height/2-a.y;if(o.translate(u,y),Array.isArray(e.color)&&o.fill(t),e.outline?.width&&Array.isArray(e.outline.color)){const i=e.outline;o.lineWidth=r(i.width)/n,o.lineJoin="round",o.strokeStyle=`rgba(${i.color[0]},${i.color[1]},${i.color[2]},${i.color[3]/255})`,o.stroke(t),a.width+=o.lineWidth,a.height+=o.lineWidth}a.width*=n,a.height*=n;const p=o.getImageData(i/2-a.width/2,i/2-a.height/2,Math.ceil(a.width),Math.ceil(a.height));s=p.width,l=p.height,o.canvas.width=s,o.canvas.height=l,o.putImageData(p,0,0)}else{const a="image/svg+xml"===e.contentType?"data:image/svg+xml;base64,"+e.imageData:e.url,i=(await t(a,{responseType:"image"})).data;s=r(e.width),l=r(e.height),o.canvas.width=s,o.canvas.height=l,o.drawImage(i,0,0,o.canvas.width,o.canvas.height)}return{type:"esriPMS",imageData:o.canvas.toDataURL("image/png").slice(22),angle:e.angle,contentType:"image/png",height:n(l),width:n(s),xoffset:e.xoffset,yoffset:e.yoffset}}async function ge(e,t){const a=e.type;if("simple"===a&&Se(e.symbol))e.symbol=await me(e.symbol,t);else if("uniqueValue"===a||"classBreaks"===a){Se(e.defaultSymbol)&&(e.defaultSymbol=await me(e.defaultSymbol,t));const i=e["uniqueValue"===a?"uniqueValueInfos":"classBreakInfos"];if(i)for(const e of i)Se(e.symbol)&&(e.symbol=await me(e.symbol,t))}}async function he(e){return e.queryFeatures(e.createQuery()).then(e=>e.features)}function be(e,t){return e.write({},{ignorePersistenceEnabled:!0,origin:t})??{}}function we(e){return e.gpMetadata?.executionType?k.fromJSON(e.gpMetadata.executionType):"sync"}function Se(e){return e&&(e.path||"image/svg+xml"===e.contentType||e.url?.endsWith(".svg"))}export{R as execute,_ as getGpPrintParams,$ as getGpServerUrl,J as getMode,C as getTaskExecutionMode,A as getTaskInfo,j as getTaskInfos,N as printCacheMap};
5
+ import{id as e}from"../kernel.js";import t from"../request.js";import{JSONMap as i}from"../core/jsonMap.js";import{createScreenPoint as a,pt2px as r,px2pt as n}from"../core/screenUtils.js";import{dataComponents as o,normalize as s}from"../core/urlUtils.js";import l from"../geometry/Polygon.js";import{collectLabelingFields as c}from"../layers/support/fieldUtils.js";import{getFloorFilterClause as u}from"../layers/support/floorFilterUtils.js";import{getSizeRangeAtScale as y}from"../renderers/visualVariables/support/visualVariableUtils.js";import{asValidOptions as p,findToken as f}from"./utils.js";import{execute as d}from"./geoprocessor/execute.js";import{submitJob as m}from"./geoprocessor/submitJob.js";import{formatJsonMap as g}from"./support/fileFormat.js";import{toJSON as h}from"./support/layoutTemplate.js";import{getVisibleLayerViews as b,isScreenshotRequired as w,isBingMapsLayer as S,isBlendLayer as x,getCopyright as I,getSelectionSymbol as v,createPointLayer as D,createPolygonLayer as T,createPolylineLayer as L,createMultipointLayer as O,getContextBoundingBox as E}from"./support/printTaskUtils.js";import P from"./support/PrintTemplate.js";import{toJSON as M}from"./support/reportTemplate.js";import{getDefaultHighlightOptions as V}from"../views/2d/support/highlightOptionsUtils.js";import F from"../views/support/HighlightOptions.js";const k={Feet:"ft",Kilometers:"km",Meters:"m",Miles:"mi"},N=new i({esriFeet:"Feet",esriKilometers:"Kilometers",esriMeters:"Meters",esriMiles:"Miles"}),U=new i({esriExecutionTypeSynchronous:"sync",esriExecutionTypeAsynchronous:"async"}),R=new Map;async function j(e,t,i){const a=await J(e,i),r=await $(t,a);if("sync"===await A(e,i)){const{results:t}=await d(e,r,void 0,i);return t?.[0]?.value}const n=await m(e,r,void 0,i);await n.waitForJobCompletion({interval:t.updateDelay});const{value:o}=await n.fetchResultData("Output_File",null,i);return o}async function J(e,i){const a=q(e),r=R.get(a)??{gpServerUrl:a,legendLayerNameMap:{},legendLayers:[]};return r.gpMetadata??=(await t(a,p({f:"json"},i))).data,r.cimVersion=r.gpMetadata.cimVersion,R.set(a,r),r}async function A(e,t){return xe(await J(e,t))}async function C(e,i){const a=await J(e,i),r=a.gpMetadata.tasks,n=a.gpServerUrl;return a.taskInfos||(a.taskInfos={},await Promise.all(r?.map(async e=>{const r=(await t(`${n}/${e}`,p({f:"json"},i))).data,o=r.name.startsWith("GetLayoutTemplatesInfo")?"GetLayoutTemplatesInfo":r.name.startsWith("ExportWebMap")?"ExportWebMap":null;o&&(a.taskInfos[o]??=r)})??[])),a.taskInfos}async function _(e,t,i){return(await C(e,i))[t]??null}async function z(e,t,i){const a=await _(e,t,i);return a?.executionType?U.fromJSON(a.executionType):"sync"}async function $(t,i){i=i||{is11xService:!1,legendLayerNameMap:{},legendLayers:[]};const a=t.template||new P;null==a.showLabels&&(a.showLabels=!0);const r=a.exportOptions;let n;const o=h(a.layout);if(r){if(n={dpi:r.dpi},"map_only"===o?.toLowerCase()||""===o){const{width:e,height:t}=r;n.outputSize=null!=e&&null!=t?[e,t]:void 0}}const s=a.layoutOptions;let l;if(s){let e,t;"Miles"===s.scalebarUnit||"Kilometers"===s.scalebarUnit?(e="Kilometers",t="Miles"):"Meters"!==s.scalebarUnit&&"Feet"!==s.scalebarUnit||(e="Meters",t="Feet"),l={titleText:s.titleText,authorText:s.authorText,copyrightText:s.copyrightText,customTextElements:s.customTextElements,elementOverrides:s.elementOverrides,scaleBarOptions:e||t?{metricUnit:N.toJSON(e)??void 0,metricLabel:e?k[e]:void 0,nonMetricUnit:N.toJSON(t)??void 0,nonMetricLabel:t?k[t]:void 0}:void 0}}let c=null;s?.legendLayers&&(c=s.legendLayers.map(e=>{const t=e.layerId;i.legendLayerNameMap[t]=e.title;const a={id:t};return e.subLayerIds&&(a.subLayerIds=e.subLayerIds),a}));const u=await W(t,a,i);if(u.operationalLayers){const e=new RegExp("[\\u4E00-\\u9FFF\\u0E00-\\u0E7F\\u0900-\\u097F\\u3040-\\u309F\\u30A0-\\u30FF\\u31F0-\\u31FF]"),t=/[\u0600-\u06FF]/,i=i=>{const a=i.text,r=i.font,n=r?.family?.toLowerCase();a&&r&&("arial"===n||"arial unicode ms"===n)&&(r.family=e.test(a)?"Arial Unicode MS":"Arial","normal"!==r.style&&t.test(a)&&(r.family="Arial Unicode MS"))};for(const a of u.operationalLayers)if(a.featureCollection?.layers)for(const e of a.featureCollection.layers){if(e.layerDefinition?.drawingInfo?.renderer?.symbol){const t=e.layerDefinition.drawingInfo.renderer;"esriTS"===t.symbol.type&&i(t.symbol)}if(e.featureSet?.features)for(const t of e.featureSet.features)t.symbol&&"esriTS"===t.symbol.type&&i(t.symbol)}}t.outSpatialReference&&(u.mapOptions.spatialReference=t.outSpatialReference.toJSON()),Object.assign(u,{exportOptions:n,layoutOptions:l||{}}),Object.assign(u.layoutOptions,{legendOptions:{operationalLayers:null!=c?c:i.legendLayers.slice()}}),i.legendLayers.length=0,R.set(i.gpServerUrl,i);const y={Web_Map_as_JSON:JSON.stringify(u),Format:g.toJSON(a.format),Layout_Template:o,Layout_Item_ID:void 0,Report_Template:M(a.report),Report_Item_ID:void 0};if(a.layoutItem){delete y.Layout_Template;const t=a.layoutItem;await t.load(),"public"!==t.access&&e&&await e.getCredential(i.gpServerUrl),y.Layout_Item_ID=JSON.stringify({id:t.id})}if(a.reportItem){delete y.Report_Template;const t=a.reportItem;await t.load(),"public"!==t.access&&e&&await e.getCredential(i.gpServerUrl),y.Report_Item_ID=JSON.stringify({id:t.id})}return t.extraParameters&&Object.assign(y,t.extraParameters),y}async function W(e,t,i){const a=e.view;let r=a.spatialReference;const n={operationalLayers:await B(a,t,i)};t.includeTables&&(n.tables=await ce(a));let o=e.extent||i.ssExtent||a.extent;if(r?.isWrappable&&(o=o.clone()._normalize(!0),r=o.spatialReference),n.mapOptions={extent:o&&o.toJSON(),spatialReference:r&&r.toJSON(),showAttribution:t.attributionVisible},i.ssExtent=null,a.background&&(n.background=a.background.toJSON()),a.rotation&&(n.mapOptions.rotation=-a.rotation),t.scalePreserved&&(n.mapOptions.scale=t.outScale||a.scale),null!=a.timeExtent){const e=null!=a.timeExtent.start?a.timeExtent.start.getTime():null,t=null!=a.timeExtent.end?a.timeExtent.end.getTime():null;n.mapOptions.time=[e,t]}return t.reportOptions&&(n.reportOptions=t.reportOptions),n}function q(e){let t=e;const i=t.lastIndexOf("/GPServer/");return i>0&&(t=t.slice(0,i+9)),t}async function B(e,t,i){const a=[],r={layerView:null,printTemplate:t,view:e};let n=0;t.scalePreserved&&(n=t.outScale||e.scale);const o=b(e,n);for(const s of o){const e=s.layer;if(!e.loaded||"layers"in e)continue;let t;r.layerView=s,t=w(s)?await oe(e,r,i):S(e)?K(e):"csv"===e?.type?await H(e,r,i):"catalog-footprint"===e?.type?await G(e,r,i):"feature"===e?.type?await X(e,r,i):"geojson"===e?.type?await Y(e,r,i):"graphics"===e?.type?await Z(e,r,i):"imagery"===e?.type?ee(e,i):"imagery-tile"===e?.type?await te(e,r,i):"kml"===e?.type?await ie(e,r,i):"map-image"===e?.type?ae(e,r,i):"map-notes"===e?.type?await re(r,i):"open-street-map"===e?.type?ne():"stream"===e?.type?await se(e,r,i):"subtype-group"===e?.type?await le(e,i):"tile"===e?.type?ue(e,i):"vector-tile"===e?.type?await ye(e,r,i):"web-tile"===e?.type?pe(e):"wfs"===e?.type?await fe(e,r,i):"wms"===e?.type?de(e,i):"wmts"===e?.type?me(e):await oe(e,r,i),t&&(Array.isArray(t)?a.push(...t):(t.id=e.id,t.title=i.legendLayerNameMap[e.id]||e.title,t.opacity=s.fullOpacity,t.minScale=e.minScale||0,t.maxScale=e.maxScale||0,x(e)&&e.blendMode&&"normal"!==e.blendMode&&(t.blendMode=e.blendMode),a.push(t)))}if(n)for(const s of a)s.minScale=0,s.maxScale=0;if(e.graphics?.length){const r=await Q(null,e.graphics,t,i);r&&a.push(r)}return a}function K(e){return{culture:e.culture,key:e.key,type:"BingMaps"+("aerial"===e.style?"Aerial":"hybrid"===e.style?"Hybrid":"Road")}}async function G(e,{layerView:t,printTemplate:i},a){if(parseFloat(a.cimVersion)<3.1){return Q(e,await we(t),i,a)}const r=e.parent,n={id:(o=Se(r,"web-map")).id,url:o.url,layerType:o.layerType,customParameters:o.customParameters,dynamicGroupLayer:{visibility:!1},footprintLayer:o.footprintLayer,layerDefinition:o.layerDefinition};var o;return ge(n,r),n}async function H(e,t,i){e.legendEnabled&&i.legendLayers.push({id:e.id});const a=t.layerView,r=t.printTemplate;if(!(a.filter||e.portalItem&&"public"!==e.portalItem.access)){const t=Se(e,"web-map");return t.type="CSV",delete t.popupInfo,delete t.layerType,t.showLabels=r.showLabels&&e.labelsVisible,t}return Q(e,await we(a),r,i)}async function Q(e,t,i,a){let r;const n=T(),o=L(),s=D(),u=O(),y=D();if(y.layerDefinition.name="textLayer",delete y.layerDefinition.drawingInfo,e){if("esri.layers.FeatureLayer"===e.declaredClass||"esri.layers.StreamLayer"===e.declaredClass?n.layerDefinition.name=o.layerDefinition.name=s.layerDefinition.name=u.layerDefinition.name=a.legendLayerNameMap[e.id]||e.arcgisProps?.title||e.title:"esri.layers.GraphicsLayer"===e.declaredClass&&(t=e.graphics.items),e.renderer){const t=e.renderer.toJSON(),i=n.layerDefinition.drawingInfo;i&&(i.renderer=t);const a=o.layerDefinition.drawingInfo;a&&(a.renderer=t);const r=s.layerDefinition.drawingInfo;r&&(r.renderer=t);const l=u.layerDefinition.drawingInfo;l&&(l.renderer=t)}if(i.showLabels&&e.labelsVisible&&"function"==typeof e.write){const t=Se(e,"web-map"),i=t.layerDefinition?.drawingInfo?.labelingInfo;if(i){r=!0;const e=n.layerDefinition.drawingInfo;e&&(e.labelingInfo=i);const t=o.layerDefinition.drawingInfo;t&&(t.labelingInfo=i);const a=s.layerDefinition.drawingInfo;a&&(a.labelingInfo=i);const l=u.layerDefinition.drawingInfo;l&&(l.labelingInfo=i)}}}let p;e?.renderer||r||(delete n.layerDefinition.drawingInfo,delete o.layerDefinition.drawingInfo,delete s.layerDefinition.drawingInfo,delete u.layerDefinition.drawingInfo);const f=e?.fieldsIndex,d=e?.renderer;if(f){const t=new Set;r&&await c(t,e),d&&"function"==typeof d.collectRequiredFields&&await d.collectRequiredFields(t,f),p=Array.from(t);const i=f.fields.map(e=>e.toJSON());n.layerDefinition.fields=i,o.layerDefinition.fields=i,s.layerDefinition.fields=i,u.layerDefinition.fields=i}const m=t?.length;let g;for(let c=0;c<m;c++){const e=t[c]||t.at(c);if(!1!==e.visible&&e.geometry){if(g=e.toJSON(),g.hasOwnProperty("popupTemplate")&&delete g.popupTemplate,g.geometry?.z&&delete g.geometry.z,g.symbol&&(g.symbol.angle||delete g.symbol.angle,Ie(g.symbol)?g.symbol=await he(g.symbol,a):g.symbol.text&&delete g.attributes),(!i||!i.forceFeatureAttributes)&&p?.length){const e={};for(const t of p)g.attributes?.hasOwnProperty(t)&&(e[t]=g.attributes[t]);g.attributes=e}"polygon"===e.geometry.type?n.featureSet.features.push(g):"polyline"===e.geometry.type?o.featureSet.features.push(g):"point"===e.geometry.type?g.symbol?.text?y.featureSet.features.push(g):s.featureSet.features.push(g):"multipoint"===e.geometry.type?u.featureSet.features.push(g):"extent"===e.geometry.type&&(g.geometry=l.fromExtent(e.geometry).toJSON(),n.featureSet.features.push(g))}}const h=[n,o,u,s,y].filter(e=>e.featureSet.features.length>0);for(const l of h){const e=l.featureSet.features.every(e=>e.symbol);if(e&&(!i||!i.forceFeatureAttributes))for(const t of l.featureSet.features)delete t.attributes;e&&delete l.layerDefinition.drawingInfo,l.layerDefinition.drawingInfo?.renderer&&await be(l.layerDefinition.drawingInfo.renderer,a)}return h.length?{featureCollection:{layers:h},showLabels:r}:null}async function X(e,t,i){let a;const r=e.renderer,n=parseFloat(i.cimVersion);if("binning"===e.featureReduction?.type||"cluster"===e.featureReduction?.type&&(n<2.9||"pie-chart"===e.featureReduction.renderer?.type)||"pie-chart"===r?.type&&n<3.1||"dot-density"===r?.type&&n<2.6)return oe(e,t,i);e.legendEnabled&&i.legendLayers.push({id:e.id});const o=t.layerView,{printTemplate:s,view:l}=t,c="feature-layer"!==e.source?.type&&"ogc-feature"!==e.source?.type;if(o.filter||c||!r||"field"in r&&null!=r.field&&!e.getField(r.field)){const t=await we(o);a=await Q(e,t,s,i)}else{if(a={id:(p=Se(e)).id,title:p.title,url:p.url,layerType:p.layerType,customParameters:p.customParameters,layerDefinition:p.layerDefinition,charts:s.includeCharts?p.charts:void 0},s.attributionVisible&&(a.credits=I(e)),a.showLabels=s.showLabels&&e.labelsVisible,ge(a,e),delete a.layerDefinition?.featureReduction?.disablePopup,delete a.layerDefinition?.featureReduction?.popupInfo,o.displayFilterEnabled||delete a.layerDefinition?.displayFilterInfo,a.layerDefinition?.drawingInfo?.renderer&&(delete a.layerDefinition.minScale,delete a.layerDefinition.maxScale,await be(a.layerDefinition.drawingInfo.renderer,i),"visualVariables"in r&&r.visualVariables?.[0])){const e=r.visualVariables[0];if("size"===e.type&&e.maxSize&&"number"!=typeof e.maxSize&&e.minSize&&"number"!=typeof e.minSize){const t=y(e,l.scale);a.layerDefinition.drawingInfo.renderer.visualVariables[0].minSize=t.minSize,a.layerDefinition.drawingInfo.renderer.visualVariables[0].maxSize=t.maxSize}}const t=u(o);if(t&&(a.layerDefinition??={},a.layerDefinition.definitionExpression=a.layerDefinition.definitionExpression?`(${a.layerDefinition.definitionExpression}) AND (${t})`:t),e.gdbVersion&&(a.layerDefinition??={},a.layerDefinition.gdbVersion=e.gdbVersion),o.hasHighlight&&"highlightIds"in o){const t=o;a.selectionObjectIds=t.highlightIds;const i=V(t)||V(l)||new F;a.selectionSymbol=v(e.geometryType,i)}}var p;return a}async function Y(e,t,i){if("binning"===e.featureReduction?.type||"cluster"===e.featureReduction?.type)return oe(e,t,i);e.legendEnabled&&i.legendLayers.push({id:e.id});return Q(e,await we(t.layerView),t.printTemplate,i)}async function Z(e,{printTemplate:t},i){return Q(e,null,t,i)}function ee(e,t){e.legendEnabled&&t.legendLayers.push({id:e.id});const i={layerType:(a=Se(e)).layerType,customParameters:a.customParameters};var a;return i.bandIds=e.bandIds,i.compressionQuality=e.compressionQuality,i.format=e.format,i.interpolation=e.interpolation,(e.mosaicRule||e.definitionExpression)&&(i.mosaicRule=e.exportImageServiceParameters.mosaicRule.toJSON()),e.rasterFunction&&(i.renderingRule=e.rasterFunction.toJSON()),e.renderer&&(i.layerDefinition??={},i.layerDefinition.drawingInfo??={},i.layerDefinition.drawingInfo.renderer=e.renderer.toJSON()),ge(i,e),i}async function te(e,t,i){if("flow"===e.renderer?.type)return oe(e,t,i);e.legendEnabled&&i.legendLayers.push({id:e.id});const a={bandIds:(r=Se(e)).bandIds,customParameters:r.customParameters,interpolation:r.interpolation,layerDefinition:r.layerDefinition};var r;return a.layerType="ArcGISImageServiceLayer",ge(a,e),a}async function ie(e,t,i){const a=t.printTemplate;if(!e.portalItem||"public"===e.portalItem.access){const t=Se(e,"web-map");return t.type="kml",delete t.layerType,t.url=s(e.url),t}const r=[],n=t.layerView,o="data:image/png;base64,";n.allVisibleMapImages.forEach((t,i)=>{const a={id:`${e.id}_image${i}`,type:"image",title:e.id,minScale:e.minScale||0,maxScale:e.maxScale||0,opacity:n.fullOpacity,extent:t.extent};t.href.startsWith(o)?a.imageData=t.href.slice(o.length):a.url=t.href,r.push(a)});const l=[...n.allVisiblePoints.items,...n.allVisiblePolylines.items,...n.allVisiblePolygons.items],c={id:e.id,...await Q(null,l,a,i)};return r.push(c),r}function ae(e,{printTemplate:t,view:i},a){let r;const n={id:e.id,subLayerIds:[]};let o=[];const s=i.scale,l=e=>{const t=0===s,i=0===e.minScale||s<=e.minScale,a=0===e.maxScale||s>=e.maxScale;if(e.visible&&(t||i&&a))if(e.sublayers)e.sublayers.forEach(l);else{const t=e.toExportImageJSON(),i={id:e.id,name:e.title,layerDefinition:{definitionExpression:t.definitionExpression,drawingInfo:t.drawingInfo,orderBy:t.orderBy,source:t.source}};o.unshift(i),n.subLayerIds.push(e.id)}};var c;return e.sublayers?.forEach(l),o.length&&(o=o.map(({id:e,name:t,layerDefinition:i})=>({id:e,name:t,layerDefinition:i})),r={layerType:(c=Se(e)).layerType,customParameters:c.customParameters},r.layers=o,r.visibleLayers=e.capabilities?.exportMap?.supportsDynamicLayers?void 0:n.subLayerIds,t.attributionVisible&&(r.credits=I(e)),e.gdbVersion&&(r.gdbVersion=e.gdbVersion),ge(r,e),e.legendEnabled&&a.legendLayers.push(n)),r}async function re({layerView:e,printTemplate:t},i){const a=[],r=e.layer;if(null!=r.featureCollections)for(const n of r.featureCollections){const e=await Q(n,n.source,t,i);e&&a.push(...e.featureCollection.layers)}else if(null!=r.sublayers)for(const n of r.sublayers){const e=await Q(null,n.graphics,t,i);e&&a.push(...e.featureCollection.layers)}return{featureCollection:{layers:a}}}function ne(){return{type:"OpenStreetMap"}}async function oe(e,{printTemplate:t,view:i},r){const n={type:"image"},s={format:"png",ignoreBackground:!0,ignorePadding:!0,layers:[e]};0!==i.rotation&&(s.rotation=0);const l=r.ssExtent||i.state.extent.clone();let c=96,u=!0,y=!0;if(t.exportOptions){const e=t.exportOptions;null!=e.dpi&&e.dpi>0&&(c=e.dpi),null!=e.width&&e.width>0&&(u=e.width%2==i.width%2),null!=e.height&&e.height>0&&(y=e.height%2==i.height%2)}if("map-only"===t.layout&&t.scalePreserved&&(!t.outScale||t.outScale===i.scale)&&96===c&&(!u||!y)&&i.state.extent.equals(i.extent)&&(s.area={x:0,y:0,width:i.width,height:i.height},u||(s.area.width-=1),y||(s.area.height-=1),!r.ssExtent)){const e=i.toMap(a(s.area.width,s.area.height));l.ymin=e.y,l.xmax=e.x,r.ssExtent=l}n.extent=l.clone()._normalize(!0).toJSON();const p=await i.takeScreenshot(s);return n.imageData=o(p.dataUrl)?.data,n}async function se(e,{layerView:t,printTemplate:i},a){e.legendEnabled&&a.legendLayers.push({id:e.id});return Q(e,await we(t),i,a)}async function le(e,t){if(e.legendEnabled)for(const r of e.sublayers)r.legendEnabled&&t.legendLayers.push({id:r.id});const i={customParameters:(a=Se(e)).customParameters,effect:a.effect,layerDefinition:a.layerDefinition,layerType:a.layerType,layers:a.layers,url:a.url};var a;if(ge(i,e),Array.isArray(i.layers)){for(const e of i.layers)delete e.popupInfo;i.token&&i.layers.length>0&&(i.layers[i.layers.length-1].token=i.token,delete i.token)}return i}async function ce(e){const t=[],i=[];for(const a of e.map.allTables)"feature"!==a.type||a.loaded||i.push(a.load());i.length&&await Promise.allSettled(i);for(const a of e.map.allTables)if("feature"===a.type&&a.loaded&&a.isTable&&"feature-layer"===a.source?.type){const e=(e=>({id:e.id,title:e.title,customParameters:e.customParameters,layerDefinition:{definitionExpression:e.layerDefinition?.definitionExpression},url:e.url}))(Se(a));ge(e,a),t.push(e)}return t.length?t:void 0}function ue(e,t){e.legendEnabled&&t.legendLayers.push({id:e.id});const i={layerType:(a=Se(e)).layerType,customParameters:a.customParameters};var a;return ge(i,e),i}async function ye(e,t,i){const a=t.layerView;if(e.serviceUrl&&e.styleUrl&&!a.spriteSourceChanged&&!a.styleChanged){const t=f(e.styleUrl,e.apiKey),a=f(e.serviceUrl,e.apiKey);if(!t&&!a||"2.1.0"!==i.cimVersion){const i={type:"VectorTileLayer"};return i.styleUrl=s(e.styleUrl),i.token=t,a!==t&&(i.additionalTokens=[{url:e.serviceUrl,token:a}]),i}}return oe(e,t,i)}function pe(e){const t=e.urlTemplate?.replace(/\${/g,"{"),i={type:"WebTiledLayer",urlTemplate:t,credits:e.copyright};return e.subDomains&&e.subDomains.length>0&&(i.subDomains=e.subDomains),i}async function fe(e,t,i){return parseFloat(i.cimVersion)<3.5?oe(e,t,i):(e.legendEnabled&&i.legendLayers.push({id:e.id}),{layerType:(a=Se(e,"web-map")).layerType,layerDefinition:a.layerDefinition,url:a.url,wfsInfo:a.wfsInfo});var a}function de(e,t){let i;const a=[],r=e=>{e.visible&&(e.sublayers?e.sublayers.forEach(r):e.name&&a.unshift(e.name))};return e.sublayers&&e.sublayers.forEach(r),a.length&&(e.legendEnabled&&t.legendLayers.push({id:e.id,subLayerIds:a}),i={type:"wms",customLayerParameters:e.customLayerParameters,customParameters:e.customParameters,transparentBackground:e.imageTransparency,visibleLayers:a,url:s(e.url),version:e.version}),i}function me(e){const t=e.activeLayer;return{type:"wmts",customLayerParameters:e.customLayerParameters,customParameters:e.customParameters,format:t.imageFormat,layer:t.id,style:t.styleId,tileMatrixSet:t.tileMatrixSetId,url:s(e.url)}}function ge(e,t){t.url&&(e.url=s(e.url||t.url),e.token=f(e.url,t.apiKey))}async function he(e,i){i.canvas||(i.canvas=document.createElement("canvas"));const a=1024;i.canvas.width=a,i.canvas.height=a;const o=i.canvas.getContext("2d");let s,l;if(e.path){const t=new Path2D(e.path);t.closePath(),o.fillStyle=Array.isArray(e.color)?`rgba(${e.color[0]},${e.color[1]},${e.color[2]},${e.color[3]/255})`:"rgb(0,0,0)",o.fill(t);const i=E(o);if(!i)return null;o.clearRect(0,0,a,a);const n=r(e.size)/Math.max(i.width,i.height);o.scale(n,n);const c=a/n,u=c/2-i.width/2-i.x,y=c/2-i.height/2-i.y;if(o.translate(u,y),Array.isArray(e.color)&&o.fill(t),e.outline?.width&&Array.isArray(e.outline.color)){const a=e.outline;o.lineWidth=r(a.width)/n,o.lineJoin="round",o.strokeStyle=`rgba(${a.color[0]},${a.color[1]},${a.color[2]},${a.color[3]/255})`,o.stroke(t),i.width+=o.lineWidth,i.height+=o.lineWidth}i.width*=n,i.height*=n;const p=o.getImageData(a/2-i.width/2,a/2-i.height/2,Math.ceil(i.width),Math.ceil(i.height));s=p.width,l=p.height,o.canvas.width=s,o.canvas.height=l,o.putImageData(p,0,0)}else{const i="image/svg+xml"===e.contentType?"data:image/svg+xml;base64,"+e.imageData:e.url,a=(await t(i,{responseType:"image"})).data;s=r(e.width),l=r(e.height),o.canvas.width=s,o.canvas.height=l,o.drawImage(a,0,0,o.canvas.width,o.canvas.height)}return{type:"esriPMS",imageData:o.canvas.toDataURL("image/png").slice(22),angle:e.angle,contentType:"image/png",height:n(l),width:n(s),xoffset:e.xoffset,yoffset:e.yoffset}}async function be(e,t){const i=e.type;if("simple"===i&&Ie(e.symbol))e.symbol=await he(e.symbol,t);else if("uniqueValue"===i||"classBreaks"===i){Ie(e.defaultSymbol)&&(e.defaultSymbol=await he(e.defaultSymbol,t));const a=e["uniqueValue"===i?"uniqueValueInfos":"classBreakInfos"];if(a)for(const e of a)Ie(e.symbol)&&(e.symbol=await he(e.symbol,t))}}async function we(e){return e.queryFeatures(e.createQuery()).then(e=>e.features)}function Se(e,t){return e.write({},{ignorePersistenceEnabled:!0,origin:t})??{}}function xe(e){return e.gpMetadata?.executionType?U.fromJSON(e.gpMetadata.executionType):"sync"}function Ie(e){return e&&(e.path||"image/svg+xml"===e.contentType||e.url?.endsWith(".svg"))}export{j as execute,$ as getGpPrintParams,q as getGpServerUrl,A as getMode,z as getTaskExecutionMode,_ as getTaskInfo,C as getTaskInfos,R as printCacheMap};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- const c="20250802",b="589bc6c2f7b2ca14c4eb9dbf065cba393f4257e0";export{c as buildDate,b as commitHash};
5
+ const b="20250806",d="7ed3634d5e3ddc792aa1325bb11351b19b915713";export{b as buildDate,d 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.34/esri/copyright.txt for details.
4
4
  */
5
- import{GeometryCursor as e}from"../../geometry/GeometryCursor.js";import{TileClipper as t}from"../../geometry/support/TileClipper.js";import{importLazily as r}from"./utils.js";const o=r(()=>import("../../geometry/operators/json/bufferOperator.js")),s=r(()=>import("../../geometry/operators/json/convexHullOperator.js")),m=r(()=>import("../../geometry/operators/json/lengthOperator.js")),n=r(()=>import("../../geometry/operators/json/generalizeOperator.js")),i=r(()=>import("../../geometry/operators/json/offsetOperator.js")),p=r(()=>import("../../geometry/operators/json/simplifyOperator.js")),f=512;let c;function l(e){switch(e.type){case"CIMGeometricEffectDonut":case"CIMGeometricEffectBuffer":return o.getImportPromise();case"CIMGeometricEffectEnclosingPolygon":return s.getImportPromise();case"CIMGeometricEffectOffset":return i.getImportPromise();case"CIMGeometricEffectTaperedPolygon":return Promise.all([p.getImportPromise(),m.getImportPromise(),n.getImportPromise()]);default:return Promise.resolve()}}class a{constructor(e){this._geometry=e}next(){const e=this._geometry;return this._geometry=null,e}}function g(r,o,s){if(!r)return null;c||(c=new t(0,0,0,1));const m=s?-1:1,n="esriGeometryPolygon"===r.geometryType,i=n?3:2,p=n?3:2;let l,a;for(c.reset(i),c.setPixelMargin(o+1),c.setExtent(f);r.nextPath();)if(!(r.pathSize<p)){for(r.nextPoint(),l=r.x,a=m*r.y,c.moveTo(l,a);r.nextPoint();)l=r.x,a=m*r.y,c.lineTo(l,a);n&&c.close()}const g=c.result(!1);if(g){const t=e.createEmptyOptimizedCIM(r.geometryType);for(const e of g){t.startPath();for(const r of e)t.pushXY(r.x,m*r.y)}return t.reset(),t}return null}export{a as SimpleEffectCursor,g as clipCursorToTileExtent,o as lazyBufferOperator,s as lazyConvexHullOperator,n as lazyGeneralizeOperator,m as lazyLengthOperator,i as lazyOffsetOperator,p as lazySimplifyOperator,l as loadGeometryOperatorsForEffect};
5
+ import{GeometryCursor as e}from"../../geometry/GeometryCursor.js";import{TileClipper as r}from"../../geometry/support/TileClipper.js";import{importLazily as t}from"./utils.js";const o=t(()=>import("../../geometry/operators/json/bufferOperator.js")),s=t(()=>import("../../geometry/operators/json/convexHullOperator.js")),m=t(()=>import("../../geometry/operators/json/lengthOperator.js")),i=t(()=>import("../../geometry/operators/json/generalizeOperator.js")),n=t(()=>import("../../geometry/operators/json/graphicBufferOperator.js")),p=t(()=>import("../../geometry/operators/json/offsetOperator.js")),f=t(()=>import("../../geometry/operators/json/simplifyOperator.js")),c=512;let a;function l(e){switch(e.type){case"CIMGeometricEffectDonut":case"CIMGeometricEffectBuffer":return o.getImportPromise();case"CIMGeometricEffectEnclosingPolygon":return s.getImportPromise();case"CIMGeometricEffectOffset":return Promise.all([p.getImportPromise(),n.getImportPromise()]);case"CIMGeometricEffectTaperedPolygon":return Promise.all([f.getImportPromise(),m.getImportPromise(),i.getImportPromise()]);default:return Promise.resolve()}}class g{constructor(e){this._geometry=e}next(){const e=this._geometry;return this._geometry=null,e}}function y(t,o,s){if(!t)return null;a||(a=new r(0,0,0,1));const m=s?-1:1,i="esriGeometryPolygon"===t.geometryType,n=i?3:2,p=i?3:2;let f,l;for(a.reset(n),a.setPixelMargin(o+1),a.setExtent(c);t.nextPath();)if(!(t.pathSize<p)){for(t.nextPoint(),f=t.x,l=m*t.y,a.moveTo(f,l);t.nextPoint();)f=t.x,l=m*t.y,a.lineTo(f,l);i&&a.close()}const g=a.result(!1);if(g){const r=e.createEmptyOptimizedCIM(t.geometryType);for(const e of g){r.startPath();for(const t of e)r.pushXY(t.x,m*t.y)}return r.reset(),r}return null}export{g as SimpleEffectCursor,y as clipCursorToTileExtent,o as lazyBufferOperator,s as lazyConvexHullOperator,i as lazyGeneralizeOperator,n as lazyGraphicBufferOperator,m as lazyLengthOperator,p as lazyOffsetOperator,f as lazySimplifyOperator,l as loadGeometryOperatorsForEffect};