@esri/solutions-components 5.1.1 → 5.1.2

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 (127) hide show
  1. package/dist/cdn/{E5A7A2YY.js → 3CSSTWYC.js} +1 -1
  2. package/dist/cdn/{OYMJFSWN.js → 3DNEBMT3.js} +1 -1
  3. package/dist/cdn/{VTRC64F6.js → 3FIRDPVD.js} +1 -1
  4. package/dist/cdn/{5YD3IE6V.js → 3KYCZII7.js} +1 -1
  5. package/dist/cdn/{P2QNOVPZ.js → 3NI2BJYO.js} +1 -1
  6. package/dist/cdn/{G2H3X6NS.js → 3W7ANZME.js} +1 -1
  7. package/dist/cdn/{P4ZYEBFM.js → 4RH7N22O.js} +1 -1
  8. package/dist/cdn/{6FNUCCS3.js → 5F6WBFDO.js} +1 -1
  9. package/dist/cdn/{S57RXN34.js → 5IO4VX4R.js} +1 -1
  10. package/dist/cdn/{KXANPOG5.js → 5Q64VY2E.js} +1 -1
  11. package/dist/cdn/{N5D7USS3.js → 65OXHGCN.js} +1 -1
  12. package/dist/cdn/{DGY2VKHA.js → 6F6YFDOY.js} +1 -1
  13. package/dist/cdn/{PGFW2YO5.js → 6KBY56R4.js} +1 -1
  14. package/dist/cdn/{XYJU325L.js → 6L6JOGWD.js} +1 -1
  15. package/dist/cdn/{Q5XHG472.js → 6OKLCUSH.js} +1 -1
  16. package/dist/cdn/{224NND54.js → 6RQBPR56.js} +1 -1
  17. package/dist/cdn/{ERQAH6G3.js → 74Z5A6E2.js} +1 -1
  18. package/dist/cdn/{WJRVHF3G.js → 7AHZBLTM.js} +1 -1
  19. package/dist/cdn/{AXEZNIEX.js → 7EJXZVSX.js} +1 -1
  20. package/dist/cdn/{K6GC6RUA.js → 7NQYBMRX.js} +1 -1
  21. package/dist/cdn/{SWUMBQ6T.js → 7XPOQHB4.js} +1 -1
  22. package/dist/cdn/A4KEZALJ.js +2 -0
  23. package/dist/cdn/{7GVLJERR.js → AS7PVOU3.js} +1 -1
  24. package/dist/cdn/{ZX5GQTIE.js → BFFHQBDI.js} +1 -1
  25. package/dist/cdn/{3T56IY7B.js → BKIKLE4Z.js} +1 -1
  26. package/dist/cdn/{D25JFQEK.js → BWNEUQZZ.js} +1 -1
  27. package/dist/cdn/{VNYXOWZX.js → BZWJ3KFS.js} +115 -115
  28. package/dist/cdn/{4G5PYXFM.js → C2GWD5VP.js} +1 -1
  29. package/dist/cdn/{US5ONKMV.js → C3SIGIJC.js} +1 -1
  30. package/dist/cdn/CC7JGR5Q.js +2 -0
  31. package/dist/cdn/{R7DGMKJ5.js → CKPQTIAF.js} +1 -1
  32. package/dist/cdn/{Z324WI3X.js → CRTJERAB.js} +1 -1
  33. package/dist/cdn/{DJXQKOIX.js → CVKCFLNY.js} +1 -1
  34. package/dist/cdn/{CJJEWE3Q.js → CVNW2AU2.js} +1 -1
  35. package/dist/cdn/{XDLYXP3W.js → CXTHIJOC.js} +65 -73
  36. package/dist/cdn/{R6ANOQU2.js → DE7GSGUB.js} +1 -1
  37. package/dist/cdn/{5VUSSAPX.js → DEVAXAP7.js} +1 -1
  38. package/dist/cdn/{K5EP7XDM.js → DF2U7HIU.js} +1 -1
  39. package/dist/cdn/{NEZAEPUJ.js → DLV7AZZ6.js} +1 -1
  40. package/dist/cdn/{4RWJ22V3.js → DQJ36YEL.js} +1 -1
  41. package/dist/cdn/{MZOWOFAE.js → DXI5HEQM.js} +1 -1
  42. package/dist/cdn/{EL34IIAJ.js → E3O6DPAL.js} +1 -1
  43. package/dist/cdn/{W3SEKNJO.js → E5YZOOW3.js} +1 -1
  44. package/dist/cdn/{SUOJTOE2.js → EBDDUQNC.js} +1 -1
  45. package/dist/cdn/{RY7S2ICL.js → EHIUCEAX.js} +1 -1
  46. package/dist/cdn/{WZHA7MTK.js → EJRV6YWD.js} +1 -1
  47. package/dist/cdn/EX4K4RKP.js +2 -0
  48. package/dist/cdn/{2MDEEI52.js → FSFVH74N.js} +1 -1
  49. package/dist/cdn/{VIZY55AV.js → GHVPHEOH.js} +1 -1
  50. package/dist/cdn/GPIIJWNM.js +2 -0
  51. package/dist/cdn/{KWOBLDUS.js → GRVDJVOF.js} +1 -1
  52. package/dist/cdn/{P734JXTN.js → GSI62QHB.js} +1 -1
  53. package/dist/cdn/{B7TH7XYI.js → GWIC6C6P.js} +1 -1
  54. package/dist/cdn/{6CVQ3V2G.js → GZZMHIFA.js} +1 -1
  55. package/dist/cdn/{TDDVICGP.js → HQFL3NGM.js} +1 -1
  56. package/dist/cdn/{QKQXW6OQ.js → INFZEU32.js} +1 -1
  57. package/dist/cdn/{Q5LSIHQ4.js → J7DTCWOP.js} +1 -1
  58. package/dist/cdn/{GSOMYPWB.js → KB7CXY4N.js} +1 -1
  59. package/dist/cdn/{OU4VLS5H.js → KMY4AVEA.js} +1 -1
  60. package/dist/cdn/{KENYVRIH.js → L6XSVTY3.js} +1 -1
  61. package/dist/cdn/{DQPIAF2T.js → LCDURBN6.js} +1 -1
  62. package/dist/cdn/{JKUPRPWA.js → LFIP5DV3.js} +1 -1
  63. package/dist/cdn/{PDJXTJHO.js → LK6WQCXQ.js} +1 -1
  64. package/dist/cdn/{ONAAPGO3.js → LSDYUCCZ.js} +1 -1
  65. package/dist/cdn/{VEBBZ2RS.js → LXJI7FYN.js} +1 -1
  66. package/dist/cdn/{4SYZADNV.js → MVXK7UGO.js} +1 -1
  67. package/dist/cdn/{LIEHXKWK.js → MZ5XI2CY.js} +1 -1
  68. package/dist/cdn/{NWNUNME7.js → NIUKLQOT.js} +1 -1
  69. package/dist/cdn/{AIM6JKQK.js → NJSQ3NUT.js} +1 -1
  70. package/dist/cdn/{G772MFBV.js → NVNB4L52.js} +1 -1
  71. package/dist/cdn/{KLFAQLC6.js → NWOPIQFN.js} +1 -1
  72. package/dist/cdn/{M5VGNDPK.js → O6HS2AMH.js} +1 -1
  73. package/dist/cdn/{HQIM7CQS.js → OPWMEQVM.js} +1 -1
  74. package/dist/cdn/{VX3K6KJB.js → OVAQRVFG.js} +1 -1
  75. package/dist/cdn/{HMZ4VIJQ.js → P2FSR5OV.js} +1 -1
  76. package/dist/cdn/{E4OPUBGE.js → PQVA7SKB.js} +1 -1
  77. package/dist/cdn/{QWQ535RX.js → PSM4UX7K.js} +1 -1
  78. package/dist/cdn/{EWIPITVN.js → Q5N7I65T.js} +1 -1
  79. package/dist/cdn/{RPUUOIRT.js → QODVIACF.js} +1 -1
  80. package/dist/cdn/{VXIWNY5G.js → QVD3AXIP.js} +1 -1
  81. package/dist/cdn/{DEATAJID.js → RAL6IXW5.js} +1 -1
  82. package/dist/cdn/{Y3PEQHDX.js → RJLEYL7O.js} +1 -1
  83. package/dist/cdn/{JGSZS6VC.js → RNNEZRGA.js} +1 -1
  84. package/dist/cdn/{SEII6Y3C.js → RPL5Q7IL.js} +1 -1
  85. package/dist/cdn/{PEI3LZZL.js → RQVXDCWL.js} +1 -1
  86. package/dist/cdn/{LADUP3BG.js → SQEPSAKG.js} +1 -1
  87. package/dist/cdn/{DXQBDTBG.js → T7O4WZGU.js} +1 -1
  88. package/dist/cdn/{F6LBLCUM.js → UDWEFNJE.js} +1 -1
  89. package/dist/cdn/{VPHEAUEZ.js → UILBHLN7.js} +1 -1
  90. package/dist/cdn/{AIZ2P72X.js → VSRNGZ43.js} +1 -1
  91. package/dist/cdn/{3BL4GCSN.js → WNYAZ4ME.js} +1 -1
  92. package/dist/cdn/{GYVIOOMC.js → WRMREY3V.js} +1 -1
  93. package/dist/cdn/{5A5W5PLO.js → WVCL5OUK.js} +1 -1
  94. package/dist/cdn/{QKPUJ5CZ.js → XIUYVZYL.js} +1 -1
  95. package/dist/cdn/{VZ2ZZK3Y.js → Y2KRCLNN.js} +1 -1
  96. package/dist/cdn/{67KMG355.js → YBJ6AHAG.js} +1 -1
  97. package/dist/cdn/{OTTBXOCQ.js → YHF3Q7QB.js} +1 -1
  98. package/dist/cdn/{GV3GU3O3.js → Z6CZ7GFZ.js} +1 -1
  99. package/dist/cdn/{YJ3DKEEZ.js → ZB5UCRCG.js} +1 -1
  100. package/dist/cdn/{NQP26Q5H.js → ZHVO477V.js} +1 -1
  101. package/dist/cdn/{OSOSX7F3.js → ZXGNDW3R.js} +1 -1
  102. package/dist/cdn/index.js +1 -1
  103. package/dist/chunks/runtime.js +1 -1
  104. package/dist/components/arcgis-solutions-assistant/customElement.js +125 -119
  105. package/dist/components/crowdsource-manager/customElement.d.ts +0 -6
  106. package/dist/components/crowdsource-manager/customElement.js +14 -11
  107. package/dist/components/layer-table/customElement.js +2 -2
  108. package/dist/docs/api.json +1 -1
  109. package/dist/docs/docs.json +1 -1
  110. package/dist/docs/vscode.html-custom-data.json +1 -1
  111. package/dist/docs/web-types.json +1 -1
  112. package/dist/loader.js +1 -1
  113. package/dist/solutions-components_commit.txt +7 -4
  114. package/dist/types/lumina.d.ts +1 -1
  115. package/dist/types/preact.d.ts +1 -1
  116. package/dist/types/react.d.ts +1 -1
  117. package/dist/types/stencil.d.ts +1 -1
  118. package/dist/utils/interfaces.d.ts +1 -0
  119. package/package.json +1 -3
  120. package/dist/cdn/4VP3KTLL.js +0 -2
  121. package/dist/cdn/BQ2LFMED.js +0 -2
  122. package/dist/cdn/D5OMLQMV.js +0 -2
  123. package/dist/cdn/OGH565H7.js +0 -3
  124. package/dist/cdn/QH343537.js +0 -56
  125. package/dist/cdn/UUKV62PY.js +0 -109
  126. package/dist/cdn/WNM5Z4SM.js +0 -2
  127. package/dist/cdn/ZPEVEBJD.js +0 -121
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import d from"./QKQXW6OQ.js";import c from"./4SYZADNV.js";import"./VVZAS55G.js";import"./US5FON7D.js";import a from"./WV7QX3ED.js";import"./CGQALCTZ.js";import{a as w}from"./AIZ2P72X.js";import"./QMAV4UTN.js";import"./Y2AUIXNK.js";import"./TEHBW75B.js";import"./RSPNBIIE.js";import"./ZCU2WWVN.js";import"./WGO4EVOV.js";import"./YKB6256M.js";import"./36LRAUE4.js";import"./JMY4B4WQ.js";import"./VQ5ZAQUF.js";import"./Z4F2NZOT.js";import"./KOIDWEP3.js";import"./3KXMYZCU.js";import"./6ERMTA3J.js";import"./GF4QELNV.js";import"./3TAQSXLA.js";import"./PY6RTQDR.js";import"./DKD2EGQP.js";import"./5O53T3SW.js";import"./AJZDBHB6.js";import"./FES7B3SJ.js";import{b}from"./YJ3DKEEZ.js";import{F as _,G as f,H as g,J as s,K as v,h as p,i,q as l,u}from"./T3EPRHTT.js";import"./EXBEKVP5.js";export default $arcgis.t(([n,y,,,m])=>{var x=p`@layer{:host{display:block;--calcite-label-margin-bottom: 0}.padding-1-2{padding:.5rem}.display-none{display:none!important}.display-flex{display:flex}.position-absolute{position:absolute;inset:0;overflow:auto}.feature-node{position:relative!important}.button-container{justify-content:center;align-items:center}.top-border{border-top:1px solid var(--calcite-color-border-1)}.width-100{width:100%}.esri-features__container{padding:.5rem!important;background-color:var(--calcite-color-surface-2)!important;height:100%!important}.end-border{border-inline-end:1px solid var(--calcite-color-border-1)}.font-bold{font-weight:700}.z-index-1{z-index:1}.visibility-hidden{visibility:hidden;height:0px}.padding-inline-start-1{padding-inline-start:1rem}.border-width-0{border-width:0px}.pagination-action{position:relative;left:3px}.pagination-count{color:var(--calcite-color-brand);border-bottom:1px solid var(--calcite-color-brand);font-weight:700}}`,h=class extends g{constructor(){super(),this.enableEditGeometry=!1,this.enableSnapping=!1,this.graphics=[],this.isLoading=!1,this.isMobile=!1,this.allowEditing=!1,this.highlightEnabled=!0,this.paginationEnabled=!0,this.position="absolute",this.showCloseBtn=!1,this.showCopyPasteActions=!1,this.pasteEnabled=!1,this._alertOpen=!1,this._count="",this._editRecordOpen=!1,this._isMultipleEdits=!1,this._mobileTitle="",this._showListView=!1,this._translations=w({name:"info-card",blocking:!0}),this._navigatedToRelatedFeature=!1,this._editEnabled=!1,this._features=_(),this.popupClosed=l(),this.clearSelection=l(),this.selectionChanged=l(),this.copyFeatures=l(),this.pasteFeatures=l(),this.listenOn(window,"closeEdit",this.closeEdit),this.listenOn(window,"layerSelectionChange",this.layerSelectionChange),this.listenOn(window,"refreshGraphics",this.refreshGraphics),this.listenOn(window,"editMultipleFeatures",this.editMultipleFeatures),this.listenOn(window,"selectedLanguageUpdated",this.selectedLanguageUpdated),this.listenOn(window,"clearSelection",this._alertClosed)}static{this.properties={enableEditGeometry:5,enableSnapping:5,graphics:0,isLoading:5,isMobile:5,mapView:0,featuresReferenceId:1,allowEditing:5,highlightEnabled:5,paginationEnabled:5,position:1,showCloseBtn:5,showCopyPasteActions:5,pasteEnabled:5,_alertOpen:16,_count:16,_editRecordOpen:16,_isMultipleEdits:16,_mobileTitle:16,_showListView:16,_translations:16,_navigatedToRelatedFeature:16}}static{this.styles=x}static{this.shadowRootOptions=u}willUpdate(e){if(e.has("graphics")&&this.graphicsWatchHandler(),e.has("pasteEnabled")&&this.hasUpdated&&this._features.value?.headerActions?.length){let t=this._features.value.headerActions.find(a=>a.id==="paste-features");t&&(t.disabled=!this.pasteEnabled)}if(e.has("showCopyPasteActions")&&this.hasUpdated&&this.handleHeaderActions(),e.has("_translations")){let t=this._translations._lang,a=e.get("_translations")?._lang;if(t&&a&&t!==a&&this._features.value){let o=[...this.graphics];this.graphics=[],this.graphics=o}}}async graphicsWatchHandler(){if(this._navigatedToRelatedFeature&&this._features.value&&(await this._features.value.clear(),await this._features.value.close(),this._count="",this._navigatedToRelatedFeature=!1),await this.setGraphics(),this._features.value?.headerActions?.length&&this.showCopyPasteActions){let e=this._features.value.headerActions.find(t=>t.id==="copy-features");e&&(e.disabled=this.graphics.length===0)}}async getSelectedFeature(){return this._features.value?.selectedFeature}async refresh(){await this.setGraphics()}async back(){await this._back()}async next(){await this._next()}async toggleListView(){this._toggleListView()}async closeEdit(){this._editRecordOpen=!1,this._isMultipleEdits=!1}async layerSelectionChange(){this._showListView=!1,this._features.value?.viewModel&&(this._features.value.featureMenuOpen=!1,await this._features.value.close())}async refreshGraphics(e){this._navigatedToRelatedFeature||(this.graphics=[...e.detail])}async editMultipleFeatures(e){this._isMultipleEdits=!0,this._openEditRecord()}async selectedLanguageUpdated(e){await this._features.value?.clear(),await this._features.value?.close()}async load(){this._popupUtils=new m}async loaded(){this.graphics?.length>0&&await this.setGraphics()}render(){let e=this.isLoading?"":"display-none",t=!this.isLoading&&this._editRecordOpen?"position-absolute":"display-none",a=!this.isLoading&&this._editRecordOpen||this._showListView?"display-none":"",o=this._features.value?.features&&this._features.value.features.length<2||this._navigatedToRelatedFeature,d=Number(this._features.value?.selectedFeature?.getObjectId()),$=Number.isNaN(d)?[]:[d],c=this._layer?.editingEnabled&&this._layer?.capabilities?.operations?.supportsDelete,F=this._relatedFeature?[this._relatedFeature]:this.graphics,E=this._navigatedToRelatedFeature?0:this._features.value?.selectedFeatureIndex,r=this.isMobile?"display-none":"";return i`<calcite-shell class="z-index-1" style=${v({position:this.position})}>${this._getHeader()}<calcite-loader class=${s(e)} .label=${this._translations.fetchingData}></calcite-loader>${this.mapView&&this._getFeaturesComponent()||""}<div class=${`${a} width-100`} slot=footer>${this.allowEditing?i`<div class="display-flex top-border padding-1-2"><calcite-button appearance=solid id=solutions-edit @click=${()=>this._openEditRecord()} width=full>${this._translations.edit}</calcite-button>${this.isMobile&&c?i`<delete-button class="padding-inline-start-1 width-100" id=solutions-delete .ids=${$} .layer=${this._layer} @editsComplete=${()=>this._closePopup()}></delete-button>`:void 0}<calcite-tooltip class=${s(r)} placement=bottom reference-element=solutions-edit><span>${this._translations.edit}</span></calcite-tooltip>${this.isMobile&&c?i`<calcite-tooltip class=${s(r)} placement=bottom reference-element=solutions-delete><span>${this._translations.delete}</span></calcite-tooltip>`:void 0}</div>`:""}${this.paginationEnabled&&!o&&i`<div class=${"display-flex padding-1-2 button-container top-border"}><div><calcite-button appearance=transparent .disabled=${o} icon-flip-rtl=both icon-start=chevron-left id=solutions-back @click=${()=>this._back()} width=full></calcite-button><calcite-tooltip class=${s(r)} placement=top reference-element=solutions-back><span>${this._translations.back}</span></calcite-tooltip></div><calcite-action class="pagination-action" icon-flip-rtl @click=${()=>this._toggleListView()} scale=s .text=${this._translations.toggleListView} text-enabled><span class="pagination-count">${this._count}</span></calcite-action><div><calcite-button appearance=transparent .disabled=${o} icon-flip-rtl=both icon-start=chevron-right id=solutions-next @click=${()=>this._next()} width=full></calcite-button><calcite-tooltip class=${s(r)} placement=top reference-element=solutions-next><span>${this._translations.next}</span></calcite-tooltip></div></div>`||""}</div><edit-card .allowMultipleEditing=${this._isMultipleEdits} class=${s(t)} .enableEditGeometry=${this.enableEditGeometry} .enableSnapping=${this.enableSnapping} .graphicIndex=${E} .graphics=${F} .mapView=${this.mapView} .open=${this._editRecordOpen}></edit-card><calcite-alert auto-close icon=layer-broken kind=warning label @calciteAlertClose=${()=>this._alertClosed()} .open=${this._alertOpen} placement=top><div slot=title>${this._translations.editDisabled}</div><div slot=message>${this._translations.enableEditing}</div></calcite-alert></calcite-shell>`}async setGraphics(){this._features.value&&(this.graphics.length>0?(this._layer=this.graphics[0]?.layer,this._editEnabled=this._layer.editingEnabled&&this._layer.capabilities?.operations.supportsUpdate,this._mobileTitle=this.mapView?.map&&await this._popupUtils?.getPopupTitle(this.graphics[0],this.mapView.map)||"",this._features.value&&(this._features.value.open=!0),this._features.value&&(this._features.value.features=this.graphics)):(await this._features.value.clear(),await this._features.value.close()),this._count=this._getCount())}handleHeaderActions(){this.showCopyPasteActions&&this._features.value?.headerActions.length===0?(this._features.value.headerActions.addMany(this._getHeaderActions()),this._headerActionsHandle&&this._headerActionsHandle.remove(),this._headerActionsHandle=n.on(()=>this._features.value,"arcgisTriggerAction",e=>{e.detail.action.id==="copy-features"?this.copyFeatures.emit({featuresIds:this.graphics.map(t=>t.getObjectId()),layerId:this._layer?.id}):e.detail.action.id==="paste-features"&&this.pasteFeatures.emit()})):!this.showCopyPasteActions&&this._features.value&&this._features.value.headerActions.length>0&&(this._features.value.headerActions.removeAll(),this._headerActionsHandle?.remove(),this._headerActionsHandle=void 0)}async featuresComponentReady(){if(this._features.value){if(this.featuresReferenceId){let e=document.getElementById(this.featuresReferenceId);e&&(await e.viewOnReady(),this._features.value.referenceElement=e)}this.handleHeaderActions(),await this.setGraphics(),this._features.value.selectedFeature&&this.selectionChanged.emit({selectedFeature:[this._features.value.selectedFeature],selectedFeatureIndex:this._features.value.selectedFeatureIndex}),n.watch(()=>this._features.value?.featureMenuOpen,e=>{this._updateCount(),e||(this._showListView=e??!1)}),n.watch(()=>this._features.value?.selectedFeatureIndex,e=>{e!==void 0&&e>-1&&this._features.value?.selectedFeature&&this.selectionChanged.emit({selectedFeature:[this._features.value.selectedFeature],selectedFeatureIndex:this._features.value.selectedFeatureIndex})}),n.watch(()=>this._features.value?.selectedDrillInFeature,e=>{e?(this._relatedFeature=e,this._navigatedToRelatedFeature=!0):(this._relatedFeature=void 0,this._navigatedToRelatedFeature=!1)})}}_getHeader(){return this.isMobile&&!this._editRecordOpen?i`<calcite-panel class="border-width-0" slot=header><calcite-action class="end-border" icon=chevron-left icon-flip-rtl @click=${()=>this._closePopup()} scale=s slot=header-actions-start text></calcite-action><span class="font-bold" slot=header-content>${this._mobileTitle}</span></calcite-panel>`:void 0}_getFeaturesComponent(){let e=this._editRecordOpen?"display-none":"";return i`<arcgis-features class=${s(e)} .view=${this.mapView} hide-action-bar .hideCloseButton=${!this.showCloseBtn} hide-feature-menu-heading .hideHeading=${this.isMobile} .highlightDisabled=${!this.highlightEnabled} hide-feature-navigation @arcgisReady=${this.featuresComponentReady} @arcgisClose=${()=>{this.clearSelection.emit()}} ${f(this._features)}></arcgis-features>`}_getHeaderActions(){return[new y({id:"copy-features",title:this._translations.copy,className:"copy-features",icon:"copy",disabled:this.graphics.length===0}),new y({id:"paste-features",title:this._translations.paste,className:"paste-features",icon:"paste-with-attribute",disabled:!this.pasteEnabled})]}_closePopup(){this.popupClosed.emit()}_alertClosed(){this._alertOpen=!1}_openEditRecord(){this._editEnabled?this._editRecordOpen=!0:this._alertOpen=!0}async _back(){await this._features.value?.previous(),await this._updateCount()}async _next(){await this._features.value?.next(),await this._updateCount()}async _updateCount(){let e=this._features.value?.selectedFeatureIndex;this._popupUtils&&this.mapView&&this.mapView.map&&e!==void 0&&(this._mobileTitle=await this._popupUtils.getPopupTitle(this.graphics[e],this.mapView.map)),this._count=this._getCount()}_getCount(){let e=this._features.value?.viewModel&&(this._features.value?.viewModel.selectedFeatureIndex+1).toString()||"",t=this._features.value?.features?.length.toString()||"";return this._translations.indexOfTotal.replace("{{index}}",e).replace("{{total}}",t)||""}_toggleListView(){if(this._showListView=!this._showListView,this._features.value){let e=this._features.value?.selectedFeatureIndex;this._features.value.open=!0,this._features.value.featureMenuOpen=this._showListView,this._features.value.features=this.graphics,this._features.value.selectedFeatureIndex=e}}};b("info-card",h);return h},"core/reactiveUtils","support/actions/ActionButton",a,c,d)
2
+ import d from"./INFZEU32.js";import c from"./MVXK7UGO.js";import"./VVZAS55G.js";import"./CGQALCTZ.js";import"./US5FON7D.js";import a from"./WV7QX3ED.js";import{a as w}from"./VSRNGZ43.js";import"./QMAV4UTN.js";import"./Y2AUIXNK.js";import"./TEHBW75B.js";import"./RSPNBIIE.js";import"./ZCU2WWVN.js";import"./WGO4EVOV.js";import"./YKB6256M.js";import"./36LRAUE4.js";import"./JMY4B4WQ.js";import"./VQ5ZAQUF.js";import"./Z4F2NZOT.js";import"./KOIDWEP3.js";import"./3KXMYZCU.js";import"./6ERMTA3J.js";import"./GF4QELNV.js";import"./3TAQSXLA.js";import"./PY6RTQDR.js";import"./DKD2EGQP.js";import"./5O53T3SW.js";import"./AJZDBHB6.js";import"./FES7B3SJ.js";import{b}from"./ZB5UCRCG.js";import{F as _,G as f,H as g,J as s,K as v,h as p,i,q as l,u}from"./T3EPRHTT.js";import"./EXBEKVP5.js";export default $arcgis.t(([n,y,,,m])=>{var x=p`@layer{:host{display:block;--calcite-label-margin-bottom: 0}.padding-1-2{padding:.5rem}.display-none{display:none!important}.display-flex{display:flex}.position-absolute{position:absolute;inset:0;overflow:auto}.feature-node{position:relative!important}.button-container{justify-content:center;align-items:center}.top-border{border-top:1px solid var(--calcite-color-border-1)}.width-100{width:100%}.esri-features__container{padding:.5rem!important;background-color:var(--calcite-color-surface-2)!important;height:100%!important}.end-border{border-inline-end:1px solid var(--calcite-color-border-1)}.font-bold{font-weight:700}.z-index-1{z-index:1}.visibility-hidden{visibility:hidden;height:0px}.padding-inline-start-1{padding-inline-start:1rem}.border-width-0{border-width:0px}.pagination-action{position:relative;left:3px}.pagination-count{color:var(--calcite-color-brand);border-bottom:1px solid var(--calcite-color-brand);font-weight:700}}`,h=class extends g{constructor(){super(),this.enableEditGeometry=!1,this.enableSnapping=!1,this.graphics=[],this.isLoading=!1,this.isMobile=!1,this.allowEditing=!1,this.highlightEnabled=!0,this.paginationEnabled=!0,this.position="absolute",this.showCloseBtn=!1,this.showCopyPasteActions=!1,this.pasteEnabled=!1,this._alertOpen=!1,this._count="",this._editRecordOpen=!1,this._isMultipleEdits=!1,this._mobileTitle="",this._showListView=!1,this._translations=w({name:"info-card",blocking:!0}),this._navigatedToRelatedFeature=!1,this._editEnabled=!1,this._features=_(),this.popupClosed=l(),this.clearSelection=l(),this.selectionChanged=l(),this.copyFeatures=l(),this.pasteFeatures=l(),this.listenOn(window,"closeEdit",this.closeEdit),this.listenOn(window,"layerSelectionChange",this.layerSelectionChange),this.listenOn(window,"refreshGraphics",this.refreshGraphics),this.listenOn(window,"editMultipleFeatures",this.editMultipleFeatures),this.listenOn(window,"selectedLanguageUpdated",this.selectedLanguageUpdated),this.listenOn(window,"clearSelection",this._alertClosed)}static{this.properties={enableEditGeometry:5,enableSnapping:5,graphics:0,isLoading:5,isMobile:5,mapView:0,featuresReferenceId:1,allowEditing:5,highlightEnabled:5,paginationEnabled:5,position:1,showCloseBtn:5,showCopyPasteActions:5,pasteEnabled:5,_alertOpen:16,_count:16,_editRecordOpen:16,_isMultipleEdits:16,_mobileTitle:16,_showListView:16,_translations:16,_navigatedToRelatedFeature:16}}static{this.styles=x}static{this.shadowRootOptions=u}willUpdate(e){if(e.has("graphics")&&this.graphicsWatchHandler(),e.has("pasteEnabled")&&this.hasUpdated&&this._features.value?.headerActions?.length){let t=this._features.value.headerActions.find(a=>a.id==="paste-features");t&&(t.disabled=!this.pasteEnabled)}if(e.has("showCopyPasteActions")&&this.hasUpdated&&this.handleHeaderActions(),e.has("_translations")){let t=this._translations._lang,a=e.get("_translations")?._lang;if(t&&a&&t!==a&&this._features.value){let o=[...this.graphics];this.graphics=[],this.graphics=o}}}async graphicsWatchHandler(){if(this._navigatedToRelatedFeature&&this._features.value&&(await this._features.value.clear(),await this._features.value.close(),this._count="",this._navigatedToRelatedFeature=!1),await this.setGraphics(),this._features.value?.headerActions?.length&&this.showCopyPasteActions){let e=this._features.value.headerActions.find(t=>t.id==="copy-features");e&&(e.disabled=this.graphics.length===0)}}async getSelectedFeature(){return this._features.value?.selectedFeature}async refresh(){await this.setGraphics()}async back(){await this._back()}async next(){await this._next()}async toggleListView(){this._toggleListView()}async closeEdit(){this._editRecordOpen=!1,this._isMultipleEdits=!1}async layerSelectionChange(){this._showListView=!1,this._features.value?.viewModel&&(this._features.value.featureMenuOpen=!1,await this._features.value.close())}async refreshGraphics(e){this._navigatedToRelatedFeature||(this.graphics=[...e.detail])}async editMultipleFeatures(e){this._isMultipleEdits=!0,this._openEditRecord()}async selectedLanguageUpdated(e){await this._features.value?.clear(),await this._features.value?.close()}async load(){this._popupUtils=new m}async loaded(){this.graphics?.length>0&&await this.setGraphics()}render(){let e=this.isLoading?"":"display-none",t=!this.isLoading&&this._editRecordOpen?"position-absolute":"display-none",a=!this.isLoading&&this._editRecordOpen||this._showListView?"display-none":"",o=this._features.value?.features&&this._features.value.features.length<2||this._navigatedToRelatedFeature,d=Number(this._features.value?.selectedFeature?.getObjectId()),$=Number.isNaN(d)?[]:[d],c=this._layer?.editingEnabled&&this._layer?.capabilities?.operations?.supportsDelete,F=this._relatedFeature?[this._relatedFeature]:this.graphics,E=this._navigatedToRelatedFeature?0:this._features.value?.selectedFeatureIndex,r=this.isMobile?"display-none":"";return i`<calcite-shell class="z-index-1" style=${v({position:this.position})}>${this._getHeader()}<calcite-loader class=${s(e)} .label=${this._translations.fetchingData}></calcite-loader>${this.mapView&&this._getFeaturesComponent()||""}<div class=${`${a} width-100`} slot=footer>${this.allowEditing?i`<div class="display-flex top-border padding-1-2"><calcite-button appearance=solid id=solutions-edit @click=${()=>this._openEditRecord()} width=full>${this._translations.edit}</calcite-button>${this.isMobile&&c?i`<delete-button class="padding-inline-start-1 width-100" id=solutions-delete .ids=${$} .layer=${this._layer} @editsComplete=${()=>this._closePopup()}></delete-button>`:void 0}<calcite-tooltip class=${s(r)} placement=bottom reference-element=solutions-edit><span>${this._translations.edit}</span></calcite-tooltip>${this.isMobile&&c?i`<calcite-tooltip class=${s(r)} placement=bottom reference-element=solutions-delete><span>${this._translations.delete}</span></calcite-tooltip>`:void 0}</div>`:""}${this.paginationEnabled&&!o&&i`<div class=${"display-flex padding-1-2 button-container top-border"}><div><calcite-button appearance=transparent .disabled=${o} icon-flip-rtl=both icon-start=chevron-left id=solutions-back @click=${()=>this._back()} width=full></calcite-button><calcite-tooltip class=${s(r)} placement=top reference-element=solutions-back><span>${this._translations.back}</span></calcite-tooltip></div><calcite-action class="pagination-action" icon-flip-rtl @click=${()=>this._toggleListView()} scale=s .text=${this._translations.toggleListView} text-enabled><span class="pagination-count">${this._count}</span></calcite-action><div><calcite-button appearance=transparent .disabled=${o} icon-flip-rtl=both icon-start=chevron-right id=solutions-next @click=${()=>this._next()} width=full></calcite-button><calcite-tooltip class=${s(r)} placement=top reference-element=solutions-next><span>${this._translations.next}</span></calcite-tooltip></div></div>`||""}</div><edit-card .allowMultipleEditing=${this._isMultipleEdits} class=${s(t)} .enableEditGeometry=${this.enableEditGeometry} .enableSnapping=${this.enableSnapping} .graphicIndex=${E} .graphics=${F} .mapView=${this.mapView} .open=${this._editRecordOpen}></edit-card><calcite-alert auto-close icon=layer-broken kind=warning label @calciteAlertClose=${()=>this._alertClosed()} .open=${this._alertOpen} placement=top><div slot=title>${this._translations.editDisabled}</div><div slot=message>${this._translations.enableEditing}</div></calcite-alert></calcite-shell>`}async setGraphics(){this._features.value&&(this.graphics.length>0?(this._layer=this.graphics[0]?.layer,this._editEnabled=this._layer.editingEnabled&&this._layer.capabilities?.operations.supportsUpdate,this._mobileTitle=this.mapView?.map&&await this._popupUtils?.getPopupTitle(this.graphics[0],this.mapView.map)||"",this._features.value&&(this._features.value.open=!0),this._features.value&&(this._features.value.features=this.graphics)):(await this._features.value.clear(),await this._features.value.close()),this._count=this._getCount())}handleHeaderActions(){this.showCopyPasteActions&&this._features.value?.headerActions.length===0?(this._features.value.headerActions.addMany(this._getHeaderActions()),this._headerActionsHandle&&this._headerActionsHandle.remove(),this._headerActionsHandle=n.on(()=>this._features.value,"arcgisTriggerAction",e=>{e.detail.action.id==="copy-features"?this.copyFeatures.emit({featuresIds:this.graphics.map(t=>t.getObjectId()),layerId:this._layer?.id}):e.detail.action.id==="paste-features"&&this.pasteFeatures.emit()})):!this.showCopyPasteActions&&this._features.value&&this._features.value.headerActions.length>0&&(this._features.value.headerActions.removeAll(),this._headerActionsHandle?.remove(),this._headerActionsHandle=void 0)}async featuresComponentReady(){if(this._features.value){if(this.featuresReferenceId){let e=document.getElementById(this.featuresReferenceId);e&&(await e.viewOnReady(),this._features.value.referenceElement=e)}this.handleHeaderActions(),await this.setGraphics(),this._features.value.selectedFeature&&this.selectionChanged.emit({selectedFeature:[this._features.value.selectedFeature],selectedFeatureIndex:this._features.value.selectedFeatureIndex}),n.watch(()=>this._features.value?.featureMenuOpen,e=>{this._updateCount(),e||(this._showListView=e??!1)}),n.watch(()=>this._features.value?.selectedFeatureIndex,e=>{e!==void 0&&e>-1&&this._features.value?.selectedFeature&&this.selectionChanged.emit({selectedFeature:[this._features.value.selectedFeature],selectedFeatureIndex:this._features.value.selectedFeatureIndex})}),n.watch(()=>this._features.value?.selectedDrillInFeature,e=>{e?(this._relatedFeature=e,this._navigatedToRelatedFeature=!0):(this._relatedFeature=void 0,this._navigatedToRelatedFeature=!1)})}}_getHeader(){return this.isMobile&&!this._editRecordOpen?i`<calcite-panel class="border-width-0" slot=header><calcite-action class="end-border" icon=chevron-left icon-flip-rtl @click=${()=>this._closePopup()} scale=s slot=header-actions-start text></calcite-action><span class="font-bold" slot=header-content>${this._mobileTitle}</span></calcite-panel>`:void 0}_getFeaturesComponent(){let e=this._editRecordOpen?"display-none":"";return i`<arcgis-features class=${s(e)} .view=${this.mapView} hide-action-bar .hideCloseButton=${!this.showCloseBtn} hide-feature-menu-heading .hideHeading=${this.isMobile} .highlightDisabled=${!this.highlightEnabled} hide-feature-navigation @arcgisReady=${this.featuresComponentReady} @arcgisClose=${()=>{this.clearSelection.emit()}} ${f(this._features)}></arcgis-features>`}_getHeaderActions(){return[new y({id:"copy-features",title:this._translations.copy,className:"copy-features",icon:"copy",disabled:this.graphics.length===0}),new y({id:"paste-features",title:this._translations.paste,className:"paste-features",icon:"paste-with-attribute",disabled:!this.pasteEnabled})]}_closePopup(){this.popupClosed.emit()}_alertClosed(){this._alertOpen=!1}_openEditRecord(){this._editEnabled?this._editRecordOpen=!0:this._alertOpen=!0}async _back(){await this._features.value?.previous(),await this._updateCount()}async _next(){await this._features.value?.next(),await this._updateCount()}async _updateCount(){let e=this._features.value?.selectedFeatureIndex;this._popupUtils&&this.mapView&&this.mapView.map&&e!==void 0&&(this._mobileTitle=await this._popupUtils.getPopupTitle(this.graphics[e],this.mapView.map)),this._count=this._getCount()}_getCount(){let e=this._features.value?.viewModel&&(this._features.value?.viewModel.selectedFeatureIndex+1).toString()||"",t=this._features.value?.features?.length.toString()||"";return this._translations.indexOfTotal.replace("{{index}}",e).replace("{{total}}",t)||""}_toggleListView(){if(this._showListView=!this._showListView,this._features.value){let e=this._features.value?.selectedFeatureIndex;this._features.value.open=!0,this._features.value.featureMenuOpen=this._showListView,this._features.value.features=this.graphics,this._features.value.selectedFeatureIndex=e}}};b("info-card",h);return h},"core/reactiveUtils","support/actions/ActionButton",a,c,d)
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import e from"./KGUELU4O.js";import{a as Ce,b as Ge,c as ue}from"./TCUNTTNI.js";import d from"./G2H3X6NS.js";import c from"./SHQFXQEI.js";import b from"./QZ2ZMWIH.js";import a from"./CS5N3DOL.js";import{a as Ne}from"./CJ3EZE7U.js";import{d as je}from"./C5KDPY7R.js";import{a as Ke,b as de,c as Ee,d as me,e as Qe,f as Xe,g as ye,h as Re,i as Ye,j as Ze,k as Oe}from"./YM4U4HSN.js";import{a as N}from"./IADXB53D.js";import{a as Q}from"./YUWXPLTE.js";import{b as We}from"./MXPZF4RB.js";import"./Y2AUIXNK.js";import{F as Ue,G as xe,H as qe,J as x,K as k,h as Be,i as L,j as Le,l as pe,u as De}from"./T3EPRHTT.js";import"./EXBEKVP5.js";export default $arcgis.t(([ct,vt,pt,U,fe,At,,{a:j,b:J,c:Je,d:he},{a:be,b:Ve,d:et,f:tt,g:we,h:it,i:nt,j:at},{a:rt,b:Ae,c:st,g:lt},oe])=>{(function(d,e){typeof exports=="object"&&typeof module<"u"?e(exports):typeof define=="function"&&define.amd?define(["exports"],e):(d=typeof globalThis<"u"?globalThis:d||self,e(d.maquette={}))})(void 0,(function(d){"use strict";var e=function(){var t,i;return{invalidate:function(){i=void 0,t=void 0},result:function(a,c){if(t)for(var p=0;p<a.length;p++)t[p]!==a[p]&&(i=void 0);return i||(i=c(),t=a),i}}},n="http://www.w3.org/",l="".concat(n,"2000/svg"),r="".concat(n,"1999/xlink"),s=[],h=function(t,i){var a={};return Object.keys(t).forEach(function(c){a[c]=t[c]}),i&&Object.keys(i).forEach(function(c){a[c]=i[c]}),a},u=function(t,i){return t.vnodeSelector!==i.vnodeSelector?!1:t.properties&&i.properties?t.properties.key!==i.properties.key?!1:t.properties.bind===i.properties.bind:!t.properties&&!i.properties},w=function(t){if(typeof t!="string")throw new Error("Style values must be strings")},$=function(t,i,a){if(i.vnodeSelector!==""){for(var c=a;c<t.length;c++)if(u(t[c],i))return c}return-1},S=function(t,i,a,c){var p=t[i];if(p.vnodeSelector!==""){var o=p.properties,C=o?o.key===void 0?o.bind:o.key:void 0;if(!C){for(var g=0;g<t.length;g++)if(g!==i){var f=t[g];if(u(f,p))throw Object.assign(new Error("".concat(a.vnodeSelector," had a ").concat(p.vnodeSelector," child ").concat(c==="added"?c:"removed",", but there is now more than one. You must add unique key properties to make them distinguishable.")),{parentNode:a,childNode:p})}}}},E=function(t){if(t.properties){var i=t.properties.enterAnimation;i&&i(t.domNode,t.properties)}},_=[],T=!1,M=function(t){(t.children||[]).forEach(M),t.properties&&t.properties.afterRemoved&&t.properties.afterRemoved.apply(t.properties.bind||t.properties,[t.domNode])},I=function(){T=!1,_.forEach(M),_.length=0},P=function(t){_.push(t),T||(T=!0,typeof window<"u"&&"requestIdleCallback"in window?window.requestIdleCallback(I,{timeout:16}):setTimeout(I,16))},A=function(t){var i=t.domNode;if(t.properties){var a=t.properties.exitAnimation;if(a){i.style.pointerEvents="none";var c=function(){i.parentNode&&(i.parentNode.removeChild(i),P(t))};a(i,c,t.properties);return}}i.parentNode&&(i.parentNode.removeChild(i),P(t))},B=["on","afterCreate","afterUpdate","afterRemoved","enterAnimation","exitAnimation","updateAnimation"];function q(t){return!B.includes(t)}var K=function(t,i,a){if(i){for(var c=a.eventHandlerInterceptor,p=Object.keys(i).filter(q),o=p.length,C=0;C<o;C++){var g=p[C],f=i[g];if(g==="className")throw new Error('Property "className" is not supported, use "class".');if(g==="class")se(t,f,!0);else if(g==="classes")for(var v=Object.keys(f),R=v.length,b=0;b<R;b++){var y=v[b];f[y]&&t.classList.add(y)}else if(g==="styles")for(var z=Object.keys(f),F=z.length,b=0;b<F;b++){var G=z[b],te=f[G];te&&(w(te),a.styleApplyer(t,G,te))}else if(g!=="key"&&f!==null&&f!==void 0){var ve=typeof f;ve==="function"?(g.lastIndexOf("on",0)===0&&c&&(f=c(g,f,t,i)),t[g]=f):a.namespace===l?g==="href"?t.setAttributeNS(r,g,f):t.setAttribute(g,f):ve==="string"&&g!=="value"&&g!=="innerHTML"?t.setAttribute(g,f):t[g]=f}}if(i.on)for(var ie=0,ge=Object.entries(i.on);ie<ge.length;ie++){var Y=ge[ie],Z=Y[0],O=Y[1],ne=typeof O=="function"?O:O.listener;c&&(ne=c(Z,ne,t,i)),ne&&t.addEventListener(Z,ne,typeof O=="function"?void 0:O.options)}}},H=function(t,i,a){if(i)for(var c=0,p=i;c<p.length;c++){var o=p[c];W(o,t,void 0,a)}},D=function(t,i,a){H(t,i.children,a),i.text&&(t.textContent=i.text),K(t,i.properties,a),i.properties&&i.properties.afterCreate&&i.properties.afterCreate.apply(i.properties.bind||i.properties,[t,a,i.vnodeSelector,i.properties,i.children])},W=function(t,i,a,c){var p,o,C=0,g=t.vnodeSelector,f=i.ownerDocument;if(g==="")t.domNode?t.domNode.nodeValue=t.text:(o=t.domNode=f.createTextNode(t.text),a!==void 0?i.insertBefore(o,a):i.appendChild(o));else{for(var v=0;v<=g.length;++v){var R=g.charAt(v);if(v===g.length||R==="."||R==="#"){var b=g.charAt(C-1),y=g.slice(C,v);b==="."?o.classList.add(y):b==="#"?o.id=y:(y==="svg"&&(c=h(c,{namespace:l})),c.namespace!==void 0?o=t.domNode=f.createElementNS(c.namespace,y):(o=t.domNode=t.domNode||(!((p=t.properties)===null||p===void 0)&&p.is?f.createElement(y,{is:t.properties.is}):f.createElement(y)),y==="input"&&t.properties&&t.properties.type!==void 0&&o.setAttribute("type",t.properties.type)),a!==void 0?i.insertBefore(o,a):o.parentNode!==i&&i.appendChild(o)),C=v+1}}D(o,t,c)}},V,se=function(t,i,a){i&&i.split(" ").forEach(function(c){c&&t.classList.toggle(c,a)})},_e=function(t,i,a,c){if(a){for(var p=!1,o=Object.keys(a).filter(q),C=o.length,g=0;g<C;g++){var f=o[g],v=a[f],R=i[f];if(f==="class")R!==v&&(se(t,R,!1),se(t,v,!0));else if(f==="classes")for(var b=t.classList,y=Object.keys(v),z=y.length,F=0;F<z;F++){var G=y[F],te=!!v[G],ve=!!R[G];te!==ve&&(p=!0,te?b.add(G):b.remove(G))}else if(f==="styles")for(var ie=Object.keys(v),ge=ie.length,F=0;F<ge;F++){var Y=ie[F],Z=v[Y],O=R[Y];Z!==O&&(p=!0,Z?(w(Z),c.styleApplyer(t,Y,Z)):c.styleApplyer(t,Y,""))}else if(!v&&typeof R=="string"&&(v=""),f==="value"){var ne=t[f];ne!==v&&v!==R&&(t[f]=v),v!==R&&(p=!0)}else if(v!==R){var He=typeof v;(He!=="function"||!c.eventHandlerInterceptor)&&(c.namespace===l?f==="href"?t.setAttributeNS(r,f,v):t.setAttribute(f,v):He==="string"&&f!=="innerHTML"?f==="role"&&v===""?t.removeAttribute(f):t.setAttribute(f,v):t[f]!==v&&(t[f]=v),p=!0)}}return p}},bt=function(t,i,a,c,p){if(a===c)return!1;a=a||s,c=c||s;for(var o=a.length,C=c.length,g=0,f=0,v,R=!1;f<C;){var b=g<o?a[g]:void 0,y=c[f];if(b!==void 0&&u(b,y))R=V(b,y,p,i,a)||R,g++;else{var z=$(a,y,g+1);if(z>=0){for(v=g;v<z;v++)A(a[v]),S(a,v,t,"removed");R=V(a[z],y,p,i,a)||R,g=z+1}else W(y,i,g<o?a[g].domNode:void 0,p),E(y),S(c,f,t,"added")}f++}if(o>g)for(v=g;v<o;v++)A(a[v]),S(a,v,t,"removed");return R};V=function(t,i,a,c,p){var o=t.domNode,C=!1;if(t===i)return!1;var g=!1;if(i.vnodeSelector===""){if(i.text!==t.text){var f=o.ownerDocument.createTextNode(i.text);try{c.replaceChild(f,o)}catch{c.replaceChild(f,c.childNodes[p.indexOf(t)])}return i.domNode=f,C=!0,C}i.domNode=o}else i.vnodeSelector.lastIndexOf("svg",0)===0&&(a=h(a,{namespace:l})),t.text!==i.text&&(g=!0,i.text===void 0?o.removeChild(o.firstChild):o.textContent=i.text),i.domNode=o,g=bt(i,o,t.children,i.children,a)||g,g=_e(o,t.properties,i.properties,a)||g,i.properties&&i.properties.afterUpdate&&i.properties.afterUpdate.apply(i.properties.bind||i.properties,[o,a,i.vnodeSelector,i.properties,i.children]);return g&&i.properties&&i.properties.updateAnimation&&i.properties.updateAnimation(o,i.properties,t.properties),C};var le=function(t,i){return{getLastRender:function(){return t},update:function(a){if(t.vnodeSelector!==a.vnodeSelector)throw new Error("The selector for the root VNode may not be changed. (consider using dom.merge and add one extra level to the virtual DOM)");var c=t;t=a,V(c,a,i,c.domNode.parentNode,[c])},domNode:t.domNode}},wt={namespace:void 0,performanceLogger:function(){},eventHandlerInterceptor:void 0,styleApplyer:function(t,i,a){i.charAt(0)==="-"?t.style.setProperty(i,a):t.style[i]=a}},ee=function(t){return h(wt,t)},ce={create:function(t,i){return i=ee(i),W(t,document.createElement("div"),void 0,i),le(t,i)},append:function(t,i,a){return a=ee(a),W(i,t,void 0,a),le(i,a)},insertBefore:function(t,i,a){return a=ee(a),W(i,t.parentNode,t,a),le(i,a)},merge:function(t,i,a){return a=ee(a),i.domNode=t,D(t,i,a),le(i,a)},replace:function(t,i,a){return a=ee(a),W(i,t.parentNode,t,a),t.parentNode.removeChild(t),le(i,a)}},$t=function(t){return{vnodeSelector:"",properties:void 0,children:void 0,text:t.toString(),domNode:null}},Me=function(t,i,a){for(var c=0,p=i.length;c<p;c++){var o=i[c];Array.isArray(o)?Me(t,o,a):o!=null&&o!==!1&&(typeof o=="string"&&(o=$t(o)),a.push(o))}};function _t(t,i,a){if(Array.isArray(i))a=i,i=void 0;else if(i&&(typeof i=="string"||i.vnodeSelector)||a&&(typeof a=="string"||a.vnodeSelector))throw new Error("h called with invalid arguments");var c,p;return a&&a.length===1&&typeof a[0]=="string"?c=a[0]:a&&(p=[],Me(t,a,p),p.length===0&&(p=void 0)),{vnodeSelector:t,properties:i,children:p,text:c===""?void 0:c,domNode:null}}var Lt=function(t,i,a){var c=[],p=[];return{results:p,map:function(o){for(var C=o.map(t),g=p.slice(),f=0,v=0;v<o.length;v++){var R=o[v],b=C[v];if(b===c[f])p[v]=g[f],a(R,g[f],v),f++;else{for(var y=!1,z=1;z<c.length+1;z++){var F=(f+z)%c.length;if(c[F]===b){p[v]=g[F],a(o[v],g[F],v),f=F+1,y=!0;break}}y||(p[v]=i(R,v))}}p.length=o.length,c=C}}},xt=function(t,i){for(var a=[];t&&t!==i;)a.push(t),t=t.parentNode;return a},Ct=function(t,i){var a=t;return i.forEach(function(c){a=a&&a.children?a.children.find(function(p){return p.domNode===c}):void 0}),a},Et=function(t,i,a){return function(p,o,C,g){return c};function c(p){var o,C;a("domEvent",p);var g=i(),f=xt(p.currentTarget,g.domNode);f.reverse();var v=Ct(g.getLastRender(),f);t.scheduleRender();var R;if(v){var b=(C=(o=v.properties["on".concat(p.type)])!==null&&o!==void 0?o:v.properties.on[p.type].listener)!==null&&C!==void 0?C:v.properties.on[p.type];R=b.apply(v.properties.bind||this,arguments)}return a("domEventProcessed",p),R}},Rt=function(t){var i,a=ee(t),c=a.performanceLogger,p=!0,o,C=!1,g=[],f=[],v=function(b,y,z){var F,G=function(){return F};a.eventHandlerInterceptor=Et(i,G,c),F=b(y,z(),a),g.push(F),f.push(z)},R=function(){if(o=void 0,!!p){p=!1,c("renderStart",void 0);for(var b=0;b<g.length;b++){var y=f[b]();c("rendered",void 0),g[b].update(y),c("patched",void 0)}c("renderDone",void 0),p=!0}};return i={renderNow:R,scheduleRender:function(){!o&&!C&&(o=requestAnimationFrame(R))},stop:function(){o&&(cancelAnimationFrame(o),o=void 0),C=!0},resume:function(){C=!1,p=!0,i.scheduleRender()},append:function(b,y){v(ce.append,b,y)},insertBefore:function(b,y){v(ce.insertBefore,b,y)},merge:function(b,y){v(ce.merge,b,y)},replace:function(b,y){v(ce.replace,b,y)},detach:function(b){for(var y=0;y<f.length;y++)if(f[y]===b)return f.splice(y,1),g.splice(y,1)[0];throw new Error("renderFunction was not found")}},i};d.createCache=e,d.createMapping=Lt,d.createProjector=Rt,d.dom=ce,d.h=_t}));function kt(d,e,n,l){let r=st(d,e,n,l),s=St(r);return r.join(s)}function St(d){return d.every(e=>e&&e.includes(rt.NOT_EQUAL))?Ae.AND:Ae.OR}async function dt(d,e,n,l,r){let{fLayerView:s}=d,h=kt(d,e,n,r),u=s?.filter?.timeExtent??s?.featureEffect?.filter?.timeExtent??null,{type:w}=l;if(ue(w))s.filter=new ct({where:h,timeExtent:u});else if(l.effect){let{includedEffect:$,excludedEffect:S}=l.effect,E=await oe(S,s,"excludedEffect"),_=await oe($,s,"includedEffect");s.featureEffect=new vt({filter:new ct({where:h,timeExtent:u}),includedEffect:_,excludedEffect:E})}return await Promise.resolve()}function It(d,e){let{type:n}=d;ue(n)?Tt(e):Ge(n)&&Ft(d,e)}function Tt(d){d?.allLayerViews?.filter(e=>be(e?.layer?.type))?.forEach(e=>{let n=e,l=ut(n);n.filter=l,n.set("featureEffect",null)})}function Ft(d,e){e?.allLayerViews?.filter(n=>be(n?.layer?.type)).forEach(async n=>{let l=n;if(d?.effect&&l){let{includedEffect:r,excludedEffect:s}=d.effect,h=await oe(s,l,"excludedEffect"),u=await oe(r,l,"includedEffect"),w=ut(l);l.featureEffect=new vt({filter:w,includedEffect:u,excludedEffect:h}),l.set(Ce.FILTER,null)}})}function ut(d){return d?.filter||d?.featureEffect?.filter}var Pt=80,zt=.2,Mt=6;function X(d){let e=typeof d=="number"?d:Number(d);return Number.isFinite(e)?e:0}function ht(d){if("infos"in d)return Math.max(...d.infos.map(e=>ht(e)),0);if("preview"in d&&d.preview){let e=d.preview,n=e.querySelector("svg"),l=X(n?.getAttribute("width")),r=X(n?.getAttribute("height")),s=X(e.style.width?.replace("px","")),h=X(e.style.height?.replace("px","")),u=X(e.clientWidth),w=X(e.clientHeight);return Math.max(l,r,s,h,u,w)}return"src"in d?Math.max(X(d.width),X(d.height)):0}function Ht(d,e){let n=ht(d);return n>=Pt?!0:typeof e!="number"||e<=0?!1:n+Mt>=e}function Bt(d){if(!(d<=0))return d*zt}var Dt=(void 0)(),mt=10,Fe=20,$e=10,Pe=20,ze={univariateAboveAndBelowSymbol:"esri-univariate-above-and-below-ramp__symbol",colorRamp:"esri-legend__color-ramp"};function Ut(d="vertical"){let e={stroke:"rgb(200, 200, 200)",strokeWidth:"1"};return d==="vertical"?L`<svg height=4 width=10>${Le`<line x1=0 y1=2 x2=10 y2=2 style=${k(e)} />`}</svg>`:L`<svg height=10 width=10>${Le`<line x1=5 y1=0 x2=5 y2=10 style=${k(e)} />`}</svg>`}function qt(d,e="vertical"){let n=document.createElement("div");return n.style.height=`${Fe}px`,n.className=ze.univariateAboveAndBelowSymbol,d!=null&&(n.style.opacity=d.toString()),Dt.append(n,Ut.bind(null,e)),n}function yt(d,e,n="vertical",l){d.infos.forEach((r,s)=>{if(l&&s===2)r.preview=qt(e,n);else{let{size:h}=r,u=re(h)+(n==="horizontal"?Pe:$e),w=r.preview.tagName.toLowerCase()==="div",$=w?r.preview:document.createElement("div");$&&($.className=ze.univariateAboveAndBelowSymbol),n==="horizontal"?$&&($.style.width=`${u}px`):$&&($.style.height=`${u}px`),w||$&&$.appendChild(r.preview),r.preview=$}})}var Wt=96;function re(d){return d?d/72*Wt:0}function ot(d,e="classic"){let n=d.infos,l=n[0].size,r=n[n.length-1].size;return e==="classic"?(re(l)+$e)/2:(re(l)-re(r))/2}function ke(d,e){if(!d)return null;let n=d.infos.map(r=>r.color),l=pt.renderColorRampPreviewHTML(e.type==="full"?n:e.type==="above"?n.slice(0,3):n.slice(2,5),{width:e.width,height:e.height,align:e.rampAlignment,effectList:e.effectList});return l.className=ze.colorRamp,e.opacity!=null&&(l.style.opacity=e.opacity.toString()),l}function Gt(d,e,n,l="vertical"){let r=0,s=d.infos,h=Math.floor(s.length/2),u=e==="full"||e==="above"?0:h,w=e==="full"||e==="below"?s.length-1:h;for(let $=u;$<=w;$++)if(n&&$===h)r+=l==="horizontal"?mt:Fe;else{let S=s[$].size,E=re(S)+(l==="horizontal"?Pe:$e);r+=E}return Math.round(r)}function Se(d,e,n,l="vertical"){let r=Gt(d,e,n,l),s=d.infos,h=Math.floor(s.length/2),u=e==="full"||e==="above"?0:h,w=e==="full"||e==="below"?s.length-1:h,$=e==="full"?s[u].size+s[w].size:e==="above"?s[u].size:s[w].size,S=n?l==="vertical"?Fe:mt:0,E=l==="vertical"?$e*(e==="full"?2:1):Pe*(e==="full"?2:1);return Math.round(r-(re($)/2+S/2+E/2))}function Jt(d,e,n="vertical"){let l=d.infos,r=l.find(h=>ye(h)),s=l.find(h=>de(h));return r&&(r={...r},r.infos=[...r.infos],yt(r,e,n,!0)),s&&(s={...s},s.infos=[...s.infos]),n==="horizontal"&&(r?.infos.reverse(),s?.infos.reverse()),{sizeRampElement:r,colorRampElement:s}}function Kt(d,e="vertical"){let n=d.infos,l=n.find(s=>ye(s)),r=n.find(s=>de(s));return l&&(l={...l},l.infos=[...l.infos],yt(l,null,e,!1)),r&&(r={...r},r.infos=[...r.infos]),e==="horizontal"&&(l?.infos.reverse(),r?.infos.reverse()),{sizeRampElement:l,colorRampElement:r}}var Qt=Be`@layer{instant-apps-interactive-legend-classic{display:block;--instant-apps-interactive-legend-heading-font-size: 1rem;--instant-apps-interactive-legend-heading-font-weight: normal;--instant-apps-interactive-legend-caption-font-weight: normal;--instant-apps-interactive-legend-secondary-color: var( --calcite-color-text-1 );--instant-apps-interactive-legend-field-name-font-size: 1rem;--instant-apps-interactive-legend-total-feature-count-font-size: .875rem;--instant-apps-interactive-legend-info-font-size: .875rem;--instant-apps-interactive-legend-info-item-background--selected: #c7ebff;--instant-apps-interactive-legend-info-item-background--selected--dark: #009af2;--instant-apps-interactive-legend-info-item-background--hover: #e9e9e9;--instant-apps-interactive-legend-info-item-background--hover--dark: #4a4a4a;--instant-apps-interactive-legend-info-item-color--selected: var( --calcite-color-text-2 );--instant-apps-interactive-legend-secondary-background-color: var( --calcite-color-background );--instant-apps-interactive-legend-ui-margin: 20px 15px;--instant-apps-interactive-legend-ui-padding: 20px 15px}instant-apps-interactive-legend-classic .esri-legend__service{padding:0}instant-apps-interactive-legend-classic .esri-legend__layer-body,instant-apps-interactive-legend-classic .esri-legend__layer,instant-apps-interactive-legend-classic .esri-legend__layer-table,instant-apps-interactive-legend-classic .esri-legend__group-layer-child,instant-apps-interactive-legend-classic .esri-legend__layer-child-table{margin:0;overflow:hidden}instant-apps-interactive-legend-classic .esri-legend__layer-caption calcite-action{margin-right:5px}instant-apps-interactive-legend-classic .esri-legend__layer-caption{display:flex;align-items:center;font-size:var(--instant-apps-interactive-legend-field-name-font-size);background-color:var(--instant-apps-interactive-legend-secondary-background-color);color:var(--instant-apps-interactive-legend-secondary-color)}instant-apps-interactive-legend-classic .instant-apps-interactive-legend__layer-caption-btn-container{white-space:nowrap}instant-apps-interactive-legend-classic .instant-apps-interactive-legend__layer-caption-btn-container calcite-button{margin:2px}instant-apps-interactive-legend-classic .esri-legend__layer-caption{font-weight:var(--instant-apps-interactive-legend-caption-font-weight)}instant-apps-interactive-legend-classic .esri-legend__layer-cell.esri-legend__layer-cell--info{font-size:var(--instant-apps-interactive-legend-info-font-size);text-align:left}instant-apps-interactive-legend-classic .esri-legend__layer-cell,instant-apps-interactive-legend-classic .esri-legend__layer-row{display:flex;align-items:center}instant-apps-interactive-legend-classic .instant-apps-interactive-legend__non-interactive .esri-legend__layer-body{display:block;margin:var(--instant-apps-interactive-legend-ui-margin)}instant-apps-interactive-legend-classic .instant-apps-interactive-legend__non-interactive.instant-apps-interactive-legend__nested-unique-symbol>.esri-legend__layer-body{margin:0}instant-apps-interactive-legend-classic .instant-apps-interactive-legend__non-interactive .esri-legend__layer-row{display:table-row}instant-apps-interactive-legend-classic .instant-apps-interactive-legend__non-interactive .esri-legend__layer-cell{display:table-cell}instant-apps-interactive-legend-classic .esri-legend__layer-cell--symbols{justify-content:center;width:20%}instant-apps-interactive-legend-classic .esri-legend__layer-cell--info{width:65%}instant-apps-interactive-legend-classic .instant-apps-interactive-legend__layer-row--interactive{margin:1px;background:transparent;border:none;width:100%}instant-apps-interactive-legend-classic .esri-legend__layer-body.instant-apps-interactive-legend__layer-body--large-symbol>.esri-legend__layer-row{display:grid;grid-template-columns:minmax(35%,max-content) minmax(0,1fr);column-gap:clamp(.125rem,.3vw,.25rem);align-items:center;width:100%}instant-apps-interactive-legend-classic .esri-legend__layer-body.instant-apps-interactive-legend__layer-body--large-symbol>.esri-legend__layer-row>.esri-legend__layer-cell--symbols{width:35%;box-sizing:border-box;padding-inline:clamp(.125rem,.3vw,.25rem);display:flex;align-items:center;justify-content:center}instant-apps-interactive-legend-classic .esri-legend__layer-body.instant-apps-interactive-legend__layer-body--large-symbol>.esri-legend__layer-row>.esri-legend__layer-cell--info{display:block;width:auto;min-width:0}instant-apps-interactive-legend-classic .esri-legend__layer-cell--info{color:var(--instant-apps-interactive-legend-secondary-color)}instant-apps-interactive-legend-classic .esri-legend__layer-row,instant-apps-interactive-legend-classic .esri-legend__layer-caption{padding:var(--instant-apps-interactive-legend-ui-padding)}instant-apps-interactive-legend-classic .instant-apps-interactive-legend__layer-row--interactive{position:relative}instant-apps-interactive-legend-classic .instant-apps-interactive-legend-element-info--selected{background-color:var(--instant-apps-interactive-legend-info-item-background--selected)}instant-apps-interactive-legend-classic .calcite-mode-dark .instant-apps-interactive-legend-element-info--selected{cursor:pointer;background-color:var(--instant-apps-interactive-legend-info-item-background--selected--dark)}instant-apps-interactive-legend-classic .calcite-mode-dark .instant-apps-interactive-legend-element-info--selected .esri-legend__layer-cell--info{color:var(--calcite-color-text-inverse)}instant-apps-interactive-legend-classic .hide{display:none}.instant-apps-interactive-legend__compact .esri-legend__layer-row{--instant-apps-interactive-legend-ui-padding: 10px 5px}.instant-apps-interactive-legend__compact .esri-legend__layer-row .esri-legend__layer-cell--info:not(:has(.esri-legend__ramp-labels)){display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2;overflow:hidden;text-overflow:ellipsis;line-clamp:2;line-height:1.3125rem;max-height:2.625rem}@media(min-width:992px){instant-apps-interactive-legend-classic .instant-apps-interactive-legend__layer-row--interactive{cursor:pointer}instant-apps-interactive-legend-classic .instant-apps-interactive-legend__layer-row--interactive:hover{background-color:var(--instant-apps-interactive-legend-info-item-background--hover)}instant-apps-interactive-legend-classic .instant-apps-interactive-legend__layer-row--interactive:hover.instant-apps-interactive-legend-element-info--selected{background-color:#e2f2fe}instant-apps-interactive-legend-classic .calcite-mode-dark .instant-apps-interactive-legend__layer-row--interactive:hover{background-color:var(--instant-apps-interactive-legend-info-item-background--hover--dark)}instant-apps-interactive-legend-classic .calcite-mode-dark .instant-apps-interactive-legend__layer-row--interactive:hover.instant-apps-interactive-legend-element-info--selected{background-color:#26a9f4}}}`,m={layer:"esri-legend__layer",layerBody:"esri-legend__layer-body",layerRow:"esri-legend__layer-row",layerInfo:"esri-legend__layer-cell esri-legend__layer-cell--info",imageryLayerStretchedImage:"esri-legend__imagery-layer-image--stretched",imageryLayerInfoStretched:"esri-legend__imagery-layer-info--stretched",symbolContainer:"esri-legend__layer-cell esri-legend__layer-cell--symbols",symbol:"esri-legend__symbol",rampContainer:"esri-legend__ramps",sizeRamp:"esri-legend__size-ramp",colorRamp:"esri-legend__color-ramp",opacityRamp:"esri-legend__opacity-ramp",rampLabelsContainer:"esri-legend__ramp-labels",rampLabel:"esri-legend__ramp-label",univariateAboveAndBelowLabel:"esri-univariate-above-and-below-ramp__label",message:"esri-legend__message",layerBodyLargeSymbol:"instant-apps-interactive-legend__layer-body--large-symbol",interactiveLayerRow:"instant-apps-interactive-legend__layer-row--interactive",infoSelected:"instant-apps-interactive-legend-element-info--selected",compact:"instant-apps-interactive-legend__compact"},Xt=24,ft={display:"flex",alignItems:"flex-start"},Ie={marginLeft:"3px"},ae={display:"table-cell",verticalAlign:"middle"},Te=class extends qe{constructor(){super(...arguments),this.featureCountRequestId=0,this._legendContainerRef=Ue(),this._hiddenLegendState={},this._pendingRestore={},this._restoreTimeouts={},this.isLoading=!0,this.zoomTo=!1,this.featureCount=!1,this.filterMode={type:Ce.FILTER}}static{this.properties={isLoading:16,legendvm:0,zoomTo:5,featureCount:5,filterMode:0,messages:0}}static{this.styles=Qt}static{this.shadowRootOptions=De}connectedCallback(){super.connectedCallback(),!this.handles&&(this.handles=new At)}async load(){new MutationObserver(()=>{this.requestUpdate()}).observe(this.el,{attributes:!0}),J.onChange("data",()=>this.requestUpdate())}willUpdate(e){e.has("filterMode")&&this.legendvm?.view&&(this.hasUpdated||!ue(this.filterMode.type))&&It(this.filterMode,this.legendvm.view),e.has("featureCount")&&e.get("featureCount")===!1&&this.featureCount&&this.legendvm&&this.refreshFeatureCount().catch(n=>{console.error(n)})}async loaded(){await this.initLegend()}disconnectedCallback(){super.disconnectedCallback(),this.handles?.removeAll(),this.handles?.destroy(),this.handles=null}async initLegend(){try{await U.whenOnce(()=>this.legendvm?.view);let e=async()=>{try{let n=this.legendvm?.view?.map;await n?.load(),await n?.basemap?.load();let l=n?.allLayers?.map(async u=>await u.load()),r=(await Promise.allSettled(l)).map(u=>u?.status==="fulfilled"&&u?.value?u.value:null).filter(u=>!!u),s=[];r.forEach(u=>{this.legendvm?.view&&s.push(this.legendvm.view.whenLayerView(u))}),await Promise.allSettled(s),await Promise.race([U.whenOnce(()=>(this.legendvm?.activeLayerInfos?.length??0)>0),new Promise(u=>{setTimeout(u,250)})]);let h=await we(this.legendvm);Object.keys(h).length===0&&(await new Promise(u=>{setTimeout(u,250)}),h=await we(this.legendvm)),J.set("data",{...j.data,...h}),await this.refreshFeatureCount(),this.isLoading=!1,await this.setupWatchersAndListeners()}catch(n){console.error(n),this.isLoading=!1}};this.legendvm?.view?.when(e),this.legendvm?.view?.map?.layers?.on("after-changes",e)}catch{this.isLoading=!1}}getStretchStopLabel(e){let n=this.messages[e.label];return e.label?`${n}: ${typeof e.value=="string"?e.value:fe.formatNumber(e.value,{style:"decimal",notation:e.value.toString().includes("e")?"scientific":"standard"})}`:""}getTitle(e,n){if(!e)return;if(typeof e=="string"||typeof e=="number")return e;if("value"in e||"unit"in e){let s=typeof this.messages?.dotValue=="string"?this.messages.dotValue:"";return fe.substitute(s,e)}if("colorName"in e||"bandName"in e){let{colorName:s,bandName:h}=e,u=this.messages[s],w=typeof this.messages[h]=="string"?this.messages[h]:h;return`${u}: ${w}`}if("showCount"in e)return e.showCount?this.messages.clusterCountTitle:null;let l=null;if(n){let s=e;l=s.ratioPercentTotal?"showRatioPercentTotal":s.ratioPercent?"showRatioPercent":s.ratio?"showRatio":e.normField?"showNormField":e.field?"showField":null}else if(this.isRendererTitle(n)){let s=e;l=s.normField?"showNormField":s.normByPct?"showNormPct":s.field?"showField":null}let r=l==="showField"?"{field}":typeof l=="string"?this.messages[l]:"";return l?fe.substitute(r,{field:e.field,normField:e.normField}):""}isRendererTitle(e){return!e}async setupWatchersAndListeners(){let e=this.legendvm?.view?.map?.allLayers?.filter(r=>be(r?.type)),n=[];for(let r of e)this.legendvm?.view&&n.push(this.legendvm?.view?.whenLayerView(r));let l=[];try{l=await Promise.all(n)}catch(r){console.error(r)}for(let r of l){let s=`fLayerViewScale-${r.layer.id}`;!this.handles?.has(s)&&r&&this.handles?.add(r.watch("visibleAtCurrentScale",()=>{this.createDataForLayer(r.layer).catch(h=>{console.error(h)})}),s)}e?.forEach(r=>{let s=`fLayer-${r?.id}`;this.handles?.has(s)||this.handles?.add(U?.watch(()=>r?.visible,()=>this.handleFeatureLayerVisibilityChange(r)),s)}),this.handles?.add(U.when(()=>this.legendvm,()=>{U.watch(()=>this.legendvm?.view?.updating,()=>{this.legendvm?.view?.updating&&U.when(()=>!this.legendvm?.view?.updating,()=>{this.refreshFeatureCount().catch(r=>{console.error(r)})},{once:!0,initial:!0})},{initial:!0})},{initial:!0,once:!0})),this.handles?.add(U.on(()=>this.legendvm?.activeLayerInfos,"change",r=>{this.regenerateData().then(()=>{this.handles?.add(U.on(()=>r.children,"change",()=>{this.regenerateData().catch(s=>{console.error(s)})}))}).catch(s=>{console.error(s)})})),this.handles?.add(U.on(()=>this.legendvm?.view?.map?.layers,"after-changes",()=>{this.refreshFeatureCount().catch(r=>{console.error(r)})}))}async createDataForLayer(e){let n=e?.id;if(nt(n,this._pendingRestore,this._hiddenLegendState))return;let l=J.get("data")?.[n],r=it(this.legendvm?.activeLayerInfos)?.find(s=>s?.layer?.id===n);if(!l&&r){let s=await Ve(this.legendvm,r);he({intLegendLayerData:s,layerId:n}),await this.refreshFeatureCount()}}applyFilter(e,n,l,r){return async()=>{let s={...j.data?.[n?.id]};r?await dt(s,e,l,this.filterMode,r):await dt(s,e,l,this.filterMode),he({intLegendLayerData:s,layerId:n?.id})}}async regenerateData(){let e=await we(this.legendvm),n=at(e,j.data,this._pendingRestore,this._hiddenLegendState);J.set("data",n),await this.refreshFeatureCount(),this.requestUpdate()}async refreshFeatureCount(){if(!this.featureCount)return;let e=++this.featureCountRequestId;try{let n=await lt(this.legendvm,j.data);if(e!==this.featureCountRequestId)return;J.set("data",{...j.data,...n})}catch{}}handleFeatureLayerVisibilityChange(e){let n=e.id,l=J.get("data")?.[n];if(e.visible){this.handleFeatureLayerVisible(n,e);return}this.handleFeatureLayerHidden(n,l)}handleFeatureLayerVisible(e,n){if(this._hiddenLegendState[e]){let l=this._hiddenLegendState[e];this._pendingRestore[e]=l,he({intLegendLayerData:l,layerId:e}),delete this._hiddenLegendState[e],this.clearRestoreGuard(e),this._restoreTimeouts[e]=window.setTimeout(()=>{delete this._pendingRestore[e],delete this._restoreTimeouts[e]},250);return}this.createDataForLayer(n).catch(l=>{console.error(l)})}handleFeatureLayerHidden(e,n){this.clearRestoreGuard(e),n&&(this._hiddenLegendState[e]=n)}clearRestoreGuard(e){this._restoreTimeouts[e]&&(clearTimeout(this._restoreTimeouts[e]),delete this._restoreTimeouts[e]),delete this._pendingRestore[e]}isImageryStretchedLegend(e,n){return!0}render(){let e=this.renderFilteredLayers(),n=J.get("compact")?` ${m.compact}`:"";return this.isLoading?Q("interactive-legend-loader",L`<calcite-loader scale=m .label=${this.messages?.loading} .text=${this.messages?.loading}></calcite-loader>`):Q("interactive-legend-classic-container",L`<div class=${`${N(this.el)}${n}`} ${xe(this._legendContainerRef)}>${e?.length>0?e:L`<div class=${x(m.message)}>${this.messages?.noLegend}</div>`}</div>`)}renderFilteredLayers(){return(this.legendvm?.activeLayerInfos?.toArray()).map(e=>this.renderLegendForLayer(e)).filter(e=>!!e)}renderLegendForLayer(e,n){if(!e.ready)return null;if(e.children.length){let s=e.children.map(h=>this.renderLegendForLayer(h,!0)).toArray();return L`<instant-apps-interactive-legend-group-legend-element class=${x(N(this.el))} .legendvm=${this.legendvm} .featureCount=${this.featureCount} .activeLayerInfo=${e} .isChild=${n}><div style=${k({paddingLeft:"20px"})} .id=${`${e?.layer?.id}-legend-layer`} slot=content>${s}</div></instant-apps-interactive-legend-group-legend-element>`}let l=e.legendElements;if(l&&!l.length)return null;let r=l.map((s,h)=>this.renderLegendForElement(s,e.layer,e.effectList,e,h)).filter(s=>!!s);return r.length?L`<instant-apps-interactive-legend-layer-element class=${x(N(this.el))} .legendvm=${this.legendvm} .featureCount=${this.featureCount} .activeLayerInfo=${e} .isChild=${!!n}><div slot=content .id=${`${e?.layer?.id}-legend-layer`} class=${x(m.layer)}>${r}</div></instant-apps-interactive-legend-layer-element>`:null}renderLegendForElement(e,n,l,r,s,h,u){let w=de(e),$=me(e),S=ye(e),E=null,_=Ne(r,e,s),T=Xe(e),M=Bt(this._legendContainerRef?.value?.clientWidth||this.el?.clientWidth);if(Ye(e)||S){let A=e.infos.some(q=>Ht(q,M)),B=e.infos.map((q,K)=>this.renderLegendForElementInfo(q,n,l,S,e,r,s,K,_,u)).filter(q=>!!q);B.length&&(E=L`<div class=${`${m.layerBody}${A?` ${m.layerBodyLargeSymbol}`:""}`}>${B}</div>`)}else if(de(e)||me(e)||Ee(e)||Re(e)){let A=e;E=this.renderLegendForRamp(A,n.opacity)}else if(T){let A=e;E=Q(Ke.RELATIONSHIP_RAMP,L`<instant-apps-interactive-legend-relationship class=${x(N(this.el))} .filterMode=${this.filterMode} .activeLayerInfo=${r} .legendElement=${A}></instant-apps-interactive-legend-relationship>`)}else if(Qe(e)){let A=e;E=this.renderPieChartRamp(A)}else if(Ze(e)){let A=e;E=this.renderUnivariateAboveAndBelowRamp(A,n.opacity,l)}else if(Oe(e)){let A=e;E=this.renderUnivariateColorSizeRamp(A,n.opacity,l)}if(!E)return null;let I=e.title,P=null;if(typeof I=="string")P=I;else if(I){let A=I,B=this.getTitle(A,w||$);this.isRendererTitle(w||$)?"title"in I&&(P=`${I.title} (${B})`):P=B}return L`<instant-apps-interactive-legend-legend-element class=${x(N(this.el))} .activeLayerInfo=${r} .isSizeRamp=${S} .isChild=${!!h} .isColorRamp=${w} .isRelationshipRamp=${T} .isInteractive=${_} .zoomTo=${this.zoomTo} .legendElement=${e} .titleText=${P} .legendvm=${this.legendvm} .legendElementIndex=${s}><div slot=content>${E}</div></instant-apps-interactive-legend-legend-element>`}renderPieChartRamp(e){return L`<div .innerHTML=${`${e.preview?.outerHTML}`}></div>`}renderUnivariateAboveAndBelowRamp(e,n,l){let{sizeRampElement:r,colorRampElement:s}=Jt(e,n);if(!r)return null;let h=Se(r,"above",!0),u=Se(r,"below",!0),w=12,$=ke(s,{width:w,height:h,rampAlignment:"vertical",opacity:n,type:"above",effectList:l}),S=ke(s,{width:w,height:u,rampAlignment:"vertical",opacity:n,type:"below",effectList:l}),E=ot(r),_=r.infos.map(H=>H.label),T=_.map((H,D)=>D===0?L`<div class=${x(H?$?m.univariateAboveAndBelowLabel:m.rampLabel:"")}>${H}</div>`:D===2?L`<div></div>`:null),M=_.length-1,I=Math.floor(_.length/2),P=_.map((H,D)=>D===I||D===M?L`<div class=${x(H?$?m.univariateAboveAndBelowLabel:m.rampLabel:"")}>${H}</div>`:null),A={display:"table-cell",verticalAlign:"middle"},B={marginTop:`${E}px`},q={height:`${h}px`},K={height:`${u}px`};return Q("univariate-above-and-below-ramp-preview",L`<div style=${k(ft)}><div class=${x(m.layerBody)}>${r.infos.map((H,D)=>L`<div class=${`${m.layerRow} ${m.sizeRamp}`}><div class=${x(m.symbol)} style=${k(A)} .innerHTML=${H?.preview?.outerHTML??""??""}></div>${!$&&D%2===0?L`<div class=${x(m.layerInfo)}>${_[D]}</div>`:null}</div>`)}</div>${$?Q("color-ramp-preview",L`<div style=${k(B)}><div style=${k(Ie)}><div style=${k(ae)}><div class=${x(m.rampContainer)}>${$}</div></div><div style=${k(ae)}><div class=${x(m.rampLabelsContainer)} style=${k(q)}>${T}</div></div></div><div style=${k(Ie)}><div style=${k(ae)}><div class=${x(m.rampContainer)}>${S}</div></div><div style=${k(ae)}><div class=${x(m.rampLabelsContainer)} style=${k(K)}>${P}</div></div></div></div>`):null}</div>`)}renderUnivariateColorSizeRamp(e,n,l){let{sizeRampElement:r,colorRampElement:s}=Kt(e);if(!r)return null;let h=ot(r),u=12,w=Se(r,"full",!1),$=ke(s,{width:u,height:w,rampAlignment:"vertical",opacity:n,type:"full",effectList:l}),S=r.infos.length-1,E=r.infos.map((I,P)=>P===0||P===S?L`<div class=${x(I.label?s?m.univariateAboveAndBelowLabel:m.rampLabel:"")}>${I.label}</div>`:null),_={display:"table-cell",verticalAlign:"middle"},T={marginTop:`${h}px`},M={height:`${w}px`};return Q("univariate-above-and-below-ramp-preview",L`<div style=${k(ft)}><div class=${x(m.layerBody)}>${r.infos.map(I=>L`<div class=${`${m.layerRow} ${m.sizeRamp}`}><div class=${x(m.symbol)} style=${k(_)} .innerHTML=${I?.preview?.outerHTML??""??""}></div></div>`)}</div>${Q("color-ramp-preview",L`<div style=${k(T)}><div style=${k(Ie)}><div style=${k(ae)}><div class=${x(m.rampContainer)}>${$}</div></div><div style=${k(ae)}><div class=${x(m.rampLabelsContainer)} style=${k(M)}>${E}</div></div></div></div>`)}</div>`)}renderLegendForRamp(e,n){let l=e.infos,r=me(e),s=Ee(e),h=Re(e),u=e.preview,w=r?m.opacityRamp:"";u&&(u.classList.add(m.colorRamp),w&&u.classList.add(w)),n!=null&&u&&(u.style.opacity=n.toString());let $=l.map(_=>{let T;if(s){let M=this.messages[_.label];T=typeof M=="string"?M:_.label}else h?T="value"in _?this.getStretchStopLabel(_):_.label:T=_.label;return L`<div class=${x(_.label?m.rampLabel:"")}>${T}</div>`}),S={width:`${Xt}px`},E={height:u?.style?.height};return L`<div class=${x(m.layerRow)}><div class=${x(m.symbolContainer)} style=${k({...S})}><div class=${x(m.rampContainer)} ${xe(_=>{_?.firstChild&&_?.firstChild?.remove(),_?.appendChild(u)})}></div></div><div class=${x(m.layerInfo)}><div class=${x(m.rampLabelsContainer)} style=${k({...E})}>${$}</div></div></div>`}renderLegendForElementInfo(e,n,l,r,s,h,u,w,$,S){if("infos"in e)return this.renderLegendForElement(e,n,l,h,u,!0,e);let E=null,_=!this.isImageryStretchedLegend(n,s.type);if("preview"in e){let{outerHTML:W}=e.preview;E=L`<div class=${x(m.symbol)} .innerHTML=${W??""}></div>`}else"src"in e&&(E=this.renderImage(e,n,_));if(!E)return null;let T=_?` ${m.imageryLayerInfoStretched}`:"",M=!_&&r?` ${m.sizeRamp}`:"",I,P=Je(n),A=tt(P,S);if(j.data){let W=et(P,n,e,A,w),V=A?A?.nestedInfos:P,se=je(V),_e=!!h?.children?.length||!!A;I=P?.categories?.size===1&&!_e?!W?.selected:se||W?.selected}let B="label"in e?e.label:null,q=A&&!("value"in e)?!1:$,K=J.get("compact"),H=this.getTitle(B,!1)||"",D=A?s.title:B??n?.id;return q?L`<button @click=${this.applyFilter(e,n,w,S)} class=${`${m.layerRow} ${m.interactiveLayerRow}${I?` ${m.infoSelected}`:""}`} title=${(K?`${H}`:void 0)??pe} .ariaPressed=${I?"true":"false"}><div class=${`${m.symbolContainer}${T}${M}`}>${E}</div><div class=${`${m.layerInfo}${T}`}>${this.getTitle(B,!1)||""}</div>${this.featureCount&&!K?L`<instant-apps-interactive-legend-count class=${x(N(this.el))} .categoryId=${D} .activeLayerInfo=${h} .legendvm=${this.legendvm} .selected=${!!I} .legendElement=${s} .infoIndex=${w}></instant-apps-interactive-legend-count>`:null}</button>`:L`<div class=${x(m.layerRow)}><div class=${`${m.symbolContainer}${T}${M}`}>${E}</div><div class=${`${m.layerInfo}${T}`}>${H}</div></div>`}renderImage(e,n,l){let{label:r,src:s,opacity:h}=e,u=l?` ${m.imageryLayerStretchedImage}`:"",w=l?"":` ${m.symbol}`,$={opacity:`${h??n.opacity}`};return L`<img alt=${this.getTitle(r,!1)??pe} src=${s??pe} width=${e.width} height=${e.height} class=${`$${u}${w}`} style=${k($)}>`}};We("instant-apps-interactive-legend-classic",Te);return Te},"layers/support/FeatureFilter","layers/support/FeatureEffect","symbols/support/symbolUtils","core/reactiveUtils","intl","core/Handles",a,b,c,d,e)
2
+ import e from"./KGUELU4O.js";import d from"./3W7ANZME.js";import{a as Ne}from"./CJ3EZE7U.js";import c from"./SHQFXQEI.js";import{d as je}from"./C5KDPY7R.js";import{a as Ke,b as de,c as Ee,d as me,e as Qe,f as Xe,g as ye,h as Re,i as Ye,j as Ze,k as Oe}from"./YM4U4HSN.js";import{a as Ce,b as Ge,c as ue}from"./TCUNTTNI.js";import{a as N}from"./IADXB53D.js";import b from"./QZ2ZMWIH.js";import a from"./CS5N3DOL.js";import{a as Q}from"./YUWXPLTE.js";import{b as We}from"./MXPZF4RB.js";import"./Y2AUIXNK.js";import{F as Ue,G as xe,H as qe,J as x,K as k,h as Be,i as L,j as Le,l as pe,u as De}from"./T3EPRHTT.js";import"./EXBEKVP5.js";export default $arcgis.t(([ct,vt,pt,U,fe,At,,{a:j,b:J,c:Je,d:he},{a:be,b:Ve,d:et,f:tt,g:we,h:it,i:nt,j:at},{a:rt,b:Ae,c:st,g:lt},oe])=>{(function(d,e){typeof exports=="object"&&typeof module<"u"?e(exports):typeof define=="function"&&define.amd?define(["exports"],e):(d=typeof globalThis<"u"?globalThis:d||self,e(d.maquette={}))})(void 0,(function(d){"use strict";var e=function(){var t,i;return{invalidate:function(){i=void 0,t=void 0},result:function(a,c){if(t)for(var p=0;p<a.length;p++)t[p]!==a[p]&&(i=void 0);return i||(i=c(),t=a),i}}},n="http://www.w3.org/",l="".concat(n,"2000/svg"),r="".concat(n,"1999/xlink"),s=[],h=function(t,i){var a={};return Object.keys(t).forEach(function(c){a[c]=t[c]}),i&&Object.keys(i).forEach(function(c){a[c]=i[c]}),a},u=function(t,i){return t.vnodeSelector!==i.vnodeSelector?!1:t.properties&&i.properties?t.properties.key!==i.properties.key?!1:t.properties.bind===i.properties.bind:!t.properties&&!i.properties},w=function(t){if(typeof t!="string")throw new Error("Style values must be strings")},$=function(t,i,a){if(i.vnodeSelector!==""){for(var c=a;c<t.length;c++)if(u(t[c],i))return c}return-1},S=function(t,i,a,c){var p=t[i];if(p.vnodeSelector!==""){var o=p.properties,C=o?o.key===void 0?o.bind:o.key:void 0;if(!C){for(var g=0;g<t.length;g++)if(g!==i){var f=t[g];if(u(f,p))throw Object.assign(new Error("".concat(a.vnodeSelector," had a ").concat(p.vnodeSelector," child ").concat(c==="added"?c:"removed",", but there is now more than one. You must add unique key properties to make them distinguishable.")),{parentNode:a,childNode:p})}}}},E=function(t){if(t.properties){var i=t.properties.enterAnimation;i&&i(t.domNode,t.properties)}},_=[],T=!1,M=function(t){(t.children||[]).forEach(M),t.properties&&t.properties.afterRemoved&&t.properties.afterRemoved.apply(t.properties.bind||t.properties,[t.domNode])},I=function(){T=!1,_.forEach(M),_.length=0},P=function(t){_.push(t),T||(T=!0,typeof window<"u"&&"requestIdleCallback"in window?window.requestIdleCallback(I,{timeout:16}):setTimeout(I,16))},A=function(t){var i=t.domNode;if(t.properties){var a=t.properties.exitAnimation;if(a){i.style.pointerEvents="none";var c=function(){i.parentNode&&(i.parentNode.removeChild(i),P(t))};a(i,c,t.properties);return}}i.parentNode&&(i.parentNode.removeChild(i),P(t))},B=["on","afterCreate","afterUpdate","afterRemoved","enterAnimation","exitAnimation","updateAnimation"];function q(t){return!B.includes(t)}var K=function(t,i,a){if(i){for(var c=a.eventHandlerInterceptor,p=Object.keys(i).filter(q),o=p.length,C=0;C<o;C++){var g=p[C],f=i[g];if(g==="className")throw new Error('Property "className" is not supported, use "class".');if(g==="class")se(t,f,!0);else if(g==="classes")for(var v=Object.keys(f),R=v.length,b=0;b<R;b++){var y=v[b];f[y]&&t.classList.add(y)}else if(g==="styles")for(var z=Object.keys(f),F=z.length,b=0;b<F;b++){var G=z[b],te=f[G];te&&(w(te),a.styleApplyer(t,G,te))}else if(g!=="key"&&f!==null&&f!==void 0){var ve=typeof f;ve==="function"?(g.lastIndexOf("on",0)===0&&c&&(f=c(g,f,t,i)),t[g]=f):a.namespace===l?g==="href"?t.setAttributeNS(r,g,f):t.setAttribute(g,f):ve==="string"&&g!=="value"&&g!=="innerHTML"?t.setAttribute(g,f):t[g]=f}}if(i.on)for(var ie=0,ge=Object.entries(i.on);ie<ge.length;ie++){var Y=ge[ie],Z=Y[0],O=Y[1],ne=typeof O=="function"?O:O.listener;c&&(ne=c(Z,ne,t,i)),ne&&t.addEventListener(Z,ne,typeof O=="function"?void 0:O.options)}}},H=function(t,i,a){if(i)for(var c=0,p=i;c<p.length;c++){var o=p[c];W(o,t,void 0,a)}},D=function(t,i,a){H(t,i.children,a),i.text&&(t.textContent=i.text),K(t,i.properties,a),i.properties&&i.properties.afterCreate&&i.properties.afterCreate.apply(i.properties.bind||i.properties,[t,a,i.vnodeSelector,i.properties,i.children])},W=function(t,i,a,c){var p,o,C=0,g=t.vnodeSelector,f=i.ownerDocument;if(g==="")t.domNode?t.domNode.nodeValue=t.text:(o=t.domNode=f.createTextNode(t.text),a!==void 0?i.insertBefore(o,a):i.appendChild(o));else{for(var v=0;v<=g.length;++v){var R=g.charAt(v);if(v===g.length||R==="."||R==="#"){var b=g.charAt(C-1),y=g.slice(C,v);b==="."?o.classList.add(y):b==="#"?o.id=y:(y==="svg"&&(c=h(c,{namespace:l})),c.namespace!==void 0?o=t.domNode=f.createElementNS(c.namespace,y):(o=t.domNode=t.domNode||(!((p=t.properties)===null||p===void 0)&&p.is?f.createElement(y,{is:t.properties.is}):f.createElement(y)),y==="input"&&t.properties&&t.properties.type!==void 0&&o.setAttribute("type",t.properties.type)),a!==void 0?i.insertBefore(o,a):o.parentNode!==i&&i.appendChild(o)),C=v+1}}D(o,t,c)}},V,se=function(t,i,a){i&&i.split(" ").forEach(function(c){c&&t.classList.toggle(c,a)})},_e=function(t,i,a,c){if(a){for(var p=!1,o=Object.keys(a).filter(q),C=o.length,g=0;g<C;g++){var f=o[g],v=a[f],R=i[f];if(f==="class")R!==v&&(se(t,R,!1),se(t,v,!0));else if(f==="classes")for(var b=t.classList,y=Object.keys(v),z=y.length,F=0;F<z;F++){var G=y[F],te=!!v[G],ve=!!R[G];te!==ve&&(p=!0,te?b.add(G):b.remove(G))}else if(f==="styles")for(var ie=Object.keys(v),ge=ie.length,F=0;F<ge;F++){var Y=ie[F],Z=v[Y],O=R[Y];Z!==O&&(p=!0,Z?(w(Z),c.styleApplyer(t,Y,Z)):c.styleApplyer(t,Y,""))}else if(!v&&typeof R=="string"&&(v=""),f==="value"){var ne=t[f];ne!==v&&v!==R&&(t[f]=v),v!==R&&(p=!0)}else if(v!==R){var He=typeof v;(He!=="function"||!c.eventHandlerInterceptor)&&(c.namespace===l?f==="href"?t.setAttributeNS(r,f,v):t.setAttribute(f,v):He==="string"&&f!=="innerHTML"?f==="role"&&v===""?t.removeAttribute(f):t.setAttribute(f,v):t[f]!==v&&(t[f]=v),p=!0)}}return p}},bt=function(t,i,a,c,p){if(a===c)return!1;a=a||s,c=c||s;for(var o=a.length,C=c.length,g=0,f=0,v,R=!1;f<C;){var b=g<o?a[g]:void 0,y=c[f];if(b!==void 0&&u(b,y))R=V(b,y,p,i,a)||R,g++;else{var z=$(a,y,g+1);if(z>=0){for(v=g;v<z;v++)A(a[v]),S(a,v,t,"removed");R=V(a[z],y,p,i,a)||R,g=z+1}else W(y,i,g<o?a[g].domNode:void 0,p),E(y),S(c,f,t,"added")}f++}if(o>g)for(v=g;v<o;v++)A(a[v]),S(a,v,t,"removed");return R};V=function(t,i,a,c,p){var o=t.domNode,C=!1;if(t===i)return!1;var g=!1;if(i.vnodeSelector===""){if(i.text!==t.text){var f=o.ownerDocument.createTextNode(i.text);try{c.replaceChild(f,o)}catch{c.replaceChild(f,c.childNodes[p.indexOf(t)])}return i.domNode=f,C=!0,C}i.domNode=o}else i.vnodeSelector.lastIndexOf("svg",0)===0&&(a=h(a,{namespace:l})),t.text!==i.text&&(g=!0,i.text===void 0?o.removeChild(o.firstChild):o.textContent=i.text),i.domNode=o,g=bt(i,o,t.children,i.children,a)||g,g=_e(o,t.properties,i.properties,a)||g,i.properties&&i.properties.afterUpdate&&i.properties.afterUpdate.apply(i.properties.bind||i.properties,[o,a,i.vnodeSelector,i.properties,i.children]);return g&&i.properties&&i.properties.updateAnimation&&i.properties.updateAnimation(o,i.properties,t.properties),C};var le=function(t,i){return{getLastRender:function(){return t},update:function(a){if(t.vnodeSelector!==a.vnodeSelector)throw new Error("The selector for the root VNode may not be changed. (consider using dom.merge and add one extra level to the virtual DOM)");var c=t;t=a,V(c,a,i,c.domNode.parentNode,[c])},domNode:t.domNode}},wt={namespace:void 0,performanceLogger:function(){},eventHandlerInterceptor:void 0,styleApplyer:function(t,i,a){i.charAt(0)==="-"?t.style.setProperty(i,a):t.style[i]=a}},ee=function(t){return h(wt,t)},ce={create:function(t,i){return i=ee(i),W(t,document.createElement("div"),void 0,i),le(t,i)},append:function(t,i,a){return a=ee(a),W(i,t,void 0,a),le(i,a)},insertBefore:function(t,i,a){return a=ee(a),W(i,t.parentNode,t,a),le(i,a)},merge:function(t,i,a){return a=ee(a),i.domNode=t,D(t,i,a),le(i,a)},replace:function(t,i,a){return a=ee(a),W(i,t.parentNode,t,a),t.parentNode.removeChild(t),le(i,a)}},$t=function(t){return{vnodeSelector:"",properties:void 0,children:void 0,text:t.toString(),domNode:null}},Me=function(t,i,a){for(var c=0,p=i.length;c<p;c++){var o=i[c];Array.isArray(o)?Me(t,o,a):o!=null&&o!==!1&&(typeof o=="string"&&(o=$t(o)),a.push(o))}};function _t(t,i,a){if(Array.isArray(i))a=i,i=void 0;else if(i&&(typeof i=="string"||i.vnodeSelector)||a&&(typeof a=="string"||a.vnodeSelector))throw new Error("h called with invalid arguments");var c,p;return a&&a.length===1&&typeof a[0]=="string"?c=a[0]:a&&(p=[],Me(t,a,p),p.length===0&&(p=void 0)),{vnodeSelector:t,properties:i,children:p,text:c===""?void 0:c,domNode:null}}var Lt=function(t,i,a){var c=[],p=[];return{results:p,map:function(o){for(var C=o.map(t),g=p.slice(),f=0,v=0;v<o.length;v++){var R=o[v],b=C[v];if(b===c[f])p[v]=g[f],a(R,g[f],v),f++;else{for(var y=!1,z=1;z<c.length+1;z++){var F=(f+z)%c.length;if(c[F]===b){p[v]=g[F],a(o[v],g[F],v),f=F+1,y=!0;break}}y||(p[v]=i(R,v))}}p.length=o.length,c=C}}},xt=function(t,i){for(var a=[];t&&t!==i;)a.push(t),t=t.parentNode;return a},Ct=function(t,i){var a=t;return i.forEach(function(c){a=a&&a.children?a.children.find(function(p){return p.domNode===c}):void 0}),a},Et=function(t,i,a){return function(p,o,C,g){return c};function c(p){var o,C;a("domEvent",p);var g=i(),f=xt(p.currentTarget,g.domNode);f.reverse();var v=Ct(g.getLastRender(),f);t.scheduleRender();var R;if(v){var b=(C=(o=v.properties["on".concat(p.type)])!==null&&o!==void 0?o:v.properties.on[p.type].listener)!==null&&C!==void 0?C:v.properties.on[p.type];R=b.apply(v.properties.bind||this,arguments)}return a("domEventProcessed",p),R}},Rt=function(t){var i,a=ee(t),c=a.performanceLogger,p=!0,o,C=!1,g=[],f=[],v=function(b,y,z){var F,G=function(){return F};a.eventHandlerInterceptor=Et(i,G,c),F=b(y,z(),a),g.push(F),f.push(z)},R=function(){if(o=void 0,!!p){p=!1,c("renderStart",void 0);for(var b=0;b<g.length;b++){var y=f[b]();c("rendered",void 0),g[b].update(y),c("patched",void 0)}c("renderDone",void 0),p=!0}};return i={renderNow:R,scheduleRender:function(){!o&&!C&&(o=requestAnimationFrame(R))},stop:function(){o&&(cancelAnimationFrame(o),o=void 0),C=!0},resume:function(){C=!1,p=!0,i.scheduleRender()},append:function(b,y){v(ce.append,b,y)},insertBefore:function(b,y){v(ce.insertBefore,b,y)},merge:function(b,y){v(ce.merge,b,y)},replace:function(b,y){v(ce.replace,b,y)},detach:function(b){for(var y=0;y<f.length;y++)if(f[y]===b)return f.splice(y,1),g.splice(y,1)[0];throw new Error("renderFunction was not found")}},i};d.createCache=e,d.createMapping=Lt,d.createProjector=Rt,d.dom=ce,d.h=_t}));function kt(d,e,n,l){let r=st(d,e,n,l),s=St(r);return r.join(s)}function St(d){return d.every(e=>e&&e.includes(rt.NOT_EQUAL))?Ae.AND:Ae.OR}async function dt(d,e,n,l,r){let{fLayerView:s}=d,h=kt(d,e,n,r),u=s?.filter?.timeExtent??s?.featureEffect?.filter?.timeExtent??null,{type:w}=l;if(ue(w))s.filter=new ct({where:h,timeExtent:u});else if(l.effect){let{includedEffect:$,excludedEffect:S}=l.effect,E=await oe(S,s,"excludedEffect"),_=await oe($,s,"includedEffect");s.featureEffect=new vt({filter:new ct({where:h,timeExtent:u}),includedEffect:_,excludedEffect:E})}return await Promise.resolve()}function It(d,e){let{type:n}=d;ue(n)?Tt(e):Ge(n)&&Ft(d,e)}function Tt(d){d?.allLayerViews?.filter(e=>be(e?.layer?.type))?.forEach(e=>{let n=e,l=ut(n);n.filter=l,n.set("featureEffect",null)})}function Ft(d,e){e?.allLayerViews?.filter(n=>be(n?.layer?.type)).forEach(async n=>{let l=n;if(d?.effect&&l){let{includedEffect:r,excludedEffect:s}=d.effect,h=await oe(s,l,"excludedEffect"),u=await oe(r,l,"includedEffect"),w=ut(l);l.featureEffect=new vt({filter:w,includedEffect:u,excludedEffect:h}),l.set(Ce.FILTER,null)}})}function ut(d){return d?.filter||d?.featureEffect?.filter}var Pt=80,zt=.2,Mt=6;function X(d){let e=typeof d=="number"?d:Number(d);return Number.isFinite(e)?e:0}function ht(d){if("infos"in d)return Math.max(...d.infos.map(e=>ht(e)),0);if("preview"in d&&d.preview){let e=d.preview,n=e.querySelector("svg"),l=X(n?.getAttribute("width")),r=X(n?.getAttribute("height")),s=X(e.style.width?.replace("px","")),h=X(e.style.height?.replace("px","")),u=X(e.clientWidth),w=X(e.clientHeight);return Math.max(l,r,s,h,u,w)}return"src"in d?Math.max(X(d.width),X(d.height)):0}function Ht(d,e){let n=ht(d);return n>=Pt?!0:typeof e!="number"||e<=0?!1:n+Mt>=e}function Bt(d){if(!(d<=0))return d*zt}var Dt=(void 0)(),mt=10,Fe=20,$e=10,Pe=20,ze={univariateAboveAndBelowSymbol:"esri-univariate-above-and-below-ramp__symbol",colorRamp:"esri-legend__color-ramp"};function Ut(d="vertical"){let e={stroke:"rgb(200, 200, 200)",strokeWidth:"1"};return d==="vertical"?L`<svg height=4 width=10>${Le`<line x1=0 y1=2 x2=10 y2=2 style=${k(e)} />`}</svg>`:L`<svg height=10 width=10>${Le`<line x1=5 y1=0 x2=5 y2=10 style=${k(e)} />`}</svg>`}function qt(d,e="vertical"){let n=document.createElement("div");return n.style.height=`${Fe}px`,n.className=ze.univariateAboveAndBelowSymbol,d!=null&&(n.style.opacity=d.toString()),Dt.append(n,Ut.bind(null,e)),n}function yt(d,e,n="vertical",l){d.infos.forEach((r,s)=>{if(l&&s===2)r.preview=qt(e,n);else{let{size:h}=r,u=re(h)+(n==="horizontal"?Pe:$e),w=r.preview.tagName.toLowerCase()==="div",$=w?r.preview:document.createElement("div");$&&($.className=ze.univariateAboveAndBelowSymbol),n==="horizontal"?$&&($.style.width=`${u}px`):$&&($.style.height=`${u}px`),w||$&&$.appendChild(r.preview),r.preview=$}})}var Wt=96;function re(d){return d?d/72*Wt:0}function ot(d,e="classic"){let n=d.infos,l=n[0].size,r=n[n.length-1].size;return e==="classic"?(re(l)+$e)/2:(re(l)-re(r))/2}function ke(d,e){if(!d)return null;let n=d.infos.map(r=>r.color),l=pt.renderColorRampPreviewHTML(e.type==="full"?n:e.type==="above"?n.slice(0,3):n.slice(2,5),{width:e.width,height:e.height,align:e.rampAlignment,effectList:e.effectList});return l.className=ze.colorRamp,e.opacity!=null&&(l.style.opacity=e.opacity.toString()),l}function Gt(d,e,n,l="vertical"){let r=0,s=d.infos,h=Math.floor(s.length/2),u=e==="full"||e==="above"?0:h,w=e==="full"||e==="below"?s.length-1:h;for(let $=u;$<=w;$++)if(n&&$===h)r+=l==="horizontal"?mt:Fe;else{let S=s[$].size,E=re(S)+(l==="horizontal"?Pe:$e);r+=E}return Math.round(r)}function Se(d,e,n,l="vertical"){let r=Gt(d,e,n,l),s=d.infos,h=Math.floor(s.length/2),u=e==="full"||e==="above"?0:h,w=e==="full"||e==="below"?s.length-1:h,$=e==="full"?s[u].size+s[w].size:e==="above"?s[u].size:s[w].size,S=n?l==="vertical"?Fe:mt:0,E=l==="vertical"?$e*(e==="full"?2:1):Pe*(e==="full"?2:1);return Math.round(r-(re($)/2+S/2+E/2))}function Jt(d,e,n="vertical"){let l=d.infos,r=l.find(h=>ye(h)),s=l.find(h=>de(h));return r&&(r={...r},r.infos=[...r.infos],yt(r,e,n,!0)),s&&(s={...s},s.infos=[...s.infos]),n==="horizontal"&&(r?.infos.reverse(),s?.infos.reverse()),{sizeRampElement:r,colorRampElement:s}}function Kt(d,e="vertical"){let n=d.infos,l=n.find(s=>ye(s)),r=n.find(s=>de(s));return l&&(l={...l},l.infos=[...l.infos],yt(l,null,e,!1)),r&&(r={...r},r.infos=[...r.infos]),e==="horizontal"&&(l?.infos.reverse(),r?.infos.reverse()),{sizeRampElement:l,colorRampElement:r}}var Qt=Be`@layer{instant-apps-interactive-legend-classic{display:block;--instant-apps-interactive-legend-heading-font-size: 1rem;--instant-apps-interactive-legend-heading-font-weight: normal;--instant-apps-interactive-legend-caption-font-weight: normal;--instant-apps-interactive-legend-secondary-color: var( --calcite-color-text-1 );--instant-apps-interactive-legend-field-name-font-size: 1rem;--instant-apps-interactive-legend-total-feature-count-font-size: .875rem;--instant-apps-interactive-legend-info-font-size: .875rem;--instant-apps-interactive-legend-info-item-background--selected: #c7ebff;--instant-apps-interactive-legend-info-item-background--selected--dark: #009af2;--instant-apps-interactive-legend-info-item-background--hover: #e9e9e9;--instant-apps-interactive-legend-info-item-background--hover--dark: #4a4a4a;--instant-apps-interactive-legend-info-item-color--selected: var( --calcite-color-text-2 );--instant-apps-interactive-legend-secondary-background-color: var( --calcite-color-background );--instant-apps-interactive-legend-ui-margin: 20px 15px;--instant-apps-interactive-legend-ui-padding: 20px 15px}instant-apps-interactive-legend-classic .esri-legend__service{padding:0}instant-apps-interactive-legend-classic .esri-legend__layer-body,instant-apps-interactive-legend-classic .esri-legend__layer,instant-apps-interactive-legend-classic .esri-legend__layer-table,instant-apps-interactive-legend-classic .esri-legend__group-layer-child,instant-apps-interactive-legend-classic .esri-legend__layer-child-table{margin:0;overflow:hidden}instant-apps-interactive-legend-classic .esri-legend__layer-caption calcite-action{margin-right:5px}instant-apps-interactive-legend-classic .esri-legend__layer-caption{display:flex;align-items:center;font-size:var(--instant-apps-interactive-legend-field-name-font-size);background-color:var(--instant-apps-interactive-legend-secondary-background-color);color:var(--instant-apps-interactive-legend-secondary-color)}instant-apps-interactive-legend-classic .instant-apps-interactive-legend__layer-caption-btn-container{white-space:nowrap}instant-apps-interactive-legend-classic .instant-apps-interactive-legend__layer-caption-btn-container calcite-button{margin:2px}instant-apps-interactive-legend-classic .esri-legend__layer-caption{font-weight:var(--instant-apps-interactive-legend-caption-font-weight)}instant-apps-interactive-legend-classic .esri-legend__layer-cell.esri-legend__layer-cell--info{font-size:var(--instant-apps-interactive-legend-info-font-size);text-align:left}instant-apps-interactive-legend-classic .esri-legend__layer-cell,instant-apps-interactive-legend-classic .esri-legend__layer-row{display:flex;align-items:center}instant-apps-interactive-legend-classic .instant-apps-interactive-legend__non-interactive .esri-legend__layer-body{display:block;margin:var(--instant-apps-interactive-legend-ui-margin)}instant-apps-interactive-legend-classic .instant-apps-interactive-legend__non-interactive.instant-apps-interactive-legend__nested-unique-symbol>.esri-legend__layer-body{margin:0}instant-apps-interactive-legend-classic .instant-apps-interactive-legend__non-interactive .esri-legend__layer-row{display:table-row}instant-apps-interactive-legend-classic .instant-apps-interactive-legend__non-interactive .esri-legend__layer-cell{display:table-cell}instant-apps-interactive-legend-classic .esri-legend__layer-cell--symbols{justify-content:center;width:20%}instant-apps-interactive-legend-classic .esri-legend__layer-cell--info{width:65%}instant-apps-interactive-legend-classic .instant-apps-interactive-legend__layer-row--interactive{margin:1px;background:transparent;border:none;width:100%}instant-apps-interactive-legend-classic .esri-legend__layer-body.instant-apps-interactive-legend__layer-body--large-symbol>.esri-legend__layer-row{display:grid;grid-template-columns:minmax(35%,max-content) minmax(0,1fr);column-gap:clamp(.125rem,.3vw,.25rem);align-items:center;width:100%}instant-apps-interactive-legend-classic .esri-legend__layer-body.instant-apps-interactive-legend__layer-body--large-symbol>.esri-legend__layer-row>.esri-legend__layer-cell--symbols{width:35%;box-sizing:border-box;padding-inline:clamp(.125rem,.3vw,.25rem);display:flex;align-items:center;justify-content:center}instant-apps-interactive-legend-classic .esri-legend__layer-body.instant-apps-interactive-legend__layer-body--large-symbol>.esri-legend__layer-row>.esri-legend__layer-cell--info{display:block;width:auto;min-width:0}instant-apps-interactive-legend-classic .esri-legend__layer-cell--info{color:var(--instant-apps-interactive-legend-secondary-color)}instant-apps-interactive-legend-classic .esri-legend__layer-row,instant-apps-interactive-legend-classic .esri-legend__layer-caption{padding:var(--instant-apps-interactive-legend-ui-padding)}instant-apps-interactive-legend-classic .instant-apps-interactive-legend__layer-row--interactive{position:relative}instant-apps-interactive-legend-classic .instant-apps-interactive-legend-element-info--selected{background-color:var(--instant-apps-interactive-legend-info-item-background--selected)}instant-apps-interactive-legend-classic .calcite-mode-dark .instant-apps-interactive-legend-element-info--selected{cursor:pointer;background-color:var(--instant-apps-interactive-legend-info-item-background--selected--dark)}instant-apps-interactive-legend-classic .calcite-mode-dark .instant-apps-interactive-legend-element-info--selected .esri-legend__layer-cell--info{color:var(--calcite-color-text-inverse)}instant-apps-interactive-legend-classic .hide{display:none}.instant-apps-interactive-legend__compact .esri-legend__layer-row{--instant-apps-interactive-legend-ui-padding: 10px 5px}.instant-apps-interactive-legend__compact .esri-legend__layer-row .esri-legend__layer-cell--info:not(:has(.esri-legend__ramp-labels)){display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2;overflow:hidden;text-overflow:ellipsis;line-clamp:2;line-height:1.3125rem;max-height:2.625rem}@media(min-width:992px){instant-apps-interactive-legend-classic .instant-apps-interactive-legend__layer-row--interactive{cursor:pointer}instant-apps-interactive-legend-classic .instant-apps-interactive-legend__layer-row--interactive:hover{background-color:var(--instant-apps-interactive-legend-info-item-background--hover)}instant-apps-interactive-legend-classic .instant-apps-interactive-legend__layer-row--interactive:hover.instant-apps-interactive-legend-element-info--selected{background-color:#e2f2fe}instant-apps-interactive-legend-classic .calcite-mode-dark .instant-apps-interactive-legend__layer-row--interactive:hover{background-color:var(--instant-apps-interactive-legend-info-item-background--hover--dark)}instant-apps-interactive-legend-classic .calcite-mode-dark .instant-apps-interactive-legend__layer-row--interactive:hover.instant-apps-interactive-legend-element-info--selected{background-color:#26a9f4}}}`,m={layer:"esri-legend__layer",layerBody:"esri-legend__layer-body",layerRow:"esri-legend__layer-row",layerInfo:"esri-legend__layer-cell esri-legend__layer-cell--info",imageryLayerStretchedImage:"esri-legend__imagery-layer-image--stretched",imageryLayerInfoStretched:"esri-legend__imagery-layer-info--stretched",symbolContainer:"esri-legend__layer-cell esri-legend__layer-cell--symbols",symbol:"esri-legend__symbol",rampContainer:"esri-legend__ramps",sizeRamp:"esri-legend__size-ramp",colorRamp:"esri-legend__color-ramp",opacityRamp:"esri-legend__opacity-ramp",rampLabelsContainer:"esri-legend__ramp-labels",rampLabel:"esri-legend__ramp-label",univariateAboveAndBelowLabel:"esri-univariate-above-and-below-ramp__label",message:"esri-legend__message",layerBodyLargeSymbol:"instant-apps-interactive-legend__layer-body--large-symbol",interactiveLayerRow:"instant-apps-interactive-legend__layer-row--interactive",infoSelected:"instant-apps-interactive-legend-element-info--selected",compact:"instant-apps-interactive-legend__compact"},Xt=24,ft={display:"flex",alignItems:"flex-start"},Ie={marginLeft:"3px"},ae={display:"table-cell",verticalAlign:"middle"},Te=class extends qe{constructor(){super(...arguments),this.featureCountRequestId=0,this._legendContainerRef=Ue(),this._hiddenLegendState={},this._pendingRestore={},this._restoreTimeouts={},this.isLoading=!0,this.zoomTo=!1,this.featureCount=!1,this.filterMode={type:Ce.FILTER}}static{this.properties={isLoading:16,legendvm:0,zoomTo:5,featureCount:5,filterMode:0,messages:0}}static{this.styles=Qt}static{this.shadowRootOptions=De}connectedCallback(){super.connectedCallback(),!this.handles&&(this.handles=new At)}async load(){new MutationObserver(()=>{this.requestUpdate()}).observe(this.el,{attributes:!0}),J.onChange("data",()=>this.requestUpdate())}willUpdate(e){e.has("filterMode")&&this.legendvm?.view&&(this.hasUpdated||!ue(this.filterMode.type))&&It(this.filterMode,this.legendvm.view),e.has("featureCount")&&e.get("featureCount")===!1&&this.featureCount&&this.legendvm&&this.refreshFeatureCount().catch(n=>{console.error(n)})}async loaded(){await this.initLegend()}disconnectedCallback(){super.disconnectedCallback(),this.handles?.removeAll(),this.handles?.destroy(),this.handles=null}async initLegend(){try{await U.whenOnce(()=>this.legendvm?.view);let e=async()=>{try{let n=this.legendvm?.view?.map;await n?.load(),await n?.basemap?.load();let l=n?.allLayers?.map(async u=>await u.load()),r=(await Promise.allSettled(l)).map(u=>u?.status==="fulfilled"&&u?.value?u.value:null).filter(u=>!!u),s=[];r.forEach(u=>{this.legendvm?.view&&s.push(this.legendvm.view.whenLayerView(u))}),await Promise.allSettled(s),await Promise.race([U.whenOnce(()=>(this.legendvm?.activeLayerInfos?.length??0)>0),new Promise(u=>{setTimeout(u,250)})]);let h=await we(this.legendvm);Object.keys(h).length===0&&(await new Promise(u=>{setTimeout(u,250)}),h=await we(this.legendvm)),J.set("data",{...j.data,...h}),await this.refreshFeatureCount(),this.isLoading=!1,await this.setupWatchersAndListeners()}catch(n){console.error(n),this.isLoading=!1}};this.legendvm?.view?.when(e),this.legendvm?.view?.map?.layers?.on("after-changes",e)}catch{this.isLoading=!1}}getStretchStopLabel(e){let n=this.messages[e.label];return e.label?`${n}: ${typeof e.value=="string"?e.value:fe.formatNumber(e.value,{style:"decimal",notation:e.value.toString().includes("e")?"scientific":"standard"})}`:""}getTitle(e,n){if(!e)return;if(typeof e=="string"||typeof e=="number")return e;if("value"in e||"unit"in e){let s=typeof this.messages?.dotValue=="string"?this.messages.dotValue:"";return fe.substitute(s,e)}if("colorName"in e||"bandName"in e){let{colorName:s,bandName:h}=e,u=this.messages[s],w=typeof this.messages[h]=="string"?this.messages[h]:h;return`${u}: ${w}`}if("showCount"in e)return e.showCount?this.messages.clusterCountTitle:null;let l=null;if(n){let s=e;l=s.ratioPercentTotal?"showRatioPercentTotal":s.ratioPercent?"showRatioPercent":s.ratio?"showRatio":e.normField?"showNormField":e.field?"showField":null}else if(this.isRendererTitle(n)){let s=e;l=s.normField?"showNormField":s.normByPct?"showNormPct":s.field?"showField":null}let r=l==="showField"?"{field}":typeof l=="string"?this.messages[l]:"";return l?fe.substitute(r,{field:e.field,normField:e.normField}):""}isRendererTitle(e){return!e}async setupWatchersAndListeners(){let e=this.legendvm?.view?.map?.allLayers?.filter(r=>be(r?.type)),n=[];for(let r of e)this.legendvm?.view&&n.push(this.legendvm?.view?.whenLayerView(r));let l=[];try{l=await Promise.all(n)}catch(r){console.error(r)}for(let r of l){let s=`fLayerViewScale-${r.layer.id}`;!this.handles?.has(s)&&r&&this.handles?.add(r.watch("visibleAtCurrentScale",()=>{this.createDataForLayer(r.layer).catch(h=>{console.error(h)})}),s)}e?.forEach(r=>{let s=`fLayer-${r?.id}`;this.handles?.has(s)||this.handles?.add(U?.watch(()=>r?.visible,()=>this.handleFeatureLayerVisibilityChange(r)),s)}),this.handles?.add(U.when(()=>this.legendvm,()=>{U.watch(()=>this.legendvm?.view?.updating,()=>{this.legendvm?.view?.updating&&U.when(()=>!this.legendvm?.view?.updating,()=>{this.refreshFeatureCount().catch(r=>{console.error(r)})},{once:!0,initial:!0})},{initial:!0})},{initial:!0,once:!0})),this.handles?.add(U.on(()=>this.legendvm?.activeLayerInfos,"change",r=>{this.regenerateData().then(()=>{this.handles?.add(U.on(()=>r.children,"change",()=>{this.regenerateData().catch(s=>{console.error(s)})}))}).catch(s=>{console.error(s)})})),this.handles?.add(U.on(()=>this.legendvm?.view?.map?.layers,"after-changes",()=>{this.refreshFeatureCount().catch(r=>{console.error(r)})}))}async createDataForLayer(e){let n=e?.id;if(nt(n,this._pendingRestore,this._hiddenLegendState))return;let l=J.get("data")?.[n],r=it(this.legendvm?.activeLayerInfos)?.find(s=>s?.layer?.id===n);if(!l&&r){let s=await Ve(this.legendvm,r);he({intLegendLayerData:s,layerId:n}),await this.refreshFeatureCount()}}applyFilter(e,n,l,r){return async()=>{let s={...j.data?.[n?.id]};r?await dt(s,e,l,this.filterMode,r):await dt(s,e,l,this.filterMode),he({intLegendLayerData:s,layerId:n?.id})}}async regenerateData(){let e=await we(this.legendvm),n=at(e,j.data,this._pendingRestore,this._hiddenLegendState);J.set("data",n),await this.refreshFeatureCount(),this.requestUpdate()}async refreshFeatureCount(){if(!this.featureCount)return;let e=++this.featureCountRequestId;try{let n=await lt(this.legendvm,j.data);if(e!==this.featureCountRequestId)return;J.set("data",{...j.data,...n})}catch{}}handleFeatureLayerVisibilityChange(e){let n=e.id,l=J.get("data")?.[n];if(e.visible){this.handleFeatureLayerVisible(n,e);return}this.handleFeatureLayerHidden(n,l)}handleFeatureLayerVisible(e,n){if(this._hiddenLegendState[e]){let l=this._hiddenLegendState[e];this._pendingRestore[e]=l,he({intLegendLayerData:l,layerId:e}),delete this._hiddenLegendState[e],this.clearRestoreGuard(e),this._restoreTimeouts[e]=window.setTimeout(()=>{delete this._pendingRestore[e],delete this._restoreTimeouts[e]},250);return}this.createDataForLayer(n).catch(l=>{console.error(l)})}handleFeatureLayerHidden(e,n){this.clearRestoreGuard(e),n&&(this._hiddenLegendState[e]=n)}clearRestoreGuard(e){this._restoreTimeouts[e]&&(clearTimeout(this._restoreTimeouts[e]),delete this._restoreTimeouts[e]),delete this._pendingRestore[e]}isImageryStretchedLegend(e,n){return!0}render(){let e=this.renderFilteredLayers(),n=J.get("compact")?` ${m.compact}`:"";return this.isLoading?Q("interactive-legend-loader",L`<calcite-loader scale=m .label=${this.messages?.loading} .text=${this.messages?.loading}></calcite-loader>`):Q("interactive-legend-classic-container",L`<div class=${`${N(this.el)}${n}`} ${xe(this._legendContainerRef)}>${e?.length>0?e:L`<div class=${x(m.message)}>${this.messages?.noLegend}</div>`}</div>`)}renderFilteredLayers(){return(this.legendvm?.activeLayerInfos?.toArray()).map(e=>this.renderLegendForLayer(e)).filter(e=>!!e)}renderLegendForLayer(e,n){if(!e.ready)return null;if(e.children.length){let s=e.children.map(h=>this.renderLegendForLayer(h,!0)).toArray();return L`<instant-apps-interactive-legend-group-legend-element class=${x(N(this.el))} .legendvm=${this.legendvm} .featureCount=${this.featureCount} .activeLayerInfo=${e} .isChild=${n}><div style=${k({paddingLeft:"20px"})} .id=${`${e?.layer?.id}-legend-layer`} slot=content>${s}</div></instant-apps-interactive-legend-group-legend-element>`}let l=e.legendElements;if(l&&!l.length)return null;let r=l.map((s,h)=>this.renderLegendForElement(s,e.layer,e.effectList,e,h)).filter(s=>!!s);return r.length?L`<instant-apps-interactive-legend-layer-element class=${x(N(this.el))} .legendvm=${this.legendvm} .featureCount=${this.featureCount} .activeLayerInfo=${e} .isChild=${!!n}><div slot=content .id=${`${e?.layer?.id}-legend-layer`} class=${x(m.layer)}>${r}</div></instant-apps-interactive-legend-layer-element>`:null}renderLegendForElement(e,n,l,r,s,h,u){let w=de(e),$=me(e),S=ye(e),E=null,_=Ne(r,e,s),T=Xe(e),M=Bt(this._legendContainerRef?.value?.clientWidth||this.el?.clientWidth);if(Ye(e)||S){let A=e.infos.some(q=>Ht(q,M)),B=e.infos.map((q,K)=>this.renderLegendForElementInfo(q,n,l,S,e,r,s,K,_,u)).filter(q=>!!q);B.length&&(E=L`<div class=${`${m.layerBody}${A?` ${m.layerBodyLargeSymbol}`:""}`}>${B}</div>`)}else if(de(e)||me(e)||Ee(e)||Re(e)){let A=e;E=this.renderLegendForRamp(A,n.opacity)}else if(T){let A=e;E=Q(Ke.RELATIONSHIP_RAMP,L`<instant-apps-interactive-legend-relationship class=${x(N(this.el))} .filterMode=${this.filterMode} .activeLayerInfo=${r} .legendElement=${A}></instant-apps-interactive-legend-relationship>`)}else if(Qe(e)){let A=e;E=this.renderPieChartRamp(A)}else if(Ze(e)){let A=e;E=this.renderUnivariateAboveAndBelowRamp(A,n.opacity,l)}else if(Oe(e)){let A=e;E=this.renderUnivariateColorSizeRamp(A,n.opacity,l)}if(!E)return null;let I=e.title,P=null;if(typeof I=="string")P=I;else if(I){let A=I,B=this.getTitle(A,w||$);this.isRendererTitle(w||$)?"title"in I&&(P=`${I.title} (${B})`):P=B}return L`<instant-apps-interactive-legend-legend-element class=${x(N(this.el))} .activeLayerInfo=${r} .isSizeRamp=${S} .isChild=${!!h} .isColorRamp=${w} .isRelationshipRamp=${T} .isInteractive=${_} .zoomTo=${this.zoomTo} .legendElement=${e} .titleText=${P} .legendvm=${this.legendvm} .legendElementIndex=${s}><div slot=content>${E}</div></instant-apps-interactive-legend-legend-element>`}renderPieChartRamp(e){return L`<div .innerHTML=${`${e.preview?.outerHTML}`}></div>`}renderUnivariateAboveAndBelowRamp(e,n,l){let{sizeRampElement:r,colorRampElement:s}=Jt(e,n);if(!r)return null;let h=Se(r,"above",!0),u=Se(r,"below",!0),w=12,$=ke(s,{width:w,height:h,rampAlignment:"vertical",opacity:n,type:"above",effectList:l}),S=ke(s,{width:w,height:u,rampAlignment:"vertical",opacity:n,type:"below",effectList:l}),E=ot(r),_=r.infos.map(H=>H.label),T=_.map((H,D)=>D===0?L`<div class=${x(H?$?m.univariateAboveAndBelowLabel:m.rampLabel:"")}>${H}</div>`:D===2?L`<div></div>`:null),M=_.length-1,I=Math.floor(_.length/2),P=_.map((H,D)=>D===I||D===M?L`<div class=${x(H?$?m.univariateAboveAndBelowLabel:m.rampLabel:"")}>${H}</div>`:null),A={display:"table-cell",verticalAlign:"middle"},B={marginTop:`${E}px`},q={height:`${h}px`},K={height:`${u}px`};return Q("univariate-above-and-below-ramp-preview",L`<div style=${k(ft)}><div class=${x(m.layerBody)}>${r.infos.map((H,D)=>L`<div class=${`${m.layerRow} ${m.sizeRamp}`}><div class=${x(m.symbol)} style=${k(A)} .innerHTML=${H?.preview?.outerHTML??""??""}></div>${!$&&D%2===0?L`<div class=${x(m.layerInfo)}>${_[D]}</div>`:null}</div>`)}</div>${$?Q("color-ramp-preview",L`<div style=${k(B)}><div style=${k(Ie)}><div style=${k(ae)}><div class=${x(m.rampContainer)}>${$}</div></div><div style=${k(ae)}><div class=${x(m.rampLabelsContainer)} style=${k(q)}>${T}</div></div></div><div style=${k(Ie)}><div style=${k(ae)}><div class=${x(m.rampContainer)}>${S}</div></div><div style=${k(ae)}><div class=${x(m.rampLabelsContainer)} style=${k(K)}>${P}</div></div></div></div>`):null}</div>`)}renderUnivariateColorSizeRamp(e,n,l){let{sizeRampElement:r,colorRampElement:s}=Kt(e);if(!r)return null;let h=ot(r),u=12,w=Se(r,"full",!1),$=ke(s,{width:u,height:w,rampAlignment:"vertical",opacity:n,type:"full",effectList:l}),S=r.infos.length-1,E=r.infos.map((I,P)=>P===0||P===S?L`<div class=${x(I.label?s?m.univariateAboveAndBelowLabel:m.rampLabel:"")}>${I.label}</div>`:null),_={display:"table-cell",verticalAlign:"middle"},T={marginTop:`${h}px`},M={height:`${w}px`};return Q("univariate-above-and-below-ramp-preview",L`<div style=${k(ft)}><div class=${x(m.layerBody)}>${r.infos.map(I=>L`<div class=${`${m.layerRow} ${m.sizeRamp}`}><div class=${x(m.symbol)} style=${k(_)} .innerHTML=${I?.preview?.outerHTML??""??""}></div></div>`)}</div>${Q("color-ramp-preview",L`<div style=${k(T)}><div style=${k(Ie)}><div style=${k(ae)}><div class=${x(m.rampContainer)}>${$}</div></div><div style=${k(ae)}><div class=${x(m.rampLabelsContainer)} style=${k(M)}>${E}</div></div></div></div>`)}</div>`)}renderLegendForRamp(e,n){let l=e.infos,r=me(e),s=Ee(e),h=Re(e),u=e.preview,w=r?m.opacityRamp:"";u&&(u.classList.add(m.colorRamp),w&&u.classList.add(w)),n!=null&&u&&(u.style.opacity=n.toString());let $=l.map(_=>{let T;if(s){let M=this.messages[_.label];T=typeof M=="string"?M:_.label}else h?T="value"in _?this.getStretchStopLabel(_):_.label:T=_.label;return L`<div class=${x(_.label?m.rampLabel:"")}>${T}</div>`}),S={width:`${Xt}px`},E={height:u?.style?.height};return L`<div class=${x(m.layerRow)}><div class=${x(m.symbolContainer)} style=${k({...S})}><div class=${x(m.rampContainer)} ${xe(_=>{_?.firstChild&&_?.firstChild?.remove(),_?.appendChild(u)})}></div></div><div class=${x(m.layerInfo)}><div class=${x(m.rampLabelsContainer)} style=${k({...E})}>${$}</div></div></div>`}renderLegendForElementInfo(e,n,l,r,s,h,u,w,$,S){if("infos"in e)return this.renderLegendForElement(e,n,l,h,u,!0,e);let E=null,_=!this.isImageryStretchedLegend(n,s.type);if("preview"in e){let{outerHTML:W}=e.preview;E=L`<div class=${x(m.symbol)} .innerHTML=${W??""}></div>`}else"src"in e&&(E=this.renderImage(e,n,_));if(!E)return null;let T=_?` ${m.imageryLayerInfoStretched}`:"",M=!_&&r?` ${m.sizeRamp}`:"",I,P=Je(n),A=tt(P,S);if(j.data){let W=et(P,n,e,A,w),V=A?A?.nestedInfos:P,se=je(V),_e=!!h?.children?.length||!!A;I=P?.categories?.size===1&&!_e?!W?.selected:se||W?.selected}let B="label"in e?e.label:null,q=A&&!("value"in e)?!1:$,K=J.get("compact"),H=this.getTitle(B,!1)||"",D=A?s.title:B??n?.id;return q?L`<button @click=${this.applyFilter(e,n,w,S)} class=${`${m.layerRow} ${m.interactiveLayerRow}${I?` ${m.infoSelected}`:""}`} title=${(K?`${H}`:void 0)??pe} .ariaPressed=${I?"true":"false"}><div class=${`${m.symbolContainer}${T}${M}`}>${E}</div><div class=${`${m.layerInfo}${T}`}>${this.getTitle(B,!1)||""}</div>${this.featureCount&&!K?L`<instant-apps-interactive-legend-count class=${x(N(this.el))} .categoryId=${D} .activeLayerInfo=${h} .legendvm=${this.legendvm} .selected=${!!I} .legendElement=${s} .infoIndex=${w}></instant-apps-interactive-legend-count>`:null}</button>`:L`<div class=${x(m.layerRow)}><div class=${`${m.symbolContainer}${T}${M}`}>${E}</div><div class=${`${m.layerInfo}${T}`}>${H}</div></div>`}renderImage(e,n,l){let{label:r,src:s,opacity:h}=e,u=l?` ${m.imageryLayerStretchedImage}`:"",w=l?"":` ${m.symbol}`,$={opacity:`${h??n.opacity}`};return L`<img alt=${this.getTitle(r,!1)??pe} src=${s??pe} width=${e.width} height=${e.height} class=${`$${u}${w}`} style=${k($)}>`}};We("instant-apps-interactive-legend-classic",Te);return Te},"layers/support/FeatureFilter","layers/support/FeatureEffect","symbols/support/symbolUtils","core/reactiveUtils","intl","core/Handles",a,b,c,d,e)
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{a as x}from"./YUWXPLTE.js";import{a as L}from"./2D6XDWYA.js";import{a as S}from"./65I4AUS4.js";import{b as I}from"./MXPZF4RB.js";import"./QMAV4UTN.js";import"./Y2AUIXNK.js";import{F as $,G as v,H as k,J as p,h as F,i as l,l as h,q as b}from"./T3EPRHTT.js";import"./EXBEKVP5.js";export default $arcgis.t(([T,m,P,O])=>{var D="instant-apps-filter-list calcite-mode-light",M="instant-apps-filter-list calcite-mode-dark",g=["feature","geojson","wfs","csv","scene","subtype-group","point-cloud","map-image","sublayer"];function w(f){return f.replaceAll("'","''")}function y(f,e=!1){if(f){let t=new Date(f),i=`${t.getFullYear()}-${t.getMonth()+1}-${t.getDate()}`;if(e){let s=`${t.getHours()}:${t.getMinutes()}:${t.getSeconds()}`;return`${i} ${s}`}else return i}}function _(f){if(f!=null){f.value=["",""];let e=f.shadowRoot?.querySelectorAll("calcite-input");if(e!=null)for(let t of e)t.value=""}}var R=F`:host{display:block}.instant-apps-filter-list *{box-sizing:border-box}.instant-apps-filter-list__container{height:100%}.instant-apps-filter-list__container calcite-block{--calcite-internal-block-actions-spacing: 0}.instant-apps-filter-list__container calcite-block calcite-action[slot=actions-end]{height:100%}.instant-apps-filter-list__container calcite-block:last-of-type{margin-bottom:0}.instant-apps-filter-list__footer{padding:12px;display:flex}.instant-apps-filter-list__footer calcite-button:nth-child(2){margin-left:6px}.instant-apps-filter-list__item-container,.instant-apps-filter-list__item-container--user-input{display:flex;justify-content:space-between;align-items:center}.instant-apps-filter-list__item-container:not(:last-child),.instant-apps-filter-list__item-container--user-input:not(:last-child){padding-bottom:20px}.instant-apps-filter-list__item-container--user-input{margin:0;display:flex;flex-direction:column;align-items:flex-start}.instant-apps-filter-list__item-container--user-input>span{margin:0 0 6px;font-size:14px;font-weight:400}.instant-apps-filter-list__item-container--user-input calcite-combobox{width:100%;font-size:16px;--calcite-combobox-input-height: 24px}.instant-apps-filter-list__number-input-container{width:100%;display:flex;justify-content:center}.instant-apps-filter-list__number-input-container calcite-slider{width:90%}.instant-apps-filter-list__date-picker-input-container{display:flex;align-items:center;justify-content:unset;width:100%}.instant-apps-filter-list__date-picker-input-container calcite-action{height:65px;border-top:1px solid var(--calcite-color-border-input);border-right:1px solid var(--calcite-color-border-input);border-bottom:1px solid var(--calcite-color-border-input)}.instant-apps-filter-list__time-picker-input-container{display:grid;grid-template-columns:auto 32px;width:100%}.instant-apps-filter-list__time-picker-input-container calcite-input-time-picker:first-child{grid-column:1;grid-row:1}.instant-apps-filter-list__time-picker-input-container calcite-input-time-picker:last-child{grid-column:1;grid-row:2}.instant-apps-filter-list__time-picker-input-container calcite-action{grid-column:2;grid-row:1/span 2;height:64px;width:33px;border-top:1px solid var(--calcite-color-border-input);border-right:1px solid var(--calcite-color-border-input);border-bottom:1px solid var(--calcite-color-border-input)}.instant-apps-filter-list__title{margin-right:20px}.instant-apps-filter-list__title>p{font-size:14px;font-weight:400;margin:0}.instant-apps-filter-list__checkbox-container{display:flex}.instant-apps-filter-list__checkbox-container calcite-checkbox{height:18px}.instant-apps-filter-list__operator-description{margin:0;--calcite-font-size--1: 12px}.instant-apps-filter-list calcite-input-date-picker{--calcite-font-size--1: 16px}@media(prefers-reduced-motion){.instant-apps-filter-list calcite-loader{--calcite-internal-duration-factor: 2;--calcite-internal-animation-timing-slow: .6s }}.instant-apps-filter-list.calcite-mode-dark .instant-apps-filter-list__header-container{background:var(--calcite-color-surface-2);color:var(--calcite-color-text-1)}.instant-apps-filter-list.calcite-mode-dark .instant-apps-filter-list__operator-description{background:var(--calcite-color-surface-1)}`,d={filterContainer:"instant-apps-filter-list__container",footer:"instant-apps-filter-list__footer",filterItemTitle:"instant-apps-filter-list__title",filterItemContainer:"instant-apps-filter-list__item-container",filterUIItemContainer:"instant-apps-filter-list__item-container--user-input",checkboxContainer:"instant-apps-filter-list__checkbox-container",numberInputContainer:"instant-apps-filter-list__number-input-container",dateInputContainer:"instant-apps-filter-list__date-picker-input-container",timeInputContainer:"instant-apps-filter-list__time-picker-input-container",operatorDesc:"instant-apps-filter-list__operator-description"},C=class extends k{constructor(){super(...arguments),this._messages=S({name:"instant-apps-filter-list",blocking:!0}),this.resetBtnEl=$(),this.panelEl=$(),this.isLayerExpUpdated=!1,this.isInitUpdateComplete=!1,this.baseClass=D,this.autoUpdateUrl=!1,this.closeBtn=!1,this.comboboxOverlayPositioning="absolute",this.openFilters=!1,this.extentSelector=!1,this.filterCount=0,this.zoomBtn=!0,this.resetBtn=!0,this.resetFiltersOnDisconnect=!0,this.filterListReset=b(),this.filterUpdate=b()}static{this.properties={loading:16,filterLayerExpressions:16,baseClass:16,initDefExpressions:16,initMapImageExpressions:16,initPointCloudFilters:16,layerExpressions:0,autoUpdateUrl:5,closeBtn:5,closeBtnOnClick:0,comboboxOverlayPositioning:1,closeBtnText:1,openFilters:5,extentSelector:5,extentSelectorConfig:0,urlParams:0,filterCount:9,view:0,zoomBtn:5,resetBtn:5,resetFiltersOnDisconnect:5}}static{this.styles=R}async forceReset(){return this.resetExpressions(),await Promise.resolve(!0)}async getCurrentLayerExpressions(){let e=structuredClone(this.filterLayerExpressions);return await Promise.resolve(e)}async getFilterInitState(){return await Promise.resolve({initDefExpressions:this.initDefExpressions,initMapImageExpressions:this.initMapImageExpressions,initPointCloudFilters:this.initPointCloudFilters})}async handleUpdatingT9nData(e){return e==null?await Promise.resolve(!0):(this.filterLayerExpressions?.forEach(t=>{let i=e?.find(s=>s.id===t.id);i!=null&&(t.title=i.title,t.expressions?.forEach(s=>{let n=i.expressions?.find(a=>a.id===s.id);n!=null&&(s.name=n.name)}))}),await Promise.resolve(!0))}async updateInitDefExpressions(e){return this.initDefExpressions=e.initDefExpressions,this.initMapImageExpressions=e.initMapImageExpressions,this.initPointCloudFilters=e.initPointCloudFilters,await Promise.resolve(!0)}connectedCallback(){super.connectedCallback(),!(this.layerExpressions==null&&this.view==null)&&(this.isLayerExpUpdated=!0,this.filterLayerExpressions=structuredClone(this.layerExpressions),this.isInitUpdateComplete=!1,this.handleLayerExpressionsUpdate())}async load(){this.baseClass=L(this.el)==="dark"?M:D,!this.isLayerExpUpdated&&(this.isLayerExpUpdated=!0,this.filterLayerExpressions=this.layerExpressions!=null?structuredClone(this.layerExpressions):[],this.view!=null&&this.handleLayerExpressionsUpdate())}willUpdate(e){e.has("view")&&this.handleWhenView(),e.has("layerExpressions")&&(this.isInitUpdateComplete=!1,this.resetAllFilters(),this.filterLayerExpressions=structuredClone(this.layerExpressions),this.handleLayerExpressionsUpdate())}updated(){this.resetBtnEl.value!=null&&(this.resetBtnEl.value.disabled=!(this.filterLayerExpressions&&this.filterLayerExpressions.length>0))}disconnectedCallback(){super.disconnectedCallback(),this.resetFiltersOnDisconnect&&(this.isLayerExpUpdated=!1,this.filterLayerExpressions=structuredClone(this.layerExpressions),this.resetAllFilters())}initFilterConfig(){if(this.filterLayerExpressions&&this.filterLayerExpressions.length>0){if(this.filterLayerExpressions.length===1){let{operator:e}=this.filterLayerExpressions[0],t=e?.trim()==="OR"?"orOperator":"andOperator",i=this.renderZoomTo(this.filterLayerExpressions[0]);return l`<calcite-block class=${p(d.operatorDesc)} .heading=${this._messages[t]} expanded>${i}${this.renderFilter(this.filterLayerExpressions[0])}</calcite-block>`}else if(this.filterLayerExpressions.length>1)return this.renderLayerBlock()}}handleResetDatePicker(e,t){let i=this.panelEl.value?.querySelector(`[id='${e.id}']`);i&&(_(i),e.active=!1,e.definitionExpression=void 0,e.range=void 0,this.generateOutput(t))}handleResetTimePicker(e,t){this.resetTimePicker(e),e.active=!1,e.definitionExpression=void 0,e.range=void 0,this.generateOutput(t)}resetTimePicker(e){let t=this.panelEl.value?.querySelector(`[id='${e.id}-min']`),i=this.panelEl.value?.querySelector(`[id='${e.id}-max']`);!t||!i||(t.value=e.min,i.value=e.max)}initInput(e,t){let{type:i,numDisplayOption:s,displayOption:n}=t;if(i==="string"||i==="coded-value"||(i==="number"||i==="range"||i==="date"||i==="time-only")&&(s==="drop-down"||n==="drop-down"))return this.renderCombobox(e,t);if(i==="number"||i==="range")return this.renderNumberSlider(e,t);if(i==="date")return this.renderDatePicker(e,t);if(i==="time-only")return this.renderTimePicker(e,t)}async initExpressions(){if(this.loading=!0,this.filterLayerExpressions==null||this.view==null){this.loading=!1;return}await this.processExpressions(),this.loading=!1}async processExpressions(){this.filterLayerExpressions&&await Promise.all(this.filterLayerExpressions.map(async e=>{await Promise.all((e.expressions||[]).map(async t=>await this.setInitExpression(e,t)))}))}handleResetFilter(){this.resetExpressions(),this.resetAllFilters(),this.generateURLParams(),this.filterListReset.emit()}resetExpressions(){this.filterLayerExpressions?.forEach(e=>{e.expressions?.forEach(t=>{let{type:i,numDisplayOption:s,displayOption:n}=t,a="";i==="string"||i==="coded-value"||(i==="number"||i==="range"||i==="date"||i==="time-only")&&(s==="drop-down"||n==="drop-down")?a="combobox":i==="date"?a="datePicker":i==="number"||i==="range"?a="numberRange":i==="time-only"&&(a="timePicker"),a?this.resetExpressionUI(a,t):this.resetCheckbox(t),t.active=!1})})}resetExpressionUI(e,t){let{id:i}=t;switch(e){case"combobox":{t.selectedFields=void 0;let s=this.panelEl.value?.querySelector(`[id='${i}']`);s&&Array.from(s.children).forEach(n=>{n.selected=!1});break}case"datePicker":{t.range=void 0;let s=this.panelEl.value?.querySelector(`[id='${i}']`);s&&_(s);break}case"numberRange":{t.range=void 0;let s=this.panelEl.value?.querySelector(`[id='${i}']`);s&&(s.minValue=t.min,s.maxValue=t.max);break}case"timePicker":t.range=void 0,this.resetTimePicker(t)}}resetCheckbox(e){let{id:t}=e,i=this.panelEl.value?.querySelector(`[id='${t}']`);i&&(i.checked=!1)}resetAllFilters(){this.view?.map?.allLayers?.concat(this.view?.map?.allTables.toArray()??[])?.forEach(e=>{if(!g.includes(e.type))return;let t=e;if(t.type==="point-cloud"){if(!this.initPointCloudFilters)return;t.filters=this.initPointCloudFilters[t.id]}else if(t.type==="map-image")t.allSublayers.forEach(i=>{i.definitionExpression=this.initMapImageExpressions?.[t.id]?.[i.id]??""});else{if(this.initDefExpressions==null)return;t.definitionExpression=this.initDefExpressions[t.id]}})}async updateStringExpression(e,t){let i=this.findFilterLayer(e);return i?(await this.getFeatureAttributes(i,t),this.handleDateField(i,t),t?.selectedFields?(t.definitionExpression=this.createDefinitionExpression(t),!0):!1):!1}handleDateField(e,t){t.type==="date"&&e.fields.find(({name:i})=>i===t.field)?.type==="date-only"&&(t.dateOnly=!0)}createDefinitionExpression(e){if(!e.selectedFields?.length)return"";let t=e.selectedFields.map(i=>typeof i=="number"?i:`'${w(i)}'`);return this.getSelectedFieldsDefExpression(e,t)}async updateNumberExpression(e,t){if(!t?.min&&t?.min!==0||!t?.max&&t?.max!==0){let i=this.findFilterLayer(e);if(!i)return!1;let{field:s}=t;if(s!=null)if(this.setExpressionFormat(i,t,s),t?.numDisplayOption==="drop-down"||t?.displayOption==="drop-down")await this.getFeatureAttributes(i,t);else{let n=(await this.calculateMinMaxStatistics(i,s))?.[0]?.attributes;if(t.format?.places!=null?(t.min=this.roundMinNumberDown(n[`min${s}`],t.format.places),t.max=this.roundMaxNumberUp(n[`max${s}`],t.format.places)):(t.min=n[`min${s}`],t.max=n[`max${s}`]),t?.range&&Object.keys(t.range).length){let{min:a,max:r}=t.range;return t.definitionExpression=`${t.field} BETWEEN ${a} AND ${r}`,!0}}}return!1}async updateDateExpression(e,t){let{field:i,range:s}=t,n=this.findFilterLayer(e);if(!n)return!1;let a=(await this.calculateMinMaxStatistics(n,i))?.[0]?.attributes;if(t.min=y(a[`min${i}`]),t.max=y(a[`max${i}`]),s!=null&&(s?.max!=null||s?.min!=null)){let{min:r,max:o}=s;if(r=r?.replace("+"," "),o=o?.replace("+"," "),r||o){let c=o&&!r?"<":!o&&r?">":null;return c?t.definitionExpression=`${i} ${c} '${r??o}'`:t.definitionExpression=`${i} BETWEEN '${r}' AND '${o}'`,!0}}return!1}async updateTimeExpression(e,t){let{field:i,range:s}=t,n=this.findFilterLayer(e);if(!n)return!1;let a=(await this.calculateMinMaxStatistics(n,i))?.[0]?.attributes;if(t.min=a[`min${i}`],t.max=a[`max${i}`],s!=null&&(s?.max!=null||s?.min!=null)){let{min:r,max:o}=s;if(r||o){let c=o&&!r?"<":!o&&r?">":null;return c?t.definitionExpression=`${i} ${c} TIME '${r??o}'`:t.definitionExpression=`${i} BETWEEN TIME '${r}' AND TIME '${o}'`,!0}}return!1}async updateCodedValueExpression(e,t,i){if(!i?.domain||i?.domain?.type!=="coded-value")return!1;let s=this.findFilterLayer(e);if(!s)return!1;await this.getFeatureAttributes(s,t);let n=i.domain.codedValues.reduce((a,{code:r,name:o})=>(a[r]=o,a),{});if(t.codedValues=n,this.sortCodedValues(t),t.selectedFields?.length){let a=t.selectedFields.map(r=>typeof r=="number"?r:`'${w(r)}'`).join(",");return t.definitionExpression=`${t.field} IN (${a})`,!0}return!1}updateRangeExpression(e,t){if(!t?.domain||t?.domain?.type!=="range")return!1;let{field:i,range:s}=e;return e.min=t.domain.minValue,e.max=t.domain.maxValue,s&&Object.keys(s).length?(e.definitionExpression=`${i} BETWEEN ${s.min} AND ${s.max}`,!0):!1}async getFeatureAttributes(e,t){if(!this.isLayerSupported(e)){t.fields=[];return}let i=await this.getQueryLayer(e),{maxRecordCount:s,supportsMaxRecordCountFactor:n}=this.extractQueryCapabilities(e),a=await i.queryFeatureCount(),r=this.createQuery(i,t);await this.queryDistinctFeatures(i,r,t),this.shouldPaginate(s,a,n)&&this.handlePagination(i,r,s,n,a,t)}isLayerSupported(e){return e&&g.includes(e.type)}extractQueryCapabilities(e){return{maxRecordCount:e.capabilities?.query?.maxRecordCount??e.sourceJSON?.maxRecordCount,supportsMaxRecordCountFactor:e.capabilities?.query?.supportsMaxRecordCountFactor}}createQuery(e,t){let i=e.createQuery();this.applyCacheHint(e,i);let s=t?.field;if(s){let n=this.getInitDefExprFromLayer(e);i.where=n||"1=1",i.outFields=[s],i.orderByFields=[`${s} ASC`],i.returnDistinctValues=!0,i.returnGeometry=!1,i.maxRecordCountFactor=5,this.applyQueryGeometryFromExtentSelector(i)}return i}async queryDistinctFeatures(e,t,i){if(!t.outFields)return;let s=await this.queryForFeatures(e,t,t.outFields[0]);s?.length&&(i.fields=[...new Set(s)],i.type==="string"?i.fields=i.fields.sort((n,a)=>n.localeCompare(a)):i.type==="number"&&(i.fields=i.fields.sort((n,a)=>n-a)))}getQueryCount(e,t){return t?e*5:e}shouldPaginate(e,t,i){let s=this.getQueryCount(e,i);return e!=null&&t>s}async handlePagination(e,t,i,s,n,a){let r=this.getQueryCount(i,s),o=[];for(let c=r;c<n;c+=r){let u=t.clone();u.num=i,u.start=c,o.push(this.queryForFeatures(e,u,t?.outFields?.[0]??""))}Promise.all(o).then(c=>{c.forEach(u=>{u?.length&&a.fields&&a.fields.push(...u)}),a.type==="string"?a.fields=[...new Set(a.fields)].sort((u,E)=>u.localeCompare(E)):a.type==="number"?a.fields=[...new Set(a.fields)].sort((u,E)=>u-E):a.type==="coded-value"&&a.codedValues?this.sortCodedValues(a):a.fields=[...new Set(a.fields)].sort()})}async queryForFeatures(e,t,i){return(await e.queryFeatures(t))?.features.filter(s=>{let n=s.attributes?.[i];return n!=null&&n!==""})?.map(s=>s.attributes?.[i])}async calculateMinMaxStatistics(e,t){if(!e||!g.includes(e.type)||!t)return[];let i=this.createStatisticsQuery(e,t);return(await e.queryFeatures(i))?.features||[]}createStatisticsQuery(e,t){let i=e.createQuery();return i.where=this.getInitDefExprFromLayer(e)||"1=1",this.applyCacheHint(e,i),i.outStatistics=[{onStatisticField:t,outStatisticFieldName:`max${t}`,statisticType:"max"},{onStatisticField:t,outStatisticFieldName:`min${t}`,statisticType:"min"}],this.applyQueryGeometryFromExtentSelector(i),i}getExtent(e,t){if(e&&t){let{constraints:i}=t,s={...i}.geometry;if(s){let n="extent"in s?s:T.fromJSON(s);if(n?.type==="extent"||n?.type==="polygon")return n}}}async setInitExpression(e,t){if(!t.field||!t.type){await this.updateExpression(e,t,void 0);return}let i=this.findFilterLayer(e);i&&((i.loadStatus==="not-loaded"||i.loadStatus==="failed")&&await i.load(),await i.when(async()=>{let s=i.fields?.find(({name:a})=>a===t.field),n=s?.domain?.type;t.type=n==="coded-value"||n==="range"?n:t.type,await this.updateExpression(e,t,s)}))}async updateExpression(e,t,i){let s=await this.handleExpressionType(e,t,i);this.requestUpdate(),s&&this.generateOutput(e)}async handleExpressionType(e,t,i){switch(t.type){case"string":return await this.updateStringExpression(e,t);case"number":return await this.updateNumberExpression(e,t);case"date":return await this.updateDateExpressionBasedOnDisplayOption(e,t);case"time-only":return await this.updateTimeExpressionBasedOnDisplayOption(e,t);case"coded-value":return await this.updateCodedValueExpression(e,t,i);case"range":return await this.updateRangeExpressionBasedOnDisplayOption(e,t,i);case"checkbox":case null:case void 0:return t.active??!1;default:return!1}}async updateDateExpressionBasedOnDisplayOption(e,t){return t.displayOption==="drop-down"?await this.updateStringExpression(e,t):await this.updateDateExpression(e,t)}async updateTimeExpressionBasedOnDisplayOption(e,t){return t.displayOption==="drop-down"?await this.updateStringExpression(e,t):await this.updateTimeExpression(e,t)}async updateRangeExpressionBasedOnDisplayOption(e,t,i){return t.displayOption==="drop-down"?await this.updateStringExpression(e,t):this.updateRangeExpression(t,i)}updateRangeExpressions(e,t,i,s){let n=this.getInitDefExprFromLayerExpression(t);(s||s===0)&&(i||i===0)&&(s===e?.min&&i===e?.max?(e.definitionExpression=void 0,e.active=!1):(e.definitionExpression=n?`(${n}) AND ${e?.field} BETWEEN ${s} AND ${i}`:`${e?.field} BETWEEN ${s} AND ${i}`,e.active=!0)),e.range={min:s,max:i}}handleCheckboxChange(e,t,i){let s=i.target;t.active=s.checked,this.generateOutput(e)}handleSliderChange(e,t,i){let{maxValue:s,minValue:n}=i.target;this.updateRangeExpressions(e,t,s,n),this.generateOutput(t)}handleComboSelect(e,t,i){let s=i.target.selectedItems,{field:n,type:a}=e;if(e.selectedFields=s.map(({value:r})=>r),s.length){let r=s.map(({value:o})=>typeof o=="number"?o:`'${w(o)}'`);e.definitionExpression=this.getSelectedFieldsDefExpression(e,r),e.active=!0}else e.definitionExpression=void 0,e.active=!1;this.generateOutput(t)}getSelectedFieldsDefExpression(e,t){let{field:i,type:s}=e;return s==="date"?t.map(n=>this.buildDateExpression(n,i)).join(" OR "):s==="time-only"?`${i} IN (${t.map(n=>`TIME ${n}`).join(",")})`:`${i} IN (${t.join(",")})`}handleDatePickerRangeChange(e,t,i){let s=i.target,[n,a]=s.valueAsDate,r=n?y(Math.floor(n.getTime()),!0):void 0,o=a?y(Math.floor(a.getTime()),!0):void 0;(r||o)&&(e.definitionExpression=this.constructDefinitionExpression(e.field,r,o),e.range={min:r,max:o},e.active=!0,this.generateOutput(t))}handleTimePickerRangeChange(e,t,i,s){let n=s.target,a=n.value;e.range==null&&(e.range={min:void 0,max:void 0}),i?e.max&&a>e.max?(e.range.min=e.max,n.value=e.range.min):e.min&&a<e.min?(e.range.min=e.min,n.value=e.range.min):e.range.min=a:e.max&&a>e.max?(e.range.max=e.max,n.value=e.range.max):e.min&&a<e.min?(e.range.max=e.min,n.value=e.range.max):e.range.max=a,(e.range.min||e.range.max)&&(e.definitionExpression=this.constructTimeDefinitionExpression(e.field,e.range.min,e.range.max),e.active=!0,this.generateOutput(t))}constructDefinitionExpression(e,t,i){return t?i?`${e} BETWEEN '${t}' AND '${i}'`:`${e} > '${t}'`:`${e} < '${i}'`}constructTimeDefinitionExpression(e,t,i){return t?i?`${e} BETWEEN TIME '${t}' AND TIME '${i}'`:`${e} > TIME '${t}'`:`${e} < TIME '${i}'`}handleURLParams(){if(!("URLSearchParams"in window))return;let e=new URLSearchParams(document.location.search).get("filter");if(!e){this.filterCount=0;return}let t=e.split(";").map(i=>JSON.parse(i));this.filterCount=this.applyFilters(t)}applyFilters(e){let t=0;return e.forEach(i=>{let s=this.filterLayerExpressions?.find(n=>n.id===i.layerId);s&&s.expressions?.forEach(n=>{n.id?.toString()===i.expressionId?.toString()&&(this.activateExpression(n,i),t++)})}),t}activateExpression(e,t){e.active=!0,t.type==="range"?e.range=t.range:t.type==="select"&&(e.selectedFields=t.selectedFields)}createURLParamExpression(e,t){let{id:i,range:s,selectedFields:n,type:a}=t;return a==="string"||a==="coded-value"||t?.numDisplayOption==="drop-down"||t?.displayOption==="drop-down"?{type:"select",layerId:e.id,expressionId:i.toString(),selectedFields:n}:a==="number"||a==="range"||a==="date"||a==="time-only"?{type:"range",layerId:e.id,expressionId:i.toString(),range:s}:{layerId:e.id,expressionId:i.toString()}}autoUpdateURLCheck(e){if(this.autoUpdateUrl){let t=e.toString()?`${window.location.pathname}?${e}`.trim():window.location.pathname;window.history.replaceState({},"",t)}}generateURLParams(){if(!("URLSearchParams"in window))return;let e=new URLSearchParams(window.location.search),t=this.filterLayerExpressions?.flatMap(i=>i?.expressions?.filter(s=>s.active).map(s=>JSON.stringify(this.createURLParamExpression(i,s)))||[])||[];this.filterCount=t.length,t.length>0?e.set("filter",t.join(";")):e.delete("filter"),this.autoUpdateURLCheck(e),this.urlParams=e}updateFilter(e,t,i){let{id:s}=e,n=this.view.map?.findLayerById(s)??this.view.map?.findTableById(s);if(n!=null)if(n.type==="point-cloud")this.updateFilterLayerPCLFilter(n,i);else if(n.type==="map-image"){let a=n.findSublayerById(e?.sublayerId);a!=null&&this.updateFilterLayerDefExpression(a,t,e)}else this.updateFilterLayerDefExpression(n,t,e)}updateFilterLayerDefExpression(e,t,i){let{operator:s}=i,n=this.getInitDefExprFromLayer(e),a=t?.length>0&&n!=null&&n!==""?`(${t.join(s)}) AND (${n})`:t.length>0?t.join(s):n;e.definitionExpression=a}updateFilterLayerPCLFilter(e,t){e.filters=t}async handleWhenView(){this.view!=null&&(await this.view.map.loadAll(),await this.handleLayerExpressionsUpdate())}async handleLayerExpressionsUpdate(){this.isInitUpdateComplete||(this.updateInitExpressions(),this.handleURLParams(),this.initExpressions())}async handleZoomTo(e){let t=e?.sublayerId?`#zoom-to-${e.id}-${e.sublayerId}`:`#zoom-to-${e.id}`,i=this.panelEl.value?.querySelector(t),s=(n,a)=>{i&&(i.loading=n,i.disabled=a)};if(s(!0,!0),await this.getZoomToExtent(e),this.zoomToExtent){let n=this.zoomToExtent.type==="point"&&this.zoomToExtent.count===1?{target:this.zoomToExtent.extent,zoom:10}:this.zoomToExtent.extent;await this.view.goTo(n)}s(!1,!1)}async getZoomToExtent(e){let t=this.view.allLayerViews.find(({layer:s})=>s.id===e.id).layer,i=t.type==="map-image"?t.findSublayerById(e.sublayerId):t;if(i&&i.type!=="point-cloud"&&g.includes(i?.type)){let s=await this.getQueryLayer(i),n=s.createQuery();n.where=s.definitionExpression??"1=1";let a=await s.queryExtent(n);this.zoomToExtent={...a,type:s.geometryType}}}generateOutput(e){if(this.view==null)return;let t=[],i=[];if(e){for(let s of e.expressions){let{active:n,definitionExpression:a,pointCloudFilters:r}=s;n&&a&&t.push(`(${a})`),n&&r!=null&&r.length>0&&(i=i.concat(r))}this.updateFilter(e,t,i),this.generateURLParams(),this.filterUpdate.emit()}}numberWithCommas(e){return e.toLocaleString("en-US",{maximumFractionDigits:20})}async getInitMap(){let e=this.view.map,t;return this.view.type==="2d"?t=new P({portalItem:{id:e.portalItem.id}}):t=new O({portalItem:{id:e.portalItem.id}}),await t.load(),t}scientificRounding(e,t,i){if(e==null)return;let s;if(!String(e).includes("e"))s=Math[i](e*Math.pow(10,t))/Math.pow(10,t);else{let[n,a]=String(e).split("e").map(o=>Number(o)),r=a+t;s=Math[i](+`${n}e${r}`)*Math.pow(10,-t)}return+s.toFixed(t)}roundMinNumberDown(e,t){return this.scientificRounding(e,t,"floor")}roundMaxNumberUp(e,t){return this.scientificRounding(e,t,"ceil")}roundNumber(e,t){return this.scientificRounding(e,t,"round")??e}setExpressionFormat(e,t,i){if(e?.popupTemplate!=null){let s=e?.popupTemplate.fieldInfos?.find(({fieldName:n})=>n===i);s?.format&&(t.format=s.format)}}getInitDefExprFromLayer(e){return e.type==="sublayer"?this.initMapImageExpressions?.[e?.layer?.id??""]?.[e.id]??"":this.initDefExpressions?.[e.id]??""}getInitDefExprFromLayerExpression(e){return e?.sublayerId!=null?this.initMapImageExpressions?.[e.id]?.[e.sublayerId]??"":this.initDefExpressions?.[e.id]??""}findFilterLayer(e){let t=this.view.map?.allLayers.concat(this.view.map?.allTables.toArray()??[])?.find(({id:i})=>i===e.id);return t?.type==="map-image"?t?.findSublayerById(e.sublayerId):t}createLabel(e,t){if(e.type==="coded-value")return e?.codedValues?.[t]??t;if(e.type==="number"&&typeof t=="number"){let i=t;return e.format?.places!=null&&(i=this.roundNumber(t,e.format.places)),e.format?.digitSeparator?this.numberWithCommas(i):i}if(e.type==="date"&&!e.dateOnly){let i=m.convertDateFormatToIntlOptions("short-date-long-time");return m.formatDate(t,i)}if(e.type==="time-only"){let i=m.convertDateFormatToIntlOptions("long-time");return m.formatTimeOnly(t,i)}return t}buildDateExpression(e,t){if(e){let i=new Date(e),s=new Date(e),n=new Date(s.setDate(i.getDate()+1)),a=`${i.getFullYear()}-${i.getMonth()+1}-${i.getDate()}`,r=`${i.getHours()}:${i.getMinutes()}:${i.getSeconds()}`,o=`${n.getHours()}:${n.getMinutes()}:${n.getSeconds()}`,c=`${n.getFullYear()}-${n.getMonth()+1}-${n.getDate()}`;return`${t} BETWEEN '${a} ${r}' AND '${c} ${o}'`}}async getQueryLayer(e){let t=e.type==="sublayer"?await e.createFeatureLayer():e;if(!t)throw new Error("Failed to create feature layer");return t}applyCacheHint(e,t){e?.capabilities?.query?.supportsCacheHint&&(t.cacheHint=!0)}applyQueryGeometryFromExtentSelector(e){if(!this.extentSelector||!this.extentSelectorConfig)return;let t=this.getExtent(this.extentSelector,this.extentSelectorConfig);t&&(e.geometry=t,e.spatialRelationship="intersects")}async updateInitExpressions(){if(!this.view?.map)return;let e=await this.getInitMap();this.initDefExpressions={},this.initPointCloudFilters={},this.initMapImageExpressions={},e.allLayers.concat(e.allTables.toArray()??[]).forEach(t=>{if(!g.includes(t.type))return;let i=t;if(i.type==="point-cloud")this.initPointCloudFilters||(this.initPointCloudFilters={}),this.initPointCloudFilters[i.id]=i.filters;else if(i.type==="map-image")this.initMapImageExpressions||(this.initMapImageExpressions={}),this.initMapImageExpressions[i.id]=i.allSublayers.reduce((s,n)=>(s[n.id]=n.definitionExpression??"",s),{});else{if(!this.initDefExpressions)return;this.initDefExpressions[i.id]=i.definitionExpression??""}}),this.isInitUpdateComplete=!0}sortCodedValues(e){typeof e.fields?.[0]=="number"?e.fields=[...new Set(e.fields)].sort((t,i)=>{let s=e.codedValues?.[t],n=e.codedValues?.[i];return(s??t)-(n??i)}):e.fields=[...new Set(e.fields)].sort((t,i)=>{let s=e.codedValues?.[t],n=e.codedValues?.[i],a=s??t,r=n??i;return a.localeCompare(r)})}render(){let e=this.loading?this.renderLoading():this.initFilterConfig(),t=this.renderFooter();return l`<calcite-panel class=${p(this.baseClass)} ${v(this.panelEl)}><slot slot=header-content name=filter-header-content></slot><slot slot=header-actions-end name=filter-header-actions-end></slot>${x("filter-container",l`<div class=${p(d.filterContainer)}>${e}${t}</div>`)}</calcite-panel>`}renderLoading(){return l`<calcite-loader label="Loading filters..."></calcite-loader>`}renderFilter(e){let{id:t}=e;return e.expressions.map((i,s)=>i.type==="checkbox"||i.type==null?x(`${t}-${s}`,l`<div class=${p(d.filterItemContainer)}><div class=${p(d.filterItemTitle)}><p>${i.name}</p></div><div class=${p(d.checkboxContainer)}><calcite-checkbox id=${i.id.toString()??h} scale=l .checked=${i?.active} @calciteCheckboxChange=${this.handleCheckboxChange.bind(this,e,i)}></calcite-checkbox></div></div>`):this.initInput(e,i))}renderLayerBlock(){return this.filterLayerExpressions?.map(e=>this.renderFilterBlocks(e))}renderFilterBlocks(e){let t=this.renderFilter(e),{operator:i}=e,s=i?.trim()==="OR"?"orOperator":"andOperator",n=this.renderZoomTo(e);return x(e.id,l`<calcite-block .heading=${e.title} .description=${this._messages[s]} .expanded=${this.openFilters?!0:void 0} collapsible>${n}${t}</calcite-block>`)}renderCombobox(e,t){return x("combo-select",l`<label class=${p(d.filterUIItemContainer)}><span>${t.name}</span><calcite-combobox id=${t.id.toString()??h} @calciteComboboxChange=${this.handleComboSelect.bind(this,t,e)} .label=${t.name} .placeholder=${t.placeholder} selection-mode=multiple max-items=6 scale=s .overlayPositioning=${this.comboboxOverlayPositioning}>${t.fields?.map((i,s)=>this.renderComboboxItem(t,i,s))}</calcite-combobox></label>`)}renderComboboxItem(e,t,i){let s=this.createLabel(e,t),n=e?.selectedFields?.includes(t)??!1;return x(`${s}-${i}`,l`<calcite-combobox-item .value=${t} .heading=${`${s}`} .selected=${n}></calcite-combobox-item>`)}renderNumberSlider(e,t){let i=t?.min,s=t?.max,n=t?.step?t.step:1,a=i!=null&&s!=null,r=t?.field??"",o=t?.range?.min!=null?t.range.min:i,c=t?.range?.max!=null?t.range.max:s,u=[o,c];return a?x(t?.id.toString(),l`<label class=${p(d.filterUIItemContainer)}><span>${t?.name}</span><div class=${p(d.numberInputContainer)}><calcite-slider id=${t?.id.toString()??h} @calciteSliderChange=${this.handleSliderChange.bind(this,t,e)} .min=${i} .max=${s} .minValue=${i} .maxValue=${s} .minLabel=${this._messages.minSlider?.replace("{field}",r)} .maxLabel=${this._messages.maxSlider?.replace("{field}",r)} .step=${n} label-handles snap .value=${u} .groupSeparator=${t?.format?.digitSeparator} precise></calcite-slider></div></label>`):void 0}renderDatePicker(e,t){let{min:i,max:s}=t,n=[t?.range?.min,t?.range?.max];return i!=null&&s!=null?l`<label class=${p(d.filterUIItemContainer)}><span>${t?.name}</span><div class=${p(d.dateInputContainer)}><calcite-input-date-picker id=${t?.id.toString()??h} @calciteInputDatePickerChange=${this.handleDatePickerRangeChange.bind(this,t,e)} .min=${i} .max=${s} calendars=1 overlay-positioning=fixed lang=${m.getLocale()??"en"??h} layout=vertical .value=${n} range></calcite-input-date-picker><calcite-action @click=${this.handleResetDatePicker.bind(this,t,e)} icon=reset .text=${this._messages.resetDatePicker} title=${this._messages.resetDatePicker??h} scale=s></calcite-action></div></label>`:void 0}renderTimePicker(e,t){let{min:i,max:s,range:n}=t,a=i!=null&&s!=null,r=n?.min!=null?n.min:i,o=n?.max!=null?n.max:s;return a?l`<label class=${p(d.filterUIItemContainer)}><span>${t?.name}</span><div class=${p(d.timeInputContainer)}><calcite-input-time-picker .id=${`${t?.id.toString()}-min`} .value=${r} overlay-positioning=fixed lang=${m.getLocale()??"en"??h} @calciteInputTimePickerChange=${this.handleTimePickerRangeChange.bind(this,t,e,!0)}></calcite-input-time-picker><calcite-input-time-picker .id=${`${t?.id.toString()}-max`} .value=${o} overlay-positioning=fixed lang=${m.getLocale()??"en"??h} @calciteInputTimePickerChange=${this.handleTimePickerRangeChange.bind(this,t,e,!1)}></calcite-input-time-picker><calcite-action @click=${this.handleResetTimePicker.bind(this,t,e)} icon=reset .text=${this._messages.resetTimePicker} title=${this._messages.resetTimePicker??h} scale=s></calcite-action></div></label>`:void 0}renderFooter(){let e=this.closeBtnText??this._messages.close,t=this.closeBtn&&this.resetBtn?"half":"full";return l`<div class=${p(d.footer)} slot=footer>${this.resetBtn?l`<calcite-button appearance=outline .width=${t} @click=${this.handleResetFilter} ${v(this.resetBtnEl)}>${this._messages.resetFilter}</calcite-button>`:void 0}${this.closeBtn?l`<calcite-button appearance=solid .width=${t} kind=brand @click=${this.closeBtnOnClick}>${e}</calcite-button>`:void 0}</div>`}renderZoomTo(e){let t=e?.sublayerId?`zoom-to-${e.id}-${e.sublayerId}`:`zoom-to-${e.id}`;return this.zoomBtn?l`<calcite-action id=${t??h} slot=actions-end appearance=transparent .text=${this._messages.zoomTo} title=${this._messages.zoomTo??h} scale=s icon=magnifying-glass-plus @click=${this.handleZoomTo.bind(this,e)}></calcite-action>`:void 0}};I("instant-apps-filter-list",C);return C},"geometry/support/jsonUtils","intl","WebMap","WebScene")
2
+ import{a as L}from"./2D6XDWYA.js";import{a as x}from"./YUWXPLTE.js";import{a as S}from"./65I4AUS4.js";import{b as I}from"./MXPZF4RB.js";import"./QMAV4UTN.js";import"./Y2AUIXNK.js";import{F as $,G as v,H as k,J as p,h as F,i as l,l as h,q as b}from"./T3EPRHTT.js";import"./EXBEKVP5.js";export default $arcgis.t(([T,m,P,O])=>{var D="instant-apps-filter-list calcite-mode-light",M="instant-apps-filter-list calcite-mode-dark",g=["feature","geojson","wfs","csv","scene","subtype-group","point-cloud","map-image","sublayer"];function w(f){return f.replaceAll("'","''")}function y(f,e=!1){if(f){let t=new Date(f),i=`${t.getFullYear()}-${t.getMonth()+1}-${t.getDate()}`;if(e){let s=`${t.getHours()}:${t.getMinutes()}:${t.getSeconds()}`;return`${i} ${s}`}else return i}}function _(f){if(f!=null){f.value=["",""];let e=f.shadowRoot?.querySelectorAll("calcite-input");if(e!=null)for(let t of e)t.value=""}}var R=F`:host{display:block}.instant-apps-filter-list *{box-sizing:border-box}.instant-apps-filter-list__container{height:100%}.instant-apps-filter-list__container calcite-block{--calcite-internal-block-actions-spacing: 0}.instant-apps-filter-list__container calcite-block calcite-action[slot=actions-end]{height:100%}.instant-apps-filter-list__container calcite-block:last-of-type{margin-bottom:0}.instant-apps-filter-list__footer{padding:12px;display:flex}.instant-apps-filter-list__footer calcite-button:nth-child(2){margin-left:6px}.instant-apps-filter-list__item-container,.instant-apps-filter-list__item-container--user-input{display:flex;justify-content:space-between;align-items:center}.instant-apps-filter-list__item-container:not(:last-child),.instant-apps-filter-list__item-container--user-input:not(:last-child){padding-bottom:20px}.instant-apps-filter-list__item-container--user-input{margin:0;display:flex;flex-direction:column;align-items:flex-start}.instant-apps-filter-list__item-container--user-input>span{margin:0 0 6px;font-size:14px;font-weight:400}.instant-apps-filter-list__item-container--user-input calcite-combobox{width:100%;font-size:16px;--calcite-combobox-input-height: 24px}.instant-apps-filter-list__number-input-container{width:100%;display:flex;justify-content:center}.instant-apps-filter-list__number-input-container calcite-slider{width:90%}.instant-apps-filter-list__date-picker-input-container{display:flex;align-items:center;justify-content:unset;width:100%}.instant-apps-filter-list__date-picker-input-container calcite-action{height:65px;border-top:1px solid var(--calcite-color-border-input);border-right:1px solid var(--calcite-color-border-input);border-bottom:1px solid var(--calcite-color-border-input)}.instant-apps-filter-list__time-picker-input-container{display:grid;grid-template-columns:auto 32px;width:100%}.instant-apps-filter-list__time-picker-input-container calcite-input-time-picker:first-child{grid-column:1;grid-row:1}.instant-apps-filter-list__time-picker-input-container calcite-input-time-picker:last-child{grid-column:1;grid-row:2}.instant-apps-filter-list__time-picker-input-container calcite-action{grid-column:2;grid-row:1/span 2;height:64px;width:33px;border-top:1px solid var(--calcite-color-border-input);border-right:1px solid var(--calcite-color-border-input);border-bottom:1px solid var(--calcite-color-border-input)}.instant-apps-filter-list__title{margin-right:20px}.instant-apps-filter-list__title>p{font-size:14px;font-weight:400;margin:0}.instant-apps-filter-list__checkbox-container{display:flex}.instant-apps-filter-list__checkbox-container calcite-checkbox{height:18px}.instant-apps-filter-list__operator-description{margin:0;--calcite-font-size--1: 12px}.instant-apps-filter-list calcite-input-date-picker{--calcite-font-size--1: 16px}@media(prefers-reduced-motion){.instant-apps-filter-list calcite-loader{--calcite-internal-duration-factor: 2;--calcite-internal-animation-timing-slow: .6s }}.instant-apps-filter-list.calcite-mode-dark .instant-apps-filter-list__header-container{background:var(--calcite-color-surface-2);color:var(--calcite-color-text-1)}.instant-apps-filter-list.calcite-mode-dark .instant-apps-filter-list__operator-description{background:var(--calcite-color-surface-1)}`,d={filterContainer:"instant-apps-filter-list__container",footer:"instant-apps-filter-list__footer",filterItemTitle:"instant-apps-filter-list__title",filterItemContainer:"instant-apps-filter-list__item-container",filterUIItemContainer:"instant-apps-filter-list__item-container--user-input",checkboxContainer:"instant-apps-filter-list__checkbox-container",numberInputContainer:"instant-apps-filter-list__number-input-container",dateInputContainer:"instant-apps-filter-list__date-picker-input-container",timeInputContainer:"instant-apps-filter-list__time-picker-input-container",operatorDesc:"instant-apps-filter-list__operator-description"},C=class extends k{constructor(){super(...arguments),this._messages=S({name:"instant-apps-filter-list",blocking:!0}),this.resetBtnEl=$(),this.panelEl=$(),this.isLayerExpUpdated=!1,this.isInitUpdateComplete=!1,this.baseClass=D,this.autoUpdateUrl=!1,this.closeBtn=!1,this.comboboxOverlayPositioning="absolute",this.openFilters=!1,this.extentSelector=!1,this.filterCount=0,this.zoomBtn=!0,this.resetBtn=!0,this.resetFiltersOnDisconnect=!0,this.filterListReset=b(),this.filterUpdate=b()}static{this.properties={loading:16,filterLayerExpressions:16,baseClass:16,initDefExpressions:16,initMapImageExpressions:16,initPointCloudFilters:16,layerExpressions:0,autoUpdateUrl:5,closeBtn:5,closeBtnOnClick:0,comboboxOverlayPositioning:1,closeBtnText:1,openFilters:5,extentSelector:5,extentSelectorConfig:0,urlParams:0,filterCount:9,view:0,zoomBtn:5,resetBtn:5,resetFiltersOnDisconnect:5}}static{this.styles=R}async forceReset(){return this.resetExpressions(),await Promise.resolve(!0)}async getCurrentLayerExpressions(){let e=structuredClone(this.filterLayerExpressions);return await Promise.resolve(e)}async getFilterInitState(){return await Promise.resolve({initDefExpressions:this.initDefExpressions,initMapImageExpressions:this.initMapImageExpressions,initPointCloudFilters:this.initPointCloudFilters})}async handleUpdatingT9nData(e){return e==null?await Promise.resolve(!0):(this.filterLayerExpressions?.forEach(t=>{let i=e?.find(s=>s.id===t.id);i!=null&&(t.title=i.title,t.expressions?.forEach(s=>{let n=i.expressions?.find(a=>a.id===s.id);n!=null&&(s.name=n.name)}))}),await Promise.resolve(!0))}async updateInitDefExpressions(e){return this.initDefExpressions=e.initDefExpressions,this.initMapImageExpressions=e.initMapImageExpressions,this.initPointCloudFilters=e.initPointCloudFilters,await Promise.resolve(!0)}connectedCallback(){super.connectedCallback(),!(this.layerExpressions==null&&this.view==null)&&(this.isLayerExpUpdated=!0,this.filterLayerExpressions=structuredClone(this.layerExpressions),this.isInitUpdateComplete=!1,this.handleLayerExpressionsUpdate())}async load(){this.baseClass=L(this.el)==="dark"?M:D,!this.isLayerExpUpdated&&(this.isLayerExpUpdated=!0,this.filterLayerExpressions=this.layerExpressions!=null?structuredClone(this.layerExpressions):[],this.view!=null&&this.handleLayerExpressionsUpdate())}willUpdate(e){e.has("view")&&this.handleWhenView(),e.has("layerExpressions")&&(this.isInitUpdateComplete=!1,this.resetAllFilters(),this.filterLayerExpressions=structuredClone(this.layerExpressions),this.handleLayerExpressionsUpdate())}updated(){this.resetBtnEl.value!=null&&(this.resetBtnEl.value.disabled=!(this.filterLayerExpressions&&this.filterLayerExpressions.length>0))}disconnectedCallback(){super.disconnectedCallback(),this.resetFiltersOnDisconnect&&(this.isLayerExpUpdated=!1,this.filterLayerExpressions=structuredClone(this.layerExpressions),this.resetAllFilters())}initFilterConfig(){if(this.filterLayerExpressions&&this.filterLayerExpressions.length>0){if(this.filterLayerExpressions.length===1){let{operator:e}=this.filterLayerExpressions[0],t=e?.trim()==="OR"?"orOperator":"andOperator",i=this.renderZoomTo(this.filterLayerExpressions[0]);return l`<calcite-block class=${p(d.operatorDesc)} .heading=${this._messages[t]} expanded>${i}${this.renderFilter(this.filterLayerExpressions[0])}</calcite-block>`}else if(this.filterLayerExpressions.length>1)return this.renderLayerBlock()}}handleResetDatePicker(e,t){let i=this.panelEl.value?.querySelector(`[id='${e.id}']`);i&&(_(i),e.active=!1,e.definitionExpression=void 0,e.range=void 0,this.generateOutput(t))}handleResetTimePicker(e,t){this.resetTimePicker(e),e.active=!1,e.definitionExpression=void 0,e.range=void 0,this.generateOutput(t)}resetTimePicker(e){let t=this.panelEl.value?.querySelector(`[id='${e.id}-min']`),i=this.panelEl.value?.querySelector(`[id='${e.id}-max']`);!t||!i||(t.value=e.min,i.value=e.max)}initInput(e,t){let{type:i,numDisplayOption:s,displayOption:n}=t;if(i==="string"||i==="coded-value"||(i==="number"||i==="range"||i==="date"||i==="time-only")&&(s==="drop-down"||n==="drop-down"))return this.renderCombobox(e,t);if(i==="number"||i==="range")return this.renderNumberSlider(e,t);if(i==="date")return this.renderDatePicker(e,t);if(i==="time-only")return this.renderTimePicker(e,t)}async initExpressions(){if(this.loading=!0,this.filterLayerExpressions==null||this.view==null){this.loading=!1;return}await this.processExpressions(),this.loading=!1}async processExpressions(){this.filterLayerExpressions&&await Promise.all(this.filterLayerExpressions.map(async e=>{await Promise.all((e.expressions||[]).map(async t=>await this.setInitExpression(e,t)))}))}handleResetFilter(){this.resetExpressions(),this.resetAllFilters(),this.generateURLParams(),this.filterListReset.emit()}resetExpressions(){this.filterLayerExpressions?.forEach(e=>{e.expressions?.forEach(t=>{let{type:i,numDisplayOption:s,displayOption:n}=t,a="";i==="string"||i==="coded-value"||(i==="number"||i==="range"||i==="date"||i==="time-only")&&(s==="drop-down"||n==="drop-down")?a="combobox":i==="date"?a="datePicker":i==="number"||i==="range"?a="numberRange":i==="time-only"&&(a="timePicker"),a?this.resetExpressionUI(a,t):this.resetCheckbox(t),t.active=!1})})}resetExpressionUI(e,t){let{id:i}=t;switch(e){case"combobox":{t.selectedFields=void 0;let s=this.panelEl.value?.querySelector(`[id='${i}']`);s&&Array.from(s.children).forEach(n=>{n.selected=!1});break}case"datePicker":{t.range=void 0;let s=this.panelEl.value?.querySelector(`[id='${i}']`);s&&_(s);break}case"numberRange":{t.range=void 0;let s=this.panelEl.value?.querySelector(`[id='${i}']`);s&&(s.minValue=t.min,s.maxValue=t.max);break}case"timePicker":t.range=void 0,this.resetTimePicker(t)}}resetCheckbox(e){let{id:t}=e,i=this.panelEl.value?.querySelector(`[id='${t}']`);i&&(i.checked=!1)}resetAllFilters(){this.view?.map?.allLayers?.concat(this.view?.map?.allTables.toArray()??[])?.forEach(e=>{if(!g.includes(e.type))return;let t=e;if(t.type==="point-cloud"){if(!this.initPointCloudFilters)return;t.filters=this.initPointCloudFilters[t.id]}else if(t.type==="map-image")t.allSublayers.forEach(i=>{i.definitionExpression=this.initMapImageExpressions?.[t.id]?.[i.id]??""});else{if(this.initDefExpressions==null)return;t.definitionExpression=this.initDefExpressions[t.id]}})}async updateStringExpression(e,t){let i=this.findFilterLayer(e);return i?(await this.getFeatureAttributes(i,t),this.handleDateField(i,t),t?.selectedFields?(t.definitionExpression=this.createDefinitionExpression(t),!0):!1):!1}handleDateField(e,t){t.type==="date"&&e.fields.find(({name:i})=>i===t.field)?.type==="date-only"&&(t.dateOnly=!0)}createDefinitionExpression(e){if(!e.selectedFields?.length)return"";let t=e.selectedFields.map(i=>typeof i=="number"?i:`'${w(i)}'`);return this.getSelectedFieldsDefExpression(e,t)}async updateNumberExpression(e,t){if(!t?.min&&t?.min!==0||!t?.max&&t?.max!==0){let i=this.findFilterLayer(e);if(!i)return!1;let{field:s}=t;if(s!=null)if(this.setExpressionFormat(i,t,s),t?.numDisplayOption==="drop-down"||t?.displayOption==="drop-down")await this.getFeatureAttributes(i,t);else{let n=(await this.calculateMinMaxStatistics(i,s))?.[0]?.attributes;if(t.format?.places!=null?(t.min=this.roundMinNumberDown(n[`min${s}`],t.format.places),t.max=this.roundMaxNumberUp(n[`max${s}`],t.format.places)):(t.min=n[`min${s}`],t.max=n[`max${s}`]),t?.range&&Object.keys(t.range).length){let{min:a,max:r}=t.range;return t.definitionExpression=`${t.field} BETWEEN ${a} AND ${r}`,!0}}}return!1}async updateDateExpression(e,t){let{field:i,range:s}=t,n=this.findFilterLayer(e);if(!n)return!1;let a=(await this.calculateMinMaxStatistics(n,i))?.[0]?.attributes;if(t.min=y(a[`min${i}`]),t.max=y(a[`max${i}`]),s!=null&&(s?.max!=null||s?.min!=null)){let{min:r,max:o}=s;if(r=r?.replace("+"," "),o=o?.replace("+"," "),r||o){let c=o&&!r?"<":!o&&r?">":null;return c?t.definitionExpression=`${i} ${c} '${r??o}'`:t.definitionExpression=`${i} BETWEEN '${r}' AND '${o}'`,!0}}return!1}async updateTimeExpression(e,t){let{field:i,range:s}=t,n=this.findFilterLayer(e);if(!n)return!1;let a=(await this.calculateMinMaxStatistics(n,i))?.[0]?.attributes;if(t.min=a[`min${i}`],t.max=a[`max${i}`],s!=null&&(s?.max!=null||s?.min!=null)){let{min:r,max:o}=s;if(r||o){let c=o&&!r?"<":!o&&r?">":null;return c?t.definitionExpression=`${i} ${c} TIME '${r??o}'`:t.definitionExpression=`${i} BETWEEN TIME '${r}' AND TIME '${o}'`,!0}}return!1}async updateCodedValueExpression(e,t,i){if(!i?.domain||i?.domain?.type!=="coded-value")return!1;let s=this.findFilterLayer(e);if(!s)return!1;await this.getFeatureAttributes(s,t);let n=i.domain.codedValues.reduce((a,{code:r,name:o})=>(a[r]=o,a),{});if(t.codedValues=n,this.sortCodedValues(t),t.selectedFields?.length){let a=t.selectedFields.map(r=>typeof r=="number"?r:`'${w(r)}'`).join(",");return t.definitionExpression=`${t.field} IN (${a})`,!0}return!1}updateRangeExpression(e,t){if(!t?.domain||t?.domain?.type!=="range")return!1;let{field:i,range:s}=e;return e.min=t.domain.minValue,e.max=t.domain.maxValue,s&&Object.keys(s).length?(e.definitionExpression=`${i} BETWEEN ${s.min} AND ${s.max}`,!0):!1}async getFeatureAttributes(e,t){if(!this.isLayerSupported(e)){t.fields=[];return}let i=await this.getQueryLayer(e),{maxRecordCount:s,supportsMaxRecordCountFactor:n}=this.extractQueryCapabilities(e),a=await i.queryFeatureCount(),r=this.createQuery(i,t);await this.queryDistinctFeatures(i,r,t),this.shouldPaginate(s,a,n)&&this.handlePagination(i,r,s,n,a,t)}isLayerSupported(e){return e&&g.includes(e.type)}extractQueryCapabilities(e){return{maxRecordCount:e.capabilities?.query?.maxRecordCount??e.sourceJSON?.maxRecordCount,supportsMaxRecordCountFactor:e.capabilities?.query?.supportsMaxRecordCountFactor}}createQuery(e,t){let i=e.createQuery();this.applyCacheHint(e,i);let s=t?.field;if(s){let n=this.getInitDefExprFromLayer(e);i.where=n||"1=1",i.outFields=[s],i.orderByFields=[`${s} ASC`],i.returnDistinctValues=!0,i.returnGeometry=!1,i.maxRecordCountFactor=5,this.applyQueryGeometryFromExtentSelector(i)}return i}async queryDistinctFeatures(e,t,i){if(!t.outFields)return;let s=await this.queryForFeatures(e,t,t.outFields[0]);s?.length&&(i.fields=[...new Set(s)],i.type==="string"?i.fields=i.fields.sort((n,a)=>n.localeCompare(a)):i.type==="number"&&(i.fields=i.fields.sort((n,a)=>n-a)))}getQueryCount(e,t){return t?e*5:e}shouldPaginate(e,t,i){let s=this.getQueryCount(e,i);return e!=null&&t>s}async handlePagination(e,t,i,s,n,a){let r=this.getQueryCount(i,s),o=[];for(let c=r;c<n;c+=r){let u=t.clone();u.num=i,u.start=c,o.push(this.queryForFeatures(e,u,t?.outFields?.[0]??""))}Promise.all(o).then(c=>{c.forEach(u=>{u?.length&&a.fields&&a.fields.push(...u)}),a.type==="string"?a.fields=[...new Set(a.fields)].sort((u,E)=>u.localeCompare(E)):a.type==="number"?a.fields=[...new Set(a.fields)].sort((u,E)=>u-E):a.type==="coded-value"&&a.codedValues?this.sortCodedValues(a):a.fields=[...new Set(a.fields)].sort()})}async queryForFeatures(e,t,i){return(await e.queryFeatures(t))?.features.filter(s=>{let n=s.attributes?.[i];return n!=null&&n!==""})?.map(s=>s.attributes?.[i])}async calculateMinMaxStatistics(e,t){if(!e||!g.includes(e.type)||!t)return[];let i=this.createStatisticsQuery(e,t);return(await e.queryFeatures(i))?.features||[]}createStatisticsQuery(e,t){let i=e.createQuery();return i.where=this.getInitDefExprFromLayer(e)||"1=1",this.applyCacheHint(e,i),i.outStatistics=[{onStatisticField:t,outStatisticFieldName:`max${t}`,statisticType:"max"},{onStatisticField:t,outStatisticFieldName:`min${t}`,statisticType:"min"}],this.applyQueryGeometryFromExtentSelector(i),i}getExtent(e,t){if(e&&t){let{constraints:i}=t,s={...i}.geometry;if(s){let n="extent"in s?s:T.fromJSON(s);if(n?.type==="extent"||n?.type==="polygon")return n}}}async setInitExpression(e,t){if(!t.field||!t.type){await this.updateExpression(e,t,void 0);return}let i=this.findFilterLayer(e);i&&((i.loadStatus==="not-loaded"||i.loadStatus==="failed")&&await i.load(),await i.when(async()=>{let s=i.fields?.find(({name:a})=>a===t.field),n=s?.domain?.type;t.type=n==="coded-value"||n==="range"?n:t.type,await this.updateExpression(e,t,s)}))}async updateExpression(e,t,i){let s=await this.handleExpressionType(e,t,i);this.requestUpdate(),s&&this.generateOutput(e)}async handleExpressionType(e,t,i){switch(t.type){case"string":return await this.updateStringExpression(e,t);case"number":return await this.updateNumberExpression(e,t);case"date":return await this.updateDateExpressionBasedOnDisplayOption(e,t);case"time-only":return await this.updateTimeExpressionBasedOnDisplayOption(e,t);case"coded-value":return await this.updateCodedValueExpression(e,t,i);case"range":return await this.updateRangeExpressionBasedOnDisplayOption(e,t,i);case"checkbox":case null:case void 0:return t.active??!1;default:return!1}}async updateDateExpressionBasedOnDisplayOption(e,t){return t.displayOption==="drop-down"?await this.updateStringExpression(e,t):await this.updateDateExpression(e,t)}async updateTimeExpressionBasedOnDisplayOption(e,t){return t.displayOption==="drop-down"?await this.updateStringExpression(e,t):await this.updateTimeExpression(e,t)}async updateRangeExpressionBasedOnDisplayOption(e,t,i){return t.displayOption==="drop-down"?await this.updateStringExpression(e,t):this.updateRangeExpression(t,i)}updateRangeExpressions(e,t,i,s){let n=this.getInitDefExprFromLayerExpression(t);(s||s===0)&&(i||i===0)&&(s===e?.min&&i===e?.max?(e.definitionExpression=void 0,e.active=!1):(e.definitionExpression=n?`(${n}) AND ${e?.field} BETWEEN ${s} AND ${i}`:`${e?.field} BETWEEN ${s} AND ${i}`,e.active=!0)),e.range={min:s,max:i}}handleCheckboxChange(e,t,i){let s=i.target;t.active=s.checked,this.generateOutput(e)}handleSliderChange(e,t,i){let{maxValue:s,minValue:n}=i.target;this.updateRangeExpressions(e,t,s,n),this.generateOutput(t)}handleComboSelect(e,t,i){let s=i.target.selectedItems,{field:n,type:a}=e;if(e.selectedFields=s.map(({value:r})=>r),s.length){let r=s.map(({value:o})=>typeof o=="number"?o:`'${w(o)}'`);e.definitionExpression=this.getSelectedFieldsDefExpression(e,r),e.active=!0}else e.definitionExpression=void 0,e.active=!1;this.generateOutput(t)}getSelectedFieldsDefExpression(e,t){let{field:i,type:s}=e;return s==="date"?t.map(n=>this.buildDateExpression(n,i)).join(" OR "):s==="time-only"?`${i} IN (${t.map(n=>`TIME ${n}`).join(",")})`:`${i} IN (${t.join(",")})`}handleDatePickerRangeChange(e,t,i){let s=i.target,[n,a]=s.valueAsDate,r=n?y(Math.floor(n.getTime()),!0):void 0,o=a?y(Math.floor(a.getTime()),!0):void 0;(r||o)&&(e.definitionExpression=this.constructDefinitionExpression(e.field,r,o),e.range={min:r,max:o},e.active=!0,this.generateOutput(t))}handleTimePickerRangeChange(e,t,i,s){let n=s.target,a=n.value;e.range==null&&(e.range={min:void 0,max:void 0}),i?e.max&&a>e.max?(e.range.min=e.max,n.value=e.range.min):e.min&&a<e.min?(e.range.min=e.min,n.value=e.range.min):e.range.min=a:e.max&&a>e.max?(e.range.max=e.max,n.value=e.range.max):e.min&&a<e.min?(e.range.max=e.min,n.value=e.range.max):e.range.max=a,(e.range.min||e.range.max)&&(e.definitionExpression=this.constructTimeDefinitionExpression(e.field,e.range.min,e.range.max),e.active=!0,this.generateOutput(t))}constructDefinitionExpression(e,t,i){return t?i?`${e} BETWEEN '${t}' AND '${i}'`:`${e} > '${t}'`:`${e} < '${i}'`}constructTimeDefinitionExpression(e,t,i){return t?i?`${e} BETWEEN TIME '${t}' AND TIME '${i}'`:`${e} > TIME '${t}'`:`${e} < TIME '${i}'`}handleURLParams(){if(!("URLSearchParams"in window))return;let e=new URLSearchParams(document.location.search).get("filter");if(!e){this.filterCount=0;return}let t=e.split(";").map(i=>JSON.parse(i));this.filterCount=this.applyFilters(t)}applyFilters(e){let t=0;return e.forEach(i=>{let s=this.filterLayerExpressions?.find(n=>n.id===i.layerId);s&&s.expressions?.forEach(n=>{n.id?.toString()===i.expressionId?.toString()&&(this.activateExpression(n,i),t++)})}),t}activateExpression(e,t){e.active=!0,t.type==="range"?e.range=t.range:t.type==="select"&&(e.selectedFields=t.selectedFields)}createURLParamExpression(e,t){let{id:i,range:s,selectedFields:n,type:a}=t;return a==="string"||a==="coded-value"||t?.numDisplayOption==="drop-down"||t?.displayOption==="drop-down"?{type:"select",layerId:e.id,expressionId:i.toString(),selectedFields:n}:a==="number"||a==="range"||a==="date"||a==="time-only"?{type:"range",layerId:e.id,expressionId:i.toString(),range:s}:{layerId:e.id,expressionId:i.toString()}}autoUpdateURLCheck(e){if(this.autoUpdateUrl){let t=e.toString()?`${window.location.pathname}?${e}`.trim():window.location.pathname;window.history.replaceState({},"",t)}}generateURLParams(){if(!("URLSearchParams"in window))return;let e=new URLSearchParams(window.location.search),t=this.filterLayerExpressions?.flatMap(i=>i?.expressions?.filter(s=>s.active).map(s=>JSON.stringify(this.createURLParamExpression(i,s)))||[])||[];this.filterCount=t.length,t.length>0?e.set("filter",t.join(";")):e.delete("filter"),this.autoUpdateURLCheck(e),this.urlParams=e}updateFilter(e,t,i){let{id:s}=e,n=this.view.map?.findLayerById(s)??this.view.map?.findTableById(s);if(n!=null)if(n.type==="point-cloud")this.updateFilterLayerPCLFilter(n,i);else if(n.type==="map-image"){let a=n.findSublayerById(e?.sublayerId);a!=null&&this.updateFilterLayerDefExpression(a,t,e)}else this.updateFilterLayerDefExpression(n,t,e)}updateFilterLayerDefExpression(e,t,i){let{operator:s}=i,n=this.getInitDefExprFromLayer(e),a=t?.length>0&&n!=null&&n!==""?`(${t.join(s)}) AND (${n})`:t.length>0?t.join(s):n;e.definitionExpression=a}updateFilterLayerPCLFilter(e,t){e.filters=t}async handleWhenView(){this.view!=null&&(await this.view.map.loadAll(),await this.handleLayerExpressionsUpdate())}async handleLayerExpressionsUpdate(){this.isInitUpdateComplete||(this.updateInitExpressions(),this.handleURLParams(),this.initExpressions())}async handleZoomTo(e){let t=e?.sublayerId?`#zoom-to-${e.id}-${e.sublayerId}`:`#zoom-to-${e.id}`,i=this.panelEl.value?.querySelector(t),s=(n,a)=>{i&&(i.loading=n,i.disabled=a)};if(s(!0,!0),await this.getZoomToExtent(e),this.zoomToExtent){let n=this.zoomToExtent.type==="point"&&this.zoomToExtent.count===1?{target:this.zoomToExtent.extent,zoom:10}:this.zoomToExtent.extent;await this.view.goTo(n)}s(!1,!1)}async getZoomToExtent(e){let t=this.view.allLayerViews.find(({layer:s})=>s.id===e.id).layer,i=t.type==="map-image"?t.findSublayerById(e.sublayerId):t;if(i&&i.type!=="point-cloud"&&g.includes(i?.type)){let s=await this.getQueryLayer(i),n=s.createQuery();n.where=s.definitionExpression??"1=1";let a=await s.queryExtent(n);this.zoomToExtent={...a,type:s.geometryType}}}generateOutput(e){if(this.view==null)return;let t=[],i=[];if(e){for(let s of e.expressions){let{active:n,definitionExpression:a,pointCloudFilters:r}=s;n&&a&&t.push(`(${a})`),n&&r!=null&&r.length>0&&(i=i.concat(r))}this.updateFilter(e,t,i),this.generateURLParams(),this.filterUpdate.emit()}}numberWithCommas(e){return e.toLocaleString("en-US",{maximumFractionDigits:20})}async getInitMap(){let e=this.view.map,t;return this.view.type==="2d"?t=new P({portalItem:{id:e.portalItem.id}}):t=new O({portalItem:{id:e.portalItem.id}}),await t.load(),t}scientificRounding(e,t,i){if(e==null)return;let s;if(!String(e).includes("e"))s=Math[i](e*Math.pow(10,t))/Math.pow(10,t);else{let[n,a]=String(e).split("e").map(o=>Number(o)),r=a+t;s=Math[i](+`${n}e${r}`)*Math.pow(10,-t)}return+s.toFixed(t)}roundMinNumberDown(e,t){return this.scientificRounding(e,t,"floor")}roundMaxNumberUp(e,t){return this.scientificRounding(e,t,"ceil")}roundNumber(e,t){return this.scientificRounding(e,t,"round")??e}setExpressionFormat(e,t,i){if(e?.popupTemplate!=null){let s=e?.popupTemplate.fieldInfos?.find(({fieldName:n})=>n===i);s?.format&&(t.format=s.format)}}getInitDefExprFromLayer(e){return e.type==="sublayer"?this.initMapImageExpressions?.[e?.layer?.id??""]?.[e.id]??"":this.initDefExpressions?.[e.id]??""}getInitDefExprFromLayerExpression(e){return e?.sublayerId!=null?this.initMapImageExpressions?.[e.id]?.[e.sublayerId]??"":this.initDefExpressions?.[e.id]??""}findFilterLayer(e){let t=this.view.map?.allLayers.concat(this.view.map?.allTables.toArray()??[])?.find(({id:i})=>i===e.id);return t?.type==="map-image"?t?.findSublayerById(e.sublayerId):t}createLabel(e,t){if(e.type==="coded-value")return e?.codedValues?.[t]??t;if(e.type==="number"&&typeof t=="number"){let i=t;return e.format?.places!=null&&(i=this.roundNumber(t,e.format.places)),e.format?.digitSeparator?this.numberWithCommas(i):i}if(e.type==="date"&&!e.dateOnly){let i=m.convertDateFormatToIntlOptions("short-date-long-time");return m.formatDate(t,i)}if(e.type==="time-only"){let i=m.convertDateFormatToIntlOptions("long-time");return m.formatTimeOnly(t,i)}return t}buildDateExpression(e,t){if(e){let i=new Date(e),s=new Date(e),n=new Date(s.setDate(i.getDate()+1)),a=`${i.getFullYear()}-${i.getMonth()+1}-${i.getDate()}`,r=`${i.getHours()}:${i.getMinutes()}:${i.getSeconds()}`,o=`${n.getHours()}:${n.getMinutes()}:${n.getSeconds()}`,c=`${n.getFullYear()}-${n.getMonth()+1}-${n.getDate()}`;return`${t} BETWEEN '${a} ${r}' AND '${c} ${o}'`}}async getQueryLayer(e){let t=e.type==="sublayer"?await e.createFeatureLayer():e;if(!t)throw new Error("Failed to create feature layer");return t}applyCacheHint(e,t){e?.capabilities?.query?.supportsCacheHint&&(t.cacheHint=!0)}applyQueryGeometryFromExtentSelector(e){if(!this.extentSelector||!this.extentSelectorConfig)return;let t=this.getExtent(this.extentSelector,this.extentSelectorConfig);t&&(e.geometry=t,e.spatialRelationship="intersects")}async updateInitExpressions(){if(!this.view?.map)return;let e=await this.getInitMap();this.initDefExpressions={},this.initPointCloudFilters={},this.initMapImageExpressions={},e.allLayers.concat(e.allTables.toArray()??[]).forEach(t=>{if(!g.includes(t.type))return;let i=t;if(i.type==="point-cloud")this.initPointCloudFilters||(this.initPointCloudFilters={}),this.initPointCloudFilters[i.id]=i.filters;else if(i.type==="map-image")this.initMapImageExpressions||(this.initMapImageExpressions={}),this.initMapImageExpressions[i.id]=i.allSublayers.reduce((s,n)=>(s[n.id]=n.definitionExpression??"",s),{});else{if(!this.initDefExpressions)return;this.initDefExpressions[i.id]=i.definitionExpression??""}}),this.isInitUpdateComplete=!0}sortCodedValues(e){typeof e.fields?.[0]=="number"?e.fields=[...new Set(e.fields)].sort((t,i)=>{let s=e.codedValues?.[t],n=e.codedValues?.[i];return(s??t)-(n??i)}):e.fields=[...new Set(e.fields)].sort((t,i)=>{let s=e.codedValues?.[t],n=e.codedValues?.[i],a=s??t,r=n??i;return a.localeCompare(r)})}render(){let e=this.loading?this.renderLoading():this.initFilterConfig(),t=this.renderFooter();return l`<calcite-panel class=${p(this.baseClass)} ${v(this.panelEl)}><slot slot=header-content name=filter-header-content></slot><slot slot=header-actions-end name=filter-header-actions-end></slot>${x("filter-container",l`<div class=${p(d.filterContainer)}>${e}${t}</div>`)}</calcite-panel>`}renderLoading(){return l`<calcite-loader label="Loading filters..."></calcite-loader>`}renderFilter(e){let{id:t}=e;return e.expressions.map((i,s)=>i.type==="checkbox"||i.type==null?x(`${t}-${s}`,l`<div class=${p(d.filterItemContainer)}><div class=${p(d.filterItemTitle)}><p>${i.name}</p></div><div class=${p(d.checkboxContainer)}><calcite-checkbox id=${i.id.toString()??h} scale=l .checked=${i?.active} @calciteCheckboxChange=${this.handleCheckboxChange.bind(this,e,i)}></calcite-checkbox></div></div>`):this.initInput(e,i))}renderLayerBlock(){return this.filterLayerExpressions?.map(e=>this.renderFilterBlocks(e))}renderFilterBlocks(e){let t=this.renderFilter(e),{operator:i}=e,s=i?.trim()==="OR"?"orOperator":"andOperator",n=this.renderZoomTo(e);return x(e.id,l`<calcite-block .heading=${e.title} .description=${this._messages[s]} .expanded=${this.openFilters?!0:void 0} collapsible>${n}${t}</calcite-block>`)}renderCombobox(e,t){return x("combo-select",l`<label class=${p(d.filterUIItemContainer)}><span>${t.name}</span><calcite-combobox id=${t.id.toString()??h} @calciteComboboxChange=${this.handleComboSelect.bind(this,t,e)} .label=${t.name} .placeholder=${t.placeholder} selection-mode=multiple max-items=6 scale=s .overlayPositioning=${this.comboboxOverlayPositioning}>${t.fields?.map((i,s)=>this.renderComboboxItem(t,i,s))}</calcite-combobox></label>`)}renderComboboxItem(e,t,i){let s=this.createLabel(e,t),n=e?.selectedFields?.includes(t)??!1;return x(`${s}-${i}`,l`<calcite-combobox-item .value=${t} .heading=${`${s}`} .selected=${n}></calcite-combobox-item>`)}renderNumberSlider(e,t){let i=t?.min,s=t?.max,n=t?.step?t.step:1,a=i!=null&&s!=null,r=t?.field??"",o=t?.range?.min!=null?t.range.min:i,c=t?.range?.max!=null?t.range.max:s,u=[o,c];return a?x(t?.id.toString(),l`<label class=${p(d.filterUIItemContainer)}><span>${t?.name}</span><div class=${p(d.numberInputContainer)}><calcite-slider id=${t?.id.toString()??h} @calciteSliderChange=${this.handleSliderChange.bind(this,t,e)} .min=${i} .max=${s} .minValue=${i} .maxValue=${s} .minLabel=${this._messages.minSlider?.replace("{field}",r)} .maxLabel=${this._messages.maxSlider?.replace("{field}",r)} .step=${n} label-handles snap .value=${u} .groupSeparator=${t?.format?.digitSeparator} precise></calcite-slider></div></label>`):void 0}renderDatePicker(e,t){let{min:i,max:s}=t,n=[t?.range?.min,t?.range?.max];return i!=null&&s!=null?l`<label class=${p(d.filterUIItemContainer)}><span>${t?.name}</span><div class=${p(d.dateInputContainer)}><calcite-input-date-picker id=${t?.id.toString()??h} @calciteInputDatePickerChange=${this.handleDatePickerRangeChange.bind(this,t,e)} .min=${i} .max=${s} calendars=1 overlay-positioning=fixed lang=${m.getLocale()??"en"??h} layout=vertical .value=${n} range></calcite-input-date-picker><calcite-action @click=${this.handleResetDatePicker.bind(this,t,e)} icon=reset .text=${this._messages.resetDatePicker} title=${this._messages.resetDatePicker??h} scale=s></calcite-action></div></label>`:void 0}renderTimePicker(e,t){let{min:i,max:s,range:n}=t,a=i!=null&&s!=null,r=n?.min!=null?n.min:i,o=n?.max!=null?n.max:s;return a?l`<label class=${p(d.filterUIItemContainer)}><span>${t?.name}</span><div class=${p(d.timeInputContainer)}><calcite-input-time-picker .id=${`${t?.id.toString()}-min`} .value=${r} overlay-positioning=fixed lang=${m.getLocale()??"en"??h} @calciteInputTimePickerChange=${this.handleTimePickerRangeChange.bind(this,t,e,!0)}></calcite-input-time-picker><calcite-input-time-picker .id=${`${t?.id.toString()}-max`} .value=${o} overlay-positioning=fixed lang=${m.getLocale()??"en"??h} @calciteInputTimePickerChange=${this.handleTimePickerRangeChange.bind(this,t,e,!1)}></calcite-input-time-picker><calcite-action @click=${this.handleResetTimePicker.bind(this,t,e)} icon=reset .text=${this._messages.resetTimePicker} title=${this._messages.resetTimePicker??h} scale=s></calcite-action></div></label>`:void 0}renderFooter(){let e=this.closeBtnText??this._messages.close,t=this.closeBtn&&this.resetBtn?"half":"full";return l`<div class=${p(d.footer)} slot=footer>${this.resetBtn?l`<calcite-button appearance=outline .width=${t} @click=${this.handleResetFilter} ${v(this.resetBtnEl)}>${this._messages.resetFilter}</calcite-button>`:void 0}${this.closeBtn?l`<calcite-button appearance=solid .width=${t} kind=brand @click=${this.closeBtnOnClick}>${e}</calcite-button>`:void 0}</div>`}renderZoomTo(e){let t=e?.sublayerId?`zoom-to-${e.id}-${e.sublayerId}`:`zoom-to-${e.id}`;return this.zoomBtn?l`<calcite-action id=${t??h} slot=actions-end appearance=transparent .text=${this._messages.zoomTo} title=${this._messages.zoomTo??h} scale=s icon=magnifying-glass-plus @click=${this.handleZoomTo.bind(this,e)}></calcite-action>`:void 0}};I("instant-apps-filter-list",C);return C},"geometry/support/jsonUtils","intl","WebMap","WebScene")