@arcgis/core 4.31.0-next.20240607 → 4.31.0-next.20240610

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 (100) hide show
  1. package/README.md +1 -1
  2. package/assets/esri/core/workers/RemoteClient.js +1 -1
  3. package/assets/esri/core/workers/chunks/06ea3bb071a83a54f1b2.js +1 -0
  4. package/assets/esri/core/workers/chunks/{fa5e171c8ce844363b6c.js → 465c718f0b9f7ba0f1ea.js} +1 -1
  5. package/assets/esri/core/workers/chunks/{342426c8a8c9f5f84811.js → 491f402da260293592ff.js} +1 -1
  6. package/assets/esri/core/workers/chunks/4e2943968517e385bd12.js +1 -0
  7. package/assets/esri/core/workers/chunks/5f3600a6d7159228731d.js +1 -0
  8. package/assets/esri/core/workers/chunks/77a360d1c9ecce4d4bed.js +1 -0
  9. package/assets/esri/core/workers/chunks/ace3297f0f314c3724da.js +1 -0
  10. package/assets/esri/core/workers/chunks/c660649465058ef82045.js +1 -0
  11. package/assets/esri/core/workers/chunks/{6a943f384fcd0af5888b.js → e66ebcfffd081f847efe.js} +1 -1
  12. package/assets/esri/core/workers/chunks/ec06875eac992c640057.js +1 -0
  13. package/assets/esri/libs/lyr3d/lyr3DMain.wasm +0 -0
  14. package/assets/esri/libs/lyr3d/lyr3DWorker.wasm +0 -0
  15. package/assets/esri/rest/knowledgeGraph/wasmInterface/arcgis-knowledge-client-core-simd.wasm +0 -0
  16. package/assets/esri/rest/knowledgeGraph/wasmInterface/arcgis-knowledge-client-core.wasm +0 -0
  17. package/assets/esri/themes/base/widgets/_BasemapLayerList.scss +8 -0
  18. package/assets/esri/themes/base/widgets/_CatalogLayerList.scss +8 -0
  19. package/assets/esri/themes/base/widgets/_LayerList.scss +8 -0
  20. package/assets/esri/themes/base/widgets/_Print.scss +12 -0
  21. package/assets/esri/themes/base/widgets/_TableList.scss +8 -0
  22. package/assets/esri/themes/dark/main.css +1 -1
  23. package/assets/esri/themes/light/main.css +1 -1
  24. package/assets/esri/themes/light/view.css +1 -1
  25. package/chunks/Terrain.glsl.js +3 -1
  26. package/chunks/lyr3DWorker.js +1 -1
  27. package/interfaces.d.ts +152 -32
  28. package/layers/CatalogLayer.js +1 -1
  29. package/layers/IntegratedMeshLayer.js +1 -1
  30. package/layers/MapImageLayer.js +1 -1
  31. package/layers/SceneLayer.js +1 -1
  32. package/layers/knowledgeGraph/KnowledgeGraphSublayer.js +1 -1
  33. package/layers/support/Sublayer.js +1 -1
  34. package/layers/support/arcgisLayers.js +1 -1
  35. package/package.json +1 -1
  36. package/smartMapping/renderers/size.js +1 -1
  37. package/support/elevationInfoUtils.js +1 -1
  38. package/support/featureFlags.js +1 -1
  39. package/support/revision.js +1 -1
  40. package/symbols/support/styleUtils.js +1 -1
  41. package/views/2d/engine/webgl/mesh/bufcut.js +1 -1
  42. package/views/3d/analysis/Viewshed/FieldOfViewManipulation.js +1 -1
  43. package/views/3d/analysis/Viewshed/ScaleOrientManipulation.js +1 -1
  44. package/views/3d/analysis/Viewshed/ViewshedSubTool.js +1 -1
  45. package/views/3d/interactive/editingTools/manipulatorUtils.js +1 -1
  46. package/views/3d/interactive/editingTools/originGeometryVisualElementUtils.js +1 -1
  47. package/views/3d/layers/BuildingSceneLayerView3D.js +1 -1
  48. package/views/3d/layers/FeatureLayerView3D.js +1 -1
  49. package/views/3d/layers/SceneLayerView3D.js +1 -1
  50. package/views/3d/layers/TiledLayerView3D.js +1 -1
  51. package/views/3d/layers/graphics/Graphics3DCore.js +1 -1
  52. package/views/3d/layers/i3s/I3SIndex.js +1 -1
  53. package/views/3d/layers/i3s/I3SOverrides.js +1 -1
  54. package/views/3d/layers/support/FeatureTileVisibility3D.js +1 -1
  55. package/views/3d/layers/support/featureTileQuery3D.js +1 -1
  56. package/views/3d/state/NearFarHeuristic.js +1 -1
  57. package/views/3d/terrain/OverlayRenderer.js +1 -1
  58. package/views/3d/webgl-engine/effects/RenderPlugin.js +1 -1
  59. package/views/3d/webgl-engine/effects/RenderPluginManager.js +1 -1
  60. package/views/3d/webgl-engine/effects/debug/RenderNodeVisualizerNode.js +1 -1
  61. package/views/3d/webgl-engine/lib/PathGeometryData.js +1 -1
  62. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  63. package/views/3d/webgl-engine/lib/SortedRenderGeometryRenderer.js +1 -1
  64. package/views/3d/webgl-engine/lib/depthRangeUtils.js +1 -1
  65. package/views/3d/webgl-engine/materials/renderers/MergedRenderer.js +1 -1
  66. package/webdoc/support/webdocSaveUtils.js +1 -1
  67. package/webscene/support/schemaValidator.js +1 -1
  68. package/widgets/BasemapLayerList/css.js +1 -1
  69. package/widgets/BasemapLayerList.js +1 -1
  70. package/widgets/CatalogLayerList/css.js +1 -1
  71. package/widgets/CatalogLayerList.js +1 -1
  72. package/widgets/Editor/UpdateRecordWorkflow.js +1 -1
  73. package/widgets/Feature/support/featureUtils.js +1 -1
  74. package/widgets/FeatureTable/FeatureTableViewModel.js +1 -1
  75. package/widgets/FeatureTable/FieldColumn.js +1 -1
  76. package/widgets/FeatureTable/Grid/Column.js +1 -1
  77. package/widgets/FeatureTable/Grid/GridViewModel.js +1 -1
  78. package/widgets/FeatureTable/RelationshipColumn.js +1 -1
  79. package/widgets/FeatureTable/support/FeatureStore.js +1 -1
  80. package/widgets/FeatureTable/support/tableUtils.js +1 -1
  81. package/widgets/FeatureTable.js +1 -1
  82. package/widgets/Features/FeaturesViewModel.js +1 -1
  83. package/widgets/Fullscreen.js +1 -1
  84. package/widgets/LayerList/css.js +1 -1
  85. package/widgets/LayerList.js +1 -1
  86. package/widgets/Locate.js +1 -1
  87. package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
  88. package/widgets/PanoramicViewer/PanoramicViewerViewModel.js +1 -1
  89. package/widgets/Print/PrintViewModel.js +1 -1
  90. package/widgets/Print.js +1 -1
  91. package/widgets/TableList/css.js +1 -1
  92. package/widgets/TableList.js +1 -1
  93. package/widgets/Track.js +1 -1
  94. package/assets/esri/core/workers/chunks/230429bc1be19dd4944b.js +0 -1
  95. package/assets/esri/core/workers/chunks/441f3eaef3b703dd1026.js +0 -1
  96. package/assets/esri/core/workers/chunks/4d7578131569e65caedc.js +0 -1
  97. package/assets/esri/core/workers/chunks/4faf7055457c04dc9fc1.js +0 -1
  98. package/assets/esri/core/workers/chunks/ba988cd3a49987a0fb83.js +0 -1
  99. package/assets/esri/core/workers/chunks/c70683b7183458b338f8.js +0 -1
  100. package/assets/esri/core/workers/chunks/d03ada1212b13e76bff4.js +0 -1
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.31/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../core/Error.js";import{MultiOriginJSONSupport as t}from"../../core/MultiOriginJSONSupport.js";import{whenOnce as o}from"../../core/reactiveUtils.js";import{hasSameCanonicalPortal as a,urlToObject as r}from"../../core/urlUtils.js";import{updateOrigins as i}from"../../core/accessorSupport/originUtils.js";import n from"../../geometry/SpatialReference.js";import{equals as s}from"../../geometry/support/spatialReferenceUtils.js";import{webMercatorToGeographic as l}from"../../geometry/support/webMercatorUtils.js";import{isServerOrServicesAGOLUrl as p}from"../../layers/support/arcgisLayerUrl.js";import{isLayerWithFeatureLayerSource as c,isFeatureCollectionLayer as m}from"../../layers/support/layerUtils.js";import u from"../../portal/Portal.js";import f from"../../portal/PortalItem.js";import{createForItemWrite as d}from"../../portal/support/jsonContext.js";import{typeKeyword as y,removeTypeKeyword as w,addTypeKeyword as g,hasTypeKeyword as h}from"../../portal/support/portalItemUtils.js";import{project as _}from"../../rest/geometryService/project.js";import v from"../../rest/support/ProjectParameters.js";import{hasDeveloperBasemapLayer as b,findSpatialReference as j,isDeveloperBasemapLayer as R}from"../../support/basemapUtils.js";import{saveResources as I}from"./resourceUtils.js";import{validateSaveAPIKey as P}from"./saveAPIKeyUtils.js";import{beforeSave as W,evaluateWriteErrors as S}from"./saveUtils.js";const A=["NatGeo_World_Map","Ocean_Basemap","USA_Topo_Maps","World_Imagery","World_Street_Map","World_Terrain_Base","World_Topo_Map","World_Hillshade","Canvas/World_Light_Gray_Base","Canvas/World_Light_Gray_Reference","Canvas/World_Dark_Gray_Base","Canvas/World_Dark_Gray_Reference","Ocean/World_Ocean_Base","Ocean/World_Ocean_Reference","Reference/World_Boundaries_and_Places","Reference/World_Reference_Overlay","Reference/World_Transportation"].map((e=>e.toLowerCase()));async function U(e,t,a){a??={},C(e,t),await o((()=>!t.updatingFromView)),await t.load(),await V(t),await W(t),await E(e,t);const r=t.portalItem,{json:i,jsonContext:n}=await O(t,r);return S(n,{errorName:`${e.name}:save`},a),await G(t,r),await we(e,t,r,i,n),await Promise.all([t.updateItemThumbnail(),I(t.resourceReferences,n)]),r}async function O(e,t){const o=d(t,"web-map",!0),a=e.write({},o);return await Promise.all(o.resources.pendingOperations),{json:a,jsonContext:o}}async function T(e,t,a,r){r??={};const i=L(e,a);await o((()=>!t.updatingFromView)),await t.load(),D(e,t),await V(t),await W(t),await E(e,t);const{json:n,jsonContext:s}=await O(t,i);S(s,{errorName:`${e.name}:save`},r),await Z(t,i);const l=t.getThumbnailState();return await ge(e,t,i,n,s,r)&&(t.resourceReferences.portalItem=i),t.restoreThumbnailFromState(l),await Promise.all([t.updateItemThumbnail(),I(t.resourceReferences,s)]),i}function C(t,o){if(!o.portalItem)throw new e(`${t.name}:portal-item-not-set`,"Portal item to save to has not been set on the WebMap");P(o.portalItem),M(t,o.portalItem)}function M(t,o){if(o.type!==t.itemType)throw new e(`${t.name}:portal-item-wrong-type`,`Portal item needs to have type "${t.itemType}"`)}function D(t,o){const a=o.allLayers.filter((e=>"unsupported"===e.type&&"KnowledgeGraphLayer"===e.resourceInfo?.layerType));if(a.length)throw new e(`${t.name}:save-as-invalid-configuration`,`Failed to save a copy of ${t.name} to prevent persisting invalid configuration. See 'details.layers'`,{layers:a.toArray()})}async function E(t,a){if(!a.basemap?.baseLayers.length)throw new e(`${t.name}:save`,"Map does not have a valid basemap with a base layer.");let r=null;if(await o((()=>{const e=j(a.initialViewProperties,a.basemap);return r=e.spatialReference,!e.updating})),!s(r,a.initialViewProperties.spatialReference))throw new e(`${t.name}:save`,"The spatial reference of the basemap is not compatible with the one from the map.",{expected:a.initialViewProperties.spatialReference,actual:r})}function L(e,t){let o=f.from(t);return o.id&&(o=o.clone(),o.id=null),o.type||(o.type=e.itemType),o.portal||(o.portal=u.getDefault()),P(o),M(e,o),o}function V(e){const t=[];return e.basemap&&t.push(e.basemap.load()),e.ground&&t.push(e.ground.load()),Promise.allSettled(t).then((()=>{}))}async function G(e,t){t.extent=await me(e.portalItem,e.initialViewProperties.viewpoint.targetGeometry),await ee(e,t)}const $=y.JSAPI,x="CollectorDisabled",k="Collector",B="Data Editing",N="OfflineDisabled",K="Offline",F="Workforce Project",H="Workforce Worker",J="Workforce Dispatcher",q="Offline Map Areas",z="FieldMapsDisabled",Q=y.DEVELOPER_BASEMAP,X="UtilityNetwork",Y="IPS";async function Z(e,t){w(t,x),w(t,z),w(t,y.METADATA),w(t,N),w(t,q),w(t,J),w(t,F),w(t,H),await G(e,t)}async function ee(e,t){g(t,$),await te(e),ie(e,t),ne(e,t),se(e,t),le(e,t),pe(e,t),ce(e,t),t.typeKeywords&&(t.typeKeywords=t.typeKeywords.filter(((e,t,o)=>o.indexOf(e)===t)))}function te(e){const t=oe(e).map((e=>e.load())).toArray();return Promise.allSettled(t).then((()=>{}))}function oe(e){return e.allLayers.concat(e.allTables)}function ae(e){return oe(e).some((e=>e.loaded&&c(e)&&e.capabilities.operations.supportsEditing&&e.editingEnabled&&("subtype-group"!==e.type||e.sublayers.some((e=>e.editingEnabled)))))}function re(e){return oe(e).filter((e=>"group"!==e.type)).every((t=>t.loaded&&de(e,t)))}function ie(e,t){h(t,x)||h(t,F)||h(t,H)||h(t,J)||!ae(e)?w(t,k):g(t,k)}function ne(e,t){ae(e)?g(t,B):w(t,B)}function se(e,t){!h(t,N)&&re(e)?g(t,K):w(t,K)}function le(e,t){b(e.basemap)?g(t,Q):w(t,Q)}function pe(e,t){e.utilityNetworks?.length?g(t,X):w(t,X)}function ce(e,t){e.ipsInfo?g(t,Y):w(t,Y)}async function me(e,t){const o=t.clone().normalize();let a;if(o.length>1)for(const r of o)a?r.width>a.width&&(a=r):a=r;else a=o[0];return ue(e,a)}async function ue(e,t){const o=t.spatialReference;if(o.isWGS84)return t.clone();if(o.isWebMercator)return l(t);const{getGeometryServiceURL:a}=await import("../../portal/support/geometryServiceUtils.js"),r=await a(e),i=new v({geometries:[t],outSpatialReference:n.WGS84});return(await _(r,i))[0]}function fe(e){return m(e)||"map-notes"===e.type||"route"===e.type}function de(e,t){return c(t)&&t.capabilities.operations.supportsSync||fe(t)&&!t.portalItem||("tile"===t.type||"vector-tile"===t.type)&&(t.capabilities.operations.supportsExportTiles||ye(t)||R(t))&&t.spatialReference.equals(e.initialViewProperties.spatialReference)}function ye(e){return"tile"===e.type&&(p(e.url)&&A.some((t=>e.url?.toLowerCase().includes("/"+t+"/"))))}async function we(e,t,o,a,r){await o.update({data:a}),ve(e,t,o,a,r)}async function ge(t,o,a,r,i,n){const s=o.portalItem,l={item:s,authenticated:!(!s?.id||!s.portal.user)},p=a.portal;await p.signIn();const{copyAllowed:c,itemReloaded:m}=await he(l,p);if(l.authenticated||=m,!c)throw new e(`${t.name}:save-as-copy-not-allowed`,"Owner of this map does not allow others to save a copy");const u=await _e(a,l,r,n);return o.portalItem=a,ve(t,o,a,r,i),u}async function he(e,t){const{item:o,authenticated:a}=e;return o?.id&&o.typeKeywords?.includes("useOnly")?o.portal.portalHostname!==t.portalHostname?{copyAllowed:!1,itemReloaded:!1}:(a||await o.reload(),{copyAllowed:"admin"===o.itemControl||"update"===o.itemControl,itemReloaded:!0}):{copyAllowed:!0,itemReloaded:!1}}async function _e(e,t,o,r){const i=e.portal,{item:n}=t,{folder:s,copyAllResources:l}=r;let p=!1;if(l&&n?.id&&a(n.portal.url,i.url)&&parseInt(n.portal.currentVersion,10)>=2023){const{total:e}=await n.fetchResources();p=!!e}if(p){const t=await n.copy({copyResources:"all",folder:s});e.id=t.id,e.portal=t.portal;const a=e.toJSON();await e.load(),e.read(a),await e.update({data:o})}else await(i.user?.addItem({item:e,folder:s,data:o}));return p}function ve(e,o,a,n,s){t.prototype.read.call(o,{version:n.version,authoringApp:n.authoringApp,authoringAppVersion:n.authoringAppVersion},{origin:e.origin,ignoreDefaults:!0,url:a.itemUrl?r(a.itemUrl):void 0}),i(s),o.resourceInfo=n}export{O as createJSON,U as save,T as saveAs};
5
+ import e from"../../core/Error.js";import{MultiOriginJSONSupport as t}from"../../core/MultiOriginJSONSupport.js";import{whenOnce as o}from"../../core/reactiveUtils.js";import{hasSameCanonicalPortal as r,urlToObject as a}from"../../core/urlUtils.js";import{updateOrigins as i}from"../../core/accessorSupport/originUtils.js";import n from"../../geometry/SpatialReference.js";import{equals as s}from"../../geometry/support/spatialReferenceUtils.js";import{webMercatorToGeographic as l}from"../../geometry/support/webMercatorUtils.js";import{isServerOrServicesAGOLUrl as p}from"../../layers/support/arcgisLayerUrl.js";import{isLayerWithFeatureLayerSource as c,isFeatureCollectionLayer as m}from"../../layers/support/layerUtils.js";import u from"../../portal/Portal.js";import f from"../../portal/PortalItem.js";import{createForItemWrite as d}from"../../portal/support/jsonContext.js";import{typeKeyword as w,removeTypeKeyword as y,addTypeKeyword as h,hasTypeKeyword as g}from"../../portal/support/portalItemUtils.js";import{project as _}from"../../rest/geometryService/project.js";import b from"../../rest/support/ProjectParameters.js";import{hasDeveloperBasemapLayer as j,findSpatialReference as R,isDeveloperBasemapLayer as v}from"../../support/basemapUtils.js";import{saveResources as P}from"./resourceUtils.js";import{validateSaveAPIKey as W}from"./saveAPIKeyUtils.js";import{beforeSave as I,evaluateWriteErrors as S}from"./saveUtils.js";const A=["NatGeo_World_Map","Ocean_Basemap","USA_Topo_Maps","World_Imagery","World_Street_Map","World_Terrain_Base","World_Topo_Map","World_Hillshade","Canvas/World_Light_Gray_Base","Canvas/World_Light_Gray_Reference","Canvas/World_Dark_Gray_Base","Canvas/World_Dark_Gray_Reference","Ocean/World_Ocean_Base","Ocean/World_Ocean_Reference","Reference/World_Boundaries_and_Places","Reference/World_Reference_Overlay","Reference/World_Transportation"].map((e=>e.toLowerCase()));async function U(e,t,r){r??={},C(e,t),await o((()=>!t.updatingFromView)),await t.load(),await V(t),await I(t),await D(e,t);const a=t.portalItem,{json:i,jsonContext:n}=await O(t,a);return S(n,{errorName:`${e.name}:save`},r),await x(t,a),await we(e,t,a,i,n),await Promise.all([t.updateItemThumbnail(),P(t.resourceReferences,n)]),a}async function O(e,t){const o=d(t,"web-map",!0),r=e.write({},o);return await Promise.all(o.resources.pendingOperations),{json:r,jsonContext:o}}async function T(e,t,r,a){a??={};const i=E(e,r);await o((()=>!t.updatingFromView)),await t.load(),await V(t),await I(t),await D(e,t);const{json:n,jsonContext:s}=await O(t,i);S(s,{errorName:`${e.name}:save`},a),await Y(t,i);const l=t.getThumbnailState();return await ye(e,t,i,n,s,a)&&(t.resourceReferences.portalItem=i),t.restoreThumbnailFromState(l),await Promise.all([t.updateItemThumbnail(),P(t.resourceReferences,s)]),i}function C(t,o){if(!o.portalItem)throw new e(`${t.name}:portal-item-not-set`,"Portal item to save to has not been set on the WebMap");W(o.portalItem),M(t,o.portalItem)}function M(t,o){if(o.type!==t.itemType)throw new e(`${t.name}:portal-item-wrong-type`,`Portal item needs to have type "${t.itemType}"`)}async function D(t,r){if(!r.basemap?.baseLayers.length)throw new e(`${t.name}:save`,"Map does not have a valid basemap with a base layer.");let a=null;if(await o((()=>{const e=R(r.initialViewProperties,r.basemap);return a=e.spatialReference,!e.updating})),!s(a,r.initialViewProperties.spatialReference))throw new e(`${t.name}:save`,"The spatial reference of the basemap is not compatible with the one from the map.",{expected:r.initialViewProperties.spatialReference,actual:a})}function E(e,t){let o=f.from(t);return o.id&&(o=o.clone(),o.id=null),o.type||(o.type=e.itemType),o.portal||(o.portal=u.getDefault()),W(o),M(e,o),o}function V(e){const t=[];return e.basemap&&t.push(e.basemap.load()),e.ground&&t.push(e.ground.load()),Promise.allSettled(t).then((()=>{}))}async function x(e,t){t.extent=await ce(e.portalItem,e.initialViewProperties.viewpoint.targetGeometry),await Z(e,t)}const G=w.JSAPI,L="CollectorDisabled",k="Collector",$="Data Editing",B="OfflineDisabled",N="Offline",K="Workforce Project",F="Workforce Worker",H="Workforce Dispatcher",J="Offline Map Areas",q="FieldMapsDisabled",z=w.DEVELOPER_BASEMAP,Q="UtilityNetwork",X="IPS";async function Y(e,t){y(t,L),y(t,q),y(t,w.METADATA),y(t,B),y(t,J),y(t,H),y(t,K),y(t,F),await x(e,t)}async function Z(e,t){h(t,G),await ee(e),ae(e,t),ie(e,t),ne(e,t),se(e,t),le(e,t),pe(e,t),t.typeKeywords&&(t.typeKeywords=t.typeKeywords.filter(((e,t,o)=>o.indexOf(e)===t)))}function ee(e){const t=te(e).map((e=>e.load())).toArray();return Promise.allSettled(t).then((()=>{}))}function te(e){return e.allLayers.concat(e.allTables)}function oe(e){return te(e).some((e=>e.loaded&&c(e)&&e.capabilities.operations.supportsEditing&&e.editingEnabled&&("subtype-group"!==e.type||e.sublayers.some((e=>e.editingEnabled)))))}function re(e){return te(e).filter((e=>"group"!==e.type)).every((t=>t.loaded&&fe(e,t)))}function ae(e,t){g(t,L)||g(t,K)||g(t,F)||g(t,H)||!oe(e)?y(t,k):h(t,k)}function ie(e,t){oe(e)?h(t,$):y(t,$)}function ne(e,t){!g(t,B)&&re(e)?h(t,N):y(t,N)}function se(e,t){j(e.basemap)?h(t,z):y(t,z)}function le(e,t){e.utilityNetworks?.length?h(t,Q):y(t,Q)}function pe(e,t){e.ipsInfo?h(t,X):y(t,X)}async function ce(e,t){const o=t.clone().normalize();let r;if(o.length>1)for(const a of o)r?a.width>r.width&&(r=a):r=a;else r=o[0];return me(e,r)}async function me(e,t){const o=t.spatialReference;if(o.isWGS84)return t.clone();if(o.isWebMercator)return l(t);const{getGeometryServiceURL:r}=await import("../../portal/support/geometryServiceUtils.js"),a=await r(e),i=new b({geometries:[t],outSpatialReference:n.WGS84});return(await _(a,i))[0]}function ue(e){return m(e)||"map-notes"===e.type||"route"===e.type}function fe(e,t){return c(t)&&t.capabilities.operations.supportsSync||ue(t)&&!t.portalItem||("tile"===t.type||"vector-tile"===t.type)&&(t.capabilities.operations.supportsExportTiles||de(t)||v(t))&&t.spatialReference.equals(e.initialViewProperties.spatialReference)}function de(e){return"tile"===e.type&&(p(e.url)&&A.some((t=>e.url?.toLowerCase().includes("/"+t+"/"))))}async function we(e,t,o,r,a){await o.update({data:r}),_e(e,t,o,r,a)}async function ye(t,o,r,a,i,n){const s=o.portalItem,l={item:s,authenticated:!(!s?.id||!s.portal.user)},p=r.portal;await p.signIn();const{copyAllowed:c,itemReloaded:m}=await he(l,p);if(l.authenticated||=m,!c)throw new e(`${t.name}:save-as-copy-not-allowed`,"Owner of this map does not allow others to save a copy");const u=await ge(r,l,a,n);return o.portalItem=r,_e(t,o,r,a,i),u}async function he(e,t){const{item:o,authenticated:r}=e;return o?.id&&o.typeKeywords?.includes("useOnly")?o.portal.portalHostname!==t.portalHostname?{copyAllowed:!1,itemReloaded:!1}:(r||await o.reload(),{copyAllowed:"admin"===o.itemControl||"update"===o.itemControl,itemReloaded:!0}):{copyAllowed:!0,itemReloaded:!1}}async function ge(e,t,o,a){const i=e.portal,{item:n}=t,{folder:s,copyAllResources:l}=a;let p=!1;if(l&&n?.id&&r(n.portal.url,i.url)&&parseInt(n.portal.currentVersion,10)>=2023){const{total:e}=await n.fetchResources();p=!!e}if(p){const t=await n.copy({copyResources:"all",folder:s});e.id=t.id,e.portal=t.portal;const r=e.toJSON();await e.load(),e.read(r),await e.update({data:o})}else await(i.user?.addItem({item:e,folder:s,data:o}));return p}function _e(e,o,r,n,s){t.prototype.read.call(o,{version:n.version,authoringApp:n.authoringApp,authoringAppVersion:n.authoringAppVersion},{origin:e.origin,ignoreDefaults:!0,url:r.itemUrl?a(r.itemUrl):void 0}),i(s),o.resourceInfo=n}export{O as createJSON,U as save,T as saveAs};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.31/esri/copyright.txt for details.
4
4
  */
