import{a as e,c as t,i as n}from"./preload-helper-B45gAKPr.js";import{pn as r,t as i}from"./iframe-NOj5DEP4.js";import{a,i as o,n as s,o as c,s as l}from"./odataStoryFixtures-8tBMjf5a.js";import{n as u,t as d}from"./useODataTreeData-DTafeDQZ.js";import{n as f,t as p}from"./TreeSelect-CPMeOcSE.js";function m({label:e,description:t,disabled:n,size:r,placeholder:i,query:a,defaultQuery:o,onQuery:s,value:c,onChange:l,odata:d,segments:f,model:m,clearable:g}){let _=u({odata:d,segments:f,model:m});return(0,h.jsx)(p,{label:e,description:t,disabled:n||_.isLoading,size:r,placeholder:i??_.placeholder,nodes:_.nodes,value:c,onChange:l,query:a,defaultQuery:o,onQuery:s,isLoading:_.isLoading,error:_.isError?`Ошибка загрузки`:void 0,clearable:g})}var h,g=n((()=>{d(),f(),h=i(),m.__docgenInfo={description:``,methods:[],displayName:`ODataTreeSelect`,props:{model:{required:!1,tsType:{name:`ODataDependentBaseProps["model"]`,raw:`ODataDependentBaseProps["model"]`},description:``},placeholder:{required:!1,tsType:{name:`string`},description:``},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:``},clearable:{required:!1,tsType:{name:`boolean`},description:``}},composes:[`Omit`]}})),_=e({Basic:()=>S,ErrorState:()=>T,LoadingState:()=>w,SelectParent:()=>C,__namedExportsOrder:()=>E,default:()=>x});function v({initialValue:e,odata:t=s,segments:n=c,label:r=`ODataTreeSelect`,description:i}){let[a,o]=(0,y.useState)(e);return(0,b.jsxs)(`div`,{style:{display:`grid`,gap:12,maxWidth:520},children:[(0,b.jsx)(m,{label:r,description:i,odata:t,segments:n,value:a,onChange:o}),(0,b.jsxs)(`div`,{style:{fontSize:`var(--font-size-sm)`,color:`var(--content-1)`},children:[`Текущее значение: `,a?`${a.codeKey}=${a.value}`:`пусто`]})]})}var y,b,x,S,C,w,T,E,D=n((()=>{y=t(r(),1),o(),g(),b=i(),x={title:`Shared/UI/ODataTreeSelect`,component:m,decorators:[l],parameters:{atomicCanvas:!0,layout:`padded`,odataMockMode:`success`},args:{label:`OData дерево`,description:`Single-select поверх одной OData-цепочки.`,odata:s,segments:c,value:void 0,onChange:()=>{}},argTypes:{segments:{control:!1},value:{control:!1},onChange:{control:!1}}},S={render:()=>(0,b.jsx)(v,{initialValue:{codeKey:`OWNER`,value:a.owner}})},C={render:()=>(0,b.jsx)(v,{label:`Выбор родителя`,description:`Проверка выбора узла верхнего уровня из OData-дерева.`,initialValue:{codeKey:`REGION`,value:a.region}})},w={parameters:{odataMockMode:`loading`},render:()=>(0,b.jsx)(v,{description:`Сценарий загрузки дерева.`})},T={parameters:{odataMockMode:`collectionError`},render:()=>(0,b.jsx)(v,{description:`Сценарий ошибки загрузки дерева.`})},S.parameters={...S.parameters,docs:{...S.parameters?.docs,source:{originalSource:`{
  render: () => <StatefulODataTreeSelect initialValue={{
    codeKey: "OWNER",
    value: storyValues.owner
  }} />
}`,...S.parameters?.docs?.source}}},C.parameters={...C.parameters,docs:{...C.parameters?.docs,source:{originalSource:`{
  render: () => <StatefulODataTreeSelect label="Выбор родителя" description="Проверка выбора узла верхнего уровня из OData-дерева." initialValue={{
    codeKey: "REGION",
    value: storyValues.region
  }} />
}`,...C.parameters?.docs?.source}}},w.parameters={...w.parameters,docs:{...w.parameters?.docs,source:{originalSource:`{
  parameters: {
    odataMockMode: "loading"
  },
  render: () => <StatefulODataTreeSelect description="Сценарий загрузки дерева." />
}`,...w.parameters?.docs?.source}}},T.parameters={...T.parameters,docs:{...T.parameters?.docs,source:{originalSource:`{
  parameters: {
    odataMockMode: "collectionError"
  },
  render: () => <StatefulODataTreeSelect description="Сценарий ошибки загрузки дерева." />
}`,...T.parameters?.docs?.source}}},E=[`Basic`,`SelectParent`,`LoadingState`,`ErrorState`]}));D();export{S as Basic,T as ErrorState,w as LoadingState,C as SelectParent,E as __namedExportsOrder,x as default,D as n,_ as t};