import s, { isPhoneContextValid as x, PLUS_SIGN as F, RFC3966_PREFIX_ as a, RFC3966_PHONE_CONTEXT_ as d, RFC3966_ISDN_SUBADDRESS_ as m } from "./index-extractPhoneContext.js";
import v from "./index-ParseError.js";
function S(r, _) {
  var f = _.extractFormattedPhoneNumber, e = s(r);
  if (!x(e))
    throw new v("NOT_A_NUMBER");
  var t;
  if (e === null)
    t = f(r) || "";
  else {
    t = "", e.charAt(0) === F && (t += e);
    var n = r.indexOf(a), o;
    n >= 0 ? o = n + a.length : o = 0;
    var h = r.indexOf(d);
    t += r.substring(o, h);
  }
  var i = t.indexOf(m);
  if (i > 0 && (t = t.substring(0, i)), t !== "")
    return t;
}
export {
  S as default
};
