@arcgis/core 4.28.1 → 4.28.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (110) hide show
  1. package/assets/esri/core/workers/RemoteClient.js +1 -1
  2. package/assets/esri/core/workers/chunks/02e86a792dbe2fdec974.js +1 -0
  3. package/assets/esri/core/workers/chunks/{5386b166f2e5dc0d9143.js → 12797aa1d6a2b49abb3f.js} +1 -1
  4. package/assets/esri/core/workers/chunks/15852a47129b9e0d04c6.js +1 -0
  5. package/assets/esri/core/workers/chunks/1687431f7b233d950195.js +1 -0
  6. package/assets/esri/core/workers/chunks/{a1e16c33f1843dbdce26.js → 175bbe8a048f17dd482b.js} +1 -1
  7. package/assets/esri/core/workers/chunks/{d0119dff8771e749436a.js → 30d3b31df52d40e5b2e6.js} +1 -1
  8. package/assets/esri/core/workers/chunks/{768271a12dc7e1781447.js → 32fbd4355a4a649623a7.js} +1 -1
  9. package/assets/esri/core/workers/chunks/3dbc399eedd347b0fbbb.js +1 -0
  10. package/assets/esri/core/workers/chunks/{6bc1f6f8a2408fa4bb6a.js → 423672fe765083e1a0ec.js} +1 -1
  11. package/assets/esri/core/workers/chunks/{18e0c5bfeb1aa7213dfa.js → 4363f2cc3909c9258064.js} +1 -1
  12. package/assets/esri/core/workers/chunks/{d5fec54e98c8622349a4.js → 46ddc52fe9cdd573a614.js} +1 -1
  13. package/assets/esri/core/workers/chunks/4747741429e8ff7112bb.js +1 -0
  14. package/assets/esri/core/workers/chunks/49d958631bcd93f6333a.js +1 -0
  15. package/assets/esri/core/workers/chunks/4ae8308e5b9c7772a11f.js +1 -0
  16. package/assets/esri/core/workers/chunks/{da124ccd18d2745195fe.js → 4bd342f13002888b6467.js} +1 -1
  17. package/assets/esri/core/workers/chunks/{7756ed853b4ba54cd081.js → 5247c00088303da7ef3b.js} +1 -1
  18. package/assets/esri/core/workers/chunks/534726130ef1698ec89e.js +1 -0
  19. package/assets/esri/core/workers/chunks/551bc697e3e17983c2bc.js +1 -0
  20. package/assets/esri/core/workers/chunks/{65d8135c89ffdd17a3c1.js → 59d3f4c0d1a43180aff3.js} +1 -1
  21. package/assets/esri/core/workers/chunks/{2d92df1e3ba4f05e0510.js → 633b34a5817f1f719e22.js} +1 -1
  22. package/assets/esri/core/workers/chunks/{c7bd63103f101c09b1ea.js → 6996537249869c41e736.js} +1 -1
  23. package/assets/esri/core/workers/chunks/{41778f8c49febe1f9404.js → 6fa0cccd4f3e1fa71421.js} +1 -1
  24. package/assets/esri/core/workers/chunks/{78e49a70193e5adea17c.js → 77f557359a5033d7e429.js} +1 -1
  25. package/assets/esri/core/workers/chunks/{6334a8a7b671d4042108.js → 7beae29abdfae23b15cc.js} +1 -1
  26. package/assets/esri/core/workers/chunks/7cc56b132c46c5922dac.js +1 -0
  27. package/assets/esri/core/workers/chunks/80831e90fe1a52f8f982.js +1 -0
  28. package/assets/esri/core/workers/chunks/{ea9ae9d2aef01af90896.js → 80d9bb9f247ecdfa266f.js} +1 -1
  29. package/assets/esri/core/workers/chunks/846e5e51dc278bc3f80f.js +1 -0
  30. package/assets/esri/core/workers/chunks/{f73563b23fd8dc6cf2fe.js → 86df7357a2bac73c0ef4.js} +1 -1
  31. package/assets/esri/core/workers/chunks/8b541cbf82a5ba0317ee.js +1 -0
  32. package/assets/esri/core/workers/chunks/{08a98e85e86ce560d005.js → 8bd621693692050d76aa.js} +1 -1
  33. package/assets/esri/core/workers/chunks/{630b31a205d9db7147d0.js → 8cdece03397d01767593.js} +1 -1
  34. package/assets/esri/core/workers/chunks/{b9a726f3bbad6fd4d65a.js → 8e91be2e38010391e351.js} +1 -1
  35. package/assets/esri/core/workers/chunks/{cbddfcf57f72428a6992.js → 90f96a2ddfb25d851d4d.js} +1 -1
  36. package/assets/esri/core/workers/chunks/91a3181071874525ed44.js +1 -0
  37. package/assets/esri/core/workers/chunks/{2304b7456ced997904f6.js → 97fd7b82eec26449977e.js} +1 -1
  38. package/assets/esri/core/workers/chunks/{b7c81a5bbcdd94b8a7f6.js → 9979ff59a144fe1df80b.js} +1 -1
  39. package/assets/esri/core/workers/chunks/{0422c5160491fbcf01dc.js → 9d97a20f69047d0c47cc.js} +1 -1
  40. package/assets/esri/core/workers/chunks/9f0e8dd5c9bacfc0f03c.js +1 -0
  41. package/assets/esri/core/workers/chunks/{a8e4726c1db23324eb54.js → 9fc1206ad378f0829e0a.js} +1 -1
  42. package/assets/esri/core/workers/chunks/{09e8babe75407c2e64c4.js → a351ab5082772b267895.js} +1 -1
  43. package/assets/esri/core/workers/chunks/{43575b9acf9819f195f9.js → a3bbf5da4f7830d2a2a1.js} +1 -1
  44. package/assets/esri/core/workers/chunks/{b03eaba5fa75d6ef834a.js → a47f74fc959b11f029a5.js} +1 -1
  45. package/assets/esri/core/workers/chunks/{cb4b17f5cf96a9e36781.js → a8cf23c3a55c1834178c.js} +1 -1
  46. package/assets/esri/core/workers/chunks/{dd55151bfac60b0deaac.js → ac4636e82a103e2c27ca.js} +1 -1
  47. package/assets/esri/core/workers/chunks/ae7ba94af6d4fd97dd8b.js +1 -0
  48. package/assets/esri/core/workers/chunks/{4adf3a8c6b49c381a633.js → b0653f63745e756f55fe.js} +1 -1
  49. package/assets/esri/core/workers/chunks/{6867ed1860afb7aac536.js → b8f3a1d887c9e054feaa.js} +1 -1
  50. package/assets/esri/core/workers/chunks/{e06cd10b6f8f363b5131.js → bdc751a752a7ff1387de.js} +1 -1
  51. package/assets/esri/core/workers/chunks/{70aa04b09143b7dd2ecb.js → c2199fb8f7a54a0ef18a.js} +1 -1
  52. package/assets/esri/core/workers/chunks/c3f462d11ed570482e7a.js +1 -0
  53. package/assets/esri/core/workers/chunks/{830d99e6c58a52a58973.js → c8cb5fe1d23145c4842b.js} +1 -1
  54. package/assets/esri/core/workers/chunks/{1f87f22e00e3218661c6.js → ce53413dd3e2062e8378.js} +1 -1
  55. package/assets/esri/core/workers/chunks/de30ff1fcb6079178958.js +1 -0
  56. package/assets/esri/core/workers/chunks/e12090768e945091cc5d.js +1 -0
  57. package/assets/esri/core/workers/chunks/e3950975030412ff6e20.js +1 -0
  58. package/assets/esri/core/workers/chunks/e8b7d1c586aff229484c.js +1 -0
  59. package/assets/esri/core/workers/chunks/{710a6268de62003af825.js → e8d1f91dc97b42d0c4f6.js} +1 -1
  60. package/assets/esri/core/workers/chunks/{6747503826bfc94bc6c0.js → eb5213ffb83d83a4dd05.js} +1 -1
  61. package/assets/esri/core/workers/chunks/{020825b9c12f2b6386a7.js → f037e4f9877ea08ced9d.js} +1 -1
  62. package/assets/esri/core/workers/chunks/f520f093aa81d8ee1790.js +1 -0
  63. package/assets/esri/core/workers/chunks/{abcfe3bda6f40318b092.js → f7ccc6c681fc9218555c.js} +1 -1
  64. package/assets/esri/core/workers/chunks/{eea0fb90cd5cc80de388.js → fa750885bb27bbb03e7d.js} +1 -1
  65. package/assets/esri/core/workers/chunks/{e67c4b7ad06d8404895a.js → fab4ee57b7c5376c9ccd.js} +1 -1
  66. package/interfaces.d.ts +6 -6
  67. package/kernel.js +1 -1
  68. package/layers/StreamLayer.js +1 -1
  69. package/layers/support/LayerContingentValuesCache.js +1 -1
  70. package/layers/support/RangeDomain.js +1 -1
  71. package/layers/support/domainUtils.js +1 -1
  72. package/layers/support/fieldUtils.js +1 -1
  73. package/layers/support/labelFormatUtils.js +1 -1
  74. package/layers/support/vectorTileLayerLoader.js +1 -1
  75. package/package.json +1 -1
  76. package/renderers/support/RasterSymbolizer.js +1 -1
  77. package/support/revision.js +1 -1
  78. package/versionManagement/VersionManagementService.js +1 -1
  79. package/views/2d/engine/vectorTiles/TileManager.js +1 -1
  80. package/views/3d/layers/i3s/I3SIndex.js +1 -1
  81. package/widgets/ElevationProfile/support/chartUtils.js +1 -1
  82. package/widgets/FeatureForm/FieldInput.js +1 -1
  83. package/widgets/FeatureForm/featureFormUtils.js +1 -1
  84. package/widgets/FeatureForm.js +1 -1
  85. package/widgets/Search/support/layerSearchUtils.js +1 -1
  86. package/widgets/support/dataUtils.js +5 -0
  87. package/widgets/support/dateUtils.js +1 -1
  88. package/assets/esri/core/workers/chunks/02d235849ba93541d7ad.js +0 -1
  89. package/assets/esri/core/workers/chunks/0a3da4b73beeaacd4667.js +0 -1
  90. package/assets/esri/core/workers/chunks/10dc578a90e1194c8720.js +0 -1
  91. package/assets/esri/core/workers/chunks/1eb5468c7cf653338d53.js +0 -1
  92. package/assets/esri/core/workers/chunks/1f30ea1a598ddd2e5df3.js +0 -1
  93. package/assets/esri/core/workers/chunks/366cf9bba6989342e447.js +0 -1
  94. package/assets/esri/core/workers/chunks/3ac9001b19a90faf5573.js +0 -1
  95. package/assets/esri/core/workers/chunks/43f7d9366d06d69e7c50.js +0 -1
  96. package/assets/esri/core/workers/chunks/4672504d6fe649da19f2.js +0 -1
  97. package/assets/esri/core/workers/chunks/56a61a8bff08ae273de4.js +0 -1
  98. package/assets/esri/core/workers/chunks/580e7d3cbf6797a50ded.js +0 -1
  99. package/assets/esri/core/workers/chunks/6046be598e8c673eeb1f.js +0 -1
  100. package/assets/esri/core/workers/chunks/69c1c850af7ee33258e0.js +0 -1
  101. package/assets/esri/core/workers/chunks/8f7997e8e6ee9e56239f.js +0 -1
  102. package/assets/esri/core/workers/chunks/a160576f21ada91995ac.js +0 -1
  103. package/assets/esri/core/workers/chunks/a50ec5b647a160199cb2.js +0 -1
  104. package/assets/esri/core/workers/chunks/b138196d304883efd5f6.js +0 -1
  105. package/assets/esri/core/workers/chunks/b3f5e97b47e896c6008a.js +0 -1
  106. package/assets/esri/core/workers/chunks/c447f4bf0e5f012f8f9b.js +0 -1
  107. package/assets/esri/core/workers/chunks/c87e9280681c20d042b5.js +0 -1
  108. package/assets/esri/core/workers/chunks/cc86c8c88124d916e1b3.js +0 -1
  109. package/assets/esri/core/workers/chunks/d878bb6409df183ea0ce.js +0 -1
  110. package/assets/esri/core/workers/chunks/ef757269fb3fe0e74ef8.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.28/esri/copyright.txt for details.
4
4
  */
