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