import{g as j,p as E,a6 as V,bR as J,r as K,bC as O,t as g,aJ as W,j as X,aK as $,k as a,X as b,F as q,a3 as G,c4 as H,V as Q,bS as Y,c5 as Z}from"./index-DHJ8t5vF.js";import{u as ee,a as w,m as ae}from"./VTextField-AERAqvmQ.js";import{a as C,b as te}from"./VCheckboxBtn-AyEh5yQH.js";const le=E({indeterminate:Boolean,inset:Boolean,flat:Boolean,loading:{type:[Boolean,String],default:!1},...ae(),...te()},"VSwitch"),ie=j()({name:"VSwitch",inheritAttrs:!1,props:le(),emits:{"update:focused":e=>!0,"update:modelValue":e=>!0,"update:indeterminate":e=>!0},setup(e,y){let{attrs:S,slots:t}=y;const n=V(e,"indeterminate"),s=V(e,"modelValue"),{loaderClasses:P}=J(e),{isFocused:_,focus:I,blur:F}=ee(e),m=K(),h=O&&window.matchMedia("(forced-colors: active)").matches,x=g(()=>typeof e.loading=="string"&&e.loading!==""?e.loading:e.color),A=W(),B=g(()=>e.id||`switch-${A}`);function R(){n.value&&(n.value=!1)}function p(i){var u,r;i.stopPropagation(),i.preventDefault(),(r=(u=m.value)==null?void 0:u.input)==null||r.click()}return X(()=>{const[i,u]=$(S),r=w.filterProps(e),z=C.filterProps(e);return a(w,b({class:["v-switch",{"v-switch--flat":e.flat},{"v-switch--inset":e.inset},{"v-switch--indeterminate":n.value},P.value,e.class]},i,r,{modelValue:s.value,"onUpdate:modelValue":c=>s.value=c,id:B.value,focused:_.value,style:e.style}),{...t,default:c=>{let{id:D,messagesId:M,isDisabled:N,isReadonly:L,isValid:k}=c;const d={model:s,isValid:k};return a(C,b({ref:m},z,{modelValue:s.value,"onUpdate:modelValue":[o=>s.value=o,R],id:D.value,"aria-describedby":M.value,type:"checkbox","aria-checked":n.value?"mixed":void 0,disabled:N.value,readonly:L.value,onFocus:I,onBlur:F},u),{...t,default:o=>{let{backgroundColorClasses:v,backgroundColorStyles:l}=o;return a("div",{class:["v-switch__track",h?void 0:v.value],style:l.value,onClick:p},[t["track-true"]&&a("div",{key:"prepend",class:"v-switch__track-true"},[t["track-true"](d)]),t["track-false"]&&a("div",{key:"append",class:"v-switch__track-false"},[t["track-false"](d)])])},input:o=>{let{inputNode:v,icon:l,backgroundColorClasses:T,backgroundColorStyles:U}=o;return a(q,null,[v,a("div",{class:["v-switch__thumb",{"v-switch__thumb--filled":l||e.loading},e.inset||h?void 0:T.value],style:e.inset?void 0:U.value},[t.thumb?a(G,{defaults:{VIcon:{icon:l,size:"x-small"}}},{default:()=>[t.thumb({...d,icon:l})]}):a(H,null,{default:()=>[e.loading?a(Y,{name:"v-switch",active:!0,color:k.value===!1?void 0:x.value},{default:f=>t.loader?t.loader(f):a(Z,{active:f.isActive,color:f.color,indeterminate:!0,size:"16",width:"2"},null)}):l&&a(Q,{key:String(l),icon:l,size:"x-small"},null)]})])])}})}})}),{}}});export{ie as V};
