import c, { getCountryCallingCode as m } from "./index-metadata.js";
import u from "./index-matchesEntirely.js";
import f from "./index-extractNationalNumber.js";
import a from "./index-checkNumberLength.js";
function x(n, i, e, r) {
  var o = i ? m(i, r) : e;
  if (n.indexOf(o) === 0) {
    r = new c(r), r.selectNumberingPlan(i, e);
    var t = n.slice(o.length), C = f(t, r), g = C.nationalNumber, N = f(n, r), l = N.nationalNumber;
    if (!u(l, r.nationalNumberPattern()) && u(g, r.nationalNumberPattern()) || a(l, r) === "TOO_LONG")
      return {
        countryCallingCode: o,
        number: t
      };
  }
  return {
    number: n
  };
}
export {
  x as default
};
