/*!
 * KoliBri - The accessible HTML-Standard
 */
"use strict";var componentNames=require("./component-names-CuI-0Pbo.js"),common=require("./common-Cd2qH809.js");const searchFormElement=e=>{for(common.getExperimentalMode()&&(common.devHint("↓ Search form element start."),common.Log.debug(e));e instanceof HTMLElement&&"FORM"!==e.tagName&&e.tagName!==componentNames.KolFormTag.toUpperCase();){try{e=e.parentElement instanceof HTMLElement?e.parentElement:e.parentNode instanceof ShadowRoot?e.parentNode.host:null}catch(e){}common.getExperimentalMode()&&(common.Log.debug(e),common.devHint("↑ Search form element finished."))}return e},propagateResetEventToForm=(e={})=>{var o,t;const n=searchFormElement(e.form);if(n instanceof HTMLElement){const e=new Event("reset",{bubbles:!0,cancelable:!0});if("FORM"===n.tagName)common.setEventTarget(e,n),n.dispatchEvent(e);else if(n.tagName===componentNames.KolFormTag.toUpperCase()){common.setEventTarget(e,common.KoliBriDevHelper.querySelector("form",n));const m=n;"function"==typeof(null===(o=m._on)||void 0===o?void 0:o.onReset)&&(null===(t=m._on)||void 0===t||t.onReset(e))}}},propagateSubmitEventToForm=(e={})=>{const o=searchFormElement(e.form);if(o instanceof HTMLElement){const e=new SubmitEvent("submit",{bubbles:!0,cancelable:!0,submitter:o});if("FORM"===o.tagName)common.getExperimentalMode()&&!1===o.noValidate&&common.devHint("If you have not focusable or hidden form fields in your form, you should enable noValidate for your form.",{force:!0}),setTimeout(()=>{"function"==typeof o.requestSubmit?o.requestSubmit():(common.setEventTarget(e,o),o.dispatchEvent(e))});else if(o.tagName===componentNames.KolFormTag.toUpperCase()){common.setEventTarget(e,common.KoliBriDevHelper.querySelector("form",o));const t=o;setTimeout(()=>{var o,n;"function"==typeof(null===(o=t._on)||void 0===o?void 0:o.onSubmit)&&(null===(n=t._on)||void 0===n||n.onSubmit(e))})}}};exports.propagateResetEventToForm=propagateResetEventToForm,exports.propagateSubmitEventToForm=propagateSubmitEventToForm;