import{n as e,o as t,r as n}from"./rolldown-runtime-C0FnF6B9.js";import{t as r}from"./react-C21x__mS.js";import{n as i,t as a}from"./circle-check-VtVMsaJJ.js";import{i as o,n as s,r as c}from"./iframe-DaN-XFub.js";import{a as l,i as u}from"./utils-DUM89eIj.js";import{n as d,t as f}from"./ui.module-DoMIk8Oc.js";var p,m;function h(){return(h=e((()=>{o(),p=[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M4.929 4.929 19.07 19.071`,key:`196cmz`}]],m=c(`ban`,p)})))()}var g,_,v,y,b;function x(){return(x=e((()=>{g=`Or5LYA`,_=`w0AMfA`,v=`P1x4lq`,y=`-ZVOZo`,b={switchWrapper:g,switch:`qge3io`,iconWrapper:_,auto:v,checked:y}})))()}function S(e){let{label:t,description:n,disabled:r,checkedIcon:i=(0,w.jsx)(a,{}),uncheckedIcon:o=(0,w.jsx)(m,{}),className:s,type:c,id:u,size:f,placeholder:p,onChange:h,value:g,triState:_,...v}=e,y=(0,C.useId)(),x=u??y,S=n?`${x}-description`:void 0,T=t?`${x}-label`:void 0,E=()=>{if(!e.triState){e.onChange(!e.value);return}if(e.value===void 0){e.onChange(!0);return}if(e.value===!0){e.onChange(!1);return}e.value===!1&&e.onChange(void 0)},D=typeof e.value==`boolean`&&e.value,O=e.triState&&typeof e.value!=`boolean`,k=v[`aria-label`]??(t?void 0:`Переключатель`);return(0,w.jsxs)(`div`,{className:l(d.uiElement,r&&d.disabled),"aria-disabled":r||void 0,children:[t&&(0,w.jsxs)(`div`,{id:T,className:d.uiLabel,children:[t,`:`]}),n&&(0,w.jsx)(`p`,{id:S,className:d.uiDescription,children:n}),(0,w.jsx)(`button`,{...v,id:x,type:c??`button`,role:`switch`,disabled:r,"aria-checked":D,"aria-describedby":S,"aria-labelledby":T,"aria-label":k,"aria-disabled":r,"data-ui":`switch`,"data-action":`toggle-switch`,onClick:E,className:l(d.uiInputControl,b.switchWrapper,s),children:(0,w.jsx)(`div`,{className:b.switch,"data-disabled":r||void 0,children:O?(0,w.jsx)(`div`,{className:l(b.iconWrapper,b.auto,b.checked),children:`Auto`}):(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(`div`,{className:l(b.iconWrapper,!e.value&&b.checked),children:o}),(0,w.jsx)(`div`,{className:l(b.iconWrapper,e.value&&b.checked),children:i})]})})})]})}var C,w;function T(){return(T=e((()=>{C=t(r(),1),u(),h(),i(),f(),x(),w=s(),S.__docgenInfo={description:`Переключатель boolean-состояния в виде слайдера. Подходит для быстрых настроек и включения/отключения опций.`,methods:[],displayName:`Switch`}})))()}var E=n({BiState:()=>A,Disabled:()=>M,TriState:()=>j,__namedExportsOrder:()=>N,default:()=>k}),D,O,k,A,j,M,N;function P(){return(P=e((()=>{D=r(),T(),O=s(),k={title:`Shared/UI/Switch`,component:S,args:{label:`Режим обработки`,description:`Переключение состояния`,value:!1,onChange:()=>{},triState:!1,disabled:!1},parameters:{atomicCanvas:!0,layout:`padded`},argTypes:{label:{description:`Заголовок переключателя.`,control:`text`},description:{description:`Описание под заголовком.`,control:`text`},value:{description:"Текущее значение (`boolean` или `undefined` в tri-state).",control:!1},onChange:{description:`Вызывается при изменении состояния.`,control:!1},triState:{description:"Включает трехсостоянный режим (`undefined → true → false`).",control:`boolean`},checkedIcon:{description:"Кастомная иконка для состояния `true`.",control:!1},uncheckedIcon:{description:"Кастомная иконка для состояния `false`.",control:!1},disabled:{description:`Блокирует переключение.`,control:`boolean`}}},A={render:e=>{let[t,n]=(0,D.useState)(!1);return(0,O.jsx)(S,{...e,value:t,onChange:n,triState:!1})}},j={render:e=>{let[t,n]=(0,D.useState)(void 0);return(0,O.jsxs)(`div`,{style:{display:`grid`,gap:8},children:[(0,O.jsx)(S,{...e,value:t,onChange:n,triState:!0}),(0,O.jsxs)(`div`,{children:[`Текущее значение: `,String(t)]})]})},args:{triState:!0,value:void 0}},M={args:{disabled:!0,value:!0}},A.parameters={...A.parameters,docs:{...A.parameters?.docs,source:{originalSource:`{
  render: args => {
    const [value, setValue] = useState(false);
    return <Switch {...args} value={value} onChange={setValue} triState={false} />;
  }
}`,...A.parameters?.docs?.source}}},j.parameters={...j.parameters,docs:{...j.parameters?.docs,source:{originalSource:`{
  render: args => {
    const [value, setValue] = useState<boolean | undefined>(undefined);
    return <div style={{
      display: "grid",
      gap: 8
    }}>
                <Switch {...args} value={value} onChange={setValue} triState />
                <div>Текущее значение: {String(value)}</div>
            </div>;
  },
  args: {
    triState: true,
    value: undefined
  }
}`,...j.parameters?.docs?.source}}},M.parameters={...M.parameters,docs:{...M.parameters?.docs,source:{originalSource:`{
  args: {
    disabled: true,
    value: true
  }
}`,...M.parameters?.docs?.source}}},N=[`BiState`,`TriState`,`Disabled`]})))()}export{P as a,j as i,M as n,E as r,A as t};