12345 |
- /*
- All material copyright ESRI, All Rights Reserved, unless otherwise specified.
- See https://js.arcgis.com/4.24/esri/copyright.txt for details.
- */
- import{_ as e}from"../chunks/tslib.es6.js";import{HandleOwnerMixin as t}from"../core/HandleOwner.js";import{when as s,watch as i}from"../core/reactiveUtils.js";import{aliasOf as r}from"../core/accessorSupport/decorators/aliasOf.js";import"../core/arrayUtils.js";import"../core/has.js";import"../core/accessorSupport/ensureType.js";import{property as o}from"../core/accessorSupport/decorators/property.js";import{subclass as l}from"../core/accessorSupport/decorators/subclass.js";import a from"./Widget.js";import{storeNode as n}from"./support/widgetUtils.js";import{messageBundle as c}from"./support/decorators/messageBundle.js";import{vmEvent as d}from"./support/decorators/vmEvent.js";import{tsx as h}from"./support/jsxFactory.js";import u from"./UtilityNetworkTrace/UtilityNetworkTraceViewModel.js";import{GraphicHandler as p,HIGHLIGHT_COLOR as g}from"./UtilityNetworkTrace/support/GraphicHandler.js";const m={base:"esri-utility-trace-network",loaderContainer:"esri-utility-trace-network__loader-container",loader:"esri-utility-trace-network__loader",fadeIn:"esri-utility-trace-network--fade-in",addButtonContainer:"esri-utility-trace-network__add-button-container",noticeContainer:"esri-utility-trace-network__notice-container",listContainer:"esri-utility-trace-network__list-container",resultsContainer:"esri-utility-trace-network__results-container",flow:"esri-utility-trace-network__flow",esriWidget:"esri-widget",esriWidgetPanel:"esri-widget--panel",esriWidgetDisabled:"esri-widget--disabled",esriButton:"esri-button",esriButtonTertiary:"esri-button--tertiary",esriInput:"esri-input",esriMatchHeight:"esri-match-height",iconHandle:"esri-icon-handle-vertical",iconPlus:"esri-icon-plus",iconEdit:"esri-icon-edit",iconHandleHorizontal:"esri-icon-handle-horizontal",iconRefresh:"esri-icon-refresh",iconLink:"esri-icon-link",iconRemove:"esri-icon-erase",widgetIcon:"esri-icon-UtilityNetworkTrace",header:"esri-widget__heading",loading:"esri-icon-loading-indicator",rotating:"esri-rotating"},w="esri.widgets.UtilityNetworkTrace";function _(e){return{height:e+"px"}}function v(e){return{width:e+"px"}}function b(){return{width:"75%"}}function y(){return{textAlign:"center"}}const T={NOEXTENTION:-2147208474};let S=class extends(t(a)){constructor(e,t){super(e,t),this._tracesExists=!0,this._graphicHandler=null,this._selectToolActive=!1,this._activeTrace=null,this._activeSwatch="",this._traceHeaderForFlow="",this._assetGroupHeader="",this._assetTypeHeader="",this._traceResultsFunctions=[],this._traceResultsAssetGroup=[],this._traceResultsAssetType=[],this._traceResultsIndividual=[],this._showTraceResultFunctions=!1,this._showTraceResultAssetGroup=!1,this._showTraceResultAssetType=!1,this._showIndividualRecords=!1,this._activeTab="input",this._flagViewType="starting-point",this._alertRemoveModal=!1,this._warningNoFlag=!1,this._warningNoTraceSelected=!1,this._warningNoStartAssetFound=!1,this._warningNoBarrierAssetFound=!1,this._confirmReset=!1,this._showResultOptions=!1,this._resultDisplayField="objectid",this._resultSortField="objectid",this._resultSortOrder="desc",this._swatchNode=null,this._individualResultNode=null,this._symbolStartFlag=null,this._symbolBarrier=null,this._watchHandler=null,this._loadUNError=!0,this._errorMessage="",this.defaultGraphicColor={color:[255,255,0,.6],haloOpacity:.9,fillOpacity:.2,hex:"#FFFF00"},this.disabled=!0,this.flags=[],this.gdbVersion="sde.DEFAULT",this.goToOverride=null,this.iconClass=m.widgetIcon,this.inputSettings=[],this.label=void 0,this.messages=null,this.messagesCommon=null,this.selectedTraces=[],this.selectOnComplete=!0,this.showGraphicsOnComplete=!0,this.showSelectionAttributes=!0,this.view=null,this.viewModel=new u}initialize(){this._utilityNetworkTraceInitialized(),this._graphicHandler=new p}async checkCanTrace(){this._confirmReset=!1;const e=this.viewModel.checkCanTrace();e.status?(this._warningNoFlag=!1,this._warningNoTraceSelected=!1,this._warningNoTraceSelected=!1,this._showTraceResultFunctions=!1,this._showTraceResultAssetGroup=!1,this._showTraceResultAssetType=!1,this._showIndividualRecords=!1,this.switchTab("result"),this.viewModel._activeProgress=!0,await this.viewModel.callTrace(),this.viewModel._activeProgress=!1):e.issues.forEach((e=>{"noStart"===e?this._warningNoFlag=!0:this._warningNoTraceSelected=!0}))}confirmReset(){this._confirmReset=!0}render(){const{state:e}=this.viewModel;this._mixCustomStrings(),this._overrideFlagSymbol();const t="loading"===e?this.renderLoading():this.renderUtilityNetworkTrace();return h("div",{class:this.classes(m.base,m.esriWidget,m.esriWidgetPanel,{[m.esriWidgetDisabled]:this.disabled})},t)}loadDependencies(){return Promise.all([import("@esri/calcite-components/dist/components/calcite-action.js"),import("@esri/calcite-components/dist/components/calcite-action-group.js"),import("@esri/calcite-components/dist/components/calcite-action-pad.js"),import("@esri/calcite-components/dist/components/calcite-checkbox.js"),import("@esri/calcite-components/dist/components/calcite-color-picker-swatch.js"),import("@esri/calcite-components/dist/components/calcite-combobox.js"),import("@esri/calcite-components/dist/components/calcite-combobox-item.js"),import("@esri/calcite-components/dist/components/calcite-block.js"),import("@esri/calcite-components/dist/components/calcite-block-section.js"),import("@esri/calcite-components/dist/components/calcite-button.js"),import("@esri/calcite-components/dist/components/calcite-flow.js"),import("@esri/calcite-components/dist/components/calcite-icon.js"),import("@esri/calcite-components/dist/components/calcite-label.js"),import("@esri/calcite-components/dist/components/calcite-list.js"),import("@esri/calcite-components/dist/components/calcite-list-item.js"),import("@esri/calcite-components/dist/components/calcite-modal.js"),import("@esri/calcite-components/dist/components/calcite-notice.js"),import("@esri/calcite-components/dist/components/calcite-option.js"),import("@esri/calcite-components/dist/components/calcite-panel.js"),import("@esri/calcite-components/dist/components/calcite-popover.js"),import("@esri/calcite-components/dist/components/calcite-select.js"),import("@esri/calcite-components/dist/components/calcite-tabs.js"),import("@esri/calcite-components/dist/components/calcite-tab.js"),import("@esri/calcite-components/dist/components/calcite-tab-nav.js"),import("@esri/calcite-components/dist/components/calcite-tab-title.js")])}switchTab(e){this._activeTab=e}switchToFunctions(e,t){this._traceResultsFunctions=e,this._showTraceResultFunctions=t}switchToAssetGroup(e,t,s){this._traceHeaderForFlow=t,this._traceResultsAssetGroup=e,this._showTraceResultAssetGroup=s}switchToAssetType(e,t,s){this._assetGroupHeader=t,this._traceResultsAssetType=e,this._showTraceResultAssetType=s}switchToIndividualRecords(e,t,s){this._assetTypeHeader=t,this._traceResultsIndividual=e,this._showIndividualRecords=s}renderLoading(){return h("div",{class:m.loaderContainer,key:"loader"},h("div",{class:m.loader}))}renderUtilityNetworkTrace(){const{messages:e}=this;let t=h("calcite-tabs",{position:"above",layout:"center",class:m.esriMatchHeight},h("calcite-tab-nav",{slot:"tab-nav"},h("calcite-tab-title",{active:"input"===this._activeTab,onclick:()=>{this.switchTab("input")}},e.inputsStrings.headerTabInputs),h("calcite-tab-title",{active:"result"===this._activeTab,onclick:()=>{this.switchTab("result")}},e.resultsStrings.headerTabResults)),h("calcite-tab",{active:"input"===this._activeTab,class:m.esriMatchHeight},this.renderInputPanel()),h("calcite-tab",{active:"result"===this._activeTab,class:m.esriMatchHeight},this.viewModel._activeProgress?h("calcite-loader",{active:!0,label:e.alertsStrings.traceExecuting,text:e.alertsStrings.traceExecuting,type:"indeterminate"}):this.viewModel._traceResults.length>0?this.renderResultPanel():this.renderWarningMessage("noTraceExecuted",!1),h("calcite-modal",{active:this._confirmReset,color:"blue",scale:"m",width:"s","intl-close":"Close",onCalciteModalClose:()=>{this._confirmReset=!1}},h("h3",{slot:"header"},e.resultsStrings.startOverButton),h("div",{slot:"content"},e.resultsStrings.startOverValidation),h("calcite-button",{slot:"secondary",width:"full",appearance:"outline",onclick:()=>{this._confirmReset=!1}},e.globalStrings.cancel),h("calcite-button",{slot:"primary",width:"full",onclick:()=>{this._confirmReset=!1,this.viewModel.reset(),this.switchTab("input")}},e.globalStrings.ok))));return this._tracesExists||(t=h("calcite-panel",null,this.renderWarningMessage("noTraceConfig",!1))),this._loadUNError||(t=h("calcite-panel",null,this.renderWarningMessage("loadUNError",!1,this._errorMessage))),t}renderInputPanel(){const{messages:e}=this;return h("calcite-flow",{class:m.flow},h("calcite-panel",null,this._warningNoFlag?this.renderWarningMessage("flag",!0):null,this._warningNoTraceSelected?this.renderWarningMessage("trace",!0):null,this.renderTraceSelectorContainer(),this.renderStartFlagsContainer(),this.renderBarriersFlagsContainer(),this._warningNoFlag&&this._warningNoTraceSelected?h("div",{styles:_(10)}):null,h("calcite-button",{slot:"footer",scale:"m",color:"blue",width:"full",onclick:()=>{this.checkCanTrace()}},e.tracingStrings.runTrace)),this._selectToolActive?this.renderActiveTool():null)}renderResultPanel(){return h("div",{class:this.classes(m.esriMatchHeight,m.resultsContainer)},h("calcite-flow",null,this.renderTraceResults(),this._showTraceResultFunctions?this.renderTraceResultFunctions():null,this._showTraceResultAssetGroup?this.renderTraceResultByAssetGroup():null,this._showTraceResultAssetType?this.renderTraceResultByAssetType():null,this._showIndividualRecords?this.renderTraceResultIndividual():null,this._showIndividualRecords?this.renderTraceResultIndividualPopover():null))}renderStartFlagsContainer(){const{messages:e}=this,t=[];let s=[];s=this.viewModel._flags.filter((e=>"starting-point"===e.type)),s.forEach((e=>{e.displayValue&&t.push(this.renderFlagRow(e,"start"))}));let i=null;return this._symbolStartFlag&&(i=this._getSymbolIcon(this._symbolStartFlag)),h("calcite-block",{heading:e.inputsStrings.headerStartingPoint+" ("+s.length+")",open:!0,collapsible:!0},h("div",{slot:"icon"},i||h("calcite-icon",{icon:"pin",scale:"s"})),h("div",null,e.inputsStrings.startingPointHint),h("div",{class:m.listContainer},t),this._warningNoStartAssetFound?this.renderWarningMessage("noStartAsset",!0):null,h("div",{class:m.addButtonContainer},h("calcite-button",{alignment:"center",appearance:"outline","icon-start":"plus",scale:"m",href:"",label:e.inputsStrings.addPointOption,onclick:()=>{this._flagViewType="starting-point",this._selectToolActive=!0,this._warningNoStartAssetFound=!1,this.viewModel.addFlagByHit("starting-point",this._symbolStartFlag).then((e=>{e?this._warningNoFlag=!1:this._warningNoStartAssetFound=!0,this._selectToolActive=!1}))},round:!0})))}renderBarriersFlagsContainer(){const{messages:e}=this,t=[];let s=[];s=this.viewModel._flags.filter((e=>"barrier"===e.type)),s.forEach((e=>{e.displayValue&&t.push(this.renderFlagRow(e,"barrier"))}));let i=null;return this._symbolBarrier&&(i=this._getSymbolIcon(this._symbolBarrier)),h("calcite-block",{heading:e.inputsStrings.headerBarrier+" ("+s.length+")",open:!1,collapsible:!0},h("div",{slot:"icon"},i||h("calcite-icon",{icon:"x-circle-f",scale:"s"})),h("div",null,e.inputsStrings.barrierPointHint),h("div",{class:m.listContainer},t),this._warningNoBarrierAssetFound?this.renderWarningMessage("noBarrierAsset",!0):null,h("div",{class:m.addButtonContainer},h("calcite-button",{alignment:"center",appearance:"outline",color:"blue","icon-start":"plus",scale:"m",href:"",round:!0,label:e.inputsStrings.addPointOption,onclick:()=>{this._flagViewType="barrier",this._selectToolActive=!0,this._warningNoBarrierAssetFound=!1,this.viewModel.addFlagByHit("barrier",this._symbolBarrier).then((e=>{e||(this._warningNoBarrierAssetFound=!0),this._selectToolActive=!1}))}})))}renderFlagRow(e,t){const{messages:s}=this,i=[];let r=!1;return null!==e.allTerminals&&void 0!==e.allTerminals&&e.allTerminals.terminals.length>0&&(r=!0,e.allTerminals.terminals.forEach((t=>{let s=!1;e.selectedTerminals.includes(t.id)&&(s=!0),i.push(h("calcite-combobox-item",{key:t.name,selected:s,value:t.id,"text-label":t.name,onclick:t=>{this.viewModel.addTerminal(t.target.value,e)}}))}))),h("calcite-block",{key:"pop"+e.globalId+e.type+e.id+t,heading:e.displayValue.value,collapsible:null!==e.allTerminals||"barrier"===e.type},h("calcite-action",{textEnabled:!0,slot:"header-menu-actions",text:s.globalStrings.remove,label:s.globalStrings.remove,onCalciteListItemChange:()=>{this.viewModel.removeFlag(e)},onclick:()=>{this.viewModel.removeFlag(e)},scale:"s",icon:"trash"}),h("calcite-action",{textEnabled:!0,slot:"header-menu-actions",text:s.globalStrings.zoomToFeature,label:s.globalStrings.zoomToFeature,onCalciteListItemChange:()=>{this.viewModel.zoomToAsset(e.details.geometry)},onclick:()=>{this.viewModel.zoomToAsset(e.details.geometry)},scale:"s",icon:"zoom-to-object"}),"barrier"===e.type?h("calcite-label",{scale:"s",layout:"inline"},h("calcite-checkbox",{checked:e.isFilterBarrier,scale:"s",onclick:()=>{this.viewModel.manageFilterBarrier(!e.isFilterBarrier,e)}}),s.inputsStrings.barrierFilter):null,r?h("calcite-combobox",{label:s.globalStrings.selectTerminalPlaceholder,placeholder:s.globalStrings.selectTerminalPlaceholder,"selection-mode":"multi",scale:"s",maxItems:0,onCalciteComboboxChipDismiss:t=>{this.viewModel.removeTerminal(t.target.value,e)}},i):null)}renderActiveTool(){const{messages:e}=this;let t=null;return"starting-point"===this._flagViewType?this._symbolStartFlag&&(t=this._getSymbolIcon(this._symbolStartFlag)):this._symbolBarrier&&(t=this._getSymbolIcon(this._symbolBarrier)),h("calcite-panel",{"height-scale":"s",onCalcitePanelBackClick:()=>{this.viewModel._clickHandler&&(this.viewModel._clickHandler.remove(),this.view.popup.autoOpenEnabled=!0),this._selectToolActive=!1},heading:e.inputsStrings.addPointOption},h("calcite-block",{open:!0,collapsible:!1,heading:""},h("div",{styles:y()},t||h("calcite-icon",{icon:"starting-point"===this._flagViewType?"pin":"x-circle-f",scale:"s"})),h("div",{styles:y()},e.inputsStrings.addPointHint)))}renderTraceSelectorContainer(){const{messages:e}=this,t=[];return this.viewModel._traces.length>0&&this.viewModel._traces.forEach((e=>{t.push(h("calcite-combobox-item",{key:e.globalId,selected:e.selected,value:e.globalId,"text-label":e.title,onCalciteComboboxItemChange:t=>{const s=t.target;this.viewModel.selectTraces(s.selected,e.globalId),this.viewModel._traces.length>0&&(this._warningNoTraceSelected=!1)}}))})),h("calcite-block",{heading:e.tracingStrings.traceOperation,open:!0,collapsible:!0},h("calcite-combobox",{label:e.inputsStrings.selectTraces,placeholder:e.inputsStrings.selectTraces,"selection-mode":"multi",scale:"s",maxItems:0,onCalciteComboboxChipDismiss:e=>{this.viewModel.selectTraces(!1,e.target.value),this.viewModel._traces.length>0&&(this._warningNoTraceSelected=!1)}},t))}renderStartOverContainer(){const{messages:e}=this;return h("calcite-button",{slot:"footer",scale:"m",color:"blue",width:"full",onclick:()=>{this.confirmReset()}},e.resultsStrings.startOverButton)}renderWarningMessage(e,t,s){const{messages:i}=this;let r=i.alertsStrings.NoRunAlertHeader,o=i.alertsStrings.noResultsInfo;switch(e){case"flag":r=i.alertsStrings.startingPointAlertHeader,o=i.alertsStrings.startingPointAlert;break;case"trace":r=i.alertsStrings.selectTraceAlertHeader,o=i.alertsStrings.selectTraceAlert;break;case"noTraceExecuted":r=i.alertsStrings.NoRunAlertHeader,o=i.alertsStrings.noResultsInfo;break;case"noBarrierAsset":case"noStartAsset":r=i.alertsStrings.noAssetsFoundHeader,o=i.alertsStrings.noAssetFound;break;case"noTraceConfig":r="",o=i.alertsStrings.noTraceSupported;break;default:r=i.alertsStrings.genericErrorHeader,o=s||""}return h("div",{class:m.noticeContainer,key:e},h("calcite-notice",{open:!0,key:e,active:!0,dismissible:t,icon:!0,scale:"s",width:"auto",color:"red",onCalciteNoticeClose:()=>{switch(e){case"flag":this._warningNoFlag=!1;break;case"trace":this._warningNoTraceSelected=!1;break;case"noStartAsset":this._warningNoStartAssetFound=!1;break;case"noBarrierAsset":this._warningNoBarrierAssetFound=!1}}},h("div",{slot:"title"},r),h("div",{slot:"message"},o)))}renderRemoveTraceContainer(e){const{messages:t}=this;return h("calcite-action",{textEnabled:!0,slot:"header-menu-actions",text:t.globalStrings.clearResults,label:t.globalStrings.clearResults,onCalciteListItemChange:()=>{this._alertRemoveModal=!0,this._activeTrace=e.trace},onclick:()=>{this._alertRemoveModal=!0,this._activeTrace=e.trace},scale:"s",icon:"trash"})}renderHighlightColorPicker(e,t){const{messages:s}=this,i=[];for(let r=0;r<g.length;r++)i.push(h("calcite-action",{key:r,text:s.resultsStrings.graphicColor,label:s.resultsStrings.graphicColor,scale:"s",onclick:()=>{this.viewModel.changeResultGraphicColor(this._graphicHandler.getHighlightColor(r),t)}},h("calcite-color-picker-swatch",{scale:"s",color:this._graphicHandler.getHighlightColor(r).hex,active:e.color===this._graphicHandler.getHighlightColor(r).color})));return h("calcite-action-pad",{position:"start",layout:"grid",expandDisabled:!0},h("calcite-action-group",{layout:"grid",columns:4},i))}renderTraceResults(){const{messages:e}=this,t=this.viewModel._traceResults,s=[];return t.forEach(((t,i)=>{let r=[],o=[],l=!1,a=!1,n=!1;null!==t.results&&t.results.hasOwnProperty("elements")?(null!==t.results.aggregatedGeometry&&(a=!0),null!==t.results.globalFunctionResults&&t.results.globalFunctionResults.length>0&&(o=t.results.globalFunctionResults,o.length>0&&(n=!0)),t.results.elements.length>0&&(r=t.results.elements,r.length>0&&(l=!0)),s.push(h("calcite-block",{key:t.trace.title,heading:t.trace.title,summary:t.trace.description,collapsible:!1,open:!0,intlOptions:e.resultsStrings.ellipsesOptions},this.renderRemoveTraceContainer(t),h("calcite-list",null,n?h("calcite-list-item",{label:e.resultsStrings.functionHeader+" ("+o.length+")",onclick:()=>{this.switchToFunctions(o,!0)}},h("calcite-icon",{icon:"chevron-right",scale:"s",slot:"content-end"})):null,l&&this.viewModel.showSelectionAttributes?h("calcite-list-item",{key:this.id,label:e.resultsStrings.viewFeatures+" ("+r.length+")",onclick:()=>{this.switchToAssetGroup(this._groupResultsByAssetGroup(t),t.trace.title+" ("+r.length+")",!0)}},h("calcite-icon",{icon:"chevron-right",scale:"s",slot:"content-end"})):this.viewModel.showSelectionAttributes?h("calcite-label",{layout:"inline",scale:"s"},e.resultsStrings.noSelectionResults):null),h("div",{styles:_(10)}),l?h("calcite-label",{layout:"inline",scale:"s",onclick:e=>{e.preventDefault(),e.stopPropagation(),this.viewModel.mergeSelection(!t.selectionEnabled,t.trace)}},h("calcite-checkbox",{checked:t.selectionEnabled,scale:"m",onclick:e=>{e.preventDefault(),e.stopPropagation(),this.viewModel.mergeSelection(!t.selectionEnabled,t.trace)}}),this.viewModel.showSelectionAttributes?e.resultsStrings.selectFeatures:e.resultsStrings.selectFeatures+" ("+r.length+")"):null,a?h("calcite-block-section",{"toggle-display":"switch",text:e.resultsStrings.highlightTrace,open:t.graphicEnabled,onCalciteBlockSectionToggle:e=>{e.target.open?this.viewModel.changeResultGraphicColor(t.graphicColor,t):this.viewModel.removeResultGraphicFromView(t)}},h("calcite-action",{text:e.resultsStrings.graphicColor,label:e.resultsStrings.graphicColor,scale:"s",onclick:e=>{const t=e.target;this._swatchNode=t,this._activeSwatch="aggGeom_"+i}},h("calcite-color-picker-swatch",{scale:"s",color:t.graphicColor.hex})),h("calcite-popover",{autoClose:!0,label:e.resultsStrings.graphicColor,text:e.resultsStrings.graphicColor,referenceElement:this._swatchNode,placement:"auto-start",offsetDistance:0,offsetSkidding:0,open:this._activeSwatch==="aggGeom_"+i,onCalcitePopoverClose:()=>{this._swatchNode=null,this._activeSwatch=null}},this.renderHighlightColorPicker(t.graphicColor,t))):null))):s.push(h("calcite-block",{key:"error-"+i,heading:t.trace.title,collapsible:!1,open:!0},this.renderRemoveTraceContainer(t),this.renderWarningMessage("noController",!1,t.status)))})),h("calcite-panel",{key:"traceResults"},s,this.renderStartOverContainer(),h("calcite-modal",{active:this._alertRemoveModal,color:"blue",scale:"m",width:"s","intl-close":"Close",onCalciteModalClose:()=>{this._alertRemoveModal=!1}},h("h3",{slot:"header"},e.globalStrings.clearResults),h("div",{slot:"content"},e.alertsStrings.clearResultsAlert),h("calcite-button",{slot:"secondary",width:"full",appearance:"outline",onclick:()=>{this._alertRemoveModal=!1}},e.globalStrings.cancel),h("calcite-button",{slot:"primary",width:"full",onclick:()=>{this.viewModel.clearResult(this._activeTrace),this._alertRemoveModal=!1,0===this.viewModel._traceResults.length?this.switchTab("input"):(this._activeTrace=this.viewModel._traceResults[0].trace,this._showTraceResultFunctions=!1,this._showTraceResultAssetGroup=!1,this._showTraceResultAssetType=!1,this._showIndividualRecords=!1)}},e.globalStrings.ok)))}renderTraceResultFunctions(){const{messages:e}=this,t=this._traceResultsFunctions,s=[];return t.forEach((e=>{s.push(this.renderResultRowFunctions(e))})),h("calcite-panel",{key:"functionResultMultiple",onCalcitePanelBackClick:()=>{this.switchToFunctions([],!1)},heading:e.resultsStrings.functionHeader},s,this.renderStartOverContainer())}renderTraceResultByAssetGroup(){const e=this._traceResultsAssetGroup,t=[];for(const s in e){const i=e[s];for(const e in i)t.push(this.renderResultRowAssetGroup(i[e]))}return h("calcite-panel",{key:"assetGroupResultMultiple",onCalcitePanelBackClick:()=>{this.switchToAssetGroup([],"",!1)},heading:this._traceHeaderForFlow},h("calcite-list",null,t),this.renderStartOverContainer())}renderTraceResultByAssetType(){const e=this._traceResultsAssetType,t=[];for(const s in e)e[s].length>0&&t.push(this.renderResultRowAssetType(e[s]));return h("calcite-panel",{key:"assetTypeResult",onCalcitePanelBackClick:()=>{this.switchToAssetType([],"",!1)},heading:this._assetGroupHeader},t,this.renderStartOverContainer())}renderTraceResultIndividual(){const{messages:e}=this,t=this._traceResultsIndividual;t.sort(this._compare(this._resultSortField,this._resultSortOrder));const s=[];if(t.length>0){t[0].details.fields.some((e=>e.name.toLowerCase()===this._resultDisplayField.toLocaleLowerCase()))||(this._resultDisplayField="objectid",this._resultSortField="objectid"),t.forEach((e=>{s.push(this.renderResultRowIndividual(e))}))}return h("calcite-panel",{key:"individualResult",onCalcitePanelBackClick:()=>{this._showResultOptions=!1,this.switchToIndividualRecords([],"",!1)},heading:this._assetTypeHeader},h("calcite-action",{"text-enabled":!0,slot:"header-actions-end",text:e.resultsStrings.displayAttribute,onCalciteListItemChange:()=>{this._showResultOptions=!0},onclick:()=>{this._showResultOptions=!0},scale:"s",icon:"gear",label:e.resultsStrings.displayAttribute,id:"field_options"+this.id,afterCreate:n,bind:this,"data-node-ref":"_individualResultNode"}),s,this.renderStartOverContainer())}renderTraceResultIndividualPopover(){const{messages:e}=this,t=this._traceResultsIndividual,s=[],i=[];return t.length>0&&t[0].details.fields.forEach((e=>{s.push(h("calcite-option",{key:"display"+e.name,label:e.alias,value:e.name,selected:e.name===this._resultDisplayField})),i.push(h("calcite-option",{key:"sort"+e.name,label:e.alias,value:e.name,selected:e.name===this._resultSortField}))})),h("calcite-popover",{autoClose:!0,label:e.resultsStrings.displayAttribute,referenceElement:this._individualResultNode,placement:"left-start",offsetDistance:0,offsetSkidding:0,open:this._showResultOptions,styles:null!==this.domNode?v(.75*this.domNode.clientWidth):b()},h("calcite-block",{heading:"",open:!0},h("calcite-label",{scale:"s"},e.resultsStrings.displayAttribute,h("calcite-select",{label:e.resultsStrings.displayAttribute,onCalciteSelectChange:e=>{const t=e.target;this._resultDisplayField=t.selectedOption.value,this._showResultOptions=!1}},s)),h("calcite-label",{scale:"s"},e.resultsStrings.sortBy,h("calcite-select",{label:e.resultsStrings.sortBy,onCalciteSelectChange:e=>{const s=e.target;this._resultSortField=s.selectedOption.value,t.sort(this._compare(this._resultSortField,this._resultSortOrder)),this._traceResultsIndividual=t,this._showResultOptions=!1}},i))))}renderResultRow(e){let t=e[0].assetGroupCode;const s=this.viewModel.getValidSources().filter((t=>t.sourceId===e[0].networkSourceId));if(s.length>0){const i=s[0].assetGroups.filter((t=>t.assetGroupCode===e[0].assetGroupCode));i.length>0&&(t=i[0].assetGroupName)}return h("calcite-list-item",{label:t+" ("+e.length+")",onclick:()=>{this.switchToAssetType(this._groupResultsByAssetType(e),t+" ("+e.length+")",!0)}},h("calcite-icon",{icon:"chevron-right",scale:"s",slot:"content-end"}))}renderResultRowFunctions(e){return h("calcite-block",{heading:e.networkAttributeName+" "+e.functionType+" = "+e.result,collapsible:!1})}renderResultRowAssetGroup(e){const t=this._getAssetGroupName(e[0]);return h("calcite-list-item",{label:t+" ("+e.length+")",onclick:()=>{this.switchToAssetType(this._groupResultsByAssetType(e),t+" ("+e.length+")",!0)}},h("calcite-icon",{slot:"content-end",icon:"chevron-right",scale:"s"}))}renderResultRowAssetType(e){const t=this._getAssetTypeName(e[0]);return h("calcite-list-item",{label:t+" ("+e.length+")",onclick:()=>{this.viewModel.queryFeaturesById(e).then((s=>{if(null!==s){const i=this._appendAttributes(e,s,"objectId");this.switchToIndividualRecords(i,t+" ("+e.length+")",!0)}else this.switchToIndividualRecords(e,t+" ("+e.length+")",!0)}))}},h("calcite-icon",{slot:"content-end",icon:"chevron-right",scale:"s"}))}renderResultRowIndividual(e){const{messages:t}=this;let s="",i=null;for(let r=0;r<e.details.fields.length;r++)e.details.fields[r].name===this._resultDisplayField&&(i=e.details.fields[r]);if("date"===i.type){s=new Date(e.details.attributes[this._resultDisplayField]).toDateString()}else if(null!==i.domain){const t=i.domain.codedValues;let r="";for(let s=0;s<t.length;s++)t[s].code===e.details.attributes[this._resultDisplayField]&&(r=t[s].name);s=r}else s="assetgroup"===this._resultDisplayField.toLocaleLowerCase()?this._getAssetGroupName(e):"assettype"===this._resultDisplayField.toLocaleLowerCase()?this._getAssetTypeName(e):e.details.attributes[this._resultDisplayField];return s&&""!==s&&null!==s||(s=t.resultsStrings.noValue),h("calcite-list-item",{label:s,onclick:()=>{this.viewModel.zoomToAsset(e.details.geometry)}},h("calcite-icon",{icon:"zoom-to-object","text-label":t.globalStrings.zoomToFeature,scale:"s",slot:"content-end"}))}_mixCustomStrings(){const{messages:e}=this;this.inputSettings.length>0&&this.inputSettings.forEach((t=>{"starting-point"===t.type&&(e.inputsStrings.headerStartingPoint=t.label,e.inputsStrings.startingPointHint=t.description),"barrier"===t.type&&(e.inputsStrings.headerBarrier=t.label,e.inputsStrings.barrierPointHint=t.description)}))}_overrideFlagSymbol(){this.inputSettings.length>0&&this.inputSettings.forEach((e=>{"starting-point"===e.type?this._symbolStartFlag=e.symbol:this._symbolBarrier=e.symbol,this.viewModel.changeFlagSymbol(e.type,e.symbol)}))}_utilityNetworkTraceInitialized(){return this.viewModel.loadUtilityNetwork().then((e=>e?(this.viewModel.selectTracesOnLoad(),this._registerWatchers(),this.viewModel._traces.length<=0&&(this._tracesExists=!1),this.viewModel.flags.length>0?this.view.when().then((()=>{this._watchHandler=s((()=>!this.view.updating),(async()=>{this._warningNoFlag=!1,this._warningNoBarrierAssetFound=!1,this._warningNoStartAssetFound=!1;const e=await this.viewModel.addFlagsOnLoad();this.viewModel.removeFlagsOnLoadWatcher(),e.includes("barrier")&&(this._warningNoBarrierAssetFound=!0),e.includes("starting-point")&&(this._warningNoStartAssetFound=!0),this.disabled=!1,null!==this._watchHandler&&this._watchHandler.remove()}))})):this.view.when().then((()=>{this._watchHandler=s((()=>!this.view.updating),(()=>{this.disabled=!1,null!==this._watchHandler&&this._watchHandler.remove()}),{initial:!0})}))):(this._tracesExists=!1,this.view.when().then((()=>{this._watchHandler=s((()=>!this.view.updating),(()=>{this.disabled=!1,null!==this._watchHandler&&this._watchHandler.remove()}),{initial:!0})}))))).catch((e=>{const{messages:t}=this;this._loadUNError=!1,e.details.raw.extendedCode===T.NOEXTENTION?this._errorMessage=t.alertsStrings.noUserExtension:this._errorMessage=e.message,this.disabled=!1}))}_registerWatchers(){this.own([i((()=>this.selectedTraces),(()=>{this.viewModel.selectTracesOnLoad(),this.scheduleRender()})),i((()=>this.defaultGraphicColor),(()=>{this.viewModel._traceResults.length>0&&this.viewModel._traceResults.forEach((e=>{this.viewModel.changeResultGraphicColor(this.viewModel.defaultGraphicColor,e)})),this.scheduleRender()}))])}_groupResultsByAssetGroup(e){const t=[],s=e.results.elements,i=this._groupBy(s,"networkSourceId");for(const r in i)t.push(this._groupBy(i[r],"assetGroupCode"));return t}_groupResultsByAssetType(e){return this._groupBy(e,"assetTypeCode")}_appendAttributes(e,t,s){const i=[];return e.forEach((e=>{t.forEach((t=>{t.featureSet.features.forEach((r=>{e[s]===r.attributes[s.toLowerCase()]&&(e.details=r,e.details.fields=t.featureSet.fields,i.push(e))}))}))})),i}_getAssetGroupName(e){let t=e.assetGroupCode.toString();const s=e.assetGroupCode,i=this.viewModel.getValidSources().find((t=>t.sourceId===e.networkSourceId));if(i){const e=i.assetGroups.find((e=>e.assetGroupCode===s));e&&(t=e.assetGroupName)}return t}_getAssetTypeName(e){let t=e.assetTypeCode.toString();const s=e.assetGroupCode,i=this.viewModel.getValidSources().find((t=>t.sourceId===e.networkSourceId));if(i){const r=i.assetGroups.find((e=>e.assetGroupCode===s));if(r){const s=r.assetTypes.find((t=>t.assetTypeCode===e.assetTypeCode));s&&(t=s.assetTypeName)}}return t}_compare(e,t){return(s,i)=>{let r=0,o=s.details.attributes[e],l=i.details.attributes[e];return isNaN(o)&&(o=o.toLowerCase()),isNaN(l)&&(l=l.toLowerCase()),"desc"===t?o>l?r=1:o<l&&(r=-1):o<l?r=1:o>l&&(r=-1),r}}_groupBy(e,t){return e.reduce(((e,s)=>((e[s[t]]=e[s[t]]||[]).push(s),e)),{})}_getSymbolIcon(e){return"picture-marker"===e.type?h("img",{src:e.url,width:e.width,height:e.height}):null}};e([o()],S.prototype,"_selectToolActive",void 0),e([o()],S.prototype,"_activeTrace",void 0),e([o()],S.prototype,"_activeSwatch",void 0),e([o()],S.prototype,"_traceHeaderForFlow",void 0),e([o()],S.prototype,"_assetGroupHeader",void 0),e([o()],S.prototype,"_assetTypeHeader",void 0),e([o()],S.prototype,"_traceResultsFunctions",void 0),e([o()],S.prototype,"_traceResultsAssetGroup",void 0),e([o()],S.prototype,"_traceResultsAssetType",void 0),e([o()],S.prototype,"_traceResultsIndividual",void 0),e([o()],S.prototype,"_showTraceResultFunctions",void 0),e([o()],S.prototype,"_showTraceResultAssetGroup",void 0),e([o()],S.prototype,"_showTraceResultAssetType",void 0),e([o()],S.prototype,"_showIndividualRecords",void 0),e([o()],S.prototype,"_activeTab",void 0),e([o()],S.prototype,"_alertRemoveModal",void 0),e([o()],S.prototype,"_warningNoFlag",void 0),e([o()],S.prototype,"_warningNoTraceSelected",void 0),e([o()],S.prototype,"_confirmReset",void 0),e([o()],S.prototype,"_swatchNode",void 0),e([o()],S.prototype,"_errorMessage",void 0),e([r("viewModel.defaultGraphicColor")],S.prototype,"defaultGraphicColor",void 0),e([o()],S.prototype,"disabled",void 0),e([r("viewModel.flags")],S.prototype,"flags",void 0),e([r("viewModel.gdbVersion")],S.prototype,"gdbVersion",void 0),e([r("viewModel.goToOverride")],S.prototype,"goToOverride",void 0),e([o()],S.prototype,"iconClass",void 0),e([o()],S.prototype,"inputSettings",void 0),e([o({aliasOf:{source:"messages.widgetLabel",overridable:!0}})],S.prototype,"label",void 0),e([o(),c("esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace")],S.prototype,"messages",void 0),e([o(),c("esri/t9n/common")],S.prototype,"messagesCommon",void 0),e([r("viewModel.selectedTraces")],S.prototype,"selectedTraces",void 0),e([r("viewModel.selectOnComplete")],S.prototype,"selectOnComplete",void 0),e([r("viewModel.showGraphicsOnComplete")],S.prototype,"showGraphicsOnComplete",void 0),e([r("viewModel.showSelectionAttributes")],S.prototype,"showSelectionAttributes",void 0),e([r("viewModel.view")],S.prototype,"view",void 0),e([d(["add-flag","add-flag-complete","add-flag-error","select-features","clear-selection"]),o({type:u})],S.prototype,"viewModel",void 0),S=e([l(w)],S);const R=S;export{R as default};
|