/* COPYRIGHT Esri - https://js.arcgis.com/1.2/LICENSE.txt */
import b from"./T2ZUVHM7.js";import a from"./HUJP6DFF.js";import{a as m}from"./XN2LWKJE.js";import"./4BPRM7CL.js";import"./NIL6NWG5.js";import{b as g}from"./ODCCVHGI.js";import{F as c,G as p,H as f,J as n,h,i as r,r as s,u as d}from"./42WFQ3AX.js";import"./3QPJ2JCA.js";export default $arcgis.t(([w,a,,{e:u}])=>{var y=h`@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;
}

#feature-form {
  padding-top: 0px;
}

.esri-editor__prompt--danger {
  position: relative !important;
  width: 100% !important;
  background-color: var(--calcite-color-foreground-1) !important;
}

.esri-feature__content-node {
  background-color: var(--calcite-color-foreground-1) !important;
}

.hide-editor-toolbar .esri-editor__panel-toolbar {
  display: none !important;
}

.position-absolute {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  overflow: auto;
}

/* override the padding of the feature form */
.esri-editor__panel-content {
  padding-block: 10px !important;
}
}`,l=class extends f{constructor(){super(),this.enableEditGeometry=!1,this.enableSnapping=!1,this.graphicIndex=0,this.graphics=[],this.open=!1,this.allowMultipleEditing=!1,this._editorLoading=!1,this._translations=m({name:"edit-card",blocking:!0}),this._editContainer=c(),this._shouldClose=!1,this._shouldEmitEditsComplete=!1,this.closeEdit=s(),this.editorInitialized=s(),this.editsComplete=s(),this.refreshGraphics=s(),this.creatingFeature=s(),this.listenOn(window,"featureSelectionChange",this.featureSelectionChange),this.listenOn(window,"mapChanged",this.mapChanged)}static{this.properties={enableEditGeometry:[5,{},{type:Boolean}],enableSnapping:[5,{},{type:Boolean}],graphicIndex:[9,{},{type:Number}],graphics:[0,{},{attribute:!1}],mapView:[0,{},{attribute:!1}],open:[5,{},{type:Boolean}],allowMultipleEditing:[5,{},{type:Boolean}],_editorLoading:[16,{},{state:!0}],_translations:[16,{},{state:!0}]}}static{this.styles=y}static{this.shadowRootOptions=d}async graphicsWatchHandler(){this.graphics.length===0&&this.open&&await this._closeEdit(!0)}async openWatchHandler(t){t&&this.graphics?.length>0&&this.graphicIndex>-1&&(this._editorLoading=!0,await this._initEditorWidget(),this.graphicIndex>-1&&this.graphics.length>0&&this.open&&!this._shouldClose&&await this._startUpdate(),this._editorLoading=!1),t||await this._closeEdit(!0)}async featureSelectionChange(){this.open&&await this._closeEdit(!1)}async mapChanged(){this.open&&await this._closeEdit(!1)}willUpdate(t){if(t.has("graphics")&&this.graphicsWatchHandler(),t.has("open")&&(this.hasUpdated||this.open!==!1)&&this.openWatchHandler(this.open),this.graphics?.length>0&&this.graphics[0]?.layer){this._layer=this.graphics[0].layer,this._layerEditHandle&&this._layerEditHandle.remove();let i=this._layer.type==="subtype-sublayer"?this._layer.parent:this._layer;i&&(this._layerEditHandle=i.on("edits",()=>{this._shouldEmitEditsComplete=!0}))}}render(){let t=this.graphics?.length>0&&this.graphics[0]?!this.graphics[0].layer.editingEnabled:!0,i=this._editorLoading?"display-none":"position-absolute",o=this._editorLoading?"":"display-none";return r`<div class="position-absolute">${t?r`<calcite-notice kind=warning open slot=content-top width=full><div slot=message>${this._translations.enableEditing}</div></calcite-notice>`:void 0}<div class="position-absolute"><div class=${n(i)} id=feature-form ${p(this._editContainer)}></div><calcite-loader class=${n(o)} label scale=s></calcite-loader></div></div>`}async _initEditorWidget(){if(this.mapView&&this.graphics&&this.graphics.length>0&&this.graphics[0]){this._editor&&this._editor.destroy();let t=document.createElement("div"),i=await u(this.mapView),o=this.enableSnapping&&this.enableEditGeometry,_=i.map(e=>({layer:e,geometryUpdatesEnabled:this.enableEditGeometry}));this._editor=new w({view:this.mapView,layerInfos:_,visibleElements:{flow:!0,settingsMenu:o,sketch:!1,snappingControls:o},container:t}),this._attachmentHandle&&this._activeWorkflowHandle&&(this._attachmentHandle.remove(),this._activeWorkflowHandle.remove()),this._attachmentHandle=a.when(()=>this._editor?.viewModel.state==="adding-attachment"||this._editor?.viewModel.state==="editing-attachment"||this._editor?.viewModel.state==="creating-features",()=>{this._shouldClose=!1}),this._activeWorkflowHandle=a.watch(()=>this._editor?.viewModel.activeWorkflow,e=>{(e?.type==="update"||e?.type==="create-features")&&(this._shouldClose=!1),(!e?.type&&!e?.hasPendingEdits&&!this._editor?.activeWorkflow||!this._editor?.activeWorkflow?.started)&&(this.allowMultipleEditing=!1,this.open=!1)}),a.watch(()=>this._editor?.viewModel.state,e=>{e==="creating-features"&&this.graphics[0].layer.isTable&&!(this._editor?.viewModel).featureTemplatesLayers.items[0].isTable&&this.creatingFeature.emit(),this._shouldEmitEditsComplete&&e==="ready"&&!this._editor?.activeWorkflow&&(this.editsComplete.emit(),this._shouldEmitEditsComplete=!1)}),this.enableSnapping||t.classList.add("hide-editor-toolbar"),this._editContainer.value&&this._editContainer.value.appendChild(t),this._editor&&this.editorInitialized.emit(this._editor)}}async _closeEdit(t){this._shouldClose=!0,t&&this._editor?.activeWorkflow?(this._editor.activeWorkflow?.activeWorkflow?.hasPendingEdits&&(await this._editor.activeWorkflow.reset(),await this._editor.cancelWorkflow()),this._editor.destroy()):this.graphicIndex>-1&&this.graphics?.length>0&&this.refreshGraphics.emit(this.graphics),this.enableSnapping&&((this.mapView?.ui.view).grid=null),this._shouldClose=!1,this.closeEdit.emit()}async _startUpdate(){this.allowMultipleEditing?await this._editor?.startUpdateFeaturesWorkflow(this.graphics):await this._editor?.startUpdateWorkflowAtFeatureEdit(this.graphics[this.graphicIndex]),this._shouldClose=!0}};g("edit-card",l);return l},"widgets/Editor","core/reactiveUtils",a,b)