import{isValidElement as f}from"react";function p(t={},i=null,n=[]){for(let[e,o]of Object.entries(t))s(n,r(i,e),o);return n}function r(t,i){return t?t+"["+i+"]":i}function s(t,i,n){if(Array.isArray(n))for(let[e,o]of n.entries())s(t,r(i,e.toString()),o);else n instanceof Date?t.push([i,n.toISOString()]):typeof n=="boolean"?t.push([i,n?"1":"0"]):typeof n=="string"?t.push([i,n]):typeof n=="number"?t.push([i,`${n}`]):n==null?t.push([i,""]):c(n)&&!f(n)&&p(n,i,t)}function g(t){var n,e;let i=(n=t==null?void 0:t.form)!=null?n:t.closest("form");if(i){for(let o of i.elements)if(o!==t&&(o.tagName==="INPUT"&&o.type==="submit"||o.tagName==="BUTTON"&&o.type==="submit"||o.nodeName==="INPUT"&&o.type==="image")){o.click();return}(e=i.requestSubmit)==null||e.call(i)}}function c(t){if(Object.prototype.toString.call(t)!=="[object Object]")return!1;let i=Object.getPrototypeOf(t);return i===null||Object.getPrototypeOf(i)===null}export{g as attemptSubmit,p as objectToFormEntries};
