/* COPYRIGHT Esri - https://js.arcgis.com/1.2/LICENSE.txt */
import b from"./N6IQW2WT.js";import a from"./C2LXNVZ5.js";import{b as n}from"./ABSRNM72.js";import{H as c,h as o,r as s,u as r}from"./5CQPQ7AE.js";import"./3QPJ2JCA.js";export default $arcgis.t(([p,m,,{c:h}])=>{var d=o`@layer{
/** @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;
  pointer-events: all !important;
}
}`,a=class extends c{constructor(){super(...arguments),this.selectedLayerId="",this.tool="rectangle",this.drawingComplete=s(),this.featuresSelected=s()}static{this.properties={mapView:[0,{},{attribute:!1}],selectedLayerId:1,tool:1}}static{this.styles=d}static{this.shadowRootOptions=r}willUpdate(e){e.has("mapView")&&this.mapViewWatchHandler()}async mapViewWatchHandler(){await this.mapView?.when(()=>{this._initSketchViewModel()})}async toggleSelectionTool(e,t){if(this._graphicsLayer?.removeAll(),this._selectionTool?.state==="active"&&this._selectionTool.cancel(),t){let i=e??this.tool;this._selectionTool?.create(i)}}async loaded(){await this.init()}render(){return""}async init(){this.mapView&&this._initSketchViewModel()}_initSketchViewModel(){this._graphicsLayer=new p({listMode:"hide"}),this._selectionTool=new m({layer:this._graphicsLayer,view:this.mapView}),this._selectionTool&&this._selectionTool.on("create",e=>{if(e.state==="complete"){this.drawingComplete.emit();let t=e.graphic?.geometry;t&&this._selectFeatures(t),this._graphicsLayer&&this._graphicsLayer.removeAll()}}),this.mapView?.map&&this._graphicsLayer&&this.mapView.map.layers.add(this._graphicsLayer)}async _selectFeatures(e){let t=this.mapView&&await h(this.mapView,this.selectedLayerId);try{let i={geometry:e},l=t&&await t.queryObjectIds(i);this.featuresSelected.emit(l)}catch(i){console.error("Error selecting features:",i)}}};n("selection-tool",a);return a},"layers/GraphicsLayer","widgets/Sketch/SketchViewModel",a,b)