@arcgis/core 4.33.0-next.20250204 → 4.33.0-next.20250205

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 (55) hide show
  1. package/assets/esri/core/workers/RemoteClient.js +1 -1
  2. package/assets/esri/core/workers/chunks/06f693780f70e5a627c4.js +1 -0
  3. package/assets/esri/core/workers/chunks/1a2e1a414e651e988435.js.LICENSE.txt +1 -1
  4. package/assets/esri/core/workers/chunks/{c3f03ccabca691186aad.js → 287362f9af132fafe4de.js} +1 -1
  5. package/assets/esri/core/workers/chunks/308ec51ff4a66f7fcb0d.js.LICENSE.txt +1 -1
  6. package/assets/esri/core/workers/chunks/354531dc2f0dea2ad96f.js.LICENSE.txt +1 -1
  7. package/assets/esri/core/workers/chunks/41cd1a5c99ab3bbd1fb4.js +1 -0
  8. package/assets/esri/core/workers/chunks/{8edae4ca2b18a219a43e.js → 5e7f16b312077ca8c18d.js} +1 -1
  9. package/assets/esri/core/workers/chunks/{b8a519d5d24b2e728ff8.js → 6d5bfcc7856cafe7b043.js} +2 -2
  10. package/assets/esri/core/workers/chunks/{b8a519d5d24b2e728ff8.js.LICENSE.txt → 6d5bfcc7856cafe7b043.js.LICENSE.txt} +1 -1
  11. package/assets/esri/core/workers/chunks/72cf9192292e5c85c6df.js.LICENSE.txt +1 -1
  12. package/assets/esri/core/workers/chunks/{e4f82b5b50996b1ae48e.js → 746c964cf07e4306f21f.js} +1 -1
  13. package/assets/esri/core/workers/chunks/77764ca90bdd13ee2167.js.LICENSE.txt +1 -1
  14. package/assets/esri/core/workers/chunks/{07360fde6ea65664e6ca.js → 82d26884127ed772cc4b.js} +1 -1
  15. package/assets/esri/core/workers/chunks/{f48ef415b90edc7ccadd.js → 858b191c078d04232342.js} +1 -1
  16. package/assets/esri/core/workers/chunks/{60cd8f4bba3e682ba57e.js → 91d2bdfa6e34c10b7f50.js} +1 -1
  17. package/assets/esri/core/workers/chunks/{12dd892cf61a76fb40ad.js → 991e0f619f1f81f94d56.js} +1 -1
  18. package/assets/esri/core/workers/chunks/9a27824d94df702e6e28.js +1 -0
  19. package/assets/esri/core/workers/chunks/b21b152fa15896577242.js.LICENSE.txt +1 -1
  20. package/assets/esri/core/workers/chunks/{c7a94e569c905f97244a.js → b33122adfd1fb68f7c0f.js} +1 -1
  21. package/assets/esri/core/workers/chunks/{da77eefaad83c0644380.js → b8fae500c69ca2cff62a.js} +1 -1
  22. package/assets/esri/core/workers/chunks/b9d9a1dc3c5d799e2685.js +1 -0
  23. package/assets/esri/core/workers/chunks/e26dc0c1654316bb1558.js +1 -0
  24. package/assets/esri/core/workers/chunks/{3ce826ebf0692363309d.js → e410a09650530d7aad10.js} +1 -1
  25. package/assets/esri/core/workers/chunks/f4e48bbdbc9da10ec71a.js +1 -0
  26. package/assets/esri/themes/base/widgets/_Directions.scss +59 -11
  27. package/assets/esri/themes/dark/main.css +1 -1
  28. package/assets/esri/themes/light/main.css +1 -1
  29. package/assets/esri/themes/light/view.css +1 -1
  30. package/chunks/ColorMaterial.glsl.js +4 -5
  31. package/chunks/Pattern.glsl.js +1 -1
  32. package/interfaces.d.ts +13 -0
  33. package/layers/graphics/sources/geojson/GeoJSONSourceWorker.js +1 -1
  34. package/layers/graphics/sources/support/MemorySourceWorker.js +1 -1
  35. package/layers/support/Sublayer.js +1 -1
  36. package/layers/support/capabilities.js +1 -1
  37. package/layers/support/featureLayerUtils.js +1 -1
  38. package/layers/support/serviceCapabilitiesUtils.js +1 -1
  39. package/package.json +2 -2
  40. package/rest/query/operations/queryAttachments.js +1 -1
  41. package/rest/support/AttachmentQuery.js +1 -1
  42. package/support/revision.js +1 -1
  43. package/views/3d/layers/graphics/Graphics3DSymbolLayer.js +1 -1
  44. package/widgets/Attachments/AttachmentsViewModel.js +1 -1
  45. package/widgets/Directions.js +1 -1
  46. package/widgets/Feature/FeatureViewModel.js +1 -1
  47. package/widgets/NavigationToggle/NavigationToggleViewModel.js +1 -1
  48. package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
  49. package/widgets/support/geolocationUtils.js +1 -1
  50. package/assets/esri/core/workers/chunks/04306c2760c1f5b19966.js +0 -1
  51. package/assets/esri/core/workers/chunks/1e3ab66d0e8a7f160f33.js +0 -1
  52. package/assets/esri/core/workers/chunks/402de76b5de05615e111.js +0 -1
  53. package/assets/esri/core/workers/chunks/6dee40b94f94ee7bc4e4.js +0 -1
  54. package/assets/esri/core/workers/chunks/7a3e4cb5f64dac2cfe0e.js +0 -1
  55. package/assets/esri/core/workers/chunks/ba37ab9e560644dc1f18.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{_ as t}from"../../chunks/tslib.es6.js";import e from"../../Graphic.js";import a from"../../core/Accessor.js";import i from"../../core/Collection.js";import n from"../../core/Error.js";import{watch as r,initial as s}from"../../core/reactiveUtils.js";import{property as c}from"../../core/accessorSupport/decorators/property.js";import{cast as o}from"../../core/accessorSupport/decorators/cast.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{subclass as h}from"../../core/accessorSupport/decorators/subclass.js";import d from"../../rest/query/support/AttachmentInfo.js";import l from"../../rest/support/AttachmentQuery.js";import{getSourceLayer as m}from"../Feature/support/featureUtils.js";const p={editing:!1,operations:{add:!0,update:!0,delete:!0}},u=i.ofType(d);let f=class extends a{constructor(t){super(t),this._getAttachmentsPromise=null,this._attachmentLayer=null,this.capabilities={...p},this.activeAttachmentInfo=null,this.activeFileInfo=null,this.attachmentInfos=new u,this.fileInfos=new i,this.graphic=null,this.mode="view",this.filesEnabled=!1,this.addHandles(r((()=>this.graphic),(()=>this._graphicChanged()),s))}destroy(){this._attachmentLayer=null,this.graphic=null}castCapabilities(t){return{...p,...t}}get state(){return this._getAttachmentsPromise?"loading":this.graphic?"ready":"disabled"}get supportsResizeAttachments(){const{graphic:t}=this;if(!t)return!1;const e=t.layer||t.sourceLayer;return e?.loaded&&"capabilities"in e&&e.capabilities&&"attachment"in e.capabilities&&e.capabilities.attachment&&"supportsResize"in e.capabilities.attachment&&e.capabilities.attachment.supportsResize||!1}async getAttachments(){const{_attachmentLayer:t,attachmentInfos:e}=this;if(!t||"function"!=typeof t.queryAttachments)throw new n("invalid-layer","getAttachments(): A valid layer is required.");const a=this._getObjectId();if("number"!=typeof a)throw new n("invalid-object-id","getAttachments(): Numeric object id is required");const i=new l({objectIds:[a],returnMetadata:!0}),r=[],s=t.queryAttachments(i).then((t=>t[a]||r)).catch((()=>r));this._getAttachmentsPromise=s,this.notifyChange("state");const c=await s;return e.destroyAll(),c.length&&e.addMany(c),this._getAttachmentsPromise=null,this.notifyChange("state"),c}async addAttachment(t,e=this.graphic){const{_attachmentLayer:a,attachmentInfos:i,capabilities:r}=this;if(!e)throw new n("invalid-graphic","addAttachment(): A valid graphic is required.",{graphic:e});if(!t)throw new n("invalid-attachment","addAttachment(): An attachment is required.",{attachment:t});if(!r.operations?.add)throw new n("invalid-capabilities","addAttachment(): add capabilities are required.");if(!a||"function"!=typeof a.addAttachment)throw new n("invalid-layer","addAttachment(): A valid layer is required.");const s=a.addAttachment(e,t).then((t=>this._queryAttachment(t.objectId,e))),c=await s;return i.add(c),c}async deleteAttachment(t){const{_attachmentLayer:e,attachmentInfos:a,graphic:i,capabilities:r}=this;if(!t)throw new n("invalid-attachment-info","deleteAttachment(): An attachmentInfo is required.",{attachmentInfo:t});if(!r.operations?.delete)throw new n("invalid-capabilities","deleteAttachment(): delete capabilities are required.");if(!e||"function"!=typeof e.deleteAttachments)throw new n("invalid-layer","deleteAttachment(): A valid layer is required.");if(!i)throw new n("invalid-graphic","deleteAttachment(): A graphic is required.");const s=e.deleteAttachments(i,[t.id]).then((()=>t)),c=await s;return a.remove(c),c.destroy(),c}async updateAttachment(t,e=this.activeAttachmentInfo){const{_attachmentLayer:a,attachmentInfos:i,graphic:r,capabilities:s}=this;if(!t)throw new n("invalid-attachment","updateAttachment(): An attachment is required.",{attachment:t});if(!e)throw new n("invalid-attachment-info","updateAttachment(): An attachmentInfo is required.",{attachmentInfo:e});if(!s.operations?.update)throw new n("invalid-capabilities","updateAttachment(): Update capabilities are required.");const c=i.indexOf(e);if(!a||"function"!=typeof a.updateAttachment)throw new n("invalid-layer","updateAttachment(): A valid layer is required.");if(!r)throw new n("invalid-graphic","updateAttachment(): A graphic is required.");const o=a.updateAttachment(r,e.id,t).then((t=>this._queryAttachment(t.objectId))),h=await o;return i.splice(c,1,h),h}async commitFiles(){return await Promise.all(this.fileInfos.items.map((t=>this.addAttachment(t.form)))),this.fileInfos.removeAll(),this.getAttachments()}addFile(t,e){if(!t||!e)return null;const a={file:t,form:e};return this.fileInfos.add(a),a}updateFile(t,e,a=this.activeFileInfo){if(!t||!e||!a)return null;const i=this.fileInfos.indexOf(a);return i>-1&&this.fileInfos.splice(i,1,{file:t,form:e}),this.fileInfos.items[i]}deleteFile(t){const e=this.fileInfos.find((e=>e.file===t));return e?(this.fileInfos.remove(e),e):null}async _queryAttachment(t,e){const{_attachmentLayer:a}=this;if(!t||!a?.queryAttachments)throw new n("invalid-attachment-id","Could not query attachment.");const i=this._getObjectId(e);if("number"!=typeof i)throw new n("invalid-object-id","getAttachments(): Numeric object id is required");const r=new l({objectIds:[i],attachmentsWhere:`AttachmentId=${t}`,returnMetadata:!0});return a.queryAttachments(r).then((t=>t[i][0]))}_getObjectId(t=this.graphic){return t?.getObjectId()??null}_graphicChanged(){this.graphic&&(this._setAttachmentLayer(),this.getAttachments().catch((()=>this.attachmentInfos.destroyAll())))}_setAttachmentLayer(){const{graphic:t}=this,e=m(t);this._attachmentLayer=e?"scene"===e.type&&null!=e.associatedLayer?e.associatedLayer:e:null}};t([c()],f.prototype,"capabilities",void 0),t([o("capabilities")],f.prototype,"castCapabilities",null),t([c()],f.prototype,"activeAttachmentInfo",void 0),t([c()],f.prototype,"activeFileInfo",void 0),t([c({readOnly:!0,type:u})],f.prototype,"attachmentInfos",void 0),t([c()],f.prototype,"fileInfos",void 0),t([c({type:e})],f.prototype,"graphic",void 0),t([c()],f.prototype,"mode",void 0),t([c({readOnly:!0})],f.prototype,"state",null),t([c()],f.prototype,"filesEnabled",void 0),t([c({readOnly:!0})],f.prototype,"supportsResizeAttachments",null),f=t([h("esri.widgets.Attachments.AttachmentsViewModel")],f);const y=f;export{y as default};
