var V=(a,o)=>()=>(o||a((o={exports:{}}).exports,o),o.exports);var g=V((p,c)=>{(function(a,o){typeof p=="object"&&typeof c<"u"?c.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.StartEndDate=o())})(void 0,function(){function a(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function o(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function v(t,e,r){return e&&o(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}function y(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&d(t,e)}function s(t){return s=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},s(t)}function d(t,e){return d=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,i){return n.__proto__=i,n},d(t,e)}function m(){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(t){if(t===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function D(t,e){if(e&&(typeof e=="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return f(t)}function F(t){var e=m();return function(){var n=s(t),i;if(e){var l=s(this).constructor;i=Reflect.construct(n,arguments,l)}else i=n.apply(this,arguments);return D(this,i)}}var b=FormValidation.Plugin,O=function(t){y(r,t);var e=F(r);function r(n){var i;return a(this,r),i=e.call(this,n),i.fieldValidHandler=i.onFieldValid.bind(f(i)),i.fieldInvalidHandler=i.onFieldInvalid.bind(f(i)),i}return v(r,[{key:"install",value:function(){var i=this,l=this.core.getFields();this.startDateFieldOptions=l[this.opts.startDate.field],this.endDateFieldOptions=l[this.opts.endDate.field];var h=this.core.getFormElement();this.core.on("core.field.valid",this.fieldValidHandler).on("core.field.invalid",this.fieldInvalidHandler).addField(this.opts.startDate.field,{validators:{date:{format:this.opts.format,max:function(){var u=h.querySelector('[name="'.concat(i.opts.endDate.field,'"]'));return u.value},message:this.opts.startDate.message}}}).addField(this.opts.endDate.field,{validators:{date:{format:this.opts.format,message:this.opts.endDate.message,min:function(){var u=h.querySelector('[name="'.concat(i.opts.startDate.field,'"]'));return u.value}}}})}},{key:"uninstall",value:function(){this.core.removeField(this.opts.startDate.field),this.startDateFieldOptions&&this.core.addField(this.opts.startDate.field,this.startDateFieldOptions),this.core.removeField(this.opts.endDate.field),this.endDateFieldOptions&&this.core.addField(this.opts.endDate.field,this.endDateFieldOptions),this.core.off("core.field.valid",this.fieldValidHandler).off("core.field.invalid",this.fieldInvalidHandler)}},{key:"onFieldInvalid",value:function(i){switch(i){case this.opts.startDate.field:this.startDateValid=!1;break;case this.opts.endDate.field:this.endDateValid=!1;break}}},{key:"onFieldValid",value:function(i){switch(i){case this.opts.startDate.field:this.startDateValid=!0,this.endDateValid===!1&&this.core.revalidateField(this.opts.endDate.field);break;case this.opts.endDate.field:this.endDateValid=!0,this.startDateValid===!1&&this.core.revalidateField(this.opts.startDate.field);break}}}]),r}(b);return O})});export default g();
