/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
function m({
  supported: e,
  disabled: s,
  ready: i,
  operationState: t,
  valid: r
}) {
  return e ? s || !i ? "disabled" : t === "active" ? "measuring" : r ? "measured" : "ready" : "unsupported";
}
function l(e, s) {
  switch (e) {
    case "unsupported":
    case "measured":
    case "ready":
      return e;
    case "disabled":
      return "ready";
    case "measuring":
      return s ? "measured" : "measuring";
  }
}
const a = ["metric", "imperial"], n = [
  "inches",
  "feet",
  "yards",
  "miles",
  "nautical-miles",
  "us-feet",
  "millimeters",
  "centimeters",
  "decimeters",
  "meters",
  "kilometers"
], u = [
  "square-inches",
  "square-feet",
  "square-yards",
  "square-miles",
  "square-nautical-miles",
  "square-us-feet",
  "square-millimeters",
  "square-centimeters",
  "square-decimeters",
  "square-meters",
  "square-kilometers",
  "acres",
  "ares",
  "hectares"
], c = [
  "liters",
  "megaliters",
  "gigaliters",
  "cubic-millimeters",
  "cubic-centimeters",
  "cubic-decimeters",
  "cubic-meters",
  "cubic-kilometers",
  "cubic-inches",
  "cubic-us-feet",
  "cubic-feet",
  "cubic-yards",
  "cubic-miles"
], o = [...a, ...n], d = [...a, ...u], f = [...a, ...c];
function b(e, s = !0) {
  return s ? e == null ? { state: "unavailable" } : { state: "available", value: e } : { state: "invalid" };
}
function g(e, s) {
  switch (s.type) {
    case "length":
      return e.formatLength(s);
    case "area":
      return e.formatArea(s);
    case "volume":
      return e.formatVolume(s);
    default:
      return "";
  }
}
function h(e) {
  return e === "imperial" || e === "metric";
}
function p(e, s, i = s) {
  const t = e?.filter((r) => s.includes(r));
  return t && t.length > 0 ? t.slice() : i.slice();
}
function q(e, s, i, t) {
  const r = e ?? s ?? t ?? void 0;
  return r && i.includes(r) ? r : i[0];
}
export {
  l as a,
  b,
  q as c,
  o as d,
  f as e,
  g as f,
  m as g,
  h as i,
  n as l,
  d as m,
  p as r
};
