import{j as e,r as c}from"./iframe-p4aYZyoq.js";import{c as L}from"./index-Dx18ixSn.js";import{C as N}from"./chip-uVzAi-nV.js";import{S as j}from"./uniparc-CR_5LT77.js";import{S as T}from"./information-CdWOuYio.js";import{S as w}from"./help-BLfYd5wX.js";import{S as C}from"./evidence-tag-Bqx2a0m2.js";import"./preload-helper-BDBacUwf.js";import"./times-DeY5Bu0x.js";const y=({header:t,statusOff:d,statusLoading:u,statusOn:g,icon:p,checked:s,isLoading:o=!1,onChange:m,ariaLabel:f="Toggle",disabled:a=!1,className:h="",...n})=>{const l=s&&!o,r=o&&u||s&&g||d,_=()=>{a||m(!s)};return e.jsx("button",{type:"button",className:L("toggle",{"toggle--on":l,"toggle--loading":o,"toggle--disabled":a},h),role:"switch","aria-checked":s,"aria-label":f,disabled:a,onClick:_,...n,children:e.jsxs("div",{className:"toggle__content",children:[e.jsx("div",{className:"toggle__icon",children:p}),e.jsxs("div",{className:"toggle__text",children:[e.jsxs("div",{className:"toggle__header",children:[t,l&&e.jsx(N,{compact:!0,className:"toggle__header__chip",tabIndex:-1,"aria-hidden":"true",asSpan:!0,children:"ON"})]}),e.jsx("div",{className:"toggle__status",children:r})]}),e.jsx("div",{className:"toggle__switch","aria-hidden":"true",children:e.jsx("span",{className:"slider"})})]})})};try{toggleswitch.displayName="toggleswitch",toggleswitch.__docgenInfo={description:"",displayName:"toggleswitch",props:{header:{defaultValue:null,description:"",name:"header",required:!0,type:{name:"string"}},statusOff:{defaultValue:null,description:"",name:"statusOff",required:!0,type:{name:"string"}},statusLoading:{defaultValue:null,description:"",name:"statusLoading",required:!0,type:{name:"string"}},statusOn:{defaultValue:null,description:"",name:"statusOn",required:!0,type:{name:"string"}},icon:{defaultValue:null,description:"",name:"icon",required:!0,type:{name:"ReactNode"}},checked:{defaultValue:null,description:"",name:"checked",required:!0,type:{name:"boolean"}},isLoading:{defaultValue:{value:"false"},description:"",name:"isLoading",required:!1,type:{name:"boolean"}},onChange:{defaultValue:null,description:"",name:"onChange",required:!0,type:{name:"(checked: boolean) => void"}},ariaLabel:{defaultValue:{value:"Toggle"},description:"",name:"ariaLabel",required:!1,type:{name:"string"}},className:{defaultValue:{value:""},description:"",name:"className",required:!1,type:{name:"string"}}}}}catch{}const I=t=>c.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:7,viewBox:"0 0 88 84",...t},c.createElement("path",{d:"M75.6 3.5v17.1M67 12.1h17.1M12 63.4v17.1m-8.6-8.6h17.1M43 3.5l9.8 29.3L77.2 42l-24.4 9.2L43 80.5l-9.8-29.3L8.8 42l24.4-9.2z"})),{fn:k}=__STORYBOOK_MODULE_TEST__,E=2e3,V=["var(--fr--color-purple-mid)","var(--fr--color-uniparc-dark)","var(--fr--color-sapphire-blue)"],v={AiAnnotations:e.jsx(I,{}),UniParc:e.jsx(j,{}),EvidenceTag:e.jsx(C,{}),Help:e.jsx(w,{}),Information:e.jsx(T,{})},z={title:"Forms/ToggleSwitch",component:y,argTypes:{disabled:{control:"boolean"},ariaLabel:{control:"text"},header:{control:"text"},statusOn:{control:"text"},statusOff:{control:"text"},statusLoading:{control:"text"},baseColor:{control:"select",name:"--toggle-on-base",options:V},icon:{options:Object.keys(v),mapping:v,control:{type:"select"}}},args:{disabled:!1,ariaLabel:"ToggleSwitch",header:"AI annotations",statusOn:"Showing AI predictions",statusOff:"Click to enable",statusLoading:"Loading AI predictions…",baseColor:"var(--fr--color-purple-mid)",icon:e.jsx(j,{}),onChange:k()}},q=t=>{const{disabled:d,ariaLabel:u,header:g,statusOn:p,statusOff:s,statusLoading:o,baseColor:m,icon:f,onChange:a}=t,[h,n]=c.useState(!1),[l,r]=c.useState(!1),_=x=>{a==null||a(x),x?(r(!0),setTimeout(()=>{n(!0),r(!1)},E)):(n(!1),r(!1))};return e.jsx(y,{checked:h,disabled:d,ariaLabel:u,header:g,statusOn:p,statusOff:s,statusLoading:o,onChange:_,icon:f,isLoading:l,style:{"--toggle-on-base":m,maxWidth:250}})},i={render:t=>e.jsx(q,{...t})};var O,S,b;i.parameters={...i.parameters,docs:{...(O=i.parameters)==null?void 0:O.docs,source:{originalSource:`{
  render: args => <ToggleSwitchStoryWrapper {...args} />
}`,...(b=(S=i.parameters)==null?void 0:S.docs)==null?void 0:b.source}}};const F=["Default"];export{i as Default,F as __namedExportsOrder,z as default};