5
+ import{_ as t}from"../../chunks/tslib.es6.js";import e from"../../Graphic.js";import i from"../../core/Accessor.js";import a from"../../core/Collection.js";import n from"../../core/Error.js";import{watch as r,initial as s}from"../../core/reactiveUtils.js";import{property as o}from"../../core/accessorSupport/decorators/property.js";import{cast as c}from"../../core/accessorSupport/decorators/cast.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{subclass as h}from"../../core/accessorSupport/decorators/subclass.js";import d from"../../popup/support/AttachmentsOrderByInfo.js";import l from"../../rest/query/support/AttachmentInfo.js";import p from"../../rest/support/AttachmentQuery.js";import{getSourceLayer as m}from"../Feature/support/featureUtils.js";const u={editing:!1,operations:{add:!0,update:!0,delete:!0}},f=a.ofType(l);let y=class extends i{constructor(t){super(t),this._getAttachmentsPromise=null,this._attachmentLayer=null,this.capabilities={...u},this.activeAttachmentInfo=null,this.activeFileInfo=null,this.attachmentInfos=new f,this.fileInfos=new a,this.graphic=null,this.mode="view",this.orderByFields=null,this.filesEnabled=!1,this.addHandles(r((()=>this.graphic),(()=>this._graphicChanged()),s))}destroy(){this._attachmentLayer=null,this.graphic=null}castCapabilities(t){return{...u,...t}}get state(){return this._getAttachmentsPromise?"loading":this.graphic?"ready":"disabled"}get supportsResizeAttachments(){const{graphic:t}=this;if(!t)return!1;const e=t.layer||t.sourceLayer;return e?.loaded&&"capabilities"in e&&e.capabilities&&"attachment"in e.capabilities&&e.capabilities.attachment&&"supportsResize"in e.capabilities.attachment&&e.capabilities.attachment.supportsResize||!1}async getAttachments(){const{_attachmentLayer:t,attachmentInfos:e,orderByFields:i}=this;if(!t||"function"!=typeof t.queryAttachments)throw new n("invalid-layer","getAttachments(): A valid layer is required.");const a=this._getObjectId();if("number"!=typeof a)throw new n("invalid-object-id","getAttachments(): Numeric object id is required");const r=i?.map((t=>`${t.field} ${"descending"===t.order?"DESC":"ASC"}`)),s=new p({objectIds:[a],returnMetadata:!0,orderByFields:r}),o=[],c=t.queryAttachments(s).then((t=>t[a]||o)).catch((()=>o));this._getAttachmentsPromise=c,this.notifyChange("state");const h=await c;return e.destroyAll(),h.length&&e.addMany(h),this._getAttachmentsPromise=null,this.notifyChange("state"),h}async addAttachment(t,e=this.graphic){const{_attachmentLayer:i,attachmentInfos:a,capabilities:r}=this;if(!e)throw new n("invalid-graphic","addAttachment(): A valid graphic is required.",{graphic:e});if(!t)throw new n("invalid-attachment","addAttachment(): An attachment is required.",{attachment:t});if(!r.operations?.add)throw new n("invalid-capabilities","addAttachment(): add capabilities are required.");if(!i||"function"!=typeof i.addAttachment)throw new n("invalid-layer","addAttachment(): A valid layer is required.");const s=i.addAttachment(e,t).then((t=>this._queryAttachment(t.objectId,e))),o=await s;return a.add(o),o}async deleteAttachment(t){const{_attachmentLayer:e,attachmentInfos:i,graphic:a,capabilities:r}=this;if(!t)throw new n("invalid-attachment-info","deleteAttachment(): An attachmentInfo is required.",{attachmentInfo:t});if(!r.operations?.delete)throw new n("invalid-capabilities","deleteAttachment(): delete capabilities are required.");if(!e||"function"!=typeof e.deleteAttachments)throw new n("invalid-layer","deleteAttachment(): A valid layer is required.");if(!a)throw new n("invalid-graphic","deleteAttachment(): A graphic is required.");const s=e.deleteAttachments(a,[t.id]).then((()=>t)),o=await s;return i.remove(o),o.destroy(),o}async updateAttachment(t,e=this.activeAttachmentInfo){const{_attachmentLayer:i,attachmentInfos:a,graphic:r,capabilities:s}=this;if(!t)throw new n("invalid-attachment","updateAttachment(): An attachment is required.",{attachment:t});if(!e)throw new n("invalid-attachment-info","updateAttachment(): An attachmentInfo is required.",{attachmentInfo:e});if(!s.operations?.update)throw new n("invalid-capabilities","updateAttachment(): Update capabilities are required.");const o=a.indexOf(e);if(!i||"function"!=typeof i.updateAttachment)throw new n("invalid-layer","updateAttachment(): A valid layer is required.");if(!r)throw new n("invalid-graphic","updateAttachment(): A graphic is required.");const c=i.updateAttachment(r,e.id,t).then((t=>this._queryAttachment(t.objectId))),h=await c;return a.splice(o,1,h),h}async commitFiles(){return await Promise.all(this.fileInfos.items.map((t=>this.addAttachment(t.form)))),this.fileInfos.removeAll(),this.getAttachments()}addFile(t,e){if(!t||!e)return null;const i={file:t,form:e};return this.fileInfos.add(i),i}updateFile(t,e,i=this.activeFileInfo){if(!t||!e||!i)return null;const a=this.fileInfos.indexOf(i);return a>-1&&this.fileInfos.splice(a,1,{file:t,form:e}),this.fileInfos.items[a]}deleteFile(t){const e=this.fileInfos.find((e=>e.file===t));return e?(this.fileInfos.remove(e),e):null}async _queryAttachment(t,e){const{_attachmentLayer:i}=this;if(!t||!i?.queryAttachments)throw new n("invalid-attachment-id","Could not query attachment.");const a=this._getObjectId(e);if("number"!=typeof a)throw new n("invalid-object-id","getAttachments(): Numeric object id is required");const r=new p({objectIds:[a],attachmentsWhere:`AttachmentId=${t}`,returnMetadata:!0});return i.queryAttachments(r).then((t=>t[a][0]))}_getObjectId(t=this.graphic){return t?.getObjectId()??null}_graphicChanged(){this.graphic&&(this._setAttachmentLayer(),this.getAttachments().catch((()=>this.attachmentInfos.destroyAll())))}_setAttachmentLayer(){const{graphic:t}=this,e=m(t);this._attachmentLayer=e?"scene"===e.type&&null!=e.associatedLayer?e.associatedLayer:e:null}};t([o()],y.prototype,"capabilities",void 0),t([c("capabilities")],y.prototype,"castCapabilities",null),t([o()],y.prototype,"activeAttachmentInfo",void 0),t([o()],y.prototype,"activeFileInfo",void 0),t([o({readOnly:!0,type:f})],y.prototype,"attachmentInfos",void 0),t([o()],y.prototype,"fileInfos",void 0),t([o({type:e})],y.prototype,"graphic",void 0),t([o()],y.prototype,"mode",void 0),t([o({type:[d]})],y.prototype,"orderByFields",void 0),t([o({readOnly:!0})],y.prototype,"state",null),t([o()],y.prototype,"filesEnabled",void 0),t([o({readOnly:!0})],y.prototype,"supportsResizeAttachments",null),y=t([h("esri.widgets.Attachments.AttachmentsViewModel")],y);const A=y;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{isSome as t}from"../core/arrayUtils.js";import{isAbortError as i}from"../core/promiseUtils.js";import{watch as s,initial as o,on as r}from"../core/reactiveUtils.js";import{escapeRegExpString as a}from"../core/string.js";import{property as n}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 c from"../portal/Portal.js";import{defaultUnitPropertyMetadata as d}from"../properties/defaultUnit.js";import m from"../rest/support/Stop.js";import p from"../symbols/SimpleMarkerSymbol.js";import h from"./Search.js";import u from"./Widget.js";import{DirectionsSearchTool as v}from"./Directions/DirectionsSearchTool.js";import g from"./Directions/DirectionsViewModel.js";import _ from"./Directions/DirectionsVisibleElements.js";import{formatDistance as w,formatDuration as y,DepartureTimeOption as b,getIconName as f}from"./Directions/support/directionsUtils.js";import{isArcGISWorldGeocoder as S,meteredArcGISLocatorUrl as M}from"./Search/support/locatorUtils.js";import{loadCalciteComponents as k}from"./support/componentsUtils.js";import{globalCss as I}from"./support/globalCss.js";import"./support/widgetUtils.js";import{messageBundle as F}from"./support/decorators/messageBundle.js";import{tsx as x}from"./support/jsxFactory.js";function T(e){const{branchName:i,displayText:s,exitName:o,intersectingName:r,name:n,objectId:l,towardName:c}=e;if(null==s)return null;const d=[i,o,r,n,c].filter(t).sort(((e,t)=>t.length-e.length)).map((e=>a(e)));if(!d.length)return s;const m=new RegExp(d.join("|"),"g"),p=s.matchAll(m);let h=0;const u=[];for(const{0:t,index:a}of p)u.push(s.slice(h,a),x("span",{class:$.labelEmphasize,key:`maneuver-${a}`},t)),h=a+t.length;return u.push(s.slice(h)),x("span",{id:`key-${l}`},u)}function C(e){const t=new Date(e);return new Date(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate())}const D="esri-directions",$={base:D,accordion:`${D}__accordion`,actionContainer:`${D}__action-container`,departureTimeOptions:`${D}__departure-time-options`,directionsHeader:`${D}__directions-header`,directionsHeaderStopNames:`${D}__directions-header-stop-names`,editFooter:`${D}__edit-footer`,editToolbar:`${D}__edit-toolbar`,editToolbarContainer:`${D}__edit-toolbar-container`,flexColumn:`${D}__flex-column`,flexRow:`${D}__flex-row`,labelEmphasize:`${D}__label-emphasize`,labelNoBottomMargin:`${D}__label-no-bottom-margin`,marginInlineMedium:`${D}__margin-inline-medium`,paddingMedium:`${D}__padding-medium`,panelHeaderAction:`${D}__panel-header-action`,panelHeaderActionColumns:`${D}__panel-header-action-columns`,panelTopBorder:`${D}__panel-top-border`,primaryFlowItem:`${D}__primary-flow-item`,primaryFooter:`${D}__primary-footer`,primaryFooterCentered:`${D}__primary-footer-centered`,saveError:`${D}__save-error`,saveErrorIcon:`${D}__save-error-icon`,saveErrorLabel:`${D}__save-error-label`,saveProcessLoader:`${D}__save-process-loader`,selectedFeatureContainer:`${D}__selected-feature-container`,separator:`${D}__separator`,stopContainer:`${D}__stop-container`,stopItem:`${D}__stop-item`};let A=class extends u{constructor(e,t){super(e,t),this._activeManeuver=null,this._placeholderStops=[new m,new m],this._portalFolderCombobox=null,this._portalFolders=null,this._portalItemNameInput=null,this._portalUserName=null,this._sections=null,this._stopsToSearches=new Map,this._currentFlowItem="primary",this._parentFlowItem="primary",this._saveState="initialized",this.headingLevel=2,this.messages=null,this.messagesUnits=null,this.searchProperties=null,this.viewModel=new g,this.visibleElements=new _}initialize(){this.addHandles([s((()=>this.viewModel.layer),(()=>{try{this.viewModel.load()}catch{}}),o),s((()=>this.viewModel.layer?.routeInfo),(()=>{this._sections=this._getStopSections()}),o)])}loadDependencies(){return k({accordion:()=>import("@esri/calcite-components/dist/components/calcite-accordion"),"accordion-item":()=>import("@esri/calcite-components/dist/components/calcite-accordion-item"),action:()=>import("@esri/calcite-components/dist/components/calcite-action"),button:()=>import("@esri/calcite-components/dist/components/calcite-button"),combobox:()=>import("@esri/calcite-components/dist/components/calcite-combobox"),"combobox-item":()=>import("@esri/calcite-components/dist/components/calcite-combobox-item"),flow:()=>import("@esri/calcite-components/dist/components/calcite-flow"),"flow-item":()=>import("@esri/calcite-components/dist/components/calcite-flow-item"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon"),input:()=>import("@esri/calcite-components/dist/components/calcite-input"),"input-date-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-date-picker"),"input-time-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-time-picker"),label:()=>import("@esri/calcite-components/dist/components/calcite-label"),list:()=>import("@esri/calcite-components/dist/components/calcite-list"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice"),panel:()=>import("@esri/calcite-components/dist/components/calcite-panel"),switch:()=>import("@esri/calcite-components/dist/components/calcite-switch")})}get apiKey(){return this.viewModel.apiKey}set apiKey(e){this.viewModel.apiKey=e}get goToOverride(){return this.viewModel.goToOverride}set goToOverride(e){this.viewModel.goToOverride=e}get icon(){return"right"}set icon(e){this._overrideIfSome("icon",e)}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get lastRoute(){return this.viewModel.lastRoute}get layer(){return this.viewModel.layer}set layer(e){this.viewModel.layer=e}get maxStops(){return this.viewModel.maxStops}set maxStops(e){this.viewModel.maxStops=e}get unit(){return this.defaultUnit}set unit(e){this._overrideIfSome("unit",e)}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}acquireSearch(e){const{view:t}=this.viewModel;if(this._stopsToSearches.has(e)){const i=this._stopsToSearches.get(e);return i.view=t,this._overrideDefaultSources(i),i}const i=new h({icon:!1,popupEnabled:!1,resultGraphicEnabled:!1,view:t,...this.searchProperties});return this._normalizeSearchSources(i),this.addHandles([r((()=>i.allSources),"change",(()=>this._normalizeSearchSources(i))),i.on("search-clear",(()=>{e.geometry=null,e.name=null,this.viewModel.layer?.removeResult()})),i.on("select-result",(()=>{const t=i.selectedResult;e.geometry=t?.feature.geometry,e.name=t?.name,this._solveRoute()})),s((()=>i.searchTerm),(t=>{e.name=t}))],i),this._stopsToSearches.set(e,i),i}getDirections(){return this.viewModel.getDirections()}render(){return x("div",{class:this.classes($.base,I.widget,I.panel)},x("calcite-flow",null,this._renderPrimaryFlowItem(),this._renderDirectionsFlowItem(),this._renderEditFlowItem(),this._renderSaveFlowItem()))}save(){return this.viewModel.save()}saveAs(e,t={}){return this.viewModel.saveAs(e,t)}zoomToRoute(){return this.viewModel.zoomToRoute()}_applyLocatorSourceOverrides({allSources:e}){for(const t of e)"url"in t&&t.url&&(t.locationType??="street",S(t.url)&&this.apiKey&&null==t.apiKey&&(t.apiKey=this.apiKey,t.url=M))}_disposeSearch(e){if(!e||!this._stopsToSearches.has(e))return;const t=this._stopsToSearches.get(e);this.removeHandles(t),t.destroy(),this._stopsToSearches.delete(e)}_getErrorDescription(){switch(this.viewModel.lastError?.name){case"directions-view-model:unable-to-route":return this.messages.errors.unableToRoute;case"directions-view-model:service-metadata-unavailable":return this.messages.errors.unableToLoadServiceMetadata;default:return this.messages.errors.unknownError}}_getNetworkFeatureName(e){switch(e.type){case"stop":switch(e.locationType){case"stop":default:return this.messages.networkFeatures.stops.stop;case"waypoint":return this.messages.networkFeatures.stops.waypoint;case"break":return this.messages.networkFeatures.stops.break}case"point-barrier":return this.messages.networkFeatures.pointBarrier;case"polyline-barrier":return this.messages.networkFeatures.polylineBarrier;case"polygon-barrier":return this.messages.networkFeatures.polygonBarrier}}_getRouteCostSummary(){const e=this.viewModel.layer?.routeInfo;if(!e)return null;const t=e.totalDistance??0,i=e.totalDuration??0,{messagesUnits:s,unit:o}=this;return{distance:w(s,t,o),duration:y(i)}}_getStopSections(){if(!this.viewModel.layer)return null;const{directionPoints:e,directionLines:t,stops:i}=this.viewModel.layer;if(!e||!t)return null;const s=[];let o=null;for(const r of e){const{objectId:e,stopId:a}=r;if(null!=a){const e=i.find((({objectId:e})=>e===a));o&&o.stop===e||(o={stop:e,directions:[]},s.push(o));continue}if(null==o)continue;const n=t.find((({directionPointId:t})=>t===e));null!=n&&o.directions.push({directionPoint:r,directionLine:n})}return s}_handleLocateStopAction(e){const{view:t}=this;if(!t)return;const i=new v({stop:e,view:t}),s="directions-search-tool";this.removeHandles(s),this.addHandles(i.on("click",(async i=>{if(i.mapPoint&&this._stopsToSearches.has(e)){const s=this._stopsToSearches.get(e),o=await s.search(i.mapPoint),r=o?.results?.[0].results?.[0];if(r){const{feature:i,name:o}=r;s.searchTerm=o,e.geometry=i.geometry,t.activeTool=null}}this.removeHandles(s)})),s),t.addAndActivateTool(i)}async _handleSaveLayerAsAction(){const e=c.getDefault();try{await e.signIn()}catch(t){if(i(t)||"identity-manager:user-aborted"===t.name)return;return this._parentFlowItem=this._currentFlowItem,this._currentFlowItem="save",void(this._saveState="connect-to-portal-error")}this._saveState="fetch-portal-information",this._parentFlowItem=this._currentFlowItem,this._currentFlowItem="save",this._portalUserName=e.user?.username;try{this._portalFolders=await(e.user?.fetchFolders())}catch{return void(this._saveState="fetch-portal-information-error")}this._saveState="save-layer"}_normalizeSearchSources(e){this._overrideDefaultSources(e),this._applyLocatorSourceOverrides(e)}_overrideDefaultSources(e){for(const t of e.viewModel.defaultSources)t.autoNavigate=!1}_renderClearRouteAction(){return x("calcite-action",{icon:"trash",key:"clear-route",onclick:()=>{this._currentFlowItem="primary",this.viewModel.reset()},slot:"header-menu-actions",text:this.messages.common.clear,textEnabled:!0})}_renderDeleteStopAction(e){const t=this.viewModel.layer?.stops;return x("calcite-action",{disabled:(t?.length??0)<=2,icon:"trash",onclick:()=>{this.viewModel.layer?.stops.remove(e),this._disposeSearch(e),this._solveRoute()},scale:"s",text:this.messages.deleteStop})}_renderDepartureTime(){const{DEPART_AT:e,NOW:t,UNSPECIFIED:i}=b;return x("calcite-label",{key:"departure-time",scale:"s"},this.messages.departureTime,x("calcite-combobox",{clearDisabled:!0,label:this.messages.departureTime,overlayPositioning:"fixed",scale:"s",selectionMode:"single",onCalciteComboboxChange:({currentTarget:e})=>{const{selectedItems:t}=e;t.length&&(this.viewModel.departureOption=t[0].value,this._solveRoute())}},x("calcite-combobox-item",{heading:this.messages.leaveNow,key:t,label:this.messages.leaveNow,selected:this.viewModel.departureOption===t,value:t}),x("calcite-combobox-item",{heading:this.messages.departAt,key:e,label:this.messages.departAt,selected:this.viewModel.departureOption===e,value:e}),x("calcite-combobox-item",{heading:this.messages.timeUnspecified,key:i,label:this.messages.timeUnspecified,selected:this.viewModel.departureOption===i,value:i})))}_renderDepartureTimeOptions(){return this.viewModel.departureOption!==b.DEPART_AT?null:x("div",{class:$.departureTimeOptions},x("calcite-input-date-picker",{scale:"s",valueAsDate:C(this.viewModel.departureIsoDate),onCalciteInputDatePickerChange:({currentTarget:{value:e}})=>{this.viewModel.departureIsoDate=e,this._solveRoute()}}),x("calcite-input-time-picker",{scale:"s",value:this.viewModel.departureIsoTime,onCalciteInputTimePickerChange:({currentTarget:{value:e}})=>{this.viewModel.departureIsoTime=e,this._solveRoute()}}))}_renderDirectionsFlowItem(){if("directions"!==this._currentFlowItem)return null;const e=this._getRouteCostSummary();if(!this._sections||!e)return null;const{distance:t,duration:i}=e,{formattedEta:s}=this.viewModel,o=this._sections.at(0)?.stop.name??"",r=this._sections.at(-1)?.stop.name??"";return x("calcite-flow-item",{key:"directions-flow-item",selected:"directions"===this._currentFlowItem,onCalciteFlowItemBack:e=>{e.stopPropagation(),this._currentFlowItem="primary"}},x("calcite-panel",{class:$.labelNoBottomMargin,overlayPositioning:"fixed",slot:"header-actions-end"},x("div",{class:$.directionsHeader,slot:"header-actions-start"},x("div",{class:$.flexRow},x("div",{class:$.flexColumn},x("calcite-label",null,this.messages.from),x("calcite-label",null,this.messages.to)),x("div",{class:$.directionsHeaderStopNames},x("calcite-label",null,o),x("calcite-label",null,r))),x("calcite-label",null,`${i} | ${t}`),s?x("calcite-label",null,s):null),this._renderRouteLayerActions()),x("calcite-accordion",{class:$.accordion,iconPosition:"start",selectionMode:"single"},this._sections.map(((e,t)=>{const{stop:i,directions:s}=e,{name:o}=i;return x("calcite-accordion-item",{expanded:0===t,heading:o??"",key:`stop-${t}`},x("calcite-action",{icon:"zoom-to-object",onclick:()=>{this.viewModel.centerAt(i)},slot:"actions-end",text:this.messages.panToStop}),this._renderDirectionTurns(s))}))))}_renderDirectionTurns(e){return x("calcite-list",{label:this.messages.drivingDirections,selectionMode:"none"},e.map(((e,t)=>{const{directionPoint:i,directionLine:s}=e,{distance:o,duration:r}=s,a=w(this.messagesUnits,o??0,this.unit),n=y(r??0),l=a&&n?`${a} | ${n}`:`${a||n}`,c=T(i),d=f(i.directionPointType);return x("calcite-list-item",{class:$.labelNoBottomMargin,key:`driving-direction-${t}`,onpointerenter:()=>{this.viewModel.highlight(s)},onpointerleave:()=>{this.viewModel.clearHighlights()},onCalciteListItemSelect:()=>{this._activeManeuver===s?this.zoomToRoute():(this._activeManeuver=s,this.viewModel.centerAt(s.geometry))}},x("calcite-icon",{icon:d,slot:"content-start"}),x("div",{slot:"content"},x("calcite-label",{layout:"inline",scale:"s"},c),x("calcite-label",{layout:"inline",scale:"s"},l)))})))}_renderEditFlowItem(){return"edit"!==this._currentFlowItem?null:x("calcite-flow-item",{heading:this.messages.editRoute,headingLevel:this.headingLevel,key:"edit-flow-item",selected:"edit"===this._currentFlowItem,onCalciteFlowItemBack:e=>{e.stopPropagation(),this.viewModel.stopEditing(),this._currentFlowItem="primary"}},x("div",{class:$.flexColumn,key:"edit-container"},x("div",{class:$.editToolbarContainer},x("div",{class:$.editToolbar},x("calcite-action",{icon:"flag",key:"add-stop",onclick:()=>{this.viewModel.create("stop")},scale:"s",text:this.messages.networkFeatures.stops.stop,textEnabled:!0}),x("calcite-action",{icon:"line",key:"add-barrier",onclick:()=>{this.viewModel.create("polyline-barrier")},scale:"s",text:this.messages.barrier,textEnabled:!0}),x("calcite-action",{disabled:this.viewModel.autoSolve,icon:"refresh",key:"solve",onclick:()=>{this._solveRoute()},scale:"s",text:this.messages.solve}),x("calcite-action",{active:this.viewModel.autoSolve,icon:"app-update",key:"auto-solve",onclick:()=>{this.viewModel.autoSolve=!this.viewModel.autoSolve},scale:"s",text:this.messages.automaticallySolve}))),x("div",{class:$.selectedFeatureContainer},x("calcite-list",{label:this.messages.selectedNetworkFeatures,scale:"s",selectionMode:"none"},this.viewModel.selectedNetworkFeatures?.toArray().map(((e,t)=>x("calcite-list-item",{description:this._getNetworkFeatureName(e),key:`network-feature-${t}`,label:e.name??e.objectId?.toString()??this.messages.unnamed},x("calcite-action",{icon:"trash",onclick:()=>{this.viewModel.delete()},scale:"s",slot:"actions-end",text:this.messages.common.delete})))))),x("div",{class:$.editFooter},x("calcite-button",{onclick:e=>{e.stopPropagation(),this.viewModel.stopEditing(),this._currentFlowItem="primary"},scale:"m",width:"full"},this.messages.common.done))))}_renderFooter(){if(!this.viewModel.layer)return x("div",{class:$.primaryFooter,key:"footer-missing-layer"},x("calcite-notice",{icon:"information",open:!0},x("calcite-label",{class:$.labelNoBottomMargin,slot:"message"},this.messages.missingLayer)));if("unauthenticated"===this.viewModel.state)return x("div",{class:$.primaryFooterCentered,key:"footer-sign-in"},x("calcite-label",null,this.messages.signInRequired),x("calcite-button",{onclick:()=>{this.viewModel.load().catch((()=>{}))}},this.messages.common.auth.signIn));if("error"===this.viewModel.state&&!this.viewModel.serviceDescription)return x("div",{class:$.primaryFooter,key:"footer-service-error"},x("calcite-notice",{icon:"exclamation-mark-circle",kind:"danger",open:!0},x("calcite-label",{class:$.labelNoBottomMargin,slot:"message"},this._getErrorDescription())));if(!this.viewModel.layer?.routeInfo)return x("div",{class:$.primaryFooter,key:"footer-unsolved-route"},x("calcite-notice",{icon:"information",open:!0},x("calcite-label",{class:$.labelNoBottomMargin,slot:"message"},this.messages.directionsPlaceholder)));const e=this._getRouteCostSummary();if(!e||!this.viewModel.layer?.directionPoints)return x("div",{class:$.primaryFooter,key:"footer-invalid-route"},x("calcite-notice",{icon:"exclamation-mark-triangle",kind:"danger",open:!0},x("calcite-label",{class:$.labelNoBottomMargin,slot:"message"},this.messages.invalidRoute)));const{distance:t,duration:i}=e,{formattedEta:s}=this.viewModel;return x("calcite-panel",{class:$.panelTopBorder,key:"footer-directions-summary",overlayPositioning:"fixed"},x("calcite-action",{onclick:()=>{this._currentFlowItem="directions"},slot:"header-actions-start",text:this.messages.viewDrivingDirections},x("div",{class:$.panelHeaderAction},x("div",{class:this.classes($.labelNoBottomMargin,$.panelHeaderActionColumns)},x("calcite-label",{class:$.labelEmphasize},`${i} | ${t}`),x("calcite-label",{scale:"s"},s)),x("calcite-icon",{icon:"chevron-right"}))),this._renderRouteLayerActions())}_renderInteractiveRouteActions(){return x("div",{class:$.actionContainer,key:"interactive-route-action-container"},x("calcite-button",{appearance:"outline",iconStart:"plus",kind:"neutral",label:this.messages.addStop,onclick:()=>{const e=new p;this.viewModel.layer?.stops.add(new m({symbol:e}))}},this.messages.addStop),x("calcite-button",{appearance:"outline",iconStart:"pencil",kind:"neutral",label:this.messages.editRoute,onclick:()=>{this._currentFlowItem="edit",this.viewModel.startEditing()}},this.messages.editRoute),x("calcite-button",{appearance:"outline",bind:this,iconStart:"arrow-up-down",kind:"neutral",label:this.messages.reverseStops,onclick:()=>{this.viewModel.layer?.stops.reverse(),this._resetStopSequence(),this._solveRoute()}}))}_renderLocateStopAction(e){if(null!=e.name||null!=e.geometry)return null;const t=this.viewModel.layer?.stops.indexOf(e)??-1;return x("calcite-action",{icon:"select",key:`stop-location-action-${t}`,onclick:()=>this._handleLocateStopAction(e),scale:"s",text:this.messages.pickALocationOnTheMap})}_renderOptimizeStopOrder(){const{routeParameters:e}=this.viewModel,{findBestSequence:t,preserveFirstStop:i,preserveLastStop:s}=e;return x("div",null,x("calcite-label",{layout:"inline-space-between",scale:"s"},this.messages.optimizeOrder,x("calcite-switch",{checked:t,scale:"s",onCalciteSwitchChange:({target:t})=>{e.findBestSequence=t.checked,t.checked||this._resetStopSequence(),this._solveRoute()}})),t?[x("calcite-label",{key:"preserve-first-stop",layout:"inline-space-between",scale:"s"},this.messages.preserveFirstStop,x("calcite-switch",{checked:i,scale:"s",onCalciteSwitchChange:({target:{checked:t}})=>{e.preserveFirstStop=t,this._resetStopSequence(),this._solveRoute()}})),x("calcite-label",{key:"preserve-last-stop",layout:"inline-space-between",scale:"s"},this.messages.preserveLastStop,x("calcite-switch",{checked:s,scale:"s",onCalciteSwitchChange:({target:{checked:t}})=>{e.preserveLastStop=t,this._resetStopSequence(),this._solveRoute()}}))]:null)}_renderPrimaryFlowItem(){return x("calcite-flow-item",{key:"primary-flow-item",loading:"initializing"===this.viewModel.state,selected:"primary"===this._currentFlowItem},x("calcite-panel",{class:$.primaryFlowItem,disabled:!this.viewModel.layer||"unauthenticated"===this.viewModel.state||"error"===this.viewModel.state&&!this.viewModel.serviceDescription},this._renderStops(),this._renderInteractiveRouteActions(),this._renderSeparator(),this._renderRouteSolveOptions()),this._renderFooter())}_renderRouteLayerActions(){return[this._renderClearRouteAction(),this._renderSaveLayerAction(),this._renderSaveLayerAsAction(),this._renderViewItemDetailsAction()]}_renderRouteSolveOptions(){return x("div",{class:$.marginInlineMedium,key:"route-solve-options"},this._renderTravelModes(),this._renderDepartureTime(),this._renderDepartureTimeOptions(),this._renderOptimizeStopOrder())}_renderSaveContent(){switch(this._saveState){case"initialized":return this._renderSaveInitialized();case"connect-to-portal":return this._renderSaveProcessing(this.messages.identity.lblSigning);case"connect-to-portal-error":return this._renderSaveError(this.messages.errors.authenticating);case"fetch-portal-information":return this._renderSaveProcessing(this.messages.processing.fetching);case"fetch-portal-information-error":return this._renderSaveError(this.messages.errors.fetching);case"save-layer":return this._renderSaveLayerSettings();case"saving":return this._renderSaveProcessing(this.messages.processing.saving);case"saving-error":return this._renderSaveError(this.messages.errors.saving)}}_renderSaveError(e){return x("calcite-panel",{class:$.paddingMedium,key:"save-layer-error"},x("div",{class:$.saveError},x("calcite-icon",{class:$.saveErrorIcon,icon:"exclamation-mark-triangle",scale:"l",textLabel:this.messages.common.errorMessage}),x("calcite-label",{class:$.saveErrorLabel},e)),x("calcite-button",{appearance:"outline",onclick:()=>{this._currentFlowItem=this._parentFlowItem},slot:"footer-actions",width:"full"},this.messages.common.close))}_renderSaveInitialized(){return x("calcite-panel",{class:$.paddingMedium,key:"save-layer-initialized"})}_renderSaveFlowItem(){return"save"!==this._currentFlowItem?null:x("calcite-flow-item",{heading:this.messages.saveLayer,headingLevel:this.headingLevel,key:"save-layer-flow-item",selected:"save"===this._currentFlowItem,onCalciteFlowItemBack:e=>{e.stopPropagation(),this._currentFlowItem=this._parentFlowItem}},this._renderSaveContent())}_renderSaveLayerAction(){if(!this.visibleElements.saveButton)return null;const e=this.viewModel.layer,t=e?.routeInfo,i=e?.portalItem?.itemControl;return x("calcite-action",{disabled:!(!!t&&("admin"===i||"update"===i)),icon:"save",key:"save-route",onclick:()=>{this.viewModel.layer?.save()},slot:"header-menu-actions",text:this.messages.common.save,textEnabled:!0})}_renderSaveLayerAsAction(){if(!this.visibleElements.saveAsButton)return null;const e=!this.viewModel.layer?.routeInfo;return x("calcite-action",{disabled:e,icon:"save-as",key:"save-as-route",onclick:()=>{this._handleSaveLayerAsAction()},slot:"header-menu-actions",text:this.messages.common.saveAs,textEnabled:!0})}_renderSaveLayerSettings(){if(null==this.layer||null==this._portalFolders||null==this._portalUserName)return this._renderSaveInitialized();const{stops:e}=this.layer,t=`${e.at(0).name} - ${e.at(-1).name}`,i=this._portalFolders.map((e=>x("calcite-combobox-item",{heading:e.title??"",key:`${D}-folder-${e.id}`,value:e.id})));return i.unshift(x("calcite-combobox-item",{heading:`${this._portalUserName} (${this.messages.common.home})`,key:`${D}-folder-home`,selected:!0,value:null})),x("calcite-panel",{key:"save-layer-panel"},x("div",{class:$.paddingMedium},x("calcite-label",null,this.messages.laverName,x("calcite-input",{afterCreate:e=>{this._portalItemNameInput=e},label:this.messages.laverName,value:t})),x("calcite-label",null,this.messages.saveInFolder,x("calcite-combobox",{afterCreate:e=>{this._portalFolderCombobox=e},label:this.messages.saveInFolder,overlayPositioning:"fixed",selectionMode:"single"},i))),x("calcite-button",{onclick:()=>{if(this._saveState="saving",null==this.layer||null==this._portalFolders)return;const e=this._portalItemNameInput?.value,t=this._portalFolderCombobox?.value,i=this._portalFolders.find((({id:e})=>e===t));this.layer.saveAs({title:e},{folder:i}).then((()=>{this._currentFlowItem=this._parentFlowItem})).catch((()=>{this._saveState="saving-error"}))},slot:"footer-actions",width:"full"},this.messages.common.save),x("calcite-button",{appearance:"outline",onclick:()=>{this._currentFlowItem=this._parentFlowItem},slot:"footer-actions",width:"full"},this.messages.common.cancel))}_renderSaveProcessing(e){return x("calcite-panel",{class:$.marginInlineMedium,key:"save-layer-processing"},x("calcite-loader",{class:$.saveProcessLoader,label:e,text:e}))}_renderSeparator(){return x("div",{class:$.separator,key:"separator"})}_renderStop(e){const t=this.acquireSearch(e);null!=e.name&&(t.searchTerm=e.name);const i=this._renderLocateStopAction(e),s=this._renderDeleteStopAction(e),o=this.viewModel.layer?.stops.indexOf(e)??-1;return x("calcite-list-item",{key:`stop-${o}`,value:e},x("div",{class:$.flexRow,slot:"actions-end"},i,s),x("div",{class:$.stopItem,slot:"content"},t.render()))}_renderStops(){const e=this.viewModel.layer?.stops.toArray()??this._placeholderStops;for(const t of this._stopsToSearches.keys())e.includes(t)||this._disposeSearch(t);return x("div",{class:$.stopContainer,key:$.stopContainer},x("calcite-list",{dragEnabled:!0,label:this.messages.widgetLabel,scale:"s",onCalciteListOrderChange:({detail:e})=>{this.viewModel.layer?.stops.reorder(e.dragEl.value,e.newIndex),this._resetStopSequence(),this._solveRoute()}},e.map((e=>this._renderStop(e)))))}_renderTravelModes(){return this.viewModel.travelModes.length?x("calcite-label",{key:"travel-modes",scale:"s"},this.messages.mode,x("calcite-combobox",{clearDisabled:!0,label:"mode",overlayPositioning:"fixed",scale:"s",selectionMode:"single",onCalciteComboboxChange:({currentTarget:e})=>{const{selectedItems:t}=e;t.length&&(this.viewModel.selectedTravelMode=t[0].value,this._solveRoute())}},this.viewModel.travelModes.map((e=>x("calcite-combobox-item",{heading:e.name,key:e.id,label:e.name,selected:this.viewModel.selectedTravelMode?.id===e.id,value:e}))))):null}_renderViewItemDetailsAction(){if(!this.visibleElements.layerDetails)return null;const e=this.viewModel.layer?.portalItem;return x("calcite-action",{disabled:!e,icon:"launch",key:"open-route-details-link",onclick:()=>{e&&window.open(`${e.portal.url}/home/item.html?id=${e.id}`,"_blank")},slot:"header-menu-actions",text:this.messages.viewLayerDetails,textEnabled:!0})}_resetStopSequence(){this.viewModel.layer?.stops.forEach((e=>{e.sequence=null}))}async _solveRoute(){this.viewModel.updateDepartureTime();const e=this.viewModel.layer?.stops.filter((({geometry:e})=>null!=e));if(e&&!(e.length<2))try{await this.viewModel.getDirections()}catch{}}};e([n()],A.prototype,"_currentFlowItem",void 0),e([n()],A.prototype,"_saveState",void 0),e([n()],A.prototype,"apiKey",null),e([n(d)],A.prototype,"defaultUnit",void 0),e([n()],A.prototype,"goToOverride",null),e([n()],A.prototype,"headingLevel",void 0),e([n()],A.prototype,"icon",null),e([n()],A.prototype,"label",null),e([n({readOnly:!0})],A.prototype,"lastRoute",null),e([n()],A.prototype,"layer",null),e([n()],A.prototype,"maxStops",null),e([n(),F("esri/widgets/Directions/t9n/Directions")],A.prototype,"messages",void 0),e([n(),F("esri/core/t9n/Units")],A.prototype,"messagesUnits",void 0),e([n()],A.prototype,"searchProperties",void 0),e([n()],A.prototype,"unit",null),e([n()],A.prototype,"view",null),e([n({type:g})],A.prototype,"viewModel",void 0),e([n({type:_,nonNullable:!0})],A.prototype,"visibleElements",void 0),A=e([l("esri.widgets.Directions")],A);const E=A;export{E as default};
5
+ import{_ as e}from"../chunks/tslib.es6.js";import{isSome as t}from"../core/arrayUtils.js";import{isAbortError as i}from"../core/promiseUtils.js";import{watch as s,initial as o,on as r}from"../core/reactiveUtils.js";import{escapeRegExpString as a}from"../core/string.js";import{property as n}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 c from"../portal/Portal.js";import{defaultUnitPropertyMetadata as d}from"../properties/defaultUnit.js";import m from"../rest/support/Stop.js";import p from"../symbols/SimpleMarkerSymbol.js";import u from"./Search.js";import h from"./Widget.js";import{DirectionsSearchTool as v}from"./Directions/DirectionsSearchTool.js";import g from"./Directions/DirectionsViewModel.js";import _ from"./Directions/DirectionsVisibleElements.js";import{formatDistance as w,formatDuration as y,DepartureTimeOption as b,getIconName as f}from"./Directions/support/directionsUtils.js";import{isArcGISWorldGeocoder as S,meteredArcGISLocatorUrl as M}from"./Search/support/locatorUtils.js";import{loadCalciteComponents as k}from"./support/componentsUtils.js";import{globalCss as I}from"./support/globalCss.js";import"./support/widgetUtils.js";import{messageBundle as F}from"./support/decorators/messageBundle.js";import{tsx as x}from"./support/jsxFactory.js";function T(e){const{branchName:i,displayText:s,exitName:o,intersectingName:r,name:n,objectId:l,towardName:c}=e;if(null==s)return null;const d=[i,o,r,n,c].filter(t).sort(((e,t)=>t.length-e.length)).map((e=>a(e)));if(!d.length)return s;const m=new RegExp(d.join("|"),"g"),p=s.matchAll(m);let u=0;const h=[];for(const{0:t,index:a}of p)h.push(s.slice(u,a),x("span",{class:$.labelEmphasize,key:`maneuver-${a}`},t)),u=a+t.length;return h.push(s.slice(u)),x("span",{id:`key-${l}`},h)}function C(e){const t=new Date(e);return new Date(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate())}const D="esri-directions",$={base:D,accordion:`${D}__accordion`,actionContainer:`${D}__action-container`,departureTimeOptions:`${D}__departure-time-options`,directionsHeader:`${D}__directions-header`,directionsHeaderStopName:`${D}__directions-header-stop-name`,editFooter:`${D}__edit-footer`,editToolbar:`${D}__edit-toolbar`,editToolbarContainer:`${D}__edit-toolbar-container`,flexColumn:`${D}__flex-column`,flexRow:`${D}__flex-row`,headerStops:`${D}__header-stops`,labelEmphasize:`${D}__label-emphasize`,labelNoBottomMargin:`${D}__label-no-bottom-margin`,marginInlineMedium:`${D}__margin-inline-medium`,paddingMedium:`${D}__padding-medium`,primaryFlowItem:`${D}__primary-flow-item`,primaryFooter:`${D}__primary-footer`,primaryFooterCentered:`${D}__primary-footer-centered`,routeItem:`${D}__route-item`,routeItemButton:`${D}__route-item-button`,routeItemButtonContent:`${D}__route-item-button-content`,routeItemLabel:`${D}__route-item-label`,routeItemDescription:`${D}__route-item-description`,saveError:`${D}__save-error`,saveErrorIcon:`${D}__save-error-icon`,saveErrorLabel:`${D}__save-error-label`,saveProcessLoader:`${D}__save-process-loader`,selectedFeatureContainer:`${D}__selected-feature-container`,separator:`${D}__separator`,stopContainer:`${D}__stop-container`,stopItem:`${D}__stop-item`};let L=class extends h{constructor(e,t){super(e,t),this._activeManeuver=null,this._placeholderStops=[new m,new m],this._portalFolderCombobox=null,this._portalFolders=null,this._portalItemNameInput=null,this._portalUserName=null,this._sections=null,this._stopsToSearches=new Map,this._currentFlowItem="primary",this._parentFlowItem="primary",this._saveState="initialized",this.headingLevel=2,this.messages=null,this.messagesUnits=null,this.searchProperties=null,this.viewModel=new g,this.visibleElements=new _}initialize(){this.addHandles([s((()=>this.viewModel.layer),(()=>{try{this.viewModel.load()}catch{}}),o),s((()=>this.viewModel.layer?.routeInfo),(()=>{this._sections=this._getStopSections()}),o)])}loadDependencies(){return k({accordion:()=>import("@esri/calcite-components/dist/components/calcite-accordion"),"accordion-item":()=>import("@esri/calcite-components/dist/components/calcite-accordion-item"),action:()=>import("@esri/calcite-components/dist/components/calcite-action"),button:()=>import("@esri/calcite-components/dist/components/calcite-button"),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"),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"),input:()=>import("@esri/calcite-components/dist/components/calcite-input"),"input-date-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-date-picker"),"input-time-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-time-picker"),label:()=>import("@esri/calcite-components/dist/components/calcite-label"),list:()=>import("@esri/calcite-components/dist/components/calcite-list"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice"),panel:()=>import("@esri/calcite-components/dist/components/calcite-panel"),switch:()=>import("@esri/calcite-components/dist/components/calcite-switch")})}get apiKey(){return this.viewModel.apiKey}set apiKey(e){this.viewModel.apiKey=e}get goToOverride(){return this.viewModel.goToOverride}set goToOverride(e){this.viewModel.goToOverride=e}get icon(){return"right"}set icon(e){this._overrideIfSome("icon",e)}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get lastRoute(){return this.viewModel.lastRoute}get layer(){return this.viewModel.layer}set layer(e){this.viewModel.layer=e}get maxStops(){return this.viewModel.maxStops}set maxStops(e){this.viewModel.maxStops=e}get unit(){return this.defaultUnit}set unit(e){this._overrideIfSome("unit",e)}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}acquireSearch(e){const{view:t}=this.viewModel;if(this._stopsToSearches.has(e)){const i=this._stopsToSearches.get(e);return i.view=t,this._overrideDefaultSources(i),i}const i=new u({icon:!1,popupEnabled:!1,resultGraphicEnabled:!1,view:t,...this.searchProperties});return this._normalizeSearchSources(i),this.addHandles([r((()=>i.allSources),"change",(()=>this._normalizeSearchSources(i))),i.on("search-clear",(()=>{e.geometry=null,e.name=null,this.viewModel.layer?.removeResult()})),i.on("select-result",(()=>{const t=i.selectedResult;e.geometry=t?.feature.geometry,e.name=t?.name,this._solveRoute()})),s((()=>i.searchTerm),(t=>{e.name=t}))],i),this._stopsToSearches.set(e,i),i}getDirections(){return this.viewModel.getDirections()}render(){return x("div",{class:this.classes($.base,I.widget,I.panel)},x("calcite-flow",null,this._renderPrimaryFlowItem(),this._renderDirectionsFlowItem(),this._renderEditFlowItem(),this._renderSaveFlowItem()))}save(){return this.viewModel.save()}saveAs(e,t={}){return this.viewModel.saveAs(e,t)}zoomToRoute(){return this.viewModel.zoomToRoute()}_applyLocatorSourceOverrides({allSources:e}){for(const t of e)"url"in t&&t.url&&(t.locationType??="street",S(t.url)&&this.apiKey&&null==t.apiKey&&(t.apiKey=this.apiKey,t.url=M))}_disposeSearch(e){if(!e||!this._stopsToSearches.has(e))return;const t=this._stopsToSearches.get(e);this.removeHandles(t),t.destroy(),this._stopsToSearches.delete(e)}_getErrorDescription(){switch(this.viewModel.lastError?.name){case"directions-view-model:unable-to-route":return this.messages.errors.unableToRoute;case"directions-view-model:service-metadata-unavailable":return this.messages.errors.unableToLoadServiceMetadata;default:return this.messages.errors.unknownError}}_getNetworkFeatureName(e){switch(e.type){case"stop":switch(e.locationType){case"stop":default:return this.messages.networkFeatures.stops.stop;case"waypoint":return this.messages.networkFeatures.stops.waypoint;case"break":return this.messages.networkFeatures.stops.break}case"point-barrier":return this.messages.networkFeatures.pointBarrier;case"polyline-barrier":return this.messages.networkFeatures.polylineBarrier;case"polygon-barrier":return this.messages.networkFeatures.polygonBarrier}}_getRouteCostSummary(){const e=this.viewModel.layer?.routeInfo;if(!e)return null;const t=e.totalDistance??0,i=e.totalDuration??0,{messagesUnits:s,unit:o}=this;return{distance:w(s,t,o),duration:y(i)}}_getStopSections(){if(!this.viewModel.layer)return null;const{directionPoints:e,directionLines:t,stops:i}=this.viewModel.layer;if(!e||!t)return null;const s=[];let o=null;for(const r of e){const{objectId:e,stopId:a}=r;if(null!=a){const e=i.find((({objectId:e})=>e===a));o&&o.stop===e||(o={stop:e,directions:[]},s.push(o));continue}if(null==o)continue;const n=t.find((({directionPointId:t})=>t===e));null!=n&&o.directions.push({directionPoint:r,directionLine:n})}return s}_handleLocateStopAction(e){const{view:t}=this;if(!t)return;const i=new v({stop:e,view:t}),s="directions-search-tool";this.removeHandles(s),this.addHandles(i.on("click",(async i=>{if(i.mapPoint&&this._stopsToSearches.has(e)){const s=this._stopsToSearches.get(e),o=await s.search(i.mapPoint),r=o?.results?.[0].results?.[0];if(r){const{feature:i,name:o}=r;s.searchTerm=o,e.geometry=i.geometry,t.activeTool=null}}this.removeHandles(s)})),s),t.addAndActivateTool(i)}async _handleSaveLayerAsAction(){const e=c.getDefault();try{await e.signIn()}catch(t){if(i(t)||"identity-manager:user-aborted"===t.name)return;return this._parentFlowItem=this._currentFlowItem,this._currentFlowItem="save",void(this._saveState="connect-to-portal-error")}this._saveState="fetch-portal-information",this._parentFlowItem=this._currentFlowItem,this._currentFlowItem="save",this._portalUserName=e.user?.username;try{this._portalFolders=await(e.user?.fetchFolders())}catch{return void(this._saveState="fetch-portal-information-error")}this._saveState="save-layer"}_normalizeSearchSources(e){this._overrideDefaultSources(e),this._applyLocatorSourceOverrides(e)}_overrideDefaultSources(e){for(const t of e.viewModel.defaultSources)t.autoNavigate=!1}_renderClearRouteAction(e){return x("calcite-action",{icon:"trash",key:"clear-route",onclick:()=>{this._currentFlowItem="primary",this.viewModel.reset()},...e,text:this.messages.common.clear,textEnabled:!0})}_renderDeleteStopAction(e){const t=this.viewModel.layer?.stops;return x("calcite-action",{disabled:(t?.length??0)<=2,icon:"trash",onclick:()=>{this.viewModel.layer?.stops.remove(e),this._disposeSearch(e),this._solveRoute()},scale:"s",text:this.messages.deleteStop})}_renderDepartureTime(){const{DEPART_AT:e,NOW:t,UNSPECIFIED:i}=b;return x("calcite-label",{key:"departure-time",scale:"s"},this.messages.departureTime,x("calcite-combobox",{clearDisabled:!0,label:this.messages.departureTime,overlayPositioning:"fixed",scale:"s",selectionMode:"single",onCalciteComboboxChange:({currentTarget:e})=>{const{selectedItems:t}=e;t.length&&(this.viewModel.departureOption=t[0].value,this._solveRoute())}},x("calcite-combobox-item",{heading:this.messages.leaveNow,key:t,label:this.messages.leaveNow,selected:this.viewModel.departureOption===t,value:t}),x("calcite-combobox-item",{heading:this.messages.departAt,key:e,label:this.messages.departAt,selected:this.viewModel.departureOption===e,value:e}),x("calcite-combobox-item",{heading:this.messages.timeUnspecified,key:i,label:this.messages.timeUnspecified,selected:this.viewModel.departureOption===i,value:i})))}_renderDepartureTimeOptions(){return this.viewModel.departureOption!==b.DEPART_AT?null:x("div",{class:$.departureTimeOptions},x("calcite-input-date-picker",{scale:"s",valueAsDate:C(this.viewModel.departureIsoDate),onCalciteInputDatePickerChange:({currentTarget:{value:e}})=>{this.viewModel.departureIsoDate=e,this._solveRoute()}}),x("calcite-input-time-picker",{scale:"s",value:this.viewModel.departureIsoTime,onCalciteInputTimePickerChange:({currentTarget:{value:e}})=>{this.viewModel.departureIsoTime=e,this._solveRoute()}}))}_renderDirectionsFlowItem(){if("directions"!==this._currentFlowItem)return null;const e=this._getRouteCostSummary();if(!this._sections||!e)return null;const{distance:t,duration:i}=e,{formattedEta:s}=this.viewModel,o=this._sections.at(0)?.stop.name??"",r=this._sections.at(-1)?.stop.name??"";return x("calcite-flow-item",{key:"directions-flow-item",overlayPositioning:"fixed",selected:"directions"===this._currentFlowItem,onCalciteFlowItemBack:e=>{e.stopPropagation(),this._currentFlowItem="primary"}},x("div",{class:$.directionsHeader,slot:"header-content"},x("div",{class:$.headerStops},x("span",null,this.messages.from)," ",x("span",{class:$.directionsHeaderStopName},o),x("span",null,this.messages.to)," ",x("span",{class:$.directionsHeaderStopName},r)),x("div",{class:$.flexColumn},x("span",null,`${i} (${t})`),s?x("span",null,s):null)),this._renderRouteLayerActions({slot:"header-menu-actions"}),x("calcite-accordion",{class:$.accordion,iconPosition:"start",selectionMode:"single"},this._sections.map(((e,t)=>{const{stop:i,directions:s}=e,{name:o}=i;return x("calcite-accordion-item",{expanded:0===t,heading:o??"",key:`stop-${t}`},x("calcite-action",{icon:"zoom-to-object",onclick:()=>{this.viewModel.centerAt(i)},slot:"actions-end",text:this.messages.panToStop}),this._renderDirectionTurns(s))}))))}_renderDirectionTurns(e){return x("calcite-list",{label:this.messages.drivingDirections,selectionMode:"none"},e.map(((e,t)=>{const{directionPoint:i,directionLine:s}=e,{distance:o,duration:r}=s,a=w(this.messagesUnits,o??0,this.unit),n=y(r??0),l=a&&n?`${a} | ${n}`:`${a||n}`,c=T(i),d=f(i.directionPointType);return x("calcite-list-item",{class:$.labelNoBottomMargin,key:`driving-direction-${t}`,onpointerenter:()=>{this.viewModel.highlight(s)},onpointerleave:()=>{this.viewModel.clearHighlights()},onCalciteListItemSelect:()=>{this._activeManeuver===s?this.zoomToRoute():(this._activeManeuver=s,this.viewModel.centerAt(s.geometry))}},x("calcite-icon",{icon:d,slot:"content-start"}),x("div",{slot:"content"},x("calcite-label",{layout:"inline",scale:"s"},c),x("calcite-label",{layout:"inline",scale:"s"},l)))})))}_renderEditFlowItem(){return"edit"!==this._currentFlowItem?null:x("calcite-flow-item",{heading:this.messages.editRoute,headingLevel:this.headingLevel,key:"edit-flow-item",selected:"edit"===this._currentFlowItem,onCalciteFlowItemBack:e=>{e.stopPropagation(),this.viewModel.stopEditing(),this._currentFlowItem="primary"}},x("div",{class:$.flexColumn,key:"edit-container"},x("div",{class:$.editToolbarContainer},x("div",{class:$.editToolbar},x("calcite-action",{icon:"flag",key:"add-stop",onclick:()=>{this.viewModel.create("stop")},scale:"s",text:this.messages.networkFeatures.stops.stop,textEnabled:!0}),x("calcite-action",{icon:"line",key:"add-barrier",onclick:()=>{this.viewModel.create("polyline-barrier")},scale:"s",text:this.messages.barrier,textEnabled:!0}),x("calcite-action",{disabled:this.viewModel.autoSolve,icon:"refresh",key:"solve",onclick:()=>{this._solveRoute()},scale:"s",text:this.messages.solve}),x("calcite-action",{active:this.viewModel.autoSolve,icon:"app-update",key:"auto-solve",onclick:()=>{this.viewModel.autoSolve=!this.viewModel.autoSolve},scale:"s",text:this.messages.automaticallySolve}))),x("div",{class:$.selectedFeatureContainer},x("calcite-list",{label:this.messages.selectedNetworkFeatures,scale:"s",selectionMode:"none"},this.viewModel.selectedNetworkFeatures?.toArray().map(((e,t)=>x("calcite-list-item",{description:this._getNetworkFeatureName(e),key:`network-feature-${t}`,label:e.name??e.objectId?.toString()??this.messages.unnamed},x("calcite-action",{icon:"trash",onclick:()=>{this.viewModel.delete()},scale:"s",slot:"actions-end",text:this.messages.common.delete})))))),x("div",{class:$.editFooter},x("calcite-button",{onclick:e=>{e.stopPropagation(),this.viewModel.stopEditing(),this._currentFlowItem="primary"},scale:"m",width:"full"},this.messages.common.done))))}_renderFooter(){if(!this.viewModel.layer)return x("div",{class:$.primaryFooter,key:"footer-missing-layer"},x("calcite-notice",{icon:"information",open:!0},x("calcite-label",{class:$.labelNoBottomMargin,slot:"message"},this.messages.missingLayer)));if("unauthenticated"===this.viewModel.state)return x("div",{class:$.primaryFooterCentered,key:"footer-sign-in"},x("calcite-label",null,this.messages.signInRequired),x("calcite-button",{onclick:()=>{this.viewModel.load().catch((()=>{}))}},this.messages.common.auth.signIn));if("error"===this.viewModel.state&&!this.viewModel.serviceDescription)return x("div",{class:$.primaryFooter,key:"footer-service-error"},x("calcite-notice",{icon:"exclamation-mark-circle",kind:"danger",open:!0},x("calcite-label",{class:$.labelNoBottomMargin,slot:"message"},this._getErrorDescription())));if(!this.viewModel.layer?.routeInfo)return x("div",{class:$.primaryFooter,key:"footer-unsolved-route"},x("calcite-notice",{icon:"information",open:!0},x("calcite-label",{class:$.labelNoBottomMargin,slot:"message"},this.messages.directionsPlaceholder)));const e=this._getRouteCostSummary();if(!e||!this.viewModel.layer?.directionPoints)return x("div",{class:$.primaryFooter,key:"footer-invalid-route"},x("calcite-notice",{icon:"exclamation-mark-triangle",kind:"danger",open:!0},x("calcite-label",{class:$.labelNoBottomMargin,slot:"message"},this.messages.invalidRoute)));const{distance:t,duration:i}=e,{formattedEta:s}=this.viewModel;return x("div",{class:$.routeItem,key:"footer-directions-summary"},x("button",{"aria-busy":"false","aria-label":this.messages.viewDrivingDirections,"aria-live":"polite",class:$.routeItemButton,onclick:()=>{this._currentFlowItem="directions"},type:"button"},x("div",{class:$.routeItemButtonContent},x("span",{class:$.routeItemLabel},`${i} (${t})`),x("span",{class:$.routeItemDescription},s)),x("calcite-icon",{icon:"chevron-right",scale:"s"})),x("calcite-dropdown",null,x("calcite-action",{icon:"ellipsis",slot:"trigger",text:"Route actions"}),this._renderRouteLayerActions()))}_renderInteractiveRouteActions(){return x("div",{class:$.actionContainer,key:"interactive-route-action-container"},x("calcite-button",{appearance:"outline",iconStart:"plus",kind:"neutral",label:this.messages.addStop,onclick:()=>{const e=new p;this.viewModel.layer?.stops.add(new m({symbol:e}))}},this.messages.addStop),x("calcite-button",{appearance:"outline",iconStart:"pencil",kind:"neutral",label:this.messages.editRoute,onclick:()=>{this._currentFlowItem="edit",this.viewModel.startEditing()}},this.messages.editRoute),x("calcite-button",{appearance:"outline",bind:this,iconStart:"arrow-up-down",kind:"neutral",label:this.messages.reverseStops,onclick:()=>{this.viewModel.layer?.stops.reverse(),this._resetStopSequence(),this._solveRoute()}}))}_renderLocateStopAction(e){if(null!=e.name||null!=e.geometry)return null;const t=this.viewModel.layer?.stops.indexOf(e)??-1;return x("calcite-action",{icon:"select",key:`stop-location-action-${t}`,onclick:()=>this._handleLocateStopAction(e),scale:"s",text:this.messages.pickALocationOnTheMap})}_renderOptimizeStopOrder(){const{routeParameters:e}=this.viewModel,{findBestSequence:t,preserveFirstStop:i,preserveLastStop:s}=e;return x("div",null,x("calcite-label",{layout:"inline-space-between",scale:"s"},this.messages.optimizeOrder,x("calcite-switch",{checked:t,scale:"s",onCalciteSwitchChange:({target:t})=>{e.findBestSequence=t.checked,t.checked||this._resetStopSequence(),this._solveRoute()}})),t?[x("calcite-label",{key:"preserve-first-stop",layout:"inline-space-between",scale:"s"},this.messages.preserveFirstStop,x("calcite-switch",{checked:i,scale:"s",onCalciteSwitchChange:({target:{checked:t}})=>{e.preserveFirstStop=t,this._resetStopSequence(),this._solveRoute()}})),x("calcite-label",{key:"preserve-last-stop",layout:"inline-space-between",scale:"s"},this.messages.preserveLastStop,x("calcite-switch",{checked:s,scale:"s",onCalciteSwitchChange:({target:{checked:t}})=>{e.preserveLastStop=t,this._resetStopSequence(),this._solveRoute()}}))]:null)}_renderPrimaryFlowItem(){return x("calcite-flow-item",{key:"primary-flow-item",loading:"initializing"===this.viewModel.state,selected:"primary"===this._currentFlowItem},x("calcite-panel",{class:$.primaryFlowItem,disabled:!this.viewModel.layer||"unauthenticated"===this.viewModel.state||"error"===this.viewModel.state&&!this.viewModel.serviceDescription},this._renderStops(),this._renderInteractiveRouteActions(),this._renderSeparator(),this._renderRouteSolveOptions()),this._renderFooter())}_renderRouteLayerActions(e){return[this._renderClearRouteAction(e),this._renderSaveLayerAction(e),this._renderSaveLayerAsAction(e),this._renderViewItemDetailsAction(e)]}_renderRouteSolveOptions(){return x("div",{class:$.marginInlineMedium,key:"route-solve-options"},this._renderTravelModes(),this._renderDepartureTime(),this._renderDepartureTimeOptions(),this._renderOptimizeStopOrder())}_renderSaveContent(){switch(this._saveState){case"initialized":return this._renderSaveInitialized();case"connect-to-portal":return this._renderSaveProcessing(this.messages.identity.lblSigning);case"connect-to-portal-error":return this._renderSaveError(this.messages.errors.authenticating);case"fetch-portal-information":return this._renderSaveProcessing(this.messages.processing.fetching);case"fetch-portal-information-error":return this._renderSaveError(this.messages.errors.fetching);case"save-layer":return this._renderSaveLayerSettings();case"saving":return this._renderSaveProcessing(this.messages.processing.saving);case"saving-error":return this._renderSaveError(this.messages.errors.saving)}}_renderSaveError(e){return x("calcite-panel",{class:$.paddingMedium,key:"save-layer-error"},x("div",{class:$.saveError},x("calcite-icon",{class:$.saveErrorIcon,icon:"exclamation-mark-triangle",scale:"l",textLabel:this.messages.common.errorMessage}),x("calcite-label",{class:$.saveErrorLabel},e)),x("calcite-button",{appearance:"outline",onclick:()=>{this._currentFlowItem=this._parentFlowItem},slot:"footer-actions",width:"full"},this.messages.common.close))}_renderSaveInitialized(){return x("calcite-panel",{class:$.paddingMedium,key:"save-layer-initialized"})}_renderSaveFlowItem(){return"save"!==this._currentFlowItem?null:x("calcite-flow-item",{heading:this.messages.saveLayer,headingLevel:this.headingLevel,key:"save-layer-flow-item",selected:"save"===this._currentFlowItem,onCalciteFlowItemBack:e=>{e.stopPropagation(),this._currentFlowItem=this._parentFlowItem}},this._renderSaveContent())}_renderSaveLayerAction(e){if(!this.visibleElements.saveButton)return null;const t=this.viewModel.layer,i=t?.routeInfo,s=t?.portalItem?.itemControl;return x("calcite-action",{disabled:!(!!i&&("admin"===s||"update"===s)),icon:"save",key:"save-route",onclick:()=>{this.viewModel.layer?.save()},...e,text:this.messages.common.save,textEnabled:!0})}_renderSaveLayerAsAction(e){if(!this.visibleElements.saveAsButton)return null;const t=!this.viewModel.layer?.routeInfo;return x("calcite-action",{disabled:t,icon:"save-as",key:"save-as-route",onclick:()=>{this._handleSaveLayerAsAction()},...e,text:this.messages.common.saveAs,textEnabled:!0})}_renderSaveLayerSettings(){if(null==this.layer||null==this._portalFolders||null==this._portalUserName)return this._renderSaveInitialized();const{stops:e}=this.layer,t=`${e.at(0).name} - ${e.at(-1).name}`,i=this._portalFolders.map((e=>x("calcite-combobox-item",{heading:e.title??"",key:`${D}-folder-${e.id}`,value:e.id})));return i.unshift(x("calcite-combobox-item",{heading:`${this._portalUserName} (${this.messages.common.home})`,key:`${D}-folder-home`,selected:!0,value:null})),x("calcite-panel",{key:"save-layer-panel"},x("div",{class:$.paddingMedium},x("calcite-label",null,this.messages.laverName,x("calcite-input",{afterCreate:e=>{this._portalItemNameInput=e},label:this.messages.laverName,value:t})),x("calcite-label",null,this.messages.saveInFolder,x("calcite-combobox",{afterCreate:e=>{this._portalFolderCombobox=e},label:this.messages.saveInFolder,overlayPositioning:"fixed",selectionMode:"single"},i))),x("calcite-button",{onclick:()=>{if(this._saveState="saving",null==this.layer||null==this._portalFolders)return;const e=this._portalItemNameInput?.value,t=this._portalFolderCombobox?.value,i=this._portalFolders.find((({id:e})=>e===t));this.layer.saveAs({title:e},{folder:i}).then((()=>{this._currentFlowItem=this._parentFlowItem})).catch((()=>{this._saveState="saving-error"}))},slot:"footer-actions",width:"full"},this.messages.common.save),x("calcite-button",{appearance:"outline",onclick:()=>{this._currentFlowItem=this._parentFlowItem},slot:"footer-actions",width:"full"},this.messages.common.cancel))}_renderSaveProcessing(e){return x("calcite-panel",{class:$.marginInlineMedium,key:"save-layer-processing"},x("calcite-loader",{class:$.saveProcessLoader,label:e,text:e}))}_renderSeparator(){return x("div",{class:$.separator,key:"separator"})}_renderStop(e){const t=this.acquireSearch(e);null!=e.name&&(t.searchTerm=e.name);const i=this._renderLocateStopAction(e),s=this._renderDeleteStopAction(e),o=this.viewModel.layer?.stops.indexOf(e)??-1;return x("calcite-list-item",{key:`stop-${o}`,value:e},x("div",{class:$.flexRow,slot:"actions-end"},i,s),x("div",{class:$.stopItem,slot:"content"},t.render()))}_renderStops(){const e=this.viewModel.layer?.stops.toArray()??this._placeholderStops;for(const t of this._stopsToSearches.keys())e.includes(t)||this._disposeSearch(t);return x("div",{class:$.stopContainer,key:$.stopContainer},x("calcite-list",{dragEnabled:!0,label:this.messages.widgetLabel,scale:"s",onCalciteListOrderChange:({detail:e})=>{this.viewModel.layer?.stops.reorder(e.dragEl.value,e.newIndex),this._resetStopSequence(),this._solveRoute()}},e.map((e=>this._renderStop(e)))))}_renderTravelModes(){return this.viewModel.travelModes.length?x("calcite-label",{key:"travel-modes",scale:"s"},this.messages.mode,x("calcite-combobox",{clearDisabled:!0,label:"mode",overlayPositioning:"fixed",scale:"s",selectionMode:"single",onCalciteComboboxChange:({currentTarget:e})=>{const{selectedItems:t}=e;t.length&&(this.viewModel.selectedTravelMode=t[0].value,this._solveRoute())}},this.viewModel.travelModes.map((e=>x("calcite-combobox-item",{heading:e.name,key:e.id,label:e.name,selected:this.viewModel.selectedTravelMode?.id===e.id,value:e}))))):null}_renderViewItemDetailsAction(e){if(!this.visibleElements.layerDetails)return null;const t=this.viewModel.layer?.portalItem;return x("calcite-action",{disabled:!t,icon:"launch",key:"open-route-details-link",onclick:()=>{t&&window.open(`${t.portal.url}/home/item.html?id=${t.id}`,"_blank")},...e,text:this.messages.viewLayerDetails,textEnabled:!0})}_resetStopSequence(){this.viewModel.layer?.stops.forEach((e=>{e.sequence=null}))}async _solveRoute(){this.viewModel.updateDepartureTime();const e=this.viewModel.layer?.stops.filter((({geometry:e})=>null!=e));if(e&&!(e.length<2))try{await this.viewModel.getDirections()}catch{}}};e([n()],L.prototype,"_currentFlowItem",void 0),e([n()],L.prototype,"_saveState",void 0),e([n()],L.prototype,"apiKey",null),e([n(d)],L.prototype,"defaultUnit",void 0),e([n()],L.prototype,"goToOverride",null),e([n()],L.prototype,"headingLevel",void 0),e([n()],L.prototype,"icon",null),e([n()],L.prototype,"label",null),e([n({readOnly:!0})],L.prototype,"lastRoute",null),e([n()],L.prototype,"layer",null),e([n()],L.prototype,"maxStops",null),e([n(),F("esri/widgets/Directions/t9n/Directions")],L.prototype,"messages",void 0),e([n(),F("esri/core/t9n/Units")],L.prototype,"messagesUnits",void 0),e([n()],L.prototype,"searchProperties",void 0),e([n()],L.prototype,"unit",null),e([n()],L.prototype,"view",null),e([n({type:g})],L.prototype,"viewModel",void 0),e([n({type:_,nonNullable:!0})],L.prototype,"visibleElements",void 0),L=e([l("esri.widgets.Directions")],L);const A=L;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 t from"../../Graphic.js";import{FeatureSetQueryInterceptor as i}from"../../arcade/featureset/support/FeatureSetQueryInterceptor.js";import o from"../../core/Accessor.js";import{isSome as r}from"../../core/arrayUtils.js";import s from"../../core/Collection.js";import n from"../../core/Identifiable.js";import a from"../../core/Logger.js";import{isAbortError as l,eachAlways as c}from"../../core/promiseUtils.js";import{watch as p,on as d,whenOnce as u,initial as h}from"../../core/reactiveUtils.js";import{throttle as f}from"../../core/throttle.js";import{property as m}from"../../core/accessorSupport/decorators/property.js";import{cast as _}from"../../core/accessorSupport/decorators/cast.js";import"../../core/has.js";import{subclass as y}from"../../core/accessorSupport/decorators/subclass.js";import b from"../../geometry/Point.js";import g from"../../geometry/SpatialReference.js";import A from"../../popup/content/TextContent.js";import{getFeaturePopupTitle as w}from"../../support/popupUtils.js";import{system as I}from"../../time/timeZoneUtils.js";import M from"./FeatureAttachments/FeatureAttachmentsViewModel.js";import v from"./FeatureContent/FeatureContentViewModel.js";import C from"./FeatureExpression/FeatureExpressionViewModel.js";import F from"./FeatureFields/FeatureFieldsViewModel.js";import x from"./FeatureMedia/FeatureMediaViewModel.js";import V from"./FeatureRelationship/FeatureRelationshipViewModel.js";import{createCompiledExpressions as T}from"./support/arcadeFeatureUtils.js";import{createFieldInfoMap as E,getAllFieldInfos as j,getSourceLayer as P,querySourceLayer as R,isRelatableFeatureSupportedLayer as L,isAssociatedFeatureSupportedLayer as O,substituteFieldsInLinksAndAttributes as Z,isExpressionField as k,isRelatedField as N,formatEditInfo as U,graphicCallback as B,queryUpdatedFeature as S,formatAttributes as H,preLayerQueryCallback as D,preRequestCallback as G}from"./support/featureUtils.js";import{queryLayerInfos as q,queryRelatedFeatures as Q,setRelatedFeatures as z,getRelatedFieldInfo as J,createRelatedInfo as K,updateRelatedInfo as W}from"./support/relatedFeatureUtils.js";import X from"../support/UtilityNetworkAssociations/UtilityNetworkAssociationsViewModel.js";var Y;const $=1,ee="content-view-models",te="relationship-view-models",ie="association-view-models",oe={attachmentsContent:!0,chartAnimation:!0,customContent:!0,expressionContent:!0,fieldsContent:!0,mediaContent:!0,textContent:!0,relationshipContent:!0,utilityNetworkAssociationsContent:!0};let re=Y=class extends(n.IdentifiableMixin(o)){constructor(e){super(e),this._error=null,this._featureAbortController=null,this._associationVMAbortController=null,this._graphicChangedThrottled=f(this._graphicChanged,$,this),this._expressionAttributes=null,this._graphicExpressionAttributes=null,this.abilities={...oe},this.content=null,this.contentViewModels=[],this.description=null,this.defaultPopupTemplateEnabled=!1,this.formattedAttributes=null,this.lastEditInfo=null,this.location=null,this.relatedInfos=new Map,this.title="",this.view=null,this._isAllowedContentType=e=>{const{abilities:t}=this;return"attachments"===e.type&&!!t.attachmentsContent||"custom"===e.type&&!!t.customContent||"fields"===e.type&&!!t.fieldsContent||"media"===e.type&&!!t.mediaContent||"text"===e.type&&!!t.textContent||"expression"===e.type&&!!t.expressionContent||"relationship"===e.type&&!!t.relationshipContent||"utility-network-associations"===e.type&&!!t.utilityNetworkAssociationsContent},this.addHandles(p((()=>[this.graphic,this._effectivePopupTemplate,this.abilities,this.timeZone]),(()=>this._graphicChangedThrottled()),h))}initialize(){this.addHandles(this._graphicChangedThrottled)}destroy(){this._clear(),this._cancelFeatureQuery(),this._error=null,this.graphic=null,this._destroyContentViewModels(),this.relatedInfos.clear()}get _effectivePopupTemplate(){return null!=this.graphic?this.graphic.getEffectivePopupTemplate(this.defaultPopupTemplateEnabled):null}get _fieldInfoMap(){return E(j(this._effectivePopupTemplate),this._sourceLayer)}get _sourceLayer(){return P(this.graphic)}castAbilities(e){return{...oe,...e}}get isTable(){return this._sourceLayer?.isTable||!1}get state(){return this.graphic?this._error?"error":this.waitingForContent?"loading":"ready":"disabled"}set graphic(e){this._featureAbortController=new AbortController,this._set("graphic",e?.clone()??null)}get spatialReference(){return this.view?.spatialReference??null}set spatialReference(e){this._override("spatialReference",e)}get timeZone(){return this.view?.timeZone??I}set timeZone(e){this._overrideIfSome("timeZone",e)}get map(){return this.view?.map||null}set map(e){this._override("map",e)}get waitingForContent(){return!(!this._featureAbortController&&!this._associationVMAbortController)}setActiveMedia(e,t){const i=this.contentViewModels[e];i instanceof x&&i.setActiveMedia(t)}nextMedia(e){const t=this.contentViewModels[e];t instanceof x&&t.next()}previousMedia(e){const t=this.contentViewModels[e];t instanceof x&&t.previous()}async updateGeometry(){const{graphic:e,spatialReference:t,_sourceLayer:i}=this;await(i?.load());const o=i?.objectIdField;if(!o||!e||!i)return;const r=e?.attributes?.[o];if(null==r)return;const s=[r];if(!e.geometry){const o=await R({layer:i,graphic:e,outFields:[],objectIds:s,returnGeometry:!0,spatialReference:t}),r=o?.geometry;r&&(e.geometry=r)}}_clear(){this._set("title",""),this._set("content",null),this._set("formattedAttributes",null)}async _graphicChanged(){this._cancelFeatureQuery(),this._error=null,this._clear();const{graphic:e}=this;if(!e)return;const t=new AbortController;this._featureAbortController=t;try{await this._queryFeature({signal:t.signal})}catch(i){l(i)||(this._error=i,a.getLogger(this).error("error","The popupTemplate could not be displayed for this feature.",{error:i,graphic:e,popupTemplate:this._effectivePopupTemplate}))}this._featureAbortController===t&&(this._featureAbortController=null)}_cancelFeatureQuery(){const{_featureAbortController:e}=this;e&&e.abort(),this._featureAbortController=null}_compileContentElement(e,t){return"attachments"===e.type?this._compileAttachments(e,t):"custom"===e.type?this._compileCustom(e,t):"fields"===e.type?this._compileFields(e,t):"media"===e.type?this._compileMedia(e,t):"text"===e.type?this._compileText(e,t):"expression"===e.type?this._compileExpression(e,t):"relationship"===e.type?this._compileRelationship(e,t):"utility-network-associations"===e.type?this._compileUtilityNetworkAssociation(e,t):void 0}_compileContent(e){if(this._destroyContentViewModels(),this.graphic)return Array.isArray(e)?e.filter(this._isAllowedContentType).map(((e,t)=>this._compileContentElement(e,t))).filter(r):"string"==typeof e?this._compileText(new A({text:e}),0).text:e}_destroyContentViewModels(){this.removeHandles(te),this.removeHandles(ee),this.contentViewModels.forEach((e=>e&&!e.destroyed&&e.destroy())),this._set("contentViewModels",[])}_matchesFeature(e,t){const i=e?.graphic?.getObjectId(),o=t?.getObjectId();return null!=i&&null!=o&&i===o}_setRelatedFeaturesViewModels({relatedFeatureViewModels:e,relatedFeatures:t,map:i}){const{view:o,spatialReference:r,timeZone:s}=this;t?.filter(Boolean).forEach((t=>{e.some((e=>this._matchesFeature(e,t)))||e.add(new Y({abilities:{relationshipContent:!1},map:i,view:o,spatialReference:r,timeZone:s,graphic:t}))})),e.forEach((i=>{const o=t?.find((e=>this._matchesFeature(i,e)));o||e.remove(i)}))}_setExpressionContentVM(e,t){const i=this.formattedAttributes,{contentElement:o,contentElementViewModel:r}=e,s=o?.type;r&&s&&("fields"===s&&(this._createFieldsFormattedAttributes({contentElement:o,contentElementIndex:t,formattedAttributes:i}),r.set(this._createFieldsVMParams(o,t))),"media"===s&&(this._createMediaFormattedAttributes({contentElement:o,contentElementIndex:t,formattedAttributes:i}),r.set(this._createMediaVMParams(o,t))),"text"===s&&r.set(this._createTextVMParams(o)))}_compileRelationship(e,t){const{displayCount:i,orderByFields:o,relationshipId:r,title:s,description:n}=e,{_sourceLayer:a,graphic:l,map:c}=this;if(!L(a))return;const p=new V({displayCount:i,graphic:l,orderByFields:o,relationshipId:r,layer:a,map:c,...this._compileTitleAndDesc({title:s,description:n})});return this.contentViewModels[t]=p,this.addHandles(d((()=>p.relatedFeatures),"change",(()=>this._setRelatedFeaturesViewModels(p))),te),e}_matchesGlobalFeature(e,t){const i=e?.association.globalId,o=t?.association.globalId;return null!=i&&null!=o&&i===o}async _setUpUtilityNetworkAssociationsViewModels(e,t,i){const{view:o,spatialReference:r,timeZone:n}=this;e.forEach(((i,o)=>{const r=t.get(o);r?i.forEach((t=>{r.find((e=>this._matchesGlobalFeature(t,e)))||(i.remove(t),0===i.length&&e.delete(o))})):(i.removeAll(),e.delete(o))})),t.forEach(((t,a)=>{const l=e.get(a)||new s;t?.filter(Boolean).forEach((e=>{l.some((t=>this._matchesGlobalFeature(t,e)))||l.add({association:e.association,featureViewModel:new Y({abilities:{utilityNetworkAssociationsContent:!1},map:i,view:o,spatialReference:r,timeZone:n,graphic:e.feature}),terminalName:e.terminalName})})),e.set(a,l)}));const a=new AbortController;this._associationVMAbortController=a,await this._sortListObjectsByTitle(e,{signal:a.signal}),this._associationVMAbortController===a&&(this._associationVMAbortController=null)}async _sortListObjectsByTitle(e,t){for(const i of e.values()){const e=i.map((e=>u((()=>"ready"===e.featureViewModel.state),t?.signal)));await Promise.all(e),i.sort(this._compareByFeatureTitle)}}_compareByFeatureTitle(e,t){const i=w(e.featureViewModel),o=w(t.featureViewModel);return i.localeCompare(o,void 0,{numeric:!0})}_compileUtilityNetworkAssociation(e,t){const{displayCount:i,title:o,description:r,associationTypes:s}=e,{_sourceLayer:n,graphic:a,map:l}=this;if(!O(n))return;const c=new X({graphic:a,displayCount:i,associationTypes:s,layer:n,map:l,...this._compileTitleAndDesc({title:o,description:r})});return this.contentViewModels[t]=c,this.addHandles([p((()=>c.associationFeatures.values()),(()=>this._setUpUtilityNetworkAssociationsViewModels(c.associationViewModels,c.associationFeatures,c.map)))],ie),e}_compileExpression(e,t){const{expressionInfo:i}=e,{graphic:o,map:r,spatialReference:s,view:n,location:a}=this,l=new C({expressionInfo:i,graphic:o,interceptor:Y.interceptor,map:r,spatialReference:s,view:n,location:a});return this.contentViewModels[t]=l,this.addHandles(p((()=>l.contentElementViewModel),(()=>this._setExpressionContentVM(l,t)),h),ee),e}_compileAttachments(e,t){const{graphic:i}=this,{description:o,title:r}=e;return this.contentViewModels[t]=new M({graphic:i,...this._compileTitleAndDesc({title:r,description:o})}),e}_compileCustom(e,t){const{graphic:i}=this,{creator:o,destroyer:r}=e;return this.contentViewModels[t]=new v({graphic:i,creator:o,destroyer:r}),e}_compileTitleAndDesc({title:e,description:t}){const{_fieldInfoMap:i,_sourceLayer:o,graphic:r,formattedAttributes:s}=this,n=r?.attributes,a=this._expressionAttributes,l=s.global;return{title:Z({attributes:n,fieldInfoMap:i,globalAttributes:l,expressionAttributes:a,layer:o,text:e}),description:Z({attributes:n,fieldInfoMap:i,globalAttributes:l,expressionAttributes:a,layer:o,text:t})}}_createFieldsVMParams(e,t){const i=this._effectivePopupTemplate,o=this.formattedAttributes,r={...o?.global,...o?.content[t]},s=e?.fieldInfos||i?.fieldInfos,n=s?.filter((({fieldName:e})=>!!e&&(k(e)||N(e)||r.hasOwnProperty(e)))),a=i?.expressionInfos,{description:l,title:c}=e;return{attributes:r,expressionInfos:a,fieldInfos:n,...this._compileTitleAndDesc({title:c,description:l})}}_compileFields(e,t){const i=e.clone(),o=new F(this._createFieldsVMParams(e,t));return this.contentViewModels[t]=o,i.fieldInfos=o.formattedFieldInfos.slice(),i}_createMediaVMParams(e,t){const{abilities:i,graphic:o,_fieldInfoMap:r,_effectivePopupTemplate:s,relatedInfos:n,_sourceLayer:a,_expressionAttributes:l}=this,c=this.formattedAttributes,p=o?.attributes??{},{description:d,mediaInfos:u,title:h}=e;return{abilities:{chartAnimation:i.chartAnimation},activeMediaInfoIndex:e.activeMediaInfoIndex||0,attributes:p,isAggregate:o?.isAggregate,layer:a,fieldInfoMap:r,formattedAttributes:{...c?.global,...c?.content[t]},expressionAttributes:l,mediaInfos:u,popupTemplate:s,relatedInfos:n,...this._compileTitleAndDesc({title:h,description:d})}}_compileMedia(e,t){const i=e.clone(),o=new x(this._createMediaVMParams(e,t));return i.mediaInfos=o.formattedMediaInfos.slice(),this.contentViewModels[t]=o,i}_createTextVMParams(e){const{graphic:t,_fieldInfoMap:i,_sourceLayer:o,_expressionAttributes:r}=this;if(e&&e.text){const s=t?.attributes??{},n=this.formattedAttributes?.global??{};e.text=Z({attributes:s,fieldInfoMap:i,globalAttributes:n,expressionAttributes:r,layer:o,text:e.text})}return{graphic:t,creator:e.text}}_compileText(e,t){const i=e.clone();return this.contentViewModels[t]=new v(this._createTextVMParams(i)),i}_compileLastEditInfo(){const{_effectivePopupTemplate:e,_sourceLayer:t,graphic:i,timeZone:o}=this;if(!e)return;const{lastEditInfoEnabled:r}=e,s=t?.editFieldsInfo;return r&&s?U(s,i?.attributes,o,t):void 0}_compileTitle(e){const{_fieldInfoMap:t,_sourceLayer:i,graphic:o,_expressionAttributes:r}=this,s=o?.attributes??{},n=this.formattedAttributes?.global??{};return Z({attributes:s,fieldInfoMap:t,globalAttributes:n,expressionAttributes:r,layer:i,text:e})}async _getTitle(){const{_effectivePopupTemplate:e,graphic:t}=this;return t?B({type:"title",value:e?.title,event:{graphic:t}}):null}async _getContent(){const{_effectivePopupTemplate:e,graphic:t}=this;return t?B({type:"content",value:e?.content,event:{graphic:t}}):null}async _queryFeature(e){const{_featureAbortController:t,_sourceLayer:i,graphic:o,_effectivePopupTemplate:r}=this,s=this.map,n=this.view,a=this.spatialReference,l=this.location;if(t!==this._featureAbortController||!o)return;await S({graphic:o,popupTemplate:r,layer:i,spatialReference:a},e);const{content:{value:p},title:{value:d}}=await c({content:this._getContent(),title:this._getTitle()}),{expressionAttributes:{value:u}}=await c({checkForRelatedFeatures:this._checkForRelatedFeatures(e),expressionAttributes:T({expressionInfos:r?.expressionInfos,spatialReference:a,graphic:o,map:s,interceptor:Y.interceptor,view:n,options:e,location:l})});t===this._featureAbortController&&o&&(this._expressionAttributes=u,this._graphicExpressionAttributes={...o.attributes,...u},this._set("formattedAttributes",this._createFormattedAttributes(p)),this._set("title",this._compileTitle(d)),this._set("lastEditInfo",this._compileLastEditInfo()||null),this._set("content",this._compileContent(p)||null))}_createMediaFormattedAttributes({contentElement:e,contentElementIndex:t,formattedAttributes:i}){const{_effectivePopupTemplate:o,graphic:r,relatedInfos:s,_sourceLayer:n,_fieldInfoMap:a,_graphicExpressionAttributes:l,timeZone:c}=this;i.content[t]=H({fieldInfos:o?.fieldInfos,graphic:r,attributes:{...l,...e.attributes},layer:n,fieldInfoMap:a,relatedInfos:s,timeZone:c})}_createFieldsFormattedAttributes({contentElement:e,contentElementIndex:t,formattedAttributes:i}){if(e.fieldInfos){const{graphic:o,relatedInfos:r,_sourceLayer:s,_fieldInfoMap:n,_graphicExpressionAttributes:a,timeZone:l}=this;i.content[t]=H({fieldInfos:e.fieldInfos,graphic:o,attributes:{...a,...e.attributes},layer:s,fieldInfoMap:n,relatedInfos:r,timeZone:l})}}_createFormattedAttributes(e){const{_effectivePopupTemplate:t,graphic:i,relatedInfos:o,_sourceLayer:r,_fieldInfoMap:s,_graphicExpressionAttributes:n,timeZone:a}=this,l=t?.fieldInfos,c={global:H({fieldInfos:l,graphic:i,attributes:n,layer:r,fieldInfoMap:s,relatedInfos:o,timeZone:a}),content:[]};return Array.isArray(e)&&e.forEach(((e,t)=>{"fields"===e.type&&this._createFieldsFormattedAttributes({contentElement:e,contentElementIndex:t,formattedAttributes:c}),"media"===e.type&&this._createMediaFormattedAttributes({contentElement:e,contentElementIndex:t,formattedAttributes:c})})),c}_checkForRelatedFeatures(e){const{graphic:t,_effectivePopupTemplate:i}=this;return this._queryRelatedInfos(t,j(i),e)}async _queryRelatedInfos(e,t,i){const{relatedInfos:o,_sourceLayer:r}=this;o.clear();const s=null!=r?.associatedLayer?await(r?.associatedLayer.load(i)):r;if(!s||!e)return;const n=t.filter((e=>!!e.fieldName&&N(e.fieldName)));if(!n?.length)return;t.forEach((e=>this._configureRelatedInfo(e,s)));const a=await q({relatedInfos:o,layer:s},i);Object.keys(a).forEach((e=>{const t=o.get(e.toString()),i=a[e]?.value;t&&i&&(t.layerInfo=i.data)}));const l=await Q({graphic:e,relatedInfos:o,layer:s},i);Object.keys(l).forEach((e=>{z(l[e]?.value,o.get(e.toString()))}))}_configureRelatedInfo(e,t){const{relatedInfos:i}=this,o=J(e.fieldName||"");if(!o)return;const{layerId:r,fieldName:s}=o;if(!r)return;const n=i.get(r.toString())||K(r,t);n&&(W({relatedInfo:n,fieldName:s,fieldInfo:e}),this.relatedInfos.set(r,n))}};re.interceptor=new i(D,G),e([m()],re.prototype,"_error",void 0),e([m()],re.prototype,"_featureAbortController",void 0),e([m()],re.prototype,"_associationVMAbortController",void 0),e([m({readOnly:!0})],re.prototype,"_effectivePopupTemplate",null),e([m({readOnly:!0})],re.prototype,"_fieldInfoMap",null),e([m({readOnly:!0})],re.prototype,"_sourceLayer",null),e([m()],re.prototype,"abilities",void 0),e([_("abilities")],re.prototype,"castAbilities",null),e([m({readOnly:!0})],re.prototype,"content",void 0),e([m({readOnly:!0})],re.prototype,"contentViewModels",void 0),e([m()],re.prototype,"description",void 0),e([m({type:Boolean})],re.prototype,"defaultPopupTemplateEnabled",void 0),e([m({readOnly:!0})],re.prototype,"isTable",null),e([m({readOnly:!0})],re.prototype,"state",null),e([m({readOnly:!0})],re.prototype,"formattedAttributes",void 0),e([m({type:t,value:null})],re.prototype,"graphic",null),e([m({readOnly:!0})],re.prototype,"lastEditInfo",void 0),e([m({type:b})],re.prototype,"location",void 0),e([m({readOnly:!0})],re.prototype,"relatedInfos",void 0),e([m({type:g})],re.prototype,"spatialReference",null),e([m()],re.prototype,"timeZone",null),e([m({readOnly:!0})],re.prototype,"title",void 0),e([m()],re.prototype,"map",null),e([m({readOnly:!0})],re.prototype,"waitingForContent",null),e([m()],re.prototype,"view",void 0),re=Y=e([y("esri.widgets.Feature.FeatureViewModel")],re);const se=re;export{se as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Graphic.js";import{FeatureSetQueryInterceptor as i}from"../../arcade/featureset/support/FeatureSetQueryInterceptor.js";import o from"../../core/Accessor.js";import{isSome as r}from"../../core/arrayUtils.js";import s from"../../core/Collection.js";import n from"../../core/Identifiable.js";import a from"../../core/Logger.js";import{isAbortError as l,eachAlways as c}from"../../core/promiseUtils.js";import{watch as p,on as d,whenOnce as u,initial as h}from"../../core/reactiveUtils.js";import{throttle as f}from"../../core/throttle.js";import{property as m}from"../../core/accessorSupport/decorators/property.js";import{cast as _}from"../../core/accessorSupport/decorators/cast.js";import"../../core/has.js";import{subclass as y}from"../../core/accessorSupport/decorators/subclass.js";import b from"../../geometry/Point.js";import g from"../../geometry/SpatialReference.js";import A from"../../popup/content/TextContent.js";import{getFeaturePopupTitle as w}from"../../support/popupUtils.js";import{system as I}from"../../time/timeZoneUtils.js";import M from"./FeatureAttachments/FeatureAttachmentsViewModel.js";import v from"./FeatureContent/FeatureContentViewModel.js";import F from"./FeatureExpression/FeatureExpressionViewModel.js";import C from"./FeatureFields/FeatureFieldsViewModel.js";import x from"./FeatureMedia/FeatureMediaViewModel.js";import V from"./FeatureRelationship/FeatureRelationshipViewModel.js";import{createCompiledExpressions as T}from"./support/arcadeFeatureUtils.js";import{createFieldInfoMap as E,getAllFieldInfos as j,getSourceLayer as P,querySourceLayer as R,isRelatableFeatureSupportedLayer as L,isAssociatedFeatureSupportedLayer as O,substituteFieldsInLinksAndAttributes as Z,isExpressionField as k,isRelatedField as N,formatEditInfo as U,graphicCallback as B,queryUpdatedFeature as S,formatAttributes as H,preLayerQueryCallback as D,preRequestCallback as G}from"./support/featureUtils.js";import{queryLayerInfos as q,queryRelatedFeatures as Q,setRelatedFeatures as z,getRelatedFieldInfo as J,createRelatedInfo as K,updateRelatedInfo as W}from"./support/relatedFeatureUtils.js";import X from"../support/UtilityNetworkAssociations/UtilityNetworkAssociationsViewModel.js";var Y;const $=1,ee="content-view-models",te="relationship-view-models",ie="association-view-models",oe={attachmentsContent:!0,chartAnimation:!0,customContent:!0,expressionContent:!0,fieldsContent:!0,mediaContent:!0,textContent:!0,relationshipContent:!0,utilityNetworkAssociationsContent:!0};let re=Y=class extends(n.IdentifiableMixin(o)){constructor(e){super(e),this._error=null,this._featureAbortController=null,this._associationVMAbortController=null,this._graphicChangedThrottled=f(this._graphicChanged,$,this),this._expressionAttributes=null,this._graphicExpressionAttributes=null,this.abilities={...oe},this.content=null,this.contentViewModels=[],this.description=null,this.defaultPopupTemplateEnabled=!1,this.formattedAttributes=null,this.lastEditInfo=null,this.location=null,this.relatedInfos=new Map,this.title="",this.view=null,this._isAllowedContentType=e=>{const{abilities:t}=this;return"attachments"===e.type&&!!t.attachmentsContent||"custom"===e.type&&!!t.customContent||"fields"===e.type&&!!t.fieldsContent||"media"===e.type&&!!t.mediaContent||"text"===e.type&&!!t.textContent||"expression"===e.type&&!!t.expressionContent||"relationship"===e.type&&!!t.relationshipContent||"utility-network-associations"===e.type&&!!t.utilityNetworkAssociationsContent},this.addHandles(p((()=>[this.graphic,this._effectivePopupTemplate,this.abilities,this.timeZone]),(()=>this._graphicChangedThrottled()),h))}initialize(){this.addHandles(this._graphicChangedThrottled)}destroy(){this._clear(),this._cancelFeatureQuery(),this._error=null,this.graphic=null,this._destroyContentViewModels(),this.relatedInfos.clear()}get _effectivePopupTemplate(){return null!=this.graphic?this.graphic.getEffectivePopupTemplate(this.defaultPopupTemplateEnabled):null}get _fieldInfoMap(){return E(j(this._effectivePopupTemplate),this._sourceLayer)}get _sourceLayer(){return P(this.graphic)}castAbilities(e){return{...oe,...e}}get isTable(){return this._sourceLayer?.isTable||!1}get state(){return this.graphic?this._error?"error":this.waitingForContent?"loading":"ready":"disabled"}set graphic(e){this._featureAbortController=new AbortController,this._set("graphic",e?.clone()??null)}get spatialReference(){return this.view?.spatialReference??null}set spatialReference(e){this._override("spatialReference",e)}get timeZone(){return this.view?.timeZone??I}set timeZone(e){this._overrideIfSome("timeZone",e)}get map(){return this.view?.map||null}set map(e){this._override("map",e)}get waitingForContent(){return!(!this._featureAbortController&&!this._associationVMAbortController)}setActiveMedia(e,t){const i=this.contentViewModels[e];i instanceof x&&i.setActiveMedia(t)}nextMedia(e){const t=this.contentViewModels[e];t instanceof x&&t.next()}previousMedia(e){const t=this.contentViewModels[e];t instanceof x&&t.previous()}async updateGeometry(){const{graphic:e,spatialReference:t,_sourceLayer:i}=this;await(i?.load());const o=i?.objectIdField;if(!o||!e||!i)return;const r=e?.attributes?.[o];if(null==r)return;const s=[r];if(!e.geometry){const o=await R({layer:i,graphic:e,outFields:[],objectIds:s,returnGeometry:!0,spatialReference:t}),r=o?.geometry;r&&(e.geometry=r)}}_clear(){this._set("title",""),this._set("content",null),this._set("formattedAttributes",null)}async _graphicChanged(){this._cancelFeatureQuery(),this._error=null,this._clear();const{graphic:e}=this;if(!e)return;const t=new AbortController;this._featureAbortController=t;try{await this._queryFeature({signal:t.signal})}catch(i){l(i)||(this._error=i,a.getLogger(this).error("error","The popupTemplate could not be displayed for this feature.",{error:i,graphic:e,popupTemplate:this._effectivePopupTemplate}))}this._featureAbortController===t&&(this._featureAbortController=null)}_cancelFeatureQuery(){const{_featureAbortController:e}=this;e&&e.abort(),this._featureAbortController=null}_compileContentElement(e,t){return"attachments"===e.type?this._compileAttachments(e,t):"custom"===e.type?this._compileCustom(e,t):"fields"===e.type?this._compileFields(e,t):"media"===e.type?this._compileMedia(e,t):"text"===e.type?this._compileText(e,t):"expression"===e.type?this._compileExpression(e,t):"relationship"===e.type?this._compileRelationship(e,t):"utility-network-associations"===e.type?this._compileUtilityNetworkAssociation(e,t):void 0}_compileContent(e){if(this._destroyContentViewModels(),this.graphic)return Array.isArray(e)?e.filter(this._isAllowedContentType).map(((e,t)=>this._compileContentElement(e,t))).filter(r):"string"==typeof e?this._compileText(new A({text:e}),0).text:e}_destroyContentViewModels(){this.removeHandles(te),this.removeHandles(ee),this.contentViewModels.forEach((e=>e&&!e.destroyed&&e.destroy())),this._set("contentViewModels",[])}_matchesFeature(e,t){const i=e?.graphic?.getObjectId(),o=t?.getObjectId();return null!=i&&null!=o&&i===o}_setRelatedFeaturesViewModels({relatedFeatureViewModels:e,relatedFeatures:t,map:i}){const{view:o,spatialReference:r,timeZone:s}=this;t?.filter(Boolean).forEach((t=>{e.some((e=>this._matchesFeature(e,t)))||e.add(new Y({abilities:{relationshipContent:!1},map:i,view:o,spatialReference:r,timeZone:s,graphic:t}))})),e.forEach((i=>{const o=t?.find((e=>this._matchesFeature(i,e)));o||e.remove(i)}))}_setExpressionContentVM(e,t){const i=this.formattedAttributes,{contentElement:o,contentElementViewModel:r}=e,s=o?.type;r&&s&&("fields"===s&&(this._createFieldsFormattedAttributes({contentElement:o,contentElementIndex:t,formattedAttributes:i}),r.set(this._createFieldsVMParams(o,t))),"media"===s&&(this._createMediaFormattedAttributes({contentElement:o,contentElementIndex:t,formattedAttributes:i}),r.set(this._createMediaVMParams(o,t))),"text"===s&&r.set(this._createTextVMParams(o)))}_compileRelationship(e,t){const{displayCount:i,orderByFields:o,relationshipId:r,title:s,description:n}=e,{_sourceLayer:a,graphic:l,map:c}=this;if(!L(a))return;const p=new V({displayCount:i,graphic:l,orderByFields:o,relationshipId:r,layer:a,map:c,...this._compileTitleAndDesc({title:s,description:n})});return this.contentViewModels[t]=p,this.addHandles(d((()=>p.relatedFeatures),"change",(()=>this._setRelatedFeaturesViewModels(p))),te),e}_matchesGlobalFeature(e,t){const i=e?.association.globalId,o=t?.association.globalId;return null!=i&&null!=o&&i===o}async _setUpUtilityNetworkAssociationsViewModels(e,t,i){const{view:o,spatialReference:r,timeZone:n}=this;e.forEach(((i,o)=>{const r=t.get(o);r?i.forEach((t=>{r.find((e=>this._matchesGlobalFeature(t,e)))||(i.remove(t),0===i.length&&e.delete(o))})):(i.removeAll(),e.delete(o))})),t.forEach(((t,a)=>{const l=e.get(a)||new s;t?.filter(Boolean).forEach((e=>{l.some((t=>this._matchesGlobalFeature(t,e)))||l.add({association:e.association,featureViewModel:new Y({abilities:{utilityNetworkAssociationsContent:!1},map:i,view:o,spatialReference:r,timeZone:n,graphic:e.feature}),terminalName:e.terminalName})})),e.set(a,l)}));const a=new AbortController;this._associationVMAbortController=a,await this._sortListObjectsByTitle(e,{signal:a.signal}),this._associationVMAbortController===a&&(this._associationVMAbortController=null)}async _sortListObjectsByTitle(e,t){for(const i of e.values()){const e=i.map((e=>u((()=>"ready"===e.featureViewModel.state),t?.signal)));await Promise.all(e),i.sort(this._compareByFeatureTitle)}}_compareByFeatureTitle(e,t){const i=w(e.featureViewModel),o=w(t.featureViewModel);return i.localeCompare(o,void 0,{numeric:!0})}_compileUtilityNetworkAssociation(e,t){const{displayCount:i,title:o,description:r,associationTypes:s}=e,{_sourceLayer:n,graphic:a,map:l}=this;if(!O(n))return;const c=new X({graphic:a,displayCount:i,associationTypes:s,layer:n,map:l,...this._compileTitleAndDesc({title:o,description:r})});return this.contentViewModels[t]=c,this.addHandles([p((()=>c.associationFeatures.values()),(()=>this._setUpUtilityNetworkAssociationsViewModels(c.associationViewModels,c.associationFeatures,c.map)))],ie),e}_compileExpression(e,t){const{expressionInfo:i}=e,{graphic:o,map:r,spatialReference:s,view:n,location:a}=this,l=new F({expressionInfo:i,graphic:o,interceptor:Y.interceptor,map:r,spatialReference:s,view:n,location:a});return this.contentViewModels[t]=l,this.addHandles(p((()=>l.contentElementViewModel),(()=>this._setExpressionContentVM(l,t)),h),ee),e}_compileAttachments(e,t){const{graphic:i}=this,{description:o,title:r,orderByFields:s}=e;return this.contentViewModels[t]=new M({graphic:i,orderByFields:s,...this._compileTitleAndDesc({title:r,description:o})}),e}_compileCustom(e,t){const{graphic:i}=this,{creator:o,destroyer:r}=e;return this.contentViewModels[t]=new v({graphic:i,creator:o,destroyer:r}),e}_compileTitleAndDesc({title:e,description:t}){const{_fieldInfoMap:i,_sourceLayer:o,graphic:r,formattedAttributes:s}=this,n=r?.attributes,a=this._expressionAttributes,l=s.global;return{title:Z({attributes:n,fieldInfoMap:i,globalAttributes:l,expressionAttributes:a,layer:o,text:e}),description:Z({attributes:n,fieldInfoMap:i,globalAttributes:l,expressionAttributes:a,layer:o,text:t})}}_createFieldsVMParams(e,t){const i=this._effectivePopupTemplate,o=this.formattedAttributes,r={...o?.global,...o?.content[t]},s=e?.fieldInfos||i?.fieldInfos,n=s?.filter((({fieldName:e})=>!!e&&(k(e)||N(e)||r.hasOwnProperty(e)))),a=i?.expressionInfos,{description:l,title:c}=e;return{attributes:r,expressionInfos:a,fieldInfos:n,...this._compileTitleAndDesc({title:c,description:l})}}_compileFields(e,t){const i=e.clone(),o=new C(this._createFieldsVMParams(e,t));return this.contentViewModels[t]=o,i.fieldInfos=o.formattedFieldInfos.slice(),i}_createMediaVMParams(e,t){const{abilities:i,graphic:o,_fieldInfoMap:r,_effectivePopupTemplate:s,relatedInfos:n,_sourceLayer:a,_expressionAttributes:l}=this,c=this.formattedAttributes,p=o?.attributes??{},{description:d,mediaInfos:u,title:h}=e;return{abilities:{chartAnimation:i.chartAnimation},activeMediaInfoIndex:e.activeMediaInfoIndex||0,attributes:p,isAggregate:o?.isAggregate,layer:a,fieldInfoMap:r,formattedAttributes:{...c?.global,...c?.content[t]},expressionAttributes:l,mediaInfos:u,popupTemplate:s,relatedInfos:n,...this._compileTitleAndDesc({title:h,description:d})}}_compileMedia(e,t){const i=e.clone(),o=new x(this._createMediaVMParams(e,t));return i.mediaInfos=o.formattedMediaInfos.slice(),this.contentViewModels[t]=o,i}_createTextVMParams(e){const{graphic:t,_fieldInfoMap:i,_sourceLayer:o,_expressionAttributes:r}=this;if(e&&e.text){const s=t?.attributes??{},n=this.formattedAttributes?.global??{};e.text=Z({attributes:s,fieldInfoMap:i,globalAttributes:n,expressionAttributes:r,layer:o,text:e.text})}return{graphic:t,creator:e.text}}_compileText(e,t){const i=e.clone();return this.contentViewModels[t]=new v(this._createTextVMParams(i)),i}_compileLastEditInfo(){const{_effectivePopupTemplate:e,_sourceLayer:t,graphic:i,timeZone:o}=this;if(!e)return;const{lastEditInfoEnabled:r}=e,s=t?.editFieldsInfo;return r&&s?U(s,i?.attributes,o,t):void 0}_compileTitle(e){const{_fieldInfoMap:t,_sourceLayer:i,graphic:o,_expressionAttributes:r}=this,s=o?.attributes??{},n=this.formattedAttributes?.global??{};return Z({attributes:s,fieldInfoMap:t,globalAttributes:n,expressionAttributes:r,layer:i,text:e})}async _getTitle(){const{_effectivePopupTemplate:e,graphic:t}=this;return t?B({type:"title",value:e?.title,event:{graphic:t}}):null}async _getContent(){const{_effectivePopupTemplate:e,graphic:t}=this;return t?B({type:"content",value:e?.content,event:{graphic:t}}):null}async _queryFeature(e){const{_featureAbortController:t,_sourceLayer:i,graphic:o,_effectivePopupTemplate:r}=this,s=this.map,n=this.view,a=this.spatialReference,l=this.location;if(t!==this._featureAbortController||!o)return;await S({graphic:o,popupTemplate:r,layer:i,spatialReference:a},e);const{content:{value:p},title:{value:d}}=await c({content:this._getContent(),title:this._getTitle()}),{expressionAttributes:{value:u}}=await c({checkForRelatedFeatures:this._checkForRelatedFeatures(e),expressionAttributes:T({expressionInfos:r?.expressionInfos,spatialReference:a,graphic:o,map:s,interceptor:Y.interceptor,view:n,options:e,location:l})});t===this._featureAbortController&&o&&(this._expressionAttributes=u,this._graphicExpressionAttributes={...o.attributes,...u},this._set("formattedAttributes",this._createFormattedAttributes(p)),this._set("title",this._compileTitle(d)),this._set("lastEditInfo",this._compileLastEditInfo()||null),this._set("content",this._compileContent(p)||null))}_createMediaFormattedAttributes({contentElement:e,contentElementIndex:t,formattedAttributes:i}){const{_effectivePopupTemplate:o,graphic:r,relatedInfos:s,_sourceLayer:n,_fieldInfoMap:a,_graphicExpressionAttributes:l,timeZone:c}=this;i.content[t]=H({fieldInfos:o?.fieldInfos,graphic:r,attributes:{...l,...e.attributes},layer:n,fieldInfoMap:a,relatedInfos:s,timeZone:c})}_createFieldsFormattedAttributes({contentElement:e,contentElementIndex:t,formattedAttributes:i}){if(e.fieldInfos){const{graphic:o,relatedInfos:r,_sourceLayer:s,_fieldInfoMap:n,_graphicExpressionAttributes:a,timeZone:l}=this;i.content[t]=H({fieldInfos:e.fieldInfos,graphic:o,attributes:{...a,...e.attributes},layer:s,fieldInfoMap:n,relatedInfos:r,timeZone:l})}}_createFormattedAttributes(e){const{_effectivePopupTemplate:t,graphic:i,relatedInfos:o,_sourceLayer:r,_fieldInfoMap:s,_graphicExpressionAttributes:n,timeZone:a}=this,l=t?.fieldInfos,c={global:H({fieldInfos:l,graphic:i,attributes:n,layer:r,fieldInfoMap:s,relatedInfos:o,timeZone:a}),content:[]};return Array.isArray(e)&&e.forEach(((e,t)=>{"fields"===e.type&&this._createFieldsFormattedAttributes({contentElement:e,contentElementIndex:t,formattedAttributes:c}),"media"===e.type&&this._createMediaFormattedAttributes({contentElement:e,contentElementIndex:t,formattedAttributes:c})})),c}_checkForRelatedFeatures(e){const{graphic:t,_effectivePopupTemplate:i}=this;return this._queryRelatedInfos(t,j(i),e)}async _queryRelatedInfos(e,t,i){const{relatedInfos:o,_sourceLayer:r}=this;o.clear();const s=null!=r?.associatedLayer?await(r?.associatedLayer.load(i)):r;if(!s||!e)return;const n=t.filter((e=>!!e.fieldName&&N(e.fieldName)));if(!n?.length)return;t.forEach((e=>this._configureRelatedInfo(e,s)));const a=await q({relatedInfos:o,layer:s},i);Object.keys(a).forEach((e=>{const t=o.get(e.toString()),i=a[e]?.value;t&&i&&(t.layerInfo=i.data)}));const l=await Q({graphic:e,relatedInfos:o,layer:s},i);Object.keys(l).forEach((e=>{z(l[e]?.value,o.get(e.toString()))}))}_configureRelatedInfo(e,t){const{relatedInfos:i}=this,o=J(e.fieldName||"");if(!o)return;const{layerId:r,fieldName:s}=o;if(!r)return;const n=i.get(r.toString())||K(r,t);n&&(W({relatedInfo:n,fieldName:s,fieldInfo:e}),this.relatedInfos.set(r,n))}};re.interceptor=new i(D,G),e([m()],re.prototype,"_error",void 0),e([m()],re.prototype,"_featureAbortController",void 0),e([m()],re.prototype,"_associationVMAbortController",void 0),e([m({readOnly:!0})],re.prototype,"_effectivePopupTemplate",null),e([m({readOnly:!0})],re.prototype,"_fieldInfoMap",null),e([m({readOnly:!0})],re.prototype,"_sourceLayer",null),e([m()],re.prototype,"abilities",void 0),e([_("abilities")],re.prototype,"castAbilities",null),e([m({readOnly:!0})],re.prototype,"content",void 0),e([m({readOnly:!0})],re.prototype,"contentViewModels",void 0),e([m()],re.prototype,"description",void 0),e([m({type:Boolean})],re.prototype,"defaultPopupTemplateEnabled",void 0),e([m({readOnly:!0})],re.prototype,"isTable",null),e([m({readOnly:!0})],re.prototype,"state",null),e([m({readOnly:!0})],re.prototype,"formattedAttributes",void 0),e([m({type:t,value:null})],re.prototype,"graphic",null),e([m({readOnly:!0})],re.prototype,"lastEditInfo",void 0),e([m({type:b})],re.prototype,"location",void 0),e([m({readOnly:!0})],re.prototype,"relatedInfos",void 0),e([m({type:g})],re.prototype,"spatialReference",null),e([m()],re.prototype,"timeZone",null),e([m({readOnly:!0})],re.prototype,"title",void 0),e([m()],re.prototype,"map",null),e([m({readOnly:!0})],re.prototype,"waitingForContent",null),e([m()],re.prototype,"view",void 0),re=Y=e([y("esri.widgets.Feature.FeatureViewModel")],re);const se=re;export{se as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as t}from"../../chunks/tslib.es6.js";import o from"../../core/Accessor.js";import{when as i}from"../../core/reactiveUtils.js";import{property as e}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as a}from"../../core/accessorSupport/decorators/subclass.js";let s=class extends o{constructor(t){super(t),this._navigationMode="pan",this.view=null}initialize(){this.addHandles(i((()=>this.view?.inputManager),(()=>this._setNavigationMode())))}destroy(){this.view=null}get state(){return this.view?.ready&&"3d"===this.view?.type?"ready":"disabled"}get navigationMode(){return this._navigationMode}set navigationMode(t){this._navigationMode=t,this._setNavigationMode()}toggle(){"disabled"!==this.state&&(this.navigationMode="pan"!==this.navigationMode?"pan":"rotate")}_setNavigationMode(){const t=this.view?.navigation.actionMap;if(!t)return;const o="pan"===this._navigationMode;t.dragPrimary=o?"pan":"rotate",t.dragSecondary=o?"rotate":"pan"}};t([e({readOnly:!0})],s.prototype,"state",null),t([e()],s.prototype,"_navigationMode",void 0),t([e()],s.prototype,"view",void 0),s=t([a("esri.widgets.NavigationToggle.NavigationToggleViewModel")],s);const r=s;export{r as default};
5
+ import{_ as t}from"../../chunks/tslib.es6.js";import o from"../../core/Accessor.js";import{when as i}from"../../core/reactiveUtils.js";import{property as a}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as e}from"../../core/accessorSupport/decorators/subclass.js";let s=class extends o{constructor(t){super(t),this._navigationMode="pan",this.view=null}initialize(){this.addHandles(i((()=>this.view?.navigation?.actionMap),(()=>this._updateNavigationActionMap())))}destroy(){this.view=null}get state(){return this.view?.ready&&"3d"===this.view?.type?"ready":"disabled"}get navigationMode(){return this._navigationMode}set navigationMode(t){this._navigationMode=t,this._updateNavigationActionMap()}toggle(){"disabled"!==this.state&&(this.navigationMode="pan"!==this.navigationMode?"pan":"rotate")}_updateNavigationActionMap(){const t=this.view?.navigation?.actionMap;if(!t)return;const o="pan"===this._navigationMode;t.dragPrimary=o?"pan":"rotate",t.dragSecondary=o?"rotate":"pan"}};t([a({readOnly:!0})],s.prototype,"state",null),t([a()],s.prototype,"_navigationMode",void 0),t([a()],s.prototype,"view",void 0),s=t([e("esri.widgets.NavigationToggle.NavigationToggleViewModel")],s);const r=s;export{r as default};