@arcgis/core 4.33.0-next.20250515 → 4.33.0-next.20250516

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.
Files changed (95) hide show
  1. package/Basemap.js +1 -1
  2. package/applications/Components/baUtils.js +1 -1
  3. package/assets/esri/core/workers/RemoteClient.js +1 -1
  4. package/assets/esri/core/workers/chunks/{8f1fbfdac04e694f621d.js → 0c50ee1f3cdd30d96479.js} +1 -1
  5. package/assets/esri/core/workers/chunks/{7e8f78b96d43c224c7b6.js → 19c50f052eba0553bf4d.js} +1 -1
  6. package/assets/esri/core/workers/chunks/{1f4fd9e3849f4e593375.js → 2b1486a466760d2152f5.js} +1 -1
  7. package/assets/esri/core/workers/chunks/{a673128da9e6656ead2e.js → 320e821af81138fe12ac.js} +1 -1
  8. package/assets/esri/core/workers/chunks/{d166f805990353578494.js → 523046e04679e301797d.js} +1 -1
  9. package/assets/esri/core/workers/chunks/{a0d2bd5d4ed3c90f6b1c.js → 5f766bcb751d66fbf1c8.js} +1 -1
  10. package/assets/esri/core/workers/chunks/{d21d9e8b8c8a2e0485d5.js → 612f6739c9399fbae4d0.js} +1 -1
  11. package/assets/esri/core/workers/chunks/7a9a0383f27f4967bcfa.js +1 -0
  12. package/assets/esri/core/workers/chunks/87fc7b6c3e2d4f7775e2.js +1 -0
  13. package/assets/esri/core/workers/chunks/{3b4b4f84d594db8945f9.js → 9839309d0cd804fe52c2.js} +1 -1
  14. package/assets/esri/core/workers/chunks/{c10885b3a0739708e9e0.js → 9a06476b834584d00d5c.js} +1 -1
  15. package/assets/esri/core/workers/chunks/{62798f66872dc32e77d6.js → a70a86ba4e487f62f683.js} +1 -1
  16. package/assets/esri/core/workers/chunks/a937076d2f8c2b6a5d8a.js +1 -0
  17. package/assets/esri/core/workers/chunks/{8e82acd1f730571680f4.js → aeb5bbe861f65544d504.js} +1 -1
  18. package/assets/esri/core/workers/chunks/{5e52c1c076a1502f9fe4.js → be2c8c0a8b2bce7979b6.js} +1 -1
  19. package/assets/esri/themes/base/widgets/_Editor.scss +2 -1
  20. package/assets/esri/themes/base/widgets/_SearchResultRenderer.scss +5 -30
  21. package/assets/esri/themes/dark/main.css +1 -1
  22. package/assets/esri/themes/light/main.css +1 -1
  23. package/assets/esri/themes/light/view.css +1 -1
  24. package/assets/esri/widgets/Search/t9n/Search.json +1 -1
  25. package/assets/esri/widgets/Search/t9n/Search_en.json +1 -1
  26. package/chunks/ShadowCastClear.glsl.js +5 -0
  27. package/config.js +1 -1
  28. package/geometry/support/aaBoundingBox.js +1 -1
  29. package/interfaces.d.ts +137 -40
  30. package/package.json +2 -2
  31. package/portal/Portal.js +1 -1
  32. package/request.js +1 -1
  33. package/rest/knowledgeGraph/GraphAddNamedTypesResult.js +1 -1
  34. package/rest/knowledgeGraph/GraphAddPropertyResult.js +5 -0
  35. package/rest/knowledgeGraph/GraphApplyEditsResult.js +1 -1
  36. package/rest/knowledgeGraph/GraphDeleteNamedTypeResult.js +1 -1
  37. package/rest/knowledgeGraph/GraphDeletePropertyResult.js +5 -0
  38. package/rest/knowledgeGraph/GraphUpdateNamedTypesResult.js +5 -0
  39. package/rest/knowledgeGraph/GraphUpdatePropertyResult.js +5 -0
  40. package/rest/knowledgeGraph/wasmInterface/updateToWasmEncodedFactories.js +1 -1
  41. package/rest/knowledgeGraph/wasmInterface/wasmToDataModelChangeResponseFactories.js +1 -1
  42. package/rest/knowledgeGraphService.js +1 -1
  43. package/rest/networks/unitIdentifiers/insertGap.js +5 -0
  44. package/rest/networks/unitIdentifiers/queryUnitIdentifiers.js +5 -0
  45. package/rest/networks/unitIdentifiers/reset.js +5 -0
  46. package/rest/networks/unitIdentifiers/resize.js +5 -0
  47. package/rest/networks/unitIdentifiers/support/InsertGapParameters.js +5 -0
  48. package/rest/networks/unitIdentifiers/support/QueryUnitIdentifiersParamters.js +5 -0
  49. package/rest/networks/unitIdentifiers/support/ResetParameters.js +5 -0
  50. package/rest/networks/unitIdentifiers/support/ResizeParameters.js +5 -0
  51. package/rest/networks/unitIdentifiers/support/UnitQueryResult.js +5 -0
  52. package/rest/utils.js +1 -1
  53. package/support/apiKeyUtils.js +1 -1
  54. package/support/basemapEnsureType.js +1 -1
  55. package/support/revision.js +1 -1
  56. package/unionTypes.d.ts +2 -0
  57. package/views/3d/FocusAreasView.js +1 -1
  58. package/views/3d/analysis/LineOfSight/LineOfSightController.js +1 -1
  59. package/views/3d/layers/ContentGeometryLayerView.js +5 -0
  60. package/views/3d/layers/FlowSubView3D.js +1 -1
  61. package/views/3d/layers/GraphicsLayerView3D.js +1 -1
  62. package/views/3d/layers/I3SMeshView3D.js +1 -1
  63. package/views/3d/layers/RouteLayerView3D.js +1 -1
  64. package/views/3d/layers/graphics/Graphics3DCore.js +1 -1
  65. package/views/3d/layers/graphics/Graphics3DFeatureProcessor.js +1 -1
  66. package/views/3d/layers/graphics/Graphics3DGraphicsPipeline.js +1 -1
  67. package/views/3d/layers/graphics/GraphicsProcessor.js +1 -1
  68. package/views/3d/support/pointsOfInterest/ContentGeometryUpdates.js +1 -1
  69. package/views/3d/support/pointsOfInterest/PointsOfInterest.js +1 -1
  70. package/views/3d/webgl-engine/effects/focusArea/FocusAreaMaskNode.js +1 -1
  71. package/views/3d/webgl-engine/lib/ShadowAccumulator.js +1 -1
  72. package/views/3d/webgl-engine/shaders/ShadowCastClear.glsl.js +5 -0
  73. package/views/3d/webgl-engine/shaders/ShadowCastClearTechnique.js +5 -0
  74. package/widgets/BatchAttributeForm/VisibleElements.js +1 -1
  75. package/widgets/BatchAttributeForm.js +1 -1
  76. package/widgets/Editor/EditorViewModel.js +1 -1
  77. package/widgets/Editor/UpdateFeaturesWorkflow.d.ts +4 -0
  78. package/widgets/Editor/UpdateFeaturesWorkflow.js +1 -1
  79. package/widgets/Editor/UpdateFeaturesWorkflowData.d.ts +4 -0
  80. package/widgets/Editor/UpdateFeaturesWorkflowData.js +1 -1
  81. package/widgets/Editor/UpdateWorkflow.js +1 -1
  82. package/widgets/Editor/components/UpdateFeaturePanelContent.js +1 -1
  83. package/widgets/Editor/support/SketchController.js +1 -1
  84. package/widgets/Editor/workflowUtils.js +1 -1
  85. package/widgets/Editor.js +1 -1
  86. package/widgets/Search/SearchResultRenderer.js +1 -1
  87. package/widgets/Search/SearchViewModel.js +1 -1
  88. package/widgets/Search/searchResultRendererCSS.js +1 -1
  89. package/widgets/support/SelectionList/SelectionListViewModel.js +1 -1
  90. package/widgets/support/SelectionList/selectionListUtils.js +1 -1
  91. package/widgets/support/SelectionList.js +1 -1
  92. package/widgets/support/SelectionToolbar.js +1 -1
  93. package/assets/esri/core/workers/chunks/297d2c0a9d3f1e978318.js +0 -1
  94. package/assets/esri/core/workers/chunks/6b42bcfbb60432e3ed1f.js +0 -1
  95. package/assets/esri/core/workers/chunks/a9b1f4bf5eaa937943be.js +0 -1
