import{b4 as n,ac as _,bR as w,aL as u,bU as i,bn as S,aU as A,bO as O,bh as y}from"./D_PZV9Md.mjs";function V(e,f,a=f){var d=new WeakSet;n(e,"input",async c=>{var v=c?e.defaultValue:e.value;if(v=m(e)?t(v):v,a(v),_!==null&&d.add(_),await w(),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))}}}),(u&&e.defaultValue!==e.value||i(f)==null&&e.value)&&(a(m(e)?t(e.value):e.value),_!==null&&d.add(_)),S(()=>{var c=f();if(e===document.activeElement){var v=_;if(d.has(v))return}m(e)&&c===t(e.value)||e.type==="date"&&!c&&!e.value||c!==e.value&&(e.value=c!=null?c:"")})}const b=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),n(a,"change",()=>{var l=a.__value;v&&(l=E(r,l,a.checked)),c(l)},()=>c(v?[]:null)),S(()=>{var l=d();if(u&&a.defaultChecked!==a.checked){s=!0;return}v?(l=l||[],a.checked=l.includes(a.__value)):a.checked=A(a.__value,l)}),O(()=>{var l=r.indexOf(a);l!==-1&&r.splice(l,1)}),b.has(r)||(b.add(r),y(()=>{r.sort((l,k)=>l.compareDocumentPosition(k)===4?-1:1),b.delete(r)})),y(()=>{if(s){var l;if(v)l=E(r,l,a.checked);else{var k=r.find(C=>C.checked);l=k==null?void 0:k.__value}c(l)}})}function B(e,f,a=f){n(e,"change",d=>{var c=d?e.defaultChecked:e.checked;a(c)}),(u&&e.defaultChecked!==e.checked||i(f)==null)&&a(e.checked),S(()=>{var d=f();e.checked=!!d})}function E(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 m(e){var f=e.type;return f==="number"||f==="range"}function t(e){return e===""?null:+e}export{q as a,B as b,V as c};
