1import{R as v,r as S,j as l}from"./main-react-Di-GvINw.js";import{C as y}from"./index-BwrzOu6C.js";import{a as K}from"./index-BKbOazEV.js";import{L as $}from"./index-DD3WqN0m.js";import{L as M}from"./index-Dxt1HXE9.js";import{F as P}from"./index-ChxTYXWf.js";import"./preload-helper-Cdv6RdwI.js";import"./_commonjsHelpers-Cpj98o6Y.js";import"./try-parse-json-PNnY1j55.js";import"./Skeleton-BnWBRKiL.js";import"./index-mLFX9G4A.js";import"./api-fetcher-CICcxupP.js";import"./index-CQDcev0L.js";import"./envelope_alt-CaVuCBMH.js";import"./index-Dn-1OOQh.js";const Q=v.forwardRef((o,t)=>{const{checked:h,value:d,name:C,onCheckedChange:f,className:_,mandatory:k,indeterminate:j,ariaControls:m}=o,u=S.useRef(null);S.useEffect(()=>{u.current&&(u.current.indeterminate=!!j)},[j]);const b=r=>{u.current=r,typeof t=="function"?t(r):t&&(t.current=r)};return l.jsx(l.Fragment,{children:l.jsx("input",{type:"checkbox",checked:h,onChange:r=>{f==null||f(r.target.checked)},name:C,required:k,value:d,ref:b,className:_,"aria-controls":m})})}),E=(o,t)=>`${o.replaceAll(" ","-").toLowerCase()}-${t}`,W=5,X=v.forwardRef(({label:o,preValues:t,name:h,onChange:d,error:C,description:f,descriptionAbove:_,errorMessage:k,collapsibleChildren:j=!1,collapsedChildrenCount:m=W,showMoreText:u="Show more",showLessText:b="Show less",...r},A)=>{const g=S.useId(),[D,q]=v.useState(new Set),G=e=>{q(c=>{const s=new Set(c);return s.has(e)?s.delete(e):s.add(e),s})},[x,w]=v.useState(r.value?[...r.value]:[]);v.useEffect(()=>{r.value&&w([...r.value])},[r.value]);const L=e=>{var s;const c=t==null?void 0:t.find(n=>n.value===e);return((s=c==null?void 0:c.children)==null?void 0:s.map(n=>n.value))||[]},T=e=>{const c=t==null?void 0:t.find(s=>s.value===e);return(c==null?void 0:c.children)&&c.children.length>0},U=e=>{const c=L(e);if(c.length===0)return{checked:x.includes(e),indeterminate:!1};const s=c.filter(n=>x.includes(n));return s.length===0?{checked:!1,indeterminate:!1}:s.length===c.length?{checked:!0,indeterminate:!1}:{checked:!1,indeterminate:!0}},R=(e,c)=>{const s=L(e);let n=[...x];s.length===0?c?n.includes(e)||n.push(e):n=n.filter(i=>i!==e):c?s.forEach(i=>{n.includes(i)||n.push(i)}):n=n.filter(i=>!s.includes(i)),w(n),d&&d(n)},H=(e,c)=>{let s=[...x];c?s.includes(e)||s.push(e):s=s.filter(n=>n!==e),w(s),d&&d(s)};return l.jsxs("fieldset",{className:"form-field",children:[l.jsx(M,{required:r.mandatory,children:o}),l.jsx(P,{description:f,descriptionAbove:_,children:t==null?void 0:t.map(e=>{var n;const c=U(e.value),s=T(e.value);return l.jsxs("div",{children:[l.jsx("div",{className:"form-field__checkbox-wrapper",children:l.jsx($,{children:l.jsxs("div",{className:"form-field__checkbox-inner-wrapper",children:[s?l.jsx(Q,{value:e.value,name:h,onCheckedChange:i=>R(e.value,i),checked:c.checked,indeterminate:c.indeterminate,className:"form-field__checkbox",ariaControls:(n=e.children)==null?void 0:n.map(i=>E(i.value,g)).join(" ")}):l.jsx(y,{value:e.value,name:h,onCheckedChange:i=>R(e.value,i),checked:c.checked,ref:A,className:"form-field__checkbox"}),l.jsx("span",{children:e.caption})]})})}),s&&(()=>{const i=e.children||[];if(i.length===0)return null;const N=D.has(e.value),F=j&&i.length>m,z=F&&!N?i.slice(0,m):i,B=i.length-m,I=`children-${E(e.value,g)}`;return l.jsxs("div",{className:"form-field__indent",id:I,children:[z.map(a=>l.jsx("div",{className:"form-field__checkbox-wrapper",children:l.jsx($,{children:l.jsxs("div",{className:"form-field__checkbox-inner-wrapper",children:[l.jsx(y,{value:a.value,name:h,onCheckedChange:J=>H(a.value,J),checked:x.includes(a.value),className:"form-field__checkbox",id:E(a.value,g)}),l.jsx("span",{children:a.caption})]})})},e.value+"-"+a.value)),F&&l.jsx("button",{type:"button",className:"form-field__checkbox-show-more-btn",onClick:()=>G(e.value),"aria-expanded":N,"aria-controls":I,children:N?b:`${u} (${B})`})]})})()]},e.value+"-"+e.caption)})}),C&&k&&l.jsx(K,{children:k})]})});X.displayName="IndeterminateCheckboxGroup";export{X as IndeterminateCheckboxGroup,X as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.