import"./Bg9kRutz.js";import{j as B,z as G,C as E,D as H,F as y,p as I,c as b,e as J,g as i,r as k,s as D,h as S,b as K}from"./AM9C8FsA.js";import{s as L}from"./B6F1ZNoe.js";import{c as M,a as j,p as N,i as Q}from"./D-bC_bvq.js";import{e as R,i as T}from"./Bbpm7MqF.js";import{p as U,t as F,a as m,b as q}from"./CmMFD2-g.js";import{s as A,r as V}from"./C6Ut6Zxy.js";import{l as O,d as W}from"./DY_kk6CS.js";const C=new Set;function X(l,a,e,s,r=s){var v=e.getAttribute("type")==="checkbox",t=l;let h=!1;if(a!==null)for(var d of a)t=t[d]??(t[d]=[]);t.push(e),O(e,"change",()=>{var c=e.__value;v&&(c=z(t,c,e.checked)),r(c)},()=>r(v?[]:null)),E(()=>{var c=s();if(B&&e.defaultChecked!==e.checked){h=!0;return}v?(c=c||[],e.checked=c.includes(e.__value)):e.checked=M(e.__value,c)}),H(()=>{var c=t.indexOf(e);c!==-1&&t.splice(c,1)}),C.has(t)||(C.add(t),y(()=>{t.sort((c,n)=>c.compareDocumentPosition(n)===4?-1:1),C.delete(t)})),y(()=>{if(h){var c;if(v)c=z(t,c,e.checked);else{var n=t.find(u=>u.checked);c=n==null?void 0:n.__value}r(c)}})}function ie(l,a,e=a){O(l,"change",s=>{var r=s?l.defaultChecked:l.checked;e(r)}),(B&&l.defaultChecked!==l.checked||G(a)==null)&&e(l.checked),E(()=>{var s=a();l.checked=!!s})}function z(l,a,e){for(var s=new Set,r=0;r<l.length;r+=1)l[r].checked&&s.add(l[r].__value);return e||s.delete(a),Array.from(s)}function Y(l,a,e,s){i(a)?e([]):e(s.elements),s.selection_changed(e())}function Z(l,a,e){a.selection_changed(e())}var $=F('<div class="form-check form-check-inline"><input class="form-check-input" type="checkbox"> <label class="form-check-label"> </label></div>'),ee=F('<div class="form-group"><button class="btn btn-outline-primary btn-sm" style="min-width: 100px"><!></button> <!></div>');function _e(l,a){const e=U();I(a,!0);const s=[];let r=j(a,"selected_elements",31,()=>N(a.elements)),v=j(a,"enabled",3,!0),t=J(()=>r().length==a.elements.length);var h=ee(),d=b(h);d.__click=[Y,t,r,a],A(d,"id",`all_checkbox_${e}`);var c=b(d);{var n=_=>{var o=q("Deselect all");m(_,o)},u=_=>{var o=q("Select all");m(_,o)};Q(c,_=>{i(t)?_(n):_(u,!1)})}k(d);var P=D(d,2);R(P,17,()=>a.elements,T,(_,o)=>{var g=$(),f=b(g);V(f);var w;f.__change=[Z,a,r];var x=D(f,2),p=b(x,!0);k(x),k(g),S(()=>{w!==(w=i(o))&&(f.value=(f.__value=i(o))==null?"":i(o)),A(f,"id",`${i(o)}_checkbox_${e}`),f.disabled=!v(),A(x,"for",`${i(o)}_checkbox_${e}`),L(p,i(o))}),X(s,[],f,()=>(i(o),r()),r),m(_,g)}),k(h),S(()=>d.disabled=!v()),m(l,h),K()}W(["click","change"]);export{_e as A,X as a,ie as b};
