import{h as p,ac as _,b0 as q,ag as V,af as v,k as C,v as u,o as n,w as c,x as f,I as S,g as e,ad as y,a6 as B,M as R,ae as k,ai as $,aT as T,b as F,y as P,N as b}from"./BzhixHsn.js";import{u as E}from"./vJ3Jskde.js";import{V as K}from"./BkS3akZz.js";const[M,N]=_("SwitchRoot");var x=p({__name:"SwitchRoot",props:{defaultValue:{type:Boolean,required:!1},modelValue:{type:[Boolean,null],required:!1,default:void 0},disabled:{type:Boolean,required:!1},id:{type:String,required:!1},value:{type:String,required:!1,default:"on"},asChild:{type:Boolean,required:!1},as:{type:null,required:!1,default:"button"},name:{type:String,required:!1},required:{type:Boolean,required:!1}},emits:["update:modelValue"],setup(o,{emit:l}){const a=o,i=l,{disabled:d}=q(a),s=V(a,"modelValue",i,{defaultValue:a.defaultValue,passive:a.modelValue===void 0});function r(){d.value||(s.value=!s.value)}const{forwardRef:h,currentElement:m}=v(),w=E(m),g=C(()=>a.id&&m.value?document.querySelector(`[for="${a.id}"]`)?.innerText:void 0);return N({modelValue:s,toggleCheck:r,disabled:d}),(t,H)=>(n(),u(e(k),y(t.$attrs,{id:t.id,ref:e(h),role:"switch",type:t.as==="button"?"button":void 0,value:t.value,"aria-label":t.$attrs["aria-label"]||g.value,"aria-checked":e(s),"aria-required":t.required,"data-state":e(s)?"checked":"unchecked","data-disabled":e(d)?"":void 0,"as-child":t.asChild,as:t.as,disabled:e(d),onClick:r,onKeydown:B(R(r,["prevent"]),["enter"])}),{default:c(()=>[f(t.$slots,"default",{modelValue:e(s)}),e(w)&&t.name?(n(),u(e(K),{key:0,type:"checkbox",name:t.name,disabled:e(d),required:t.required,value:t.value,checked:!!e(s)},null,8,["name","disabled","required","value","checked"])):S("v-if",!0)]),_:3},16,["id","type","value","aria-label","aria-checked","aria-required","data-state","data-disabled","as-child","as","disabled","onKeydown"]))}}),z=x,I=p({__name:"SwitchThumb",props:{asChild:{type:Boolean,required:!1},as:{type:null,required:!1,default:"span"}},setup(o){const l=M();return v(),(a,i)=>(n(),u(e(k),{"data-state":e(l).modelValue?.value?"checked":"unchecked","data-disabled":e(l).disabled.value?"":void 0,"as-child":a.asChild,as:a.as},{default:c(()=>[f(a.$slots,"default")]),_:3},8,["data-state","data-disabled","as-child","as"]))}}),j=I;const D=p({__name:"Switch",props:{defaultValue:{type:Boolean},modelValue:{type:[Boolean,null]},disabled:{type:Boolean},id:{},value:{},asChild:{type:Boolean},as:{},name:{},required:{type:Boolean},class:{}},emits:["update:modelValue"],setup(o,{emit:l}){const a=o,i=l,d=$(a,"class"),s=T(d,i);return(r,h)=>(n(),u(e(z),y({"data-slot":"switch"},e(s),{class:e(b)("peer data-[state=checked]:bg-primary data-[state=unchecked]:bg-input focus-visible:border-ring focus-visible:ring-ring/50 dark:data-[state=unchecked]:bg-input/80 inline-flex h-[1.15rem] w-8 shrink-0 items-center rounded-full border border-transparent shadow-xs transition-all outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",a.class)}),{default:c(()=>[F(e(j),{"data-slot":"switch-thumb",class:P(e(b)("bg-background dark:data-[state=unchecked]:bg-foreground dark:data-[state=checked]:bg-primary-foreground pointer-events-none block size-4 rounded-full ring-0 transition-transform data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0"))},{default:c(()=>[f(r.$slots,"thumb")]),_:3},8,["class"])]),_:3},16,["class"]))}});export{D as _};
