@arcgis/core 4.34.0-next.85 → 4.34.0-next.87

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 (286) hide show
  1. package/Basemap.js +1 -1
  2. package/Ground.js +1 -1
  3. package/Map.js +1 -1
  4. package/analysis/ElevationProfile/ElevationProfileLineGround.d.ts +4 -0
  5. package/analysis/ElevationProfile/{ElevationProfileGroundLine.js → ElevationProfileLineGround.js} +1 -1
  6. package/analysis/ElevationProfile/ElevationProfileLineInput.d.ts +4 -0
  7. package/analysis/ElevationProfile/{ElevationProfileInputLine.js → ElevationProfileLineInput.js} +1 -1
  8. package/analysis/ElevationProfile/ElevationProfileLineQuery.d.ts +4 -0
  9. package/analysis/ElevationProfile/{ElevationProfileQueryLine.js → ElevationProfileLineQuery.js} +1 -1
  10. package/analysis/ElevationProfile/ElevationProfileLineScene.d.ts +4 -0
  11. package/analysis/ElevationProfile/{ElevationProfileSceneLine.js → ElevationProfileLineScene.js} +1 -1
  12. package/analysis/ElevationProfile/elevationProfileLineTypes.js +1 -1
  13. package/analysis/ElevationProfileAnalysis.js +1 -1
  14. package/arcade/functions/measures.js +1 -1
  15. package/assets/esri/core/workers/RemoteClient.js +1 -1
  16. package/assets/esri/core/workers/chunks/0074f1836d7ff69ff6ec.js +1 -0
  17. package/assets/esri/core/workers/chunks/03ef19f0753d68770444.js +1 -0
  18. package/assets/esri/core/workers/chunks/06c389283ee5b60573f2.js +1 -0
  19. package/assets/esri/core/workers/chunks/09c2004126f4a5242b85.js +1 -0
  20. package/assets/esri/core/workers/chunks/0b679d5a1bfdbd006d6e.js +1 -0
  21. package/assets/esri/core/workers/chunks/0f05425954578ac796ec.js +1 -0
  22. package/assets/esri/core/workers/chunks/109149c378aa4c5f8526.js +1 -0
  23. package/assets/esri/core/workers/chunks/143503f6eb270c4683f8.js +1 -0
  24. package/assets/esri/core/workers/chunks/177840d5f0076c0de46b.js +316 -0
  25. package/assets/esri/core/workers/chunks/1c1b0cc91fe9cb3fec61.js +1 -0
  26. package/assets/esri/core/workers/chunks/{9eb1bfcb9b05f2a36748.js → 1f2d13466c60a6b57717.js} +1 -1
  27. package/assets/esri/core/workers/chunks/1fc6311d4f0d27e88737.js +1 -0
  28. package/assets/esri/core/workers/chunks/257fd65786feb5951b90.js +1 -0
  29. package/assets/esri/core/workers/chunks/{7a23b127f551bf13ef54.js → 268f5b233640a9dbbf89.js} +2 -2
  30. package/assets/esri/core/workers/chunks/2896ada406074f754b00.js +1 -0
  31. package/assets/esri/core/workers/chunks/28d30be414e59eabd963.js +1 -0
  32. package/assets/esri/core/workers/chunks/29471e0b3f7296dee096.js +1 -0
  33. package/assets/esri/core/workers/chunks/{3192b68675ff2afcb1d6.js → 2d3ae187f8aa3495d4ae.js} +1 -1
  34. package/assets/esri/core/workers/chunks/2dc88379ee94fabdaf52.js +1 -0
  35. package/assets/esri/core/workers/chunks/336b54144afec0c7d396.js +2 -0
  36. package/assets/esri/core/workers/chunks/366db86914a63e6d0c68.js +1 -0
  37. package/assets/esri/core/workers/chunks/{d66cdb9bb494da19696b.js → 47e4f66c33bb697fbe6b.js} +2 -2
  38. package/assets/esri/core/workers/chunks/481c2b01e2fe92249698.js +1 -0
  39. package/assets/esri/core/workers/chunks/4840bd93d8fe15c7aefd.js +1 -0
  40. package/assets/esri/core/workers/chunks/4d4db6854aff7656f6e1.js +1 -0
  41. package/assets/esri/core/workers/chunks/5c585b338a9e9aa0e205.js +1 -0
  42. package/assets/esri/core/workers/chunks/639d856cd217914dfe1f.js +1 -0
  43. package/assets/esri/core/workers/chunks/68f5a2d2666636c3f807.js +1 -0
  44. package/assets/esri/core/workers/chunks/7540b34e743a23e67729.js +1 -0
  45. package/assets/esri/core/workers/chunks/7be11a3ef1f49245089f.js +1 -0
  46. package/assets/esri/core/workers/chunks/819a8bc1f0a694017ee6.js +1 -0
  47. package/assets/esri/core/workers/chunks/{afb76f9d6abedef771df.js → 8380a092ffc8e92ede7a.js} +1 -1
  48. package/assets/esri/core/workers/chunks/8d63b42aea32ce2e5d09.js +1 -0
  49. package/assets/esri/core/workers/chunks/8de11aab65d91e7f1a4d.js +1 -0
  50. package/assets/esri/core/workers/chunks/9386a0ebff78b6303ed2.js +1 -0
  51. package/assets/esri/core/workers/chunks/{4d47187bc0821413492d.js → 95bae3c275f1483eb7ed.js} +1 -1
  52. package/assets/esri/core/workers/chunks/{f8f85207b382c1ea038c.js → 97489bf16a1d327992b2.js} +3 -3
  53. package/assets/esri/core/workers/chunks/a2652d10bb0bc41c9a8d.js +1 -0
  54. package/assets/esri/core/workers/chunks/a845c68e76382a73da5e.js +1 -0
  55. package/assets/esri/core/workers/chunks/{9c64b78c5c9b35b31d98.js → aa78b69219d9a0ef1c54.js} +2 -2
  56. package/assets/esri/core/workers/chunks/b09b34f64a6bc2b49e0a.js +1 -0
  57. package/assets/esri/core/workers/chunks/b0a03b6edbcf6e933431.js +1 -0
  58. package/assets/esri/core/workers/chunks/{1859a11df9f579b993d7.js → b2fbb44e219232e61cbd.js} +1 -1
  59. package/assets/esri/core/workers/chunks/b4349db7155673329432.js +1 -0
  60. package/assets/esri/core/workers/chunks/b8997ae5893afa0298d1.js +1 -0
  61. package/assets/esri/core/workers/chunks/c0ae186620b68d43b338.js +1 -0
  62. package/assets/esri/core/workers/chunks/{d153b29c542c37ae1636.js → c50e8d5f554cf151865c.js} +2 -2
  63. package/assets/esri/core/workers/chunks/c5cc0fc652432a9264cc.js +1 -0
  64. package/assets/esri/core/workers/chunks/c6cae8471c5d4ae40c65.js +1 -0
  65. package/assets/esri/core/workers/chunks/cab2a1382bdd32bb34d8.js +1 -0
  66. package/assets/esri/core/workers/chunks/ce937ff0dd1147ea297e.js +1 -0
  67. package/assets/esri/core/workers/chunks/d142a42755a78bb157ed.js +1 -0
  68. package/assets/esri/core/workers/chunks/{280af3640f8e93c1024e.js → d6e0528eacee7ea4c1ce.js} +2 -2
  69. package/assets/esri/core/workers/chunks/d9d86cf0500fa29d1d43.js +1 -0
  70. package/assets/esri/core/workers/chunks/db5a985ccc6b7d0ad855.js +1 -0
  71. package/assets/esri/core/workers/chunks/f3ee035fa7bf638c8e60.js +1 -0
  72. package/assets/esri/core/workers/chunks/{b15ff6c9ef2de8a49853.js → f651c05604eab83aef5f.js} +2 -2
  73. package/assets/esri/core/workers/chunks/{ed773dab5965e42a2879.js → f6e18668f728dfd8ba5e.js} +2 -2
  74. package/assets/esri/core/workers/chunks/fc5ac54aab66562c8463.js +1 -0
  75. package/assets/esri/core/workers/chunks/ff8e2f998169ca3a7a68.js +1 -0
  76. package/assets/esri/libs/dracoMeshDecoder/draco_mesh_decoder.wasm +0 -0
  77. package/assets/esri/libs/i3s/i3s.wasm +0 -0
  78. package/assets/esri/themes/dark/main.css +1 -1
  79. package/assets/esri/themes/light/main.css +1 -1
  80. package/assets/esri/themes/light/view.css +1 -1
  81. package/assets/esri/views/3d/analysis/VolumeMeasurement/t9n/VolumeMeasurementAnalysis.json +1 -0
  82. package/assets/esri/widgets/Editor/t9n/Editor.json +1 -1
  83. package/assets/esri/widgets/Editor/t9n/Editor_en.json +1 -1
  84. package/chunks/CloudsComposition.glsl.js +2 -2
  85. package/chunks/HUDMaterial.glsl.js +49 -50
  86. package/chunks/LineMarker.glsl.js +34 -34
  87. package/chunks/PointRenderer.glsl.js +4 -4
  88. package/chunks/ShadowHighlight.glsl.js +3 -3
  89. package/chunks/draco_mesh_decoder.js +1 -1
  90. package/config.js +1 -1
  91. package/core/NestedMap.js +1 -1
  92. package/core/iteratorUtils.js +1 -1
  93. package/editing/geometry/lineUtils.js +1 -1
  94. package/identity/IdentityManagerBase.js +1 -1
  95. package/interfaces.d.ts +188 -134
  96. package/kernel.js +1 -1
  97. package/layers/GaussianSplatLayer.js +1 -1
  98. package/layers/IntegratedMesh3DTilesLayer.js +1 -1
  99. package/layers/IntegratedMeshLayer.js +1 -1
  100. package/layers/ParquetLayer.js +1 -1
  101. package/layers/SceneLayer.js +1 -1
  102. package/layers/VectorTileLayer.js +1 -1
  103. package/layers/graphics/sources/ParquetSource.js +1 -1
  104. package/layers/graphics/sources/support/ParquetSourceWorker.js +1 -1
  105. package/layers/knowledgeGraph/KnowledgeGraphLayerDataManager.js +1 -1
  106. package/layers/knowledgeGraph/cypherUtils.js +1 -1
  107. package/layers/support/FieldConfiguration.js +1 -1
  108. package/layers/support/fieldConfigUtils.js +1 -1
  109. package/layers/support/layerUtils.js +1 -1
  110. package/layers/support/vectorTileLayerLoader.js +1 -1
  111. package/package.json +5 -5
  112. package/portal/schemas/definitions.js +1 -1
  113. package/support/basemapEnsureType.js +1 -1
  114. package/support/revision.js +1 -1
  115. package/support/userTypeGuards/isBasemap.js +5 -0
  116. package/symbols/support/previewSymbol2D.js +1 -1
  117. package/views/2d/analysis/ElevationProfileAnalysisView2D.js +1 -1
  118. package/views/2d/layers/FeatureLayerView2D.js +1 -1
  119. package/views/2d/layers/features/FeaturePipelineWorker.js +1 -1
  120. package/views/2d/layers/features/Processor.js +1 -1
  121. package/views/2d/layers/features/layerAdapters/CatalogFootprintLayerAdapter.js +1 -1
  122. package/views/2d/layers/features/layerAdapters/FeatureLayerAdapter.js +1 -1
  123. package/views/2d/layers/features/layerAdapters/InMemoryLayerAdapter.js +1 -1
  124. package/views/2d/layers/features/layerAdapters/KnowledgeGraphSublayerAdapter.js +1 -1
  125. package/views/2d/layers/features/layerAdapters/OGCFeatureLayerAdapter.js +1 -1
  126. package/views/2d/layers/features/layerAdapters/OrientedImageryLayerAdapter.js +1 -1
  127. package/views/2d/layers/features/layerAdapters/ParquetLayerAdapter.js +1 -1
  128. package/views/2d/layers/features/layerAdapters/StreamLayerAdapter.js +1 -1
  129. package/views/2d/layers/features/layerAdapters/SubtypeGroupLayerAdapter.js +1 -1
  130. package/views/2d/layers/features/layerAdapters/featureServiceUtils.js +1 -1
  131. package/views/2d/layers/features/schema/SourceSchema.js +1 -1
  132. package/views/2d/layers/features/sources/FeatureSource.js +1 -1
  133. package/views/2d/layers/features/sources/FeatureSourceQueryInfo.js +1 -1
  134. package/views/2d/layers/features/sources/strategies/AFeatureLoadStrategy.js +5 -0
  135. package/views/2d/layers/features/sources/strategies/AFeatureTileLoadStrategy.js +5 -0
  136. package/views/2d/layers/features/sources/strategies/ALoadStrategy.js +1 -1
  137. package/views/2d/layers/features/sources/strategies/FeatureDrillDownTileLoadStrategy.js +5 -0
  138. package/views/2d/layers/features/sources/strategies/FeaturePagedTileLoadStrategy.js +5 -0
  139. package/views/2d/layers/features/sources/strategies/FeatureSnapshotLoadStrategy.js +5 -0
  140. package/views/2d/layers/features/sources/strategies/ParquetSnapshotLoadStrategy.js +1 -1
  141. package/views/2d/layers/features/sources/strategies/ParquetTileLoadStrategy.js +1 -1
  142. package/views/2d/layers/features/sources/strategies/StreamLoadStrategy.js +1 -1
  143. package/views/2d/layers/features/sources/strategies/chunks/FeatureSnapshotSourceChunk.js +1 -1
  144. package/views/2d/layers/features/sources/strategies/chunks/SourceChunkStore.js +1 -1
  145. package/views/2d/layers/features/sources/strategies/support/queryAdapters.js +1 -1
  146. package/views/2d/layers/features/support/FeatureSetReaderParquet.js +1 -1
  147. package/views/3d/FocusAreasView.js +1 -1
  148. package/views/3d/GroundView3D.js +5 -0
  149. package/views/3d/analysis/ElevationProfile/{ElevationProfileSceneLineComputation.js → ElevationProfileLineSceneComputation.js} +1 -1
  150. package/views/3d/analysis/ElevationProfileAnalysisView3D.js +1 -1
  151. package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementConfiguration.js +1 -1
  152. package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementCutFillVisualization.js +1 -1
  153. package/views/3d/analysis/VolumeMeasurementAnalysisView3D.js +1 -1
  154. package/views/3d/environment/CloudsComposition.glsl.js +1 -1
  155. package/views/3d/glTF/internal/Resource.js +1 -1
  156. package/views/3d/interactive/SnappingVisualizer3D.js +1 -1
  157. package/views/3d/interactive/visualElements/DrapedVisualElementResources.js +1 -1
  158. package/views/3d/interactive/visualElements/LabelVisualElement.js +1 -1
  159. package/views/3d/interactive/visualElements/ParallelLineVisualElement.js +1 -1
  160. package/views/3d/interactive/visualElements/RightAngleQuadVisualElement.js +1 -1
  161. package/views/3d/layers/DrapedSubView3D.js +1 -1
  162. package/views/3d/layers/FlowSubView3D.js +1 -1
  163. package/views/3d/layers/GaussianSplatLayerView3D.js +1 -1
  164. package/views/3d/layers/I3SMeshView3D.js +1 -1
  165. package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
  166. package/views/3d/layers/IntegratedMeshLayerView3D.js +1 -1
  167. package/views/3d/layers/MediaLayerView3D.js +1 -1
  168. package/views/3d/layers/graphics/Graphics3DCore.js +1 -1
  169. package/views/3d/layers/i3s/I3SMaterialUtil.js +1 -1
  170. package/views/3d/layers/support/HeatmapFeatureProcessor.js +1 -1
  171. package/views/3d/state/helpers/SceneIntersectionHelper.js +1 -1
  172. package/views/3d/support/MemoryController.js +1 -1
  173. package/views/3d/support/engineContent/marker.js +1 -1
  174. package/views/3d/support/engineContent/sdfPrimitives.js +1 -1
  175. package/views/3d/support/pointsOfInterest/CenterOnSurface.js +1 -1
  176. package/views/3d/support/pointsOfInterest/PointsOfInterest.js +1 -1
  177. package/views/3d/support/popupHitTest.js +1 -1
  178. package/views/3d/terrain/OverlayManager.js +1 -1
  179. package/views/3d/terrain/OverlayRenderer.js +1 -1
  180. package/views/3d/webgl-engine/core/shaderLibrary/shading/LineStipple.glsl.js +11 -11
  181. package/views/3d/webgl-engine/lib/BasisUtil.js +1 -1
  182. package/views/3d/webgl-engine/lib/Texture.js +1 -1
  183. package/views/3d/webgl-engine/materials/renderers/InstancedCommandVAO.js +5 -0
  184. package/views/3d/webgl-engine/materials/renderers/InstancedCommandVAOs.js +5 -0
  185. package/views/3d/webgl-engine/materials/renderers/PerBufferData.js +1 -1
  186. package/views/3d/webgl-engine/materials/renderers/PerOriginData.js +1 -1
  187. package/views/3d/webgl-engine/materials/renderers/VaoRenderer.js +1 -1
  188. package/views/3d/webgl-engine/materials/renderers/VaoWriter.js +1 -1
  189. package/views/3d/webgl-engine/parts/RenderView.js +1 -1
  190. package/views/3d/webgl-engine/shaders/AnimatedLine.glsl.js +14 -9
  191. package/views/3d/webgl-engine/shaders/HUDMaterial.glsl.js +1 -1
  192. package/views/3d/webgl-engine/shaders/LineMarker.glsl.js +1 -1
  193. package/views/3d/webgl-engine/shaders/PointRenderer.glsl.js +1 -1
  194. package/views/3d/webgl-engine/shaders/ShadowHighlight.glsl.js +1 -1
  195. package/views/3d/webgl-engine/shaders/sources/edgeRenderer/LineOffset.glsl.js +8 -8
  196. package/views/BasemapView.js +1 -1
  197. package/views/GroundView.js +1 -1
  198. package/views/SceneView.js +1 -1
  199. package/views/View.js +1 -1
  200. package/views/View2D.js +1 -1
  201. package/views/analysis/ElevationProfile/ElevationProfileChart.js +1 -1
  202. package/views/analysis/ElevationProfile/{ElevationProfileGroundLineComputation.js → ElevationProfileLineGroundComputation.js} +1 -1
  203. package/views/analysis/ElevationProfile/{ElevationProfileInputLineComputation.js → ElevationProfileLineInputComputation.js} +1 -1
  204. package/views/analysis/ElevationProfile/{ElevationProfileQueryLineComputation.js → ElevationProfileLineQueryComputation.js} +1 -1
  205. package/views/analysis/ElevationProfile/ElevationProfileTool.js +1 -1
  206. package/views/support/LayerViewManager.js +1 -1
  207. package/views/webgl/RenderbufferDescriptor.js +1 -1
  208. package/views/webgl/TextureDescriptor.js +1 -1
  209. package/views/webgl/Util.js +1 -1
  210. package/views/webgl/VertexArrayObject.js +1 -1
  211. package/webscene/Slide.js +1 -1
  212. package/widgets/Editor/CreateFeaturesWorkflow.js +1 -1
  213. package/widgets/Editor/SplitFeatureWorkflow.js +1 -1
  214. package/widgets/Editor/UpdateFeatureWorkflow.js +1 -1
  215. package/widgets/Editor/Upload.js +1 -1
  216. package/widgets/Editor/components/Notices.js +1 -1
  217. package/widgets/Editor/modelUploadUtils.js +1 -1
  218. package/widgets/Editor/support/SketchController.js +1 -1
  219. package/widgets/Editor/support/splitFeatureUtils.js +1 -1
  220. package/widgets/Editor/workflowUtils.js +1 -1
  221. package/widgets/ElevationProfile/ElevationProfileLineGround.d.ts +2 -2
  222. package/widgets/ElevationProfile/ElevationProfileLineInput.d.ts +2 -2
  223. package/widgets/ElevationProfile/ElevationProfileLineQuery.d.ts +2 -2
  224. package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
  225. package/widgets/Sketch/SketchViewModel.js +1 -1
  226. package/widgets/Sketch/adapters/layer/GraphicsLayerAdapter.js +5 -0
  227. package/widgets/Sketch/adapters/layer/MapNotesLayerAdapter.js +5 -0
  228. package/analysis/ElevationProfile/ElevationProfileGroundLine.d.ts +0 -4
  229. package/analysis/ElevationProfile/ElevationProfileInputLine.d.ts +0 -4
  230. package/analysis/ElevationProfile/ElevationProfileQueryLine.d.ts +0 -4
  231. package/analysis/ElevationProfile/ElevationProfileSceneLine.d.ts +0 -4
  232. package/assets/esri/core/workers/chunks/03e5d1a00d85e4d16bff.js +0 -1
  233. package/assets/esri/core/workers/chunks/0914a52fb33af5d77fab.js +0 -1
  234. package/assets/esri/core/workers/chunks/1d491447b13f2f2b4399.js +0 -1
  235. package/assets/esri/core/workers/chunks/20850b0fdb55fb17bc90.js +0 -1
  236. package/assets/esri/core/workers/chunks/25ea02dd7d45a90cbb3b.js +0 -1
  237. package/assets/esri/core/workers/chunks/264a9a916e1e972b69d7.js +0 -1
  238. package/assets/esri/core/workers/chunks/30c85a1a4f118cc45a25.js +0 -1
  239. package/assets/esri/core/workers/chunks/3ef8a7468d7e3b2f0b69.js +0 -351
  240. package/assets/esri/core/workers/chunks/486ea51306c619238e41.js +0 -1
  241. package/assets/esri/core/workers/chunks/49cb78c85de0102e5f02.js +0 -1
  242. package/assets/esri/core/workers/chunks/5610dfde4e636e2333a9.js +0 -1
  243. package/assets/esri/core/workers/chunks/5c1cdc2ec06c4c6bd0b3.js +0 -1
  244. package/assets/esri/core/workers/chunks/609abf071c4ea24955c2.js +0 -1
  245. package/assets/esri/core/workers/chunks/71c2a8e5a17803d3e949.js +0 -1
  246. package/assets/esri/core/workers/chunks/7402c2853f6aed8d1bc7.js +0 -1
  247. package/assets/esri/core/workers/chunks/7889a909394c61a9d3e0.js +0 -1
  248. package/assets/esri/core/workers/chunks/79a9f47dfa9ebabb5dbd.js +0 -1
  249. package/assets/esri/core/workers/chunks/86378d4f4d7f9a370c22.js +0 -1
  250. package/assets/esri/core/workers/chunks/99ac292a858bbedc6a89.js +0 -1
  251. package/assets/esri/core/workers/chunks/9a6fa91dd204f64d2590.js +0 -1
  252. package/assets/esri/core/workers/chunks/9cdeead9d444e8d95477.js +0 -1
  253. package/assets/esri/core/workers/chunks/aa1eb7b4d9ccda725da5.js +0 -1
  254. package/assets/esri/core/workers/chunks/b19d723d09f5bea9ca27.js +0 -1
  255. package/assets/esri/core/workers/chunks/b4a053063e6022080d31.js +0 -1
  256. package/assets/esri/core/workers/chunks/b4b26cc2ba3ff30e1d03.js +0 -1
  257. package/assets/esri/core/workers/chunks/b78ea9cc4d5f2fd3d871.js +0 -1
  258. package/assets/esri/core/workers/chunks/bbb585f0b484ab5eabb3.js +0 -1
  259. package/assets/esri/core/workers/chunks/bd4125d163f372a7e978.js +0 -1
  260. package/assets/esri/core/workers/chunks/c2bc70b65f5c2a2c9671.js +0 -1
  261. package/assets/esri/core/workers/chunks/cd1869e183001266c4c1.js +0 -2
  262. package/assets/esri/core/workers/chunks/d0a149050f7f1c1ada09.js +0 -1
  263. package/assets/esri/core/workers/chunks/d2fe403d6ab237bc89c2.js +0 -1
  264. package/assets/esri/core/workers/chunks/d51e8eeb1e1eb0605cc9.js +0 -1
  265. package/assets/esri/core/workers/chunks/da42cc4f6142846cb745.js +0 -1
  266. package/assets/esri/core/workers/chunks/dd84f630466a26722d57.js +0 -1
  267. package/assets/esri/core/workers/chunks/e080628ac6e1cf25dc72.js +0 -1
  268. package/assets/esri/core/workers/chunks/e17df11c98dbd869302b.js +0 -1
  269. package/assets/esri/core/workers/chunks/e1b3ae6426886e2fab07.js +0 -1
  270. package/assets/esri/core/workers/chunks/e8e0f73fb94e63e2abc3.js +0 -1
  271. package/assets/esri/core/workers/chunks/f45c343527709f6f91c2.js +0 -1
  272. package/assets/esri/core/workers/chunks/f6513ec888a7d927d948.js +0 -1
  273. package/assets/esri/core/workers/chunks/fcac475e4e82911b3126.js +0 -1
  274. package/views/2d/layers/features/sources/strategies/AFetchLoadStrategy.js +0 -5
  275. package/views/2d/layers/features/sources/strategies/ATileLoadStrategy.js +0 -5
  276. package/views/2d/layers/features/sources/strategies/DrillDownTileLoadStrategy.js +0 -5
  277. package/views/2d/layers/features/sources/strategies/PagedTileLoadStrategy.js +0 -5
  278. package/views/2d/layers/features/sources/strategies/SnapshotLoadStrategy.js +0 -5
  279. /package/assets/esri/core/workers/chunks/{7a23b127f551bf13ef54.js.LICENSE.txt → 268f5b233640a9dbbf89.js.LICENSE.txt} +0 -0
  280. /package/assets/esri/core/workers/chunks/{cd1869e183001266c4c1.js.LICENSE.txt → 336b54144afec0c7d396.js.LICENSE.txt} +0 -0
  281. /package/assets/esri/core/workers/chunks/{280af3640f8e93c1024e.js.LICENSE.txt → 47e4f66c33bb697fbe6b.js.LICENSE.txt} +0 -0
  282. /package/assets/esri/core/workers/chunks/{9c64b78c5c9b35b31d98.js.LICENSE.txt → aa78b69219d9a0ef1c54.js.LICENSE.txt} +0 -0
  283. /package/assets/esri/core/workers/chunks/{d153b29c542c37ae1636.js.LICENSE.txt → c50e8d5f554cf151865c.js.LICENSE.txt} +0 -0
  284. /package/assets/esri/core/workers/chunks/{b15ff6c9ef2de8a49853.js.LICENSE.txt → d6e0528eacee7ea4c1ce.js.LICENSE.txt} +0 -0
  285. /package/assets/esri/core/workers/chunks/{d66cdb9bb494da19696b.js.LICENSE.txt → f651c05604eab83aef5f.js.LICENSE.txt} +0 -0
  286. /package/assets/esri/core/workers/chunks/{ed773dab5965e42a2879.js.LICENSE.txt → f6e18668f728dfd8ba5e.js.LICENSE.txt} +0 -0
