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