import{e as p,a9 as k,a7 as q,aa as v,x as C,ab as V,m as u,o as n,w as c,X as f,C as S,n as e,a6 as y,ad as B,p as R,ac as w,ai as $,af as F,W as b,b as P,I as T}from"./BoB2h2qv.js";import{u as E,V as K}from"./D3fadyjq.js";const[I,M]=V("SwitchRoot");var N=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(d,{emit:o}){const a=d,i=o,{disabled:l}=k(a),s=q(a,"modelValue",i,{defaultValue:a.defaultValue,passive:a.modelValue===void 0});function r(){l.value||(s.value=!s.value)}const{forwardRef:m,currentElement:h}=v(),_=E(h),g=C(()=>a.id&&h.value?document.querySelector(`[for="${a.id}"]`)?.innerText:void 0);return M({modelValue:s,toggleCheck:r,disabled:l}),(t,L)=>(n(),u(e(w),y(t.$attrs,{id:t.id,ref:e(m),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(l)?"":void 0,"as-child":t.asChild,as:t.as,disabled:e(l),onClick:r,onKeydown:B(R(r,["prevent"]),["enter"])}),{default:c(()=>[f(t.$slots,"default",{modelValue:e(s)}),e(_)&&t.name?(n(),u(e(K),{key:0,type:"checkbox",name:t.name,disabled:e(l),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"]))}}),j=N,z=p({__name:"SwitchThumb",props:{asChild:{type:Boolean,required:!1},as:{type:null,required:!1,default:"span"}},setup(d){const o=I();return v(),(a,i)=>(n(),u(e(w),{"data-state":e(o).modelValue?.value?"checked":"unchecked","data-disabled":e(o).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"]))}}),H=z;const X=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(d,{emit:o}){const a=d,i=o,l=$(a,"class"),s=F(l,i);return(r,m)=>(n(),u(e(j),y(e(s),{class:e(b)("peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",a.class)}),{default:c(()=>[P(e(H),{class:T(e(b)("pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5"))},{default:c(()=>[f(r.$slots,"thumb")]),_:3},8,["class"])]),_:3},16,["class"]))}});export{X as _};
