import a from "./index-extractNationalNumberFromPossiblyIncompleteNumber.js";
import i from "./index-matchesEntirely.js";
import u from "./index-checkNumberLength.js";
function m(r, e) {
  var t = a(r, e), o = t.carrierCode, n = t.nationalNumber;
  if (n !== r) {
    if (!l(r, n, e))
      return {
        nationalNumber: r
      };
    if (e.possibleLengths() && !N(n, e))
      return {
        nationalNumber: r
      };
  }
  return {
    nationalNumber: n,
    carrierCode: o
  };
}
function l(r, e, t) {
  return !(i(r, t.nationalNumberPattern()) && !i(e, t.nationalNumberPattern()));
}
function N(r, e) {
  switch (u(r, e)) {
    case "TOO_SHORT":
    case "INVALID_LENGTH":
      return !1;
    default:
      return !0;
  }
}
export {
  m as default
};
