import{nothing as e}from"lit";import{directive as t,AsyncDirective as n,PartType as r}from"lit/async-directive.js";import{EventHandler as i}from"../events.js";import{formSubmitHandler as o}from"./form-submit-handler.js";const s=t(class extends n{constructor(e){super(e),this._formElement=null,this._eventHandler=null}render(...t){return e}update(e,t){const n=this.getFormElement(e),r=l(t,0),s=l(t,1);return n===this._formElement&&this._onValid===r&&this._onInvalid!==s||(this._eventHandler?.disconnect(),this._formElement=n,this._onValid=r,this._onInvalid=s,this._formElement.setAttribute("novalidate",""),this._eventHandler=new i(n,"submit",o({onValid:r,onInvalid:s})),this._eventHandler.connect()),this.render()}disconnected(){this._eventHandler?.disconnect()}reconnected(){this._eventHandler?.connect()}getFormElement(e){if(!(function(e){return e.type===r.ELEMENT}(e)&&(t=e.element,t instanceof HTMLFormElement)))throw new Error("This directive must be used on an `<form>` element");var t;return e.element}});function l(e,t){return null==e||0===e.length||e.length<t+1?null:e[t]}export{s as formSubmit};
//# sourceMappingURL=form-submit-directive.js.map
