import{e as X,ce as Z,i as g,s as _,ap as x,bv as N,b1 as w,ah as V,O as S,bw as P,cf as B,f as L,at as ee,ax as ae,y as ie,by as te,bx as ne,j as d,z as E,a0 as se,A as M,W as le,a5 as oe,o as i,c as v,G as T,l as a,D as u,M as ce,b as c,w as p,k as b,E as h,d as r,t as C,a as re,bg as ue,a3 as O,a1 as de,ab as ve,p as fe,ac as pe,cg as F,b0 as he,Y as me}from"./admin.js?ver=1.3.1";const be=X({modelValue:{type:[Boolean,String,Number],default:!1},disabled:Boolean,loading:Boolean,size:{type:String,validator:Z},width:{type:[String,Number],default:""},inlinePrompt:Boolean,inactiveActionIcon:{type:g},activeActionIcon:{type:g},activeIcon:{type:g},inactiveIcon:{type:g},activeText:{type:String,default:""},inactiveText:{type:String,default:""},activeValue:{type:[Boolean,String,Number],default:!0},inactiveValue:{type:[Boolean,String,Number],default:!1},name:{type:String,default:""},validateEvent:{type:Boolean,default:!0},beforeChange:{type:_(Function)},id:String,tabindex:{type:[String,Number]},...x(["ariaLabel"])}),ye={[N]:l=>w(l)||V(l)||S(l),[P]:l=>w(l)||V(l)||S(l),[B]:l=>w(l)||V(l)||S(l)},U="ElSwitch",ke=L({name:U}),Ie=L({...ke,props:be,emits:ye,setup(l,{expose:G,emit:f}){const n=l,{formItem:y}=ee(),W=ae(),t=ie("switch"),{inputId:$}=te(n,{formItemContext:y}),k=ne(d(()=>n.loading)),A=E(n.modelValue!==!1),m=E(),j=E(),H=d(()=>[t.b(),t.m(W.value),t.is("disabled",k.value),t.is("checked",s.value)]),R=d(()=>[t.e("label"),t.em("label","left"),t.is("active",!s.value)]),Y=d(()=>[t.e("label"),t.em("label","right"),t.is("active",s.value)]),q=d(()=>({width:se(n.width)}));M(()=>n.modelValue,()=>{A.value=!0});const z=d(()=>A.value?n.modelValue:!1),s=d(()=>z.value===n.activeValue);[n.activeValue,n.inactiveValue].includes(z.value)||(f(N,n.inactiveValue),f(P,n.inactiveValue),f(B,n.inactiveValue)),M(s,e=>{var o;m.value.checked=e,n.validateEvent&&((o=y==null?void 0:y.validate)==null||o.call(y,"change").catch(Q=>le()))});const I=()=>{const e=s.value?n.inactiveValue:n.activeValue;f(N,e),f(P,e),f(B,e),pe(()=>{m.value.checked=s.value})},D=()=>{if(k.value)return;const{beforeChange:e}=n;if(!e){I();return}const o=e();[F(o),w(o)].includes(!0)||he(U,"beforeChange must return type `Promise<boolean>` or `boolean`"),F(o)?o.then(K=>{K&&I()}).catch(K=>{}):o&&I()},J=()=>{var e,o;(o=(e=m.value)==null?void 0:e.focus)==null||o.call(e)};return oe(()=>{m.value.checked=s.value}),G({focus:J,checked:s}),(e,o)=>(i(),v("div",{class:u(a(H)),onClick:ve(D,["prevent"])},[T("input",{id:a($),ref_key:"input",ref:m,class:u(a(t).e("input")),type:"checkbox",role:"switch","aria-checked":a(s),"aria-disabled":a(k),"aria-label":e.ariaLabel,name:e.name,"true-value":e.activeValue,"false-value":e.inactiveValue,disabled:a(k),tabindex:e.tabindex,onChange:I,onKeydown:ce(D,["enter"])},null,42,["id","aria-checked","aria-disabled","aria-label","name","true-value","false-value","disabled","tabindex","onKeydown"]),!e.inlinePrompt&&(e.inactiveIcon||e.inactiveText)?(i(),v("span",{key:0,class:u(a(R))},[e.inactiveIcon?(i(),c(a(h),{key:0},{default:p(()=>[(i(),c(b(e.inactiveIcon)))]),_:1})):r("v-if",!0),!e.inactiveIcon&&e.inactiveText?(i(),v("span",{key:1,"aria-hidden":a(s)},C(e.inactiveText),9,["aria-hidden"])):r("v-if",!0)],2)):r("v-if",!0),T("span",{ref_key:"core",ref:j,class:u(a(t).e("core")),style:de(a(q))},[e.inlinePrompt?(i(),v("div",{key:0,class:u(a(t).e("inner"))},[e.activeIcon||e.inactiveIcon?(i(),c(a(h),{key:0,class:u(a(t).is("icon"))},{default:p(()=>[(i(),c(b(a(s)?e.activeIcon:e.inactiveIcon)))]),_:1},8,["class"])):e.activeText||e.inactiveText?(i(),v("span",{key:1,class:u(a(t).is("text")),"aria-hidden":!a(s)},C(a(s)?e.activeText:e.inactiveText),11,["aria-hidden"])):r("v-if",!0)],2)):r("v-if",!0),T("div",{class:u(a(t).e("action"))},[e.loading?(i(),c(a(h),{key:0,class:u(a(t).is("loading"))},{default:p(()=>[re(a(ue))]),_:1},8,["class"])):a(s)?O(e.$slots,"active-action",{key:1},()=>[e.activeActionIcon?(i(),c(a(h),{key:0},{default:p(()=>[(i(),c(b(e.activeActionIcon)))]),_:1})):r("v-if",!0)]):a(s)?r("v-if",!0):O(e.$slots,"inactive-action",{key:2},()=>[e.inactiveActionIcon?(i(),c(a(h),{key:0},{default:p(()=>[(i(),c(b(e.inactiveActionIcon)))]),_:1})):r("v-if",!0)])],2)],6),!e.inlinePrompt&&(e.activeIcon||e.activeText)?(i(),v("span",{key:1,class:u(a(Y))},[e.activeIcon?(i(),c(a(h),{key:0},{default:p(()=>[(i(),c(b(e.activeIcon)))]),_:1})):r("v-if",!0),!e.activeIcon&&e.activeText?(i(),v("span",{key:1,"aria-hidden":!a(s)},C(e.activeText),9,["aria-hidden"])):r("v-if",!0)],2)):r("v-if",!0)],10,["onClick"]))}});var ge=fe(Ie,[["__file","switch.vue"]]);const Ve=me(ge);export{Ve as E};
