var CodiceFiscale=function(A){function O(I){if(E[I])return E[I].exports;var N=E[I]={i:I,l:!1,exports:{}};return A[I].call(N.exports,N,N.exports,O),N.l=!0,N.exports}var E={};return O.m=A,O.c=E,O.i=function(A){return A},O.d=function(A,E,I){O.o(A,E)||Object.defineProperty(A,E,{configurable:!1,enumerable:!0,get:I})},O.n=function(A){var E=A&&A.__esModule?function(){return A.default}:function(){return A};return O.d(E,"a",E),E},O.o=function(A,O){return Object.prototype.hasOwnProperty.call(A,O)},O.p="",O(O.s=4)}([function(A,O,E){"use strict";function I(A){return A.trim().replace(new RegExp(/[àá]/g),"a'").replace(new RegExp(/[èé]/g),"e'").replace(new RegExp(/[ìí]/g),"i'").replace(new RegExp(/[òó]/g),"o'").replace(new RegExp(/[ùú]/g),"u'").toUpperCase()}function N(A,O){switch(A){case 1:return O%4==0&&O%100!=0||O%400==0?29:28;case 8:case 3:case 5:case 10:return 30;default:return 31}}function L(A,O,E){var I=O-1;return I>=0&&I<12&&A>0&&A<=N(I,E)}function R(A,O,E){if("string"==typeof A&&void 0===O&&void 0===E)return new Date(A);if(L(A,O,E))return new Date(E,O-1,A,0,0,0,0);throw new Error("The date "+E+"/"+O+"/"+A+" is not a valid date")}function C(A){return A.replace(/[^AEIOU]/gi,"")}function S(A){return A.replace(/[^BCDFGHJKLMNPQRSTVWXYZ]/gi,"")}function T(A){for(var O=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2,E=String(A);E.length3&&void 0!==arguments[3])||arguments[3];if(I(this,A),L||void 0===N||void 0===E){var R=void 0;if(R=void 0!==E?this.searchByNameAndProvince(O,E):this.searchByName(O),void 0===R&&4===O.length&&(R=this.searchByCC(O)),void 0===R)throw new Error("Comune with name "+O+" doesn't exist");if(void 0!==N&&R.cc!==N)throw new Error("Comune with cc "+N+" doesn't exist");this.nome=R.nome,this.prov=R.prov,this.cc=R.cc}else this.nome=O,this.prov=E,this.cc=N}return N(A,[{key:"nomeNorm",get:function(){return(0,R.normalizeString)(this.nome)}}]),N(A,[{key:"searchByCC",value:function(O){var E=void 0;try{E=A.GetByCC(O)}catch(A){}if(void 0!==E)return E.toJSON()}},{key:"searchByName",value:function(A){for(var O=(0,R.normalizeString)(A),E=0,I=L.COMUNI.length-1,N=[];E<=I;){var C=Math.floor((E+I)/2),S=L.COMUNI[C];if(O===S[2]){N.push(S),C>0&&L.COMUNI[C-1][2]===O?N.push(L.COMUNI[C-1]):C1)throw new Error("Comune with name of "+A+" is found in more than one province. Please specify the province code")}},{key:"searchByNameAndProvince",value:function(A,O){for(var E=(0,R.normalizeString)(A),I=0,N=L.COMUNI.length-1,C=void 0;I<=N;){var S=Math.floor((I+N)/2),T=L.COMUNI[S];if(E===T[2]){O===T[1]?C=T:S>0&&L.COMUNI[S-1][2]===E&&O===L.COMUNI[S-1][1]?C=L.COMUNI[S-1]:S=0;I-=1){var N=this.code[I];null!==N.match(/\d/)&&(E=""+E.substr(0,I)+C.OMOCODIA_TABLE[N]+E.substr(I+1),O.push(E+A.getCheckCode(E)))}return O}},{key:"compute",value:function(){var O=this.getSurnameCode();O+=this.getNameCode(),O+=this.dateCode(),O+=this.birthplace.cc,O+=A.getCheckCode(O),this.code=O}},{key:"reverse",value:function(){this.name=this.code.substr(3,3),this.surname=this.code.substr(0,3);var A=this.code.substr(6,2),O=parseInt("19"+A,10),E=parseInt("20"+A,10),I=(new Date).getFullYear(),N=E>I?O:E,L=this.code.substr(8,1),S=C.MONTH_CODES.indexOf(L);this.gender="M";var T=parseInt(this.code.substr(9,2),10);T>31&&(this.gender="F",T-=40),this.birthday=new Date(N,S,T,0,0,0,0);var G=this.code.substr(11,4);return this.birthplace=R.Comune.GetByCC(G),this.toJSON()}},{key:"checkGender",value:function(A){if(this.gender=void 0!==A?A.toUpperCase():this.gender.toUpperCase(),"string"!=typeof this.gender)throw new Error("Gender must be a string");if("M"!==this.gender&&"F"!==this.gender)throw new Error("Gender must be either 'M' or 'F'");return A}},{key:"getSurnameCode",value:function(){return(""+(0,S.extractConsonants)(this.surname)+(0,S.extractVowels)(this.surname)+"XXX").substr(0,3).toUpperCase()}},{key:"getNameCode",value:function(){var A=(0,S.extractConsonants)(this.name);return A.length>=4?A=A.charAt(0)+A.charAt(2)+A.charAt(3):(A+=(0,S.extractVowels)(this.name)+"XXX",A=A.substr(0,3)),A.toUpperCase()}},{key:"dateCode",value:function(){var A="0"+this.birthday.getFullYear();A=A.substr(A.length-2,2);var O=C.MONTH_CODES[this.birthday.getMonth()],E=this.birthday.getDate();"F"===this.gender.toUpperCase()&&(E+=40);var I="0"+E;return I=I.substr(I.length-2,2),String(A+O+I)}}],[{key:"getCheckCode",value:function(A){for(var O=0,E=0;E<15;E+=1){var I=A[E];O+=E%2!=0?C.CHECK_CODE_EVEN[I]:C.CHECK_CODE_ODD[I]}return O%=26,C.CHECK_CODE_CHARS.charAt(O)}},{key:"findLocationCode",value:function(A,O){return new R.Comune(A,O).cc}},{key:"computeInverse",value:function(O){return new A(O).toJSON()}},{key:"compute",value:function(O){return new A(O).toString()}},{key:"check",value:function(O){if("string"!=typeof O)return!1;var E=O.toUpperCase();if(16!==E.length)return!1;var I=O.charAt(15);return E=O.slice(0,15),A.getCheckCode(E)===I}},{key:"getOmocodie",value:function(O){return new A(O).omocodie()}}]),A}();T.utils={birthplaceFields:S.birthplaceFields},A.exports=T}]);