5
- import has from"../../../../core/has.js";import e from"../../../../core/PooledArray.js";import{isAbortError as t}from"../../../../core/promiseUtils.js";import{l as i}from"../../../../chunks/vec3.js";import{projectBoundingSphere as s}from"../../../../geometry/projection/projectBoundingSphere.js";import{f as n,h as o,u as r,c as a}from"../../../../chunks/sphere.js";import{i3sPatchingEnabled as l}from"../../../../support/featureFlags.js";import{expandElevationRange as d}from"./ElevationRange.js";import{LodMetric as h,NodeBase as u,Node as c,NodeFilterImpact as g,NodeIMModificationImpact as _,NodeTraversalState as f}from"./I3SNode.js";import{invalidateMbs as m,invalidateObb as v,addWraparound as N}from"./I3SUtil.js";import{clone as p}from"../../support/orientedBoundingBox.js";class b{constructor(e,t,i,s,n){this.childOffset=e,this.childCount=t,this.visibilityCache=i,this.ref=s,this.node=n,this.useAsHole=0,this.filterImpact=g.NotChecked,this.traversalState=null,this.parent=-1}}class P{constructor(e=[],t=[]){this.nodes=e,this.children=t,this.lastTraversed=0,this.numNodesWithLoadedChildren=0}}class y{get _useNodePages(){return this._pageSize>0}constructor(t,i,s,n,o,r,a,d,u,c,g,_,f,m,v){this._layer=t,this._streamDataController=s,this._clientNodeLoader=n,this._viewportQueries=o,this._logger=r,this.holeFilling=a,this._isLoaded=d,this._isReloading=u,this._isSelected=c,this._enable=g,this._needsUpdate=_,this._canRequest=f,this._computeVisibilityObb=m,this._computeNodeFiltering=v,this._dirty=!0,this._nodePages=new Map,this._clientNodePage=null,this._pageSize=0,this._rootIndex=0,this._lodMetric=h.None,this._lodConversion=e=>e,this._isEditable=!1,this._urlPrefix="",this._loadingNodes=new Set,this._loadingPages=new Set,this._failedNodes=new Set,this._failedPages=new Set,this._indexMissing=1,this._maxUnloadedPrio=Number.NEGATIVE_INFINITY,this._maxProcessingPrio=Number.POSITIVE_INFINITY,this._version=S(0),this._visibilityCacheVersion=S(0),this._maxLevel=1,this._featureEstimate={estimate:0,leavesReached:!1},this._unloadedMemoryEstimate=0,this._missingPagesAndNodes=new e({deallocator:null}),this._prefetchNodes=new e({deallocator:null}),this._updates=new I(this._missingPagesAndNodes),this._imModificationUncategorized=new e({deallocator:null}),this.ignoreServiceObb=!1,this.progressiveLoadPenalty=0,this._pageQueue=new Array,this._newPages=new Array,this.needNodeElevationRange=!1,this.layerHasModifications=!1,this._layerHasFilter=!1,this._frameNumber=0,this._isEditable=l()&&null!=t.associatedLayer?.infoFor3D,t.serviceUpdateTimeStamp?.lastUpdate&&(this._lastUpdate=`${t.serviceUpdateTimeStamp.lastUpdate}`),this._maxLodLevel=this._viewportQueries?this._viewportQueries.maxLodLevel:1,this._init(i)}_init(e){if("page"===e.type){const t=e.rootPage;switch(this._urlPrefix=e.urlPrefix,this._pageSize=e.pageSize,e.lodMetric){case"maxScreenThreshold":this._lodMetric=h.MaxScreenThreshold;break;case"maxScreenThresholdSQ":this._lodMetric=h.MaxScreenThreshold,this._lodConversion=F}if(this._isEditable){this._rootIndex=-1;const i=A(e.rootIndex,e.pageSize),s=t.nodes[i],n={nodes:[{index:this._rootIndex,children:[e.rootIndex],mesh:void 0,obb:s.obb,lodThreshold:s.lodThreshold}]};this._addPage(O(this._rootIndex,this._pageSize),n),this.getNode(-1).serviceObb=void 0}else this._rootIndex=e.rootIndex;this._addPage(O(e.rootIndex,this._pageSize),t),this._updateParentsAndLevel()}else if("node"===e.type){this._urlPrefix=e.urlPrefix;const t=new P;if(this._nodePages.set(0,t),this._isEditable){this._clientNodePage=new P;const t={id:"-1",version:null,mbs:e.rootNode.mbs,obb:e.rootNode.obb,sharedResource:null,geometryData:null,attributeData:null,featureData:null,children:[{id:"root",href:"../root",mbs:e.rootNode.mbs,obb:e.rootNode.obb}]};this._rootIndex=this._makeClientRefNode(new u(t.id,null),-1);const i=this._validateNode(t.id,t);i&&this._addNode(i,this._rootIndex)}else this._rootIndex=this._makeRefNode(new u(e.rootNode.id,null),-1);const i=this._validateNode(e.rootNode.id,e.rootNode);i&&this._addNode(i,0)}}addClientNodeToIndex(e,t){const i=-1,s=new u(e,t),n=this._makeClientRefNode(s,i);return this._linkChildToParentNode(i,n),this.requestUpdate(),n}removeClientNodeFromIndex(e,t,i){this._destroyClientRefNode(e,t,i),this.requestUpdate()}_loadPage(e){this._loadingPages.add(e);const i=this._urlPrefix+e;this._streamDataController.request(i,"json").then((t=>{this._pageQueue.push({pageIndex:e,page:t})})).catch((i=>{this._loadingPages.delete(e),t(i)||(this._failedPages.add(e),this._logger.error("#loadPage()",this._layer,`Error when loading page ${e}`,i))}))}_addQueuedPages(e){for(;this._pageQueue.length>0&&!e.done;){const{pageIndex:t,page:i}=this._pageQueue.shift();this._addPage(t,i),this._loadingPages.delete(t),e.madeProgress(),this.needNodeElevationRange&&this._newPages.push(t)}this._updateParentsAndLevel()}_invalidateElevationRangeForNewPages(e){if(this.needNodeElevationRange)for(;this._newPages.length>0&&!e.done;){const e=this._nodePages.get(this._newPages.shift());if(null==e)continue;const t=e.nodes;for(let i=0;i<this._pageSize;i++){let e=t[i].parent;for(;null!=e&&e!==this._rootIndex;){const t=this.getNode(e);t&&!Number.isNaN(t?.elevationRangeMin)&&(t.invalidateElevationRange(),this.invalidateBoundingVolumeCache(e)),e=this.getParentIndex(e)}}}}_addPage(e,t){const s=[],o=[],r=t.nodes.map(((t,r)=>{const a=s.length,l=t.children?t.children.length:0;o.push(this._rootIndex);for(let e=0;e<l;e++)s.push(t.children[e]);const d=`${t.index}`,h=p(t.obb),u=n(h.center[0],h.center[1],h.center[2],i(h.halfSize)),g=t.mesh?.attribute,_=t.mesh?.geometry,f=t.mesh?.material,m={hasSharedResource:!1,isEmpty:null==_,attributes:null!=g?.resource?`${g.resource}`:void 0,geometry:null!=_?.resource?`${_.resource}`:void 0,texture:null!=f?.resource?`${f.resource}`:void 0,geometryDefinition:_?_.definition:-1,materialDefinition:f?f.definition:-1},v=new c(d,V(r,e,this._pageSize),u,l,0,m,this._lastUpdate,this._lodMetric,this._lodConversion(t.lodThreshold),_?_.featureCount:null);return v.serviceObb=h,v.visibilityObb=this._computeVisibilityObb(v),v.vertexCount=_?_.vertexCount:0,new b(a,l,w(this._visibilityCacheVersion),null,v)})),a=new P(r,s);-1===e?this._clientNodePage=a:this._nodePages.set(e,a)}_updateParentsAndLevel(){const e=new Array,t=(t,i,s)=>{const n=this._getPage(t);if(null!=n){const o=A(t,this._pageSize),r=n.nodes[o];r.parent=null!=i?i:-1;const a=r.node;null!=a&&(a.level=s,e.push(t))}};for(t(this._rootIndex,null,0);e.length;){const i=e.pop(),s=this.getNode(i);if(null!=s)for(let e=0;e<s.childCount;e++){t(this.getChildIndex(s.index,e),i,s.level+1),this._maxLevel=Math.max(this._maxLevel,s.level+1)}}}_getPage(e){const t=O(e,this._pageSize);return t<0?this._clientNodePage:this._nodePages.get(t)}_getNodeInternal(e){const t=this._getPage(e);return null==t?null:(t.lastTraversed=this._frameNumber,t.nodes[A(e,this._pageSize)])}_addNode(e,t){null!=e.children&&this.populateChildren(t,e.children);const i=this.getParent(t),s=null!=i?i.level+1:0;this._maxLevel=Math.max(this._maxLevel,e.children?s+1:s);const{lodMetric:n,maxError:o}=k(e.lodSelection),r=this._getNodeInternal(t);return r.node=new c(e.id,t,e.mbs,r.childCount,s,e.resources,e.version,n,o,e.numFeatures),e.obb&&(r.node.serviceObb=p(e.obb)),r.node.visibilityObb=this._computeVisibilityObb(r.node),null!=r.ref&&(null==r.ref.mbs&&(r.ref.mbs=e.mbs),r.node.renderMbs=r.ref.renderMbs,r.node.serviceObbInRenderSR=r.ref.serviceObbInRenderSR,r.ref.visibilityObb=r.node.visibilityObb),r.node}_makeRefNode(e,t){const i=this._nodePages.get(0);if(t<-1)return this._makeClientRefNode(e,t);if(null==i)return-1;const s=i.nodes.length,n=new b(0,0,w(this._visibilityCacheVersion),e,null);return i.nodes.push(n),n.parent=t,m(e.renderMbs),v(e.serviceObbInRenderSR),s}_makeClientRefNode(e,t){const i=this._clientNodePage;if(null==i)return-1;if(t>=0)throw new Error("I3SIndex::client side nodes can not be made children of service side nodes.");const s=-(i.nodes.length+1),n=new b(0,0,w(this._visibilityCacheVersion),e,null);return i.nodes.push(n),n.parent=t,m(e.renderMbs),v(e.serviceObbInRenderSR),s}_linkChildToParentNode(e,t){const i=this._clientNodePage;if(null==i||e>=0)return;const s=A(e,this._pageSize),n=A(t,this._pageSize),o=i.nodes[s],r=o.childOffset;i.children.splice(o.childOffset+o.childCount,0,t);const a=1;o.childCount+=a,null!=o.node&&(o.node.childCount+=a);for(const l of i.nodes)l.childOffset>r&&(l.childOffset+=a);i.nodes[n].parent=e,this._updateParentBoundingInformation(e)}_destroyClientRefNode(e,t,i){const s=this._clientNodePage;if(null==s)return;const n=this.getParentIndex(e);if(null==n)return;const o=new Set,r=new Map,a=e=>{const i=A(e,this._pageSize),n=s.nodes[i];if(n.childCount>0)for(let t=n.childOffset;t<n.childOffset+n.childCount;++t)a(s.children[t]);const r=n.node?.id??n.ref?.id;if(null==r)throw new Error("Node has no id");t(r,e),o.add(n)};a(e);const l=s.nodes,d=s.children,h=s.nodes.map((()=>-1)),u=[],c=[];for(let g=0;g<l.length;++g){const e=l[g];if(o.has(e))continue;const t=u.length,s=V(g,-1,this._pageSize),n=V(t,-1,this._pageSize);if(e.node&&(e.node.index=n),h[g]=n,u.push(e),s!==n){const t=e.node?.id??e.ref?.id;if(null==t)throw new Error("Node has no id");i(t,s,n),r.set(s,n)}}for(let g=0;g<u.length;++g){const e=V(g,-1,this._pageSize),t=u[g],i=c.length;for(let s=t.childOffset;s<t.childOffset+t.childCount;++s){const t=d[s];if(t>=0)c.push(t);else{const i=A(t,this._pageSize),s=l[i];if(o.has(s))continue;const n=h[i];c.push(n),s.parent=e}}t.childOffset=i,t.childCount=c.length-i,t.node&&(t.node.childCount=t.childCount)}s.nodes=u,s.children=c,this._updateParentBoundingInformation(h[A(n,this._pageSize)])}_updateParentBoundingInformation(e){let t=e;do{let e=null;const i=this._clientNodeLoader.indexSR,n=this._clientNodeLoader.renderSR,l=this._getNodeInternal(t);if(null==l)return;for(let a=0;a<l.childCount;a++){const l=this.getChildIndex(t,a),d=this._getNodeInternal(l),h=null!=d?d.ref||d.node:null;if(null!=h&&h.mbs[3]>0)if(null==e)e=o(h.mbs,T);else{const t=D,o=U,a=Q;s(h.mbs,i,t,n),s(e,i,o,n),r(t,o,a),s(a,n,e,i)}}const d=l.ref||l.node;null!=d&&(null!=e?d.mbs=o(e,null!=d.mbs?d.mbs:a()):m(d.mbs),m(d.renderMbs),v(d.serviceObbInRenderSR),d.geometryObb=null),this.invalidateNodeVisibilityCacheInternal(l),t=this.getParentIndex(t)}while(null!=t)}populateChildren(e,t){const i=this._getNodeInternal(e),s=this._getPage(e);i.childOffset=s.children.length,i.childCount=t.length;for(let n=0;n<t.length;n++){const i=this._makeRefNode(t[n],e);s.children.push(i)}}getNode(e){const t=this._getNodeInternal(e);return null!=t?t.node:null}getIndexById(e){let t;return this._forAllNodes(((i,s)=>{(null!=i.node&&i.node.id===e||null!=i.ref&&i.ref.id===e)&&(t=s)})),t}getNodeById(e){const t=this.getIndexById(e);return null!=t&&t>=0?this.getNode(t):null}getChildIndex(e,t){const i=this._getPage(e);if(null==i)return-1;const s=i.nodes[A(e,this._pageSize)];return i.children[s.childOffset+t]}getParentIndex(e){const t=this._getPage(e);return null!=t&&e!==this._rootIndex?t.nodes[A(e,this._pageSize)].parent:null}getParent(e){const t=this.getParentIndex(e);return null!=t?this.getNode(t):null}isLeaf(e){const t=this._getNodeInternal(e);return null!=t&&0===t.childCount}get rootNode(){return this.getNode(this._rootIndex)}get isEditable(){return this._isEditable}removeAllGeometryObbs(){this._forAllNodes((e=>{null!=e.node&&(e.node.geometryObb=null)}))}invalidateVisibilityCache(){this._visibilityCacheVersion=S(this._visibilityCacheVersion)}invalidateNodeVisibilityCache(e){const t=this._getNodeInternal(e);null!=t&&this.invalidateNodeVisibilityCacheInternal(t)}invalidateNodeVisibilityCacheInternal(e){e.visibilityCache=w(this._visibilityCacheVersion)}invalidateBoundingVolumeCache(e){const t=this._getNodeInternal(e);null!=t&&(C(t),this.invalidateNodeVisibilityCacheInternal(t))}updateElevationChanged(e){const t=this._getNodeInternal(e);if(null==t)return;if(!this.needNodeElevationRange)return void this.invalidateBoundingVolumeCache(e);const i=null!=t.node?t.node:t.ref;null!=i&&i.invalidateElevationRange()}invalidateGeometryVisibility(e){const t=this._getNodeInternal(e);null!=t?.node&&(t.node.geometryObb=null,m(t.node.renderMbs),v(t.node.serviceObbInRenderSR))}invalidateVisibilityObbs(){null!=this.rootNode&&this.traverse(this.rootNode,(e=>(e.visibilityObb=this._computeVisibilityObb(e),e.geometryObb=null,!0)))}_updateElevationRange(e){this._updateElevationRangeInternal(e,null)}_updateElevationRangeInternal(e,t){const i=this._getNodeInternal(e);if(!i)return!1;const s=i?.node??i?.ref;if(!s)return!1;const n=s.elevationRangeMin;if(!Number.isNaN(n))return d(t,s),!0;const o={elevationRangeMin:1/0,elevationRangeMax:-1/0};let r=!1;for(let l=0;l<i.childCount;l++){const t=this.getChildIndex(e,l);this._updateElevationRangeInternal(t,o)||(r=!0)}if(0===i.childCount||r){const e=!i.node?.resources.isEmpty;this._viewportQueries.expandElevationRange(s,e,o)}const a=s.elevationRangeMax;return Number.isNaN(n)||n!==o.elevationRangeMin||a!==o.elevationRangeMax?(i.node&&(i.node.elevationRangeMin=o.elevationRangeMin,i.node.elevationRangeMax=o.elevationRangeMax),i.ref&&(i.ref.elevationRangeMin=o.elevationRangeMin,i.ref.elevationRangeMax=o.elevationRangeMax),this.invalidateBoundingVolumeCache(e),d(t,s),!0):(d(t,s),!0)}isNodeVisible(e){const t=this._getNodeInternal(e);if(null==t||null!=t.ref&&!t.ref.mbs)return!0;if(this.needNodeElevationRange&&this._updateElevationRange(e),!M(t.visibilityCache,this._visibilityCacheVersion)){const e=t.node,i=!e||t.ref&&!e.visibilityObb?t.ref??null:e;if(this._layerHasFilter&&this._computeNodeFiltering&&(null!=e||null!=t.ref)&&t.filterImpact===g.NotChecked){const i=null!=e?e.mbs:null!=t.ref?t.ref.mbs:null;t.filterImpact=null!=i?this._computeNodeFiltering(i):g.Unmodified}const s=null!=e&&t.filterImpact===g.Culled,n=!(null!=e&&e.imModificationImpact===_.Culled)&&(!i||this._viewportQueries.isNodeVisible(i))&&!s;return t.visibilityCache=R(n,this._visibilityCacheVersion),n}return E(t.visibilityCache)}isGeometryVisible(e){if(!this.isNodeVisible(e))return!1;const t=this._getNodeInternal(e);return!!(null==t?.node?.geometryObb||this.layerHasModifications&&t.node.imModificationImpact===_.NotChecked)||this._viewportQueries.isGeometryVisible(t.node)}_traverseCoverage(e,t,i,s,n){const o=this._getPage(e);if(null==o||0===t.childCount)return;const r=t.childOffset+t.childCount,a=new Array;for(let l=t.childOffset;l<r;++l){const e=o.children[l],t=this._getNodeInternal(e);null!=t?.node&&this.isGeometryVisible(e)&&a.push(t)}s/=a.length;for(const l of a){const e=l.node.index;this._isLoaded(e)||this._isReloading(e)?(n.delta=Math.max(n.delta,i),n.coverage+=s):this._traverseCoverage(e,l,i+1,s,n)}}useNodeAsHole(e){if("off"===this.holeFilling)return!1;const t=this._getNodeInternal(e);if(null==t)return!1;if("always"===this.holeFilling)return!0;if(M(t.useAsHole,this._version))return E(t.useAsHole);const i={delta:0,coverage:0};this._traverseCoverage(e,t,0,1,i);const s=i.delta*i.coverage<=.5;return t.useAsHole=R(s,this._version),s}get maxLevel(){return this._maxLevel}get dirty(){return this._dirty}destroy(){this._updates.add.prune(),this._updates.update.prune()}requestUpdate(){this._dirty=!0,this._indexMissing=1,this._version=S(this._version)}imModificationsChanged(e){this.layerHasModifications=e,this._forAllNodes((({node:e})=>{null!=e&&(e.imModificationImpact=_.NotChecked,e.visibilityObb=this._computeVisibilityObb(e),e.hasModifications&&this.invalidateGeometryVisibility(e.index))})),this.invalidateVisibilityCache()}layerFilterChanged(e){this._layerHasFilter=e,this._forAllNodes((e=>{if(null!=e){e.filterImpact=g.NotChecked;const t=e.node;null!=t&&this.invalidateNodeVisibilityCache(t.index)}})),this.invalidateVisibilityCache()}update(e,t,i){if(!this._dirty)return;this._pageQueue.length>0&&this._addQueuedPages(t),this._invalidateElevationRangeForNewPages(t),this._maxUnloadedPrio=Number.NEGATIVE_INFINITY,this._maxProcessingPrio=Number.NEGATIVE_INFINITY,this._missingPagesAndNodes.clear(),this._prefetchNodes.clear(),this._updates.reset(e),x.clear();let s=!0;const n=new z,o=new z,r=this._imModificationUncategorized;r.clear();const a=new Set;let l=0;const d=(d,h,u)=>{const c=O(d,this._pageSize);if(a.add(c),null==h){let e=this._entryPriority(d);return e===1/0&&(e=this._entryPriority(u)),x.set(c,Math.max(e,x.get(c)||0)),this._loadingPages.has(c)||this._failedPages.has(c)||(this._missingPagesAndNodes.push(c),++l),void(this._maxProcessingPrio=Math.max(this._maxProcessingPrio,e))}const g=h.node;if(this._updateNodeFeatureEstimate(g,o),null==g){const e=this._entryPriority(d);return this._loadingNodes.has(d)||this._failedNodes.has(d)||(this._missingPagesAndNodes.push(d),x.set(d,e)),void(this._maxProcessingPrio=Math.max(this._maxProcessingPrio,e))}const f=this._getPage(d);if(0===this._missingPagesAndNodes.length&&!this._useNodePages)for(let e=0;e<h.childCount;e++){const t=f.children[h.childOffset+e],i=this._getNodeInternal(t);null==i||i.node||this._loadingNodes.has(t)||this._failedNodes.has(t)||(x.set(t,this._entryPriority(t)),this._prefetchNodes.push(t))}if(g.failed||g.resources.isEmpty)return void(s&&h.childCount>0&&this._isSelected(g)&&(s=!1));if(this._isLoaded(d)){if(n.known+=g.memory,++n.knownNodes,this._isSelected(g)?h.childCount>0&&(s=!1):(n.unremoved+=g.memory,s=!1),this._needsUpdate(g)){const e=this._entryPriority(d);x.set(d,e),this._maxProcessingPrio=Math.max(this._maxProcessingPrio,e),this._updates.update.push(d)}return}if(g.memory&&(n.known+=g.memory,++n.knownNodes),!this._isSelected(g))return void(this._isReloading(d)&&this._updates.remove.push(d));if(h.childCount>0&&(s=!1),g.memory?(n.missing+=g.memory,n.known+=g.memory,++n.knownNodes):++n.missingNodes,e.includes(g.index))return this._maxProcessingPrio=Math.max(this._maxProcessingPrio,this._entryPriority(d)),void(this._updates.cancel=this._updates.cancel.filter((e=>e!==g.index)));if(!t.done&&this._enable(g))return void t.madeProgress();const m=this._entryPriority(d);x.set(d,m),this._maxProcessingPrio=Math.max(this._maxProcessingPrio,m),this._updates.add.push(d),this.layerHasModifications&&i&&null!=g&&g.imModificationImpact===_.NotChecked&&r.push(d)};this.traverseVisible(d),this._frameNumber++,this._missingPagesAndNodes.sort(((e,t)=>e-t)),this._missingPagesAndNodes.filterInPlace(((e,t)=>t<1||this._missingPagesAndNodes.data[t-1]!==e)),this._missingPagesAndNodes.sort(((e,t)=>x.get(e)-x.get(t))),this._missingPagesAndNodes.length>0&&(this._maxUnloadedPrio=x.get(this._missingPagesAndNodes.back()),this._prefetchNodes.clear()),this._removeUnusedNodePages(a,l);const h=this._updates.add;h.length>0&&this.layerHasModifications&&(r.length>0&&i?.(r),h.filterInPlace((e=>{const t=this._getNodeInternal(e),i=null==t?.node||t.node.imModificationImpact!==_.Culled;return i||this.invalidateNodeVisibilityCache(e),i}))),this._unloadedMemoryEstimate=n.missing-n.unremoved,n.knownNodes>3&&n.missingNodes>0&&(this._unloadedMemoryEstimate+=n.known/n.knownNodes*n.missingNodes),this._unloadedMemoryEstimate=.8*Math.max(0,this._unloadedMemoryEstimate),this._featureEstimate.estimate=this._computeFeatureEstimate(o),this._featureEstimate.leavesReached=s,this._updates.add.filterInPlace((e=>x.get(e)>=this._maxUnloadedPrio)).sort(((e,t)=>x.get(e)-x.get(t))),this._updates.update.sort(((e,t)=>x.get(e)-x.get(t))),this._indexMissing=this._loadingPages.size+this._loadingNodes.size+this._missingPagesAndNodes.length,this._dirty=this._indexMissing>0,x.clear()}checkFeatureTarget(e,t){const i=this._viewportQueries.updateScreenSpaceErrorBias(t);let s=t,n=t,o=i,r=10;for(;r--;){const i=new z;this._updateFeatureEstimate(s,i);if(this._computeFeatureEstimate(i)<=e){if(s>=t||i.missingNodes>0||0===r)break;o=s,s=.5*(s+n)}else n=s,s=.5*(s+o)}return this._version=S(this._version),this._viewportQueries.updateScreenSpaceErrorBias(i),Math.min(t,s)}_removeUnusedNodePages(e,t){if(!this._useNodePages)return;const i=this._nodePages,s=e.size,n=i.size+this._loadingPages.size+t;if(n>$&&n>s){const t=new Array;for(const[s,n]of i)0!==n.numNodesWithLoadedChildren||e.has(s)||t.push([n.lastTraversed,s]);t.sort(((e,t)=>e[0]-t[0])).some((e=>{const t=e[1];return this._deleteNodePage(t),i.size<=$}))}}_updateFeatureEstimate(e,t){this._version=S(this._version),this._viewportQueries.updateScreenSpaceErrorBias(e),this.traverseVisible(((e,i)=>this._updateNodeFeatureEstimate(null!=i?i.node:void 0,t)))}_updateNodeFeatureEstimate(e,t){null==e||e.failed||null==e.numFeatures||this._isSelected(e)&&(null!=e.numFeatures?(t.missing+=e.numFeatures,t.known+=e.numFeatures,++t.knownNodes):++t.missingNodes)}_computeFeatureEstimate(e){let t=e.known-e.unremoved;return e.knownNodes>3&&e.missingNodes>0&&(t+=e.known/e.knownNodes*e.missingNodes),Math.max(0,t)}load(){return this._load(this._missingPagesAndNodes)}prefetch(){return this._prefetchNodes.sort(((e,t)=>x.get(e)-x.get(t))),this._load(this._prefetchNodes)}_load(e){if(0===e.length||!this._canRequest())return!1;for(;e.length>0&&this._canRequest();){const t=e.pop();this._useNodePages&&t>=0?this._loadPage(t):this._loadNode(t)}return!0}get isLoading(){return this._indexMissing>0}get isPrefetching(){return this._prefetchNodes.length>0}get indexLoading(){return this._loadingPages.size+this._loadingNodes.size}get indexMissing(){return this._indexMissing}get unloadedMemoryEstimate(){return this._unloadedMemoryEstimate}get updates(){return this._updates}get featureEstimate(){return this._featureEstimate}get maxPriority(){return Math.max(this._maxProcessingPrio,this._maxUnloadedPrio)}nodeTraversalState(e){if(null==e)return null;const t=e.index,i=this._getNodeInternal(t);if(!i)return null;let s=i?.traversalState;if(s&&M(s.version,this._version))return s;const n=this._viewportQueries.getLodLevel(e),o=this._viewportQueries.hasLOD(e);let r=!0;if(o){const e=this.getParentIndex(t);if(null!=e){const t=this._getNodeInternal(e),i=t?.traversalState;r=!!i&&n>i.lodLevel}else r=n>0}else r=0===e.childCount;return s?(s.lodLevel=n,s.isChosen=r,s.version=R(!0,this._version),s):(s=new f(o,r,n,R(!0,this._version)),i.traversalState=s,s)}async _loadNode(e){this._loadingNodes.add(e);const i=this._getNodeInternal(e).ref;if(null==i)return void this._failedNodes.add(e);const s=i.id,n=this._urlPrefix+s,o=()=>{this._loadingNodes.delete(e),0===this._missingPagesAndNodes.length&&0===this._loadingNodes.size&&this.requestUpdate()};let r=null;try{r=e>=0?await this._streamDataController.request(n,"json"):await this._clientNodeLoader.loadNodeJSON(s)}catch(d){return o(),void(t(d)||(this._logger.error("#loadNode()",this._layer,"Error loading node: "+n),this._failedNodes.add(e)))}o();const a=this._validateNode(s,r);if(null==a)return;a.obb&&this.invalidateNodeVisibilityCache(e);const l=this._addNode(a,e);this.nodeTraversalState(l)}_validateNode(e,t){if(null==t||"object"!=typeof t||t.id!==e)return this._logger.error("#validateNode()",this._layer,`Invalid node. Wrong type or wrong id "${e}"`),null;if(!Array.isArray(t.mbs))return this._logger.error("#validateNode()",this._layer,`Invalid bounding volume on node ${e}.`),null;t.sharedResource&&"./shared"!==t.sharedResource.href&&"./shared/"!==t.sharedResource.href&&this._logger.warn("#validateNode()",this._layer,`Invalid shared resource href on node "${e}"`);const i=t.geometryData;null==i||Array.isArray(i)&&0===i.length||Array.isArray(i)&&1===i.length&&"./geometries/0"===i[0].href||this._logger.warn("#validateNode()",this._layer,`Invalid geometry data on node "${e}"`);const s=t.attributeData,n=this._layer.attributeStorageInfo;null==s||Array.isArray(s)&&!s.some(((e,t)=>e.href!==`./attributes/${n?.[t]?.key??`f_${t}`}/0`))||this._logger.warn("#validateNode()",this._layer,`Invalid attribute data on node "${e}"`),t.featureData&&t.featureData.length>1&&this._logger.warn("#validateNode()",this._layer,`Node ${e} has ${t.featureData.length} bundles. Only the first bundle will be loaded.`);const o=t.hasOwnProperty("obb")&&!this.ignoreServiceObb?t.obb:null,r=t.featureData&&1===t.featureData.length&&t.featureData[0].featureRange?t.featureData[0].featureRange[1]-t.featureData[0].featureRange[0]+1:void 0,a=t=>{if(null==t)return null;const i=t=>this._logger.error("#validateNode()",this._layer,`Invalid node reference on node ${e}: ${t}`);if("number"==typeof t.id)i(`id ${t.id} is a number instead of a string.`);else if("string"!=typeof t.id||!Array.isArray(t.mbs))return i("Missing or invalid id."),null;if(!Array.isArray(t.mbs))return i(`Invalid bounding volume on reference ${t.id}.`),null;t.href&&t.href!=="../"+t.id&&this._logger.error("#validateNode()",this._layer,`Invalid node href on node "${e}"`);const s=t.hasOwnProperty("obb")&&!this.ignoreServiceObb?t.obb:null,n=new u(`${t.id}`,t.mbs);return n.serviceObb=s,n.visibilityObb=this._computeVisibilityObb(n),n},l=Array.isArray(t.children)?t.children.map(a).filter((e=>null!=e)):null,d=t.featureData?.length??!1,h=!0===t.isEmpty;return{id:e,mbs:t.mbs,obb:o,children:l,resources:{isEmpty:!d&&h,hasSharedResource:null!=t.sharedResource,attributes:t.attributeData?e:void 0,texture:t.textureData&&t.textureData.length>0?e:void 0,geometry:null!=t.geometryData?e:void 0},version:"string"==typeof t.version?t.version:null,lodSelection:Array.isArray(t.lodSelection)?t.lodSelection:null,numFeatures:r}}resetFailedNodes(){this._failedNodes.clear(),this._failedPages.clear(),this._forAllNodes((e=>{null!=e.node&&(e.node.failed=!1)}))}_entryPriority(e){const t=this._getNodeInternal(e),i=this.getParentIndex(e);if(null==t||null==i&&null==t.node)return null==i?1/0:this._entryPriority(i);let s=0;if(t.node&&null!=i){const e=this._getNodeInternal(i).traversalState;null!=e&&(s=e.lodLevel)}let n=this.progressiveLoadPenalty;for(let r=e;null!=r;r=this.getParentIndex(r))if(this._isLoaded(r)){n=0;break}const o=null!=t.ref?this._viewportQueries.distToPOI(t.ref):null!=t.node?this._viewportQueries.distToPOI(t.node):0;return-o-s*(o+this.progressiveLoadPenalty)+n}traverseVisible(e){const t=this._getNodeInternal(this._rootIndex);null!=t?this._traverseVisible(this._rootIndex,null,t,e):e(this._rootIndex,null,null)}_traverseVisible(e,t,i,s){if(i.node&&0===i.childCount)return void(this.isGeometryVisible(e)&&s(e,i,t));if(!this.isNodeVisible(e))return;if(s(e,i,t),null==i.node)return;const n=this.nodeTraversalState(i.node);if(n?.nodeHasLOD&&n.lodLevel===this._maxLodLevel)return;const o=this._getPage(e);for(let r=0;r<i.childCount;r++){const t=o.children[i.childOffset+r],n=this._getNodeInternal(t);n?this._traverseVisible(t,e,n,s):s(t,null,e)}}traverse(e,t){t(e)&&this.traverseChildren(e,t)}traverseChildren(e,t){const i=e.index,s=this._getNodeInternal(i);null!=s&&this._traverseChildren(i,s,t)}_traverseChildren(e,t,i){const s=this._getPage(e);if(null==s)return;const n=t.childOffset+t.childCount;for(let o=t.childOffset;o<n;++o){const e=s.children[o],t=this._getNodeInternal(e);null!=t?.node&&i(t.node)&&this._traverseChildren(e,t,i)}}updateChildrenLoaded(e,t){let i=this.getNode(e);for(;null!=i;){const e=i.childrenLoaded,s=e+t;i.childrenLoaded=s;const n=0===e?1:0===s?-1:0,o=i.index;if(0!==n){this._getPage(o).numNodesWithLoadedChildren+=n}i=this.getParent(o)}}checkChildrenLoadedInvariant(){if(null==this.rootNode)return!0;const e=[],t=i=>{let s=this._isLoaded(i.index)||this._isReloading(i.index)?1:0;return this.traverseChildren(i,(e=>(s+=t(e),!1))),i.childrenLoaded!==s&&e.push(i.index),s};return t(this.rootNode),e.length&&this._logger.error("childrenLoaded invariant broken at following nodes: "+e.join(",")),e.length>0}updateStats(e){if(this._updates.add.length>0&&(e.nodes+=" + "+this._updates.add.length),e.index=this._nodePages.size*(this._pageSize||1)+(this._clientNodePage?.nodes.length??0),e.prio=this._maxProcessingPrio,(this._indexMissing||this._prefetchNodes.length>0)&&(e.index+=" + "+this._indexMissing||this._prefetchNodes.length),this._featureEstimate.estimate){const t=this._featureEstimate.estimate-e.features;t>0?e.features+=" + "+t:t<0&&(e.features+=" - "+-t)}}updateElevationInfo(e,t){this.needNodeElevationRange=t&&!!e&&("relative-to-ground"===e.mode||"on-the-ground"===e.mode),this._viewportQueries.updateElevationInfo(e),this.invalidateAllElevationRanges()}invalidateAllElevationRanges(){this._forAllNodes((e=>{C(e),null!=e.node&&e.node.invalidateElevationRange(),null!=e.ref&&e.ref.invalidateElevationRange()}))}_forAllNodes(e){if(null!=this._clientNodePage){const t=this._clientNodePage;for(let i=0;i<t.nodes.length;i++)e(t.nodes[i],-(i+1))}for(const[t,i]of this._nodePages){const s=t*this._pageSize;for(let t=0;t<i.nodes.length;t++)e(i.nodes[t],s+t)}}clearCaches(){if(this._useNodePages){const e=this._nodePages,t=new Set;this.traverseVisible((e=>t.add(O(e,this._pageSize))));for(const[i,s]of e)if(0!==s.numNodesWithLoadedChildren||t.has(i))for(const e of s.nodes)e.traversalState=null;else this._deleteNodePage(i)}}_deleteNodePage(e){this._nodePages.delete(e)}get test(){return{addNode:(e,t)=>this._addNode(e,t),getNodeInternal:e=>this._getNodeInternal(e),getPageIndex:e=>O(e,this._pageSize),getIndexWithinPage:e=>A(e,this._pageSize),getNodePage:e=>e<0?this._clientNodePage:this._nodePages.get(e),getChildIndices:e=>{const t=this._getNodeInternal(e),i=this._getPage(e);if(null==t||null==i)return[];const s=[];for(let n=t.childOffset;n<t.childOffset+t.childCount;++n)s.push(i.children[n]);return s},rootIndex:this._rootIndex,clientNodePage:this._clientNodePage,nodePages:this._nodePages}}}const x=new Map;class I{constructor(t){this.missing=t,this.update=new e({deallocator:null}),this.add=new e({deallocator:null}),this.remove=new e({deallocator:null}),this.cancel=[]}reset(e){this.add.clear(),this.update.clear(),this.cancel=e}}function C(e){null!=e.node&&(m(e.node.renderMbs),v(e.node.serviceObbInRenderSR)),null!=e.ref&&(m(e.ref.renderMbs),v(e.ref.serviceObbInRenderSR))}function w(e){return N(e,-2)}function S(e){return N(e,2)}function R(e,t){return t+(e?1:0)}function M(e,t){return(-2&e)===t}function E(e){return 1==(1&e)}function O(e,t){return e<0?-1:t>0?e/t|0:0}function A(e,t){return e<0?-e-1:0===t?e:e%t}function V(e,t,i){return-1===t?-(e+1):0===i?e:t*i+e}const L=[["maxScreenThreshold",h.MaxScreenThreshold],["screenSpaceRelative",h.ScreenSpaceRelative],["removedFeatureDiameter",h.RemovedFeatureDiameter],["distanceRangeFromDefaultCamera",h.DistanceRangeFromDefaultCamera]];function k(e){if(e)for(let t=0;t<e.length;t++)for(const i of L)if(i[0]===e[t].metricType)return{lodMetric:i[1],maxError:e[t].maxError};return{lodMetric:h.None,maxError:0}}class z{constructor(){this.known=0,this.knownNodes=0,this.missing=0,this.missingNodes=0,this.unremoved=0}}function F(e){return Math.sqrt(e*(4/Math.PI))}const T=a(),D=a(),U=a(),Q=a(),$=has("esri-mobile")?100:300;export{y as I3SIndex,k as selectErrorMetric};
5
+ import e from"../../../../core/PooledArray.js";import{isAbortError as t}from"../../../../core/promiseUtils.js";import{l as i}from"../../../../chunks/vec3.js";import{projectBoundingSphere as s}from"../../../../geometry/projection/projectBoundingSphere.js";import{f as n,h as o,u as r,c as a}from"../../../../chunks/sphere.js";import{i3sPatchingEnabled as l}from"../../../../support/featureFlags.js";import{expandElevationRange as d}from"./ElevationRange.js";import{LodMetric as h,NodeBase as u,Node as c,NodeFilterImpact as g,NodeIMModificationImpact as _,NodeTraversalState as f}from"./I3SNode.js";import{invalidateMbs as m,invalidateObb as v,addWraparound as N}from"./I3SUtil.js";import{clone as p}from"../../support/orientedBoundingBox.js";class b{constructor(e,t,i,s,n){this.childOffset=e,this.childCount=t,this.visibilityCache=i,this.ref=s,this.node=n,this.useAsHole=0,this.filterImpact=g.NotChecked,this.traversalState=null,this.parent=-1}}class y{constructor(e=[],t=[]){this.nodes=e,this.children=t,this.lastTraversed=0,this.numNodesWithLoadedChildren=0}}class P{get _useNodePages(){return this._pageSize>0}constructor(t,i,s,n,o,r,a,d,u,c,g,_,f,m,v){this._layer=t,this._streamDataController=s,this._clientNodeLoader=n,this._viewportQueries=o,this._logger=r,this.holeFilling=a,this._isLoaded=d,this._isReloading=u,this._isSelected=c,this._enable=g,this._needsUpdate=_,this._canRequest=f,this._computeVisibilityObb=m,this._computeNodeFiltering=v,this._dirty=!0,this._nodePages=new Map,this._clientNodePage=null,this._pageSize=0,this._rootIndex=0,this._lodMetric=h.None,this._lodConversion=e=>e,this._isEditable=!1,this._urlPrefix="",this._loadingNodes=new Set,this._loadingPages=new Set,this._failedNodes=new Set,this._failedPages=new Set,this._indexMissing=1,this._maxUnloadedPrio=Number.NEGATIVE_INFINITY,this._maxProcessingPrio=Number.POSITIVE_INFINITY,this._version=S(0),this._visibilityCacheVersion=S(0),this._maxLevel=1,this._featureEstimate={estimate:0,leavesReached:!1},this._unloadedMemoryEstimate=0,this._missingPagesAndNodes=new e({deallocator:null}),this._prefetchNodes=new e({deallocator:null}),this._updates=new I(this._missingPagesAndNodes),this._imModificationUncategorized=new e({deallocator:null}),this.ignoreServiceObb=!1,this.progressiveLoadPenalty=0,this._pageQueue=new Array,this._newPages=new Array,this.needNodeElevationRange=!1,this.layerHasModifications=!1,this._layerHasFilter=!1,this._frameNumber=0,this._isEditable=l()&&null!=t.associatedLayer?.infoFor3D,t.serviceUpdateTimeStamp?.lastUpdate&&(this._lastUpdate=`${t.serviceUpdateTimeStamp.lastUpdate}`),this._maxLodLevel=this._viewportQueries?this._viewportQueries.maxLodLevel:1,this._init(i)}_init(e){if("page"===e.type){const t=e.rootPage;switch(this._urlPrefix=e.urlPrefix,this._pageSize=e.pageSize,e.lodMetric){case"maxScreenThreshold":this._lodMetric=h.MaxScreenThreshold;break;case"maxScreenThresholdSQ":this._lodMetric=h.MaxScreenThreshold,this._lodConversion=z}if(this._isEditable){this._rootIndex=-1;const i=A(e.rootIndex,e.pageSize),s=t.nodes[i],n={nodes:[{index:this._rootIndex,children:[e.rootIndex],mesh:void 0,obb:s.obb,lodThreshold:s.lodThreshold}]};this._addPage(O(this._rootIndex,this._pageSize),n),this.getNode(-1).serviceObb=void 0}else this._rootIndex=e.rootIndex;this._addPage(O(e.rootIndex,this._pageSize),t),this._updateParentsAndLevel()}else if("node"===e.type){this._urlPrefix=e.urlPrefix;const t=new y;if(this._nodePages.set(0,t),this._isEditable){this._clientNodePage=new y;const t={id:"-1",version:null,mbs:e.rootNode.mbs,obb:e.rootNode.obb,sharedResource:null,geometryData:null,attributeData:null,featureData:null,children:[{id:"root",href:"../root",mbs:e.rootNode.mbs,obb:e.rootNode.obb}]};this._rootIndex=this._makeClientRefNode(new u(t.id,null),-1);const i=this._validateNode(t.id,t);i&&this._addNode(i,this._rootIndex)}else this._rootIndex=this._makeRefNode(new u(e.rootNode.id,null),-1);const i=this._validateNode(e.rootNode.id,e.rootNode);i&&this._addNode(i,0)}}addClientNodeToIndex(e,t){const i=-1,s=new u(e,t),n=this._makeClientRefNode(s,i);return this._linkChildToParentNode(i,n),this.requestUpdate(),n}removeClientNodeFromIndex(e,t,i){this._destroyClientRefNode(e,t,i),this.requestUpdate()}_loadPage(e){this._loadingPages.add(e);const i=this._urlPrefix+e;this._streamDataController.request(i,"json").then((t=>{this._pageQueue.push({pageIndex:e,page:t})})).catch((i=>{this._loadingPages.delete(e),t(i)||(this._failedPages.add(e),this._logger.error("#loadPage()",this._layer,`Error when loading page ${e}`,i))}))}_addQueuedPages(e){for(;this._pageQueue.length>0&&!e.done;){const{pageIndex:t,page:i}=this._pageQueue.shift();this._addPage(t,i),this._loadingPages.delete(t),e.madeProgress(),this.needNodeElevationRange&&this._newPages.push(t)}this._updateParentsAndLevel()}_invalidateElevationRangeForNewPages(e){if(this.needNodeElevationRange)for(;this._newPages.length>0&&!e.done;){const e=this._nodePages.get(this._newPages.shift());if(null==e)continue;const t=e.nodes;for(let i=0;i<this._pageSize;i++){let e=t[i].parent;for(;null!=e&&e!==this._rootIndex;){const t=this.getNode(e);t&&!Number.isNaN(t?.elevationRangeMin)&&(t.invalidateElevationRange(),this.invalidateBoundingVolumeCache(e)),e=this.getParentIndex(e)}}}}_addPage(e,t){const s=[],o=[],r=t.nodes.map(((t,r)=>{const a=s.length,l=t.children?t.children.length:0;o.push(this._rootIndex);for(let e=0;e<l;e++)s.push(t.children[e]);const d=`${t.index}`,h=p(t.obb),u=n(h.center[0],h.center[1],h.center[2],i(h.halfSize)),g=t.mesh?.attribute,_=t.mesh?.geometry,f=t.mesh?.material,m={hasSharedResource:!1,isEmpty:null==_,attributes:null!=g?.resource?`${g.resource}`:void 0,geometry:null!=_?.resource?`${_.resource}`:void 0,texture:null!=f?.resource?`${f.resource}`:void 0,geometryDefinition:_?_.definition:-1,materialDefinition:f?f.definition:-1},v=new c(d,V(r,e,this._pageSize),u,l,0,m,this._lastUpdate,this._lodMetric,this._lodConversion(t.lodThreshold),_?_.featureCount:null);return v.serviceObb=h,v.visibilityObb=this._computeVisibilityObb(v),v.vertexCount=_?_.vertexCount:0,new b(a,l,w(this._visibilityCacheVersion),null,v)})),a=new y(r,s);-1===e?this._clientNodePage=a:this._nodePages.set(e,a)}_updateParentsAndLevel(){const e=new Array,t=(t,i,s)=>{const n=this._getPage(t);if(null!=n){const o=A(t,this._pageSize),r=n.nodes[o];r.parent=null!=i?i:-1;const a=r.node;null!=a&&(a.level=s,e.push(t))}};for(t(this._rootIndex,null,0);e.length;){const i=e.pop(),s=this.getNode(i);if(null!=s)for(let e=0;e<s.childCount;e++){t(this.getChildIndex(s.index,e),i,s.level+1),this._maxLevel=Math.max(this._maxLevel,s.level+1)}}}_getPage(e){const t=O(e,this._pageSize);return t<0?this._clientNodePage:this._nodePages.get(t)}_getNodeInternal(e){const t=this._getPage(e);return null==t?null:(t.lastTraversed=this._frameNumber,t.nodes[A(e,this._pageSize)])}_addNode(e,t){null!=e.children&&this.populateChildren(t,e.children);const i=this.getParent(t),s=null!=i?i.level+1:0;this._maxLevel=Math.max(this._maxLevel,e.children?s+1:s);const{lodMetric:n,maxError:o}=k(e.lodSelection),r=this._getNodeInternal(t);return r.node=new c(e.id,t,e.mbs,r.childCount,s,e.resources,e.version,n,o,e.numFeatures),e.obb&&(r.node.serviceObb=p(e.obb)),r.node.visibilityObb=this._computeVisibilityObb(r.node),null!=r.ref&&(null==r.ref.mbs&&(r.ref.mbs=e.mbs),r.node.renderMbs=r.ref.renderMbs,r.node.serviceObbInRenderSR=r.ref.serviceObbInRenderSR,r.ref.visibilityObb=r.node.visibilityObb),r.node}_makeRefNode(e,t){const i=this._nodePages.get(0);if(t<-1)return this._makeClientRefNode(e,t);if(null==i)return-1;const s=i.nodes.length,n=new b(0,0,w(this._visibilityCacheVersion),e,null);return i.nodes.push(n),n.parent=t,m(e.renderMbs),v(e.serviceObbInRenderSR),s}_makeClientRefNode(e,t){const i=this._clientNodePage;if(null==i)return-1;if(t>=0)throw new Error("I3SIndex::client side nodes can not be made children of service side nodes.");const s=-(i.nodes.length+1),n=new b(0,0,w(this._visibilityCacheVersion),e,null);return i.nodes.push(n),n.parent=t,m(e.renderMbs),v(e.serviceObbInRenderSR),s}_linkChildToParentNode(e,t){const i=this._clientNodePage;if(null==i||e>=0)return;const s=A(e,this._pageSize),n=A(t,this._pageSize),o=i.nodes[s],r=o.childOffset;i.children.splice(o.childOffset+o.childCount,0,t);const a=1;o.childCount+=a,null!=o.node&&(o.node.childCount+=a);for(const l of i.nodes)l.childOffset>r&&(l.childOffset+=a);i.nodes[n].parent=e,this._updateParentBoundingInformation(e)}_destroyClientRefNode(e,t,i){const s=this._clientNodePage;if(null==s)return;const n=this.getParentIndex(e);if(null==n)return;const o=new Set,r=new Map,a=e=>{const i=A(e,this._pageSize),n=s.nodes[i];if(n.childCount>0)for(let t=n.childOffset;t<n.childOffset+n.childCount;++t)a(s.children[t]);const r=n.node?.id??n.ref?.id;if(null==r)throw new Error("Node has no id");t(r,e),o.add(n)};a(e);const l=s.nodes,d=s.children,h=s.nodes.map((()=>-1)),u=[],c=[];for(let g=0;g<l.length;++g){const e=l[g];if(o.has(e))continue;const t=u.length,s=V(g,-1,this._pageSize),n=V(t,-1,this._pageSize);if(e.node&&(e.node.index=n),h[g]=n,u.push(e),s!==n){const t=e.node?.id??e.ref?.id;if(null==t)throw new Error("Node has no id");i(t,s,n),r.set(s,n)}}for(let g=0;g<u.length;++g){const e=V(g,-1,this._pageSize),t=u[g],i=c.length;for(let s=t.childOffset;s<t.childOffset+t.childCount;++s){const t=d[s];if(t>=0)c.push(t);else{const i=A(t,this._pageSize),s=l[i];if(o.has(s))continue;const n=h[i];c.push(n),s.parent=e}}t.childOffset=i,t.childCount=c.length-i,t.node&&(t.node.childCount=t.childCount)}s.nodes=u,s.children=c,this._updateParentBoundingInformation(h[A(n,this._pageSize)])}_updateParentBoundingInformation(e){let t=e;do{let e=null;const i=this._clientNodeLoader.indexSR,n=this._clientNodeLoader.renderSR,l=this._getNodeInternal(t);if(null==l)return;for(let a=0;a<l.childCount;a++){const l=this.getChildIndex(t,a),d=this._getNodeInternal(l),h=null!=d?d.ref||d.node:null;if(null!=h&&h.mbs[3]>0)if(null==e)e=o(h.mbs,D);else{const t=T,o=Q,a=U;s(h.mbs,i,t,n),s(e,i,o,n),r(t,o,a),s(a,n,e,i)}}const d=l.ref||l.node;null!=d&&(null!=e?d.mbs=o(e,null!=d.mbs?d.mbs:a()):m(d.mbs),m(d.renderMbs),v(d.serviceObbInRenderSR),d.geometryObb=null),this.invalidateNodeVisibilityCacheInternal(l),t=this.getParentIndex(t)}while(null!=t)}populateChildren(e,t){const i=this._getNodeInternal(e),s=this._getPage(e);i.childOffset=s.children.length,i.childCount=t.length;for(let n=0;n<t.length;n++){const i=this._makeRefNode(t[n],e);s.children.push(i)}}getNode(e){const t=this._getNodeInternal(e);return null!=t?t.node:null}getIndexById(e){let t;return this._forAllNodes(((i,s)=>{(null!=i.node&&i.node.id===e||null!=i.ref&&i.ref.id===e)&&(t=s)})),t}getNodeById(e){const t=this.getIndexById(e);return null!=t&&t>=0?this.getNode(t):null}getChildIndex(e,t){const i=this._getPage(e);if(null==i)return-1;const s=i.nodes[A(e,this._pageSize)];return i.children[s.childOffset+t]}getParentIndex(e){const t=this._getPage(e);return null!=t&&e!==this._rootIndex?t.nodes[A(e,this._pageSize)].parent:null}getParent(e){const t=this.getParentIndex(e);return null!=t?this.getNode(t):null}isLeaf(e){const t=this._getNodeInternal(e);return null!=t&&0===t.childCount}get rootNode(){return this.getNode(this._rootIndex)}get isEditable(){return this._isEditable}removeAllGeometryObbs(){this._forAllNodes((e=>{null!=e.node&&(e.node.geometryObb=null)}))}invalidateVisibilityCache(){this._visibilityCacheVersion=S(this._visibilityCacheVersion)}invalidateNodeVisibilityCache(e){const t=this._getNodeInternal(e);null!=t&&this.invalidateNodeVisibilityCacheInternal(t)}invalidateNodeVisibilityCacheInternal(e){e.visibilityCache=w(this._visibilityCacheVersion)}invalidateBoundingVolumeCache(e){const t=this._getNodeInternal(e);null!=t&&(C(t),this.invalidateNodeVisibilityCacheInternal(t))}updateElevationChanged(e){const t=this._getNodeInternal(e);if(null==t)return;if(!this.needNodeElevationRange)return void this.invalidateBoundingVolumeCache(e);const i=null!=t.node?t.node:t.ref;null!=i&&i.invalidateElevationRange()}invalidateGeometryVisibility(e){const t=this._getNodeInternal(e);null!=t?.node&&(t.node.geometryObb=null,m(t.node.renderMbs),v(t.node.serviceObbInRenderSR))}invalidateVisibilityObbs(){null!=this.rootNode&&this.traverse(this.rootNode,(e=>(e.visibilityObb=this._computeVisibilityObb(e),e.geometryObb=null,!0)))}_updateElevationRange(e){this._updateElevationRangeInternal(e,null)}_updateElevationRangeInternal(e,t){const i=this._getNodeInternal(e);if(!i)return!1;const s=i?.node??i?.ref;if(!s)return!1;const n=s.elevationRangeMin;if(!Number.isNaN(n))return d(t,s),!0;const o={elevationRangeMin:1/0,elevationRangeMax:-1/0};let r=!1;for(let l=0;l<i.childCount;l++){const t=this.getChildIndex(e,l);this._updateElevationRangeInternal(t,o)||(r=!0)}if(0===i.childCount||r){const e=!i.node?.resources.isEmpty;this._viewportQueries.expandElevationRange(s,e,o)}const a=s.elevationRangeMax;return Number.isNaN(n)||n!==o.elevationRangeMin||a!==o.elevationRangeMax?(i.node&&(i.node.elevationRangeMin=o.elevationRangeMin,i.node.elevationRangeMax=o.elevationRangeMax),i.ref&&(i.ref.elevationRangeMin=o.elevationRangeMin,i.ref.elevationRangeMax=o.elevationRangeMax),this.invalidateBoundingVolumeCache(e),d(t,s),!0):(d(t,s),!0)}isNodeVisible(e){const t=this._getNodeInternal(e);if(null==t||null!=t.ref&&!t.ref.mbs)return!0;if(this.needNodeElevationRange&&this._updateElevationRange(e),!M(t.visibilityCache,this._visibilityCacheVersion)){const e=t.node,i=!e||t.ref&&!e.visibilityObb?t.ref??null:e;if(this._layerHasFilter&&this._computeNodeFiltering&&(null!=e||null!=t.ref)&&t.filterImpact===g.NotChecked){const i=null!=e?e.mbs:null!=t.ref?t.ref.mbs:null;t.filterImpact=null!=i?this._computeNodeFiltering(i):g.Unmodified}const s=null!=e&&t.filterImpact===g.Culled,n=!(null!=e&&e.imModificationImpact===_.Culled)&&(!i||this._viewportQueries.isNodeVisible(i))&&!s;return t.visibilityCache=R(n,this._visibilityCacheVersion),n}return E(t.visibilityCache)}isGeometryVisible(e){if(!this.isNodeVisible(e))return!1;const t=this._getNodeInternal(e);return!!(null==t?.node?.geometryObb||this.layerHasModifications&&t.node.imModificationImpact===_.NotChecked)||this._viewportQueries.isGeometryVisible(t.node)}_traverseCoverage(e,t,i,s,n){const o=this._getPage(e);if(null==o||0===t.childCount)return;const r=t.childOffset+t.childCount,a=new Array;for(let l=t.childOffset;l<r;++l){const e=o.children[l],t=this._getNodeInternal(e);null!=t?.node&&this.isGeometryVisible(e)&&a.push(t)}s/=a.length;for(const l of a){const e=l.node.index;this._isLoaded(e)||this._isReloading(e)?(n.delta=Math.max(n.delta,i),n.coverage+=s):this._traverseCoverage(e,l,i+1,s,n)}}useNodeAsHole(e){if("off"===this.holeFilling)return!1;const t=this._getNodeInternal(e);if(null==t)return!1;if("always"===this.holeFilling)return!0;if(M(t.useAsHole,this._version))return E(t.useAsHole);const i={delta:0,coverage:0};this._traverseCoverage(e,t,0,1,i);const s=i.delta*i.coverage<=.5;return t.useAsHole=R(s,this._version),s}get maxLevel(){return this._maxLevel}get dirty(){return this._dirty}destroy(){this._updates.add.prune(),this._updates.update.prune()}requestUpdate(){this._dirty=!0,this._indexMissing=1,this._version=S(this._version)}imModificationsChanged(e){this.layerHasModifications=e,this._forAllNodes((({node:e})=>{null!=e&&(e.imModificationImpact=_.NotChecked,e.visibilityObb=this._computeVisibilityObb(e),e.hasModifications&&this.invalidateGeometryVisibility(e.index))})),this.invalidateVisibilityCache()}layerFilterChanged(e){this._layerHasFilter=e,this._forAllNodes((e=>{if(null!=e){e.filterImpact=g.NotChecked;const t=e.node;null!=t&&this.invalidateNodeVisibilityCache(t.index)}})),this.invalidateVisibilityCache()}update(e,t,i){if(!this._dirty)return;this._pageQueue.length>0&&this._addQueuedPages(t),this._invalidateElevationRangeForNewPages(t),this._maxUnloadedPrio=Number.NEGATIVE_INFINITY,this._maxProcessingPrio=Number.NEGATIVE_INFINITY,this._missingPagesAndNodes.clear(),this._prefetchNodes.clear(),this._updates.reset(e),x.clear();let s=!0;const n=new F,o=new F,r=this._imModificationUncategorized;r.clear();const a=new Set,l=(l,d,h)=>{const u=O(l,this._pageSize);if(a.add(u),null==d){let e=this._entryPriority(l);return e===1/0&&(e=this._entryPriority(h)),x.set(u,Math.max(e,x.get(u)||0)),this._loadingPages.has(u)||this._failedPages.has(u)||this._missingPagesAndNodes.push(u),void(this._maxProcessingPrio=Math.max(this._maxProcessingPrio,e))}const c=d.node;if(this._updateNodeFeatureEstimate(c,o),null==c){const e=this._entryPriority(l);return this._loadingNodes.has(l)||this._failedNodes.has(l)||(this._missingPagesAndNodes.push(l),x.set(l,e)),void(this._maxProcessingPrio=Math.max(this._maxProcessingPrio,e))}const g=this._getPage(l);if(0===this._missingPagesAndNodes.length&&!this._useNodePages)for(let e=0;e<d.childCount;e++){const t=g.children[d.childOffset+e],i=this._getNodeInternal(t);null==i||i.node||this._loadingNodes.has(t)||this._failedNodes.has(t)||(x.set(t,this._entryPriority(t)),this._prefetchNodes.push(t))}if(c.failed||c.resources.isEmpty)return void(s&&d.childCount>0&&this._isSelected(c)&&(s=!1));if(this._isLoaded(l)){if(n.known+=c.memory,++n.knownNodes,this._isSelected(c)?d.childCount>0&&(s=!1):(n.unremoved+=c.memory,s=!1),this._needsUpdate(c)){const e=this._entryPriority(l);x.set(l,e),this._maxProcessingPrio=Math.max(this._maxProcessingPrio,e),this._updates.update.push(l)}return}if(c.memory&&(n.known+=c.memory,++n.knownNodes),!this._isSelected(c))return void(this._isReloading(l)&&this._updates.remove.push(l));if(d.childCount>0&&(s=!1),c.memory?(n.missing+=c.memory,n.known+=c.memory,++n.knownNodes):++n.missingNodes,e.includes(c.index))return this._maxProcessingPrio=Math.max(this._maxProcessingPrio,this._entryPriority(l)),void(this._updates.cancel=this._updates.cancel.filter((e=>e!==c.index)));if(!t.done&&this._enable(c))return void t.madeProgress();const f=this._entryPriority(l);x.set(l,f),this._maxProcessingPrio=Math.max(this._maxProcessingPrio,f),this._updates.add.push(l),this.layerHasModifications&&i&&null!=c&&c.imModificationImpact===_.NotChecked&&r.push(l)};this.traverseVisible(l),this._frameNumber++,this._missingPagesAndNodes.sort(((e,t)=>e-t)),this._missingPagesAndNodes.filterInPlace(((e,t)=>t<1||this._missingPagesAndNodes.data[t-1]!==e)),this._missingPagesAndNodes.sort(((e,t)=>x.get(e)-x.get(t))),this._missingPagesAndNodes.length>0&&(this._maxUnloadedPrio=x.get(this._missingPagesAndNodes.back()),this._prefetchNodes.clear());const d=this._updates.add;d.length>0&&this.layerHasModifications&&(r.length>0&&i?.(r),d.filterInPlace((e=>{const t=this._getNodeInternal(e),i=null==t?.node||t.node.imModificationImpact!==_.Culled;return i||this.invalidateNodeVisibilityCache(e),i}))),this._unloadedMemoryEstimate=n.missing-n.unremoved,n.knownNodes>3&&n.missingNodes>0&&(this._unloadedMemoryEstimate+=n.known/n.knownNodes*n.missingNodes),this._unloadedMemoryEstimate=.8*Math.max(0,this._unloadedMemoryEstimate),this._featureEstimate.estimate=this._computeFeatureEstimate(o),this._featureEstimate.leavesReached=s,this._updates.add.filterInPlace((e=>x.get(e)>=this._maxUnloadedPrio)).sort(((e,t)=>x.get(e)-x.get(t))),this._updates.update.sort(((e,t)=>x.get(e)-x.get(t))),this._indexMissing=this._loadingPages.size+this._loadingNodes.size+this._missingPagesAndNodes.length,this._dirty=this._indexMissing>0,x.clear()}checkFeatureTarget(e,t){const i=this._viewportQueries.updateScreenSpaceErrorBias(t);let s=t,n=t,o=i,r=10;for(;r--;){const i=new F;this._updateFeatureEstimate(s,i);if(this._computeFeatureEstimate(i)<=e){if(s>=t||i.missingNodes>0||0===r)break;o=s,s=.5*(s+n)}else n=s,s=.5*(s+o)}return this._version=S(this._version),this._viewportQueries.updateScreenSpaceErrorBias(i),Math.min(t,s)}_updateFeatureEstimate(e,t){this._version=S(this._version),this._viewportQueries.updateScreenSpaceErrorBias(e),this.traverseVisible(((e,i)=>this._updateNodeFeatureEstimate(null!=i?i.node:void 0,t)))}_updateNodeFeatureEstimate(e,t){null==e||e.failed||null==e.numFeatures||this._isSelected(e)&&(null!=e.numFeatures?(t.missing+=e.numFeatures,t.known+=e.numFeatures,++t.knownNodes):++t.missingNodes)}_computeFeatureEstimate(e){let t=e.known-e.unremoved;return e.knownNodes>3&&e.missingNodes>0&&(t+=e.known/e.knownNodes*e.missingNodes),Math.max(0,t)}load(){return this._load(this._missingPagesAndNodes)}prefetch(){return this._prefetchNodes.sort(((e,t)=>x.get(e)-x.get(t))),this._load(this._prefetchNodes)}_load(e){if(0===e.length||!this._canRequest())return!1;for(;e.length>0&&this._canRequest();){const t=e.pop();this._useNodePages&&t>=0?this._loadPage(t):this._loadNode(t)}return!0}get isLoading(){return this._indexMissing>0}get isPrefetching(){return this._prefetchNodes.length>0}get indexLoading(){return this._loadingPages.size+this._loadingNodes.size}get indexMissing(){return this._indexMissing}get unloadedMemoryEstimate(){return this._unloadedMemoryEstimate}get updates(){return this._updates}get featureEstimate(){return this._featureEstimate}get maxPriority(){return Math.max(this._maxProcessingPrio,this._maxUnloadedPrio)}nodeTraversalState(e){if(null==e)return null;const t=e.index,i=this._getNodeInternal(t);if(!i)return null;let s=i?.traversalState;if(s&&M(s.version,this._version))return s;const n=this._viewportQueries.getLodLevel(e),o=this._viewportQueries.hasLOD(e);let r=!0;if(o){const e=this.getParentIndex(t);if(null!=e){const t=this._getNodeInternal(e),i=t?.traversalState;r=!!i&&n>i.lodLevel}else r=n>0}else r=0===e.childCount;return s?(s.lodLevel=n,s.isChosen=r,s.version=R(!0,this._version),s):(s=new f(o,r,n,R(!0,this._version)),i.traversalState=s,s)}async _loadNode(e){this._loadingNodes.add(e);const i=this._getNodeInternal(e).ref;if(null==i)return void this._failedNodes.add(e);const s=i.id,n=this._urlPrefix+s,o=()=>{this._loadingNodes.delete(e),0===this._missingPagesAndNodes.length&&0===this._loadingNodes.size&&this.requestUpdate()};let r=null;try{r=e>=0?await this._streamDataController.request(n,"json"):await this._clientNodeLoader.loadNodeJSON(s)}catch(d){return o(),void(t(d)||(this._logger.error("#loadNode()",this._layer,"Error loading node: "+n),this._failedNodes.add(e)))}o();const a=this._validateNode(s,r);if(null==a)return;a.obb&&this.invalidateNodeVisibilityCache(e);const l=this._addNode(a,e);this.nodeTraversalState(l)}_validateNode(e,t){if(null==t||"object"!=typeof t||t.id!==e)return this._logger.error("#validateNode()",this._layer,`Invalid node. Wrong type or wrong id "${e}"`),null;if(!Array.isArray(t.mbs))return this._logger.error("#validateNode()",this._layer,`Invalid bounding volume on node ${e}.`),null;t.sharedResource&&"./shared"!==t.sharedResource.href&&"./shared/"!==t.sharedResource.href&&this._logger.warn("#validateNode()",this._layer,`Invalid shared resource href on node "${e}"`);const i=t.geometryData;null==i||Array.isArray(i)&&0===i.length||Array.isArray(i)&&1===i.length&&"./geometries/0"===i[0].href||this._logger.warn("#validateNode()",this._layer,`Invalid geometry data on node "${e}"`);const s=t.attributeData,n=this._layer.attributeStorageInfo;null==s||Array.isArray(s)&&!s.some(((e,t)=>e.href!==`./attributes/${n?.[t]?.key??`f_${t}`}/0`))||this._logger.warn("#validateNode()",this._layer,`Invalid attribute data on node "${e}"`),t.featureData&&t.featureData.length>1&&this._logger.warn("#validateNode()",this._layer,`Node ${e} has ${t.featureData.length} bundles. Only the first bundle will be loaded.`);const o=t.hasOwnProperty("obb")&&!this.ignoreServiceObb?t.obb:null,r=t.featureData&&1===t.featureData.length&&t.featureData[0].featureRange?t.featureData[0].featureRange[1]-t.featureData[0].featureRange[0]+1:void 0,a=t=>{if(null==t)return null;const i=t=>this._logger.error("#validateNode()",this._layer,`Invalid node reference on node ${e}: ${t}`);if("number"==typeof t.id)i(`id ${t.id} is a number instead of a string.`);else if("string"!=typeof t.id||!Array.isArray(t.mbs))return i("Missing or invalid id."),null;if(!Array.isArray(t.mbs))return i(`Invalid bounding volume on reference ${t.id}.`),null;t.href&&t.href!=="../"+t.id&&this._logger.error("#validateNode()",this._layer,`Invalid node href on node "${e}"`);const s=t.hasOwnProperty("obb")&&!this.ignoreServiceObb?t.obb:null,n=new u(`${t.id}`,t.mbs);return n.serviceObb=s,n.visibilityObb=this._computeVisibilityObb(n),n},l=Array.isArray(t.children)?t.children.map(a).filter((e=>null!=e)):null,d=t.featureData?.length??!1,h=!0===t.isEmpty;return{id:e,mbs:t.mbs,obb:o,children:l,resources:{isEmpty:!d&&h,hasSharedResource:null!=t.sharedResource,attributes:t.attributeData?e:void 0,texture:t.textureData&&t.textureData.length>0?e:void 0,geometry:null!=t.geometryData?e:void 0},version:"string"==typeof t.version?t.version:null,lodSelection:Array.isArray(t.lodSelection)?t.lodSelection:null,numFeatures:r}}resetFailedNodes(){this._failedNodes.clear(),this._failedPages.clear(),this._forAllNodes((e=>{null!=e.node&&(e.node.failed=!1)}))}_entryPriority(e){const t=this._getNodeInternal(e),i=this.getParentIndex(e);if(null==t||null==i&&null==t.node)return null==i?1/0:this._entryPriority(i);let s=0;if(t.node&&null!=i){const e=this._getNodeInternal(i).traversalState;null!=e&&(s=e.lodLevel)}let n=this.progressiveLoadPenalty;for(let r=e;null!=r;r=this.getParentIndex(r))if(this._isLoaded(r)){n=0;break}const o=null!=t.ref?this._viewportQueries.distToPOI(t.ref):null!=t.node?this._viewportQueries.distToPOI(t.node):0;return-o-s*(o+this.progressiveLoadPenalty)+n}traverseVisible(e){const t=this._getNodeInternal(this._rootIndex);null!=t?this._traverseVisible(this._rootIndex,null,t,e):e(this._rootIndex,null,null)}_traverseVisible(e,t,i,s){if(i.node&&0===i.childCount)return void(this.isGeometryVisible(e)&&s(e,i,t));if(!this.isNodeVisible(e))return;if(s(e,i,t),null==i.node)return;const n=this.nodeTraversalState(i.node);if(n?.nodeHasLOD&&n.lodLevel===this._maxLodLevel)return;const o=this._getPage(e);for(let r=0;r<i.childCount;r++){const t=o.children[i.childOffset+r],n=this._getNodeInternal(t);n?this._traverseVisible(t,e,n,s):s(t,null,e)}}traverse(e,t){t(e)&&this.traverseChildren(e,t)}traverseChildren(e,t){const i=e.index,s=this._getNodeInternal(i);null!=s&&this._traverseChildren(i,s,t)}_traverseChildren(e,t,i){const s=this._getPage(e);if(null==s)return;const n=t.childOffset+t.childCount;for(let o=t.childOffset;o<n;++o){const e=s.children[o],t=this._getNodeInternal(e);null!=t?.node&&i(t.node)&&this._traverseChildren(e,t,i)}}updateChildrenLoaded(e,t){let i=this.getNode(e);for(;null!=i;){const e=i.childrenLoaded,s=e+t;i.childrenLoaded=s;const n=0===e?1:0===s?-1:0,o=i.index;if(0!==n){this._getPage(o).numNodesWithLoadedChildren+=n}i=this.getParent(o)}}checkChildrenLoadedInvariant(){if(null==this.rootNode)return!0;const e=[],t=i=>{let s=this._isLoaded(i.index)||this._isReloading(i.index)?1:0;return this.traverseChildren(i,(e=>(s+=t(e),!1))),i.childrenLoaded!==s&&e.push(i.index),s};return t(this.rootNode),e.length&&this._logger.error("childrenLoaded invariant broken at following nodes: "+e.join(",")),e.length>0}updateStats(e){if(this._updates.add.length>0&&(e.nodes+=" + "+this._updates.add.length),e.index=this._nodePages.size*(this._pageSize||1)+(this._clientNodePage?.nodes.length??0),e.prio=this._maxProcessingPrio,(this._indexMissing||this._prefetchNodes.length>0)&&(e.index+=" + "+this._indexMissing||this._prefetchNodes.length),this._featureEstimate.estimate){const t=this._featureEstimate.estimate-e.features;t>0?e.features+=" + "+t:t<0&&(e.features+=" - "+-t)}}updateElevationInfo(e,t){this.needNodeElevationRange=t&&!!e&&("relative-to-ground"===e.mode||"on-the-ground"===e.mode),this._viewportQueries.updateElevationInfo(e),this.invalidateAllElevationRanges()}invalidateAllElevationRanges(){this._forAllNodes((e=>{C(e),null!=e.node&&e.node.invalidateElevationRange(),null!=e.ref&&e.ref.invalidateElevationRange()}))}_forAllNodes(e){if(null!=this._clientNodePage){const t=this._clientNodePage;for(let i=0;i<t.nodes.length;i++)e(t.nodes[i],-(i+1))}for(const[t,i]of this._nodePages){const s=t*this._pageSize;for(let t=0;t<i.nodes.length;t++)e(i.nodes[t],s+t)}}clearCaches(){if(this._useNodePages){const e=this._nodePages,t=new Set;this.traverseVisible((e=>t.add(O(e,this._pageSize))));for(const[i,s]of e)if(0!==s.numNodesWithLoadedChildren||t.has(i))for(const e of s.nodes)e.traversalState=null;else this._deleteNodePage(i)}}_deleteNodePage(e){this._nodePages.delete(e)}get test(){return{addNode:(e,t)=>this._addNode(e,t),getNodeInternal:e=>this._getNodeInternal(e),getPageIndex:e=>O(e,this._pageSize),getIndexWithinPage:e=>A(e,this._pageSize),getNodePage:e=>e<0?this._clientNodePage:this._nodePages.get(e),getChildIndices:e=>{const t=this._getNodeInternal(e),i=this._getPage(e);if(null==t||null==i)return[];const s=[];for(let n=t.childOffset;n<t.childOffset+t.childCount;++n)s.push(i.children[n]);return s},rootIndex:this._rootIndex,clientNodePage:this._clientNodePage,nodePages:this._nodePages}}}const x=new Map;class I{constructor(t){this.missing=t,this.update=new e({deallocator:null}),this.add=new e({deallocator:null}),this.remove=new e({deallocator:null}),this.cancel=[]}reset(e){this.add.clear(),this.update.clear(),this.cancel=e}}function C(e){null!=e.node&&(m(e.node.renderMbs),v(e.node.serviceObbInRenderSR)),null!=e.ref&&(m(e.ref.renderMbs),v(e.ref.serviceObbInRenderSR))}function w(e){return N(e,-2)}function S(e){return N(e,2)}function R(e,t){return t+(e?1:0)}function M(e,t){return(-2&e)===t}function E(e){return 1==(1&e)}function O(e,t){return e<0?-1:t>0?e/t|0:0}function A(e,t){return e<0?-e-1:0===t?e:e%t}function V(e,t,i){return-1===t?-(e+1):0===i?e:t*i+e}const L=[["maxScreenThreshold",h.MaxScreenThreshold],["screenSpaceRelative",h.ScreenSpaceRelative],["removedFeatureDiameter",h.RemovedFeatureDiameter],["distanceRangeFromDefaultCamera",h.DistanceRangeFromDefaultCamera]];function k(e){if(e)for(let t=0;t<e.length;t++)for(const i of L)if(i[0]===e[t].metricType)return{lodMetric:i[1],maxError:e[t].maxError};return{lodMetric:h.None,maxError:0}}class F{constructor(){this.known=0,this.knownNodes=0,this.missing=0,this.missingNodes=0,this.unremoved=0}}function z(e){return Math.sqrt(e*(4/Math.PI))}const D=a(),T=a(),Q=a(),U=a();export{P as I3SIndex,k as selectErrorMetric};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{r as t,d as i}from"../../../chunks/Responsive.js";import"../../../intl.js";import{binaryFindClosest as e}from"../../../core/arrayUtils.js";import{handlesGroup as n,makeHandle as o}from"../../../core/handleUtils.js";import{throwIfAborted as s}from"../../../core/promiseUtils.js";import{signal as a}from"../../../core/signal.js";import{formatDecimal as l,unitName as r}from"../../../core/unitFormatUtils.js";import{convertUnit as d}from"../../../core/unitUtils.js";import{g as c}from"../../../chunks/common.js";import{getConfig as p,notAvailable as m}from"./constants.js";import{getTranslatedLineTitle as u}from"./intlUtils.js";import{niceScale as f}from"./niceScale.js";import{c as x,N as g}from"../../../chunks/chartUtilsAm5.js";import{isRTL as h}from"../../support/widgetUtils.js";import{isDarkTheme as A}from"../../../support/themeUtils.js";import{X as v,V as b,A as y,a as T,b as L,L as M}from"../../../chunks/LineSeries.js";import{aq as S,a6 as F,a4 as k,C as P}from"../../../chunks/Theme.js";import{T as X}from"../../../chunks/Tooltip.js";import{substitute as Y}from"../../../intl/substitute.js";import{formatNumber as z}from"../../../intl/number.js";const C="#f8f8f8",j="#a9a9a9",w="#323232",H="line",B="fill",U=15,D=12,R=.001,O=.1,W=.02,G={fontFamily:"Avenir Next",paddingBottom:D/2,paddingLeft:0,paddingRight:0,paddingTop:0,axisGridStroke:"#f4f4f4",axisLabelsFontSize:9,axisLabelsFontWeight:"400",axisLabelsColor:j,axisTooltipFontSize:12,axisTooltipBackgroundColor:w,axisTooltipLabelColor:C,axisTooltipPaddingTop:Math.round(D/4),axisTooltipPaddingBottom:Math.round(D/4),axisTooltipPaddingHorizontal:Math.round(U/4),xAxisMinGridDistance:50,xAxisLabelsSpacing:Math.round(D/2),xAxisMinLabelPosition:.05,xAxisMaxLabelPosition:.9,yAxisMinGridDistance:30,yAxisLabelSpacing:Math.round(U/4),yAxisMinLabelPosition:0,yAxisMaxLabelPosition:.8,seriesTooltipFontSize:12,seriesTooltipBackgroundColor:C,seriesTooltipLabelColor:w,seriesFillLighten:.9,seriesTooltipSpacing:D/2,seriesTooltipPaddingVertical:Math.round(U/4),seriesTooltipPaddingHorizontal:Math.round(U/4)},V={...G,axisGridStroke:w,axisLabelsColor:j,axisTooltipBackgroundColor:w,axisTooltipLabelColor:C,seriesTooltipBackgroundColor:w,seriesTooltipLabelColor:C,seriesFillLighten:-.75},E={minX:void 0,maxX:void 0,minY:void 0,maxY:void 0};async function I(e){const o=await x(e.container);s(e.abortOptions);const l=A(),r=l?V:G;o.setThemes(l?[t.new(o),i.new(o)]:[t.new(o)]);const d=h(e.container),c=o.container.children.push(v.new(o,{panX:!0,panY:!0,paddingTop:r.paddingTop,paddingBottom:r.paddingBottom,paddingLeft:d?r.paddingRight:r.paddingLeft,paddingRight:d?r.paddingLeft:r.paddingRight,maxTooltipDistance:0}));c.zoomOutButton.set("forceHidden",!0);const p=c.xAxes.push(b.new(o,{renderer:y.new(o,{})})),m=c.yAxes.push(b.new(o,{renderer:T.new(o,{})})),u=a(null),f=a("loading"),g={params:e,chart:c,xAxis:p,yAxis:m,seriesInfos:new Map,messages:null,theme:r,pointerIsOver:!1,get state(){return f.value},get data(){return u.value},set data(t){u.value=t}};Z(g),q(g),N(g);const L=n([lt(g,e.onRangeChange),dt(g,e.onCursorPositionChange),yt(o.events.once("frameended",(()=>{f.value="ready"}))),yt(o)]);return{destroy:()=>{L.remove(),f.value="destroyed"},update:t=>{t.data===g.data&&t.messages===g.messages||$(g)||J(g,t)},zoomOut:()=>K(g)}}function $(t){return"destroyed"===t.state}function N({chart:t,xAxis:i,yAxis:e}){const n=L.new(t.root,{behavior:"none",xAxis:i,yAxis:e});n.lineY.set("visible",!1),t.set("cursor",n)}function Z(t){const{chart:i,xAxis:e,theme:n}=t;e.setAll({extraMax:0,extraMin:0,maxDeviation:0,numberFormatter:gt(t,"distance"),strictMinMax:!0,strictMinMaxSelection:!0}),e.axisHeader.set("forceHidden",!0);const o=e.get("renderer");o.setAll({inside:!1,minGridDistance:n.xAxisMinGridDistance}),o.labels.template.setAll({centerX:S,centerY:S,fill:F(n.axisLabelsColor),fontFamily:n.fontFamily,fontSize:n.axisLabelsFontSize,fontWeight:n.axisLabelsFontWeight,maxPosition:n.xAxisMaxLabelPosition,minPosition:n.xAxisMinLabelPosition,paddingLeft:0,paddingRight:0,paddingTop:n.xAxisLabelsSpacing});const s=e.set("tooltip",X.new(i.root,{paddingBottom:0,paddingLeft:0,paddingRight:0,paddingTop:0}));s.get("background")?.setAll({fill:F(n.axisTooltipBackgroundColor),stroke:void 0}),s.label.setAll({fill:F(n.axisTooltipLabelColor),fontFamily:n.fontFamily,fontSize:n.axisTooltipFontSize,paddingBottom:n.axisTooltipPaddingBottom,paddingLeft:n.axisTooltipPaddingHorizontal,paddingRight:n.axisTooltipPaddingHorizontal,paddingTop:n.axisTooltipPaddingTop}),o.grid.template.setAll({strokeOpacity:1,stroke:F(n.axisGridStroke)})}function q(t){const{yAxis:i,theme:e}=t;i.setAll({baseValue:p().noDataValue,extraMax:0,extraMin:0,maxDeviation:0,numberFormatter:gt(t,"elevation"),strictMinMax:!0,strictMinMaxSelection:!0,tooltip:void 0}),i.axisHeader.set("visible",!1);const n=h(t.params.container),o=i.get("renderer");o.setAll({minGridDistance:e.yAxisMinGridDistance,opposite:n,inside:!0}),o.labels.template.setAll({centerX:S,centerY:k,fill:F(e.axisLabelsColor),fontFamily:e.fontFamily,fontSize:e.axisLabelsFontSize,fontWeight:e.axisLabelsFontWeight,maxPosition:e.yAxisMaxLabelPosition,minPosition:e.yAxisMinLabelPosition,paddingBottom:0,paddingLeft:n?0:e.yAxisLabelSpacing,paddingRight:n?e.yAxisLabelSpacing:0,paddingTop:0,textAlign:"start"}),o.grid.template.setAll({strokeOpacity:1,stroke:F(e.axisGridStroke)})}function J(t,i){if($(t))return;const e=t.data??void 0,n=i.data??void 0;t.chart.get("cursor")?.set("forceHidden",!n?.refined);const o=e!==n,s=e?.effectiveUnits!==n?.effectiveUnits,a=e?.uniformScaling!==n?.uniformScaling;t.data=n,t.messages=i.messages,(o||s)&&(Q(t),et(t)),a&&K(t),pt(t)}function K(t){$(t)||(t.xAxis.zoom(0,1),t.yAxis.zoom(0,1))}function Q(t){const{chart:i,data:e,xAxis:n,yAxis:o}=t,{minX:s,maxX:a,minY:l,maxY:r}=_({data:e,pixelWidth:n.width(),pixelHeight:o.height()}),d=e?.uniformScaling;i.setAll({panX:!0,panY:d,pinchZoomX:!0,pinchZoomY:d,wheelX:"panX",wheelY:d?"zoomXY":"zoomX"}),n.setAll({max:a,min:s,panX:!0,panY:!1,zoomX:!0,zoomY:d}),o.setAll({max:r,min:l,panX:!1,panY:d,zoomX:d,zoomY:d})}function _({data:t,pixelWidth:i,pixelHeight:e}){if(null==t)return E;const n=t.statistics,o=0,s=n?.maxDistance;let a=n?.minElevation,l=n?.maxElevation;if(null==s||null==a||null==l)return E;const r=Math.max(s-o,R);let c=Math.max(l-a,R);const m=t.effectiveUnits;if(t.dynamicElevationRange){const t=d(r,m.distance,m.elevation);c=Math.max(c,t/p().maxChartRatio)}return a-=W*c,l=a+c+O*c,[a,l]=f(a,l,10),c=l-a,t.uniformScaling?tt({data:t,bounds:{minX:o,maxX:s,minY:a,maxY:l},pixelWidth:i,pixelHeight:e,centered:!0}):{minX:o,maxX:o+r,minY:a,maxY:a+c}}function tt({data:t,bounds:i,pixelWidth:e,pixelHeight:n,centered:o}){if(null==t)return i;let{minX:s,maxX:a,minY:l,maxY:r}=i;if(null==s||null==a||null==l||null==r)return E;const c=a-s,p=r-l,m=t.effectiveUnits,u=d(p,m.elevation,m.distance)/n/(c/e);return u>=1?[s,a]=it([s,a],u,o):[l,r]=it([l,r],1/u,o),{minX:s,maxX:a,minY:l,maxY:r}}function it([t,i],e,n){const o=(i-t)*e;if(n){const e=(t+i)/2-o/2;return[e,e+o]}return[t,t+o]}function et(t){const{chart:i,data:e,seriesInfos:n,xAxis:o,yAxis:s}=t;if(null==e||0===e.lines.length)return void i.series.clear();const a=new Map,l=new Set(i.series.values),r=e.lines.length;for(let d=0;d<r;d++){const o=e.lines[d];let s=n.get(o.id);s?(s.fill&&l.delete(s.fill),l.delete(s.line)):(s=ot(t,o),s.fill&&i.series.push(s.fill),i.series.push(s.line)),a.set(s.id,s);const c=r-d-1;s.fill?.set("layer",c),s.line.set("layer",r+c),nt(t,s,o)}t.seriesInfos=a;for(const d of l)i.series.removeValue(d);o.set("layer",r+1),s.set("layer",r+2)}function nt({theme:t},i,e){const n=F(e.color.toCss()),o=e.samples??[],s=o.length>0,{line:a,fill:l}=i;a.set("visible",s),a.set("stroke",n),l?.set("visible",s),l?.set("fill",P.lighten(n,t.seriesFillLighten)),a.data.setAll(o),l?.data.setAll(o)}function ot(t,i){const{id:e}=i,n=st(t,`${H}-${e}`);n.setAll({dy:i.chartStrokeOffsetY,tooltip:at(t)}),n.strokes.template.setAll({strokeWidth:i.chartStrokeWidth});let o=null;return i.chartFillEnabled&&(o=st(t,`${B}-${e}`),o.fills.template.setAll({fillOpacity:1,visible:!0})),{id:e,line:n,fill:o}}function st(t,i){return M.new(t.chart.root,{connect:!1,excludeFromTotal:!0,fill:void 0,id:i,stroke:void 0,valueXField:"distance",valueYField:"elevation",xAxis:t.xAxis,yAxis:t.yAxis})}function at({theme:t,chart:i}){const e=X.new(i.root,{forceHidden:!0,getFillFromSprite:!1,getLabelFillFromSprite:!1,pointerOrientation:"vertical",visible:!1}),n=t.seriesTooltipPaddingHorizontal,o=t.seriesTooltipPaddingVertical;return e.label.setAll({fill:F(t.seriesTooltipLabelColor),fontFamily:t.fontFamily,fontSize:t.seriesTooltipFontSize,paddingBottom:o,paddingLeft:n,paddingRight:n,paddingTop:o,textAlign:"start"}),e.get("background")?.setAll({stroke:void 0,fill:F(t.seriesTooltipBackgroundColor)}),e.adapters.add("dy",(i=>{const n=t.seriesTooltipSpacing,o=e.get("pointTo")?.y??0;return(i??0)+(e.y()>o?n:-n)})),e}function lt(t,i){const{xAxis:e,yAxis:n}=t,o=()=>{i(rt(e),rt(n))},s=t=>[t.on("start",o),t.on("end",o)];return bt([...s(e),...s(n)])}function rt(t){const i=Math.abs((t.get("end")??0)-(t.get("start")??0)),e=0!==i?1/i:1;return Math.abs(1-e)<c()?1:e}function dt(t,i){const{chart:e,xAxis:n,yAxis:o}=t,s=e.get("cursor"),a=e.plotContainer.events,l=i=>{t.pointerIsOver=i,pt(t)},r=()=>{l(!1),i(null,null)};return bt([s?.events.on("cursormoved",(()=>{if(!t.pointerIsOver)return;pt(t);let e=s?.getPrivate("positionX")??0,a=s?.getPrivate("positionY")??0;const l=t.data;if(null!=l?.statistics){const{maxDistance:t,minElevation:i,maxElevation:s}=l.statistics;if(null!=t){e=ct(e,At(n),vt(n),0,t)}if(null!=i&&null!=s){a=ct(a,At(o),vt(o),i,s)}}i(e,a)})),a.on("pointerover",(()=>l(!0))),a.on("pointerout",r),a.on("blur",r)])}function ct(t,i,e,n,o){return(i+t*(e-i)-n)/(o-n)}function pt(t){const i=mt(t);if(!i)return void t.seriesInfos.forEach((t=>{t.line.get("tooltip")?.set("forceHidden",!0)}));t.seriesInfos.forEach((t=>{const e=t.line.get("tooltip");e.set("forceHidden",!1),e.label.set("text",i)}));t.xAxis.getTooltip().setAll({tooltipText:xt(t)})}function mt(t){const{data:i}=t,e=i?.lines.map((i=>({line:i,y:ht(t,i)?.elevation}))).sort(ut);return e&&0!==e.length&&null!=e[0].y?e.map((({y:i,line:e})=>ft(t,e,i))).join("\n"):null}function ut({y:t},{y:i}){return null==t?1:null==i?-1:i-t}function ft(t,i,e){const{data:n,messages:o}=t;if(null==n||null==o)return"";const s=p().formatPrecision,a=Y(o.chartTooltip,{name:u(i,o),elevation:null!=e?l(o,e,n.effectiveUnits.elevation,s):m});return`[${i.color.toHex()}]●[/] ${a}`}function xt(t){const{data:i,messages:e}=t;if(null==i||null==e)return"";const n=i.lines[0],o=n?ht(t,n):null,s=p().formatPrecision;return null!=o?l(e,o.distance,i.effectiveUnits.distance,s):"-"}function gt(t,i){const e=g.new(t.chart.root,{});return e.format=(e,n,o)=>{const{data:s,messages:a}=t;if(null==a||null==s||"string"==typeof e)return"";return`${z(e,{maximumFractionDigits:o})} ${r(a,s.effectiveUnits[i],"abbr")}`},e}function ht({chart:t,xAxis:i},n){const o=n.samples??[];if(0===o.length)return null;const s=t.get("cursor"),a=s?.getPrivate("positionX")??0,l=i.toAxisPosition(a),r=i.positionToValue(l);return e(o,r,(t=>t.distance))}function At(t){return t.positionToValue(t.get("start")??0)}function vt(t){return t.positionToValue(t.get("end")??1)}function bt(t){return n(t.map(yt))}function yt(t){return o((()=>{t?.dispose()}))}export{I as createChart,_ as getAdjustedBounds};
5
+ import{r as t,d as i}from"../../../chunks/Responsive.js";import"../../../intl.js";import{binaryFindClosest as e}from"../../../core/arrayUtils.js";import{handlesGroup as n,makeHandle as o}from"../../../core/handleUtils.js";import{throwIfAborted as s}from"../../../core/promiseUtils.js";import{signal as a}from"../../../core/signal.js";import{formatDecimal as l,unitName as r}from"../../../core/unitFormatUtils.js";import{convertUnit as d}from"../../../core/unitUtils.js";import{g as c}from"../../../chunks/common.js";import{getConfig as p,notAvailable as m}from"./constants.js";import{getTranslatedLineTitle as u}from"./intlUtils.js";import{niceScale as f}from"./niceScale.js";import{c as x,N as g}from"../../../chunks/chartUtilsAm5.js";import{isRTL as h}from"../../support/widgetUtils.js";import{isDarkTheme as A}from"../../../support/themeUtils.js";import{X as v,V as b,A as y,a as T,b as L,L as M}from"../../../chunks/LineSeries.js";import{aq as S,a6 as F,a4 as k,C as P}from"../../../chunks/Theme.js";import{T as X}from"../../../chunks/Tooltip.js";import{substitute as Y}from"../../../intl/substitute.js";import{formatNumber as z}from"../../../intl/number.js";const C="#f8f8f8",j="#a9a9a9",w="#323232",H="line",B="fill",U=15,D=12,R=.001,O=.1,W=.02,G={fontFamily:"Avenir Next",paddingBottom:D/2,paddingLeft:0,paddingRight:0,paddingTop:0,axisGridStroke:"#f4f4f4",axisLabelsFontSize:9,axisLabelsFontWeight:"400",axisLabelsColor:j,axisTooltipFontSize:12,axisTooltipBackgroundColor:w,axisTooltipLabelColor:C,axisTooltipPaddingTop:Math.round(D/4),axisTooltipPaddingBottom:Math.round(D/4),axisTooltipPaddingHorizontal:Math.round(U/4),xAxisMinGridDistance:50,xAxisLabelsSpacing:Math.round(D/2),xAxisMinLabelPosition:.05,xAxisMaxLabelPosition:.9,yAxisMinGridDistance:30,yAxisLabelSpacing:Math.round(U/4),yAxisMinLabelPosition:0,yAxisMaxLabelPosition:.8,seriesTooltipFontSize:12,seriesTooltipBackgroundColor:C,seriesTooltipLabelColor:w,seriesFillLighten:.9,seriesTooltipSpacing:D/2,seriesTooltipPaddingVertical:Math.round(U/4),seriesTooltipPaddingHorizontal:Math.round(U/4)},V={...G,axisGridStroke:w,axisLabelsColor:j,axisTooltipBackgroundColor:w,axisTooltipLabelColor:C,seriesTooltipBackgroundColor:w,seriesTooltipLabelColor:C,seriesFillLighten:-.75},E={minX:void 0,maxX:void 0,minY:void 0,maxY:void 0};async function I(e){const o=await x(e.container);s(e.abortOptions);const l=A(),r=l?V:G;o.setThemes(l?[t.new(o),i.new(o)]:[t.new(o)]);const d=h(e.container),c=o.container.children.push(v.new(o,{panX:!0,panY:!0,paddingTop:r.paddingTop,paddingBottom:r.paddingBottom,paddingLeft:d?r.paddingRight:r.paddingLeft,paddingRight:d?r.paddingLeft:r.paddingRight,maxTooltipDistance:0}));c.zoomOutButton.set("forceHidden",!0);const p=c.xAxes.push(b.new(o,{renderer:y.new(o,{})})),m=c.yAxes.push(b.new(o,{renderer:T.new(o,{})})),u=a(null),f=a("loading"),g={params:e,chart:c,xAxis:p,yAxis:m,seriesInfos:new Map,messages:null,theme:r,pointerIsOver:!1,get state(){return f.value},get data(){return u.value},set data(t){u.value=t}};Z(g),q(g),N(g);const L=n([lt(g,e.onRangeChange),dt(g,e.onCursorPositionChange),yt(o.events.once("frameended",(()=>{f.value="ready"}))),yt(o)]);return{destroy:()=>{L.remove(),f.value="destroyed"},update:t=>{t.data===g.data&&t.messages===g.messages||$(g)||J(g,t)},zoomOut:()=>K(g)}}function $(t){return"destroyed"===t.state}function N({chart:t,xAxis:i,yAxis:e}){const n=L.new(t.root,{behavior:"none",xAxis:i,yAxis:e});n.lineY.set("visible",!1),t.set("cursor",n)}function Z(t){const{chart:i,xAxis:e,theme:n}=t;e.setAll({extraMax:0,extraMin:0,maxDeviation:0,numberFormatter:gt(t,"distance"),strictMinMax:!0,strictMinMaxSelection:!0}),e.axisHeader.set("forceHidden",!0);const o=e.get("renderer");o.setAll({inside:!1,minGridDistance:n.xAxisMinGridDistance}),o.labels.template.setAll({centerX:S,centerY:S,fill:F(n.axisLabelsColor),fontFamily:n.fontFamily,fontSize:n.axisLabelsFontSize,fontWeight:n.axisLabelsFontWeight,maxPosition:n.xAxisMaxLabelPosition,minPosition:n.xAxisMinLabelPosition,paddingLeft:0,paddingRight:0,paddingTop:n.xAxisLabelsSpacing});const s=e.set("tooltip",X.new(i.root,{paddingBottom:0,paddingLeft:0,paddingRight:0,paddingTop:0}));s.get("background")?.setAll({fill:F(n.axisTooltipBackgroundColor),stroke:void 0}),s.label.setAll({fill:F(n.axisTooltipLabelColor),fontFamily:n.fontFamily,fontSize:n.axisTooltipFontSize,paddingBottom:n.axisTooltipPaddingBottom,paddingLeft:n.axisTooltipPaddingHorizontal,paddingRight:n.axisTooltipPaddingHorizontal,paddingTop:n.axisTooltipPaddingTop}),o.grid.template.setAll({strokeOpacity:1,stroke:F(n.axisGridStroke)})}function q(t){const{yAxis:i,theme:e}=t;i.setAll({baseValue:p().noDataValue,extraMax:0,extraMin:0,maxDeviation:0,numberFormatter:gt(t,"elevation"),strictMinMax:!0,strictMinMaxSelection:!0,tooltip:void 0}),i.axisHeader.set("visible",!1);const n=h(t.params.container),o=i.get("renderer");o.setAll({minGridDistance:e.yAxisMinGridDistance,opposite:n,inside:!0}),o.labels.template.setAll({centerX:S,centerY:k,fill:F(e.axisLabelsColor),fontFamily:e.fontFamily,fontSize:e.axisLabelsFontSize,fontWeight:e.axisLabelsFontWeight,maxPosition:e.yAxisMaxLabelPosition,minPosition:e.yAxisMinLabelPosition,paddingBottom:0,paddingLeft:n?0:e.yAxisLabelSpacing,paddingRight:n?e.yAxisLabelSpacing:0,paddingTop:0,textAlign:"start"}),o.grid.template.setAll({strokeOpacity:1,stroke:F(e.axisGridStroke)})}function J(t,i){if($(t))return;const e=t.data??void 0,n=i.data??void 0;t.chart.get("cursor")?.set("forceHidden",!n?.refined);const o=e!==n,s=e?.effectiveUnits!==n?.effectiveUnits,a=e?.uniformScaling!==n?.uniformScaling;t.data=n,t.messages=i.messages,(o||s)&&(Q(t),et(t)),a&&K(t),pt(t)}function K(t){$(t)||(t.xAxis.zoom(0,1),t.yAxis.zoom(0,1))}function Q(t){const{chart:i,data:e,xAxis:n,yAxis:o}=t,{minX:s,maxX:a,minY:l,maxY:r}=_({data:e,pixelWidth:n.width(),pixelHeight:o.height()}),d=!!e?.uniformScaling,c=!!e?.refined;i.setAll({panX:!0,panY:d,pinchZoomX:c,pinchZoomY:c&&d,wheelX:"panX",wheelY:c?d?"zoomXY":"zoomX":"none"}),n.setAll({max:a,min:s,panX:!0,panY:!1,zoomX:!0,zoomY:d}),o.setAll({max:r,min:l,panX:!1,panY:d,zoomX:d,zoomY:d})}function _({data:t,pixelWidth:i,pixelHeight:e}){if(null==t)return E;const n=t.statistics,o=0,s=n?.maxDistance;let a=n?.minElevation,l=n?.maxElevation;if(null==s||null==a||null==l)return E;const r=Math.max(s-o,R);let c=Math.max(l-a,R);const m=t.effectiveUnits;if(t.dynamicElevationRange){const t=d(r,m.distance,m.elevation);c=Math.max(c,t/p().maxChartRatio)}return a-=W*c,l=a+c+O*c,[a,l]=f(a,l,10),c=l-a,t.uniformScaling?tt({data:t,bounds:{minX:o,maxX:s,minY:a,maxY:l},pixelWidth:i,pixelHeight:e,centered:!0}):{minX:o,maxX:o+r,minY:a,maxY:a+c}}function tt({data:t,bounds:i,pixelWidth:e,pixelHeight:n,centered:o}){if(null==t)return i;let{minX:s,maxX:a,minY:l,maxY:r}=i;if(null==s||null==a||null==l||null==r)return E;const c=a-s,p=r-l,m=t.effectiveUnits,u=d(p,m.elevation,m.distance)/n/(c/e);return u>=1?[s,a]=it([s,a],u,o):[l,r]=it([l,r],1/u,o),{minX:s,maxX:a,minY:l,maxY:r}}function it([t,i],e,n){const o=(i-t)*e;if(n){const e=(t+i)/2-o/2;return[e,e+o]}return[t,t+o]}function et(t){const{chart:i,data:e,seriesInfos:n,xAxis:o,yAxis:s}=t;if(null==e||0===e.lines.length)return void i.series.clear();const a=new Map,l=new Set(i.series.values),r=e.lines.length;for(let d=0;d<r;d++){const o=e.lines[d];let s=n.get(o.id);s?(s.fill&&l.delete(s.fill),l.delete(s.line)):(s=ot(t,o),s.fill&&i.series.push(s.fill),i.series.push(s.line)),a.set(s.id,s);const c=r-d-1;s.fill?.set("layer",c),s.line.set("layer",r+c),nt(t,s,o)}t.seriesInfos=a;for(const d of l)i.series.removeValue(d);o.set("layer",r+1),s.set("layer",r+2)}function nt({theme:t},i,e){const n=F(e.color.toCss()),o=e.samples??[],s=o.length>0,{line:a,fill:l}=i;a.set("visible",s),a.set("stroke",n),l?.set("visible",s),l?.set("fill",P.lighten(n,t.seriesFillLighten)),a.data.setAll(o),l?.data.setAll(o)}function ot(t,i){const{id:e}=i,n=st(t,`${H}-${e}`);n.setAll({dy:i.chartStrokeOffsetY,tooltip:at(t)}),n.strokes.template.setAll({strokeWidth:i.chartStrokeWidth});let o=null;return i.chartFillEnabled&&(o=st(t,`${B}-${e}`),o.fills.template.setAll({fillOpacity:1,visible:!0})),{id:e,line:n,fill:o}}function st(t,i){return M.new(t.chart.root,{connect:!1,excludeFromTotal:!0,fill:void 0,id:i,stroke:void 0,valueXField:"distance",valueYField:"elevation",xAxis:t.xAxis,yAxis:t.yAxis})}function at({theme:t,chart:i}){const e=X.new(i.root,{forceHidden:!0,getFillFromSprite:!1,getLabelFillFromSprite:!1,pointerOrientation:"vertical",visible:!1}),n=t.seriesTooltipPaddingHorizontal,o=t.seriesTooltipPaddingVertical;return e.label.setAll({fill:F(t.seriesTooltipLabelColor),fontFamily:t.fontFamily,fontSize:t.seriesTooltipFontSize,paddingBottom:o,paddingLeft:n,paddingRight:n,paddingTop:o,textAlign:"start"}),e.get("background")?.setAll({stroke:void 0,fill:F(t.seriesTooltipBackgroundColor)}),e.adapters.add("dy",(i=>{const n=t.seriesTooltipSpacing,o=e.get("pointTo")?.y??0;return(i??0)+(e.y()>o?n:-n)})),e}function lt(t,i){const{xAxis:e,yAxis:n}=t,o=()=>{i(rt(e),rt(n))},s=t=>[t.on("start",o),t.on("end",o)];return bt([...s(e),...s(n)])}function rt(t){const i=Math.abs((t.get("end")??0)-(t.get("start")??0)),e=0!==i?1/i:1;return Math.abs(1-e)<c()?1:e}function dt(t,i){const{chart:e,xAxis:n,yAxis:o}=t,s=e.get("cursor"),a=e.plotContainer.events,l=i=>{t.pointerIsOver=i,pt(t)},r=()=>{l(!1),i(null,null)};return bt([s?.events.on("cursormoved",(()=>{if(!t.pointerIsOver)return;pt(t);let e=s?.getPrivate("positionX")??0,a=s?.getPrivate("positionY")??0;const l=t.data;if(null!=l?.statistics){const{maxDistance:t,minElevation:i,maxElevation:s}=l.statistics;if(null!=t){e=ct(e,At(n),vt(n),0,t)}if(null!=i&&null!=s){a=ct(a,At(o),vt(o),i,s)}}i(e,a)})),a.on("pointerover",(()=>l(!0))),a.on("pointerout",r),a.on("blur",r)])}function ct(t,i,e,n,o){return(i+t*(e-i)-n)/(o-n)}function pt(t){const i=mt(t);if(!i)return void t.seriesInfos.forEach((t=>{t.line.get("tooltip")?.set("forceHidden",!0)}));t.seriesInfos.forEach((t=>{const e=t.line.get("tooltip");e.set("forceHidden",!1),e.label.set("text",i)}));t.xAxis.getTooltip().setAll({tooltipText:xt(t)})}function mt(t){const{data:i}=t,e=i?.lines.map((i=>({line:i,y:ht(t,i)?.elevation}))).sort(ut);return e&&0!==e.length&&null!=e[0].y?e.map((({y:i,line:e})=>ft(t,e,i))).join("\n"):null}function ut({y:t},{y:i}){return null==t?1:null==i?-1:i-t}function ft(t,i,e){const{data:n,messages:o}=t;if(null==n||null==o)return"";const s=p().formatPrecision,a=Y(o.chartTooltip,{name:u(i,o),elevation:null!=e?l(o,e,n.effectiveUnits.elevation,s):m});return`[${i.color.toHex()}]●[/] ${a}`}function xt(t){const{data:i,messages:e}=t;if(null==i||null==e)return"";const n=i.lines[0],o=n?ht(t,n):null,s=p().formatPrecision;return null!=o?l(e,o.distance,i.effectiveUnits.distance,s):"-"}function gt(t,i){const e=g.new(t.chart.root,{});return e.format=(e,n,o)=>{const{data:s,messages:a}=t;if(null==a||null==s||"string"==typeof e)return"";return`${z(e,{maximumFractionDigits:o})} ${r(a,s.effectiveUnits[i],"abbr")}`},e}function ht({chart:t,xAxis:i},n){const o=n.samples??[];if(0===o.length)return null;const s=t.get("cursor"),a=s?.getPrivate("positionX")??0,l=i.toAxisPosition(a),r=i.positionToValue(l);return e(o,r,(t=>t.distance))}function At(t){return t.positionToValue(t.get("start")??0)}function vt(t){return t.positionToValue(t.get("end")??1)}function bt(t){return n(t.map(yt))}function yt(t){return o((()=>{t?.dispose()}))}export{I as createChart,_ as getAdjustedBounds};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../core/Error.js";import{property as i}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as l}from"../../core/accessorSupport/decorators/subclass.js";import{CodedValue as n}from"../../layers/support/CodedValue.js";import r from"../../layers/support/CodedValueDomain.js";import"../../layers/support/Domain.js";import"../../layers/support/InheritedDomain.js";import"../../layers/support/RangeDomain.js";import{getDomainRange as s,validateDomainValue as u}from"../../layers/support/domainUtils.js";import{isFieldVisibleByDefault as o,getLowerCaseEditTrackingFields as a,isNumericField as p,isStringField as d,isTimeOnlyField as m,getFieldRange as y,TypeValidationError as h,NumericRangeValidationError as f,validateFieldValue as c}from"../../layers/support/fieldUtils.js";import{isAnyDateField as g}from"../../smartMapping/support/utils.js";import{isRelatableFeatureSupportedLayer as b}from"../Feature/support/featureUtils.js";import v from"./EditableInput.js";import{parseFormTemplateString as E,getNormalizedFeatureTypeInfo as x,isFieldElementWithInputType as _,valueIsInvalidSwitchValue as V,isFieldElementWithTextInput as T,isFieldElementWithShowNoValueOptionInput as F,LengthValidationError as D}from"./featureFormUtils.js";import{timeResolutionToStepMap as w,isArcadeDate as N,arcadeDateToFieldValue as I,valueIsInRange as j}from"../support/dateUtils.js";var O;!function(e){e.Text="text",e.Number="number",e.Date="date",e.Unsupported="unsupported"}(O||(O={}));const A="__internal-type-based-coded-value-domain__";let L=class extends v{constructor(e){super(e),this._storedValue=null,this.error=null,this.preservesValueWhenHidden=!0,this.field=null,this.group=null,this.requiredExpressionExecutor=null,this.type="field",this._fieldInputWasVisibleDuringLifetime=!1,this.valueExpressionExecutor=null}get _dateRange(){const{element:e}=this;if("datetime-picker"===e?.input?.type){const{max:t,min:i}=e.input;return{max:t,min:i}}return{min:null,max:null}}get _configAllowsEdits(){const{element:e,layer:t,name:i}=this;if(null!=e)return e.editableExpression?!!this.evaluatedEditableExpression:!1!==e.editable;if(t?.userHasUpdateItemPrivileges)return!0;const l=t&&"popupTemplate"in t?t?.popupTemplate?.fieldInfos?.find((({fieldName:e})=>e===i)):null;return l?.isEditable??!0}get _layerAndFieldAllowEdits(){return this.layerAllowsEdits&&this.field?.editable}get _isVisibleByDefault(){const{field:e,layer:t}=this;return!!e?.visible&&o(e,t)}get _isEditTrackingField(){return a(this.layer).includes(this.name?.toLowerCase())}get _shouldUseValueExpression(){return this._layerAndFieldAllowEdits&&!this._configAllowsEdits&&null!=this.valueExpressionExecutor}get _isSubtypeField(){const{layer:e}=this;if(e&&"subtypeField"in e){const{subtypeField:t,fieldsIndex:i}=e;return(i.get(t)?.name??t)===this.name}return!1}get test(){return{_isSubtypeField:this._isSubtypeField}}get dataType(){const{field:e}=this;return p(e)?O.Number:d(e)?O.Text:g(e)||m(e)?O.Date:O.Unsupported}get dateDataType(){if(this.dataType===O.Date)return"date"!==this.field.type?"string":"number"}get description(){const{element:e,feature:t,layer:i,timeZone:l}=this,n=e?.description;return null!=i&&null!=n?E({label:n,attributes:t.attributes,fieldsIndex:i.fieldsIndex,timeZone:l}):n}get domain(){const{layer:e}=this,{typeFieldName:t,types:i}=x(e);if(this._isSubtypeField&&"subtypes"in e&&e.subtypes)return new r({name:A,codedValues:e.subtypes.map((({code:e,name:t})=>new n({code:e,name:t})))});if(t===this.name&&null==this.field.domain)return new r({name:A,codedValues:i.map((({code:e,name:t})=>new n({code:e,name:t})))});const{feature:l}=this,s=e?.getFieldDomain(this.name,{feature:l}),u=this.element?.domain;return null!=u&&this._isDomainCompatible(u)?u:s}get editable(){return!!this._layerAndFieldAllowEdits&&(this.evaluatedEditableExpression??this._configAllowsEdits)}get evaluatedRequiredExpression(){const{requiredExpressionExecutor:e}=this;return null!=e?!!e.lastEvaluatedValue:null}get evaluatedValueExpression(){const{valueExpressionExecutor:e}=this;return null!=e?e.lastEvaluatedValue:null}get hint(){return this.element?.hint}get includeDate(){return!(this.dataType!==O.Date||"time-only"===this.field.type)}get includeTime(){const{element:e,field:t}=this;if(this.dataType!==O.Date)return!1;if("time-only"===t.type)return!0;if("date-only"===t.type)return!1;const i="datetime-picker"===e?.input?.type?e.input.includeTime:void 0;return void 0===i||i}get includeTimeOffset(){if("timestamp-offset"!==this.field.type)return!1;const e=this.element?.input;return!e||"datetimeoffset-picker"===e.type&&e.includeTimeOffset}set initialFeature(e){this._set("initialFeature",e),this.notifyChange("valid")}get inputType(){return this.element?.input?.type}get hasInvalidSwitchValue(){const{element:e}=this,t=_(e,"switch")?e.input:null;return!t||V(this.value,t)}get isRelationshipKeyField(){const{field:e,layer:t}=this;return b(t)&&!!t.relationships?.some((t=>t.keyField===e.name))}get label(){const{element:e,feature:t,field:i,layer:l,timeZone:n}=this;return null!=l&&null!=e?.label?E({label:e.label,attributes:t.attributes,fieldsIndex:l.fieldsIndex,timeZone:n}):e?.label||i.alias||i.name}get maxLength(){const e=-1;if(this.dataType===O.Date)return e;const{field:t,element:i}=this,l=t?.length??-1,n=T(i)?i.input.maxLength:NaN;return null!=n&&!isNaN(n)&&n>=e&&(l===e||n<=l)?n:l}get minLength(){const e=-1;if(this.dataType===O.Date)return e;const{field:t,element:i}=this,l=t?.length??-1,n=T(i)?i.input.minLength:NaN;return null!=n&&!isNaN(n)&&n>=e&&(l===e||n<=l)?n:e}get name(){return this.field?.name}get range(){const{_dateRange:e,domain:t,field:i}=this,{max:l,min:n}=e,r=null!=l&&S(l)?l.getTime():null,u=null!=n&&S(n)?n.getTime():null,o=s(t)||y(i);if(!o)return{max:r,min:u};const a=o.max===Number.MAX_VALUE?null:o.max,p=o.min===Number.MIN_VALUE?null:o.min;return{max:null!=r&&(null===a||null!=a&&r<a)?r:a,min:null!=u&&(null===p||null!=p&&u>p)?u:p}}get required(){const{editable:e,evaluatedRequiredExpression:t,field:i,visible:l,_isSubtypeField:n}=this;return!!e&&(!1===i?.nullable||(!!n||!(!l||null==t)&&t))}set required(e){this._overrideIfSome("required",e)}get showNoValueOptionEnabled(){const{element:e}=this;return!this.required&&(!F(e)||e.input.showNoValueOption)}get showNoValueLabel(){const{element:e}=this;return F(e)?e.input.noValueOptionLabel:null}get submittable(){const{field:e,required:t,valid:i,value:l}=this;return(!t||null!=l)&&(!!i||this.initialFeature.getAttribute(e.name)===l)}get timeResolution(){const e=this.element?.input;if(e&&("datetimeoffset-picker"===e.type||"time-picker"===e.type))return e.timeResolution??"minutes"}get timeStep(){return null!=this.timeResolution?w.get(this.timeResolution):void 0}get updating(){const{editableExpressionExecutor:e,valueExpressionExecutor:t,visibilityExpressionExecutor:i,preservesValueWhenHidden:l}=this;return null!=t&&t.updating||null!=e&&e.updating||!1===l&&null!=i&&i.updating}get valid(){const e=this.editable?this._validate():null;return this._set("error",e),null===e}get value(){if(this._fieldInputWasVisibleDuringLifetime=this._fieldInputWasVisibleDuringLifetime||this.visible&&!1!==this.group?.visible,!1===this.preservesValueWhenHidden&&this._fieldInputWasVisibleDuringLifetime&&(!1===this.evaluatedVisibilityExpression||!1===this.group?.evaluatedVisibilityExpression))return null!==this._storedValue&&this.set("_storedValue",null),null;if(this._shouldUseValueExpression){const e=this.evaluatedValueExpression;return this.dataType===O.Date?this._arcadeOutputToDateFieldValue(e):null!=e&&"object"==typeof e?e.toString():e}return this._storedValue}set value(e){this.notifyChange("evaluatedVisibilityExpression"),this.set("_storedValue",e)}get visible(){return!this._isEditTrackingField&&(null!=this.evaluatedVisibilityExpression?this.evaluatedVisibilityExpression:null!=this.element||this._isVisibleByDefault)}_arcadeOutputToDateFieldValue(e){const i=this.field.type;try{if("object"==typeof e){if(null===e)throw new t("feature-form:invalid-date-value");if(N(e))return I(e,i);if("getTime"in e&&"function"==typeof e.getTime&&"date"===i)return parseInt(e.getTime(),10);if("date-only"===i||"time-only"===i||"timestamp-offset"===i)return e.toString()}else{if("string"==typeof e)return"date"===i?parseInt(e,10):e;if("number"==typeof e&&"date"===i)return e}throw new t("feature-form:invalid-date-value")}catch{return"date"===i?NaN:""}}_isDomainCompatible(e){const{field:t}=this;if("coded-value"===e?.type){const i=typeof e.codedValues[0].code;if("string"===i&&d(t)||"number"===i&&p(t))return!0}return!!("range"===e?.type&&p(t)||g(t)||m(t))}_validate(){const{dataType:e,domain:t,field:i,initialFeature:l,minLength:n,range:r,required:s,valid:o,value:a}=this,p=s&&null==a,d=void 0!==o;return!p&&l.getAttribute(i.name)===a&&d?null:p?h.INVALID_TYPE:"text"===e&&n>-1&&"string"==typeof a&&a.length<n?D.TOO_SHORT:"date"===i.type&&null!=a&&r&&!j({value:a,max:r.max,min:r.min})?f.OUT_OF_RANGE:t?null!==a||s?u(t,a):null:c(i,a)}};e([i()],L.prototype,"_storedValue",void 0),e([i()],L.prototype,"_configAllowsEdits",null),e([i()],L.prototype,"_layerAndFieldAllowEdits",null),e([i()],L.prototype,"_isVisibleByDefault",null),e([i()],L.prototype,"_isEditTrackingField",null),e([i()],L.prototype,"_shouldUseValueExpression",null),e([i()],L.prototype,"_isSubtypeField",null),e([i()],L.prototype,"dataType",null),e([i()],L.prototype,"dateDataType",null),e([i()],L.prototype,"description",null),e([i()],L.prototype,"domain",null),e([i()],L.prototype,"editable",null),e([i({readOnly:!0})],L.prototype,"error",void 0),e([i({constructOnly:!0})],L.prototype,"preservesValueWhenHidden",void 0),e([i()],L.prototype,"evaluatedRequiredExpression",null),e([i()],L.prototype,"evaluatedValueExpression",null),e([i()],L.prototype,"field",void 0),e([i()],L.prototype,"group",void 0),e([i({readOnly:!0})],L.prototype,"hint",null),e([i()],L.prototype,"includeDate",null),e([i()],L.prototype,"includeTime",null),e([i()],L.prototype,"includeTimeOffset",null),e([i()],L.prototype,"initialFeature",null),e([i({readOnly:!0})],L.prototype,"inputType",null),e([i()],L.prototype,"hasInvalidSwitchValue",null),e([i()],L.prototype,"isRelationshipKeyField",null),e([i()],L.prototype,"label",null),e([i()],L.prototype,"maxLength",null),e([i()],L.prototype,"minLength",null),e([i({readOnly:!0})],L.prototype,"name",null),e([i()],L.prototype,"range",null),e([i()],L.prototype,"required",null),e([i()],L.prototype,"requiredExpressionExecutor",void 0),e([i()],L.prototype,"showNoValueOptionEnabled",null),e([i()],L.prototype,"submittable",null),e([i()],L.prototype,"timeResolution",null),e([i()],L.prototype,"timeStep",null),e([i({readOnly:!0})],L.prototype,"type",void 0),e([i()],L.prototype,"updating",null),e([i()],L.prototype,"valid",null),e([i({value:null})],L.prototype,"value",null),e([i()],L.prototype,"valueExpressionExecutor",void 0),e([i()],L.prototype,"visible",null),L=e([l("esri.widgets.FeatureForm.FieldInput")],L);const S=e=>e&&!Number.isNaN(e.valueOf()),R=L;export{R as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../core/Error.js";import{property as i}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as l}from"../../core/accessorSupport/decorators/subclass.js";import{CodedValue as n}from"../../layers/support/CodedValue.js";import r from"../../layers/support/CodedValueDomain.js";import"../../layers/support/Domain.js";import"../../layers/support/InheritedDomain.js";import"../../layers/support/RangeDomain.js";import{getDomainRange as s,dateTimeFieldValuesToNumericRange as a,validateDomainValue as u}from"../../layers/support/domainUtils.js";import{isFieldVisibleByDefault as o,getLowerCaseEditTrackingFields as p,isNumericField as d,isStringField as m,isTimeOnlyField as y,getFieldRange as h,TypeValidationError as f,NumericRangeValidationError as c,validateFieldValue as g}from"../../layers/support/fieldUtils.js";import{isAnyDateField as b}from"../../smartMapping/support/utils.js";import{isRelatableFeatureSupportedLayer as x}from"../Feature/support/featureUtils.js";import v from"./EditableInput.js";import{parseFormTemplateString as E,getNormalizedFeatureTypeInfo as _,isFieldElementWithInputType as V,valueIsInvalidSwitchValue as w,isFieldElementWithTextInput as T,isFieldElementWithShowNoValueOptionInput as F,LengthValidationError as D}from"./featureFormUtils.js";import{isNumber as N}from"../support/dataUtils.js";import{timeResolutionToStepMap as j,isArcadeDate as A,arcadeDateToFieldValue as I,dateTimeIsInRange as O}from"../support/dateUtils.js";var M;!function(e){e.Text="text",e.Number="number",e.Date="date",e.Unsupported="unsupported"}(M||(M={}));const R="__internal-type-based-coded-value-domain__";let L=class extends v{constructor(e){super(e),this._storedValue=null,this.error=null,this.preservesValueWhenHidden=!0,this.field=null,this.group=null,this.requiredExpressionExecutor=null,this.type="field",this._fieldInputWasVisibleDuringLifetime=!1,this.valueExpressionExecutor=null}get _dateFormRange(){const{element:e,field:t}=this;if("date"!==this.dataType)return{};const i=e?.domain?s(t,e.domain):null;if(!e?.input)return i??{};const l=e.input,{type:n}=l;let r={};if("date-picker"!==n&&"time-picker"!==n&&"datetimeoffset-picker"!==n||(r=a(t,l.max,l.min)),"datetime-picker"===n){const{max:e,min:t}=l;r={max:null!=e&&S(e)?e.getTime():null,min:null!=t&&S(t)?t.getTime():null}}const{max:u,min:o}=r;if(i){const{max:e,min:t}=i,l=N(e)&&(null==u||null!=u&&e<u),n=N(t)&&(null==o||null!=o&&t>o);return{max:l?e:u??null,min:n?t:o??null,rawMax:l?i.rawMax:r?.rawMax??null,rawMin:n?i.rawMin:r?.rawMin??null}}return{min:o,max:u,rawMax:r?.rawMax??null,rawMin:r?.rawMin??null}}get _dateRange(){const{_dateFormRange:e,field:t}=this;if("date"!==this.dataType)return{};const i=s(t);if(!i)return e;const{max:l,min:n,rawMax:r,rawMin:a}=e;if("date"===t.type){const{max:e,min:t}=i;return{max:N(l)&&(null===e||null!=e&&l<e)?l:e??null,min:N(n)&&(null===t||null!=t&&n>t)?n:t??null}}if("date-only"===t.type||"time-only"===t.type||"timestamp-offset"===t.type){const{max:e,min:t,rawMax:s,rawMin:u}=i,o=N(l)&&r&&(null==e||l<e);return{max:o?l:e,min:N(n)&&a&&(null==t||n>t)?n:t,rawMax:o?r:s,rawMin:o?a:u}}return{max:null,min:null}}get _configAllowsEdits(){const{element:e,layer:t,name:i}=this;if(null!=e)return e.editableExpression?!!this.evaluatedEditableExpression:!1!==e.editable;if(t?.userHasUpdateItemPrivileges)return!0;const l=t&&"popupTemplate"in t?t?.popupTemplate?.fieldInfos?.find((({fieldName:e})=>e===i)):null;return l?.isEditable??!0}get _layerAndFieldAllowEdits(){return this.layerAllowsEdits&&this.field?.editable}get _isVisibleByDefault(){const{field:e,layer:t}=this;return!!e?.visible&&o(e,t)}get _isEditTrackingField(){return p(this.layer).includes(this.name?.toLowerCase())}get _shouldUseValueExpression(){return this._layerAndFieldAllowEdits&&!this._configAllowsEdits&&null!=this.valueExpressionExecutor}get _isSubtypeField(){const{layer:e}=this;if(e&&"subtypeField"in e){const{subtypeField:t,fieldsIndex:i}=e;return(i.get(t)?.name??t)===this.name}return!1}get test(){return{_isSubtypeField:this._isSubtypeField}}get dataType(){const{field:e}=this;return d(e)?M.Number:m(e)?M.Text:b(e)||y(e)?M.Date:M.Unsupported}get dateDataType(){if(this.dataType===M.Date)return"date"!==this.field.type?"string":"number"}get description(){const{element:e,feature:t,layer:i,timeZone:l}=this,n=e?.description;return null!=i&&null!=n?E({label:n,attributes:t.attributes,fieldsIndex:i.fieldsIndex,timeZone:l}):n}get domain(){const{layer:e}=this,{typeFieldName:t,types:i}=_(e);if(this._isSubtypeField&&"subtypes"in e&&e.subtypes)return new r({name:R,codedValues:e.subtypes.map((({code:e,name:t})=>new n({code:e,name:t})))});if(t===this.name&&null==this.field.domain)return new r({name:R,codedValues:i.map((({code:e,name:t})=>new n({code:e,name:t})))});const{feature:l}=this,s=e?.getFieldDomain(this.name,{feature:l}),a=this.element?.domain;return null!=a&&this._isDomainCompatible(a)?a:s}get editable(){return!!this._layerAndFieldAllowEdits&&(this.evaluatedEditableExpression??this._configAllowsEdits)}get evaluatedRequiredExpression(){const{requiredExpressionExecutor:e}=this;return null!=e?!!e.lastEvaluatedValue:null}get evaluatedValueExpression(){const{valueExpressionExecutor:e}=this;return null!=e?e.lastEvaluatedValue:null}get hint(){return this.element?.hint}get includeDate(){return!(this.dataType!==M.Date||"time-only"===this.field.type)}get includeTime(){const{element:e,field:t}=this;if(this.dataType!==M.Date)return!1;if("time-only"===t.type)return!0;if("date-only"===t.type)return!1;const i="datetime-picker"===e?.input?.type?e.input.includeTime:void 0;return void 0===i||i}get includeTimeOffset(){if("timestamp-offset"!==this.field.type)return!1;const e=this.element?.input;return!e||"datetimeoffset-picker"===e.type&&e.includeTimeOffset}set initialFeature(e){this._set("initialFeature",e),this.notifyChange("valid")}get inputType(){return this.element?.input?.type}get hasInvalidSwitchValue(){const{element:e}=this,t=V(e,"switch")?e.input:null;return!t||w(this.value,t)}get isRelationshipKeyField(){const{field:e,layer:t}=this;return x(t)&&!!t.relationships?.some((t=>t.keyField===e.name))}get label(){const{element:e,feature:t,field:i,layer:l,timeZone:n}=this;return null!=l&&null!=e?.label?E({label:e.label,attributes:t.attributes,fieldsIndex:l.fieldsIndex,timeZone:n}):e?.label||i.alias||i.name}get maxLength(){const e=-1;if(this.dataType===M.Date)return e;const{field:t,element:i}=this,l=t?.length??-1,n=T(i)?i.input.maxLength:NaN;return null!=n&&!isNaN(n)&&n>=e&&(l===e||n<=l)?n:l}get minLength(){const e=-1;if(this.dataType===M.Date)return e;const{field:t,element:i}=this,l=t?.length??-1,n=T(i)?i.input.minLength:NaN;return null!=n&&!isNaN(n)&&n>=e&&(l===e||n<=l)?n:e}get name(){return this.field?.name}get range(){const{domain:e,element:t,field:i}=this;if("date"===this.dataType)return this._dateRange;const l=s(i,e)||h(i,e),n=l?.max===Number.MAX_VALUE?null:l?.max??null,r=l?.min===-Number.MAX_VALUE?null:l?.min??null;if(!t?.domain||"range"!==t.domain.type)return{max:n,min:r};const{max:a,min:u}=s(i)||{};return{max:null!=a&&(null===n||null!=n&&a<n)?a:n,min:null!=u&&(null===r||null!=r&&u>r)?u:r}}get required(){const{editable:e,evaluatedRequiredExpression:t,field:i,visible:l,_isSubtypeField:n}=this;return!!e&&(!1===i?.nullable||(!!n||!(!l||null==t)&&t))}set required(e){this._overrideIfSome("required",e)}get showNoValueOptionEnabled(){const{element:e}=this;return!this.required&&(!F(e)||e.input.showNoValueOption)}get showNoValueLabel(){const{element:e}=this;return F(e)?e.input.noValueOptionLabel:null}get submittable(){const{field:e,required:t,valid:i,value:l}=this;return(!t||null!=l)&&(!!i||this.initialFeature.getAttribute(e.name)===l)}get timeResolution(){const e=this.element?.input;if(e&&("datetimeoffset-picker"===e.type||"time-picker"===e.type))return e.timeResolution??"minutes"}get timeStep(){return null!=this.timeResolution?j.get(this.timeResolution):void 0}get updating(){const{editableExpressionExecutor:e,valueExpressionExecutor:t,visibilityExpressionExecutor:i,preservesValueWhenHidden:l}=this;return null!=t&&t.updating||null!=e&&e.updating||!1===l&&null!=i&&i.updating}get valid(){const e=this.editable?this._validate():null;return this._set("error",e),null===e}get value(){if(this._fieldInputWasVisibleDuringLifetime=this._fieldInputWasVisibleDuringLifetime||this.visible&&!1!==this.group?.visible,!1===this.preservesValueWhenHidden&&this._fieldInputWasVisibleDuringLifetime&&(!1===this.evaluatedVisibilityExpression||!1===this.group?.evaluatedVisibilityExpression))return null!==this._storedValue&&this.set("_storedValue",null),null;if(this._shouldUseValueExpression){const e=this.evaluatedValueExpression;return this.dataType===M.Date?this._arcadeOutputToDateFieldValue(e):null!=e&&"object"==typeof e?e.toString():e}return this._storedValue}set value(e){this.notifyChange("evaluatedVisibilityExpression"),this.set("_storedValue",e)}get visible(){return!this._isEditTrackingField&&(null!=this.evaluatedVisibilityExpression?this.evaluatedVisibilityExpression:null!=this.element||this._isVisibleByDefault)}_arcadeOutputToDateFieldValue(e){const i=this.field.type;try{if("object"==typeof e){if(null===e)throw new t("feature-form:invalid-date-value");if(A(e))return I(e,i);if("getTime"in e&&"function"==typeof e.getTime&&"date"===i)return parseInt(e.getTime(),10);if("date-only"===i||"time-only"===i||"timestamp-offset"===i)return e.toString()}else{if("string"==typeof e)return"date"===i?parseInt(e,10):e;if("number"==typeof e&&"date"===i)return e}throw new t("feature-form:invalid-date-value")}catch{return"date"===i?NaN:""}}_isDomainCompatible(e){const{field:t}=this;if("coded-value"===e?.type){const i=typeof e.codedValues[0].code;if("string"===i&&m(t)||"number"===i&&d(t))return!0}return!!("range"===e?.type&&d(t)||b(t)||y(t))}_validate(){const{dataType:e,domain:t,field:i,initialFeature:l,minLength:n,range:r,required:s,valid:a,value:o}=this,p=s&&null==o,d=void 0!==a;return!p&&l.getAttribute(i.name)===o&&d?null:p?f.INVALID_TYPE:"text"===e&&n>-1&&"string"==typeof o&&o.length<n?D.TOO_SHORT:"date"!==e||null==o||O({type:i.type,range:r,value:o})?t?null!==o||s?u(i,o):null:g(i,o):c.OUT_OF_RANGE}};e([i()],L.prototype,"_dateFormRange",null),e([i()],L.prototype,"_dateRange",null),e([i()],L.prototype,"_storedValue",void 0),e([i()],L.prototype,"_configAllowsEdits",null),e([i()],L.prototype,"_layerAndFieldAllowEdits",null),e([i()],L.prototype,"_isVisibleByDefault",null),e([i()],L.prototype,"_isEditTrackingField",null),e([i()],L.prototype,"_shouldUseValueExpression",null),e([i()],L.prototype,"_isSubtypeField",null),e([i()],L.prototype,"dataType",null),e([i()],L.prototype,"dateDataType",null),e([i()],L.prototype,"description",null),e([i()],L.prototype,"domain",null),e([i()],L.prototype,"editable",null),e([i({readOnly:!0})],L.prototype,"error",void 0),e([i({constructOnly:!0})],L.prototype,"preservesValueWhenHidden",void 0),e([i()],L.prototype,"evaluatedRequiredExpression",null),e([i()],L.prototype,"evaluatedValueExpression",null),e([i()],L.prototype,"field",void 0),e([i()],L.prototype,"group",void 0),e([i({readOnly:!0})],L.prototype,"hint",null),e([i()],L.prototype,"includeDate",null),e([i()],L.prototype,"includeTime",null),e([i()],L.prototype,"includeTimeOffset",null),e([i()],L.prototype,"initialFeature",null),e([i({readOnly:!0})],L.prototype,"inputType",null),e([i()],L.prototype,"hasInvalidSwitchValue",null),e([i()],L.prototype,"isRelationshipKeyField",null),e([i()],L.prototype,"label",null),e([i()],L.prototype,"maxLength",null),e([i()],L.prototype,"minLength",null),e([i({readOnly:!0})],L.prototype,"name",null),e([i()],L.prototype,"range",null),e([i()],L.prototype,"required",null),e([i()],L.prototype,"requiredExpressionExecutor",void 0),e([i()],L.prototype,"showNoValueOptionEnabled",null),e([i()],L.prototype,"submittable",null),e([i()],L.prototype,"timeResolution",null),e([i()],L.prototype,"timeStep",null),e([i({readOnly:!0})],L.prototype,"type",void 0),e([i()],L.prototype,"updating",null),e([i()],L.prototype,"valid",null),e([i({value:null})],L.prototype,"value",null),e([i()],L.prototype,"valueExpressionExecutor",void 0),e([i()],L.prototype,"visible",null),L=e([l("esri.widgets.FeatureForm.FieldInput")],L);const S=e=>e&&!Number.isNaN(e.valueOf()),U=L;export{U 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.28/esri/copyright.txt for details.
4
4
  */
5
- import"../../intl.js";import{isSome as e}from"../../core/arrayUtils.js";import{neverReached as t}from"../../core/compilerUtils.js";import{templateHasKey as n,replace as r}from"../../core/string.js";import{DomainValidationError as o}from"../../layers/support/domainUtils.js";import{isTimeOnlyField as i,NumericRangeValidationError as a,TypeValidationError as l}from"../../layers/support/fieldUtils.js";import{isAnyDateField as s}from"../../smartMapping/support/utils.js";import{getLabelForDateFieldValue as u}from"../support/dateUtils.js";import{substitute as p}from"../../intl/substitute.js";const m=e=>"field"===e?.type,d=e=>"group"===e?.type,c=e=>"relationship"===e?.type,f=e=>!d(e)&&null!=e.group,y=e=>"field"===e.type,b=e=>"group"===e.type,T=e=>"relationship"===e.type,E=e=>e.reduce(((e,t)=>d(t)?[...e,...t.inputs]:[...e,t]),[]),g=e=>E(e).filter(m),v=e=>E(e).filter(c),O=e=>null!=e&&(j(e,"combo-box")||j(e,"radio-buttons")),j=(e,t)=>null!=e&&e.input?.type===t,x=e=>null!=e&&(j(e,"text-box")||j(e,"text-area")),V=({domain:e,inputType:t="text-box",dataType:n})=>"number"===n&&"text-box"===t&&(!e||"coded-value"!==e.type),h=e=>"items"in e,U={typeFieldName:null,types:[]};function N(t){const{attributes:r,fieldsIndex:o,label:i,timeZone:a}=t,l=Object.keys(r).filter((e=>n(i,e))),s=l.map((e=>r[e])),u=l.map((e=>o.get(e))).filter(e);return A(i,_({values:s,fields:u,timeZone:a}))}function _(e){const{fields:t,values:n,timeZone:r}=e,o=t.map(((e,t)=>{let o=n[t];if(e.domain&&"coded-value"===e.domain.type){const t=e.domain.codedValues.find((e=>e.code===o));t?.name&&(o=t.name)}return(s(e)||i(e))&&(o=u(e,o,{timeZone:"date"===e.type&&null!=r?r:void 0})),[e.name,o]}));return Object.fromEntries(o)}function A(e,t){return r(r(e,(e=>`{${e.toLowerCase()}}`)),Object.fromEntries(Object.entries(t).map((([e,t])=>[e.toLowerCase(),t]))))}const I=e=>e?"subtype-sublayer"===e.type?{typeFieldName:e.parent?.subtypeField,types:e.parent?.subtypes??[]}:"types"in e&&e.types?{typeFieldName:e.typeIdField,types:e.types.map((({id:e,name:t,domains:n})=>({code:e,name:t,domains:n})))}:U:U,L=(e,t)=>{if(!e)return!0;const{operations:n}=e;switch(t){case"INSERT":return n.supportsAdd;case"UPDATE":case"DELETE":return n.supportsUpdate;default:return!0}};var F;!function(e){e.TOO_SHORT="length-validation-error::too-short"}(F||(F={}));const D={type:"number"},R={type:"number",intlOptions:{notation:"scientific"}},Z={day:"2-digit",month:"2-digit",year:"numeric",hour:"numeric",minute:"numeric",second:"numeric"};function w(e){return e>=1e7||e<=-1e7}const C=(e,t,n)=>{const{dataType:r,error:i,minLength:s,value:u,required:m}=e;if(!t||!i)return null;if(m&&null===u)return t.validationErrors.cannotBeNull;if(i===o.VALUE_OUT_OF_RANGE||i===a.OUT_OF_RANGE){const o=e.range,i={type:"date",intlOptions:{...Z,timeZone:n??void 0}};return p(t.validationErrors.outsideRange,o,{format:{max:"date"===r?i:w(o.max)?R:D,min:"date"===r?i:w(o.min)?R:D}})}return i===o.INVALID_CODED_VALUE?t.validationErrors.invalidCodedValue:i===l.INVALID_TYPE?t.validationErrors.invalidType:i===F.TOO_SHORT?p(t.validationErrors.tooShort,{min:s}):null},S=e=>{if(!e)return;const t=e.layer,n=t&&"geometryType"in t?t.geometryType:void 0,r=e.geometry?.type;return"polyline"===r||"polyline"===n?"line":r||n||"table"},G=e=>{const t=[];if(e.formTemplate){const{description:r,title:o}=e.formTemplate;e.fields?.forEach((e=>{const i=o&&n(o,e.name),a=r&&n(r,e.name);(i||a)&&t.push(e.name)}))}return t};function H(e){if("formTemplate"in e&&e.formTemplate){return(e.formTemplate.elements?.filter(y)??[]).some((({fieldName:t})=>!e.fieldsIndex.get(t)))}return!1}function P(e,t){return null==e||t.onValue!==e&&t.offValue!==e}function k(e,n){switch(n.objectType){case"any":return!0;case"null":return null==e;case"code":return e===n.codedValue?.code;case"range":return null!=e&&null!=n.minValue&&null!=n.maxValue&&+e>=n.minValue&&+e<=n.maxValue;default:return t(n.objectType),!1}}export{F as LengthValidationError,L as capabilitiesAllowEditType,g as flattenFieldInputs,E as flattenInputs,v as flattenRelationshipInputs,H as formTemplateHasInvalidFields,_ as getComputedAttributes,C as getErrorMessageForFieldInput,G as getFieldsInTitleAndDesc,S as getIconForFeature,I as getNormalizedFeatureTypeInfo,y as isFieldElement,j as isFieldElementWithInputType,O as isFieldElementWithShowNoValueOptionInput,x as isFieldElementWithTextInput,m as isFieldInput,b as isGroupElement,d as isGroupInput,f as isInputInGroupInput,V as isNumberFieldInput,T as isRelationshipElement,c as isRelationshipInput,h as isTemplateItemGroup,N as parseFormTemplateString,A as substituteFieldTemplatesInString,P as valueIsInvalidSwitchValue,k as valueIsValidContingentValue};
5
+ import"../../intl.js";import{isSome as e}from"../../core/arrayUtils.js";import{neverReached as t}from"../../core/compilerUtils.js";import{templateHasKey as n,replace as r}from"../../core/string.js";import{DomainValidationError as i}from"../../layers/support/domainUtils.js";import{isTimeOnlyField as o,NumericRangeValidationError as l,TypeValidationError as a}from"../../layers/support/fieldUtils.js";import{isAnyDateField as s}from"../../smartMapping/support/utils.js";import{getLabelForDateFieldValue as u}from"../support/dateUtils.js";import{substitute as p}from"../../intl/substitute.js";const m=e=>"field"===e?.type,d=e=>"group"===e?.type,c=e=>"relationship"===e?.type,f=e=>!d(e)&&null!=e.group,y=e=>"field"===e.type,b=e=>"group"===e.type,T=e=>"relationship"===e.type,E=e=>e.reduce(((e,t)=>d(t)?[...e,...t.inputs]:[...e,t]),[]),g=e=>E(e).filter(m),v=e=>E(e).filter(c),O=e=>null!=e&&(x(e,"combo-box")||x(e,"radio-buttons")),x=(e,t)=>null!=e&&e.input?.type===t,j=e=>null!=e&&(x(e,"text-box")||x(e,"text-area")),V=({domain:e,inputType:t="text-box",dataType:n})=>"number"===n&&"text-box"===t&&(!e||"coded-value"!==e.type),h=e=>"items"in e,U={typeFieldName:null,types:[]};function N(t){const{attributes:r,fieldsIndex:i,label:o,timeZone:l}=t,a=Object.keys(r).filter((e=>n(o,e))),s=a.map((e=>r[e])),u=a.map((e=>i.get(e))).filter(e);return A(o,_({values:s,fields:u,timeZone:l}))}function _(e){const{fields:t,values:n,timeZone:r}=e,i=t.map(((e,t)=>{let i=n[t];if(e.domain&&"coded-value"===e.domain.type){const t=e.domain.codedValues.find((e=>e.code===i));t?.name&&(i=t.name)}return(s(e)||o(e))&&(i=u(e,i,{timeZone:"date"===e.type&&null!=r?r:void 0})),[e.name,i]}));return Object.fromEntries(i)}function A(e,t){return r(r(e,(e=>`{${e.toLowerCase()}}`)),Object.fromEntries(Object.entries(t).map((([e,t])=>[e.toLowerCase(),t]))))}const I=e=>e?"subtype-sublayer"===e.type?{typeFieldName:e.parent?.subtypeField,types:e.parent?.subtypes??[]}:"types"in e&&e.types?{typeFieldName:e.typeIdField,types:e.types.map((({id:e,name:t,domains:n})=>({code:e,name:t,domains:n})))}:U:U,L=(e,t)=>{if(!e)return!0;const{operations:n}=e;switch(t){case"INSERT":return n.supportsAdd;case"UPDATE":case"DELETE":return n.supportsUpdate;default:return!0}};var F;!function(e){e.TOO_SHORT="length-validation-error::too-short"}(F||(F={}));const D={type:"number"},R={type:"number",intlOptions:{notation:"scientific"}},Z={day:"2-digit",month:"2-digit",year:"numeric"},w={hour:"numeric",minute:"numeric",second:"numeric"},C={...Z,...w};function S(e){return e>=1e7||e<=-1e7}const G=(e,t,n)=>{const{dataType:r,error:o,minLength:s,value:u,required:m}=e;if(!t||!o)return null;if(m&&null===u)return t.validationErrors.cannotBeNull;if(o===i.VALUE_OUT_OF_RANGE||o===l.OUT_OF_RANGE){const{field:i,range:o}=e,l={type:"date",intlOptions:{..."time-only"===i.type?w:"date-only"===i.type?Z:C,timeZone:n??void 0}};return p(t.validationErrors.outsideRange,o,{format:{max:"date"===r?l:null!=o.max&&S(o.max)?R:D,min:"date"===r?l:null!=o.min&&S(o.min)?R:D}})}return o===i.INVALID_CODED_VALUE?t.validationErrors.invalidCodedValue:o===a.INVALID_TYPE?t.validationErrors.invalidType:o===F.TOO_SHORT?p(t.validationErrors.tooShort,{min:s}):null},H=e=>{if(!e)return;const t=e.layer,n=t&&"geometryType"in t?t.geometryType:void 0,r=e.geometry?.type;return"polyline"===r||"polyline"===n?"line":r||n||"table"},P=e=>{const t=[];if(e.formTemplate){const{description:r,title:i}=e.formTemplate;e.fields?.forEach((e=>{const o=i&&n(i,e.name),l=r&&n(r,e.name);(o||l)&&t.push(e.name)}))}return t};function k(e){if("formTemplate"in e&&e.formTemplate){return(e.formTemplate.elements?.filter(y)??[]).some((({fieldName:t})=>!e.fieldsIndex.get(t)))}return!1}function q(e,t){return null==e||t.onValue!==e&&t.offValue!==e}function B(e,n){switch(n.objectType){case"any":return!0;case"null":return null==e;case"code":return e===n.codedValue?.code;case"range":return null!=e&&null!=n.minValue&&null!=n.maxValue&&+e>=n.minValue&&+e<=n.maxValue;default:return t(n.objectType),!1}}export{F as LengthValidationError,L as capabilitiesAllowEditType,g as flattenFieldInputs,E as flattenInputs,v as flattenRelationshipInputs,k as formTemplateHasInvalidFields,_ as getComputedAttributes,G as getErrorMessageForFieldInput,P as getFieldsInTitleAndDesc,H as getIconForFeature,I as getNormalizedFeatureTypeInfo,y as isFieldElement,x as isFieldElementWithInputType,O as isFieldElementWithShowNoValueOptionInput,j as isFieldElementWithTextInput,m as isFieldInput,b as isGroupElement,d as isGroupInput,f as isInputInGroupInput,V as isNumberFieldInput,T as isRelationshipElement,c as isRelationshipInput,h as isTemplateItemGroup,N as parseFormTemplateString,A as substituteFieldTemplatesInString,q as valueIsInvalidSwitchValue,B as valueIsValidContingentValue};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import{isSome as t}from"../core/arrayUtils.js";import{deprecatedProperty as i}from"../core/deprecate.js";import o from"../core/Logger.js";import{watch as n,whenOnce as a}from"../core/reactiveUtils.js";import{property as s}from"../core/accessorSupport/decorators/property.js";import"../core/accessorSupport/ensureType.js";import"../core/has.js";import{subclass as r}from"../core/accessorSupport/decorators/subclass.js";import{isIntegerField as l}from"../layers/support/fieldUtils.js";import d from"./Widget.js";import{css as p}from"./FeatureForm/css.js";import{isGroupInput as c,isFieldInput as u,isRelationshipInput as m,isInputInGroupInput as h,isFieldElementWithInputType as v,getErrorMessageForFieldInput as _,getIconForFeature as g,isNumberFieldInput as b}from"./FeatureForm/featureFormUtils.js";import f from"./FeatureForm/FeatureFormViewModel.js";import{loadCalciteComponents as C}from"./support/componentsUtils.js";import{getLabelForDateFieldValue as y,numberingSystem as F,prepareISOFieldValueForDateComponents as R,prepareUnixFieldValueForDateComponents as w,normalizeTimeOnlyString as O,getISOFieldValueFromDateComponents as k,getUnixFieldValueFromDateComponents as I}from"./support/dateUtils.js";import{globalCss as M}from"./support/globalCss.js";import{Heading as D,incrementHeadingLevel as x}from"./support/Heading.js";import"./support/widgetUtils.js";import{messageBundle as V}from"./support/decorators/messageBundle.js";import{vmEvent as N}from"./support/decorators/vmEvent.js";import{tsx as T}from"./support/jsxFactory.js";import{substitute as L}from"../intl/substitute.js";const j="data-field-name",S="esri.widgets.FeatureForm",E=o.getLogger(S);let U=class extends d{constructor(e,t){super(e,t),this._attemptFocusOnNextRender=!1,this._dateComponentMap=new Map,this._inputsWithChanges=new Set,this._focusedFieldName=null,this._listObserverNode=null,this._listObserver=new IntersectionObserver((e=>{e.length&&e[0].isIntersecting&&this._incrementRelatedRecordPage()}),{root:window.document}),this.groupDisplay="all",this.headingLevel=2,this.messages=null,this.messagesCommon=null,this.messagesFeature=null,this.messagesTemplates=null,this.viewModel=new f,this._onShowAllRelatedRecordsClick=e=>{const{feature:t,relatedRecordCallbacks:i}=this;t&&i?.showAllRelatedRecords&&i.showAllRelatedRecords({parentFeature:t,relationshipId:e})},this._onAddRelatedRecordsClick=(e,t)=>{const{feature:i,relatedRecordCallbacks:o}=this;i&&o?.addRelatedRecord&&o.addRelatedRecord({parentFeature:i,relatedLayer:t,relationshipId:e})},this._onFormKeyDown=this._onFormKeyDown.bind(this),this._onFormSubmit=this._onFormSubmit.bind(this),this._onGroupToggle=this._onGroupToggle.bind(this),this._onComponentBlur=this._onComponentBlur.bind(this),this._onComponentFocus=this._onComponentFocus.bind(this),this._onComponentKeyDown=this._onComponentKeyDown.bind(this),this._afterComponentCreate=this._afterComponentCreate.bind(this),this._afterComponentCreateOrUpdate=this._afterComponentCreateOrUpdate.bind(this),this._afterDateComponentCreate=this._afterDateComponentCreate.bind(this),this._afterDateComponentCreateOrUpdate=this._afterDateComponentCreateOrUpdate.bind(this),this._afterRadioGroupCreateOrUpdate=this._afterRadioGroupCreateOrUpdate.bind(this)}initialize(){this.addHandles([n((()=>this.feature),(()=>{a((()=>!this.viewModel.updating)).then((()=>{const e=this._getFocusableInput("forward");this._inputsWithChanges.clear(),this._dateComponentMap.clear(),this._syncGroupInputStates(),this._focusedFieldName=e?.name||null,this._attemptFocusOnNextRender=!0}))})),n((()=>this.groupDisplay),(()=>this._syncGroupInputStates())),this.on("submit",(e=>{if(e.invalid.length>0){const[t]=e.invalid;e.invalid.forEach((e=>this._inputsWithChanges.add(e))),this._focusedFieldName=t,this._attemptFocusOnNextRender=!0,this.scheduleRender()}})),n((()=>[this.viewModel.activeRelationshipInput,this._listObserverNode]),(()=>this._onObserverChange()))])}loadDependencies(){return C({block:()=>import("@esri/calcite-components/dist/components/calcite-block.js"),button:()=>import("@esri/calcite-components/dist/components/calcite-button.js"),combobox:()=>import("@esri/calcite-components/dist/components/calcite-combobox.js"),"combobox-item":()=>import("@esri/calcite-components/dist/components/calcite-combobox-item.js"),"combobox-item-group":()=>import("@esri/calcite-components/dist/components/calcite-combobox-item-group.js"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon.js"),input:()=>import("@esri/calcite-components/dist/components/calcite-input.js"),"input-date-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-date-picker.js"),"input-message":()=>import("@esri/calcite-components/dist/components/calcite-input-message.js"),"input-number":()=>import("@esri/calcite-components/dist/components/calcite-input-number.js"),"input-time-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-time-picker.js"),"input-time-zone":()=>import("@esri/calcite-components/dist/components/calcite-input-time-zone.js"),label:()=>import("@esri/calcite-components/dist/components/calcite-label.js"),list:()=>import("@esri/calcite-components/dist/components/calcite-list.js"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item.js"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader.js"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice.js"),"radio-button":()=>import("@esri/calcite-components/dist/components/calcite-radio-button.js"),"radio-button-group":()=>import("@esri/calcite-components/dist/components/calcite-radio-button-group.js"),switch:()=>import("@esri/calcite-components/dist/components/calcite-switch.js")})}destroy(){this._listObserverNode&&this._listObserver.unobserve(this._listObserverNode)}get _relatedRecordsEnabled(){const e=this.relatedRecordCallbacks;return!(!e||!(e.addRelatedRecord||e.editRelatedRecord||e.showAllRelatedRecords))}get disabled(){return this.viewModel.disabled}set disabled(e){this.viewModel.disabled=e}get feature(){return this.viewModel.feature}set feature(e){this.viewModel.feature=e}get formTemplate(){return this.viewModel.formTemplate}set formTemplate(e){this.viewModel.formTemplate=e}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get layer(){return this.viewModel.layer}set layer(e){this.viewModel.layer=e}get map(){return this.viewModel.map}set map(e){this.viewModel.map=e}get relatedRecordCallbacks(){return this.viewModel.relatedRecordCallbacks}set relatedRecordCallbacks(e){this.viewModel.relatedRecordCallbacks=e}get relationshipId(){return this.viewModel.relationshipId}set relationshipId(e){this.viewModel.relationshipId=e}get spatialReference(){return this.viewModel.spatialReference}set spatialReference(e){this.viewModel.spatialReference=e}get strict(){return this.viewModel.strict}set strict(e){this.viewModel.strict=e}get timeZone(){return this.viewModel.timeZone}set timeZone(e){this.viewModel.timeZone=e}get view(){return i(E,"view",{replacement:"Use FeatureForm.map instead.",version:"4.27"}),this.viewModel.view}set view(e){i(E,"view",{replacement:"Use FeatureForm.map instead.",version:"4.27"}),this.viewModel.view=e}getValues(){return this.viewModel.getValues()}submit(){return this.viewModel.submit()}render(){const{state:e}=this.viewModel;return T("div",{class:this.classes(p.base,M.widget,M.panel)},"ready"===e?this._renderForm():null)}_renderForm(){return T("form",{class:p.form,novalidate:!0,onkeydown:this._onFormKeyDown,onsubmit:this._onFormSubmit},this._renderHeader(),this._renderContent())}_renderHeader(){const e=this.viewModel;if(!e.formHeaderVisible)return;const t=null!=e.formTitle&&T(D,{key:"title",level:this.headingLevel},e.formTitle),i=null!=e.formDescription&&T("p",{class:p.description,key:"description"},e.formDescription);return T("div",{class:p.formHeader},t,i)}_renderContent(){const{viewModel:e}=this;return e.activeRelationshipInput?this._renderActiveRelationshipInput(e.activeRelationshipInput):e.inputs.filter(t).filter((e=>e.visible)).map(((e,t)=>c(e)?this._renderGroup(e,t):u(e)?this._renderLabeledField(e):m(e)?this._renderRelationshipInput(e):void 0))}_renderActiveRelationshipInput(e){return this._renderRelationshipInput(e)}_renderDescriptionOrEmpty(e,t){return null==e?null:T("div",{class:this.classes(p.description),id:t},e)}_renderGroup(e,t){const{disabled:i,formTemplate:o,headingLevel:n}=this,{description:a,inputs:s,label:r,open:l}=e,d=s.filter((e=>e.visible)),c=this.viewModel.findField(this._focusedFieldName),h=c?.group===e,v=`${this.id}_group_${t}`,_="sequential"===this.groupDisplay;return T("calcite-block",{class:this.classes(p.group,_?p.groupSequential:null,h?p.groupActive:null,i?p.inputDisabled:null),collapsible:!0,"data-group":e,description:a||void 0,disabled:i,heading:`${r}`,headingLevel:o?.title?x(n):n,id:v,key:v,open:l,onCalciteBlockToggle:({target:t})=>this._onGroupToggle(t,e)},d.map((e=>u(e)?this._renderLabeledField(e):m(e)?this._renderRelationshipInput(e):void 0)))}_getFocusableInput(e,t){const i=this.viewModel.allFieldInputs,o="forward"===e?i:i.slice().reverse();let n;if(!t||m(t))n=0;else if(c(t)){const e=t.inputs.find(u);n=e?o.indexOf(e):0}else{let i;if(h(t)&&!t.group.open){const o=t.group.inputs.filter(u);i="forward"===e?o[o.length-1]:o[0]}else i=t;n=o.indexOf(i)+1}for(let a=n;a<o.length;a++){const e=o[a];if(e.visible&&u(e))return e}return null}_renderLabeledField(e){const{dataType:t,feature:i,label:o,layer:n,required:a}=e,s={"aria-label":a?L(this.messages.requiredFieldLabel,{name:o}):o,class:p.label,key:`${n.id}-${i.uid}-${e.name}`},r=[T("div",{class:p.labelTextContent,key:"labelTextContainer"},o,a?T("span",{"aria-hidden":"true",title:this.messagesCommon.required},"*"):void 0),"unsupported"!==t?this._renderFieldInput(e):this._renderReadOnlyComponent(e),this._renderAuxiliaryText(e)];return"date"===t&&"coded-value"!==e.domain?.type?T("label",{...s},r):T("calcite-label",{...s},r)}_renderFieldInput(e){const{dataType:t,domain:i,inputType:o,name:n}=e,a=this.getCommonInputProps(e);if("coded-value"===i?.type){const t=this.viewModel.getFieldValueOptionsForField(n,this.messages.empty);return"switch"!==o||e.hasInvalidSwitchValue?"radio-buttons"===o?this._renderRadioButtonComponents(e,t.flat(),a):this._renderComboBoxComponent(e,t,a):this._renderSwitchComponent(e,a)}return"datetime-picker"===o||"date"===t?this._renderDateComponents(e,a):"number"===t?this._renderNumberComponent(e,a):this._renderStringComponent(e,a)}_renderStringComponent(e,t){return T("calcite-input",{...t,loading:e.updating,type:"text-area"===e.inputType?"textarea":"text",onCalciteInputInput:e=>this._saveValueFromComponent(e.target)})}_renderNumberComponent(e,t){return T("calcite-input-number",{...t,integer:l(e.field),loading:e.updating,type:"number",onCalciteInputNumberInput:e=>this._saveValueFromComponent(e.target)})}_renderDateComponents(e,t){const{field:i}=e;switch(i.type){case"date":return this._renderDateFieldCompnents(e,t);case"date-only":return this._renderDateOnlyFieldComponent(e,t);case"time-only":return this._renderTimeOnlyFieldComponent(e,t);case"timestamp-offset":return this._renderTimestampOffsetFieldComponents(e,t);default:return this._renderReadOnlyComponent(e,y(e.field,t.value,{timeZone:this.timeZone}))}}_renderDateOnlyFieldComponent(e,t){const{valid:i,value:o}=e,{class:n,max:a,min:s,key:r,readOnly:l}=t;return T("calcite-input-date-picker",{afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterDateComponentCreateOrUpdate,"aria-invalid":!i,class:n,"data-date-part":"date","data-field-name":t[j],key:`${r}-date-input`,max:null!=a?`${a}`:void 0,min:null!=s?`${s}`:void 0,numberingSystem:F,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},onfocus:this._onComponentFocus,overlayPositioning:"fixed",readOnly:l,value:null!=o?`${o}`:void 0,onCalciteInputDatePickerChange:e=>this._saveValueFromDateComponent(e.target)})}_renderTimeOnlyFieldComponent(e,t){const{valid:i,value:o}=e,{class:n,key:a,readOnly:s}=t;return T("calcite-input-time-picker",{afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterDateComponentCreateOrUpdate,"aria-invalid":!i,class:n,"data-date-part":"time","data-field-name":t[j],key:`${a}-time-input`,numberingSystem:F,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},onfocus:this._onComponentFocus,overlayPositioning:"fixed",readOnly:s,step:e.timeStep,value:null!=o?`${o}`:void 0,onCalciteInputTimePickerChange:e=>this._saveValueFromDateComponent(e.target)})}_renderTimestampOffsetFieldComponents(e,t){const{name:i,valid:o,value:n}=e,{class:a,key:s,readOnly:r}=t,l=null!=n?`${n}`:void 0,{dateAsString:d,time:c,timeZoneOffset:u}=R(l),m={afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterDateComponentCreateOrUpdate,"aria-invalid":!o,numberingSystem:F,overlayPositioning:"fixed",readOnly:r,[j]:i,onfocus:this._onComponentFocus};return T("div",{class:p.dateInputContainer,key:`${s}-date-time-container`},T("calcite-input-date-picker",{...m,class:a,"data-date-part":"date",key:`${s}-date-input`,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},value:d??void 0,onCalciteInputDatePickerChange:e=>this._saveValueFromDateComponent(e.target)}),T("calcite-input-time-picker",{...m,class:a,"data-date-part":"time",key:`${s}-time-input`,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},step:e.timeStep,value:c??void 0,onCalciteInputTimePickerChange:e=>this._saveValueFromDateComponent(e.target)}),e.includeTimeOffset?T("calcite-input-time-zone",{...m,class:a,"data-date-part":"timeZone",key:`${s}-timezone-input`,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},value:u??"0",onCalciteInputTimeZoneChange:e=>this._saveValueFromDateComponent(e.target)}):null)}_renderDateFieldCompnents(e,t){const{includeTime:i,name:o,valid:n,value:a}=e,{class:s,max:r,min:l,key:d,readOnly:c}=t,{timeZone:u}=this,m={afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterDateComponentCreateOrUpdate,"aria-invalid":!n,numberingSystem:F,overlayPositioning:"fixed",readOnly:c,[j]:o,onfocus:this._onComponentFocus},{dateAsString:h,time:v}=w(a,u),_=null!=r?w(r,u):void 0,g=null!=l?w(l,u):void 0;return T("div",{class:p.dateInputContainer,key:`${d}-date-time-container`},T("calcite-input-date-picker",{...m,class:s,"data-date-part":"date",key:`${d}-date-input`,max:_?.dateAsString??void 0,min:g?.dateAsString??void 0,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},value:h??void 0,onCalciteInputDatePickerChange:e=>this._saveValueFromDateComponent(e.target)}),i?T("calcite-input-time-picker",{...m,class:s,"data-date-part":"time",key:`${d}-time-input`,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},step:1,value:v??void 0,onCalciteInputTimePickerChange:e=>this._saveValueFromDateComponent(e.target)}):null)}_renderReadOnlyComponent(e,t){const i=this.getCommonInputProps(e);return T("calcite-input",{...i,class:this.classes(p.fieldInput,p.inputDisabled),readOnly:!0,type:"text",value:null!=t?`${t}`:i.value})}_renderComboBoxComponent(e,t,i){const{value:o,name:n}=e,{messages:a,messagesTemplates:s,viewModel:r,_inputsWithChanges:l}=this,d=t.map((e=>e.map((({name:e,value:t})=>T("calcite-combobox-item",{key:`#${t}`,selected:o===t,textLabel:e,value:`${t}`}))))),[p,c]=d;this.viewModel.fieldsWithInvalidCodedValue.has(e)&&c.unshift(T("calcite-combobox-item",{key:"incompatible-option",readOnly:!0,textLabel:`${e.value}`,value:`${e.value}`}));const u=c.length>0?[T("calcite-combobox-item-group",{key:"recommended",label:a.recommended},p),T("calcite-combobox-item-group",{key:"other",label:s.other},c)]:p,m="INSERT"===r.arcadeEditType,h=l.has(n),v=null==o&&(!m||h);if(e.showNoValueOptionEnabled){const t="",i=e.showNoValueLabel||a.empty;u.unshift(T("calcite-combobox-item",{key:"empty-option",selected:v,textLabel:a.empty,value:t},i))}const _=m&&e.showNoValueOptionEnabled&&!h?()=>{}:i.onblur;return T("calcite-combobox",{...i,allowCustomValues:!1,clearDisabled:!0,disabled:i.readOnly,onblur:_,overlayPositioning:"fixed",selectionMode:"single",onCalciteComboboxChange:({target:e})=>{v&&0===e.selectedItems.length?this._ignoreDeselectionOfNoValueOption(e):this._saveValueFromComponent(e)}},u)}_renderRadioButtonComponents(e,t,i){const{name:o,value:n}=e,a=t.map((({name:e,value:t})=>this._renderRadioButtonComponent({key:e,label:e,name:o,value:t,selected:t===n,props:i})));if(e.showNoValueOptionEnabled){const t="",s=e.showNoValueLabel||this.messages.empty,r=n===t||null===n;a.unshift(this._renderRadioButtonComponent({key:"empty-option",label:s,name:o,value:t,selected:r,props:i}))}return T("calcite-radio-button-group",{afterCreate:this._afterRadioGroupCreateOrUpdate,afterUpdate:this._afterRadioGroupCreateOrUpdate,class:p.inputRadioGroup,"data-field-name":i[j],key:`${i.key}-radio-group`,layout:"vertical",name:i.key,required:i.required},a)}_renderSwitchComponent(e,t){const{value:i}=e,o=!!v(e.element,"switch")&&i===e.element.input.onValue;return T("calcite-switch",{...t,checked:o,class:p.inputSwitch,disabled:t.readOnly,onblur:()=>{this._focusedFieldName=null},onCalciteSwitchChange:e=>this._saveValueFromComponent(e.target)})}_renderRadioButtonComponent({key:e,name:t,value:i,selected:o,label:n,props:a}){return T("calcite-label",{class:p.inputRadioLabel,key:e,layout:"inline"},T("calcite-radio-button",{...a,afterCreate:void 0,afterUpdate:void 0,checked:o,class:p.inputRadio,disabled:a.readOnly,name:t,onblur:()=>{this._focusedFieldName=null},value:i,onCalciteRadioButtonChange:({target:e})=>{e.checked&&this._saveValueFromComponent(e)}}),n)}_renderAuxiliaryText(e){const t=e.name,i=this._inputsWithChanges.has(t)&&!e.valid?_(e,this.messages,this.timeZone):null!=this.viewModel.contingencyConstraintViolations.get(t)?this.messages.validationErrors.valuesIncompatible:null!=e.valueExpressionExecutor&&e.valueExpressionExecutor.stale?this.messages.valueExpressionError:null;return null!=i?T("calcite-input-message",{icon:!0,status:"invalid"},i):this._renderDescriptionOrEmpty(e.description)}_renderShowAllRelatedRecordsListItem(e){const{featureCount:t,relationshipId:i,showAllActionVisible:o}=e,{relatedRecordCallbacks:n}=this;if(!o||!n?.showAllRelatedRecords)return;const a=this.messages;return T("calcite-list-item",{description:L(a.totalCount,{count:t}),label:a.showAll,value:!0,onCalciteListItemSelect:()=>this._onShowAllRelatedRecordsClick(i)},T("calcite-icon",{icon:"list",scale:"s",slot:"content-end"}))}_renderAddRelatedRecordButton(e){const{canAddRelatedFeature:t,relationshipId:i,relatedLayer:o}=e,{messages:n,relatedRecordCallbacks:a}=this;if(t&&a?.addRelatedRecord&&o)return T("calcite-button",{alignment:"center",appearance:"outline-fill",class:p.centeredButton,disabled:e.updating||!e.originHasValidKey,iconStart:"plus",key:`${i}-add-button`,onclick:()=>this._onAddRelatedRecordsClick(i,o),round:!0,scale:"s",width:"half"},e.relatedLayerIsTable?n.addRecord:n.addFeature)}_renderRelatedRecordListItem(e,t){const{feature:i,description:o,title:n}=e,{feature:a,relatedRecordCallbacks:s}=this,{highlightHelper:r}=this.viewModel,l=()=>{r?.removeAll(),s?.editRelatedRecord&&a&&s.editRelatedRecord({parentFeature:a,relationshipId:t,relatedFeature:i})},d=r?()=>r.add(i):void 0,p=r?()=>r.remove(i):void 0;return T("calcite-list-item",{bind:this,description:o,key:`${t}-${i.uid}`,label:n,onclick:l,onmouseenter:d,onmouseleave:p,value:n},T("calcite-icon",{icon:g(i),scale:"m",slot:"content-start"}),T("calcite-icon",{icon:"chevron-right",scale:"s",slot:"content-end"}))}_renderRelationshipInput(e){if(!this._relatedRecordsEnabled||!e.editable)return;const{featureCount:t,relationshipId:i,showAllEnabled:o}=e,n=o?null:this._renderDescriptionOrEmpty(e.description),a=t>0?this._renderRelatedRecordsList(e):e.loaded?e.originHasValidKey?this._renderNoRelatedRecordsNotice():this._renderNoValidOriginKeyNotice(e):void 0;return T("calcite-label",{class:this.classes(p.label,p.relatedRecordsLabel),key:`relationship-${i}-container`},T("div",null,this._renderRelatedRecordsHeaderContainer(e),n,a),this._renderAddRelatedRecordButton(e))}_renderRelatedRecordsHeaderContainer(e){const t=e.updating||!e.loaded;return T("div",{class:p.relatedRecordsHeader,key:`relationship-${e.relationshipId}-header`},T("span",null,e.label),t?T("calcite-loader",{inline:!0,key:"loader",label:this.messagesCommon?.loading,scale:"s",type:"indeterminate"}):void 0)}_renderRelatedRecordsList(e){const{relationshipId:t}=e;return T("calcite-list",{class:p.relatedRecordsList},e.relatedFeatureInfos.map((e=>this._renderRelatedRecordListItem(e,t))),this._renderShowAllRelatedRecordsListItem(e),this._renderObserverNode())}_renderNoValidOriginKeyNotice(e){const{messages:t}=this,i=e.relatedLayerIsTable?t.noOriginKeyRecord:t.noOriginKeyFeature,o=e.relationship?.keyField,n=this.viewModel.findField(o),a=e.layer?.fieldsIndex.get(o),s=n?.label||a?.alias||o,r=L(i,{relatedLayerName:e.relatedLayer?.title,originKeyField:s});return T("calcite-notice",{icon:"information",kind:"brand",open:!0,scale:"s",width:"full"},T("div",{slot:"message"},r))}_renderNoRelatedRecordsNotice(){return T("calcite-notice",{icon:"information",kind:"brand",open:!0,scale:"s",width:"full"},T("div",{slot:"message"},this.messagesFeature.noRelatedFeatures))}_renderObserverNode(){if(this.viewModel.activeRelationshipInput?.showAllEnabled)return T("div",{afterCreate:this._afterListObserverCreated,afterRemoved:this._afterListObserverRemoved,bind:this,class:p.listObserver,key:"feature-observer"})}getCommonInputProps(e){const{disabled:t}=this,{editable:i,hint:o,label:n,maxLength:a,minLength:s,name:r,range:{max:l,min:d},required:c,valid:u,value:m}=e,h=this._inputsWithChanges.has(r),v=!i||t;return{afterCreate:this._afterComponentCreate,afterUpdate:this._afterComponentCreateOrUpdate,"aria-invalid":u?"false":"true",class:this.classes(p.fieldInput,v?p.inputDisabled:null,h&&!u?p.inputInvalid:null),key:r,label:n,max:null!=l?l:void 0,min:null!=d?d:void 0,maxLength:a>-1?a:void 0,minLength:s>-1?s:void 0,placeholder:o??void 0,readOnly:v,required:c,value:null==m?"":`${m}`,onblur:this._onComponentBlur,onfocus:this._onComponentFocus,onkeydown:this._onComponentKeyDown,[j]:r}}_getFieldInputFromHTMLElement(e){return this.viewModel.findField(e.getAttribute(j))}_afterDateComponentCreate(e){const t=this._getFieldInputFromHTMLElement(e),i=e.dataset.datePart,o=this._dateComponentMap.get(t.name);if("valueAsDate"in e&&null!=e.value){const t=e.value,i=new ResizeObserver((()=>{e.value=void 0,e.value=t,i.unobserve(e)}));i.observe(e)}if(null!=o)switch(i){case"date":o.date=e;break;case"time":o.time=e;break;case"timeZone":o.timeZone=e}else this._dateComponentMap.set(t.name,{[i]:e});this._afterDateComponentCreateOrUpdate(e)}_afterDateComponentCreateOrUpdate(e){this._afterComponentCreateOrUpdate(e)}_afterComponentCreate(e){const t=this._getFieldInputFromHTMLElement(e);b(t)&&null!=e.value&&"setNumberValue"in e&&e.setNumberValue({committing:!1,value:e.value,origin:"direct"}),this._afterComponentCreateOrUpdate(e)}_afterRadioGroupCreateOrUpdate(e){const t=e.selectedItem,i=e.querySelector("calcite-radio-button"),o=t||i;o&&this._afterComponentCreateOrUpdate(o)}_afterComponentCreateOrUpdate(e){const{viewModel:t}=this,i=this._getFieldInputFromHTMLElement(e),o=t.findField(this._focusedFieldName);this._attemptFocusOnNextRender&&o===i&&(this._attemptFocusOnNextRender=!1,h(i)&&(i.group.open=!0),e.setFocus())}_onComponentFocus(e){const t=e.target,i=this._getFieldInputFromHTMLElement(t);this._focusedFieldName=i.name}_onComponentBlur(e){const t=e.target;this._focusedFieldName=null,this._saveValueFromComponent(t)}_saveValueFromDateComponent(e){const t=this._getFieldInputFromHTMLElement(e),i=t.field.type,{name:o}=t,n=this._dateComponentMap.get(o);if(!n)return;let a=this.viewModel.getValue(o),s=null;"date-only"===i?s=e.value:"time-only"===i?(a=O(a),s=O(e.value)):s="timestamp-offset"===i?null!=e.value?k({dateComponent:n.date,timeComponent:n.time,timeZoneComponent:n.timeZone,oldValue:a}):null:null!=e.value?I({oldValue:a,dateComponent:n.date,timeComponent:n.time,timeZone:this.timeZone,max:t.range?.max,min:t.range?.min}):null,null!==s&&e.value?a!==s&&this._updateFieldValue(o,s):this._updateFieldValue(o,null)}_saveValueFromComponent(e){const t=this._getFieldInputFromHTMLElement(e);this._updateFieldValue(t.name,this._parseValue(e))}_onComponentKeyDown({key:e,target:t}){const i=this._getFieldInputFromHTMLElement(t);"Enter"===e&&h(i)&&!i.group.open&&(i.group.open=!0)}_updateFieldValue(e,t){if(this.viewModel.setValue(e,t),this._inputsWithChanges.add(e),this.viewModel.fieldsWithContingentValues.has(e)){const e=Object.fromEntries(Object.entries(this.getValues()).filter((([e,t])=>null!=t)));this.viewModel.validateContingencyConstraints(e)}}_parseValue(e){const t=this._getFieldInputFromHTMLElement(e),i=e.value;return v(t.element,"switch")?e.checked?t.element.input.onValue:t.element.input.offValue:null==i||""===i?null:"number"===t.dataType?"-0"===i||"-0."===i||"-0,"===i?i:parseFloat(i):"date"===t.field.type?parseFloat(i):i}_ignoreDeselectionOfNoValueOption(e){const{firstChild:t,selectedItems:i}=e;0===i.length&&t&&"selected"in t?t.selected=!0:E.warnOnce("Failed to override user attempt to deselect 'No value' option.")}_onGroupToggle(e,t){e.open?(t.open=!0,this._focusedFieldName=this._getFocusableInput("forward",t)?.name||null,this._attemptFocusOnNextRender=!0,"sequential"===this.groupDisplay&&this.viewModel.allGroupInputs.forEach((e=>{e!==t&&(e.open=!1)}))):t.open=!1,this.scheduleRender()}_onFormSubmit(e){e.preventDefault()}_onFormKeyDown(e){"Enter"===e.key&&this.viewModel.submit()}_afterListObserverCreated(e){this.viewModel.activeRelationshipInput&&(this._listObserverNode=e)}_afterListObserverRemoved(){this._listObserverNode=null}_onObserverChange(){this._listObserverNode&&this._listObserver.unobserve(this._listObserverNode);const e=this.viewModel.activeRelationshipInput;e&&this._listObserverNode&&e.showAllEnabled&&this._listObserver.observe(this._listObserverNode)}_incrementRelatedRecordPage(){const e=this.viewModel.activeRelationshipInput;e?.incrementPage()}_syncGroupInputStates(){if("sequential"!==this.groupDisplay)return;const e=this.viewModel.allGroupInputs;if(!e.length)return;const t=e.filter((e=>e.open));0===t.length?e[0].open=!0:t.length>1&&t.slice(1).forEach((e=>e.open=!1))}};e([s()],U.prototype,"_listObserverNode",void 0),e([s()],U.prototype,"_relatedRecordsEnabled",null),e([s()],U.prototype,"disabled",null),e([s()],U.prototype,"feature",null),e([s()],U.prototype,"formTemplate",null),e([s()],U.prototype,"groupDisplay",void 0),e([s()],U.prototype,"headingLevel",void 0),e([s()],U.prototype,"label",null),e([s()],U.prototype,"layer",null),e([s()],U.prototype,"map",null),e([s(),V("esri/widgets/FeatureForm/t9n/FeatureForm")],U.prototype,"messages",void 0),e([s(),V("esri/t9n/common")],U.prototype,"messagesCommon",void 0),e([s(),V("esri/widgets/Feature/t9n/Feature")],U.prototype,"messagesFeature",void 0),e([s(),V("esri/widgets/FeatureTemplates/t9n/FeatureTemplates")],U.prototype,"messagesTemplates",void 0),e([s()],U.prototype,"relatedRecordCallbacks",null),e([s()],U.prototype,"relationshipId",null),e([s()],U.prototype,"spatialReference",null),e([s()],U.prototype,"strict",null),e([s()],U.prototype,"timeZone",null),e([s()],U.prototype,"view",null),e([s(),N(["value-change","submit"])],U.prototype,"viewModel",void 0),U=e([r(S)],U);const $=U;export{$ as default};
5
+ import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import{isSome as t}from"../core/arrayUtils.js";import{deprecatedProperty as i}from"../core/deprecate.js";import o from"../core/Logger.js";import{watch as n,whenOnce as a}from"../core/reactiveUtils.js";import{property as s}from"../core/accessorSupport/decorators/property.js";import"../core/accessorSupport/ensureType.js";import"../core/has.js";import{subclass as r}from"../core/accessorSupport/decorators/subclass.js";import{isIntegerField as l}from"../layers/support/fieldUtils.js";import d from"./Widget.js";import{css as p}from"./FeatureForm/css.js";import{isGroupInput as c,isFieldInput as u,isRelationshipInput as m,isInputInGroupInput as h,isFieldElementWithInputType as v,getErrorMessageForFieldInput as _,getIconForFeature as b,isNumberFieldInput as g}from"./FeatureForm/featureFormUtils.js";import f from"./FeatureForm/FeatureFormViewModel.js";import{loadCalciteComponents as C}from"./support/componentsUtils.js";import{isString as y}from"./support/dataUtils.js";import{getLabelForDateFieldValue as F,numberingSystem as w,prepareISOFieldValueForDateComponents as R,prepareUnixFieldValueForDateComponents as O,normalizeTimeOnlyString as k,getISOFieldValueFromDateComponents as I,getUnixFieldValueFromDateComponents as M}from"./support/dateUtils.js";import{globalCss as D}from"./support/globalCss.js";import{Heading as x,incrementHeadingLevel as V}from"./support/Heading.js";import"./support/widgetUtils.js";import{messageBundle as N}from"./support/decorators/messageBundle.js";import{vmEvent as T}from"./support/decorators/vmEvent.js";import{tsx as L}from"./support/jsxFactory.js";import{substitute as j}from"../intl/substitute.js";const E="data-field-name",U="esri.widgets.FeatureForm",S=o.getLogger(U);let $=class extends d{constructor(e,t){super(e,t),this._attemptFocusOnNextRender=!1,this._dateComponentMap=new Map,this._inputsWithChanges=new Set,this._focusedFieldName=null,this._listObserverNode=null,this._listObserver=new IntersectionObserver((e=>{e.length&&e[0].isIntersecting&&this._incrementRelatedRecordPage()}),{root:window.document}),this.groupDisplay="all",this.headingLevel=2,this.messages=null,this.messagesCommon=null,this.messagesFeature=null,this.messagesTemplates=null,this.viewModel=new f,this._onShowAllRelatedRecordsClick=e=>{const{feature:t,relatedRecordCallbacks:i}=this;t&&i?.showAllRelatedRecords&&i.showAllRelatedRecords({parentFeature:t,relationshipId:e})},this._onAddRelatedRecordsClick=(e,t)=>{const{feature:i,relatedRecordCallbacks:o}=this;i&&o?.addRelatedRecord&&o.addRelatedRecord({parentFeature:i,relatedLayer:t,relationshipId:e})},this._onFormKeyDown=this._onFormKeyDown.bind(this),this._onFormSubmit=this._onFormSubmit.bind(this),this._onGroupToggle=this._onGroupToggle.bind(this),this._onComponentBlur=this._onComponentBlur.bind(this),this._onComponentFocus=this._onComponentFocus.bind(this),this._onComponentKeyDown=this._onComponentKeyDown.bind(this),this._afterComponentCreate=this._afterComponentCreate.bind(this),this._afterComponentCreateOrUpdate=this._afterComponentCreateOrUpdate.bind(this),this._afterDateComponentCreate=this._afterDateComponentCreate.bind(this),this._afterDateComponentCreateOrUpdate=this._afterDateComponentCreateOrUpdate.bind(this),this._afterRadioGroupCreateOrUpdate=this._afterRadioGroupCreateOrUpdate.bind(this)}initialize(){this.addHandles([n((()=>this.feature),(()=>{a((()=>!this.viewModel.updating)).then((()=>{const e=this._getFocusableInput("forward");this._inputsWithChanges.clear(),this._dateComponentMap.clear(),this._syncGroupInputStates(),this._focusedFieldName=e?.name||null,this._attemptFocusOnNextRender=!0}))})),n((()=>this.groupDisplay),(()=>this._syncGroupInputStates())),this.on("submit",(e=>{if(e.invalid.length>0){const[t]=e.invalid;e.invalid.forEach((e=>this._inputsWithChanges.add(e))),this._focusedFieldName=t,this._attemptFocusOnNextRender=!0,this.scheduleRender()}})),n((()=>[this.viewModel.activeRelationshipInput,this._listObserverNode]),(()=>this._onObserverChange()))])}loadDependencies(){return C({block:()=>import("@esri/calcite-components/dist/components/calcite-block.js"),button:()=>import("@esri/calcite-components/dist/components/calcite-button.js"),combobox:()=>import("@esri/calcite-components/dist/components/calcite-combobox.js"),"combobox-item":()=>import("@esri/calcite-components/dist/components/calcite-combobox-item.js"),"combobox-item-group":()=>import("@esri/calcite-components/dist/components/calcite-combobox-item-group.js"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon.js"),input:()=>import("@esri/calcite-components/dist/components/calcite-input.js"),"input-date-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-date-picker.js"),"input-message":()=>import("@esri/calcite-components/dist/components/calcite-input-message.js"),"input-number":()=>import("@esri/calcite-components/dist/components/calcite-input-number.js"),"input-time-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-time-picker.js"),"input-time-zone":()=>import("@esri/calcite-components/dist/components/calcite-input-time-zone.js"),label:()=>import("@esri/calcite-components/dist/components/calcite-label.js"),list:()=>import("@esri/calcite-components/dist/components/calcite-list.js"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item.js"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader.js"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice.js"),"radio-button":()=>import("@esri/calcite-components/dist/components/calcite-radio-button.js"),"radio-button-group":()=>import("@esri/calcite-components/dist/components/calcite-radio-button-group.js"),switch:()=>import("@esri/calcite-components/dist/components/calcite-switch.js")})}destroy(){this._listObserverNode&&this._listObserver.unobserve(this._listObserverNode)}get _relatedRecordsEnabled(){const e=this.relatedRecordCallbacks;return!(!e||!(e.addRelatedRecord||e.editRelatedRecord||e.showAllRelatedRecords))}get disabled(){return this.viewModel.disabled}set disabled(e){this.viewModel.disabled=e}get feature(){return this.viewModel.feature}set feature(e){this.viewModel.feature=e}get formTemplate(){return this.viewModel.formTemplate}set formTemplate(e){this.viewModel.formTemplate=e}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get layer(){return this.viewModel.layer}set layer(e){this.viewModel.layer=e}get map(){return this.viewModel.map}set map(e){this.viewModel.map=e}get relatedRecordCallbacks(){return this.viewModel.relatedRecordCallbacks}set relatedRecordCallbacks(e){this.viewModel.relatedRecordCallbacks=e}get relationshipId(){return this.viewModel.relationshipId}set relationshipId(e){this.viewModel.relationshipId=e}get spatialReference(){return this.viewModel.spatialReference}set spatialReference(e){this.viewModel.spatialReference=e}get strict(){return this.viewModel.strict}set strict(e){this.viewModel.strict=e}get timeZone(){return this.viewModel.timeZone}set timeZone(e){this.viewModel.timeZone=e}get view(){return i(S,"view",{replacement:"Use FeatureForm.map instead.",version:"4.27"}),this.viewModel.view}set view(e){i(S,"view",{replacement:"Use FeatureForm.map instead.",version:"4.27"}),this.viewModel.view=e}getValues(){return this.viewModel.getValues()}submit(){return this.viewModel.submit()}render(){const{state:e}=this.viewModel;return L("div",{class:this.classes(p.base,D.widget,D.panel)},"ready"===e?this._renderForm():null)}_renderForm(){return L("form",{class:p.form,novalidate:!0,onkeydown:this._onFormKeyDown,onsubmit:this._onFormSubmit},this._renderHeader(),this._renderContent())}_renderHeader(){const e=this.viewModel;if(!e.formHeaderVisible)return;const t=null!=e.formTitle&&L(x,{key:"title",level:this.headingLevel},e.formTitle),i=null!=e.formDescription&&L("p",{class:p.description,key:"description"},e.formDescription);return L("div",{class:p.formHeader},t,i)}_renderContent(){const{viewModel:e}=this;return e.activeRelationshipInput?this._renderActiveRelationshipInput(e.activeRelationshipInput):e.inputs.filter(t).filter((e=>e.visible)).map(((e,t)=>c(e)?this._renderGroup(e,t):u(e)?this._renderLabeledField(e):m(e)?this._renderRelationshipInput(e):void 0))}_renderActiveRelationshipInput(e){return this._renderRelationshipInput(e)}_renderDescriptionOrEmpty(e,t){return null==e?null:L("div",{class:this.classes(p.description),id:t},e)}_renderGroup(e,t){const{disabled:i,formTemplate:o,headingLevel:n}=this,{description:a,inputs:s,label:r,open:l}=e,d=s.filter((e=>e.visible)),c=this.viewModel.findField(this._focusedFieldName),h=c?.group===e,v=`${this.id}_group_${t}`,_="sequential"===this.groupDisplay;return L("calcite-block",{class:this.classes(p.group,_?p.groupSequential:null,h?p.groupActive:null,i?p.inputDisabled:null),collapsible:!0,"data-group":e,description:a||void 0,disabled:i,heading:`${r}`,headingLevel:o?.title?V(n):n,id:v,key:v,open:l,onCalciteBlockToggle:({target:t})=>this._onGroupToggle(t,e)},d.map((e=>u(e)?this._renderLabeledField(e):m(e)?this._renderRelationshipInput(e):void 0)))}_getFocusableInput(e,t){const i=this.viewModel.allFieldInputs,o="forward"===e?i:i.slice().reverse();let n;if(!t||m(t))n=0;else if(c(t)){const e=t.inputs.find(u);n=e?o.indexOf(e):0}else{let i;if(h(t)&&!t.group.open){const o=t.group.inputs.filter(u);i="forward"===e?o[o.length-1]:o[0]}else i=t;n=o.indexOf(i)+1}for(let a=n;a<o.length;a++){const e=o[a];if(e.visible&&u(e))return e}return null}_renderLabeledField(e){const{dataType:t,feature:i,label:o,layer:n,required:a}=e,s={"aria-label":a?j(this.messages.requiredFieldLabel,{name:o}):o,class:p.label,key:`${n.id}-${i.uid}-${e.name}`},r=[L("div",{class:p.labelTextContent,key:"labelTextContainer"},o,a?L("span",{"aria-hidden":"true",title:this.messagesCommon.required},"*"):void 0),"unsupported"!==t?this._renderFieldInput(e):this._renderReadOnlyComponent(e),this._renderAuxiliaryText(e)];return"date"===t&&"coded-value"!==e.domain?.type?L("label",{...s},r):L("calcite-label",{...s},r)}_renderFieldInput(e){const{dataType:t,domain:i,inputType:o,name:n}=e,a=this.getCommonInputProps(e);if("coded-value"===i?.type){const t=this.viewModel.getFieldValueOptionsForField(n,this.messages.empty);return"switch"!==o||e.hasInvalidSwitchValue?"radio-buttons"===o?this._renderRadioButtonComponents(e,t.flat(),a):this._renderComboBoxComponent(e,t,a):this._renderSwitchComponent(e,a)}return"datetime-picker"===o||"date"===t?this._renderDateComponents(e,a):"number"===t?this._renderNumberComponent(e,a):this._renderStringComponent(e,a)}_renderStringComponent(e,t){return L("calcite-input",{...t,loading:e.updating,type:"text-area"===e.inputType?"textarea":"text",onCalciteInputInput:e=>this._saveValueFromComponent(e.target)})}_renderNumberComponent(e,t){return L("calcite-input-number",{...t,integer:l(e.field),loading:e.updating,type:"number",onCalciteInputNumberInput:e=>this._saveValueFromComponent(e.target)})}_renderDateComponents(e,t){const{field:i}=e;switch(i.type){case"date":return this._renderDateFieldComponents(e,t);case"date-only":return this._renderDateOnlyFieldComponent(e,t);case"time-only":return this._renderTimeOnlyFieldComponent(e,t);case"timestamp-offset":return this._renderTimestampOffsetFieldComponents(e,t);default:return this._renderReadOnlyComponent(e,F(e.field,t.value,{timeZone:this.timeZone}))}}_renderDateOnlyFieldComponent(e,t){const{range:i,valid:o,value:n}=e,{class:a,key:s,readOnly:r}=t,{rawMax:l,rawMin:d}=i;return L("calcite-input-date-picker",{afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterDateComponentCreateOrUpdate,"aria-invalid":!o,class:a,"data-date-part":"date","data-field-name":t[E],key:`${s}-date-input`,max:y(l)?l:void 0,min:y(d)?d:void 0,numberingSystem:w,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},onfocus:this._onComponentFocus,overlayPositioning:"fixed",readOnly:r,value:null!=n?`${n}`:void 0,onCalciteInputDatePickerChange:e=>this._saveValueFromDateComponent(e.target)})}_renderTimeOnlyFieldComponent(e,t){const{valid:i,value:o}=e,{class:n,key:a,readOnly:s}=t;return L("calcite-input-time-picker",{afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterDateComponentCreateOrUpdate,"aria-invalid":!i,class:n,"data-date-part":"time","data-field-name":t[E],key:`${a}-time-input`,numberingSystem:w,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},onfocus:this._onComponentFocus,overlayPositioning:"fixed",readOnly:s,step:e.timeStep,value:null!=o?`${o}`:void 0,onCalciteInputTimePickerChange:e=>this._saveValueFromDateComponent(e.target)})}_renderTimestampOffsetFieldComponents(e,t){const{name:i,range:o,valid:n,value:a}=e,{class:s,key:r,readOnly:l}=t,{rawMax:d,rawMin:c}=o,u={afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterDateComponentCreateOrUpdate,"aria-invalid":!n,numberingSystem:w,overlayPositioning:"fixed",readOnly:l,[E]:i,onfocus:this._onComponentFocus},m=R(d),h=R(c),v=R(a);return L("div",{class:p.dateInputContainer,key:`${r}-date-time-container`},L("calcite-input-date-picker",{...u,class:s,"data-date-part":"date",key:`${r}-date-input`,max:m?.date??void 0,min:h?.date??void 0,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},value:v.date??void 0,onCalciteInputDatePickerChange:e=>this._saveValueFromDateComponent(e.target)}),L("calcite-input-time-picker",{...u,class:s,"data-date-part":"time",key:`${r}-time-input`,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},step:e.timeStep,value:v.time??void 0,onCalciteInputTimePickerChange:e=>this._saveValueFromDateComponent(e.target)}),e.includeTimeOffset?L("calcite-input-time-zone",{...u,class:s,"data-date-part":"timeZone",disabled:l,key:`${r}-timezone-input`,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},value:v.timeZoneOffset??"0",onCalciteInputTimeZoneChange:e=>this._saveValueFromDateComponent(e.target)}):null)}_renderDateFieldComponents(e,t){const{includeTime:i,name:o,valid:n,value:a}=e,{class:s,key:r,max:l,min:d,readOnly:c}=t,{timeZone:u}=this,m={afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterDateComponentCreateOrUpdate,"aria-invalid":!n,numberingSystem:w,overlayPositioning:"fixed",readOnly:c,[E]:o,onfocus:this._onComponentFocus},h=O(a,u),v=O(l,u),_=O(d,u);return L("div",{class:p.dateInputContainer,key:`${r}-date-time-container`},L("calcite-input-date-picker",{...m,class:s,"data-date-part":"date",key:`${r}-date-input`,max:v?.date??void 0,min:_?.date??void 0,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},value:h.date??void 0,onCalciteInputDatePickerChange:e=>this._saveValueFromDateComponent(e.target)}),i?L("calcite-input-time-picker",{...m,class:s,"data-date-part":"time",key:`${r}-time-input`,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},step:1,value:h.time??void 0,onCalciteInputTimePickerChange:e=>this._saveValueFromDateComponent(e.target)}):null)}_renderReadOnlyComponent(e,t){const i=this.getCommonInputProps(e);return L("calcite-input",{...i,class:this.classes(p.fieldInput,p.inputDisabled),readOnly:!0,type:"text",value:null!=t?`${t}`:i.value})}_renderComboBoxComponent(e,t,i){const{value:o,name:n}=e,{messages:a,messagesTemplates:s,viewModel:r,_inputsWithChanges:l}=this,d=t.map((e=>e.map((({name:e,value:t})=>L("calcite-combobox-item",{key:`#${t}`,selected:o===t,textLabel:e,value:`${t}`}))))),[p,c]=d;this.viewModel.fieldsWithInvalidCodedValue.has(e)&&c.unshift(L("calcite-combobox-item",{key:"incompatible-option",readOnly:!0,textLabel:`${e.value}`,value:`${e.value}`}));const u=c.length>0?[L("calcite-combobox-item-group",{key:"recommended",label:a.recommended},p),L("calcite-combobox-item-group",{key:"other",label:s.other},c)]:p,m="INSERT"===r.arcadeEditType,h=l.has(n),v=null==o&&(!m||h);if(e.showNoValueOptionEnabled){const t="",i=e.showNoValueLabel||a.empty;u.unshift(L("calcite-combobox-item",{key:"empty-option",selected:v,textLabel:a.empty,value:t},i))}const _=m&&e.showNoValueOptionEnabled&&!h?()=>{}:i.onblur;return L("calcite-combobox",{...i,allowCustomValues:!1,clearDisabled:!0,disabled:i.readOnly,onblur:_,overlayPositioning:"fixed",selectionMode:"single",onCalciteComboboxChange:({target:e})=>{v&&0===e.selectedItems.length?this._ignoreDeselectionOfNoValueOption(e):this._saveValueFromComponent(e)}},u)}_renderRadioButtonComponents(e,t,i){const{name:o,value:n}=e,a=t.map((({name:e,value:t})=>this._renderRadioButtonComponent({key:e,label:e,name:o,value:t,selected:t===n,props:i})));if(e.showNoValueOptionEnabled){const t="",s=e.showNoValueLabel||this.messages.empty,r=n===t||null===n;a.unshift(this._renderRadioButtonComponent({key:"empty-option",label:s,name:o,value:t,selected:r,props:i}))}return L("calcite-radio-button-group",{afterCreate:this._afterRadioGroupCreateOrUpdate,afterUpdate:this._afterRadioGroupCreateOrUpdate,class:p.inputRadioGroup,"data-field-name":i[E],key:`${i.key}-radio-group`,layout:"vertical",name:i.key,required:i.required},a)}_renderSwitchComponent(e,t){const{value:i}=e,o=!!v(e.element,"switch")&&i===e.element.input.onValue;return L("calcite-switch",{...t,checked:o,class:p.inputSwitch,disabled:t.readOnly,onblur:()=>{this._focusedFieldName=null},onCalciteSwitchChange:e=>this._saveValueFromComponent(e.target)})}_renderRadioButtonComponent({key:e,name:t,value:i,selected:o,label:n,props:a}){return L("calcite-label",{class:p.inputRadioLabel,key:e,layout:"inline"},L("calcite-radio-button",{...a,afterCreate:void 0,afterUpdate:void 0,checked:o,class:p.inputRadio,disabled:a.readOnly,name:t,onblur:()=>{this._focusedFieldName=null},value:i,onCalciteRadioButtonChange:({target:e})=>{e.checked&&this._saveValueFromComponent(e)}}),n)}_renderAuxiliaryText(e){const t=e.name,i=this._inputsWithChanges.has(t)&&!e.valid?_(e,this.messages,this.timeZone):null!=this.viewModel.contingencyConstraintViolations.get(t)?this.messages.validationErrors.valuesIncompatible:null!=e.valueExpressionExecutor&&e.valueExpressionExecutor.stale?this.messages.valueExpressionError:null;return null!=i?L("calcite-input-message",{icon:!0,status:"invalid"},i):this._renderDescriptionOrEmpty(e.description)}_renderShowAllRelatedRecordsListItem(e){const{featureCount:t,relationshipId:i,showAllActionVisible:o}=e,{relatedRecordCallbacks:n}=this;if(!o||!n?.showAllRelatedRecords)return;const a=this.messages;return L("calcite-list-item",{description:j(a.totalCount,{count:t}),label:a.showAll,value:!0,onCalciteListItemSelect:()=>this._onShowAllRelatedRecordsClick(i)},L("calcite-icon",{icon:"list",scale:"s",slot:"content-end"}))}_renderAddRelatedRecordButton(e){const{canAddRelatedFeature:t,relationshipId:i,relatedLayer:o}=e,{messages:n,relatedRecordCallbacks:a}=this;if(t&&a?.addRelatedRecord&&o)return L("calcite-button",{alignment:"center",appearance:"outline-fill",class:p.centeredButton,disabled:e.updating||!e.originHasValidKey,iconStart:"plus",key:`${i}-add-button`,onclick:()=>this._onAddRelatedRecordsClick(i,o),round:!0,scale:"s",width:"half"},e.relatedLayerIsTable?n.addRecord:n.addFeature)}_renderRelatedRecordListItem(e,t){const{feature:i,description:o,title:n}=e,{feature:a,relatedRecordCallbacks:s}=this,{highlightHelper:r}=this.viewModel,l=()=>{r?.removeAll(),s?.editRelatedRecord&&a&&s.editRelatedRecord({parentFeature:a,relationshipId:t,relatedFeature:i})},d=r?()=>r.add(i):void 0,p=r?()=>r.remove(i):void 0;return L("calcite-list-item",{bind:this,description:o,key:`${t}-${i.uid}`,label:n,onclick:l,onmouseenter:d,onmouseleave:p,value:n},L("calcite-icon",{icon:b(i),scale:"m",slot:"content-start"}),L("calcite-icon",{icon:"chevron-right",scale:"s",slot:"content-end"}))}_renderRelationshipInput(e){if(!this._relatedRecordsEnabled||!e.editable)return;const{featureCount:t,relationshipId:i,showAllEnabled:o}=e,n=o?null:this._renderDescriptionOrEmpty(e.description),a=t>0?this._renderRelatedRecordsList(e):e.loaded?e.originHasValidKey?this._renderNoRelatedRecordsNotice():this._renderNoValidOriginKeyNotice(e):void 0;return L("calcite-label",{class:this.classes(p.label,p.relatedRecordsLabel),key:`relationship-${i}-container`},L("div",null,this._renderRelatedRecordsHeaderContainer(e),n,a),this._renderAddRelatedRecordButton(e))}_renderRelatedRecordsHeaderContainer(e){const t=e.updating||!e.loaded;return L("div",{class:p.relatedRecordsHeader,key:`relationship-${e.relationshipId}-header`},L("span",null,e.label),t?L("calcite-loader",{inline:!0,key:"loader",label:this.messagesCommon?.loading,scale:"s",type:"indeterminate"}):void 0)}_renderRelatedRecordsList(e){const{relationshipId:t}=e;return L("calcite-list",{class:p.relatedRecordsList},e.relatedFeatureInfos.map((e=>this._renderRelatedRecordListItem(e,t))),this._renderShowAllRelatedRecordsListItem(e),this._renderObserverNode())}_renderNoValidOriginKeyNotice(e){const{messages:t}=this,i=e.relatedLayerIsTable?t.noOriginKeyRecord:t.noOriginKeyFeature,o=e.relationship?.keyField,n=this.viewModel.findField(o),a=e.layer?.fieldsIndex.get(o),s=n?.label||a?.alias||o,r=j(i,{relatedLayerName:e.relatedLayer?.title,originKeyField:s});return L("calcite-notice",{icon:"information",kind:"brand",open:!0,scale:"s",width:"full"},L("div",{slot:"message"},r))}_renderNoRelatedRecordsNotice(){return L("calcite-notice",{icon:"information",kind:"brand",open:!0,scale:"s",width:"full"},L("div",{slot:"message"},this.messagesFeature.noRelatedFeatures))}_renderObserverNode(){if(this.viewModel.activeRelationshipInput?.showAllEnabled)return L("div",{afterCreate:this._afterListObserverCreated,afterRemoved:this._afterListObserverRemoved,bind:this,class:p.listObserver,key:"feature-observer"})}getCommonInputProps(e){const{disabled:t}=this,{editable:i,hint:o,label:n,maxLength:a,minLength:s,name:r,range:{max:l,min:d},required:c,valid:u,value:m}=e,h=this._inputsWithChanges.has(r),v=!i||t;return{afterCreate:this._afterComponentCreate,afterUpdate:this._afterComponentCreateOrUpdate,"aria-invalid":u?"false":"true",class:this.classes(p.fieldInput,v?p.inputDisabled:null,h&&!u?p.inputInvalid:null),key:r,label:n,max:null!=l?l:void 0,min:null!=d?d:void 0,maxLength:a>-1?a:void 0,minLength:s>-1?s:void 0,placeholder:o??void 0,readOnly:v,required:c,value:null==m?"":`${m}`,onblur:this._onComponentBlur,onfocus:this._onComponentFocus,onkeydown:this._onComponentKeyDown,[E]:r}}_getFieldInputFromHTMLElement(e){return this.viewModel.findField(e.getAttribute(E))}_afterDateComponentCreate(e){const t=this._getFieldInputFromHTMLElement(e),i=e.dataset.datePart,o=this._dateComponentMap.get(t.name);if("valueAsDate"in e&&null!=e.value){const t=e.value,i=new ResizeObserver((()=>{e.value=void 0,e.value=t,i.unobserve(e)}));i.observe(e)}if(null!=o)switch(i){case"date":o.date=e;break;case"time":o.time=e;break;case"timeZone":o.timeZone=e}else this._dateComponentMap.set(t.name,{[i]:e});this._afterDateComponentCreateOrUpdate(e)}_afterDateComponentCreateOrUpdate(e){this._afterComponentCreateOrUpdate(e)}_afterComponentCreate(e){const t=this._getFieldInputFromHTMLElement(e);g(t)&&null!=e.value&&"setNumberValue"in e&&e.setNumberValue({committing:!1,value:e.value,origin:"direct"}),this._afterComponentCreateOrUpdate(e)}_afterRadioGroupCreateOrUpdate(e){const t=e.selectedItem,i=e.querySelector("calcite-radio-button"),o=t||i;o&&this._afterComponentCreateOrUpdate(o)}_afterComponentCreateOrUpdate(e){const{viewModel:t}=this,i=this._getFieldInputFromHTMLElement(e),o=t.findField(this._focusedFieldName);this._attemptFocusOnNextRender&&o===i&&(this._attemptFocusOnNextRender=!1,h(i)&&(i.group.open=!0),e.setFocus())}_onComponentFocus(e){const t=e.target,i=this._getFieldInputFromHTMLElement(t);this._focusedFieldName=i.name}_onComponentBlur(e){const t=e.target;this._focusedFieldName=null,this._saveValueFromComponent(t)}_saveValueFromDateComponent(e){const t=this._getFieldInputFromHTMLElement(e),i=t.field.type,{name:o,range:n}=t,a=this._dateComponentMap.get(o);if(!a)return;let s=this.viewModel.getValue(o),r=null;"date-only"===i?r=e.value:"time-only"===i?(s=k(s),r=k(e.value)):r="timestamp-offset"===i?null!=e.value?I({dateComponent:a.date,timeComponent:a.time,timeZoneComponent:a.timeZone,oldValue:s}):null:null!=e.value?M({oldValue:s,dateComponent:a.date,timeComponent:a.time,timeZone:this.timeZone,max:n.max,min:n.min}):null,null!==r&&e.value?s!==r&&this._updateFieldValue(o,r):this._updateFieldValue(o,null)}_saveValueFromComponent(e){const t=this._getFieldInputFromHTMLElement(e);this._updateFieldValue(t.name,this._parseValue(e))}_onComponentKeyDown({key:e,target:t}){const i=this._getFieldInputFromHTMLElement(t);"Enter"===e&&h(i)&&!i.group.open&&(i.group.open=!0)}_updateFieldValue(e,t){if(this.viewModel.setValue(e,t),this._inputsWithChanges.add(e),this.viewModel.fieldsWithContingentValues.has(e)){const e=Object.fromEntries(Object.entries(this.getValues()).filter((([e,t])=>null!=t)));this.viewModel.validateContingencyConstraints(e)}}_parseValue(e){const t=this._getFieldInputFromHTMLElement(e),i=e.value;return v(t.element,"switch")?e.checked?t.element.input.onValue:t.element.input.offValue:null==i||""===i?null:"number"===t.dataType?"-0"===i||"-0."===i||"-0,"===i?i:parseFloat(i):"date"===t.field.type?parseFloat(i):i}_ignoreDeselectionOfNoValueOption(e){const{firstChild:t,selectedItems:i}=e;0===i.length&&t&&"selected"in t?t.selected=!0:S.warnOnce("Failed to override user attempt to deselect 'No value' option.")}_onGroupToggle(e,t){e.open?(t.open=!0,this._focusedFieldName=this._getFocusableInput("forward",t)?.name||null,this._attemptFocusOnNextRender=!0,"sequential"===this.groupDisplay&&this.viewModel.allGroupInputs.forEach((e=>{e!==t&&(e.open=!1)}))):t.open=!1,this.scheduleRender()}_onFormSubmit(e){e.preventDefault()}_onFormKeyDown(e){"Enter"===e.key&&this.viewModel.submit()}_afterListObserverCreated(e){this.viewModel.activeRelationshipInput&&(this._listObserverNode=e)}_afterListObserverRemoved(){this._listObserverNode=null}_onObserverChange(){this._listObserverNode&&this._listObserver.unobserve(this._listObserverNode);const e=this.viewModel.activeRelationshipInput;e&&this._listObserverNode&&e.showAllEnabled&&this._listObserver.observe(this._listObserverNode)}_incrementRelatedRecordPage(){const e=this.viewModel.activeRelationshipInput;e?.incrementPage()}_syncGroupInputStates(){if("sequential"!==this.groupDisplay)return;const e=this.viewModel.allGroupInputs;if(!e.length)return;const t=e.filter((e=>e.open));0===t.length?e[0].open=!0:t.length>1&&t.slice(1).forEach((e=>e.open=!1))}};e([s()],$.prototype,"_listObserverNode",void 0),e([s()],$.prototype,"_relatedRecordsEnabled",null),e([s()],$.prototype,"disabled",null),e([s()],$.prototype,"feature",null),e([s()],$.prototype,"formTemplate",null),e([s()],$.prototype,"groupDisplay",void 0),e([s()],$.prototype,"headingLevel",void 0),e([s()],$.prototype,"label",null),e([s()],$.prototype,"layer",null),e([s()],$.prototype,"map",null),e([s(),N("esri/widgets/FeatureForm/t9n/FeatureForm")],$.prototype,"messages",void 0),e([s(),N("esri/t9n/common")],$.prototype,"messagesCommon",void 0),e([s(),N("esri/widgets/Feature/t9n/Feature")],$.prototype,"messagesFeature",void 0),e([s(),N("esri/widgets/FeatureTemplates/t9n/FeatureTemplates")],$.prototype,"messagesTemplates",void 0),e([s()],$.prototype,"relatedRecordCallbacks",null),e([s()],$.prototype,"relationshipId",null),e([s()],$.prototype,"spatialReference",null),e([s()],$.prototype,"strict",null),e([s()],$.prototype,"timeZone",null),e([s()],$.prototype,"view",null),e([s(),T(["value-change","submit"])],$.prototype,"viewModel",void 0),$=e([r(U)],$);const A=$;export{A 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.28/esri/copyright.txt for details.
4
4
  */
5
- import"../../../intl.js";import e from"../../../core/Error.js";import{clone as t}from"../../../core/lang.js";import r from"../../../core/Logger.js";import{getMetersPerUnitForSR as i}from"../../../core/unitUtils.js";import n from"../../../geometry/Polygon.js";import l from"../../../rest/support/FullTextSearch.js";import{createExtentFromGeometry as o,scaleExtent as s}from"./geometryUtils.js";import{substitute as u}from"../../../intl/substitute.js";import{formatDate as a}from"../../../intl/date.js";const c=/https?:\/\/services.*\.arcgis\.com/i,d=/(?:\{([^}]+)\})/g,f=r.getLogger("esri.widgets.Search.support.layerSearchUtils");function p(t,r){const{exactMatch:n=!1,location:l,maxResults:o,spatialReference:s,source:u,sourceIndex:a,suggestResult:c,view:d}=t,{layer:p,filter:m,zoomScale:T}=u,L=d?.scale,S=g(u,d),q=r?.signal;return h(p).then((()=>{const e=p.popupTemplate;return e?e.getRequiredFields(p.fieldsIndex):null})).then((t=>{const{objectIdField:r,returnZ:g}=p,h=b(u);if(!I(p,h))throw f.error("invalid-field: displayField is invalid."),new e("getResults():invalid-field","displayField is invalid.");const C=t&&t.length?t:[h],E=u.outFields||C,M=y(E);E.includes(r)||M||E.push(r),p.floorInfo?.floorField&&E.push(p.floorInfo.floorField);if(!(M||j(p,E)))throw f.error("invalid-field: outField is invalid."),new e("getResults():invalid-field","outField is invalid.");const A=p.createQuery(),{orderByFields:N}=u;if(N&&(A.orderByFields=N),s){A.outSpatialReference=s;const e=1/i(s);e&&(A.maxAllowableOffset=e)}const k="mesh"===p.geometryType||"multipatch"===p.geometryType,O=p.capabilities?.data?.supportsZ&&!k;if(A.returnZ=O&&!1!==g,A.returnGeometry=!0,A.multipatchOption=k?"xyFootprint":null,E&&(A.outFields=E),l)A.geometry=l;else if(c.key)A.objectIds=[c.key];else{const t=u.searchFields||[h];if(!j(p,t))throw f.error("invalid-field: search field is invalid."),new e("getResults():invalid-field","search field is invalid.");$(p)&&(A.num=o),S&&(A.geometry=S);const r=c.text?.trim();if(!r)return[];const i=c.text,{prefix:l="",suffix:s=""}=u,a=R(`${l}${i}${s}`);w(p)&&x(p,t)&&!n&&i&&(A.fullText=v({text:i,searchFields:t}));const d=D({searchTerm:a,layer:p,searchFields:t,filter:m,exactMatch:n,query:A,type:"search"});if(A.where=d,!F(A))return[]}return p.queryFeatures(A,{signal:q}).then((e=>U(e,d,u,a,h,L,T)))}))}function m(t,r){const{source:i,spatialReference:n,view:l,suggestTerm:o,maxSuggestions:s,sourceIndex:u,exactMatch:a}=t,{layer:c,filter:p}=i,m=r?.signal,T=g(i,l);return h(c).then((()=>{if(!$(c))return[];const t=b(i),r=i.searchFields||[t],l=[];i.suggestionTemplate?i.suggestionTemplate.replaceAll(d,((e,t)=>(l.push(t),e))):l.push(t);const g=y(l);l.includes(c.objectIdField)||g||l.push(c.objectIdField);const h=I(c,t),L=g||j(c,l),S=j(c,r);if(!h)throw f.error("invalid-field: displayField is invalid."),new e("getSuggestions():invalid-field","displayField is invalid.");if(!L)throw f.error("invalid-field: outField is invalid."),new e("getSuggestions():invalid-field","outField is invalid.");if(!S)throw f.error("invalid-field: search field is invalid."),new e("getSuggestions():invalid-field","search field is invalid.");const q=c.createQuery(),{orderByFields:C}=i;C&&(q.orderByFields=C),q.outSpatialReference=n,q.returnGeometry=!1,q.num=s,q.outFields=l,T&&(q.geometry=T);if(!o.trim())return[];const{prefix:E="",suffix:M=""}=i,A=R(`${E}${o}${M}`);w(c)&&x(c,r)&&!a&&o&&(q.fullText=v({text:o,searchFields:r}));const N=D({searchTerm:A,layer:c,searchFields:r,filter:p,exactMatch:a,query:q,type:"suggest"});return q.where=N,F(q)?c.queryFeatures(q,{signal:m}).then((e=>O(e,i,u,t))):[]}))}function g(e,t){const{filter:r,withinViewEnabled:i}=e,n=t?.extent,l=r?.geometry;return l??(i&&n?n:void 0)}function y(e){return e&&e.includes("*")}async function h(e){e&&await e.load()}function F(e){return!(!e.fullText&&!e.where)}function x(e,t){const r=e?.indexes;if(!r||!t?.length)return!1;return r.filter((e=>"FullText"===e.indexType)).some((e=>{const r=e.fields?.split(",").map((e=>e.trim().toLowerCase()))||[];return t.every((e=>r.includes(e.toLowerCase())))}))}function v({text:e,searchFields:t}){return e.trim().split(" ").filter((e=>!!e.trim())).map((e=>new l({onFields:t,searchTerm:e,searchType:"prefix"})))}function w(e){return e?.capabilities?.query?.supportsFullTextSearch??!1}function $(e){return e?.capabilities?.query?.supportsPagination??!1}function T(e){return e?.fieldsIndex?.fields?.find((e=>"string"===e.type))?.name??""}function b(e){return e.displayField||e.layer.displayField||T(e.layer)}function j(e,t){return!(!e||!t?.length)&&t.every((t=>I(e,t)))}function I(e,t){return!!e.getField(t)}function L(e){for(let t=0;t<e.length;t++)if(e.charCodeAt(t)>255)return!0;return!1}function S(e,t,r){let i=null;const{codedValues:n}=e;return n&&n.some((e=>{const n=e.name,l=r?n:n.toLowerCase();return(r?t:t.toLowerCase())===l&&(i=e.code.toString(),!0)})),i}function R(e){return e.replaceAll("'","''")}function q(e,t){const r=t?.where;return r?`(${e}) AND (${r})`:e}function C({currentTerm:e,field:t,filter:r,exactMatch:i,url:n,type:l}){const o=t?.type,s=t?.name;if("string"===o||"date"===o||"global-id"===o){const t=c.test(n??""),o=t&&L(e)?"N":"";if(i&&"search"===l)return q(`${s} = ${o}'${e}'`,r);if(t){return q(`${s} LIKE ${o}${`'${e}%'`}`,r)}return q(`${`LOWER(${s})`} LIKE ${o}${`'${e.toLowerCase()}%'`}`,r)}if("oid"===o||"small-integer"===o||"integer"===o||"single"===o||"double"===o){const t=Number(e);return isNaN(t)?null:q(`${s} = ${t}`,r)}return q(`${s} = ${e}`,r)}function E(e,t){return e?` OR (${t})`:`(${t})`}function D({searchTerm:e,layer:t,searchFields:r,filter:i,exactMatch:n,query:l,type:o}){const{definitionExpression:s,url:u}=t;let a="";return!l.fullText&&e&&r&&r.forEach((r=>{const l=t.getField(r),s="function"==typeof t.getFieldDomain&&t.getFieldDomain(r),c=(s&&"coded-value"===s.type?S(s,e,n):null)||e||null;if(null!==c){const e=C({currentTerm:c,field:l,filter:i,exactMatch:n,url:u,type:o});e&&(a+=E(a,e))}})),s&&a?`(${s}) AND (${a})`:s||a}function M(e,t){let r=null;const{codedValues:i}=e;return i&&i.length&&i.some((e=>e.code===t&&(r=e.name,!0))),r}function A(e,t){return e[Object.keys(e).find((e=>e.toLowerCase()===t.toLowerCase()))]}function N(e,t,r){const i=e.sourceLayer,{attributes:n}=e,l="function"==typeof i.getFieldDomain&&i.getFieldDomain(r);if(t)return u(t,n);if(r&&n){const e=i.getField(r),t=A(n,r);return null==t?"":l&&"coded-value"===l.type?M(l,t)??"":"date"===e?.type?a(new Date(t)):"number"==typeof t?t.toString():"string"!=typeof t?"":t.trim()}return""}function k(e,t,r,i){const n=e.sourceLayer,{attributes:l}=e,{objectIdField:o}=n,s=o?l[o]:null;return{text:N(e,t.suggestionTemplate,i),key:s,sourceIndex:r}}function O(e,t,r,i){return e.features.map((e=>k(e,t,r,i)))}function B(e,r,i,l,u,a,c){const d=e.clone(),f=e.sourceLayer,p=f?.objectIdField,m=p?e.attributes[p]:null,g=N(e,i.searchTemplate,u),y=o(d.geometry,r,a),h="number"==typeof c?s(t(y),r,c):y,F=e.clone();return null!=h&&(F.geometry=n.fromExtent(h)),{extent:h,target:F,feature:d,key:m,name:g,sourceIndex:l}}function U(e,t,r,i,n,l,o){return e.features.map((e=>B(e,t,r,i,n,l,o)))}export{v as createFullTextSearchInfos,p as getResults,m as getSuggestions};
5
+ import"../../../intl.js";import e from"../../../core/Error.js";import{clone as t}from"../../../core/lang.js";import r from"../../../core/Logger.js";import{getMetersPerUnitForSR as i}from"../../../core/unitUtils.js";import n from"../../../geometry/Polygon.js";import l from"../../../rest/support/FullTextSearch.js";import{createExtentFromGeometry as o,scaleExtent as s}from"./geometryUtils.js";import{substitute as u}from"../../../intl/substitute.js";import{formatDate as a}from"../../../intl/date.js";const c=/https?:\/\/services.*\.arcgis\.com/i,d=/(?:\{([^}]+)\})/g,f=r.getLogger("esri.widgets.Search.support.layerSearchUtils");function m(t,r){const{exactMatch:n=!1,location:l,maxResults:o,spatialReference:s,source:u,sourceIndex:a,suggestResult:c,view:d}=t,{layer:m,filter:p,zoomScale:T}=u,I=d?.scale,L=g(u,d),q=r?.signal;return h(m).then((()=>{const e=m.popupTemplate;return e?e.getRequiredFields(m.fieldsIndex):null})).then((t=>{const{objectIdField:r,returnZ:g}=m,h=b(u);if(!j(m,h))throw f.error("invalid-field: displayField is invalid."),new e("getResults():invalid-field","displayField is invalid.");const C=t&&t.length?t:[h],E=u.outFields||C,M=y(E);E.includes(r)||M||E.push(r),m.floorInfo?.floorField&&E.push(m.floorInfo.floorField);if(!(M||S(m,E)))throw f.error("invalid-field: outField is invalid."),new e("getResults():invalid-field","outField is invalid.");const A=m.createQuery(),{orderByFields:N}=u;if(N&&(A.orderByFields=N),s){A.outSpatialReference=s;const e=1/i(s);e&&(A.maxAllowableOffset=e)}const k="mesh"===m.geometryType||"multipatch"===m.geometryType,O=m.capabilities?.data?.supportsZ&&!k;if(A.returnZ=O&&!1!==g,A.returnGeometry=!0,A.multipatchOption=k?"xyFootprint":null,E&&(A.outFields=E),l)A.geometry=l;else if(c.key)A.objectIds=[c.key];else{const t=u.searchFields||[h];if(!S(m,t))throw f.error("invalid-field: search field is invalid."),new e("getResults():invalid-field","search field is invalid.");$(m)&&(A.num=o),L&&(A.geometry=L);const r=c.text?.trim();if(!r)return[];const i=c.text,{prefix:l="",suffix:s=""}=u,a=R(`${l}${i}${s}`);w(m)&&x(m,t)&&!n&&i&&(A.fullText=v({text:i,searchFields:t}));const d=D({searchTerm:a,layer:m,searchFields:t,filter:p,exactMatch:n,query:A,type:"search"});if(A.where=d,!F(A))return[]}return m.queryFeatures(A,{signal:q}).then((e=>V(e,d,u,a,h,I,T)))}))}function p(t,r){const{source:i,spatialReference:n,view:l,suggestTerm:o,maxSuggestions:s,sourceIndex:u,exactMatch:a}=t,{layer:c,filter:m}=i,p=r?.signal,T=g(i,l);return h(c).then((()=>{if(!$(c))return[];const t=b(i),r=i.searchFields||[t],l=[];i.suggestionTemplate?i.suggestionTemplate.replaceAll(d,((e,t)=>(l.push(t),e))):l.push(t);const g=y(l);l.includes(c.objectIdField)||g||l.push(c.objectIdField);const h=j(c,t),I=g||S(c,l),L=S(c,r);if(!h)throw f.error("invalid-field: displayField is invalid."),new e("getSuggestions():invalid-field","displayField is invalid.");if(!I)throw f.error("invalid-field: outField is invalid."),new e("getSuggestions():invalid-field","outField is invalid.");if(!L)throw f.error("invalid-field: search field is invalid."),new e("getSuggestions():invalid-field","search field is invalid.");const q=c.createQuery(),{orderByFields:C}=i;C&&(q.orderByFields=C),q.outSpatialReference=n,q.returnGeometry=!1,q.num=s,q.outFields=l,T&&(q.geometry=T);if(!o.trim())return[];const{prefix:E="",suffix:M=""}=i,A=R(`${E}${o}${M}`);w(c)&&x(c,r)&&!a&&o&&(q.fullText=v({text:o,searchFields:r}));const N=D({searchTerm:A,layer:c,searchFields:r,filter:m,exactMatch:a,query:q,type:"suggest"});return q.where=N,F(q)?c.queryFeatures(q,{signal:p}).then((e=>O(e,i,u,t))):[]}))}function g(e,t){const{filter:r,withinViewEnabled:i}=e,n=t?.extent,l=r?.geometry;return l??(i&&n?n:void 0)}function y(e){return e&&e.includes("*")}async function h(e){e&&await e.load()}function F(e){return!(!e.fullText&&!e.where)}function x(e,t){const r=e?.indexes;if(!r||!t?.length)return!1;return r.filter((e=>"FullText"===e.indexType)).some((e=>{const r=e.fields?.split(",").map((e=>e.trim().toLowerCase()))||[];return t.every((e=>r.includes(e.toLowerCase())))}))}function v({text:e,searchFields:t}){return e.trim().split(" ").filter((e=>!!e.trim())).map((e=>new l({onFields:t,searchTerm:e,searchType:"prefix"})))}function w(e){return e?.capabilities?.query?.supportsFullTextSearch??!1}function $(e){return e?.capabilities?.query?.supportsPagination??!1}function T(e){return e?.fieldsIndex?.fields?.find((e=>"string"===e.type))?.name??""}function b(e){return e.displayField||e.layer.displayField||T(e.layer)}function S(e,t){return!(!e||!t?.length)&&t.every((t=>j(e,t)))}function j(e,t){return!!e.getField(t)}function I(e){for(let t=0;t<e.length;t++)if(e.charCodeAt(t)>255)return!0;return!1}function L(e,t,r){let i=null;const{codedValues:n}=e;return n&&n.some((e=>{const n=e.name,l=r?n:n.toLowerCase();return(r?t:t.toLowerCase())===l&&(i=e.code.toString(),!0)})),i}function R(e){return e.replaceAll("'","''")}function q(e,t){const r=t?.where;return r?`(${e}) AND (${r})`:e}function C({currentTerm:e,field:t,filter:r,exactMatch:i,url:n,type:l}){const o=t?.type,s=t?.name;if("string"===o||"date"===o||"global-id"===o){const t=c.test(n??""),o=t&&I(e)?"N":"";if(i&&"search"===l)return q(`${s} = ${o}'${e}'`,r);if(t){return q(`${s} LIKE ${o}${`'${e}%'`}`,r)}return q(`${`LOWER(${s})`} LIKE ${o}${`'${e.toLowerCase()}%'`}`,r)}if("oid"===o||"small-integer"===o||"integer"===o||"single"===o||"double"===o){const t=Number(e);return isNaN(t)?null:q(`${s} = ${t}`,r)}return q(`${s} = ${e}`,r)}function E(e,t){return e?` OR (${t})`:`(${t})`}function D({searchTerm:e,layer:t,searchFields:r,filter:i,exactMatch:n,query:l,type:o}){const{definitionExpression:s,url:u}=t;let a="";return!l.fullText&&e&&r&&r.forEach((r=>{const l=t.getField(r),s="function"==typeof t.getFieldDomain&&t.getFieldDomain(r),c=(s&&"coded-value"===s.type?L(s,e,n):null)||e||null;if(null!==c){const e=C({currentTerm:c,field:l,filter:i,exactMatch:n,url:u,type:o});e&&(a+=E(a,e))}})),s&&a?`(${s}) AND (${a})`:s||a}function M(e,t){let r=null;const{codedValues:i}=e;return i&&i.length&&i.some((e=>e.code===t&&(r=e.name,!0))),r}function A(e,t){return e[Object.keys(e).find((e=>e.toLowerCase()===t.toLowerCase()))]}function N(e,t,r){const i=e.sourceLayer,{attributes:n}=e,l="function"==typeof i.getFieldDomain&&i.getFieldDomain(r);if(t)return u(t,n);if(r&&n){const e=i.getField(r),t=A(n,r);return null==t?"":l&&"coded-value"===l.type?M(l,t)??"":"date"===e?.type?a(new Date(t)):"number"==typeof t?t.toString():"string"!=typeof t?"":t.trim()}return""}function k(e,t,r,i){const n=e.sourceLayer,{attributes:l}=e,{objectIdField:o}=n,s=o?l[o]:null;return{text:N(e,t.suggestionTemplate,i),key:s,sourceIndex:r}}function O(e,t,r,i){return e.features.map((e=>k(e,t,r,i)))}function B(e){return null!=e&&null!=e.minScale&&null!=e.maxScale}function U(e,r,i,l,u,a,c){const d=e.clone(),f=e.sourceLayer,m=f?.objectIdField,p=m?e.attributes[m]:null,g=N(e,i.searchTemplate,u);null!=a&&B(f)&&(f.minScale&&f.minScale<a?a=f.minScale:f.maxScale&&f.maxScale>a&&(a=f.maxScale));const y=o(d.geometry,r,a),h="number"==typeof c?s(t(y),r,c):y,F=e.clone();return null!=h&&(F.geometry=n.fromExtent(h)),{extent:h,target:F,feature:d,key:p,name:g,sourceIndex:l}}function V(e,t,r,i,n,l,o){return e.features.map((e=>U(e,t,r,i,n,l,o)))}export{v as createFullTextSearchInfos,m as getResults,p as getSuggestions};
@@ -0,0 +1,5 @@
1
+ /*
2
+ All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
+ See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
+ */
5
+ function n(n){return"number"==typeof n}function t(n){return"string"==typeof n||n instanceof String}export{n as isNumber,t as isString};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import"../../intl.js";import n from"../../core/Error.js";import{clamp as t}from"../../core/mathUtils.js";import{formatTimestamp as e,formatTimeOnly as o,formatDateOnly as l,formatDate as i}from"../../intl/date.js";import{utc as r}from"../../time/timeZoneUtils.js";import{DateTime as u,FixedOffsetZone as a}from"luxon";import{getLocale as m}from"../../intl/locale.js";const s=r,f={date:null,dateAsString:null,time:null,timeZoneOffset:null},c=new Map([["hours",3600],["minutes",60],["seconds",1],["deciseconds",.1],["centiseconds",.01],["milliseconds",.001]]),d="yyyy-MM-dd",y="TT";var S;!function(n){n.HM="HH:mm",n.HMS="HH:mm:ss",n.HMS_MS="HH:mm:ss.SSS"}(S||(S={}));const p=[S.HMS_MS,S.HMS,S.HM,y],h="latn",v=new Set(["date-only","time-only","timestamp-offset"]),M=n=>"valueAsDate"in n;function H(n){return{locale:m(),numberingSystem:h,zone:n??s}}function O(n){return n?.isValid?n.toMillis():null}function g(n,t){return null===n?null:u.fromMillis(n,H(t))}function w(n){if(null==n)return f;const t=u.fromISO(n,{setZone:!0});return{date:t.toJSDate(),dateAsString:t.toFormat(d,H()),time:t.toFormat(S.HMS_MS,H()),timeZoneOffset:t.offset.toString()}}function j(n,t){if(null==n||isNaN(n))return f;const e=g(n,t);return e?{date:e.toJSDate(),dateAsString:e.toFormat(d,H(t)),time:e.toFormat(y,H(t))}:f}function Z(n,t,r){if(!n||null==t)return null;switch(n.type){case"date":return i(t,r);case"date-only":return l(t,r);case"time-only":return o(t,r);case"timestamp-offset":return e(t,r);default:return null}}function I(n){const{dateComponent:t,timeComponent:e,timeZoneComponent:o,oldValue:l}=n;if(!t?.value||!e?.value)return null;const{year:i,month:m,day:s}=u.fromFormat(t.value,d),{hour:f,minute:c,second:y,millisecond:S}=A(e,r)??u.now(),p=w(l),h=null!=o?.value?parseInt(o.value,10):null!=p.timeZoneOffset?parseInt(p.timeZoneOffset,10):(new Date).getTimezoneOffset(),v=a.instance(h),M=u.fromObject({year:i,month:m,day:s,hour:f,minute:c,second:y,millisecond:S},{zone:v});return M.isValid?M.toISO({includeOffset:!0}):null}function x(n){const{dateComponent:t,timeComponent:e,timeZone:o,max:l,min:i,oldValue:r}=n,a=A(t,o);let m=!!n.applyRange;if(!a)return null;let s=null;if(null!=e?.value){const n=A(e,o),t=Date.now(),i=null!=l&&l<t?l:t,r=u.fromMillis(i,H(o)),m=a||r,{year:f,month:c,day:d}=m,{hour:y,minute:S,second:p,millisecond:h}=n||r;s=m.set({year:f,month:c,day:d,hour:y,minute:S,second:p,millisecond:h})}else{const n=g(F({value:r??Date.now(),max:l,min:i}),o),{year:t,month:e,day:u}=a,{hour:f,minute:c,second:d,millisecond:y}=n;m=!0,s=a.set({year:t,month:e,day:u,hour:f,minute:c,second:d,millisecond:y})}if(!s.isValid)return null;const f=s.toMillis();return m?F({value:f,max:l,min:i}):f}function A(n,t){if(!n)return null;let e=null;if(M(n)){const o=n.value;if(!o||Array.isArray(o))return null;e=u.fromFormat(o,d,H(t))}else{if(!n.value)return null;p.find((o=>(e=u.fromFormat(n.value,o,H(t)),e.isValid)))}return e?.isValid?e:null}function D(n){const{max:t,min:e,value:o}=n;return!isNaN(o)&&(!(null!=t&&o>t)&&!(null!=e&&o<e))}function F(n){const{max:e,min:o,value:l}=n;return null!=e&&null!=o?t(l,o,e):null!=e&&l>e?e:null!=o&&l<o?o:l}function V(t){if(!t)return"";const e=t.split(".").at(0);if(!e||e.length<1)throw new n("invalid time-only field",`Cannot parse valid time-only field value from ${t}`);const o=e.split(":"),l=new Array(3);for(let n=0;n<3;n++){const t=o.at(n)??"";l[n]=t.padStart(2,"0")}return l.join(":")}function C(n,t){switch(t){case"date":return n.getTime();case"date-only":return n.toISODate();case"time-only":return V(n.toISOTime(!0,!1));case"timestamp-offset":return n.toISOString(!1);default:return null}}function T(n){return!!n&&"object"==typeof n&&"getTime"in n&&"toISOString"in n&&"timeZone"in n}export{S as TimeStampOffsetPattern,C as arcadeDateToFieldValue,F as clampValueToRange,g as createDateTimeFromFieldValue,v as dateFieldsWithStringFieldValue,O as dateTimeToFieldValue,d as defaultDatePattern,y as defaultTimePattern,H as getDefaultLocaleOptions,I as getISOFieldValueFromDateComponents,Z as getLabelForDateFieldValue,A as getLocalDateTimeFromComponent,x as getUnixFieldValueFromDateComponents,T as isArcadeDate,M as isCalciteDateComponent,V as normalizeTimeOnlyString,h as numberingSystem,w as prepareISOFieldValueForDateComponents,j as prepareUnixFieldValueForDateComponents,p as supportedTimeFormats,c as timeResolutionToStepMap,D as valueIsInRange};
5
+ import"../../intl.js";import"../../core/has.js";import n from"../../core/Error.js";import{clamp as e}from"../../core/mathUtils.js";import{formatTimestamp as t,formatTimeOnly as o,formatDateOnly as l,formatDate as i}from"../../intl/date.js";import{utc as r}from"../../time/timeZoneUtils.js";import{isString as u,isNumber as a}from"./dataUtils.js";import{DateTime as s,FixedOffsetZone as m,Interval as f}from"luxon";import{getLocale as c}from"../../intl/locale.js";const d=r,y={date:null,time:null,timeZoneOffset:null},p=new Map([["hours",3600],["minutes",60],["seconds",1],["deciseconds",.1],["centiseconds",.01],["milliseconds",.001]]),v="yyyy-MM-dd",S="TT";var h;!function(n){n.HM="HH:mm",n.HMS="HH:mm:ss",n.HMS_MS="HH:mm:ss.SSS"}(h||(h={}));const M=[h.HMS_MS,h.HMS,h.HM,S],O="latn",g=new Set(["date-only","time-only","timestamp-offset"]),w=n=>"valueAsDate"in n;function H(n){return{locale:c(),numberingSystem:O,zone:n??d}}function j(n){return n?.isValid?n.toMillis():null}function V(n,e){return null===n?null:s.fromMillis(n,H(e))}function x(n){if(null==n||!u(n)||""===n)return y;const e=s.fromISO(n,{setZone:!0});return{date:e.toFormat(v,H()),time:e.toFormat(h.HMS_MS,H()),timeZoneOffset:e.offset.toString()}}function F(n,e){if(null==n||!a(n)||isNaN(n))return y;const t=V(n,e);return t?{date:t.toFormat(v,H(e)),time:t.toFormat(S,H(e))}:y}function I(n,e,r){if(!n||null==e)return null;switch(console.log("getLabelForDateFieldValue"),console.log(" -- value: ",e),console.log(" -- options: ",r),n.type){case"date":return i(e,r);case"date-only":return l(e,r);case"time-only":return o(e,r);case"timestamp-offset":return t(e,r);default:return null}}function Z(n){const{dateComponent:e,timeComponent:t,timeZoneComponent:o,oldValue:l}=n;if(!e?.value||!t?.value)return null;const{year:i,month:u,day:a}=s.fromFormat(e.value,v),{hour:f,minute:c,second:d,millisecond:y}=T(t,r)??s.now(),p=x(l),S=null!=o?.value?parseInt(o.value,10):null!=p.timeZoneOffset?parseInt(p.timeZoneOffset,10):(new Date).getTimezoneOffset(),h=m.instance(S),M=s.fromObject({year:i,month:u,day:a,hour:f,minute:c,second:d,millisecond:y},{zone:h});return M.isValid?M.toISO({includeOffset:!0}):null}function D(n){const{dateComponent:e,timeComponent:t,timeZone:o,max:l,min:i,oldValue:r}=n,u=T(e,o);let a=!!n.applyRange;if(!u)return null;let m=null;if(null!=t?.value){const n=T(t,o),e=Date.now(),i=null!=l&&l<e?l:e,r=s.fromMillis(i,H(o)),a=u||r,{year:f,month:c,day:d}=a,{hour:y,minute:p,second:v,millisecond:S}=n||r;m=a.set({year:f,month:c,day:d,hour:y,minute:p,second:v,millisecond:S})}else{const n=V(C({value:r??Date.now(),max:l,min:i}),o),{year:e,month:t,day:s}=u,{hour:f,minute:c,second:d,millisecond:y}=n;a=!0,m=u.set({year:e,month:t,day:s,hour:f,minute:c,second:d,millisecond:y})}if(!m.isValid)return null;const f=m.toMillis();return a?C({value:f,max:l,min:i}):f}function T(n,e){if(!n||null==n.value||Array.isArray(n.value))return null;let t=null;return t=w(n)?s.fromFormat(n.value,v,H(e)):_(n.value),t?.isValid?t:null}function b(n){const{max:e,min:t,value:o}=n;return!isNaN(o)&&(!(null!=e&&o>e)&&!(null!=t&&o<t))}function C(n){const{max:t,min:o,value:l}=n;return null!=t&&null!=o?e(l,o,t):null!=t&&l>t?t:null!=o&&l<o?o:l}function A(e){if(!e)return"";const t=e.split(".").at(0);if(!t||t.length<1)throw new n("invalid time-only field",`Cannot parse valid time-only field value from ${e}`);const o=t.split(":"),l=new Array(3);for(let n=0;n<3;n++){const e=o.at(n)??"";l[n]=e.padStart(2,"0")}return l.join(":")}function N(n,e){switch(e){case"date":return n.getTime();case"date-only":return n.toISODate();case"time-only":return A(n.toISOTime(!0,!1));case"timestamp-offset":return n.toISOString(!1);default:return null}}function z(n){return!!n&&"object"==typeof n&&"getTime"in n&&"toISOString"in n&&"timeZone"in n}function U(n){return s.fromFormat(n,v)}function _(n){let e=null;return M.find((t=>(e=s.fromFormat(n,t),e.isValid))),e}function k(n){return s.fromISO(n)}function E(n){const{type:e,range:t,value:o}=n;if(null==o||!t)return!0;if("date"===e)return b({value:o,min:t.min,max:t.max});const{rawMax:l,rawMin:i}=t;if(!u(l)||!u(i)||!u(o))return!0;let r=null,a=null,s=null;switch(e){case"date-only":r=U(l),a=U(i),s=U(o);break;case"time-only":r=_(l),a=_(i),s=_(o);break;case"timestamp-offset":r=k(l),a=k(i),s=k(o)}return!(r?.isValid&&a?.isValid&&s?.isValid)||(f.fromDateTimes(a,r).contains(s)||a.valueOf()===s.valueOf()||r.valueOf()===s.valueOf())}export{h as TimeStampOffsetPattern,N as arcadeDateToFieldValue,C as clampValueToRange,V as createDateTimeFromFieldValue,g as dateFieldsWithStringFieldValue,U as dateOnlyToDateTime,E as dateTimeIsInRange,j as dateTimeToFieldValue,v as defaultDatePattern,S as defaultTimePattern,H as getDefaultLocaleOptions,Z as getISOFieldValueFromDateComponents,I as getLabelForDateFieldValue,T as getLocalDateTimeFromComponent,D as getUnixFieldValueFromDateComponents,z as isArcadeDate,w as isCalciteDateComponent,A as normalizeTimeOnlyString,O as numberingSystem,x as prepareISOFieldValueForDateComponents,F as prepareUnixFieldValueForDateComponents,M as supportedTimeFormats,_ as timeOnlyToDateTime,p as timeResolutionToStepMap,k as timestampOffsetToDateTime,b as valueIsInRange};