import{g as J,p as Q,j as k,d3 as $,cP as G,J as g,d4 as K,t as w,cU as W,n as X,cV as Y,cQ as C,o as l,ae as y,ap as Z,cR as ee,E as n,q as b,r as S,an as ae,cO as te,aL as le,d5 as se,b8 as oe,ah as ne}from"./index-Cf2d7tRd.js";import{V as P,m as ie}from"./VSelectionControl-MlceO9op.js";const re=Q({indeterminate:Boolean,inset:Boolean,flat:Boolean,loading:{type:[Boolean,String],default:!1},...ee(),...ie()},"VSwitch"),de=J()({name:"VSwitch",inheritAttrs:!1,props:re(),emits:{"update:focused":e=>!0,"update:modelValue":e=>!0,"update:indeterminate":e=>!0},setup(e,_){let{attrs:A,slots:a}=_;const i=k(e,"indeterminate"),s=k(e,"modelValue"),{loaderClasses:I}=$(e),{isFocused:R,focus:x,blur:B}=G(e),v=g(),m=g(),h=K&&window.matchMedia("(forced-colors: active)").matches,F=w(()=>typeof e.loading=="string"&&e.loading!==""?e.loading:e.color),p=W(),z=w(()=>e.id||`switch-${p}`);function M(){i.value&&(i.value=!1)}function D(r){r.stopPropagation(),r.preventDefault(),v.value?.input?.click()}return X(()=>{const[r,T]=Y(A),U=C.filterProps(e),L=P.filterProps(e);return l(C,y({ref:m,class:["v-switch",{"v-switch--flat":e.flat},{"v-switch--inset":e.inset},{"v-switch--indeterminate":i.value},I.value,e.class]},r,U,{modelValue:s.value,"onUpdate:modelValue":c=>s.value=c,id:z.value,focused:R.value,style:e.style}),{...a,default:c=>{let{id:N,messagesId:E,isDisabled:O,isReadonly:j,isValid:V}=c;const u={model:s,isValid:V};return l(P,y({ref:v},L,{modelValue:s.value,"onUpdate:modelValue":[o=>s.value=o,M],id:N.value,"aria-describedby":E.value,type:"checkbox","aria-checked":i.value?"mixed":void 0,disabled:O.value,readonly:j.value,onFocus:x,onBlur:B},T),{...a,default:o=>{let{backgroundColorClasses:d,backgroundColorStyles:t}=o;return n("div",{class:S(["v-switch__track",h?void 0:d.value]),style:b(t.value),onClick:D},[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:q,backgroundColorStyles:H}=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:q.value]),style:b(e.inset?void 0:H.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:V.value===!1?void 0:F.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};
