namefully 1.1.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (156) hide show
  1. package/dist/example/index.js +2734 -0
  2. package/dist/lib/config.d.ts +121 -0
  3. package/dist/lib/config.js +189 -0
  4. package/dist/lib/config.js.map +1 -0
  5. package/dist/lib/constants.d.ts +4 -0
  6. package/dist/lib/constants.js +31 -0
  7. package/dist/lib/constants.js.map +1 -0
  8. package/dist/lib/error.d.ts +172 -0
  9. package/dist/lib/error.js +210 -0
  10. package/dist/lib/error.js.map +1 -0
  11. package/dist/lib/example/example.d.ts +1 -0
  12. package/dist/lib/full-name.d.ts +71 -0
  13. package/dist/lib/full-name.js +147 -0
  14. package/dist/lib/full-name.js.map +1 -0
  15. package/dist/lib/index.d.ts +16 -6
  16. package/dist/lib/index.js +29 -8
  17. package/dist/lib/index.js.map +1 -1
  18. package/dist/lib/name.d.ts +177 -0
  19. package/dist/lib/name.js +322 -0
  20. package/dist/lib/name.js.map +1 -0
  21. package/dist/lib/namefully.d.ts +285 -208
  22. package/dist/lib/namefully.js +576 -576
  23. package/dist/lib/namefully.js.map +1 -1
  24. package/dist/lib/parser.d.ts +46 -0
  25. package/dist/lib/parser.js +173 -0
  26. package/dist/lib/parser.js.map +1 -0
  27. package/dist/lib/src/config.d.ts +121 -0
  28. package/dist/lib/src/constants.d.ts +4 -0
  29. package/dist/lib/src/error.d.ts +172 -0
  30. package/dist/lib/src/full-name.d.ts +71 -0
  31. package/dist/lib/src/index.d.ts +20 -0
  32. package/dist/lib/src/name.d.ts +177 -0
  33. package/dist/lib/src/namefully.d.ts +379 -0
  34. package/dist/lib/src/parser.d.ts +46 -0
  35. package/dist/lib/src/types.d.ts +127 -0
  36. package/dist/lib/src/utils.d.ts +63 -0
  37. package/dist/lib/src/validator.d.ts +66 -0
  38. package/dist/lib/types.d.ts +127 -0
  39. package/dist/lib/types.js +181 -0
  40. package/dist/lib/types.js.map +1 -0
  41. package/dist/lib/utils.d.ts +63 -0
  42. package/dist/lib/utils.js +138 -0
  43. package/dist/lib/utils.js.map +1 -0
  44. package/dist/lib/validator.d.ts +66 -0
  45. package/dist/lib/validator.js +332 -0
  46. package/dist/lib/validator.js.map +1 -0
  47. package/dist/umd/namefully.js +2118 -2700
  48. package/dist/umd/namefully.js.map +1 -1
  49. package/dist/umd/namefully.min.js +1 -1
  50. package/dist/umd/namefully.min.js.LICENSE.txt +1 -18
  51. package/dist/umd/namefully.min.js.map +1 -1
  52. package/package.json +50 -54
  53. package/readme.md +132 -162
  54. package/changelog.md +0 -134
  55. package/dist/lib/core/constants.d.ts +0 -48
  56. package/dist/lib/core/constants.js +0 -101
  57. package/dist/lib/core/constants.js.map +0 -1
  58. package/dist/lib/core/core.d.ts +0 -17
  59. package/dist/lib/core/core.js +0 -24
  60. package/dist/lib/core/core.js.map +0 -1
  61. package/dist/lib/core/index.d.ts +0 -9
  62. package/dist/lib/core/index.js +0 -13
  63. package/dist/lib/core/index.js.map +0 -1
  64. package/dist/lib/core/parsers/array-name.parser.d.ts +0 -41
  65. package/dist/lib/core/parsers/array-name.parser.js +0 -86
  66. package/dist/lib/core/parsers/array-name.parser.js.map +0 -1
  67. package/dist/lib/core/parsers/array-string.parser.d.ts +0 -47
  68. package/dist/lib/core/parsers/array-string.parser.js +0 -95
  69. package/dist/lib/core/parsers/array-string.parser.js.map +0 -1
  70. package/dist/lib/core/parsers/index.d.ts +0 -11
  71. package/dist/lib/core/parsers/index.js +0 -11
  72. package/dist/lib/core/parsers/index.js.map +0 -1
  73. package/dist/lib/core/parsers/nama.parser.d.ts +0 -33
  74. package/dist/lib/core/parsers/nama.parser.js +0 -74
  75. package/dist/lib/core/parsers/nama.parser.js.map +0 -1
  76. package/dist/lib/core/parsers/parser.d.ts +0 -28
  77. package/dist/lib/core/parsers/parser.js +0 -3
  78. package/dist/lib/core/parsers/parser.js.map +0 -1
  79. package/dist/lib/core/parsers/string.parser.d.ts +0 -60
  80. package/dist/lib/core/parsers/string.parser.js +0 -62
  81. package/dist/lib/core/parsers/string.parser.js.map +0 -1
  82. package/dist/lib/core/utils.d.ts +0 -52
  83. package/dist/lib/core/utils.js +0 -178
  84. package/dist/lib/core/utils.js.map +0 -1
  85. package/dist/lib/models/enums.d.ts +0 -106
  86. package/dist/lib/models/enums.js +0 -114
  87. package/dist/lib/models/enums.js.map +0 -1
  88. package/dist/lib/models/firstname.d.ts +0 -77
  89. package/dist/lib/models/firstname.js +0 -131
  90. package/dist/lib/models/firstname.js.map +0 -1
  91. package/dist/lib/models/fullname.d.ts +0 -73
  92. package/dist/lib/models/fullname.js +0 -99
  93. package/dist/lib/models/fullname.js.map +0 -1
  94. package/dist/lib/models/index.d.ts +0 -13
  95. package/dist/lib/models/index.js +0 -16
  96. package/dist/lib/models/index.js.map +0 -1
  97. package/dist/lib/models/lastname.d.ts +0 -80
  98. package/dist/lib/models/lastname.js +0 -157
  99. package/dist/lib/models/lastname.js.map +0 -1
  100. package/dist/lib/models/misc.d.ts +0 -108
  101. package/dist/lib/models/misc.js +0 -3
  102. package/dist/lib/models/misc.js.map +0 -1
  103. package/dist/lib/models/name.d.ts +0 -76
  104. package/dist/lib/models/name.js +0 -115
  105. package/dist/lib/models/name.js.map +0 -1
  106. package/dist/lib/models/summary.d.ts +0 -26
  107. package/dist/lib/models/summary.js +0 -61
  108. package/dist/lib/models/summary.js.map +0 -1
  109. package/dist/lib/validators/array-name.validator.d.ts +0 -25
  110. package/dist/lib/validators/array-name.validator.js +0 -75
  111. package/dist/lib/validators/array-name.validator.js.map +0 -1
  112. package/dist/lib/validators/array-string.validator.d.ts +0 -43
  113. package/dist/lib/validators/array-string.validator.js +0 -76
  114. package/dist/lib/validators/array-string.validator.js.map +0 -1
  115. package/dist/lib/validators/common/validation-error.d.ts +0 -19
  116. package/dist/lib/validators/common/validation-error.js +0 -26
  117. package/dist/lib/validators/common/validation-error.js.map +0 -1
  118. package/dist/lib/validators/common/validation-rule.d.ts +0 -72
  119. package/dist/lib/validators/common/validation-rule.js +0 -76
  120. package/dist/lib/validators/common/validation-rule.js.map +0 -1
  121. package/dist/lib/validators/common/validation-type.d.ts +0 -24
  122. package/dist/lib/validators/common/validation-type.js +0 -28
  123. package/dist/lib/validators/common/validation-type.js.map +0 -1
  124. package/dist/lib/validators/firstname.validator.d.ts +0 -20
  125. package/dist/lib/validators/firstname.validator.js +0 -29
  126. package/dist/lib/validators/firstname.validator.js.map +0 -1
  127. package/dist/lib/validators/fullname.validator.d.ts +0 -21
  128. package/dist/lib/validators/fullname.validator.js +0 -38
  129. package/dist/lib/validators/fullname.validator.js.map +0 -1
  130. package/dist/lib/validators/index.d.ts +0 -21
  131. package/dist/lib/validators/index.js +0 -35
  132. package/dist/lib/validators/index.js.map +0 -1
  133. package/dist/lib/validators/lastname.validator.d.ts +0 -20
  134. package/dist/lib/validators/lastname.validator.js +0 -29
  135. package/dist/lib/validators/lastname.validator.js.map +0 -1
  136. package/dist/lib/validators/middlename.validator.d.ts +0 -20
  137. package/dist/lib/validators/middlename.validator.js +0 -38
  138. package/dist/lib/validators/middlename.validator.js.map +0 -1
  139. package/dist/lib/validators/nama.validator.d.ts +0 -21
  140. package/dist/lib/validators/nama.validator.js +0 -44
  141. package/dist/lib/validators/nama.validator.js.map +0 -1
  142. package/dist/lib/validators/namon.validator.d.ts +0 -20
  143. package/dist/lib/validators/namon.validator.js +0 -29
  144. package/dist/lib/validators/namon.validator.js.map +0 -1
  145. package/dist/lib/validators/prefix.validator.d.ts +0 -14
  146. package/dist/lib/validators/prefix.validator.js +0 -31
  147. package/dist/lib/validators/prefix.validator.js.map +0 -1
  148. package/dist/lib/validators/string-name.validator.d.ts +0 -20
  149. package/dist/lib/validators/string-name.validator.js +0 -29
  150. package/dist/lib/validators/string-name.validator.js.map +0 -1
  151. package/dist/lib/validators/suffix.validator.d.ts +0 -14
  152. package/dist/lib/validators/suffix.validator.js +0 -31
  153. package/dist/lib/validators/suffix.validator.js.map +0 -1
  154. package/dist/lib/validators/validator.d.ts +0 -13
  155. package/dist/lib/validators/validator.js +0 -9
  156. package/dist/lib/validators/validator.js.map +0 -1
@@ -1,3 +1,3 @@
1
1
  /*! For license information please see namefully.min.js.LICENSE.txt */