@@ -2,7 +2,7 @@
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{n as e,t as i}from"./vec32.js";import{create as o}from"../core/libs/gl-matrix-2/factories/vec3f64.js";import{NormalFromDepth as r}from"../views/3d/webgl-engine/core/shaderLibrary/NormalFromDepth.glsl.js";import{ScreenSpacePass as t}from"../views/3d/webgl-engine/core/shaderLibrary/ScreenSpacePass.glsl.js";import{calculateUVZShadowFromDepthPass as a}from"../views/3d/webgl-engine/core/shaderLibrary/shading/calculateUVZShadowFromDepth.glsl.js";import{ShadowmapFiltering as l}from"../views/3d/webgl-engine/core/shaderLibrary/shading/ShadowmapFiltering.glsl.js";import{RgbaFloatEncoding as h}from"../views/3d/webgl-engine/core/shaderLibrary/util/RgbaFloatEncoding.glsl.js";import{Float3BindUniform as d}from"../views/3d/webgl-engine/core/shaderModules/Float3BindUniform.js";import{Float4PassUniform as n}from"../views/3d/webgl-engine/core/shaderModules/Float4PassUniform.js";import{FloatPassUniform as g}from"../views/3d/webgl-engine/core/shaderModules/FloatPassUniform.js";import{glsl as s}from"../views/3d/webgl-engine/core/shaderModules/glsl.js";import{Texture2DBindUniform as c}from"../views/3d/webgl-engine/core/shaderModules/Texture2DBindUniform.js";import{Texture2DShadowBindUniform as u}from"../views/3d/webgl-engine/core/shaderModules/Texture2DShadowBindUniform.js";import{Texture2DUintPassUniform as w}from"../views/3d/webgl-engine/core/shaderModules/Texture2DUintPassUniform.js";import{ShaderBuilder as m}from"../views/webgl/ShaderBuilder.js";const p=.025;function f(){const o=new m;o.include(a),o.include(l),o.include(t),o.include(r);const f=o.fragment;return f.include(h),f.uniforms.add(new u("shadowMapExcludingHighlight",e=>e.shadowMap.getSnapshot(1)),new u("shadowMapHighlight",e=>e.shadowMap.getSnapshot(0)),new c("depthMap",e=>e.depth?.attachment),new w("highlightTexture",e=>e.highlightTexture),new n("uColor",e=>e.shadowColor),new g("opacity",e=>e.shadowOpacity),new g("occludedOpacity",e=>e.occludedShadowOpacity),new g("terminationFactor",e=>e.opacityElevation*e.dayNightTerminator),new d("lightingMainDirectionView",({lighting:o,camera:r})=>e(v,i(v,o.mainLight.direction,r.viewInverseTransposeMatrix)))),f.main.add(s`
5
+ import{n as e,t as i}from"./vec32.js";import{create as o}from"../core/libs/gl-matrix-2/factories/vec3f64.js";import{NormalFromDepth as r}from"../views/3d/webgl-engine/core/shaderLibrary/NormalFromDepth.glsl.js";import{ScreenSpacePass as t}from"../views/3d/webgl-engine/core/shaderLibrary/ScreenSpacePass.glsl.js";import{calculateUVZShadowFromDepthPass as a}from"../views/3d/webgl-engine/core/shaderLibrary/shading/calculateUVZShadowFromDepth.glsl.js";import{ShadowmapFiltering as l}from"../views/3d/webgl-engine/core/shaderLibrary/shading/ShadowmapFiltering.glsl.js";import{Float3BindUniform as h}from"../views/3d/webgl-engine/core/shaderModules/Float3BindUniform.js";import{Float4PassUniform as d}from"../views/3d/webgl-engine/core/shaderModules/Float4PassUniform.js";import{FloatPassUniform as n}from"../views/3d/webgl-engine/core/shaderModules/FloatPassUniform.js";import{glsl as g}from"../views/3d/webgl-engine/core/shaderModules/glsl.js";import{Texture2DBindUniform as s}from"../views/3d/webgl-engine/core/shaderModules/Texture2DBindUniform.js";import{Texture2DShadowBindUniform as c}from"../views/3d/webgl-engine/core/shaderModules/Texture2DShadowBindUniform.js";import{Texture2DUintPassUniform as u}from"../views/3d/webgl-engine/core/shaderModules/Texture2DUintPassUniform.js";import{ShaderBuilder as w}from"../views/webgl/ShaderBuilder.js";const m=.025;function p(){const o=new w;o.include(a),o.include(l),o.include(t),o.include(r);const p=o.fragment;return p.uniforms.add(new c("shadowMapExcludingHighlight",e=>e.shadowMap.getSnapshot(1)),new c("shadowMapHighlight",e=>e.shadowMap.getSnapshot(0)),new s("depthMap",e=>e.depth?.attachment),new u("highlightTexture",e=>e.highlightTexture),new d("uColor",e=>e.shadowColor),new n("opacity",e=>e.shadowOpacity),new n("occludedOpacity",e=>e.occludedShadowOpacity),new n("terminationFactor",e=>e.opacityElevation*e.dayNightTerminator),new h("lightingMainDirectionView",({lighting:o,camera:r})=>e(f,i(f,o.mainLight.direction,r.viewInverseTransposeMatrix)))),p.main.add(g`
6
6
  ivec2 highlightTextureSize = textureSize(highlightTexture, 0);
7
7
  ivec2 highlightIUV = ivec2(uv * vec2(highlightTextureSize));
8
8
  uvec2 highlightInfo = texelFetch(highlightTexture, highlightIUV, 0).rg;
@@ -31,9 +31,9 @@ import{n as e,t as i}from"./vec32.js";import{create as o}from"../core/libs/gl-ma
31
31
  float shadowExcludingHighlightFactor = readShadowMapUVZ(uvzShadow, shadowMapExcludingHighlight);
32
32
 
33
33
  vec3 normal = normalFromDepth(depthMap, currentPixelPos.xyz, gl_FragCoord.xy, uv);
34
- bool shaded = dot(normal, lightingMainDirectionView) < ${s.float(p)};
34
+ bool shaded = dot(normal, lightingMainDirectionView) < ${g.float(m)};
35
35
 
36
36
  float occludedFactor = max(shadowExcludingHighlightFactor, shaded ? 1.0 : 0.0);
37
37
  float fragOpacity = mix(opacity, occludedOpacity, occludedFactor);
38
38
  fragColor = vec4(uColor.rgb, uColor.a * fragOpacity * terminationFactor);
39
- `),o}const v=o(),b=Object.freeze(Object.defineProperty({__proto__:null,build:f},Symbol.toStringTag,{value:"Module"}));export{b as S,f as b};
39
+ `),o}const f=o(),v=Object.freeze(Object.defineProperty({__proto__:null,build:p},Symbol.toStringTag,{value:"Module"}));export{v as S,p as b};
@@ -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
- var r,e=(r="undefined"!=typeof document?document.currentScript?.src:void 0,function(e={}){var t,n,a,o=e,i=new Promise((r,e)=>{t=r,n=e}),u=Object.assign({},o),s="";function l(r){return o.locateFile?o.locateFile(r,s):s+r}"undefined"!=typeof document&&document.currentScript&&(s=document.currentScript.src),r&&(s=r),s=s.startsWith("blob:")?"":s.substr(0,s.replace(/[?#].*/,"").lastIndexOf("/")+1),a=async r=>{var e=await fetch(r,{credentials:"same-origin"});if(e.ok)return e.arrayBuffer();throw new Error(e.status+" : "+e.url)},o.print||console.log.bind(console);var c=o.printErr||console.error.bind(console);Object.assign(o,u),u=null,o.arguments&&o.arguments,o.thisProgram&&o.thisProgram;var f,d,h,p,v,g,m,y,b,$=o.wasmBinary,w=!1;function A(){var r=f.buffer;o.HEAP8=d=new Int8Array(r),o.HEAP16=p=new Int16Array(r),o.HEAPU8=h=new Uint8Array(r),o.HEAPU16=v=new Uint16Array(r),o.HEAP32=g=new Int32Array(r),o.HEAPU32=m=new Uint32Array(r),o.HEAPF32=y=new Float32Array(r),o.HEAPF64=b=new Float64Array(r)}var T=[],C=[],P=[];function W(){if(o.preRun)for("function"==typeof o.preRun&&(o.preRun=[o.preRun]);o.preRun.length;)F(o.preRun.shift());L(T)}function E(){L(C)}function _(){if(o.postRun)for("function"==typeof o.postRun&&(o.postRun=[o.postRun]);o.postRun.length;)R(o.postRun.shift());L(P)}function F(r){T.unshift(r)}function k(r){C.unshift(r)}function R(r){P.unshift(r)}var S=0,x=null;function j(r){S++,o.monitorRunDependencies?.(S)}function V(r){if(S--,o.monitorRunDependencies?.(S),0==S&&x){var e=x;x=null,e()}}function I(r){o.onAbort?.(r),c(r="Aborted("+r+")"),w=!0,r+=". Build with -sASSERTIONS for more info.";var e=new WebAssembly.RuntimeError(r);throw n(e),e}var H,U="data:application/octet-stream;base64,",O=r=>r.startsWith(U);function D(){var r="draco_mesh_decoder.wasm";return O(r)?r:l(r)}function B(r){if(r==H&&$)return new Uint8Array($);throw"both async and sync fetching of the wasm failed"}async function M(r){if(!$)try{var e=await a(r);return new Uint8Array(e)}catch{}return B(r)}async function N(r,e){try{var t=await M(r);return await WebAssembly.instantiate(t,e)}catch(n){c(`failed to asynchronously prepare wasm: ${n}`),I(n)}}async function z(r,e,t){if(!r&&"function"==typeof WebAssembly.instantiateStreaming&&!O(e)&&"function"==typeof fetch)try{var n=fetch(e,{credentials:"same-origin"});return await WebAssembly.instantiateStreaming(n,t)}catch(a){c(`wasm streaming compile failed: ${a}`),c("falling back to ArrayBuffer instantiation")}return N(e,t)}function q(){return{a:Oe}}async function G(){function r(r,e){return Ue=r.exports,f=Ue.C,A(),kr=Ue.F,k(Ue.D),V(),Ue}function e(e){r(e.instance)}j();var t=q();if(o.instantiateWasm)try{return o.instantiateWasm(t,r)}catch(i){c(`Module.instantiateWasm callback failed with error: ${i}`),n(i)}H??=D();try{var a=await z($,H,t);return e(a),a}catch(i){return void n(i)}}var L=r=>{for(;r.length>0;)r.shift()(o)};o.noExitRuntime;class J{constructor(r){this.excPtr=r,this.ptr=r-24}set_type(r){m[this.ptr+4>>2]=r}get_type(){return m[this.ptr+4>>2]}set_destructor(r){m[this.ptr+8>>2]=r}get_destructor(){return m[this.ptr+8>>2]}set_caught(r){r=r?1:0,d[this.ptr+12]=r}get_caught(){return 0!=d[this.ptr+12]}set_rethrown(r){r=r?1:0,d[this.ptr+13]=r}get_rethrown(){return 0!=d[this.ptr+13]}init(r,e){this.set_adjusted_ptr(0),this.set_type(r),this.set_destructor(e)}set_adjusted_ptr(r){m[this.ptr+16>>2]=r}get_adjusted_ptr(){return m[this.ptr+16>>2]}}var K=(r,e,t)=>{throw new J(r).init(e,t),r},Q=()=>I(""),X={},Y=r=>{for(;r.length;){var e=r.pop();r.pop()(e)}};function Z(r){return this.fromWireType(m[r>>2])}var rr,er,tr,nr={},ar={},or={},ir=r=>{throw new rr(r)},ur=(r,e,t)=>{function n(e){var n=t(e);n.length!==r.length&&ir("Mismatched type converter count");for(var a=0;a<r.length;++a)pr(r[a],n[a])}r.forEach(r=>or[r]=e);var a=new Array(e.length),o=[],i=0;e.forEach((r,e)=>{ar.hasOwnProperty(r)?a[e]=ar[r]:(o.push(r),nr.hasOwnProperty(r)||(nr[r]=[]),nr[r].push(()=>{a[e]=ar[r],++i===o.length&&n(a)}))}),0===o.length&&n(a)},sr=r=>{var e=X[r];delete X[r];var t=e.rawConstructor,n=e.rawDestructor,a=e.fields,o=a.map(r=>r.getterReturnType).concat(a.map(r=>r.setterArgumentType));ur([r],o,r=>{var o={};return a.forEach((e,t)=>{var n=e.fieldName,i=r[t],u=e.getter,s=e.getterContext,l=r[t+a.length],c=e.setter,f=e.setterContext;o[n]={read:r=>i.fromWireType(u(s,r)),write:(r,e)=>{var t=[];c(f,r,l.toWireType(t,e)),Y(t)}}}),[{name:e.name,fromWireType:r=>{var e={};for(var t in o)e[t]=o[t].read(r);return n(r),e},toWireType:(r,e)=>{for(var a in o)if(!(a in e))throw new TypeError(`Missing field: "${a}"`);var i=t();for(a in o)o[a].write(i,e[a]);return null!==r&&r.push(n,i),i},argPackAdvance:vr,readValueFromPointer:Z,destructorFunction:n}]})},lr=(r,e,t,n,a)=>{},cr=()=>{for(var r=new Array(256),e=0;e<256;++e)r[e]=String.fromCharCode(e);er=r},fr=r=>{for(var e="",t=r;h[t];)e+=er[h[t++]];return e},dr=r=>{throw new tr(r)};function hr(r,e,t={}){var n=e.name;if(r||dr(`type "${n}" must have a positive integer typeid pointer`),ar.hasOwnProperty(r)){if(t.ignoreDuplicateRegistrations)return;dr(`Cannot register type '${n}' twice`)}if(ar[r]=e,delete or[r],nr.hasOwnProperty(r)){var a=nr[r];delete nr[r],a.forEach(r=>r())}}function pr(r,e,t={}){return hr(r,e,t)}var vr=8,gr=(r,e,t,n)=>{pr(r,{name:e=fr(e),fromWireType:function(r){return!!r},toWireType:function(r,e){return e?t:n},argPackAdvance:vr,readValueFromPointer:function(r){return this.fromWireType(h[r])},destructorFunction:null})},mr=[],yr=[],br=r=>{r>9&&0===--yr[r+1]&&(yr[r]=void 0,mr.push(r))},$r=()=>yr.length/2-5-mr.length,wr=()=>{yr.push(0,1,void 0,1,null,1,!0,1,!1,1),o.count_emval_handles=$r},Ar={toValue:r=>(r||dr("Cannot use deleted val. handle = "+r),yr[r]),toHandle:r=>{switch(r){case void 0:return 2;case null:return 4;case!0:return 6;case!1:return 8;default:{const e=mr.pop()||yr.length;return yr[e]=r,yr[e+1]=1,e}}}},Tr={name:"emscripten::val",fromWireType:r=>{var e=Ar.toValue(r);return br(r),e},toWireType:(r,e)=>Ar.toHandle(e),argPackAdvance:vr,readValueFromPointer:Z,destructorFunction:null},Cr=r=>pr(r,Tr),Pr=(r,e)=>{switch(e){case 4:return function(r){return this.fromWireType(y[r>>2])};case 8:return function(r){return this.fromWireType(b[r>>3])};default:throw new TypeError(`invalid float width (${e}): ${r}`)}},Wr=(r,e,t)=>{pr(r,{name:e=fr(e),fromWireType:r=>r,toWireType:(r,e)=>e,argPackAdvance:vr,readValueFromPointer:Pr(e,t),destructorFunction:null})},Er=(r,e)=>Object.defineProperty(e,"name",{value:r});function _r(r){for(var e=1;e<r.length;++e)if(null!==r[e]&&void 0===r[e].destructorFunction)return!0;return!1}function Fr(r,e,t,n,a,o){var i=e.length;i<2&&dr("argTypes array size mismatch! Must at least get return value and 'this' types!"),e[1];var u=_r(e),s="void"!==e[0].name,l=i-2,c=new Array(l),f=[],d=[];return Er(r,function(...r){var t;d.length=0,f.length=1,f[0]=a;for(var o=0;o<l;++o)c[o]=e[o+2].toWireType(d,r[o]),f.push(c[o]);function i(r){if(u)Y(d);else for(var n=2;n<e.length;n++){var a=1===n?t:c[n-2];null!==e[n].destructorFunction&&e[n].destructorFunction(a)}if(s)return e[0].fromWireType(r)}return i(n(...f))})}var kr,Rr,Sr=(r,e,t)=>{if(void 0===r[e].overloadTable){var n=r[e];r[e]=function(...n){return r[e].overloadTable.hasOwnProperty(n.length)||dr(`Function '${t}' called with an invalid number of arguments (${n.length}) - expects one of (${r[e].overloadTable})!`),r[e].overloadTable[n.length].apply(this,n)},r[e].overloadTable=[],r[e].overloadTable[n.argCount]=n}},xr=(r,e,t)=>{o.hasOwnProperty(r)?((void 0===t||void 0!==o[r].overloadTable&&void 0!==o[r].overloadTable[t])&&dr(`Cannot register public name '${r}' twice`),Sr(o,r,r),o[r].overloadTable.hasOwnProperty(t)&&dr(`Cannot register multiple overloads of a function with the same number of arguments (${t})!`),o[r].overloadTable[t]=e):(o[r]=e,o[r].argCount=t)},jr=(r,e)=>{for(var t=[],n=0;n<r;n++)t.push(m[e+4*n>>2]);return t},Vr=(r,e,t)=>{o.hasOwnProperty(r)||ir("Replacing nonexistent public symbol"),void 0!==o[r].overloadTable&&void 0!==t?o[r].overloadTable[t]=e:(o[r]=e,o[r].argCount=t)},Ir=(r,e,t)=>(r=r.replace(/p/g,"i"),(0,o["dynCall_"+r])(e,...t)),Hr=[],Ur=r=>{var e=Hr[r];return e||(r>=Hr.length&&(Hr.length=r+1),Hr[r]=e=kr.get(r)),e},Or=(r,e,t=[])=>r.includes("j")?Ir(r,e,t):Ur(e)(...t),Dr=(r,e)=>(...t)=>Or(r,e,t),Br=(r,e)=>{function t(){return r.includes("j")?Dr(r,e):Ur(e)}r=fr(r);var n=t();return"function"!=typeof n&&dr(`unknown function pointer with signature ${r}: ${e}`),n},Mr=(r,e)=>{var t=Er(e,function(r){this.name=e,this.message=r;var t=new Error(r).stack;void 0!==t&&(this.stack=this.toString()+"\n"+t.replace(/^Error(:[^\n]*)?\n/,""))});return t.prototype=Object.create(r.prototype),t.prototype.constructor=t,t.prototype.toString=function(){return void 0===this.message?this.name:`${this.name}: ${this.message}`},t},Nr=r=>{var e=Be(r),t=fr(e);return Ne(e),t},zr=(r,e)=>{var t=[],n={};function a(r){n[r]||ar[r]||(or[r]?or[r].forEach(a):(t.push(r),n[r]=!0))}throw e.forEach(a),new Rr(`${r}: `+t.map(Nr).join([", "]))},qr=r=>{const e=(r=r.trim()).indexOf("(");return-1!==e?r.substr(0,e):r},Gr=(r,e,t,n,a,o,i,u)=>{var s=jr(e,t);r=fr(r),r=qr(r),a=Br(n,a),xr(r,function(){zr(`Cannot call ${r} due to unbound types`,s)},e-1),ur([],s,t=>{var n=[t[0],null].concat(t.slice(1));return Vr(r,Fr(r,n,null,a,o),e-1),[]})},Lr=(r,e,t)=>{switch(e){case 1:return t?r=>d[r]:r=>h[r];case 2:return t?r=>p[r>>1]:r=>v[r>>1];case 4:return t?r=>g[r>>2]:r=>m[r>>2];default:throw new TypeError(`invalid integer width (${e}): ${r}`)}},Jr=(r,e,t,n,a)=>{e=fr(e);var o=r=>r;if(0===n){var i=32-8*t;o=r=>r<<i>>>i}var u=e.includes("unsigned"),s=(r,e)=>{};pr(r,{name:e,fromWireType:o,toWireType:u?function(r,e){return s(e,this.name),e>>>0}:function(r,e){return s(e,this.name),e},argPackAdvance:vr,readValueFromPointer:Lr(e,t,0!==n),destructorFunction:null})},Kr=(r,e,t)=>{var n=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array][e];function a(r){var e=m[r>>2],t=m[r+4>>2];return new n(d.buffer,t,e)}pr(r,{name:t=fr(t),fromWireType:a,argPackAdvance:vr,readValueFromPointer:a},{ignoreDuplicateRegistrations:!0})},Qr=(r,e,t,n)=>{if(!(n>0))return 0;for(var a=t,o=t+n-1,i=0;i<r.length;++i){var u=r.charCodeAt(i);if(u>=55296&&u<=57343&&(u=65536+((1023&u)<<10)|1023&r.charCodeAt(++i)),u<=127){if(t>=o)break;e[t++]=u}else if(u<=2047){if(t+1>=o)break;e[t++]=192|u>>6,e[t++]=128|63&u}else if(u<=65535){if(t+2>=o)break;e[t++]=224|u>>12,e[t++]=128|u>>6&63,e[t++]=128|63&u}else{if(t+3>=o)break;e[t++]=240|u>>18,e[t++]=128|u>>12&63,e[t++]=128|u>>6&63,e[t++]=128|63&u}}return e[t]=0,t-a},Xr=(r,e,t)=>Qr(r,h,e,t),Yr=r=>{for(var e=0,t=0;t<r.length;++t){var n=r.charCodeAt(t);n<=127?e++:n<=2047?e+=2:n>=55296&&n<=57343?(e+=4,++t):e+=3}return e},Zr="undefined"!=typeof TextDecoder?new TextDecoder:void 0,re=(r,e=0,t=NaN)=>{for(var n=e+t,a=e;r[a]&&!(a>=n);)++a;if(a-e>16&&r.buffer&&Zr)return Zr.decode(r.subarray(e,a));for(var o="";e<a;){var i=r[e++];if(128&i){var u=63&r[e++];if(192!=(224&i)){var s=63&r[e++];if((i=224==(240&i)?(15&i)<<12|u<<6|s:(7&i)<<18|u<<12|s<<6|63&r[e++])<65536)o+=String.fromCharCode(i);else{var l=i-65536;o+=String.fromCharCode(55296|l>>10,56320|1023&l)}}else o+=String.fromCharCode((31&i)<<6|u)}else o+=String.fromCharCode(i)}return o},ee=(r,e)=>r?re(h,r,e):"",te=(r,e)=>{pr(r,{name:e=fr(e),fromWireType(r){for(var e,t=m[r>>2],n=r+4,a=n,o=0;o<=t;++o){var i=n+o;if(o==t||0==h[i]){var u=ee(a,i-a);void 0===e?e=u:(e+=String.fromCharCode(0),e+=u),a=i+1}}return Ne(r),e},toWireType(r,e){var t;e instanceof ArrayBuffer&&(e=new Uint8Array(e));var n="string"==typeof e;n||e instanceof Uint8Array||e instanceof Uint8ClampedArray||e instanceof Int8Array||dr("Cannot pass non-string to std::string"),t=n?Yr(e):e.length;var a=Me(4+t+1),o=a+4;if(m[a>>2]=t,n)Xr(e,o,t+1);else if(n)for(var i=0;i<t;++i){var u=e.charCodeAt(i);u>255&&(Ne(o),dr("String has UTF-16 code units that do not fit in 8 bits")),h[o+i]=u}else for(i=0;i<t;++i)h[o+i]=e[i];return null!==r&&r.push(Ne,a),a},argPackAdvance:vr,readValueFromPointer:Z,destructorFunction(r){Ne(r)}})},ne="undefined"!=typeof TextDecoder?new TextDecoder("utf-16le"):void 0,ae=(r,e)=>{for(var t=r,n=t>>1,a=n+e/2;!(n>=a)&&v[n];)++n;if((t=n<<1)-r>32&&ne)return ne.decode(h.subarray(r,t));for(var o="",i=0;!(i>=e/2);++i){var u=p[r+2*i>>1];if(0==u)break;o+=String.fromCharCode(u)}return o},oe=(r,e,t)=>{if(t??=2147483647,t<2)return 0;for(var n=e,a=(t-=2)<2*r.length?t/2:r.length,o=0;o<a;++o){var i=r.charCodeAt(o);p[e>>1]=i,e+=2}return p[e>>1]=0,e-n},ie=r=>2*r.length,ue=(r,e)=>{for(var t=0,n="";!(t>=e/4);){var a=g[r+4*t>>2];if(0==a)break;if(++t,a>=65536){var o=a-65536;n+=String.fromCharCode(55296|o>>10,56320|1023&o)}else n+=String.fromCharCode(a)}return n},se=(r,e,t)=>{if(t??=2147483647,t<4)return 0;for(var n=e,a=n+t-4,o=0;o<r.length;++o){var i=r.charCodeAt(o);if(i>=55296&&i<=57343&&(i=65536+((1023&i)<<10)|1023&r.charCodeAt(++o)),g[e>>2]=i,(e+=4)+4>a)break}return g[e>>2]=0,e-n},le=r=>{for(var e=0,t=0;t<r.length;++t){var n=r.charCodeAt(t);n>=55296&&n<=57343&&++t,e+=4}return e},ce=(r,e,t)=>{var n,a,o,i;t=fr(t),2===e?(n=ae,a=oe,i=ie,o=r=>v[r>>1]):4===e&&(n=ue,a=se,i=le,o=r=>m[r>>2]),pr(r,{name:t,fromWireType:r=>{for(var t,a=m[r>>2],i=r+4,u=0;u<=a;++u){var s=r+4+u*e;if(u==a||0==o(s)){var l=n(i,s-i);void 0===t?t=l:(t+=String.fromCharCode(0),t+=l),i=s+e}}return Ne(r),t},toWireType:(r,n)=>{"string"!=typeof n&&dr(`Cannot pass non-string to C++ string type ${t}`);var o=i(n),u=Me(4+o+e);return m[u>>2]=o/e,a(n,u+4,o+e),null!==r&&r.push(Ne,u),u},argPackAdvance:vr,readValueFromPointer:Z,destructorFunction(r){Ne(r)}})},fe=(r,e,t,n,a,o)=>{X[r]={name:fr(e),rawConstructor:Br(t,n),rawDestructor:Br(a,o),fields:[]}},de=(r,e,t,n,a,o,i,u,s,l)=>{X[r].fields.push({fieldName:fr(e),getterReturnType:t,getter:Br(n,a),getterContext:o,setterArgumentType:i,setter:Br(u,s),setterContext:l})},he=(r,e)=>{pr(r,{isVoid:!0,name:e=fr(e),argPackAdvance:0,fromWireType:()=>{},toWireType:(r,e)=>{}})},pe=(r,e,t)=>h.copyWithin(r,e,e+t),ve=(r,e)=>{var t=ar[r];return void 0===t&&dr(`${e} has unknown type ${Nr(r)}`),t},ge=(r,e,t)=>{var n=[],a=r.toWireType(n,t);return n.length&&(m[e>>2]=Ar.toHandle(n)),a},me=(r,e,t)=>(r=Ar.toValue(r),e=ve(e,"emval::as"),ge(e,t,r)),ye=[],be=(r,e,t,n)=>(r=ye[r])(null,e=Ar.toValue(e),t,n),$e={},we=r=>{var e=$e[r];return void 0===e?fr(r):e},Ae=(r,e,t,n,a)=>(r=ye[r])(e=Ar.toValue(e),e[t=we(t)],n,a),Te=()=>{if("object"==typeof globalThis)return globalThis;function r(r){r.$$$embind_global$$$=r;var e="object"==typeof $$$embind_global$$$&&r.$$$embind_global$$$==r;return e||delete r.$$$embind_global$$$,e}if("object"==typeof $$$embind_global$$$)return $$$embind_global$$$;if("object"==typeof global&&r(global)?$$$embind_global$$$=global:"object"==typeof self&&r(self)&&($$$embind_global$$$=self),"object"==typeof $$$embind_global$$$)return $$$embind_global$$$;throw Error("unable to get global object.")},Ce=r=>0===r?Ar.toHandle(Te()):(r=we(r),Ar.toHandle(Te()[r])),Pe=r=>{var e=ye.length;return ye.push(r),e},We=(r,e)=>{for(var t=new Array(r),n=0;n<r;++n)t[n]=ve(m[e+4*n>>2],"parameter "+n);return t},Ee=Reflect.construct,_e=(r,e,t)=>{var n=We(r,e),a=n.shift();r--;var o=new Array(r),i=(e,i,u,s)=>{for(var l=0,c=0;c<r;++c)o[c]=n[c].readValueFromPointer(s+l),l+=n[c].argPackAdvance;var f=1===t?Ee(i,o):i.apply(e,o);return ge(a,u,f)},u=`methodCaller<(${n.map(r=>r.name).join(", ")}) => ${a.name}>`;return Pe(Er(u,i))},Fe=(r,e)=>(r=Ar.toValue(r),e=Ar.toValue(e),Ar.toHandle(r[e])),ke=r=>{r>9&&(yr[r+1]+=1)},Re=r=>Ar.toHandle(we(r)),Se=r=>{var e=Ar.toValue(r);Y(e),br(r)},xe=(r,e)=>{var t=(r=ve(r,"_emval_take_value")).readValueFromPointer(e);return Ar.toHandle(t)},je=()=>2147483648,Ve=(r,e)=>Math.ceil(r/e)*e,Ie=r=>{var e=(r-f.buffer.byteLength+65535)/65536|0;try{return f.grow(e),A(),1}catch(t){}},He=r=>{var e=h.length;r>>>=0;var t=je();if(r>t)return!1;for(var n=1;n<=4;n*=2){var a=e*(1+.2/n);a=Math.min(a,r+100663296);var o=Math.min(t,Ve(Math.max(r,a),65536));if(Ie(o))return!0}return!1};rr=o.InternalError=class extends Error{constructor(r){super(r),this.name="InternalError"}},cr(),tr=o.BindingError=class extends Error{constructor(r){super(r),this.name="BindingError"}},wr(),Rr=o.UnboundTypeError=Mr(Error,"UnboundTypeError");var Ue,Oe={g:K,p:Q,x:sr,o:lr,u:gr,s:Cr,l:Wr,w:Gr,c:Jr,a:Kr,t:te,i:ce,y:fe,d:de,v:he,r:pe,n:me,z:be,j:Ae,b:br,m:Ce,h:_e,A:Fe,e:ke,B:Re,f:Se,k:xe,q:He};G();var De,Be=r=>(Be=Ue.E)(r),Me=r=>(Me=Ue.G)(r),Ne=r=>(Ne=Ue.H)(r);function ze(){function r(){De||(De=!0,o.calledRun=!0,w||(E(),t(o),o.onRuntimeInitialized?.(),_()))}S>0||(W(),S>0||(o.setStatus?(o.setStatus("Running..."),setTimeout(()=>{setTimeout(()=>o.setStatus(""),1),r()},1)):r()))}if(x=function r(){De||ze(),De||(x=r)},o.preInit)for("function"==typeof o.preInit&&(o.preInit=[o.preInit]);o.preInit.length>0;)o.preInit.pop()();return ze(),i});export{e as default};
5
+ var r,e=(r="undefined"!=typeof document?document.currentScript?.src:void 0,function(e={}){var t,n,a,o=e,i=new Promise((r,e)=>{t=r,n=e}),u=Object.assign({},o),s="";function l(r){return o.locateFile?o.locateFile(r,s):s+r}"undefined"!=typeof document&&document.currentScript&&(s=document.currentScript.src),r&&(s=r),s=s.startsWith("blob:")?"":s.substr(0,s.replace(/[?#].*/,"").lastIndexOf("/")+1),a=async r=>{var e=await fetch(r,{credentials:"same-origin"});if(e.ok)return e.arrayBuffer();throw new Error(e.status+" : "+e.url)},o.print||console.log.bind(console);var c=o.printErr||console.error.bind(console);Object.assign(o,u),u=null,o.arguments&&o.arguments,o.thisProgram&&o.thisProgram;var f,d,h,p,v,g,m,y,b,$=o.wasmBinary,w=!1;function A(){var r=f.buffer;o.HEAP8=d=new Int8Array(r),o.HEAP16=p=new Int16Array(r),o.HEAPU8=h=new Uint8Array(r),o.HEAPU16=v=new Uint16Array(r),o.HEAP32=g=new Int32Array(r),o.HEAPU32=m=new Uint32Array(r),o.HEAPF32=y=new Float32Array(r),o.HEAPF64=b=new Float64Array(r)}var T=[],C=[],P=[];function W(){if(o.preRun)for("function"==typeof o.preRun&&(o.preRun=[o.preRun]);o.preRun.length;)F(o.preRun.shift());L(T)}function E(){L(C)}function _(){if(o.postRun)for("function"==typeof o.postRun&&(o.postRun=[o.postRun]);o.postRun.length;)R(o.postRun.shift());L(P)}function F(r){T.unshift(r)}function k(r){C.unshift(r)}function R(r){P.unshift(r)}var S=0,x=null;function j(r){S++,o.monitorRunDependencies?.(S)}function V(r){if(S--,o.monitorRunDependencies?.(S),0==S&&x){var e=x;x=null,e()}}function I(r){o.onAbort?.(r),c(r="Aborted("+r+")"),w=!0,r+=". Build with -sASSERTIONS for more info.";var e=new WebAssembly.RuntimeError(r);throw n(e),e}var H,U="data:application/octet-stream;base64,",O=r=>r.startsWith(U);function D(){var r="draco_mesh_decoder.wasm";return O(r)?r:l(r)}function B(r){if(r==H&&$)return new Uint8Array($);throw"both async and sync fetching of the wasm failed"}async function M(r){if(!$)try{var e=await a(r);return new Uint8Array(e)}catch{}return B(r)}async function N(r,e){try{var t=await M(r);return await WebAssembly.instantiate(t,e)}catch(n){c(`failed to asynchronously prepare wasm: ${n}`),I(n)}}async function z(r,e,t){if(!r&&"function"==typeof WebAssembly.instantiateStreaming&&!O(e)&&"function"==typeof fetch)try{var n=fetch(e,{credentials:"same-origin"});return await WebAssembly.instantiateStreaming(n,t)}catch(a){c(`wasm streaming compile failed: ${a}`),c("falling back to ArrayBuffer instantiation")}return N(e,t)}function q(){return{a:Oe}}async function G(){function r(r,e){return Ue=r.exports,f=Ue.C,A(),kr=Ue.F,k(Ue.D),V(),Ue}function e(e){r(e.instance)}j();var t=q();if(o.instantiateWasm)try{return o.instantiateWasm(t,r)}catch(i){c(`Module.instantiateWasm callback failed with error: ${i}`),n(i)}H??=D();try{var a=await z($,H,t);return e(a),a}catch(i){return void n(i)}}var L=r=>{for(;r.length>0;)r.shift()(o)};o.noExitRuntime;class J{constructor(r){this.excPtr=r,this.ptr=r-24}set_type(r){m[this.ptr+4>>2]=r}get_type(){return m[this.ptr+4>>2]}set_destructor(r){m[this.ptr+8>>2]=r}get_destructor(){return m[this.ptr+8>>2]}set_caught(r){r=r?1:0,d[this.ptr+12]=r}get_caught(){return 0!=d[this.ptr+12]}set_rethrown(r){r=r?1:0,d[this.ptr+13]=r}get_rethrown(){return 0!=d[this.ptr+13]}init(r,e){this.set_adjusted_ptr(0),this.set_type(r),this.set_destructor(e)}set_adjusted_ptr(r){m[this.ptr+16>>2]=r}get_adjusted_ptr(){return m[this.ptr+16>>2]}}var K=(r,e,t)=>{throw new J(r).init(e,t),r},Q=()=>I(""),X={},Y=r=>{for(;r.length;){var e=r.pop();r.pop()(e)}};function Z(r){return this.fromWireType(m[r>>2])}var rr,er,tr,nr={},ar={},or={},ir=r=>{throw new rr(r)},ur=(r,e,t)=>{function n(e){var n=t(e);n.length!==r.length&&ir("Mismatched type converter count");for(var a=0;a<r.length;++a)pr(r[a],n[a])}r.forEach(r=>or[r]=e);var a=new Array(e.length),o=[],i=0;e.forEach((r,e)=>{ar.hasOwnProperty(r)?a[e]=ar[r]:(o.push(r),nr.hasOwnProperty(r)||(nr[r]=[]),nr[r].push(()=>{a[e]=ar[r],++i===o.length&&n(a)}))}),0===o.length&&n(a)},sr=r=>{var e=X[r];delete X[r];var t=e.rawConstructor,n=e.rawDestructor,a=e.fields,o=a.map(r=>r.getterReturnType).concat(a.map(r=>r.setterArgumentType));ur([r],o,r=>{var o={};return a.forEach((e,t)=>{var n=e.fieldName,i=r[t],u=e.getter,s=e.getterContext,l=r[t+a.length],c=e.setter,f=e.setterContext;o[n]={read:r=>i.fromWireType(u(s,r)),write:(r,e)=>{var t=[];c(f,r,l.toWireType(t,e)),Y(t)}}}),[{name:e.name,fromWireType:r=>{var e={};for(var t in o)e[t]=o[t].read(r);return n(r),e},toWireType:(r,e)=>{for(var a in o)if(!(a in e))throw new TypeError(`Missing field: "${a}"`);var i=t();for(a in o)o[a].write(i,e[a]);return null!==r&&r.push(n,i),i},argPackAdvance:vr,readValueFromPointer:Z,destructorFunction:n}]})},lr=(r,e,t,n,a)=>{},cr=()=>{for(var r=new Array(256),e=0;e<256;++e)r[e]=String.fromCharCode(e);er=r},fr=r=>{for(var e="",t=r;h[t];)e+=er[h[t++]];return e},dr=r=>{throw new tr(r)};function hr(r,e,t={}){var n=e.name;if(r||dr(`type "${n}" must have a positive integer typeid pointer`),ar.hasOwnProperty(r)){if(t.ignoreDuplicateRegistrations)return;dr(`Cannot register type '${n}' twice`)}if(ar[r]=e,delete or[r],nr.hasOwnProperty(r)){var a=nr[r];delete nr[r],a.forEach(r=>r())}}function pr(r,e,t={}){return hr(r,e,t)}var vr=8,gr=(r,e,t,n)=>{pr(r,{name:e=fr(e),fromWireType:function(r){return!!r},toWireType:function(r,e){return e?t:n},argPackAdvance:vr,readValueFromPointer:function(r){return this.fromWireType(h[r])},destructorFunction:null})},mr=[],yr=[],br=r=>{r>9&&0===--yr[r+1]&&(yr[r]=void 0,mr.push(r))},$r=()=>yr.length/2-5-mr.length,wr=()=>{yr.push(0,1,void 0,1,null,1,!0,1,!1,1),o.count_emval_handles=$r},Ar={toValue:r=>(r||dr("Cannot use deleted val. handle = "+r),yr[r]),toHandle:r=>{switch(r){case void 0:return 2;case null:return 4;case!0:return 6;case!1:return 8;default:{const e=mr.pop()||yr.length;return yr[e]=r,yr[e+1]=1,e}}}},Tr={name:"emscripten::val",fromWireType:r=>{var e=Ar.toValue(r);return br(r),e},toWireType:(r,e)=>Ar.toHandle(e),argPackAdvance:vr,readValueFromPointer:Z,destructorFunction:null},Cr=r=>pr(r,Tr),Pr=(r,e)=>{switch(e){case 4:return function(r){return this.fromWireType(y[r>>2])};case 8:return function(r){return this.fromWireType(b[r>>3])};default:throw new TypeError(`invalid float width (${e}): ${r}`)}},Wr=(r,e,t)=>{pr(r,{name:e=fr(e),fromWireType:r=>r,toWireType:(r,e)=>e,argPackAdvance:vr,readValueFromPointer:Pr(e,t),destructorFunction:null})},Er=(r,e)=>Object.defineProperty(e,"name",{value:r});function _r(r){for(var e=1;e<r.length;++e)if(null!==r[e]&&void 0===r[e].destructorFunction)return!0;return!1}function Fr(r,e,t,n,a,o){var i=e.length;i<2&&dr("argTypes array size mismatch! Must at least get return value and 'this' types!"),e[1];var u=_r(e),s="void"!==e[0].name,l=i-2,c=new Array(l),f=[],d=[];return Er(r,function(...r){var t;d.length=0,f.length=1,f[0]=a;for(var o=0;o<l;++o)c[o]=e[o+2].toWireType(d,r[o]),f.push(c[o]);function i(r){if(u)Y(d);else for(var n=2;n<e.length;n++){var a=1===n?t:c[n-2];null!==e[n].destructorFunction&&e[n].destructorFunction(a)}if(s)return e[0].fromWireType(r)}return i(n(...f))})}var kr,Rr,Sr=(r,e,t)=>{if(void 0===r[e].overloadTable){var n=r[e];r[e]=function(...n){return r[e].overloadTable.hasOwnProperty(n.length)||dr(`Function '${t}' called with an invalid number of arguments (${n.length}) - expects one of (${r[e].overloadTable})!`),r[e].overloadTable[n.length].apply(this,n)},r[e].overloadTable=[],r[e].overloadTable[n.argCount]=n}},xr=(r,e,t)=>{o.hasOwnProperty(r)?((void 0===t||void 0!==o[r].overloadTable&&void 0!==o[r].overloadTable[t])&&dr(`Cannot register public name '${r}' twice`),Sr(o,r,r),o[r].overloadTable.hasOwnProperty(t)&&dr(`Cannot register multiple overloads of a function with the same number of arguments (${t})!`),o[r].overloadTable[t]=e):(o[r]=e,o[r].argCount=t)},jr=(r,e)=>{for(var t=[],n=0;n<r;n++)t.push(m[e+4*n>>2]);return t},Vr=(r,e,t)=>{o.hasOwnProperty(r)||ir("Replacing nonexistent public symbol"),void 0!==o[r].overloadTable&&void 0!==t?o[r].overloadTable[t]=e:(o[r]=e,o[r].argCount=t)},Ir=(r,e,t)=>(r=r.replace(/p/g,"i"),(0,o["dynCall_"+r])(e,...t)),Hr=[],Ur=r=>{var e=Hr[r];return e||(r>=Hr.length&&(Hr.length=r+1),Hr[r]=e=kr.get(r)),e},Or=(r,e,t=[])=>r.includes("j")?Ir(r,e,t):Ur(e)(...t),Dr=(r,e)=>(...t)=>Or(r,e,t),Br=(r,e)=>{function t(){return r.includes("j")?Dr(r,e):Ur(e)}r=fr(r);var n=t();return"function"!=typeof n&&dr(`unknown function pointer with signature ${r}: ${e}`),n},Mr=(r,e)=>{var t=Er(e,function(r){this.name=e,this.message=r;var t=new Error(r).stack;void 0!==t&&(this.stack=this.toString()+"\n"+t.replace(/^Error(:[^\n]*)?\n/,""))});return t.prototype=Object.create(r.prototype),t.prototype.constructor=t,t.prototype.toString=function(){return void 0===this.message?this.name:`${this.name}: ${this.message}`},t},Nr=r=>{var e=Be(r),t=fr(e);return Ne(e),t},zr=(r,e)=>{var t=[],n={};function a(r){n[r]||ar[r]||(or[r]?or[r].forEach(a):(t.push(r),n[r]=!0))}throw e.forEach(a),new Rr(`${r}: `+t.map(Nr).join([", "]))},qr=r=>{const e=(r=r.trim()).indexOf("(");return-1!==e?r.substr(0,e):r},Gr=(r,e,t,n,a,o,i,u)=>{var s=jr(e,t);r=fr(r),r=qr(r),a=Br(n,a),xr(r,function(){zr(`Cannot call ${r} due to unbound types`,s)},e-1),ur([],s,t=>{var n=[t[0],null].concat(t.slice(1));return Vr(r,Fr(r,n,null,a,o),e-1),[]})},Lr=(r,e,t)=>{switch(e){case 1:return t?r=>d[r]:r=>h[r];case 2:return t?r=>p[r>>1]:r=>v[r>>1];case 4:return t?r=>g[r>>2]:r=>m[r>>2];default:throw new TypeError(`invalid integer width (${e}): ${r}`)}},Jr=(r,e,t,n,a)=>{e=fr(e);var o=r=>r;if(0===n){var i=32-8*t;o=r=>r<<i>>>i}var u=e.includes("unsigned"),s=(r,e)=>{};pr(r,{name:e,fromWireType:o,toWireType:u?function(r,e){return s(e,this.name),e>>>0}:function(r,e){return s(e,this.name),e},argPackAdvance:vr,readValueFromPointer:Lr(e,t,0!==n),destructorFunction:null})},Kr=(r,e,t)=>{var n=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array][e];function a(r){var e=m[r>>2],t=m[r+4>>2];return new n(d.buffer,t,e)}pr(r,{name:t=fr(t),fromWireType:a,argPackAdvance:vr,readValueFromPointer:a},{ignoreDuplicateRegistrations:!0})},Qr=(r,e,t,n)=>{if(!(n>0))return 0;for(var a=t,o=t+n-1,i=0;i<r.length;++i){var u=r.charCodeAt(i);if(u>=55296&&u<=57343&&(u=65536+((1023&u)<<10)|1023&r.charCodeAt(++i)),u<=127){if(t>=o)break;e[t++]=u}else if(u<=2047){if(t+1>=o)break;e[t++]=192|u>>6,e[t++]=128|63&u}else if(u<=65535){if(t+2>=o)break;e[t++]=224|u>>12,e[t++]=128|u>>6&63,e[t++]=128|63&u}else{if(t+3>=o)break;e[t++]=240|u>>18,e[t++]=128|u>>12&63,e[t++]=128|u>>6&63,e[t++]=128|63&u}}return e[t]=0,t-a},Xr=(r,e,t)=>Qr(r,h,e,t),Yr=r=>{for(var e=0,t=0;t<r.length;++t){var n=r.charCodeAt(t);n<=127?e++:n<=2047?e+=2:n>=55296&&n<=57343?(e+=4,++t):e+=3}return e},Zr="undefined"!=typeof TextDecoder?new TextDecoder:void 0,re=(r,e=0,t=NaN)=>{for(var n=e+t,a=e;r[a]&&!(a>=n);)++a;if(a-e>16&&r.buffer&&Zr)return Zr.decode(r.subarray(e,a));for(var o="";e<a;){var i=r[e++];if(128&i){var u=63&r[e++];if(192!=(224&i)){var s=63&r[e++];if((i=224==(240&i)?(15&i)<<12|u<<6|s:(7&i)<<18|u<<12|s<<6|63&r[e++])<65536)o+=String.fromCharCode(i);else{var l=i-65536;o+=String.fromCharCode(55296|l>>10,56320|1023&l)}}else o+=String.fromCharCode((31&i)<<6|u)}else o+=String.fromCharCode(i)}return o},ee=(r,e)=>r?re(h,r,e):"",te=(r,e)=>{pr(r,{name:e=fr(e),fromWireType(r){for(var e,t=m[r>>2],n=r+4,a=n,o=0;o<=t;++o){var i=n+o;if(o==t||0==h[i]){var u=ee(a,i-a);void 0===e?e=u:(e+=String.fromCharCode(0),e+=u),a=i+1}}return Ne(r),e},toWireType(r,e){var t;e instanceof ArrayBuffer&&(e=new Uint8Array(e));var n="string"==typeof e;n||e instanceof Uint8Array||e instanceof Uint8ClampedArray||e instanceof Int8Array||dr("Cannot pass non-string to std::string"),t=n?Yr(e):e.length;var a=Me(4+t+1),o=a+4;if(m[a>>2]=t,n)Xr(e,o,t+1);else if(n)for(var i=0;i<t;++i){var u=e.charCodeAt(i);u>255&&(Ne(o),dr("String has UTF-16 code units that do not fit in 8 bits")),h[o+i]=u}else for(i=0;i<t;++i)h[o+i]=e[i];return null!==r&&r.push(Ne,a),a},argPackAdvance:vr,readValueFromPointer:Z,destructorFunction(r){Ne(r)}})},ne="undefined"!=typeof TextDecoder?new TextDecoder("utf-16le"):void 0,ae=(r,e)=>{for(var t=r,n=t>>1,a=n+e/2;!(n>=a)&&v[n];)++n;if((t=n<<1)-r>32&&ne)return ne.decode(h.subarray(r,t));for(var o="",i=0;!(i>=e/2);++i){var u=p[r+2*i>>1];if(0==u)break;o+=String.fromCharCode(u)}return o},oe=(r,e,t)=>{if(t??=2147483647,t<2)return 0;for(var n=e,a=(t-=2)<2*r.length?t/2:r.length,o=0;o<a;++o){var i=r.charCodeAt(o);p[e>>1]=i,e+=2}return p[e>>1]=0,e-n},ie=r=>2*r.length,ue=(r,e)=>{for(var t=0,n="";!(t>=e/4);){var a=g[r+4*t>>2];if(0==a)break;if(++t,a>=65536){var o=a-65536;n+=String.fromCharCode(55296|o>>10,56320|1023&o)}else n+=String.fromCharCode(a)}return n},se=(r,e,t)=>{if(t??=2147483647,t<4)return 0;for(var n=e,a=n+t-4,o=0;o<r.length;++o){var i=r.charCodeAt(o);if(i>=55296&&i<=57343&&(i=65536+((1023&i)<<10)|1023&r.charCodeAt(++o)),g[e>>2]=i,(e+=4)+4>a)break}return g[e>>2]=0,e-n},le=r=>{for(var e=0,t=0;t<r.length;++t){var n=r.charCodeAt(t);n>=55296&&n<=57343&&++t,e+=4}return e},ce=(r,e,t)=>{var n,a,o,i;t=fr(t),2===e?(n=ae,a=oe,i=ie,o=r=>v[r>>1]):4===e&&(n=ue,a=se,i=le,o=r=>m[r>>2]),pr(r,{name:t,fromWireType:r=>{for(var t,a=m[r>>2],i=r+4,u=0;u<=a;++u){var s=r+4+u*e;if(u==a||0==o(s)){var l=n(i,s-i);void 0===t?t=l:(t+=String.fromCharCode(0),t+=l),i=s+e}}return Ne(r),t},toWireType:(r,n)=>{"string"!=typeof n&&dr(`Cannot pass non-string to C++ string type ${t}`);var o=i(n),u=Me(4+o+e);return m[u>>2]=o/e,a(n,u+4,o+e),null!==r&&r.push(Ne,u),u},argPackAdvance:vr,readValueFromPointer:Z,destructorFunction(r){Ne(r)}})},fe=(r,e,t,n,a,o)=>{X[r]={name:fr(e),rawConstructor:Br(t,n),rawDestructor:Br(a,o),fields:[]}},de=(r,e,t,n,a,o,i,u,s,l)=>{X[r].fields.push({fieldName:fr(e),getterReturnType:t,getter:Br(n,a),getterContext:o,setterArgumentType:i,setter:Br(u,s),setterContext:l})},he=(r,e)=>{pr(r,{isVoid:!0,name:e=fr(e),argPackAdvance:0,fromWireType:()=>{},toWireType:(r,e)=>{}})},pe=(r,e,t)=>h.copyWithin(r,e,e+t),ve=(r,e)=>{var t=ar[r];return void 0===t&&dr(`${e} has unknown type ${Nr(r)}`),t},ge=(r,e,t)=>{var n=[],a=r.toWireType(n,t);return n.length&&(m[e>>2]=Ar.toHandle(n)),a},me=(r,e,t)=>(r=Ar.toValue(r),e=ve(e,"emval::as"),ge(e,t,r)),ye=[],be=(r,e,t,n)=>(r=ye[r])(null,e=Ar.toValue(e),t,n),$e={},we=r=>{var e=$e[r];return void 0===e?fr(r):e},Ae=(r,e,t,n,a)=>(r=ye[r])(e=Ar.toValue(e),e[t=we(t)],n,a),Te=()=>{if("object"==typeof globalThis)return globalThis;function r(r){r.$$$embind_global$$$=r;var e="object"==typeof $$$embind_global$$$&&r.$$$embind_global$$$==r;return e||delete r.$$$embind_global$$$,e}if("object"==typeof $$$embind_global$$$)return $$$embind_global$$$;if("object"==typeof global&&r(global)?$$$embind_global$$$=global:"object"==typeof self&&r(self)&&($$$embind_global$$$=self),"object"==typeof $$$embind_global$$$)return $$$embind_global$$$;throw Error("unable to get global object.")},Ce=r=>0===r?Ar.toHandle(Te()):(r=we(r),Ar.toHandle(Te()[r])),Pe=r=>{var e=ye.length;return ye.push(r),e},We=(r,e)=>{for(var t=new Array(r),n=0;n<r;++n)t[n]=ve(m[e+4*n>>2],"parameter "+n);return t},Ee=Reflect.construct,_e=(r,e,t)=>{var n=We(r,e),a=n.shift();r--;var o=new Array(r),i=(e,i,u,s)=>{for(var l=0,c=0;c<r;++c)o[c]=n[c].readValueFromPointer(s+l),l+=n[c].argPackAdvance;var f=1===t?Ee(i,o):i.apply(e,o);return ge(a,u,f)},u=`methodCaller<(${n.map(r=>r.name).join(", ")}) => ${a.name}>`;return Pe(Er(u,i))},Fe=(r,e)=>(r=Ar.toValue(r),e=Ar.toValue(e),Ar.toHandle(r[e])),ke=r=>{r>9&&(yr[r+1]+=1)},Re=r=>Ar.toHandle(we(r)),Se=r=>{var e=Ar.toValue(r);Y(e),br(r)},xe=(r,e)=>{var t=(r=ve(r,"_emval_take_value")).readValueFromPointer(e);return Ar.toHandle(t)},je=()=>2147483648,Ve=(r,e)=>Math.ceil(r/e)*e,Ie=r=>{var e=(r-f.buffer.byteLength+65535)/65536|0;try{return f.grow(e),A(),1}catch(t){}},He=r=>{var e=h.length;r>>>=0;var t=je();if(r>t)return!1;for(var n=1;n<=4;n*=2){var a=e*(1+.2/n);a=Math.min(a,r+100663296);var o=Math.min(t,Ve(Math.max(r,a),65536));if(Ie(o))return!0}return!1};rr=o.InternalError=class extends Error{constructor(r){super(r),this.name="InternalError"}},cr(),tr=o.BindingError=class extends Error{constructor(r){super(r),this.name="BindingError"}},wr(),Rr=o.UnboundTypeError=Mr(Error,"UnboundTypeError");var Ue,Oe={g:K,r:Q,m:sr,q:lr,w:gr,u:Cr,l:Wr,y:Gr,d:Jr,a:Kr,v:te,i:ce,n:fe,c:de,x:he,t:pe,p:me,z:be,j:Ae,b:br,o:Ce,h:_e,A:Fe,e:ke,B:Re,f:Se,k:xe,s:He};G();var De,Be=r=>(Be=Ue.E)(r),Me=r=>(Me=Ue.G)(r),Ne=r=>(Ne=Ue.H)(r);function ze(){function r(){De||(De=!0,o.calledRun=!0,w||(E(),t(o),o.onRuntimeInitialized?.(),_()))}S>0||(W(),S>0||(o.setStatus?(o.setStatus("Running..."),setTimeout(()=>{setTimeout(()=>o.setStatus(""),1),r()},1)):r()))}if(x=function r(){De||ze(),De||(x=r)},o.preInit)for("function"==typeof o.preInit&&(o.preInit=[o.preInit]);o.preInit.length>0;)o.preInit.pop()();return ze(),i});export{e as default};
package/config.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"./core/has.js";import{deepMerge as e}from"./core/object.js";const s={apiKey:void 0,apiKeys:{scopes:[]},applicationName:"",applicationUrl:globalThis.location?.href,assetsPath:"",fontsUrl:"https://static.arcgis.com/fonts",geometryServiceUrl:"https://utility.arcgisonline.com/arcgis/rest/services/Geometry/GeometryServer",geoRSSServiceUrl:"https://utility.arcgis.com/sharing/rss",kmlServiceUrl:"https://utility.arcgis.com/sharing/kml",userPrivilegesApplied:!0,portalUrl:"https://www.arcgis.com",respectPrefersReducedMotion:!0,routeServiceUrl:"https://route-api.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World",workers:{loaderConfig:{has:{},paths:{},map:{},packages:[]}},request:{crossOriginNoCorsDomains:null,httpsDomains:["arcgis.com","arcgisonline.com","esrikr.com","premiumservices.blackbridge.com","esripremium.accuweather.com","gbm.digitalglobe.com","firstlook.digitalglobe.com","msi.digitalglobe.com"],interceptors:[],internalInterceptors:[],maxUrlLength:2e3,priority:"high",proxyRules:[],proxyUrl:null,timeout:62e3,trustedServers:[],useIdentity:!0},log:{interceptors:[],level:null}};if(globalThis.esriConfig&&(e(s,globalThis.esriConfig,!0),delete s.has),!s.assetsPath){{const e="4.34.0-next.85";s.assetsPath=`https://cdn.jsdelivr.net/npm/@arcgis/core@${e}/assets`}s.defaultAssetsPath=s.assetsPath}export{s as default};
5
+ import"./core/has.js";import{deepMerge as e}from"./core/object.js";const s={apiKey:void 0,apiKeys:{scopes:[]},applicationName:"",applicationUrl:globalThis.location?.href,assetsPath:"",fontsUrl:"https://static.arcgis.com/fonts",geometryServiceUrl:"https://utility.arcgisonline.com/arcgis/rest/services/Geometry/GeometryServer",geoRSSServiceUrl:"https://utility.arcgis.com/sharing/rss",kmlServiceUrl:"https://utility.arcgis.com/sharing/kml",userPrivilegesApplied:!0,portalUrl:"https://www.arcgis.com",respectPrefersReducedMotion:!0,routeServiceUrl:"https://route-api.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World",workers:{loaderConfig:{has:{},paths:{},map:{},packages:[]}},request:{crossOriginNoCorsDomains:null,httpsDomains:["arcgis.com","arcgisonline.com","esrikr.com","premiumservices.blackbridge.com","esripremium.accuweather.com","gbm.digitalglobe.com","firstlook.digitalglobe.com","msi.digitalglobe.com"],interceptors:[],internalInterceptors:[],maxUrlLength:2e3,priority:"high",proxyRules:[],proxyUrl:null,timeout:62e3,trustedServers:[],useIdentity:!0},log:{interceptors:[],level:null}};if(globalThis.esriConfig&&(e(s,globalThis.esriConfig,!0),delete s.has),!s.assetsPath){{const e="4.34.0-next.87";s.assetsPath=`https://cdn.jsdelivr.net/npm/@arcgis/core@${e}/assets`}s.defaultAssetsPath=s.assetsPath}export{s as default};
package/core/NestedMap.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
- class t{constructor(){this._outer=new Map}clear(){this._outer.clear()}get empty(){return 0===this._outer.size}get outerSize(){return this._outer.size}get(t,e){return this._outer.get(t)?.get(e)}getInner(t){return this._outer.get(t)}set(t,e,r){const o=this._outer.get(t);o?o.set(e,r):this._outer.set(t,new Map([[e,r]]))}delete(t,e){const r=this._outer.get(t);r&&(r.delete(e),0===r.size&&this._outer.delete(t))}*outerMap(){for(const t of this._outer)yield t}forEach(t){this._outer.forEach((e,r)=>t(e,r))}forAll(t){this._outer.forEach((e,r)=>e.forEach((e,o)=>t(e,r,o)))}}export{t as NestedMap};
5
+ class t{constructor(){this._outer=new Map}clear(){this._outer.clear()}get empty(){return 0===this._outer.size}get outerSize(){return this._outer.size}get size(){let t=0;for(const e of this._outer.values())t+=e.size;return t}get(t,e){return this._outer.get(t)?.get(e)}getInner(t){return this._outer.get(t)}set(t,e,r){const o=this._outer.get(t);o?o.set(e,r):this._outer.set(t,new Map([[e,r]]))}delete(t,e){const r=this._outer.get(t);r&&(r.delete(e),0===r.size&&this._outer.delete(t))}pop(t,e){const r=this.get(t,e);return this.delete(t,e),r}*outerMap(){for(const t of this._outer)yield t}*values(){for(const t of this._outer.values())yield*t.values()}*[Symbol.iterator](){for(const[t,e]of this._outer)for(const[r,o]of e)yield[t,r,o]}forEach(t){this._outer.forEach((e,r)=>t(e,r))}forAll(t){this._outer.forEach((e,r)=>e.forEach((e,o)=>t(e,r,o)))}copy(){const e=new t;return this.forAll((t,r,o)=>e.set(r,o,t)),e}}export{t as NestedMap};
@@ -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
- function n(n){const o=[];return function*(){yield*o;for(const t of n)o.push(t),yield t}}function o(n,o){for(const t of n)if(null!=t&&o(t))return t}function t(n){return null!=n&&"function"==typeof n[Symbol.iterator]}export{n as cache,o as find,t as isIterable};
5
+ function n(n){const t=[];return function*(){yield*t;let e,o=t.length;for(;!(e=n.next()).done;)for(t.push(e.value),yield e.value;++o<t.length;)yield t[o]}}function t(n,t){for(const e of n)if(null!=e&&t(e))return e}function e(n){return null!=n&&"function"==typeof n[Symbol.iterator]}export{n as cache,t as find,e as isIterable};
@@ -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{fromArray as e,fromValues as t,create as r}from"../../core/libs/gl-matrix-2/factories/vec3f64.js";import{n,b as o}from"../../chunks/vec32.js";import{interpolateM as s}from"./coordUtils.js";import a from"../../geometry/Point.js";import{getLength as i}from"../../geometry/support/coordsUtils.js";import{isCoordinate as f,getEndpoint as c}from"../../geometry/support/curves/curveUtils.js";import{splitCurveAtPoint as l}from"../../geometry/support/curves/splitCurveAtPoint.js";function p(e,t,r){let n=t[0]-e[0],o=t[1]-e[1];const s=Math.hypot(n,o);return n/=s,o/=s,n*=r,o*=r,[e[0]+n,e[1]+o]}function u(e,s,a,i){const f=t(s[0]-e[0],s[1]-e[1],s[2]*i-e[2]*i);return n(f,f),o(r(),e,f,a)}function m(e,t){let r=0,n=null;const o=e.hasM,f=e.hasZ?3:2;for(const c of e.paths){if(0===t){n=new a({x:c[0][0],y:c[0][1],...o?{m:c[0][f]}:{},spatialReference:e.spatialReference,hasM:o});break}for(let l=0;l<c.length-1;l++){const u=i(c[l],c[l+1]),m=r+u;if(m===t){n=new a({x:c[l+1][0],y:c[l+1][1],...o?{m:c[l+1][f]}:{},spatialReference:e.spatialReference,hasM:o});break}if(m>t){const i=p(c[l],c[l+1],t-r);n=new a({x:i[0],y:i[1],...o?{m:s(c[l][f],c[l+1][f],u,t-r)??void 0}:{},spatialReference:e.spatialReference,hasM:o});break}r+=u}if(null!==n)break}return n}function h(t,r,n){let o=0;const i=t.hasM;for(const f of t.paths){if(0===r)return new a({x:f[0][0],y:f[0][1],z:f[0][2],...i?{m:f[0][3]}:{},hasZ:!0,hasM:i,spatialReference:t.spatialReference});for(let c=0;c<f.length-1;c++){const l=y(f[c],f[c+1],n),p=o+l;if(p===r)return new a({x:f[c+1][0],y:f[c+1][1],z:f[c+1][2],...i?{m:f[c+1][3]}:{},hasZ:!0,hasM:i,spatialReference:t.spatialReference});if(p>r){const p=u(e(f[c]),e(f[c+1]),r-o,n);return new a({x:p[0],y:p[1],z:p[2],...i?{m:s(f[c][3],f[c+1][3],l,r-o)??void 0}:{},hasZ:!0,hasM:i,spatialReference:t.spatialReference})}o+=l}}return null}function y(e,t,r){return Math.hypot(e[0]-t[0],e[1]-t[1],void 0!==e[2]&&void 0!==t[2]?e[2]*r-t[2]*r:0)}function R(e,t,r,n=.001){if(f(t)){return[[e,r],[r,t]]}const[o,s]=l(e,t,r,n);return[[e,o],[c(o),s]]}export{p as distanceAlongLineSegment,u as distanceAlongLineSegmentWithZ,m as pointAlongLine,h as pointAlongLineWithZ,y as segmentLength3d,R as splitSegmentAtPoint};
5
+ import{fromArray as e,fromValues as t,create as r}from"../../core/libs/gl-matrix-2/factories/vec3f64.js";import{n,b as o}from"../../chunks/vec32.js";import{interpolateM as s}from"./coordUtils.js";import a from"../../geometry/Point.js";import{getLength as i}from"../../geometry/support/coordsUtils.js";import{isCoordinate as f,getEndpoint as c}from"../../geometry/support/curves/curveUtils.js";import{splitCurveAtPoint as l}from"../../geometry/support/curves/splitCurveAtPoint.js";function p(e,t,r){let n=t[0]-e[0],o=t[1]-e[1];const s=Math.hypot(n,o);return n/=s,o/=s,n*=r,o*=r,[e[0]+n,e[1]+o]}function u(e,s,a,i){const f=t(s[0]-e[0],s[1]-e[1],s[2]*i-e[2]*i);return n(f,f),o(r(),e,f,a)}function m(e,t){let r=0,n=null;const o=e.hasM,f=e.hasZ?3:2;for(const c of e.paths){if(0===t){n=new a({x:c[0][0],y:c[0][1],...o?{m:c[0][f]}:{},spatialReference:e.spatialReference,hasM:o});break}for(let l=0;l<c.length-1;l++){const u=i(c[l],c[l+1]),m=r+u;if(m===t){n=new a({x:c[l+1][0],y:c[l+1][1],...o?{m:c[l+1][f]}:{},spatialReference:e.spatialReference,hasM:o});break}if(m>t){const i=p(c[l],c[l+1],t-r);n=new a({x:i[0],y:i[1],...o?{m:s(c[l][f],c[l+1][f],u,t-r)??void 0}:{},spatialReference:e.spatialReference,hasM:o});break}r+=u}if(null!==n)break}return n}function h(t,r,n){let o=0;const i=t.hasM;for(const f of t.paths){if(0===r)return new a({x:f[0][0],y:f[0][1],z:f[0][2],...i?{m:f[0][3]}:{},hasZ:!0,hasM:i,spatialReference:t.spatialReference});for(let c=0;c<f.length-1;c++){const l=y(f[c],f[c+1],n),p=o+l;if(p===r)return new a({x:f[c+1][0],y:f[c+1][1],z:f[c+1][2],...i?{m:f[c+1][3]}:{},hasZ:!0,hasM:i,spatialReference:t.spatialReference});if(p>r){const p=u(e(f[c]),e(f[c+1]),r-o,n);return new a({x:p[0],y:p[1],z:p[2],...i?{m:s(f[c][3],f[c+1][3],l,r-o)??void 0}:{},hasZ:!0,hasM:i,spatialReference:t.spatialReference})}o+=l}}return null}function y(e,t,r){return Math.hypot(e[0]-t[0],e[1]-t[1],void 0!==e[2]&&void 0!==t[2]?e[2]*r-t[2]*r:0)}function R(e,t,r,n,o=.001){if(f(t)){return[[e,r],[r,t]]}const[s,a]=l(e,t,r,o);if(n&&null!=r[2]){const e=r[2];c(s)[2]=e}return[[e,s],[c(s),a]]}export{p as distanceAlongLineSegment,u as distanceAlongLineSegmentWithZ,m as pointAlongLine,h as pointAlongLineWithZ,y as segmentLength3d,R as splitSegmentAtPoint};
@@ -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 s from"../request.js";import i from"../core/Error.js";import{Evented as o,EventedAccessor as n}from"../core/Evented.js";import{on as a}from"../core/events.js";import{fixJson as h}from"../core/lang.js";import{getDeepValue as l}from"../core/object.js";import{createResolver as c,onAbort as d,isAborted as u}from"../core/promiseUtils.js";import{urlToObject as p,hasSameOrigin as _,Url as f,queryToObject as g,base64UrlEncode as m,objectToQuery as v,normalize as S,getProxyRule as w,makeAbsolute as I,addQueryParameters as k}from"../core/urlUtils.js";import{property as A}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/Logger.js";import{subclass as y}from"../core/accessorSupport/decorators/subclass.js";import U from"./IdentityModal.js";import T from"./OAuthCredential.js";import x from"./OAuthInfo.js";import O from"./ServerInfo.js";import{isSecureProxyService as P,normalizeArcGISOnlineOrgDomain as R}from"../portal/support/urlUtils.js";const C={},D=e=>{const t=new f(e.owningSystemUrl).host,r=new f(e.server).host,s=/.+\.arcgis\.com$/i;return s.test(t)&&s.test(r)},b=(e,t)=>!!(D(e)&&t&&t.some(t=>t.test(e.server)));let q=null,j=null;try{q=window.localStorage,j=window.sessionStorage}catch{}class E extends o{constructor(){super(),this._portalConfig=globalThis.esriGeowConfig,this.serverInfos=[],this.oAuthInfos=[],this.credentials=[],this._soReqs=[],this._xoReqs=[],this._portals=[],this._defaultOAuthInfo=null,this._defaultTokenValidity=60,this.dialog=null,this.tokenValidity=null,this.normalizeWebTierAuth=!1,this._appOrigin="null"!==window.origin?window.origin:window.location.origin,this._appUrlObj=p(window.location.href),this._busy=null,this._rejectOnPersistedPageShow=!1,this._oAuthLocationParams=null,this._gwTokenUrl="/sharing/rest/generateToken",this._agsRest="/rest/services",this._agsPortal=/\/sharing(\/|$)/i,this._agsAdmin=/(https?:\/\/[^/]+\/[^/]+)\/admin\/?(\/.*)?$/i,this._adminSvcs=/\/rest\/admin\/services(\/|$)/i,this._gwDomains=[{regex:/^https?:\/\/www\.arcgis\.com/i,customBaseUrl:"maps.arcgis.com",tokenServiceUrl:"https://www.arcgis.com/sharing/rest/generateToken"},{regex:/^https?:\/\/(?:dev|[a-z\d-]+\.mapsdev)\.arcgis\.com/i,customBaseUrl:"mapsdev.arcgis.com",tokenServiceUrl:"https://dev.arcgis.com/sharing/rest/generateToken"},{regex:/^https?:\/\/(?:devext|[a-z\d-]+\.mapsdevext)\.arcgis\.com/i,customBaseUrl:"mapsdevext.arcgis.com",tokenServiceUrl:"https://devext.arcgis.com/sharing/rest/generateToken"},{regex:/^https?:\/\/(?:qaext|[a-z\d-]+\.mapsqa)\.arcgis\.com/i,customBaseUrl:"mapsqa.arcgis.com",tokenServiceUrl:"https://qaext.arcgis.com/sharing/rest/generateToken"},{regex:/^https?:\/\/[a-z\d-]+\.maps\.arcgis\.com/i,customBaseUrl:"maps.arcgis.com",tokenServiceUrl:"https://www.arcgis.com/sharing/rest/generateToken"}],this._legacyFed=[],this._regexSDirUrl=/http.+\/rest\/services\/?/gi,this._regexServerType=/(\/(FeatureServer|GPServer|GeoDataServer|GeocodeServer|GeoenrichmentServer|GeometryServer|GlobeServer|ImageServer|KnowledgeGraphServer|MapServer|MissionServer|MobileServer|NAServer|NetworkDiagramServer|OGCFeatureServer|ParcelFabricServer|RelationalCatalogServer|SceneServer|StreamServer|UtilityNetworkServer|ValidationServer|VectorTileServer|VersionManagementServer|VideoServer)).*/gi,this._gwUser=/http.+\/users\/([^/]+).*/i,this._gwItem=/http.+\/items\/([^/]+).*/i,this._gwGroup=/http.+\/groups\/([^/]+).*/i,this._rePortalTokenSvc=/\/sharing(\/rest)?\/generatetoken/i,this._createDefaultOAuthInfo=!0,this._hasTestedIfAppIsOnPortal=!1,this._getPlatformSelfError=null,this._getOAuthLocationParams(),window.addEventListener("pageshow",e=>{this._pageShowHandler(e)})}registerServers(e){const t=this.serverInfos;t?(e=e.filter(e=>!this.findServerInfo(e.server)),this.serverInfos=t.concat(e)):this.serverInfos=e,e.forEach(e=>{e.owningSystemUrl&&this._portals.push(e.owningSystemUrl),e.hasPortal&&this._portals.push(e.server)})}registerOAuthInfos(e){const t=this.oAuthInfos;if(t){for(const r of e){const e=this.findOAuthInfo(r.portalUrl);e&&t.splice(t.indexOf(e),1)}this.oAuthInfos=t.concat(e)}else this.oAuthInfos=e}registerToken(e){e={...e};const t=this._sanitizeUrl(e.server),r=this._isServerRsrc(t);let s,i=this.findServerInfo(t),o=!0;i||(i=new O,i.server=this._getServerInstanceRoot(t),r?i.hasServer=!0:(i.tokenServiceUrl=this._getTokenSvcUrl(t),i.hasPortal=!0),this.registerServers([i])),s=this._findCredential(t),s?(delete e.server,Object.assign(s,e),o=!1):(s=new L({userId:e.userId,server:i.server??void 0,token:e.token,expires:e.expires,ssl:e.ssl,scope:r?"server":"portal"}),s.resources=[t],this.credentials.push(s)),s.emitTokenChange(!1),o||s.refreshServerTokens()}toJSON(){return h({serverInfos:this.serverInfos.map(e=>e.toJSON()),oAuthInfos:this.oAuthInfos.map(e=>e.toJSON()),credentials:this.credentials.map(e=>e.toJSON())})}initialize(e){if(!e)return;"string"==typeof e&&(e=JSON.parse(e));const t=e.serverInfos,r=e.oAuthInfos,s=e.credentials;if(t){const e=[];t.forEach(t=>{t.server&&t.tokenServiceUrl&&e.push(t.declaredClass?t:new O(t))}),e.length&&this.registerServers(e)}if(r){const e=[];r.forEach(t=>{t.appId&&e.push(t.declaredClass?t:new x(t))}),e.length&&this.registerOAuthInfos(e)}s&&s.forEach(e=>{e.server&&e.token&&e.expires&&e.expires>Date.now()&&((e=e.declaredClass?e:new L(e)).emitTokenChange(),this.credentials.push(e))})}findServerInfo(e){let t;e=this._sanitizeUrl(e);for(const r of this.serverInfos)if(this._hasSameServerInstance(r.server,e)){t=r;break}return t}findOAuthInfo(e){let t;e=this._sanitizeUrl(e);for(const r of this.oAuthInfos)if(this._hasSameServerInstance(r.portalUrl,e)){t=r;break}return t}findCredential(e,t){if(!e)return;let r;e=this._sanitizeUrl(e);const s=this._isServerRsrc(e)?"server":"portal";if(t){for(const i of this.credentials)if(this._hasSameServerInstance(i.server,e)&&t===i.userId&&i.scope===s){r=i;break}}else for(const i of this.credentials)if(this._hasSameServerInstance(i.server,e)&&-1!==this._getIdenticalSvcIdx(e,i)&&i.scope===s){r=i;break}return r}getCredential(e,t){let r,s=!1,o=!0;t&&(s=!(!t.token&&!t.credential),r=t.error,o=!1!==t.prompt),t={...t},e=this._sanitizeUrl(e);const n=new AbortController,a=c();if(t.signal&&d(t.signal,()=>{n.abort()}),d(n,()=>{a.reject(new i("identity-manager:user-aborted","ABORTED"))}),u(n))return a.promise;t.signal=n.signal;const h=this._isAdminResource(e),l=s?this.findCredential(e):null;let p;if(l&&498===r?.details?.httpStatus)l.destroy();else if(l)return p=new i("identity-manager:not-authorized","You are currently signed in as: '"+l.userId+"'. You do not have access to this resource: "+e,{error:r}),a.reject(p),a.promise;const f=this._findCredential(e,t);if(f)return a.resolve(f),a.promise;let g=this.findServerInfo(e);if(g)!g.hasPortal&&g.server&&g.owningSystemUrl&&this._hasSameServerInstance(g.server,g.owningSystemUrl)&&(g.hasPortal=!0),!g.hasServer&&this._isServerRsrc(e)&&(g._restInfoPms=this._getTokenSvcUrl(e),g.hasServer=!0);else{const t=this._getTokenSvcUrl(e);if(!t)return p=new i("identity-manager:unknown-resource","Unknown resource - could not find token service endpoint."),a.reject(p),a.promise;g=new O,g.server=this._getServerInstanceRoot(e),"string"==typeof t?(g.tokenServiceUrl=t,g.hasPortal=!0):(g._restInfoPms=t,g.hasServer=!0),this.registerServers([g])}return g.hasPortal&&void 0===g._selfReq&&(o||_(g.tokenServiceUrl,this._appOrigin)||this._gwDomains.some(e=>e.tokenServiceUrl===g.tokenServiceUrl))&&(g._selfReq={owningTenant:t?.owningTenant,selfDfd:this._getPortalSelf(g.tokenServiceUrl.replace(this._rePortalTokenSvc,"/sharing/rest/portals/self"),e)}),this._enqueue(e,g,t,a,h)}getResourceName(e){return this._isRESTService(e)?e.replace(this._regexSDirUrl,"").replace(this._regexServerType,"")||"":this._gwUser.test(e)&&e.replace(this._gwUser,"$1")||this._gwItem.test(e)&&e.replace(this._gwItem,"$1")||this._gwGroup.test(e)&&e.replace(this._gwGroup,"$1")||""}generateToken(e,t,r){const o=this._rePortalTokenSvc.test(e.tokenServiceUrl),n=new f(this._appOrigin),a=e.shortLivedTokenValidity;let h,l,c,d,u,p,g,m;t&&(m=this.tokenValidity||a||this._defaultTokenValidity,m>a&&a>0&&(m=a)),r&&(h=r.isAdmin,l=r.serverUrl,c=r.token,p=r.signal,g=r.ssl,e.customParameters=r.customParameters),h?d=e.adminTokenServiceUrl:(d=e.tokenServiceUrl,u=new f(d.toLowerCase()),e.webTierAuth&&r?.serverUrl&&!g&&"http"===n.scheme&&(_(n.uri,d,!0)||"https"===u.scheme&&n.host===u.host&&"7080"===n.port&&"7443"===u.port)&&(d=d.replace(/^https:/i,"http:").replace(/:7443/i,":7080")));const v={query:{request:"getToken",username:t?.username,password:t?.password,serverUrl:l,token:c,expiration:m,referer:h||o?this._appOrigin:null,client:h?"referer":null,f:"json",...e.customParameters},method:"post",authMode:"anonymous",useProxy:this._useProxy(e,r),signal:p,...r?.ioArgs};o||(v.withCredentials=!1);return s(d,v).then(r=>{const s=r.data;if(!s?.token)return new i("identity-manager:authentication-failed","Unable to generate token");const o=e.server;return C[o]||(C[o]={}),t&&(C[o][t.username]=t.password),s.validity=m,s})}isBusy(){return!!this._busy}async checkSignInStatus(e){return(await this.checkAppAccess(e,"")).credential}checkAppAccess(e,t,r){let o=!1;return this.getCredential(e,{prompt:!1}).then(n=>{let a;const h={f:"json"};if("portal"===n.scope)if(t&&(this._doPortalSignIn(e)||r?.force))a=n.server+"/sharing/rest/oauth2/validateAppAccess",h.client_id=t;else{if(!n.token)return{credential:n};a=n.server+"/sharing/rest"}else{if(!n.token)return{credential:n};a=n.server+"/rest/services"}return n.token&&(h.token=n.token),s(a,{query:h,authMode:"anonymous"}).then(e=>{if(!1===e.data.valid)throw new i("identity-manager:not-authorized",`You are currently signed in as: '${n.userId}'.`,e.data);return o=!!e.data.viewOnlyUserTypeApp,{credential:n}}).catch(e=>{if("identity-manager:not-authorized"===e.name)throw e;const t=e.details?.httpStatus;if(498===t)throw n.destroy(),new i("identity-manager:not-authenticated","User is not signed in.");if(400===t)throw new i("identity-manager:invalid-request","Bad request");return{credential:n}})}).then(e=>({credential:e.credential,viewOnly:o}))}setOAuthResponseHash(e){e&&(e.startsWith("#")&&(e=e.slice(1)),this._processOAuthPopupParams(g(e)))}setOAuthRedirectionHandler(e){this._oAuthRedirectFunc=e}setProtocolErrorHandler(e){this._protocolFunc=e}signIn(e,t,r={}){const s=c(),o=()=>{h?.remove(),l?.remove(),this.dialog?.destroy(),this.dialog=h=l=null},n=()=>{o(),this._oAuthDfd=null,s.reject(new i("identity-manager:user-aborted","ABORTED"))};r.signal&&d(r.signal,()=>{n()});const a=new U({open:!0,resource:this.getResourceName(e),server:t.server});this.dialog=a,this.emit("dialog-create");let h=a.on("cancel",n),l=a.on("submit",e=>{this.generateToken(t,e,{isAdmin:r.isAdmin,signal:r.signal}).then(i=>{o();const n=new L({userId:e.username,server:t.server??void 0,token:i.token,expires:null!=i.expires?Number(i.expires):null,ssl:!!i.ssl,isAdmin:r.isAdmin,validity:i.validity});s.resolve(n)}).catch(e=>{a.error=e,a.signingIn=!1})});return s.promise}oAuthSignIn(e,t,r,s){this._oAuthDfd=c();const o=this._oAuthDfd;let n;s?.signal&&d(s.signal,()=>{const e=this._oAuthDfd&&this._oAuthDfd.oAuthWin_;e&&!e.closed?e.close():this.dialog&&u()}),o.resUrl_=e,o.sinfo_=t,o.oinfo_=r;const a=r._oAuthCred;if(a.storage&&("authorization-code"===r.flowType||"auto"===r.flowType&&t.currentVersion>=8.4)){let e=crypto.getRandomValues(new Uint8Array(32));n=m(e),a.codeVerifier=n,e=crypto.getRandomValues(new Uint8Array(32)),a.stateUID=m(e),a.save()||(a.codeVerifier=n=null)}else a.codeVerifier=null;let h,l;this._getCodeChallenge(n).then(i=>{const o=!s||!1!==s.oAuthPopupConfirmation;if(!r.popup||!o)return void this._doOAuthSignIn(e,t,r,i);const n=new U({oAuthPrompt:!0,server:t.server,open:!0});this.dialog=n,this.emit("dialog-create"),h=n.on("cancel",u),l=n.on("submit",()=>{p(),this._doOAuthSignIn(e,t,r,i)})});const u=()=>{p(),this._oAuthDfd=null,o.reject(new i("identity-manager:user-aborted","ABORTED"))},p=()=>{h?.remove(),l?.remove(),this.dialog?.destroy(),this.dialog=null};return o.promise}destroyCredentials(){if(this.credentials){this.credentials.slice().forEach(e=>{e.destroy()})}this.emit("credentials-destroy")}enablePostMessageAuth(e="https://www.arcgis.com/sharing/rest"){this._postMessageAuthHandle&&this._postMessageAuthHandle.remove(),this._postMessageAuthHandle=a(window,"message",t=>{if((t.origin===this._appOrigin||t.origin.endsWith(".arcgis.com"))&&"arcgis:auth:requestCredential"===t.data?.type){const r=t.source;this.getCredential(e).then(e=>{r.postMessage({type:"arcgis:auth:credential",credential:{expires:e.expires,server:e.server,ssl:e.ssl,token:e.token,userId:e.userId}},t.origin)}).catch(e=>{r.postMessage({type:"arcgis:auth:error",error:{name:e.name,message:e.message}},t.origin)})}})}disablePostMessageAuth(){this._postMessageAuthHandle&&(this._postMessageAuthHandle.remove(),this._postMessageAuthHandle=null)}_getOAuthLocationParams(){let e=window.location.hash;if(e){e.startsWith("#")&&(e=e.slice(1));const t=g(e);let r=!1;if(t.access_token&&t.expires_in&&t.state&&t.hasOwnProperty("username"))try{t.state=JSON.parse(t.state),t.state.portalUrl&&(this._oAuthLocationParams=t,r=!0)}catch{}else if(t.error&&t.error_description&&(console.log("IdentityManager OAuth Error: ",t.error," - ",t.error_description),"access_denied"===t.error&&(r=!0,t.state)))try{t.state=JSON.parse(t.state)}catch{}r&&(window.location.hash=t.state?.hash||"")}let t=window.location.search;if(t){t.startsWith("?")&&(t=t.slice(1));const e=g(t);let r=!1;if(e.code&&e.state)try{e.state=JSON.parse(e.state),e.state.portalUrl&&e.state.uid&&(this._oAuthLocationParams=e,r=!0)}catch{}else if(e.error&&e.error_description&&(console.log("IdentityManager OAuth Error: ",e.error," - ",e.error_description),"access_denied"===e.error&&(r=!0,e.state)))try{e.state=JSON.parse(e.state)}catch{}if(r){const t={...e};["code","error","error_description","message_code","persist","state"].forEach(e=>{delete t[e]});const r=v(t),s=window.location.pathname+(r?`?${r}`:"")+(e.state?.hash||"");window.history.replaceState(window.history.state,"",s)}}}_getOAuthToken(e,t,r,i,o){return e=e.replace(/^http:/i,"https:"),s(`${e}/sharing/rest/oauth2/token`,{authMode:"anonymous",method:"post",query:i&&o?{grant_type:"authorization_code",code:t,redirect_uri:i,client_id:r,code_verifier:o}:{grant_type:"refresh_token",refresh_token:t,client_id:r}}).then(e=>e.data)}async _getCodeChallenge(e){if(e&&globalThis.isSecureContext){const t=(new TextEncoder).encode(e),r=await crypto.subtle.digest("SHA-256",t);return m(new Uint8Array(r))}return null}_pageShowHandler(e){if(e.persisted&&this.isBusy()&&this._rejectOnPersistedPageShow){const e=new i("identity-manager:user-aborted","ABORTED");this._errbackFunc(e)}}_findCredential(e,t){let r,s,i,o,n=-1;const a=t?.token,h=t?.resource,l=this._isServerRsrc(e)?"server":"portal",c=this.credentials.filter(t=>this._hasSameServerInstance(t.server,e)&&t.scope===l);if(e=h||e,c.length)if(1===c.length){if(r=c[0],i=this.findServerInfo(r.server),s=i?.owningSystemUrl,o=s?this.findCredential(s,r.userId):void 0,n=this._getIdenticalSvcIdx(e,r),!a)return-1===n&&r.resources.push(e),this._addResource(e,o),r;-1!==n&&(r.resources.splice(n,1),this._removeResource(e,o))}else{let t,r;if(c.some(a=>(r=this._getIdenticalSvcIdx(e,a),-1!==r&&(t=a,i=this.findServerInfo(t.server),s=i?.owningSystemUrl,o=s?this.findCredential(s,t.userId):void 0,n=r,!0))),a)t&&(t.resources.splice(n,1),this._removeResource(e,o));else if(t)return this._addResource(e,o),t}}_findOAuthInfo(e){let t=this.findOAuthInfo(e);if(!t)for(const r of this.oAuthInfos)if(this._isIdProvider(r.portalUrl,e)){t=r;break}return t}_addResource(e,t){t&&-1===this._getIdenticalSvcIdx(e,t)&&t.resources.push(e)}_removeResource(e,t){let r=-1;t&&(r=this._getIdenticalSvcIdx(e,t),r>-1&&t.resources.splice(r,1))}_useProxy(e,t){return t?.isAdmin&&!_(e.adminTokenServiceUrl,this._appOrigin)||!this._isPortalDomain(e.tokenServiceUrl)&&"10.1"===String(e.currentVersion)&&!_(e.tokenServiceUrl,this._appOrigin)}_getOrigin(e){const t=new f(e);return t.scheme+"://"+t.host+(null!=t.port?":"+t.port:"")}_getServerInstanceRoot(e){const t=e.toLowerCase();let r=t.indexOf(this._agsRest);return-1===r&&this._isAdminResource(e)&&(r=this._agsAdmin.test(e)?e.replace(this._agsAdmin,"$1").length:e.search(this._adminSvcs)),-1!==r||P(t)||(r=t.indexOf("/sharing")),-1===r&&t.endsWith("/")&&(r=t.length-1),r>-1?e.slice(0,r):e}_hasSameServerInstance(e,t){return e.endsWith("/")&&(e=e.slice(0,-1)),e=e.toLowerCase(),t=this._getServerInstanceRoot(t).toLowerCase(),e=R(e),t=R(t),(e=e.slice(Math.max(0,e.indexOf(":"))))===(t=t.slice(Math.max(0,t.indexOf(":"))))}_sanitizeUrl(e){const r=(t.request.proxyUrl||"").toLowerCase(),s=r?e.toLowerCase().indexOf(r+"?"):-1;return-1!==s&&(e=e.slice(s+r.length+1)),e=S(e),p(e).path}_isRESTService(e){return e.includes(this._agsRest)}_isAdminResource(e){return this._agsAdmin.test(e)||this._adminSvcs.test(e)}_isServerRsrc(e){return this._isRESTService(e)||this._isAdminResource(e)}_isIdenticalService(e,t){let r=!1;if(this._isRESTService(e)&&this._isRESTService(t)){const s=this._getSuffix(e).toLowerCase(),i=this._getSuffix(t).toLowerCase();if(r=s===i,!r){const e=/(.*)\/(MapServer|FeatureServer|UtilityNetworkServer).*/gi;r=s.replaceAll(e,"$1")===i.replaceAll(e,"$1")}}else this._isAdminResource(e)&&this._isAdminResource(t)?r=!0:this._isServerRsrc(e)||this._isServerRsrc(t)||!this._isPortalDomain(e)||(r=!0);return r}_isPortalDomain(e){const r=new f(e.toLowerCase()),s=this._portalConfig;let i=this._gwDomains.some(e=>e.regex.test(r.uri));return!i&&s&&(i=this._hasSameServerInstance(this._getServerInstanceRoot(s.restBaseUrl),r.uri)),i||t.portalUrl&&(i=_(r,t.portalUrl,!0)),i||(i=this._portals.some(e=>this._hasSameServerInstance(e,r.uri))),i=i||this._agsPortal.test(r.path),i}_isIdProvider(e,t){let r=-1,s=-1;this._gwDomains.forEach((i,o)=>{-1===r&&i.regex.test(e)&&(r=o),-1===s&&i.regex.test(t)&&(s=o)});let i=!1;if(r>-1&&s>-1&&(0===r||4===r?0!==s&&4!==s||(i=!0):1===r?1!==s&&2!==s||(i=!0):2===r?2===s&&(i=!0):3===r&&3===s&&(i=!0)),!i){const r=this.findServerInfo(t),s=r?.owningSystemUrl;s&&D(r)&&this._isPortalDomain(s)&&this._isIdProvider(e,s)&&(i=!0)}return i}_getIdenticalSvcIdx(e,t){let r=-1;for(let s=0;s<t.resources.length;s++){const i=t.resources[s];if(this._isIdenticalService(e,i)){r=s;break}}return r}_getSuffix(e){return e.replace(this._regexSDirUrl,"").replace(this._regexServerType,"$1")}_getTokenSvcUrl(e){let t,r,i;if(this._isRESTService(e)||this._isAdminResource(e)){const i=this._getServerInstanceRoot(e);return t=i+"/admin/generateToken",r=s(e=i+"/rest/info",{query:{f:"json"}}).then(e=>e.data),{adminUrl:t,promise:r}}if(this._isPortalDomain(e)){let t="";if(this._gwDomains.some(r=>(r.regex.test(e)&&(t=r.tokenServiceUrl),!!t)),t||this._portals.some(r=>(this._hasSameServerInstance(r,e)&&(t=r+this._gwTokenUrl),!!t)),t||(i=e.toLowerCase().indexOf("/sharing"),-1!==i&&(t=e.slice(0,i)+this._gwTokenUrl)),t||(t=this._getOrigin(e)+this._gwTokenUrl),t){const r=new f(e).port;/^http:\/\//i.test(e)&&"7080"===r&&(t=t.replace(/:7080/i,":7443")),t=t.replace(/http:/i,"https:")}return t}}_processOAuthResponseParams(e,t,r){const s=t._oAuthCred;if(e.code){const i=s.codeVerifier;return s.codeVerifier=null,s.stateUID=null,s.save(),this._getOAuthToken(r.server,e.code,t.appId,this._getRedirectURI(t,!0),i).then(i=>{const o=new L({userId:i.username,server:r.server??void 0,token:i.access_token,expires:Date.now()+1e3*i.expires_in,ssl:i.ssl,oAuthState:e.state,_oAuthCred:s});return t.userId=o.userId,s.storage=i.persist?q:j,s.refreshToken=i.refresh_token,s.token=null,s.expires=i.refresh_token_expires_in?Date.now()+1e3*i.refresh_token_expires_in:null,s.userId=o.userId,s.ssl=o.ssl,s.save(),o})}const i=new L({userId:e.username,server:r.server??void 0,token:e.access_token,expires:Date.now()+1e3*Number(e.expires_in),ssl:"true"===e.ssl,oAuthState:e.state,_oAuthCred:s});return t.userId=i.userId,s.storage=e.persist?q:j,s.refreshToken=null,s.token=i.token,s.expires=i.expires,s.userId=i.userId,s.ssl=i.ssl,s.save(),Promise.resolve(i)}_processOAuthPopupParams(e){const t=this._oAuthDfd;if(this._oAuthDfd=null,t)if(clearInterval(this._oAuthIntervalId),this._oAuthOnPopupHandle?.remove(),e.error){const r="access_denied"===e.error,s=new i(r?"identity-manager:user-aborted":"identity-manager:authentication-failed",r?"ABORTED":"OAuth: "+e.error+" - "+e.error_description);t.reject(s)}else this._processOAuthResponseParams(e,t.oinfo_,t.sinfo_).then(e=>{t.resolve(e)}).catch(e=>{t.reject(e)})}_setOAuthResponseQueryString(e){e&&(e.startsWith("?")&&(e=e.slice(1)),this._processOAuthPopupParams(g(e)))}async _exchangeToken(e,t,r){return(await s(`${e}/sharing/rest/oauth2/exchangeToken`,{authMode:"anonymous",method:"post",query:{f:"json",client_id:t,token:r}})).data.token}async _getPlatformSelf(e,t){if(this._getPlatformSelfError&&Date.now()-this._getPlatformSelfError[1]<1e3)throw this._getPlatformSelfError[0];e=e.replace(/^http:/i,"https:");try{const r=await s(`${e}/sharing/rest/oauth2/platformSelf`,{authMode:"anonymous",headers:{"X-Esri-Auth-Client-Id":t,"X-Esri-Auth-Redirect-Uri":window.location.href.replace(/#.*$/,"")},method:"post",query:{f:"json",expiration:30},withCredentials:!0});return this._getPlatformSelfError=null,r.data}catch(r){throw"OAUTH_0066"===r.details?.messageCode&&(this._getPlatformSelfError=[r,Date.now()]),r}}_getPortalSelf(e,t){let r;if(this._gwDomains.some(t=>(t.regex.test(e)&&(r=t.customBaseUrl),!!r)),r)return Promise.resolve({allSSL:!0,currentVersion:"8.4",customBaseUrl:r,portalMode:"multitenant",supportsOAuth:!0});this._appOrigin.startsWith("https:")?e=e.replace(/^http:/i,"https:").replace(/:7080/i,":7443"):/^http:/i.test(t)&&(e=e.replace(/^https:/i,"http:").replace(/:7443/i,":7080"));return s(e,{query:{f:"json"},authMode:"anonymous",withCredentials:!0}).then(e=>e.data)}_doPortalSignIn(e){const t=this._portalConfig,r=window.location.href,s=this.findServerInfo(e);return!(!t&&!this._isPortalDomain(r)||!(s?s.hasPortal||s.owningSystemUrl&&this._isPortalDomain(s.owningSystemUrl):this._isPortalDomain(e))||!(this._isIdProvider(r,e)||t&&(this._hasSameServerInstance(this._getServerInstanceRoot(t.restBaseUrl),e)||this._isIdProvider(t.restBaseUrl,e))||_(r,e,!0)))}_checkProtocol(e,t,r,s){let o=!0;const n=s?t.adminTokenServiceUrl:t.tokenServiceUrl;if(n.trim().toLowerCase().startsWith("https:")&&!this._appOrigin.startsWith("https:")&&w(n)&&(o=!!this._protocolFunc&&!!this._protocolFunc({resourceUrl:e,serverInfo:t}),!o)){r(new i("identity-manager:aborted","Aborted the Sign-In process to avoid sending password over insecure connection."))}return o}_enqueue(e,t,r,s,i,o){return s||(s=c()),s.resUrl_=e,s.sinfo_=t,s.options_=r,s.admin_=i,s.refresh_=o,this._busy?this._hasSameServerInstance(this._getServerInstanceRoot(e),this._busy.resUrl_)?(this._oAuthDfd&&this._oAuthDfd.oAuthWin_&&this._oAuthDfd.oAuthWin_.focus(),this._soReqs.push(s)):this._xoReqs.push(s):this._doSignIn(s),s.promise}_doSignIn(e){this._busy=e,this._rejectOnPersistedPageShow=!1;const t=t=>{const r=e.options_?.resource,s=e.resUrl_,i=e.refresh_;let o=!1;this.credentials.includes(t)||(i&&this.credentials.includes(i)?(i.userId=t.userId,i.token=t.token,i.expires=t.expires,i.validity=t.validity,i.ssl=t.ssl,i.creationTime=t.creationTime,o=!0,t=i):this.credentials.push(t)),t.resources||(t.resources=[]),t.resources.includes(r||s)||t.resources.push(r||s),t.scope=this._isServerRsrc(s)?"server":"portal",t.emitTokenChange();const n=this._soReqs,a={};this._soReqs=[],n.forEach(e=>{if(!this._isIdenticalService(s,e.resUrl_)){const r=this._getSuffix(e.resUrl_);a[r]||(a[r]=!0,t.resources.push(e.resUrl_))}}),e.resolve(t),n.forEach(e=>{this._hasSameServerInstance(this._getServerInstanceRoot(s),e.resUrl_)?e.resolve(t):this._soReqs.push(e)}),this._busy=e.resUrl_=e.sinfo_=e.refresh_=null,o||this.emit("credential-create",{credential:t}),this._soReqs.length?this._doSignIn(this._soReqs.shift()):this._xoReqs.length&&this._doSignIn(this._xoReqs.shift())},r=t=>{e.reject(t),this._busy=e.resUrl_=e.sinfo_=e.refresh_=null,this._soReqs.length?this._doSignIn(this._soReqs.shift()):this._xoReqs.length&&this._doSignIn(this._xoReqs.shift())},s=(o,n,h,l)=>{const c=e.sinfo_,u=!e.options_||!1!==e.options_.prompt,p=c.hasPortal&&this._findOAuthInfo(e.resUrl_);let f,g;if(o)t(new L({userId:o,server:c.server??void 0,token:h??void 0,expires:null!=l?Number(l):null,ssl:!!n}));else if(window!==window.parent&&this._appUrlObj.query?.["arcgis-auth-origin"]&&this._appUrlObj.query?.["arcgis-auth-portal"]&&this._hasSameServerInstance(this._getServerInstanceRoot(this._appUrlObj.query["arcgis-auth-portal"]),e.resUrl_)){window.parent.postMessage({type:"arcgis:auth:requestCredential"},this._appUrlObj.query["arcgis-auth-origin"]);const s=a(window,"message",e=>{e.source===window.parent&&e.data&&("arcgis:auth:credential"===e.data.type?(s.remove(),e.data.credential.expires<Date.now()?r(new i("identity-manager:credential-request-failed","Parent application's token has expired.")):t(new L(e.data.credential))):"arcgis:auth:error"===e.data.type&&(s.remove(),"tokenExpiredError"===e.data.error.name?r(new i("identity-manager:credential-request-failed","Parent application's token has expired.")):r(i.fromJSON(e.data.error))))});d(e.options_?.signal,()=>{s.remove()})}else if(p){let o=p._oAuthCred;if(!o){const e=new T(p,q),t=new T(p,j);e.isValid()&&t.isValid()?e.expires>t.expires?(o=e,t.destroy()):(o=t,e.destroy()):o=e.isValid()?e:t,p._oAuthCred=o}if(o.isValid()){f=new L({userId:o.userId??void 0,server:c.server??void 0,token:o.token??void 0,expires:o.expires,ssl:o.ssl??void 0,_oAuthCred:o});const i=p.appId!==o.appId&&this._doPortalSignIn(e.resUrl_);i||o.refreshToken?(e._pendingDfd=o.refreshToken?this._getOAuthToken(c.server,o.refreshToken,o.appId).then(e=>(f.expires=Date.now()+1e3*e.expires_in,f.token=e.access_token,f)):Promise.resolve(f),e._pendingDfd.then(e=>i?this._exchangeToken(e.server,p.appId,e.token).then(t=>(e.token=t,e)).catch(()=>e):e).then(e=>{t(e)}).catch(e=>{const t=e.details?.httpStatus;t>0&&404!==t?(o.destroy(),s()):r(e)})):t(f)}else if(this._oAuthLocationParams&&this._hasSameServerInstance(p.portalUrl,this._oAuthLocationParams.state.portalUrl)&&(this._oAuthLocationParams.access_token||this._oAuthLocationParams.code&&this._oAuthLocationParams.state.uid===o.stateUID&&o.codeVerifier)){const s=this._oAuthLocationParams;this._oAuthLocationParams=null,e._pendingDfd=this._processOAuthResponseParams(s,p,c).then(e=>{t(e)}).catch(r)}else{const s=()=>{u?e._pendingDfd=this.oAuthSignIn(e.resUrl_,c,p,e.options_).then(t,r):(g=new i("identity-manager:not-authenticated","User is not signed in."),r(g))};this._doPortalSignIn(e.resUrl_)?e._pendingDfd=this._getPlatformSelf(c.server,p.appId).then(e=>{_(e.portalUrl,this._appOrigin,!0)?(f=new L({userId:e.username,server:c.server??void 0,expires:Date.now()+1e3*e.expires_in,token:e.token}),t(f)):s()}).catch(s):s()}}else if(u){if(this._checkProtocol(e.resUrl_,c,r,e.admin_)){let s=e.options_;e.admin_&&(s=s||{},s.isAdmin=!0),e._pendingDfd=this.signIn(e.resUrl_,c,s).then(t,r)}}else g=new i("identity-manager:not-authenticated","User is not signed in."),r(g)},o=()=>{const s=e.sinfo_,i=s.owningSystemUrl,o=e.options_;let n,a,h,l;if(o&&(n=o.token,a=o.error,h=o.prompt),l=this._findCredential(i,{token:n,resource:e.resUrl_}),!l)for(const e of this.credentials)if(this._isIdProvider(i,e.server)){l=e;break}if(l){const i=this.findCredential(e.resUrl_,l.userId);if(i)t(i);else if(b(s,this._legacyFed)){const e=l.toJSON();e.server=s.server,e.resources=null,t(new L(e))}else{(e._pendingDfd=this.generateToken(this.findServerInfo(l.server),null,{serverUrl:e.resUrl_,token:l.token,signal:e.options_.signal,ssl:l.ssl})).then(r=>{t(new L({userId:l?.userId,server:s.server??void 0,token:r.token,expires:null!=r.expires?Number(r.expires):null,ssl:!!r.ssl,isAdmin:e.admin_,validity:r.validity}))},r)}}else{this._busy=null,n&&(e.options_.token=null);(e._pendingDfd=this.getCredential(i.replace(/\/?$/,"/sharing"),{resource:e.resUrl_,owningTenant:s.owningTenant,signal:e.options_.signal,token:n,error:a,prompt:h})).then(()=>{this._enqueue(e.resUrl_,e.sinfo_,e.options_,e,e.admin_)},t=>{e.resUrl_=e.sinfo_=e.refresh_=null,e.reject(t)})}};this._errbackFunc=r;const n=e.sinfo_.owningSystemUrl,h=this._isServerRsrc(e.resUrl_),c=e.sinfo_._restInfoPms;c?c.promise.then(t=>{const r=e.sinfo_;if(r._restInfoPms){r.adminTokenServiceUrl=r._restInfoPms.adminUrl,r._restInfoPms=null,r.tokenServiceUrl=(l("authInfo.tokenServicesUrl",t)||l("authInfo.tokenServiceUrl",t)||l("tokenServiceUrl",t))??null,r.shortLivedTokenValidity=l("authInfo.shortLivedTokenValidity",t)??null,r.currentVersion=t.currentVersion,r.owningTenant=t.owningTenant;const e=r.owningSystemUrl=t.owningSystemUrl;e&&this._portals.push(e)}h&&r.owningSystemUrl?o():s()},()=>{e.sinfo_._restInfoPms=null;const t=new i("identity-manager:server-identification-failed","Unknown resource - could not find token service endpoint.");r(t)}):h&&n?o():e.sinfo_._selfReq?e.sinfo_._selfReq.selfDfd.then(t=>{const r={};let s,i,o,n;return t&&(s=t.user?.username,r.username=s,r.allSSL=t.allSSL,i=t.supportsOAuth,n=parseFloat(t.currentVersion),"multitenant"===t.portalMode&&(o=t.customBaseUrl),e.sinfo_.currentVersion=n),e.sinfo_.webTierAuth=!!s,s&&this.normalizeWebTierAuth?this.generateToken(e.sinfo_,null,{ssl:r.allSSL}).catch(()=>null).then(e=>(r.portalToken=e?.token,r.tokenExpiration=e?.expires,r)):!s&&i&&n>=4.4&&!this._findOAuthInfo(e.resUrl_)?this._generateOAuthInfo({portalUrl:e.sinfo_.server,customBaseUrl:o,owningTenant:e.sinfo_._selfReq.owningTenant}).catch(()=>null).then(()=>r):r}).catch(()=>null).then(t=>{e.sinfo_._selfReq=null,t?s(t.username,t.allSSL,t.portalToken,t.tokenExpiration):s()}):s()}_generateOAuthInfo(e){let t,r=null,i=e.portalUrl;const o=e.customBaseUrl,n=e.owningTenant,a=!this._defaultOAuthInfo&&this._createDefaultOAuthInfo&&!this._hasTestedIfAppIsOnPortal;if(a){r=this._appUrlObj.path;const e=r.search(/\/(apps|home)\//);r=e>-1?r.slice(0,e):null}return a&&r?(this._hasTestedIfAppIsOnPortal=!0,t=s(r+"/sharing/rest",{query:{f:"json"}}).then(()=>{this._defaultOAuthInfo=new x({appId:"arcgisonline",popupCallbackUrl:r+"/home/oauth-callback.html"})})):t=Promise.resolve(),t.then(()=>{if(this._defaultOAuthInfo)return i=i.replace(/^http:/i,"https:"),s(i+"/sharing/rest/oauth2/validateRedirectUri",{query:{accountId:n,client_id:this._defaultOAuthInfo.appId,redirect_uri:I(this._defaultOAuthInfo.popupCallbackUrl),f:"json"}}).then(e=>{if(e.data.valid){const t=this._defaultOAuthInfo.clone();e.data.urlKey&&o?t.portalUrl="https://"+e.data.urlKey.toLowerCase()+"."+o:t.portalUrl=i,t.popup=window!==window.top||!(_(i,this._appOrigin)||this._gwDomains.some(e=>e.regex.test(i)&&e.regex.test(this._appOrigin))),this.oAuthInfos.push(t)}})})}_doOAuthSignIn(e,t,r,s){const o=r._oAuthCred,n={portalUrl:r.portalUrl};!r.popup&&r.preserveUrlHash&&window.location.hash&&(n.hash=window.location.hash),o.stateUID&&(n.uid=o.stateUID);const h={client_id:r.appId,response_type:o.codeVerifier?"code":"token",state:JSON.stringify(n),expiration:r.expiration,locale:r.locale,redirect_uri:this._getRedirectURI(r,!!o.codeVerifier)};r.forceLogin&&(h.force_login=!0),r.forceUserId&&r.userId&&(h.prepopulatedusername=r.userId),!r.popup&&this._doPortalSignIn(e)&&(h.redirectToUserOrgUrl=!0),o.codeVerifier&&(h.code_challenge=s||o.codeVerifier,h.code_challenge_method=s?"S256":"plain");const l=r.portalUrl.replace(/^http:/i,"https:")+"/sharing/oauth2/authorize",c=l+"?"+v(h);if(r.popup){const e=window.open(c,"esriJSAPIOAuth",r.popupWindowFeatures);if(e)e.focus(),this._oAuthDfd.oAuthWin_=e,this._oAuthIntervalId=setInterval(()=>{if(e.closed){clearInterval(this._oAuthIntervalId),this._oAuthOnPopupHandle.remove();const e=this._oAuthDfd;if(e){const t=new i("identity-manager:user-aborted","ABORTED");e.reject(t)}}},500),this._oAuthOnPopupHandle=a(window,["arcgis:auth:hash","arcgis:auth:location:search"],e=>{"arcgis:auth:hash"===e.type?this.setOAuthResponseHash(e.detail):this._setOAuthResponseQueryString(e.detail)});else{const e=new i("identity-manager:popup-blocked","ABORTED");this._oAuthDfd.reject(e)}}else this._rejectOnPersistedPageShow=!0,this._oAuthRedirectFunc?this._oAuthRedirectFunc({authorizeParams:h,authorizeUrl:l,resourceUrl:e,serverInfo:t,oAuthInfo:r}):window.location.href=c}_getRedirectURI(e,t){const r=window.location.href.replace(/#.*$/,"");if(e.popup)return I(e.popupCallbackUrl);if(t){const e=p(r);return e.query&&["code","error","error_description","message_code","persist","state"].forEach(t=>{delete e.query[t]}),k(e.path,e.query)}return r}}E.prototype.declaredClass="esri.identity.IdentityManagerBase";let L=class extends n{constructor(e){super(e),this._oAuthCred=null,this.tokenRefreshBuffer=2,e?._oAuthCred&&(this._oAuthCred=e._oAuthCred)}initialize(){this.resources=this.resources||[],null==this.creationTime&&(this.creationTime=Date.now())}refreshToken(){const e=r,t=e.findServerInfo(this.server),s=t?.owningSystemUrl,i=!!s&&"server"===this.scope,o=i&&b(t,e._legacyFed),n=t.webTierAuth,a=n&&e.normalizeWebTierAuth,h=C[this.server],l=h?.[this.userId];let c,d=this.resources&&this.resources[0],u=i?e.findServerInfo(s):null,p={username:this.userId,password:l};if(n&&!a)return;i&&!u&&e.serverInfos.some(t=>(e._isIdProvider(s,t.server)&&(u=t),!!u));const _=u?e.findCredential(u.server,this.userId):null;if(!i||_){if(!o){if(i)c={serverUrl:d,token:_?.token,ssl:_?.ssl};else if(a)p=null,c={ssl:this.ssl};else{if(!l){let r;return d&&(d=e._sanitizeUrl(d),this._enqueued=1,r=e._enqueue(d,t,null,null,this.isAdmin,this),r.then(()=>{this._enqueued=0,this.refreshServerTokens()}).catch(()=>{this._enqueued=0})),r}this.isAdmin&&(c={isAdmin:!0})}return e.generateToken(i?u:t,i?null:p,c).then(e=>{this.token=e.token,this.expires=null!=e.expires?Number(e.expires):null,this.creationTime=Date.now(),this.validity=e.validity,this.emitTokenChange(),this.refreshServerTokens()}).catch(()=>{})}_?.refreshToken()}}refreshServerTokens(){if("portal"===this.scope){const e=r;e.credentials.forEach(t=>{const r=e.findServerInfo(t.server),s=r?.owningSystemUrl;t!==this&&t.userId===this.userId&&s&&"server"===t.scope&&(e._hasSameServerInstance(this.server,s)||e._isIdProvider(s,this.server))&&(b(r,e._legacyFed)?(t.token=this.token,t.expires=this.expires,t.creationTime=this.creationTime,t.validity=this.validity,t.emitTokenChange()):t.refreshToken())})}}emitTokenChange(e){clearTimeout(this._refreshTimer);const t=r,s=this.server?t.findServerInfo(this.server):null,i=s?.owningSystemUrl,o=i?t.findServerInfo(i):null;!1===e||i&&"portal"!==this.scope&&(!o?.webTierAuth||t.normalizeWebTierAuth)||null==this.expires&&null==this.validity||this._startRefreshTimer(),this.emit("token-change")}destroy(){this.userId=this.server=this.token=this.expires=this.validity=this.resources=this.creationTime=null,this._oAuthCred&&(this._oAuthCred.destroy(),this._oAuthCred=null);const e=r,t=e.credentials.indexOf(this);t>-1&&e.credentials.splice(t,1),this.emitTokenChange(),this.emit("destroy")}toJSON(){const e=h({userId:this.userId,server:this.server,token:this.token,expires:this.expires,validity:this.validity,ssl:this.ssl,isAdmin:this.isAdmin,creationTime:this.creationTime,scope:this.scope}),t=this.resources;return t&&t.length>0&&(e.resources=t.slice()),e}_startRefreshTimer(){clearTimeout(this._refreshTimer);const e=6e4*this.tokenRefreshBuffer,t=2**31-1;let r=(this.validity?this.creationTime+6e4*this.validity:this.expires)-Date.now();r<0?r=0:r>t&&(r=t),this._refreshTimer=setTimeout(this.refreshToken.bind(this),r>e?r-e:r)}};e([A()],L.prototype,"creationTime",void 0),e([A()],L.prototype,"expires",void 0),e([A()],L.prototype,"isAdmin",void 0),e([A()],L.prototype,"oAuthState",void 0),e([A()],L.prototype,"resources",void 0),e([A()],L.prototype,"scope",void 0),e([A()],L.prototype,"server",void 0),e([A()],L.prototype,"ssl",void 0),e([A()],L.prototype,"token",void 0),e([A()],L.prototype,"tokenRefreshBuffer",void 0),e([A()],L.prototype,"userId",void 0),e([A()],L.prototype,"validity",void 0),L=e([y("esri.identity.Credential")],L);export{L as Credential,E as IdentityManagerBase};
5
+ import{__decorate as e}from"tslib";import t from"../config.js";import{id as r}from"../kernel.js";import s from"../request.js";import i from"../core/Error.js";import{Evented as o,EventedAccessor as n}from"../core/Evented.js";import{on as a}from"../core/events.js";import{fixJson as h}from"../core/lang.js";import{getDeepValue as l}from"../core/object.js";import{createResolver as c,onAbort as d,isAborted as u}from"../core/promiseUtils.js";import{urlToObject as p,hasSameOrigin as _,Url as f,queryToObject as g,base64UrlEncode as m,objectToQuery as v,normalize as S,getProxyRule as w,makeAbsolute as I,addQueryParameters as k}from"../core/urlUtils.js";import{property as A}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/Logger.js";import{subclass as y}from"../core/accessorSupport/decorators/subclass.js";import U from"./IdentityModal.js";import T from"./OAuthCredential.js";import x from"./OAuthInfo.js";import O from"./ServerInfo.js";import{isSecureProxyService as P,normalizeArcGISOnlineOrgDomain as R}from"../portal/support/urlUtils.js";const C={},D=e=>{const t=new f(e.owningSystemUrl).host,r=new f(e.server).host,s=/.+\.arcgis\.com$/i;return s.test(t)&&s.test(r)},b=(e,t)=>!!(D(e)&&t&&t.some(t=>t.test(e.server)));let q=null,j=null;try{q=window.localStorage,j=window.sessionStorage}catch{}class E extends o{constructor(){super(),this._portalConfig=globalThis.esriGeowConfig,this.serverInfos=[],this.oAuthInfos=[],this.credentials=[],this._soReqs=[],this._xoReqs=[],this._portals=[],this._defaultOAuthInfo=null,this._defaultTokenValidity=60,this.dialog=null,this.tokenValidity=null,this.normalizeWebTierAuth=!1,this._appOrigin="null"!==window.origin?window.origin:window.location.origin,this._appUrlObj=p(window.location.href),this._busy=null,this._rejectOnPersistedPageShow=!1,this._oAuthLocationParams=null,this._gwTokenUrl="/sharing/rest/generateToken",this._agsRest="/rest/services",this._agsPortal=/\/sharing(\/|$)/i,this._agsAdmin=/(https?:\/\/[^/]+\/[^/]+)\/admin\/?(\/.*)?$/i,this._adminSvcs=/\/rest\/admin\/services(\/|$)/i,this._gwDomains=[{regex:/^https?:\/\/www\.arcgis\.com/i,customBaseUrl:"maps.arcgis.com",tokenServiceUrl:"https://www.arcgis.com/sharing/rest/generateToken"},{regex:/^https?:\/\/(?:dev|[a-z\d-]+\.mapsdev)\.arcgis\.com/i,customBaseUrl:"mapsdev.arcgis.com",tokenServiceUrl:"https://dev.arcgis.com/sharing/rest/generateToken"},{regex:/^https?:\/\/(?:devext|[a-z\d-]+\.mapsdevext)\.arcgis\.com/i,customBaseUrl:"mapsdevext.arcgis.com",tokenServiceUrl:"https://devext.arcgis.com/sharing/rest/generateToken"},{regex:/^https?:\/\/(?:qaext|[a-z\d-]+\.mapsqa)\.arcgis\.com/i,customBaseUrl:"mapsqa.arcgis.com",tokenServiceUrl:"https://qaext.arcgis.com/sharing/rest/generateToken"},{regex:/^https?:\/\/[a-z\d-]+\.maps\.arcgis\.com/i,customBaseUrl:"maps.arcgis.com",tokenServiceUrl:"https://www.arcgis.com/sharing/rest/generateToken"}],this._legacyFed=[],this._regexSDirUrl=/http.+\/rest\/services\/?/gi,this._regexServerType=/(\/(FeatureServer|GPServer|GeoDataServer|GeocodeServer|GeoenrichmentServer|GeometryServer|GlobeServer|ImageServer|KnowledgeGraphServer|MapServer|MissionServer|MobileServer|NAServer|NetworkDiagramServer|OGCFeatureServer|ParcelFabricServer|RelationalCatalogServer|SceneServer|StreamServer|UtilityNetworkServer|ValidationServer|VectorTileServer|VersionManagementServer|VideoServer)).*/gi,this._gwUser=/http.+\/users\/([^/]+).*/i,this._gwItem=/http.+\/items\/([^/]+).*/i,this._gwGroup=/http.+\/groups\/([^/]+).*/i,this._rePortalTokenSvc=/\/sharing(\/rest)?\/generatetoken/i,this._createDefaultOAuthInfo=!0,this._hasTestedIfAppIsOnPortal=!1,this._getPlatformSelfError=null,this._getOAuthLocationParams(),window.addEventListener("pageshow",e=>{this._pageShowHandler(e)})}registerServers(e){const t=this.serverInfos;t?(e=e.filter(e=>!this.findServerInfo(e.server)),this.serverInfos=t.concat(e)):this.serverInfos=e,e.forEach(e=>{e.owningSystemUrl&&this._portals.push(e.owningSystemUrl),e.hasPortal&&this._portals.push(e.server)})}registerOAuthInfos(e){const t=this.oAuthInfos;if(t){for(const r of e){const e=this.findOAuthInfo(r.portalUrl);e&&t.splice(t.indexOf(e),1)}this.oAuthInfos=t.concat(e)}else this.oAuthInfos=e}registerToken(e){e={...e};const t=this._sanitizeUrl(e.server),r=this._isServerRsrc(t);let s,i=this.findServerInfo(t),o=!0;i||(i=new O,i.server=this._getServerInstanceRoot(t),r?i.hasServer=!0:(i.tokenServiceUrl=this._getTokenSvcUrl(t),i.hasPortal=!0),this.registerServers([i])),s=this._findCredential(t),s?(delete e.server,Object.assign(s,e),o=!1):(s=new L({userId:e.userId,server:i.server??void 0,token:e.token,expires:e.expires,ssl:e.ssl,scope:r?"server":"portal"}),s.resources=[t],this.credentials.push(s)),s.emitTokenChange(!1),o||s.refreshServerTokens()}toJSON(){return h({serverInfos:this.serverInfos.map(e=>e.toJSON()),oAuthInfos:this.oAuthInfos.map(e=>e.toJSON()),credentials:this.credentials.map(e=>e.toJSON())})}initialize(e){if(!e)return;"string"==typeof e&&(e=JSON.parse(e));const t=e.serverInfos,r=e.oAuthInfos,s=e.credentials;if(t){const e=[];t.forEach(t=>{t.server&&t.tokenServiceUrl&&e.push(t.declaredClass?t:new O(t))}),e.length&&this.registerServers(e)}if(r){const e=[];r.forEach(t=>{t.appId&&e.push(t.declaredClass?t:new x(t))}),e.length&&this.registerOAuthInfos(e)}s&&s.forEach(e=>{e.server&&e.token&&e.expires&&e.expires>Date.now()&&((e=e.declaredClass?e:new L(e)).emitTokenChange(),this.credentials.push(e))})}findServerInfo(e){let t;e=this._sanitizeUrl(e);for(const r of this.serverInfos)if(this._hasSameServerInstance(r.server,e)){t=r;break}return t}findOAuthInfo(e){let t;e=this._sanitizeUrl(e);for(const r of this.oAuthInfos)if(this._hasSameServerInstance(r.portalUrl,e)){t=r;break}return t}findCredential(e,t){if(!e)return;let r;e=this._sanitizeUrl(e);const s=this._isServerRsrc(e)?"server":"portal";if(t){for(const i of this.credentials)if(this._hasSameServerInstance(i.server,e)&&t===i.userId&&i.scope===s){r=i;break}}else for(const i of this.credentials)if(this._hasSameServerInstance(i.server,e)&&-1!==this._getIdenticalSvcIdx(e,i)&&i.scope===s){r=i;break}return r}getCredential(e,t){let r,s=!1,o=!0;t&&(s=!(!t.token&&!t.credential),r=t.error,o=!1!==t.prompt),t={...t},e=this._sanitizeUrl(e);const n=new AbortController,a=c();if(t.signal&&d(t.signal,()=>{n.abort()}),d(n,()=>{a.reject(new i("identity-manager:user-aborted","ABORTED"))}),u(n))return a.promise;t.signal=n.signal;const h=this._isAdminResource(e),l=s?this.findCredential(e):null;let p;if(l&&498===r?.details?.httpStatus)l.destroy();else if(l)return p=new i("identity-manager:not-authorized","You are currently signed in as: '"+l.userId+"'. You do not have access to this resource: "+e,{error:r}),a.reject(p),a.promise;const f=this._findCredential(e,t);if(f)return a.resolve(f),a.promise;let g=this.findServerInfo(e);if(g)!g.hasPortal&&g.server&&g.owningSystemUrl&&this._hasSameServerInstance(g.server,g.owningSystemUrl)&&(g.hasPortal=!0),!g.hasServer&&this._isServerRsrc(e)&&(g._restInfoPms=this._getTokenSvcUrl(e),g.hasServer=!0);else{const t=this._getTokenSvcUrl(e);if(!t)return p=new i("identity-manager:unknown-resource","Unknown resource - could not find token service endpoint."),a.reject(p),a.promise;g=new O,g.server=this._getServerInstanceRoot(e),"string"==typeof t?(g.tokenServiceUrl=t,g.hasPortal=!0):(g._restInfoPms=t,g.hasServer=!0),this.registerServers([g])}return g.hasPortal&&void 0===g._selfReq&&(o||_(g.tokenServiceUrl,this._appOrigin)||this._gwDomains.some(e=>e.tokenServiceUrl===g.tokenServiceUrl))&&(g._selfReq={owningTenant:t?.owningTenant,selfDfd:this._getPortalSelf(g.tokenServiceUrl.replace(this._rePortalTokenSvc,"/sharing/rest/portals/self"),e)}),this._enqueue(e,g,t,a,h)}getResourceName(e){return this._isRESTService(e)?e.replace(this._regexSDirUrl,"").replace(this._regexServerType,"")||"":this._gwUser.test(e)&&e.replace(this._gwUser,"$1")||this._gwItem.test(e)&&e.replace(this._gwItem,"$1")||this._gwGroup.test(e)&&e.replace(this._gwGroup,"$1")||""}generateToken(e,t,r){const o=this._rePortalTokenSvc.test(e.tokenServiceUrl),n=new f(this._appOrigin),a=e.shortLivedTokenValidity;let h,l,c,d,u,p,g,m;t&&(m=this.tokenValidity||a||this._defaultTokenValidity,m>a&&a>0&&(m=a)),r&&(h=r.isAdmin,l=r.serverUrl,c=r.token,p=r.signal,g=r.ssl,e.customParameters=r.customParameters),h?d=e.adminTokenServiceUrl:(d=e.tokenServiceUrl,u=new f(d.toLowerCase()),e.webTierAuth&&r?.serverUrl&&!g&&"http"===n.scheme&&(_(n.uri,d,!0)||"https"===u.scheme&&n.host===u.host&&"7080"===n.port&&"7443"===u.port)&&(d=d.replace(/^https:/i,"http:").replace(/:7443/i,":7080")));const v={query:{request:"getToken",username:t?.username,password:t?.password,serverUrl:l,token:c,expiration:m,referer:h||o?this._appOrigin:null,client:h?"referer":null,f:"json",...e.customParameters},method:"post",authMode:"anonymous",useProxy:this._useProxy(e,r),signal:p};o||(v.withCredentials=!1);return s(d,v).then(r=>{const s=r.data;if(!s?.token)return new i("identity-manager:authentication-failed","Unable to generate token");const o=e.server;return C[o]||(C[o]={}),t&&(C[o][t.username]=t.password),s.validity=m,s})}isBusy(){return!!this._busy}async checkSignInStatus(e){return(await this.checkAppAccess(e,"")).credential}checkAppAccess(e,t,r){let o=!1;return this.getCredential(e,{prompt:!1}).then(n=>{let a;const h={f:"json"};if("portal"===n.scope)if(t&&(this._doPortalSignIn(e)||r?.force))a=n.server+"/sharing/rest/oauth2/validateAppAccess",h.client_id=t;else{if(!n.token)return{credential:n};a=n.server+"/sharing/rest"}else{if(!n.token)return{credential:n};a=n.server+"/rest/services"}return n.token&&(h.token=n.token),s(a,{query:h,authMode:"anonymous"}).then(e=>{if(!1===e.data.valid)throw new i("identity-manager:not-authorized",`You are currently signed in as: '${n.userId}'.`,e.data);return o=!!e.data.viewOnlyUserTypeApp,{credential:n}}).catch(e=>{if("identity-manager:not-authorized"===e.name)throw e;const t=e.details?.httpStatus;if(498===t)throw n.destroy(),new i("identity-manager:not-authenticated","User is not signed in.");if(400===t)throw new i("identity-manager:invalid-request","Bad request");return{credential:n}})}).then(e=>({credential:e.credential,viewOnly:o}))}setOAuthResponseHash(e){e&&(e.startsWith("#")&&(e=e.slice(1)),this._processOAuthPopupParams(g(e)))}setOAuthRedirectionHandler(e){this._oAuthRedirectFunc=e}setProtocolErrorHandler(e){this._protocolFunc=e}signIn(e,t,r={}){const s=c(),o=()=>{h?.remove(),l?.remove(),this.dialog?.destroy(),this.dialog=h=l=null},n=()=>{o(),this._oAuthDfd=null,s.reject(new i("identity-manager:user-aborted","ABORTED"))};r.signal&&d(r.signal,()=>{n()});const a=new U({open:!0,resource:this.getResourceName(e),server:t.server});this.dialog=a,this.emit("dialog-create");let h=a.on("cancel",n),l=a.on("submit",e=>{this.generateToken(t,e,{isAdmin:r.isAdmin,signal:r.signal}).then(i=>{o();const n=new L({userId:e.username,server:t.server??void 0,token:i.token,expires:null!=i.expires?Number(i.expires):null,ssl:!!i.ssl,isAdmin:r.isAdmin,validity:i.validity});s.resolve(n)}).catch(e=>{a.error=e,a.signingIn=!1})});return s.promise}oAuthSignIn(e,t,r,s){this._oAuthDfd=c();const o=this._oAuthDfd;let n;s?.signal&&d(s.signal,()=>{const e=this._oAuthDfd&&this._oAuthDfd.oAuthWin_;e&&!e.closed?e.close():this.dialog&&u()}),o.resUrl_=e,o.sinfo_=t,o.oinfo_=r;const a=r._oAuthCred;if(a.storage&&("authorization-code"===r.flowType||"auto"===r.flowType&&t.currentVersion>=8.4)){let e=crypto.getRandomValues(new Uint8Array(32));n=m(e),a.codeVerifier=n,e=crypto.getRandomValues(new Uint8Array(32)),a.stateUID=m(e),a.save()||(a.codeVerifier=n=null)}else a.codeVerifier=null;let h,l;this._getCodeChallenge(n).then(i=>{const o=!s||!1!==s.oAuthPopupConfirmation;if(!r.popup||!o)return void this._doOAuthSignIn(e,t,r,i);const n=new U({oAuthPrompt:!0,server:t.server,open:!0});this.dialog=n,this.emit("dialog-create"),h=n.on("cancel",u),l=n.on("submit",()=>{p(),this._doOAuthSignIn(e,t,r,i)})});const u=()=>{p(),this._oAuthDfd=null,o.reject(new i("identity-manager:user-aborted","ABORTED"))},p=()=>{h?.remove(),l?.remove(),this.dialog?.destroy(),this.dialog=null};return o.promise}destroyCredentials(){if(this.credentials){this.credentials.slice().forEach(e=>{e.destroy()})}this.emit("credentials-destroy")}enablePostMessageAuth(e="https://www.arcgis.com/sharing/rest"){this._postMessageAuthHandle&&this._postMessageAuthHandle.remove(),this._postMessageAuthHandle=a(window,"message",t=>{if((t.origin===this._appOrigin||t.origin.endsWith(".arcgis.com"))&&"arcgis:auth:requestCredential"===t.data?.type){const r=t.source;this.getCredential(e).then(e=>{r.postMessage({type:"arcgis:auth:credential",credential:{expires:e.expires,server:e.server,ssl:e.ssl,token:e.token,userId:e.userId}},t.origin)}).catch(e=>{r.postMessage({type:"arcgis:auth:error",error:{name:e.name,message:e.message}},t.origin)})}})}disablePostMessageAuth(){this._postMessageAuthHandle&&(this._postMessageAuthHandle.remove(),this._postMessageAuthHandle=null)}_getOAuthLocationParams(){let e=window.location.hash;if(e){e.startsWith("#")&&(e=e.slice(1));const t=g(e);let r=!1;if(t.access_token&&t.expires_in&&t.state&&t.hasOwnProperty("username"))try{t.state=JSON.parse(t.state),t.state.portalUrl&&(this._oAuthLocationParams=t,r=!0)}catch{}else if(t.error&&t.error_description&&(console.log("IdentityManager OAuth Error: ",t.error," - ",t.error_description),"access_denied"===t.error&&(r=!0,t.state)))try{t.state=JSON.parse(t.state)}catch{}r&&(window.location.hash=t.state?.hash||"")}let t=window.location.search;if(t){t.startsWith("?")&&(t=t.slice(1));const e=g(t);let r=!1;if(e.code&&e.state)try{e.state=JSON.parse(e.state),e.state.portalUrl&&e.state.uid&&(this._oAuthLocationParams=e,r=!0)}catch{}else if(e.error&&e.error_description&&(console.log("IdentityManager OAuth Error: ",e.error," - ",e.error_description),"access_denied"===e.error&&(r=!0,e.state)))try{e.state=JSON.parse(e.state)}catch{}if(r){const t={...e};["code","error","error_description","message_code","persist","state"].forEach(e=>{delete t[e]});const r=v(t),s=window.location.pathname+(r?`?${r}`:"")+(e.state?.hash||"");window.history.replaceState(window.history.state,"",s)}}}_getOAuthToken(e,t,r,i,o){return e=e.replace(/^http:/i,"https:"),s(`${e}/sharing/rest/oauth2/token`,{authMode:"anonymous",method:"post",query:i&&o?{grant_type:"authorization_code",code:t,redirect_uri:i,client_id:r,code_verifier:o}:{grant_type:"refresh_token",refresh_token:t,client_id:r}}).then(e=>e.data)}async _getCodeChallenge(e){if(e&&globalThis.isSecureContext){const t=(new TextEncoder).encode(e),r=await crypto.subtle.digest("SHA-256",t);return m(new Uint8Array(r))}return null}_pageShowHandler(e){if(e.persisted&&this.isBusy()&&this._rejectOnPersistedPageShow){const e=new i("identity-manager:user-aborted","ABORTED");this._errbackFunc(e)}}_findCredential(e,t){let r,s,i,o,n=-1;const a=t?.token,h=t?.resource,l=this._isServerRsrc(e)?"server":"portal",c=this.credentials.filter(t=>this._hasSameServerInstance(t.server,e)&&t.scope===l);if(e=h||e,c.length)if(1===c.length){if(r=c[0],i=this.findServerInfo(r.server),s=i?.owningSystemUrl,o=s?this.findCredential(s,r.userId):void 0,n=this._getIdenticalSvcIdx(e,r),!a)return-1===n&&r.resources.push(e),this._addResource(e,o),r;-1!==n&&(r.resources.splice(n,1),this._removeResource(e,o))}else{let t,r;if(c.some(a=>(r=this._getIdenticalSvcIdx(e,a),-1!==r&&(t=a,i=this.findServerInfo(t.server),s=i?.owningSystemUrl,o=s?this.findCredential(s,t.userId):void 0,n=r,!0))),a)t&&(t.resources.splice(n,1),this._removeResource(e,o));else if(t)return this._addResource(e,o),t}}_findOAuthInfo(e){let t=this.findOAuthInfo(e);if(!t)for(const r of this.oAuthInfos)if(this._isIdProvider(r.portalUrl,e)){t=r;break}return t}_addResource(e,t){t&&-1===this._getIdenticalSvcIdx(e,t)&&t.resources.push(e)}_removeResource(e,t){let r=-1;t&&(r=this._getIdenticalSvcIdx(e,t),r>-1&&t.resources.splice(r,1))}_useProxy(e,t){return t?.isAdmin&&!_(e.adminTokenServiceUrl,this._appOrigin)||!this._isPortalDomain(e.tokenServiceUrl)&&"10.1"===String(e.currentVersion)&&!_(e.tokenServiceUrl,this._appOrigin)}_getOrigin(e){const t=new f(e);return t.scheme+"://"+t.host+(null!=t.port?":"+t.port:"")}_getServerInstanceRoot(e){const t=e.toLowerCase();let r=t.indexOf(this._agsRest);return-1===r&&this._isAdminResource(e)&&(r=this._agsAdmin.test(e)?e.replace(this._agsAdmin,"$1").length:e.search(this._adminSvcs)),-1!==r||P(t)||(r=t.indexOf("/sharing")),-1===r&&t.endsWith("/")&&(r=t.length-1),r>-1?e.slice(0,r):e}_hasSameServerInstance(e,t){return e.endsWith("/")&&(e=e.slice(0,-1)),e=e.toLowerCase(),t=this._getServerInstanceRoot(t).toLowerCase(),e=R(e),t=R(t),(e=e.slice(Math.max(0,e.indexOf(":"))))===(t=t.slice(Math.max(0,t.indexOf(":"))))}_sanitizeUrl(e){const r=(t.request.proxyUrl||"").toLowerCase(),s=r?e.toLowerCase().indexOf(r+"?"):-1;return-1!==s&&(e=e.slice(s+r.length+1)),e=S(e),p(e).path}_isRESTService(e){return e.includes(this._agsRest)}_isAdminResource(e){return this._agsAdmin.test(e)||this._adminSvcs.test(e)}_isServerRsrc(e){return this._isRESTService(e)||this._isAdminResource(e)}_isIdenticalService(e,t){let r=!1;if(this._isRESTService(e)&&this._isRESTService(t)){const s=this._getSuffix(e).toLowerCase(),i=this._getSuffix(t).toLowerCase();if(r=s===i,!r){const e=/(.*)\/(MapServer|FeatureServer|UtilityNetworkServer).*/gi;r=s.replaceAll(e,"$1")===i.replaceAll(e,"$1")}}else this._isAdminResource(e)&&this._isAdminResource(t)?r=!0:this._isServerRsrc(e)||this._isServerRsrc(t)||!this._isPortalDomain(e)||(r=!0);return r}_isPortalDomain(e){const r=new f(e.toLowerCase()),s=this._portalConfig;let i=this._gwDomains.some(e=>e.regex.test(r.uri));return!i&&s&&(i=this._hasSameServerInstance(this._getServerInstanceRoot(s.restBaseUrl),r.uri)),i||t.portalUrl&&(i=_(r,t.portalUrl,!0)),i||(i=this._portals.some(e=>this._hasSameServerInstance(e,r.uri))),i=i||this._agsPortal.test(r.path),i}_isIdProvider(e,t){let r=-1,s=-1;this._gwDomains.forEach((i,o)=>{-1===r&&i.regex.test(e)&&(r=o),-1===s&&i.regex.test(t)&&(s=o)});let i=!1;if(r>-1&&s>-1&&(0===r||4===r?0!==s&&4!==s||(i=!0):1===r?1!==s&&2!==s||(i=!0):2===r?2===s&&(i=!0):3===r&&3===s&&(i=!0)),!i){const r=this.findServerInfo(t),s=r?.owningSystemUrl;s&&D(r)&&this._isPortalDomain(s)&&this._isIdProvider(e,s)&&(i=!0)}return i}_getIdenticalSvcIdx(e,t){let r=-1;for(let s=0;s<t.resources.length;s++){const i=t.resources[s];if(this._isIdenticalService(e,i)){r=s;break}}return r}_getSuffix(e){return e.replace(this._regexSDirUrl,"").replace(this._regexServerType,"$1")}_getTokenSvcUrl(e){let t,r,i;if(this._isRESTService(e)||this._isAdminResource(e)){const i=this._getServerInstanceRoot(e);return t=i+"/admin/generateToken",r=s(e=i+"/rest/info",{query:{f:"json"}}).then(e=>e.data),{adminUrl:t,promise:r}}if(this._isPortalDomain(e)){let t="";if(this._gwDomains.some(r=>(r.regex.test(e)&&(t=r.tokenServiceUrl),!!t)),t||this._portals.some(r=>(this._hasSameServerInstance(r,e)&&(t=r+this._gwTokenUrl),!!t)),t||(i=e.toLowerCase().indexOf("/sharing"),-1!==i&&(t=e.slice(0,i)+this._gwTokenUrl)),t||(t=this._getOrigin(e)+this._gwTokenUrl),t){const r=new f(e).port;/^http:\/\//i.test(e)&&"7080"===r&&(t=t.replace(/:7080/i,":7443")),t=t.replace(/http:/i,"https:")}return t}}_processOAuthResponseParams(e,t,r){const s=t._oAuthCred;if(e.code){const i=s.codeVerifier;return s.codeVerifier=null,s.stateUID=null,s.save(),this._getOAuthToken(r.server,e.code,t.appId,this._getRedirectURI(t,!0),i).then(i=>{const o=new L({userId:i.username,server:r.server??void 0,token:i.access_token,expires:Date.now()+1e3*i.expires_in,ssl:i.ssl,oAuthState:e.state,_oAuthCred:s});return t.userId=o.userId,s.storage=i.persist?q:j,s.refreshToken=i.refresh_token,s.token=null,s.expires=i.refresh_token_expires_in?Date.now()+1e3*i.refresh_token_expires_in:null,s.userId=o.userId,s.ssl=o.ssl,s.save(),o})}const i=new L({userId:e.username,server:r.server??void 0,token:e.access_token,expires:Date.now()+1e3*Number(e.expires_in),ssl:"true"===e.ssl,oAuthState:e.state,_oAuthCred:s});return t.userId=i.userId,s.storage=e.persist?q:j,s.refreshToken=null,s.token=i.token,s.expires=i.expires,s.userId=i.userId,s.ssl=i.ssl,s.save(),Promise.resolve(i)}_processOAuthPopupParams(e){const t=this._oAuthDfd;if(this._oAuthDfd=null,t)if(clearInterval(this._oAuthIntervalId),this._oAuthOnPopupHandle?.remove(),e.error){const r="access_denied"===e.error,s=new i(r?"identity-manager:user-aborted":"identity-manager:authentication-failed",r?"ABORTED":"OAuth: "+e.error+" - "+e.error_description);t.reject(s)}else this._processOAuthResponseParams(e,t.oinfo_,t.sinfo_).then(e=>{t.resolve(e)}).catch(e=>{t.reject(e)})}_setOAuthResponseQueryString(e){e&&(e.startsWith("?")&&(e=e.slice(1)),this._processOAuthPopupParams(g(e)))}async _exchangeToken(e,t,r){return(await s(`${e}/sharing/rest/oauth2/exchangeToken`,{authMode:"anonymous",method:"post",query:{f:"json",client_id:t,token:r}})).data.token}async _getPlatformSelf(e,t){if(this._getPlatformSelfError&&Date.now()-this._getPlatformSelfError[1]<1e3)throw this._getPlatformSelfError[0];e=e.replace(/^http:/i,"https:");try{const r=await s(`${e}/sharing/rest/oauth2/platformSelf`,{authMode:"anonymous",headers:{"X-Esri-Auth-Client-Id":t,"X-Esri-Auth-Redirect-Uri":window.location.href.replace(/#.*$/,"")},method:"post",query:{f:"json",expiration:30},withCredentials:!0});return this._getPlatformSelfError=null,r.data}catch(r){throw"OAUTH_0066"===r.details?.messageCode&&(this._getPlatformSelfError=[r,Date.now()]),r}}_getPortalSelf(e,t){let r;if(this._gwDomains.some(t=>(t.regex.test(e)&&(r=t.customBaseUrl),!!r)),r)return Promise.resolve({allSSL:!0,currentVersion:"8.4",customBaseUrl:r,portalMode:"multitenant",supportsOAuth:!0});this._appOrigin.startsWith("https:")?e=e.replace(/^http:/i,"https:").replace(/:7080/i,":7443"):/^http:/i.test(t)&&(e=e.replace(/^https:/i,"http:").replace(/:7443/i,":7080"));return s(e,{query:{f:"json"},authMode:"anonymous",withCredentials:!0}).then(e=>e.data)}_doPortalSignIn(e){const t=this._portalConfig,r=window.location.href,s=this.findServerInfo(e);return!(!t&&!this._isPortalDomain(r)||!(s?s.hasPortal||s.owningSystemUrl&&this._isPortalDomain(s.owningSystemUrl):this._isPortalDomain(e))||!(this._isIdProvider(r,e)||t&&(this._hasSameServerInstance(this._getServerInstanceRoot(t.restBaseUrl),e)||this._isIdProvider(t.restBaseUrl,e))||_(r,e,!0)))}_checkProtocol(e,t,r,s){let o=!0;const n=s?t.adminTokenServiceUrl:t.tokenServiceUrl;if(n.trim().toLowerCase().startsWith("https:")&&!this._appOrigin.startsWith("https:")&&w(n)&&(o=!!this._protocolFunc&&!!this._protocolFunc({resourceUrl:e,serverInfo:t}),!o)){r(new i("identity-manager:aborted","Aborted the Sign-In process to avoid sending password over insecure connection."))}return o}_enqueue(e,t,r,s,i,o){return s||(s=c()),s.resUrl_=e,s.sinfo_=t,s.options_=r,s.admin_=i,s.refresh_=o,this._busy?this._hasSameServerInstance(this._getServerInstanceRoot(e),this._busy.resUrl_)?(this._oAuthDfd&&this._oAuthDfd.oAuthWin_&&this._oAuthDfd.oAuthWin_.focus(),this._soReqs.push(s)):this._xoReqs.push(s):this._doSignIn(s),s.promise}_doSignIn(e){this._busy=e,this._rejectOnPersistedPageShow=!1;const t=t=>{const r=e.options_?.resource,s=e.resUrl_,i=e.refresh_;let o=!1;this.credentials.includes(t)||(i&&this.credentials.includes(i)?(i.userId=t.userId,i.token=t.token,i.expires=t.expires,i.validity=t.validity,i.ssl=t.ssl,i.creationTime=t.creationTime,o=!0,t=i):this.credentials.push(t)),t.resources||(t.resources=[]),t.resources.includes(r||s)||t.resources.push(r||s),t.scope=this._isServerRsrc(s)?"server":"portal",t.emitTokenChange();const n=this._soReqs,a={};this._soReqs=[],n.forEach(e=>{if(!this._isIdenticalService(s,e.resUrl_)){const r=this._getSuffix(e.resUrl_);a[r]||(a[r]=!0,t.resources.push(e.resUrl_))}}),e.resolve(t),n.forEach(e=>{this._hasSameServerInstance(this._getServerInstanceRoot(s),e.resUrl_)?e.resolve(t):this._soReqs.push(e)}),this._busy=e.resUrl_=e.sinfo_=e.refresh_=null,o||this.emit("credential-create",{credential:t}),this._soReqs.length?this._doSignIn(this._soReqs.shift()):this._xoReqs.length&&this._doSignIn(this._xoReqs.shift())},r=t=>{e.reject(t),this._busy=e.resUrl_=e.sinfo_=e.refresh_=null,this._soReqs.length?this._doSignIn(this._soReqs.shift()):this._xoReqs.length&&this._doSignIn(this._xoReqs.shift())},s=(o,n,h,l)=>{const c=e.sinfo_,u=!e.options_||!1!==e.options_.prompt,p=c.hasPortal&&this._findOAuthInfo(e.resUrl_);let f,g;if(o)t(new L({userId:o,server:c.server??void 0,token:h??void 0,expires:null!=l?Number(l):null,ssl:!!n}));else if(window!==window.parent&&this._appUrlObj.query?.["arcgis-auth-origin"]&&this._appUrlObj.query?.["arcgis-auth-portal"]&&this._hasSameServerInstance(this._getServerInstanceRoot(this._appUrlObj.query["arcgis-auth-portal"]),e.resUrl_)){window.parent.postMessage({type:"arcgis:auth:requestCredential"},this._appUrlObj.query["arcgis-auth-origin"]);const s=a(window,"message",e=>{e.source===window.parent&&e.data&&("arcgis:auth:credential"===e.data.type?(s.remove(),e.data.credential.expires<Date.now()?r(new i("identity-manager:credential-request-failed","Parent application's token has expired.")):t(new L(e.data.credential))):"arcgis:auth:error"===e.data.type&&(s.remove(),"tokenExpiredError"===e.data.error.name?r(new i("identity-manager:credential-request-failed","Parent application's token has expired.")):r(i.fromJSON(e.data.error))))});d(e.options_?.signal,()=>{s.remove()})}else if(p){let o=p._oAuthCred;if(!o){const e=new T(p,q),t=new T(p,j);e.isValid()&&t.isValid()?e.expires>t.expires?(o=e,t.destroy()):(o=t,e.destroy()):o=e.isValid()?e:t,p._oAuthCred=o}if(o.isValid()){f=new L({userId:o.userId??void 0,server:c.server??void 0,token:o.token??void 0,expires:o.expires,ssl:o.ssl??void 0,_oAuthCred:o});const i=p.appId!==o.appId&&this._doPortalSignIn(e.resUrl_);i||o.refreshToken?(e._pendingDfd=o.refreshToken?this._getOAuthToken(c.server,o.refreshToken,o.appId).then(e=>(f.expires=Date.now()+1e3*e.expires_in,f.token=e.access_token,f)):Promise.resolve(f),e._pendingDfd.then(e=>i?this._exchangeToken(e.server,p.appId,e.token).then(t=>(e.token=t,e)).catch(()=>e):e).then(e=>{t(e)}).catch(e=>{const t=e.details?.httpStatus;t>0&&404!==t?(o.destroy(),s()):r(e)})):t(f)}else if(this._oAuthLocationParams&&this._hasSameServerInstance(p.portalUrl,this._oAuthLocationParams.state.portalUrl)&&(this._oAuthLocationParams.access_token||this._oAuthLocationParams.code&&this._oAuthLocationParams.state.uid===o.stateUID&&o.codeVerifier)){const s=this._oAuthLocationParams;this._oAuthLocationParams=null,e._pendingDfd=this._processOAuthResponseParams(s,p,c).then(e=>{t(e)}).catch(r)}else{const s=()=>{u?e._pendingDfd=this.oAuthSignIn(e.resUrl_,c,p,e.options_).then(t,r):(g=new i("identity-manager:not-authenticated","User is not signed in."),r(g))};this._doPortalSignIn(e.resUrl_)?e._pendingDfd=this._getPlatformSelf(c.server,p.appId).then(e=>{_(e.portalUrl,this._appOrigin,!0)?(f=new L({userId:e.username,server:c.server??void 0,expires:Date.now()+1e3*e.expires_in,token:e.token}),t(f)):s()}).catch(s):s()}}else if(u){if(this._checkProtocol(e.resUrl_,c,r,e.admin_)){let s=e.options_;e.admin_&&(s=s||{},s.isAdmin=!0),e._pendingDfd=this.signIn(e.resUrl_,c,s).then(t,r)}}else g=new i("identity-manager:not-authenticated","User is not signed in."),r(g)},o=()=>{const s=e.sinfo_,i=s.owningSystemUrl,o=e.options_;let n,a,h,l;if(o&&(n=o.token,a=o.error,h=o.prompt),l=this._findCredential(i,{token:n,resource:e.resUrl_}),!l)for(const e of this.credentials)if(this._isIdProvider(i,e.server)){l=e;break}if(l){const i=this.findCredential(e.resUrl_,l.userId);if(i)t(i);else if(b(s,this._legacyFed)){const e=l.toJSON();e.server=s.server,e.resources=null,t(new L(e))}else{(e._pendingDfd=this.generateToken(this.findServerInfo(l.server),null,{serverUrl:e.resUrl_,token:l.token,signal:e.options_.signal,ssl:l.ssl})).then(r=>{t(new L({userId:l?.userId,server:s.server??void 0,token:r.token,expires:null!=r.expires?Number(r.expires):null,ssl:!!r.ssl,isAdmin:e.admin_,validity:r.validity}))},r)}}else{this._busy=null,n&&(e.options_.token=null);(e._pendingDfd=this.getCredential(i.replace(/\/?$/,"/sharing"),{resource:e.resUrl_,owningTenant:s.owningTenant,signal:e.options_.signal,token:n,error:a,prompt:h})).then(()=>{this._enqueue(e.resUrl_,e.sinfo_,e.options_,e,e.admin_)},t=>{e.resUrl_=e.sinfo_=e.refresh_=null,e.reject(t)})}};this._errbackFunc=r;const n=e.sinfo_.owningSystemUrl,h=this._isServerRsrc(e.resUrl_),c=e.sinfo_._restInfoPms;c?c.promise.then(t=>{const r=e.sinfo_;if(r._restInfoPms){r.adminTokenServiceUrl=r._restInfoPms.adminUrl,r._restInfoPms=null,r.tokenServiceUrl=(l("authInfo.tokenServicesUrl",t)||l("authInfo.tokenServiceUrl",t)||l("tokenServiceUrl",t))??null,r.shortLivedTokenValidity=l("authInfo.shortLivedTokenValidity",t)??null,r.currentVersion=t.currentVersion,r.owningTenant=t.owningTenant;const e=r.owningSystemUrl=t.owningSystemUrl;e&&this._portals.push(e)}h&&r.owningSystemUrl?o():s()},()=>{e.sinfo_._restInfoPms=null;const t=new i("identity-manager:server-identification-failed","Unknown resource - could not find token service endpoint.");r(t)}):h&&n?o():e.sinfo_._selfReq?e.sinfo_._selfReq.selfDfd.then(t=>{const r={};let s,i,o,n;return t&&(s=t.user?.username,r.username=s,r.allSSL=t.allSSL,i=t.supportsOAuth,n=parseFloat(t.currentVersion),"multitenant"===t.portalMode&&(o=t.customBaseUrl),e.sinfo_.currentVersion=n),e.sinfo_.webTierAuth=!!s,s&&this.normalizeWebTierAuth?this.generateToken(e.sinfo_,null,{ssl:r.allSSL}).catch(()=>null).then(e=>(r.portalToken=e?.token,r.tokenExpiration=e?.expires,r)):!s&&i&&n>=4.4&&!this._findOAuthInfo(e.resUrl_)?this._generateOAuthInfo({portalUrl:e.sinfo_.server,customBaseUrl:o,owningTenant:e.sinfo_._selfReq.owningTenant}).catch(()=>null).then(()=>r):r}).catch(()=>null).then(t=>{e.sinfo_._selfReq=null,t?s(t.username,t.allSSL,t.portalToken,t.tokenExpiration):s()}):s()}_generateOAuthInfo(e){let t,r=null,i=e.portalUrl;const o=e.customBaseUrl,n=e.owningTenant,a=!this._defaultOAuthInfo&&this._createDefaultOAuthInfo&&!this._hasTestedIfAppIsOnPortal;if(a){r=this._appUrlObj.path;const e=r.search(/\/(apps|home)\//);r=e>-1?r.slice(0,e):null}return a&&r?(this._hasTestedIfAppIsOnPortal=!0,t=s(r+"/sharing/rest",{query:{f:"json"}}).then(()=>{this._defaultOAuthInfo=new x({appId:"arcgisonline",popupCallbackUrl:r+"/home/oauth-callback.html"})})):t=Promise.resolve(),t.then(()=>{if(this._defaultOAuthInfo)return i=i.replace(/^http:/i,"https:"),s(i+"/sharing/rest/oauth2/validateRedirectUri",{query:{accountId:n,client_id:this._defaultOAuthInfo.appId,redirect_uri:I(this._defaultOAuthInfo.popupCallbackUrl),f:"json"}}).then(e=>{if(e.data.valid){const t=this._defaultOAuthInfo.clone();e.data.urlKey&&o?t.portalUrl="https://"+e.data.urlKey.toLowerCase()+"."+o:t.portalUrl=i,t.popup=window!==window.top||!(_(i,this._appOrigin)||this._gwDomains.some(e=>e.regex.test(i)&&e.regex.test(this._appOrigin))),this.oAuthInfos.push(t)}})})}_doOAuthSignIn(e,t,r,s){const o=r._oAuthCred,n={portalUrl:r.portalUrl};!r.popup&&r.preserveUrlHash&&window.location.hash&&(n.hash=window.location.hash),o.stateUID&&(n.uid=o.stateUID);const h={client_id:r.appId,response_type:o.codeVerifier?"code":"token",state:JSON.stringify(n),expiration:r.expiration,locale:r.locale,redirect_uri:this._getRedirectURI(r,!!o.codeVerifier)};r.forceLogin&&(h.force_login=!0),r.forceUserId&&r.userId&&(h.prepopulatedusername=r.userId),!r.popup&&this._doPortalSignIn(e)&&(h.redirectToUserOrgUrl=!0),o.codeVerifier&&(h.code_challenge=s||o.codeVerifier,h.code_challenge_method=s?"S256":"plain");const l=r.portalUrl.replace(/^http:/i,"https:")+"/sharing/oauth2/authorize",c=l+"?"+v(h);if(r.popup){const e=window.open(c,"esriJSAPIOAuth",r.popupWindowFeatures);if(e)e.focus(),this._oAuthDfd.oAuthWin_=e,this._oAuthIntervalId=setInterval(()=>{if(e.closed){clearInterval(this._oAuthIntervalId),this._oAuthOnPopupHandle.remove();const e=this._oAuthDfd;if(e){const t=new i("identity-manager:user-aborted","ABORTED");e.reject(t)}}},500),this._oAuthOnPopupHandle=a(window,["arcgis:auth:hash","arcgis:auth:location:search"],e=>{"arcgis:auth:hash"===e.type?this.setOAuthResponseHash(e.detail):this._setOAuthResponseQueryString(e.detail)});else{const e=new i("identity-manager:popup-blocked","ABORTED");this._oAuthDfd.reject(e)}}else this._rejectOnPersistedPageShow=!0,this._oAuthRedirectFunc?this._oAuthRedirectFunc({authorizeParams:h,authorizeUrl:l,resourceUrl:e,serverInfo:t,oAuthInfo:r}):window.location.href=c}_getRedirectURI(e,t){const r=window.location.href.replace(/#.*$/,"");if(e.popup)return I(e.popupCallbackUrl);if(t){const e=p(r);return e.query&&["code","error","error_description","message_code","persist","state"].forEach(t=>{delete e.query[t]}),k(e.path,e.query)}return r}}E.prototype.declaredClass="esri.identity.IdentityManagerBase";let L=class extends n{constructor(e){super(e),this._oAuthCred=null,this.tokenRefreshBuffer=2,e?._oAuthCred&&(this._oAuthCred=e._oAuthCred)}initialize(){this.resources=this.resources||[],null==this.creationTime&&(this.creationTime=Date.now())}refreshToken(){const e=r,t=e.findServerInfo(this.server),s=t?.owningSystemUrl,i=!!s&&"server"===this.scope,o=i&&b(t,e._legacyFed),n=t.webTierAuth,a=n&&e.normalizeWebTierAuth,h=C[this.server],l=h?.[this.userId];let c,d=this.resources&&this.resources[0],u=i?e.findServerInfo(s):null,p={username:this.userId,password:l};if(n&&!a)return;i&&!u&&e.serverInfos.some(t=>(e._isIdProvider(s,t.server)&&(u=t),!!u));const _=u?e.findCredential(u.server,this.userId):null;if(!i||_){if(!o){if(i)c={serverUrl:d,token:_?.token,ssl:_?.ssl};else if(a)p=null,c={ssl:this.ssl};else{if(!l){let r;return d&&(d=e._sanitizeUrl(d),this._enqueued=1,r=e._enqueue(d,t,null,null,this.isAdmin,this),r.then(()=>{this._enqueued=0,this.refreshServerTokens()}).catch(()=>{this._enqueued=0})),r}this.isAdmin&&(c={isAdmin:!0})}return e.generateToken(i?u:t,i?null:p,c).then(e=>{this.token=e.token,this.expires=null!=e.expires?Number(e.expires):null,this.creationTime=Date.now(),this.validity=e.validity,this.emitTokenChange(),this.refreshServerTokens()}).catch(()=>{})}_?.refreshToken()}}refreshServerTokens(){if("portal"===this.scope){const e=r;e.credentials.forEach(t=>{const r=e.findServerInfo(t.server),s=r?.owningSystemUrl;t!==this&&t.userId===this.userId&&s&&"server"===t.scope&&(e._hasSameServerInstance(this.server,s)||e._isIdProvider(s,this.server))&&(b(r,e._legacyFed)?(t.token=this.token,t.expires=this.expires,t.creationTime=this.creationTime,t.validity=this.validity,t.emitTokenChange()):t.refreshToken())})}}emitTokenChange(e){clearTimeout(this._refreshTimer);const t=r,s=this.server?t.findServerInfo(this.server):null,i=s?.owningSystemUrl,o=i?t.findServerInfo(i):null;!1===e||i&&"portal"!==this.scope&&(!o?.webTierAuth||t.normalizeWebTierAuth)||null==this.expires&&null==this.validity||this._startRefreshTimer(),this.emit("token-change")}destroy(){this.userId=this.server=this.token=this.expires=this.validity=this.resources=this.creationTime=null,this._oAuthCred&&(this._oAuthCred.destroy(),this._oAuthCred=null);const e=r,t=e.credentials.indexOf(this);t>-1&&e.credentials.splice(t,1),this.emitTokenChange(),this.emit("destroy")}toJSON(){const e=h({userId:this.userId,server:this.server,token:this.token,expires:this.expires,validity:this.validity,ssl:this.ssl,isAdmin:this.isAdmin,creationTime:this.creationTime,scope:this.scope}),t=this.resources;return t&&t.length>0&&(e.resources=t.slice()),e}_startRefreshTimer(){clearTimeout(this._refreshTimer);const e=6e4*this.tokenRefreshBuffer,t=2**31-1;let r=(this.validity?this.creationTime+6e4*this.validity:this.expires)-Date.now();r<0?r=0:r>t&&(r=t),this._refreshTimer=setTimeout(this.refreshToken.bind(this),r>e?r-e:r)}};e([A()],L.prototype,"creationTime",void 0),e([A()],L.prototype,"expires",void 0),e([A()],L.prototype,"isAdmin",void 0),e([A()],L.prototype,"oAuthState",void 0),e([A()],L.prototype,"resources",void 0),e([A()],L.prototype,"scope",void 0),e([A()],L.prototype,"server",void 0),e([A()],L.prototype,"ssl",void 0),e([A()],L.prototype,"token",void 0),e([A()],L.prototype,"tokenRefreshBuffer",void 0),e([A()],L.prototype,"userId",void 0),e([A()],L.prototype,"validity",void 0),L=e([y("esri.identity.Credential")],L);export{L as Credential,E as IdentityManagerBase};