@@ -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 e from"../../Color.js";import t from"../../Graphic.js";import{isSome as r,equals as a,addMany as n}from"../../core/arrayUtils.js";import{createTask as o}from"../../core/asyncUtils.js";import"../../core/has.js";import i from"../../core/Error.js";import{handlesGroup as s,makeHandle as l,abortHandle as c}from"../../core/handleUtils.js";import{clone as u}from"../../core/lang.js";import p from"../../core/Logger.js";import{getOrCreateMapValue as d}from"../../core/MapUtils.js";import{debounce as f,isPromiseLike as y,throwIfAborted as m,whenOrAbort as h}from"../../core/promiseUtils.js";import{watch as g,on as b,whenOnce as w}from"../../core/reactiveUtils.js";import{px2pt as v}from"../../core/screenUtils.js";import{diff as I}from"../../core/accessorSupport/diffUtils.js";import{isSharedTemplateOrMetadata as T,isSharedGroupTemplate as S,isSharedTemplate as j,isSharedPresetTemplate as F,isStandardFeatureTemplate as k,isSharedFeatureTemplate as A}from"../../editing/templateUtils.js";import{getSharedTemplateProvider as U}from"../../editing/sharedTemplates/SharedTemplateProvider.js";import V from"../../layers/GraphicsLayer.js";import{featureHasFields as L,fixFields as M,getDisplayFieldName as O}from"../../layers/support/fieldUtils.js";import{isSubtypeSublayer as x}from"../../layers/support/layerUtils.js";import{calculateTolerance as z}from"../../renderers/support/clickToleranceUtils.js";import{meterIn as q}from"../../renderers/support/lengthUtils.js";import{isRenderer as P}from"../../renderers/support/typeUtils.js";import{getTransformationType as E,TransformationType as C}from"../../renderers/visualVariables/support/sizeVariableUtils.js";import R from"../../symbols/SimpleFillSymbol.js";import D from"../../symbols/SimpleLineSymbol.js";import G from"../../symbols/SimpleMarkerSymbol.js";import{to3D as B}from"../../symbols/support/symbolConversion.js";import{getDisplayedSymbol as N}from"../../symbols/support/symbolUtils.js";import{getServices as Z}from"../../undoredo/support/Services.js";import{GraphicState as Q}from"../../views/3d/layers/graphics/GraphicState.js";import{defaultDrawingMode as W}from"../../views/draw/DrawingMode.js";import{createQueryGeometry as $}from"../../views/support/drapedUtils.js";import{filterGraphicHits as J,hitTestSelectSimilarDistance as H}from"../../views/support/hitTestSelectUtils.js";import{dependencySort as K}from"./support/dependencySort.js";import{isDrawGraphicTool as X}from"../Sketch/support/sketchUtils.js";const Y=()=>p.getLogger("esri.widgets.Editor.workflowUtils");function _(e){return"update"===e.type}function ee(e){if(!(e&&"renderer"in e&&se(e.renderer)))return{rotation:null,size:null};const t=e.renderer.getVisualVariablesForType("rotation").filter((e=>(!e.axis||"heading"===e.axis)&&e.field&&!e.valueExpression)),r=e.renderer.getVisualVariablesForType("size").filter((e=>e.field&&!e.useSymbolValue&&!e.valueExpression&&E(e)===C.RealWorldSize));return{rotation:1===t.length?t[0]:null,size:1===r.length?r[0]:null}}function te(e){const t=e.sourceLayer;if(!(t&&"renderer"in t&&se(t.renderer)))return{rotation:null,size:null};const{rotation:r,size:a}=ee(t);let n=null,o=null;if(r){const e=t.fields?.filter((e=>e.name===r.field)),a=1===e?.length?e[0]:null;n=re(r,a)}if(a){const e=t.fields?.filter((e=>e.name===a.field)),r=1===e?.length?e[0]:null;o=oe(a,r)}return{rotation:n,size:o}}function re(e,t){const r="heading"===(e.axis||"heading")&&"arithmetic"===e.rotationType?-1:1,a=t?.type??"double",n={initial:0,current:0};return{field:e.field,fieldType:a,getDefaultValue:()=>Promise.resolve(0),getValue:e=>(n.current=n.initial-r*e,ie((n.current+360)%360,a)),setInitialValue:e=>{n.initial=e,n.current=0},isUpdatingInteractively:!1,rotationType:e.rotationType??"geographic"}}function ae(e,t){switch(t){case"width":return e[0];case"depth":return e[1];case"height":return e[2];default:return e[2]||e[1]||e[0]}}async function ne(e,t,r){if(null==t)return 0;const{symbol:a}=B(t);if(null==a||"web-style"===a.type||"cim"===a.type)return 0;const n=a.symbolLayers.at(0);if(!n)return 0;switch(n.type){case"icon":{const{computeIconLayerResourceSize:e}=await import("../../symbols/support/symbolLayerUtils.js");return Math.min($e.icon,(await e(n,$e.icon))[0])||$e.icon}case"text":return $e.text;case"line":return $e.line;case"object":{const{computeObjectLayerResourceSize:t}=await import("../../symbols/support/symbolLayerUtils.js");return ae(await t(n,e.scale/$e.viewScaleSizeFactor),r)}case"path":case"extrude":return e.scale/$e.viewScaleSizeFactor;default:return 0}}function oe(e,t){const r=e.axis,a=t?.type??"double",n={initial:0,current:0},o=q[e.valueUnit]??1;let i;return i="area"===e.valueRepresentation?e=>(e*o/2)**2*Math.PI:"radius"===e.valueRepresentation||"distance"===e.valueRepresentation?e=>e*o/2:e=>e*o,{field:e.field,fieldType:a,getDefaultValue:async(e,t)=>ie(i(await ne(t,e,r)),a),getValue:(e,t)=>(n.initial||(n.initial=t.pixelSizeAt(t.center)),n.current=n.initial*e,ie(n.current,a)),setInitialValue:e=>{n.initial=e,n.current=0},isUpdatingInteractively:!1,displayUnit:Ke(e.valueUnit),axis:e.axis}}function ie(e,t){switch(t){case"small-integer":case"integer":case"long":return Math.round(e);case"double":case"single":return e;default:return 0}}function se(e){if(!P(e))return!1;switch(e?.type){case"class-breaks":case"simple":case"unique-value":case"dot-density":case"dictionary":case"pie-chart":return!0;default:return!1}}async function le(e,t,r){const a=await N(e,{useSourceLayer:!0,ignoreGraphicSymbol:!0,webStyleCache:t,scale:r});null!=I(e.symbol,a)&&(e.symbol=a)}function ce(e,t){if(!e||!t)throw new Error("no geometry type");if("multipatch"===e)return{tool:"mesh",createOptions:{mode:"hybrid"}};const r=new Map;r.set("circle",{mode:"freehand"}),r.set("rectangle",{mode:"freehand"});const a={mode:W,optionsPerTool:r};if(T(t)){const n=t.defaultTool,o=S(t)?t.definition?.inputGeometryType??e:e;switch(n){case"freehand":case"stream-line":return{tool:"polyline"===o?"freehandPolyline":"freehandPolygon",createOptions:a};case"autocomplete-freehand-polygons":case"stream-polygon":return{tool:"freehandPolygon",createOptions:a};case"autocomplete-polygons":case"difference-polygon":case"create-structures":case"polygon":case"trace":return{tool:"polygon"===o?"polygon":"polyline",createOptions:a};case"circle":return r.get("circle").preserveAspectRatio=!0,{tool:"circle",createOptions:a};case"ellipse":return r.get("circle").preserveAspectRatio=!1,{tool:"circle",createOptions:a};case"create-points-along-line":case"multipoint":return{tool:"multipoint",createOptions:a};case"line":case"radial-line":case"right-angle-line":case"split":case"two-point-line":return{tool:"polyline",createOptions:a};case"rectangle":case"regular-polygon":case"right-angle-polygon":return{tool:"rectangle",createOptions:a};case"elevation-point-from-contour":case"elevation-point-from-dem":case"parcel-seed":case"point":case"point-and-rotation":case"point-at-end-of-line":return{tool:"point",createOptions:a}}}else{const n=t.drawingTool;if("circle"===n||"ellipse"===n)return r.get("circle").preserveAspectRatio="circle"===n,{tool:"circle",createOptions:a};if("rectangle"===n)return{tool:"rectangle",createOptions:a};if("freehand"===n)return{tool:"polygon"===e?"freehandPolygon":"freehandPolyline",createOptions:a}}return{tool:e,createOptions:a}}async function ue(e,t,r){const{creationInfo:a,fullTemplate:n}=t;if(!a)throw new i("featureworkflow","No creation info provided.");const o=a.layer,s=Ue(n,a.attributeOverrides),{view:l}=e,c="2d"===l?.type;S(n)||F(n)||await Ve(e,o,s,r,c?l.scale:null);const{capabilities:u}=o;e.layer.elevationInfo=o.elevationInfo;const p=ce(o.geometryType,n);e.defaultCreateOptions={graphicProperties:{attributes:s,sourceLayer:o},mode:p.createOptions.mode,optionsPerTool:p.createOptions.optionsPerTool,preserveAspectRatio:p.createOptions.preserveAspectRatio,hasZ:u.data.supportsZ,defaultZ:(c?u.editing.zDefault:null)??e.defaultCreateOptions.defaultZ},null==a.geometryToPlace?await e.create(p.tool):await e.place(a.geometryToPlace,{graphicProperties:{attributes:s,sourceLayer:o}})}async function pe(e){return s([await de(e),await fe(e)])}async function de({creationAttributes:e,data:t,sketchViewModel:r,view:a,webStyleCache:n}){const{creationInfo:o}=t,{fullTemplate:i}=t;if(!o||"2d"!==a?.type||S(i)||F(i))return null;const s=f((t=>Ve(r,o.layer,e,n,t)));return g((()=>a.scale),(e=>s(e)))}async function fe({data:t,sketchViewModel:r,view:a}){const{templateExecutorInfo:n}=t;if(!n)return null;const o=r.activeComponent;if(!a||!X(o))return Y().error(new i("featureworkflow","Failed to set up template feedback.")),null;const c=new V({effect:"saturate(0.6) opacity(0.8)",listMode:"hide",title:"Shared Template Feedback Graphics"});a.map?.add(c);const{executor:u,serviceLayersById:p}=n,d=a.theme?.accentColor??new e([255,165,0,1]);return s([b((()=>o),["cursor-update","vertex-add"],(()=>{c.removeAll();const e=o.graphic?.geometry;if(!e||!ye(e))return;const t=u(e,"digitizing");if(!y(t))for(const r of t.edits){const e=p.get(r.id);if(e&&r.addFeatures&&0!==r.addFeatures.length)for(const t of e)if(!t.isTable)for(const e of r.addFeatures){const t=me(e,d);t&&c.add(t)}}})),l((()=>{a.map.remove(c),c.destroy()}))])}function ye(e){switch(e.type){case"point":case"multipoint":return!0;case"polyline":return e.paths[0].length>1;case"polygon":{const t=e.rings[0];return a(t.at(0),t.at(-1))?t.length>2:t.length>1}default:return!1}}function me(e,r){let a=null;switch(e.geometry?.type){case"point":case"multipoint":a=new G({angle:0,color:r,outline:new D({cap:"round",color:r,join:"round",miterLimit:1,style:"solid",width:1}),path:"undefined",size:8,style:"circle",xoffset:0,yoffset:0});break;case"polygon":a=new R({color:r,outline:new D({cap:"round",color:r,join:"round",miterLimit:1,style:"solid",width:3}),style:"none"});break;case"polyline":a=new D({cap:"round",color:r,join:"round",miterLimit:1,style:"solid",width:2});break;default:return null}return new t({geometry:e.geometry,symbol:a,attributes:{...e.attributes}})}async function he(e,t){const r=await Z(t).load(),a=x(e)?e.parent:e;return r.tablesAndLayersLookup.get(a)}async function ge(e,t){const r=await he(e,t);if(!r)return new Map;const a=new Map;for(const n of r.layersAndTables)d(a,n.layerId,(()=>[])).push(n);return a}function be(e){const t=e.objectIdField,r=e.globalIdField??"";return{id:e.layerId,identifierFields:{objectIdField:t,globalIdField:r},addFeatures:[],deleteAttachments:[],addAttachments:[],deleteFeatures:[],updateFeatures:[]}}function we(e){const{edits:t,serviceInfo:a,view:n,findOriginalFeature:o}=e,i=ve(a.layersAndTables),s=a.layersAndTables.toArray(),{allEditData:l,editDataByLayerIdMap:c,editDataByIdMap:u}=Te(t,i,o),p=Se(l,Ie(s,c),c);if(ke(l,p,n),0===p.length)return t;const d=K(p,{continueOnCircularDependency:!0}).map((e=>u.get(e))).filter(r),f=new Map;for(const r of d)f.set(r.uniqueId,r);const y=[];for(const r of l)f.has(r.uniqueId)||y.push(r);const m=[];let h=null;for(const r of d){const{layer:e}=r;switch(null==h?h=be(e):h.id!==e.layerId&&(m.push(h),h=be(e)),r.operationType){case"add":case"modify":h.addFeatures.push(r.after);break;case"delete":h.deleteFeatures.push(r.before)}}null!==h&&m.push(h);for(const r of y){const e=r.layer.layerId,t=m.find((t=>t.id===e))??be(r.layer);switch(m.includes(t)||m.push(t),r.operationType){case"add":t.addFeatures.push(r.after);break;case"modify":t.updateFeatures.push(r.after);break;case"delete":t.deleteFeatures.push(r.before);break;case"deleteAttachment":t.deleteAttachments.push(r.attachmentId);break;case"addAttachment":t.addAttachments.push(r.attachment)}}for(const r of m)void 0!==r.deleteAttachments&&0===r.deleteAttachments.length&&delete r.deleteAttachments,void 0!==r.addAttachments&&0===r.addAttachments.length&&delete r.addAttachments;return m}function ve(e){const t=new Map;for(const r of e)t.set(r.layerId,r);return t}function Ie(e,t){const r=new Map;for(const a of e)for(const e of a.relationships??[])if(r.set(je(a,e),""),t.has(e.relatedTableId)){const n=t.get(e.relatedTableId);if(n.length>0)for(const t of n[0].layer.relationships??[])if(t.id===e.id){r.set(je(a,e),t.keyField);break}}return r}function Te(e,t,r){const a=new Map,n=[],o=new Map;let s=1;for(const l of e){const e=[],c=t.get(l.id);if(!c)throw new i("featureworkflow",`Failed to prepare applyEdits payload. Layer with id ${l.id} not found.`);for(const t of l.addFeatures??[])e.push({uniqueId:"T"+s++,operationType:"add",layer:c,after:t});for(const t of l.deleteFeatures??[])e.push({uniqueId:"T"+s++,operationType:"delete",before:t,layer:c});for(const t of l.deleteAttachments??[])e.push({uniqueId:"T"+s++,operationType:"deleteAttachment",attachmentId:t,layer:c});for(const t of l.addAttachments??[])e.push({uniqueId:"T"+s++,operationType:"addAttachment",attachment:t,layer:c});for(const t of l.updateFeatures??[])e.push({uniqueId:"T"+s++,operationType:"modify",before:r(t),after:t,layer:c});a.set(c.layerId,e);for(const t of e)n.push(t),o.set(t.uniqueId,t)}return{allEditData:n,editDataByIdMap:o,editDataByLayerIdMap:a}}function Se(e,t,r){const a=[];for(const n of e){const e=n.layer.relationships??[],{uniqueId:o}=n;for(const i of e){const e=i.keyField;if("origin"===i.role){const s=r.get(i.relatedTableId);if(!s||0===s.length)continue;const l=je(n.layer,i),c=t.get(l);if(void 0===c||""===c)continue;switch(n.operationType){case"add":for(const t of s)t!==n&&("add"!==t.operationType&&"modify"!==t.operationType||t.after.attributes[c]===n.after.attributes[e]&&a.push([o,t.uniqueId]));break;case"modify":if(n.before.attributes[e]!==n.after.attributes[e])for(const t of s){const r=t.uniqueId;t!==n&&("delete"===t.operationType?t.before.attributes[c]===n.before.attributes[e]?a.push([r,o]):t.before.attributes[c]===n.after.attributes[e]&&a.push([o,r]):"add"===t.operationType?t.after.attributes[c]===n.after.attributes[e]?a.push([o,r]):t.after.attributes[c]===n.before.attributes[e]&&a.push([r,o]):"modify"===t.operationType&&(t.before.attributes[c]!==t.after.attributes[c]?t.after.attributes[c]===n.after.attributes[e]?a.push([o,r]):a.push([r,o]):a.push([o,r])))}break;case"delete":for(const t of s)t!==n&&("delete"!==t.operationType&&"modify"!==t.operationType||t.before.attributes[c]===n.before.attributes[e]&&a.push([t.uniqueId,o]))}}}}return a}function je(e,t){return`${e.layerId}:${t.id}`}function Fe(e,t){return!!(t?.map&&"utilityNetworks"in t.map&&t.map.utilityNetworks?.length&&t.map.utilityNetworks.some((t=>!(!t.loaded||!e.url?.startsWith(t.featureServiceUrl)||e.layerId!==t.networkSystemLayers.associationsTableId))))}function ke(e,t,r){const a=[];for(const o of e)Fe(o.layer,r)&&a.push(o);if(0===a.length)return;let n=[];for(const o of a){const r=o.layer;switch(o.operationType){case"delete":n=[...Ae(o.before.attributes[r.fieldsIndex.get("fromglobalid").name],e),...Ae(o.before.attributes[r.fieldsIndex.get("toglobalid").name],e)];for(const e of n)t.push([o.uniqueId,e.uniqueId]);break;case"add":n=[...Ae(o.after.attributes[r.fieldsIndex.get("fromglobalid").name],e),...Ae(o.after.attributes[r.fieldsIndex.get("toglobalid").name],e)];for(const e of n)t.push([e.uniqueId,o.uniqueId])}}}function Ae(e,t){const r=[],a=t.filter((({layer:e})=>""!==e.globalIdField&&null!=e.globalIdField));for(const n of a){const t=n.layer.globalIdField;("before"in n&&n.before?.attributes[t]===e||"after"in n&&n.after?.attributes[t]===e)&&r.push(n)}return r}function Ue(e,t={}){return S(e)||F(e)?{}:k(e)?{...e.prototype.attributes,...t}:A(e)?{...e.definition?.defaultValues,...t}:{...t}}async function Ve(e,r,a,n,o){const i=new t({sourceLayer:r,attributes:a}),{rotation:s,size:l}=te(i);let c=await N(i,{useSourceLayer:!0,webStyleCache:n,scale:o}),u=!1;for(const t of[l,s]){if(null==t)continue;null==a[t.field]&&(a[t.field]=await t.getDefaultValue(c,e.view),u=!0)}switch(u&&(c=await N(i,{useSourceLayer:!0,webStyleCache:n,scale:o})),c?.type){case"simple-fill":case"polygon-3d":e.polygonSymbol=c;break;case"simple-line":case"line-3d":e.polylineSymbol=c;break;case"simple-marker":case"picture-marker":case"point-3d":case"cim":e.pointSymbol=c;break;case"mesh-3d":e.meshSymbol=c}Le(e.tooltipOptions,l,s)}function Le(e,t,r){e.visualVariables=null!=t||null!=r?{size:null!=t?{unit:t.displayUnit,axis:t.axis,valueType:t.fieldType}:null,rotation:null!=r?{valueType:r.fieldType,rotationType:r.rotationType??"geographic"}:null}:null}function Me(e,t){return e?.find((e=>e.layer===t))}async function Oe(e,t,r,a){switch(t.type){case"3d":return xe(e,t,r,a);case"2d":return ze(e,t,r,a)}}async function xe(e,t,r,a){if(0===e.length)return[];const{updatable:o,graphicsByLayer:i}=await r.defer((async()=>{const{results:n}=await h(H(t,r),a),o=new Map,i=e=>{const t=e.layer,r=o.get(t);if(!r){const e=new Array;return o.set(t,e),e}return r};J(n).forEach((({graphic:e})=>i(e).push(e)));const s=e.filter((({capabilities:e,layer:t})=>e.update.enabled&&o.has(t)));return 0!==s.length&&r.stopPropagation(),{updatable:s,graphicsByLayer:o}}));return h(Promise.allSettled(o.map((async({layer:e})=>{const t=i.get(e),r=qe(e);if(t.every((e=>L(r,e))))return t;const o=[];for(const a of t){o.push(a.getObjectId());const e=Object.keys(a.attributes);n(r,e)}const s=e.createQuery();return s.returnGeometry=!1,s.objectIds=o,s.outFields=M(e.fieldsIndex,r),e.queryFeatures(s,{signal:a}).then((({features:e})=>e))}))),a)}async function ze(e,t,r,a){if(0===e.length)return[];const{mapPoint:n}=r;if(null==n)return[];let o=null;const i=await r.defer((async()=>{const{results:n}=await h(t.hitTest(r),a);if(0===n.length)return[];const i=new Set;o=J(n),o.forEach((({graphic:e})=>e&&i.add(e.layer)));const s=e.filter((e=>i.has(e.layer)&&e.supportsUpdateWorkflow));return s.length>0&&r.stopPropagation(),s}));return h(Promise.allSettled(i.map((async({layer:e})=>{const i=e.createQuery();i.returnGeometry=!0,i.outFields=qe(e);const s="renderer"in e?z({renderer:e.renderer,pointerType:r.pointerType}):0;i.geometry=$(n,s,t),i.outSpatialReference=t.spatialReference;const{features:l}=await e.queryFeatures(i,{signal:a});return o?.forEach((({graphic:t})=>{t.layer!==e||l.some((e=>e.getObjectId()===t.getObjectId()))||l.push(t)})),l}))),a)}function qe(e){return M(e.fieldsIndex,[e.objectIdField,O({displayField:"displayField"in e?e.displayField:null,fields:e.fields})])}async function Pe(e,t,a,n){const o=t.createQuery();o.objectIds=e.map((e=>e.getObjectId())).filter(r),o.outFields=["*"],o.returnM=t.capabilities.data.supportsM,o.returnZ=t.capabilities.data.supportsZ,"scene"===t.type&&null!=t.infoFor3D||(o.outSpatialReference=a);const i=await t.queryFeatures(o,{signal:n});return m(n),i.features}function Ee(e){const t=new Map;for(const r of e){const e=r.sourceLayer,a=x(e)?e.parent:e;d(t,a,(()=>[])).push(r)}return t}async function Ce(e){const{graphic:t,sketchViewModel:r,sourceLayer:a,visualVariables:n}=e;await Re(e);const o={multipleSelectionEnabled:!1};return"point"===a.geometryType&&(o.enableRotation=null!=n.rotation,o.enableScaling=null!=n.size),r.update(t,o)}async function Re(e){const{graphic:t,sketchViewModel:r,sourceLayer:a,visualVariables:n,webStyleCache:o}=e;let i=!1;const{rotation:s,size:l}=n;for(const c of[s,l]){if(null==c)continue;const e=t.getAttribute(c.field);if(null!=e)c.setInitialValue(e);else{const e=await c.getDefaultValue(t.symbol,r.view);c.setInitialValue(e),t.setAttribute(c.field,e),i=!0}}if(i){const e="2d"===r.view?.type?r.view.scale:null;await le(t,o,e)}Le(r.tooltipOptions,l,s),r.layer.elevationInfo=a.elevationInfo}function De(e){return null==e||"rotate-start"!==e.type&&"rotate"!==e.type&&"rotate-stop"!==e.type?null:e}function Ge(e){return null==e||"scale-start"!==e.type&&"scale"!==e.type&&"scale-stop"!==e.type?null:e}function Be(e,t,r,a){if(null==t.geometry||"point"!==t.geometry?.type)return!1;const n=t.attributes;let o=!1;const i=a.rotation,s=De(r.toolEventInfo);if(null!=i&&null!=s){const{field:r,getValue:a}=i;if("rotate-stop"===s.type)i.isUpdatingInteractively=!1,i.setInitialValue(t.getAttribute(r));else{i.isUpdatingInteractively=!0;const l=a(s.angle,e);l!==n[r]&&(t.setAttribute(r,l),o=!0)}}const l=a.size,c=Ge(r.toolEventInfo);if(null!=l&&null!=c){const{field:r,getValue:a}=l;if("scale-stop"===c.type)l.isUpdatingInteractively=!1,l.setInitialValue(t.getAttribute(r));else{l.isUpdatingInteractively=!0;const i=a(c.xScale,e);i!==n[r]&&(t.setAttribute(r,i),o=!0)}}return o}async function Ne({feature:e,featureClone:t,visualVariableAttributes:r,sketchViewModel:a,view:n,onUpdate:o,webStyleCache:i,addUpdatingPromise:u,addHandle:p}){await le(t,i,"2d"===n.type?n.scale:null);let d=null;if("2d"===a?.view?.type){const e=f((e=>le(t,i,e)));d=g((()=>a?.view?.scale),(t=>e(t)))}const y=t.sourceLayer,m=_e(n,y);await Ce({graphic:t,sketchViewModel:a,sourceLayer:y,visualVariables:r,webStyleCache:i});let h=null;m.then((e=>h=e)).catch((()=>{}));const b=r.size,v=r.rotation,I=g((()=>e.attributes),(async e=>{let r=!1;for(const a in e){const n=e[a];n!==t.getAttribute(a)&&(t.setAttribute(a,n),null==b||b.isUpdatingInteractively||b.field!==a||b.setInitialValue(n),null==v||v.isUpdatingInteractively||v.field!==a||v.setInitialValue(n),(null==h||h.requiredFields.includes(a))&&(r=!0))}r&&await le(t,i,"2d"===n.type?n.scale:null)})),T=a.on("update",(async e=>{const t=e.graphics[0],s={graphic:t,sketchViewModel:a,sourceLayer:y,visualVariables:r,webStyleCache:i};if("complete"===e.state){if(null===n.activeTool)return Ce(s);const e=new AbortController,t=c(e);return p(t),u(w((()=>null===n.activeTool),e.signal).then((async()=>{if(!e.signal.aborted)return e.abort(),Ce(s)})))}Be(n,t,e,r)&&await le(t,i,"2d"===n.type?n.scale:null),o(tt(t),e)})),S=a.on(["undo","redo"],(async e=>{o(tt(e.graphics[0]),e)}));return s([S,T,l((()=>a.cancel())),I,d])}async function Ze(e,t,r){const a=e.view;e.layer.add(r);const n=t.sourceLayer,i=t.layer,c=t.getAttribute(i.objectIdField);let u=null;function p(e){u?.abort(),u=o((async t=>{const r=await _e(a,n);m(t),r.setVisibility?.(c,e)}))}return await We(a,r),p(!1),s([Qe(a,r,(e=>p(!e))),l((async()=>{p(!0);try{const e=await _e(a,n);await w((()=>!e.updating))}finally{e.layer.remove(r)}}))])}function Qe(e,t,r){if("3d"===e.type){const a=new Q({graphic:t});return s([e.trackGraphicState(a),g((()=>a.displaying),r)])}return g((()=>t.visible),r)}async function We(e,t){if("3d"===e.type){const r=new Q({graphic:t}),a=e.trackGraphicState(r);await w((()=>r.displaying||r.error)),a.remove()}else await w((()=>t.visible))}const $e={icon:v(24),text:v(12),line:v(1),viewScaleSizeFactor:100};function Je(e,t,r){let a=!1;return e.filter((e=>!!a||(a=e===t,a))).map((e=>r[e]()))}function He(e,t){e.viewModel.syncFeatureTemplates();const r=e.creationInfo;if("awaiting-feature-creation-info"===t[0].id&&r){const a=r.layer,n=e.viewModel.getTemplatesForLayer(a);1===n.length&&"scene"!==a.type&&(r.template=n[0],t.shift())}return t}function Ke(e){return"unknown"===e?null:e}function Xe(e){e.filesEnabled=!0,e.mode="view",e.capabilities={editing:!0,operations:{add:!0,update:!0,delete:!0}}}const Ye=e=>/-stop/.test(e)||/vertex-/.test(e),_e=(e,t)=>{const r="subtype-sublayer"===t.type?t.parent:t;return e.whenLayerView(r)};function et(e){return"createInteractiveEditSession"in e}function tt(e){const t=e.geometry;if("mesh"===t?.type){const r=e.cloneShallow();return r.attributes=u(e.attributes),r.geometry=t.cloneShallow(),r.geometry.transform=t.transform?.clone()??null,r}return e.clone()}function rt(e){const t=e.cursor;return e.cursor="progress",l((()=>e.cursor=t))}async function at(e,t){const{template:r}=e;if(null==r)return null;if(j(r))return r.load();if(T(r)){const e=(await import("../../editing/sharedTemplates/SharedTemplate.js")).default,a=U(t,{makeSharedTemplateFromJSON:t=>e.fromJSON(t)}),n=await a.getTemplates({templateIds:[r.templateId],featureService:r.featureService});if(0===n.length)throw new i("editor:failed-to-load-template","Unable to load the provided template");return n[0].load()}return r}function nt(e){for(const t of e){const{destinationGraphic:e,destinationField:r,sourceGraphic:a,sourceField:n}=t;e.setAttribute(r,a.getAttribute(n))}}function ot(e){const t=e.templateExecutorInfo?.completionResults;return t?.length?(t.forEach((e=>nt(e.relationships))),t.flatMap((e=>e.edits))):null}export{ke as appendAllUtilityNetworkAssociationRelationships,He as avoidFeatureTemplateSelectionWithOnlyOneItem,et as canCreateInteractiveEditSession,tt as cloneGraphicExceptMesh,ve as createLayerIdMap,Ie as createRelationshipKeyMap,ce as createToolFromGeometryType,Je as createWorkflowSteps,Oe as fetchCandidates,Pe as fetchFullFeatures,Se as findAllDependencies,Ae as findChangesByGlobalId,Me as findLayerInfo,je as generateHashForRelationship,Ue as getCreationAttributes,at as getFullTemplateForCreationInfo,re as getRotationVariableAttribute,ot as getServiceEditsFromWorkflowData,he as getServiceInfoForLayer,ge as getServiceLayersById,oe as getSizeVariableAttribute,te as getVisualVariableAttributes,ee as getVisualVariablesForLayer,Ee as groupFeaturesByLayer,Ye as isTerminalUpdateEventType,_ as isUpdateWorkflow,Fe as isUtilityNetworkAssociationsTable,we as orderEditsByRelationshipDependencies,Xe as prepareAttachmentsForCreateFeaturesWorkflow,nt as setRelationshipFields,Ne as setUpGeometryUpdate,pe as setUpSketchCreateWatchers,Re as setVisualVariablesAndElevationInfoForUpdate,rt as showProgressCursor,$e as sizeDefaults,Ke as sizeVariableUnitToLengthUnit,ue as startCreatingNewFeature,Ce as startUpdatingFeatureGeometry,Ze as swapForEditingSession,le as updateGraphicSymbolWhenRequired,Be as visualVariableInteractiveUpdate,_e as whenEditorLayerView,We as whenGraphicDisplayed};
5
+ import e from"../../Color.js";import t from"../../Graphic.js";import{isSome as r,equals as n,addMany as a}from"../../core/arrayUtils.js";import{createTask as o}from"../../core/asyncUtils.js";import"../../core/has.js";import i from"../../core/Error.js";import{handlesGroup as s,makeHandle as l,abortHandle as c}from"../../core/handleUtils.js";import{clone as u}from"../../core/lang.js";import p from"../../core/Logger.js";import{getOrCreateMapValue as d}from"../../core/MapUtils.js";import{debounce as f,isPromiseLike as y,throwIfAborted as m,whenOrAbort as h}from"../../core/promiseUtils.js";import{watch as g,on as b,whenOnce as w}from"../../core/reactiveUtils.js";import{px2pt as v}from"../../core/screenUtils.js";import{diff as I}from"../../core/accessorSupport/diffUtils.js";import{isSharedTemplateOrMetadata as T,isSharedGroupTemplate as S,isSharedTemplate as j,isSharedPresetTemplate as F,isStandardFeatureTemplate as k,isSharedFeatureTemplate as A}from"../../editing/templateUtils.js";import{getSharedTemplateProvider as U}from"../../editing/sharedTemplates/SharedTemplateProvider.js";import V from"../../layers/GraphicsLayer.js";import{featureHasFields as L,fixFields as M,getDisplayFieldName as O}from"../../layers/support/fieldUtils.js";import{isSubtypeSublayer as x}from"../../layers/support/layerUtils.js";import{calculateTolerance as z}from"../../renderers/support/clickToleranceUtils.js";import{meterIn as q}from"../../renderers/support/lengthUtils.js";import{isRenderer as P}from"../../renderers/support/typeUtils.js";import{getTransformationType as E,TransformationType as C}from"../../renderers/visualVariables/support/sizeVariableUtils.js";import R from"../../symbols/SimpleFillSymbol.js";import D from"../../symbols/SimpleLineSymbol.js";import G from"../../symbols/SimpleMarkerSymbol.js";import{to3D as B}from"../../symbols/support/symbolConversion.js";import{getDisplayedSymbol as N}from"../../symbols/support/symbolUtils.js";import{getServices as Z}from"../../undoredo/support/Services.js";import{GraphicState as W}from"../../views/3d/layers/graphics/GraphicState.js";import{defaultDrawingMode as Q}from"../../views/draw/DrawingMode.js";import{createQueryGeometry as $}from"../../views/support/drapedUtils.js";import{filterGraphicHits as J,hitTestSelectSimilarDistance as H}from"../../views/support/hitTestSelectUtils.js";import{dependencySort as K}from"./support/dependencySort.js";import{isDrawGraphicTool as X}from"../Sketch/support/sketchUtils.js";const Y=()=>p.getLogger("esri.widgets.Editor.workflowUtils");function _(e){return!!e&&"features"in e}function ee(e){return"update"===e.type}function te(e){return"update-features"===e.type}function re(e){if(!(e&&"renderer"in e&&ce(e.renderer)))return{rotation:null,size:null};const t=e.renderer.getVisualVariablesForType("rotation").filter((e=>(!e.axis||"heading"===e.axis)&&e.field&&!e.valueExpression)),r=e.renderer.getVisualVariablesForType("size").filter((e=>e.field&&!e.useSymbolValue&&!e.valueExpression&&E(e)===C.RealWorldSize));return{rotation:1===t.length?t[0]:null,size:1===r.length?r[0]:null}}function ne(e){const t=e.sourceLayer;if(!(t&&"renderer"in t&&ce(t.renderer)))return{rotation:null,size:null};const{rotation:r,size:n}=re(t);let a=null,o=null;if(r){const e=t.fields?.filter((e=>e.name===r.field)),n=1===e?.length?e[0]:null;a=ae(r,n)}if(n){const e=t.fields?.filter((e=>e.name===n.field)),r=1===e?.length?e[0]:null;o=se(n,r)}return{rotation:a,size:o}}function ae(e,t){const r="heading"===(e.axis||"heading")&&"arithmetic"===e.rotationType?-1:1,n=t?.type??"double",a={initial:0,current:0};return{field:e.field,fieldType:n,getDefaultValue:()=>Promise.resolve(0),getValue:e=>(a.current=a.initial-r*e,le((a.current+360)%360,n)),setInitialValue:e=>{a.initial=e,a.current=0},isUpdatingInteractively:!1,rotationType:e.rotationType??"geographic"}}function oe(e,t){switch(t){case"width":return e[0];case"depth":return e[1];case"height":return e[2];default:return e[2]||e[1]||e[0]}}async function ie(e,t,r){if(null==t)return 0;const{symbol:n}=B(t);if(null==n||"web-style"===n.type||"cim"===n.type)return 0;const a=n.symbolLayers.at(0);if(!a)return 0;switch(a.type){case"icon":{const{computeIconLayerResourceSize:e}=await import("../../symbols/support/symbolLayerUtils.js");return Math.min(He.icon,(await e(a,He.icon))[0])||He.icon}case"text":return He.text;case"line":return He.line;case"object":{const{computeObjectLayerResourceSize:t}=await import("../../symbols/support/symbolLayerUtils.js");return oe(await t(a,e.scale/He.viewScaleSizeFactor),r)}case"path":case"extrude":return e.scale/He.viewScaleSizeFactor;default:return 0}}function se(e,t){const r=e.axis,n=t?.type??"double",a={initial:0,current:0},o=q[e.valueUnit]??1;let i;return i="area"===e.valueRepresentation?e=>(e*o/2)**2*Math.PI:"radius"===e.valueRepresentation||"distance"===e.valueRepresentation?e=>e*o/2:e=>e*o,{field:e.field,fieldType:n,getDefaultValue:async(e,t)=>le(i(await ie(t,e,r)),n),getValue:(e,t)=>(a.initial||(a.initial=t.pixelSizeAt(t.center)),a.current=a.initial*e,le(a.current,n)),setInitialValue:e=>{a.initial=e,a.current=0},isUpdatingInteractively:!1,displayUnit:Ye(e.valueUnit),axis:e.axis}}function le(e,t){switch(t){case"small-integer":case"integer":case"long":return Math.round(e);case"double":case"single":return e;default:return 0}}function ce(e){if(!P(e))return!1;switch(e?.type){case"class-breaks":case"simple":case"unique-value":case"dot-density":case"dictionary":case"pie-chart":return!0;default:return!1}}async function ue(e,t,r){const n=await N(e,{useSourceLayer:!0,ignoreGraphicSymbol:!0,webStyleCache:t,scale:r});null!=I(e.symbol,n)&&(e.symbol=n)}function pe(e,t){if(!e||!t)throw new Error("no geometry type");if("multipatch"===e)return{tool:"mesh",createOptions:{mode:"hybrid"}};const r=new Map;r.set("circle",{mode:"freehand"}),r.set("rectangle",{mode:"freehand"});const n={mode:Q,optionsPerTool:r};if(T(t)){const a=t.defaultTool,o=S(t)?t.definition?.inputGeometryType??e:e;switch(a){case"freehand":case"stream-line":return{tool:"polyline"===o?"freehandPolyline":"freehandPolygon",createOptions:n};case"autocomplete-freehand-polygons":case"stream-polygon":return{tool:"freehandPolygon",createOptions:n};case"autocomplete-polygons":case"difference-polygon":case"create-structures":case"polygon":case"trace":return{tool:"polygon"===o?"polygon":"polyline",createOptions:n};case"circle":return r.get("circle").preserveAspectRatio=!0,{tool:"circle",createOptions:n};case"ellipse":return r.get("circle").preserveAspectRatio=!1,{tool:"circle",createOptions:n};case"create-points-along-line":case"multipoint":return{tool:"multipoint",createOptions:n};case"line":case"radial-line":case"right-angle-line":case"split":case"two-point-line":return{tool:"polyline",createOptions:n};case"rectangle":case"regular-polygon":case"right-angle-polygon":return{tool:"rectangle",createOptions:n};case"elevation-point-from-contour":case"elevation-point-from-dem":case"parcel-seed":case"point":case"point-and-rotation":case"point-at-end-of-line":return{tool:"point",createOptions:n}}}else{const a=t.drawingTool;if("circle"===a||"ellipse"===a)return r.get("circle").preserveAspectRatio="circle"===a,{tool:"circle",createOptions:n};if("rectangle"===a)return{tool:"rectangle",createOptions:n};if("freehand"===a)return{tool:"polygon"===e?"freehandPolygon":"freehandPolyline",createOptions:n}}return{tool:e,createOptions:n}}async function de(e,t,r){const{creationInfo:n,fullTemplate:a}=t;if(!n)throw new i("featureworkflow","No creation info provided.");const o=n.layer,s=Le(a,n.attributeOverrides),{view:l}=e,c="2d"===l?.type;S(a)||F(a)||await Me(e,o,s,r,c?l.scale:null);const{capabilities:u}=o;e.layer.elevationInfo=o.elevationInfo;const p=pe(o.geometryType,a);e.defaultCreateOptions={graphicProperties:{attributes:s,sourceLayer:o},mode:p.createOptions.mode,optionsPerTool:p.createOptions.optionsPerTool,preserveAspectRatio:p.createOptions.preserveAspectRatio,hasZ:u.data.supportsZ,defaultZ:(c?u.editing.zDefault:null)??e.defaultCreateOptions.defaultZ},null==n.geometryToPlace?await e.create(p.tool):await e.place(n.geometryToPlace,{graphicProperties:{attributes:s,sourceLayer:o}})}async function fe(e){return s([await ye(e),await me(e)])}async function ye({creationAttributes:e,data:t,sketchViewModel:r,view:n,webStyleCache:a}){const{creationInfo:o}=t,{fullTemplate:i}=t;if(!o||"2d"!==n?.type||S(i)||F(i))return null;const s=f((t=>Me(r,o.layer,e,a,t)));return g((()=>n.scale),(e=>s(e)))}async function me({data:t,sketchViewModel:r,view:n}){const{templateExecutorInfo:a}=t;if(!a)return null;const o=r.activeComponent;if(!n||!X(o))return Y().error(new i("featureworkflow","Failed to set up template feedback.")),null;const c=new V({effect:"saturate(0.6) opacity(0.8)",listMode:"hide",title:"Shared Template Feedback Graphics"});n.map?.add(c);const{executor:u,serviceLayersById:p}=a,d=n.theme?.accentColor??new e([255,165,0,1]);return s([b((()=>o),["cursor-update","vertex-add"],(()=>{c.removeAll();const e=o.graphic?.geometry;if(!e||!he(e))return;const t=u(e,"digitizing");if(!y(t))for(const r of t.edits){const e=p.get(r.id);if(e&&r.addFeatures&&0!==r.addFeatures.length)for(const t of e)if(!t.isTable)for(const e of r.addFeatures){const t=ge(e,d);t&&c.add(t)}}})),l((()=>{n.map.remove(c),c.destroy()}))])}function he(e){switch(e.type){case"point":case"multipoint":return!0;case"polyline":return e.paths[0].length>1;case"polygon":{const t=e.rings[0];return n(t.at(0),t.at(-1))?t.length>2:t.length>1}default:return!1}}function ge(e,r){let n=null;switch(e.geometry?.type){case"point":case"multipoint":n=new G({angle:0,color:r,outline:new D({cap:"round",color:r,join:"round",miterLimit:1,style:"solid",width:1}),path:"undefined",size:8,style:"circle",xoffset:0,yoffset:0});break;case"polygon":n=new R({color:r,outline:new D({cap:"round",color:r,join:"round",miterLimit:1,style:"solid",width:3}),style:"none"});break;case"polyline":n=new D({cap:"round",color:r,join:"round",miterLimit:1,style:"solid",width:2});break;default:return null}return new t({geometry:e.geometry,symbol:n,attributes:{...e.attributes}})}async function be(e,t){const r=await Z(t).load(),n=x(e)?e.parent:e;return r.tablesAndLayersLookup.get(n)}async function we(e,t){const r=await be(e,t);if(!r)return new Map;const n=new Map;for(const a of r.layersAndTables)d(n,a.layerId,(()=>[])).push(a);return n}function ve(e){const t=e.objectIdField,r=e.globalIdField??"";return{id:e.layerId,identifierFields:{objectIdField:t,globalIdField:r},addFeatures:[],deleteAttachments:[],addAttachments:[],deleteFeatures:[],updateFeatures:[]}}function Ie(e){const{edits:t,serviceInfo:n,view:a,findOriginalFeature:o}=e,i=Te(n.layersAndTables),s=n.layersAndTables.toArray(),{allEditData:l,editDataByLayerIdMap:c,editDataByIdMap:u}=je(t,i,o),p=Fe(l,Se(s,c),c);if(a&&Ue(l,p,a),0===p.length)return t;const d=K(p,{continueOnCircularDependency:!0}).map((e=>u.get(e))).filter(r),f=new Map;for(const r of d)f.set(r.uniqueId,r);const y=[];for(const r of l)f.has(r.uniqueId)||y.push(r);const m=[];let h=null;for(const r of d){const{layer:e}=r;switch(null==h?h=ve(e):h.id!==e.layerId&&(m.push(h),h=ve(e)),r.operationType){case"add":case"modify":h.addFeatures.push(r.after);break;case"delete":h.deleteFeatures.push(r.before)}}null!==h&&m.push(h);for(const r of y){const e=r.layer.layerId,t=m.find((t=>t.id===e))??ve(r.layer);switch(m.includes(t)||m.push(t),r.operationType){case"add":t.addFeatures.push(r.after);break;case"modify":t.updateFeatures.push(r.after);break;case"delete":t.deleteFeatures.push(r.before);break;case"deleteAttachment":t.deleteAttachments.push(r.attachmentId);break;case"addAttachment":t.addAttachments.push(r.attachment)}}for(const r of m)void 0!==r.deleteAttachments&&0===r.deleteAttachments.length&&delete r.deleteAttachments,void 0!==r.addAttachments&&0===r.addAttachments.length&&delete r.addAttachments;return m}function Te(e){const t=new Map;for(const r of e)t.set(r.layerId,r);return t}function Se(e,t){const r=new Map;for(const n of e)for(const e of n.relationships??[])if(r.set(ke(n,e),""),t.has(e.relatedTableId)){const a=t.get(e.relatedTableId);if(a.length>0)for(const t of a[0].layer.relationships??[])if(t.id===e.id){r.set(ke(n,e),t.keyField);break}}return r}function je(e,t,r){const n=new Map,a=[],o=new Map;let s=1;for(const l of e){const e=[],c=t.get(l.id);if(!c)throw new i("featureworkflow",`Failed to prepare applyEdits payload. Layer with id ${l.id} not found.`);for(const t of l.addFeatures??[])e.push({uniqueId:"T"+s++,operationType:"add",layer:c,after:t});for(const t of l.deleteFeatures??[])e.push({uniqueId:"T"+s++,operationType:"delete",before:t,layer:c});for(const t of l.deleteAttachments??[])e.push({uniqueId:"T"+s++,operationType:"deleteAttachment",attachmentId:t,layer:c});for(const t of l.addAttachments??[])e.push({uniqueId:"T"+s++,operationType:"addAttachment",attachment:t,layer:c});for(const t of l.updateFeatures??[])e.push({uniqueId:"T"+s++,operationType:"modify",before:r(t),after:t,layer:c});n.set(c.layerId,e);for(const t of e)a.push(t),o.set(t.uniqueId,t)}return{allEditData:a,editDataByIdMap:o,editDataByLayerIdMap:n}}function Fe(e,t,r){const n=[];for(const a of e){const e=a.layer.relationships??[],{uniqueId:o}=a;for(const i of e){const e=i.keyField;if("origin"===i.role){const s=r.get(i.relatedTableId);if(!s||0===s.length)continue;const l=ke(a.layer,i),c=t.get(l);if(void 0===c||""===c)continue;switch(a.operationType){case"add":for(const t of s)t!==a&&("add"!==t.operationType&&"modify"!==t.operationType||t.after.attributes[c]===a.after.attributes[e]&&n.push([o,t.uniqueId]));break;case"modify":if(a.before.attributes[e]!==a.after.attributes[e])for(const t of s){const r=t.uniqueId;t!==a&&("delete"===t.operationType?t.before.attributes[c]===a.before.attributes[e]?n.push([r,o]):t.before.attributes[c]===a.after.attributes[e]&&n.push([o,r]):"add"===t.operationType?t.after.attributes[c]===a.after.attributes[e]?n.push([o,r]):t.after.attributes[c]===a.before.attributes[e]&&n.push([r,o]):"modify"===t.operationType&&(t.before.attributes[c]!==t.after.attributes[c]?t.after.attributes[c]===a.after.attributes[e]?n.push([o,r]):n.push([r,o]):n.push([o,r])))}break;case"delete":for(const t of s)t!==a&&("delete"!==t.operationType&&"modify"!==t.operationType||t.before.attributes[c]===a.before.attributes[e]&&n.push([t.uniqueId,o]))}}}}return n}function ke(e,t){return`${e.layerId}:${t.id}`}function Ae(e,t){return!!(t?.map&&"utilityNetworks"in t.map&&t.map.utilityNetworks?.length&&t.map.utilityNetworks.some((t=>!(!t.loaded||!e.url?.startsWith(t.featureServiceUrl)||e.layerId!==t.networkSystemLayers.associationsTableId))))}function Ue(e,t,r){const n=[];for(const o of e)Ae(o.layer,r)&&n.push(o);if(0===n.length)return;let a=[];for(const o of n){const r=o.layer;switch(o.operationType){case"delete":a=[...Ve(o.before.attributes[r.fieldsIndex.get("fromglobalid").name],e),...Ve(o.before.attributes[r.fieldsIndex.get("toglobalid").name],e)];for(const e of a)t.push([o.uniqueId,e.uniqueId]);break;case"add":a=[...Ve(o.after.attributes[r.fieldsIndex.get("fromglobalid").name],e),...Ve(o.after.attributes[r.fieldsIndex.get("toglobalid").name],e)];for(const e of a)t.push([e.uniqueId,o.uniqueId])}}}function Ve(e,t){const r=[],n=t.filter((({layer:e})=>""!==e.globalIdField&&null!=e.globalIdField));for(const a of n){const t=a.layer.globalIdField;("before"in a&&a.before?.attributes[t]===e||"after"in a&&a.after?.attributes[t]===e)&&r.push(a)}return r}function Le(e,t={}){return S(e)||F(e)?{}:k(e)?{...e.prototype.attributes,...t}:A(e)?{...e.definition?.defaultValues,...t}:{...t}}async function Me(e,r,n,a,o){const i=new t({sourceLayer:r,attributes:n}),{rotation:s,size:l}=ne(i);let c=await N(i,{useSourceLayer:!0,webStyleCache:a,scale:o}),u=!1;for(const t of[l,s]){if(null==t)continue;null==n[t.field]&&(n[t.field]=await t.getDefaultValue(c,e.view),u=!0)}switch(u&&(c=await N(i,{useSourceLayer:!0,webStyleCache:a,scale:o})),c?.type){case"simple-fill":case"polygon-3d":e.polygonSymbol=c;break;case"simple-line":case"line-3d":e.polylineSymbol=c;break;case"simple-marker":case"picture-marker":case"point-3d":case"cim":e.pointSymbol=c;break;case"mesh-3d":e.meshSymbol=c}Oe(e.tooltipOptions,l,s)}function Oe(e,t,r){e.visualVariables=null!=t||null!=r?{size:null!=t?{unit:t.displayUnit,axis:t.axis,valueType:t.fieldType}:null,rotation:null!=r?{valueType:r.fieldType,rotationType:r.rotationType??"geographic"}:null}:null}function xe(e,t){return e?.find((e=>e.layer===t))}async function ze(e,t,r,n){switch(t.type){case"3d":return qe(e,t,r,n);case"2d":return Pe(e,t,r,n)}}async function qe(e,t,r,n){if(0===e.length)return[];const{updatable:o,graphicsByLayer:i}=await r.defer((async()=>{const{results:a}=await h(H(t,r),n),o=new Map,i=e=>{const t=e.layer,r=o.get(t);if(!r){const e=new Array;return o.set(t,e),e}return r};J(a).forEach((({graphic:e})=>i(e).push(e)));const s=e.filter((({capabilities:e,layer:t})=>e.update.enabled&&o.has(t)));return 0!==s.length&&r.stopPropagation(),{updatable:s,graphicsByLayer:o}}));return h(Promise.allSettled(o.map((async({layer:e})=>{const t=i.get(e),r=Ee(e);if(t.every((e=>L(r,e))))return t;const o=[];for(const n of t){o.push(n.getObjectId());const e=Object.keys(n.attributes);a(r,e)}const s=e.createQuery();return s.returnGeometry=!1,s.objectIds=o,s.outFields=M(e.fieldsIndex,r),e.queryFeatures(s,{signal:n}).then((({features:e})=>e))}))),n)}async function Pe(e,t,r,n){if(0===e.length)return[];const{mapPoint:a}=r;if(null==a)return[];let o=null;const i=await r.defer((async()=>{const{results:a}=await h(t.hitTest(r),n);if(0===a.length)return[];const i=new Set;o=J(a),o.forEach((({graphic:e})=>e&&i.add(e.layer)));const s=e.filter((e=>i.has(e.layer)&&e.supportsUpdateWorkflow));return s.length>0&&r.stopPropagation(),s}));return h(Promise.allSettled(i.map((async({layer:e})=>{const i=e.createQuery();i.returnGeometry=!0,i.outFields=Ee(e);const s="renderer"in e?z({renderer:e.renderer,pointerType:r.pointerType}):0;i.geometry=$(a,s,t),i.outSpatialReference=t.spatialReference;const{features:l}=await e.queryFeatures(i,{signal:n});return o?.forEach((({graphic:t})=>{t.layer!==e||l.some((e=>e.getObjectId()===t.getObjectId()))||l.push(t)})),l}))),n)}function Ee(e){return M(e.fieldsIndex,[e.objectIdField,O({displayField:"displayField"in e?e.displayField:null,fields:e.fields})])}async function Ce(e,t,n,a){const o=t.createQuery();o.objectIds=e.map((e=>e.getObjectId())).filter(r),o.outFields=["*"],o.returnM=t.capabilities.data.supportsM,o.returnZ=t.capabilities.data.supportsZ,"scene"===t.type&&null!=t.infoFor3D||(o.outSpatialReference=n);const i=await t.queryFeatures(o,{signal:a});return m(a),i.features}function Re(e){const t=new Map;for(const r of e){const e=r.sourceLayer,n=x(e)?e.parent:e;d(t,n,(()=>[])).push(r)}return t}async function De(e){const{graphic:t,sketchViewModel:r,sourceLayer:n,visualVariables:a}=e;await Ge(e);const o={multipleSelectionEnabled:!1};return"point"===n.geometryType&&(o.enableRotation=null!=a.rotation,o.enableScaling=null!=a.size),r.update(t,o)}async function Ge(e){const{graphic:t,sketchViewModel:r,sourceLayer:n,visualVariables:a,webStyleCache:o}=e;let i=!1;const{rotation:s,size:l}=a;for(const c of[s,l]){if(null==c)continue;const e=t.getAttribute(c.field);if(null!=e)c.setInitialValue(e);else{const e=await c.getDefaultValue(t.symbol,r.view);c.setInitialValue(e),t.setAttribute(c.field,e),i=!0}}if(i){const e="2d"===r.view?.type?r.view.scale:null;await ue(t,o,e)}Oe(r.tooltipOptions,l,s),r.layer.elevationInfo=n.elevationInfo}function Be(e){return null==e||"rotate-start"!==e.type&&"rotate"!==e.type&&"rotate-stop"!==e.type?null:e}function Ne(e){return null==e||"scale-start"!==e.type&&"scale"!==e.type&&"scale-stop"!==e.type?null:e}function Ze(e,t,r,n){if(null==t.geometry||"point"!==t.geometry?.type)return!1;const a=t.attributes;let o=!1;const i=n.rotation,s=Be(r.toolEventInfo);if(null!=i&&null!=s){const{field:r,getValue:n}=i;if("rotate-stop"===s.type)i.isUpdatingInteractively=!1,i.setInitialValue(t.getAttribute(r));else{i.isUpdatingInteractively=!0;const l=n(s.angle,e);l!==a[r]&&(t.setAttribute(r,l),o=!0)}}const l=n.size,c=Ne(r.toolEventInfo);if(null!=l&&null!=c){const{field:r,getValue:n}=l;if("scale-stop"===c.type)l.isUpdatingInteractively=!1,l.setInitialValue(t.getAttribute(r));else{l.isUpdatingInteractively=!0;const i=n(c.xScale,e);i!==a[r]&&(t.setAttribute(r,i),o=!0)}}return o}async function We({feature:e,featureClone:t,visualVariableAttributes:r,sketchViewModel:n,view:a,onUpdate:o,webStyleCache:i,addUpdatingPromise:u,addHandle:p}){await ue(t,i,"2d"===a.type?a.scale:null);let d=null;if("2d"===n?.view?.type){const e=f((e=>ue(t,i,e)));d=g((()=>n?.view?.scale),(t=>e(t)))}const y=t.sourceLayer,m=tt(a,y);await De({graphic:t,sketchViewModel:n,sourceLayer:y,visualVariables:r,webStyleCache:i});let h=null;m.then((e=>h=e)).catch((()=>{}));const b=r.size,v=r.rotation,I=g((()=>e.attributes),(async e=>{let r=!1;for(const n in e){const a=e[n];a!==t.getAttribute(n)&&(t.setAttribute(n,a),null==b||b.isUpdatingInteractively||b.field!==n||b.setInitialValue(a),null==v||v.isUpdatingInteractively||v.field!==n||v.setInitialValue(a),(null==h||h.requiredFields.includes(n))&&(r=!0))}r&&await ue(t,i,"2d"===a.type?a.scale:null)})),T=n.on("update",(async e=>{const t=e.graphics[0],s={graphic:t,sketchViewModel:n,sourceLayer:y,visualVariables:r,webStyleCache:i};if("complete"===e.state){if(null===a.activeTool)return De(s);const e=new AbortController,t=c(e);return p(t),u(w((()=>null===a.activeTool),e.signal).then((async()=>{if(!e.signal.aborted)return e.abort(),De(s)})))}Ze(a,t,e,r)&&await ue(t,i,"2d"===a.type?a.scale:null),o(nt(t),e)})),S=n.on(["undo","redo"],(async e=>{o(nt(e.graphics[0]),e)}));return s([S,T,l((()=>n.cancel())),I,d])}async function Qe(e,t,r){const n=e.view;e.layer.add(r);const a=t.sourceLayer,i=t.layer,c=t.getAttribute(i.objectIdField);let u=null;function p(e){u?.abort(),u=o((async t=>{const r=await tt(n,a);m(t),r.setVisibility?.(c,e)}))}return await Je(n,r),p(!1),s([$e(n,r,(e=>p(!e))),l((async()=>{p(!0);try{const e=await tt(n,a);await w((()=>!e.updating))}finally{e.layer.remove(r)}}))])}function $e(e,t,r){if("3d"===e.type){const n=new W({graphic:t});return s([e.trackGraphicState(n),g((()=>n.displaying),r)])}return g((()=>t.visible),r)}async function Je(e,t){if("3d"===e.type){const r=new W({graphic:t}),n=e.trackGraphicState(r);await w((()=>r.displaying||r.error)),n.remove()}else await w((()=>t.visible))}const He={icon:v(24),text:v(12),line:v(1),viewScaleSizeFactor:100};function Ke(e,t,r){let n=!1;return e.filter((e=>!!n||(n=e===t,n))).map((e=>r[e]()))}function Xe(e,t){e.viewModel.syncFeatureTemplates();const r=e.creationInfo;if("awaiting-feature-creation-info"===t[0].id&&r){const n=r.layer,a=e.viewModel.getTemplatesForLayer(n);1===a.length&&"scene"!==n.type&&(r.template=a[0],t.shift())}return t}function Ye(e){return"unknown"===e?null:e}function _e(e){e.filesEnabled=!0,e.mode="view",e.capabilities={editing:!0,operations:{add:!0,update:!0,delete:!0}}}const et=e=>/-stop/.test(e)||/vertex-/.test(e),tt=(e,t)=>{const r="subtype-sublayer"===t.type?t.parent:t;return e.whenLayerView(r)};function rt(e){return"createInteractiveEditSession"in e}function nt(e){const t=e.geometry;if("mesh"===t?.type){const r=e.cloneShallow();return r.attributes=u(e.attributes),r.geometry=t.cloneShallow(),r.geometry.transform=t.transform?.clone()??null,r}return e.clone()}function at(e){const t=e.cursor;return e.cursor="progress",l((()=>e.cursor=t))}async function ot(e,t){const{template:r}=e;if(null==r)return null;if(j(r))return r.load();if(T(r)){const e=(await import("../../editing/sharedTemplates/SharedTemplate.js")).default,n=U(t,{makeSharedTemplateFromJSON:t=>e.fromJSON(t)}),a=await n.getTemplates({templateIds:[r.templateId],featureService:r.featureService});if(0===a.length)throw new i("editor:failed-to-load-template","Unable to load the provided template");return a[0].load()}return r}function it(e){for(const t of e){const{destinationGraphic:e,destinationField:r,sourceGraphic:n,sourceField:a}=t;e.setAttribute(r,n.getAttribute(a))}}function st(e){const t=e.templateExecutorInfo?.completionResults;return t?.length?(t.forEach((e=>it(e.relationships))),t.flatMap((e=>e.edits))):null}function lt(e){if(null==e)return[];if(te(e))return e.data.layers;const t=ee(e)?e.activeWorkflow:e,r=t?.layer;return r?[r]:[]}export{Ue as appendAllUtilityNetworkAssociationRelationships,Xe as avoidFeatureTemplateSelectionWithOnlyOneItem,rt as canCreateInteractiveEditSession,nt as cloneGraphicExceptMesh,Te as createLayerIdMap,Se as createRelationshipKeyMap,pe as createToolFromGeometryType,Ke as createWorkflowSteps,ze as fetchCandidates,Ce as fetchFullFeatures,Fe as findAllDependencies,Ve as findChangesByGlobalId,xe as findLayerInfo,ke as generateHashForRelationship,Le as getCreationAttributes,ot as getFullTemplateForCreationInfo,lt as getLayersFromWorkflow,ae as getRotationVariableAttribute,st as getServiceEditsFromWorkflowData,be as getServiceInfoForLayer,we as getServiceLayersById,se as getSizeVariableAttribute,ne as getVisualVariableAttributes,re as getVisualVariablesForLayer,Re as groupFeaturesByLayer,_ as isBatchAttributeFormViewModel,et as isTerminalUpdateEventType,te as isUpdateFeaturesWorkflow,ee as isUpdateWorkflow,Ae as isUtilityNetworkAssociationsTable,Ie as orderEditsByRelationshipDependencies,_e as prepareAttachmentsForCreateFeaturesWorkflow,it as setRelationshipFields,We as setUpGeometryUpdate,fe as setUpSketchCreateWatchers,Ge as setVisualVariablesAndElevationInfoForUpdate,at as showProgressCursor,He as sizeDefaults,Ye as sizeVariableUnitToLengthUnit,de as startCreatingNewFeature,De as startUpdatingFeatureGeometry,Qe as swapForEditingSession,ue as updateGraphicSymbolWhenRequired,Ze as visualVariableInteractiveUpdate,tt as whenEditorLayerView,Je as whenGraphicDisplayed};
package/widgets/Editor.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{destroyMaybe as t,mappedFind as s,abortMaybe as o}from"../core/maybe.js";import{createResolver as i}from"../core/promiseUtils.js";import{watch as a,on as r,when as n,initial as l}from"../core/reactiveUtils.js";import{property as c}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/Logger.js";import"../core/RandomLCG.js";import{subclass as d}from"../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as m}from"../core/support/UpdatingHandles.js";import h from"../views/interactive/sketch/SketchValueOptions.js";import p from"./Attachments.js";import u from"./FeatureForm.js";import g from"./FeatureTemplates.js";import w from"./Spinner.js";import _ from"./Widget.js";import{css as v}from"./Editor/css.js";import f from"./Editor/EditorViewModel.js";import{isModelUpload as y}from"./Editor/modelUploadUtils.js";import k from"./Editor/VisibleElements.js";import{loadCreateFeaturesPanelContentComponents as b,CreateFeaturesPanelContent as A}from"./Editor/components/CreateFeaturesPanelContent.js";import{loadFeatureListComponents as F,FeatureList as M}from"./Editor/components/FeatureList.js";import{loadFooterActionsComponents as T,FooterActions as C}from"./Editor/components/FooterActions.js";import{loadNoticesComponents as W,Notice as E}from"./Editor/components/Notices.js";import{loadPanelContentComponents as P,PanelContent as L,PanelContentSection as S,PanelContentMessage as I}from"./Editor/components/PanelContent.js";import{PanelToolbar as j,loadPanelToolbarComponents as U}from"./Editor/components/PanelToolbar.js";import{loadPromptComponents as D,Prompt as V}from"./Editor/components/Prompt.js";import{loadUpdateFeaturePanelContentComponents as O,UpdateFeaturePanelContent as x}from"./Editor/components/UpdateFeaturePanelContent.js";import{loadUploadDetailsComponents as B,UploadDetails as N}from"./Editor/components/UploadDetails.js";import{VisibleElements as z,CreateToolVisibilityMap as H}from"./Sketch/VisibleElements.js";import{loadCalciteComponents as R}from"./support/componentsUtils.js";import{globalCss as G}from"./support/globalCss.js";import{incrementHeadingLevel as q,Heading as Z}from"./support/Heading.js";import{renderItem as K}from"./support/ItemList.js";import{connectDelayedLoading as $}from"./support/loaderUtils.js";import"./support/widgetUtils.js";import{messageBundle as J}from"./support/decorators/messageBundle.js";import{vmEvent as Q}from"./support/decorators/vmEvent.js";import{tsx as X}from"./support/jsxFactory.js";import{substitute as Y}from"../intl/substitute.js";const ee=Symbol("sketch-setup-handles");let te=class extends _{constructor(e,t){super(e,t),this._featureForm=new u,this._sketchToolbar=null,this._attachments=new p({visibleElements:{addSubmitButton:!1,cancelAddButton:!1,cancelUpdateButton:!1,deleteButton:!1,errorMessage:!1,progressBar:!1,updateButton:!1}}),this._associationItemList=null,this._associationSettings=null,this._featureTemplates=new g({enableListScroll:!1,renderItemContentEnd:e=>e.supportsUpload?X("calcite-icon",{class:v.templateItemContentEnd,icon:"upload-to",key:"upload-icon"}):null,renderItemLabel:e=>e.label,renderCustomGroupContent:e=>this._renderCustomTemplateGroupContent(e)}),this._filterText="",this._prompt=null,this._spinner=new w,this._loading=!1,this._updatingHandles=new m,this.headingLevel=4,this.messages=null,this.messagesCommon=null,this.messagesTemplates=null,this.messagesFeature=null,this.supportingWidgetDefaults=null,this.viewModel=new f,this.visibleElements=new k,this._renderAttachments=()=>this._attachments.render(),this._renderFeatureForm=()=>this._featureForm.render(),this._renderFeatureTemplates=()=>this._featureTemplates.render(),this._renderSketch=()=>this._sketchToolbar?X("div",{class:v.sketchContainer,key:"editor-sketch-container"},this._sketchToolbar?.render()):void 0,this._renderSelectIcon=()=>X("calcite-icon",{icon:"cursor",slot:"content-start"}),this.EditorPanel=({heading:e,key:t,selected:s},...o)=>{const{visibleElements:i}=this;return X("calcite-flow-item",{closable:!1,heading:e,headingLevel:this.headingLevel,key:t,loading:this._loading,selected:s,onCalciteFlowItemBack:this._onBack},i.zoomToButton&&this.viewModel.canZoomTo?X("calcite-action",{alignment:"center",appearance:"transparent",icon:"zoom-to-object",key:"zoom-to-button",onclick:()=>this.viewModel.zoomTo(),slot:"header-actions-end",text:this.messages.zoomTo,title:this.messages.zoomTo}):null,i.settingsMenu?X(j,{editorViewModel:this.viewModel,messagesCommon:this.messagesCommon,visibleElements:i}):null,...o)},this._showDiscardEditsPrompt=()=>{const{messages:e,activeWorkflow:t}=this,s={title:e.cancelEditTitle,message:e.cancelEditWarningMessage,yesLabel:e.discardEdits,noLabel:e.continueEditing};return"create-features"===t?.type&&y(t.data.creationInfo)?this._showPromptAndWait("success"===t.data.upload?.state?e.modelUploads.cancelPlacementPrompt:e.modelUploads.cancelUploadPrompt):"update"===t?.type&&t.activeFeatureFormViewModel?.activeAssociation?this._showPromptAndWait({...s,message:e.cancelAssociationEditWarning}):this._showPromptAndWait(s)},this._showGenericCancelPrompt=()=>{const{messages:e,messagesCommon:t}=this;return this._showPromptAndWait({title:e.cancelRequestTitle,message:e.cancelRequestWarningMessage,yesLabel:t.form.yes,noLabel:t.form.no})},this._showPrompt=e=>{this._prompt?.cancel?.(),this._prompt=e},this._clearPrompt=()=>{this._prompt=null},this._onSave=()=>{this.viewModel.saveWorkflow()},this._onDelete=()=>{const{messages:e,messagesCommon:t}=this;this._showPrompt({title:e.deleteWarningTitle,message:e.deleteWarningMessage,context:"danger",actions:{primary:{label:t.delete,action:()=>{this.deleteFeatureFromWorkflow(),this._clearPrompt()}},secondary:{label:e.keepFeature,action:this._clearPrompt}}})},this._onDeleteAssociation=()=>{const{messages:e,messagesCommon:t}=this;this._showPrompt({title:e.deleteAssociationTitle,message:e.deleteAssociationMessage,context:"danger",actions:{primary:{label:t.delete,action:()=>{this.deleteAssociationFromWorkflow(),this._clearPrompt()}},secondary:{label:e.keepAssociation,action:this._clearPrompt}}})},this._onToggleUpdateWorkflow=()=>this.viewModel.toggleUpdateWorkflow(),this._onBack=e=>(e?.stopPropagation(),this.viewModel.back()),this._onAttachmentAdd=()=>{const{activeWorkflow:e}=this.viewModel;e&&("create-features"===e.type||"update"===e.type&&"create-features"===e.activeWorkflow?.type?(this._attachments.addFile(),e.back()):this._attachments.addAttachment().then((()=>e.back())))},this._onAttachmentUpdate=()=>{const{activeWorkflow:e}=this.viewModel;e&&("create-features"===e.type?(this._attachments.updateFile(),e.back()):this._attachments.updateAttachment().then((()=>e.back())))},this._onAttachmentDelete=()=>{const{messages:e,messagesCommon:t}=this;this._showPrompt({title:e.deleteAttachmentWarningTitle,message:e.deleteAttachmentWarningMessage,context:"danger",actions:{primary:{label:t.delete,action:this._onAttachmentDeleteConfirm},secondary:{label:e.keepAttachment,action:this._clearPrompt}}})},this._onAttachmentDeleteConfirm=async()=>{const e=this._attachments,{activeWorkflow:t}=this.viewModel;t&&("create-features"===t.type?e.deleteFile():(await e.deleteAttachment(e.viewModel.activeAttachmentInfo),this._clearPrompt()),await t.back(),this._clearPrompt())},this._onAttachmentsError=e=>{this._showPrompt({title:this.messages.errorWarningTitle,message:e.message,context:"warning",actions:{primary:{label:this.messagesCommon.form.ok,action:this._clearPrompt}}})}}initialize(){this._featureForm.showPrompt=this._showPrompt,this._featureForm.clearPrompt=this._clearPrompt,this.addHandles([a((()=>q(this.headingLevel)),(e=>{this._featureForm.headingLevel=e,this._featureTemplates.headingLevel=e}),l),r((()=>this.viewModel.activeWorkflow),"cancel-request",(({controller:e})=>{(this.viewModel.hasPendingEdits?this._showDiscardEditsPrompt():this._showGenericCancelPrompt()).then((t=>t?e.allow():e.deny()))})),n((()=>this.viewModel.featureFormViewModel),(e=>{this._featureForm.viewModel=e}),l),n((()=>this.viewModel.utilityNetworkAssociationAddAssociationViewModel),(e=>{this._associationItemList?this._associationItemList.viewModel=e:this._updatingHandles.addPromise(this._initializeAssociationItemList(e))}),l),n((()=>this.viewModel.utilityNetworkAssociationAddAssociationViewModel?.association),(()=>{this._setUpAssociationSettings()})),a((()=>this.viewModel),(e=>{this._attachments.viewModel=e?.attachmentsViewModel??null,this._featureTemplates.viewModel=e?.featureTemplatesViewModel??null,this._spinner.viewModel=e?.spinnerViewModel??null,e.showDiscardEditsPrompt=this._showDiscardEditsPrompt}),l),a((()=>this.view),((e,t)=>{const s=`editor-${this.id}-spinner`;t?.ui.remove(this._spinner,s),e?.ui.add(this._spinner,{key:s,position:"manual"}),this._associationItemList&&(this._associationItemList.view=e)}),l),a((()=>[this.supportingWidgetDefaults,this.viewModel.sketchViewModel]),(([e])=>{e&&(this._featureForm.set(e.featureForm),this._attachments.set(e.attachments),this._featureTemplates.set(e.featureTemplates),this.viewModel.sketchViewModel?.set(e.sketch))}),l),n((()=>this._attachments?.error),(e=>this._onAttachmentsError(e))),n((()=>this.viewModel?.failures),(e=>{const{messages:t}=this,[{error:s,retry:o,cancel:i}]=e;this._showPrompt({title:t.errorWarningTitle,message:Y(t.errorWarningMessageTemplate,{errorMessage:s.message}),context:"warning",actions:{primary:{label:t.retry,action:()=>{o(),this._clearPrompt()}},secondary:{label:t.ignore,action:()=>{i(),this._clearPrompt()}}}})})),a((()=>this.viewModel?.state),(e=>{switch(e){case"awaiting-feature-to-update":case"ready":case"disabled":this._filterText="",this._featureTemplates.filterText=""}})),a((()=>this.viewModel.featureFormDisabled),(e=>this._featureForm.disabled=e)),a((()=>this.visibleElements.sketch),(()=>this._setupSketch()),l),$({getLoading:()=>{const{viewModel:e}=this;return e.syncing||e.updating||this._attachments.submitting||this._updatingHandles.updating},setEffectiveLoading:e=>{this._loading=e}})])}destroy(){this._associationItemList?.destroy(),this._associationSettings?.destroy(),this._attachments.destroy(),this._featureForm.destroy(),this._featureTemplates.destroy(),this._sketchToolbar=t(this._sketchToolbar)}loadDependencies(){return Promise.all([R({action:()=>import("@esri/calcite-components/dist/components/calcite-action"),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")}),b(),F(),T(),W(),P(),U(),D(),O(),B()])}get _deleteButtonCommonInfo(){return{appearance:"outline",kind:"danger"}}get activeWorkflow(){return this.viewModel.activeWorkflow}get hideTemplatesForInactiveLayers(){return this.viewModel.hideTemplatesForInactiveLayers}set hideTemplatesForInactiveLayers(e){this.viewModel.hideTemplatesForInactiveLayers=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 layerInfos(){return this.viewModel.layerInfos}set layerInfos(e){this.viewModel.layerInfos=e}get snappingOptions(){return this.viewModel.snappingOptions}set snappingOptions(e){this.viewModel.snappingOptions=e}get tooltipOptions(){return this.viewModel.tooltipOptions}set tooltipOptions(e){this.viewModel.tooltipOptions=e}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}startCreateFeaturesWorkflowAtFeatureTypeSelection(){return this.viewModel.startCreateFeaturesWorkflowAtFeatureTypeSelection()}startCreateFeaturesWorkflowAtFeatureCreation(e){return this.viewModel.startCreateFeaturesWorkflowAtFeatureCreation(e)}startCreateFeaturesWorkflowAtFeatureEdit(e){return this.viewModel.startCreateFeaturesWorkflowAtFeatureEdit(e)}startUpdateWorkflowAtFeatureSelection(){return this.viewModel.startUpdateWorkflowAtFeatureSelection()}startUpdateWorkflowAtMultipleFeatureSelection(e){return this.viewModel.startUpdateWorkflowAtMultipleFeatureSelection(e)}startUpdateWorkflowAtFeatureEdit(e){return this.viewModel.startUpdateWorkflowAtFeatureEdit(e)}deleteFeatureFromWorkflow(){return this.viewModel.deleteFeatureFromWorkflow()}deleteAssociationFromWorkflow(){return this.viewModel.deleteAssociationFromWorkflow()}cancelWorkflow(e){return this.viewModel.cancelWorkflow(e)}render(){const{visibleElements:e,viewModel:t}=this,s=this.classes(v.base,G.widget,G.panel);if(!t)return X("div",{class:s,key:"empty"});const{pageStack:o}=t,i=o.length-1,a=o.map(((e,t)=>this._renderPage(e,t===i)));return X("div",{class:s,key:"base"},e.flow?X("calcite-flow",{inert:!!this._prompt,key:"flow"},a):a,this._prompt?X(V,{...this._prompt,headingLevel:this.headingLevel}):void 0)}_renderPage(e,t){const s={selected:t};switch(e){case"disabled":break;case"ready":return this._renderReady(s);case"awaiting-feature-creation-info":return this._renderAwaitingFeatureCreationInfo(s);case"creating-features-upload-details":return this._renderUploadDetails(s);case"creating-features":return this._renderCreatingFeatures(s);case"editing-existing-feature":case"editing-attributes":return this._renderUpdateFeature(s);case"awaiting-update-feature-candidate":return this._renderFeatureList(s);case"adding-attachment":return this._renderAttachmentAdding(s);case"editing-attachment":return this._renderAttachmentEditing(s);case"viewing-associated-layers":case"viewing-associated-features":return this._renderViewAssociatedLayers(s);case"add-association-select-layer":case"add-association-select-feature":return this._renderSelectFeature(s);case"add-association-create-association":return this._renderAddAssociation(s)}return X("div",{key:"empty-page"})}_renderAwaitingFeatureCreationInfo(e){const{EditorPanel:t,messages:s}=this;return X(t,{heading:s.selectTemplate,key:"templates-panel",...e},X(L,{key:"feature-templates"},X(S,null,this._renderFeatureTemplates())))}_renderUploadDetails(e){const{EditorPanel:t,activeWorkflow:s,messages:o}=this;if("create-features"!==s?.type)return null;const i=s.data.upload;return i?X(t,{heading:o.createFeatures,key:"upload-details-panel",...e},X(N,{helpMessage:this._helpMessage,messages:o,upload:i})):null}_renderCreatingFeatures(e){const{EditorPanel:t,activeWorkflow:s,messages:o,messagesCommon:i,headingLevel:a,viewModel:r}=this;if(!s)return null;const n="create-features"===s.type&&s.numPendingFeatures>0||"update"===s.type&&"create-features"===s?.activeWorkflow?.type&&s.activeWorkflow?.numPendingFeatures>0;return X(t,{heading:o.createFeatures,key:"create-features-panel",...e},n?X(x,{editorViewModel:r,headingLevel:a,messages:o,messagesCommon:i,renderAttachments:this._renderAttachments,renderFeatureForm:this._renderFeatureForm,renderSketchToolbar:this._renderSketch,onDelete:this._onDelete,onDeleteAssociation:this._onDeleteAssociation,onSave:this._onSave}):X(A,{helpMessage:this._helpMessage,renderSketchToolbar:this._renderSketch}))}_renderUpdateFeature(e){const{EditorPanel:t,messages:s,messagesCommon:o,headingLevel:i,viewModel:a}=this;return X(t,{heading:s.editFeature,key:"update-feature-panel",...e},X(x,{editorViewModel:a,headingLevel:i,messages:s,messagesCommon:o,renderAttachments:this._renderAttachments,renderFeatureForm:this._renderFeatureForm,renderSketchToolbar:this._renderSketch,onDelete:this._onDelete,onDeleteAssociation:this._onDeleteAssociation,onSave:this._onSave}))}_getAssociationTypeTitle(e){const{messages:t}=this;if(!e)return t.editFeature;if(e.title)return e.title;const{messagesFeature:s}=this;switch(e.type){case"attachment":return s.associationsAttachments;case"connectivity":return s.associationsConnectivity;case"structure":return s.associationsStructure;case"content":return s.associationsContents;case"container":return s.associationsContainer}}_getAddAssociationTypeTitle(e){const{messages:t}=this;if(!e)return t.editFeature;const s=t.associations;switch(e.type){case"attachment":return s.addAttachment;case"connectivity":return s.addConnectivity;case"structure":return s.addStructure;case"content":return s.addContent;case"container":return s.addContainer}}async _initializeAssociationItemList(e){const t=(await import("./FeatureForm/FeatureFormUtilityNetworkAssociations/UtilityNetworkAssociationItemList.js")).default;this._associationItemList=new t({view:this.view,viewModel:e})}async _initializeAssociationSettings(){const e=new(0,(await import("./FeatureForm/FeatureFormUtilityNetworkAssociations/UtilityNetworkAssociationSettings.js")).default);return this._associationSettings=e,e}_renderViewAssociatedLayers(e){const{EditorPanel:t,messages:s,messagesCommon:o,headingLevel:i,viewModel:a}=this,r=a.featureFormViewModel?.activeAssociationInput?.activeAssociationType,n=this._getAssociationTypeTitle(r);return X(t,{heading:n,key:"viewing-associated-layers-panel",...e},X(x,{editorViewModel:a,headingLevel:i,messages:s,messagesCommon:o,renderAttachments:this._renderAttachments,renderFeatureForm:this._renderFeatureForm,renderSketchToolbar:this._renderSketch,onDelete:this._onDelete,onDeleteAssociation:this._onDeleteAssociation,onSave:this._onSave}))}_renderSelectFeature(e){const{_associationItemList:t,EditorPanel:s,viewModel:o,messagesCommon:i}=this,a=o.utilityNetworkAssociationAddAssociationViewModel,r=this._getAddAssociationTypeTitle(a?.associationType),n="ready"!==a?.state;return t?X(s,{heading:r,key:"add-association-select-feature",...e},X(L,{key:"select-feature"},X(S,null,t.render())),X(C,{buttons:[t.filterOptionsVisible?{appearance:"solid",label:i.apply,disabled:n,onClick:()=>t.applyFilterOptions(),type:"button"}:void 0,{appearance:"outline",label:i.cancel,disabled:n,onClick:()=>{"update"===o.activeWorkflow?.type&&(a?.reset(),o.activeWorkflow.cancelActiveWorkflow())},type:"button"}]})):X(s,{heading:r,key:"add-association-select-feature",...e})}async _setUpAssociationSettings(){const{viewModel:e}=this,t=this._associationSettings??await this._updatingHandles.addPromise(this._initializeAssociationSettings()),s=e.utilityNetworkAssociationAddAssociationViewModel,o="update"===e.activeWorkflow?.type?e.activeWorkflow:null,i=o?o.activeWorkflow:null,a="add-association"===i?.type?i.sourceFeatureItem:null,r=s?.selectedFeature,n=s?.association,l=s?.utilityNetwork;a&&r&&n&&l&&(t.sourceFeature=a,t.targetFeature=r,t.association=n,t.utilityNetwork=l)}_renderAddAssociation(e){const{_associationSettings:t,EditorPanel:s,viewModel:o,messagesCommon:i}=this;if(!t)return null;const a=o.utilityNetworkAssociationAddAssociationViewModel,r=this._getAddAssociationTypeTitle(a?.associationType),n="ready"!==a?.state;return X(s,{heading:r,key:"add-association",...e},X(L,{key:"add-association-content"},X(S,null,t.render())),X(C,{buttons:[{label:i.add,disabled:n||!a.canAddAssociation,onClick:()=>this._onSave(),type:"button"},{appearance:"outline",label:i.cancel,disabled:n,onClick:()=>{"update"===o.activeWorkflow?.type&&o.activeWorkflow.cancelActiveWorkflow()},type:"button"}]}))}_renderCustomTemplateGroupContent(e){const{messages:t,viewModel:o}=this,i=s(e.group.items,(e=>o.itemHasInvalidFormTemplate(e)?t.formFieldCreateError:void 0));return i?X(E,{kind:"warning",message:i}):null}_renderAttachmentAdding(e){const{EditorPanel:t,_attachments:s,messages:o,messagesCommon:i}=this;return X(t,{heading:o.addAttachment,key:"attachment-adding-panel",...e},X(L,{key:"attachments"},this._renderAttachments()),X(C,{buttons:[{label:s.submitting?i.cancel:i.add,disabled:s.submitting||!s.selectedFile,onClick:this._onAttachmentAdd,type:"button"}]}))}_renderAttachmentEditing(e){const{EditorPanel:t,_attachments:s,activeWorkflow:o,messages:i,messagesCommon:a}=this;return o?X(t,{heading:i.editAttachment,key:"attachment-editing-panel",...e},X(L,{key:"attachments"},this._renderAttachments()),o.shouldAllowAttachmentEditing?X(C,{buttons:[{label:a.update,disabled:s.submitting||!s.selectedFile,onClick:this._onAttachmentUpdate,type:"button"},{...this._deleteButtonCommonInfo,onClick:this._onAttachmentDelete,disabled:s.submitting,label:a.delete,type:"button"}]}):void 0):null}_renderReady(e){const{EditorPanel:t,messages:s,viewModel:o,visibleElements:i}=this,a=this._helpMessage;return X(t,{heading:s.widgetLabel,key:"landing-panel",...e},X(L,{key:"landing-content"},o.editorItems.length?[i.editFeaturesSection?X(S,{key:"edit-actions"},this._renderUpdateActions()):null,i.createFeaturesSection&&o.canCreateVisible?X(S,{key:"create-actions"},this._renderCreateActions()):null]:X(I,{key:"no-content"},s.noEditableLayers)),a?X("div",{class:v.helpMessage,key:"footer-actions",slot:"footer"},a):void 0)}get _helpMessage(){const{activeWorkflow:e,messages:t,view:s}=this,o=e?.helpMessage;return o?t["3d"===s?.type?"helpMessages3d":"helpMessages2d"]?.[o]:void 0}_renderUpdateActions(){const{messages:e,messagesCommon:t,viewModel:s}=this,o={id:"select",label:t.select};return X("div",{class:v.updateActions,key:"update-actions"},X(Z,{level:q(this.headingLevel)},e.editFeatures),X("calcite-list",{class:v.updateActionsList,label:e.editFeaturesList,selectionAppearance:"border",selectionMode:"single"},K({disabled:!s.canUpdateVisible,grouped:!1,item:o,selectedItem:"awaiting-feature-to-update"===s.activeWorkflow?.stepId?o:void 0,renderIcon:this._renderSelectIcon,onItemSelect:this._onToggleUpdateWorkflow})))}_renderCreateActions(){return X("div",{key:"create-actions"},X(Z,{level:q(this.headingLevel)},this.messages.createFeatures),X("div",{class:v.featureTemplatesContainer,key:"templates"},this._renderFeatureTemplates()))}_renderFeatureList(e){const{EditorPanel:t,viewModel:s}=this,{activeWorkflow:o}=s;if("update"!==o?.type)return null;const i=o.data.candidates,a=Y(this.messages.multipleFeaturesTemplate,{total:i.length});return X(t,{heading:a,key:"feature-list",...e},X(M,{editorItems:s.editorItems,editorMessages:this.messages,filterText:this._filterText,id:this.id,messagesTemplates:this.messagesTemplates,workflow:o,onFilterTextChange:e=>this._filterText=e,onSelectFeature:(e,t)=>s.selectFeature(e,t),onZoomTo:e=>s.zoomTo(e)}))}_showPromptAndWait({title:e,message:t,yesLabel:s,noLabel:o}){const a=i(),{view:r}=this,n=r?.focused;return this._showPrompt({title:e,message:t,context:"danger",actions:{primary:{label:s,action:()=>a.resolve(!0)},secondary:{label:o,action:()=>a.resolve(!1)}}}),a.promise.finally((()=>{this._clearPrompt(),n&&r?.focus()}))}async _setupSketch(){if(!!!this.visibleElements.sketch)return this._sketchImportAbortController=o(this._sketchImportAbortController),this._sketchToolbar=t(this._sketchToolbar),void this.removeHandles(ee);if(this._sketchImportAbortController)return;const e=new AbortController;this._sketchImportAbortController=e;const s=await import("./Sketch.js");if(!e.signal.aborted)try{this._sketchToolbar=new s.default({toolbarKind:"docked",contextualToolLocation:"inline-end",scale:"s",visibleElements:new z({deleteButton:!1,settingsMenu:!1,directionModePicker:!1,selectionCountLabel:!1,duplicateButton:!1,createTools:new H({freehandPolygon:!0,freehandPolyline:!0})})}),this.addHandles([a((()=>this.viewModel.activeLeafWorkflow?.availableCreateTools),(e=>{this._sketchToolbar&&(this._sketchToolbar.availableCreateTools=e)}),l),a((()=>this.visibleElements.undoRedoButtons),(e=>{this._sketchToolbar&&(this._sketchToolbar.visibleElements.undoRedoMenu=e)}),l),n((()=>this.viewModel?.sketchViewModel),(e=>{this._sketchToolbar&&(this._sketchToolbar.viewModel=e)}),l)],ee)}finally{this._sketchImportAbortController=null}}get test(){return{sketch:this._sketchToolbar,showPrompt:this._showPromptAndWait.bind(this)}}};e([c()],te.prototype,"_featureForm",void 0),e([c()],te.prototype,"_sketchToolbar",void 0),e([c()],te.prototype,"_attachments",void 0),e([c()],te.prototype,"_associationItemList",void 0),e([c()],te.prototype,"_associationSettings",void 0),e([c()],te.prototype,"_featureTemplates",void 0),e([c()],te.prototype,"_filterText",void 0),e([c()],te.prototype,"_prompt",void 0),e([c()],te.prototype,"_spinner",void 0),e([c()],te.prototype,"_deleteButtonCommonInfo",null),e([c()],te.prototype,"_loading",void 0),e([c({readOnly:!0})],te.prototype,"activeWorkflow",null),e([c()],te.prototype,"headingLevel",void 0),e([c()],te.prototype,"hideTemplatesForInactiveLayers",null),e([c()],te.prototype,"icon",null),e([c()],te.prototype,"label",null),e([c()],te.prototype,"labelOptions",null),e([c()],te.prototype,"layerInfos",null),e([c(),J("esri/widgets/Editor/t9n/Editor")],te.prototype,"messages",void 0),e([c(),J("esri/t9n/common")],te.prototype,"messagesCommon",void 0),e([c(),J("esri/widgets/FeatureTemplates/t9n/FeatureTemplates")],te.prototype,"messagesTemplates",void 0),e([c(),J("esri/widgets/Feature/t9n/Feature")],te.prototype,"messagesFeature",void 0),e([c()],te.prototype,"snappingOptions",null),e([c()],te.prototype,"tooltipOptions",null),e([c()],te.prototype,"supportingWidgetDefaults",void 0),e([c({type:h,nonNullable:!0})],te.prototype,"valueOptions",null),e([c()],te.prototype,"view",null),e([c(),Q(["sketch-create","sketch-delete","sketch-update","workflow-cancel","workflow-commit"])],te.prototype,"viewModel",void 0),e([c({type:k,nonNullable:!0})],te.prototype,"visibleElements",void 0),e([c()],te.prototype,"_helpMessage",null),te=e([d("esri.widgets.Editor")],te);const se=te;export{se as default};
5
+ import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import{destroyMaybe as t,mappedFind as s,abortMaybe as i}from"../core/maybe.js";import{createResolver as o}from"../core/promiseUtils.js";import{watch as a,on as r,when as n,initial as l}from"../core/reactiveUtils.js";import{property as c}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/Logger.js";import"../core/RandomLCG.js";import{subclass as d}from"../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as m}from"../core/support/UpdatingHandles.js";import h from"../views/interactive/sketch/SketchValueOptions.js";import p from"./Attachments.js";import u from"./BatchAttributeForm.js";import g from"./FeatureForm.js";import w from"./FeatureTemplates.js";import _ from"./Spinner.js";import v from"./Widget.js";import{VisibleElements as f}from"./BatchAttributeForm/VisibleElements.js";import{css as y}from"./Editor/css.js";import k from"./Editor/EditorViewModel.js";import{isModelUpload as b}from"./Editor/modelUploadUtils.js";import A from"./Editor/VisibleElements.js";import{isBatchAttributeFormViewModel as F}from"./Editor/workflowUtils.js";import{loadCreateFeaturesPanelContentComponents as M,CreateFeaturesPanelContent as T}from"./Editor/components/CreateFeaturesPanelContent.js";import{loadFeatureListComponents as C,FeatureList as E}from"./Editor/components/FeatureList.js";import{loadFooterActionsComponents as W,FooterActions as P}from"./Editor/components/FooterActions.js";import{loadNoticesComponents as L,Notice as S}from"./Editor/components/Notices.js";import{loadPanelContentComponents as I,PanelContent as j,PanelContentSection as U,PanelContentMessage as D}from"./Editor/components/PanelContent.js";import{PanelToolbar as V,loadPanelToolbarComponents as B}from"./Editor/components/PanelToolbar.js";import{loadPromptComponents as O,Prompt as x}from"./Editor/components/Prompt.js";import{loadUpdateFeaturePanelContentComponents as N,UpdateFeaturePanelContent as z}from"./Editor/components/UpdateFeaturePanelContent.js";import{loadUploadDetailsComponents as H,UploadDetails as R}from"./Editor/components/UploadDetails.js";import{VisibleElements as G,CreateToolVisibilityMap as q}from"./Sketch/VisibleElements.js";import{loadCalciteComponents as Z}from"./support/componentsUtils.js";import{globalCss as K}from"./support/globalCss.js";import{incrementHeadingLevel as $,Heading as J}from"./support/Heading.js";import{renderItem as Q}from"./support/ItemList.js";import{connectDelayedLoading as X}from"./support/loaderUtils.js";import"./support/widgetUtils.js";import{messageBundle as Y}from"./support/decorators/messageBundle.js";import{vmEvent as ee}from"./support/decorators/vmEvent.js";import{tsx as te}from"./support/jsxFactory.js";import{substitute as se}from"../intl/substitute.js";const ie=Symbol("sketch-setup-handles");let oe=class extends v{constructor(e,t){super(e,t),this._batchAttributeForm=new u({visibleElements:new f({loadingIndicator:!1})}),this._featureForm=new g,this._sketchToolbar=null,this._attachments=new p({visibleElements:{addSubmitButton:!1,cancelAddButton:!1,cancelUpdateButton:!1,deleteButton:!1,errorMessage:!1,progressBar:!1,updateButton:!1}}),this._associationItemList=null,this._associationSettings=null,this._featureTemplates=new w({enableListScroll:!1,renderItemContentEnd:e=>e.supportsUpload?te("calcite-icon",{class:y.templateItemContentEnd,icon:"upload-to",key:"upload-icon"}):null,renderItemLabel:e=>e.label,renderCustomGroupContent:e=>this._renderCustomTemplateGroupContent(e)}),this._filterText="",this._prompt=null,this._spinner=new _,this._loading=!1,this._updatingHandles=new m,this.headingLevel=4,this.messages=null,this.messagesCommon=null,this.messagesTemplates=null,this.messagesFeature=null,this.supportingWidgetDefaults=null,this.viewModel=new k,this.visibleElements=new A,this._renderAttachments=()=>this._attachments.render(),this._renderFeatureForm=()=>this._featureForm.render(),this._renderBatchAttributeForm=()=>this._batchAttributeForm.render(),this._renderFeatureTemplates=()=>this._featureTemplates.render(),this._renderSketch=()=>this._sketchToolbar?te("div",{class:y.sketchContainer,key:"editor-sketch-container"},this._sketchToolbar?.render()):void 0,this._renderSelectIcon=()=>te("calcite-icon",{icon:"cursor",slot:"content-start"}),this.EditorPanel=({heading:e,key:t,selected:s},...i)=>{const{visibleElements:o}=this;return te("calcite-flow-item",{closable:!1,heading:e,headingLevel:this.headingLevel,key:t,loading:this._loading,selected:s,onCalciteFlowItemBack:this._onBack},o.zoomToButton&&this.viewModel.canZoomTo?te("calcite-action",{alignment:"center",appearance:"transparent",icon:"zoom-to-object",key:"zoom-to-button",onclick:()=>this.viewModel.zoomTo(),slot:"header-actions-end",text:this.messages.zoomTo,title:this.messages.zoomTo}):null,o.settingsMenu?te(V,{editorViewModel:this.viewModel,messagesCommon:this.messagesCommon,visibleElements:o}):null,...i)},this._showDiscardEditsPrompt=()=>{const{messages:e,activeWorkflow:t}=this,s={title:e.cancelEditTitle,message:e.cancelEditWarningMessage,yesLabel:e.discardEdits,noLabel:e.continueEditing};return"create-features"===t?.type&&b(t.data.creationInfo)?this._showPromptAndWait("success"===t.data.upload?.state?e.modelUploads.cancelPlacementPrompt:e.modelUploads.cancelUploadPrompt):"update"===t?.type&&t.activeFeatureFormViewModel?.activeAssociation?this._showPromptAndWait({...s,message:e.cancelAssociationEditWarning}):this._showPromptAndWait(s)},this._showGenericCancelPrompt=()=>{const{messages:e,messagesCommon:t}=this;return this._showPromptAndWait({title:e.cancelRequestTitle,message:e.cancelRequestWarningMessage,yesLabel:t.form.yes,noLabel:t.form.no})},this._showPrompt=e=>{this._prompt?.cancel?.(),this._prompt=e},this._clearPrompt=()=>{this._prompt=null},this._onSave=()=>{this.viewModel.saveWorkflow()},this._onDelete=()=>{const{messages:e,messagesCommon:t}=this;this._showPrompt({title:e.deleteWarningTitle,message:e.deleteWarningMessage,context:"danger",actions:{primary:{label:t.delete,action:()=>{this.deleteFeatureFromWorkflow(),this._clearPrompt()}},secondary:{label:e.keepFeature,action:this._clearPrompt}}})},this._onDeleteAssociation=()=>{const{messages:e,messagesCommon:t}=this;this._showPrompt({title:e.deleteAssociationTitle,message:e.deleteAssociationMessage,context:"danger",actions:{primary:{label:t.delete,action:()=>{this.deleteAssociationFromWorkflow(),this._clearPrompt()}},secondary:{label:e.keepAssociation,action:this._clearPrompt}}})},this._onToggleUpdateWorkflow=()=>this.viewModel.toggleUpdateWorkflow(),this._onBack=e=>(e?.stopPropagation(),this.viewModel.back()),this._onAttachmentAdd=()=>{const{activeWorkflow:e}=this.viewModel;e&&("create-features"===e.type||"update"===e.type&&"create-features"===e.activeWorkflow?.type?(this._attachments.addFile(),e.back()):this._attachments.addAttachment().then((()=>e.back())))},this._onAttachmentUpdate=()=>{const{activeWorkflow:e}=this.viewModel;e&&("create-features"===e.type?(this._attachments.updateFile(),e.back()):this._attachments.updateAttachment().then((()=>e.back())))},this._onAttachmentDelete=()=>{const{messages:e,messagesCommon:t}=this;this._showPrompt({title:e.deleteAttachmentWarningTitle,message:e.deleteAttachmentWarningMessage,context:"danger",actions:{primary:{label:t.delete,action:this._onAttachmentDeleteConfirm},secondary:{label:e.keepAttachment,action:this._clearPrompt}}})},this._onAttachmentDeleteConfirm=async()=>{const e=this._attachments,{activeWorkflow:t}=this.viewModel;t&&("create-features"===t.type?e.deleteFile():(await e.deleteAttachment(e.viewModel.activeAttachmentInfo),this._clearPrompt()),await t.back(),this._clearPrompt())},this._onAttachmentsError=e=>{this._showPrompt({title:this.messages.errorWarningTitle,message:e.message,context:"warning",actions:{primary:{label:this.messagesCommon.form.ok,action:this._clearPrompt}}})}}initialize(){this._featureForm.showPrompt=this._showPrompt,this._featureForm.clearPrompt=this._clearPrompt,this.addHandles([a((()=>$(this.headingLevel)),(e=>{this._featureForm.headingLevel=e,this._featureTemplates.headingLevel=e}),l),r((()=>this.viewModel.activeWorkflow),"cancel-request",(({controller:e})=>{(this.viewModel.hasPendingEdits?this._showDiscardEditsPrompt():this._showGenericCancelPrompt()).then((t=>t?e.allow():e.deny()))})),n((()=>this.viewModel.formViewModel),(e=>{F(e)?this._batchAttributeForm.viewModel=e:this._featureForm.viewModel=e}),l),n((()=>this.viewModel.utilityNetworkAssociationAddAssociationViewModel),(e=>{this._associationItemList?this._associationItemList.viewModel=e:this._updatingHandles.addPromise(this._initializeAssociationItemList(e))}),l),n((()=>this.viewModel.utilityNetworkAssociationAddAssociationViewModel?.association),(()=>{this._setUpAssociationSettings()})),a((()=>this.viewModel),(e=>{this._attachments.viewModel=e?.attachmentsViewModel??null,this._featureTemplates.viewModel=e?.featureTemplatesViewModel??null,this._spinner.viewModel=e?.spinnerViewModel??null,e.showDiscardEditsPrompt=this._showDiscardEditsPrompt}),l),a((()=>this.view),((e,t)=>{const s=`editor-${this.id}-spinner`;t?.ui.remove(this._spinner,s),e?.ui.add(this._spinner,{key:s,position:"manual"}),this._associationItemList&&(this._associationItemList.view=e)}),l),a((()=>[this.supportingWidgetDefaults,this.viewModel.sketchViewModel]),(([e])=>{e&&(this._featureForm.set(e.featureForm),this._attachments.set(e.attachments),this._featureTemplates.set(e.featureTemplates),this.viewModel.sketchViewModel?.set(e.sketch))}),l),n((()=>this._attachments?.error),(e=>this._onAttachmentsError(e))),n((()=>this.viewModel?.failures),(e=>{const{messages:t}=this,[{error:s,retry:i,cancel:o}]=e;this._showPrompt({title:t.errorWarningTitle,message:se(t.errorWarningMessageTemplate,{errorMessage:s.message}),context:"warning",actions:{primary:{label:t.retry,action:()=>{i(),this._clearPrompt()}},secondary:{label:t.ignore,action:()=>{o(),this._clearPrompt()}}}})})),a((()=>this.viewModel?.state),(e=>{switch(e){case"awaiting-feature-to-update":case"ready":case"disabled":this._filterText="",this._featureTemplates.filterText=""}})),a((()=>this.viewModel.featureFormDisabled),(e=>this._featureForm.disabled=e)),a((()=>this.visibleElements.sketch),(()=>this._setupSketch()),l),X({getLoading:()=>{const{viewModel:e}=this;return e.syncing||e.updating||this._attachments.submitting||this._updatingHandles.updating},setEffectiveLoading:e=>{this._loading=e}})])}destroy(){this._associationItemList?.destroy(),this._associationSettings?.destroy(),this._attachments.destroy(),this._batchAttributeForm.destroy(),this._featureForm.destroy(),this._featureTemplates.destroy(),this._sketchToolbar=t(this._sketchToolbar)}loadDependencies(){return Promise.all([Z({action:()=>import("@esri/calcite-components/dist/components/calcite-action"),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")}),M(),C(),W(),L(),I(),B(),O(),N(),H()])}get _deleteButtonCommonInfo(){return{appearance:"outline",kind:"danger"}}get activeWorkflow(){return this.viewModel.activeWorkflow}get hideTemplatesForInactiveLayers(){return this.viewModel.hideTemplatesForInactiveLayers}set hideTemplatesForInactiveLayers(e){this.viewModel.hideTemplatesForInactiveLayers=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 layerInfos(){return this.viewModel.layerInfos}set layerInfos(e){this.viewModel.layerInfos=e}get snappingOptions(){return this.viewModel.snappingOptions}set snappingOptions(e){this.viewModel.snappingOptions=e}get tooltipOptions(){return this.viewModel.tooltipOptions}set tooltipOptions(e){this.viewModel.tooltipOptions=e}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}startCreateFeaturesWorkflowAtFeatureTypeSelection(){return this.viewModel.startCreateFeaturesWorkflowAtFeatureTypeSelection()}startCreateFeaturesWorkflowAtFeatureCreation(e){return this.viewModel.startCreateFeaturesWorkflowAtFeatureCreation(e)}startCreateFeaturesWorkflowAtFeatureEdit(e){return this.viewModel.startCreateFeaturesWorkflowAtFeatureEdit(e)}startUpdateFeaturesWorkflow(e){return this.viewModel.startUpdateFeaturesWorkflow(e)}startUpdateWorkflowAtFeatureSelection(){return this.viewModel.startUpdateWorkflowAtFeatureSelection()}startUpdateWorkflowAtMultipleFeatureSelection(e){return this.viewModel.startUpdateWorkflowAtMultipleFeatureSelection(e)}startUpdateWorkflowAtFeatureEdit(e){return this.viewModel.startUpdateWorkflowAtFeatureEdit(e)}deleteFeatureFromWorkflow(){return this.viewModel.deleteFeatureFromWorkflow()}deleteAssociationFromWorkflow(){return this.viewModel.deleteAssociationFromWorkflow()}cancelWorkflow(e){return this.viewModel.cancelWorkflow(e)}render(){const{visibleElements:e,viewModel:t}=this,s=this.classes(y.base,K.widget,K.panel);if(!t)return te("div",{class:s,key:"empty"});const{pageStack:i}=t,o=i.length-1,a=i.map(((e,t)=>this._renderPage(e,t===o)));return te("div",{class:s,key:"base"},e.flow?te("calcite-flow",{inert:!!this._prompt,key:"flow"},a):a,this._prompt?te(x,{...this._prompt,headingLevel:this.headingLevel}):void 0)}_renderPage(e,t){const s={selected:t};switch(e){case"disabled":break;case"ready":return this._renderReady(s);case"awaiting-feature-creation-info":return this._renderAwaitingFeatureCreationInfo(s);case"creating-features-upload-details":return this._renderUploadDetails(s);case"creating-features":return this._renderCreatingFeatures(s);case"editing-existing-feature":case"editing-features":case"editing-attributes":return this._renderUpdateFeature(s);case"awaiting-update-feature-candidate":return this._renderFeatureList(s);case"adding-attachment":return this._renderAttachmentAdding(s);case"editing-attachment":return this._renderAttachmentEditing(s);case"viewing-associated-layers":case"viewing-associated-features":return this._renderViewAssociatedLayers(s);case"add-association-select-layer":case"add-association-select-feature":return this._renderSelectFeature(s);case"add-association-create-association":return this._renderAddAssociation(s)}return te("div",{key:"empty-page"})}_renderAwaitingFeatureCreationInfo(e){const{EditorPanel:t,messages:s}=this;return te(t,{heading:s.selectTemplate,key:"templates-panel",...e},te(j,{key:"feature-templates"},te(U,null,this._renderFeatureTemplates())))}_renderUploadDetails(e){const{EditorPanel:t,activeWorkflow:s,messages:i}=this;if("create-features"!==s?.type)return null;const o=s.data.upload;return o?te(t,{heading:i.createFeatures,key:"upload-details-panel",...e},te(R,{helpMessage:this._helpMessage,messages:i,upload:o})):null}_renderCreatingFeatures(e){const{EditorPanel:t,activeWorkflow:s,messages:i,messagesCommon:o,headingLevel:a,viewModel:r}=this;if(!s)return null;const n="create-features"===s.type&&s.numPendingFeatures>0||"update"===s.type&&"create-features"===s?.activeWorkflow?.type&&s.activeWorkflow?.numPendingFeatures>0;return te(t,{heading:i.createFeatures,key:"create-features-panel",...e},n?te(z,{editorViewModel:r,headingLevel:a,messages:i,messagesCommon:o,renderAttachments:this._renderAttachments,renderBatchAttributeForm:this._renderBatchAttributeForm,renderFeatureForm:this._renderFeatureForm,renderSketchToolbar:this._renderSketch,onDelete:this._onDelete,onDeleteAssociation:this._onDeleteAssociation,onSave:this._onSave}):te(T,{helpMessage:this._helpMessage,renderSketchToolbar:this._renderSketch}))}_renderUpdateFeature(e){const{EditorPanel:t,messages:s,messagesCommon:i,headingLevel:o,viewModel:a}=this;return te(t,{heading:s.editFeature,key:"update-feature-panel",...e},te(z,{editorViewModel:a,headingLevel:o,messages:s,messagesCommon:i,renderAttachments:this._renderAttachments,renderBatchAttributeForm:this._renderBatchAttributeForm,renderFeatureForm:this._renderFeatureForm,onDelete:this._onDelete,onDeleteAssociation:this._onDeleteAssociation,onSave:this._onSave}))}_getAssociationTypeTitle(e){const{messages:t}=this;if(!e)return t.editFeature;if(e.title)return e.title;const{messagesFeature:s}=this;switch(e.type){case"attachment":return s.associationsAttachments;case"connectivity":return s.associationsConnectivity;case"structure":return s.associationsStructure;case"content":return s.associationsContents;case"container":return s.associationsContainer}}_getAddAssociationTypeTitle(e){const{messages:t}=this;if(!e)return t.editFeature;const s=t.associations;switch(e.type){case"attachment":return s.addAttachment;case"connectivity":return s.addConnectivity;case"structure":return s.addStructure;case"content":return s.addContent;case"container":return s.addContainer}}async _initializeAssociationItemList(e){const t=(await import("./FeatureForm/FeatureFormUtilityNetworkAssociations/UtilityNetworkAssociationItemList.js")).default;this._associationItemList=new t({view:this.view,viewModel:e})}async _initializeAssociationSettings(){const e=new(0,(await import("./FeatureForm/FeatureFormUtilityNetworkAssociations/UtilityNetworkAssociationSettings.js")).default);return this._associationSettings=e,e}_renderViewAssociatedLayers(e){const{EditorPanel:t,messages:s,messagesCommon:i,headingLevel:o,viewModel:a}=this,r=a.featureFormViewModel?.activeAssociationInput?.activeAssociationType,n=this._getAssociationTypeTitle(r);return te(t,{heading:n,key:"viewing-associated-layers-panel",...e},te(z,{editorViewModel:a,headingLevel:o,messages:s,messagesCommon:i,renderAttachments:this._renderAttachments,renderBatchAttributeForm:this._renderBatchAttributeForm,renderFeatureForm:this._renderFeatureForm,renderSketchToolbar:this._renderSketch,onDelete:this._onDelete,onDeleteAssociation:this._onDeleteAssociation,onSave:this._onSave}))}_renderSelectFeature(e){const{_associationItemList:t,EditorPanel:s,viewModel:i,messagesCommon:o}=this,a=i.utilityNetworkAssociationAddAssociationViewModel,r=this._getAddAssociationTypeTitle(a?.associationType),n="ready"!==a?.state;return t?te(s,{heading:r,key:"add-association-select-feature",...e},te(j,{key:"select-feature"},te(U,null,t.render())),te(P,{buttons:[t.filterOptionsVisible?{appearance:"solid",label:o.apply,disabled:n,onClick:()=>t.applyFilterOptions(),type:"button"}:void 0,{appearance:"outline",label:o.cancel,disabled:n,onClick:()=>{"update"===i.activeWorkflow?.type&&(a?.reset(),i.activeWorkflow.cancelActiveWorkflow())},type:"button"}]})):te(s,{heading:r,key:"add-association-select-feature",...e})}async _setUpAssociationSettings(){const{viewModel:e}=this,t=this._associationSettings??await this._updatingHandles.addPromise(this._initializeAssociationSettings()),s=e.utilityNetworkAssociationAddAssociationViewModel,i="update"===e.activeWorkflow?.type?e.activeWorkflow:null,o=i?i.activeWorkflow:null,a="add-association"===o?.type?o.sourceFeatureItem:null,r=s?.selectedFeature,n=s?.association,l=s?.utilityNetwork;a&&r&&n&&l&&(t.sourceFeature=a,t.targetFeature=r,t.association=n,t.utilityNetwork=l)}_renderAddAssociation(e){const{_associationSettings:t,EditorPanel:s,viewModel:i,messagesCommon:o}=this;if(!t)return null;const a=i.utilityNetworkAssociationAddAssociationViewModel,r=this._getAddAssociationTypeTitle(a?.associationType),n="ready"!==a?.state;return te(s,{heading:r,key:"add-association",...e},te(j,{key:"add-association-content"},te(U,null,t.render())),te(P,{buttons:[{label:o.add,disabled:n||!a.canAddAssociation,onClick:()=>this._onSave(),type:"button"},{appearance:"outline",label:o.cancel,disabled:n,onClick:()=>{"update"===i.activeWorkflow?.type&&i.activeWorkflow.cancelActiveWorkflow()},type:"button"}]}))}_renderCustomTemplateGroupContent(e){const{messages:t,viewModel:i}=this,o=s(e.group.items,(e=>i.itemHasInvalidFormTemplate(e)?t.formFieldCreateError:void 0));return o?te(S,{kind:"warning",message:o}):null}_renderAttachmentAdding(e){const{EditorPanel:t,_attachments:s,messages:i,messagesCommon:o}=this;return te(t,{heading:i.addAttachment,key:"attachment-adding-panel",...e},te(j,{key:"attachments"},this._renderAttachments()),te(P,{buttons:[{label:s.submitting?o.cancel:o.add,disabled:s.submitting||!s.selectedFile,onClick:this._onAttachmentAdd,type:"button"}]}))}_renderAttachmentEditing(e){const{EditorPanel:t,_attachments:s,activeWorkflow:i,messages:o,messagesCommon:a}=this;return i?te(t,{heading:o.editAttachment,key:"attachment-editing-panel",...e},te(j,{key:"attachments"},this._renderAttachments()),i.shouldAllowAttachmentEditing?te(P,{buttons:[{label:a.update,disabled:s.submitting||!s.selectedFile,onClick:this._onAttachmentUpdate,type:"button"},{...this._deleteButtonCommonInfo,onClick:this._onAttachmentDelete,disabled:s.submitting,label:a.delete,type:"button"}]}):void 0):null}_renderReady(e){const{EditorPanel:t,messages:s,viewModel:i,visibleElements:o}=this,a=this._helpMessage;return te(t,{heading:s.widgetLabel,key:"landing-panel",...e},te(j,{key:"landing-content"},i.editorItems.length?[o.editFeaturesSection?te(U,{key:"edit-actions"},this._renderUpdateActions()):null,o.createFeaturesSection&&i.canCreateVisible?te(U,{key:"create-actions"},this._renderCreateActions()):null]:te(D,{key:"no-content"},s.noEditableLayers)),a?te("div",{class:y.helpMessage,key:"footer-actions",slot:"footer"},a):void 0)}get _helpMessage(){const{activeWorkflow:e,messages:t,view:s}=this,i=e?.helpMessage;return i?t["3d"===s?.type?"helpMessages3d":"helpMessages2d"]?.[i]:void 0}_renderUpdateActions(){const{messages:e,messagesCommon:t,viewModel:s}=this,i={id:"select",label:t.select};return te("div",{class:y.updateActions,key:"update-actions"},te(J,{level:$(this.headingLevel)},e.editFeatures),te("calcite-list",{class:y.updateActionsList,label:e.editFeaturesList,selectionAppearance:"border",selectionMode:"single"},Q({disabled:!s.canUpdateVisible,grouped:!1,item:i,selectedItem:"awaiting-feature-to-update"===s.activeWorkflow?.stepId?i:void 0,renderIcon:this._renderSelectIcon,onItemSelect:this._onToggleUpdateWorkflow})))}_renderCreateActions(){return te("div",{key:"create-actions"},te(J,{level:$(this.headingLevel)},this.messages.createFeatures),te("div",{class:y.featureTemplatesContainer,key:"templates"},this._renderFeatureTemplates()))}_renderFeatureList(e){const{EditorPanel:t,viewModel:s}=this,{activeWorkflow:i}=s;if("update"!==i?.type)return null;const o=i.data.candidates,a=se(this.messages.multipleFeaturesTemplate,{total:o.length});return te(t,{heading:a,key:"feature-list",...e},te(E,{editorItems:s.editorItems,editorMessages:this.messages,filterText:this._filterText,id:this.id,messagesTemplates:this.messagesTemplates,workflow:i,onFilterTextChange:e=>this._filterText=e,onSelectFeature:(e,t)=>s.selectFeature(e,t),onZoomTo:e=>s.zoomTo(e)}))}_showPromptAndWait({title:e,message:t,yesLabel:s,noLabel:i}){const a=o(),{view:r}=this,n=r?.focused;return this._showPrompt({title:e,message:t,context:"danger",actions:{primary:{label:s,action:()=>a.resolve(!0)},secondary:{label:i,action:()=>a.resolve(!1)}}}),a.promise.finally((()=>{this._clearPrompt(),n&&r?.focus()}))}async _setupSketch(){if(!!!this.visibleElements.sketch)return this._sketchImportAbortController=i(this._sketchImportAbortController),this._sketchToolbar=t(this._sketchToolbar),void this.removeHandles(ie);if(this._sketchImportAbortController)return;const e=new AbortController;this._sketchImportAbortController=e;const s=await import("./Sketch.js");if(!e.signal.aborted)try{this._sketchToolbar=new s.default({toolbarKind:"docked",contextualToolLocation:"inline-end",scale:"s",visibleElements:new G({deleteButton:!1,settingsMenu:!1,directionModePicker:!1,selectionCountLabel:!1,duplicateButton:!1,createTools:new q({freehandPolygon:!0,freehandPolyline:!0})})}),this.addHandles([a((()=>this.viewModel.activeLeafWorkflow?.availableCreateTools),(e=>{this._sketchToolbar&&(this._sketchToolbar.availableCreateTools=e)}),l),a((()=>this.visibleElements.undoRedoButtons),(e=>{this._sketchToolbar&&(this._sketchToolbar.visibleElements.undoRedoMenu=e)}),l),n((()=>this.viewModel?.sketchViewModel),(e=>{this._sketchToolbar&&(this._sketchToolbar.viewModel=e)}),l)],ie)}finally{this._sketchImportAbortController=null}}get test(){return{sketch:this._sketchToolbar,showPrompt:this._showPromptAndWait.bind(this)}}};e([c()],oe.prototype,"_batchAttributeForm",void 0),e([c()],oe.prototype,"_featureForm",void 0),e([c()],oe.prototype,"_sketchToolbar",void 0),e([c()],oe.prototype,"_attachments",void 0),e([c()],oe.prototype,"_associationItemList",void 0),e([c()],oe.prototype,"_associationSettings",void 0),e([c()],oe.prototype,"_featureTemplates",void 0),e([c()],oe.prototype,"_filterText",void 0),e([c()],oe.prototype,"_prompt",void 0),e([c()],oe.prototype,"_spinner",void 0),e([c()],oe.prototype,"_deleteButtonCommonInfo",null),e([c()],oe.prototype,"_loading",void 0),e([c({readOnly:!0})],oe.prototype,"activeWorkflow",null),e([c()],oe.prototype,"headingLevel",void 0),e([c()],oe.prototype,"hideTemplatesForInactiveLayers",null),e([c()],oe.prototype,"icon",null),e([c()],oe.prototype,"label",null),e([c()],oe.prototype,"labelOptions",null),e([c()],oe.prototype,"layerInfos",null),e([c(),Y("esri/widgets/Editor/t9n/Editor")],oe.prototype,"messages",void 0),e([c(),Y("esri/t9n/common")],oe.prototype,"messagesCommon",void 0),e([c(),Y("esri/widgets/FeatureTemplates/t9n/FeatureTemplates")],oe.prototype,"messagesTemplates",void 0),e([c(),Y("esri/widgets/Feature/t9n/Feature")],oe.prototype,"messagesFeature",void 0),e([c()],oe.prototype,"snappingOptions",null),e([c()],oe.prototype,"tooltipOptions",null),e([c()],oe.prototype,"supportingWidgetDefaults",void 0),e([c({type:h,nonNullable:!0})],oe.prototype,"valueOptions",null),e([c()],oe.prototype,"view",null),e([c(),ee(["sketch-create","sketch-delete","sketch-update","workflow-cancel","workflow-commit"])],oe.prototype,"viewModel",void 0),e([c({type:A,nonNullable:!0})],oe.prototype,"visibleElements",void 0),e([c()],oe.prototype,"_helpMessage",null),oe=e([d("esri.widgets.Editor")],oe);const ae=oe;export{ae 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 s}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 t from"../Widget.js";import{css as o}from"./searchResultRendererCSS.js";import l from"./SearchViewModel.js";import{globalCss as i}from"../support/globalCss.js";import{accessibleHandler as u}from"../support/decorators/accessibleHandler.js";import{messageBundle as n}from"../support/decorators/messageBundle.js";import{tsx as c}from"../support/jsxFactory.js";import"../support/widgetUtils.js";let d=class extends t{constructor(e,s){super(e,s),this.messages=null,this.showMoreResultsOpen=!1,this.viewModel=null}destroy(){this.viewModel=null}render(){const e={[o.showMoreResults]:this.showMoreResultsOpen};return c("div",{class:this.classes(o.base,i.widget)},c("div",{class:this.classes(o.moreResults,e),key:"esri-search-renderer__container"},this._renderSearchResultName(),this._renderMoreResults()))}_renderMoreResults(){return c("div",{key:"esri-search-renderer__more-results"},this._renderMoreResultsButton(),this._renderMoreResultsLists())}_renderSearchResultName(){const e=this.viewModel?.selectedResult,s=e?.name||"";return c("div",{class:o.moreResultsItem,key:"esri-search-renderer__result-name"},s)}_renderMoreResultsLists(){const{viewModel:e}=this;if(!e)return[];const s=e.results;if((e.resultCount??0)<2)return null;const r=s?.map((e=>this._renderMoreResultsList(e)));return c("div",{class:o.moreResultsList,key:"esri-search-renderer__more-results-container"},r)}_renderMoreResultsButton(){const{messages:e,viewModel:s}=this;if(!s)return null;return(s.resultCount??0)<2?null:c("div",{class:o.moreResultsItem,key:"esri-search-renderer__more-results-button"},c("a",{bind:this,class:i.anchor,href:"#",onclick:this._showMoreResultsClick,onkeydown:this._showMoreResultsClick},this.showMoreResultsOpen?e.hideMoreResults:e.showMoreResults))}_renderMoreResultsHeader(e,s){return c("div",{class:o.moreResultsListHeader,key:`esri-search-result-renderer__header-${s}`},e)}_renderMoreResultsList(e){const{results:s}=e,r=s?.length??0,t=r>0,o=this.viewModel?.selectedResult,l=1===r&&s[0]===o,i=this._getSourceName(e.source,e.sourceIndex),u=(this.viewModel?.results?.length??0)>1&&!l?this._renderMoreResultsHeader(i,e.sourceIndex):null,n=t&&s.map(((e,s)=>this._renderMoreResultsListItem(e,s))),d=t&&!l?c("ul",{key:`esri-search-result-renderer__list-${e.sourceIndex}`},n):null;return t?c("div",{key:`esri-search-result-renderer__results-${e.sourceIndex}`},u,d):null}_renderMoreResultsListItem(e,s){const r=this.viewModel?.selectedResult;return e!==r?c("li",{key:`esri-search-result-renderer__list-item-${s}`},c("a",{bind:this,class:i.anchor,"data-result":e,href:"#",onclick:this._selectResultClick,onkeydown:this._selectResultClick,tabIndex:0},e.name)):null}_showMoreResultsClick(e){e.preventDefault(),this.showMoreResultsOpen=!this.showMoreResultsOpen;const s=this.viewModel?.view?.popup;s&&"reposition"in s&&s.reposition()}_selectResultClick(e){e.preventDefault();const s=e.currentTarget["data-result"];this.viewModel?.select(s)}_getSourceName(e,s){return s===l.ALL_INDEX?this.messages.all:e.name}};e([s(),n("esri/widgets/Search/t9n/Search")],d.prototype,"messages",void 0),e([s()],d.prototype,"showMoreResultsOpen",void 0),e([s()],d.prototype,"viewModel",void 0),e([u()],d.prototype,"_showMoreResultsClick",null),e([u()],d.prototype,"_selectResultClick",null),d=e([r("esri.widgets.Search.SearchResultRenderer")],d);const a=d;export{a as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import"../../intl.js";import{property as s}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as t}from"../../core/accessorSupport/decorators/subclass.js";import o from"../Widget.js";import{css as r}from"./searchResultRendererCSS.js";import i from"./SearchViewModel.js";import{loadCalciteComponents as l}from"../support/componentsUtils.js";import{globalCss as c}from"../support/globalCss.js";import"../support/widgetUtils.js";import{messageBundle as n}from"../support/decorators/messageBundle.js";import{tsx as p}from"../support/jsxFactory.js";import{substitute as u}from"../../intl/substitute.js";let m=class extends o{constructor(e,s){super(e,s),this.messages=null,this.showMoreResultsOpen=!1,this.viewModel=null}loadDependencies(){return l({block:()=>import("@esri/calcite-components/dist/components/calcite-block"),list:()=>import("@esri/calcite-components/dist/components/calcite-list"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item"),"list-item-group":()=>import("@esri/calcite-components/dist/components/calcite-list-item-group")})}destroy(){this.viewModel=null}render(){return p("div",{class:this.classes(r.base,c.widget)},this.viewModel?.selectedResult?.name??"",this._renderMoreResults())}_renderMoreResults(){if(!this.viewModel)return null;const{resultCount:e,results:s}=this.viewModel;return!e||e<2||!s?null:p("calcite-block",{class:r.moreResults,collapsible:!0,expanded:this.showMoreResultsOpen,heading:u(this.messages.showMoreResults,{count:e-1}),onCalciteBlockClose:()=>this._toggleShowMoreResults(!1),onCalciteBlockOpen:()=>this._toggleShowMoreResults(!0)},s.map((e=>this._renderMoreResultsList(e,s?.length>1))))}_renderListItem(e){return p("calcite-list-item",{key:`result-${e.sourceIndex}-${e.key}`,label:e.name,onCalciteListItemSelect:()=>this._selectResult(e)})}_renderMoreResultsList(e,s){const{results:t}=e;if(!(t?.length??0)||!t)return null;const o=this.viewModel?.selectedResult,r=this._getSourceName(e.source,e.sourceIndex),i=t.filter((e=>e!==o)).map((e=>this._renderListItem(e)));return p("calcite-list",{label:r},s?p("calcite-list-item-group",{heading:r,key:`group-${e.sourceIndex}`},i):i)}_selectResult(e){this.showMoreResultsOpen=!1,this.viewModel?.select(e)}_toggleShowMoreResults(e){this.showMoreResultsOpen=e;const s=this.viewModel?.view?.popup;s&&"reposition"in s&&s.reposition()}_getSourceName(e,s){return s===i.ALL_INDEX?this.messages.all:e.name}};e([s(),n("esri/widgets/Search/t9n/Search")],m.prototype,"messages",void 0),e([s()],m.prototype,"showMoreResultsOpen",void 0),e([s()],m.prototype,"viewModel",void 0),m=e([t("esri.widgets.Search.SearchResultRenderer")],m);const a=m;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{getAssetUrl as t}from"../../assets.js";import r from"../../config.js";import s from"../../Graphic.js";import o from"../../PopupTemplate.js";import i from"../../core/Accessor.js";import{isSome as l}from"../../core/arrayUtils.js";import a from"../../core/Collection.js";import n from"../../core/Error.js";import u from"../../core/Evented.js";import c from"../../core/Logger.js";import{mappedFind as h}from"../../core/maybe.js";import{eachAlways as p,after as g}from"../../core/promiseUtils.js";import{watch as d,initial as m,whenOnce as y}from"../../core/reactiveUtils.js";import{property as f}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import{subclass as S}from"../../core/accessorSupport/decorators/subclass.js";import _ from"../../geometry/Point.js";import v from"../../geometry/SpatialReference.js";import{getPointFromGeometry as w,getPointWithElevation as b}from"../../geometry/support/geometryUtils.js";import{onLocaleChange as x}from"../../intl/locale.js";import{fetchMessageBundle as L}from"../../intl/messages.js";import I from"../../portal/Portal.js";import T from"../../symbols/PictureMarkerSymbol.js";import R from"../../symbols/SimpleFillSymbol.js";import E from"../../symbols/SimpleLineSymbol.js";import F from"../../symbols/TextSymbol.js";import{highlightsSupported as j}from"../../views/support/layerViewUtils.js";import P from"./LayerSearchSource.js";import C from"./LocatorSearchSource.js";import G from"./SearchSource.js";import{isArcGISWorldGeocoder as O,meteredArcGISLocatorUrl as A,isProxiedArcGISWorldGeocoder as N,isMeteredArcGISWorldGeocoder as D}from"./support/locatorUtils.js";import{supported as M,getCurrentPosition as V,positionToPoint as k}from"../support/geolocationUtils.js";import J from"../support/GoTo.js";function H(e,t){return e.hasOwnProperty(t)&&null!=e[t]&&""!==e[t]}const U=()=>L("esri/widgets/Search/t9n/Search"),B="highlight",Q=a.ofType({key:e=>e.layer?"layer":"locator",base:G,typeMap:{layer:P,locator:C}}),Z=v.WGS84,q="esri/images/search/search-symbol-32.png",z=/<[\s\S]*?>/g,K=-1;let W=class extends(J(u.EventedMixin(i))){constructor(e){super(e),this._gotoController=null,this._searching=null,this._updatingPromise=null,this._createdFeatureLayers=[],this.autoNavigate=!0,this.autoSelect=!0,this.defaultPopupTemplate=null,this.defaultSources=new Q,this.defaultSymbols={point:new T({url:t(q),size:24,width:24,height:24}),polyline:new E({color:[130,130,130,1],width:2}),polygon:new R({color:[235,235,235,.4],outline:{color:[130,130,130,1],width:2}})},this.includeDefaultSources=!0,this.maxInputLength=128,this.maxResults=6,this.maxSuggestions=6,this.messages=null,this.minSuggestCharacters=3,this.popupEnabled=!0,this.popupTemplate=null,this.portal=I.getDefault(),this.resultCount=null,this.resultGraphicEnabled=!0,this.resultGraphic=null,this.results=null,this.selectedSuggestion=null,this.searchAllEnabled=!0,this.selectedResult=null,this.sources=new Q,this.suggestionDelay=350,this.suggestionCount=null,this.suggestions=null,this.suggestionsEnabled=!0,this.view=null}initialize(){const e=async()=>{const e=await U();this.messages=e,this.defaultPopupTemplate=new o({title:e.searchResult,content:"{Match_addr}"})};e(),this.addHandles([d((()=>[this.includeDefaultSources,this.view,this.portal]),(()=>this._update()),m),x(e)])}destroy(){this._destroyFeatureLayers(),this._abortGoTo(),this.clearGraphics()}static{this.ALL_INDEX=K}get activeSource(){return this.allSources.at(this.activeSourceIndex)??null}get activeSourceIndex(){return 1===this.allSources.length||!this.searchAllEnabled?0:K}set activeSourceIndex(e){this._overrideIfSome("activeSourceIndex",e)}get allPlaceholder(){return this.messages?.allPlaceholder}set allPlaceholder(e){this._overrideIfSome("allPlaceholder",e)}get allSources(){const{sources:e,defaultSources:t,includeDefaultSources:r}=this,s="function"==typeof r?r.call(null,{sources:e,defaultSources:t}):r?t.concat(e):e,o=this._get("allSources")||new Q;return o.removeAll(),o.addMany(s.filter(Boolean)),o}get locationEnabled(){return this._get("locationEnabled")||M()}set locationEnabled(e){if(void 0===e)return void this._clearOverride("locationEnabled");const t=M();if(e&&!t){const e=new n("locationEnabled:geolocation-unsupported","Geolocation API is unsupported.",{geolocation:navigator.geolocation});c.getLogger(this).error(e)}this._override("locationEnabled",!!e&&t)}get placeholder(){const{allSources:e,activeSourceIndex:t,allPlaceholder:r}=this;if(t===K)return r??"";const s=e.at(t);return s?.placeholder??""}set searchTerm(e){this._set("searchTerm",e||""),this.clearGraphics(),this.selectedSuggestion&&this.selectedSuggestion.text!==e&&this._set("selectedSuggestion",null),""===e&&this._clear()}get searchTerm(){return this._get("searchTerm")||""}get state(){return this._searching?"searching":this.updating?"loading":0===this.allSources.length?"disabled":"ready"}get updating(){return null!=this._updatingPromise}clear(){this.searchTerm=""}clearGraphics(){this._removeHighlight(),this._closePopup();const{view:e,resultGraphic:t}=this;e&&t&&e.graphics.remove(t),this._set("resultGraphic",null)}search(e,t){this.emit("search-start"),this.clearGraphics();const r=this._createSuggestionForSearch(e),s=(async()=>{try{await this.when();const e=await this._getResultsFromSources(r,t);if(t?.signal?.aborted)return null;const s={activeSourceIndex:this.activeSourceIndex,searchTerm:r.text??"",numResults:0,numErrors:0,errors:[],results:[]};this._formatResponse(s,e,r);const o=this._getFirstResult(s.results),i=r.location&&o?o.name:r.text,l=i?.replace(z,"");return this._set("searchTerm",l),(r.key&&"number"==typeof r.sourceIndex||r.location)&&this._set("selectedSuggestion",r),this._set("results",s.results),this._set("resultCount",s.results.reduce(((e,t)=>e+(t.results?.length??0)),0)),this.emit("search-complete",s),await this._selectFirstResult(o),s}finally{this._clearSearching()}})();return this._searching=s,s}async searchNearby(e){if(!this.locationEnabled){const e=new n("searchNearby:geolocation-unsupported","Geolocation API is unsupported.",{geolocation:navigator.geolocation});throw c.getLogger(this).error(e),e}const t=(async()=>{try{const t=await V(),r=await k({position:t,view:this.view},e);return await this.search(r,e)}finally{this._clearSearching()}})();return this._searching=t,t}async select(e){if(this.clearGraphics(),!e){const t=new n("select:missing-parameter","Cannot select without a searchResult.",{searchResult:e});throw c.getLogger(this).error(t),t}const{view:t}=this,r=H(e,"sourceIndex")?e.sourceIndex:this._getSourceIndexOfResult(e),o=null!=r?this.allSources.at(r):null;if(!o){const e=new n("select:missing-source","Cannot select without a source.",{source:o});throw c.getLogger(this).error(e),e}const i=o instanceof P?this._getLayerSourcePopupTemplate(o):o.popupTemplate,l=o.resultSymbol||this._getDefaultSymbol(e),a=H(o,"resultGraphicEnabled")?o.resultGraphicEnabled:this.resultGraphicEnabled,u=H(o,"autoNavigate")?o.autoNavigate:this.autoNavigate,h=H(o,"popupEnabled")?o.popupEnabled:this.popupEnabled,g=h?i||this.popupTemplate||this.defaultPopupTemplate:null,{feature:d}=e;if(!d){const e=new n("select:missing-feature","Cannot select without a feature.",{feature:d});throw c.getLogger(this).error(e),e}const{attributes:m,geometry:y,layer:f,sourceLayer:S}=d,_=y?w(y):null,v={layerViewQuery:this._getLayerView(d),elevationQuery:t&&null!=_?b(_,t):Promise.resolve(_)},x=await p(v),L=x.layerViewQuery.value,I=x.elevationQuery.value;l instanceof F&&(l.text=e.name);const T=t&&u?e.target||e.extent:null,R=null!=T?this._goToSearchResult(T):Promise.resolve();await R;const E=L?d:new s({geometry:y,symbol:l,attributes:m,layer:f,sourceLayer:S,popupTemplate:g}),C=t?.popup,G=C&&h&&E.getEffectivePopupTemplate(C.defaultPopupTemplateEnabled);return G&&await t.openPopup({features:[E],location:I}),L&&j(L)&&!G&&this._highlightFeature({graphic:E,layerView:L}),!L&&a&&t&&t.graphics.push(E),this._setResultFloor(e),this._set("selectedResult",e),this._set("resultGraphic",E),this.emit("select-result",{result:e,source:o,sourceIndex:r}),e}async suggest(e,t,r){const s=e||this.searchTerm;this.emit("suggest-start",{searchTerm:s}),await this._suggestTimer(t,r);const o=await this._suggestImmediate(s,r);return this._set("suggestions",o?.results),this._set("suggestionCount",o?.results.reduce(((e,t)=>e+(t.results?.length??0)),0)??null),this.emit("suggest-complete",o),o}async when(){await y((()=>!this.updating))}async _update(){const{portal:e,view:t}=this;if(this.includeDefaultSources){const r=this._updatingPromise=p([e?.load(),t?.when()]);if(this.destroyed)return;if(await r,r!==this._updatingPromise)return}await y((()=>this.messages)),this.destroyed||this._updateDefaultSources(),this._updatingPromise=null}_clearSearching(){this._searching=null}_convertHelperServices(){const e=this.portal?.helperServices?.geocode;if(!e)return[];return e.map((e=>{if(!1===e.placefinding)return;const t=r.apiKey&&O(e.url)?{url:A}:null,s=C.fromJSON({...e,...t}),o=s.url;if(O(o)||N(o)||D(o)){const e=s.outFields??["Addr_type","Match_addr","StAddr","City"],t=(s.placeholder||this.messages?.placeholder)??"",r="number"==typeof s.defaultZoomScale?s.defaultZoomScale:2500;s.singleLineFieldName="SingleLine",s.outFields=e,s.placeholder=t,s.defaultZoomScale=r}return s.singleLineFieldName?s:void 0})).filter(l)}_destroyFeatureLayers(){this._createdFeatureLayers.forEach((e=>e?.destroy())),this._createdFeatureLayers=[]}_getLayerSources(e,t){const r=this.view?.map;return e.map((e=>{const s=r.findLayerById(e.id);if(!s)return;const o=this._getLayerJSON(e),i=P.fromJSON(o);return i.placeholder=t,this._getLayer(s,o).then((e=>{i.layer=e})),i})).filter(l).toArray()}_getTableSources(e,t){const r=this.view?.map;return e.map((e=>{if(!e.id)return;const s=r.findTableById(e.id);if(!s)return;const o=this._getLayerJSON(e),i=P.fromJSON(o);return i.placeholder=t,this._getLayer(s,o).then((e=>{i.layer=e})),i})).filter(l).toArray()}_convertApplicationProperties(){const e=this.view?.map,t=e?.applicationProperties?.viewing?.search;if(!t)return[];const{enabled:r,hintText:s,layers:o,tables:i}=t;if(!r)return[];return[...this._getLayerSources(o,s),...this._getTableSources(i,s)]}async _getSubLayer(e,t){if(await e.load(),!e.allSublayers)throw new Error;const r=e.allSublayers.find((e=>e.id===t.subLayer));if(!r)throw new Error;const s=await(r.createFeatureLayer?.());if(!s)throw new Error;return this._createdFeatureLayers.push(s),s}async _getBuildingSubLayer(e,t){await e.load();const r=e.allSublayers.find((e=>e.id===t.subLayer));if("building-component"!==r?.type)throw new Error;if(await r.load(),null==r.associatedLayer)throw new Error;return await r.associatedLayer.load(),r}async _getLayer(e,t){if("feature"===e.type||"scene"===e.type||"csv"===e.type||"geojson"===e.type||"ogc-feature"===e.type)return e;if("map-image"===e.type)try{return await this._getSubLayer(e,t)}catch(r){const t=new n("search:create-featurelayer","Could not create a FeatureLayer from the MapImageLayer",{layer:e});return c.getLogger(this).error(t),null}return"building-scene"===e.type?this._getBuildingSubLayer(e,t):null}_getLayerJSON(e){return"function"==typeof e.toJSON?e.toJSON():e}_updateDefaultSources(){const{defaultSources:e,includeDefaultSources:t}=this;this._destroyFeatureLayers(),e.removeAll(),t&&e.addMany([...this._convertApplicationProperties(),...this._convertHelperServices()])}_abortGoTo(){this._gotoController&&this._gotoController.abort(),this._gotoController=null}_clear(){this._abortGoTo(),this._set("resultCount",null),this._set("results",null),this._set("suggestions",null),this._set("suggestionCount",null),this._set("selectedResult",null),this._set("selectedSuggestion",null),this.emit("search-clear")}_closePopup(){const e=this.view?.popup,{resultGraphic:t}=this;if(!e||!t)return;const r="selectedFeature"in e,s=r?e.selectedFeature:null;r&&(s&&s===t)&&e.close()}_suggestTimer(e,t){const r=null!=e?e:this.suggestionDelay;return g(r,null,t?.signal)}_createLocationForSearch(e){return e instanceof s&&e.geometry?w(e.geometry):e instanceof _?e:Array.isArray(e)&&2===e.length?new _({longitude:e[0],latitude:e[1]}):null}_createSuggestionForSearch(e){if(e&&H(e,"key")&&H(e,"text")&&H(e,"sourceIndex"))return e;const t=this._createLocationForSearch(e),r="string"==typeof e?e:this.searchTerm,{selectedSuggestion:s,selectedResult:o}=this,i=!e&&s&&o,l=i&&s.key===o.key&&s.sourceIndex===o.sourceIndex,a=i&&s.location;return l||a?s:{location:t,text:t?"":r,sourceIndex:null,key:null}}_getFirstResult(e){return h(e,(({results:e})=>e?.[0]))??null}async _selectFirstResult(e){return this.autoSelect&&e?this.select(e):null}async _suggestImmediate(e,t){await this.when();const r=await this._getSuggestionsFromSources(e,t);if(t?.signal?.aborted)return null;const s={activeSourceIndex:this.activeSourceIndex,searchTerm:e??"",numResults:0,numErrors:0,errors:[],results:[]};return this._formatResponse(s,r),s}_formatSourceResponse(e,t,r){const s=t?.value||[],o=t?.error,i=this.allSources.at(r);if(o){const t={sourceIndex:r,source:i,error:o};e.errors.push(t),c.getLogger(this).error(o),e.numErrors++}else{const t={sourceIndex:r,source:i,results:s};e.results.push(t),e.numResults+=s.length}}_formatResponse(e,t,r){if(t)if(e.activeSourceIndex===K){const s=r&&H(r,"sourceIndex")&&-1!==r.sourceIndex?r.sourceIndex:void 0;t.forEach(((t,r)=>{const o=void 0!==s?s:r;this._formatSourceResponse(e,t,o)}))}else this._formatSourceResponse(e,t[0],e.activeSourceIndex)}async _getResultsFromSources(e,t){const{allSources:r}=this,s=!e.location&&H(e,"sourceIndex")?e.sourceIndex:this.activeSourceIndex,o=[];if(!r.length){const e=new n("search:no-sources-defined","At least one source is required.",{allSources:r});throw c.getLogger(this).error(e),e}return s===K?r.forEach(((r,s)=>{o.push(this._getResultsFromSource(e,s,t))})):o.push(this._getResultsFromSource(e,s,t)),p(o)}async _getSuggestionsFromSources(e,t){const{allSources:r,activeSourceIndex:s}=this,o=[];if(!r.length){const e=new n("suggest:no-sources-defined","At least one source is required.",{allSources:r});throw c.getLogger(this).error(e),e}return s===K?r.forEach(((r,s)=>{o.push(this._getSuggestionsFromSource(e,s,t))})):o.push(this._getSuggestionsFromSource(e,s,t)),p(o)}async _getResultsFromSource(e,t,r){const s=null!=t?this.allSources.at(t):null;if(!s)return null;const{location:o=null}=e,i=this.view?.spatialReference||Z,l=H(s,"maxResults")?s.maxResults:this.maxResults,a=!!(s instanceof P&&H(s,"exactMatch"))&&s.exactMatch,{view:n}=this;return s.getResults?.({view:n,sourceIndex:t,location:o,suggestResult:e,spatialReference:i,exactMatch:a,maxResults:l},r)}async _getSuggestionsFromSource(e,t,r){const s=this.allSources.at(t);if(!s)return null;e??="";const o=H(s,"suggestionsEnabled")?s.suggestionsEnabled:this.suggestionsEnabled,i=e?.length,l=H(s,"minSuggestCharacters")?s.minSuggestCharacters:this.minSuggestCharacters;if(o&&e.trim()&&i>=l){const o=this.view?.spatialReference||Z,i=H(s,"maxSuggestions")?s.maxSuggestions:this.maxSuggestions,{view:l}=this,a=!!(s instanceof P&&H(s,"exactMatch"))&&s.exactMatch;return s.getSuggestions?.({view:l,sourceIndex:t,suggestTerm:e,spatialReference:o,maxSuggestions:i,exactMatch:a},r)}return null}_getLayerSourcePopupTemplate(e){const{layer:t}=e;if(t)return H(e,"popupTemplate")?e.popupTemplate:t.popupTemplate}_getSourceIndexOfResult(e){return h(this.results??[],(({results:t,sourceIndex:r})=>{const s=t?.includes(e);return s?r:null}))??null}async _goToSearchResult(e){this._abortGoTo();const t=new AbortController;this._gotoController=t;const r={target:{target:e},options:{signal:t.signal}};e||(r.options.animate=!1),await this.callGoTo(r),this._gotoController=null}_getDefaultSymbol(e){const{defaultSymbols:t}=this,r=e.feature?.geometry;if(null==r)return null;switch(r.type){case"point":case"multipoint":return t.point;case"polyline":return t.polyline;case"extent":case"polygon":return t.polygon;default:return null}}_removeHighlight(){this.removeHandles(B)}async _getLayerView(e){const{view:t}=this;if(!e||!t||"building-component"===e.layer?.type||"subtype-sublayer"===e.layer?.type)return null;const{layer:r}=e;return r?(await t.when(),t.whenLayerView(r)):null}_highlightFeature(e){const{graphic:t,layerView:r}=e,{attributes:s,layer:o}=t,{objectIdField:i}=o,l=(i&&s?.[i])??null,a=r.highlight(l??t);this.addHandles(a,B)}_setResultFloor(e){const{view:t}=this,r=e.feature?.attributes,s=e.feature?.sourceLayer;if(s&&"floorInfo"in s&&s?.floorInfo?.floorField&&r){const e=r[s.floorInfo.floorField];t?.emit("select-result-floor",e)}}};e([f()],W.prototype,"_searching",void 0),e([f()],W.prototype,"_updatingPromise",void 0),e([f({readOnly:!0,value:null})],W.prototype,"activeSource",null),e([f()],W.prototype,"activeSourceIndex",null),e([f()],W.prototype,"allPlaceholder",null),e([f({readOnly:!0})],W.prototype,"allSources",null),e([f()],W.prototype,"autoNavigate",void 0),e([f()],W.prototype,"autoSelect",void 0),e([f({type:o})],W.prototype,"defaultPopupTemplate",void 0),e([f({readOnly:!0})],W.prototype,"defaultSources",void 0),e([f()],W.prototype,"defaultSymbols",void 0),e([f()],W.prototype,"includeDefaultSources",void 0),e([f()],W.prototype,"locationEnabled",null),e([f()],W.prototype,"maxInputLength",void 0),e([f()],W.prototype,"maxResults",void 0),e([f()],W.prototype,"maxSuggestions",void 0),e([f()],W.prototype,"messages",void 0),e([f()],W.prototype,"minSuggestCharacters",void 0),e([f({readOnly:!0})],W.prototype,"placeholder",null),e([f()],W.prototype,"popupEnabled",void 0),e([f({type:o})],W.prototype,"popupTemplate",void 0),e([f({type:I})],W.prototype,"portal",void 0),e([f()],W.prototype,"resultCount",void 0),e([f()],W.prototype,"resultGraphicEnabled",void 0),e([f({readOnly:!0})],W.prototype,"resultGraphic",void 0),e([f({readOnly:!0})],W.prototype,"results",void 0),e([f({readOnly:!0})],W.prototype,"selectedSuggestion",void 0),e([f()],W.prototype,"searchAllEnabled",void 0),e([f({readOnly:!0})],W.prototype,"selectedResult",void 0),e([f()],W.prototype,"searchTerm",null),e([f({type:Q})],W.prototype,"sources",void 0),e([f({readOnly:!0})],W.prototype,"state",null),e([f()],W.prototype,"suggestionDelay",void 0),e([f()],W.prototype,"suggestionCount",void 0),e([f({readOnly:!0})],W.prototype,"suggestions",void 0),e([f()],W.prototype,"suggestionsEnabled",void 0),e([f({readOnly:!0})],W.prototype,"updating",null),e([f()],W.prototype,"view",void 0),e([f()],W.prototype,"clear",null),W=e([S("esri.widgets.Search.SearchViewModel")],W);const X=W;export{X as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import{getAssetUrl as t}from"../../assets.js";import r from"../../Graphic.js";import s from"../../PopupTemplate.js";import o from"../../core/Accessor.js";import{isSome as i}from"../../core/arrayUtils.js";import l from"../../core/Collection.js";import a from"../../core/Error.js";import n from"../../core/Evented.js";import u from"../../core/Logger.js";import{mappedFind as c}from"../../core/maybe.js";import{eachAlways as h,after as p}from"../../core/promiseUtils.js";import{watch as g,initial as d,whenOnce as m}from"../../core/reactiveUtils.js";import{property as y}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import{subclass as f}from"../../core/accessorSupport/decorators/subclass.js";import S from"../../geometry/Point.js";import _ from"../../geometry/SpatialReference.js";import{getPointFromGeometry as v,getPointWithElevation as w}from"../../geometry/support/geometryUtils.js";import{onLocaleChange as b}from"../../intl/locale.js";import{fetchMessageBundle as x}from"../../intl/messages.js";import L from"../../portal/Portal.js";import{isApiKeyApplicable as I}from"../../support/apiKeyUtils.js";import T from"../../symbols/PictureMarkerSymbol.js";import R from"../../symbols/SimpleFillSymbol.js";import E from"../../symbols/SimpleLineSymbol.js";import F from"../../symbols/TextSymbol.js";import{highlightsSupported as j}from"../../views/support/layerViewUtils.js";import P from"./LayerSearchSource.js";import C from"./LocatorSearchSource.js";import G from"./SearchSource.js";import{isArcGISWorldGeocoder as O,meteredArcGISLocatorUrl as A,isProxiedArcGISWorldGeocoder as N,isMeteredArcGISWorldGeocoder as D}from"./support/locatorUtils.js";import{supported as M,getCurrentPosition as V,positionToPoint as k}from"../support/geolocationUtils.js";import J from"../support/GoTo.js";function U(e,t){return e.hasOwnProperty(t)&&null!=e[t]&&""!==e[t]}const H=()=>x("esri/widgets/Search/t9n/Search"),B="highlight",Q=l.ofType({key:e=>e.layer?"layer":"locator",base:G,typeMap:{layer:P,locator:C}}),Z=_.WGS84,q="esri/images/search/search-symbol-32.png",z=/<[\s\S]*?>/g,K=-1;let W=class extends(J(n.EventedMixin(o))){constructor(e){super(e),this._gotoController=null,this._searching=null,this._updatingPromise=null,this._createdFeatureLayers=[],this.autoNavigate=!0,this.autoSelect=!0,this.defaultPopupTemplate=null,this.defaultSources=new Q,this.defaultSymbols={point:new T({url:t(q),size:24,width:24,height:24}),polyline:new E({color:[130,130,130,1],width:2}),polygon:new R({color:[235,235,235,.4],outline:{color:[130,130,130,1],width:2}})},this.includeDefaultSources=!0,this.maxInputLength=128,this.maxResults=6,this.maxSuggestions=6,this.messages=null,this.minSuggestCharacters=3,this.popupEnabled=!0,this.popupTemplate=null,this.portal=L.getDefault(),this.resultCount=null,this.resultGraphicEnabled=!0,this.resultGraphic=null,this.results=null,this.selectedSuggestion=null,this.searchAllEnabled=!0,this.selectedResult=null,this.sources=new Q,this.suggestionDelay=350,this.suggestionCount=null,this.suggestions=null,this.suggestionsEnabled=!0,this.view=null}initialize(){const e=async()=>{const e=await H();this.messages=e,this.defaultPopupTemplate=new s({title:e.searchResult,content:"{Match_addr}"})};e(),this.addHandles([g((()=>[this.includeDefaultSources,this.view,this.portal]),(()=>this._update()),d),b(e)])}destroy(){this._destroyFeatureLayers(),this._abortGoTo(),this.clearGraphics()}static{this.ALL_INDEX=K}get activeSource(){return this.allSources.at(this.activeSourceIndex)??null}get activeSourceIndex(){return 1===this.allSources.length||!this.searchAllEnabled?0:K}set activeSourceIndex(e){this._overrideIfSome("activeSourceIndex",e)}get allPlaceholder(){return this.messages?.allPlaceholder}set allPlaceholder(e){this._overrideIfSome("allPlaceholder",e)}get allSources(){const{sources:e,defaultSources:t,includeDefaultSources:r}=this,s="function"==typeof r?r.call(null,{sources:e,defaultSources:t}):r?t.concat(e):e,o=this._get("allSources")||new Q;return o.removeAll(),o.addMany(s.filter(Boolean)),o}get locationEnabled(){return this._get("locationEnabled")||M()}set locationEnabled(e){if(void 0===e)return void this._clearOverride("locationEnabled");const t=M();if(e&&!t){const e=new a("locationEnabled:geolocation-unsupported","Geolocation API is unsupported.",{geolocation:navigator.geolocation});u.getLogger(this).error(e)}this._override("locationEnabled",!!e&&t)}get placeholder(){const{allSources:e,activeSourceIndex:t,allPlaceholder:r}=this;if(t===K)return r??"";const s=e.at(t);return s?.placeholder??""}set searchTerm(e){this._set("searchTerm",e||""),this.clearGraphics(),this.selectedSuggestion&&this.selectedSuggestion.text!==e&&this._set("selectedSuggestion",null),""===e&&this._clear()}get searchTerm(){return this._get("searchTerm")||""}get state(){return this._searching?"searching":this.updating?"loading":0===this.allSources.length?"disabled":"ready"}get updating(){return null!=this._updatingPromise}clear(){this.searchTerm=""}clearGraphics(){this._removeHighlight(),this._closePopup();const{view:e,resultGraphic:t}=this;e&&t&&e.graphics.remove(t),this._set("resultGraphic",null)}search(e,t){this.emit("search-start"),this.clearGraphics();const r=this._createSuggestionForSearch(e),s=(async()=>{try{await this.when();const e=await this._getResultsFromSources(r,t);if(t?.signal?.aborted)return null;const s={activeSourceIndex:this.activeSourceIndex,searchTerm:r.text??"",numResults:0,numErrors:0,errors:[],results:[]};this._formatResponse(s,e,r);const o=this._getFirstResult(s.results),i=r.location&&o?o.name:r.text,l=i?.replace(z,"");return this._set("searchTerm",l),(r.key&&"number"==typeof r.sourceIndex||r.location)&&this._set("selectedSuggestion",r),this._set("results",s.results),this._set("resultCount",s.results.reduce(((e,t)=>e+(t.results?.length??0)),0)),this.emit("search-complete",s),await this._selectFirstResult(o),s}finally{this._clearSearching()}})();return this._searching=s,s}async searchNearby(e){if(!this.locationEnabled){const e=new a("searchNearby:geolocation-unsupported","Geolocation API is unsupported.",{geolocation:navigator.geolocation});throw u.getLogger(this).error(e),e}const t=(async()=>{try{const t=await V(),r=await k({position:t,view:this.view},e);return await this.search(r,e)}finally{this._clearSearching()}})();return this._searching=t,t}async select(e){if(this.clearGraphics(),!e){const t=new a("select:missing-parameter","Cannot select without a searchResult.",{searchResult:e});throw u.getLogger(this).error(t),t}const{view:t}=this,s=U(e,"sourceIndex")?e.sourceIndex:this._getSourceIndexOfResult(e),o=null!=s?this.allSources.at(s):null;if(!o){const e=new a("select:missing-source","Cannot select without a source.",{source:o});throw u.getLogger(this).error(e),e}const i=o instanceof P?this._getLayerSourcePopupTemplate(o):o.popupTemplate,l=o.resultSymbol||this._getDefaultSymbol(e),n=U(o,"resultGraphicEnabled")?o.resultGraphicEnabled:this.resultGraphicEnabled,c=U(o,"autoNavigate")?o.autoNavigate:this.autoNavigate,p=U(o,"popupEnabled")?o.popupEnabled:this.popupEnabled,g=p?i||this.popupTemplate||this.defaultPopupTemplate:null,{feature:d}=e;if(!d){const e=new a("select:missing-feature","Cannot select without a feature.",{feature:d});throw u.getLogger(this).error(e),e}const{attributes:m,geometry:y,layer:f,sourceLayer:S}=d,_=y?v(y):null,b={layerViewQuery:this._getLayerView(d),elevationQuery:t&&null!=_?w(_,t):Promise.resolve(_)},x=await h(b),L=x.layerViewQuery.value,I=x.elevationQuery.value;l instanceof F&&(l.text=e.name);const T=t&&c?e.target||e.extent:null,R=null!=T?this._goToSearchResult(T):Promise.resolve();await R;const E=L?d:new r({geometry:y,symbol:l,attributes:m,layer:f,sourceLayer:S,popupTemplate:g}),C=t?.popup,G=C&&p&&E.getEffectivePopupTemplate(C.defaultPopupTemplateEnabled);return G&&await t.openPopup({features:[E],location:I}),L&&j(L)&&!G&&this._highlightFeature({graphic:E,layerView:L}),!L&&n&&t&&t.graphics.push(E),this._setResultFloor(e),this._set("selectedResult",e),this._set("resultGraphic",E),this.emit("select-result",{result:e,source:o,sourceIndex:s}),e}async suggest(e,t,r){const s=e||this.searchTerm;this.emit("suggest-start",{searchTerm:s}),await this._suggestTimer(t,r);const o=await this._suggestImmediate(s,r);return this._set("suggestions",o?.results),this._set("suggestionCount",o?.results.reduce(((e,t)=>e+(t.results?.length??0)),0)??null),this.emit("suggest-complete",o),o}async when(){await m((()=>!this.updating))}async _update(){const{portal:e,view:t}=this;if(this.includeDefaultSources){const r=this._updatingPromise=h([e?.load(),t?.when()]);if(this.destroyed)return;if(await r,r!==this._updatingPromise)return}await m((()=>this.messages)),this.destroyed||this._updateDefaultSources(),this._updatingPromise=null}_clearSearching(){this._searching=null}_convertHelperServices(){const e=this.portal?.helperServices?.geocode;if(!e)return[];return e.map((e=>{if(!1===e.placefinding)return;const t=O(e.url)&&I(e.url)?{url:A}:null,r=C.fromJSON({...e,...t}),s=r.url;if(O(s)||N(s)||D(s)){const e=r.outFields??["Addr_type","Match_addr","StAddr","City"],t=(r.placeholder||this.messages?.placeholder)??"",s="number"==typeof r.defaultZoomScale?r.defaultZoomScale:2500;r.singleLineFieldName="SingleLine",r.outFields=e,r.placeholder=t,r.defaultZoomScale=s}return r.singleLineFieldName?r:void 0})).filter(i)}_destroyFeatureLayers(){this._createdFeatureLayers.forEach((e=>e?.destroy())),this._createdFeatureLayers=[]}_getLayerSources(e,t){const r=this.view?.map;return e.map((e=>{const s=r.findLayerById(e.id);if(!s)return;const o=this._getLayerJSON(e),i=P.fromJSON(o);return i.placeholder=t,this._getLayer(s,o).then((e=>{i.layer=e})),i})).filter(i).toArray()}_getTableSources(e,t){const r=this.view?.map;return e.map((e=>{if(!e.id)return;const s=r.findTableById(e.id);if(!s)return;const o=this._getLayerJSON(e),i=P.fromJSON(o);return i.placeholder=t,this._getLayer(s,o).then((e=>{i.layer=e})),i})).filter(i).toArray()}_convertApplicationProperties(){const e=this.view?.map,t=e?.applicationProperties?.viewing?.search;if(!t)return[];const{enabled:r,hintText:s,layers:o,tables:i}=t;if(!r)return[];return[...this._getLayerSources(o,s),...this._getTableSources(i,s)]}async _getSubLayer(e,t){if(await e.load(),!e.allSublayers)throw new Error;const r=e.allSublayers.find((e=>e.id===t.subLayer));if(!r)throw new Error;const s=await(r.createFeatureLayer?.());if(!s)throw new Error;return this._createdFeatureLayers.push(s),s}async _getBuildingSubLayer(e,t){await e.load();const r=e.allSublayers.find((e=>e.id===t.subLayer));if("building-component"!==r?.type)throw new Error;if(await r.load(),null==r.associatedLayer)throw new Error;return await r.associatedLayer.load(),r}async _getLayer(e,t){if("feature"===e.type||"scene"===e.type||"csv"===e.type||"geojson"===e.type||"ogc-feature"===e.type)return e;if("map-image"===e.type)try{return await this._getSubLayer(e,t)}catch(r){const t=new a("search:create-featurelayer","Could not create a FeatureLayer from the MapImageLayer",{layer:e});return u.getLogger(this).error(t),null}return"building-scene"===e.type?this._getBuildingSubLayer(e,t):null}_getLayerJSON(e){return"function"==typeof e.toJSON?e.toJSON():e}_updateDefaultSources(){const{defaultSources:e,includeDefaultSources:t}=this;this._destroyFeatureLayers(),e.removeAll(),t&&e.addMany([...this._convertApplicationProperties(),...this._convertHelperServices()])}_abortGoTo(){this._gotoController&&this._gotoController.abort(),this._gotoController=null}_clear(){this._abortGoTo(),this._set("resultCount",null),this._set("results",null),this._set("suggestions",null),this._set("suggestionCount",null),this._set("selectedResult",null),this._set("selectedSuggestion",null),this.emit("search-clear")}_closePopup(){const e=this.view?.popup,{resultGraphic:t}=this;if(!e||!t)return;const r="selectedFeature"in e,s=r?e.selectedFeature:null;r&&(s&&s===t)&&e.close()}_suggestTimer(e,t){const r=null!=e?e:this.suggestionDelay;return p(r,null,t?.signal)}_createLocationForSearch(e){return e instanceof r&&e.geometry?v(e.geometry):e instanceof S?e:Array.isArray(e)&&2===e.length?new S({longitude:e[0],latitude:e[1]}):null}_createSuggestionForSearch(e){if(e&&U(e,"key")&&U(e,"text")&&U(e,"sourceIndex"))return e;const t=this._createLocationForSearch(e),r="string"==typeof e?e:this.searchTerm,{selectedSuggestion:s,selectedResult:o}=this,i=!e&&s&&o,l=i&&s.key===o.key&&s.sourceIndex===o.sourceIndex,a=i&&s.location;return l||a?s:{location:t,text:t?"":r,sourceIndex:null,key:null}}_getFirstResult(e){return c(e,(({results:e})=>e?.[0]))??null}async _selectFirstResult(e){return this.autoSelect&&e?this.select(e):null}async _suggestImmediate(e,t){await this.when();const r=await this._getSuggestionsFromSources(e,t);if(t?.signal?.aborted)return null;const s={activeSourceIndex:this.activeSourceIndex,searchTerm:e??"",numResults:0,numErrors:0,errors:[],results:[]};return this._formatResponse(s,r),s}_formatSourceResponse(e,t,r){const s=t?.value||[],o=t?.error,i=this.allSources.at(r);if(o){const t={sourceIndex:r,source:i,error:o};e.errors.push(t),u.getLogger(this).error(o),e.numErrors++}else{const t={sourceIndex:r,source:i,results:s};e.results.push(t),e.numResults+=s.length}}_formatResponse(e,t,r){if(t)if(e.activeSourceIndex===K){const s=r&&U(r,"sourceIndex")&&-1!==r.sourceIndex?r.sourceIndex:void 0;t.forEach(((t,r)=>{const o=void 0!==s?s:r;this._formatSourceResponse(e,t,o)}))}else this._formatSourceResponse(e,t[0],e.activeSourceIndex)}async _getResultsFromSources(e,t){const{allSources:r}=this,s=!e.location&&U(e,"sourceIndex")?e.sourceIndex:this.activeSourceIndex,o=[];if(!r.length){const e=new a("search:no-sources-defined","At least one source is required.",{allSources:r});throw u.getLogger(this).error(e),e}return s===K?r.forEach(((r,s)=>{o.push(this._getResultsFromSource(e,s,t))})):o.push(this._getResultsFromSource(e,s,t)),h(o)}async _getSuggestionsFromSources(e,t){const{allSources:r,activeSourceIndex:s}=this,o=[];if(!r.length){const e=new a("suggest:no-sources-defined","At least one source is required.",{allSources:r});throw u.getLogger(this).error(e),e}return s===K?r.forEach(((r,s)=>{o.push(this._getSuggestionsFromSource(e,s,t))})):o.push(this._getSuggestionsFromSource(e,s,t)),h(o)}async _getResultsFromSource(e,t,r){const s=null!=t?this.allSources.at(t):null;if(!s)return null;const{location:o=null}=e,i=this.view?.spatialReference||Z,l=U(s,"maxResults")?s.maxResults:this.maxResults,a=!!(s instanceof P&&U(s,"exactMatch"))&&s.exactMatch,{view:n}=this;return s.getResults?.({view:n,sourceIndex:t,location:o,suggestResult:e,spatialReference:i,exactMatch:a,maxResults:l},r)}async _getSuggestionsFromSource(e,t,r){const s=this.allSources.at(t);if(!s)return null;e??="";const o=U(s,"suggestionsEnabled")?s.suggestionsEnabled:this.suggestionsEnabled,i=e?.length,l=U(s,"minSuggestCharacters")?s.minSuggestCharacters:this.minSuggestCharacters;if(o&&e.trim()&&i>=l){const o=this.view?.spatialReference||Z,i=U(s,"maxSuggestions")?s.maxSuggestions:this.maxSuggestions,{view:l}=this,a=!!(s instanceof P&&U(s,"exactMatch"))&&s.exactMatch;return s.getSuggestions?.({view:l,sourceIndex:t,suggestTerm:e,spatialReference:o,maxSuggestions:i,exactMatch:a},r)}return null}_getLayerSourcePopupTemplate(e){const{layer:t}=e;if(t)return U(e,"popupTemplate")?e.popupTemplate:t.popupTemplate}_getSourceIndexOfResult(e){return c(this.results??[],(({results:t,sourceIndex:r})=>{const s=t?.includes(e);return s?r:null}))??null}async _goToSearchResult(e){this._abortGoTo();const t=new AbortController;this._gotoController=t;const r={target:{target:e},options:{signal:t.signal}};e||(r.options.animate=!1),await this.callGoTo(r),this._gotoController=null}_getDefaultSymbol(e){const{defaultSymbols:t}=this,r=e.feature?.geometry;if(null==r)return null;switch(r.type){case"point":case"multipoint":return t.point;case"polyline":return t.polyline;case"extent":case"polygon":return t.polygon;default:return null}}_removeHighlight(){this.removeHandles(B)}async _getLayerView(e){const{view:t}=this;if(!e||!t||"building-component"===e.layer?.type||"subtype-sublayer"===e.layer?.type)return null;const{layer:r}=e;return r?(await t.when(),t.whenLayerView(r)):null}_highlightFeature(e){const{graphic:t,layerView:r}=e,{attributes:s,layer:o}=t,{objectIdField:i}=o,l=(i&&s?.[i])??null,a=r.highlight(l??t);this.addHandles(a,B)}_setResultFloor(e){const{view:t}=this,r=e.feature?.attributes,s=e.feature?.sourceLayer;if(s&&"floorInfo"in s&&s?.floorInfo?.floorField&&r){const e=r[s.floorInfo.floorField];t?.emit("select-result-floor",e)}}};e([y()],W.prototype,"_searching",void 0),e([y()],W.prototype,"_updatingPromise",void 0),e([y({readOnly:!0,value:null})],W.prototype,"activeSource",null),e([y()],W.prototype,"activeSourceIndex",null),e([y()],W.prototype,"allPlaceholder",null),e([y({readOnly:!0})],W.prototype,"allSources",null),e([y()],W.prototype,"autoNavigate",void 0),e([y()],W.prototype,"autoSelect",void 0),e([y({type:s})],W.prototype,"defaultPopupTemplate",void 0),e([y({readOnly:!0})],W.prototype,"defaultSources",void 0),e([y()],W.prototype,"defaultSymbols",void 0),e([y()],W.prototype,"includeDefaultSources",void 0),e([y()],W.prototype,"locationEnabled",null),e([y()],W.prototype,"maxInputLength",void 0),e([y()],W.prototype,"maxResults",void 0),e([y()],W.prototype,"maxSuggestions",void 0),e([y()],W.prototype,"messages",void 0),e([y()],W.prototype,"minSuggestCharacters",void 0),e([y({readOnly:!0})],W.prototype,"placeholder",null),e([y()],W.prototype,"popupEnabled",void 0),e([y({type:s})],W.prototype,"popupTemplate",void 0),e([y({type:L})],W.prototype,"portal",void 0),e([y()],W.prototype,"resultCount",void 0),e([y()],W.prototype,"resultGraphicEnabled",void 0),e([y({readOnly:!0})],W.prototype,"resultGraphic",void 0),e([y({readOnly:!0})],W.prototype,"results",void 0),e([y({readOnly:!0})],W.prototype,"selectedSuggestion",void 0),e([y()],W.prototype,"searchAllEnabled",void 0),e([y({readOnly:!0})],W.prototype,"selectedResult",void 0),e([y()],W.prototype,"searchTerm",null),e([y({type:Q})],W.prototype,"sources",void 0),e([y({readOnly:!0})],W.prototype,"state",null),e([y()],W.prototype,"suggestionDelay",void 0),e([y()],W.prototype,"suggestionCount",void 0),e([y({readOnly:!0})],W.prototype,"suggestions",void 0),e([y()],W.prototype,"suggestionsEnabled",void 0),e([y({readOnly:!0})],W.prototype,"updating",null),e([y()],W.prototype,"view",void 0),e([y()],W.prototype,"clear",null),W=e([f("esri.widgets.Search.SearchViewModel")],W);const X=W;export{X 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
- const e="esri-search-result-renderer",s={base:e,showMoreResults:`${e}__more-results--show-more-results`,moreResults:`${e}__more-results`,moreResultsList:`${e}__more-results-list`,moreResultsHeader:`${e}__more-results-header`,moreResultsItem:`${e}__more-results-item`,moreResultsListHeader:`${e}__more-results-list-header`};export{s as css};
5
+ const e="esri-search-result-renderer",r={base:e,moreResults:`${e}--more-results`};export{r as css};
@@ -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 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 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 m}from"../goToUtils.js";import y 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())),n((()=>this.effectiveSelectionManager?.sources),"change",(()=>this._onSelectionChangeDebounced())),n((()=>this.effectiveSelectionManager),"selection-change",(()=>this._onSelectionChangeDebounced()))])}destroy(){this.removeTemporaryHighlight(),this._updatingHandles.destroy()}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 visibleFeatureCount(){let e=0;for(const t of this.layerItems)e+=t.maxVisibleFeatureCountExceeded?t.maxVisibleFeatureCountPerLayer:t.total;return e}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:n}=this,a=o??n;if(!l)return[];const c=[];for(const h of a)switch(h.type){case"subtype-group":case"group":{const e=i.get(h),o=e??new y({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),n=i??new f({layer:e,viewModel:this});i||s.set(e,n),r.push(n.sync({controller:t,promises:r})),c.push(n)}}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 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([a()],_.prototype,"_groupItemCache",void 0),e([a()],_.prototype,"_hoverHighlightHandle",void 0),e([a()],_.prototype,"_layerItemCache",void 0),e([a()],_.prototype,"_allLayerItems",void 0),e([a()],_.prototype,"_onChangeAbortController",void 0),e([a()],_.prototype,"allLayerItems",null),e([a()],_.prototype,"effectiveCount",null),e([a()],_.prototype,"effectiveSelectionManager",null),e([a()],_.prototype,"featureTitleMap",void 0),e([a()],_.prototype,"isUpdating",null),e([a()],_.prototype,"layer",void 0),e([a()],_.prototype,"layerItems",null),e([a()],_.prototype,"layerViewMap",null),e([a()],_.prototype,"maxVisibleFeatureCountExceeded",null),e([a()],_.prototype,"maxVisibleFeatureCountPerLayer",void 0),e([a()],_.prototype,"selectionManager",void 0),e([a()],_.prototype,"selectionSources",null),e([a()],_.prototype,"state",null),e([a()],_.prototype,"totalCount",null),e([a()],_.prototype,"view",void 0),e([a()],_.prototype,"viewLayersAndTables",null),e([a()],_.prototype,"visibleFeatureCount",null),_=e([c("esri.widgets.support.SelectionList.SelectionListViewModel")],_);const M=_;export{M 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 l,on 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 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 m}from"../../../views/support/selectionUtils.js";import{goTo as u}from"../goToUtils.js";import y 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())),n((()=>this.effectiveSelectionManager?.sources),"change",(()=>this._onSelectionChangeDebounced())),n((()=>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 visibleFeatureCount(){let e=0;for(const t of this.layerItems)e+=t.maxVisibleFeatureCountExceeded?t.maxVisibleFeatureCountPerLayer:t.total;return e}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:n}=this,a=o??n;if(!l)return[];const c=[];for(const h of a)switch(h.type){case"subtype-group":case"group":{const e=i.get(h),o=e??new y({layer:h,viewModel:this});e||i.set(h,o),r.push(o.sync({controller:t,promises:r})),c.push(o)}break;default:if(m(h)||g(h)){const e=h,o=l.getSelection(e);if(!o?.length)continue;const i=s.get(e),n=i??new f({layer:e,viewModel:this});i||s.set(e,n),r.push(n.sync({controller:t,promises:r})),c.push(n)}}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 u(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([a()],_.prototype,"_groupItemCache",void 0),e([a()],_.prototype,"_hoverHighlightHandle",void 0),e([a()],_.prototype,"_layerItemCache",void 0),e([a()],_.prototype,"_allLayerItems",void 0),e([a()],_.prototype,"_onChangeAbortController",void 0),e([a()],_.prototype,"activeLayerItem",null),e([a()],_.prototype,"allLayerItems",null),e([a()],_.prototype,"effectiveCount",null),e([a()],_.prototype,"effectiveSelectionManager",null),e([a()],_.prototype,"featureTitleMap",void 0),e([a()],_.prototype,"isUpdating",null),e([a()],_.prototype,"layer",void 0),e([a()],_.prototype,"layerItems",null),e([a()],_.prototype,"layerViewMap",null),e([a()],_.prototype,"maxVisibleFeatureCountExceeded",null),e([a()],_.prototype,"maxVisibleFeatureCountPerLayer",void 0),e([a()],_.prototype,"selectionManager",void 0),e([a()],_.prototype,"selectionSources",null),e([a()],_.prototype,"state",null),e([a()],_.prototype,"totalCount",null),e([a()],_.prototype,"view",void 0),e([a()],_.prototype,"viewLayersAndTables",null),e([a()],_.prototype,"visibleFeatureCount",null),_=e([c("esri.widgets.support.SelectionList.SelectionListViewModel")],_);const M=_;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{isSome as n}from"../../../core/arrayUtils.js";function t(e){return e.flatMap((n=>i(n)?n.selection:l(n)?n.children.flatMap((n=>t([n]))):n)).filter(n)}function e(t){return t.flatMap((n=>l(n)?n.children.filter((n=>"selection"in n)):i(n)?n:null)).filter(n)}function r(n){let t=0;for(const e of n)i(e)&&(t+=e.total),l(e)&&(t+=r(e.children));return t}function l(n){return null!=n&&"object"==typeof n&&"children"in n}function i(n){return null!=n&&"object"==typeof n&&"selection"in n}function o(n){return null!=n&&"object"==typeof n&&"graphic"in n}export{r as computeEffectiveCount,t as getNestedFeatureItems,e as getNestedLayerItems,o as isFeatureItem,l as isGroupLayerItem,i as isLayerItem};
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};
@@ -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}from"../../core/reactiveUtils.js";import{property as s}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import{subclass as o}from"../../core/accessorSupport/decorators/subclass.js";import l from"../Widget.js";import{loadCalciteComponents as n}from"./componentsUtils.js";import{globalCss as r}from"./globalCss.js";import{storeNode as a}from"./widgetUtils.js";import{messageBundle as c}from"./decorators/messageBundle.js";import{tsx as m}from"./jsxFactory.js";import{isGroupLayerItem as d,isLayerItem as h,isFeatureItem as p}from"./SelectionList/selectionListUtils.js";import u from"./SelectionList/SelectionListViewModel.js";import y from"./SelectionList/VisibleElements.js";import{formatNumber as v}from"../../intl/number.js";import{substitute as g}from"../../intl/substitute.js";const I="esri-selection-list",f=`${I}__list-item`,b={base:I,container:`${I}__container`,notice:`${I}__notice`,countText:`${I}__count-text`,layerDropdown:`${I}__layer-dropdown`,listItemFeature:`${f}__feature`,listItemFeatureIcon:`${f}__feature-icon`,listItemIcon:`${f}__icon`,totalCountChip:`${I}__total-count`};let _=class extends l{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.itemActionConfigs=null,this.menuScale="m",this.messages=null,this.messagesCommon=null,this.scale="s",this.viewModel=new u,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()))])}destroy(){this._iconIntersectionObserver?.disconnect(),this._iconIntersectionObserver=null}loadDependencies(){return n({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"),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.layer&&this.layerItems.find((e=>e.layer===this.layer))}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}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 m("div",{class:this.classes(b.base,r.widget,r.panel)},m("calcite-flow",null,m("calcite-flow-item",{class:b.container,heading:this.visibleElements.header?this.messages.selection:void 0,loading:"loading"===this.state,overlayPositioning:"fixed",scale:this.scale,selected:!0},m("calcite-panel",{overlayPositioning:"fixed",scale:this.scale},this._renderLayerFilter(),this._renderCountText(),this._renderList()),this._renderTotalChip(),this._renderMenuActions())))}_renderTotalChip(){const{visibleElements:e}=this;if(!e.totalCountChip||!e.header)return;const{effectiveCount:t}=this,i=v(t),s=g(this.messages.selectionCount,{count:i});return m("calcite-chip",{appearance:"outline",class:b.totalCountChip,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[m("calcite-action",{disabled:i,icon:"reset",key:"clear-action",onclick:this.clear,scale:t,slot:"header-menu-actions",text:this.messagesCommon.clear,textEnabled:!0}),m("calcite-action",{disabled:i,icon:"folders",key:"collapse-action",onclick:this.collapseItems,scale:t,slot:"header-menu-actions",text:this.messages.collapseAll,textEnabled:!0})]}_renderCountText(){if(!this.visibleElements.countText)return;const{effectiveCount:e,messages:t,visibleFeatureCount:i}=this,s=v(e);return m("div",{class:b.countText,key:"feature-count-label"},this.maxVisibleFeatureCountExceeded?g(t.featuresCountShowing,{count:s,visibleCount:v(i)}):g(t.featuresCount,{count:s}))}_renderLayerFilter(){const{layerItems:e,messages:t}=this;if(0!==this.totalCount&&0!==e.length&&this.visibleElements.layerFilter)return m("calcite-combobox",{class:b.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}},m("calcite-combobox-item",{heading:g(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 m("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 m("calcite-list",{afterCreate:a,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=>d(e)?this._renderGroupItem(e):h(e)?this._renderLayerItem(e):null)).filter(t)}_renderFilterNotice(){const{visibleElements:e}=this;if(e.filter&&e.filterNotice)return m("calcite-notice",{icon:"exclamation-mark-triangle",kind:"info",open:!0,scale:this.scale,slot:"filter-no-results"},m("div",{slot:"message"},this.messages.noMatchingFeatures))}_renderItemCountChip(e){if(!this.visibleElements.itemCountChip)return;const{messages:t}=this,{maxVisibleFeatureCountExceeded:i,total:s}=e,o=v(s),l=i?t.tooManyFeatures:g(t.selectionCount,{count:o});return m("calcite-chip",{appearance:"outline",icon:i?"exclamation-mark-triangle":void 0,label:o,scale:"s",slot:"content-end",title:l},o)}_renderItemActions(e){if(!this.visibleElements.itemMenus)return;const{messages:t,messagesCommon:i}=this,s=this._itemWithOpenMenu===e,o=p(e),l=h(e),n=d(e),r=o?t.deselectFeature:l?t.deselectLayer:t.deselectGroup;return[m("calcite-dropdown",{open:s,overlayPositioning:"fixed",scale:this.menuScale,slot:"actions-end",width:"m",onCalciteDropdownClose:()=>this._closeItemMenu(e),onCalciteDropdownOpen:()=>{this._itemWithOpenMenu=e}},m("calcite-action",{appearance:"transparent",icon:"ellipsis",scale:this.scale,slot:"trigger",text:i.menu,textEnabled:!1}),s?m("calcite-dropdown-group",{selectionMode:"none"},m("calcite-dropdown-item",{iconStart:"layer-zoom-to",onCalciteDropdownItemSelect:()=>this.goToItem(e)},t.zoomTo),m("calcite-dropdown-item",{iconStart:"selection-filter",onCalciteDropdownItemSelect:()=>this.selectSingleItem(e)},o?t.onlySelectFeature:t.onlySelectThis),m("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 m("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 m("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 m("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._renderItemCountChip(e),this._renderItemActions(e),this._renderItems(e.selection),e.maxVisibleFeatureCountExceeded?m("calcite-notice",{class:b.notice,icon:"exclamation-mark-triangle",kind:"info",open:!0,scale:this.scale},m("div",{slot:"message"},t.tooManyFeatures)):void 0)}_renderItems(e){return e.map((e=>this._renderItem(e)))}_renderItem(e){const{messages:t,visibleElements:i}=this,s=e.title||t.untitledFeature,o=i.itemIcons&&"feature"!==this.displayMode;return m("calcite-list-item",{bind:this,class:o?b.listItemFeatureIcon:b.listItemFeature,closable:!!i.itemCloseActions,"data-item":e,key:e.key,label:s,name:s,onblur:this.removeTemporaryHighlight,onfocus:()=>this.addTemporaryHighlight(e),onpointerenter:()=>this.addTemporaryHighlight(e),onpointerleave:this.removeTemporaryHighlight,scale:this.scale,value:s,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 m("div",{class:b.listItemIcon,key:"content-start",slot:"content-start"},m("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.emit("item-click",{item:e})}_closeItemMenu(e){e&&e!==this._itemWithOpenMenu||(this._itemWithOpenMenu=null)}};e([s()],_.prototype,"_activeLayerItem",null),e([s()],_.prototype,"_list",void 0),e([s()],_.prototype,"_itemWithOpenMenu",void 0),e([s()],_.prototype,"allLayerItems",null),e([s()],_.prototype,"displayMode",void 0),e([s()],_.prototype,"effectiveCount",null),e([s()],_.prototype,"effectiveSelectionManager",null),e([s()],_.prototype,"featureTitleMap",null),e([s()],_.prototype,"icon",null),e([s()],_.prototype,"itemActionConfigs",void 0),e([s()],_.prototype,"isUpdating",null),e([s()],_.prototype,"label",null),e([s()],_.prototype,"layer",null),e([s()],_.prototype,"layerItems",null),e([s()],_.prototype,"layerViewMap",null),e([s()],_.prototype,"maxVisibleFeatureCountExceeded",null),e([s()],_.prototype,"maxVisibleFeatureCountPerLayer",null),e([s()],_.prototype,"menuScale",void 0),e([s(),c("esri/widgets/support/SelectionList/t9n/SelectionList")],_.prototype,"messages",void 0),e([s(),c("esri/t9n/common")],_.prototype,"messagesCommon",void 0),e([s()],_.prototype,"scale",void 0),e([s()],_.prototype,"selectionManager",null),e([s()],_.prototype,"selectionSources",null),e([s()],_.prototype,"state",null),e([s()],_.prototype,"totalCount",null),e([s()],_.prototype,"view",null),e([s()],_.prototype,"viewLayersAndTables",null),e([s()],_.prototype,"viewModel",void 0),e([s()],_.prototype,"visibleFeatureCount",null),e([s({type:y,nonNullable:!0})],_.prototype,"visibleElements",void 0),_=e([o("esri.widgets.support.SelectionList")],_);const C=_;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{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 g from"./SelectionList/VisibleElements.js";import{formatNumber as y}from"../../intl/number.js";import{substitute as I}from"../../intl/substitute.js";const f="esri-selection-list",b=`${f}__list-item`,_={base:f,container:`${f}__container`,notice:`${f}__notice`,countText:`${f}__count-text`,layerDropdown:`${f}__layer-dropdown`,listItemFeature:`${b}__feature`,listItemFeatureIcon:`${b}__feature-icon`,listItemIcon:`${b}__icon`,totalCountChip:`${f}__total-count`};let C=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.scale="s",this.viewModel=new v,this.visibleElements=new g,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"),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}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._renderCountText(),this._renderList()),this._renderTotalChip(),this._renderMenuActions())))}_renderTotalChip(){const{visibleElements:e}=this;if(!e.totalCountChip||!e.header)return;const{effectiveCount:t}=this,i=y(t),s=I(this.messages.selectionCount,{count:i});return d("calcite-chip",{appearance:"outline",class:_.totalCountChip,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})]}_renderCountText(){if(!this.visibleElements.countText)return;const{effectiveCount:e,messages:t,visibleFeatureCount:i}=this,s=y(e);return d("div",{class:_.countText,key:"feature-count-label"},this.maxVisibleFeatureCountExceeded?I(t.featuresCountShowing,{count:s,visibleCount:y(i)}):I(t.featuresCount,{count:s}))}_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))}_renderItemCountChip(e){if(!this.visibleElements.itemCountChip)return;const{messages:t}=this,{maxVisibleFeatureCountExceeded:i,total:s}=e,o=y(s),l=i?t.tooManyFeatures:I(t.selectionCount,{count:o});return d("calcite-chip",{appearance:"outline",icon:i?"exclamation-mark-triangle":void 0,label:o,scale:"s",slot:"content-end",title:l},o)}_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._renderItemCountChip(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.emit("item-click",{item:e})}_closeItemMenu(e){e&&e!==this._itemWithOpenMenu||(this._itemWithOpenMenu=null)}};e([o()],C.prototype,"_list",void 0),e([o()],C.prototype,"_itemWithOpenMenu",void 0),e([o()],C.prototype,"activeLayerItem",null),e([o()],C.prototype,"allLayerItems",null),e([o()],C.prototype,"displayMode",void 0),e([o()],C.prototype,"effectiveCount",null),e([o()],C.prototype,"effectiveSelectionManager",null),e([o()],C.prototype,"featureTitleMap",null),e([o()],C.prototype,"hightlightOnHoverEnabled",void 0),e([o()],C.prototype,"icon",null),e([o()],C.prototype,"itemActionConfigs",void 0),e([o()],C.prototype,"isUpdating",null),e([o()],C.prototype,"label",null),e([o()],C.prototype,"layer",null),e([o()],C.prototype,"layerItems",null),e([o()],C.prototype,"layerViewMap",null),e([o()],C.prototype,"maxVisibleFeatureCountExceeded",null),e([o()],C.prototype,"maxVisibleFeatureCountPerLayer",null),e([o()],C.prototype,"menuScale",void 0),e([o(),m("esri/widgets/support/SelectionList/t9n/SelectionList")],C.prototype,"messages",void 0),e([o(),m("esri/t9n/common")],C.prototype,"messagesCommon",void 0),e([o()],C.prototype,"scale",void 0),e([o()],C.prototype,"selectionManager",null),e([o()],C.prototype,"selectionSources",null),e([o()],C.prototype,"state",null),e([o()],C.prototype,"totalCount",null),e([o()],C.prototype,"view",null),e([o()],C.prototype,"viewLayersAndTables",null),e([o()],C.prototype,"viewModel",void 0),e([o()],C.prototype,"visibleFeatureCount",null),e([o({type:g,nonNullable:!0})],C.prototype,"visibleElements",void 0),C=e([l("esri.widgets.support.SelectionList")],C);const w=C;export{w as default};