import v from "../../../@babel/runtime/helpers/esm/objectSpread2.mjs";
import * as t from "react";
const b = function(o, r) {
  var n = t.useRef({
    values: /* @__PURE__ */ new Map(),
    options: /* @__PURE__ */ new Map()
  }), p = t.useMemo(function() {
    var a = n.current, i = a.values, d = a.options, c = o.map(function(e) {
      if (e.label === void 0) {
        var u;
        return v(v({}, e), {}, {
          label: (u = i.get(e.value)) === null || u === void 0 ? void 0 : u.label
        });
      }
      return e;
    }), l = /* @__PURE__ */ new Map(), f = /* @__PURE__ */ new Map();
    return c.forEach(function(e) {
      l.set(e.value, e), f.set(e.value, r.get(e.value) || d.get(e.value));
    }), n.current.values = l, n.current.options = f, c;
  }, [o, r]), s = t.useCallback(function(a) {
    return r.get(a) || n.current.options.get(a);
  }, [r]);
  return [p, s];
};
export {
  b as default
};
