/* COPYRIGHT Esri - https://js.arcgis.com/1.2/LICENSE.txt */
import{b as m}from"./ABSRNM72.js";import{F as d,G as p,H as u,h,i as l}from"./5CQPQ7AE.js";import"./3QPJ2JCA.js";export default $arcgis.t(([y,w])=>{var S=h`/** @license
 * Copyright 2025 Esri
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

:host {
  display: block;
}

.search-widget {
  width: 100% !important;
  border: 1px solid var(--calcite-color-border-input);
}`,a=class extends u{constructor(){super(...arguments),this.popupEnabled=!1,this.resultGraphicEnabled=!1,this.searchTerm="",this._searchElement=d()}static{this.properties={mapView:[0,{},{attribute:!1}],popupEnabled:[5,{},{type:Boolean}],resultGraphicEnabled:[5,{},{type:Boolean}],searchConfiguration:[0,{},{attribute:!1}],searchTerm:1,searchWidget:[0,{},{attribute:!1}]}}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 l`<div class="search-widget" ${p(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 y(i),this.searchWidget&&(this.searchWidget.popupEnabled=this.popupEnabled,this.searchWidget.resultGraphicEnabled=this.resultGraphicEnabled)}else this.searchWidget&&(this.searchWidget.view=this.mapView)}_getSearchConfig(i,o){let f="includeDefaultSources",r=i.sources;return r&&r?.length>0?(i[f]=!1,r.forEach(t=>{if(t.hasOwnProperty("layer")){let e=t,s=e.layer?.id,c=s?o.map?.findLayerById(s):null,n=e?.layer?.url;c?e.layer=c:n&&(e.layer=new w(n))}}),r?.forEach(t=>{if(t.hasOwnProperty("locator")){let e=t;if(e?.name==="ArcGIS World Geocoding Service"){let s=e.outFields||["Addr_type","Match_addr","StAddr","City"];e.outFields=s,e.singleLineFieldName="SingleLine"}e.url=e.url,delete e.url}})):i={...i,includeDefaultSources:!0},i}};m("map-search",a);return a},"widgets/Search","layers/FeatureLayer")