/* COPYRIGHT Esri - https://js.arcgis.com/5.0.18/LICENSE.txt */
import{createLength as t,toUnit as r}from"../../../core/quantity.js";import{formatDecimal as e}from"../../../core/unitFormatUtils.js";import{formatNumber as a}from"../../../intl/number.js";const n=new Map([["arrive","route-to"],["bear-left","bear-left"],["bear-right","bear-right"],["boundary-crossing","blank"],["central-fork","fork-middle"],["clockwise-roundabout","round-about-right"],["counter-clockwise-roundabout","round-about"],["depart","route-from"],["door","walk-through-door"],["down-elevator","elevator-down"],["down-escalator","escalator-down"],["down-stairs","stairs-down"],["elevator","elevator"],["escalator","escalator"],["general-event","information"],["header","blank"],["landmark","map-pin"],["lane","blank"],["left-fork","fork-left"],["left-handed-u-turn","u-turn"],["left-ramp","ramp-left"],["left-turn","left"],["left-turn-and-immediate-left-turn","left-left"],["left-turn-and-immediate-right-turn","left-right"],["off-ferry","disembark"],["on-ferry","embark"],["pedestrian-ramp","take-pedestrian-ramp"],["restriction-violation","exclamation-mark-triangle"],["right-fork","fork-right"],["right-handed-u-turn","u-turn-right"],["right-ramp","ramp-right"],["right-turn","right"],["right-turn-and-immediate-left-turn","right-left"],["right-turn-and-immediate-right-turn","right-right"],["roundabout","round-about"],["scaled-cost-barrier-event","blank"],["sharp-left","sharp-left"],["sharp-right","sharp-right"],["stairs","stairs"],["straight","straight"],["time-zone-change","clock"],["traffic-event","exclamation-mark-triangle"],["u-turn","u-turn"],["up-elevator","elevator-up"],["up-escalator","escalator-up"],["up-stairs","stairs-up"]]),i={NOW:"now",DEPART_AT:"depart-at",UNSPECIFIED:"unspecified"};function u(t,r){return a(t,{style:"unit",unit:r,unitDisplay:"short"})}function o(a,n,i){if(0===n)return"";let u,o,l=0;const s=t(n,"meters");switch(i){case"metric":s.value<.01?({value:u,unit:o}=r(s,"millimeters")):s.value<1?({value:u,unit:o}=r(s,"centimeters")):s.value<1e3?({value:u,unit:o}=r(s,"meters")):s.value<1e5?(({value:u,unit:o}=r(s,"kilometers")),l=1):({value:u,unit:o}=r(s,"kilometers"));break;case"imperial":s.value<.254?({value:u,unit:o}=r(s,"inches")):s.value<160.9344?({value:u,unit:o}=r(s,"feet")):s.value<160934.4?(({value:u,unit:o}=r(s,"miles")),l=1):({value:u,unit:o}=r(s,"miles"));break;default:({value:u,unit:o}=r(s,i)),l=2}return e(a,u,o,l)}function l(t){if(0===t)return"";if(t<1){return u(Math.floor(60*t),"second")}if(t<60){return u(Math.floor(t),"minute")}const r=Math.floor(t/60);if(t<1440){const e=Math.floor(t%60);return 0===e?`${u(r,"hour")}`:`${u(r,"hour")} ${u(e,"minute")}`}return u(r,"hour")}function s(t){return null!=t&&n.has(t)?n.get(t):"blank"}export{i as DepartureTimeOption,o as formatDistance,l as formatDuration,s as getIconName};
