import{c as e,i as t}from"./preload-helper-B45gAKPr.js";import{pn as n,t as r}from"./iframe-CMLjY6eW.js";import{s as i}from"./Input-nC3liV_k.js";import{t as a}from"./input-CCEUBfi5.js";import{n as o,t as s}from"./Select-DMXjzkDO.js";import{a as c,s as l}from"./odata-CaYek0XH.js";import{r as u,t as d}from"./useODataSelectBase-Dvnu67xy.js";import{n as f,t as p}from"./SelectOptionContent-BDd8ltGY.js";function m({odata:e,segment:t,model:n,value:r,dependencies:i,onChange:a}){let o=u({odata:e,segment:t,model:n,value:r?[r]:[],dependencies:i}),s=o.selectedItems[0],c=(0,h.useMemo)(()=>s?[s,...o.filteredItems]:o.filteredItems,[o.filteredItems,s]),l=e=>{a(e?.[o.selectionKey])};return{...o,selectedItem:s,options:c,handleChange:l}}var h,g=t((()=>{h=e(n(),1),d()}));function _(e,t,n){return e?t||Object.keys(e).find(e=>e!==n)||n:t||n}var v,y,b=t((()=>{n(),l(),a(),g(),o(),f(),v=r(),y=({odata:e,segment:t,model:n,size:r,label:a,description:o,disabled:l,value:u,dependencies:d,onChange:f,clearable:h})=>{let g=m({odata:e,segment:t,model:c(n),value:u,dependencies:d,onChange:f});if(g.isLoading)return(0,v.jsx)(i,{size:r,label:a,description:o});let y=t.hideCode??e.hideCode,b=_(g.selectedItem??g.options[0],g.textKey,g.codeKey);return(0,v.jsx)(s,{size:r,label:a,description:o,options:g.options,value:g.selectedItem,onChange:g.handleChange,getOptionKey:e=>e[g.codeKey],getOptionLabel:e=>e[b],getOptionCode:y?void 0:e=>e[g.codeKey],getOptionAriaLabel:e=>y||e[b]===e[g.codeKey]?String(e[b]):`${e[b]} ${e[g.codeKey]}`,renderValue:e=>(0,v.jsx)(p,{label:e[b],code:y?void 0:e[g.codeKey]}),renderOption:e=>(0,v.jsx)(p,{label:e[b],code:y?void 0:e[g.codeKey],highlight:g.debouncedQuery}),searchable:!0,query:g.query,onQuery:g.setQuery,defaultFilter:!1,disabled:l||g.isLoading,placeholder:g.placeholder,loadingState:`Загрузка...`,errorState:g.isError?`Ошибка загрузки`:void 0,emptyState:!g.isLoading&&!g.isError?`Нет данных`:void 0,clearable:h})},y.__docgenInfo={description:``,methods:[],displayName:`ODataSelect`,props:{label:{required:!1,tsType:{name:`ReactNode`},description:``},description:{required:!1,tsType:{name:`string`},description:``},placeholder:{required:!1,tsType:{name:`string`},description:``},disabled:{required:!1,tsType:{name:`boolean`},description:``},size:{required:!1,tsType:{name:`union`,raw:`"xs" | "sm" | "md" | "lg" | "xl"`,elements:[{name:`literal`,value:`"xs"`},{name:`literal`,value:`"sm"`},{name:`literal`,value:`"md"`},{name:`literal`,value:`"lg"`},{name:`literal`,value:`"xl"`}]},description:``},value:{required:!0,tsType:{name:`V`},description:"Если начальное состояние может быть `null | undefined`\nзначит `onChange` тоже должен ументь сбрасывать.\nПоэтому такой контрол явно должен передавать `UiBaseProps<AnyType | undefined>`"},onChange:{required:!0,tsType:{name:`signature`,type:`function`,raw:`(value: T) => void`,signature:{arguments:[{type:{name:`C`},name:`value`}],return:{name:`void`}}},description:``},clearable:{required:!1,tsType:{name:`boolean`},description:``}}}}));export{b as n,y as t};