import{n as e}from"./rolldown-runtime-C0FnF6B9.js";import{t}from"./react-C21x__mS.js";import{n}from"./iframe-DaN-XFub.js";import{a as r,n as i,o as a,t as o}from"./MultiSelectToken-fjW8p4YG.js";import{a as s,c,i as l,n as u,r as d,s as f,t as p,u as m}from"./TreePickerBase-ycYQYQgi.js";function h(e,t){if(e.size!==0){if(e.size===1){let n=t.nodeById.get([...e][0]);return n?n.label:void 0}return`${e.size} элементов`}}function g(e,t,n){let r=c(e,n),i=c(t,n);return r.size===i.size&&[...r].every(e=>i.has(e))}function _({label:e,description:t,disabled:n,placeholder:r=`Выберите значения`,size:i,nodes:u,value:_,onChange:b,query:x,defaultQuery:S,onQuery:C,isLoading:w,error:T,optionsLayout:E=`tree`,defaultExpandedCodeKeys:D}){let[O,k]=(0,v.useState)(!1),A=(0,v.useMemo)(()=>d(u),[u]),{draftValue:j,setDraftValue:M,prepareOpen:N}=a({value:_,open:O,onCommit:b,isEqual:(e,t)=>g(e,t,A)}),P=O?j:_,F=(0,v.useMemo)(()=>c(P,A),[P,A]),I=(0,v.useMemo)(()=>s(F,A),[F,A]),L=(0,v.useMemo)(()=>h(F,A),[F,A]);return(0,y.jsx)(p,{label:e,description:t,disabled:n,placeholder:r,size:i,nodes:u,selectedIds:I.selectedIds,partialIds:I.partialIds,selectionMode:`multi`,optionsLayout:E,defaultExpandedCodeKeys:D,open:O,onOpenChange:e=>{e&&!O&&N(),k(e)},bulkActions:{onSelectAll:()=>{M(m(l(A),A))},onDeselectAll:()=>M({})},triggerMode:`search`,selectedSummary:L?(0,y.jsx)(o,{value:L}):void 0,query:x,defaultQuery:S,onQuery:C,onNodeActivate:e=>{M(t=>f(t,e.id,A))},onClearSelection:()=>{M({}),O||b({})},isLoading:w,error:T})}var v,y;function b(){return(b=e((()=>{v=t(),i(),r(),u(),y=n(),_.__docgenInfo={description:``,methods:[],displayName:`TreeMultiSelect`,props:{nodes:{required:!0,tsType:{name:`unknown`},description:``},placeholder:{required:!1,tsType:{name:`string`},description:``,defaultValue:{value:`"Выберите значения"`,computed:!1}},query:{required:!1,tsType:{name:`string`},description:``},defaultQuery:{required:!1,tsType:{name:`string`},description:``},onQuery:{required:!1,tsType:{name:`signature`,type:`function`,raw:`(value: string) => void`,signature:{arguments:[{type:{name:`string`},name:`value`}],return:{name:`void`}}},description:``},isLoading:{required:!1,tsType:{name:`boolean`},description:``},error:{required:!1,tsType:{name:`string`},description:``},optionsLayout:{required:!1,tsType:{name:`union`,raw:`"tree" | "columns"`,elements:[{name:`literal`,value:`"tree"`},{name:`literal`,value:`"columns"`}]},description:`Определяет обычное раскрываемое дерево или полностью открытый адаптивный набор колонок.`,defaultValue:{value:`"tree"`,computed:!1}},defaultExpandedCodeKeys:{required:!1,tsType:{name:`unknown`},description:"Ключи уровней, узлы которых раскрываются до ручного действия пользователя.\nВ режиме `columns` дерево по-прежнему отображается полностью раскрытым."}},composes:[`Omit`]}})))()}export{b as n,_ as t};