5
- import{A as n}from"../../chunks/ajv.bundle.js";import{json as o}from"../../portal/schemas/webScene.js";import{convertAjvErrors as e}from"../../support/validationUtilsAjv.js";const t=new n({allErrors:!0,extendRefs:!0});function i(n,o){return r(o),t.validate(a(o),n)?[]:e(t.errors??[])}function s(n){const e=n?o.definitions[a(n)]:void 0;if(!e)throw new Error(`invalid schema name to validate against '${n}'`);const t={};for(const o in e)t[o]=e[o];return t.definitions=o.definitions,t}function r(n){const o=a(n);if(!t.getSchema(o)){const e=s(n);t.addSchema(e,o)}}function a(n){return n?`${n}_schema.json`:"webScene_schema.json"}t.addSchema(o,a());export{i as validate};
5
+ import{A as n}from"../../chunks/ajv.bundle.js";import{json as t}from"../../portal/schemas/webScene.js";import{convertAjvErrors as e}from"../../support/validationUtilsAjv.js";let o=null;function i(n,t){s(t);const o=a();return o.validate(c(t),n)?[]:e(o.errors??[])}function r(n){const e=n?t.definitions[c(n)]:void 0;if(!e)throw new Error(`invalid schema name to validate against '${n}'`);const o={};for(const t in e)o[t]=e[t];return o.definitions=t.definitions,o}function s(n){const t=c(n),e=a();if(!e.getSchema(t)){const o=r(n);e.addSchema(o,t)}}function a(){return o||(o=new n({allErrors:!0,extendRefs:!0}),o.addSchema(t,c()),o)}function c(n){return n?`${n}_schema.json`:"webScene_schema.json"}export{i as validate};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.31/esri/copyright.txt for details.
4
4
  */
