import{y as k,q as i,d as m,z as t,A as g,B as y,C as s}from"./BZ0BXH4m.js";const o=new Set;function C(c,f,e,r,l=r){var h=e.getAttribute("type")==="checkbox",d=c;let n=!1;if(f!==null)for(var u of f)d=d[u]??=[];d.push(e),k(e,"change",()=>{var a=e.__value;h&&(a=v(d,a,e.checked)),l(a)},()=>l(h?[]:null)),t(()=>{var a=r();if(i&&e.defaultChecked!==e.checked){n=!0;return}h?(a=a||[],e.checked=a.includes(e.__value)):e.checked=g(e.__value,a)}),y(()=>{var a=d.indexOf(e);a!==-1&&d.splice(a,1)}),o.has(d)||(o.add(d),s(()=>{d.sort((a,_)=>a.compareDocumentPosition(_)===4?-1:1),o.delete(d)})),s(()=>{if(n){var a;if(h)a=v(d,a,e.checked);else{var _=d.find(b=>b.checked);a=_?.__value}l(a)}})}function w(c,f,e=f){k(c,"change",r=>{var l=r?c.defaultChecked:c.checked;e(l)}),(i&&c.defaultChecked!==c.checked||m(f)==null)&&e(c.checked),t(()=>{var r=f();c.checked=!!r})}function v(c,f,e){for(var r=new Set,l=0;l<c.length;l+=1)c[l].checked&&r.add(c[l].__value);return e||r.delete(f),Array.from(r)}export{w as a,C as b};
