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