/* COPYRIGHT Esri - https://js.arcgis.com/1.2/LICENSE.txt */
import{b as m}from"./RFGSSUZF.js";import{F as l,G as d,H as p,h as n,i as o}from"./5CQPQ7AE.js";import"./3QPJ2JCA.js";export default $arcgis.t(([f,w])=>{var S=n`:host{display:block}.search-widget{width:100%!important;border:1px solid var(--calcite-color-border-input)}`,s=class extends p{constructor(){super(...arguments),this.popupEnabled=!1,this.resultGraphicEnabled=!1,this.searchTerm="",this._searchElement=l()}static{this.properties={mapView:0,popupEnabled:5,resultGraphicEnabled:5,searchConfiguration:0,searchTerm:1,searchWidget:0}}static{this.styles=S}willUpdate(i){i.has("searchConfiguration")&&this.watchSearchConfigurationHandler(),i.has("mapView")&&this.mapViewWatchHandler()}async watchSearchConfigurationHandler(){this._initSearchWidget()}async mapViewWatchHandler(){await this.mapView?.when(()=>{this._initSearchWidget()})}loaded(){return this._initSearchWidget()}render(){return o`<div class="search-widget" ${d(this._searchElement)}></div>`}_initSearchWidget(){if(this.mapView&&this._searchElement.value&&!this.searchWidget){let i={view:this.mapView,container:this._searchElement.value,searchTerm:this.searchTerm};this.searchConfiguration&&(i={...this._getSearchConfig(this.searchConfiguration,this.mapView)}),this.searchWidget=new f(i),this.searchWidget&&(this.searchWidget.popupEnabled=this.popupEnabled,this.searchWidget.resultGraphicEnabled=this.resultGraphicEnabled)}else this.searchWidget&&(this.searchWidget.view=this.mapView)}_getSearchConfig(i,u){let g="includeDefaultSources",t=i.sources;return t&&t?.length>0?(i[g]=!1,t.forEach(r=>{if(r.hasOwnProperty("layer")){let e=r,a=e.layer?.id,h=a?u.map?.findLayerById(a):null,c=e?.layer?.url;h?e.layer=h:c&&(e.layer=new w(c))}}),t?.forEach(r=>{if(r.hasOwnProperty("locator")){let e=r;if(e?.name==="ArcGIS World Geocoding Service"){let a=e.outFields||["Addr_type","Match_addr","StAddr","City"];e.outFields=a,e.singleLineFieldName="SingleLine"}e.url=e.url,delete e.url}})):i={...i,includeDefaultSources:!0},i}};m("map-search",s);return s},"widgets/Search","layers/FeatureLayer")