@arcgis/core 4.33.0-next.20250608 → 4.33.0-next.20250610

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import"../../intl.js";import{isSome as e}from"../../core/arrayUtils.js";import{neverReached as t}from"../../core/compilerUtils.js";import{equalsShallow as r}from"../../core/lang.js";import n from"../../core/Logger.js";import{templateHasKey as o,replace as i}from"../../core/string.js";import{isFieldElement as s}from"../../form/support/formUtils.js";import{DomainValidationError as l}from"../../layers/support/domainUtils.js";import{isTimeOnlyField as u,NumericRangeValidationError as a,TypeValidationError as p}from"../../layers/support/fieldUtils.js";import{isSubtypeSublayer as m,getSubtypesFromLayer as f}from"../../layers/support/layerUtils.js";import{isAnyDateField as d}from"../../smartMapping/support/utils.js";import{getLabelForDateFieldValue as c,getIntlOptionsForField as y}from"../support/dateUtils.js";import{InputValidationError as g,getRangeErrorMessage as b,shouldUseScientificNotation as j,scientificNumberFormatOptions as T,numberFormatOptions as N}from"../support/forms/formUtils.js";import{getFeatureTitle as x}from"../support/UtilityNetworkAssociations/utils/getFeatureTitle.js";import{substitute as F}from"../../intl/substitute.js";const O=e=>"field"===e?.type,V=e=>"group"===e?.type,h=e=>"relationship"===e?.type,U=e=>"text"===e.type,v=e=>"utilityNetworkAssociations"===e.type,E=e=>!V(e)&&null!=e.group,_=(e,t)=>E(e)&&e.group===t,L=e=>e.reduce(((e,t)=>V(t)?[...e,...t.inputs]:[...e,t]),[]),A=e=>L(e).filter(O),I=e=>L(e).filter(h),$=e=>L(e).filter(v),w=e=>null!=e&&(C(e,"combo-box")||C(e,"radio-buttons")),C=(e,t)=>null!=e&&e.input?.type===t,Z=({domain:e,inputType:t="text-box",dataType:r})=>"number"===r&&"text-box"===t&&(!e||"coded-value"!==e.type);function D(e,t){const{title:r,feature:n}=e??{};return r||(n?x(n):null)||t||""}function k(t){const{attributes:r,fieldsIndex:n,label:i,timeZone:s}=t;if(!r||"object"!=typeof r)return i;const l=Object.keys(r).filter((e=>o(i,e))),u=l.map((e=>r[e])),a=l.map((e=>n.get(e))).filter(e);return q(i,H({values:u,fields:a,timeZone:s}))}const G="expression/",R="expr/",S="field/";function B(e){const[t,r]=e.split(G);return""===t&&r?r:(n.getLogger("esri.widgets.FeatureForm/featureFormUtils").error("extractExpressionNameFromString:invalid-input",`The string ${e} is not a valid expression reference of the form '${G}/expressionName'`),"")}function M(e){return`${G}${e}`}function P(e){return`${S}${e}`}function W(e){return e.startsWith(G)}function Y(e){return e.startsWith(R)}function H(e){const{fields:t,values:r}=e,n=e.timeZone??void 0,o=t.map(((e,t)=>{let o=r[t];if(e.domain&&"coded-value"===e.domain.type){const t=e.domain.codedValues.find((e=>e.code===o));t?.name&&(o=t.name)}return(d(e)||u(e))&&(o=c(e,o,{timeZone:n,...y(e)})),[e.name,o]}));return Object.fromEntries(o)}function q(e,t){return i(i(e,(e=>`{${e.toLowerCase()}}`)),Object.fromEntries(Object.entries(t).map((([e,t])=>[e.toLowerCase(),t]))))}const z=e=>{const t={typeFieldName:null,types:[]};return e?(m(e)?(t.typeFieldName=e.parent?.subtypeField,t.types=e.parent?.subtypes??[]):"subtype-group"===e.type||"feature"===e.type&&e.subtypes?.length?(t.typeFieldName=e.subtypeField,t.types=e.subtypes??[]):"types"in e&&e.types&&(t.typeFieldName=e.typeIdField,t.types=e.types.map((({id:e,name:t,domains:r})=>({code:e,name:t,domains:r})))),null!=t.typeFieldName&&(t.typeFieldName=e.getField(t.typeFieldName)?.name??t.typeFieldName),t):t},J=(e,t,r)=>{const{dataType:n,error:o,minLength:i}=e,s=t?.validationErrors;if(!s||!o)return null;if(o===g.CANNOT_BE_EMPTY)return s.cannotBeNull;if(o===l.VALUE_OUT_OF_RANGE||o===a.OUT_OF_RANGE){const{field:t,range:o}=e,i={type:"date",intlOptions:{timeZone:"date"===t.type&&r?r:void 0,...y(t)}},l=b(o,s);return F(l,o,{format:{max:"date"===n?i:null!=o.max&&j(o.max)?T:N,min:"date"===n?i:null!=o.min&&j(o.min)?T:N}})}return o===l.INVALID_CODED_VALUE?s.invalidCodedValue:o===p.INVALID_TYPE?s.invalidType:o===g.TOO_SHORT?F(s.tooShort,{min:i}):(g.TOO_LONG,null)},K=e=>{if(!e)return;const t=e.layer,r=t&&"geometryType"in t?t.geometryType:void 0,n=e.geometry?.type;return"polyline"===n||"polyline"===r?"line":"mesh"===n||"mesh"===r||"multipatch"===r?"cube":"multipoint"===n||"multipoint"===r?"point":n||r||"table"},Q=e=>{const t=[];if(e.formTemplate){const{description:r,title:n}=e.formTemplate;e.fields?.forEach((e=>{const i=n&&o(n,e.name),s=r&&o(r,e.name);(i||s)&&t.push(e.name)}))}return t};function X(e,t){const r=t??("formTemplate"in e&&e.formTemplate);if(r){return(r.elements?.filter(s)??[]).some((({fieldName:t})=>!e.fieldsIndex.get(t)))}return!1}function ee(e,t){return null==e||t.onValue!==e&&t.offValue!==e}function te(e,r){switch(r.objectType){case"any":return!0;case"null":return null==e;case"code":return e===r.codedValue?.code;case"range":return null!=e&&null!=r.minValue&&null!=r.maxValue&&+e>=r.minValue&&+e<=r.maxValue;default:return t(r.objectType),!1}}function re(e,t,n){const o=f(e),i=o?.find((e=>e.code===n));if(!i)return!1;const s=o?.find((e=>e.code===t));return!r(i.defaultValues,s?.defaultValues)&&Object.values(i.defaultValues).some((e=>null!=e))}export{B as extractExpressionNameFromString,$ as flattenAssociationInputs,A as flattenFieldInputs,L as flattenInputs,I as flattenRelationshipInputs,X as formTemplateHasInvalidFields,H as getComputedAttributes,J as getErrorMessageForFieldInput,D as getFeatureFormTitle,Q as getFieldsInTitleAndDesc,K as getIconForFeature,z as getNormalizedFeatureTypeInfo,W as isExpressionReference,C as isFieldElementWithInputType,w as isFieldElementWithShowNoValueOptionInput,O as isFieldInput,V as isGroupInput,E as isInputInGroupInput,_ as isInputInThisGroupInput,Y as isLegacyFieldMapsExpressionReference,Z as isNumberFieldInput,h as isRelationshipInput,U as isTextElementInput,v as isUtilityNetworkAssociationInput,k as parseFormTemplateString,M as prependExpressionPrefix,P as prependFieldPrefix,q as substituteFieldTemplatesInString,re as subtypeChangeShouldPrompt,ee as valueIsInvalidSwitchValue,te as valueIsValidContingentValue};
5
+ import"../../intl.js";import{isSome as e}from"../../core/arrayUtils.js";import{neverReached as t}from"../../core/compilerUtils.js";import{equalsShallow as r}from"../../core/lang.js";import n from"../../core/Logger.js";import{templateHasKey as o,replace as i}from"../../core/string.js";import{isFieldElement as s}from"../../form/support/formUtils.js";import{DomainValidationError as l}from"../../layers/support/domainUtils.js";import{isTimeOnlyField as a,NumericRangeValidationError as u,TypeValidationError as p}from"../../layers/support/fieldUtils.js";import{isSubtypeSublayer as m,getSubtypesFromLayer as f}from"../../layers/support/layerUtils.js";import{isAnyDateField as d}from"../../smartMapping/support/utils.js";import{getLabelForDateFieldValue as c,getIntlOptionsForField as y}from"../support/dateUtils.js";import{InputValidationError as b,getRangeErrorMessage as g,shouldUseScientificNotation as j,scientificNumberFormatOptions as T,numberFormatOptions as x}from"../support/forms/formUtils.js";import{substitute as N}from"../../intl/substitute.js";const F=e=>"field"===e?.type,O=e=>"group"===e?.type,V=e=>"relationship"===e?.type,h=e=>"text"===e.type,v=e=>"utilityNetworkAssociations"===e.type,E=e=>!O(e)&&null!=e.group,U=(e,t)=>E(e)&&e.group===t,_=e=>e.reduce(((e,t)=>O(t)?[...e,...t.inputs]:[...e,t]),[]),L=e=>_(e).filter(F),A=e=>_(e).filter(V),I=e=>_(e).filter(v),$=e=>null!=e&&(w(e,"combo-box")||w(e,"radio-buttons")),w=(e,t)=>null!=e&&e.input?.type===t,C=({domain:e,inputType:t="text-box",dataType:r})=>"number"===r&&"text-box"===t&&(!e||"coded-value"!==e.type);function Z(t){const{attributes:r,fieldsIndex:n,label:i,timeZone:s}=t;if(!r||"object"!=typeof r)return i;const l=Object.keys(r).filter((e=>o(i,e))),a=l.map((e=>r[e])),u=l.map((e=>n.get(e))).filter(e);return Y(i,W({values:a,fields:u,timeZone:s}))}const D="expression/",G="expr/",R="field/";function S(e){const[t,r]=e.split(D);return""===t&&r?r:(n.getLogger("esri.widgets.FeatureForm/featureFormUtils").error("extractExpressionNameFromString:invalid-input",`The string ${e} is not a valid expression reference of the form '${D}/expressionName'`),"")}function k(e){return`${D}${e}`}function B(e){return`${R}${e}`}function M(e){return e.startsWith(D)}function P(e){return e.startsWith(G)}function W(e){const{fields:t,values:r}=e,n=e.timeZone??void 0,o=t.map(((e,t)=>{let o=r[t];if(e.domain&&"coded-value"===e.domain.type){const t=e.domain.codedValues.find((e=>e.code===o));t?.name&&(o=t.name)}return(d(e)||a(e))&&(o=c(e,o,{timeZone:n,...y(e)})),[e.name,o]}));return Object.fromEntries(o)}function Y(e,t){return i(i(e,(e=>`{${e.toLowerCase()}}`)),Object.fromEntries(Object.entries(t).map((([e,t])=>[e.toLowerCase(),t]))))}const H=e=>{const t={typeFieldName:null,types:[]};return e?(m(e)?(t.typeFieldName=e.parent?.subtypeField,t.types=e.parent?.subtypes??[]):"subtype-group"===e.type||"feature"===e.type&&e.subtypes?.length?(t.typeFieldName=e.subtypeField,t.types=e.subtypes??[]):"types"in e&&e.types&&(t.typeFieldName=e.typeIdField,t.types=e.types.map((({id:e,name:t,domains:r})=>({code:e,name:t,domains:r})))),null!=t.typeFieldName&&(t.typeFieldName=e.getField(t.typeFieldName)?.name??t.typeFieldName),t):t},q=(e,t,r)=>{const{dataType:n,error:o,minLength:i}=e,s=t?.validationErrors;if(!s||!o)return null;if(o===b.CANNOT_BE_EMPTY)return s.cannotBeNull;if(o===l.VALUE_OUT_OF_RANGE||o===u.OUT_OF_RANGE){const{field:t,range:o}=e,i={type:"date",intlOptions:{timeZone:"date"===t.type&&r?r:void 0,...y(t)}},l=g(o,s);return N(l,o,{format:{max:"date"===n?i:null!=o.max&&j(o.max)?T:x,min:"date"===n?i:null!=o.min&&j(o.min)?T:x}})}return o===l.INVALID_CODED_VALUE?s.invalidCodedValue:o===p.INVALID_TYPE?s.invalidType:o===b.TOO_SHORT?N(s.tooShort,{min:i}):(b.TOO_LONG,null)},z=e=>{if(!e)return;const t=e.layer,r=t&&"geometryType"in t?t.geometryType:void 0,n=e.geometry?.type;return"polyline"===n||"polyline"===r?"line":"mesh"===n||"mesh"===r||"multipatch"===r?"cube":"multipoint"===n||"multipoint"===r?"point":n||r||"table"},J=e=>{const t=[];if(e.formTemplate){const{description:r,title:n}=e.formTemplate;e.fields?.forEach((e=>{const i=n&&o(n,e.name),s=r&&o(r,e.name);(i||s)&&t.push(e.name)}))}return t};function K(e,t){const r=t??("formTemplate"in e&&e.formTemplate);if(r){return(r.elements?.filter(s)??[]).some((({fieldName:t})=>!e.fieldsIndex.get(t)))}return!1}function Q(e,t){return null==e||t.onValue!==e&&t.offValue!==e}function X(e,r){switch(r.objectType){case"any":return!0;case"null":return null==e;case"code":return e===r.codedValue?.code;case"range":return null!=e&&null!=r.minValue&&null!=r.maxValue&&+e>=r.minValue&&+e<=r.maxValue;default:return t(r.objectType),!1}}function ee(e,t,n){const o=f(e),i=o?.find((e=>e.code===n));if(!i)return!1;const s=o?.find((e=>e.code===t));return!r(i.defaultValues,s?.defaultValues)&&Object.values(i.defaultValues).some((e=>null!=e))}export{S as extractExpressionNameFromString,I as flattenAssociationInputs,L as flattenFieldInputs,_ as flattenInputs,A as flattenRelationshipInputs,K as formTemplateHasInvalidFields,W as getComputedAttributes,q as getErrorMessageForFieldInput,J as getFieldsInTitleAndDesc,z as getIconForFeature,H as getNormalizedFeatureTypeInfo,M as isExpressionReference,w as isFieldElementWithInputType,$ as isFieldElementWithShowNoValueOptionInput,F as isFieldInput,O as isGroupInput,E as isInputInGroupInput,U as isInputInThisGroupInput,P as isLegacyFieldMapsExpressionReference,C as isNumberFieldInput,V as isRelationshipInput,h as isTextElementInput,v as isUtilityNetworkAssociationInput,Z as parseFormTemplateString,k as prependExpressionPrefix,B as prependFieldPrefix,Y as substituteFieldTemplatesInString,ee as subtypeChangeShouldPrompt,Q as valueIsInvalidSwitchValue,X as valueIsValidContingentValue};
package/widgets/Sketch.js CHANGED
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import{isSome as t}from"../core/arrayUtils.js";import{handlesGroup as o}from"../core/handleUtils.js";import i from"../core/Logger.js";import{removeMaybe as s,destroyMaybe as l}from"../core/maybe.js";import{ignoreAbortErrors as r}from"../core/promiseUtils.js";import{watch as n,when as a,syncAndInitial as p}from"../core/reactiveUtils.js";import{property as c}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import{subclass as d}from"../core/accessorSupport/decorators/subclass.js";import u from"../views/interactive/sketch/SketchValueOptions.js";import h from"./Widget.js";import v from"./Sketch/SketchViewModel.js";import{VisibleElements as m}from"./Sketch/VisibleElements.js";import{LayoutPriority as g}from"./Sketch/support/sketchUtils.js";import f from"./Sketch/support/ResponsiveToolbar/ResponsiveToolbar.js";import{loadCalciteComponents as _}from"./support/componentsUtils.js";import y from"./support/SelectionToolbar.js";import b from"./support/SketchTooltipControls.js";import w from"./support/SnappingControls.js";import"./support/widgetUtils.js";import{messageBundle as T}from"./support/decorators/messageBundle.js";import{vmEvent as M}from"./support/decorators/vmEvent.js";import{tsx as C}from"./support/jsxFactory.js";import O from"./support/SelectionToolbar/VisibleElements.js";import S from"./support/SketchTooltipControls/VisibleElements.js";import{substitute as k}from"../intl/substitute.js";const P="esri-sketch",I={base:P,vertical:`${P}--vertical`,docked:`${P}-bar`,floating:`${P}-pad`,chipHorizontal:`${P}__selection-count-chip--horizontal`,chipVertical:`${P}__selection-count-chip--vertical`,chipVerticalSmall:`${P}__selection-count-chip--vertical--s`,popoverWrapper:`${P}__popover-wrapper`},R={point:"pin",polyline:"line",polygon:"polygon",rectangle:"rectangle",circle:"circle",multipoint:"pins",mesh:"i3d-building",freehandPolygon:"freehand-area",freehandPolyline:"freehand"};let E=class extends h{constructor(e,t){super(e,t),this._activeCustomToolOptions=null,this._selectionToolbar=null,this._viewModelHandlesGroup=null,this.availableCreateTools=["point","polyline","polygon","rectangle","circle"],this.customToolOptions=null,this.customActions=null,this.toolbarKind="floating",this.contextualToolLocation="separate",this.groupCollapsePriorities=null,this.groupAllowCollapseOptions=null,this.messages=null,this.messagesCommon=null,this.visibleElements=new m,this._defaultViewModel=null,this._calcitePopoverReferenceElement=null,this._relativeLocation="top",this._popoverOpen=!1,this._activateCreateTool=this._activateCreateTool.bind(this),this.viewModel=e?.viewModel||(this._defaultViewModel=new v({creationMode:e?.creationMode??"continuous"}))}initialize(){const{layer:e,view:t}=this,i="2d"===t?.type,l=new y({persistSelection:!1,visibleElements:new O({chip:!1,pan:!1,pointTool:!1,lassoTool:i,rectangleTool:i}),view:t,sources:e?[e]:null,scale:this.scale});this.addHandles([n((()=>this.viewModel),(e=>{this._viewModelHandlesGroup=s(this._viewModelHandlesGroup),e&&(this._viewModelHandlesGroup=o([e.on("create",(()=>this.scheduleRender())),e.on("update",(()=>this.scheduleRender())),e.on("delete",(e=>this.emit("delete",e))),e.on("undo",(()=>this.scheduleRender())),e.on("redo",(()=>this.scheduleRender())),n((()=>e.layer),(e=>{this._selectionToolbar&&(this._selectionToolbar.sources=e?[e]:null)})),n((()=>e.view),(e=>{this._selectionToolbar&&(this._selectionToolbar.view=e)})),n((()=>e.state),(()=>this.notifyChange("state")))]))}),p),a((()=>l.activeOperation),(()=>this.viewModel.cancel())),l.on("complete",(e=>this._onSelectionOperationComplete(e))),n((()=>{const{view:e,visibleElements:{selectionTools:t}}=this;return{lassoTool:"3d"!==e?.type&&!!t?.["lasso-selection"],rectangleTool:"3d"!==e?.type&&!!t?.["rectangle-selection"]}}),(e=>{Object.assign(l.visibleElements,e)}),p)]),this._selectionToolbar=l}loadDependencies(){return _({action:()=>import("@esri/calcite-components/dist/components/calcite-action"),chip:()=>import("@esri/calcite-components/dist/components/calcite-chip"),popover:()=>import("@esri/calcite-components/dist/components/calcite-popover")})}destroy(){this._selectionToolbar?.destroy(),this._viewModelHandlesGroup=s(this._viewModelHandlesGroup)}get activeTool(){const e=this._selectionToolbar?.activeOperation;if(e)switch(e.name){case"lasso":return"lasso-selection";case"rectangle":return"rectangle-selection";case"default":return"custom-selection"}const t=this._effectiveAvailableCreateTools,{activeTool:o,activeCreateToolDrawMode:i}=this.viewModel;return"polygon"===o&&"freehand"===i&&t?.includes("freehandPolygon")?"freehandPolygon":"polyline"===o&&"freehand"===i&&t?.includes("freehandPolyline")?"freehandPolyline":this.viewModel.activeTool}get activeTooltip(){return this.viewModel.activeTooltip}get createGraphic(){return this.viewModel.createGraphic}get creationMode(){return this.viewModel.creationMode}set creationMode(e){this.viewModel.creationMode=e}get defaultCreateOptions(){return this.viewModel.defaultCreateOptions}set defaultCreateOptions(e){this.viewModel.defaultCreateOptions=e}get defaultUpdateOptions(){return this.viewModel.defaultUpdateOptions}set defaultUpdateOptions(e){this.viewModel.defaultUpdateOptions=e}get icon(){return"pencil"}set icon(e){this._overrideIfSome("icon",e)}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get labelOptions(){return this.viewModel.labelOptions}set labelOptions(e){this.viewModel.labelOptions=e}get layer(){return this.viewModel.layer}set layer(e){this.viewModel.layer=e}set layout(e){this._set("layout",e),this._selectionToolbar&&(this._selectionToolbar.layout=e)}set scale(e){this._set("scale",e),this._selectionToolbar&&(this._selectionToolbar.scale=e)}get snappingOptions(){return this.viewModel.snappingOptions}set snappingOptions(e){this.viewModel.snappingOptions=e}get state(){return this._selectionToolbar?.activeOperation?"active":this.viewModel.state}get tooltipOptions(){return this.viewModel.tooltipOptions}set tooltipOptions(e){this.viewModel.tooltipOptions=e}get updateGraphics(){return this.viewModel.updateGraphics}get valueOptions(){return this.viewModel.valueOptions}set valueOptions(e){this.viewModel.valueOptions=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}set viewModel(e){const t=this._get("viewModel");e!==t&&(t&&t===this._defaultViewModel&&l(t),this._set("viewModel",e))}get _effectiveAvailableCreateTools(){const{availableCreateTools:e,view:t,visibleElements:o}=this,i=e?.filter((e=>!!o.createTools?.[e]));return"3d"===t?.type?i?.filter((e=>"multipoint"!==e)):i}create(e,t,o){const i=o?.createOptions??t;return this._activeCustomToolOptions=o,r(this.viewModel.create(e,i))}update(e,t){return r(this.viewModel.update(e,t))}complete(){this.viewModel.complete()}cancel(){this._selectionToolbar?.cancel(),this.viewModel.cancel(),this._activeCustomToolOptions=null}undo(){this.viewModel.undo(),this.view?.focus()}redo(){this.viewModel.redo(),this.view?.focus()}delete(){this.viewModel.delete()}duplicate(){return this.viewModel.duplicate()}dismissFloatingElements(){this._popoverOpen=!1}render(){const{toolbarKind:e,layout:t,scale:o}=this,i=this.customActions?.filter((e=>"selection-toolbar"===e.position));return C("div",null,C("div",{classes:{[I.base]:!0,[I.floating]:"floating"===e,[I.docked]:"docked"===e,[I.vertical]:"vertical"===t}},C(f,{barStyle:e,layout:t,scale:o},this._renderSelectionSetItemGroupInline(),C("div",{"allow-collapse":this.groupAllowCollapseOptions?.get("selectionTools")??!0,"group-kind":"split-button",key:"selection-split-button",priority:this.groupCollapsePriorities?.get("selectionTools")??g.Low},this._renderDefaultSelectionButton(),this._selectionToolbar?.render(),i?.map((e=>this._renderToolbarItem(e)))),this._renderCreateToolActionGroup(),this._renderUndoRedoMenuItemGroup(),this._renderSettingsMenuItemGroup()),this._renderSelectionSetToolbar(),this._renderSettingsMenuPopover()))}_renderSettingsMenuPopover(){const{messagesCommon:e,snappingOptions:t,view:o,viewModel:i,visibleElements:s}=this;if(!this._calcitePopoverReferenceElement)return;const l={directionModePicker:s.directionModePicker,labelsToggle:s.labelsToggle,tooltipsToggle:s.tooltipsToggle},r="horizontal"===this.layout?"top"===this._relativeLocation?"bottom-end":"top-end":"right-end";return C("calcite-popover",{closable:!0,focusTrapDisabled:!0,heading:e.settings,label:e.settings,open:this._popoverOpen,overlayPositioning:"fixed",placement:r,referenceElement:this._calcitePopoverReferenceElement,scale:this.scale,onCalcitePopoverBeforeClose:()=>this._popoverOpen=!1,onCalcitePopoverBeforeOpen:e=>this._remeasurePopoverSizes(e.currentTarget),onCalcitePopoverClose:()=>this._refocusOnView()},C("div",{class:I.popoverWrapper},Object.values(l).includes(!0)?C(b,{sketchOptions:i.sketchOptions,viewType:o?.type,visibleElements:new S(l)}):void 0,s.snappingControls&&o&&t?C(w,{snappingManager:this.viewModel.snappingManager,snappingOptions:t,view:o,visibleElements:s.snappingControlsElements}):void 0))}_renderSelectionSetToolbar(){if("separate"!==this.contextualToolLocation)return;const e=this._renderSelectionSetItemGroup();return e?.length?C(f,{barStyle:this.toolbarKind,layout:this.layout,scale:this.scale},e):void 0}_renderSelectionSetItemGroupInline(){return"separate"===this.contextualToolLocation?[]:this._renderSelectionSetItemGroup()}_renderUndoRedoMenuItemGroup(){return C("div",{"allow-collapse":this.groupAllowCollapseOptions?.get("undoRedo")??!0,"group-kind":"split-button",key:"undo-redo-menu",priority:this.groupCollapsePriorities?.get("undoRedo")??g.Medium,slot:"actions-end"},this._renderUndoButton(),this._renderRedoButton())}_renderSettingsMenuItemGroup(){const e=[],o=[];this.customActions?.forEach((t=>{"settings-before"===t.position?o.push(t):"settings-after"===t.position&&e.push(t)}));const i=[...o.map((e=>this._renderToolbarItem(e))),this._renderSettingsMenuButton(),...e.map((e=>this._renderToolbarItem(e)))].filter(t);if(i.length)return C("div",{"allow-collapse":this.groupAllowCollapseOptions?.get("settings")??!1,"group-kind":"overflow-group",key:"settings-menu",priority:this.groupCollapsePriorities?.get("settings")??g.Max,slot:"actions-end"},i)}_renderSelectionSetItemGroup(){if(!this.updateGraphics.length)return[];const e="inline-end"===this.contextualToolLocation?"actions-end":void 0,t=this.customActions?.filter((e=>"before-selection-set"===e.position)),o=this.customActions?.filter((e=>"after-selection-set"===e.position)),i=this.groupCollapsePriorities?.get("selectionSet")??g.High;return[C("div",{"group-kind":"measured-content",key:"selection-count-chip-group",priority:i,slot:e},this._renderFeatureCountChip()),C("div",{"allow-collapse":this.groupAllowCollapseOptions?.get("selectionSet")??!1,"group-kind":"overflow-group",key:"selection-set-tool-group",priority:i,slot:e},t?.map((e=>this._renderToolbarItem(e))),this._renderDuplicateButton(),this._renderDeleteButton(),o?.map((e=>this._renderToolbarItem(e))))]}_renderDefaultSelectionButton(){if(!this.viewModel.updateOnGraphicClick)return[];const{messages:e,state:t}=this;return this._renderToolbarItem({id:"pointer-select",text:e.selectFeature,icon:"cursor",onclick:this._activateDefaultSelectTool,active:"ready"===t})}_renderCreateToolActionGroup(){const e=this._effectiveAvailableCreateTools?.flatMap((e=>this._renderBuiltInCreateToolItem(e)))??[],t=this.customToolOptions?.flatMap((e=>this._renderCustomToolItem(e)))??[];return C("div",{"allow-collapse":this.groupAllowCollapseOptions?.get("createTools")??!0,"group-kind":"overflow-group",key:"create-tools-group",priority:this.groupCollapsePriorities?.get("createTools")??g.High},e,t)}_renderBuiltInCreateToolItem(e){return this._renderToolbarItem({id:`${e}-button`,text:this.messages.draw[e],icon:R[e],onclick:()=>this._activateCreateTool(e),active:this.activeTool===e&&!this._activeCustomToolOptions})}_renderCustomToolItem(e){const{toolKey:t}=e;return this._renderToolbarItem({id:`custom-${e.toolKey}`,text:e.label,icon:e.icon,onclick:()=>this._activateCreateTool(e.toolName,null,e),active:this._activeCustomToolOptions?.toolKey===t})}_renderUndoButton(){return this.visibleElements.undoRedoMenu?this._renderToolbarItem({id:"undo-button",text:this.messages.undo,icon:"undo",disabled:!this.viewModel.canUndo(),onclick:this.undo,flipRTL:!0}):[]}_renderRedoButton(){return this.visibleElements.undoRedoMenu?this._renderToolbarItem({id:"redo-button",text:this.messages.redo,icon:"redo",disabled:!this.viewModel.canRedo(),onclick:this.redo,flipRTL:!0}):[]}_renderSettingsMenuButton(){return this.visibleElements.settingsMenu?this._renderToolbarItem({id:"settings-menu-action",text:this.messagesCommon.settings,icon:"gear",active:this._popoverOpen,onclick:()=>this._popoverOpen=!this._popoverOpen,afterCreate:e=>this._calcitePopoverReferenceElement=e,afterUpdate:e=>this._calcitePopoverReferenceElement=e,afterRemoved:()=>this._calcitePopoverReferenceElement=null}):[]}_renderFeatureCountChip(){if(!this.visibleElements.selectionCountLabel)return[];const{layout:e,messages:t,scale:o,id:i,updateGraphics:{length:s}}=this,l=k(t.selectedCount,{count:s}),r="s"===o?99:999,n=s>r?k(t.selectedCountTruncated,{truncated:r}):s,a="s"===o&&"vertical"===e,p=a?`${i}-selection-chip-small`:`${i}-selection-chip`;return[a?C("span",{classes:{[I.chipVertical]:!0,[I.chipVerticalSmall]:"s"===this.scale},id:p,tabIndex:0,title:l},n):C("calcite-chip",{appearance:"outline",class:"horizontal"===e?I.chipHorizontal:I.chipVertical,id:p,kind:"brand",label:l,scale:"l"===o?"m":"s",tabIndex:0,title:"vertical"===e?l:void 0},"vertical"===e?n:l)]}_renderDuplicateButton(){if(!this.visibleElements.duplicateButton)return[];const{messages:e}=this;return this._renderToolbarItem({id:"duplicate",text:this.updateGraphics.length>1?e.duplicateFeatures:e.duplicateFeature,icon:"copy",onclick:this._onDuplicateSelect})}_renderDeleteButton(){if(!this.visibleElements.deleteButton)return[];const{messages:e}=this,t=this.updateGraphics.length>1?e.deleteFeatures:e.deleteFeature;return this._renderToolbarItem({id:"delete",text:t,icon:"trash",onclick:this.delete})}_renderToolbarItem({id:e,text:t,icon:o,disabled:i,onclick:s,active:l,flipRTL:r,afterCreate:n,afterUpdate:a,afterRemoved:p}){const c=`${this.id}-${e}`;return[C("calcite-action",{active:l,afterCreate:n,afterRemoved:p,afterUpdate:a,bind:this,"data-testid":e,disabled:i||"disabled"===this.state,icon:o,iconFlipRtl:r??!1,id:c,key:e,onclick:s,scale:this.scale,text:t,title:t})]}_remeasurePopoverSizes(e){try{const t=e.parentElement,o=this?.view?.container?.getBoundingClientRect(),i=t?.style;if(!(t&&o&&i&&this.view?.container?.contains(t)))return;const s=this._calcitePopoverReferenceElement;if(!s)return;const{bottom:l,top:r}=s.getBoundingClientRect();if("horizontal"===this.layout){const e=l<o.height/2;e!==("top"===this._relativeLocation)&&(this._relativeLocation=e?"top":"bottom"),e?(i?.setProperty("--sketch-view-height-offset",l-o.top+"px"),i?.setProperty("--sketch-view-margin-offset","30px")):(i?.setProperty("--sketch-view-height-offset",o.bottom-r+"px"),i?.setProperty("--sketch-view-margin-offset","15px"))}else"vertical"===this.layout&&(i.setProperty("--sketch-view-height-offset","15px"),i.setProperty("--sketch-view-margin-offset","15px"));const n=e.shadowRoot?.querySelector("div.header")?.getBoundingClientRect().height;i.setProperty("--sketch-popover-header-offset",`${n}px`)}catch(t){i.getLogger(this.declaredClass).warnOnce("Sketch failed to lay out settings menu.",t)}}_activateCreateTool(e,t,o){const i=this._activeCustomToolOptions;if(o||i){if(o?.toolKey===i?.toolKey)return void this.cancel()}else if(this.activeTool===e)return void this.cancel();this._selectionToolbar?.cancel(),this.create(e,t,o)}_onDuplicateSelect(){const e=this.duplicate(),t=this.viewModel.activeTool;"transform"!==t&&"reshape"!==t||this.update(e,{tool:t})}_onSelectionOperationComplete(e){const{viewModel:{defaultUpdateOptions:t}}=this,{selection:o}=e;if(!e.aborted&&o.length){const e=t.tool,i=o.length>1&&"reshape"===e?"transform":e;this.update(o,{...t,tool:i})}this.notifyChange("state")}_activateDefaultSelectTool(){this.cancel(),this.view?.focus()}_refocusOnView(){this.activeTool&&this.view?.focus()}};e([c()],E.prototype,"_activeCustomToolOptions",void 0),e([c()],E.prototype,"activeTool",null),e([c({readOnly:!0})],E.prototype,"activeTooltip",null),e([c({cast:e=>{if(!e?.length)return null;const t=new Set(["point","polyline","polygon","rectangle","circle","multipoint","freehandPolyline","freehandPolygon","mesh"]);return e.filter((e=>t.has(e)))}})],E.prototype,"availableCreateTools",void 0),e([c({readOnly:!0})],E.prototype,"createGraphic",null),e([c()],E.prototype,"creationMode",null),e([c()],E.prototype,"customToolOptions",void 0),e([c()],E.prototype,"customActions",void 0),e([c()],E.prototype,"defaultCreateOptions",null),e([c()],E.prototype,"defaultUpdateOptions",null),e([c()],E.prototype,"icon",null),e([c()],E.prototype,"label",null),e([c()],E.prototype,"labelOptions",null),e([c()],E.prototype,"layer",null),e([c({type:["horizontal","vertical"],value:"horizontal"})],E.prototype,"layout",null),e([c({value:"m"})],E.prototype,"scale",null),e([c()],E.prototype,"toolbarKind",void 0),e([c()],E.prototype,"contextualToolLocation",void 0),e([c()],E.prototype,"groupCollapsePriorities",void 0),e([c()],E.prototype,"groupAllowCollapseOptions",void 0),e([c(),T("esri/widgets/Sketch/t9n/Sketch")],E.prototype,"messages",void 0),e([c(),T("esri/t9n/common")],E.prototype,"messagesCommon",void 0),e([c()],E.prototype,"snappingOptions",null),e([c()],E.prototype,"state",null),e([c()],E.prototype,"tooltipOptions",null),e([c({readOnly:!0})],E.prototype,"updateGraphics",null),e([c({type:u,nonNullable:!0})],E.prototype,"valueOptions",null),e([c()],E.prototype,"view",null),e([c({type:v}),M(["create","update","undo","redo"])],E.prototype,"viewModel",null),e([c({type:m,nonNullable:!0})],E.prototype,"visibleElements",void 0),e([c()],E.prototype,"_effectiveAvailableCreateTools",null),e([c()],E.prototype,"_defaultViewModel",void 0),e([c()],E.prototype,"_calcitePopoverReferenceElement",void 0),e([c()],E.prototype,"_relativeLocation",void 0),e([c()],E.prototype,"_popoverOpen",void 0),E=e([d("esri.widgets.Sketch")],E);const j=E;export{j as default};
5
+ import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import{isSome as t}from"../core/arrayUtils.js";import{handlesGroup as o}from"../core/handleUtils.js";import i from"../core/Logger.js";import{removeMaybe as s,destroyMaybe as l}from"../core/maybe.js";import{ignoreAbortErrors as r}from"../core/promiseUtils.js";import{watch as n,when as a,syncAndInitial as p}from"../core/reactiveUtils.js";import{property as c}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import{subclass as d}from"../core/accessorSupport/decorators/subclass.js";import u from"../views/interactive/sketch/SketchValueOptions.js";import h from"./Widget.js";import v from"./Sketch/SketchViewModel.js";import{VisibleElements as m}from"./Sketch/VisibleElements.js";import{LayoutPriority as g}from"./Sketch/support/sketchUtils.js";import f from"./Sketch/support/ResponsiveToolbar/ResponsiveToolbar.js";import{loadCalciteComponents as _}from"./support/componentsUtils.js";import y from"./support/SelectionToolbar.js";import b from"./support/SketchTooltipControls.js";import w from"./support/SnappingControls.js";import"./support/widgetUtils.js";import{messageBundle as T}from"./support/decorators/messageBundle.js";import{vmEvent as M}from"./support/decorators/vmEvent.js";import{tsx as C}from"./support/jsxFactory.js";import O from"./support/SelectionToolbar/VisibleElements.js";import S from"./support/SketchTooltipControls/VisibleElements.js";import{substitute as k}from"../intl/substitute.js";const P="esri-sketch",I={base:P,vertical:`${P}--vertical`,docked:`${P}-bar`,floating:`${P}-pad`,chipHorizontal:`${P}__selection-count-chip--horizontal`,chipVertical:`${P}__selection-count-chip--vertical`,chipVerticalSmall:`${P}__selection-count-chip--vertical--s`,popoverWrapper:`${P}__popover-wrapper`},R={point:"pin",polyline:"line",polygon:"polygon",rectangle:"rectangle",circle:"circle",multipoint:"pins",mesh:"i3d-building",freehandPolygon:"freehand-area",freehandPolyline:"freehand"};let E=class extends h{constructor(e,t){super(e,t),this._activeCustomToolOptions=null,this._selectionToolbar=null,this._viewModelHandlesGroup=null,this.availableCreateTools=["point","polyline","polygon","rectangle","circle"],this.customToolOptions=null,this.customActions=null,this.toolbarKind="floating",this.contextualToolLocation="separate",this.groupCollapsePriorities=null,this.groupAllowCollapseOptions=null,this.messages=null,this.messagesCommon=null,this.visibleElements=new m,this._defaultViewModel=null,this._calcitePopoverReferenceElement=null,this._relativeLocation="top",this._popoverOpen=!1,this._activateCreateTool=this._activateCreateTool.bind(this),this.viewModel=e?.viewModel||(this._defaultViewModel=new v({creationMode:e?.creationMode??"continuous"}))}initialize(){const{layer:e,view:t}=this,i="2d"===t?.type,l=new y({persistSelection:!1,visibleElements:new O({chip:!1,pan:!1,pointTool:!1,lassoTool:i,rectangleTool:i}),view:t,sources:e?[e]:null,scale:this.scale});this.addHandles([n((()=>this.viewModel),(e=>{this._viewModelHandlesGroup=s(this._viewModelHandlesGroup),e&&(this._viewModelHandlesGroup=o([e.on("create",(()=>this.scheduleRender())),e.on("update",(()=>this.scheduleRender())),e.on("delete",(e=>this.emit("delete",e))),e.on("undo",(()=>this.scheduleRender())),e.on("redo",(()=>this.scheduleRender())),n((()=>e.layer),(e=>{this._selectionToolbar&&(this._selectionToolbar.sources=e?[e]:null)})),n((()=>e.view),(e=>{this._selectionToolbar&&(this._selectionToolbar.view=e)})),n((()=>e.state),(()=>this.notifyChange("state")))]))}),p),a((()=>l.activeOperation),(()=>this.viewModel.cancel())),l.on("complete",(e=>this._onSelectionOperationComplete(e))),n((()=>{const{view:e,visibleElements:{selectionTools:t}}=this;return{lassoTool:"3d"!==e?.type&&!!t?.["lasso-selection"],rectangleTool:"3d"!==e?.type&&!!t?.["rectangle-selection"]}}),(e=>{Object.assign(l.visibleElements,e)}),p)]),this._selectionToolbar=l}loadDependencies(){return _({action:()=>import("@esri/calcite-components/dist/components/calcite-action"),chip:()=>import("@esri/calcite-components/dist/components/calcite-chip"),popover:()=>import("@esri/calcite-components/dist/components/calcite-popover")})}destroy(){this._selectionToolbar?.destroy(),this._viewModelHandlesGroup=s(this._viewModelHandlesGroup)}get activeTool(){const e=this._selectionToolbar?.activeOperation;if(e)switch(e.toolName){case"lasso":return"lasso-selection";case"rectangle":return"rectangle-selection";case"default":return"custom-selection"}const t=this._effectiveAvailableCreateTools,{activeTool:o,activeCreateToolDrawMode:i}=this.viewModel;return"polygon"===o&&"freehand"===i&&t?.includes("freehandPolygon")?"freehandPolygon":"polyline"===o&&"freehand"===i&&t?.includes("freehandPolyline")?"freehandPolyline":this.viewModel.activeTool}get activeTooltip(){return this.viewModel.activeTooltip}get createGraphic(){return this.viewModel.createGraphic}get creationMode(){return this.viewModel.creationMode}set creationMode(e){this.viewModel.creationMode=e}get defaultCreateOptions(){return this.viewModel.defaultCreateOptions}set defaultCreateOptions(e){this.viewModel.defaultCreateOptions=e}get defaultUpdateOptions(){return this.viewModel.defaultUpdateOptions}set defaultUpdateOptions(e){this.viewModel.defaultUpdateOptions=e}get icon(){return"pencil"}set icon(e){this._overrideIfSome("icon",e)}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get labelOptions(){return this.viewModel.labelOptions}set labelOptions(e){this.viewModel.labelOptions=e}get layer(){return this.viewModel.layer}set layer(e){this.viewModel.layer=e}set layout(e){this._set("layout",e),this._selectionToolbar&&(this._selectionToolbar.layout=e)}set scale(e){this._set("scale",e),this._selectionToolbar&&(this._selectionToolbar.scale=e)}get snappingOptions(){return this.viewModel.snappingOptions}set snappingOptions(e){this.viewModel.snappingOptions=e}get state(){return this._selectionToolbar?.activeOperation?"active":this.viewModel.state}get tooltipOptions(){return this.viewModel.tooltipOptions}set tooltipOptions(e){this.viewModel.tooltipOptions=e}get updateGraphics(){return this.viewModel.updateGraphics}get valueOptions(){return this.viewModel.valueOptions}set valueOptions(e){this.viewModel.valueOptions=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}set viewModel(e){const t=this._get("viewModel");e!==t&&(t&&t===this._defaultViewModel&&l(t),this._set("viewModel",e))}get _effectiveAvailableCreateTools(){const{availableCreateTools:e,view:t,visibleElements:o}=this,i=e?.filter((e=>!!o.createTools?.[e]));return"3d"===t?.type?i?.filter((e=>"multipoint"!==e)):i}create(e,t,o){const i=o?.createOptions??t;return this._activeCustomToolOptions=o,r(this.viewModel.create(e,i))}update(e,t){return r(this.viewModel.update(e,t))}complete(){this.viewModel.complete()}cancel(){this._selectionToolbar?.cancel(),this.viewModel.cancel(),this._activeCustomToolOptions=null}undo(){this.viewModel.undo(),this.view?.focus()}redo(){this.viewModel.redo(),this.view?.focus()}delete(){this.viewModel.delete()}duplicate(){return this.viewModel.duplicate()}dismissFloatingElements(){this._popoverOpen=!1}render(){const{toolbarKind:e,layout:t,scale:o}=this,i=this.customActions?.filter((e=>"selection-toolbar"===e.position));return C("div",null,C("div",{classes:{[I.base]:!0,[I.floating]:"floating"===e,[I.docked]:"docked"===e,[I.vertical]:"vertical"===t}},C(f,{barStyle:e,layout:t,scale:o},this._renderSelectionSetItemGroupInline(),C("div",{"allow-collapse":this.groupAllowCollapseOptions?.get("selectionTools")??!0,"group-kind":"split-button",key:"selection-split-button",priority:this.groupCollapsePriorities?.get("selectionTools")??g.Low},this._renderDefaultSelectionButton(),this._selectionToolbar?.render(),i?.map((e=>this._renderToolbarItem(e)))),this._renderCreateToolActionGroup(),this._renderUndoRedoMenuItemGroup(),this._renderSettingsMenuItemGroup()),this._renderSelectionSetToolbar(),this._renderSettingsMenuPopover()))}_renderSettingsMenuPopover(){const{messagesCommon:e,snappingOptions:t,view:o,viewModel:i,visibleElements:s}=this;if(!this._calcitePopoverReferenceElement)return;const l={directionModePicker:s.directionModePicker,labelsToggle:s.labelsToggle,tooltipsToggle:s.tooltipsToggle},r="horizontal"===this.layout?"top"===this._relativeLocation?"bottom-end":"top-end":"right-end";return C("calcite-popover",{closable:!0,focusTrapDisabled:!0,heading:e.settings,label:e.settings,open:this._popoverOpen,overlayPositioning:"fixed",placement:r,referenceElement:this._calcitePopoverReferenceElement,scale:this.scale,onCalcitePopoverBeforeClose:()=>this._popoverOpen=!1,onCalcitePopoverBeforeOpen:e=>this._remeasurePopoverSizes(e.currentTarget),onCalcitePopoverClose:()=>this._refocusOnView()},C("div",{class:I.popoverWrapper},Object.values(l).includes(!0)?C(b,{sketchOptions:i.sketchOptions,viewType:o?.type,visibleElements:new S(l)}):void 0,s.snappingControls&&o&&t?C(w,{snappingManager:this.viewModel.snappingManager,snappingOptions:t,view:o,visibleElements:s.snappingControlsElements}):void 0))}_renderSelectionSetToolbar(){if("separate"!==this.contextualToolLocation)return;const e=this._renderSelectionSetItemGroup();return e?.length?C(f,{barStyle:this.toolbarKind,layout:this.layout,scale:this.scale},e):void 0}_renderSelectionSetItemGroupInline(){return"separate"===this.contextualToolLocation?[]:this._renderSelectionSetItemGroup()}_renderUndoRedoMenuItemGroup(){return C("div",{"allow-collapse":this.groupAllowCollapseOptions?.get("undoRedo")??!0,"group-kind":"split-button",key:"undo-redo-menu",priority:this.groupCollapsePriorities?.get("undoRedo")??g.Medium,slot:"actions-end"},this._renderUndoButton(),this._renderRedoButton())}_renderSettingsMenuItemGroup(){const e=[],o=[];this.customActions?.forEach((t=>{"settings-before"===t.position?o.push(t):"settings-after"===t.position&&e.push(t)}));const i=[...o.map((e=>this._renderToolbarItem(e))),this._renderSettingsMenuButton(),...e.map((e=>this._renderToolbarItem(e)))].filter(t);if(i.length)return C("div",{"allow-collapse":this.groupAllowCollapseOptions?.get("settings")??!1,"group-kind":"overflow-group",key:"settings-menu",priority:this.groupCollapsePriorities?.get("settings")??g.Max,slot:"actions-end"},i)}_renderSelectionSetItemGroup(){if(!this.updateGraphics.length)return[];const e="inline-end"===this.contextualToolLocation?"actions-end":void 0,t=this.customActions?.filter((e=>"before-selection-set"===e.position)),o=this.customActions?.filter((e=>"after-selection-set"===e.position)),i=this.groupCollapsePriorities?.get("selectionSet")??g.High;return[C("div",{"group-kind":"measured-content",key:"selection-count-chip-group",priority:i,slot:e},this._renderFeatureCountChip()),C("div",{"allow-collapse":this.groupAllowCollapseOptions?.get("selectionSet")??!1,"group-kind":"overflow-group",key:"selection-set-tool-group",priority:i,slot:e},t?.map((e=>this._renderToolbarItem(e))),this._renderDuplicateButton(),this._renderDeleteButton(),o?.map((e=>this._renderToolbarItem(e))))]}_renderDefaultSelectionButton(){if(!this.viewModel.updateOnGraphicClick)return[];const{messages:e,state:t}=this;return this._renderToolbarItem({id:"pointer-select",text:e.selectFeature,icon:"cursor",onclick:this._activateDefaultSelectTool,active:"ready"===t})}_renderCreateToolActionGroup(){const e=this._effectiveAvailableCreateTools?.flatMap((e=>this._renderBuiltInCreateToolItem(e)))??[],t=this.customToolOptions?.flatMap((e=>this._renderCustomToolItem(e)))??[];return C("div",{"allow-collapse":this.groupAllowCollapseOptions?.get("createTools")??!0,"group-kind":"overflow-group",key:"create-tools-group",priority:this.groupCollapsePriorities?.get("createTools")??g.High},e,t)}_renderBuiltInCreateToolItem(e){return this._renderToolbarItem({id:`${e}-button`,text:this.messages.draw[e],icon:R[e],onclick:()=>this._activateCreateTool(e),active:this.activeTool===e&&!this._activeCustomToolOptions})}_renderCustomToolItem(e){const{toolKey:t}=e;return this._renderToolbarItem({id:`custom-${e.toolKey}`,text:e.label,icon:e.icon,onclick:()=>this._activateCreateTool(e.toolName,null,e),active:this._activeCustomToolOptions?.toolKey===t})}_renderUndoButton(){return this.visibleElements.undoRedoMenu?this._renderToolbarItem({id:"undo-button",text:this.messages.undo,icon:"undo",disabled:!this.viewModel.canUndo(),onclick:this.undo,flipRTL:!0}):[]}_renderRedoButton(){return this.visibleElements.undoRedoMenu?this._renderToolbarItem({id:"redo-button",text:this.messages.redo,icon:"redo",disabled:!this.viewModel.canRedo(),onclick:this.redo,flipRTL:!0}):[]}_renderSettingsMenuButton(){return this.visibleElements.settingsMenu?this._renderToolbarItem({id:"settings-menu-action",text:this.messagesCommon.settings,icon:"gear",active:this._popoverOpen,onclick:()=>this._popoverOpen=!this._popoverOpen,afterCreate:e=>this._calcitePopoverReferenceElement=e,afterUpdate:e=>this._calcitePopoverReferenceElement=e,afterRemoved:()=>this._calcitePopoverReferenceElement=null}):[]}_renderFeatureCountChip(){if(!this.visibleElements.selectionCountLabel)return[];const{layout:e,messages:t,scale:o,id:i,updateGraphics:{length:s}}=this,l=k(t.selectedCount,{count:s}),r="s"===o?99:999,n=s>r?k(t.selectedCountTruncated,{truncated:r}):s,a="s"===o&&"vertical"===e,p=a?`${i}-selection-chip-small`:`${i}-selection-chip`;return[a?C("span",{classes:{[I.chipVertical]:!0,[I.chipVerticalSmall]:"s"===this.scale},id:p,tabIndex:0,title:l},n):C("calcite-chip",{appearance:"outline",class:"horizontal"===e?I.chipHorizontal:I.chipVertical,id:p,kind:"brand",label:l,scale:"l"===o?"m":"s",tabIndex:0,title:"vertical"===e?l:void 0},"vertical"===e?n:l)]}_renderDuplicateButton(){if(!this.visibleElements.duplicateButton)return[];const{messages:e}=this;return this._renderToolbarItem({id:"duplicate",text:this.updateGraphics.length>1?e.duplicateFeatures:e.duplicateFeature,icon:"copy",onclick:this._onDuplicateSelect})}_renderDeleteButton(){if(!this.visibleElements.deleteButton)return[];const{messages:e}=this,t=this.updateGraphics.length>1?e.deleteFeatures:e.deleteFeature;return this._renderToolbarItem({id:"delete",text:t,icon:"trash",onclick:this.delete})}_renderToolbarItem({id:e,text:t,icon:o,disabled:i,onclick:s,active:l,flipRTL:r,afterCreate:n,afterUpdate:a,afterRemoved:p}){const c=`${this.id}-${e}`;return[C("calcite-action",{active:l,afterCreate:n,afterRemoved:p,afterUpdate:a,bind:this,"data-testid":e,disabled:i||"disabled"===this.state,icon:o,iconFlipRtl:r??!1,id:c,key:e,onclick:s,scale:this.scale,text:t,title:t})]}_remeasurePopoverSizes(e){try{const t=e.parentElement,o=this?.view?.container?.getBoundingClientRect(),i=t?.style;if(!(t&&o&&i&&this.view?.container?.contains(t)))return;const s=this._calcitePopoverReferenceElement;if(!s)return;const{bottom:l,top:r}=s.getBoundingClientRect();if("horizontal"===this.layout){const e=l<o.height/2;e!==("top"===this._relativeLocation)&&(this._relativeLocation=e?"top":"bottom"),e?(i?.setProperty("--sketch-view-height-offset",l-o.top+"px"),i?.setProperty("--sketch-view-margin-offset","30px")):(i?.setProperty("--sketch-view-height-offset",o.bottom-r+"px"),i?.setProperty("--sketch-view-margin-offset","15px"))}else"vertical"===this.layout&&(i.setProperty("--sketch-view-height-offset","15px"),i.setProperty("--sketch-view-margin-offset","15px"));const n=e.shadowRoot?.querySelector("div.header")?.getBoundingClientRect().height;i.setProperty("--sketch-popover-header-offset",`${n}px`)}catch(t){i.getLogger(this.declaredClass).warnOnce("Sketch failed to lay out settings menu.",t)}}_activateCreateTool(e,t,o){const i=this._activeCustomToolOptions;if(o||i){if(o?.toolKey===i?.toolKey)return void this.cancel()}else if(this.activeTool===e)return void this.cancel();this._selectionToolbar?.cancel(),this.create(e,t,o)}_onDuplicateSelect(){const e=this.duplicate(),t=this.viewModel.activeTool;"transform"!==t&&"reshape"!==t||this.update(e,{tool:t})}_onSelectionOperationComplete(e){const{viewModel:{defaultUpdateOptions:t}}=this,{selection:o}=e;if(!e.aborted&&o.length){const e=t.tool,i=o.length>1&&"reshape"===e?"transform":e;this.update(o,{...t,tool:i})}this.notifyChange("state")}_activateDefaultSelectTool(){this.cancel(),this.view?.focus()}_refocusOnView(){this.activeTool&&this.view?.focus()}};e([c()],E.prototype,"_activeCustomToolOptions",void 0),e([c()],E.prototype,"activeTool",null),e([c({readOnly:!0})],E.prototype,"activeTooltip",null),e([c({cast:e=>{if(!e?.length)return null;const t=new Set(["point","polyline","polygon","rectangle","circle","multipoint","freehandPolyline","freehandPolygon","mesh"]);return e.filter((e=>t.has(e)))}})],E.prototype,"availableCreateTools",void 0),e([c({readOnly:!0})],E.prototype,"createGraphic",null),e([c()],E.prototype,"creationMode",null),e([c()],E.prototype,"customToolOptions",void 0),e([c()],E.prototype,"customActions",void 0),e([c()],E.prototype,"defaultCreateOptions",null),e([c()],E.prototype,"defaultUpdateOptions",null),e([c()],E.prototype,"icon",null),e([c()],E.prototype,"label",null),e([c()],E.prototype,"labelOptions",null),e([c()],E.prototype,"layer",null),e([c({type:["horizontal","vertical"],value:"horizontal"})],E.prototype,"layout",null),e([c({value:"m"})],E.prototype,"scale",null),e([c()],E.prototype,"toolbarKind",void 0),e([c()],E.prototype,"contextualToolLocation",void 0),e([c()],E.prototype,"groupCollapsePriorities",void 0),e([c()],E.prototype,"groupAllowCollapseOptions",void 0),e([c(),T("esri/widgets/Sketch/t9n/Sketch")],E.prototype,"messages",void 0),e([c(),T("esri/t9n/common")],E.prototype,"messagesCommon",void 0),e([c()],E.prototype,"snappingOptions",null),e([c()],E.prototype,"state",null),e([c()],E.prototype,"tooltipOptions",null),e([c({readOnly:!0})],E.prototype,"updateGraphics",null),e([c({type:u,nonNullable:!0})],E.prototype,"valueOptions",null),e([c()],E.prototype,"view",null),e([c({type:v}),M(["create","update","undo","redo"])],E.prototype,"viewModel",null),e([c({type:m,nonNullable:!0})],E.prototype,"visibleElements",void 0),e([c()],E.prototype,"_effectiveAvailableCreateTools",null),e([c()],E.prototype,"_defaultViewModel",void 0),e([c()],E.prototype,"_calcitePopoverReferenceElement",void 0),e([c()],E.prototype,"_relativeLocation",void 0),e([c()],E.prototype,"_popoverOpen",void 0),E=e([d("esri.widgets.Sketch")],E);const j=E;export{j as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as t}from"../../../chunks/tslib.es6.js";import{property as e}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as i}from"../../../core/accessorSupport/decorators/subclass.js";import{fetchThumbnail as r}from"../symbolPreviewUtils.js";import o from"./ItemBase.js";let s=class extends o{constructor(t){super(t),this._title=null,this._thumbnail=null,this.graphic=null,this.layer=null,this.thumbnailSize=24}get key(){return`${this.layer.id}:${this.objectId??this.graphic.uid}`}get objectId(){return this.graphic.getObjectId()}get title(){return this._title??this.objectId?.toString()}get thumbnail(){return this._thumbnail??void 0}async fetchThumbnail(){return this._thumbnail=await r(this.graphic,this.layer,{maxSize:this.thumbnailSize})}async sync(t){t.push(this._setFeatureTitle())}async _setFeatureTitle(){const{graphic:t,key:e,layer:i,viewModel:r}=this,o=r.featureTitleMap.get(e)||(i?.getFeatureTitle?await i.getFeatureTitle(t,{fetchMissingFields:!1}):null);o&&r.featureTitleMap.set(e,o),this._title=o}};t([e()],s.prototype,"_title",void 0),t([e()],s.prototype,"_thumbnail",void 0),t([e()],s.prototype,"graphic",void 0),t([e()],s.prototype,"key",null),t([e()],s.prototype,"layer",void 0),t([e()],s.prototype,"objectId",null),t([e()],s.prototype,"title",null),t([e()],s.prototype,"thumbnail",null),t([e()],s.prototype,"thumbnailSize",void 0),s=t([i("esri.widgets.support.SelectionList.FeatureItem")],s);const l=s;export{l as default};
5
+ import{_ as t}from"../../../chunks/tslib.es6.js";import{property as e}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as i}from"../../../core/accessorSupport/decorators/subclass.js";import{fetchThumbnail as r}from"../symbolPreviewUtils.js";import o from"./ItemBase.js";let s=class extends o{constructor(t){super(t),this._title=null,this._thumbnail=null,this.graphic=null,this.layer=null,this.layerItem=null,this.thumbnailSize=24}get key(){return`${this.layer.id}:${this.objectId??this.graphic.uid}`}get metadata(){const{layerItem:t}=this;return{parentTitle:t.title??void 0,groupTitle:t.groupLayerItem?.title??void 0}}get objectId(){return this.graphic.getObjectId()}get title(){return this._title??this.objectId?.toString()}get thumbnail(){return this._thumbnail??void 0}async fetchThumbnail(){return this._thumbnail=await r(this.graphic,this.layer,{maxSize:this.thumbnailSize})}async sync(t){t.push(this._setFeatureTitle())}async _setFeatureTitle(){const{graphic:t,key:e,layer:i,viewModel:r}=this,o=r.featureTitleMap.get(e)||(i?.getFeatureTitle?await i.getFeatureTitle(t,{fetchMissingFields:!1}):null);o&&r.featureTitleMap.set(e,o),this._title=o}};t([e()],s.prototype,"_title",void 0),t([e()],s.prototype,"_thumbnail",void 0),t([e()],s.prototype,"graphic",void 0),t([e()],s.prototype,"key",null),t([e()],s.prototype,"layer",void 0),t([e()],s.prototype,"layerItem",void 0),t([e()],s.prototype,"metadata",null),t([e()],s.prototype,"objectId",null),t([e()],s.prototype,"title",null),t([e()],s.prototype,"thumbnail",null),t([e()],s.prototype,"thumbnailSize",void 0),s=t([i("esri.widgets.support.SelectionList.FeatureItem")],s);const l=s;export{l as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import"../../../core/has.js";import{property as r}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as t}from"../../../core/accessorSupport/decorators/subclass.js";import o from"./ItemBase.js";let s=class extends o{constructor(e){super(e),this.children=[],this.layer=null}get layers(){const{layer:e}=this;return"group"===e.type?e.layers.toArray().reverse():"subtype-group"===e.type?e.sublayers.toArray().reverse():[]}get maxVisibleFeatureCountExceeded(){return this.children.some((e=>e.maxVisibleFeatureCountExceeded))}get total(){return this.children.reduce(((e,r)=>e+r.total),0)}async sync({controller:e,promises:r}){const{layers:t,viewModel:o}=this;this.children=o.layersToItems({controller:e,layers:t,promises:r})}};e([r()],s.prototype,"children",void 0),e([r()],s.prototype,"layer",void 0),e([r()],s.prototype,"layers",null),e([r()],s.prototype,"maxVisibleFeatureCountExceeded",null),e([r()],s.prototype,"total",null),s=e([t("esri.widgets.support.SelectionList.GroupLayerItem")],s);const l=s;export{l as default};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import"../../../core/has.js";import{property as r}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as t}from"../../../core/accessorSupport/decorators/subclass.js";import s from"./ItemBase.js";let o=class extends s{constructor(e){super(e),this.items=[],this.layer=null}get layers(){const{layer:e}=this;return"group"===e.type?e.layers.toArray().reverse():"subtype-group"===e.type?e.sublayers.toArray().reverse():[]}get maxVisibleFeatureCountExceeded(){return this.items.some((e=>e.maxVisibleFeatureCountExceeded))}get total(){return this.items.reduce(((e,r)=>e+r.total),0)}async sync({controller:e,promises:r}){const{layers:t,viewModel:s}=this;this.items=s.layersToItems({controller:e,groupLayerItem:this,layers:t,promises:r})}};e([r()],o.prototype,"items",void 0),e([r()],o.prototype,"layer",void 0),e([r()],o.prototype,"layers",null),e([r()],o.prototype,"maxVisibleFeatureCountExceeded",null),e([r()],o.prototype,"total",null),o=e([t("esri.widgets.support.SelectionList.GroupLayerItem")],o);const a=o;export{a as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import{property as t}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as r}from"../../../core/accessorSupport/decorators/subclass.js";import o from"./FeatureItem.js";import s from"./ItemBase.js";let i=class extends s{constructor(e){super(e),this._onChangeController=null,this.layer=null,this.selection=[]}get effectiveObjectIds(){return this.objectIds.slice(0,this.maxVisibleFeatureCountPerLayer)}get maxVisibleFeatureCountExceeded(){return this.objectIds.length>this.viewModel.maxVisibleFeatureCountPerLayer}get maxVisibleFeatureCountPerLayer(){return this.viewModel.maxVisibleFeatureCountPerLayer}get objectIds(){return this.viewModel.effectiveSelectionManager?.getSelection(this.layer)??[]}get total(){return this.objectIds.length}cancel(){this._onChangeController?.abort()}async sync({controller:e,promises:t}){this.cancel();const r=this.selection.slice(),o=new Map(r.map((e=>[e.objectId,e]))),s=this.effectiveObjectIds.slice(),i=[],a=[];for(const n of s){const e=o.get(n);e?(i.push(e),t.push(e.sync(t))):a.push(n)}if(this._onChangeController=e,a.length>0){const r=await this._createFeatureItems(a,e);for(const e of r)i.push(e),t.push(e.sync(t))}e.signal.aborted||(this.selection=i)}async _createFeatureItems(e,t){const{layer:r,layerView:s,viewModel:i}=this,a=new Map;if(s){const o=s.createQuery();o.objectIds=e,o.outFields=["*"],o.returnGeometry=!0;const i=await s.queryFeatures(o,t),{objectIdField:n}=r;for(const e of i?.features??[])a.set(e.attributes[n],e)}if(t.signal.aborted)return[];const n=e.filter((e=>!a.has(e)));if(n.length){const e=r.createQuery();e.objectIds=n,e.outSpatialReference=this.view?.spatialReference,e.outFields=["*"],e.returnGeometry=!0;const o=await r.queryFeatures(e,t);for(const t of o.features??[])a.set(t.attributes[r.objectIdField],t)}return Array.from(a.values()).map((e=>new o({layer:r,graphic:e,viewModel:i})))}};e([t()],i.prototype,"_onChangeController",void 0),e([t()],i.prototype,"effectiveObjectIds",null),e([t()],i.prototype,"layer",void 0),e([t()],i.prototype,"maxVisibleFeatureCountExceeded",null),e([t()],i.prototype,"maxVisibleFeatureCountPerLayer",null),e([t()],i.prototype,"objectIds",null),e([t()],i.prototype,"selection",void 0),e([t()],i.prototype,"total",null),i=e([r("esri.widgets.support.SelectionList.LayerItem")],i);const a=i;export{a as default};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import{property as t}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as r}from"../../../core/accessorSupport/decorators/subclass.js";import o from"./FeatureItem.js";import s from"./ItemBase.js";import{getSuggestedQueryOutFields as a}from"../Selector2D/selectorUtils.js";let i=class extends s{constructor(e){super(e),this._onChangeController=null,this.featureItems=[],this.groupLayerItem=null,this.layer=null}get effectiveObjectIds(){return this.objectIds.slice(0,this.maxVisibleFeatureCountPerLayer)}get maxVisibleFeatureCountExceeded(){return this.objectIds.length>this.viewModel.maxVisibleFeatureCountPerLayer}get maxVisibleFeatureCountPerLayer(){return this.viewModel.maxVisibleFeatureCountPerLayer}get objectIds(){return this.viewModel.effectiveSelectionManager?.getSelection(this.layer)??[]}get total(){return this.objectIds.length}cancel(){this._onChangeController?.abort()}async sync({controller:e,promises:t}){this.cancel();const r=this.featureItems.slice(),o=new Map(r.map((e=>[e.objectId,e]))),s=this.effectiveObjectIds.slice(),a=[],i=[];for(const n of s){const e=o.get(n);e?(a.push(e),t.push(e.sync(t))):i.push(n)}if(this._onChangeController=e,i.length>0){const r=await this._createFeatureItems(i,e);for(const e of r)a.push(e),t.push(e.sync(t))}e.signal.aborted||(this.featureItems=a)}async _createFeatureItems(e,t){const{layer:r,layerView:s,viewModel:i}=this,n=new Map;if(s){const r=s.createQuery();r.objectIds=e,r.outFields=["*"],r.returnGeometry=!0;const o=await s.queryFeatures(r,t);for(const e of o.features){const t=e.getObjectId();null!=t&&n.set(t,e)}}if(t.signal.aborted)return[];const l=e.filter((e=>!n.has(e)));if(l.length){const{view:e}=this,o=r.createQuery();o.objectIds=l,o.outSpatialReference=e?.spatialReference,o.outFields=e?a(r,e,!0):["*"],o.returnGeometry=!0;const s=await r.queryFeatures(o,t);for(const t of s.features){const e=t.getObjectId();null!=e&&n.set(e,t)}}return Array.from(n.values()).map((e=>new o({graphic:e,layer:r,layerItem:this,viewModel:i})))}};e([t()],i.prototype,"_onChangeController",void 0),e([t()],i.prototype,"effectiveObjectIds",null),e([t()],i.prototype,"featureItems",void 0),e([t()],i.prototype,"groupLayerItem",void 0),e([t()],i.prototype,"layer",void 0),e([t()],i.prototype,"maxVisibleFeatureCountExceeded",null),e([t()],i.prototype,"maxVisibleFeatureCountPerLayer",null),e([t()],i.prototype,"objectIds",null),e([t()],i.prototype,"total",null),i=e([r("esri.widgets.support.SelectionList.LayerItem")],i);const n=i;export{n as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Accessor.js";import o from"../../../core/Logger.js";import{removeMaybe as r}from"../../../core/maybe.js";import{ignoreAbortErrors as i,debounce as s}from"../../../core/promiseUtils.js";import{watch as l,on as a}from"../../../core/reactiveUtils.js";import{property as n}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/RandomLCG.js";import{subclass as c}from"../../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as h}from"../../../core/support/UpdatingHandles.js";import{isSubtypeGroupLayer as p,isSubtypeSublayer as g}from"../../../layers/support/layerUtils.js";import{isSelectableLayer as u}from"../../../views/support/selectionUtils.js";import{goTo as y}from"../goToUtils.js";import m from"./GroupLayerItem.js";import f from"./LayerItem.js";import{computeEffectiveCount as d,getNestedLayerItems as v,isLayerItem as S,isGroupLayerItem as C,getNestedFeatureItems as I}from"./selectionListUtils.js";const b=100;let _=class extends t{constructor(e){super(e),this._groupItemCache=new Map,this._hoverHighlightHandle=null,this._layerItemCache=new Map,this._allLayerItems=null,this._onChangeAbortController=null,this._updatingHandles=new h,this.featureTitleMap=new Map,this.layer=null,this.maxVisibleFeatureCountPerLayer=500,this.selectionManager=null,this._onSelectionChangeController=async()=>{this._cancelOnSelectionChange();const e=new AbortController;this._onChangeAbortController=e,await this._updatingHandles.addPromise(i(this._onSelectionChange(e))),this._onChangeAbortController===e&&(this._onChangeAbortController=null);const t=this.layer&&this.effectiveSelectionManager?.getSelection(this.layer);t?.length||(this.layer=null)},this._cancelOnSelectionChange=()=>this._onChangeAbortController?.abort(),this._onSelectionChangeDebounced=s(this._onSelectionChangeController,b)}initialize(){this.addHandles([l((()=>[this.view,this.effectiveSelectionManager]),(()=>this._onSelectionChangeDebounced())),a((()=>this.effectiveSelectionManager?.sources),"change",(()=>this._onSelectionChangeDebounced())),a((()=>this.effectiveSelectionManager),"selection-change",(()=>this._onSelectionChangeDebounced()))])}destroy(){this.removeTemporaryHighlight(),this._updatingHandles.destroy()}get activeLayerItem(){const{layer:e}=this;return e&&this.layerItems.find((t=>t.layer===e))}get allLayerItems(){return this._allLayerItems??[]}get effectiveCount(){return d(this.allLayerItems)}get effectiveSelectionManager(){return this.selectionManager??this.view?.selectionManager}get isUpdating(){return!(!this._onChangeAbortController&&!this._updatingHandles.updating)}get layerItems(){return v(this.allLayerItems)}get layerViewMap(){const e=new Map,{view:t}=this;if(!t)return e;for(const o of t.allLayerViews)if(e.set(o.layer.id,o),p(o.layer))for(const t of o.layer.sublayers)e.set(t.id,o);return e}get maxVisibleFeatureCountExceeded(){return this.allLayerItems.some((e=>e.maxVisibleFeatureCountExceeded))}get selectionSources(){const e=this.effectiveSelectionManager,t=new Set;if(e?.sources)for(const o of e.sources)t.add(o);return t}get state(){const{view:e}=this;return e?e.ready?this.effectiveSelectionManager?"ready":"error":"loading":"disabled"}get totalCount(){return this.effectiveSelectionManager?.count??0}get viewLayersAndTables(){const{view:e}=this;return e?.map?[...e.map.layers.toArray().reverse(),...e.map.tables.toArray().reverse()]:[]}get visibleLayerCount(){const{effectiveSelectionManager:e}=this;return e&&0!==e.count?1===e.count||this.activeLayerItem?1:this.layerItems.length:0}get visibleFeatureCount(){const{activeLayerItem:e}=this;if(e)return e.maxVisibleFeatureCountExceeded?e.maxVisibleFeatureCountPerLayer:e.total;let t=0;for(const o of this.layerItems)t+=o.maxVisibleFeatureCountExceeded?o.maxVisibleFeatureCountPerLayer:o.total;return t}addTemporaryHighlight({graphic:e,layerView:t}){this.removeTemporaryHighlight(),t&&e&&(this._hoverHighlightHandle=t.highlight(e,{name:"temporary"}))}clear(){this.effectiveSelectionManager?.clear()}deselectFeatureItem(e){const t=e.graphic.getObjectId();null!=t&&this.effectiveSelectionManager?.removeFromSelection(e.layer,[t])}deselectGroupItem(e){e.children.forEach((e=>{S(e)?this.deselectLayerItem(e):this.deselectGroupItem(e)}))}deselectLayerItem(e){this.effectiveSelectionManager?.setSelection(e.layer,[])}deselectItem(e){C(e)?this.deselectGroupItem(e):S(e)?this.deselectLayerItem(e):this.deselectFeatureItem(e)}goToItem(e){S(e)||C(e)?this._goTo(I([e]).map((e=>e.graphic))):this._goTo(e.graphic)}layersToItems(e){const{controller:t,layers:o,promises:r}=e,{_groupItemCache:i,_layerItemCache:s,effectiveSelectionManager:l,viewLayersAndTables:a}=this,n=o??a;if(!l)return[];const c=[];for(const h of n)switch(h.type){case"subtype-group":case"group":{const e=i.get(h),o=e??new m({layer:h,viewModel:this});e||i.set(h,o),r.push(o.sync({controller:t,promises:r})),c.push(o)}break;default:if(u(h)||g(h)){const e=h,o=l.getSelection(e);if(!o?.length)continue;const i=s.get(e),a=i??new f({layer:e,viewModel:this});i||s.set(e,a),r.push(a.sync({controller:t,promises:r})),c.push(a)}}return c}removeFromSelection(e){this.effectiveSelectionManager?.removeFromSelection(e.layer,e.objectIds)}removeTemporaryHighlight(){this._hoverHighlightHandle=r(this._hoverHighlightHandle)}selectSingleFeatureItem(e){const t=e.objectId;if(null!=t&&this.effectiveSelectionManager)for(const{layer:o}of this.effectiveSelectionManager.selections)this.setSelection({layer:o,objectIds:o===e.layer?[t]:[]})}selectSingleGroupItem(e){if(this.effectiveSelectionManager)for(const{layer:t,selection:o}of this.effectiveSelectionManager.selections)this.setSelection({layer:t,objectIds:t.parent===e.layer?o:[]})}selectSingleItem(e){C(e)?this.selectSingleGroupItem(e):S(e)?this.selectSingleLayerItem(e):this.selectSingleFeatureItem(e)}selectSingleLayerItem(e){if(this.effectiveSelectionManager)for(const{layer:t,selection:o}of this.effectiveSelectionManager.selections)this.setSelection({layer:t,objectIds:t===e.layer?o:[]})}setSelection(e){this.effectiveSelectionManager?.setSelection(e.layer,e.objectIds)}async _goTo(e){const{view:t}=this;if(t)try{await y(t,e)}catch(r){"AbortError"!==r.name&&o.getLogger(this).warn("Failed to go to feature(s)",r)}}async _onSelectionChange(e){try{this.removeTemporaryHighlight();const t=[],o=this.layersToItems({controller:e,promises:t});t.length>0&&await Promise.all(t),this._onChangeAbortController===e&&(this._allLayerItems=o)}catch(t){o.getLogger(this).warn("Failed updating selection",t)}}};e([n()],_.prototype,"_groupItemCache",void 0),e([n()],_.prototype,"_hoverHighlightHandle",void 0),e([n()],_.prototype,"_layerItemCache",void 0),e([n()],_.prototype,"_allLayerItems",void 0),e([n()],_.prototype,"_onChangeAbortController",void 0),e([n()],_.prototype,"activeLayerItem",null),e([n()],_.prototype,"allLayerItems",null),e([n()],_.prototype,"effectiveCount",null),e([n()],_.prototype,"effectiveSelectionManager",null),e([n()],_.prototype,"featureTitleMap",void 0),e([n()],_.prototype,"isUpdating",null),e([n()],_.prototype,"layer",void 0),e([n()],_.prototype,"layerItems",null),e([n()],_.prototype,"layerViewMap",null),e([n()],_.prototype,"maxVisibleFeatureCountExceeded",null),e([n()],_.prototype,"maxVisibleFeatureCountPerLayer",void 0),e([n()],_.prototype,"selectionManager",void 0),e([n()],_.prototype,"selectionSources",null),e([n()],_.prototype,"state",null),e([n()],_.prototype,"totalCount",null),e([n()],_.prototype,"view",void 0),e([n()],_.prototype,"viewLayersAndTables",null),e([n()],_.prototype,"visibleLayerCount",null),e([n()],_.prototype,"visibleFeatureCount",null),_=e([c("esri.widgets.support.SelectionList.SelectionListViewModel")],_);const L=_;export{L as default};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Accessor.js";import o from"../../../core/Logger.js";import{removeMaybe as r}from"../../../core/maybe.js";import{ignoreAbortErrors as i,debounce as s}from"../../../core/promiseUtils.js";import{watch as a,on as l}from"../../../core/reactiveUtils.js";import{property as n}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/RandomLCG.js";import{subclass as c}from"../../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as h}from"../../../core/support/UpdatingHandles.js";import{isSubtypeGroupLayer as p,isSubtypeSublayer as g}from"../../../layers/support/layerUtils.js";import{isSelectableLayer as y}from"../../../views/support/selectionUtils.js";import{goTo as m}from"../goToUtils.js";import u from"./GroupLayerItem.js";import f from"./LayerItem.js";import{computeEffectiveCount as d,getNestedLayerItems as v,isLayerItem as S,isGroupLayerItem as I,getNestedFeatureItems as C}from"./selectionListUtils.js";const b=100;let _=class extends t{constructor(e){super(e),this._groupItemCache=new Map,this._hoverHighlightHandle=null,this._layerItemCache=new Map,this._allLayerItems=null,this._onChangeAbortController=null,this._updatingHandles=new h,this.featureTitleMap=new Map,this.filterText=void 0,this.layer=null,this.maxVisibleFeatureCountPerLayer=500,this.selectionManager=null,this._onSelectionChangeController=async()=>{this._cancelOnSelectionChange();const e=new AbortController;this._onChangeAbortController=e,await this._updatingHandles.addPromise(i(this._onSelectionChange(e))),this._onChangeAbortController===e&&(this._onChangeAbortController=null);const t=this.layer&&this.effectiveSelectionManager?.getSelection(this.layer);t?.length||(this.layer=null)},this._cancelOnSelectionChange=()=>this._onChangeAbortController?.abort(),this._onSelectionChangeDebounced=s(this._onSelectionChangeController,b)}initialize(){this.addHandles([a((()=>[this.view,this.effectiveSelectionManager]),(()=>this._onSelectionChangeDebounced())),l((()=>this.effectiveSelectionManager?.sources),"change",(()=>this._onSelectionChangeDebounced())),l((()=>this.effectiveSelectionManager),"selection-change",(()=>this._onSelectionChangeDebounced()))])}destroy(){this.removeTemporaryHighlight(),this._updatingHandles.destroy()}get activeLayerItem(){const{layer:e}=this;return e&&this.layerItems.find((t=>t.layer===e))}get allLayerItems(){return this._allLayerItems??[]}get effectiveCount(){return d(this.allLayerItems)}get effectiveSelectionManager(){return this.selectionManager??this.view?.selectionManager}get isUpdating(){return!(!this._onChangeAbortController&&!this._updatingHandles.updating)}get layerItems(){return v(this.allLayerItems)}get layerViewMap(){const e=new Map,{view:t}=this;if(!t)return e;for(const o of t.allLayerViews)if(e.set(o.layer.id,o),p(o.layer))for(const t of o.layer.sublayers)e.set(t.id,o);return e}get maxVisibleFeatureCountExceeded(){return this.allLayerItems.some((e=>e.maxVisibleFeatureCountExceeded))}get selectionSources(){const e=this.effectiveSelectionManager,t=new Set;if(e?.sources)for(const o of e.sources)t.add(o);return t}get state(){const{view:e}=this;return e?e.ready?this.effectiveSelectionManager?"ready":"error":"loading":"disabled"}get viewLayersAndTables(){const{view:e}=this;return e?.map?[...e.map.layers.toArray().reverse(),...e.map.tables.toArray().reverse()]:[]}get visibleLayerCount(){const{effectiveSelectionManager:e}=this;return e&&0!==e.count?1===e.count||this.activeLayerItem?1:this.layerItems.length:0}get visibleFeatureCount(){const{activeLayerItem:e}=this;if(e)return e.maxVisibleFeatureCountExceeded?e.maxVisibleFeatureCountPerLayer:e.total;let t=0;for(const o of this.layerItems)t+=o.maxVisibleFeatureCountExceeded?o.maxVisibleFeatureCountPerLayer:o.total;return t}addTemporaryHighlight({graphic:e,layerView:t}){this.removeTemporaryHighlight(),t&&e&&(this._hoverHighlightHandle=t.highlight(e,{name:"temporary"}))}clear(){this.effectiveSelectionManager?.clear()}deselectFeatureItem(e){const t=e.graphic.getObjectId();null!=t&&this.effectiveSelectionManager?.removeFromSelection(e.layer,[t])}deselectGroupItem(e){e.items.forEach((e=>{S(e)?this.deselectLayerItem(e):this.deselectGroupItem(e)}))}deselectLayerItem(e){this.effectiveSelectionManager?.setSelection(e.layer,[])}deselectItem(e){I(e)?this.deselectGroupItem(e):S(e)?this.deselectLayerItem(e):this.deselectFeatureItem(e)}goToItem(e){S(e)||I(e)?this._goTo(C([e]).map((e=>e.graphic))):this._goTo(e.graphic)}layersToItems(e){const{controller:t,groupLayerItem:o,layers:r,promises:i}=e,{_groupItemCache:s,_layerItemCache:a,effectiveSelectionManager:l,viewLayersAndTables:n}=this,c=r??n;if(!l)return[];const h=[];for(const p of c)switch(p.type){case"subtype-group":case"group":{const e=s.get(p),o=e??new u({layer:p,viewModel:this});e||s.set(p,o),i.push(o.sync({controller:t,promises:i})),h.push(o)}break;default:if(y(p)||g(p)){const e=p,r=l.getSelection(e);if(!r?.length)continue;const s=a.get(e),n=s??new f({groupLayerItem:o,layer:e,viewModel:this});s||a.set(e,n),i.push(n.sync({controller:t,promises:i})),h.push(n)}}return h}removeFromSelection(e){this.effectiveSelectionManager?.removeFromSelection(e.layer,e.objectIds)}removeTemporaryHighlight(){this._hoverHighlightHandle=r(this._hoverHighlightHandle)}selectSingleFeatureItem(e){const t=e.objectId;if(null!=t&&this.effectiveSelectionManager)for(const{layer:o}of this.effectiveSelectionManager.selections)this.setSelection({layer:o,objectIds:o===e.layer?[t]:[]})}selectSingleGroupItem(e){if(this.effectiveSelectionManager)for(const{layer:t,selection:o}of this.effectiveSelectionManager.selections)this.setSelection({layer:t,objectIds:t.parent===e.layer?o:[]})}selectSingleItem(e){I(e)?this.selectSingleGroupItem(e):S(e)?this.selectSingleLayerItem(e):this.selectSingleFeatureItem(e)}selectSingleLayerItem(e){if(this.effectiveSelectionManager)for(const{layer:t,selection:o}of this.effectiveSelectionManager.selections)this.setSelection({layer:t,objectIds:t===e.layer?o:[]})}setSelection(e){this.effectiveSelectionManager?.setSelection(e.layer,e.objectIds)}async _goTo(e){const{view:t}=this;if(t)try{await m(t,e)}catch(r){"AbortError"!==r.name&&o.getLogger(this).warn("Failed to go to feature(s)",r)}}async _onSelectionChange(e){try{this.removeTemporaryHighlight();const t=[],o=this.layersToItems({controller:e,promises:t});t.length>0&&await Promise.all(t),this._onChangeAbortController===e&&(this._allLayerItems=o)}catch(t){o.getLogger(this).warn("Failed updating selection",t)}}};e([n()],_.prototype,"_groupItemCache",void 0),e([n()],_.prototype,"_hoverHighlightHandle",void 0),e([n()],_.prototype,"_layerItemCache",void 0),e([n()],_.prototype,"_allLayerItems",void 0),e([n()],_.prototype,"_onChangeAbortController",void 0),e([n()],_.prototype,"activeLayerItem",null),e([n()],_.prototype,"allLayerItems",null),e([n()],_.prototype,"effectiveCount",null),e([n()],_.prototype,"effectiveSelectionManager",null),e([n()],_.prototype,"featureTitleMap",void 0),e([n()],_.prototype,"filterText",void 0),e([n()],_.prototype,"isUpdating",null),e([n()],_.prototype,"layer",void 0),e([n()],_.prototype,"layerItems",null),e([n()],_.prototype,"layerViewMap",null),e([n()],_.prototype,"maxVisibleFeatureCountExceeded",null),e([n()],_.prototype,"maxVisibleFeatureCountPerLayer",void 0),e([n()],_.prototype,"selectionManager",void 0),e([n()],_.prototype,"selectionSources",null),e([n()],_.prototype,"state",null),e([n()],_.prototype,"view",void 0),e([n()],_.prototype,"viewLayersAndTables",null),e([n()],_.prototype,"visibleLayerCount",null),e([n()],_.prototype,"visibleFeatureCount",null),_=e([c("esri.widgets.support.SelectionList.SelectionListViewModel")],_);const L=_;export{L as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{isSome as t}from"../../../core/arrayUtils.js";function n(e){return e.flatMap((t=>o(t)?t.selection:l(t)?t.children.flatMap((t=>n([t]))):t)).filter(t)}function e(n){return n.flatMap((t=>l(t)?t.children.filter((t=>"selection"in t)):o(t)&&t.total?t:null)).filter(t)}function r(t){let n=0;for(const e of t)o(e)&&(n+=e.total),l(e)&&(n+=r(e.children));return n}function l(t){return null!=t&&"object"==typeof t&&"children"in t}function o(t){return null!=t&&"object"==typeof t&&"selection"in t}function i(t){return null!=t&&"object"==typeof t&&"graphic"in t}export{r as computeEffectiveCount,n as getNestedFeatureItems,e as getNestedLayerItems,i as isFeatureItem,l as isGroupLayerItem,o as isLayerItem};
5
+ import{isSome as t}from"../../../core/arrayUtils.js";function e(n){return n.flatMap((t=>f(t)?t.featureItems:o(t)?t.items.flatMap((t=>e([t]))):t)).filter(t)}function n(e){return e.flatMap((t=>o(t)?t.items.filter((t=>f(t))):f(t)&&t.total?t:null)).filter(t)}function r(t){let e=0;for(const n of t)f(n)&&(e+=n.total),o(n)&&(e+=r(n.items));return e}function o(t){return null!=t&&"object"==typeof t&&"items"in t}function f(t){return null!=t&&"object"==typeof t&&"featureItems"in t}function i(t){return null!=t&&"object"==typeof t&&"graphic"in t}export{r as computeEffectiveCount,e as getNestedFeatureItems,n as getNestedLayerItems,i as isFeatureItem,o as isGroupLayerItem,f as isLayerItem};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import"../../intl.js";import{isSome as t}from"../../core/arrayUtils.js";import{on as i,watch as s}from"../../core/reactiveUtils.js";import{property as o}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import{subclass as l}from"../../core/accessorSupport/decorators/subclass.js";import n from"../Widget.js";import{loadCalciteComponents as r}from"./componentsUtils.js";import{globalCss as a}from"./globalCss.js";import{storeNode as c}from"./widgetUtils.js";import{messageBundle as m}from"./decorators/messageBundle.js";import{tsx as d}from"./jsxFactory.js";import{isGroupLayerItem as h,isLayerItem as p,isFeatureItem as u}from"./SelectionList/selectionListUtils.js";import v from"./SelectionList/SelectionListViewModel.js";import y from"./SelectionList/VisibleElements.js";import{formatNumber as g}from"../../intl/number.js";import{substitute as I}from"../../intl/substitute.js";const b="esri-selection-list",f=`${b}__list-item`,_={base:b,container:`${b}__container`,notice:`${b}__notice`,layerDropdown:`${b}__layer-dropdown`,listItemFeature:`${f}__feature`,listItemFeatureIcon:`${f}__feature-icon`,listItemIcon:`${f}__icon`,itemCount:`${b}__item-count`,totalCount:`${b}__total-count`};let w=class extends n{constructor(e,t){super(e,t),this._list=null,this._iconIntersectionObserver=new IntersectionObserver(((e,t)=>{e.forEach((async e=>{if(e.isIntersecting){const i=e.target;if(this._hasIcon(i))return void t.unobserve(i);const s=this._getListItem(i);if(!s)return;this._setHasIcon(i,!0);const o=await s.fetchThumbnail().catch((()=>(this._setHasIcon(i,!1),null)));if(null==o)return;i.appendChild(o)}}))})),this._itemWithOpenMenu=null,this.displayMode="group",this.hightlightOnHoverEnabled=!1,this.itemActionConfigs=null,this.menuScale="m",this.messages=null,this.messagesCommon=null,this.onListItemSelect=null,this.scale="s",this.viewModel=new v,this.visibleElements=new y,this._afterItemCreate=e=>{this._iconIntersectionObserver?.observe(e)},this._afterItemRemoved=e=>{this._iconIntersectionObserver?.unobserve(e)},this.clear=this.clear.bind(this),this.collapseItems=this.collapseItems.bind(this),this.removeTemporaryHighlight=this.removeTemporaryHighlight.bind(this)}initialize(){this.addHandles([i((()=>this.effectiveSelectionManager),"selection-change",(()=>this._closeItemMenu())),s((()=>this.hightlightOnHoverEnabled),(e=>{e||this.removeTemporaryHighlight()}))])}destroy(){this._iconIntersectionObserver?.disconnect(),this._iconIntersectionObserver=null}loadDependencies(){return r({action:()=>import("@esri/calcite-components/dist/components/calcite-action"),chip:()=>import("@esri/calcite-components/dist/components/calcite-chip"),combobox:()=>import("@esri/calcite-components/dist/components/calcite-combobox"),"combobox-item":()=>import("@esri/calcite-components/dist/components/calcite-combobox-item"),dropdown:()=>import("@esri/calcite-components/dist/components/calcite-dropdown"),"dropdown-group":()=>import("@esri/calcite-components/dist/components/calcite-dropdown-group"),"dropdown-item":()=>import("@esri/calcite-components/dist/components/calcite-dropdown-item"),flow:()=>import("@esri/calcite-components/dist/components/calcite-flow"),"flow-item":()=>import("@esri/calcite-components/dist/components/calcite-flow-item"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon"),list:()=>import("@esri/calcite-components/dist/components/calcite-list"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice"),panel:()=>import("@esri/calcite-components/dist/components/calcite-panel")})}get activeLayerItem(){return this.viewModel.activeLayerItem}get allLayerItems(){return this.viewModel.allLayerItems}get effectiveCount(){return this.viewModel.effectiveCount}get effectiveSelectionManager(){return this.viewModel.effectiveSelectionManager}get featureTitleMap(){return this.viewModel.featureTitleMap}get icon(){return"selection"}set icon(e){this._overrideIfSome("icon",e)}get isUpdating(){return this.viewModel.isUpdating}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get layer(){return this.viewModel.layer}set layer(e){this.viewModel.layer=e}get layerItems(){return this.viewModel.layerItems}get layerViewMap(){return this.viewModel.layerViewMap}get maxVisibleFeatureCountExceeded(){return this.viewModel.maxVisibleFeatureCountExceeded}get maxVisibleFeatureCountPerLayer(){return this.viewModel.maxVisibleFeatureCountPerLayer}set maxVisibleFeatureCountPerLayer(e){this.viewModel.maxVisibleFeatureCountPerLayer=e}get selectionManager(){return this.viewModel.selectionManager}set selectionManager(e){this.viewModel.selectionManager=e}get selectionSources(){return this.viewModel.selectionSources}get state(){return this.viewModel.state}get totalCount(){return this.viewModel.totalCount}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}get viewLayersAndTables(){return this.viewModel.viewLayersAndTables}get visibleFeatureCount(){return this.viewModel.visibleFeatureCount}get visibleLayerCount(){return this.viewModel.visibleLayerCount}addTemporaryHighlight(e){this.viewModel.addTemporaryHighlight(e)}clear(){this.viewModel.clear()}deselectFeatureItem(e){this.viewModel.deselectFeatureItem(e)}deselectGroupItem(e){this.viewModel.deselectGroupItem(e)}deselectLayerItem(e){this.viewModel.deselectLayerItem(e)}deselectItem(e){this.viewModel.deselectItem(e)}collapseItems(){this._list?.filteredItems.forEach((e=>e.expanded=!1))}goToItem(e){this.viewModel.goToItem(e)}removeFromSelection(e){this.viewModel.removeFromSelection(e)}removeTemporaryHighlight(){this.viewModel.removeTemporaryHighlight()}selectSingleFeatureItem(e){this.viewModel.selectSingleFeatureItem(e)}selectSingleGroupItem(e){this.viewModel.selectSingleGroupItem(e)}selectSingleItem(e){this.viewModel.selectSingleItem(e)}selectSingleLayerItem(e){this.viewModel.selectSingleLayerItem(e)}setSelection(e){this.viewModel.setSelection(e)}render(){return d("div",{class:this.classes(_.base,a.widget,a.panel)},d("calcite-flow",null,d("calcite-flow-item",{class:_.container,heading:this.visibleElements.header?this.messages.selection:void 0,loading:"loading"===this.state,overlayPositioning:"fixed",scale:this.scale,selected:!0},d("calcite-panel",{overlayPositioning:"fixed",scale:this.scale},this._renderLayerFilter(),this._renderList()),this._renderTotalChip(),this._renderMenuActions())))}_renderTotalChip(){const{visibleElements:e}=this;if(!e.totalCount||!e.header)return;const{effectiveCount:t}=this,i=g(t),s=I(this.messages.selectionCount,{count:i});return d("calcite-chip",{appearance:"outline",class:_.totalCount,closable:t>0,closed:0===t,icon:this.maxVisibleFeatureCountExceeded?"exclamation-mark-triangle":void 0,label:i,scale:this.scale,slot:"header-actions-end",title:s,onCalciteChipClose:this.clear},i)}_renderMenuActions(){const{visibleElements:e}=this;if(!e.header||!e.menu)return;const{menuScale:t}=this,i=0===this.totalCount;return[d("calcite-action",{disabled:i,icon:"reset",key:"clear-action",onclick:this.clear,scale:t,slot:"header-menu-actions",text:this.messagesCommon.clear,textEnabled:!0}),d("calcite-action",{disabled:i,icon:"folders",key:"collapse-action",onclick:this.collapseItems,scale:t,slot:"header-menu-actions",text:this.messages.collapseAll,textEnabled:!0})]}_renderLayerFilter(){const{layerItems:e,messages:t}=this;if(0!==this.totalCount&&0!==e.length&&this.visibleElements.layerFilter)return d("calcite-combobox",{class:_.layerDropdown,clearDisabled:!0,label:t.filterByLayer,overlayPositioning:"fixed",placeholder:t.filterByLayer,scale:this.scale,selectionMode:"single-persist",onCalciteComboboxChange:({currentTarget:e})=>{this._list&&(this._list.filterText="");const t=e.selectedItems[0]?.value??void 0;this.layer="all-layers"===t?void 0:t}},d("calcite-combobox-item",{heading:I(t.allLayersCount,{count:e.length}),icon:"layers",key:"all-layers",selected:null==this.layer,value:"all-layers"}),this.layerItems.map((e=>this._renderLayerFilterItem(e))))}_renderLayerFilterItem(e){const t=e.title||this.messages.untitledLayer;return d("calcite-combobox-item",{heading:t,icon:e.iconName,key:e.key,selected:e.layer===this.layer,value:e.layer})}_renderList(){const{messages:e}=this,t=!!(this.visibleElements.filter&&this.effectiveCount>0);return d("calcite-list",{afterCreate:c,bind:this,"data-node-ref":"_list",displayMode:"nested",filterEnabled:t,filterPlaceholder:e.filter,filterPredicate:({value:e})=>null==this._list?.filterText||new RegExp(this._list.filterText,"iu").test(e),interactionMode:"interactive",label:e.widgetLabel,loading:this.isUpdating,scale:this.scale,selectionMode:"none"},this._renderListContent(this.allLayerItems),this._renderFilterNotice())}_renderListContent(e){return this.activeLayerItem?this._renderLayerItem(this.activeLayerItem):e.map((e=>h(e)?this._renderGroupItem(e):p(e)?this._renderLayerItem(e):null)).filter(t)}_renderFilterNotice(){const{visibleElements:e}=this;if(e.filter&&e.filterNotice)return d("calcite-notice",{icon:"exclamation-mark-triangle",kind:"info",open:!0,scale:this.scale,slot:"filter-no-results"},d("div",{slot:"message"},this.messages.noMatchingFeatures))}_renderItemCount(e){if(!this.visibleElements.itemCount)return;const{messages:t}=this,i=g(e.total),s=I(t.selectionCount,{count:i});return e.maxVisibleFeatureCountExceeded?d("span",{class:_.itemCount,slot:"content-end",title:s},d("calcite-icon",{icon:"exclamation-mark-triangle",scale:"s",title:t.tooManyFeatures}),`${g(this.maxVisibleFeatureCountPerLayer)}+`):d("span",{class:_.itemCount,slot:"content-end",title:s},i)}_renderItemActions(e){if(!this.visibleElements.itemMenus)return;const{messages:t,messagesCommon:i}=this,s=this._itemWithOpenMenu===e,o=u(e),l=p(e),n=h(e),r=o?t.deselectFeature:l?t.deselectLayer:t.deselectGroup;return[d("calcite-dropdown",{open:s,overlayPositioning:"fixed",scale:this.menuScale,slot:"actions-end",width:"m",onCalciteDropdownClose:()=>this._closeItemMenu(e),onCalciteDropdownOpen:()=>{this._itemWithOpenMenu=e}},d("calcite-action",{appearance:"transparent",icon:"ellipsis",scale:this.scale,slot:"trigger",text:i.menu,textEnabled:!1}),s?d("calcite-dropdown-group",{selectionMode:"none"},d("calcite-dropdown-item",{iconStart:"layer-zoom-to",onCalciteDropdownItemSelect:()=>this.goToItem(e)},t.zoomTo),d("calcite-dropdown-item",{iconStart:"selection-filter",onCalciteDropdownItemSelect:()=>this.selectSingleItem(e)},o?t.onlySelectFeature:t.onlySelectThis),d("calcite-dropdown-item",{iconStart:"selection-x",onCalciteDropdownItemSelect:()=>this.deselectItem(e)},r),this.itemActionConfigs?.map((t=>{if(!t.type||"feature"===t.type&&o||"layer"===t.type&&l||"group"===t.type&&n)return d("calcite-dropdown-item",{iconStart:t.icon??void 0,onCalciteDropdownItemSelect:()=>t.callback({item:e})},t.label)}))):void 0)]}_renderGroupItem(e){const t=e.title||this.messages.untitledLayer;if(0===e.total)return;const{displayMode:i}=this;if("layer"===i||"feature"===i)return this._renderListContent(e.children);const{visibleElements:s}=this;return d("calcite-list-item",{bind:this,closable:!!s.itemCloseActions,expanded:!0,iconStart:s.itemIcons?e.iconName:void 0,key:e.key,label:t,value:e.title,onCalciteListItemClose:t=>{t.stopPropagation(),this.deselectItem(e)},onCalciteListItemSelect:t=>this._onListItemSelect(e,t)},this._renderItemActions(e),this._renderListContent(e.children))}_renderLayerItem(e){const{messages:t}=this,i=e.title||t.untitledLayer;if(0===e.total)return;if("feature"===this.displayMode||this.activeLayerItem)return this._renderItems(e.selection);const{visibleElements:s}=this;return d("calcite-list-item",{bind:this,closable:!!s.itemCloseActions,expanded:!0,iconStart:s.itemIcons?e.iconName:void 0,key:e.key,label:i,scale:this.scale,value:e.title,onCalciteListItemClose:t=>{t.stopPropagation(),this.deselectItem(e)},onCalciteListItemSelect:t=>this._onListItemSelect(e,t)},this._renderItemCount(e),this._renderItemActions(e),this._renderItems(e.selection),e.maxVisibleFeatureCountExceeded?d("calcite-notice",{class:_.notice,icon:"exclamation-mark-triangle",kind:"info",open:!0,scale:this.scale},d("div",{slot:"message"},t.tooManyFeatures)):void 0)}_renderItems(e){return e.map((e=>this._renderItem(e)))}_renderItem(e){const{hightlightOnHoverEnabled:t,messages:i,visibleElements:s}=this,o=e.title||i.untitledFeature,l=s.itemIcons&&"feature"!==this.displayMode;return d("calcite-list-item",{bind:this,class:l?_.listItemFeatureIcon:_.listItemFeature,closable:!!s.itemCloseActions,"data-item":e,key:e.key,label:o,name:o,onblur:t?()=>this.removeTemporaryHighlight():void 0,onfocus:t?()=>this.addTemporaryHighlight(e):void 0,onpointerenter:t?()=>this.addTemporaryHighlight(e):void 0,onpointerleave:t?()=>this.removeTemporaryHighlight():void 0,scale:this.scale,value:o,onCalciteListItemClose:t=>{t.stopPropagation(),this.deselectItem(e)},onCalciteListItemSelect:t=>this._onListItemSelect(e,t)},this._renderItemIcon(e),this._renderItemActions(e))}_renderItemIcon(e){if(this.visibleElements.itemIcons)return d("div",{class:_.listItemIcon,key:"content-start",slot:"content-start"},d("span",{afterCreate:this._afterItemCreate,afterRemoved:this._afterItemRemoved,"data-has-icon":!1,"data-item":e,key:"icon"}))}_getListItem(e){return e?.["data-item"]}_hasIcon(e){return!!e?.["data-has-icon"]}_setHasIcon(e,t){e&&(e["data-has-icon"]=t)}_onListItemSelect(e,t){t.stopPropagation(),this._closeItemMenu(),this.onListItemSelect?.({item:e})}_closeItemMenu(e){e&&e!==this._itemWithOpenMenu||(this._itemWithOpenMenu=null)}};e([o()],w.prototype,"_list",void 0),e([o()],w.prototype,"_itemWithOpenMenu",void 0),e([o()],w.prototype,"activeLayerItem",null),e([o()],w.prototype,"allLayerItems",null),e([o()],w.prototype,"displayMode",void 0),e([o()],w.prototype,"effectiveCount",null),e([o()],w.prototype,"effectiveSelectionManager",null),e([o()],w.prototype,"featureTitleMap",null),e([o()],w.prototype,"hightlightOnHoverEnabled",void 0),e([o()],w.prototype,"icon",null),e([o()],w.prototype,"itemActionConfigs",void 0),e([o()],w.prototype,"isUpdating",null),e([o()],w.prototype,"label",null),e([o()],w.prototype,"layer",null),e([o()],w.prototype,"layerItems",null),e([o()],w.prototype,"layerViewMap",null),e([o()],w.prototype,"maxVisibleFeatureCountExceeded",null),e([o()],w.prototype,"maxVisibleFeatureCountPerLayer",null),e([o()],w.prototype,"menuScale",void 0),e([o(),m("esri/widgets/support/SelectionList/t9n/SelectionList")],w.prototype,"messages",void 0),e([o(),m("esri/t9n/common")],w.prototype,"messagesCommon",void 0),e([o()],w.prototype,"onListItemSelect",void 0),e([o()],w.prototype,"scale",void 0),e([o()],w.prototype,"selectionManager",null),e([o()],w.prototype,"selectionSources",null),e([o()],w.prototype,"state",null),e([o()],w.prototype,"totalCount",null),e([o()],w.prototype,"view",null),e([o()],w.prototype,"viewLayersAndTables",null),e([o()],w.prototype,"viewModel",void 0),e([o()],w.prototype,"visibleFeatureCount",null),e([o()],w.prototype,"visibleLayerCount",null),e([o({type:y,nonNullable:!0})],w.prototype,"visibleElements",void 0),w=e([l("esri.widgets.support.SelectionList")],w);const C=w;export{C as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import"../../intl.js";import{isSome as t}from"../../core/arrayUtils.js";import{on as i,watch as s}from"../../core/reactiveUtils.js";import{throttle as o}from"../../core/throttle.js";import{property as l}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import{subclass as r}from"../../core/accessorSupport/decorators/subclass.js";import n from"../Widget.js";import{loadCalciteComponents as a}from"./componentsUtils.js";import{globalCss as c}from"./globalCss.js";import{storeNode as m}from"./widgetUtils.js";import{messageBundle as d}from"./decorators/messageBundle.js";import{tsx as h}from"./jsxFactory.js";import{isGroupLayerItem as u,isLayerItem as p,isFeatureItem as y}from"./SelectionList/selectionListUtils.js";import v from"./SelectionList/SelectionListViewModel.js";import f from"./SelectionList/VisibleElements.js";import{formatNumber as g}from"../../intl/number.js";import{substitute as I}from"../../intl/substitute.js";const b="esri-selection-list",_=`${b}__list-item`,C={base:b,container:`${b}__container`,notice:`${b}__notice`,layerDropdown:`${b}__layer-dropdown`,listItemFeature:`${_}__feature`,listItemFeatureIcon:`${_}__feature-icon`,listItemIcon:`${_}__icon`,itemCount:`${b}__item-count`,totalCount:`${b}__total-count`};let w=class extends n{constructor(e,t){super(e,t),this._filteredFeatureInfo=null,this._iconIntersectionObserver=new IntersectionObserver(((e,t)=>{e.forEach((async e=>{if(e.isIntersecting){const i=e.target;if(this._hasIcon(i))return void t.unobserve(i);const s=this._getListItem(i);if(!s)return;this._setHasIcon(i,!0);const o=await s.fetchThumbnail().catch((()=>(this._setHasIcon(i,!1),null)));if(null==o)return;i.appendChild(o)}}))})),this._itemWithOpenMenu=null,this._list=null,this.displayMode="group",this.hightlightOnHoverEnabled=!1,this.itemActionConfigs=null,this.menuScale="m",this.messages=null,this.messagesCommon=null,this.onListItemSelect=null,this.scale="s",this.viewModel=new v,this.visibleElements=new f,this._afterItemCreate=e=>{this._iconIntersectionObserver?.observe(e)},this._afterItemRemoved=e=>{this._iconIntersectionObserver?.unobserve(e)},this._syncVisibleCountsThrottled=o((()=>this._syncVisibleCounts()),100),this.clear=this.clear.bind(this),this.collapseItems=this.collapseItems.bind(this),this.removeTemporaryHighlight=this.removeTemporaryHighlight.bind(this),this._filterPredicate=this._filterPredicate.bind(this)}initialize(){this.addHandles([i((()=>this.effectiveSelectionManager),"selection-change",(()=>{this._closeItemMenu(),this._syncVisibleCountsThrottled()})),s((()=>this.hightlightOnHoverEnabled),(e=>{e||this.removeTemporaryHighlight()})),s((()=>this._visibleCountsParameters),(()=>this._syncVisibleCountsThrottled()))])}destroy(){this._iconIntersectionObserver?.disconnect(),this._iconIntersectionObserver=null}loadDependencies(){return a({action:()=>import("@esri/calcite-components/dist/components/calcite-action"),chip:()=>import("@esri/calcite-components/dist/components/calcite-chip"),combobox:()=>import("@esri/calcite-components/dist/components/calcite-combobox"),"combobox-item":()=>import("@esri/calcite-components/dist/components/calcite-combobox-item"),dropdown:()=>import("@esri/calcite-components/dist/components/calcite-dropdown"),"dropdown-group":()=>import("@esri/calcite-components/dist/components/calcite-dropdown-group"),"dropdown-item":()=>import("@esri/calcite-components/dist/components/calcite-dropdown-item"),flow:()=>import("@esri/calcite-components/dist/components/calcite-flow"),"flow-item":()=>import("@esri/calcite-components/dist/components/calcite-flow-item"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon"),list:()=>import("@esri/calcite-components/dist/components/calcite-list"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice"),panel:()=>import("@esri/calcite-components/dist/components/calcite-panel")})}get _filterIsActive(){const{filterText:e}=this;return!(!this._list||null==e||""===e)}get _visibleCountsParameters(){return{count:this.effectiveCount,filterText:this.filterText,layer:this.layer}}get activeLayerItem(){return this.viewModel.activeLayerItem}get allLayerItems(){return this.viewModel.allLayerItems}get effectiveCount(){return this.viewModel.effectiveCount}get effectiveSelectionManager(){return this.viewModel.effectiveSelectionManager}get featureTitleMap(){return this.viewModel.featureTitleMap}get filterText(){return this.viewModel.filterText}set filterText(e){this.viewModel.filterText=e}get filteredFeatureItems(){return this._filteredFeatureInfo?.featureItems}get icon(){return"selection"}set icon(e){this._overrideIfSome("icon",e)}get isUpdating(){return this.viewModel.isUpdating}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get layer(){return this.viewModel.layer}set layer(e){this.viewModel.layer=e}get layerItems(){return this.viewModel.layerItems}get layerViewMap(){return this.viewModel.layerViewMap}get maxVisibleFeatureCountExceeded(){return this.viewModel.maxVisibleFeatureCountExceeded}get maxVisibleFeatureCountPerLayer(){return this.viewModel.maxVisibleFeatureCountPerLayer}set maxVisibleFeatureCountPerLayer(e){this.viewModel.maxVisibleFeatureCountPerLayer=e}get selectionManager(){return this.viewModel.selectionManager}set selectionManager(e){this.viewModel.selectionManager=e}get selectionSources(){return this.viewModel.selectionSources}get state(){return this.viewModel.state}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}get viewLayersAndTables(){return this.viewModel.viewLayersAndTables}get visibleFeatureCount(){return this._filteredFeatureInfo?.featureItems.length??this.viewModel.visibleFeatureCount}get visibleLayerCount(){return this._filteredFeatureInfo?.layerCount??this.viewModel.visibleLayerCount}addTemporaryHighlight(e){this.viewModel.addTemporaryHighlight(e)}clear(){this.viewModel.clear()}deselectFeatureItem(e){this.viewModel.deselectFeatureItem(e)}deselectGroupItem(e){this.viewModel.deselectGroupItem(e)}deselectLayerItem(e){this.viewModel.deselectLayerItem(e)}deselectItem(e){this.viewModel.deselectItem(e)}collapseItems(){this._list?.filteredItems.forEach((e=>e.expanded=!1))}goToItem(e){this.viewModel.goToItem(e)}removeFromSelection(e){this.viewModel.removeFromSelection(e)}removeTemporaryHighlight(){this.viewModel.removeTemporaryHighlight()}selectSingleFeatureItem(e){this.viewModel.selectSingleFeatureItem(e)}selectSingleGroupItem(e){this.viewModel.selectSingleGroupItem(e)}selectSingleItem(e){this.viewModel.selectSingleItem(e)}selectSingleLayerItem(e){this.viewModel.selectSingleLayerItem(e)}setSelection(e){this.viewModel.setSelection(e)}render(){return h("div",{class:this.classes(C.base,c.widget,c.panel)},h("calcite-flow",null,h("calcite-flow-item",{class:C.container,heading:this.visibleElements.header?this.messages.selection:void 0,loading:"loading"===this.state,overlayPositioning:"fixed",scale:this.scale,selected:!0},h("calcite-panel",{overlayPositioning:"fixed",scale:this.scale},this._renderLayerFilter(),this._renderList()),this._renderTotalChip(),this._renderMenuActions())))}_renderTotalChip(){const{visibleElements:e}=this;if(!e.totalCount||!e.header)return;const{effectiveCount:t}=this,i=g(t),s=I(this.messages.selectionCount,{count:i});return h("calcite-chip",{appearance:"outline",class:C.totalCount,closable:t>0,closed:0===t,icon:this.maxVisibleFeatureCountExceeded?"exclamation-mark-triangle":void 0,label:i,scale:this.scale,slot:"header-actions-end",title:s,onCalciteChipClose:this.clear},i)}_renderMenuActions(){const{visibleElements:e}=this;if(!e.header||!e.menu)return;const{menuScale:t}=this,i=0===this.effectiveCount;return[h("calcite-action",{disabled:i,icon:"reset",key:"clear-action",onclick:this.clear,scale:t,slot:"header-menu-actions",text:this.messagesCommon.clear,textEnabled:!0}),h("calcite-action",{disabled:i,icon:"folders",key:"collapse-action",onclick:this.collapseItems,scale:t,slot:"header-menu-actions",text:this.messages.collapseAll,textEnabled:!0})]}_renderLayerFilter(){const{layerItems:e,messages:t}=this;if(!(0===this.effectiveCount||e.length<2)&&this.visibleElements.layerFilter)return h("calcite-combobox",{class:C.layerDropdown,clearDisabled:!0,label:t.filterByLayer,overlayPositioning:"fixed",placeholder:t.filterByLayer,scale:this.scale,selectionMode:"single-persist",onCalciteComboboxChange:({currentTarget:e})=>{this.filterText=void 0;const t=e.selectedItems[0]?.value??void 0;this.layer="all-layers"===t?void 0:t}},h("calcite-combobox-item",{heading:I(t.allLayersCount,{count:e.length}),icon:"layers",key:"all-layers",selected:null==this.layer,value:"all-layers"}),this.layerItems.map((e=>this._renderLayerFilterItem(e))))}_renderLayerFilterItem(e){const t=e.title||this.messages.untitledLayer;return h("calcite-combobox-item",{heading:t,icon:e.iconName,key:e.key,selected:e.layer===this.layer,value:e.layer})}_renderList(){const{messages:e}=this,t=!!(this.visibleElements.filter&&this.effectiveCount>0);return h("calcite-list",{afterCreate:m,bind:this,"data-node-ref":"_list",displayMode:"nested",filterEnabled:t,filterPlaceholder:e.filter,filterPredicate:this._filterPredicate,filterText:this.filterText,interactionMode:"interactive",label:e.widgetLabel,loading:this.isUpdating,scale:this.scale,selectionMode:"none",onCalciteListFilter:e=>this.filterText=e.target.filterText||void 0},this._renderListContent(this.allLayerItems),this._renderFilterNotice())}_renderListContent(e){return this.activeLayerItem?this._renderLayerItem(this.activeLayerItem):e.map((e=>u(e)?this._renderGroupItem(e):p(e)?this._renderLayerItem(e):null)).filter(t)}_renderFilterNotice(){const{visibleElements:e}=this;if(e.filter&&e.filterNotice)return h("calcite-notice",{icon:"exclamation-mark-triangle",kind:"info",open:!0,scale:this.scale,slot:"filter-no-results"},h("div",{slot:"message"},this.messages.noMatchingFeatures))}_renderItemCount(e){if(!this.visibleElements.itemCount||this._filterIsActive)return;const{messages:t}=this,i=g(e.total),s=I(t.selectionCount,{count:i});return e.maxVisibleFeatureCountExceeded?h("span",{class:C.itemCount,slot:"content-end",title:s},h("calcite-icon",{icon:"exclamation-mark-triangle",scale:"s",title:t.tooManyFeatures}),`${g(this.maxVisibleFeatureCountPerLayer)}+`):h("span",{class:C.itemCount,slot:"content-end",title:s},i)}_renderItemActions(e){if(!this.visibleElements.itemMenus)return;const{messages:t,messagesCommon:i}=this,s=this._itemWithOpenMenu===e,o=y(e),l=p(e),r=u(e),n=o?t.deselectFeature:l?t.deselectLayer:t.deselectGroup;return[h("calcite-dropdown",{open:s,overlayPositioning:"fixed",scale:this.menuScale,slot:"actions-end",width:"m",onCalciteDropdownClose:()=>this._closeItemMenu(e),onCalciteDropdownOpen:()=>{this._itemWithOpenMenu=e}},h("calcite-action",{appearance:"transparent",icon:"ellipsis",scale:this.scale,slot:"trigger",text:i.menu,textEnabled:!1}),s?h("calcite-dropdown-group",{selectionMode:"none"},h("calcite-dropdown-item",{iconStart:"layer-zoom-to",onCalciteDropdownItemSelect:()=>this.goToItem(e)},t.zoomTo),h("calcite-dropdown-item",{iconStart:"selection-filter",onCalciteDropdownItemSelect:()=>this.selectSingleItem(e)},o?t.onlySelectFeature:t.onlySelectThis),h("calcite-dropdown-item",{iconStart:"selection-x",onCalciteDropdownItemSelect:()=>this.deselectItem(e)},n),this.itemActionConfigs?.map((t=>{if(!t.type||"feature"===t.type&&o||"layer"===t.type&&l||"group"===t.type&&r)return h("calcite-dropdown-item",{iconStart:t.icon??void 0,onCalciteDropdownItemSelect:()=>t.callback({item:e})},t.label)}))):void 0)]}_renderGroupItem(e){const t=e.title||this.messages.untitledLayer;if(0===e.total)return;const{displayMode:i}=this;if("layer"===i||"feature"===i)return this._renderListContent(e.items);const{visibleElements:s}=this;return h("calcite-list-item",{afterCreate:this._syncVisibleCountsThrottled,afterRemoved:this._syncVisibleCountsThrottled,bind:this,closable:!!s.itemCloseActions,"data-type":"group",expanded:!0,iconStart:s.itemIcons?e.iconName:void 0,key:e.key,label:t,value:e.title,onCalciteListItemClose:t=>{t.stopPropagation(),this.deselectItem(e)},onCalciteListItemSelect:t=>this._onListItemSelect(e,t)},this._renderItemActions(e),this._renderListContent(e.items))}_renderLayerItem(e){const{messages:t}=this,i=e.title||t.untitledLayer;if(0===e.total)return;if("feature"===this.displayMode)return this._renderItems(e.featureItems);const{visibleElements:s}=this;return h("calcite-list-item",{afterCreate:this._syncVisibleCountsThrottled,afterRemoved:this._syncVisibleCountsThrottled,bind:this,closable:!!s.itemCloseActions,"data-type":"layer",expanded:!0,iconStart:s.itemIcons?e.iconName:void 0,key:e.key,label:i,scale:this.scale,value:e.title,onCalciteListItemClose:t=>{t.stopPropagation(),this.deselectItem(e)},onCalciteListItemSelect:t=>this._onListItemSelect(e,t)},this._renderItemCount(e),this._renderItemActions(e),this._renderItems(e.featureItems),e.maxVisibleFeatureCountExceeded?h("calcite-notice",{class:C.notice,icon:"exclamation-mark-triangle",kind:"info",open:!0,scale:this.scale},h("div",{slot:"message"},t.tooManyFeatures)):void 0)}_renderItems(e){return e.map((e=>this._renderItem(e)))}_renderItem(e){const{hightlightOnHoverEnabled:t,messages:i,visibleElements:s}=this,o=e.title||i.untitledFeature,l=s.itemIcons&&"feature"!==this.displayMode;return h("calcite-list-item",{afterCreate:this._syncVisibleCountsThrottled,afterRemoved:this._syncVisibleCountsThrottled,bind:this,class:l?C.listItemFeatureIcon:C.listItemFeature,closable:!!s.itemCloseActions,"data-item":e,"data-type":"feature",key:e.key,label:o,metadata:e.metadata,name:o,onblur:t?()=>this.removeTemporaryHighlight():void 0,onfocus:t?()=>this.addTemporaryHighlight(e):void 0,onpointerenter:t?()=>this.addTemporaryHighlight(e):void 0,onpointerleave:t?()=>this.removeTemporaryHighlight():void 0,scale:this.scale,value:o,onCalciteListItemClose:t=>{t.stopPropagation(),this.deselectItem(e)},onCalciteListItemSelect:t=>this._onListItemSelect(e,t)},this._renderItemIcon(e),this._renderItemActions(e))}_renderItemIcon(e){if(this.visibleElements.itemIcons)return h("div",{class:C.listItemIcon,key:"content-start",slot:"content-start"},h("span",{afterCreate:this._afterItemCreate,afterRemoved:this._afterItemRemoved,"data-has-icon":!1,"data-item":e,key:"icon"}))}_getListItem(e){return e?.["data-item"]}_hasIcon(e){return!!e?.["data-has-icon"]}_setHasIcon(e,t){e&&(e["data-has-icon"]=t)}_onListItemSelect(e,t){t.stopPropagation(),this._closeItemMenu(),this.onListItemSelect?.({item:e})}_closeItemMenu(e){e&&e!==this._itemWithOpenMenu||(this._itemWithOpenMenu=null)}_syncVisibleCounts(){this._filteredFeatureInfo=this._getFilteredFeatureInfo()}_getFilteredFeatureInfo(){const{_list:e}=this;if(!e||!this._filterIsActive)return;const t=[];let i=0;return e.filteredItems.forEach((e=>{switch(e.getAttribute("data-type")){case"feature":{const i=this._getListItem(e);i&&t.push(i);break}case"layer":i++}})),{featureItems:t,layerCount:i}}_filterPredicate(e){const t=this._list?.filterText;if(null==t||""===t)return!0;const i=[e.value],s=e.metadata;return null!=s?.parentTitle&&i.push(s.parentTitle),null!=s?.groupTitle&&i.push(s.groupTitle),i.some((e=>new RegExp(t,"iu").test(e)))}};e([l()],w.prototype,"_filteredFeatureInfo",void 0),e([l()],w.prototype,"_filterIsActive",null),e([l()],w.prototype,"_itemWithOpenMenu",void 0),e([l()],w.prototype,"_list",void 0),e([l()],w.prototype,"_visibleCountsParameters",null),e([l()],w.prototype,"activeLayerItem",null),e([l()],w.prototype,"allLayerItems",null),e([l()],w.prototype,"displayMode",void 0),e([l()],w.prototype,"effectiveCount",null),e([l()],w.prototype,"effectiveSelectionManager",null),e([l()],w.prototype,"featureTitleMap",null),e([l()],w.prototype,"filterText",null),e([l()],w.prototype,"filteredFeatureItems",null),e([l()],w.prototype,"hightlightOnHoverEnabled",void 0),e([l()],w.prototype,"icon",null),e([l()],w.prototype,"itemActionConfigs",void 0),e([l()],w.prototype,"isUpdating",null),e([l()],w.prototype,"label",null),e([l()],w.prototype,"layer",null),e([l()],w.prototype,"layerItems",null),e([l()],w.prototype,"layerViewMap",null),e([l()],w.prototype,"maxVisibleFeatureCountExceeded",null),e([l()],w.prototype,"maxVisibleFeatureCountPerLayer",null),e([l()],w.prototype,"menuScale",void 0),e([l(),d("esri/widgets/support/SelectionList/t9n/SelectionList")],w.prototype,"messages",void 0),e([l(),d("esri/t9n/common")],w.prototype,"messagesCommon",void 0),e([l()],w.prototype,"onListItemSelect",void 0),e([l()],w.prototype,"scale",void 0),e([l()],w.prototype,"selectionManager",null),e([l()],w.prototype,"selectionSources",null),e([l()],w.prototype,"state",null),e([l()],w.prototype,"view",null),e([l()],w.prototype,"viewLayersAndTables",null),e([l()],w.prototype,"viewModel",void 0),e([l()],w.prototype,"visibleFeatureCount",null),e([l()],w.prototype,"visibleLayerCount",null),e([l({type:f,nonNullable:!0})],w.prototype,"visibleElements",void 0),w=e([r("esri.widgets.support.SelectionList")],w);const M=w;export{M as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import{deprecatedProperty as t}from"../../../core/deprecate.js";import o from"../../../core/Evented.js";import{handlesGroup as i}from"../../../core/handleUtils.js";import s from"../../../core/Logger.js";import{removeMaybe as r}from"../../../core/maybe.js";import{watch as n}from"../../../core/reactiveUtils.js";import{property as a}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/RandomLCG.js";import{subclass as l}from"../../../core/accessorSupport/decorators/subclass.js";import{isKnowledgeGraphLayer as c,isLinkChartLayer as p}from"../../../layers/support/layerUtils.js";import{findLayerView as u}from"../../../views/draw/support/layerUtils.js";import{isSelectableLayerView2D as h}from"../../../views/support/layerViewUtils.js";import d from"../Selector2D/SelectionOperation.js";let f=class extends o.EventedAccessor{constructor(e){super(e),this._operationHandlesGroup=null,this.continuousSelectionEnabled=!1,this.activeOperation=null,this.defaultLassoToolOptions={createTool:"polygon",mode:"hybrid",name:"lasso"},this.defaultPointToolOptions={createTool:"point",name:"point"},this.defaultRectangleToolOptions={createTool:"rectangle",name:"rectangle"},this.layerViewPreferenceEnabled=!0,this.persistSelection=!0,this.selectionManager=null,this.returnFeatureTitleFields=!1,this.returnGeometry=!0,this.selectOnComplete=!0,this.sources=null,this.toolConfigs=[]}initialize(){this.addHandles([n((()=>this.effectiveSources),(e=>{this.activeOperation&&(this.activeOperation.sources=e)}))])}destroy(){this._operationHandlesGroup=r(this._operationHandlesGroup)}get effectiveSelectionManager(){return this.selectionManager??this.view?.selectionManager}get effectiveSources(){const{layerViewPreferenceEnabled:e,sources:t,view:o}=this,i=t??this.effectiveSelectionManager?.sources;if(!i?.length)return[];const s=[];return i.forEach((t=>{if(h(t))s.push(t);else if(c(t)||p(t)){(t.layers||[]).forEach((t=>{const i=o?u(o,t):void 0,r=e&&h(i)?i:t;s.push(r)}))}else if(e){const e=o?u(o,t):void 0,i=h(e)?e:t;s.push(i)}else s.push(t)})),s}get layers(){return t(s.getLogger(this),"layers",{replacement:"Use SelectionToolbar.sources instead."}),this.sources}set layers(e){t(s.getLogger(this),"layers",{replacement:"Use SelectionToolbar.sources instead."}),this.sources=e}get state(){return this.activeOperation?"active":this.view?.ready&&this.effectiveSources.length?"ready":"disabled"}activate(e){const{state:t}=this,o=e?.view||this.view,r=e?.sources||this.effectiveSources;if("disabled"===t||!o)return void s.getLogger(this).warn("Unable to start selection operation.");"active"===t&&this.cancel();const n=new CustomEvent("before-activate",{cancelable:!0,detail:{toolName:e?.name??null}});if(this.emit("before-activate",n),n.defaultPrevented)return;const a={persistSelection:this.persistSelection,returnFeatureTitleFields:this.returnFeatureTitleFields,returnGeometry:this.returnGeometry,selectOnComplete:this.selectOnComplete,selectionManager:this.effectiveSelectionManager,...e,sources:r,view:o},l=new d({...a});return this._operationHandlesGroup=i([l.on("selection-change",(e=>this.emit("selection-change",e))),l.once("complete",(e=>this._onOperationComplete(e,a)))]),this._set("activeOperation",l),l}activateTool(e){this.cancel();const t=this._getToolOptions(e);if(t)return this.activate(t);s.getLogger(this).warn("Unable to activate tool: unable to determine options.")}cancel(){this.activeOperation?.cancel(),this._set("activeOperation",null)}toggleTool(e){const{activeOperation:t}=this;if(t){const o=t.name;if(this.cancel(),o===e)return}return this.activateTool(e)}_onOperationComplete(e,t){this._operationHandlesGroup=r(this._operationHandlesGroup),this._set("activeOperation",null),this.emit("complete",e),this.continuousSelectionEnabled&&!e.aborted&&this.activate(t)}_getToolOptions(e){const t=this.toolConfigs.find((t=>t.toolName===e));return t||("lasso"===e?this.defaultLassoToolOptions:"point"===e?this.defaultPointToolOptions:"rectangle"===e?this.defaultRectangleToolOptions:void 0)}};e([a()],f.prototype,"continuousSelectionEnabled",void 0),e([a({readOnly:!0})],f.prototype,"activeOperation",void 0),e([a()],f.prototype,"defaultLassoToolOptions",void 0),e([a()],f.prototype,"defaultPointToolOptions",void 0),e([a()],f.prototype,"defaultRectangleToolOptions",void 0),e([a()],f.prototype,"effectiveSelectionManager",null),e([a()],f.prototype,"effectiveSources",null),e([a()],f.prototype,"layers",null),e([a()],f.prototype,"layerViewPreferenceEnabled",void 0),e([a()],f.prototype,"persistSelection",void 0),e([a()],f.prototype,"selectionManager",void 0),e([a()],f.prototype,"returnFeatureTitleFields",void 0),e([a()],f.prototype,"returnGeometry",void 0),e([a()],f.prototype,"selectOnComplete",void 0),e([a()],f.prototype,"sources",void 0),e([a({readOnly:!0})],f.prototype,"state",null),e([a()],f.prototype,"toolConfigs",void 0),e([a()],f.prototype,"view",void 0),f=e([l("esri.widgets.support.SelectionToolbar.SelectionToolbarViewModel")],f);const v=f;export{v as default};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import{deprecatedProperty as t}from"../../../core/deprecate.js";import o from"../../../core/Evented.js";import{handlesGroup as i}from"../../../core/handleUtils.js";import s from"../../../core/Logger.js";import{removeMaybe as r}from"../../../core/maybe.js";import{watch as n}from"../../../core/reactiveUtils.js";import{property as a}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/RandomLCG.js";import{subclass as l}from"../../../core/accessorSupport/decorators/subclass.js";import{isKnowledgeGraphLayer as c,isLinkChartLayer as p}from"../../../layers/support/layerUtils.js";import{findLayerView as u}from"../../../views/draw/support/layerUtils.js";import{isSelectableLayerView2D as d}from"../../../views/support/layerViewUtils.js";import h from"../Selector2D/SelectionOperation.js";let f=class extends o.EventedAccessor{constructor(e){super(e),this._operationHandlesGroup=null,this.activeOperation=null,this.continuousSelectionEnabled=!1,this.defaultLassoToolOptions={createTool:"polygon",mode:"hybrid",toolName:"lasso"},this.defaultOperationType="add",this.defaultPointToolOptions={createTool:"point",toolName:"point"},this.defaultRectangleToolOptions={createTool:"rectangle",toolName:"rectangle"},this.layerViewPreferenceEnabled=!0,this.persistSelection=!0,this.selectionManager=null,this.returnFeatureTitleFields=!1,this.returnGeometry=!0,this.selectOnComplete=!0,this.sources=null,this.toolConfigs=[]}initialize(){this.addHandles([n((()=>this.effectiveSources),(e=>{this.activeOperation&&(this.activeOperation.sources=e)}))])}destroy(){this._operationHandlesGroup=r(this._operationHandlesGroup)}get effectiveSelectionManager(){return this.selectionManager??this.view?.selectionManager}get effectiveSources(){const{layerViewPreferenceEnabled:e,sources:t,view:o}=this,i=t??this.effectiveSelectionManager?.sources;if(!i?.length)return[];const s=[];return i.forEach((t=>{if(d(t))s.push(t);else if(c(t)||p(t)){(t.layers||[]).forEach((t=>{const i=o?u(o,t):void 0,r=e&&d(i)?i:t;s.push(r)}))}else if(e){const e=o?u(o,t):void 0,i=d(e)?e:t;s.push(i)}else s.push(t)})),s}get layers(){return t(s.getLogger(this),"layers",{replacement:"Use SelectionToolbar.sources instead."}),this.sources}set layers(e){t(s.getLogger(this),"layers",{replacement:"Use SelectionToolbar.sources instead."}),this.sources=e}get state(){return this.activeOperation?"active":this.view?.ready&&this.effectiveSources.length?"ready":"disabled"}activate(e){const{state:t}=this,o=e?.view||this.view,r=e?.sources||this.effectiveSources;if("disabled"===t||!o)return void s.getLogger(this).warn("Unable to start selection operation.");"active"===t&&this.cancel();const n=new CustomEvent("before-activate",{cancelable:!0,detail:{toolName:e?.toolName??null}});if(this.emit("before-activate",n),n.defaultPrevented)return;const a={type:this.defaultOperationType,persistSelection:this.persistSelection,returnFeatureTitleFields:this.returnFeatureTitleFields,returnGeometry:this.returnGeometry,selectOnComplete:this.selectOnComplete,selectionManager:this.effectiveSelectionManager,...e,sources:r,view:o},l=new h({...a});return this._operationHandlesGroup=i([l.on("selection-change",(e=>this.emit("selection-change",e))),l.once("complete",(e=>this._onOperationComplete(e,a)))]),this._set("activeOperation",l),l}activateTool(e){this.cancel();const t=this._getToolOptions(e);if(t)return this.activate(t);s.getLogger(this).warn("Unable to activate tool: unable to determine options.")}cancel(){this.activeOperation?.cancel(),this._set("activeOperation",null)}toggleTool(e){const{activeOperation:t}=this;if(t){const o=t.toolName;if(this.cancel(),o===e)return}return this.activateTool(e)}_onOperationComplete(e,t){this._operationHandlesGroup=r(this._operationHandlesGroup),this._set("activeOperation",null),this.emit("complete",e),this.continuousSelectionEnabled&&!e.aborted&&this.activate(t)}_getToolOptions(e){const t=this.toolConfigs.find((t=>t.toolName===e));return t||("lasso"===e?this.defaultLassoToolOptions:"point"===e?this.defaultPointToolOptions:"rectangle"===e?this.defaultRectangleToolOptions:void 0)}};e([a({readOnly:!0})],f.prototype,"activeOperation",void 0),e([a()],f.prototype,"continuousSelectionEnabled",void 0),e([a()],f.prototype,"defaultLassoToolOptions",void 0),e([a()],f.prototype,"defaultOperationType",void 0),e([a()],f.prototype,"defaultPointToolOptions",void 0),e([a()],f.prototype,"defaultRectangleToolOptions",void 0),e([a()],f.prototype,"effectiveSelectionManager",null),e([a()],f.prototype,"effectiveSources",null),e([a()],f.prototype,"layers",null),e([a()],f.prototype,"layerViewPreferenceEnabled",void 0),e([a()],f.prototype,"persistSelection",void 0),e([a()],f.prototype,"selectionManager",void 0),e([a()],f.prototype,"returnFeatureTitleFields",void 0),e([a()],f.prototype,"returnGeometry",void 0),e([a()],f.prototype,"selectOnComplete",void 0),e([a()],f.prototype,"sources",void 0),e([a({readOnly:!0})],f.prototype,"state",null),e([a()],f.prototype,"toolConfigs",void 0),e([a()],f.prototype,"view",void 0),f=e([l("esri.widgets.support.SelectionToolbar.SelectionToolbarViewModel")],f);const v=f;export{v as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import"../../intl.js";import{deprecatedProperty as t}from"../../core/deprecate.js";import{handlesGroup as o}from"../../core/handleUtils.js";import i from"../../core/Logger.js";import{removeMaybe as s}from"../../core/maybe.js";import{on as l}from"../../core/reactiveUtils.js";import{property as r}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{subclass as n}from"../../core/accessorSupport/decorators/subclass.js";import a from"../Widget.js";import{loadCalciteComponents as c}from"./componentsUtils.js";import{globalCss as d}from"./globalCss.js";import"./widgetUtils.js";import{messageBundle as p}from"./decorators/messageBundle.js";import{tsx as u}from"./jsxFactory.js";import h from"./SelectionToolbar/SelectionToolbarViewModel.js";import v from"./SelectionToolbar/VisibleElements.js";import{formatNumber as m}from"../../intl/number.js";const f="esri-selection-toolbar",g={base:f,container:`${f}__container`,toolButton:`${f}__tool-button`};let b=class extends a{constructor(e,t){super(e,t),this._viewModelHandlesGroup=null,this.disabled=!1,this.layout="horizontal",this.messages=null,this.scale="s",this.viewModel=new h,this.visibleElements=new v}initialize(){this._viewModelHandlesGroup=o([l((()=>this.viewModel),"before-activate",(e=>this.emit("before-activate",e))),l((()=>this.viewModel),"complete",(e=>this.emit("complete",e))),l((()=>this.viewModel),"selection-change",(e=>this.emit("selection-change",e)))])}destroy(){this._viewModelHandlesGroup=s(this._viewModelHandlesGroup)}loadDependencies(){return c({action:()=>import("@esri/calcite-components/dist/components/calcite-action"),"action-bar":()=>import("@esri/calcite-components/dist/components/calcite-action-bar"),chip:()=>import("@esri/calcite-components/dist/components/calcite-chip")})}get _effectiveDisabled(){return this.disabled||"disabled"===this.state}get activeOperation(){return this.viewModel.activeOperation}get continuousSelectionEnabled(){return this.viewModel.continuousSelectionEnabled}set continuousSelectionEnabled(e){this.viewModel.continuousSelectionEnabled=e}get defaultLassoToolOptions(){return this.viewModel.defaultLassoToolOptions}set defaultLassoToolOptions(e){this.viewModel.defaultLassoToolOptions=e}get defaultPointToolOptions(){return this.viewModel.defaultPointToolOptions}set defaultPointToolOptions(e){this.viewModel.defaultPointToolOptions=e}get defaultRectangleToolOptions(){return this.viewModel.defaultRectangleToolOptions}set defaultRectangleToolOptions(e){this.viewModel.defaultRectangleToolOptions=e}get effectiveSelectionManager(){return this.viewModel.effectiveSelectionManager}get effectiveSources(){return this.viewModel.effectiveSources}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get layers(){return t(i.getLogger(this),"layers",{replacement:"Use SelectionToolbar.sources instead."}),this.viewModel.sources}set layers(e){t(i.getLogger(this),"layers",{replacement:"Use SelectionToolbar.sources instead."}),this.viewModel.sources=e}get layerViewPreferenceEnabled(){return this.viewModel.layerViewPreferenceEnabled}set layerViewPreferenceEnabled(e){this.viewModel.layerViewPreferenceEnabled=e}get persistSelection(){return this.viewModel.persistSelection}set persistSelection(e){this.viewModel.persistSelection=e}get returnFeatureTitleFields(){return this.viewModel.returnFeatureTitleFields}set returnFeatureTitleFields(e){this.viewModel.returnFeatureTitleFields=e}get returnGeometry(){return this.viewModel.returnGeometry}set returnGeometry(e){this.viewModel.returnGeometry=e}get selectOnComplete(){return this.viewModel.selectOnComplete}set selectOnComplete(e){this.viewModel.selectOnComplete=e}get selectionManager(){return this.viewModel.selectionManager}set selectionManager(e){this.viewModel.selectionManager=e}get state(){return this.viewModel.state}get sources(){return this.viewModel.sources}set sources(e){this.viewModel.sources=e}get toolConfigs(){return this.viewModel.toolConfigs}set toolConfigs(e){this.viewModel.toolConfigs=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}get visibleToolCount(){const{visibleElements:e}=this;return this.toolConfigs.length+(e.lassoTool?1:0)+(e.rectangleTool?1:0)}activate(e){if(this.cancel(),!this._effectiveDisabled)return this.viewModel.activate(e)}activateTool(e){if(!this._effectiveDisabled)return this.viewModel.activateTool(e)}cancel(){this.viewModel.cancel()}toggleTool(e){if(!this._effectiveDisabled)return this.viewModel.toggleTool(e)}render(){return u("div",{"aria-label":this.label,class:this.classes(g.base,d.widget)},u("div",{class:g.container},u("calcite-action-bar",{expandDisabled:!0,layout:"horizontal",scale:this.scale},this._renderDefaultTools(),this._renderCustomTools(),this._renderChip())))}_renderDefaultTools(){return[this._renderPanAction(),this._renderPointTool(),this._renderRectangleTool(),this._renderLassoTool()]}_renderPanAction(){if(!this.visibleElements.pan)return;const e=this.messages.pan,t=`${this.id}-tool-pan`;return this._renderAction({active:!this.activeOperation,disabled:this._effectiveDisabled,icon:"pan",id:t,key:t,onclick:()=>this.cancel(),text:e,title:e})}_renderChip(){if(!this.visibleElements.chip)return;const{effectiveSelectionManager:e}=this,t=e?.count??0,o=m(t);return u("calcite-chip",{appearance:"outline",closable:t>0,closed:0===t,disabled:this._effectiveDisabled||0===t,label:o,scale:this.scale,slot:"actions-end",title:this.messages.clearSelection,onCalciteChipClose:()=>e?.clear()},o)}_renderCustomTools(){return this.toolConfigs.map((({toolName:e,icon:t,toolKey:o})=>this._renderToolWithTooltip(e,o,t)))}_renderPointTool(){if(this.visibleElements.pointTool)return this._renderToolWithTooltip("point","point","selection-set",this.messages.selectByPoint)}_renderLassoTool(){if(this.visibleElements.lassoTool)return this._renderToolWithTooltip("lasso","lasso","lasso-select",this.messages.selectByLasso)}_renderRectangleTool(){if(this.visibleElements.rectangleTool)return this._renderToolWithTooltip("rectangle","rectangle","cursor-marquee",this.messages.selectByRectangle)}_renderToolWithTooltip(e,t,o,i=e){const s=`${this.id}-tool-${t}`;return this._renderAction({active:this.activeOperation?.name===e,disabled:this._effectiveDisabled,icon:o||"selection",id:s,key:s,onclick:()=>this.toggleTool(e),text:i,title:i})}_renderAction(e){return u("calcite-action",{...e,bind:this,class:g.toolButton,scale:this.scale})}};e([r()],b.prototype,"_effectiveDisabled",null),e([r()],b.prototype,"activeOperation",null),e([r()],b.prototype,"continuousSelectionEnabled",null),e([r()],b.prototype,"defaultLassoToolOptions",null),e([r()],b.prototype,"defaultPointToolOptions",null),e([r()],b.prototype,"defaultRectangleToolOptions",null),e([r()],b.prototype,"disabled",void 0),e([r()],b.prototype,"effectiveSelectionManager",null),e([r()],b.prototype,"effectiveSources",null),e([r()],b.prototype,"label",null),e([r()],b.prototype,"layers",null),e([r()],b.prototype,"layerViewPreferenceEnabled",null),e([r()],b.prototype,"layout",void 0),e([r(),p("esri/widgets/support/SelectionToolbar/t9n/SelectionToolbar")],b.prototype,"messages",void 0),e([r()],b.prototype,"persistSelection",null),e([r()],b.prototype,"returnFeatureTitleFields",null),e([r()],b.prototype,"returnGeometry",null),e([r()],b.prototype,"selectOnComplete",null),e([r()],b.prototype,"scale",void 0),e([r()],b.prototype,"selectionManager",null),e([r()],b.prototype,"state",null),e([r()],b.prototype,"sources",null),e([r()],b.prototype,"toolConfigs",null),e([r()],b.prototype,"view",null),e([r()],b.prototype,"viewModel",void 0),e([r({type:v,nonNullable:!0})],b.prototype,"visibleElements",void 0),e([r()],b.prototype,"visibleToolCount",null),b=e([n("esri.widgets.support.SelectionToolbar")],b);const w=b;export{w as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import"../../intl.js";import{deprecatedProperty as t}from"../../core/deprecate.js";import{handlesGroup as o}from"../../core/handleUtils.js";import i from"../../core/Logger.js";import{removeMaybe as s}from"../../core/maybe.js";import{on as l}from"../../core/reactiveUtils.js";import{property as r}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{subclass as n}from"../../core/accessorSupport/decorators/subclass.js";import a from"../Widget.js";import{loadCalciteComponents as c}from"./componentsUtils.js";import{globalCss as d}from"./globalCss.js";import"./widgetUtils.js";import{messageBundle as p}from"./decorators/messageBundle.js";import{tsx as u}from"./jsxFactory.js";import h from"./SelectionToolbar/SelectionToolbarViewModel.js";import v from"./SelectionToolbar/VisibleElements.js";import{formatNumber as f}from"../../intl/number.js";const m="esri-selection-toolbar",g={base:m,container:`${m}__container`,toolButton:`${m}__tool-button`};let b=class extends a{constructor(e,t){super(e,t),this._viewModelHandlesGroup=null,this.disabled=!1,this.layout="horizontal",this.messages=null,this.scale="s",this.viewModel=new h,this.visibleElements=new v}initialize(){this._viewModelHandlesGroup=o([l((()=>this.viewModel),"before-activate",(e=>this.emit("before-activate",e))),l((()=>this.viewModel),"complete",(e=>this.emit("complete",e))),l((()=>this.viewModel),"selection-change",(e=>this.emit("selection-change",e)))])}destroy(){this._viewModelHandlesGroup=s(this._viewModelHandlesGroup)}loadDependencies(){return c({action:()=>import("@esri/calcite-components/dist/components/calcite-action"),"action-bar":()=>import("@esri/calcite-components/dist/components/calcite-action-bar"),chip:()=>import("@esri/calcite-components/dist/components/calcite-chip")})}get _effectiveDisabled(){return this.disabled||"disabled"===this.state}get activeOperation(){return this.viewModel.activeOperation}get continuousSelectionEnabled(){return this.viewModel.continuousSelectionEnabled}set continuousSelectionEnabled(e){this.viewModel.continuousSelectionEnabled=e}get defaultLassoToolOptions(){return this.viewModel.defaultLassoToolOptions}set defaultLassoToolOptions(e){this.viewModel.defaultLassoToolOptions=e}get defaultOperationType(){return this.viewModel.defaultOperationType}set defaultOperationType(e){this.viewModel.defaultOperationType=e}get defaultPointToolOptions(){return this.viewModel.defaultPointToolOptions}set defaultPointToolOptions(e){this.viewModel.defaultPointToolOptions=e}get defaultRectangleToolOptions(){return this.viewModel.defaultRectangleToolOptions}set defaultRectangleToolOptions(e){this.viewModel.defaultRectangleToolOptions=e}get effectiveSelectionManager(){return this.viewModel.effectiveSelectionManager}get effectiveSources(){return this.viewModel.effectiveSources}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get layers(){return t(i.getLogger(this),"layers",{replacement:"Use SelectionToolbar.sources instead."}),this.viewModel.sources}set layers(e){t(i.getLogger(this),"layers",{replacement:"Use SelectionToolbar.sources instead."}),this.viewModel.sources=e}get layerViewPreferenceEnabled(){return this.viewModel.layerViewPreferenceEnabled}set layerViewPreferenceEnabled(e){this.viewModel.layerViewPreferenceEnabled=e}get persistSelection(){return this.viewModel.persistSelection}set persistSelection(e){this.viewModel.persistSelection=e}get returnFeatureTitleFields(){return this.viewModel.returnFeatureTitleFields}set returnFeatureTitleFields(e){this.viewModel.returnFeatureTitleFields=e}get returnGeometry(){return this.viewModel.returnGeometry}set returnGeometry(e){this.viewModel.returnGeometry=e}get selectOnComplete(){return this.viewModel.selectOnComplete}set selectOnComplete(e){this.viewModel.selectOnComplete=e}get selectionManager(){return this.viewModel.selectionManager}set selectionManager(e){this.viewModel.selectionManager=e}get state(){return this.viewModel.state}get sources(){return this.viewModel.sources}set sources(e){this.viewModel.sources=e}get toolConfigs(){return this.viewModel.toolConfigs}set toolConfigs(e){this.viewModel.toolConfigs=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}get visibleToolCount(){const{visibleElements:e}=this;return this.toolConfigs.length+(e.lassoTool?1:0)+(e.rectangleTool?1:0)}activate(e){if(this.cancel(),!this._effectiveDisabled)return this.viewModel.activate(e)}activateTool(e){if(!this._effectiveDisabled)return this.viewModel.activateTool(e)}cancel(){this.viewModel.cancel()}toggleTool(e){if(!this._effectiveDisabled)return this.viewModel.toggleTool(e)}render(){return u("div",{"aria-label":this.label,class:this.classes(g.base,d.widget)},u("div",{class:g.container},u("calcite-action-bar",{expandDisabled:!0,layout:"horizontal",scale:this.scale},this._renderDefaultTools(),this._renderCustomTools(),this._renderChip())))}_renderDefaultTools(){return[this._renderPanAction(),this._renderPointTool(),this._renderRectangleTool(),this._renderLassoTool()]}_renderPanAction(){if(!this.visibleElements.pan)return;const e=this.messages.pan,t=`${this.id}-tool-pan`;return this._renderAction({active:!this.activeOperation,disabled:this._effectiveDisabled,icon:"pan",id:t,key:t,onclick:()=>this.cancel(),text:e,title:e})}_renderChip(){if(!this.visibleElements.chip)return;const{effectiveSelectionManager:e}=this,t=e?.count??0,o=f(t);return u("calcite-chip",{appearance:"outline",closable:t>0,closed:0===t,disabled:this._effectiveDisabled||0===t,label:o,scale:this.scale,slot:"actions-end",title:this.messages.clearSelection,onCalciteChipClose:()=>e?.clear()},o)}_renderCustomTools(){return this.toolConfigs.map((({toolName:e,icon:t})=>this._renderToolWithTooltip(e,t)))}_renderPointTool(){if(this.visibleElements.pointTool)return this._renderToolWithTooltip("point","selection-set",this.messages.selectByPoint)}_renderLassoTool(){if(this.visibleElements.lassoTool)return this._renderToolWithTooltip("lasso","lasso-select",this.messages.selectByLasso)}_renderRectangleTool(){if(this.visibleElements.rectangleTool)return this._renderToolWithTooltip("rectangle","cursor-marquee",this.messages.selectByRectangle)}_renderToolWithTooltip(e,t,o=e){const i=`${this.id}-tool-${e}`;return this._renderAction({active:this.activeOperation?.toolName===e,disabled:this._effectiveDisabled,icon:t||"selection",id:i,key:i,onclick:()=>this.toggleTool(e),text:o,title:o})}_renderAction(e){return u("calcite-action",{...e,bind:this,class:g.toolButton,scale:this.scale})}};e([r()],b.prototype,"_effectiveDisabled",null),e([r()],b.prototype,"activeOperation",null),e([r()],b.prototype,"continuousSelectionEnabled",null),e([r()],b.prototype,"defaultLassoToolOptions",null),e([r()],b.prototype,"defaultOperationType",null),e([r()],b.prototype,"defaultPointToolOptions",null),e([r()],b.prototype,"defaultRectangleToolOptions",null),e([r()],b.prototype,"disabled",void 0),e([r()],b.prototype,"effectiveSelectionManager",null),e([r()],b.prototype,"effectiveSources",null),e([r()],b.prototype,"label",null),e([r()],b.prototype,"layers",null),e([r()],b.prototype,"layerViewPreferenceEnabled",null),e([r()],b.prototype,"layout",void 0),e([r(),p("esri/widgets/support/SelectionToolbar/t9n/SelectionToolbar")],b.prototype,"messages",void 0),e([r()],b.prototype,"persistSelection",null),e([r()],b.prototype,"returnFeatureTitleFields",null),e([r()],b.prototype,"returnGeometry",null),e([r()],b.prototype,"selectOnComplete",null),e([r()],b.prototype,"scale",void 0),e([r()],b.prototype,"selectionManager",null),e([r()],b.prototype,"state",null),e([r()],b.prototype,"sources",null),e([r()],b.prototype,"toolConfigs",null),e([r()],b.prototype,"view",null),e([r()],b.prototype,"viewModel",void 0),e([r({type:v,nonNullable:!0})],b.prototype,"visibleElements",void 0),e([r()],b.prototype,"visibleToolCount",null),b=e([n("esri.widgets.support.SelectionToolbar")],b);const w=b;export{w as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import{createTask as t}from"../../../core/asyncUtils.js";import o from"../../../core/Collection.js";import r from"../../../core/Evented.js";import{makeHandle as s}from"../../../core/handleUtils.js";import i from"../../../core/Logger.js";import{abortMaybe as n}from"../../../core/maybe.js";import{debounce as l,onAbort as c,ignoreAbortErrors as a}from"../../../core/promiseUtils.js";import{createScreenPoint as p}from"../../../core/screenUtils.js";import{property as d}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/RandomLCG.js";import{subclass as h}from"../../../core/accessorSupport/decorators/subclass.js";import m from"../../../geometry/Point.js";import u from"../../../geometry/Polygon.js";import{isClockwise as y}from"../../../geometry/support/coordsUtils.js";import{sketchKeys as f,selectionKeys as v}from"../../../views/interactive/keybindings.js";import{loadAutomaticLengthMeasurementUtils as g}from"../../../views/support/automaticLengthMeasurementUtils.js";import{getSelectionFromGeometry as _}from"./selectorUtils.js";const w=100;let T=class extends r.EventedAccessor{constructor(e){super(e),this._completed=!1,this._isConstraintKeyDown=!1,this._processTask=null,this.createTool="rectangle",this.mode=null,this.name="",this.persistSelection=!0,this.returnFeatureTitleFields=!1,this.returnGeometry=!0,this.selection=new o,this.selectionManager=null,this.selectOnComplete=!0,this.sources=null,this.type="add",this._process=l((async(e,o)=>{const{callback:r,selector:s,completed:i}=e,n=t((async e=>{const{effectiveSelectionManager:t,returnFeatureTitleFields:o,returnGeometry:n,selection:l,sources:c,view:a}=this,p=!c?.length&&!t.sources.length;if(l.removeAll(),!p&&a){if(s&&null!=c){const r=await _({returnFeatureTitleFields:o,returnGeometry:n,selector:s,signal:e,sources:c,view:a});if(l.addMany(r),i&&this.persistSelection)switch(this.effectiveType){case"remove":t.updateSelection({current:[],added:[],removed:r});break;case"replace":t.clear(),t.updateSelection({current:r,added:[],removed:[]});break;default:t.updateSelection({current:r,added:[],removed:[]})}}r&&r()}}));return c(o,(()=>n.abort())),this._processTask=n,n.promise}),w),this._onOperationFinish=this._onOperationFinish.bind(this)}initialize(){this._setup()}get _defaultMode(){return"polygon"===this.createTool?"click":"hybrid"}get _selectionArea(){const e=this._tool.coordinates;if(0===e.length)return;const t=p(),o=this.view.spatialReference,r=e=>{t.x=e[0],t.y=e[1];const o=this.view.toMap(t);return[o?.x??0,o?.y??0]};if(1===e.length||e.every((([t,o])=>t===e[0][0]&&o===e[0][1]))){const[t,s]=r(e[0]);return new m({x:t,y:s,spatialReference:o})}const s=e.map(r);if(0===s.length)return;y(s)||s.reverse();return new u({spatialReference:o,rings:[s]})}get completed(){return this._completed}get effectiveSelectionManager(){return this.selectionManager??this.view.selectionManager}get effectiveType(){const e=this.type??"add";if(this._isConstraintKeyDown)switch(e){case"add":return"remove";case"remove":case"replace":return"add";default:return e}return e}get processingFinalSelection(){return!(!this._processTask||!this._tool?.drawOperation?.isCompleted)}cancel(){this.selection.removeAll(),this._onOperationFinish(!0)}destroy(){this._toolImportController=n(this._toolImportController)}async _setup(){const{createTool:e,view:t}=this;if(await t.whenReady(),this.destroyed||this._toolImportController)return;const o=new AbortController;this._toolImportController=o;const[r,n]=await Promise.all([import("../../../views/draw/DrawScreenTool.js"),g()]);if(o.signal.aborted)return;const l=Symbol();try{this._tool=new r.DrawScreenTool({view:t,mode:this.mode??this._defaultMode,geometryType:e,automaticLengthMeasurementUtils:n})}finally{this._toolImportController=null}this._tool?(this.selectOnComplete||this.addHandles(this._tool.on(["cursor-update","vertex-add","vertex-remove"],(()=>{this._syncConstraintKeyDown(),a(this._process({selector:this._selectionArea}))})),l),this.addHandles([t.on("key-down",(e=>{if(!e.repeat)switch(e.key){case f.constraint:this._tool.uniformSizeToggled=!0,e.stopPropagation();break;case f.center:this._tool.centeredToggled=!0,e.stopPropagation()}})),t.on("key-up",(e=>{switch(e.key){case f.constraint:this._tool.uniformSizeToggled=!1,e.stopPropagation();break;case f.center:this._tool.centeredToggled=!1,e.stopPropagation()}})),this.selection.on("change",(e=>this.emit("selection-change",{operationType:this.effectiveType,...e}))),this._tool.on("complete",(async e=>{this._syncConstraintKeyDown(),this.removeHandles(l),e.aborted?this.cancel():(this._tool.cursor="progress",await this._process({selector:this._selectionArea,callback:this._onOperationFinish,completed:!0}))}))],l),this.addHandles(s((()=>t.tools.remove(this._tool)))),t.addAndActivateTool(this._tool)):i.getLogger(this).warn("Unable to import Draw module. SelectionOperation failed to load.")}_syncConstraintKeyDown(){const{inputManager:e}=this.view;this._isConstraintKeyDown=v.invertType.some((t=>e.isModifierKeyDown(t)))}_onOperationFinish(e=!1){this.removeAllHandles(),this._processTask?.abort(),this.emit("complete",{aborted:e,operationType:this.effectiveType,selection:this.selection.toArray()}),this._completed=!0}};e([d()],T.prototype,"_completed",void 0),e([d()],T.prototype,"_defaultMode",null),e([d()],T.prototype,"_isConstraintKeyDown",void 0),e([d()],T.prototype,"_processTask",void 0),e([d()],T.prototype,"_selectionArea",null),e([d()],T.prototype,"completed",null),e([d({constructOnly:!0})],T.prototype,"createTool",void 0),e([d()],T.prototype,"effectiveSelectionManager",null),e([d()],T.prototype,"effectiveType",null),e([d({constructOnly:!0})],T.prototype,"mode",void 0),e([d({constructOnly:!0})],T.prototype,"name",void 0),e([d()],T.prototype,"persistSelection",void 0),e([d()],T.prototype,"processingFinalSelection",null),e([d()],T.prototype,"returnFeatureTitleFields",void 0),e([d()],T.prototype,"returnGeometry",void 0),e([d({readOnly:!0})],T.prototype,"selection",void 0),e([d({constructOnly:!0})],T.prototype,"selectionManager",void 0),e([d({constructOnly:!0})],T.prototype,"selectOnComplete",void 0),e([d()],T.prototype,"sources",void 0),e([d({constructOnly:!0})],T.prototype,"type",void 0),e([d({constructOnly:!0})],T.prototype,"view",void 0),T=e([h("esri.widgets.support.Selector2D.SelectionOperation")],T);const S=T;export{S as default};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import{createTask as t}from"../../../core/asyncUtils.js";import o from"../../../core/Collection.js";import r from"../../../core/Evented.js";import{makeHandle as s}from"../../../core/handleUtils.js";import i from"../../../core/Logger.js";import{abortMaybe as n}from"../../../core/maybe.js";import{debounce as l,onAbort as c,ignoreAbortErrors as a}from"../../../core/promiseUtils.js";import{createScreenPoint as p}from"../../../core/screenUtils.js";import{property as d}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/RandomLCG.js";import{subclass as h}from"../../../core/accessorSupport/decorators/subclass.js";import m from"../../../geometry/Point.js";import u from"../../../geometry/Polygon.js";import{isClockwise as y}from"../../../geometry/support/coordsUtils.js";import{sketchKeys as f,selectionKeys as v}from"../../../views/interactive/keybindings.js";import{loadAutomaticLengthMeasurementUtils as g}from"../../../views/support/automaticLengthMeasurementUtils.js";import{getSelectionFromGeometry as _}from"./selectorUtils.js";const w=100;let T=class extends r.EventedAccessor{constructor(e){super(e),this._completed=!1,this._isConstraintKeyDown=!1,this._processTask=null,this.createTool="rectangle",this.mode=null,this.persistSelection=!0,this.returnFeatureTitleFields=!1,this.returnGeometry=!0,this.selection=new o,this.selectionManager=null,this.selectOnComplete=!0,this.sources=null,this.toolName="",this.type="add",this._process=l((async(e,o)=>{const{callback:r,selector:s,completed:i}=e,n=t((async e=>{const{effectiveSelectionManager:t,returnFeatureTitleFields:o,returnGeometry:n,selection:l,sources:c,view:a}=this,p=!c?.length&&!t.sources.length;if(l.removeAll(),!p&&a){if(s&&null!=c){const r=await _({returnFeatureTitleFields:o,returnGeometry:n,selector:s,signal:e,sources:c,view:a});if(l.addMany(r),i&&this.persistSelection)switch(this.effectiveType){case"remove":t.updateSelection({current:[],added:[],removed:r});break;case"replace":t.clear(),t.updateSelection({current:r,added:[],removed:[]});break;default:t.updateSelection({current:r,added:[],removed:[]})}}r&&r()}}));return c(o,(()=>n.abort())),this._processTask=n,n.promise}),w),this._onOperationFinish=this._onOperationFinish.bind(this)}initialize(){this._setup()}get _defaultMode(){return"polygon"===this.createTool?"click":"hybrid"}get _selectionArea(){const e=this._tool.coordinates;if(0===e.length)return;const t=p(),o=this.view.spatialReference,r=e=>{t.x=e[0],t.y=e[1];const o=this.view.toMap(t);return[o?.x??0,o?.y??0]};if(1===e.length||e.every((([t,o])=>t===e[0][0]&&o===e[0][1]))){const[t,s]=r(e[0]);return new m({x:t,y:s,spatialReference:o})}const s=e.map(r);if(0===s.length)return;y(s)||s.reverse();return new u({spatialReference:o,rings:[s]})}get completed(){return this._completed}get effectiveSelectionManager(){return this.selectionManager??this.view.selectionManager}get effectiveType(){const e=this.type??"add";if(this._isConstraintKeyDown)switch(e){case"add":return"remove";case"remove":case"replace":return"add";default:return e}return e}get processingFinalSelection(){return!(!this._processTask||!this._tool?.drawOperation?.isCompleted)}cancel(){this.selection.removeAll(),this._onOperationFinish(!0)}destroy(){this._toolImportController=n(this._toolImportController)}async _setup(){const{createTool:e,view:t}=this;if(await t.whenReady(),this.destroyed||this._toolImportController)return;const o=new AbortController;this._toolImportController=o;const[r,n]=await Promise.all([import("../../../views/draw/DrawScreenTool.js"),g()]);if(o.signal.aborted)return;const l=Symbol();try{this._tool=new r.DrawScreenTool({view:t,mode:this.mode??this._defaultMode,geometryType:e,automaticLengthMeasurementUtils:n})}finally{this._toolImportController=null}this._tool?(this.selectOnComplete||this.addHandles(this._tool.on(["cursor-update","vertex-add","vertex-remove"],(()=>{this._syncConstraintKeyDown(),a(this._process({selector:this._selectionArea}))})),l),this.addHandles([t.on("key-down",(e=>{if(!e.repeat)switch(e.key){case f.constraint:this._tool.uniformSizeToggled=!0,e.stopPropagation();break;case f.center:this._tool.centeredToggled=!0,e.stopPropagation()}})),t.on("key-up",(e=>{switch(e.key){case f.constraint:this._tool.uniformSizeToggled=!1,e.stopPropagation();break;case f.center:this._tool.centeredToggled=!1,e.stopPropagation()}})),this.selection.on("change",(e=>this.emit("selection-change",{operationType:this.effectiveType,...e}))),this._tool.on("complete",(async e=>{this._syncConstraintKeyDown(),this.removeHandles(l),e.aborted?this.cancel():(this._tool.cursor="progress",await this._process({selector:this._selectionArea,callback:this._onOperationFinish,completed:!0}))}))],l),this.addHandles(s((()=>t.tools.remove(this._tool)))),t.addAndActivateTool(this._tool)):i.getLogger(this).warn("Unable to import Draw module. SelectionOperation failed to load.")}_syncConstraintKeyDown(){const{inputManager:e}=this.view;this._isConstraintKeyDown=v.invertType.some((t=>e.isModifierKeyDown(t)))}_onOperationFinish(e=!1){this.removeAllHandles(),this._processTask?.abort(),this.emit("complete",{aborted:e,operationType:this.effectiveType,selection:this.selection.toArray(),toolName:this.toolName}),this._completed=!0}};e([d()],T.prototype,"_completed",void 0),e([d()],T.prototype,"_defaultMode",null),e([d()],T.prototype,"_isConstraintKeyDown",void 0),e([d()],T.prototype,"_processTask",void 0),e([d()],T.prototype,"_selectionArea",null),e([d()],T.prototype,"completed",null),e([d({constructOnly:!0})],T.prototype,"createTool",void 0),e([d()],T.prototype,"effectiveSelectionManager",null),e([d()],T.prototype,"effectiveType",null),e([d({constructOnly:!0})],T.prototype,"mode",void 0),e([d()],T.prototype,"persistSelection",void 0),e([d()],T.prototype,"processingFinalSelection",null),e([d()],T.prototype,"returnFeatureTitleFields",void 0),e([d()],T.prototype,"returnGeometry",void 0),e([d({readOnly:!0})],T.prototype,"selection",void 0),e([d({constructOnly:!0})],T.prototype,"selectionManager",void 0),e([d({constructOnly:!0})],T.prototype,"selectOnComplete",void 0),e([d()],T.prototype,"sources",void 0),e([d({constructOnly:!0})],T.prototype,"toolName",void 0),e([d({constructOnly:!0})],T.prototype,"type",void 0),e([d({constructOnly:!0})],T.prototype,"view",void 0),T=e([h("esri.widgets.support.Selector2D.SelectionOperation")],T);const S=T;export{S as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{addMany as e}from"../../../core/arrayUtils.js";import{ignoreAbortErrors as r,whenOrAbort as t}from"../../../core/promiseUtils.js";import{getDisplayFieldName as s}from"../../../layers/support/fieldUtils.js";import{isFeatureLayer as a,isSubtypeGroupLayer as i,isSubtypeSublayer as l,isKnowledgeGraphLayer as n,isLinkChartLayer as o,isMapNotesLayer as c,isGraphicsLayer as u}from"../../../layers/support/layerUtils.js";import{calculateTolerance as d}from"../../../renderers/support/clickToleranceUtils.js";import{createQueryGeometry as y}from"../../../views/support/drapedUtils.js";import{isSelectableLayerView2D as p}from"../../../views/support/layerViewUtils.js";async function m(e){const{returnFeatureTitleFields:s,returnGeometry:a,selector:i,signal:l,sources:n,view:o}=e;if(!n?.length)return[];const{layers:c,layerViews:u,graphicsLayers:d}=f(n),y=[];return await r(t(Promise.all([w({candidates:y,layers:c,returnFeatureTitleFields:s,returnGeometry:a,selector:i,signal:l,view:o}),g({candidates:y,layerViews:u,returnGeometry:a,selector:i,signal:l,view:o}),j({candidates:y,graphicsLayers:d,selector:i})]),l)),y}function f(e){const r=[],t=[],s=[];return e.forEach((e=>{a(e)||i(e)||l(e)?r.push(e):(n(e)||o(e))&&e.layers?.length?r.push(...e.layers.toArray()):c(e)&&e.sublayers?.length?s.push(...e.sublayers.toArray()):u(e)?s.push(e):p(e)&&t.push(e)})),{layers:r,layerViews:t,graphicsLayers:s}}async function g(r){const{candidates:s,layerViews:a,returnGeometry:i,selector:l,signal:n,view:o}=r;"point"!==l.type?await t(Promise.allSettled(a.map((async r=>{const t=T(r,l,o,i),a=await r.queryFeatures(t,{signal:n});e(s,a.features)}))),n):await h({candidates:s,layerViews:a,selector:l,view:o})}async function h({candidates:e,layerViews:r,selector:t,view:s}){const a=s.toScreen(t);if(!a)return;const i=r.map((e=>e.layer)),{results:l}=await s.hitTest(a,{include:i});l.forEach((r=>{"graphic"in r&&r.graphic&&e.push(r.graphic)}))}async function w(r){const{candidates:s,layers:a,returnFeatureTitleFields:i,returnGeometry:l,selector:n,signal:o,view:c}=r;await t(Promise.allSettled(a.map((async r=>{if("isTable"in r&&r.isTable)return;const t=v(r,n,c,i,l),a=await r.queryFeatures(t,{signal:o});e(s,a.features)}))),o)}function F(e,r,t){return"point"===e.type?y(e,"renderer"in r?d({renderer:r.renderer}):0,t):e}function b(e,r,t){const{fields:a,fieldsIndex:i}=e,l=new Set([e.objectIdField]);"globalIdField"in e&&null!=e.globalIdField&&i.has(e.globalIdField)&&l.add(i.get(e.globalIdField).name);const n="displayField"in e?e.displayField:null,o=s({displayField:n,fields:a});if(null!=o&&i.has(o)&&l.add(o),"subtypeField"in e&&null!=e.subtypeField){const t=i.get(e.subtypeField)?.name;if(null!=t&&l.add(t),"utilityNetworks"in r.map&&r.map.utilityNetworks?.length){const e=i.get("assetgroup");e?.name&&l.add(e.name);const r=i.get("assettype");r?.name&&l.add(r.name)}}return(t||r.requiredFieldsOptions.featureTitleFields)&&"featureTitleFields"in e&&e.featureTitleFields&&e.featureTitleFields.forEach((e=>l.add(e))),Array.from(l.values())}function T(e,r,t,s=!0){const a=e.createQuery();return a.outFields=["*"],a.geometry=F(r,e.layer,t),a.returnGeometry=s,a.outSpatialReference=t.spatialReference,a}function v(e,r,t,s=!1,a=!0){const i=e.createQuery();return i.outFields=b(e,t,s),i.geometry=F(r,e,t),i.returnGeometry=a,i.outSpatialReference=t.spatialReference,i}async function j(e){const{candidates:r,graphicsLayers:t,selector:s}=e,a=t.flatMap((e=>e.graphics.toArray()))??[];if(!a?.length||!s)return;const i=await import("../../../geometry/operators/intersectsOperator.js");i.accelerateGeometry(s),a.forEach((e=>{e.geometry&&"mesh"!==e.geometry.type&&i.execute(s,e.geometry)&&r.push(e)}))}export{g as collectSelectionFromFeatureLayerViews,w as collectSelectionFromFeatureLayers,j as collectSelectionFromGraphicsLayers,m as getSelectionFromGeometry,F as getSuggestedQueryGeometry};
5
+ import{addMany as e}from"../../../core/arrayUtils.js";import{ignoreAbortErrors as r,whenOrAbort as t}from"../../../core/promiseUtils.js";import{getDisplayFieldName as s}from"../../../layers/support/fieldUtils.js";import{isFeatureLayer as a,isSubtypeGroupLayer as i,isSubtypeSublayer as l,isKnowledgeGraphLayer as n,isLinkChartLayer as o,isMapNotesLayer as c,isGraphicsLayer as u}from"../../../layers/support/layerUtils.js";import{calculateTolerance as d}from"../../../renderers/support/clickToleranceUtils.js";import{createQueryGeometry as y}from"../../../views/support/drapedUtils.js";import{isSelectableLayerView2D as p}from"../../../views/support/layerViewUtils.js";async function m(e){const{returnFeatureTitleFields:s,returnGeometry:a,selector:i,signal:l,sources:n,view:o}=e;if(!n?.length)return[];const{layers:c,layerViews:u,graphicsLayers:d}=f(n),y=[];return await r(t(Promise.all([w({candidates:y,layers:c,returnFeatureTitleFields:s,returnGeometry:a,selector:i,signal:l,view:o}),g({candidates:y,layerViews:u,returnGeometry:a,selector:i,signal:l,view:o}),j({candidates:y,graphicsLayers:d,selector:i})]),l)),y}function f(e){const r=[],t=[],s=[];return e.forEach((e=>{a(e)||i(e)||l(e)?r.push(e):(n(e)||o(e))&&e.layers?.length?r.push(...e.layers.toArray()):c(e)&&e.sublayers?.length?s.push(...e.sublayers.toArray()):u(e)?s.push(e):p(e)&&t.push(e)})),{layers:r,layerViews:t,graphicsLayers:s}}async function g(r){const{candidates:s,layerViews:a,returnGeometry:i,selector:l,signal:n,view:o}=r;"point"!==l.type?await t(Promise.allSettled(a.map((async r=>{const t=T(r,l,o,i),a=await r.queryFeatures(t,{signal:n});e(s,a.features)}))),n):await h({candidates:s,layerViews:a,selector:l,view:o})}async function h({candidates:e,layerViews:r,selector:t,view:s}){const a=s.toScreen(t);if(!a)return;const i=r.map((e=>e.layer)),{results:l}=await s.hitTest(a,{include:i});l.forEach((r=>{"graphic"in r&&r.graphic&&e.push(r.graphic)}))}async function w(r){const{candidates:s,layers:a,returnFeatureTitleFields:i,returnGeometry:l,selector:n,signal:o,view:c}=r;await t(Promise.allSettled(a.map((async r=>{if("isTable"in r&&r.isTable)return;const t=v(r,n,c,i,l),a=await r.queryFeatures(t,{signal:o});e(s,a.features)}))),o)}function F(e,r,t){return"point"===e.type?y(e,"renderer"in r?d({renderer:r.renderer}):0,t):e}function b(e,r,t){const{fields:a,fieldsIndex:i}=e,l=new Set([e.objectIdField]);"globalIdField"in e&&null!=e.globalIdField&&i.has(e.globalIdField)&&l.add(i.get(e.globalIdField).name);const n="displayField"in e?e.displayField:null,o=s({displayField:n,fields:a});if(null!=o&&i.has(o)&&l.add(o),"subtypeField"in e&&null!=e.subtypeField){const t=i.get(e.subtypeField)?.name;if(null!=t&&l.add(t),"utilityNetworks"in r.map&&r.map.utilityNetworks?.length){const e=i.get("assetgroup");e?.name&&l.add(e.name);const r=i.get("assettype");r?.name&&l.add(r.name)}}return(t||r.requiredFieldsOptions.featureTitleFields)&&"featureTitleFields"in e&&e.featureTitleFields&&e.featureTitleFields.forEach((e=>l.add(e))),Array.from(l.values())}function T(e,r,t,s=!0){const a=e.createQuery();return a.outFields=["*"],a.geometry=F(r,e.layer,t),a.returnGeometry=s,a.outSpatialReference=t.spatialReference,a}function v(e,r,t,s=!1,a=!0){const i=e.createQuery();return i.outFields=b(e,t,s),i.geometry=F(r,e,t),i.returnGeometry=a,i.outSpatialReference=t.spatialReference,i}async function j(e){const{candidates:r,graphicsLayers:t,selector:s}=e,a=t.flatMap((e=>e.graphics.toArray()))??[];if(!a?.length||!s)return;const i=await import("../../../geometry/operators/intersectsOperator.js");i.accelerateGeometry(s),a.forEach((e=>{e.geometry&&"mesh"!==e.geometry.type&&i.execute(s,e.geometry)&&r.push(e)}))}export{g as collectSelectionFromFeatureLayerViews,w as collectSelectionFromFeatureLayers,j as collectSelectionFromGraphicsLayers,m as getSelectionFromGeometry,F as getSuggestedQueryGeometry,b as getSuggestedQueryOutFields};