import{K as b,C as _,L as A,k as n,u as E,M as S,N as w,O as M,A as y}from"./DXA5xaTu.mjs";function V(e,f,a=f){var d=new WeakSet;b(e,"input",async c=>{var v=c?e.defaultValue:e.value;if(v=t(e)?u(v):v,a(v),_!==null&&d.add(_),await A(),v!==(v=f())){var r=e.selectionStart,s=e.selectionEnd,h=e.value.length;if(e.value=v!=null?v:"",s!==null){var o=e.value.length;r===s&&s===h&&o>h?(e.selectionStart=o,e.selectionEnd=o):(e.selectionStart=r,e.selectionEnd=Math.min(s,o))}}}),(n&&e.defaultValue!==e.value||E(f)==null&&e.value)&&(a(t(e)?u(e.value):e.value),_!==null&&d.add(_)),S(()=>{var c=f();if(e===document.activeElement){var v=_;if(d.has(v))return}t(e)&&c===u(e.value)||e.type==="date"&&!c&&!e.value||c!==e.value&&(e.value=c!=null?c:"")})}const m=new Set;function q(e,f,a,d,c=d){var o;var v=a.getAttribute("type")==="checkbox",r=e;let s=!1;if(f!==null)for(var h of f)r=(o=r[h])!=null?o:r[h]=[];r.push(a),b(a,"change",()=>{var l=a.__value;v&&(l=C(r,l,a.checked)),c(l)},()=>c(v?[]:null)),S(()=>{var l=d();if(n&&a.defaultChecked!==a.checked){s=!0;return}v?(l=l||[],a.checked=l.includes(a.__value)):a.checked=w(a.__value,l)}),M(()=>{var l=r.indexOf(a);l!==-1&&r.splice(l,1)}),m.has(r)||(m.add(r),y(()=>{r.sort((l,k)=>l.compareDocumentPosition(k)===4?-1:1),m.delete(r)})),y(()=>{if(s){var l;if(v)l=C(r,l,a.checked);else{var k=r.find(i=>i.checked);l=k==null?void 0:k.__value}c(l)}})}function B(e,f,a=f){b(e,"change",d=>{var c=d?e.defaultChecked:e.checked;a(c)}),(n&&e.defaultChecked!==e.checked||E(f)==null)&&a(e.checked),S(()=>{var d=f();e.checked=!!d})}function C(e,f,a){for(var d=new Set,c=0;c<e.length;c+=1)e[c].checked&&d.add(e[c].__value);return a||d.delete(f),Array.from(d)}function t(e){var f=e.type;return f==="number"||f==="range"}function u(e){return e===""?null:+e}export{B as a,q as b,V as c};
