/* COPYRIGHT Esri - https://js.arcgis.com/1.2/LICENSE.txt */
import{b as m}from"./ABSRNM72.js";import{F as o,G as n,H as p,h as t,i as r}from"./5CQPQ7AE.js";import"./3QPJ2JCA.js";export default $arcgis.t(([l,c])=>{var h=t`/** @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.
 */

.display-block {
  display: block;
}`,a=class extends p{constructor(){super(...arguments),this._basemapElement=o()}static{this.properties={mapView:[0,{},{attribute:!1}],basemapConfig:[0,{},{attribute:!1}],basemapWidget:[0,{},{attribute:!1}]}}static{this.styles=h}willUpdate(e){e.has("basemapConfig")&&this.basemapConfigWatchHandler(),e.has("mapView")&&this.mapViewWatchHandler()}async basemapConfigWatchHandler(){if(this.basemapWidget?.source){let e=this.basemapWidget?.source;e.query=this.basemapConfig?.basemapGroupId?`id:${this.basemapConfig.basemapGroupId}`:null,await e.refresh()}}async mapViewWatchHandler(){this.mapView!==void 0&&await this.mapView.when(()=>{this._initBaseMapGallery(this.mapView)})}render(){return r`<div class="display-block" ${n(this._basemapElement)}></div>`}loaded(){this.mapView&&this.mapViewWatchHandler()}async _initBaseMapGallery(e){if(e){let i=new c({query:this.basemapConfig?.basemapGroupId?`id:${this.basemapConfig.basemapGroupId}`:null,filterFunction:this.basemapConfig?s=>s?.portalItem?.id&&this.basemapConfig?!this.basemapConfig.basemapIdsToFilter.includes(s?.portalItem?.id):!0:()=>!0});await i.refresh(),this.basemapWidget?(this.basemapWidget.view=e,this.basemapWidget.source=i):this.basemapWidget=new l({container:this._basemapElement.value,view:e,source:i})}}};m("map-basemap-gallery",a);return a},"widgets/BasemapGallery","widgets/BasemapGallery/support/PortalBasemapsSource")