var w=(a,o)=>()=>(o||a((o={exports:{}}).exports,o),o.exports);var T=w((m,h)=>{(function(a,o){typeof m=="object"&&typeof h<"u"?h.exports=o():typeof define=="function"&&define.amd?define(o):(a=typeof globalThis<"u"?globalThis:a||self,a.FormValidation=a.FormValidation||{},a.FormValidation.plugins=a.FormValidation.plugins||{},a.FormValidation.plugins.PasswordStrength=o())})(void 0,function(){function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function O(e,t,n){return t&&o(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function P(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function S(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&l(e,t)}function u(e){return u=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},u(e)}function l(e,t){return l=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(i,r){return i.__proto__=r,i},l(e,t)}function b(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function f(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function V(e,t){if(t&&(typeof t=="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return f(e)}function g(e){var t=b();return function(){var i=u(e),r;if(t){var s=u(this).constructor;r=Reflect.construct(i,arguments,s)}else r=i.apply(this,arguments);return V(this,r)}}var R=FormValidation.Plugin,v=function(e){S(n,e);var t=g(n);function n(i){var r;return a(this,n),r=t.call(this,i),r.opts=Object.assign({},{minimalScore:3,onValidated:function(){}},i),r.validatePassword=r.checkPasswordStrength.bind(f(r)),r.validatorValidatedHandler=r.onValidatorValidated.bind(f(r)),r}return O(n,[{key:"install",value:function(){this.core.registerValidator(n.PASSWORD_STRENGTH_VALIDATOR,this.validatePassword),this.core.on("core.validator.validated",this.validatorValidatedHandler),this.core.addField(this.opts.field,{validators:P({},n.PASSWORD_STRENGTH_VALIDATOR,{message:this.opts.message,minimalScore:this.opts.minimalScore})})}},{key:"uninstall",value:function(){this.core.off("core.validator.validated",this.validatorValidatedHandler),this.core.disableValidator(this.opts.field,n.PASSWORD_STRENGTH_VALIDATOR)}},{key:"checkPasswordStrength",value:function(){var r=this;return{validate:function(c){var _=c.value;if(_==="")return{valid:!0};var y=zxcvbn(_),d=y.score,p=y.feedback.warning||"The password is weak";return d<r.opts.minimalScore?{message:p,meta:{message:p,score:d},valid:!1}:{meta:{message:p,score:d},valid:!0}}}}},{key:"onValidatorValidated",value:function(r){if(r.field===this.opts.field&&r.validator===n.PASSWORD_STRENGTH_VALIDATOR&&r.result.meta){var s=r.result.meta.message,c=r.result.meta.score;this.opts.onValidated(r.result.valid,s,c)}}}]),n}(R);return v.PASSWORD_STRENGTH_VALIDATOR="___PasswordStrengthValidator",v})});export default T();