5
- const t="esri-basemap-layer-list",i=`${t}__item`,e={base:t,filterNoResults:`${t}__filter-no-results`,item:i,itemActive:`${i}--active`,itemContent:`${i}-content`,itemContentBottom:`${i}-content-bottom`,itemMessage:`${i}-message`,itemInvisible:`${i}--invisible`,itemActionIcon:`${i}-action-icon`,itemActionImage:`${i}-action-image`,itemTemporaryIcon:`${i}-temporary-icon`,itemCatalogIcon:`${i}-catalog-icon`,statusIndicator:`${t}__status-indicator`,publishing:`${t}__publishing`,updating:`${t}__updating`,editing:`${t}__editing`,connectionStatus:`${t}__connection-status`,connectionStatusConnected:`${t}__connection-status--connected`,visibleToggle:`${t}__visible-toggle`,visibleIcon:`${t}__visible-icon`,section:`${t}__section`};export{e as css};
5
+ const t="esri-basemap-layer-list",i=`${t}__item`,e={base:t,actionMenu:`${t}__action-menu`,actionGroup:`${t}__action-group`,filterNoResults:`${t}__filter-no-results`,item:i,itemActive:`${i}--active`,itemContent:`${i}-content`,itemContentBottom:`${i}-content-bottom`,itemMessage:`${i}-message`,itemInvisible:`${i}--invisible`,itemActionIcon:`${i}-action-icon`,itemActionImage:`${i}-action-image`,itemTemporaryIcon:`${i}-temporary-icon`,itemCatalogIcon:`${i}-catalog-icon`,statusIndicator:`${t}__status-indicator`,publishing:`${t}__publishing`,updating:`${t}__updating`,editing:`${t}__editing`,connectionStatus:`${t}__connection-status`,connectionStatusConnected:`${t}__connection-status--connected`,visibleToggle:`${t}__visible-toggle`,visibleIcon:`${t}__visible-icon`,section:`${t}__section`};export{e as css};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.31/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../chunks/tslib.es6.js";import t from"../core/Collection.js";import{deprecatedProperty as i}from"../core/deprecate.js";import{IdentifiableMixin as s}from"../core/Identifiable.js";import o from"../core/Logger.js";import{property as l}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/RandomLCG.js";import{subclass as n}from"../core/accessorSupport/decorators/subclass.js";import{getActionIcon as a,getActionStyles as r}from"../support/actions/actionUtils.js";import c from"./Widget.js";import d from"./BasemapLayerList/BasemapLayerListViewModel.js";import m from"./BasemapLayerList/BasemapLayerListVisibleElements.js";import{css as p}from"./BasemapLayerList/css.js";import u from"./LayerList/ListItem.js";import{minFilterItems as h,getItem as g,getLayerType as f,getStatusIcon as b,sortLayersToIds as y,sortChildLayersToIds as _,listItemHasChildren as v,areChildrenHidden as I,canSortSublayers as L,getVisibilityIcon as w}from"./LayerList/support/layerListUtils.js";import{loadCalciteComponents as E}from"./support/componentsUtils.js";import{globalCss as F}from"./support/globalCss.js";import{incrementHeadingLevel as C}from"./support/Heading.js";import"./support/widgetUtils.js";import{messageBundle as T}from"./support/decorators/messageBundle.js";import{vmEvent as M}from"./support/decorators/vmEvent.js";import{tsx as A}from"./support/jsxFactory.js";const k=t.ofType(u),S=".*\\S+.*";let x=class extends(s(c)){constructor(e,t){super(e,t),this._activeItem=null,this._tooltipReferenceMap=new Map,this._editTitleInput=null,this._focusRootFlowItem=!1,this._focusPanelFlowItem=!1,this._focusEditingFlowItem=!1,this._focusCatalogFlowItem=!1,this._catalogFlowItem=null,this._lastDragDetail=null,this._selectedDragItemLayerUid=null,this._rootGroupUid=`basemap-${this.uid}`,this.catalogLayerList=null,this.catalogOptions=null,this.collapsed=!1,this.dragEnabled=!1,this.editingTitle=!1,this.filterPlaceholder="",this.baseFilterText="",this.referenceFilterText="",this.listItemCanGiveFunction=null,this.listItemCanReceiveFunction=null,this.headingLevel=2,this.messages=null,this.messagesCommon=null,this.minFilterItems=h,this.selectedItems=new k,this.selectionMode="none",this.viewModel=new d,this.visibilityAppearance="default",this.visibleElements=new m,this._canMove=({dragEl:e,fromEl:t,toEl:i},s)=>{const o="pull"===s?this.listItemCanGiveFunction:this.listItemCanReceiveFunction,l=g(e);if(!l?.sortable)return!1;const n=g(t),a=f(t),r=g(i),c=f(i),d=!!a&&!!c&&a===c,m={selected:l,from:n,to:r},p=t.group,u=i.group,h=n?.layer?.type??"",b=r?.layer?.type??"",y=new Set(["map-image","catalog","knowledge-graph"]),_="sublayer";return p&&u&&"function"==typeof o?o.call(null,m):d&&!y.has(h)&&!y.has(b)&&l?.layer?.type!==_},this._clearActiveItem=()=>{this._activeItem=null},this._setActiveItem=e=>{if("default"!==this.visibilityAppearance)return;const t=Array.from(e.composedPath()).find((e=>e.classList?.contains(p.item)));this._activeItem=g(t)},this._onCalciteListOrderChange=e=>{const{_lastDragDetail:t}=this,{toEl:i,fromEl:s,dragEl:o,newIndex:l}=e;if(!s||!i||t?.newIndex===l&&t?.dragEl===o&&t?.toEl===i&&t?.fromEl===s)return;this._lastDragDetail=e;const n=s,a=i;if(n!==a)this._moveLayerFromChildList({toEl:a,fromEl:n,dragEl:o,newIndex:l});else{const e=Array.from(s.children).filter((e=>e?.matches("calcite-list-item"))).map((e=>e.value));this._sortLayers(n,e)}}}normalizeCtorArgs(e){return null!=e?.editingEnabled&&null!=e.visibleElements?{...e,visibleElements:new m({...e.visibleElements,editTitleButton:e.editingEnabled})}:e}loadDependencies(){return E({action:()=>import("@esri/calcite-components/dist/components/calcite-action.js"),"action-group":()=>import("@esri/calcite-components/dist/components/calcite-action-group.js"),"action-menu":()=>import("@esri/calcite-components/dist/components/calcite-action-menu.js"),block:()=>import("@esri/calcite-components/dist/components/calcite-block.js"),label:()=>import("@esri/calcite-components/dist/components/calcite-label.js"),input:()=>import("@esri/calcite-components/dist/components/calcite-input.js"),button:()=>import("@esri/calcite-components/dist/components/calcite-button.js"),flow:()=>import("@esri/calcite-components/dist/components/calcite-flow.js"),"flow-item":()=>import("@esri/calcite-components/dist/components/calcite-flow-item.js"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon.js"),list:()=>import("@esri/calcite-components/dist/components/calcite-list.js"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item.js"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice.js"),tooltip:()=>import("@esri/calcite-components/dist/components/calcite-tooltip.js")})}destroy(){this._tooltipReferenceMap.clear()}get _baseFilterEnabled(){return this.viewModel.totalBaseItems>=this.minFilterItems&&this.visibleElements.filter}get _referenceFilterEnabled(){return this.viewModel.totalReferenceItems>=this.minFilterItems&&this.visibleElements.filter}get basemapTitle(){return this.viewModel.basemapTitle}set basemapTitle(e){this.viewModel.basemapTitle=e}get baseListItemCreatedFunction(){return this.viewModel.baseListItemCreatedFunction}set baseListItemCreatedFunction(e){this.viewModel.baseListItemCreatedFunction=e}get editingEnabled(){return i(o.getLogger(this),"editingEnabled",{replacement:"selectionMode, dragEnabled, visibleElements.editTitleButton",version:"4.29",warnOnce:!0}),"none"!==this.selectionMode&&this.dragEnabled&&this.visibleElements.editTitleButton}set editingEnabled(e){i(o.getLogger(this),"editingEnabled",{replacement:"selectionMode, dragEnabled, visibleElements.editTitleButton",version:"4.29",warnOnce:!0}),this.dragEnabled=e,this.visibleElements.editTitleButton=e,this.selectionMode=e?this.multipleSelectionEnabled?"multiple":"single":"none"}get icon(){return"layers"}set icon(e){this._overrideIfSome("icon",e)}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get multipleSelectionEnabled(){return i(o.getLogger(this),"multipleSelectionEnabled",{replacement:"selectionMode",version:"4.29",warnOnce:!0}),"multiple"===this.selectionMode}set multipleSelectionEnabled(e){i(o.getLogger(this),"multipleSelectionEnabled",{replacement:"selectionMode",version:"4.29",warnOnce:!0}),this.selectionMode=e?"multiple":this.editingEnabled?"single":"none"}get referenceListItemCreatedFunction(){return this.viewModel.referenceListItemCreatedFunction}set referenceListItemCreatedFunction(e){this.viewModel.referenceListItemCreatedFunction=e}get baseItems(){return this.viewModel.baseItems}get referenceItems(){return this.viewModel.referenceItems}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}triggerAction(e,t){return this.viewModel.triggerAction(e,t)}render(){const{state:e}=this.viewModel,t={[F.hidden]:"loading"===e,[F.disabled]:"disabled"===e};return A("div",{class:this.classes(p.base,F.widget,F.panel,t)},this._renderItems())}_renderItemTooltip(e){return e?A("calcite-tooltip",{key:`tooltip-${e.layer.uid}`,referenceElement:this._tooltipReferenceMap.get(e.layer.uid)},this.messages.layerIncompatibleTooltip):null}_renderItemTooltipNodes(e){return e.incompatible?this._renderItemTooltip(e):e.children?.filter((e=>!e.hidden)).toArray().map((e=>this._renderItemTooltipNodes(e)))}_renderItemTooltips(e){return e?.toArray().map((e=>this._renderItemTooltipNodes(e)))}async _createCatalog(e){const{default:t}=await import("./CatalogLayerList.js"),{headingLevel:i,catalogOptions:s,view:o,filterPlaceholder:l,baseListItemCreatedFunction:n,referenceListItemCreatedFunction:a,minFilterItems:r,selectionMode:c,visibilityAppearance:d}=this,m=this._catalogFlowItem?.layer;this._set("catalogLayerList",new t({headingLevel:i,view:o,filterPlaceholder:l,minFilterItems:r,selectionMode:c,listItemCreatedFunction:"base"===e?n:a,visibilityAppearance:d,...s,catalogLayer:m}))}_destroyCatalog(){this._catalogFlowItem=null,this._focusRootFlowItem=!0,this.catalogLayerList?.destroy(),this._set("catalogLayerList",null)}_renderCatalogFlowItem(){const{_catalogFlowItem:e,messages:t}=this;if(!e)return null;const i=this._getLayerTitle(e);return A("calcite-flow-item",{afterCreate:this._focusCatalogFlowItemNode,afterUpdate:this._focusCatalogFlowItemNode,bind:this,description:i,heading:t.catalogLayers,headingLevel:this.headingLevel,key:`flow-catalog-${e.uid}`,onCalciteFlowItemBack:e=>{e.preventDefault(),this._destroyCatalog()}},this.catalogLayerList?.render())}_focusCatalogFlowItemNode(e){this._focusCatalogFlowItem&&(this._focusCatalogFlowItem=!1,requestAnimationFrame((()=>e?.setFocus())))}_renderPanelFlowItems(e){return e?e.flatten((e=>e.children)).filter((({hidden:e,panel:t})=>!e&&t?.open&&!t.disabled&&t.flowEnabled)).toArray().map((({title:e,panel:t})=>{const i=()=>this._handlePanelFlowItemBack(t);return A("calcite-flow-item",{afterCreate:this._focusPanelFlowItemNode,afterUpdate:this._focusPanelFlowItemNode,bind:this,description:e,heading:t.title,headingLevel:this.headingLevel,key:`flow-panel-${t.uid}`,onCalciteFlowItemBack:e=>{e.preventDefault(),i()}},t.render(),A("calcite-button",{appearance:"transparent",onclick:i,slot:"footer-actions",width:"full"},this.messagesCommon.back))})):[]}_handlePanelFlowItemBack(e){e.open=!1,this._focusRootFlowItem=!0}_focusEditingFlowItemNode(e){this._focusEditingFlowItem&&(this._focusEditingFlowItem=!1,requestAnimationFrame((()=>e?.setFocus())))}_focusRootFlowItemNode(e){this._focusRootFlowItem&&(this._focusRootFlowItem=!1,requestAnimationFrame((()=>e?.setFocus())))}_focusPanelFlowItemNode(e){this._focusPanelFlowItem&&(this._focusPanelFlowItem=!1,requestAnimationFrame((()=>e?.setFocus())))}_renderItemMessage(e){return e.error?A("div",{class:p.itemMessage,key:"esri-layer-list__error",slot:"content-bottom"},A("calcite-notice",{icon:"exclamation-mark-triangle",kind:"warning",open:!0,scale:"s",width:"full"},A("div",{slot:"message"},this.messages.layerError))):e.incompatible?A("div",{class:p.itemMessage,key:"esri-layer-list__incompatible",slot:"content-bottom"},A("calcite-notice",{afterCreate:t=>this._setTooltipReference(t,e),afterRemoved:()=>this._removeTooltipReference(e),icon:"exclamation-mark-triangle",kind:"warning",open:!0,scale:"s",tabIndex:0,width:"full"},A("div",{slot:"message"},this.messages.layerIncompatible))):null}_getLayerTitle(e){return e.title||this.messages.untitledLayer}_renderItem(e,t,i,s,o){const{_activeItem:l,_selectedDragItemLayerUid:n,selectionMode:a,selectedItems:r,messages:c,visibleElements:d}=this,m=this._getLayerTitle(e),u=e.visibleAtCurrentTimeExtent?e.visibleAtCurrentScale?m:`${m} (${c.layerInvisibleAtScale})`:`${m} (${c.layerInvisibleAtTime})`,h=this._filterActions(e.actionsSections),g=this._countActions(h),f="catalog"===e.parent?.layer?.type,b="catalog-footprint"===e.layer?.type,y="catalog-dynamic-group"===e.layer?.type,_=b?A("calcite-icon",{class:p.itemCatalogIcon,icon:"footprint",key:"footprint",scale:"s",slot:"content-start"}):null,v=d.catalogLayerList&&y?A("calcite-icon",{class:p.itemCatalogIcon,icon:"catalog-dataset",key:"catalog-dataset",scale:"s",slot:"content-start"}):null,I=y?A("calcite-action",{appearance:"transparent",icon:"chevron-right",iconFlipRtl:!0,onclick:()=>{this._catalogFlowItem=s,this._focusCatalogFlowItem=!0,this._createCatalog(t)},scale:"s",slot:"actions-end",text:m}):null;return A("calcite-list-item",{afterCreate:t=>this._focusSelectedDragEl(t,e),afterUpdate:t=>this._focusSelectedDragEl(t,e),class:this.classes(p.item,{[p.itemActive]:l===e}),"data-item":e,"data-layer-id":e.layer.id,dragDisabled:!e.sortable||i||f,dragSelected:e.layer.uid===n,id:e.layer.uid,key:`list-item-${e.layer.uid}`,label:m,metadata:{parentTitles:o,title:m},open:e.open,selected:"none"!==a&&r.includes(e),title:u,value:e.layer.uid,onCalciteListItemDragHandleChange:t=>this._handleCalciteListItemDragHandleChange(t,e),onCalciteListItemSelect:t=>this._handleCalciteListItemSelect(t,e,s),onCalciteListItemToggle:t=>this._handleCalciteListItemToggle(t,e)},_,v,A("div",{class:this.classes({[p.itemContent]:!0,[p.itemInvisible]:!e.visibleAtCurrentScale||!e.visibleAtCurrentTimeExtent}),slot:"content"},m),this._renderItemStatus(e,s),this._renderItemToggle(e,s),I,this._renderItemTemporaryIcon(e),this._renderChildList(e,t,o),this._renderItemMessage(e),this._renderPanel(e.panel),this._renderPanelAction(e.panel),g>1?this._renderActionsSections(e,h):1===g?this._renderAction({item:e,action:this._getSingleAction(h),textEnabled:!1}):null)}_renderItemStatus(e,t){const{visibleElements:i}=this;if(!i.statusIndicators)return null;const{connectionStatus:s,publishing:o,updating:l}=e,n=l&&!t,a=!!s;return A("calcite-icon",{class:this.classes({[p.statusIndicator]:!0,[p.publishing]:o,[p.updating]:n,[p.connectionStatus]:a,[p.connectionStatusConnected]:a&&"connected"===s}),icon:b({connectionStatus:s,publishing:o}),key:"layer-item-status",scale:"s",slot:"actions-end"})}_renderItemTemporaryIcon(e){return this.visibleElements.temporaryLayerIndicators&&"persistenceEnabled"in e.layer&&!e.layer.persistenceEnabled?A("calcite-icon",{class:p.itemTemporaryIcon,icon:"temporary",key:"temporary-icon",scale:"s",slot:"actions-start",title:this.messages.temporary}):null}_renderItemToggle(e,t){const{messages:i,visibilityAppearance:s}=this,{visible:o}=e,l=t?.visibilityMode;if("inherited"===l)return null;const n=w({visible:o,exclusive:"exclusive"===l,visibilityAppearance:s}),a="checkbox"===s,r=i.layerVisibility;return A("calcite-action",{appearance:"transparent",class:p.visibleToggle,icon:a?n:void 0,key:"visibility-toggle",onclick:()=>this._toggleVisibility(e,t),scale:"s",slot:a?"actions-start":"actions-end",text:r,title:r},a?null:A("calcite-icon",{class:this.classes({[p.visibleIcon]:"exclusive"!==l&&o}),icon:n,scale:"s"}))}_renderPanel(e){return!e?.open||e.disabled||e.flowEnabled?null:A("div",{class:p.itemContentBottom,key:`content-panel-${e.uid}`,slot:"content-bottom"},e.render())}_renderPanelAction(e){if(!e?.visible)return null;const{open:t,title:i,disabled:s}=e;return A("calcite-action",{active:t,appearance:"transparent",disabled:s,icon:a(e),key:`action-${e.uid}`,onclick:()=>this._togglePanel(e),scale:"s",slot:"actions-end",text:i??"",title:i??void 0},this._renderFallbackIcon(e))}_renderActionsSections(e,t){const i=this.messagesCommon.options;return A("calcite-action-menu",{appearance:"transparent",key:"item-action-menu",label:this.messagesCommon.menu,open:e.actionsOpen,overlayPositioning:"fixed",placement:"bottom-end",scale:"s",slot:"actions-end",onCalciteActionMenuOpen:t=>e.actionsOpen=t.target.open},A("calcite-action",{appearance:"transparent",icon:"ellipsis",scale:"s",slot:"trigger",text:i,title:i}),t.toArray().map(((t,i)=>this._renderActionSection(e,t,i))))}_renderActionSection(e,t,i){return A("calcite-action-group",{key:`action-section-${i}`},t.toArray().map((t=>this._renderAction({item:e,action:t,textEnabled:!0}))))}_renderFallbackIcon(e){const{className:t,icon:i}=e;if(i)return null;const s="image"in e?e.image:void 0,o={[p.itemActionIcon]:!!t,[p.itemActionImage]:!!s};return t&&(o[t]=!0),s||t?A("span",{"aria-hidden":"true",class:this.classes(p.itemActionIcon,o),key:"icon",styles:r(s)}):null}_renderAction(e){const{item:t,action:i,textEnabled:s}=e;if(!i)return null;const{active:o,disabled:l,title:n,type:r,indicator:c}=i;return A("calcite-action",{active:"toggle"===r&&i.value,appearance:"transparent",disabled:l,icon:a(i),indicator:c,key:`action-${i.uid}`,loading:o,onclick:()=>this._triggerAction(t,i),scale:"s",slot:s?void 0:"actions-end",text:n??"",textEnabled:s,title:n??void 0},this._renderFallbackIcon(i))}_setTooltipReference(e,t){this._tooltipReferenceMap.set(t.layer.uid,e)}_removeTooltipReference(e){this._tooltipReferenceMap.delete(e.layer.uid)}_moveLayerFromChildList({toEl:e,fromEl:t,dragEl:i,newIndex:s}){const o=g(i),l=g(e),n=g(t),a=j(t),r=j(e);a&&r&&this.viewModel.moveListItem({targetItem:o,fromParentItem:n,toParentItem:l,newIndex:s,from:a,to:r})}_handleCalciteListDragEnd(e){const{fromEl:t,dragEl:i,oldIndex:s}=e;t.insertBefore(i,t.children[s])}_sortLayers(e,t){if(e)if(e.group===this._rootGroupUid){const i=j(e),s="base"===i?this.view?.map?.basemap?.baseLayers:"reference"===i?this.view?.map?.basemap?.referenceLayers:null;y(s,t)}else{const i=g(e);if(!i)return;_(i,t)}}_getSingleAction(e){return e.reduce((e=>e)).find((e=>e&&("button"===e.type||"toggle"===e.type)))}_filterActions(e){return e.map((e=>e.filter((e=>e.visible))))}_countActions(e){return e.reduce(((e,t)=>e+t.length),0)}_triggerAction(e,t){t&&e&&("toggle"===t.type&&(t.value=!t.value),this.triggerAction(t,e))}_handleCalciteListChange(e){const{selectionMode:t,selectedItems:i}=this;if("none"===t)return;const s=e.target.selectedItems.map((e=>g(e))).filter(Boolean);i.removeAll(),i.addMany(s)}_handleCalciteListItemToggle(e,t){e.stopPropagation(),t.open=e.target.open}_focusSelectedDragEl(e,t){this._selectedDragItemLayerUid===t.layer.uid&&requestAnimationFrame((()=>e?.setFocus()))}_handleCalciteListItemDragHandleChange(e,t){e.stopPropagation();const i=e.target.dragSelected;this._selectedDragItemLayerUid=i?t.layer.uid:null}_handleCalciteListItemSelect(e,t,i){g(e.target)===t&&"none"===this.selectionMode&&"inherited"!==i?.visibilityMode&&this._toggleVisibility(t,i)}_togglePanel(e){e.open=!e.open,e.open&&(this._focusPanelFlowItem=!0)}_toggleVisibility(e,t){if(!e)return;const i=t?.visibilityMode;"exclusive"===i&&e.visible||(e.visible=!e.visible)}_renderEditingInput(){const{messages:e}=this,{basemapTitle:t}=this.viewModel;return A("div",{class:p.editing},A("calcite-label",null,e.basemapTitle,A("calcite-input",{afterCreate:e=>this._editTitleInput=e,label:e.basemapTitle,name:"basemaptitle",pattern:S,placeholder:e.basemapTitle,required:!0,title:e.basemapTitle,type:"text",value:t??void 0})))}_renderCancelButton(){const{messagesCommon:{cancel:e}}=this;return A("calcite-button",{appearance:"outline",bind:this,label:e,onclick:this._toggleEditingTitle,slot:"footer",title:e,width:"half"},e)}_renderSubmitButton(){const{messagesCommon:e}=this;return A("calcite-button",{label:e.form.submit,slot:"footer",title:e.form.submit,type:"submit",width:"half"},e.form.ok)}_renderEditingForm(){return this.editingTitle?A("form",{bind:this,onsubmit:this._formSubmit},A("calcite-flow-item",{afterCreate:this._focusEditingFlowItemNode,afterUpdate:this._focusEditingFlowItemNode,bind:this,heading:this.visibleElements.heading?this.messages.basemapTitle:void 0,headingLevel:this.headingLevel,onCalciteFlowItemBack:e=>{e.preventDefault(),this._toggleEditingTitle()}},this._renderEditingInput(),this._renderCancelButton(),this._renderSubmitButton())):null}_renderEditTitleButton(){const{editingTitle:e,visibleElements:t,messagesCommon:i}=this,s=i.edit;return t.editTitleButton&&!e?A("calcite-action",{bind:this,icon:"pencil",onclick:this._toggleEditingTitle,slot:"header-actions-end",text:s,title:s}):null}_renderNoLayersInfoMessage(e){return A("div",{slot:"message"},e)}_renderNoLayersInfo(e,t){return A("div",{class:p.itemMessage},A("calcite-notice",{icon:"information",key:t,kind:"info",open:!0,width:"full"},this._renderNoLayersInfoMessage(e)))}_getFilteredItems(e){return e?.filter((e=>!e.hidden&&(this.visibleElements.errors||!e.error)))}_renderItems(){const{collapsed:e,visible:t,visibleElements:{closeButton:i,collapseButton:s,heading:o,flow:l},messages:n,viewModel:a,referenceItems:r,baseItems:c}=this,d=this.visibleElements.referenceLayers?this._getFilteredItems(r):null,m=this.visibleElements.baseLayers?this._getFilteredItems(c):null,p=[A("calcite-flow-item",{afterCreate:this._focusRootFlowItemNode,afterUpdate:this._focusRootFlowItemNode,bind:this,closable:i,closed:!t,collapsed:e,collapsible:s,heading:o?a.basemapTitle??n.widgetLabel:void 0,headingLevel:this.headingLevel,key:"root-flow-item",onCalciteFlowItemClose:()=>this.visible=!1},this._renderEditTitleButton(),this._renderReferenceSection(d),this._renderBaseSection(m,1===m?.length)),this._renderEditingForm(),this._renderPanelFlowItems(m),this._renderPanelFlowItems(d),this._renderCatalogFlowItem()];return t?[l?A("calcite-flow",{key:"root-flow"},p):p,this._renderItemTooltips(d),this._renderItemTooltips(m)]:null}_renderChildList(e,t,i=[]){const{_rootGroupUid:s,dragEnabled:o,viewModel:{listModeDisabled:l},selectionMode:n}=this,{children:a}=e,r="catalog-dynamic-group"!==e.layer?.type&&v(e),c=!(!l&&I(e.layer))&&!r&&o&&"group"===e.layer?.type;return r||c?A("calcite-list",{canPull:e=>this._canMove(e,"pull"),canPut:e=>this._canMove(e,"put"),"data-basemap-layer-type":t,"data-item":e,"data-layer-type":s,dragEnabled:!!o&&(e.childrenSortable&&L(e)),group:`${s}-${e.layer.uid}`,key:`child-list-${e.layer.uid}`,selectionAppearance:"border",selectionMode:n},a?.filter((e=>!e.hidden)).toArray().map((s=>this._renderItem(s,t,!1,e,[...i,e.title])))):null}_renderList(e,t,i){const{messages:s,dragEnabled:o,selectionMode:l,filterPlaceholder:n,baseFilterText:a,referenceFilterText:r,_baseFilterEnabled:c,_referenceFilterEnabled:d,_rootGroupUid:m}=this,u="reference"===t?s.noReferenceLayers:s.noBaseLayers,h="reference"===t?d:c;return A("calcite-block",{class:p.section,collapsible:!0,heading:"reference"===t?s.referenceHeading:s.baseHeading,headingLevel:C(this.headingLevel),key:`block-${t}`,open:!0},0===e?.length?this._renderNoLayersInfo(u,t):null,A("calcite-list",{afterCreate:e=>{e.addEventListener("focusin",this._setActiveItem),e.addEventListener("focusout",this._clearActiveItem)},afterRemoved:e=>{e.removeEventListener("focusin",this._setActiveItem),e.removeEventListener("focusout",this._clearActiveItem)},canPull:e=>this._canMove(e,"pull"),canPut:e=>this._canMove(e,"put"),"data-basemap-layer-type":t,"data-layer-type":m,dragEnabled:o,filterEnabled:h,filterPlaceholder:n,filterText:h?"reference"===t?r:a:"",group:m,key:`list-${t}`,label:s.widgetLabel,onmouseleave:this._clearActiveItem,onmouseover:this._setActiveItem,selectionAppearance:"border",selectionMode:l,onCalciteListChange:e=>this._handleCalciteListChange(e),onCalciteListDragEnd:e=>this._handleCalciteListDragEnd(e.detail),onCalciteListFilter:e=>this["reference"===t?"referenceFilterText":"baseFilterText"]=e.target?.filterText??"",onCalciteListOrderChange:e=>this._onCalciteListOrderChange(e.detail)},e?.toArray().map((e=>this._renderItem(e,t,i))),e?.length&&h?A("div",{class:p.filterNoResults,slot:"filter-no-results"},A("calcite-notice",{kind:"info",open:!0,width:"full"},this._renderNoLayersInfoMessage(u))):null))}_renderBaseSection(e,t){return this.visibleElements.baseLayers?this._renderList(e,"base",t):null}_renderReferenceSection(e){return this.visibleElements.referenceLayers?this._renderList(e,"reference",!1):null}_toggleEditingTitle(){const{editingTitle:e}=this,t=!e;this.editingTitle=t,t?this._focusEditingFlowItem=!0:this._focusRootFlowItem=!0}_formSubmit(e){e.preventDefault();const t=this._editTitleInput?.value;t?.trim()&&(this.basemapTitle=t),this._toggleEditingTitle()}};function j(e){return e?.getAttribute("data-basemap-layer-type")}e([l()],x.prototype,"_activeItem",void 0),e([l()],x.prototype,"_tooltipReferenceMap",void 0),e([l()],x.prototype,"_focusRootFlowItem",void 0),e([l()],x.prototype,"_focusPanelFlowItem",void 0),e([l()],x.prototype,"_focusEditingFlowItem",void 0),e([l()],x.prototype,"_focusCatalogFlowItem",void 0),e([l()],x.prototype,"_catalogFlowItem",void 0),e([l()],x.prototype,"_baseFilterEnabled",null),e([l()],x.prototype,"_referenceFilterEnabled",null),e([l()],x.prototype,"basemapTitle",null),e([l({readOnly:!0})],x.prototype,"catalogLayerList",void 0),e([l()],x.prototype,"catalogOptions",void 0),e([l()],x.prototype,"collapsed",void 0),e([l()],x.prototype,"dragEnabled",void 0),e([l()],x.prototype,"editingTitle",void 0),e([l()],x.prototype,"filterPlaceholder",void 0),e([l()],x.prototype,"baseFilterText",void 0),e([l()],x.prototype,"referenceFilterText",void 0),e([l()],x.prototype,"listItemCanGiveFunction",void 0),e([l()],x.prototype,"listItemCanReceiveFunction",void 0),e([l()],x.prototype,"baseListItemCreatedFunction",null),e([l()],x.prototype,"editingEnabled",null),e([l()],x.prototype,"headingLevel",void 0),e([l()],x.prototype,"icon",null),e([l()],x.prototype,"label",null),e([l(),T("esri/widgets/BasemapLayerList/t9n/BasemapLayerList")],x.prototype,"messages",void 0),e([l(),T("esri/t9n/common")],x.prototype,"messagesCommon",void 0),e([l()],x.prototype,"minFilterItems",void 0),e([l()],x.prototype,"multipleSelectionEnabled",null),e([l()],x.prototype,"referenceListItemCreatedFunction",null),e([l({readOnly:!0})],x.prototype,"baseItems",null),e([l({readOnly:!0})],x.prototype,"referenceItems",null),e([l()],x.prototype,"selectedItems",void 0),e([l()],x.prototype,"selectionMode",void 0),e([l()],x.prototype,"view",null),e([M("trigger-action"),l({type:d})],x.prototype,"viewModel",void 0),e([l()],x.prototype,"visibilityAppearance",void 0),e([l({type:m,nonNullable:!0})],x.prototype,"visibleElements",void 0),x=e([n("esri.widgets.BasemapLayerList")],x);const B=x;export{B as default};
5
+ import{_ as e}from"../chunks/tslib.es6.js";import t from"../core/Collection.js";import{deprecatedProperty as i}from"../core/deprecate.js";import{IdentifiableMixin as s}from"../core/Identifiable.js";import o from"../core/Logger.js";import{watch as l}from"../core/reactiveUtils.js";import{property as n}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/RandomLCG.js";import{subclass as a}from"../core/accessorSupport/decorators/subclass.js";import{getActionIcon as r,getActionStyles as c}from"../support/actions/actionUtils.js";import d from"./Widget.js";import m from"./BasemapLayerList/BasemapLayerListViewModel.js";import p from"./BasemapLayerList/BasemapLayerListVisibleElements.js";import{css as u}from"./BasemapLayerList/css.js";import h from"./LayerList/ListItem.js";import{minFilterItems as g,getItem as f,getLayerType as y,getStatusIcon as b,sortLayersToIds as _,sortChildLayersToIds as v,listItemHasChildren as I,areChildrenHidden as L,canSortSublayers as w,getVisibilityIcon as E}from"./LayerList/support/layerListUtils.js";import{loadCalciteComponents as C}from"./support/componentsUtils.js";import{globalCss as F}from"./support/globalCss.js";import{incrementHeadingLevel as T}from"./support/Heading.js";import"./support/widgetUtils.js";import{messageBundle as M}from"./support/decorators/messageBundle.js";import{vmEvent as A}from"./support/decorators/vmEvent.js";import{tsx as k}from"./support/jsxFactory.js";const S=t.ofType(h),x=".*\\S+.*";let j=class extends(s(d)){constructor(e,t){super(e,t),this._activeItem=null,this._tooltipReferenceMap=new Map,this._editTitleInput=null,this._focusRootFlowItem=!1,this._focusPanelFlowItem=!1,this._focusEditingFlowItem=!1,this._focusCatalogFlowItem=!1,this._lastDragDetail=null,this._selectedDragItemLayerUid=null,this._rootGroupUid=`basemap-${this.uid}`,this.catalogLayerList=null,this.catalogOptions=null,this.collapsed=!1,this.dragEnabled=!1,this.editingTitle=!1,this.filterPlaceholder="",this.baseFilterText="",this.referenceFilterText="",this.listItemCanGiveFunction=null,this.listItemCanReceiveFunction=null,this.headingLevel=2,this.messages=null,this.messagesCommon=null,this.minFilterItems=g,this.openCatalogItem=null,this.selectedItems=new S,this.selectionMode="none",this.viewModel=new m,this.visibilityAppearance="default",this.visibleElements=new p,this._canMove=({dragEl:e,fromEl:t,toEl:i},s)=>{const o="pull"===s?this.listItemCanGiveFunction:this.listItemCanReceiveFunction,l=f(e);if(!l?.sortable)return!1;const n=f(t),a=y(t),r=f(i),c=y(i),d=!!a&&!!c&&a===c,m={selected:l,from:n,to:r},p=t.group,u=i.group,h=n?.layer?.type??"",g=r?.layer?.type??"",b=new Set(["map-image","catalog","knowledge-graph"]),_="sublayer";return p&&u&&"function"==typeof o?o.call(null,m):d&&!b.has(h)&&!b.has(g)&&l?.layer?.type!==_},this._clearActiveItem=()=>{this._activeItem=null},this._setActiveItem=e=>{if("default"!==this.visibilityAppearance)return;const t=Array.from(e.composedPath()).find((e=>e.classList?.contains(u.item)));this._activeItem=f(t)},this._onCalciteListOrderChange=e=>{const{_lastDragDetail:t}=this,{toEl:i,fromEl:s,dragEl:o,newIndex:l}=e;if(!s||!i||t?.newIndex===l&&t?.dragEl===o&&t?.toEl===i&&t?.fromEl===s)return;this._lastDragDetail=e;const n=s,a=i;if(n!==a)this._moveLayerFromChildList({toEl:a,fromEl:n,dragEl:o,newIndex:l});else{const e=Array.from(s.children).filter((e=>e?.matches("calcite-list-item"))).map((e=>e.value));this._sortLayers(n,e)}}}initialize(){this.addHandles([l((()=>this.openCatalogItem),(e=>e?this._createCatalog():this._destroyCatalog()))])}normalizeCtorArgs(e){return null!=e?.editingEnabled&&null!=e.visibleElements?{...e,visibleElements:new p({...e.visibleElements,editTitleButton:e.editingEnabled})}:e}loadDependencies(){return C({action:()=>import("@esri/calcite-components/dist/components/calcite-action.js"),"action-group":()=>import("@esri/calcite-components/dist/components/calcite-action-group.js"),"action-menu":()=>import("@esri/calcite-components/dist/components/calcite-action-menu.js"),block:()=>import("@esri/calcite-components/dist/components/calcite-block.js"),label:()=>import("@esri/calcite-components/dist/components/calcite-label.js"),input:()=>import("@esri/calcite-components/dist/components/calcite-input.js"),button:()=>import("@esri/calcite-components/dist/components/calcite-button.js"),flow:()=>import("@esri/calcite-components/dist/components/calcite-flow.js"),"flow-item":()=>import("@esri/calcite-components/dist/components/calcite-flow-item.js"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon.js"),list:()=>import("@esri/calcite-components/dist/components/calcite-list.js"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item.js"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice.js"),tooltip:()=>import("@esri/calcite-components/dist/components/calcite-tooltip.js")})}destroy(){this._tooltipReferenceMap.clear()}get _totalBaseItems(){return this.viewModel.baseItems.flatten((e=>e.children.filter((e=>"catalog-dynamic-group"!==e.layer.type)))).length}get _totalReferenceItems(){return this.viewModel.referenceItems.flatten((e=>e.children.filter((e=>"catalog-dynamic-group"!==e.layer.type)))).length}get _baseFilterEnabled(){return this._totalBaseItems>=this.minFilterItems&&this.visibleElements.filter}get _referenceFilterEnabled(){return this._totalReferenceItems>=this.minFilterItems&&this.visibleElements.filter}get basemapTitle(){return this.viewModel.basemapTitle}set basemapTitle(e){this.viewModel.basemapTitle=e}get baseListItemCreatedFunction(){return this.viewModel.baseListItemCreatedFunction}set baseListItemCreatedFunction(e){this.viewModel.baseListItemCreatedFunction=e}get editingEnabled(){return i(o.getLogger(this),"editingEnabled",{replacement:"selectionMode, dragEnabled, visibleElements.editTitleButton",version:"4.29",warnOnce:!0}),"none"!==this.selectionMode&&this.dragEnabled&&this.visibleElements.editTitleButton}set editingEnabled(e){i(o.getLogger(this),"editingEnabled",{replacement:"selectionMode, dragEnabled, visibleElements.editTitleButton",version:"4.29",warnOnce:!0}),this.dragEnabled=e,this.visibleElements.editTitleButton=e,this.selectionMode=e?this.multipleSelectionEnabled?"multiple":"single":"none"}get icon(){return"layers"}set icon(e){this._overrideIfSome("icon",e)}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get multipleSelectionEnabled(){return i(o.getLogger(this),"multipleSelectionEnabled",{replacement:"selectionMode",version:"4.29",warnOnce:!0}),"multiple"===this.selectionMode}set multipleSelectionEnabled(e){i(o.getLogger(this),"multipleSelectionEnabled",{replacement:"selectionMode",version:"4.29",warnOnce:!0}),this.selectionMode=e?"multiple":this.editingEnabled?"single":"none"}get referenceListItemCreatedFunction(){return this.viewModel.referenceListItemCreatedFunction}set referenceListItemCreatedFunction(e){this.viewModel.referenceListItemCreatedFunction=e}get baseItems(){return this.viewModel.baseItems}get referenceItems(){return this.viewModel.referenceItems}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}triggerAction(e,t){return this.viewModel.triggerAction(e,t)}render(){const{state:e}=this.viewModel,t={[F.hidden]:"loading"===e,[F.disabled]:"disabled"===e};return k("div",{class:this.classes(u.base,F.widget,F.panel,t)},this._renderItems())}_renderItemTooltip(e){return e?k("calcite-tooltip",{key:`tooltip-${e.layer.uid}`,referenceElement:this._tooltipReferenceMap.get(e.layer.uid)},this.messages.layerIncompatibleTooltip):null}_renderItemTooltipNodes(e){return e.incompatible?this._renderItemTooltip(e):e.children?.filter((e=>!e.hidden)).toArray().map((e=>this._renderItemTooltipNodes(e)))}_renderItemTooltips(e){return e?.toArray().map((e=>this._renderItemTooltipNodes(e)))}async _createCatalog(){this._destroyCatalog();const{default:e}=await import("./CatalogLayerList.js"),{headingLevel:t,catalogOptions:i,view:s,filterPlaceholder:o,baseListItemCreatedFunction:l,referenceListItemCreatedFunction:n,minFilterItems:a,selectionMode:r,visibilityAppearance:c,openCatalogItem:d,referenceItems:m}=this,p=d&&m.flatten((e=>e.children)).includes(d)?"reference":"base",u=this.openCatalogItem?.layer;this._set("catalogLayerList",new e({headingLevel:t,view:s,filterPlaceholder:o,minFilterItems:a,selectionMode:r,listItemCreatedFunction:"base"===p?l:n,visibilityAppearance:c,...i,catalogLayer:u}))}_destroyCatalog(){this.catalogLayerList?.destroy(),this._set("catalogLayerList",null)}_renderCatalogFlowItem(){const{openCatalogItem:e,messages:t}=this;if(!e)return null;const i=this._getLayerTitle(e);return k("calcite-flow-item",{afterCreate:this._focusCatalogFlowItemNode,afterUpdate:this._focusCatalogFlowItemNode,bind:this,description:i,heading:t.catalogLayers,headingLevel:this.headingLevel,key:`flow-catalog-${e.uid}`,onCalciteFlowItemBack:e=>{e.preventDefault(),this.openCatalogItem=null,this._focusRootFlowItem=!0}},this.catalogLayerList?.render())}_focusCatalogFlowItemNode(e){this._focusCatalogFlowItem&&(this._focusCatalogFlowItem=!1,requestAnimationFrame((()=>e?.setFocus())))}_renderPanelFlowItems(e){return e?e.flatten((e=>e.children)).filter((({hidden:e,panel:t})=>!e&&t?.open&&!t.disabled&&t.flowEnabled)).toArray().map((({title:e,panel:t})=>{const i=()=>this._handlePanelFlowItemBack(t);return k("calcite-flow-item",{afterCreate:this._focusPanelFlowItemNode,afterUpdate:this._focusPanelFlowItemNode,bind:this,description:e,heading:t.title,headingLevel:this.headingLevel,key:`flow-panel-${t.uid}`,onCalciteFlowItemBack:e=>{e.preventDefault(),i()}},t.render(),k("calcite-button",{appearance:"transparent",onclick:i,slot:"footer-actions",width:"full"},this.messagesCommon.back))})):[]}_handlePanelFlowItemBack(e){e.open=!1,this._focusRootFlowItem=!0}_focusEditingFlowItemNode(e){this._focusEditingFlowItem&&(this._focusEditingFlowItem=!1,requestAnimationFrame((()=>e?.setFocus())))}_focusRootFlowItemNode(e){this._focusRootFlowItem&&(this._focusRootFlowItem=!1,requestAnimationFrame((()=>e?.setFocus())))}_focusPanelFlowItemNode(e){this._focusPanelFlowItem&&(this._focusPanelFlowItem=!1,requestAnimationFrame((()=>e?.setFocus())))}_renderItemMessage(e){return e.error?k("div",{class:u.itemMessage,key:"esri-layer-list__error",slot:"content-bottom"},k("calcite-notice",{icon:"exclamation-mark-triangle",kind:"warning",open:!0,scale:"s",width:"full"},k("div",{slot:"message"},this.messages.layerError))):e.incompatible?k("div",{class:u.itemMessage,key:"esri-layer-list__incompatible",slot:"content-bottom"},k("calcite-notice",{afterCreate:t=>this._setTooltipReference(t,e),afterRemoved:()=>this._removeTooltipReference(e),icon:"exclamation-mark-triangle",kind:"warning",open:!0,scale:"s",tabIndex:0,width:"full"},k("div",{slot:"message"},this.messages.layerIncompatible))):null}_getLayerTitle(e){return e.title||this.messages.untitledLayer}_renderItem(e,t,i,s,o){const{_activeItem:l,_selectedDragItemLayerUid:n,selectionMode:a,selectedItems:r,messages:c,visibleElements:d}=this,m=this._getLayerTitle(e),p=e.visibleAtCurrentTimeExtent?e.visibleAtCurrentScale?m:`${m} (${c.layerInvisibleAtScale})`:`${m} (${c.layerInvisibleAtTime})`,h=this._filterActions(e.actionsSections),g=this._countActions(h),f="catalog"===e.parent?.layer?.type,y="catalog-footprint"===e.layer?.type,b="catalog-dynamic-group"===e.layer?.type,_=y?k("calcite-icon",{class:u.itemCatalogIcon,icon:"footprint",key:"footprint",scale:"s",slot:"content-start"}):null,v=d.catalogLayerList&&b?k("calcite-icon",{class:u.itemCatalogIcon,icon:"catalog-dataset",key:"catalog-dataset",scale:"s",slot:"content-start"}):null,I=b?k("calcite-action",{appearance:"transparent",icon:"chevron-right",iconFlipRtl:!0,onclick:()=>{this.openCatalogItem=s,this._focusCatalogFlowItem=!0},scale:"s",slot:"actions-end",text:m}):null;return k("calcite-list-item",{afterCreate:t=>this._focusSelectedDragEl(t,e),afterUpdate:t=>this._focusSelectedDragEl(t,e),class:this.classes(u.item,{[u.itemActive]:l===e}),"data-item":e,"data-layer-id":e.layer.id,dragDisabled:!e.sortable||i||f,dragSelected:e.layer.uid===n,id:e.layer.uid,key:`list-item-${e.layer.uid}`,label:m,metadata:{parentTitles:o,title:m},open:e.open,selected:"none"!==a&&r.includes(e),title:p,value:e.layer.uid,onCalciteListItemDragHandleChange:t=>this._handleCalciteListItemDragHandleChange(t,e),onCalciteListItemSelect:t=>this._handleCalciteListItemSelect(t,e,s),onCalciteListItemToggle:t=>this._handleCalciteListItemToggle(t,e)},_,v,k("div",{class:this.classes({[u.itemContent]:!0,[u.itemInvisible]:!e.visibleAtCurrentScale||!e.visibleAtCurrentTimeExtent}),slot:"content"},m),this._renderItemStatus(e,s),this._renderItemToggle(e,s),I,this._renderItemTemporaryIcon(e),this._renderChildList(e,t,o),this._renderItemMessage(e),this._renderPanel(e.panel),this._renderPanelAction(e.panel),g>1?this._renderActionsSections(e,h):1===g?this._renderAction({item:e,action:this._getSingleAction(h),textEnabled:!1}):null)}_renderItemStatus(e,t){const{visibleElements:i}=this;if(!i.statusIndicators)return null;const{connectionStatus:s,publishing:o,updating:l}=e,n=l&&!t,a=!!s;return k("calcite-icon",{class:this.classes({[u.statusIndicator]:!0,[u.publishing]:o,[u.updating]:n,[u.connectionStatus]:a,[u.connectionStatusConnected]:a&&"connected"===s}),icon:b({connectionStatus:s,publishing:o}),key:"layer-item-status",scale:"s",slot:"actions-end"})}_renderItemTemporaryIcon(e){return this.visibleElements.temporaryLayerIndicators&&"persistenceEnabled"in e.layer&&!e.layer.persistenceEnabled?k("calcite-icon",{class:u.itemTemporaryIcon,icon:"temporary",key:"temporary-icon",scale:"s",slot:"actions-start",title:this.messages.temporary}):null}_renderItemToggle(e,t){const{messages:i,visibilityAppearance:s}=this,{visible:o}=e,l=t?.visibilityMode;if("inherited"===l)return null;const n=E({visible:o,exclusive:"exclusive"===l,visibilityAppearance:s}),a="checkbox"===s,r=i.layerVisibility;return k("calcite-action",{appearance:"transparent",class:u.visibleToggle,icon:a?n:void 0,key:"visibility-toggle",onclick:()=>this._toggleVisibility(e,t),scale:"s",slot:a?"actions-start":"actions-end",text:r,title:r},a?null:k("calcite-icon",{class:this.classes({[u.visibleIcon]:"exclusive"!==l&&o}),icon:n,scale:"s"}))}_renderPanel(e){return!e?.open||e.disabled||e.flowEnabled?null:k("div",{class:u.itemContentBottom,key:`content-panel-${e.uid}`,slot:"content-bottom"},e.render())}_renderPanelAction(e){if(!e?.visible)return null;const{open:t,title:i,disabled:s}=e;return k("calcite-action",{active:t,appearance:"transparent",disabled:s,icon:r(e),key:`action-${e.uid}`,onclick:()=>this._togglePanel(e),scale:"s",slot:"actions-end",text:i??"",title:i??void 0},this._renderFallbackIcon(e))}_renderActionsSections(e,t){const i=this.messagesCommon.options;return k("calcite-action-menu",{appearance:"transparent",class:u.actionMenu,key:"item-action-menu",label:this.messagesCommon.menu,open:e.actionsOpen,overlayPositioning:"fixed",placement:"bottom-end",scale:"s",slot:"actions-end",onCalciteActionMenuOpen:t=>e.actionsOpen=t.target.open},k("calcite-action",{appearance:"transparent",icon:"ellipsis",scale:"s",slot:"trigger",text:i,title:i}),t.toArray().map(((t,i)=>this._renderActionSection(e,t,i))))}_renderActionSection(e,t,i){return k("calcite-action-group",{class:u.actionGroup,key:`action-section-${i}`},t.toArray().map((t=>this._renderAction({item:e,action:t,textEnabled:!0}))))}_renderFallbackIcon(e){const{className:t,icon:i}=e;if(i)return null;const s="image"in e?e.image:void 0,o={[u.itemActionIcon]:!!t,[u.itemActionImage]:!!s};return t&&(o[t]=!0),s||t?k("span",{"aria-hidden":"true",class:this.classes(u.itemActionIcon,o),key:"icon",styles:c(s)}):null}_renderAction(e){const{item:t,action:i,textEnabled:s}=e;if(!i)return null;const{active:o,disabled:l,title:n,type:a,indicator:c}=i;return k("calcite-action",{active:"toggle"===a&&i.value,appearance:"transparent",disabled:l,icon:r(i),indicator:c,key:`action-${i.uid}`,loading:o,onclick:()=>this._triggerAction(t,i),scale:"s",slot:s?void 0:"actions-end",text:n??"",textEnabled:s,title:n??void 0},this._renderFallbackIcon(i))}_setTooltipReference(e,t){this._tooltipReferenceMap.set(t.layer.uid,e)}_removeTooltipReference(e){this._tooltipReferenceMap.delete(e.layer.uid)}_moveLayerFromChildList({toEl:e,fromEl:t,dragEl:i,newIndex:s}){const o=f(i),l=f(e),n=f(t),a=B(t),r=B(e);a&&r&&this.viewModel.moveListItem({targetItem:o,fromParentItem:n,toParentItem:l,newIndex:s,from:a,to:r})}_handleCalciteListDragEnd(e){const{fromEl:t,dragEl:i,oldIndex:s}=e;t.insertBefore(i,t.children[s])}_sortLayers(e,t){if(e)if(e.group===this._rootGroupUid){const i=B(e),s="base"===i?this.view?.map?.basemap?.baseLayers:"reference"===i?this.view?.map?.basemap?.referenceLayers:null;_(s,t)}else{const i=f(e);if(!i)return;v(i,t)}}_getSingleAction(e){return e.reduce((e=>e)).find((e=>e&&("button"===e.type||"toggle"===e.type)))}_filterActions(e){return e.map((e=>e.filter((e=>e.visible))))}_countActions(e){return e.reduce(((e,t)=>e+t.length),0)}_triggerAction(e,t){t&&e&&("toggle"===t.type&&(t.value=!t.value),this.triggerAction(t,e))}_handleCalciteListChange(e){const{selectionMode:t,selectedItems:i}=this;if("none"===t)return;const s=e.target.selectedItems.map((e=>f(e))).filter(Boolean);i.removeAll(),i.addMany(s)}_handleCalciteListItemToggle(e,t){e.stopPropagation(),t.open=e.target.open}_focusSelectedDragEl(e,t){this._selectedDragItemLayerUid===t.layer.uid&&requestAnimationFrame((()=>e?.setFocus()))}_handleCalciteListItemDragHandleChange(e,t){e.stopPropagation();const i=e.target.dragSelected;this._selectedDragItemLayerUid=i?t.layer.uid:null}_handleCalciteListItemSelect(e,t,i){f(e.target)===t&&"none"===this.selectionMode&&"inherited"!==i?.visibilityMode&&this._toggleVisibility(t,i)}_togglePanel(e){e.open=!e.open,e.open&&(this._focusPanelFlowItem=!0)}_toggleVisibility(e,t){if(!e)return;const i=t?.visibilityMode;"exclusive"===i&&e.visible||(e.visible=!e.visible)}_renderEditingInput(){const{messages:e}=this,{basemapTitle:t}=this.viewModel;return k("div",{class:u.editing},k("calcite-label",null,e.basemapTitle,k("calcite-input",{afterCreate:e=>this._editTitleInput=e,label:e.basemapTitle,name:"basemaptitle",pattern:x,placeholder:e.basemapTitle,required:!0,title:e.basemapTitle,type:"text",value:t??void 0})))}_renderCancelButton(){const{messagesCommon:{cancel:e}}=this;return k("calcite-button",{appearance:"outline",bind:this,label:e,onclick:this._toggleEditingTitle,slot:"footer",title:e,width:"half"},e)}_renderSubmitButton(){const{messagesCommon:e}=this;return k("calcite-button",{label:e.form.submit,slot:"footer",title:e.form.submit,type:"submit",width:"half"},e.form.ok)}_renderEditingForm(){return this.editingTitle?k("form",{bind:this,onsubmit:this._formSubmit},k("calcite-flow-item",{afterCreate:this._focusEditingFlowItemNode,afterUpdate:this._focusEditingFlowItemNode,bind:this,heading:this.visibleElements.heading?this.messages.basemapTitle:void 0,headingLevel:this.headingLevel,onCalciteFlowItemBack:e=>{e.preventDefault(),this._toggleEditingTitle()}},this._renderEditingInput(),this._renderCancelButton(),this._renderSubmitButton())):null}_renderEditTitleButton(){const{editingTitle:e,visibleElements:t,messagesCommon:i}=this,s=i.edit;return t.editTitleButton&&!e?k("calcite-action",{bind:this,icon:"pencil",onclick:this._toggleEditingTitle,slot:"header-actions-end",text:s,title:s}):null}_renderNoLayersInfoMessage(e){return k("div",{slot:"message"},e)}_renderNoLayersInfo(e,t){return k("div",{class:u.itemMessage},k("calcite-notice",{icon:"information",key:t,kind:"info",open:!0,width:"full"},this._renderNoLayersInfoMessage(e)))}_getFilteredItems(e){return e?.filter((e=>!e.hidden&&(this.visibleElements.errors||!e.error)))}_renderItems(){const{collapsed:e,visible:t,visibleElements:{closeButton:i,collapseButton:s,heading:o,flow:l},messages:n,viewModel:a,referenceItems:r,baseItems:c}=this,d=this.visibleElements.referenceLayers?this._getFilteredItems(r):null,m=this.visibleElements.baseLayers?this._getFilteredItems(c):null,p=[k("calcite-flow-item",{afterCreate:this._focusRootFlowItemNode,afterUpdate:this._focusRootFlowItemNode,bind:this,closable:i,closed:!t,collapsed:e,collapsible:s,heading:o?a.basemapTitle??n.widgetLabel:void 0,headingLevel:this.headingLevel,key:"root-flow-item",onCalciteFlowItemClose:()=>this.visible=!1},this._renderEditTitleButton(),this._renderReferenceSection(d),this._renderBaseSection(m,1===m?.length)),this._renderEditingForm(),this._renderPanelFlowItems(m),this._renderPanelFlowItems(d),this._renderCatalogFlowItem()];return t?[l?k("calcite-flow",{key:"root-flow"},p):p,this._renderItemTooltips(d),this._renderItemTooltips(m)]:null}_renderChildList(e,t,i=[]){const{_rootGroupUid:s,dragEnabled:o,viewModel:{listModeDisabled:l},selectionMode:n}=this,{children:a}=e,r="catalog-dynamic-group"!==e.layer?.type&&I(e),c=!(!l&&L(e.layer))&&!r&&o&&"group"===e.layer?.type;return r||c?k("calcite-list",{canPull:e=>this._canMove(e,"pull"),canPut:e=>this._canMove(e,"put"),"data-basemap-layer-type":t,"data-item":e,"data-layer-type":s,dragEnabled:!!o&&(e.childrenSortable&&w(e)),group:`${s}-${e.layer.uid}`,key:`child-list-${e.layer.uid}`,selectionAppearance:"border",selectionMode:n},a?.filter((e=>!e.hidden)).toArray().map((s=>this._renderItem(s,t,!1,e,[...i,e.title])))):null}_renderList(e,t,i){const{messages:s,dragEnabled:o,selectionMode:l,filterPlaceholder:n,baseFilterText:a,referenceFilterText:r,_baseFilterEnabled:c,_referenceFilterEnabled:d,_rootGroupUid:m}=this,p="reference"===t?s.noReferenceLayers:s.noBaseLayers,h="reference"===t?d:c;return k("calcite-block",{class:u.section,collapsible:!0,heading:"reference"===t?s.referenceHeading:s.baseHeading,headingLevel:T(this.headingLevel),key:`block-${t}`,open:!0},0===e?.length?this._renderNoLayersInfo(p,t):null,k("calcite-list",{afterCreate:e=>{e.addEventListener("focusin",this._setActiveItem),e.addEventListener("focusout",this._clearActiveItem)},afterRemoved:e=>{e.removeEventListener("focusin",this._setActiveItem),e.removeEventListener("focusout",this._clearActiveItem)},canPull:e=>this._canMove(e,"pull"),canPut:e=>this._canMove(e,"put"),"data-basemap-layer-type":t,"data-layer-type":m,dragEnabled:o,filterEnabled:h,filterPlaceholder:n,filterText:h?"reference"===t?r:a:"",group:m,key:`list-${t}`,label:s.widgetLabel,onmouseleave:this._clearActiveItem,onmouseover:this._setActiveItem,selectionAppearance:"border",selectionMode:l,onCalciteListChange:e=>this._handleCalciteListChange(e),onCalciteListDragEnd:e=>this._handleCalciteListDragEnd(e.detail),onCalciteListFilter:e=>this["reference"===t?"referenceFilterText":"baseFilterText"]=e.target?.filterText??"",onCalciteListOrderChange:e=>this._onCalciteListOrderChange(e.detail)},e?.toArray().map((e=>this._renderItem(e,t,i))),e?.length&&h?k("div",{class:u.filterNoResults,slot:"filter-no-results"},k("calcite-notice",{kind:"info",open:!0,width:"full"},this._renderNoLayersInfoMessage(p))):null))}_renderBaseSection(e,t){return this.visibleElements.baseLayers?this._renderList(e,"base",t):null}_renderReferenceSection(e){return this.visibleElements.referenceLayers?this._renderList(e,"reference",!1):null}_toggleEditingTitle(){const{editingTitle:e}=this,t=!e;this.editingTitle=t,t?this._focusEditingFlowItem=!0:this._focusRootFlowItem=!0}_formSubmit(e){e.preventDefault();const t=this._editTitleInput?.value;t?.trim()&&(this.basemapTitle=t),this._toggleEditingTitle()}};function B(e){return e?.getAttribute("data-basemap-layer-type")}e([n()],j.prototype,"_activeItem",void 0),e([n()],j.prototype,"_tooltipReferenceMap",void 0),e([n()],j.prototype,"_focusRootFlowItem",void 0),e([n()],j.prototype,"_focusPanelFlowItem",void 0),e([n()],j.prototype,"_focusEditingFlowItem",void 0),e([n()],j.prototype,"_focusCatalogFlowItem",void 0),e([n()],j.prototype,"_totalBaseItems",null),e([n()],j.prototype,"_totalReferenceItems",null),e([n()],j.prototype,"_baseFilterEnabled",null),e([n()],j.prototype,"_referenceFilterEnabled",null),e([n()],j.prototype,"basemapTitle",null),e([n({readOnly:!0})],j.prototype,"catalogLayerList",void 0),e([n()],j.prototype,"catalogOptions",void 0),e([n()],j.prototype,"collapsed",void 0),e([n()],j.prototype,"dragEnabled",void 0),e([n()],j.prototype,"editingTitle",void 0),e([n()],j.prototype,"filterPlaceholder",void 0),e([n()],j.prototype,"baseFilterText",void 0),e([n()],j.prototype,"referenceFilterText",void 0),e([n()],j.prototype,"listItemCanGiveFunction",void 0),e([n()],j.prototype,"listItemCanReceiveFunction",void 0),e([n()],j.prototype,"baseListItemCreatedFunction",null),e([n()],j.prototype,"editingEnabled",null),e([n()],j.prototype,"headingLevel",void 0),e([n()],j.prototype,"icon",null),e([n()],j.prototype,"label",null),e([n(),M("esri/widgets/BasemapLayerList/t9n/BasemapLayerList")],j.prototype,"messages",void 0),e([n(),M("esri/t9n/common")],j.prototype,"messagesCommon",void 0),e([n()],j.prototype,"minFilterItems",void 0),e([n()],j.prototype,"multipleSelectionEnabled",null),e([n()],j.prototype,"referenceListItemCreatedFunction",null),e([n({readOnly:!0})],j.prototype,"baseItems",null),e([n()],j.prototype,"openCatalogItem",void 0),e([n({readOnly:!0})],j.prototype,"referenceItems",null),e([n()],j.prototype,"selectedItems",void 0),e([n()],j.prototype,"selectionMode",void 0),e([n()],j.prototype,"view",null),e([A("trigger-action"),n({type:m})],j.prototype,"viewModel",void 0),e([n()],j.prototype,"visibilityAppearance",void 0),e([n({type:p,nonNullable:!0})],j.prototype,"visibleElements",void 0),j=e([a("esri.widgets.BasemapLayerList")],j);const P=j;export{P as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.31/esri/copyright.txt for details.
4
4
  */
5
- const t="esri-catalog-layer-list",i=`${t}__item`,e={base:t,filterNoResults:`${t}__filter-no-results`,item:i,itemActive:`${i}--active`,itemContent:`${i}-content`,itemContentBottom:`${i}-content-bottom`,itemMessage:`${i}-message`,itemInvisible:`${i}--invisible`,itemActionIcon:`${i}-action-icon`,itemActionImage:`${i}-action-image`,itemTemporaryIcon:`${i}-temporary-icon`,itemTableIcon:`${i}-table-icon`,statusIndicator:`${t}__status-indicator`,publishing:`${t}__publishing`,updating:`${t}__updating`,connectionStatus:`${t}__connection-status`,connectionStatusConnected:`${t}__connection-status--connected`,visibleToggle:`${t}__visible-toggle`,visibleIcon:`${t}__visible-icon`};export{e as css};
5
+ const t="esri-catalog-layer-list",i=`${t}__item`,e={base:t,actionMenu:`${t}__action-menu`,actionGroup:`${t}__action-group`,filterNoResults:`${t}__filter-no-results`,item:i,itemActive:`${i}--active`,itemContent:`${i}-content`,itemContentBottom:`${i}-content-bottom`,itemMessage:`${i}-message`,itemInvisible:`${i}--invisible`,itemActionIcon:`${i}-action-icon`,itemActionImage:`${i}-action-image`,itemTemporaryIcon:`${i}-temporary-icon`,itemTableIcon:`${i}-table-icon`,statusIndicator:`${t}__status-indicator`,publishing:`${t}__publishing`,updating:`${t}__updating`,connectionStatus:`${t}__connection-status`,connectionStatusConnected:`${t}__connection-status--connected`,visibleToggle:`${t}__visible-toggle`,visibleIcon:`${t}__visible-icon`};export{e as css};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.31/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../chunks/tslib.es6.js";import t from"../core/Collection.js";import{IdentifiableMixin as i}from"../core/Identifiable.js";import o from"../core/ReactiveMap.js";import{property as s}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/Logger.js";import"../core/RandomLCG.js";import{subclass as l}from"../core/accessorSupport/decorators/subclass.js";import{getActionIcon as n,getActionStyles as r}from"../support/actions/actionUtils.js";import a from"./Widget.js";import c from"./CatalogLayerList/CatalogLayerListViewModel.js";import d from"./CatalogLayerList/CatalogLayerListVisibleElements.js";import{css as m}from"./CatalogLayerList/css.js";import p from"./LayerList/ListItem.js";import{minFilterItems as u,getItem as h,listItemHasChildren as g,areChildrenHidden as y,getStatusIcon as v,getVisibilityIcon as f}from"./LayerList/support/layerListUtils.js";import{loadCalciteComponents as _}from"./support/componentsUtils.js";import{globalCss as I}from"./support/globalCss.js";import"./support/widgetUtils.js";import{messageBundle as b}from"./support/decorators/messageBundle.js";import{vmEvent as L}from"./support/decorators/vmEvent.js";import{tsx as w}from"./support/jsxFactory.js";const A=t.ofType(p);let C=class extends(i(a)){constructor(e,t){super(e,t),this._activeItem=null,this._tooltipReferenceMap=new o,this._focusRootFlowItem=!1,this._focusPanelFlowItem=!1,this._rootGroupUid=`operational-${this.uid}`,this.collapsed=!1,this.filterPlaceholder="",this.filterText="",this.headingLevel=2,this.messages=null,this.messagesLayerList=null,this.messagesCommon=null,this.minFilterItems=u,this.selectedItems=new A,this.selectionMode="none",this.viewModel=new c,this.visibilityAppearance="default",this.visibleElements=new d,this._clearActiveItem=()=>{this._activeItem=null},this._setActiveItem=e=>{if("default"!==this.visibilityAppearance)return;const t=Array.from(e.composedPath()).find((e=>e.classList?.contains(m.item)));this._activeItem=h(t)}}loadDependencies(){return _({action:()=>import("@esri/calcite-components/dist/components/calcite-action.js"),"action-group":()=>import("@esri/calcite-components/dist/components/calcite-action-group.js"),"action-menu":()=>import("@esri/calcite-components/dist/components/calcite-action-menu.js"),button:()=>import("@esri/calcite-components/dist/components/calcite-button.js"),flow:()=>import("@esri/calcite-components/dist/components/calcite-flow.js"),"flow-item":()=>import("@esri/calcite-components/dist/components/calcite-flow-item.js"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon.js"),list:()=>import("@esri/calcite-components/dist/components/calcite-list.js"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item.js"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice.js"),tooltip:()=>import("@esri/calcite-components/dist/components/calcite-tooltip.js")})}destroy(){this._tooltipReferenceMap.clear()}get _filterEnabled(){return this.viewModel.totalItems>=this.minFilterItems&&this.visibleElements.filter}get catalogItems(){return this.viewModel.catalogItems}set catalogItems(e){this.viewModel.catalogItems=e}get catalogLayer(){return this.viewModel.catalogLayer}set catalogLayer(e){this.viewModel.catalogLayer=e}get icon(){return"catalog-dataset"}set icon(e){this._overrideIfSome("icon",e)}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get listItemCreatedFunction(){return this.viewModel.listItemCreatedFunction}set listItemCreatedFunction(e){this.viewModel.listItemCreatedFunction=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}triggerAction(e,t){return this.viewModel.triggerAction(e,t)}render(){const e=this.viewModel?.state,t={[I.hidden]:"loading"===e,[I.disabled]:"disabled"===e},i=this.catalogItems?.filter((e=>!e.hidden&&(this.visibleElements.errors||!e.error)));return w("div",{class:this.classes(m.base,I.widget,I.panel,t)},i?.length?[this._renderItemTooltips(i),this._renderItems(i)]:this._renderNoItems())}_renderItemTooltip(e){const{_tooltipReferenceMap:t,messagesLayerList:i}=this;return e?w("calcite-tooltip",{key:`tooltip-${e.layer.uid}`,referenceElement:t.get(e.layer.uid)},i.layerIncompatibleTooltip):null}_renderItemTooltipNodes(e){return e.incompatible?this._renderItemTooltip(e):e.children?.filter((e=>!e.hidden)).toArray().map((e=>this._renderItemTooltipNodes(e)))}_renderItemTooltips(e){return e?.toArray().map((e=>this._renderItemTooltipNodes(e)))}_renderNoItemsMessage(){return w("div",{slot:"message"},this.messagesLayerList.noItemsToDisplay)}_renderNoItems(){return w("div",{class:m.itemMessage,key:"esri-layer-list__no-items"},w("calcite-notice",{icon:"information",kind:"info",open:!0,width:"full"},this._renderNoItemsMessage()))}_renderPanelFlowItems(e){return e?e.flatten((e=>e.children)).filter((({hidden:e,panel:t})=>!e&&t?.open&&!t.disabled&&t.flowEnabled)).toArray().map((({title:e,panel:t})=>{const i=()=>this._handlePanelFlowItemBack(t);return w("calcite-flow-item",{afterCreate:this._focusPanelFlowItemNode,afterUpdate:this._focusPanelFlowItemNode,bind:this,description:e,heading:t.title,headingLevel:this.headingLevel,key:`flow-panel-${t.uid}`,onCalciteFlowItemBack:e=>{e.preventDefault(),i()}},t.render(),w("calcite-button",{appearance:"transparent",onclick:i,slot:"footer-actions",width:"full"},this.messagesCommon.back))})):[]}_handlePanelFlowItemBack(e){e.open=!1,this._focusRootFlowItem=!0}_focusRootFlowItemNode(e){this._focusRootFlowItem&&(this._focusRootFlowItem=!1,requestAnimationFrame((()=>e?.setFocus())))}_focusPanelFlowItemNode(e){this._focusPanelFlowItem&&(this._focusPanelFlowItem=!1,requestAnimationFrame((()=>e?.setFocus())))}_renderItems(e){const{visible:t,collapsed:i,_filterEnabled:o,_rootGroupUid:s,visibleElements:{closeButton:l,collapseButton:n,heading:r,flow:a},selectionMode:c,filterText:d,filterPlaceholder:p,messages:u}=this,h=[w("calcite-flow-item",{afterCreate:this._focusRootFlowItemNode,afterUpdate:this._focusRootFlowItemNode,bind:this,closable:l,closed:!t,collapsed:i,collapsible:n,heading:r?u.widgetLabel:void 0,headingLevel:this.headingLevel,key:"root-flow-item",onCalciteFlowItemClose:()=>this.visible=!1},w("calcite-list",{afterCreate:e=>{e.addEventListener("focusin",this._setActiveItem),e.addEventListener("focusout",this._clearActiveItem)},afterRemoved:e=>{e.removeEventListener("focusin",this._setActiveItem),e.removeEventListener("focusout",this._clearActiveItem)},"data-layer-type":s,filterEnabled:o,filterPlaceholder:p,filterText:o?d:"",group:s,key:"root-list",label:u.widgetLabel,onmouseleave:this._clearActiveItem,onmouseover:this._setActiveItem,selectionAppearance:"border",selectionMode:c,onCalciteListChange:e=>this._handleCalciteListChange(e),onCalciteListFilter:e=>this.filterText=e.target?.filterText??""},e?.toArray().map((e=>this._renderItem(e))),e?.length&&o?w("div",{class:m.filterNoResults,slot:"filter-no-results"},w("calcite-notice",{kind:"info",open:!0,width:"full"},this._renderNoItemsMessage())):null)),this._renderPanelFlowItems(e)];return t?a?w("calcite-flow",{key:"root-flow"},h):h:null}_renderChildList(e,t=[]){const{_rootGroupUid:i,viewModel:{listModeDisabled:o},selectionMode:s}=this,{children:l}=e,n=g(e),r=!(!o&&y(e.layer))&&!n&&"group"===e.layer?.type;return n||r?w("calcite-list",{"data-item":e,"data-layer-type":i,group:`${i}-${e.layer.uid}`,key:`child-list-${e.layer.uid}`,selectionAppearance:"border",selectionMode:s},l?.filter((e=>!e.hidden)).toArray().map((i=>this._renderItem(i,e,[...t,e.title])))):null}_renderItemMessage(e){return e.error?w("div",{class:m.itemMessage,key:"esri-layer-list__error",slot:"content-bottom"},w("calcite-notice",{icon:"exclamation-mark-triangle",kind:"warning",open:!0,scale:"s",width:"full"},w("div",{slot:"message"},this.messagesLayerList.layerError))):e.incompatible?w("div",{class:m.itemMessage,key:"esri-layer-list__incompatible",slot:"content-bottom"},w("calcite-notice",{afterCreate:t=>this._setTooltipReference(t,e),afterRemoved:()=>this._removeTooltipReference(e),bind:this,icon:"exclamation-mark-triangle",kind:"warning",open:!0,scale:"s",tabIndex:0,width:"full"},w("div",{slot:"message"},this.messagesLayerList.layerIncompatible))):null}_getLayerTitle(e){return e.title||this.messagesLayerList.untitledLayer}_renderItem(e,t,i){const{_activeItem:o,selectionMode:s,selectedItems:l,messagesLayerList:n}=this,r=this._getLayerTitle(e),a=e.visibleAtCurrentTimeExtent?e.visibleAtCurrentScale?r:`${r} (${n.layerInvisibleAtScale})`:`${r} (${n.layerInvisibleAtTime})`,c=this._filterActions(e.actionsSections),d=this._countActions(c);return w("calcite-list-item",{class:this.classes(m.item,{[m.itemActive]:o===e}),"data-item":e,"data-layer-id":e.layer.id,id:e.layer.uid,key:`list-item-${e.layer.uid}`,label:r,metadata:{parentTitles:i,title:r},open:e.open,selected:"none"!==s&&l.includes(e),title:a,value:e.layer.uid,onCalciteListItemSelect:i=>this._handleCalciteListItemSelect(i,e,t),onCalciteListItemToggle:t=>this._handleCalciteListItemToggle(t,e)},w("div",{class:this.classes({[m.itemContent]:!0,[m.itemInvisible]:!e.visibleAtCurrentScale||!e.visibleAtCurrentTimeExtent}),slot:"content"},r),this._renderItemStatus(e,t),this._renderItemToggle(e,t),this._renderItemTemporaryIcon(e),this._renderChildList(e,i),this._renderItemMessage(e),this._renderPanel(e.panel),this._renderPanelAction(e.panel),d>1?this._renderActionsSections(e,c):1===d?this._renderAction({item:e,action:this._getSingleAction(c),textEnabled:!1}):null)}_renderItemStatus(e,t){const{visibleElements:i}=this;if(!i.statusIndicators)return null;const{connectionStatus:o,publishing:s,updating:l}=e,n=l&&!t,r=!!o;return w("calcite-icon",{class:this.classes({[m.statusIndicator]:!0,[m.publishing]:s,[m.updating]:n,[m.connectionStatus]:r,[m.connectionStatusConnected]:r&&"connected"===o}),icon:v({connectionStatus:o,publishing:s}),key:"layer-item-status",scale:"s",slot:"actions-end"})}_renderItemTemporaryIcon(e){return this.visibleElements.temporaryLayerIndicators&&"persistenceEnabled"in e.layer&&!e.layer.persistenceEnabled?w("calcite-icon",{class:m.itemTemporaryIcon,icon:"temporary",key:"temporary-icon",scale:"s",slot:"actions-start",title:this.messagesLayerList.temporary}):null}_renderItemToggle(e,t){const{messagesLayerList:i,visibilityAppearance:o}=this,{visible:s}=e,l=t?.visibilityMode;if("inherited"===l)return null;const n=f({visible:s,exclusive:"exclusive"===l,visibilityAppearance:o}),r="checkbox"===o,a=i.layerVisibility;return w("calcite-action",{appearance:"transparent",class:m.visibleToggle,icon:r?n:void 0,key:"visibility-toggle",onclick:()=>this._toggleVisibility(e,t),scale:"s",slot:r?"actions-start":"actions-end",text:a,title:a},r?null:w("calcite-icon",{class:this.classes({[m.visibleIcon]:"exclusive"!==l&&s}),icon:n,scale:"s"}))}_renderPanel(e){return!e?.open||e.disabled||e.flowEnabled?null:w("div",{class:m.itemContentBottom,key:`content-panel-${e.uid}`,slot:"content-bottom"},e.render())}_renderPanelAction(e){if(!e?.visible)return null;const{open:t,title:i,disabled:o}=e;return w("calcite-action",{active:t,appearance:"transparent",disabled:o,icon:n(e),key:`action-${e.uid}`,onclick:()=>this._togglePanel(e),scale:"s",slot:"actions-end",text:i??"",title:i??void 0},this._renderFallbackIcon(e))}_renderActionsSections(e,t){const i=this.messagesCommon.options;return w("calcite-action-menu",{appearance:"transparent",key:"item-action-menu",label:this.messagesCommon.menu,open:e.actionsOpen,overlayPositioning:"fixed",placement:"bottom-end",scale:"s",slot:"actions-end",onCalciteActionMenuOpen:t=>e.actionsOpen=t.target.open},w("calcite-action",{appearance:"transparent",icon:"ellipsis",scale:"s",slot:"trigger",text:i,title:i}),t.toArray().map(((t,i)=>this._renderActionSection(e,t,i))))}_renderActionSection(e,t,i){return w("calcite-action-group",{key:`action-section-${i}`},t.toArray().map((t=>this._renderAction({item:e,action:t,textEnabled:!0}))))}_renderFallbackIcon(e){const{className:t,icon:i}=e;if(i)return null;const o="image"in e?e.image:void 0,s={[m.itemActionIcon]:!!t,[m.itemActionImage]:!!o};return t&&(s[t]=!0),o||t?w("span",{"aria-hidden":"true",class:this.classes(m.itemActionIcon,s),key:"icon",styles:r(o)}):null}_renderAction(e){const{item:t,action:i,textEnabled:o}=e;if(!i)return null;const{active:s,disabled:l,title:r,type:a,indicator:c}=i;return w("calcite-action",{active:"toggle"===a&&i.value,appearance:"transparent",disabled:l,icon:n(i),indicator:c,key:`action-${i.uid}`,loading:s,onclick:()=>this._triggerAction(t,i),scale:"s",slot:o?void 0:"actions-end",text:r??"",textEnabled:o,title:r??void 0},this._renderFallbackIcon(i))}_setTooltipReference(e,t){this._tooltipReferenceMap.set(t.layer.uid,e)}_removeTooltipReference(e){this._tooltipReferenceMap.delete(e.layer.uid)}_getSingleAction(e){return e.reduce((e=>e)).find((e=>e&&("button"===e.type||"toggle"===e.type)))}_filterActions(e){return e.map((e=>e.filter((e=>e.visible))))}_countActions(e){return e.reduce(((e,t)=>e+t.length),0)}_triggerAction(e,t){t&&e&&("toggle"===t.type&&(t.value=!t.value),this.triggerAction(t,e))}_handleCalciteListChange(e){const{selectionMode:t,selectedItems:i}=this;if("none"===t)return;const o=e.target.selectedItems.map((e=>h(e))).filter(Boolean);i.removeAll(),i.addMany(o)}_handleCalciteListItemToggle(e,t){e.stopPropagation(),t.open=e.target.open}_handleCalciteListItemSelect(e,t,i){h(e.target)===t&&"none"===this.selectionMode&&"inherited"!==i?.visibilityMode&&this._toggleVisibility(t,i)}_togglePanel(e){e.open=!e.open,e.open&&(this._focusPanelFlowItem=!0)}_toggleVisibility(e,t){if(!e)return;const i=t?.visibilityMode;"exclusive"===i&&e.visible||(e.visible=!e.visible)}};e([s()],C.prototype,"_activeItem",void 0),e([s()],C.prototype,"_tooltipReferenceMap",void 0),e([s()],C.prototype,"_focusRootFlowItem",void 0),e([s()],C.prototype,"_focusPanelFlowItem",void 0),e([s()],C.prototype,"_filterEnabled",null),e([s()],C.prototype,"catalogItems",null),e([s()],C.prototype,"catalogLayer",null),e([s()],C.prototype,"collapsed",void 0),e([s()],C.prototype,"filterPlaceholder",void 0),e([s()],C.prototype,"filterText",void 0),e([s()],C.prototype,"headingLevel",void 0),e([s()],C.prototype,"icon",null),e([s()],C.prototype,"label",null),e([s()],C.prototype,"listItemCreatedFunction",null),e([s(),b("esri/widgets/CatalogLayerList/t9n/CatalogLayerList")],C.prototype,"messages",void 0),e([s(),b("esri/widgets/LayerList/t9n/LayerList")],C.prototype,"messagesLayerList",void 0),e([s(),b("esri/t9n/common")],C.prototype,"messagesCommon",void 0),e([s()],C.prototype,"minFilterItems",void 0),e([s()],C.prototype,"selectedItems",void 0),e([s()],C.prototype,"selectionMode",void 0),e([s()],C.prototype,"view",null),e([L("trigger-action"),s({type:c})],C.prototype,"viewModel",void 0),e([s()],C.prototype,"visibilityAppearance",void 0),e([s({type:d,nonNullable:!0})],C.prototype,"visibleElements",void 0),C=e([l("esri.widgets.CatalogLayerList")],C);const M=C;export{M as default};
5
+ import{_ as e}from"../chunks/tslib.es6.js";import t from"../core/Collection.js";import{IdentifiableMixin as i}from"../core/Identifiable.js";import o from"../core/ReactiveMap.js";import{property as s}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/Logger.js";import"../core/RandomLCG.js";import{subclass as l}from"../core/accessorSupport/decorators/subclass.js";import{getActionIcon as n,getActionStyles as r}from"../support/actions/actionUtils.js";import a from"./Widget.js";import c from"./CatalogLayerList/CatalogLayerListViewModel.js";import d from"./CatalogLayerList/CatalogLayerListVisibleElements.js";import{css as m}from"./CatalogLayerList/css.js";import p from"./LayerList/ListItem.js";import{minFilterItems as u,getItem as h,listItemHasChildren as g,areChildrenHidden as y,getStatusIcon as v,getVisibilityIcon as f}from"./LayerList/support/layerListUtils.js";import{loadCalciteComponents as _}from"./support/componentsUtils.js";import{globalCss as I}from"./support/globalCss.js";import"./support/widgetUtils.js";import{messageBundle as b}from"./support/decorators/messageBundle.js";import{vmEvent as L}from"./support/decorators/vmEvent.js";import{tsx as w}from"./support/jsxFactory.js";const A=t.ofType(p);let C=class extends(i(a)){constructor(e,t){super(e,t),this._activeItem=null,this._tooltipReferenceMap=new o,this._focusRootFlowItem=!1,this._focusPanelFlowItem=!1,this._rootGroupUid=`operational-${this.uid}`,this.collapsed=!1,this.filterPlaceholder="",this.filterText="",this.headingLevel=2,this.messages=null,this.messagesLayerList=null,this.messagesCommon=null,this.minFilterItems=u,this.selectedItems=new A,this.selectionMode="none",this.viewModel=new c,this.visibilityAppearance="default",this.visibleElements=new d,this._clearActiveItem=()=>{this._activeItem=null},this._setActiveItem=e=>{if("default"!==this.visibilityAppearance)return;const t=Array.from(e.composedPath()).find((e=>e.classList?.contains(m.item)));this._activeItem=h(t)}}loadDependencies(){return _({action:()=>import("@esri/calcite-components/dist/components/calcite-action.js"),"action-group":()=>import("@esri/calcite-components/dist/components/calcite-action-group.js"),"action-menu":()=>import("@esri/calcite-components/dist/components/calcite-action-menu.js"),button:()=>import("@esri/calcite-components/dist/components/calcite-button.js"),flow:()=>import("@esri/calcite-components/dist/components/calcite-flow.js"),"flow-item":()=>import("@esri/calcite-components/dist/components/calcite-flow-item.js"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon.js"),list:()=>import("@esri/calcite-components/dist/components/calcite-list.js"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item.js"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice.js"),tooltip:()=>import("@esri/calcite-components/dist/components/calcite-tooltip.js")})}destroy(){this._tooltipReferenceMap.clear()}get _filterEnabled(){return this.viewModel.totalItems>=this.minFilterItems&&this.visibleElements.filter}get catalogItems(){return this.viewModel.catalogItems}set catalogItems(e){this.viewModel.catalogItems=e}get catalogLayer(){return this.viewModel.catalogLayer}set catalogLayer(e){this.viewModel.catalogLayer=e}get icon(){return"catalog-dataset"}set icon(e){this._overrideIfSome("icon",e)}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get listItemCreatedFunction(){return this.viewModel.listItemCreatedFunction}set listItemCreatedFunction(e){this.viewModel.listItemCreatedFunction=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}triggerAction(e,t){return this.viewModel.triggerAction(e,t)}render(){const e=this.viewModel?.state,t={[I.hidden]:"loading"===e,[I.disabled]:"disabled"===e},i=this.catalogItems?.filter((e=>!e.hidden&&(this.visibleElements.errors||!e.error)));return w("div",{class:this.classes(m.base,I.widget,I.panel,t)},i?.length?[this._renderItemTooltips(i),this._renderItems(i)]:this._renderNoItems())}_renderItemTooltip(e){const{_tooltipReferenceMap:t,messagesLayerList:i}=this;return e?w("calcite-tooltip",{key:`tooltip-${e.layer.uid}`,referenceElement:t.get(e.layer.uid)},i.layerIncompatibleTooltip):null}_renderItemTooltipNodes(e){return e.incompatible?this._renderItemTooltip(e):e.children?.filter((e=>!e.hidden)).toArray().map((e=>this._renderItemTooltipNodes(e)))}_renderItemTooltips(e){return e?.toArray().map((e=>this._renderItemTooltipNodes(e)))}_renderNoItemsMessage(){return w("div",{slot:"message"},this.messagesLayerList.noItemsToDisplay)}_renderNoItems(){return w("div",{class:m.itemMessage,key:"esri-layer-list__no-items"},w("calcite-notice",{icon:"information",kind:"info",open:!0,width:"full"},this._renderNoItemsMessage()))}_renderPanelFlowItems(e){return e?e.flatten((e=>e.children)).filter((({hidden:e,panel:t})=>!e&&t?.open&&!t.disabled&&t.flowEnabled)).toArray().map((({title:e,panel:t})=>{const i=()=>this._handlePanelFlowItemBack(t);return w("calcite-flow-item",{afterCreate:this._focusPanelFlowItemNode,afterUpdate:this._focusPanelFlowItemNode,bind:this,description:e,heading:t.title,headingLevel:this.headingLevel,key:`flow-panel-${t.uid}`,onCalciteFlowItemBack:e=>{e.preventDefault(),i()}},t.render(),w("calcite-button",{appearance:"transparent",onclick:i,slot:"footer-actions",width:"full"},this.messagesCommon.back))})):[]}_handlePanelFlowItemBack(e){e.open=!1,this._focusRootFlowItem=!0}_focusRootFlowItemNode(e){this._focusRootFlowItem&&(this._focusRootFlowItem=!1,requestAnimationFrame((()=>e?.setFocus())))}_focusPanelFlowItemNode(e){this._focusPanelFlowItem&&(this._focusPanelFlowItem=!1,requestAnimationFrame((()=>e?.setFocus())))}_renderItems(e){const{visible:t,collapsed:i,_filterEnabled:o,_rootGroupUid:s,visibleElements:{closeButton:l,collapseButton:n,heading:r,flow:a},selectionMode:c,filterText:d,filterPlaceholder:p,messages:u}=this,h=[w("calcite-flow-item",{afterCreate:this._focusRootFlowItemNode,afterUpdate:this._focusRootFlowItemNode,bind:this,closable:l,closed:!t,collapsed:i,collapsible:n,heading:r?u.widgetLabel:void 0,headingLevel:this.headingLevel,key:"root-flow-item",onCalciteFlowItemClose:()=>this.visible=!1},w("calcite-list",{afterCreate:e=>{e.addEventListener("focusin",this._setActiveItem),e.addEventListener("focusout",this._clearActiveItem)},afterRemoved:e=>{e.removeEventListener("focusin",this._setActiveItem),e.removeEventListener("focusout",this._clearActiveItem)},"data-layer-type":s,filterEnabled:o,filterPlaceholder:p,filterText:o?d:"",group:s,key:"root-list",label:u.widgetLabel,onmouseleave:this._clearActiveItem,onmouseover:this._setActiveItem,selectionAppearance:"border",selectionMode:c,onCalciteListChange:e=>this._handleCalciteListChange(e),onCalciteListFilter:e=>this.filterText=e.target?.filterText??""},e?.toArray().map((e=>this._renderItem(e))),e?.length&&o?w("div",{class:m.filterNoResults,slot:"filter-no-results"},w("calcite-notice",{kind:"info",open:!0,width:"full"},this._renderNoItemsMessage())):null)),this._renderPanelFlowItems(e)];return t?a?w("calcite-flow",{key:"root-flow"},h):h:null}_renderChildList(e,t=[]){const{_rootGroupUid:i,viewModel:{listModeDisabled:o},selectionMode:s}=this,{children:l}=e,n=g(e),r=!(!o&&y(e.layer))&&!n&&"group"===e.layer?.type;return n||r?w("calcite-list",{"data-item":e,"data-layer-type":i,group:`${i}-${e.layer.uid}`,key:`child-list-${e.layer.uid}`,selectionAppearance:"border",selectionMode:s},l?.filter((e=>!e.hidden)).toArray().map((i=>this._renderItem(i,e,[...t,e.title])))):null}_renderItemMessage(e){return e.error?w("div",{class:m.itemMessage,key:"esri-layer-list__error",slot:"content-bottom"},w("calcite-notice",{icon:"exclamation-mark-triangle",kind:"warning",open:!0,scale:"s",width:"full"},w("div",{slot:"message"},this.messagesLayerList.layerError))):e.incompatible?w("div",{class:m.itemMessage,key:"esri-layer-list__incompatible",slot:"content-bottom"},w("calcite-notice",{afterCreate:t=>this._setTooltipReference(t,e),afterRemoved:()=>this._removeTooltipReference(e),bind:this,icon:"exclamation-mark-triangle",kind:"warning",open:!0,scale:"s",tabIndex:0,width:"full"},w("div",{slot:"message"},this.messagesLayerList.layerIncompatible))):null}_getLayerTitle(e){return e.title||this.messagesLayerList.untitledLayer}_renderItem(e,t,i){const{_activeItem:o,selectionMode:s,selectedItems:l,messagesLayerList:n}=this,r=this._getLayerTitle(e),a=e.visibleAtCurrentTimeExtent?e.visibleAtCurrentScale?r:`${r} (${n.layerInvisibleAtScale})`:`${r} (${n.layerInvisibleAtTime})`,c=this._filterActions(e.actionsSections),d=this._countActions(c);return w("calcite-list-item",{class:this.classes(m.item,{[m.itemActive]:o===e}),"data-item":e,"data-layer-id":e.layer.id,id:e.layer.uid,key:`list-item-${e.layer.uid}`,label:r,metadata:{parentTitles:i,title:r},open:e.open,selected:"none"!==s&&l.includes(e),title:a,value:e.layer.uid,onCalciteListItemSelect:i=>this._handleCalciteListItemSelect(i,e,t),onCalciteListItemToggle:t=>this._handleCalciteListItemToggle(t,e)},w("div",{class:this.classes({[m.itemContent]:!0,[m.itemInvisible]:!e.visibleAtCurrentScale||!e.visibleAtCurrentTimeExtent}),slot:"content"},r),this._renderItemStatus(e,t),this._renderItemToggle(e,t),this._renderItemTemporaryIcon(e),this._renderChildList(e,i),this._renderItemMessage(e),this._renderPanel(e.panel),this._renderPanelAction(e.panel),d>1?this._renderActionsSections(e,c):1===d?this._renderAction({item:e,action:this._getSingleAction(c),textEnabled:!1}):null)}_renderItemStatus(e,t){const{visibleElements:i}=this;if(!i.statusIndicators)return null;const{connectionStatus:o,publishing:s,updating:l}=e,n=l&&!t,r=!!o;return w("calcite-icon",{class:this.classes({[m.statusIndicator]:!0,[m.publishing]:s,[m.updating]:n,[m.connectionStatus]:r,[m.connectionStatusConnected]:r&&"connected"===o}),icon:v({connectionStatus:o,publishing:s}),key:"layer-item-status",scale:"s",slot:"actions-end"})}_renderItemTemporaryIcon(e){return this.visibleElements.temporaryLayerIndicators&&"persistenceEnabled"in e.layer&&!e.layer.persistenceEnabled?w("calcite-icon",{class:m.itemTemporaryIcon,icon:"temporary",key:"temporary-icon",scale:"s",slot:"actions-start",title:this.messagesLayerList.temporary}):null}_renderItemToggle(e,t){const{messagesLayerList:i,visibilityAppearance:o}=this,{visible:s}=e,l=t?.visibilityMode;if("inherited"===l)return null;const n=f({visible:s,exclusive:"exclusive"===l,visibilityAppearance:o}),r="checkbox"===o,a=i.layerVisibility;return w("calcite-action",{appearance:"transparent",class:m.visibleToggle,icon:r?n:void 0,key:"visibility-toggle",onclick:()=>this._toggleVisibility(e,t),scale:"s",slot:r?"actions-start":"actions-end",text:a,title:a},r?null:w("calcite-icon",{class:this.classes({[m.visibleIcon]:"exclusive"!==l&&s}),icon:n,scale:"s"}))}_renderPanel(e){return!e?.open||e.disabled||e.flowEnabled?null:w("div",{class:m.itemContentBottom,key:`content-panel-${e.uid}`,slot:"content-bottom"},e.render())}_renderPanelAction(e){if(!e?.visible)return null;const{open:t,title:i,disabled:o}=e;return w("calcite-action",{active:t,appearance:"transparent",disabled:o,icon:n(e),key:`action-${e.uid}`,onclick:()=>this._togglePanel(e),scale:"s",slot:"actions-end",text:i??"",title:i??void 0},this._renderFallbackIcon(e))}_renderActionsSections(e,t){const i=this.messagesCommon.options;return w("calcite-action-menu",{appearance:"transparent",class:m.actionMenu,key:"item-action-menu",label:this.messagesCommon.menu,open:e.actionsOpen,overlayPositioning:"fixed",placement:"bottom-end",scale:"s",slot:"actions-end",onCalciteActionMenuOpen:t=>e.actionsOpen=t.target.open},w("calcite-action",{appearance:"transparent",icon:"ellipsis",scale:"s",slot:"trigger",text:i,title:i}),t.toArray().map(((t,i)=>this._renderActionSection(e,t,i))))}_renderActionSection(e,t,i){return w("calcite-action-group",{class:m.actionGroup,key:`action-section-${i}`},t.toArray().map((t=>this._renderAction({item:e,action:t,textEnabled:!0}))))}_renderFallbackIcon(e){const{className:t,icon:i}=e;if(i)return null;const o="image"in e?e.image:void 0,s={[m.itemActionIcon]:!!t,[m.itemActionImage]:!!o};return t&&(s[t]=!0),o||t?w("span",{"aria-hidden":"true",class:this.classes(m.itemActionIcon,s),key:"icon",styles:r(o)}):null}_renderAction(e){const{item:t,action:i,textEnabled:o}=e;if(!i)return null;const{active:s,disabled:l,title:r,type:a,indicator:c}=i;return w("calcite-action",{active:"toggle"===a&&i.value,appearance:"transparent",disabled:l,icon:n(i),indicator:c,key:`action-${i.uid}`,loading:s,onclick:()=>this._triggerAction(t,i),scale:"s",slot:o?void 0:"actions-end",text:r??"",textEnabled:o,title:r??void 0},this._renderFallbackIcon(i))}_setTooltipReference(e,t){this._tooltipReferenceMap.set(t.layer.uid,e)}_removeTooltipReference(e){this._tooltipReferenceMap.delete(e.layer.uid)}_getSingleAction(e){return e.reduce((e=>e)).find((e=>e&&("button"===e.type||"toggle"===e.type)))}_filterActions(e){return e.map((e=>e.filter((e=>e.visible))))}_countActions(e){return e.reduce(((e,t)=>e+t.length),0)}_triggerAction(e,t){t&&e&&("toggle"===t.type&&(t.value=!t.value),this.triggerAction(t,e))}_handleCalciteListChange(e){const{selectionMode:t,selectedItems:i}=this;if("none"===t)return;const o=e.target.selectedItems.map((e=>h(e))).filter(Boolean);i.removeAll(),i.addMany(o)}_handleCalciteListItemToggle(e,t){e.stopPropagation(),t.open=e.target.open}_handleCalciteListItemSelect(e,t,i){h(e.target)===t&&"none"===this.selectionMode&&"inherited"!==i?.visibilityMode&&this._toggleVisibility(t,i)}_togglePanel(e){e.open=!e.open,e.open&&(this._focusPanelFlowItem=!0)}_toggleVisibility(e,t){if(!e)return;const i=t?.visibilityMode;"exclusive"===i&&e.visible||(e.visible=!e.visible)}};e([s()],C.prototype,"_activeItem",void 0),e([s()],C.prototype,"_tooltipReferenceMap",void 0),e([s()],C.prototype,"_focusRootFlowItem",void 0),e([s()],C.prototype,"_focusPanelFlowItem",void 0),e([s()],C.prototype,"_filterEnabled",null),e([s()],C.prototype,"catalogItems",null),e([s()],C.prototype,"catalogLayer",null),e([s()],C.prototype,"collapsed",void 0),e([s()],C.prototype,"filterPlaceholder",void 0),e([s()],C.prototype,"filterText",void 0),e([s()],C.prototype,"headingLevel",void 0),e([s()],C.prototype,"icon",null),e([s()],C.prototype,"label",null),e([s()],C.prototype,"listItemCreatedFunction",null),e([s(),b("esri/widgets/CatalogLayerList/t9n/CatalogLayerList")],C.prototype,"messages",void 0),e([s(),b("esri/widgets/LayerList/t9n/LayerList")],C.prototype,"messagesLayerList",void 0),e([s(),b("esri/t9n/common")],C.prototype,"messagesCommon",void 0),e([s()],C.prototype,"minFilterItems",void 0),e([s()],C.prototype,"selectedItems",void 0),e([s()],C.prototype,"selectionMode",void 0),e([s()],C.prototype,"view",null),e([L("trigger-action"),s({type:c})],C.prototype,"viewModel",void 0),e([s()],C.prototype,"visibilityAppearance",void 0),e([s({type:d,nonNullable:!0})],C.prototype,"visibleElements",void 0),C=e([l("esri.widgets.CatalogLayerList")],C);const M=C;export{M as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.31/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../core/Error.js";import{abortHandle as r,makeHandle as i}from"../../core/handleUtils.js";import{isAborted as a}from"../../core/promiseUtils.js";import{watch as o}from"../../core/reactiveUtils.js";import{property as s}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as l}from"../../core/accessorSupport/decorators/subclass.js";import{sceneLayerEditingEnabled as n,i3sPatchingEnabled as d}from"../../support/featureFlags.js";import c from"../../views/draw/support/HighlightHelper.js";import u from"./UpdateRecordWorkflowData.js";import m from"./Workflow.js";import{fetchFullFeature as p}from"./workflowUtils.js";import h from"../FeatureForm/FeatureFormViewModel.js";var f;const g={exit:Symbol()};let w=f=class extends m{constructor(e){super(e),this._highlightHelper=null,this.fullFeature=null,this.type="update-table-record"}initialize(){const{data:e}=this,{edits:o}=e,{view:s}=e.viewModel,l=o.feature,n=new AbortController;this.addHandles(r(n)),this._updatingHandles.addPromise(p(l,e.viewModel.view.spatialReference,n.signal).then((e=>{a(n)||(this._onFullFeatureLoaded(e),this._initializeFeatureFormViewModel())}),(e=>this.cancel({force:!0,error:new t("editor:failed-to-fetch-full-feature","Failed to retrieve all information for this feature. The update cannot proceed.",{detail:{error:e}})})))),s&&(this._highlightHelper=new c({view:s}),this.addHandles(i((()=>this._highlightHelper?.removeAll()))))}get editorItem(){return this.data.editorItem}get featureFormViewModel(){return this._featureFormViewModel}get hasPendingEdits(){return this.data.edits.modified}get layer(){return this.data.editorItem.layer}get parent(){return this.data.parent}get parentLayer(){return this.parent?.data.editorItem.layer}get shouldShowAttachments(){return this.editorItem.capabilities.attachments.enabled}get shouldAllowAttachmentEditing(){return this.editorItem.capabilities.update.attachments.enabled}get reliesOnOwnerAdminPrivileges(){const e=this.editorItem.capabilities;return e.update.reliesOnOwnerAdminPrivileges||e.delete.reliesOnOwnerAdminPrivileges}async deleteAndCommit(){return this.data.edits.stageDelete(),this.commit()}async enter(){this._configureAttachmentsViewModel()}exit(e){this.removeHandles(g.exit)}async start(){return await super.start(),null}_configureAttachmentsViewModel(){const{data:e,fullFeature:t}=this,{attachmentsCapabilities:r,viewModel:a}=e,{attachmentsViewModel:s}=a;s.set({capabilities:r,graphic:t,filesEnabled:!1,mode:"view"}),this.addHandles([i((()=>s.fileInfos.removeAll())),o((()=>s.mode),(e=>{switch(e){case"add":this.go("adding-attachment");break;case"edit":this.go("editing-attachment")}}))],g.exit)}_initializeFeatureFormViewModel(){const{edits:e,formTemplate:t,viewModel:{view:r}}=this.data,i=this._featureFormViewModel=new h({arcadeEditType:"UPDATE",feature:this.fullFeature,formTemplate:t,highlightHelper:this._highlightHelper,map:r?.map,spatialReference:r.spatialReference,timeZone:r?.timeZone});i.relatedRecordCallbacks={...this.data.relatedRecordCallbacks,showAllRelatedRecords:e=>i.relationshipId=e.relationshipId};const{initialFeature:a}=e;a&&i.overrideInitialFeature(a),this.addHandles([i.on("value-change",(()=>{e.updateAttributes(i.getValues()),this.fullFeature.attributes=e.feature.attributes})),o((()=>r?.timeZone),(e=>i.timeZone=e))])}_onFullFeatureLoaded(e){this.fullFeature=e;const{edits:t}=this.data;t.updateAttributes(e.attributes),t.trackChanges()}static async create(e){const t=new f({data:await u.create(e),onCommit:this._onCommitFactory(e.applyEdits)});return t._set("steps",this._createWorkflowSteps(t)),t}static _createWorkflowSteps(e){const{attachmentsViewModel:t}=e.data.viewModel;return[{id:"editing-attributes",async setUp(){},async tearDown(){}},{id:"adding-attachment",async setUp(){},async tearDown(){t.mode="view"}},{id:"editing-attachment",async setUp(){},async tearDown(){t.mode="view"}}]}};w._onCommitFactory=e=>async t=>{const{edits:r}=t,{feature:i}=r;if(!i)return;const a=i.sourceLayer,o=i.clone();if(!r.attributesModified||r.stagedForDelete){const e=a.objectIdField;if(o.attributes={[e]:i.getAttribute(e)},n()&&d()&&"scene"===a.type&&null!=a.infoFor3D){const e=a.associatedLayer?.globalIdField;null!=e&&o.setAttribute(e,i.getAttribute(e))}}r.geometryModified&&!r.stagedForDelete||(o.geometry=null);const s=r.stagedForDelete?"deleteFeatures":"updateFeatures";await e(a,{[s]:[o]})},e([s()],w.prototype,"editorItem",null),e([s()],w.prototype,"featureFormViewModel",null),e([s()],w.prototype,"fullFeature",void 0),e([s()],w.prototype,"hasPendingEdits",null),e([s()],w.prototype,"layer",null),e([s()],w.prototype,"parent",null),e([s()],w.prototype,"parentLayer",null),e([s()],w.prototype,"shouldShowAttachments",null),e([s()],w.prototype,"shouldAllowAttachmentEditing",null),e([s()],w.prototype,"reliesOnOwnerAdminPrivileges",null),w=f=e([l("esri.widgets.Editor.UpdateRecordWorkflow")],w);export{w as UpdateRecordWorkflow,g as handleKeys};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../core/Error.js";import{abortHandle as r,makeHandle as i}from"../../core/handleUtils.js";import{isAborted as a}from"../../core/promiseUtils.js";import{watch as o}from"../../core/reactiveUtils.js";import{property as s}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as l}from"../../core/accessorSupport/decorators/subclass.js";import n from"../../views/draw/support/HighlightHelper.js";import d from"./UpdateRecordWorkflowData.js";import c from"./Workflow.js";import{fetchFullFeature as u}from"./workflowUtils.js";import m from"../FeatureForm/FeatureFormViewModel.js";var p;const h={exit:Symbol()};let f=p=class extends c{constructor(e){super(e),this._highlightHelper=null,this.fullFeature=null,this.type="update-table-record"}initialize(){const{data:e}=this,{edits:o}=e,{view:s}=e.viewModel,l=o.feature,d=new AbortController;this.addHandles(r(d)),this._updatingHandles.addPromise(u(l,e.viewModel.view.spatialReference,d.signal).then((e=>{a(d)||(this._onFullFeatureLoaded(e),this._initializeFeatureFormViewModel())}),(e=>this.cancel({force:!0,error:new t("editor:failed-to-fetch-full-feature","Failed to retrieve all information for this feature. The update cannot proceed.",{detail:{error:e}})})))),s&&(this._highlightHelper=new n({view:s}),this.addHandles(i((()=>this._highlightHelper?.removeAll()))))}get editorItem(){return this.data.editorItem}get featureFormViewModel(){return this._featureFormViewModel}get hasPendingEdits(){return this.data.edits.modified}get layer(){return this.data.editorItem.layer}get parent(){return this.data.parent}get parentLayer(){return this.parent?.data.editorItem.layer}get shouldShowAttachments(){return this.editorItem.capabilities.attachments.enabled}get shouldAllowAttachmentEditing(){return this.editorItem.capabilities.update.attachments.enabled}get reliesOnOwnerAdminPrivileges(){const e=this.editorItem.capabilities;return e.update.reliesOnOwnerAdminPrivileges||e.delete.reliesOnOwnerAdminPrivileges}async deleteAndCommit(){return this.data.edits.stageDelete(),this.commit()}async enter(){this._configureAttachmentsViewModel()}exit(e){this.removeHandles(h.exit)}async start(){return await super.start(),null}_configureAttachmentsViewModel(){const{data:e,fullFeature:t}=this,{attachmentsCapabilities:r,viewModel:a}=e,{attachmentsViewModel:s}=a;s.set({capabilities:r,graphic:t,filesEnabled:!1,mode:"view"}),this.addHandles([i((()=>s.fileInfos.removeAll())),o((()=>s.mode),(e=>{switch(e){case"add":this.go("adding-attachment");break;case"edit":this.go("editing-attachment")}}))],h.exit)}_initializeFeatureFormViewModel(){const{edits:e,formTemplate:t,viewModel:{view:r}}=this.data,i=this._featureFormViewModel=new m({arcadeEditType:"UPDATE",feature:this.fullFeature,formTemplate:t,highlightHelper:this._highlightHelper,map:r?.map,spatialReference:r.spatialReference,timeZone:r?.timeZone});i.relatedRecordCallbacks={...this.data.relatedRecordCallbacks,showAllRelatedRecords:e=>i.relationshipId=e.relationshipId};const{initialFeature:a}=e;a&&i.overrideInitialFeature(a),this.addHandles([i.on("value-change",(()=>{e.updateAttributes(i.getValues()),this.fullFeature.attributes=e.feature.attributes})),o((()=>r?.timeZone),(e=>i.timeZone=e))])}_onFullFeatureLoaded(e){this.fullFeature=e;const{edits:t}=this.data;t.updateAttributes(e.attributes),t.trackChanges()}static async create(e){const t=new p({data:await d.create(e),onCommit:this._onCommitFactory(e.applyEdits)});return t._set("steps",this._createWorkflowSteps(t)),t}static _createWorkflowSteps(e){const{attachmentsViewModel:t}=e.data.viewModel;return[{id:"editing-attributes",async setUp(){},async tearDown(){}},{id:"adding-attachment",async setUp(){},async tearDown(){t.mode="view"}},{id:"editing-attachment",async setUp(){},async tearDown(){t.mode="view"}}]}};f._onCommitFactory=e=>async t=>{const{edits:r}=t,{feature:i}=r;if(!i)return;const a=i.sourceLayer,o=i.clone();if(!r.attributesModified||r.stagedForDelete){const e=a.objectIdField;if(o.attributes={[e]:i.getAttribute(e)},"scene"===a.type&&null!=a.infoFor3D){const e=a.associatedLayer?.globalIdField;null!=e&&o.setAttribute(e,i.getAttribute(e))}}r.geometryModified&&!r.stagedForDelete||(o.geometry=null);const s=r.stagedForDelete?"deleteFeatures":"updateFeatures";await e(a,{[s]:[o]})},e([s()],f.prototype,"editorItem",null),e([s()],f.prototype,"featureFormViewModel",null),e([s()],f.prototype,"fullFeature",void 0),e([s()],f.prototype,"hasPendingEdits",null),e([s()],f.prototype,"layer",null),e([s()],f.prototype,"parent",null),e([s()],f.prototype,"parentLayer",null),e([s()],f.prototype,"shouldShowAttachments",null),e([s()],f.prototype,"shouldAllowAttachmentEditing",null),e([s()],f.prototype,"reliesOnOwnerAdminPrivileges",null),f=p=e([l("esri.widgets.Editor.UpdateRecordWorkflow")],f);export{f as UpdateRecordWorkflow,h as handleKeys};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.31/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../core/Logger.js";import{replace as t}from"../../../core/string.js";import{convertDateFormatToIntlOptions as n,formatDate as r}from"../../../intl/date.js";import{formatNumber as i,convertNumberFormatToIntlOptions as o}from"../../../intl/number.js";import{isRasterPixelValueField as a,featureHasFields as l,isTimeOnlyField as u}from"../../../layers/support/fieldUtils.js";import{getEffectiveLayerCapabilities as s}from"../../../layers/support/layerUtils.js";import{formatAnyDate as f,isAnyDateField as c}from"../../../smartMapping/support/utils.js";import{loadArcade as d}from"../../../support/arcadeOnDemand.js";import{getTimeZoneFormattingOptions as p}from"../../../time/timeZoneUtils.js";const y="esri.widgets.Feature.support.featureUtils",m=()=>e.getLogger(y),g=/href=(""|'')/gi,h=/(\{([^{\r\n]+)\})/g,I=/'/g,b=/^\s*expression\//i,T=/(\n)/gi,w=/[\u00A0-\u9999<>&]/gim,F=/href\s*=\s*(?:"([^"]+)"|'([^']+)')/gi,N=/^(?:mailto:|tel:)/,j="relationships/",Z=n("short-date-short-time");function E(e){if(null!=e)return(e.sourceLayer||e.layer)??void 0}async function v({type:e,value:t,event:n}){try{return"function"==typeof t?t(n):t}catch(r){return void m().error("error",`An error occurred when calling the "${e}" function`,{error:r,graphic:n.graphic,value:t})}}function x(e=""){if(e)return!N.test(e.trim().toLowerCase())}function A(e){return!!e&&b.test(e)}function C(e,t){if(!t||!A(t)||!e)return;const n=t.replace(b,"").toLowerCase();return e.find((({name:e})=>e.toLowerCase()===n))}function M(e,t){const n=C(t,e?.fieldName);return n?n.title||null:e?e.label||e.fieldName:null}function U(e,t){const n=t.get(e.toLowerCase());return`{${n?.fieldName||e}}`}function q(e){return e.replaceAll(g,"")}function L(e,t){const n=$(t,e);return n?n.name:e}function R(e,t){return e&&e.map((e=>L(e,t)))}function $(e,t){return e&&"function"==typeof e.getField&&t?e.getField(t)??null:null}function k(e){return`${e}`.trim()}function D({attributes:e,globalAttributes:t,layer:n,text:r,expressionAttributes:i,fieldInfoMap:o}){return r?z({formattedAttributes:t,template:Q(r,{...t,...i,...e},n),fieldInfoMap:o}):""}function z({formattedAttributes:e,template:n,fieldInfoMap:r}){return k(q(t(t(n,(e=>U(e,r))),e)))}function O(e,t,n=!1){const r=t[e];if("string"==typeof r){const i="%27",o=(n?encodeURIComponent(r):r).replaceAll(I,i);t[e]=o}}function G(e,t=!1){const n={...e};return Object.keys(n).forEach((e=>O(e,n,t))),n}function S(e,n,r){const i=(n=k(n))&&"{"!==n[0];return t(e,G(r,i||!1))}function P(e,t){return e.replaceAll(h,((e,n,r)=>{const i=$(t,r);return i?`{${i.name}}`:n}))}function Q(e,t,n){const r=P(e,n);return r?r.replaceAll(F,((e,n,r)=>S(e,n||r,t))):r}function _(e,t){if("string"==typeof e&&t&&null==t.dateFormat&&(null!=t.places||null!=t.digitSeparator)){const t=Number(e);if(!isNaN(t))return t}return e}function H(e){return null!=e&&"object"==typeof e&&"fieldsIndex"in e&&"geometryType"in e&&"getField"in e&&"load"in e&&"loaded"in e&&"objectIdField"in e&&"spatialReference"in e&&"type"in e&&("feature"===e.type||"scene"===e.type||"sublayer"===e.type)&&"when"in e}function B(e){return null!=e&&"object"==typeof e&&"createQuery"in e&&"queryFeatureCount"in e&&"queryObjectIds"in e&&"queryRelatedFeatures"in e&&"queryRelatedFeaturesCount"in e&&"relationships"in e}function J(e){return H(e)&&B(e)}function K(e){return!!e&&"object"==typeof e&&"sourceLayer"in e&&J(e.sourceLayer)}function V(e,t){const{fieldInfos:n,fieldName:r,preventPlacesFormatting:l,layer:u,timeZone:s}=t,c=Y(n,r),d=$(u,r);if(c&&!a(r)){const t=d?.type,n=c.format?.dateFormat;if("date"===t||"date-only"===t||"time-only"===t||"timestamp-offset"===t||n)return f(e,{format:n,fieldType:t,timeZoneOptions:{layerTimeZone:u&&"preferredTimeZone"in u?u.preferredTimeZone:null,viewTimeZone:s,datesInUnknownTimezone:!(!u||!("datesInUnknownTimezone"in u))&&!!u.datesInUnknownTimezone}})}const p=c?.format;return"string"==typeof e&&a(r)&&p?W(e,p):"string"==typeof(e=_(e,p))||null==e||null==p?ae(e):i(e,l?{...o(p),minimumFractionDigits:0,maximumFractionDigits:20}:o(p))}function W(e,t){return e=e.trim(),/\d{2}-\d{2}/.test(e)?e:e.includes(",")?X(e,",",", ",t):e.includes(";")?X(e,";","; ",t):e.includes(" ")?X(e," "," ",t):i(Number(e),o(t))}function X(e,t,n,r){return e.trim().split(t).map((e=>i(Number(e),o(r)))).join(n)}function Y(e,t){if(e?.length&&t)return e.find((e=>e.fieldName?.toLowerCase()===t.toLowerCase()))}function ee({fieldName:e,graphic:t,layer:n}){if(de(e))return null;if(!n||"function"!=typeof n.getFeatureType)return null;const{typeIdField:r}=n;if(!r||e!==r)return null;const i=n.getFeatureType(t);return i?i.name:null}function te({fieldName:e,value:t,graphic:n,layer:r}){if(de(e))return null;if(!r||"function"!=typeof r.getFieldDomain)return null;const i=n&&r.getFieldDomain(e,{feature:n});return i&&"coded-value"===i.type?i.getName(t):null}function ne(e,t,n,i){const{creatorField:o,creationDateField:a,editorField:l,editDateField:u}=e;if(!t)return;const s=p(i&&"preferredTimeZone"in i?i.preferredTimeZone:null,!(!i||!("datesInUnknownTimezone"in i))&&!!i.datesInUnknownTimezone,n,Z,"date"),f={...Z,...s},c=t[u];if("number"==typeof c){const e=t[l];return{type:"edit",date:r(c,f),user:e}}const d=t[a];if("number"==typeof d){const e=t[o];return{type:"create",date:r(d,f),user:e}}return null}function re(e,t){const n=new Map;if(!e)return n;for(const r of e){if(!r.fieldName)continue;const e=L(r.fieldName,t);r.fieldName=e,n.set(e.toLowerCase(),r)}return n}function ie(e){const t=[];if(!e)return t;const{fieldInfos:n,content:r}=e;return n&&t.push(...n),r&&Array.isArray(r)?(r.forEach((e=>{if("fields"===e.type){const n=e?.fieldInfos;n&&t.push(...n)}})),t):t}function oe(e){return e.replaceAll(w,(e=>`&#${e.charCodeAt(0)};`))}function ae(e){return"string"==typeof e?e.replaceAll(T,'<br class="esri-text-new-line" />'):e}function le(e){const{value:t,fieldName:n,fieldInfos:r,fieldInfoMap:i,layer:o,graphic:a,timeZone:l}=e;if(null==t)return"";const s=te({fieldName:n,value:t,graphic:a,layer:o});if(s)return s;const d=ee({fieldName:n,graphic:a,layer:o});if(d)return d;if(i.get(n.toLowerCase()))return V(t,{fieldInfos:r||Array.from(i.values()),fieldName:n,layer:o,timeZone:l});const p=o?.fieldsIndex?.get(n);return p&&(c(p)||u(p))?f(t,{fieldType:p.type,timeZoneOptions:{layerTimeZone:o&&"preferredTimeZone"in o?o.preferredTimeZone:null,viewTimeZone:l,datesInUnknownTimezone:!(!o||!("datesInUnknownTimezone"in o))&&!!o.datesInUnknownTimezone}}):ae(t)}function ue({fieldInfos:e,attributes:t,layer:n,graphic:r,fieldInfoMap:i,relatedInfos:o,timeZone:a}){const l={};return o?.forEach((t=>me({attributes:l,relatedInfo:t,fieldInfoMap:i,fieldInfos:e,layer:n,timeZone:a}))),t&&Object.keys(t).forEach((o=>{const u=t[o];l[o]=le({fieldName:o,fieldInfos:e,fieldInfoMap:i,layer:n,value:u,graphic:r,timeZone:a})})),l}async function se(e,t){const{layer:n,graphic:r,outFields:i,objectIds:o,returnGeometry:a,spatialReference:l}=e,u=o[0];if("number"!=typeof u&&"string"!=typeof u){const e="Could not query required fields for the specified feature. The feature's ID is invalid.",t={layer:n,graphic:r,objectId:u,requiredFields:i};return m().warn(e,t),null}if(!s(n)?.operations?.supportsQuery){const e="The specified layer cannot be queried. The following fields will not be available.",t={layer:n,graphic:r,requiredFields:i,returnGeometry:a};return m().warn(e,t),null}const f=n.createQuery();f.objectIds=o,f.outFields=i?.length?i:[n.objectIdField],f.returnGeometry=!!a,f.returnZ=!!a,f.returnM=!!a,f.outSpatialReference=l;return(await n.queryFeatures(f,t)).features[0]}async function fe(e){if(!e.expressionInfos?.length)return!1;const t=await d(),{arcadeUtils:{hasGeometryFunctions:n}}=t;return n(e)}async function ce({graphic:e,popupTemplate:t,layer:n,spatialReference:r},i){if(!n||!t)return;if("function"==typeof n.load&&await n.load(i),!e.attributes)return;const o=n.objectIdField,a=e.attributes[o];if(null==a)return;const u=[a],s=await t.getRequiredFields(n.fieldsIndex),f=l(s,e),c=f?[]:s.includes(o)?s:[...s,o],d=t.returnGeometry||await fe(t);if(f&&!d)return;const p=await se({layer:n,graphic:e,outFields:c,objectIds:u,returnGeometry:d,spatialReference:r},i);p&&(p.geometry&&(e.geometry=p.geometry),p.attributes&&(e.attributes={...e.attributes,...p.attributes}))}function de(e=""){return!!e&&e.includes(j)}function pe(e){return e?`${j}${e.layerId}/${e.fieldName}`:""}function ye({attributes:e,graphic:t,relatedInfo:n,fieldInfos:r,fieldInfoMap:i,layer:o,timeZone:a}){e&&t&&n&&Object.keys(t.attributes).forEach((l=>{const u=pe({layerId:n.relation.id.toString(),fieldName:l}),s=t.attributes[l];e[u]=le({fieldName:u,fieldInfos:r,fieldInfoMap:i,layer:o,value:s,graphic:t,timeZone:a})}))}function me({attributes:e,relatedInfo:t,fieldInfoMap:n,fieldInfos:r,layer:i,timeZone:o}){e&&t&&(t.relatedFeatures?.forEach((a=>ye({attributes:e,graphic:a,relatedInfo:t,fieldInfoMap:n,fieldInfos:r,layer:i,timeZone:o}))),t.relatedStatsFeatures?.forEach((a=>ye({attributes:e,graphic:a,relatedInfo:t,fieldInfoMap:n,fieldInfos:r,layer:i,timeZone:o}))))}const ge=e=>{if(!e)return!1;const t=e.toUpperCase();return t.includes("CURRENT_TIMESTAMP")||t.includes("CURRENT_DATE")||t.includes("CURRENT_TIME")},he=({layer:e,method:t,query:n,definitionExpression:r})=>{if(!e.capabilities?.query?.supportsCacheHint||"attachments"===t)return;const i=null!=n.where?n.where:null,o=null!=n.geometry?n.geometry:null;ge(r)||ge(i)||"extent"===o?.type||"tile"===n.resultType||(n.cacheHint=!0)},Ie=({query:e,layer:t,method:n})=>{he({layer:t,method:n,query:e,definitionExpression:`${t.definitionExpression} ${t.serviceDefinitionExpression??""}`})},be=({queryPayload:e,layer:t,method:n})=>{he({layer:t,method:n,query:e,definitionExpression:`${t.definitionExpression} ${t.serviceDefinitionExpression??""}`})};function Te(e,t,n){return e&&t&&n?"sublayer"===t.type?we({layers:t.layer?.sublayers,layer:t,relationship:n})||we({layers:t.layer?.subtables,layer:t,relationship:n}):we({layers:e.allLayers,layer:t,relationship:n})||we({layers:e.allTables,layer:t,relationship:n}):null}function we({relationship:{relatedTableId:e},layer:t,layers:n}){if(!n)return null;const r=n.filter(J);if("sublayer"===t.type)return r.find((n=>n!==t&&n.id===e));const i="scene"===t.type&&t.associatedLayer?t.associatedLayer.url:t.url;return i?r.find((n=>n!==t&&n.url===i&&n.layerId===e)):null}function Fe(e){const t=e.getObjectId();return null!=t?`oid:${t}`:`uid:${e.uid}`}export{ae as applyTextFormattingHTML,re as createFieldInfoMap,Te as findRelatedLayer,P as fixTokens,ue as formatAttributes,ne as formatEditInfo,V as formatValueToFieldInfo,ie as getAllFieldInfos,Y as getFieldInfo,M as getFieldInfoLabel,L as getFixedFieldName,R as getFixedFieldNames,Fe as getHighlightKeyForFeature,E as getSourceLayer,v as graphicCallback,oe as htmlEntities,A as isExpressionField,H as isFeatureSupportedLayer,K as isGraphicForRelatableFeatureSupportedLayer,J as isRelatableFeatureSupportedLayer,B as isRelatableLayer,de as isRelatedField,Ie as preLayerQueryCallback,be as preRequestCallback,se as querySourceLayer,ce as queryUpdatedFeature,x as shouldOpenInNewTab,z as substituteAttributes,D as substituteFieldsInLinksAndAttributes};
5
+ import e from"../../../core/Logger.js";import{replace as t}from"../../../core/string.js";import{convertDateFormatToIntlOptions as n,formatDate as r}from"../../../intl/date.js";import{formatNumber as i,convertNumberFormatToIntlOptions as o}from"../../../intl/number.js";import{isRasterPixelValueField as a,featureHasFields as l,isTimeOnlyField as u}from"../../../layers/support/fieldUtils.js";import{getEffectiveLayerCapabilities as s}from"../../../layers/support/layerUtils.js";import{formatAnyDate as f,isAnyDateField as c}from"../../../smartMapping/support/utils.js";import{loadArcade as d}from"../../../support/arcadeOnDemand.js";import{getTimeZoneFormattingOptions as p}from"../../../time/timeZoneUtils.js";const y="esri.widgets.Feature.support.featureUtils",m=()=>e.getLogger(y),g=/href=(""|'')/gi,h=/(\{([^{\r\n]+)\})/g,b=/'/g,I=/^\s*expression\//i,T=/(\n)/gi,w=/[\u00A0-\u9999<>&]/gim,F=/href\s*=\s*(?:"([^"]+)"|'([^']+)')/gi,N=/^(?:mailto:|tel:)/,j="relationships/",Z=n("short-date-short-time");function L(e){if(null!=e)return(e.sourceLayer||e.layer)??void 0}async function E({type:e,value:t,event:n}){try{return"function"==typeof t?t(n):t}catch(r){return void m().error("error",`An error occurred when calling the "${e}" function`,{error:r,graphic:n.graphic,value:t})}}function v(e=""){if(e)return!N.test(e.trim().toLowerCase())}function x(e){return!!e&&I.test(e)}function A(e,t){if(!t||!x(t)||!e)return;const n=t.replace(I,"").toLowerCase();return e.find((({name:e})=>e.toLowerCase()===n))}function C(e,t){const n=A(t,e?.fieldName);return n?n.title||null:e?e.label||e.fieldName:null}function M(e,t){const n=t.get(e.toLowerCase());return`{${n?.fieldName||e}}`}function U(e){return e.replaceAll(g,"")}function q(e,t){const n=$(t,e);return n?n.name:e}function R(e,t){return e&&e.map((e=>q(e,t)))}function $(e,t){return e&&"function"==typeof e.getField&&t?e.getField(t)??null:null}function k(e){return`${e}`.trim()}function D({attributes:e,globalAttributes:t,layer:n,text:r,expressionAttributes:i,fieldInfoMap:o}){return r?z({formattedAttributes:t,template:Q(r,{...t,...i,...e},n),fieldInfoMap:o}):""}function z({formattedAttributes:e,template:n,fieldInfoMap:r}){return k(U(t(t(n,(e=>M(e,r))),e)))}function O(e,t,n=!1){const r=t[e];if("string"==typeof r){const i="%27",o=(n?encodeURIComponent(r):r).replaceAll(b,i);t[e]=o}}function G(e,t=!1){const n={...e};return Object.keys(n).forEach((e=>O(e,n,t))),n}function S(e,n,r){const i=(n=k(n))&&"{"!==n[0];return t(e,G(r,i||!1))}function P(e,t){return e.replaceAll(h,((e,n,r)=>{const i=$(t,r);return i?`{${i.name}}`:n}))}function Q(e,t,n){const r=P(e,n);return r?r.replaceAll(F,((e,n,r)=>S(e,n||r,t))):r}function _(e,t){if("string"==typeof e&&t&&null==t.dateFormat&&(null!=t.places||null!=t.digitSeparator)){const t=Number(e);if(!isNaN(t))return t}return e}function H(e){return null!=e&&"object"==typeof e&&"fieldsIndex"in e&&"geometryType"in e&&"getField"in e&&"load"in e&&"loaded"in e&&"objectIdField"in e&&"spatialReference"in e&&"type"in e&&("feature"===e.type||"scene"===e.type||"sublayer"===e.type)&&"when"in e}function B(e){return null!=e&&"object"==typeof e&&"createQuery"in e&&"queryFeatureCount"in e&&"queryObjectIds"in e&&"queryRelatedFeatures"in e&&"queryRelatedFeaturesCount"in e&&"relationships"in e}function J(e){return H(e)&&B(e)}function K(e){return!!e&&"object"==typeof e&&"sourceLayer"in e&&J(e.sourceLayer)}function V(e,t){const{fieldInfos:n,fieldName:r,preventPlacesFormatting:l,layer:u,timeZone:s}=t,c=Y(n,r),d=$(u,r);if(c&&!a(r)){const t=d?.type,n=c.format?.dateFormat;if("date"===t||"date-only"===t||"time-only"===t||"timestamp-offset"===t||n)return f(e,{format:n,fieldType:t,timeZoneOptions:{layerTimeZone:u&&"preferredTimeZone"in u?u.preferredTimeZone:null,viewTimeZone:s,datesInUnknownTimezone:!(!u||!("datesInUnknownTimezone"in u))&&!!u.datesInUnknownTimezone}})}const p=c?.format;return"string"==typeof e&&a(r)&&p?W(e,p):"string"==typeof(e=_(e,p))||null==e||null==p?ae(e):i(e,l?{...o(p),minimumFractionDigits:0,maximumFractionDigits:20}:o(p))}function W(e,t){return e=e.trim(),/\d{2}-\d{2}/.test(e)?e:e.includes(",")?X(e,",",", ",t):e.includes(";")?X(e,";","; ",t):e.includes(" ")?X(e," "," ",t):i(Number(e),o(t))}function X(e,t,n,r){return e.trim().split(t).map((e=>i(Number(e),o(r)))).join(n)}function Y(e,t){if(e?.length&&t)return e.find((e=>e.fieldName?.toLowerCase()===t.toLowerCase()))}function ee({fieldName:e,graphic:t,layer:n}){if(de(e))return null;if(!n||"function"!=typeof n.getFeatureType)return null;const{typeIdField:r}=n;if(!r||e!==r)return null;const i=n.getFeatureType(t);return i?i.name:null}function te({fieldName:e,value:t,graphic:n,layer:r}){if(de(e))return null;if(!r||"function"!=typeof r.getFieldDomain)return null;const i=n&&r.getFieldDomain(e,{feature:n});return i&&"coded-value"===i.type?i.getName(t):null}function ne(e,t,n,i){const{creatorField:o,creationDateField:a,editorField:l,editDateField:u}=e;if(!t)return;const s=p(i&&"preferredTimeZone"in i?i.preferredTimeZone:null,!(!i||!("datesInUnknownTimezone"in i))&&!!i.datesInUnknownTimezone,n,Z,"date"),f={...Z,...s},c=t[u];if("number"==typeof c){const e=t[l];return{type:"edit",date:r(c,f),user:e}}const d=t[a];if("number"==typeof d){const e=t[o];return{type:"create",date:r(d,f),user:e}}return null}function re(e,t){const n=new Map;if(!e)return n;for(const r of e){if(!r.fieldName)continue;const e=q(r.fieldName,t);r.fieldName=e,n.set(e.toLowerCase(),r)}return n}function ie(e){const t=[];if(!e)return t;const{fieldInfos:n,content:r}=e;return n&&t.push(...n),r&&Array.isArray(r)?(r.forEach((e=>{if("fields"===e.type){const n=e?.fieldInfos;n&&t.push(...n)}})),t):t}function oe(e){return e.replaceAll(w,(e=>`&#${e.charCodeAt(0)};`))}function ae(e){return"string"==typeof e?e.replaceAll(T,'<br class="esri-text-new-line" />'):e}function le(e){const{value:t,fieldName:n,fieldInfos:r,fieldInfoMap:i,layer:o,graphic:a,timeZone:l}=e;if(null==t)return"";const s=te({fieldName:n,value:t,graphic:a,layer:o});if(s)return s;const d=ee({fieldName:n,graphic:a,layer:o});if(d)return d;if(i.get(n.toLowerCase()))return V(t,{fieldInfos:r||Array.from(i.values()),fieldName:n,layer:o,timeZone:l});const p=o?.fieldsIndex?.get(n);return p&&(c(p)||u(p))?f(t,{fieldType:p.type,timeZoneOptions:{layerTimeZone:o&&"preferredTimeZone"in o?o.preferredTimeZone:null,viewTimeZone:l,datesInUnknownTimezone:!(!o||!("datesInUnknownTimezone"in o))&&!!o.datesInUnknownTimezone}}):ae(t)}function ue({fieldInfos:e,attributes:t,layer:n,graphic:r,fieldInfoMap:i,relatedInfos:o,timeZone:a}){const l={};return o?.forEach((t=>me({attributes:l,relatedInfo:t,fieldInfoMap:i,fieldInfos:e,layer:n,timeZone:a}))),t&&Object.keys(t).forEach((o=>{const u=t[o];l[o]=le({fieldName:o,fieldInfos:e,fieldInfoMap:i,layer:n,value:u,graphic:r,timeZone:a})})),l}async function se(e,t){const{layer:n,graphic:r,outFields:i,objectIds:o,returnGeometry:a,spatialReference:l}=e,u=o[0];if("number"!=typeof u&&"string"!=typeof u){const e="Could not query required fields for the specified feature. The feature's ID is invalid.",t={layer:n,graphic:r,objectId:u,requiredFields:i};return m().warn(e,t),null}if(!s(n)?.operations?.supportsQuery){const e="The specified layer cannot be queried. The following fields will not be available.",t={layer:n,graphic:r,requiredFields:i,returnGeometry:a};return m().warn(e,t),null}const f=n.createQuery();f.objectIds=o,f.outFields=i?.length?i:[n.objectIdField],f.returnGeometry=!!a,f.returnZ=!!a,f.returnM=!!a,f.outSpatialReference=l;return(await n.queryFeatures(f,t)).features[0]}async function fe(e){if(!e.expressionInfos?.length)return!1;const t=await d(),{arcadeUtils:{hasGeometryFunctions:n}}=t;return n(e)}async function ce({graphic:e,popupTemplate:t,layer:n,spatialReference:r},i){if(!n||!t)return;if("function"==typeof n.load&&await n.load(i),!e.attributes)return;const o=n.objectIdField,a=e.attributes[o];if(null==a)return;const u=[a],s=await t.getRequiredFields(n.fieldsIndex),f=l(s,e),c=f?[]:s.includes(o)?s:[...s,o],d=t.returnGeometry||await fe(t);if(f&&!d)return;const p=await se({layer:n,graphic:e,outFields:c,objectIds:u,returnGeometry:d,spatialReference:r},i);p&&(p.geometry&&(e.geometry=p.geometry),p.attributes&&(e.attributes={...e.attributes,...p.attributes}))}function de(e=""){return!!e&&e.includes(j)}function pe(e){return e?`${j}${e.layerId}/${e.fieldName}`:""}function ye({attributes:e,graphic:t,relatedInfo:n,fieldInfos:r,fieldInfoMap:i,layer:o,timeZone:a}){e&&t&&n&&Object.keys(t.attributes).forEach((l=>{const u=pe({layerId:n.relation.id.toString(),fieldName:l}),s=t.attributes[l];e[u]=le({fieldName:u,fieldInfos:r,fieldInfoMap:i,layer:o,value:s,graphic:t,timeZone:a})}))}function me({attributes:e,relatedInfo:t,fieldInfoMap:n,fieldInfos:r,layer:i,timeZone:o}){e&&t&&(t.relatedFeatures?.forEach((a=>ye({attributes:e,graphic:a,relatedInfo:t,fieldInfoMap:n,fieldInfos:r,layer:i,timeZone:o}))),t.relatedStatsFeatures?.forEach((a=>ye({attributes:e,graphic:a,relatedInfo:t,fieldInfoMap:n,fieldInfos:r,layer:i,timeZone:o}))))}const ge=e=>{if(!e)return!1;const t=e.toUpperCase();return t.includes("CURRENT_TIMESTAMP")||t.includes("CURRENT_DATE")||t.includes("CURRENT_TIME")},he=({layer:e,method:t,query:n,definitionExpression:r})=>{if(!e.capabilities?.query?.supportsCacheHint||"attachments"===t)return;const i=null!=n.where?n.where:null,o=null!=n.geometry?n.geometry:null;ge(r)||ge(i)||"extent"===o?.type||"tile"===n.resultType||(n.cacheHint=!0)},be=({query:e,layer:t,method:n})=>{he({layer:t,method:n,query:e,definitionExpression:`${t.definitionExpression} ${t.serviceDefinitionExpression??""}`})},Ie=({queryPayload:e,layer:t,method:n})=>{he({layer:t,method:n,query:e,definitionExpression:`${t.definitionExpression} ${t.serviceDefinitionExpression??""}`})};function Te(e,t,n){return e&&t&&n?"sublayer"===t.type?we({layers:t.layer?.sublayers,map:e,relatedLayer:t,relationship:n})||we({layers:t.layer?.subtables,map:e,relatedLayer:t,relationship:n}):we({layers:e.allLayers,map:e,relatedLayer:t,relationship:n})||we({layers:e.allTables,map:e,relatedLayer:t,relationship:n}):null}function we({map:e,relationship:t,relationship:{relatedTableId:n},relatedLayer:r,layers:i}){if(!i)return null;for(const o of i){if("map-image"===o.type){const n=we({layers:o.sublayers,map:e,relatedLayer:r,relationship:t})||we({layers:o.subtables,map:e,relatedLayer:r,relationship:t});if(n)return n;continue}if(!J(o))continue;if("sublayer"===r.type){if(o!==r&&o.id===n)return o.isTable?e?.allTables.find((e=>"feature"===e.type&&e.layerId===o.id&&e.url===o.layer?.url))??o:o;continue}const i="scene"===r.type&&r.associatedLayer?r.associatedLayer.url:r.url;if(!i)return null;if("sublayer"!==o.type){if(o!==r&&o.url===i&&o.layerId===n)return o}else if(o!==r&&o.layer?.url===i&&o.id===n)return o}return null}function Fe(e){const t=e.getObjectId();return null!=t?`oid:${t}`:`uid:${e.uid}`}export{ae as applyTextFormattingHTML,re as createFieldInfoMap,Te as findRelatedLayer,P as fixTokens,ue as formatAttributes,ne as formatEditInfo,V as formatValueToFieldInfo,ie as getAllFieldInfos,Y as getFieldInfo,C as getFieldInfoLabel,q as getFixedFieldName,R as getFixedFieldNames,Fe as getHighlightKeyForFeature,L as getSourceLayer,E as graphicCallback,oe as htmlEntities,x as isExpressionField,H as isFeatureSupportedLayer,K as isGraphicForRelatableFeatureSupportedLayer,J as isRelatableFeatureSupportedLayer,B as isRelatableLayer,de as isRelatedField,be as preLayerQueryCallback,Ie as preRequestCallback,se as querySourceLayer,ce as queryUpdatedFeature,v as shouldOpenInNewTab,z as substituteAttributes,D as substituteFieldsInLinksAndAttributes};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.31/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import"../../intl.js";import t from"../../core/Collection.js";import{referenceSetter as i}from"../../core/collectionUtils.js";import{deprecatedFunction as s}from"../../core/deprecate.js";import o from"../../core/Handles.js";import r from"../../core/Logger.js";import{debounce as n,ignoreAbortErrors as l}from"../../core/promiseUtils.js";import{watch as a,initial as h,on as d}from"../../core/reactiveUtils.js";import{property as m}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{subclass as c}from"../../core/accessorSupport/decorators/subclass.js";import{getLowerCaseDefaultHiddenFields as g}from"../../layers/support/fieldUtils.js";import{getTimeZoneFormattingOptions as p,system as u}from"../../time/timeZoneUtils.js";import{highlightsSupported as f}from"../../views/support/layerViewUtils.js";import{isSelectableLayer as y}from"../../views/support/selectionUtils.js";import b from"./ActionColumn.js";import _ from"./AttachmentsColumn.js";import C from"./FieldColumn.js";import v from"./RelationshipColumn.js";import I from"./Grid/Column.js";import w from"./Grid/Grid.js";import E from"./Grid/GridViewModel.js";import T from"./Grid/GroupColumn.js";import j from"./support/FeatureStore.js";import S from"./support/TableTemplate.js";import{isIFeatureTableSupportedLayerWithRelationships as R,findRelatedLayer as F,uniqueColumnNames as U}from"./support/tableUtils.js";import"../support/widgetUtils.js";import{messageBundle as O}from"../support/decorators/messageBundle.js";import{onLocaleChange as L}from"../../intl/locale.js";import{convertDateFormatToIntlOptions as x}from"../../intl/date.js";import{fetchMessageBundle as A}from"../../intl/messages.js";let z=class extends E{constructor(e){super(e),this._debounceRefresh=n((()=>this._refresh())),this._highlights=new o,this.actionColumnConfig=null,this.attachmentsEnabled=!1,this.autoRefreshEnabled=!0,this.columns=new t,this.dataProvider=async(e,t)=>{const{layer:i,store:s}=this;if(!t)return;if(!i||!s)return void(t&&t([]));await i.load();const o=this._sortOrdersToLayerOrderByFields(i,e.sortOrders);s.set({orderByFields:o});const{objectIds:r}=this;if(this.filterBySelectionEnabled&&!this.highlightIds.length||1===r.length&&-1===r.items[0])return void t([]);"loaded"!==s.state&&"loading"!==s.state&&await s.load();const n=await s.fetchItems(e);t&&t(n)},this.editingEnabled=!1,this.grid=null,this.highlightEnabled=!0,this.itemIdPath="objectId",this.layer=null,this.messages=null,this.messagesCommon=null,this.messagesURIUtils=null,this.relationshipColumnConfigs=null,this.returnGeometryEnabled=!1,this.selectionSource="table",this.showRelatedTableCallback=null,this.store=null,this.tableTemplate=null,this.tableTemplateOverride=null,this.timeZone=null,this.view=null,this._onLayerRefresh=this._onLayerRefresh.bind(this),this._set("store",new j),this._set("grid",new w({itemIdPath:this.itemIdPath,viewModel:this}))}initialize(){const e=async()=>{this.messages=await A("esri/widgets/FeatureTable/t9n/FeatureTable"),this.messagesCommon=await A("esri/t9n/common"),this.messagesURIUtils=await A("esri/widgets/support/t9n/uriUtils")};e(),this.addHandles([L((()=>{e(),this._generateColumns()})),a((()=>[this.messages,this.messagesCommon,this.messagesURIUtils]),(()=>{const e=this.messages;this.grid&&(this.grid.messages=e),this.columns.forEach((t=>{t.messages=e,t.messagesCommon=this.messagesCommon,t.messagesURIUtils=this.messagesURIUtils})),this._requestContentUpdate()}),h),d((()=>this.highlightIds),"change",(e=>this._onHighlightIdsChange(e)),{onListenerAdd:()=>this._syncSelection(),onListenerRemove:()=>this._highlights.removeAll()}),a((()=>this.attachmentsEnabled),(e=>{const{attachmentsColumn:t,columns:i}=this;this.store.attachmentsEnabled=e,t&&i.remove(t),e&&i.length&&i.add(this._generateAttachmentsColumn(),this._getIndexOfFirstFrozenToEndColumn())})),a((()=>this._viewSelection),(()=>{this._viewSelectionReady&&(this.highlightIds.items=this._viewSelection)})),a((()=>[this._tableHighlightsReady,this._viewSelectionReady]),(()=>this._syncSelection())),a((()=>this.returnGeometryEnabled),(e=>this.store.returnGeometry=e)),a((()=>this.layer),(async(e,t)=>{const i=this.grid;i&&(i.clearSort(),e&&t&&await this.reset()),this._drainColumns(),this.store.layer=e,e&&(e.loaded?this._onLayerLoad():e.load().catch((()=>{})))})),a((()=>this.layer?.loaded),(e=>e&&this._onLayerLoad())),a((()=>this.store.state),(e=>{"loaded"===e&&(this.grid?.scrollToTop(),this.refreshCellContent())})),a((()=>this._effectiveTableTemplate),(()=>this.layer?.loaded&&this._generateColumns())),a((()=>[this.timeZone,this.view?.timeZone]),(()=>{this.columns.forEach((e=>{if("field"in e&&e.field){const{timeZone:t,timeZoneName:i}=this._getTimeZoneInfoForFieldColumn(e.field);e.set({timeZone:t,timeZoneName:i})}})),this._requestContentUpdate()})),a((()=>this.editingEnabled),(e=>{this.editorColumns.forEach((t=>t.tableEditingEnabled=e)),this._requestContentUpdate()})),a((()=>this.layer?.definitionExpression),((e,t)=>(e||t)&&"loaded"===this.store.state&&this.reset())),a((()=>this.layer?.timeExtent),((e,t)=>(e||t)&&!this.timeExtent&&"loaded"===this.store.state&&this.reset())),d((()=>this.layer),"refresh",(e=>this._onLayerRefresh(e))),d((()=>this.grid),["cell-click","cell-pointerover","cell-pointerout","cell-keydown"],(({index:e,item:t,native:i,path:s,type:o})=>{const r=t?.feature;this.emit(o,{feature:r,index:e,native:i,type:o,fieldName:s??void 0,objectId:r?.getObjectId()})})),a((()=>this.actionColumnConfig),(e=>{const{actionColumn:t,columns:i}=this;t?e?t.set(e):i.remove(t):e&&i.length&&i.add(this._generateActionColumn(),!1!==e.frozenToEnd?void 0:this._getIndexOfFirstFrozenToEndColumn())})),a((()=>[this.relationshipColumnConfigs?.length,this.relatedRecordsEnabled]),(([e,t])=>{const{columns:i,relationshipColumns:s}=this;s.length&&i.removeMany(s),i.length&&t&&i.addMany(this._generateRelationshipColumns(),this._getIndexOfFirstFrozenToEndColumn())})),d((()=>this.objectIds),"change",(()=>this._onObjectIdsChange()),{onListenerAdd:()=>this._onObjectIdsChange()})])}destroy(){this._drainColumns(),this._highlights.removeAll(),this._highlights.destroy(),this.grid?.destroy(),this.columns.destroyed||this.columns.destroy(),this.layer=null,this.view=null}get _defaultHiddenFields(){return g(this.layer)}get _effectiveTableTemplate(){return this.tableTemplateOverride||this.tableTemplate}get _highlightableLayerView(){const e=this.layerView;return f(e)?e:null}get _layerWithRelationships(){const e=this.layer;if(!R(e))return null;const t=e.effectiveCapabilities??e.capabilities;return t?.queryRelated?.supportsCount&&t.queryRelated.supportsPagination?e:null}get _relationshipInfos(){const{_layerWithRelationships:e,relatedRecordsEnabled:t,relationships:i,view:s}=this,o=[];return t&&e?.loaded&&s?.map&&i?.length?(i.forEach((t=>{const i=F(e,s,t);i&&(i.load(),o.push({layer:e,relatedLayer:i,relationshipId:t.id}))})),o):o}get _selectionManager(){const{view:e}=this;return!e||e.destroyed?null:e.selectionManager?.sources?.length?e.selectionManager:null}get _selectableLayer(){const{layer:e}=this;return y(e)&&this._selectionManager?.sources.includes(e)?e:null}get _tableHighlightsReady(){return!("table"!==this.selectionSource||!this.highlightEnabled||!this._highlightableLayerView)}get _viewSelection(){const{_selectableLayer:e}=this;return e?this._selectionManager?.getSelection(e)??[]:[]}get _viewSelectionReady(){return!(!this.layer||"view"!==this.selectionSource||!this._selectionManager)}get activeFilters(){const{filterGeometry:e,objectIds:i,filterBySelectionEnabled:s,highlightIds:o}=this,r=new t;return e&&r.push({type:"geometry",geometry:e}),s?r.push({type:"selection",objectIds:o.toArray()}):i.length&&r.push({type:"objectId",objectIds:i.toArray()}),r}get activeSortOrders(){return this.grid?.sortOrders?this.grid.sortOrders.map((({path:e,direction:t})=>({fieldName:e,direction:t}))).filter((e=>e.fieldName&&e.direction)):[]}get filterGeometry(){return this._get("filterGeometry")}set filterGeometry(e){this.store.filterGeometry=e,this._set("filterGeometry",e)}get filterBySelectionEnabled(){return!!this._get("filterBySelectionEnabled")}set filterBySelectionEnabled(e){const{objectIds:t}=this,i=t.length;e?(i&&(t.removeAll(),this._logWarning("Selection filter has been applied with an objectID filter. Object ID filter has been removed.")),this.filterGeometry&&this._logWarning("Selection filter has been applied with a geometry filter. Results may appear inconsistent"),this._syncObjectIdsWithStore(this.highlightIds.toArray())):i||this._syncObjectIdsWithStore(null),this._set("filterBySelectionEnabled",e)}get hiddenFields(){return this._get("hiddenFields")??new t}set hiddenFields(e){this._set("hiddenFields",i(e,this._get("hiddenFields"),t))}get isQueryingOrSyncing(){const{store:e}=this;return e?.syncing||e?.querying}get layerView(){return this.view?.allLayerViews.find((e=>e.layer===this.layer))||null}get objectIds(){return this._get("objectIds")??new t}set objectIds(e){this._set("objectIds",i(e,this._get("objectIds"),t))}get relatedRecordsEnabled(){return!!this._get("relatedRecordsEnabled")}set relatedRecordsEnabled(e){this.store.relatedRecordsEnabled=e,this._set("relatedRecordsEnabled",e)}get relationship(){const e=this.relationshipConfig?.relationshipId;return null==e?null:this.relationships?.find((({id:t})=>t===e))}get relationshipConfig(){return this._get("relationshipConfig")}set relationshipConfig(e){this.objectIds.removeAll(),this.filterBySelectionEnabled=!1,this.store.relationshipConfig=e,this._set("relationshipConfig",e)}get relationships(){const{layer:e}=this;return R(e)?e.relationships:null}set timeExtent(e){this._set("timeExtent",e),this.store.timeExtent=e}async deleteSelection(){const e=this.highlightIds.toArray();if(!e?.length)return;const{deleteFeatureResults:t}=await this.store.deleteRowsByObjectId(e),i=t.filter((e=>!e.error)).map((e=>e.objectId));i.length&&(this.highlightIds.removeMany(i),await this.refresh())}filterBySelection(){this.filterBySelectionEnabled?this._logWarning("Property 'filterBySelectionEnabled' is already 'true'. This method has no effect."):(s(r.getLogger(this),"`FeatureTable.filterBySelection` is deprecated in favor of 'filterBySelectionEnabled' and 'objectIds'",{replacement:"FeatureTable.filterBySelectionEnabled or FeatureTable.objectIds",version:"4.30",warnOnce:!0}),this.objectIds.addMany(this.highlightIds.toArray()))}getObjectIdIndex(e){return this.store?.getItemIndexByObjectId(e)}getValue(e,t){const i=this.store.getItemByObjectId(e);return i?.feature?.attributes[t]}async refresh(){return l(this._debounceRefresh())}refreshCellContent(){this._requestContentUpdate()}async reset(){await(this.grid?.reset())}scrollToIndex(e){this.grid?.scrollToIndex(e)}clearSelectionFilter(){s(r.getLogger(this),"`FeatureTable.clearSelectionFilter` is deprecated in favor of 'filterBySelectionEnabled' and 'objectIds'",{replacement:"FeatureTable.filterBySelectionEnabled or FeatureTable.objectIds",version:"4.30",warnOnce:!0}),this.objectIds.removeAll()}async zoomToSelection(){const{layer:e,view:t}=this,i=this.highlightIds.toArray();if(!e||!t||!i.length)return;const s=e.createQuery();s.objectIds=i,s.returnGeometry=!0;const o=await e.queryFeatures(s);try{await t.goTo(o.features)}catch(r){"AbortError"!==r.name&&console.error(r)}}_requestContentUpdate(){this.grid?.requestContentUpdate()}async _refresh(){await this.store.refreshLayerInfo();const e=this.highlightIds.toArray();if(e.length){(await this.store.verifyFeaturesByObjectId(e)).forEach(((t,i)=>{t||this.highlightIds.remove(e[i])}))}this.grid?.refreshPageCache()}_onLayerLoad(){const{layer:e}=this;if(!e)return;const t=e.capabilities.query?.maxRecordCount;t&&t<this.pageSize&&this.grid&&(this.grid.pageSize=t),this.store.load(),this._generateColumns()}_onLayerRefresh(e){this.autoRefreshEnabled&&e.dataChanged&&this.refresh()}_generateColumns(){this._drainColumns();const e=this._effectiveTableTemplate?.columnTemplates,t=[],i=e?this._generateColumnsFromTemplates(e):this._generateDefaultFieldColumns();t.push(...i),t.length&&this.attachmentsEnabled&&t.push(this._generateAttachmentsColumn()),t.length&&this.relatedRecordsEnabled&&this._relationshipInfos.length&&t.push(...this._generateRelationshipColumns()),this.actionColumnConfig&&t.push(this._generateActionColumn()),t.sort(((e,t)=>e.frozen&&t.frozen||e.frozenToEnd&&t.frozenToEnd?0:e.frozen||t.frozenToEnd?-1:0)),this.columns.addMany([...t])}_generateColumnsFromTemplates(e){const{editingEnabled:t,_effectiveTableTemplate:i,grid:s,layer:o,messages:r,messagesCommon:n,messagesURIUtils:l,store:a,timeZone:h}=this,d=o?.fields??[],m=[],c=e=>d.find((t=>e.fieldName.toLowerCase()===t.name?.toLowerCase()));return e.forEach((e=>{const{autoWidth:d,direction:g,flexGrow:p,fieldName:u,formatFunction:f,frozen:y,frozenToEnd:b,icon:_,initialSortPriority:v,invalid:w,label:E,menuConfig:j,resizable:S,sortable:R,textAlign:F,textWrap:U,type:O,width:L}=e;if(!O)return void this._logWarning("Property 'type' is missing from the provided template. Skipped generating a column for this template.");if(y&&b)return void this._logWarning("Both 'frozen' and 'frozenToEnd' cannot be true for a single template. Skipped generating a column for this template.");const x=!1===e.visible;if("group"===O){if(!e.columnTemplates?.length)return void this._logWarning("Group columns must contain column templates. Skipped generating a column for this template.");if(!e.label)return void this._logWarning("Group columns require a label. Skipped generating a column for this template.");const t=this._generateColumnsFromTemplates(e.columnTemplates),i=x||this._isFieldHidden(e.label);m.push(new T({autoWidth:d,columns:t,flexGrow:p,frozen:y,frozenToEnd:b,grid:s,hidden:i,icon:_,invalid:w,label:E,menuConfig:j,messages:r,messagesCommon:n,messagesURIUtils:l,resizable:S,textAlign:F,textWrap:U,width:L}))}if(!u)return void this._logWarning("'fieldName' was missing from the provided template. Skipped generating a column for this template.");const A=x||this._isFieldHidden(u);if("column"===O&&m.push(new I({autoWidth:d,direction:g,fieldName:u,flexGrow:p,formatFunction:f,frozen:y,frozenToEnd:b,grid:s,hidden:A,icon:_,initialSortPriority:v,invalid:w,label:E,menuConfig:j,messages:r,messagesCommon:n,messagesURIUtils:l,resizable:S,sortable:R,textAlign:F,textWrap:U,timeZone:h,width:L})),"field"===O){const h=c(e);if(!h)return void this._logWarning("A valid 'field' could not be found for the provided template. Skipped generating a column for this template.");const{editable:u,required:I}=e,T=i?.expressionInfos||null,{timeZone:O,timeZoneName:x}=this._getTimeZoneInfoForFieldColumn(h);m.push(new C({autoWidth:d,direction:g,editable:u,expressionInfos:T,field:h,fieldName:h.name,flexGrow:p,formatFunction:f,frozen:y,frozenToEnd:b,grid:s,hidden:A,icon:_,initialSortPriority:v,invalid:w,label:E,layer:o,messages:r,messagesCommon:n,messagesURIUtils:l,menuConfig:j,sortable:R,store:a,required:I,resizable:S,tableEditingEnabled:t,template:e,textAlign:F,textWrap:U,timeZone:O,timeZoneName:x,width:L}))}})),m}_generateDefaultFieldColumns(){const{editingEnabled:e,grid:t,layer:i,messages:s,messagesCommon:o,messagesURIUtils:r,store:n}=this;return(i?.fields??[]).map((l=>{const{timeZone:a,timeZoneName:h}=this._getTimeZoneInfoForFieldColumn(l),d=l.name;return new C({field:l,fieldName:d,grid:t,hidden:this._isFieldHidden(d),layer:i,messages:s,messagesCommon:o,messagesURIUtils:r,store:n,tableEditingEnabled:e,timeZone:a,timeZoneName:h})}))}_getTimeZoneInfoForFieldColumn(e){const{layer:t,timeZone:i,view:s}=this;return!t||"date"!==e?.type&&"timestamp-offset"!==e?.type?{timeZone:void 0,timeZoneName:void 0}:p(t.preferredTimeZone||null,!!t.datesInUnknownTimezone,i??s?.timeZone??u,x("short-time"),e.type)}_generateAttachmentsColumn(){return new _({hidden:this._isFieldHidden(U.attachments),messages:this.messages})}_generateRelationshipColumns(){const{_layerWithRelationships:e,_relationshipInfos:t,grid:i,messages:s,messagesCommon:o,messagesURIUtils:r,relationshipColumnConfigs:n}=this,l=[];if(!e)return l;const a={grid:i,messages:s,messagesCommon:o,messagesURIUtils:r};return n?n.forEach((e=>{const{relationshipId:i}=e,s=t.find((e=>e.relationshipId===i));s&&l.push(new v({...e,...a,fieldName:`${U.relationship}-${i}`,layer:s.relatedLayer,relatedLayer:s.layer,relationshipId:i,showRelatedTableCallback:e=>this._onShowRelatedTable(e)}))})):t.forEach((({layer:e,relatedLayer:t,relationshipId:i})=>{l.push(new v({...a,fieldName:`${U.relationship}-${i}`,layer:t,relatedLayer:e,relationshipId:i,showRelatedTableCallback:e=>this._onShowRelatedTable(e)}))})),l}_generateActionColumn(){return new b({hidden:this._isFieldHidden(U.action),...this.actionColumnConfig})}_sortOrdersToLayerOrderByFields(e,t=[]){const i=t.map((e=>e.path)),s=t.filter(((e,t)=>{const s=i.indexOf(e.path)===t,o=null!=e.direction;return s&&o})).map((({path:e,direction:t})=>`${e} ${t?.toUpperCase()}`));return!s.length&&!e.objectIdField&&e.fields?.length&&e.fields[0]?.name&&s.push(`${e.fields[0].name} ASC`),s}_isFieldHidden(e){const t=e?.toLowerCase();return(this.hiddenFields??this._defaultHiddenFields).some((e=>e.toLowerCase()===t))}_addTableHighlight(e){this._highlightableLayerView&&this._highlights.add(this._highlightableLayerView.highlight(e),e)}_removeTableHighlight(e){this._highlights.remove(e)}_syncSelection(){this._highlights.removeAll(),this._tableHighlightsReady?this.highlightIds.forEach((e=>this._addTableHighlight(e))):this._viewSelectionReady&&(this.highlightIds.items=this._viewSelection)}_appendToViewSelection(e){const{_selectableLayer:t}=this;t&&this._selectionManager?.appendToSelection(t,e)}_removeFromViewSelection(e){const{_selectableLayer:t}=this;t&&this._selectionManager?.removeFromSelection(t,e)}_onHighlightIdsChange(e){const{added:t,removed:i}=e;this._tableHighlightsReady?(i.forEach((e=>this._removeTableHighlight(e))),t.forEach((e=>this._addTableHighlight(e)))):this._viewSelectionReady&&(this._removeFromViewSelection(i),this._appendToViewSelection(t)),this.filterBySelectionEnabled&&this._syncObjectIdsWithStore(this.highlightIds.toArray())}_onShowRelatedTable(e){const{highlightIds:t}=this,{feature:i,layer:s,relatedLayer:o,relationshipId:r}=e,n=i.getObjectId()??i.attributes[o.objectIdField];if(null!=n){if(t.removeAll(),t.add(n),this.showRelatedTableCallback)return void this.showRelatedTableCallback(e);this.emit("show-related-table",{layer:s,relatedLayer:o,relationshipId:r,feature:i})}}_onObjectIdsChange(){const e=this.objectIds.toArray();e.length&&this.filterBySelectionEnabled&&(this.filterBySelectionEnabled=!1,this._logWarning("Object ID filter was applied while a selection filter was applied. Selection filter has been removed.")),this._syncObjectIdsWithStore(e)}_syncObjectIdsWithStore(e){this.store.objectIds=e,this.grid?.refreshPageCache()}_drainColumns(){this.columns.drain((e=>!e.destroyed&&e.destroy()))}_getIndexOfFirstFrozenToEndColumn(){const e=this.columns.findIndex((e=>e.frozenToEnd));return e>-1?e:void 0}_logWarning(e){r.getLogger(this).warn(e)}};e([m()],z.prototype,"_defaultHiddenFields",null),e([m()],z.prototype,"_effectiveTableTemplate",null),e([m()],z.prototype,"_highlights",void 0),e([m()],z.prototype,"_highlightableLayerView",null),e([m({readOnly:!0})],z.prototype,"_layerWithRelationships",null),e([m()],z.prototype,"_relationshipInfos",null),e([m()],z.prototype,"_selectionManager",null),e([m()],z.prototype,"_selectableLayer",null),e([m()],z.prototype,"_tableHighlightsReady",null),e([m()],z.prototype,"_viewSelection",null),e([m()],z.prototype,"_viewSelectionReady",null),e([m()],z.prototype,"actionColumnConfig",void 0),e([m()],z.prototype,"activeFilters",null),e([m({readOnly:!0})],z.prototype,"activeSortOrders",null),e([m()],z.prototype,"attachmentsEnabled",void 0),e([m()],z.prototype,"autoRefreshEnabled",void 0),e([m({readOnly:!0})],z.prototype,"columns",void 0),e([m()],z.prototype,"dataProvider",void 0),e([m()],z.prototype,"editingEnabled",void 0),e([m()],z.prototype,"filterGeometry",null),e([m()],z.prototype,"filterBySelectionEnabled",null),e([m({readOnly:!0})],z.prototype,"grid",void 0),e([m()],z.prototype,"hiddenFields",null),e([m()],z.prototype,"highlightEnabled",void 0),e([m()],z.prototype,"isQueryingOrSyncing",null),e([m({readOnly:!0})],z.prototype,"itemIdPath",void 0),e([m()],z.prototype,"layer",void 0),e([m()],z.prototype,"layerView",null),e([m()],z.prototype,"messages",void 0),e([m(),O("esri/t9n/common")],z.prototype,"messagesCommon",void 0),e([m(),O("esri/widgets/support/t9n/uriUtils")],z.prototype,"messagesURIUtils",void 0),e([m()],z.prototype,"objectIds",null),e([m()],z.prototype,"relatedRecordsEnabled",null),e([m()],z.prototype,"relationship",null),e([m()],z.prototype,"relationshipColumnConfigs",void 0),e([m()],z.prototype,"relationshipConfig",null),e([m()],z.prototype,"relationships",null),e([m()],z.prototype,"returnGeometryEnabled",void 0),e([m()],z.prototype,"selectionSource",void 0),e([m()],z.prototype,"showRelatedTableCallback",void 0),e([m({readOnly:!0,type:j})],z.prototype,"store",void 0),e([m({type:S})],z.prototype,"tableTemplate",void 0),e([m()],z.prototype,"tableTemplateOverride",void 0),e([m()],z.prototype,"timeExtent",null),e([m()],z.prototype,"timeZone",void 0),e([m()],z.prototype,"view",void 0),z=e([c("esri.widgets.FeatureTable.FeatureTableViewModel")],z);const B=z;export{B as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import"../../intl.js";import t from"../../core/Collection.js";import{referenceSetter as i}from"../../core/collectionUtils.js";import{deprecatedFunction as s}from"../../core/deprecate.js";import o from"../../core/Handles.js";import r from"../../core/Logger.js";import{debounce as n,ignoreAbortErrors as l}from"../../core/promiseUtils.js";import{watch as a,initial as h,on as d}from"../../core/reactiveUtils.js";import{property as m}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{subclass as c}from"../../core/accessorSupport/decorators/subclass.js";import{getLowerCaseDefaultHiddenFields as g}from"../../layers/support/fieldUtils.js";import{getTimeZoneFormattingOptions as p,system as u}from"../../time/timeZoneUtils.js";import{highlightsSupported as f}from"../../views/support/layerViewUtils.js";import{isSelectableLayer as y}from"../../views/support/selectionUtils.js";import b from"./ActionColumn.js";import _ from"./AttachmentsColumn.js";import v from"./FieldColumn.js";import C from"./RelationshipColumn.js";import I from"./Grid/Column.js";import w from"./Grid/Grid.js";import E from"./Grid/GridViewModel.js";import j from"./Grid/GroupColumn.js";import T from"./support/FeatureStore.js";import S from"./support/TableTemplate.js";import{isIFeatureTableSupportedLayerWithRelationships as R,findRelatedLayer as F,uniqueColumnNames as U}from"./support/tableUtils.js";import"../support/widgetUtils.js";import{messageBundle as O}from"../support/decorators/messageBundle.js";import{onLocaleChange as L}from"../../intl/locale.js";import{convertDateFormatToIntlOptions as x}from"../../intl/date.js";import{fetchMessageBundle as A}from"../../intl/messages.js";let Z=class extends E{constructor(e){super(e),this._debounceRefresh=n((()=>this._refresh())),this._highlights=new o,this.actionColumnConfig=null,this.attachmentsEnabled=!1,this.autoRefreshEnabled=!0,this.columns=new t,this.dataProvider=async(e,t)=>{const{layer:i,store:s}=this;if(!t)return;if(!i||!s)return void(t&&t([]));await i.load();const o=this._sortOrdersToLayerOrderByFields(i,e.sortOrders);s.set({orderByFields:o});const{objectIds:r}=this;if(this.filterBySelectionEnabled&&!this.highlightIds.length||1===r.length&&-1===r.items[0])return void t([]);"loaded"!==s.state&&"loading"!==s.state&&await s.load();const n=await s.fetchItems(e);t&&t(n)},this.editingEnabled=!1,this.grid=null,this.highlightEnabled=!0,this.itemIdPath="objectId",this.layer=null,this.messages=null,this.messagesCommon=null,this.messagesURIUtils=null,this.relationshipColumnConfigs=null,this.returnGeometryEnabled=!1,this.returnMEnabled=!1,this.returnZEnabled=!1,this.selectionSource="table",this.showRelatedTableCallback=null,this.store=null,this.tableTemplate=null,this.tableTemplateOverride=null,this.timeZone=null,this.view=null,this._onLayerRefresh=this._onLayerRefresh.bind(this),this._set("store",new T),this._set("grid",new w({itemIdPath:this.itemIdPath,viewModel:this}))}initialize(){const e=async()=>{this.messages=await A("esri/widgets/FeatureTable/t9n/FeatureTable"),this.messagesCommon=await A("esri/t9n/common"),this.messagesURIUtils=await A("esri/widgets/support/t9n/uriUtils")};e(),this.addHandles([L((()=>{e(),this._generateColumns()})),a((()=>[this.messages,this.messagesCommon,this.messagesURIUtils]),(()=>{const e=this.messages;this.grid&&(this.grid.messages=e),this.columns.forEach((t=>{t.messages=e,t.messagesCommon=this.messagesCommon,t.messagesURIUtils=this.messagesURIUtils})),this._requestContentUpdate()}),h),d((()=>this.highlightIds),"change",(e=>this._onHighlightIdsChange(e)),{onListenerAdd:()=>this._syncSelection(),onListenerRemove:()=>this._highlights.removeAll()}),a((()=>this.attachmentsEnabled),(e=>{const{attachmentsColumn:t,columns:i}=this;this.store.attachmentsEnabled=e,t&&i.remove(t),e&&i.length&&i.add(this._generateAttachmentsColumn(),this._getIndexOfFirstFrozenToEndColumn())})),a((()=>this._viewSelection),(()=>{this._viewSelectionReady&&(this.highlightIds.items=this._viewSelection)})),a((()=>[this._tableHighlightsReady,this._viewSelectionReady]),(()=>this._syncSelection())),a((()=>[this.returnGeometryEnabled,this.returnMEnabled,this.returnZEnabled]),(()=>{const{store:e}=this;e.set({returnGeometry:this.returnGeometryEnabled,returnM:this.returnMEnabled,returnZ:this.returnZEnabled})})),a((()=>this.layer),(async(e,t)=>{const i=this.grid;i&&(i.clearSort(),e&&t&&await this.reset()),this._drainColumns(),this.store.layer=e,e&&(e.loaded?this._onLayerLoad():e.load().catch((()=>{})))})),a((()=>this.layer?.loaded),(e=>e&&this._onLayerLoad())),a((()=>this.store.state),(e=>{"loaded"===e&&(this.grid?.scrollToTop(),this.refreshCellContent())})),a((()=>this._effectiveTableTemplate),(()=>this.layer?.loaded&&this._generateColumns())),a((()=>[this.timeZone,this.view?.timeZone]),(()=>{this.columns.forEach((e=>{if("field"in e&&e.field){const{timeZone:t,timeZoneName:i}=this._getTimeZoneInfoForFieldColumn(e.field);e.set({timeZone:t,timeZoneName:i})}})),this._requestContentUpdate()})),a((()=>this.editingEnabled),(e=>{this.editorColumns.forEach((t=>t.tableEditingEnabled=e)),this._requestContentUpdate()})),a((()=>this.layer?.definitionExpression),((e,t)=>(e||t)&&"loaded"===this.store.state&&this.reset())),a((()=>this.layer?.timeExtent),((e,t)=>(e||t)&&!this.timeExtent&&"loaded"===this.store.state&&this.reset())),d((()=>this.layer),"refresh",(e=>this._onLayerRefresh(e))),d((()=>this.grid),["cell-click","cell-pointerover","cell-pointerout","cell-keydown"],(({index:e,item:t,native:i,path:s,type:o})=>{const r=t?.feature;this.emit(o,{feature:r,index:e,native:i,type:o,fieldName:s??void 0,objectId:r?.getObjectId()})})),a((()=>this.actionColumnConfig),(e=>{const{actionColumn:t,columns:i}=this;t?e?t.set(e):i.remove(t):e&&i.length&&i.add(this._generateActionColumn(),!1!==e.frozenToEnd?void 0:this._getIndexOfFirstFrozenToEndColumn())})),a((()=>[this.relationshipColumnConfigs?.length,this.relatedRecordsEnabled]),(([e,t])=>{const{columns:i,relationshipColumns:s}=this;s.length&&i.removeMany(s),i.length&&t&&i.addMany(this._generateRelationshipColumns(),this._getIndexOfFirstFrozenToEndColumn())})),d((()=>this.objectIds),"change",(()=>this._onObjectIdsChange()),{onListenerAdd:()=>this._onObjectIdsChange()})])}destroy(){this._drainColumns(),this._highlights.removeAll(),this._highlights.destroy(),this.grid?.destroy(),this.columns.destroyed||this.columns.destroy(),this.layer=null,this.view=null}get _defaultHiddenFields(){return g(this.layer)}get _effectiveTableTemplate(){return this.tableTemplateOverride||this.tableTemplate}get _highlightableLayerView(){const e=this.layerView;return f(e)?e:null}get _layerWithRelationships(){const e=this.layer;if(!R(e))return null;const t=e.effectiveCapabilities??e.capabilities;return t?.queryRelated?.supportsCount&&t.queryRelated.supportsPagination?e:null}get _relationshipInfos(){const{_layerWithRelationships:e,relatedRecordsEnabled:t,relationships:i,view:s}=this,o=[];return t&&e?.loaded&&s?.map&&i?.length?(i.forEach((t=>{const i=F(e,s,t);i&&(i.load(),o.push({layer:e,relatedLayer:i,relationshipId:t.id}))})),o):o}get _selectionManager(){const{view:e}=this;return!e||e.destroyed?null:e.selectionManager?.sources?.length?e.selectionManager:null}get _selectableLayer(){const{layer:e}=this;return y(e)&&this._selectionManager?.sources.includes(e)?e:null}get _tableHighlightsReady(){return!("table"!==this.selectionSource||!this.highlightEnabled||!this._highlightableLayerView)}get _viewSelection(){const{_selectableLayer:e}=this;return e?this._selectionManager?.getSelection(e)??[]:[]}get _viewSelectionReady(){return!(!this.layer||"view"!==this.selectionSource||!this._selectionManager)}get activeFilters(){const{filterGeometry:e,objectIds:i,filterBySelectionEnabled:s,highlightIds:o}=this,r=new t;return e&&r.push({type:"geometry",geometry:e}),s?r.push({type:"selection",objectIds:o.toArray()}):i.length&&r.push({type:"objectId",objectIds:i.toArray()}),r}get activeSortOrders(){return this.grid?.sortOrders?this.grid.sortOrders.map((({path:e,direction:t})=>({fieldName:e,direction:t}))).filter((e=>e.fieldName&&e.direction)):[]}get filterGeometry(){return this._get("filterGeometry")}set filterGeometry(e){this.store.filterGeometry=e,this._set("filterGeometry",e)}get filterBySelectionEnabled(){return!!this._get("filterBySelectionEnabled")}set filterBySelectionEnabled(e){const{objectIds:t}=this,i=t.length;e?(i&&(t.removeAll(),this._logWarning("Selection filter has been applied with an objectID filter. Object ID filter has been removed.")),this.filterGeometry&&this._logWarning("Selection filter has been applied with a geometry filter. Results may appear inconsistent"),this._syncObjectIdsWithStore(this.highlightIds.toArray())):i||this._syncObjectIdsWithStore(null),this._set("filterBySelectionEnabled",e)}get hiddenFields(){return this._get("hiddenFields")??new t}set hiddenFields(e){this._set("hiddenFields",i(e,this._get("hiddenFields"),t))}get isQueryingOrSyncing(){const{store:e}=this;return e?.syncing||e?.querying}get layerView(){const{layer:e,view:t}=this;if(!e||!t)return null;const i="sublayer"===e.type?e.parent:e;return t.allLayerViews.find((e=>e.layer===i))}get objectIds(){return this._get("objectIds")??new t}set objectIds(e){this._set("objectIds",i(e,this._get("objectIds"),t))}get relatedRecordsEnabled(){return!!this._get("relatedRecordsEnabled")}set relatedRecordsEnabled(e){this.store.relatedRecordsEnabled=e,this._set("relatedRecordsEnabled",e)}get relationship(){const e=this.relationshipConfig?.relationshipId;return null==e?null:this.relationships?.find((({id:t})=>t===e))}get relationshipConfig(){return this._get("relationshipConfig")}set relationshipConfig(e){this.objectIds.removeAll(),this.filterBySelectionEnabled=!1,this.store.relationshipConfig=e,this._set("relationshipConfig",e)}get relationships(){const{layer:e}=this;return R(e)?e.relationships:null}set timeExtent(e){this._set("timeExtent",e),this.store.timeExtent=e}async deleteSelection(){const e=this.highlightIds.toArray();if(!e?.length)return;const{deleteFeatureResults:t}=await this.store.deleteRowsByObjectId(e),i=t.filter((e=>!e.error)).map((e=>e.objectId));i.length&&(this.highlightIds.removeMany(i),await this.refresh())}filterBySelection(){this.filterBySelectionEnabled?this._logWarning("Property 'filterBySelectionEnabled' is already 'true'. This method has no effect."):(s(r.getLogger(this),"`FeatureTable.filterBySelection` is deprecated in favor of 'filterBySelectionEnabled' and 'objectIds'",{replacement:"FeatureTable.filterBySelectionEnabled or FeatureTable.objectIds",version:"4.30",warnOnce:!0}),this.objectIds.addMany(this.highlightIds.toArray()))}getObjectIdIndex(e){return this.store?.getItemIndexByObjectId(e)}getValue(e,t){const i=this.store.getItemByObjectId(e);return i?.feature?.attributes[t]}async refresh(){return l(this._debounceRefresh())}refreshCellContent(){this._requestContentUpdate()}async reset(){await(this.grid?.reset())}scrollToIndex(e){this.grid?.scrollToIndex(e)}clearSelectionFilter(){s(r.getLogger(this),"`FeatureTable.clearSelectionFilter` is deprecated in favor of 'filterBySelectionEnabled' and 'objectIds'",{replacement:"FeatureTable.filterBySelectionEnabled or FeatureTable.objectIds",version:"4.30",warnOnce:!0}),this.objectIds.removeAll()}async zoomToSelection(){const{layer:e,view:t}=this,i=this.highlightIds.toArray();if(!e||!t||!i.length)return;const s=e.createQuery();s.objectIds=i,s.returnGeometry=!0;const o=await e.queryFeatures(s);try{await t.goTo(o.features)}catch(r){"AbortError"!==r.name&&console.error(r)}}_requestContentUpdate(){this.grid?.requestContentUpdate()}async _refresh(){await this.store.refreshLayerInfo();const e=this.highlightIds.toArray();if(e.length){(await this.store.verifyFeaturesByObjectId(e)).forEach(((t,i)=>{t||this.highlightIds.remove(e[i])}))}this.grid?.refreshPageCache()}_onLayerLoad(){const{layer:e}=this;if(!e)return;const t=e.capabilities.query?.maxRecordCount;t&&t<this.pageSize&&this.grid&&(this.grid.pageSize=t),this.store.load(),this._generateColumns()}_onLayerRefresh(e){this.autoRefreshEnabled&&e.dataChanged&&this.refresh()}_generateColumns(){this._drainColumns();const e=this._effectiveTableTemplate?.columnTemplates,t=e?this._generateColumnsFromTemplates(e):this._generateDefaultFieldColumns();t.length&&this.attachmentsEnabled&&t.push(this._generateAttachmentsColumn()),t.length&&this.relatedRecordsEnabled&&this._relationshipInfos.length&&t.push(...this._generateRelationshipColumns()),this.actionColumnConfig&&t.push(this._generateActionColumn()),t.sort(((e,t)=>e.frozen&&t.frozen||e.frozenToEnd&&t.frozenToEnd?0:e.frozen||t.frozenToEnd?-1:0)),this.columns.addMany(t)}_generateColumnsFromTemplates(e){const{editingEnabled:t,_effectiveTableTemplate:i,grid:s,layer:o,messages:r,messagesCommon:n,messagesURIUtils:l,store:a,timeZone:h}=this,d=o?.fields??[],m=[],c=e=>d.find((t=>e.fieldName.toLowerCase()===t.name?.toLowerCase()));return e.forEach((e=>{const{autoWidth:d,direction:g,flexGrow:p,fieldName:u,formatFunction:f,frozen:y,frozenToEnd:b,icon:_,initialSortPriority:C,invalid:w,label:E,menuConfig:T,resizable:S,sortable:R,textAlign:F,textWrap:U,type:O,width:L}=e;if(!O)return void this._logWarning("Property 'type' is missing from the provided template. Skipped generating a column for this template.");if(y&&b)return void this._logWarning("Both 'frozen' and 'frozenToEnd' cannot be true for a single template. Skipped generating a column for this template.");const x=!1===e.visible;if("group"===O){if(!e.columnTemplates?.length)return void this._logWarning("Group columns must contain column templates. Skipped generating a column for this template.");if(!e.label)return void this._logWarning("Group columns require a label. Skipped generating a column for this template.");const t=this._generateColumnsFromTemplates(e.columnTemplates),i=x||this._isFieldHidden(e.label);m.push(new j({autoWidth:d,columns:t,flexGrow:p,frozen:y,frozenToEnd:b,grid:s,hidden:i,icon:_,invalid:w,label:E,menuConfig:T,messages:r,messagesCommon:n,messagesURIUtils:l,resizable:S,textAlign:F,textWrap:U,width:L}))}if(!u)return void this._logWarning("'fieldName' was missing from the provided template. Skipped generating a column for this template.");const A=x||this._isFieldHidden(u);if("column"===O&&m.push(new I({autoWidth:d,direction:g,fieldName:u,flexGrow:p,formatFunction:f,frozen:y,frozenToEnd:b,grid:s,hidden:A,icon:_,initialSortPriority:C,invalid:w,label:E,menuConfig:T,messages:r,messagesCommon:n,messagesURIUtils:l,resizable:S,sortable:R,textAlign:F,textWrap:U,timeZone:h,width:L})),"field"===O){const h=c(e);if(!h)return void this._logWarning("A valid 'field' could not be found for the provided template. Skipped generating a column for this template.");const{editable:u,required:I}=e,j=i?.expressionInfos||null,{timeZone:O,timeZoneName:x}=this._getTimeZoneInfoForFieldColumn(h);m.push(new v({autoWidth:d,direction:g,editable:u,expressionInfos:j,field:h,fieldName:h.name,flexGrow:p,formatFunction:f,frozen:y,frozenToEnd:b,grid:s,hidden:A,icon:_,initialSortPriority:C,invalid:w,label:E,layer:o,messages:r,messagesCommon:n,messagesURIUtils:l,menuConfig:T,sortable:R,store:a,required:I,resizable:S,tableEditingEnabled:t,template:e,textAlign:F,textWrap:U,timeZone:O,timeZoneName:x,width:L}))}})),m}_generateDefaultFieldColumns(){const{editingEnabled:e,grid:t,layer:i,messages:s,messagesCommon:o,messagesURIUtils:r,store:n}=this,l=[];return i?.fields.length?(i.fields.forEach((a=>{if("geometry"===a.type)return;const{timeZone:h,timeZoneName:d}=this._getTimeZoneInfoForFieldColumn(a),m=a.name;l.push(new v({field:a,fieldName:m,grid:t,hidden:this._isFieldHidden(m),layer:i,messages:s,messagesCommon:o,messagesURIUtils:r,store:n,tableEditingEnabled:e,timeZone:h,timeZoneName:d}))})),l):l}_getTimeZoneInfoForFieldColumn(e){const{layer:t,timeZone:i,view:s}=this;return!t||"date"!==e?.type&&"timestamp-offset"!==e?.type?{timeZone:void 0,timeZoneName:void 0}:p(t.preferredTimeZone||null,!!t.datesInUnknownTimezone,i??s?.timeZone??u,x("short-time"),e.type)}_generateAttachmentsColumn(){return new _({hidden:this._isFieldHidden(U.attachments),messages:this.messages})}_generateRelationshipColumns(){const{_layerWithRelationships:e,_relationshipInfos:t,grid:i,messages:s,messagesCommon:o,messagesURIUtils:r,relationshipColumnConfigs:n}=this,l=[];if(!e)return l;const a={grid:i,messages:s,messagesCommon:o,messagesURIUtils:r};return n?n.forEach((e=>{const{relationshipId:i}=e,s=t.find((e=>e.relationshipId===i));s&&l.push(new C({...e,...a,fieldName:`${U.relationship}-${i}`,layer:s.relatedLayer,relatedLayer:s.layer,relationshipId:i,showRelatedTableCallback:e=>this._onShowRelatedTable(e)}))})):t.forEach((({layer:e,relatedLayer:t,relationshipId:i})=>{l.push(new C({...a,fieldName:`${U.relationship}-${i}`,layer:t,relatedLayer:e,relationshipId:i,showRelatedTableCallback:e=>this._onShowRelatedTable(e)}))})),l}_generateActionColumn(){return new b({hidden:this._isFieldHidden(U.action),...this.actionColumnConfig})}_sortOrdersToLayerOrderByFields(e,t=[]){const i=t.map((e=>e.path)),s=t.filter(((e,t)=>{const s=i.indexOf(e.path)===t,o=null!=e.direction;return s&&o})).map((({path:e,direction:t})=>`${e} ${t?.toUpperCase()}`));return!s.length&&!e.objectIdField&&e.fields?.length&&e.fields[0]?.name&&s.push(`${e.fields[0].name} ASC`),s}_isFieldHidden(e){const t=e?.toLowerCase();return(this.hiddenFields??this._defaultHiddenFields).some((e=>e.toLowerCase()===t))}_addTableHighlight(e){const{_highlightableLayerView:t,layer:i}=this;if(t&&i){const s=this.store.getItemByObjectId(e),o="sublayer"===i.type&&s?.feature?s.feature:e;this._highlights.add(t.highlight(o),`${i.id}-${e}`)}}_removeTableHighlight(e){const{layer:t}=this;t&&this._highlights.remove(`${t.id}-${e}`)}_syncSelection(){this._highlights.removeAll(),this._tableHighlightsReady?this.highlightIds.forEach((e=>this._addTableHighlight(e))):this._viewSelectionReady&&(this.highlightIds.items=this._viewSelection)}_appendToViewSelection(e){const{_selectableLayer:t}=this;t&&this._selectionManager?.appendToSelection(t,e)}_removeFromViewSelection(e){const{_selectableLayer:t}=this;t&&this._selectionManager?.removeFromSelection(t,e)}_onHighlightIdsChange(e){const{added:t,removed:i}=e;this._tableHighlightsReady?(i.forEach((e=>this._removeTableHighlight(e))),t.forEach((e=>this._addTableHighlight(e)))):this._viewSelectionReady&&(this._removeFromViewSelection(i),this._appendToViewSelection(t)),this.filterBySelectionEnabled&&this._syncObjectIdsWithStore(this.highlightIds.toArray())}_onShowRelatedTable(e){const{highlightIds:t}=this,{feature:i,layer:s,relatedLayer:o,relationshipId:r}=e,n=i.getObjectId()??i.attributes[o.objectIdField];if(null!=n){if(t.removeAll(),t.add(n),this.showRelatedTableCallback)return void this.showRelatedTableCallback(e);this.emit("show-related-table",{layer:s,relatedLayer:o,relationshipId:r,feature:i})}}_onObjectIdsChange(){const e=this.objectIds.toArray();e.length&&this.filterBySelectionEnabled&&(this.filterBySelectionEnabled=!1,this._logWarning("Object ID filter was applied while a selection filter was applied. Selection filter has been removed.")),this._syncObjectIdsWithStore(e)}_syncObjectIdsWithStore(e){this.store.objectIds=e,this.grid?.refreshPageCache()}_drainColumns(){this.columns.drain((e=>!e.destroyed&&e.destroy()))}_getIndexOfFirstFrozenToEndColumn(){const e=this.columns.findIndex((e=>e.frozenToEnd));return e>-1?e:void 0}_logWarning(e){r.getLogger(this).warn(e)}};e([m()],Z.prototype,"_defaultHiddenFields",null),e([m()],Z.prototype,"_effectiveTableTemplate",null),e([m()],Z.prototype,"_highlights",void 0),e([m()],Z.prototype,"_highlightableLayerView",null),e([m({readOnly:!0})],Z.prototype,"_layerWithRelationships",null),e([m()],Z.prototype,"_relationshipInfos",null),e([m()],Z.prototype,"_selectionManager",null),e([m()],Z.prototype,"_selectableLayer",null),e([m()],Z.prototype,"_tableHighlightsReady",null),e([m()],Z.prototype,"_viewSelection",null),e([m()],Z.prototype,"_viewSelectionReady",null),e([m()],Z.prototype,"actionColumnConfig",void 0),e([m()],Z.prototype,"activeFilters",null),e([m({readOnly:!0})],Z.prototype,"activeSortOrders",null),e([m()],Z.prototype,"attachmentsEnabled",void 0),e([m()],Z.prototype,"autoRefreshEnabled",void 0),e([m({readOnly:!0})],Z.prototype,"columns",void 0),e([m()],Z.prototype,"dataProvider",void 0),e([m()],Z.prototype,"editingEnabled",void 0),e([m()],Z.prototype,"filterGeometry",null),e([m()],Z.prototype,"filterBySelectionEnabled",null),e([m({readOnly:!0})],Z.prototype,"grid",void 0),e([m()],Z.prototype,"hiddenFields",null),e([m()],Z.prototype,"highlightEnabled",void 0),e([m()],Z.prototype,"isQueryingOrSyncing",null),e([m({readOnly:!0})],Z.prototype,"itemIdPath",void 0),e([m()],Z.prototype,"layer",void 0),e([m()],Z.prototype,"layerView",null),e([m()],Z.prototype,"messages",void 0),e([m(),O("esri/t9n/common")],Z.prototype,"messagesCommon",void 0),e([m(),O("esri/widgets/support/t9n/uriUtils")],Z.prototype,"messagesURIUtils",void 0),e([m()],Z.prototype,"objectIds",null),e([m()],Z.prototype,"relatedRecordsEnabled",null),e([m()],Z.prototype,"relationship",null),e([m()],Z.prototype,"relationshipColumnConfigs",void 0),e([m()],Z.prototype,"relationshipConfig",null),e([m()],Z.prototype,"relationships",null),e([m()],Z.prototype,"returnGeometryEnabled",void 0),e([m()],Z.prototype,"returnMEnabled",void 0),e([m()],Z.prototype,"returnZEnabled",void 0),e([m()],Z.prototype,"selectionSource",void 0),e([m()],Z.prototype,"showRelatedTableCallback",void 0),e([m({readOnly:!0,type:T})],Z.prototype,"store",void 0),e([m({type:S})],Z.prototype,"tableTemplate",void 0),e([m()],Z.prototype,"tableTemplateOverride",void 0),e([m()],Z.prototype,"timeExtent",null),e([m()],Z.prototype,"timeZone",void 0),e([m()],Z.prototype,"view",void 0),Z=e([c("esri.widgets.FeatureTable.FeatureTableViewModel")],Z);const z=Z;export{z as default};