(()=>{"use strict";var e={date:{pattern:/^(\d{0,2})\/?(\d{0,2})\/?(\d{0,4})$/,format:function(e){var t=e.replace(/\D/g,"");return t.length<=2?t:t.length<=4?"".concat(t.slice(0,2),"/").concat(t.slice(2)):"".concat(t.slice(0,2),"/").concat(t.slice(2,4),"/").concat(t.slice(4,8))},placeholder:"dd/mm/yyyy",maxLength:10},dateUS:{pattern:/^(\d{0,2})\/?(\d{0,2})\/?(\d{0,4})$/,format:function(e){var t=e.replace(/\D/g,"");return t.length<=2?t:t.length<=4?"".concat(t.slice(0,2),"/").concat(t.slice(2)):"".concat(t.slice(0,2),"/").concat(t.slice(2,4),"/").concat(t.slice(4,8))},placeholder:"mm/dd/yyyy",maxLength:10},currency:{pattern:/^\$?\s?[\d,]+\.?\d{0,2}$/,format:function(e){var t=e.replace(/[^\d.]/g,"").split("."),a=t[0]||"",n=t[1]||"",r=a=a.replace(/\B(?=(\d{3})+(?!\d))/g,",");return n&&(r+="."+n.slice(0,2)),r?"$ "+r:""},placeholder:"$ 0.00"},licensePlate:{pattern:/^[0-9]?-?[A-Z]{0,3}-?[0-9]{0,3}$/,format:function(e){var t=e.toUpperCase().replace(/[^A-Z0-9]/g,""),a="",n=0;t[0]&&/\d/.test(t[0])&&(a=t[0]+"-",n=1);var r=t.slice(n).match(/[A-Z]/g)||[];return a+=r.slice(0,3).join(""),r.length>=3&&(a+="-",a+=(t.slice(n+3).match(/\d/g)||[]).slice(0,3).join("")),a},placeholder:"[9-]AAA-999"},decimal:{pattern:/^[\d,]+\.?\d*$/,format:function(e){var t=e.replace(/[^\d.]/g,"").split("."),a=t[0]||"",n=t[1]||"",r=a=a.replace(/\B(?=(\d{3})+(?!\d))/g,",");return t.length>1&&(r+="."+n),r},placeholder:"0"},ip:{pattern:/^(\d{1,3}\.){0,3}\d{0,3}$/,format:function(e){for(var t=e.replace(/\D/g,""),a=[],n=0;n<t.length;n+=3){var r=t.slice(n,n+3);if(parseInt(r)>255&&(r="255"),a.push(r),a.length>=4)break}return a.join(".")},placeholder:"0.0.0.0",validate:function(e){var t=e.split(".");return 4===t.length&&t.every(function(e){var t=parseInt(e);return!isNaN(t)&&t>=0&&t<=255})}},email:{pattern:/^[a-zA-Z0-9._%+-]*@?[a-zA-Z0-9.-]*\.?[a-zA-Z]{0,}$/,format:function(e){return e.toLowerCase()},placeholder:"email@example.com",validate:function(e){return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e)}}};function t(t,a){var n=e[a];n?(n.placeholder&&!t.placeholder&&(t.placeholder=n.placeholder),n.maxLength&&(t.maxLength=n.maxLength),t.addEventListener("input",function(e){var t=e.target.selectionStart,a=e.target.value,r=n.format(a);if(r!==a){e.target.value=r;var c=r.length-a.length,l=Math.max(0,Math.min(t+c,r.length));e.target.setSelectionRange(l,l)}}),n.validate&&t.addEventListener("blur",function(e){!n.validate(e.target.value)&&e.target.value?e.target.classList.add("is-invalid"):e.target.classList.remove("is-invalid")}),t.value&&(t.value=n.format(t.value))):console.warn("Unknown format type: ".concat(a))}document.addEventListener("DOMContentLoaded",function(){document.querySelectorAll('[data-inputmask-alias="datetime"]').forEach(function(e){var a=e.dataset.inputmaskInputformat;"dd/mm/yyyy"===a?t(e,"date"):"mm/dd/yyyy"===a&&t(e,"dateUS")}),document.querySelectorAll('[data-inputmask*="numeric"][data-inputmask*="prefix"]').forEach(function(e){t(e,"currency")}),document.querySelectorAll('[data-inputmask*="[9-]AAA-999"]').forEach(function(e){t(e,"licensePlate")}),document.querySelectorAll('[data-inputmask*="decimal"]').forEach(function(e){t(e,"decimal")}),document.querySelectorAll('[data-inputmask*="ip"]').forEach(function(e){t(e,"ip")}),document.querySelectorAll('[data-inputmask*="email"]').forEach(function(e){t(e,"email")}),document.querySelectorAll("[data-mask]").forEach(function(e){var t=e.dataset.mask;e.addEventListener("input",function(e){for(var a=e.target.value.replace(/\D/g,""),n="",r=0,c=0;r<t.length&&c<a.length;)"9"===t[r]?(n+=a[c],c++):n+=t[r],r++;e.target.value=n})})})})();