// All material copyright ESRI, All Rights Reserved, unless otherwise specified. // See https://js.arcgis.com/4.7/esri/copyright.txt for details. //>>built define("require exports ../core/tsSupport/declareExtendsHelper ../core/tsSupport/decorateHelper ../core/tsSupport/assignHelper dojo/i18n!../nls/common dojo/i18n!./Directions/nls/Directions ../moment ../core/Collection ../core/Handles ../core/lang ../core/on ../core/watchUtils ../core/accessorSupport/decorators ./Search ./Widget ./Directions/DirectionsViewModel ./Directions/support/CostSummary ./Directions/support/DatePicker ./Directions/support/directionsUtils ./Directions/support/maneuverUtils ./Directions/support/RouteSections ./Directions/support/TimePicker ./support/widget".split(" "), function(A,O,B,f,C,t,k,x,D,E,v,n,m,l,F,G,y,H,I,p,J,K,L,c){var M=[{},{}],N=A.toUrl("../themes/base/images/maneuvers/");return function(z){function b(a){a=z.call(this)||this;a._autoStopRemovalDelay=100;a._costSummary=new H;a._departureTime="now";a._datePicker=new I;a._handles=new E;a._newPlaceholderStop=null;a._routeSections=new K;a._stops=new D(M);a._stopsToSearches=new Map;a._timePicker=new L;a.iconClass="esri-icon-directions";a.label=k.widgetLabel;a.maxStops=null;a.routeServiceUrl=null;a.routeSymbol= null;a.searchProperties=null;a.stopSymbols=null;a.view=null;a.viewModel=new y;return a}B(b,z);b.prototype.postInitialize=function(){var a=this;this.own([m.init(this,"viewModel.lastRoute",function(){a._routeSections.routePath=a.get("viewModel.directionLines");a._activeManeuver=null;a._focusedManeuver=null;a.scheduleRender()}),m.init(this,"viewModel.selectedTravelMode, viewModel.departureTime",function(){1=this.maxStops,h=k.addStop,d=2<=g.length&&d&&!w?c.tsx("div",{"aria-label":h,bind:this,class:"esri-directions__add-stop",key:"esri-directions__add-stop",onfocus:this._handleAddStopFocus,tabIndex:0},c.tsx("span",{"aria-hidden":"true",class:c.join("esri-icon-plus","esri-directions__stop-icon","esri-directions__stop-icon--interactive")}),c.tsx("div",{"aria-hidden":"true",class:"esri-directions__add-stop-text"}, h)):null;return c.tsx("div",null,c.tsx("ol",{class:"esri-directions__stops",role:"group"},b),d)};b.prototype._handleStopIconClick=function(a){(a=this._stops.getItemAt(a.currentTarget["data-stop-index"]))&&a.result&&this._centerAtStop(a)};b.prototype._centerAtStop=function(a){this.viewModel.centerAt(a.result.feature)};b.prototype._handleStopFieldCreation=function(a){var b=this._newPlaceholderStop;b&&(a=this._stops.getItemAt(a["data-stop-index"]),b===a&&this._acquireSearch(a).focus(),this._newPlaceholderStop= null)};b.prototype._handleStopInputBlur=function(a,b){var c=this;this._handles.remove("awaiting-view-click-stop");this.view.cursor=this._previousCursor;a.selectedResult&&b.result&&a.selectedResult===b.result||("none"!==a.activeMenu||!a.searchTerm||a.selectedResult===b.result&&(a.selectedResult||b.result)?a.searchTerm||(this._viewClickHandle.resume(),clearTimeout(this._autoStopRemovalTimeoutId),this._autoStopRemovalTimeoutId=setTimeout(function(){c.destroyed||(c._pauseViewClickHandles(),"searching"!== a.state&&(c._removeStop(b),b.result&&(b.result=null,c._processStops()),c.scheduleRender()))},this._autoStopRemovalDelay)):a.search())};b.prototype._handleStopInputFocus=function(a,b){if(!this._handles.has("awaiting-view-click-stop")){var c=this.view,g=this.view.cursor;this._previousCursor=g;this._handles.add(m.init(a,"searchTerm",function(a){c.cursor=0===a.length?"copy":g}),"awaiting-view-click-stop");this._activeStop=b}};b.prototype._prepViewClick=function(){var a=this,b=this.get("viewModel.view"), c=n.pausable(b,"click",this._handleViewClick.bind(this)),d=n.pausable(b.surface,"click",function(){clearTimeout(a._autoStopRemovalTimeoutId);d.pause()});return{remove:function(){d.remove();c.remove()},pause:function(){d.pause();c.pause()},resume:function(){d.resume();c.resume()}}};b.prototype._handleViewClick=function(a){var b=this,c=this._stopsToSearches.get(this._activeStop);c&&!c.searchTerm&&(c.search(a.mapPoint).then(function(a){a=a.results[0].results[0];var g=b._activeStop;g.result=a;g.result.feature.attributes.Name= a.name;c.searchTerm=a.name;b._processStops();b.scheduleRender()}),this.scheduleRender());this._pauseViewClickHandles();clearTimeout(this._autoStopRemovalTimeoutId)};b.prototype._pauseViewClickHandles=function(){this._viewClickHandle.pause()};b.prototype._handleAddStopFocus=function(a){this._addNewPlaceholder()};b.prototype._addNewPlaceholder=function(){if(!this._newPlaceholderStop){var a={};this._stops.add(a);this._newPlaceholderStop=a}};b.prototype._handleReverseStops=function(){this._reverseStops()}; b.prototype._reverseStops=function(){this._stops.reverse();this._processStops()};b.prototype._handleRemoveStop=function(a){this._removeStop(this._stops.getItemAt(a.currentTarget["data-stop-index"]));this._processStops()};b.prototype._removeStop=function(a){2>=this._stops.length||(this._disposeSearch(a),this._stops.remove(a))};b.prototype._getStopFieldGhost=function(){var a=this._ghost;a||(a=document.createElement("div"),a.classList.add("esri-directions__stop-row-ghost","esri-offscreen"),this._ghost= a);return a};b.prototype._handleStopFieldDragStart=function(a){var b=a.dataTransfer;a=a.currentTarget;var c=Number(a["data-stop-index"]);this._draggedStopIndex=c;var d=this._getStopFieldGhost(),c=this._acquireSearch(this._stops.getItemAt(c));d.innerHTML=c.searchTerm||c.activeSource.placeholder;document.body.appendChild(d);c=d.getBoundingClientRect().height;b.effectAllowed="move";b.setDragImage(d,20,c/2);b.setData("text/plain",a["data-stop-index"])};b.prototype._handleStopFieldDragEnd=function(){this._dropTargetStopIndex= this._draggedStopIndex=null;document.body.removeChild(this._getStopFieldGhost())};b.prototype._handleStopFieldDragOver=function(a){var b=Number(a.currentTarget["data-stop-index"]);a.preventDefault();this._dropTargetStopIndex=this._draggedStopIndex===b?null:b};b.prototype._handleStopFieldDrop=function(a){a.stopPropagation();a.preventDefault();var b=Number(a.currentTarget["data-stop-index"]);a=Number(a.dataTransfer.getData("text/plain"));if(a!==b){var c=this._stops;c.reorder(c.getItemAt(a),b);this._processStops()}}; b.prototype._handleDepartureOptionChange=function(){var a=this,b=event.currentTarget,b=b.item(b.selectedIndex);"now"===b.value?(this._departureTime="now",this.viewModel.departureTime="now",this._handles.remove("departure-time-controls")):"depart-by"===b.value&&(this._departureTime="depart-by",this._handles.add([m.init(this._datePicker,"value",function(){return a._updateDepartureTime()}),m.init(this._timePicker,"value",function(){return a._updateDepartureTime()})],"departure-time-controls"))};b.prototype._updateDepartureTime= function(){var a=this._datePicker.value,b=this._timePicker.value,a=x({date:a.date(),month:a.month(),year:a.year(),hour:b.hour(),minute:b.minute()});this.viewModel.departureTime=a.toDate()};b.prototype._renderTimeControls=function(){return c.tsx("div",{class:"esri-directions__departure-time-controls",key:"esri-directions__time-controls",role:"group"},this._datePicker.render(),this._timePicker.render())};b.prototype._renderSectionSplitter=function(){return c.tsx("div",{class:"esri-directions__section-splitter"})}; b.prototype._renderDisclaimer=function(){var a=v.substitute({esriTerms:'\x3ca href\x3d"http://www.esri.com/legal/software-license" target\x3d"_blank"\x3e'+k.esriTerms+"\x3c/a\x3e"},k.disclaimer);return c.tsx("div",{class:"esri-directions__disclaimer",innerHTML:a,key:"esri-directions__disclaimer"})};b.prototype._renderDirectionsContainer=function(){return c.tsx("div",{class:c.join("esri-directions__directions-section","esri-directions__section"),key:"esri-directions__container"},this._renderDirectionsContainerContent())}; b.prototype._renderLoader=function(){return c.tsx("div",{class:"esri-directions__loader",key:"loader"})};b.prototype._renderDirectionsContainerContent=function(){var a=this.viewModel,b=a.lastRoute,a=a.state,e="routing"===a;return"error"===a?this._renderMessage(k.serviceError,"esri-directions__message"):e?this._renderLoader():b?c.tsx("div",{class:"esri-directions__summary",key:"esri-directions__summary",role:"group"},this._renderCosts(),this._renderManeuverSections()):c.tsx("div",{key:"esri-directions__placeholder", class:"esri-widget__content--empty"},c.tsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 256 256"},c.tsx("path",{fill:"currentcolor",d:"M192 36c-15.477 0-24 6.034-24 16.99v45.822l24 24 24-24v-45.82C216 42.033 207.477 36 192 36zm20 61.155l-20 20-20-20V52.99c0-8.62 6.73-12.99 20-12.99s20 4.37 20 12.99zM192 52a12 12 0 1 0 12 12 12.013 12.013 0 0 0-12-12zm0 20a8 8 0 1 1 8-8 8.008 8.008 0 0 1-8 8zM92 140.99C92 130.035 83.477 124 68 124s-24 6.034-24 16.99v45.822l24 24 24-24zm-4 44.165l-20 20-20-20V140.99c0-8.62 6.73-12.99 20-12.99s20 4.37 20 12.99zM68 140a12 12 0 1 0 12 12 12.013 12.013 0 0 0-12-12zm0 20a8 8 0 1 1 8-8 8.008 8.008 0 0 1-8 8zm84-44h16v4h-16zm-24 80h4v12h-12v-4h8zm0-28h4v16h-4zm0-52h12v4h-8v8h-4zm0 24h4v16h-4zm-36 64h16v4H92z"})), c.tsx("h4",{class:"esri-directions__message"},k.directionsPlaceholder))};b.prototype._renderMessage=function(a,b){return c.tsx("h3",{class:"esri-directions__message",key:b},a)};b.prototype._renderManeuverSections=function(){var a=this,b=this._routeSections.sections;return c.tsx("div",{class:"esri-directions__maneuvers",role:"group"},b.map(function(e,d){var g=e.open,h;0