2
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("namefully",[],t):"object"==typeof exports?exports.namefully=t():e.namefully=t()}(window,(function(){return function(e){var t={};function r(a){if(t[a])return t[a].exports;var n=t[a]={i:a,l:!1,exports:{}};return e[a].call(n.exports,n,n.exports,r),n.l=!0,n.exports}return r.m=e,r.c=t,r.d=function(e,t,a){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:a})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var a=Object.create(null);if(r.r(a),Object.defineProperty(a,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)r.d(a,n,function(t){return e[t]}.bind(null,n));return a},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=6)}([function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const a=r(3);a.__exportStar(r(9),t),a.__exportStar(r(10),t),a.__exportStar(r(11),t),a.__exportStar(r(12),t),a.__exportStar(r(13),t),a.__exportStar(r(14),t)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const a=r(3);a.__exportStar(r(15),t),a.__exportStar(r(16),t),a.__exportStar(r(17),t);var n=r(18);t.NamonValidator=n.default;var i=r(19);t.PrefixValidator=i.default;var s=r(20);t.SuffixValidator=s.default;var o=r(21);t.FirstnameValidator=o.default;var l=r(22);t.LastnameValidator=l.default;var c=r(23);t.MiddlenameValidator=c.default;var u=r(24);t.FullnameValidator=u.default;var m=r(25);t.NamaValidator=m.default;var f=r(27);t.ArrayNameValidator=f.default;var p=r(28);t.ArrayStringValidator=p.default;var h=r(29);t.StringNameValidator=h.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const a=r(3);a.__exportStar(r(5),t),a.__exportStar(r(33),t),a.__exportStar(r(4),t)},function(e,t,r){"use strict";r.r(t),r.d(t,"__extends",(function(){return n})),r.d(t,"__assign",(function(){return i})),r.d(t,"__rest",(function(){return s})),r.d(t,"__decorate",(function(){return o})),r.d(t,"__param",(function(){return l})),r.d(t,"__metadata",(function(){return c})),r.d(t,"__awaiter",(function(){return u})),r.d(t,"__generator",(function(){return m})),r.d(t,"__exportStar",(function(){return f})),r.d(t,"__values",(function(){return p})),r.d(t,"__read",(function(){return h})),r.d(t,"__spread",(function(){return d})),r.d(t,"__spreadArrays",(function(){return _})),r.d(t,"__await",(function(){return E})),r.d(t,"__asyncGenerator",(function(){return S})),r.d(t,"__asyncDelegator",(function(){return y})),r.d(t,"__asyncValues",(function(){return M})),r.d(t,"__makeTemplateObject",(function(){return w})),r.d(t,"__importStar",(function(){return N})),r.d(t,"__importDefault",(function(){return A})),r.d(t,"__classPrivateFieldGet",(function(){return g})),r.d(t,"__classPrivateFieldSet",(function(){return I}));var a=function(e,t){return(a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)};function n(e,t){function r(){this.constructor=e}a(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}var i=function(){return(i=Object.assign||function(e){for(var t,r=1,a=arguments.length;r<a;r++)for(var n in t=arguments[r])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e}).apply(this,arguments)};function s(e,t){var r={};for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&t.indexOf(a)<0&&(r[a]=e[a]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(a=Object.getOwnPropertySymbols(e);n<a.length;n++)t.indexOf(a[n])<0&&Object.prototype.propertyIsEnumerable.call(e,a[n])&&(r[a[n]]=e[a[n]])}return r}function o(e,t,r,a){var n,i=arguments.length,s=i<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,r):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,a);else for(var o=e.length-1;o>=0;o--)(n=e[o])&&(s=(i<3?n(s):i>3?n(t,r,s):n(t,r))||s);return i>3&&s&&Object.defineProperty(t,r,s),s}function l(e,t){return function(r,a){t(r,a,e)}}function c(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function u(e,t,r,a){return new(r||(r=Promise))((function(n,i){function s(e){try{l(a.next(e))}catch(e){i(e)}}function o(e){try{l(a.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,o)}l((a=a.apply(e,t||[])).next())}))}function m(e,t){var r,a,n,i,s={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return i={next:o(0),throw:o(1),return:o(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function o(i){return function(o){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,a&&(n=2&i[0]?a.return:i[0]?a.throw||((n=a.return)&&n.call(a),0):a.next)&&!(n=n.call(a,i[1])).done)return n;switch(a=0,n&&(i=[2&i[0],n.value]),i[0]){case 0:case 1:n=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,a=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(n=(n=s.trys).length>0&&n[n.length-1])&&(6===i[0]||2===i[0])){s=0;continue}if(3===i[0]&&(!n||i[1]>n[0]&&i[1]<n[3])){s.label=i[1];break}if(6===i[0]&&s.label<n[1]){s.label=n[1],n=i;break}if(n&&s.label<n[2]){s.label=n[2],s.ops.push(i);break}n[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],a=0}finally{r=n=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,o])}}}function f(e,t){for(var r in e)t.hasOwnProperty(r)||(t[r]=e[r])}function p(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],a=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&a>=e.length&&(e=void 0),{value:e&&e[a++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function h(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var a,n,i=r.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(a=i.next()).done;)s.push(a.value)}catch(e){n={error:e}}finally{try{a&&!a.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}return s}function d(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(h(arguments[t]));return e}function _(){for(var e=0,t=0,r=arguments.length;t<r;t++)e+=arguments[t].length;var a=Array(e),n=0;for(t=0;t<r;t++)for(var i=arguments[t],s=0,o=i.length;s<o;s++,n++)a[n]=i[s];return a}function E(e){return this instanceof E?(this.v=e,this):new E(e)}function S(e,t,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var a,n=r.apply(e,t||[]),i=[];return a={},s("next"),s("throw"),s("return"),a[Symbol.asyncIterator]=function(){return this},a;function s(e){n[e]&&(a[e]=function(t){return new Promise((function(r,a){i.push([e,t,r,a])>1||o(e,t)}))})}function o(e,t){try{(r=n[e](t)).value instanceof E?Promise.resolve(r.value.v).then(l,c):u(i[0][2],r)}catch(e){u(i[0][3],e)}var r}function l(e){o("next",e)}function c(e){o("throw",e)}function u(e,t){e(t),i.shift(),i.length&&o(i[0][0],i[0][1])}}function y(e){var t,r;return t={},a("next"),a("throw",(function(e){throw e})),a("return"),t[Symbol.iterator]=function(){return this},t;function a(a,n){t[a]=e[a]?function(t){return(r=!r)?{value:E(e[a](t)),done:"return"===a}:n?n(t):t}:n}}function M(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,r=e[Symbol.asyncIterator];return r?r.call(e):(e=p(e),t={},a("next"),a("throw"),a("return"),t[Symbol.asyncIterator]=function(){return this},t);function a(r){t[r]=e[r]&&function(t){return new Promise((function(a,n){(function(e,t,r,a){Promise.resolve(a).then((function(t){e({value:t,done:r})}),t)})(a,n,(t=e[r](t)).done,t.value)}))}}}function w(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}function N(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}function A(e){return e&&e.__esModule?e:{default:e}}function g(e,t){if(!t.has(e))throw new TypeError("attempted to get private field on non-instance");return t.get(e)}function I(e,t,r){if(!t.has(e))throw new TypeError("attempted to set private field on non-instance");return t.set(e,r),r}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const a=r(0),n=r(26);t.version="1.1.0",t.CONFIG={orderedBy:"firstname",separator:a.Separator.SPACE,titling:"uk",ending:!1,bypass:!1,lastnameFormat:"father"},t.NAME_INDEX={prefix:0,firstname:1,middlename:2,lastname:3,suffix:4},t.FIRST_LAST_NAME_INDEX=2,t.LAST_FIRST_NAME_INDEX=2,t.FIRST_MIDDLE_LAST_NAME_INDEX=3,t.LAST_FIRST_MIDDLE_NAME_INDEX=3,t.PREFIX_FIRST_MIDDLE_LAST_NAME_INDEX=4,t.PREFIX_LAST_FIRST_MIDDLE_NAME_INDEX=4,t.PREFIX_FIRST_MIDDLE_LAST_SUFFIX_NAME_INDEX=5,t.PREFIX_LAST_FIRST_MIDDLE_SUFFIX_NAME_INDEX=5,t.MIN_NUMBER_NAME_PART=2,t.MAX_NUMBER_NAME_PART=5,t.RESTRICTED_CHARS=[a.Separator.SPACE,a.Separator.SINGLE_QUOTE,a.Separator.HYPHEN,a.Separator.PERIOD,a.Separator.COMMA],t.PASSWORD_MAPPER=new Map([["a",new n.CharSet(["a","A","@","4"])],["b",new n.CharSet(["b","B","6","|)","|3","|>"])],["c",new n.CharSet(["c","C","(","<"])],["d",new n.CharSet(["d","D","(|","<|"])],["e",new n.CharSet(["e","E","3","*"])],["f",new n.CharSet(["f","F","7","(-"])],["g",new n.CharSet(["g","G","8","&","**"])],["h",new n.CharSet(["h","H","#","|-|"])],["i",new n.CharSet(["i","I","!","1","|","--"])],["j",new n.CharSet(["j","J",")","1"])],["k",new n.CharSet(["k","K","%","|<"])],["l",new n.CharSet(["l","L","1","!","|_"])],["m",new n.CharSet(["m","M","^^",">>"])],["n",new n.CharSet(["n","N","!=","++"])],["o",new n.CharSet(["o","O","0",".","*"])],["p",new n.CharSet(["p","P","|3","|)","|>"])],["q",new n.CharSet(["q","Q","&","9","<|"])],["r",new n.CharSet(["r","R","7","&"])],["s",new n.CharSet(["s","S","5","$"])],["t",new n.CharSet(["t","T","7","["])],["u",new n.CharSet(["u","U","|_|","v"])],["v",new n.CharSet(["v","V",">","<","^"])],["w",new n.CharSet(["w","W","[|]","vv"])],["x",new n.CharSet(["x","X","%","#"])],["z",new n.CharSet(["z","Z","2","!="])],["$",new n.CharSet(["!","@","#","$","%","^","&","*","(",")","-","+","[","_","=","{","}",":",";",",",".","<",">","|","~","]","0","1","2","3","4","5","6","7","8","9"])]])},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var a=r(8);t.ArrayNameParser=a.default;var n=r(30);t.ArrayStringParser=n.default;var i=r(31);t.NamaParser=i.default;var s=r(32);t.StringParser=s.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const a=r(3);a.__exportStar(r(7),t),a.__exportStar(r(2),t),a.__exportStar(r(0),t),a.__exportStar(r(1),t)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const a=r(2),n=r(0),i=r(1);class s{constructor(e,t){this.configure(t),this.build(e)}getFullname(e){e=this.parseNameOrder(e);const{titling:t,ending:r}=this.config,a="us"===t?n.Separator.PERIOD:n.Separator.EMPTY,i=r?",":n.Separator.EMPTY,s=[];return this.fullname.prefix&&s.push(n.Separator.EMPTY.concat(this.fullname.prefix,a)),"firstname"===e?(s.push(this.getFirstname()),s.push(...this.getMiddlenames()),s.push(n.Separator.EMPTY.concat(this.getLastname(),i))):(s.push(this.getLastname()),s.push(this.getFirstname()),s.push(this.getMiddlenames().join(n.Separator.SPACE).concat(i))),this.fullname.suffix&&s.push(this.fullname.suffix),s.join(n.Separator.SPACE)}getBirthname(e){const t=[];return"firstname"===(e=this.parseNameOrder(e))?(t.push(this.getFirstname()),t.push(...this.getMiddlenames()),t.push(this.getLastname())):(t.push(this.getLastname()),t.push(this.getFirstname()),t.push(...this.getMiddlenames())),t.join(n.Separator.SPACE)}getFirstname(e=!0){return this.fullname.firstname.tostring(e)}getLastname(e){return this.fullname.lastname.tostring(e)}getMiddlenames(){return this.hasMiddlename()?this.fullname.middlename.map(e=>e.namon):[]}getPrefix(){return this.fullname.prefix?this.fullname.prefix.concat("us"===this.config.titling?n.Separator.PERIOD:n.Separator.EMPTY):n.Separator.EMPTY}getSuffix(){return this.fullname.suffix||n.Separator.EMPTY}getInitials(e,t=!1){e=this.parseNameOrder(e);const r=this.fullname.middlename?this.fullname.middlename.map(e=>e.getInitials()):[];t&&!this.hasMiddlename()&&console.warn("No initials for middle names since none was set.");const a=[];return"firstname"===e?(a.push(...this.fullname.firstname.getInitials()),t&&r.forEach(e=>a.push(...e)),a.push(...this.fullname.lastname.getInitials())):(a.push(...this.fullname.lastname.getInitials()),a.push(...this.fullname.firstname.getInitials()),t&&r.forEach(e=>a.push(...e))),a}describe(e){switch(e=a.allowShortNameType(e)){case"firstname":return this.fullname.firstname.describe();case"lastname":return this.fullname.lastname.describe();case"middlename":return this.hasMiddlename()?new n.Summary(this.fullname.middlename.map(e=>e.namon).join(n.Separator.SPACE)):(console.warn("No Summary for middle names since none was set."),null);default:return this.summary}}shorten(e){e=e||this.config.orderedBy;const{firstname:t,lastname:r}=this.fullname;return"firstname"===e?[t.namon,r.tostring()].join(n.Separator.SPACE):[r.tostring(),t.namon].join(n.Separator.SPACE)}compress(e=20,t="mn",r=!0){if(this.getFullname().length<=e)return this.getFullname();const{firstname:a,lastname:i,middlename:s}=this.fullname,o=this.getMiddlenames().join(n.Separator.SPACE),l=Array.isArray(s)&&s.length>0,c=n.Separator.PERIOD,u=a.getInitials().join(c).concat(c),m=i.getInitials().join(c).concat(c),f=l?s.map(e=>e.getInitials()).join(c).concat(c):n.Separator.EMPTY;let p="";if("firstname"===this.config.orderedBy)switch(t){case"firstname":case"fn":p=l?[u,o,i.tostring()].join(n.Separator.SPACE):[u,i.tostring()].join(n.Separator.SPACE);break;case"lastname":case"ln":p=l?[a.tostring(),o,m].join(n.Separator.SPACE):[a.tostring(),m].join(n.Separator.SPACE);break;case"middlename":case"mn":p=l?[a.tostring(),f,i.tostring()].join(n.Separator.SPACE):[a.tostring(),i.tostring()].join(n.Separator.SPACE);break;case"firstmid":case"fm":p=l?[u,f,i.tostring()].join(n.Separator.SPACE):[u,i.tostring()].join(n.Separator.SPACE);break;case"midlast":case"ml":p=l?[a.tostring(),f,m].join(n.Separator.SPACE):[a.tostring(),m].join(n.Separator.SPACE)}else switch(t){case"firstname":case"fn":p=l?[i.tostring(),u,o].join(n.Separator.SPACE):[i.tostring(),u].join(n.Separator.SPACE);break;case"lastname":case"ln":p=l?[m,a.tostring(),o].join(n.Separator.SPACE):[m,a.tostring()].join(n.Separator.SPACE);break;case"middlename":case"mn":p=l?[i.tostring(),a.tostring(),f].join(n.Separator.SPACE):[i.tostring(),a.tostring()].join(n.Separator.SPACE);break;case"firstmid":case"fm":p=l?[i.tostring(),u,f].join(n.Separator.SPACE):[i.tostring(),u].join(n.Separator.SPACE);break;case"midlast":case"ml":p=l?[m,a.tostring(),f].join(n.Separator.SPACE):[m,a.tostring()].join(n.Separator.SPACE)}return r&&p.length>e&&console.warn(`The compressed name <${p}> still surpasses the set limit ${e}`),p}zip(e="mn"){let t;return"fn"!==e&&"firstname"!==e||(t="firstname"),"mn"!==e&&"middlename"!==e||(t="middlename"),"ln"!==e&&"lastname"!==e||(t="lastname"),"fm"!==e&&"firstmid"!==e||(t="firstmid"),"ml"!==e&&"midlast"!==e||(t="midlast"),this.compress(0,t,!1)}username(){const e=[],{firstname:t,lastname:r}=this.fullname,a=n.Separator.PERIOD,i=t.tostring().toLowerCase(),s=r.father.toLowerCase();return e.push(i+s),e.push(s+i),e.push(i[0]+s),e.push(s[0]+i),e.push(i[0]+a+s),e.push(s[0]+a+i),e.push(i.slice(0,2)+s),e.push(s.slice(0,2)+i),e.push(i.slice(0,2)+a+s),e.push(s.slice(0,2)+a+i),e}format(e="official"){if("short"===e)return this.shorten();if("long"===e)return this.getBirthname();"official"===e&&(e="o");const t=[],r=[".",","," ","-","_","b","B","f","F","l","L","m","M","n","N","o","O","p","P","s","S"];for(const a of e){if(-1===r.indexOf(a))throw new Error(`<${a}> is an invalid character for the formatting.`);t.push(this.map(a))}return t.join(n.Separator.EMPTY).trim()}size(){return new n.Summary(this.getBirthname(),[...a.RESTRICTED_CHARS]).count}ascii(e={}){const{exceptions:t}=e,r=a.allowShortNameType(e.nameType),{firstname:n,lastname:i,middlename:s}=this.fullname;switch(r){case"firstname":return n.ascii(t);case"lastname":return i.ascii(t);case"middlename":return this.hasMiddlename()||console.warn("No ASCII conversion for middle names since none was set."),s.map(e=>e.ascii(t)).reduce((e,t)=>e.concat(t),[]);default:const e=n.ascii(t),r=s.map(e=>e.ascii(t)).reduce((e,t)=>e.concat(t),[]),a=i.ascii(t);return"firstname"===this.config.orderedBy?e.concat(r,a):a.concat(e,r)}}to(e){const t=this.getBirthname(),r=t.replace(/[' -]/g,n.Separator.SPACE).split(n.Separator.SPACE);switch(e){case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();case"camel":case"pascal":const i=r.map(e=>a.capitalize(e)).join(n.Separator.EMPTY);return"camel"===e?a.decapitalize(i):i;case"snake":return r.map(e=>e.toLowerCase()).join(n.Separator.UNDERSCORE);case"hyphen":return r.map(e=>e.toLowerCase()).join(n.Separator.HYPHEN);case"dot":return r.map(e=>e.toLowerCase()).join(n.Separator.PERIOD);case"toggle":return a.toggleCase(t);default:return n.Separator.EMPTY}}passwd(e){switch(e=a.allowShortNameType(e)){case"firstname":return this.fullname.firstname.passwd();case"lastname":return this.fullname.lastname.passwd();case"middlename":return this.hasMiddlename()||console.warn("No password for middle names since none was set."),this.fullname.middlename.map(e=>e.passwd()).join(n.Separator.EMPTY);default:return a.generatePassword(this.getBirthname())}}hasMiddlename(){return Array.isArray(this.fullname.middlename)&&this.fullname.middlename.length>0}configure(e){this.config=Object.assign(Object.assign({},a.CONFIG),e),this.config.orderedBy=a.allowShortNameOrder(this.config.orderedBy)}initialize(e){const{orderedBy:t,separator:r,bypass:a,lastnameFormat:n}=this.config;this.fullname=e.parse({orderedBy:t,separator:r,bypass:a,lastnameFormat:n})}parseNameOrder(e){return e=e||this.config.orderedBy,a.allowShortNameOrder(e)}map(e){const{firstname:t,lastname:r,middlename:a,prefix:i,suffix:s}=this.fullname;switch(e){case".":return n.Separator.PERIOD;case",":return n.Separator.COMMA;case" ":return n.Separator.SPACE;case"-":return n.Separator.HYPHEN;case"_":return n.Separator.UNDERSCORE;case"b":return this.getBirthname();case"B":return this.getBirthname().toUpperCase();case"f":return t.tostring();case"F":return t.tostring().toUpperCase();case"l":return r.tostring();case"L":return r.tostring().toUpperCase();case"m":return this.hasMiddlename()?this.fullname.middlename.map(e=>e.namon).join(n.Separator.SPACE):(console.warn("No formatting for middle names since none was set."),n.Separator.EMPTY);case"M":return this.hasMiddlename()?a.map(e=>e.namon.toUpperCase()).join(n.Separator.SPACE):(console.warn("No formatting for middle names since none was set."),n.Separator.EMPTY);case"o":case"O":const{titling:o,ending:l}=this.config,c="us"===o?n.Separator.PERIOD:n.Separator.EMPTY,u=l?",":n.Separator.EMPTY,m=[];i&&m.push(i.concat(c)),m.push(r.tostring().concat(n.Separator.COMMA).toUpperCase()),this.hasMiddlename()?(m.push(t.tostring()),m.push(a.map(e=>e.namon).join(n.Separator.SPACE).concat(u))):m.push(t.tostring().concat(u)),m.push(s||n.Separator.EMPTY);const f=m.join(n.Separator.SPACE).trim();return"o"===e?f:f.toUpperCase();case"p":return i||n.Separator.EMPTY;case"P":return i?i.toUpperCase():n.Separator.EMPTY;case"s":return s||n.Separator.EMPTY;case"S":return s?s.toUpperCase():n.Separator.EMPTY}}build(e){if(this.config.parser)this.initialize(this.config.parser);else if("string"==typeof e)this.initialize(new a.StringParser(e));else if(Array.isArray(e)&&e.length)if("string"==typeof e[0]){for(const t of e)if("string"!=typeof t)throw new Error("Cannot parse raw data as array of 'string'");this.initialize(new a.ArrayStringParser(e))}else{if(!(e[0]instanceof n.Name))throw new Error("Cannot parse raw data as arrays that are not of 'Name' or string");for(const t of e)if(!(t instanceof n.Name))throw new Error("Cannot parse raw data as array of 'Name'");this.initialize(new a.ArrayNameParser(e))}else{if(!(e instanceof Object))throw new Error("Cannot parse raw data. Review the data type expected.");for(const[t,r]of Object.entries(e)){if(-1===["firstname","lastname","middlename","prefix","suffix"].indexOf(t))throw new Error("Cannot parse raw data as json object that does not contains keys of"+`'${Object.keys(n.Namon)}'`);if("string"!=typeof r&&"object"!=typeof r)throw new Error(`Cannot parse raw data. The key <${t}> should be a 'string|object' type`)}"string"==typeof e.firstname?this.initialize(new a.NamaParser(e)):this.fullname=e}this.config.bypass||(new i.FullnameValidator).validate(this.fullname),this.summary=new n.Summary(this.getFullname())}}t.Namefully=s,s.prototype.full=s.prototype.getFullname,s.prototype.birth=s.prototype.getBirthname,s.prototype.fn=s.prototype.getFirstname,s.prototype.ln=s.prototype.getLastname,s.prototype.mn=s.prototype.getMiddlenames,s.prototype.px=s.prototype.getPrefix,s.prototype.sx=s.prototype.getSuffix,s.prototype.inits=s.prototype.getInitials,s.prototype.stats=s.prototype.describe},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const a=r(0),n=r(1);t.default=class{constructor(e){this.raw=e}parse(e){const{bypass:t,lastnameFormat:r}=e;return t||(new n.ArrayNameValidator).validate(this.raw),this.distribute(r)}distribute(e){const t={firstname:null,lastname:null,middlename:[],prefix:null,suffix:null};return this.raw.forEach(r=>{switch(r.type){case a.Namon.PREFIX:t.prefix=r.namon;break;case a.Namon.FIRST_NAME:r instanceof a.Firstname?t.firstname=new a.Firstname(r.namon,...r.more):t.firstname=new a.Firstname(r.namon);break;case a.Namon.LAST_NAME:r instanceof a.Lastname?t.lastname=new a.Lastname(r.father,r.mother,e):t.lastname=new a.Lastname(r.namon,null,e);break;case a.Namon.MIDDLE_NAME:t.middlename.push(r);break;case a.Namon.SUFFIX:t.suffix=r.namon}}),t}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const a=r(0),n=r(2);class i{constructor(e,t,r){this.namon=e,this.type=t,this.initial=e[0],this.body=e.slice(1),r&&this.capitalize(r)}describe(){return new a.Summary(this.namon)}tostring(){return this.namon}getInitials(){return[this.namon[0]]}capitalize(e="initial"){const t=this.initial.toUpperCase();return this.namon="initial"===e?t.concat(this.body):this.namon.toUpperCase(),this}decapitalize(e="initial"){const t=this.initial.toLowerCase();return this.namon="initial"===e?t.concat(this.body):t.concat(this.body.toLowerCase()),this}normalize(){return this.namon=this.namon[0].toUpperCase().concat(this.namon.slice(1).toLowerCase()),this}reset(){return this.namon=this.initial.concat(this.body),this}ascii(e){return n.convertToAscii(this.namon,e)}passwd(){return n.generatePassword(this.namon)}}t.Name=i,i.prototype.cap=i.prototype.capitalize,i.prototype.decap=i.prototype.decapitalize,i.prototype.norm=i.prototype.normalize,i.prototype.stats=i.prototype.describe,i.prototype.inits=i.prototype.getInitials},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const a=r(0),n=r(2);class i extends a.Name{constructor(e,...t){super(e,a.Namon.FIRST_NAME),this.namon=e,this.more=[],this.more=t}hasMore(){return Array.isArray(this.more)&&this.more.length>0}describe(e=!1){return new a.Summary(this.tostring(e))}tostring(e=!0){return e?this.namon.concat(a.Separator.SPACE,this.more.join(a.Separator.SPACE)).trim():this.namon}getInitials(e=!1){const t=[this.namon[0]];return e&&this.hasMore()&&t.push(...this.more.map(e=>e[0])),t}capitalize(e="initial"){return"initial"===e?(this.namon=this.namon[0].toUpperCase().concat(this.namon.slice(1)),this.hasMore()&&(this.more=this.more.map(e=>e[0].toUpperCase().concat(e.slice(1))))):(this.namon=this.namon.toUpperCase(),this.hasMore()&&(this.more=this.more.map(e=>e.toUpperCase()))),this}decapitalize(e="initial"){return"initial"===e?(this.namon=this.namon[0].toLowerCase().concat(this.namon.slice(1)),this.hasMore()&&(this.more=this.more.map(e=>e[0].toLowerCase().concat(e.slice(1))))):(this.namon=this.namon.toLowerCase(),this.hasMore()&&(this.more=this.more.map(e=>e.toLowerCase()))),this}normalize(){return this.namon=this.namon[0].toUpperCase().concat(this.namon.slice(1).toLowerCase()),this.hasMore()&&(this.more=this.more.map(e=>e[0].toUpperCase().concat(e.slice(1).toLowerCase()))),this}ascii(e){return n.convertToAscii(this.tostring(!0),e)}passwd(){return n.generatePassword(this.tostring(!0))}}t.Firstname=i,i.prototype.cap=i.prototype.capitalize,i.prototype.decap=i.prototype.decapitalize,i.prototype.norm=i.prototype.normalize,i.prototype.stats=i.prototype.describe,i.prototype.inits=i.prototype.getInitials},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const a=r(0),n=r(2);class i extends a.Name{constructor(e,t,r="father"){super(e,a.Namon.LAST_NAME),this.father=e,this.mother=t,this.format=r}hasMother(){return!!this.mother&&this.mother.length>0}describe(e){return e=e||this.format,new a.Summary(this.tostring(e))}tostring(e){switch(e=e||this.format){case"father":return this.father;case"mother":return this.mother||a.Separator.EMPTY;case"hyphenated":return this.mother?this.father.concat(a.Separator.HYPHEN,this.mother):this.father;case"all":return this.mother?this.father.concat(a.Separator.SPACE,this.mother):this.father}}getInitials(e){const t=[];switch(e=e||this.format){case"father":t.push(this.father[0]);break;case"mother":this.hasMother()&&t.push(this.mother[0]);break;case"hyphenated":case"all":t.push(this.father[0]),this.hasMother()&&t.push(this.mother[0])}return t}capitalize(e="initial"){return super.capitalize(e),"initial"===e?(this.father=this.father[0].toUpperCase().concat(this.father.slice(1)),this.hasMother()&&(this.mother=this.mother[0].toUpperCase().concat(this.mother.slice(1)))):(this.father=this.father.toUpperCase(),this.hasMother()&&(this.mother=this.mother.toUpperCase())),this}decapitalize(e="initial"){return super.capitalize(e),"initial"===e?(this.father=this.father[0].toLowerCase().concat(this.father.slice(1)),this.hasMother()&&(this.mother=this.mother[0].toLowerCase().concat(this.mother.slice(1)))):(this.father=this.father.toLowerCase(),this.hasMother()&&(this.mother=this.mother.toLowerCase())),this}normalize(){return this.father=this.father[0].toUpperCase().concat(this.father.slice(1).toLowerCase()),this.hasMother()&&(this.mother=this.mother[0].toUpperCase().concat(this.mother.slice(1).toLowerCase())),this}ascii(e){return n.convertToAscii(this.tostring(),e)}passwd(){return n.generatePassword(this.tostring())}}t.Lastname=i,i.prototype.cap=i.prototype.capitalize,i.prototype.decap=i.prototype.decapitalize,i.prototype.norm=i.prototype.normalize,i.prototype.stats=i.prototype.describe,i.prototype.inits=i.prototype.getInitials},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),function(e){e.PREFIX="prefix",e.LAST_NAME="lastname",e.MIDDLE_NAME="middlename",e.FIRST_NAME="firstname",e.SUFFIX="suffix"}(t.Namon||(t.Namon={})),function(e){e.LATIN="Latin",e.CYRILLIC="Cyrillic",e.GREEK="Greek",e.ARMENIAN="Armenian",e.GEORGIAN="Georgian",e.HANGUL="Hangul"}(t.Alphabet||(t.Alphabet={})),function(e){e.FIRT_LIEUTENANT="1st Lt",e.ADMIRAL="Adm",e.ATTORNEY="Atty",e.BROTHER="Brother",e.CAPTAIN="Capt",e.CHIEF="Chief",e.COMMANDER="Cmdr",e.COLONEL="Col",e.UNI_DEAN="Dean",e.DOCTOR="Dr",e.ELDER="Elder",e.FATHER="Father",e.GENERAL="Gen",e.HONORABLE="Hon",e.LIEUTENANT_COLONEL="Lt Col",e.MAJOR="Maj",e.MASTER_SERGEANT="MSgt",e.MISTER="Mr",e.MARRIED_WOMAN="Mrs",e.SINGLE_WOMAN="Ms",e.PRINCE="Prince",e.PROFESSOR="Prof",e.RABBI="Rabbi",e.REVEREND="Rev",e.SISTER="Sister"}(t.Prefix||(t.Prefix={})),function(e){e.THE_SECOND="II",e.THE_THIRD="III",e.THE_FOURTH="IV",e.CERT_PUB_ACCOUNTANT="CPA",e.DOCTOR_DENTAL_MED="DDS",e.ESQUIRE="Esq",e.JURIST_DOCTOR="JD",e.JUNIOR="Jr",e.DOCTOR_OF_LAWS="LLD",e.DOCTORATE="PhD",e.RETIRED_ARMED_FORCES="Ret",e.REGISTERED_NURSE="RN",e.SENIOR="Sr",e.DOCTOR_OF_OSTEO="DO"}(t.Suffix||(t.Suffix={})),function(e){e.COLON=":",e.COMMA=",",e.EMPTY="",e.HYPHEN="-",e.PERIOD=".",e.SPACE=" ",e.SINGLE_QUOTE="'",e.DOUBLE_QUOTE='"',e.UNDERSCORE="_"}(t.Separator||(t.Separator={}))},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const a=r(0);t.Summary=class{constructor(e,t=[a.Separator.SPACE]){this.namon=e,this.compute(t)}tostring(){return a.Separator.EMPTY.concat(`Descriptive statistics for "${this.namon}" \n`,`count : ${this.count} \n`,`frequency: ${this.frequency} \n`,`top : ${this.top} \n`,`unique : ${this.unique} \n`,`distrib : ${Object.entries(this.distribution).map(e=>`${e[1]}${e[0]}`).join(",")} \n`)}compute(e=[]){let t=0,r=0,a=0,n="";const i=this.groupByChar();for(const s in i)-1===e.indexOf(s)&&(t+=i[s],i[s]>=r&&(r=i[s],n=s),a++);this.distribution=i,this.count=t,this.frequency=r,this.top=n,this.unique=a}groupByChar(){const e={};for(const t of this.namon.toUpperCase())Object.keys(e).includes(t)?e[t]+=1:e[t]=1;return e}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const a=r(0),n=r(1);class i{constructor(e=!1){this.bypass=e,this._px=null,this._fn=null,this._mn=[],this._ln=null,this._sx=null}prefix(e){return this.bypass||(new n.PrefixValidator).validate(e),this._px=e,this}firstname(e,...t){return this._fn=new a.Firstname(e,...t),this.bypass||(new n.FirstnameValidator).validate(this._fn.tostring()),this}middlename(...e){const t=new n.NamonValidator;return this._mn=e.map(e=>(this.bypass||t.validate(e),new a.Name(e,a.Namon.MIDDLE_NAME))),this}lastname(e,t,r="father"){return this._ln=new a.Lastname(e,t,r),this.bypass||(new n.LastnameValidator).validate(this._ln.tostring()),this}suffix(e){return this.bypass||(new n.SuffixValidator).validate(e),this._sx=e,this}build(){return{firstname:this._fn,lastname:this._ln,middlename:this._mn,prefix:this._px,suffix:this._sx}}}t.FullnameBuilder=i,i.prototype.px=i.prototype.prefix,i.prototype.fn=i.prototype.firstname,i.prototype.mn=i.prototype.middlename,i.prototype.ln=i.prototype.lastname,i.prototype.sx=i.prototype.sx},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});class a{}t.ValidationRule=a,a.base=/[a-zA-Z\u00C0-\u00D6\u00D8-\u00f6\u00f8-\u00ff\u0400-\u04FFΆ-ωΑ-ώ]/,a.namon=new RegExp(`^${a.base.source}+(([' -]${a.base.source})?${a.base.source}*)*$`),a.fullname=new RegExp(`^${a.base.source}+(([',. -]${a.base.source})?${a.base.source}*)*$`),a.firstname=a.namon,a.middlename=new RegExp(`^${a.base.source}+(([' -]${a.base.source})?${a.base.source}*)*$`),a.lastname=a.namon},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),function(e){e[e.NONE=0]="NONE",e[e.NAMON=1]="NAMON",e[e.NAMA=2]="NAMA",e[e.ARR_NAMES=3]="ARR_NAMES",e[e.ARR_STRING=4]="ARR_STRING",e[e.FULL_NAME=5]="FULL_NAME",e[e.PREFIX=6]="PREFIX",e[e.FIRST_NAME=7]="FIRST_NAME",e[e.MIDDLE_NAME=8]="MIDDLE_NAME",e[e.LAST_NAME=9]="LAST_NAME",e[e.SUFFIX=10]="SUFFIX",e[e.CUSTOM=11]="CUSTOM"}(t.ValidatorType||(t.ValidatorType={}))},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});class a extends Error{constructor(e,t){super(`${t?t+" :: "+e:e}`),this.name="ValidationError"}}t.ValidationError=a},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const a=r(1);t.default=class{constructor(){this.type=a.ValidatorType.NAMON}validate(e){if(!a.ValidationRule.namon.test(e))throw new a.ValidationError(`invalid string content '${e}'`,"Name")}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const a=r(0),n=r(1);t.default=class{constructor(){this.type=n.ValidatorType.PREFIX}validate(e){if(-1===Object.entries(a.Prefix).map(e=>e[1].toLowerCase()).indexOf(e.toLowerCase()))throw new n.ValidationError(`unknown value '${e}'`,"Prefix")}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const a=r(0),n=r(1);t.default=class{constructor(){this.type=n.ValidatorType.SUFFIX}validate(e){if(-1===Object.entries(a.Suffix).map(e=>e[1].toLowerCase()).indexOf(e.toLowerCase()))throw new n.ValidationError(`unknown value '${e}'`,"Suffix")}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const a=r(1);t.default=class{constructor(){this.type=a.ValidatorType.FIRST_NAME}validate(e){if(!a.ValidationRule.firstname.test(e))throw new a.ValidationError(`invalid string content '${e}'`,"First name")}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const a=r(1);t.default=class{constructor(){this.type=a.ValidatorType.LAST_NAME}validate(e){if(!a.ValidationRule.lastname.test(e))throw new a.ValidationError(`invalid string content '${e}'`,"Last name")}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const a=r(1);t.default=class{constructor(){this.type=a.ValidatorType.MIDDLE_NAME}validate(e){if("string"==typeof e){if(!a.ValidationRule.middlename.test(e))throw new a.ValidationError(`invalid string content '${e}'`,"Middle name")}else{if(!(e instanceof Array))throw new Error("Expecting string or Array<string> type");{const t=new a.NamonValidator;e.forEach(e=>t.validate(e))}}}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const a=r(0),n=r(1);t.default=class{constructor(){this.type=n.ValidatorType.FULL_NAME}validate(e){if(!(e.firstname&&e.firstname instanceof a.Firstname))throw new n.ValidationError("first name is corrupted","Fullname");if(!(e.lastname&&e.lastname instanceof a.Lastname))throw new n.ValidationError("last name is corrupted","Fullname");if(e.middlename&&!(e.middlename instanceof Array))throw new n.ValidationError("middle name is corrupted","Fullname");e.prefix&&(new n.PrefixValidator).validate(e.prefix),e.suffix&&(new n.SuffixValidator).validate(e.suffix)}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const a=r(0),n=r(4),i=r(1);t.default=class{constructor(){this.type=i.ValidatorType.NAMA}validate(e){const t=Object.entries(e);if(t.length<n.MIN_NUMBER_NAME_PART&&t.length>n.MAX_NUMBER_NAME_PART)throw new i.ValidationError("incomplete JSON object","Nama");const r={[a.Namon.PREFIX]:new i.PrefixValidator,[a.Namon.FIRST_NAME]:new i.FirstnameValidator,[a.Namon.MIDDLE_NAME]:new i.MiddlenameValidator,[a.Namon.LAST_NAME]:new i.LastnameValidator,[a.Namon.SUFFIX]:new i.SuffixValidator};for(const e of t){const t=e[0],a=e[1];r[t].validate(a)}}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});class a extends Set{random(){return Array.from(this)[Math.floor(Math.random()*this.size)]}}t.CharSet=a;t.CharArray=class extends Array{}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const a=r(0),n=r(1),i=r(4);t.default=class{constructor(){this.type=n.ValidatorType.ARR_NAMES}validate(e){if(e.length<i.MIN_NUMBER_NAME_PART||e.length>i.MAX_NUMBER_NAME_PART)throw new n.ValidationError(`must be an array of ${i.MIN_NUMBER_NAME_PART} - `+`${i.MAX_NUMBER_NAME_PART} 'Name's`,"Array of Names");const t={[a.Namon.PREFIX]:new n.PrefixValidator,[a.Namon.FIRST_NAME]:new n.FirstnameValidator,[a.Namon.MIDDLE_NAME]:new n.MiddlenameValidator,[a.Namon.LAST_NAME]:new n.LastnameValidator,[a.Namon.SUFFIX]:new n.SuffixValidator};switch(e.length){case i.FIRST_LAST_NAME_INDEX:e.forEach(e=>{if(![a.Namon.FIRST_NAME,a.Namon.LAST_NAME].includes(e.type))throw new n.ValidationError("Both first and last names are required");t[e.type].validate(e.tostring())});break;case i.FIRST_MIDDLE_LAST_NAME_INDEX:e.forEach(e=>{if(![a.Namon.FIRST_NAME,a.Namon.MIDDLE_NAME,a.Namon.LAST_NAME].includes(e.type))throw new n.ValidationError("First, middle and last names are required");t[e.type].validate(e.tostring())});break;case i.PREFIX_FIRST_MIDDLE_LAST_NAME_INDEX:e.forEach(e=>{if(![a.Namon.PREFIX,a.Namon.FIRST_NAME,a.Namon.MIDDLE_NAME,a.Namon.LAST_NAME].includes(e.type))throw new n.ValidationError("More fields are required");t[e.type].validate(e.tostring())});break;case i.PREFIX_FIRST_MIDDLE_LAST_SUFFIX_NAME_INDEX:e.forEach(e=>{if(![a.Namon.PREFIX,a.Namon.FIRST_NAME,a.Namon.MIDDLE_NAME,a.Namon.LAST_NAME,a.Namon.SUFFIX].includes(e.type))throw new n.ValidationError("More fields are required");t[e.type].validate(e.tostring())})}}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const a=r(4),n=r(1);t.default=class{constructor(e){this.indexing=e,this.type=n.ValidatorType.ARR_STRING}validate(e){if(e.length<a.MIN_NUMBER_NAME_PART||e.length>a.MAX_NUMBER_NAME_PART)throw new n.ValidationError(`must be an array of ${a.MIN_NUMBER_NAME_PART} - `+`${a.MAX_NUMBER_NAME_PART} elements`,"Array of names");const t=new n.PrefixValidator,r=new n.SuffixValidator,i=new n.FirstnameValidator,s=new n.LastnameValidator,o=new n.MiddlenameValidator,l=this.indexing;switch(e.length){case a.FIRST_LAST_NAME_INDEX:i.validate(e[l.firstname]),s.validate(e[l.lastname]);break;case a.FIRST_MIDDLE_LAST_NAME_INDEX:i.validate(e[l.firstname]),o.validate(e[l.middlename]),s.validate(e[l.lastname]);break;case a.PREFIX_FIRST_MIDDLE_LAST_NAME_INDEX:t.validate(e[l.prefix]),i.validate(e[l.firstname]),o.validate(e[l.middlename]),s.validate(e[l.lastname]);break;case a.PREFIX_FIRST_MIDDLE_LAST_SUFFIX_NAME_INDEX:t.validate(e[l.prefix]),i.validate(e[l.firstname]),o.validate(e[l.middlename]),s.validate(e[l.lastname]),r.validate(e[l.suffix])}}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const a=r(1);t.default=class{constructor(){this.type=a.ValidatorType.FULL_NAME}validate(e){if(!a.ValidationRule.fullname.test(e))throw new a.ValidationError(`invalid string content '${e}'`,"Full name")}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const a=r(0),n=r(1),i=r(2);t.default=class{constructor(e){this.raw=e}parse(e){const{orderedBy:t,bypass:r}=e,a=this.raw.map(e=>e.trim()),s=i.organizeNameIndex(t,a.length);return r||new n.ArrayStringValidator(s).validate(a),this.distribute(a,s)}distribute(e,t){const r={firstname:null,lastname:null,middlename:[],prefix:null,suffix:null};switch(e.length){case 2:r.firstname=new a.Firstname(e[t.firstname]),r.lastname=new a.Lastname(e[t.lastname]);break;case 3:r.firstname=new a.Firstname(e[t.firstname]),r.middlename.push(new a.Name(e[t.middlename],a.Namon.MIDDLE_NAME)),r.lastname=new a.Lastname(e[t.lastname]);break;case 4:r.prefix=e[t.prefix],r.firstname=new a.Firstname(e[t.firstname]),r.middlename.push(new a.Name(e[t.middlename],a.Namon.MIDDLE_NAME)),r.lastname=new a.Lastname(e[t.lastname]);break;case 5:r.prefix=e[t.prefix],r.firstname=new a.Firstname(e[t.firstname]),r.middlename.push(new a.Name(e[t.middlename],a.Namon.MIDDLE_NAME)),r.lastname=new a.Lastname(e[t.lastname]),r.suffix=e[t.suffix]}return r}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const a=r(0),n=r(1);t.default=class{constructor(e){this.raw=e}parse(e){return e.bypass||(new n.NamaValidator).validate(this.raw),this.distribute()}distribute(){const e={firstname:null,lastname:null,middlename:[],prefix:null,suffix:null};for(const t of Object.entries(this.raw)){const r=t[0],n=t[1];switch(r){case a.Namon.FIRST_NAME:e.firstname=new a.Firstname(n);break;case a.Namon.LAST_NAME:e.lastname=new a.Lastname(n);break;case a.Namon.MIDDLE_NAME:e.middlename.push(new a.Name(n,a.Namon.MIDDLE_NAME));break;case a.Namon.PREFIX:e.prefix=n;break;case a.Namon.SUFFIX:e.suffix=n}}return e}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const a=r(5);t.default=class{constructor(e){this.raw=e}parse(e){const{orderedBy:t,separator:r,bypass:n}=e,i=this.raw.split(r);return new a.ArrayStringParser(i).parse({orderedBy:t,bypass:n})}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const a=r(0),n=r(2);t.capitalize=function(e,t="initial"){if(!e)return"";const r=e[0].toUpperCase(),a=e.slice(1).toLowerCase();return"initial"===t?r.concat(a):e.toUpperCase()},t.decapitalize=function(e,t="initial"){if(!e)return"";const r=e[0].toLowerCase(),a=e.slice(1);return"initial"===t?r.concat(a):e.toLowerCase()},t.toggleCase=function(e){const t=[];for(const r of e)r===r.toUpperCase()?t.push(r.toLowerCase()):t.push(r.toUpperCase());return t.join(a.Separator.EMPTY)},t.organizeNameIndex=function(e,t,r=n.NAME_INDEX){const a=Object.assign({},r);if("firstname"===e)switch(t){case n.FIRST_LAST_NAME_INDEX:a.firstname=0,a.lastname=1;break;case n.FIRST_MIDDLE_LAST_NAME_INDEX:a.firstname=0,a.middlename=1,a.lastname=2;break;case n.PREFIX_FIRST_MIDDLE_LAST_NAME_INDEX:a.prefix=0,a.firstname=1,a.middlename=2,a.lastname=3;break;case n.PREFIX_FIRST_MIDDLE_LAST_SUFFIX_NAME_INDEX:a.prefix=0,a.firstname=1,a.middlename=2,a.lastname=3,a.suffix=4}else switch(t){case n.LAST_FIRST_NAME_INDEX:a.lastname=0,a.firstname=1;break;case n.LAST_FIRST_MIDDLE_NAME_INDEX:a.lastname=0,a.firstname=1,a.middlename=2;break;case n.PREFIX_LAST_FIRST_MIDDLE_NAME_INDEX:a.prefix=0,a.lastname=1,a.firstname=2,a.middlename=3;break;case n.PREFIX_LAST_FIRST_MIDDLE_SUFFIX_NAME_INDEX:a.prefix=0,a.lastname=1,a.firstname=2,a.middlename=3,a.suffix=4}return a},t.allowShortNameType=function(e){switch(e){case"firstname":case"fn":return"firstname";case"lastname":case"ln":return"lastname";case"middlename":case"mn":return"middlename";default:return e}},t.allowShortNameOrder=function(e){switch(e){case"firstname":case"fn":return"firstname";case"lastname":case"ln":return"lastname";default:return e}},t.convertToAscii=function(e,t=[...n.RESTRICTED_CHARS]){return e.split(a.Separator.EMPTY).filter(e=>-1===t.indexOf(e)).map(e=>e.charCodeAt(0))},t.generatePassword=function(e){const t=n.PASSWORD_MAPPER;return e.split(a.Separator.EMPTY).map(e=>t.has(e.toLowerCase())?t.get(e.toLowerCase()).random():t.get("$").random()).join(a.Separator.EMPTY)}}])}));
2
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("namefully",[],t):"object"==typeof exports?exports.namefully=t():e.namefully=t()}(window,(function(){return function(e){var t={};function r(s){if(t[s])return t[s].exports;var a=t[s]={i:s,l:!1,exports:{}};return e[s].call(a.exports,a,a.exports,r),a.l=!0,a.exports}return r.m=e,r.c=t,r.d=function(e,t,s){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:s})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var s=Object.create(null);if(r.r(s),Object.defineProperty(s,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var a in e)r.d(s,a,function(t){return e[t]}.bind(null,a));return s},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=9)}([function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Separator=t.Namon=t.CapsRange=t.Flat=t.NameType=t.NameOrder=t.Surname=t.Title=void 0,function(e){e.US="US",e.UK="UK"}(t.Title||(t.Title={})),function(e){e.FATHER="father",e.MOTHER="mother",e.HYPHENATED="hyphenated",e.ALL="all"}(t.Surname||(t.Surname={})),function(e){e.FIRST_NAME="firstName",e.LAST_NAME="lastName"}(t.NameOrder||(t.NameOrder={})),function(e){e.FIRST_NAME="firstName",e.MIDDLE_NAME="middleName",e.LAST_NAME="lastName",e.BIRTH_NAME="birthName"}(t.NameType||(t.NameType={})),function(e){e.FIRST_NAME="firstName",e.MIDDLE_NAME="middleName",e.LAST_NAME="lastName",e.FIRST_MID="firstMid",e.MID_LAST="midLast",e.ALL="all"}(t.Flat||(t.Flat={})),function(e){e[e.NONE=0]="NONE",e[e.INITIAL=1]="INITIAL",e[e.ALL=2]="ALL"}(t.CapsRange||(t.CapsRange={}));class s{constructor(e,t){this.index=e,this.key=t}static has(e){return s.all.has(e)}static cast(e){return s.has(e)?s.all.get(e):void 0}toString(){return"Namon."+this.key}equal(e){return e instanceof s&&e.index===this.index&&e.key===this.key}}t.Namon=s,s.PREFIX=new s(0,"prefix"),s.FIRST_NAME=new s(1,"firstName"),s.MIDDLE_NAME=new s(2,"middleName"),s.LAST_NAME=new s(3,"lastName"),s.SUFFIX=new s(4,"suffix"),s.values=[s.PREFIX,s.FIRST_NAME,s.MIDDLE_NAME,s.LAST_NAME,s.SUFFIX],s.all=new Map([[s.PREFIX.key,s.PREFIX],[s.FIRST_NAME.key,s.FIRST_NAME],[s.MIDDLE_NAME.key,s.MIDDLE_NAME],[s.LAST_NAME.key,s.LAST_NAME],[s.SUFFIX.key,s.SUFFIX]]);class a{constructor(e,t){this.name=e,this.token=t}toString(){return"Separator."+this.name}}t.Separator=a,a.COMMA=new a("comma",","),a.COLON=new a("colon",":"),a.DOUBLE_QUOTE=new a("doubleQuote",'"'),a.EMPTY=new a("empty",""),a.HYPHEN=new a("hyphen","-"),a.PERIOD=new a("period","."),a.SEMI_COLON=new a("semiColon",";"),a.SINGLE_QUOTE=new a("singleQuote","'"),a.SPACE=new a("space"," "),a.UNDERSCORE=new a("underscore","_"),a.all=new Map([[a.COMMA.name,a.COMMA],[a.COLON.name,a.COLON],[a.DOUBLE_QUOTE.name,a.DOUBLE_QUOTE],[a.EMPTY.name,a.EMPTY],[a.HYPHEN.name,a.HYPHEN],[a.PERIOD.name,a.PERIOD],[a.SEMI_COLON.name,a.SEMI_COLON],[a.SINGLE_QUOTE.name,a.SINGLE_QUOTE],[a.SPACE.name,a.SPACE],[a.UNDERSCORE.name,a.UNDERSCORE]]),a.tokens=[...a.all.values()].map(e=>e.token)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.UnknownError=t.NotAllowedError=t.ValidationError=t.InputError=t.NameError=t.NameErrorType=void 0;const s=r(2);var a;!function(e){e[e.INPUT=0]="INPUT",e[e.VALIDATION=1]="VALIDATION",e[e.NOT_ALLOWED=2]="NOT_ALLOWED",e[e.UNKNOWN=3]="UNKNOWN"}(a=t.NameErrorType||(t.NameErrorType={}));class i extends Error{constructor(e,t,r=a.UNKNOWN){super(t),this.source=e,this.type=r,this.name="NameError"}get sourceAsString(){let e="";return this.source||(e="<undefined>"),"string"==typeof this.source&&(e=this.source),s.isNameArray(this.source)&&(e=this.source.map(e=>e.toString()).join(" ")),s.isStringArray(this.source)&&(e=this.source.join(" ")),e}get hasMessage(){return this.message&&this.message.trim().length>0}toString(){let e=`${this.name} (${this.sourceAsString})`;return this.hasMessage&&(e=`${e}: ${this.message}`),e}}t.NameError=i;t.InputError=class extends i{constructor(e){super(e.source,e.message,a.INPUT),this.name="InputError"}};t.ValidationError=class extends i{constructor(e){super(e.source,e.message,a.VALIDATION),this.nameType=e.nameType,this.name="ValidationError"}toString(){let e=`${this.name} (${this.nameType}='${this.sourceAsString}')`;return this.hasMessage&&(e=`${e}: ${this.message}`),e}};t.NotAllowedError=class extends i{constructor(e){super(e.source,e.message,a.NOT_ALLOWED),this.operation=e.operation,this.name="NotAllowedError"}toString(){let e=`${this.name} (${this.sourceAsString})`;return this.operation&&this.operation.trim().length>0&&(e=`${e} - ${this.operation}`),this.hasMessage&&(e=`${e}: ${this.message}`),e}};t.UnknownError=class extends i{constructor(e){super(e.source,e.message,a.UNKNOWN),this.origin=e.error,this.name="UnknownError"}toString(){let e=super.toString();return this.origin&&(e+="\n"+this.origin.toString()),e}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isNameArray=t.isStringArray=t.toggleCase=t.decapitalize=t.capitalize=t.NameIndex=void 0;const s=r(5),a=r(3),i=r(0);class n{constructor(e,t,r,s,a){this.prefix=e,this.firstName=t,this.middleName=r,this.lastName=s,this.suffix=a}static get min(){return s.MIN_NUMBER_OF_NAME_PARTS}static get max(){return s.MAX_NUMBER_OF_NAME_PARTS}static base(){return new this(-1,0,-1,1,-1)}static when(e,t=2){if(e===i.NameOrder.FIRST_NAME)switch(t){case 2:return new this(-1,0,-1,1,-1);case 3:return new this(-1,0,1,2,-1);case 4:return new this(0,1,2,3,-1);case 5:return new this(0,1,2,3,4);default:return n.base()}else switch(t){case 2:return new this(-1,1,-1,0,-1);case 3:return new this(-1,1,2,0,-1);case 4:return new this(0,2,3,1,-1);case 5:return new this(0,2,3,1,4);default:return n.base()}}}t.NameIndex=n,t.capitalize=function(e,t=i.CapsRange.INITIAL){if(!e||t===i.CapsRange.NONE)return e;const r=e[0].toUpperCase(),s=e.slice(1).toLowerCase();return t===i.CapsRange.INITIAL?r.concat(s):e.toUpperCase()},t.decapitalize=function(e,t=i.CapsRange.INITIAL){if(!e||t===i.CapsRange.NONE)return e;const r=e[0].toLowerCase(),s=e.slice(1);return t===i.CapsRange.INITIAL?r.concat(s):e.toLowerCase()},t.toggleCase=function(e){const t=[];for(const r of e)r===r.toUpperCase()?t.push(r.toLowerCase()):t.push(r.toUpperCase());return t.join("")},t.isStringArray=function(e){return Array.isArray(e)&&e.length>0&&e.every(e=>"string"==typeof e)},t.isNameArray=function(e){return Array.isArray(e)&&e.length>0&&e.every(e=>e instanceof a.Name)}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.LastName=t.FirstName=t.Name=void 0;const s=r(1),a=r(0),i=r(2);class n{constructor(e,t,r){this.type=t,this.capsRange=null!=r?r:a.CapsRange.INITIAL,this.value=e,r&&this.caps(r)}set value(e){if(e.trim().length<2)throw new s.InputError({source:e,message:"must be 2+ characters"});this.namon=e,this.initial=e[0]}get value(){return this.namon}get length(){return this.namon.length}get isPrefix(){return this.type===a.Namon.PREFIX}get isFirstName(){return this.type===a.Namon.FIRST_NAME}get isMiddleName(){return this.type===a.Namon.MIDDLE_NAME}get isLastName(){return this.type===a.Namon.LAST_NAME}get isSuffix(){return this.type===a.Namon.SUFFIX}static prefix(e){return new this(e,a.Namon.PREFIX)}static first(e){return new this(e,a.Namon.FIRST_NAME)}static middle(e){return new this(e,a.Namon.MIDDLE_NAME)}static last(e){return new this(e,a.Namon.LAST_NAME)}static suffix(e){return new this(e,a.Namon.SUFFIX)}initials(){return[this.initial]}toString(){return this.namon}equal(e){return e instanceof n&&e.value===this.value&&e.type===this.type}caps(e){return this.value=i.capitalize(this.namon,null!=e?e:this.capsRange),this}decaps(e){return this.value=i.decapitalize(this.namon,null!=e?e:this.capsRange),this}}t.Name=n;class o extends n{constructor(e,...t){super(e,a.Namon.FIRST_NAME);for(const e of t)if(e.trim().length<2)throw new s.InputError({source:e,message:"must be 2+ characters"});this._more=t}get hasMore(){return this._more.length>0}get length(){return super.length+(this.hasMore?this._more.reduce((e,t)=>e+t).length:0)}get asNames(){const e=[n.first(this.value)];return this.hasMore&&e.push(...this._more.map(e=>n.first(e))),e}get more(){return this._more}toString(e=!1){return e&&this.hasMore?`${this.value} ${this._more.join(" ")}`.trim():this.value}initials(e=!1){const t=[this.initial];return e&&this.hasMore&&t.push(...this._more.map(e=>e[0])),t}caps(e){return e=e||this.capsRange,this.value=i.capitalize(this.value,e),this.hasMore&&(this._more=this._more.map(t=>i.capitalize(t,e))),this}decaps(e){return e=e||this.capsRange,this.value=i.decapitalize(this.value,e),this.hasMore&&(this._more=this._more.map(t=>i.decapitalize(t,e))),this}copyWith(e){var t,r;return new o(null!==(t=e.first)&&void 0!==t?t:this.value,...null!==(r=e.more)&&void 0!==r?r:this._more)}}t.FirstName=o;class l extends n{constructor(e,t,r=a.Surname.FATHER){if(super(e,a.Namon.LAST_NAME),this.format=r,t&&t.trim().length<2)throw new s.InputError({source:t,message:"must be 2+ characters"});this._mother=t}get father(){return this.value}get mother(){return this._mother}get hasMother(){return!!this._mother}get length(){var e,t;return super.length+(null!==(t=null===(e=this._mother)||void 0===e?void 0:e.length)&&void 0!==t?t:0)}get asNames(){const e=[n.last(this.value)];return this.hasMother&&e.push(n.last(this._mother)),e}toString(e){var t;switch(e=null!=e?e:this.format){case a.Surname.FATHER:return this.value;case a.Surname.MOTHER:return null!==(t=this.mother)&&void 0!==t?t:"";case a.Surname.HYPHENATED:return this.hasMother?`${this.value}-${this._mother}`:this.value;case a.Surname.ALL:return this.hasMother?`${this.value} ${this._mother}`:this.value}}initials(e){const t=[];switch(e=e||this.format){case a.Surname.MOTHER:this.hasMother&&t.push(this._mother[0]);break;case a.Surname.HYPHENATED:case a.Surname.ALL:t.push(this.initial),this.hasMother&&t.push(this._mother[0]);break;case a.Surname.FATHER:default:t.push(this.initial)}return t}caps(e){return e=e||this.capsRange,this.value=i.capitalize(this.value,e),this.hasMother&&(this._mother=i.capitalize(this._mother,e)),this}decaps(e){return e=e||this.capsRange,this.value=i.decapitalize(this.value,e),this.hasMother&&(this._mother=i.decapitalize(this._mother,e)),this}copyWith(e){var t,r,s;return new l(null!==(t=e.father)&&void 0!==t?t:this.value,null!==(r=e.mother)&&void 0!==r?r:this.mother,null!==(s=e.format)&&void 0!==s?s:this.format)}}t.LastName=l},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Config=void 0;const s=r(0);class a{constructor(e,t=s.NameOrder.FIRST_NAME,r=s.Separator.SPACE,a=s.Title.UK,i=!1,n=!0,o=s.Surname.FATHER){this._name=e,this._orderedBy=t,this._separator=r,this._title=a,this._ending=i,this._bypass=n,this._surname=o}get orderedBy(){return this._orderedBy}get separator(){return this._separator}get title(){return this._title}get ending(){return this._ending}get bypass(){return this._bypass}get surname(){return this._surname}get name(){return this._name}static create(e="default"){return a.cache.has(e)||a.cache.set(e,new this(e)),a.cache.get(e)}static merge(e){var t,r,s,i,n,o;if(e){const l=a.create(e.name);return l._orderedBy=null!==(t=e.orderedBy)&&void 0!==t?t:l.orderedBy,l._separator=null!==(r=e.separator)&&void 0!==r?r:l.separator,l._title=null!==(s=e.title)&&void 0!==s?s:l.title,l._ending=null!==(i=e.ending)&&void 0!==i?i:l.ending,l._bypass=null!==(n=e.bypass)&&void 0!==n?n:l.bypass,l._surname=null!==(o=e.surname)&&void 0!==o?o:l.surname,l}return a.create()}copyWith(e={}){const{name:t,orderedBy:r,separator:s,title:i,ending:n,bypass:o,surname:l}=e,u=a.create(this.genNewName(null!=t?t:this.name+"_copy"));return u._orderedBy=null!=r?r:this.orderedBy,u._separator=null!=s?s:this.separator,u._title=null!=i?i:this.title,u._ending=null!=n?n:this.ending,u._bypass=null!=o?o:this.bypass,u._surname=null!=l?l:this.surname,u}clone(){return this.copyWith()}reset(){this._orderedBy=s.NameOrder.FIRST_NAME,this._separator=s.Separator.SPACE,this._title=s.Title.UK,this._ending=!1,this._bypass=!0,this._surname=s.Surname.FATHER,a.cache.set(this.name,this)}updateOrder(e){e&&e!==this._orderedBy&&(a.cache.get(this.name)._orderedBy=e)}genNewName(e){return e===this.name||a.cache.has(e)?this.genNewName(e+"_copy"):e}}t.Config=a,a.cache=new Map},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ALLOWED_TOKENS=t.MAX_NUMBER_OF_NAME_PARTS=t.MIN_NUMBER_OF_NAME_PARTS=t.version=void 0,t.version="1.2.0",t.MIN_NUMBER_OF_NAME_PARTS=2,t.MAX_NUMBER_OF_NAME_PARTS=5,t.ALLOWED_TOKENS=[".",","," ","-","_","b","B","f","F","l","L","m","M","n","N","o","O","p","P","s","S","$"]},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.FullName=void 0;const s=r(4),a=r(1),i=r(3),n=r(0),o=r(7);class l{constructor(e){this._middleName=[],this._config=s.Config.merge(e)}get config(){return this._config}get prefix(){return this._prefix}get firstName(){return this._firstName}get lastName(){return this._lastName}get middleName(){return this._middleName}get suffix(){return this._suffix}static parse(e,t){try{const r=new l(t);return r.setPrefix(e.prefix),r.setFirstName(e.firstName),r.setMiddleName(e.middleName),r.setLastName(e.lastName),r.setSuffix(e.suffix),r}catch(t){throw t instanceof a.NameError?t:new a.UnknownError({source:Object.values(e).join(" "),message:"could not parse JSON content",error:t})}}setPrefix(e){if(!e)return this;this._config.bypass||o.Validators.prefix.validate(e);const t=e instanceof i.Name?e.value:e;return this._prefix=i.Name.prefix(this._config.title===n.Title.US?t+".":t),this}setFirstName(e){return this._config.bypass||o.Validators.firstName.validate(e),this._firstName=e instanceof i.FirstName?e:new i.FirstName(e),this}setLastName(e){return this._config.bypass||o.Validators.lastName.validate(e),this._lastName=e instanceof i.LastName?e:new i.LastName(e),this}setMiddleName(e){if(Array.isArray(e))return this._config.bypass||o.Validators.middleName.validate(e),this._middleName=e.map(e=>e instanceof i.Name?e:i.Name.middle(e)),this}setSuffix(e){return e?(this._config.bypass||o.Validators.suffix.validate(e),this._suffix=i.Name.suffix(e instanceof i.Name?e.value:e),this):this}has(e){return e.equal(n.Namon.PREFIX)?!!this._prefix:e.equal(n.Namon.SUFFIX)?!!this._suffix:!e.equal(n.Namon.MIDDLE_NAME)||this._middleName.length>0}}t.FullName=l},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Validators=t.ArrayNameValidator=t.ArrayStringValidator=t.NamaValidator=void 0;const s=r(5),a=r(1),i=r(3),n=r(0),o=r(2);class l{}l.base=/[a-zA-Z\u00C0-\u00D6\u00D8-\u00f6\u00f8-\u00ff\u0400-\u04FFΆ-ωΑ-ώ]/,l.namon=new RegExp(`^${l.base.source}+(([' -]${l.base.source})?${l.base.source}*)*$`),l.firstName=l.namon,l.middleName=new RegExp(`^${l.base.source}+(([' -]${l.base.source})?${l.base.source}*)*$`),l.lastName=l.namon;class u{constructor(){}static create(){return this.validator||(this.validator=new this)}validate(e,t){if(e instanceof i.Name)(class{constructor(){}static create(){return this.validator||(this.validator=new this)}validate(e,t){if(t&&e.type!==t)throw new a.ValidationError({source:[e],nameType:e.type.toString(),message:"wrong type"});if(!l.namon.test(e.value))throw new a.ValidationError({source:[e],nameType:e.type.toString(),message:"invalid content"})}}).create().validate(e,t);else{if("string"!=typeof e)throw new a.InputError({source:typeof e,message:"expecting types of string | Name"});if(!l.namon.test(e))throw new a.ValidationError({source:e,nameType:"namon",message:"invalid content"})}}}class h{constructor(){}static create(){return this.validator||(this.validator=new this)}validate(e){this.validateKeys(e),m.firstName.validate(e.get(n.Namon.FIRST_NAME)),m.lastName.validate(e.get(n.Namon.LAST_NAME)),e.has(n.Namon.PREFIX)&&m.namon.validate(e.get(n.Namon.PREFIX)),e.has(n.Namon.SUFFIX)&&m.namon.validate(e.get(n.Namon.SUFFIX))}validateKeys(e){if(!e.size)throw new a.InputError({source:void 0,message:"Map<k,v> must not be empty"});if(e.size<s.MIN_NUMBER_OF_NAME_PARTS||e.size>s.MAX_NUMBER_OF_NAME_PARTS)throw new a.InputError({source:[...e.values()],message:`expecting ${s.MIN_NUMBER_OF_NAME_PARTS}-${s.MIN_NUMBER_OF_NAME_PARTS} fields`});if(!e.has(n.Namon.FIRST_NAME))throw new a.InputError({source:[...e.values()],message:'"firstName" is a required key'});if(!e.has(n.Namon.LAST_NAME))throw new a.InputError({source:[...e.values()],message:'"lastName" is a required key'})}}t.NamaValidator=h;t.ArrayStringValidator=class extends class{validate(e){if(0===e.length||e.length<s.MIN_NUMBER_OF_NAME_PARTS||e.length>s.MAX_NUMBER_OF_NAME_PARTS)throw new a.InputError({source:e.map(e=>e.toString()),message:`expecting a list of ${s.MIN_NUMBER_OF_NAME_PARTS}-${s.MIN_NUMBER_OF_NAME_PARTS} elements`})}}{constructor(e=o.NameIndex.base()){super(),this.index=e}validate(e){switch(this.validateIndex(e),e.length){case 2:m.firstName.validate(e[this.index.firstName]),m.lastName.validate(e[this.index.lastName]);break;case 3:m.firstName.validate(e[this.index.firstName]),m.middleName.validate(e[this.index.middleName]),m.lastName.validate(e[this.index.lastName]);break;case 4:m.namon.validate(e[this.index.prefix]),m.firstName.validate(e[this.index.firstName]),m.middleName.validate(e[this.index.middleName]),m.lastName.validate(e[this.index.lastName]);break;case 5:m.namon.validate(e[this.index.prefix]),m.firstName.validate(e[this.index.firstName]),m.middleName.validate(e[this.index.middleName]),m.lastName.validate(e[this.index.lastName]),m.namon.validate(e[this.index.suffix])}}validateIndex(e){super.validate(e)}};t.ArrayNameValidator=class{constructor(){}static create(){return this.validator||(this.validator=new this)}validate(e){if(e.length<s.MIN_NUMBER_OF_NAME_PARTS)throw new a.InputError({source:e,message:`expecting at least ${s.MIN_NUMBER_OF_NAME_PARTS} elements`});if(!this.hasBasicNames(e))throw new a.InputError({source:e,message:"both first and last names are required"})}hasBasicNames(e){const t={};for(const r of e)(r.isFirstName||r.isLastName)&&(t[r.type.key]=r.toString());return Object.keys(t).length===s.MIN_NUMBER_OF_NAME_PARTS}};class m{}t.Validators=m,m.namon=u.create(),m.nama=h.create(),m.prefix=u.create(),m.firstName=class{constructor(){}static create(){return this.validator||(this.validator=new this)}validate(e){if(e instanceof i.FirstName)e.asNames.forEach(e=>this.validate(e.value));else{if("string"!=typeof e)throw new a.InputError({source:typeof e,message:"expecting types string | FirstName"});if(!l.firstName.test(e))throw new a.ValidationError({source:e,nameType:"firstName",message:"invalid content"})}}}.create(),m.middleName=class{constructor(){}static create(){return this.validator||(this.validator=new this)}validate(e){if("string"==typeof e){if(!l.middleName.test(e))throw new a.ValidationError({source:e,nameType:"middleName",message:"invalid content"})}else{if(!Array.isArray(e))throw new a.InputError({source:typeof e,message:"expecting types of string | string[] | Name[]"});try{const t=u.create();for(const r of e)t.validate(r,n.Namon.MIDDLE_NAME)}catch(t){throw new a.ValidationError({source:e,nameType:"middleName",message:null==t?void 0:t.message})}}}}.create(),m.lastName=class{constructor(){}static create(){return this.validator||(this.validator=new this)}validate(e){if(e instanceof i.LastName)e.asNames.forEach(e=>this.validate(e.value));else{if("string"!=typeof e)throw new a.InputError({source:typeof e,message:"expecting types string | LastName"});if(!l.lastName.test(e))throw new a.ValidationError({source:e,nameType:"lastName",message:"invalid content"})}}}.create(),m.suffix=u.create()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ArrayNameParser=t.NamaParser=t.ArrayStringParser=t.StringParser=t.Parser=void 0;const s=r(6),a=r(4),i=r(2),n=r(7),o=r(3),l=r(0),u=r(1);class h{constructor(e){this.raw=e}static build(e){const t=e.trim().split(l.Separator.SPACE.token),r=t.length;if(0===r||1===r)throw new u.InputError({source:e,message:"cannot build from invalid input"});if(2===r||3===r)return new m(e);{const e=t.pop(),[r,...s]=t;return new c([r,s.join(" "),e])}}static buildAsync(e){try{return Promise.resolve(h.build(e))}catch(e){return Promise.reject(e)}}}t.Parser=h;class m extends h{constructor(e){super(e)}parse(e){const t=a.Config.merge(e),r=this.raw.split(t.separator.token);return new c(r).parse(e)}}t.StringParser=m;class c extends h{constructor(e){super(e)}parse(e){const t=a.Config.merge(e),r=new s.FullName(t),l=this.raw.map(e=>e.trim()),u=i.NameIndex.when(t.orderedBy,l.length),h=new n.ArrayStringValidator(u);switch(t.bypass?h.validateIndex(l):h.validate(l),l.length){case 2:r.setFirstName(new o.FirstName(l[u.firstName])),r.setLastName(new o.LastName(l[u.lastName]));break;case 3:r.setFirstName(new o.FirstName(l[u.firstName])),r.setMiddleName(this.split(l[u.middleName],t)),r.setLastName(new o.LastName(l[u.lastName]));break;case 4:r.setPrefix(o.Name.prefix(l[u.prefix])),r.setFirstName(new o.FirstName(l[u.firstName])),r.setMiddleName(this.split(l[u.middleName],t)),r.setLastName(new o.LastName(l[u.lastName]));break;case 5:r.setPrefix(o.Name.prefix(l[u.prefix])),r.setFirstName(new o.FirstName(l[u.firstName])),r.setMiddleName(this.split(l[u.middleName],t)),r.setLastName(new o.LastName(l[u.lastName])),r.setSuffix(o.Name.suffix(l[u.suffix]))}return r}split(e,t){return e.split(t.separator.token).map(e=>o.Name.middle(e))}}t.ArrayStringParser=c;t.NamaParser=class extends h{constructor(e){super(e)}parse(e){const t=a.Config.merge(e);return t.bypass?n.NamaValidator.create().validateKeys(this.asNama()):n.NamaValidator.create().validate(this.asNama()),s.FullName.parse(this.raw,t)}asNama(){return new Map(Object.entries(this.raw).map(([e,t])=>{const r=l.Namon.cast(e);if(!r)throw new u.InputError({source:Object.values(this.raw).join(" "),message:`unsupported key "${e}"`});return[r,t]}))}};t.ArrayNameParser=class extends h{constructor(e){super(e)}parse(e){const t=a.Config.merge(e),r=new s.FullName(t);n.ArrayNameValidator.create().validate(this.raw);for(const e of this.raw)if(e.isPrefix)r.setPrefix(e);else if(e.isSuffix)r.setSuffix(e);else if(e.isFirstName)r.setFirstName(e instanceof o.FirstName?e:new o.FirstName(e.value));else if(e.isMiddleName)r.middleName.push(e);else if(e.isLastName){const s=new o.LastName(e.value,e instanceof o.LastName?e.mother:void 0,t.surname);r.setLastName(s)}return r}}},function(e,t,r){"use strict";var s=this&&this.__createBinding||(Object.create?function(e,t,r,s){void 0===s&&(s=r),Object.defineProperty(e,s,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,s){void 0===s&&(s=r),e[s]=t[r]}),a=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||t.hasOwnProperty(r)||s(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),a(r(4),t),a(r(1),t),a(r(6),t),a(r(3),t),a(r(10),t);var i=r(8);Object.defineProperty(t,"Parser",{enumerable:!0,get:function(){return i.Parser}}),a(r(0),t);var n=r(2);Object.defineProperty(t,"NameIndex",{enumerable:!0,get:function(){return n.NameIndex}})},function(e,t,r){"use strict";var s=this&&this.__awaiter||function(e,t,r,s){return new(r||(r=Promise))((function(a,i){function n(e){try{l(s.next(e))}catch(e){i(e)}}function o(e){try{l(s.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?a(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(n,o)}l((s=s.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.Namefully=void 0;const a=r(4),i=r(5),n=r(1),o=r(8),l=r(0),u=r(2);class h{constructor(e,t){this.build(this.toParser(e),t)}static tryParse(e){try{return new this(o.Parser.build(e))}catch(e){return}}static parse(e){return s(this,void 0,void 0,(function*(){return o.Parser.buildAsync(e).then(e=>new h(e))}))}get config(){return this._config}get length(){return this.birth.length}get prefix(){var e;return null===(e=this._fullName.prefix)||void 0===e?void 0:e.toString()}get first(){return this.firstName()}get middle(){return this.hasMiddle?this.middleName()[0]:void 0}get hasMiddle(){return this._fullName.has(l.Namon.MIDDLE_NAME)}get last(){return this.lastName()}get suffix(){var e;return null===(e=this._fullName.suffix)||void 0===e?void 0:e.toString()}get birth(){return this.birthName()}get short(){return this.shorten()}get long(){return this.birth}get full(){return this.fullName()}get public(){return this.format("f $l")}toString(){return this.full}get(e){return e.equal(l.Namon.PREFIX)?this._fullName.prefix:e.equal(l.Namon.FIRST_NAME)?this._fullName.firstName:e.equal(l.Namon.MIDDLE_NAME)?this._fullName.middleName:e.equal(l.Namon.LAST_NAME)?this._fullName.lastName:e.equal(l.Namon.SUFFIX)?this._fullName.suffix:void 0}equal(e){return this.toString()===e.toString()}toJson(){return{prefix:this.prefix,firstName:this.first,middleName:this.middleName(),lastName:this.last,suffix:this.suffix}}has(e){return this._fullName.has(e)}fullName(e){const t=this._config.ending?",":"",r=[];return e=e||this._config.orderedBy,this.prefix&&r.push(this.prefix),e===l.NameOrder.FIRST_NAME?r.push(this.first,...this.middleName(),this.last+t):r.push(this.last,this.first,this.middleName().join(" ")+t),this.suffix&&r.push(this.suffix),r.join(" ").trim()}birthName(e){return(e=e||this._config.orderedBy)===l.NameOrder.FIRST_NAME?[this.first,...this.middleName(),this.last].join(" "):[this.last,this.first,...this.middleName()].join(" ")}firstName(e=!0){return this._fullName.firstName.toString(e)}middleName(){return this._fullName.middleName.map(e=>e.value)}lastName(e){return this._fullName.lastName.toString(e)}initials(e){const t=[],r=this._fullName.firstName.initials(),s=this._fullName.middleName.map(e=>e.initials()[0]),a=this._fullName.lastName.initials(),i=Object.assign({orderedBy:this._config.orderedBy,only:l.NameType.BIRTH_NAME},e),{orderedBy:n,only:o}=i;return o!==l.NameType.BIRTH_NAME?o===l.NameType.FIRST_NAME?t.push(...r):o===l.NameType.MIDDLE_NAME?t.push(...s):t.push(...a):n===l.NameOrder.FIRST_NAME?t.push(...r,...s,...a):t.push(...a,...r,...s),t}shorten(e){return(e=e||this._config.orderedBy)===l.NameOrder.FIRST_NAME?[this._fullName.firstName.value,this._fullName.lastName.toString()].join(" "):[this._fullName.lastName.toString(),this._fullName.firstName.value].join(" ")}flatten(e){if(this.length<=e.limit)return this.full;const t=Object.assign({limit:20,by:l.Flat.MIDDLE_NAME,withPeriod:!0,recursive:!1,withMore:!1},e),{by:r,limit:s,recursive:a,withMore:i,withPeriod:n,surname:o}=t,u=n?".":"",h=this._fullName.firstName.toString(),m=this.middleName().join(" "),c=this._fullName.lastName.toString(),N=this.hasMiddle,d=this._fullName.firstName.initials(i).join(u+" ")+u,f=this._fullName.lastName.initials(o).join(u+" ")+u,p=N?this._fullName.middleName.map(e=>e.initials()[0]).join(u+" ")+u:"";let _=[];if(this._config.orderedBy===l.NameOrder.FIRST_NAME)switch(r){case l.Flat.FIRST_NAME:_=N?[d,m,c]:[d,c];break;case l.Flat.LAST_NAME:_=N?[h,m,f]:[h,f];break;case l.Flat.MIDDLE_NAME:_=N?[h,p,c]:[h,c];break;case l.Flat.FIRST_MID:_=N?[d,p,c]:[d,c];break;case l.Flat.MID_LAST:_=N?[h,p,f]:[h,f];break;case l.Flat.ALL:_=N?[d,p,f]:[d,f]}else switch(r){case l.Flat.FIRST_NAME:_=N?[c,d,m]:[c,d];break;case l.Flat.LAST_NAME:_=N?[f,h,m]:[f,h];break;case l.Flat.MIDDLE_NAME:_=N?[c,h,p]:[c,h];break;case l.Flat.FIRST_MID:_=N?[c,d,p]:[c,d];break;case l.Flat.MID_LAST:_=N?[f,h,p]:[f,h];break;case l.Flat.ALL:_=N?[f,d,p]:[f,d]}const g=_.join(" ");if(a&&g.length>s){const t=r===l.Flat.FIRST_NAME?l.Flat.MIDDLE_NAME:r===l.Flat.MIDDLE_NAME?l.Flat.LAST_NAME:r===l.Flat.LAST_NAME?l.Flat.FIRST_MID:r===l.Flat.FIRST_MID?l.Flat.MID_LAST:r===l.Flat.MID_LAST||r===l.Flat.ALL?l.Flat.ALL:r;return t===r?g:this.flatten(Object.assign(Object.assign({},e),{by:t}))}return g}zip(e=l.Flat.MID_LAST,t=!0){return this.flatten({limit:0,by:e,withPeriod:t})}format(e){var t;if("short"===e)return this.short;if("long"===e)return this.long;if("public"===e)return this.public;"official"===e&&(e="o");let r="";const s=[];for(const a of e.split("")){if(-1===i.ALLOWED_TOKENS.indexOf(a))throw new n.NotAllowedError({source:this.full,operation:"format",message:`unsupported character <${a}> from ${e}.`});r+=a,"$"!==a&&(s.push(null!==(t=this.map(r))&&void 0!==t?t:""),r="")}return s.join("").trim()}flip(){this._config.orderedBy===l.NameOrder.FIRST_NAME?(this._config.updateOrder(l.NameOrder.LAST_NAME),console.log("The name order is now changed to: "+l.NameOrder.LAST_NAME)):(this._config.updateOrder(l.NameOrder.FIRST_NAME),console.log("The name order is now changed to: "+l.NameOrder.FIRST_NAME))}split(e=/[' -]/g){return this.birth.replace(e," ").split(" ")}join(e=""){return this.split().join(e)}toUpperCase(){return this.birth.toUpperCase()}toLowerCase(){return this.birth.toLowerCase()}toCamelCase(){return u.decapitalize(this.toPascalCase())}toPascalCase(){return this.split().map(e=>u.capitalize(e)).join("")}toSnakeCase(){return this.split().map(e=>e.toLowerCase()).join("_")}toHyphenCase(){return this.split().map(e=>e.toLowerCase()).join("-")}toDotCase(){return this.split().map(e=>e.toLowerCase()).join(".")}toToggleCase(){return u.toggleCase(this.birth)}build(e,t){this._config=a.Config.merge(t),this._fullName=e.parse(this._config)}toParser(e){if(e instanceof o.Parser)return e;if("string"==typeof e)return new o.StringParser(e);if(u.isStringArray(e))return new o.ArrayStringParser(e);if(u.isNameArray(e))return new o.ArrayNameParser(e);if("object"==typeof e)return new o.NamaParser(e);throw new n.InputError({source:e,message:"Cannot parse raw data. Review expected data types."})}map(e){var t,r;switch(e){case".":case",":case" ":case"-":case"_":return e;case"b":return this.birth;case"B":return this.birth.toUpperCase();case"f":return this.first;case"F":return this.first.toUpperCase();case"l":return this.last;case"L":return this.last.toUpperCase();case"m":case"M":return"m"===e?this.middleName().join(" "):this.middleName().join(" ").toUpperCase();case"o":case"O":const s=this._config.ending?",":"",a=[];this.prefix&&a.push(this.prefix),a.push((this.last+",").toUpperCase()),this.hasMiddle?a.push(this.first,this.middleName().join(" ")+s):a.push(this.first+s),this.suffix&&a.push(this.suffix);const i=a.join(" ").trim();return"o"===e?i:i.toUpperCase();case"p":return this.prefix;case"P":return null===(t=this.prefix)||void 0===t?void 0:t.toUpperCase();case"s":return this.suffix;case"S":return null===(r=this.suffix)||void 0===r?void 0:r.toUpperCase();case"$f":case"$F":return this._fullName.firstName.initials()[0];case"$l":case"$L":return this._fullName.lastName.initials()[0];case"$m":case"$M":return this.hasMiddle?this.middle[0]:void 0;default:return}}}t.Namefully=h}])}));
3
3
  //# sourceMappingURL=namefully.min.js.map
@@ -1,29 +1,12 @@
1
- /*! *****************************************************************************
2
- Copyright (c) Microsoft Corporation. All rights reserved.
3
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use
4
- this file except in compliance with the License. You may obtain a copy of the
5
- License at http://www.apache.org/licenses/LICENSE-2.0
6
-
7
- THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
8
- KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
9
- WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
10
- MERCHANTABLITY OR NON-INFRINGEMENT.
11
-
12
- See the Apache Version 2.0 License for specific language governing permissions
13
- and limitations under the License.
14
- ***************************************************************************** */
15
-
16
1
  /**
17
2
  * Welcome to namefully!
18
3
  *
19
- * namefully is a JS utility for handing person names.
4
+ * `namefully` is a JavaScript utility for handing person names.
20
5
  *
21
6
  * Sources
22
7
  * - repo: https://github.com/ralflorent/namefully
23
8
  * - docs: https://namefully.netlify.app
24
9
  * - npm: https://npmjs.com/package/namefully
25
10
  *
26
- * Created on March 03, 2020
27
- * @author Ralph Florent <ralflornt@gmail.com>
28
11
  * @license MIT
29
12
  */