"use strict";const v=require("react/jsx-runtime"),B=require("react"),g=require("../tools/tools.cjs"),D=require("./tree-node.cjs"),O=(y=[],r)=>y.map((n,o)=>{const l=n.id!==void 0?n.id:r!==void 0?`${r}${o}`:`${o}`;return{...n,children:n.children?O(n.children,l):void 0,id:l}}),$=(y,r)=>{const n=r.toLowerCase(),o=l=>{var h;const d=[];for(const t of l){const u=(h=t.label)==null?void 0:h.toLowerCase(),f=(u==null?void 0:u.includes(n))||!1;let c=!f;const T=f;let a;if(t.children&&t.children.length>0){a=o(t.children);const p=a.some(i=>!i.hidden);c=!f&&!p}(!c||a)&&d.push({...t,children:a,hidden:c,highlighted:T})}return d};return o(y)},m=function(r){const{as:n="div",checkbox:o,checkMode:l,className:d,dropOldClass:h,label:t,onCheck:u,onOptionChange:f,onSearch:c,onSelect:T,onToggle:a,options:p,searchTerm:i,style:N,useCustomSearch:b,variables:S,...M}=r,k=B.useMemo(()=>{const e=g.classx(!h&&"",d),s=g.stylex((q,K)=>({tKey:g.convertBsKeyToVar(K)}),S,N);return{className:e,style:s}},[d,h,N,S]),C=B.useMemo(()=>{let e;const s=i==null?void 0:i.trim();return s?e=(c||$)(p,s):e=p,O(e)},[c,p,i]),x=B.useMemo(()=>g.generateTreeNodeMap(C),[C]);return v.jsx(n,{...M,...k,children:C.filter(e=>!e.hidden).map(e=>{const s=`${e.id}`;return v.jsx(D.TreeNode,{checkbox:o,checkMode:l,label:t,level:0,nodeKey:s,onCheck:u,onOptionChange:f,onSelect:T,onToggle:a,option:e,options:C,parentKey:s,treeMap:x,useCustomSearch:b},e.id)})})};m.Node=D.TreeNode;m.displayName="BRL.Tree";exports.Tree=m;
//# sourceMappingURL=tree.cjs.map
