import{p as L,q as P,a2 as u,r as g,s as T,k as o,a3 as i,S as v,K as q,a4 as z,t as W,h as K,o as I,v as n,u as l,w as h,b as F,c as H,A as J,a as Q,x as B,D as R}from"./index-DRopsKkO.js";import{b as X}from"./index-_-ijfL1Q.js";import{_ as Y}from"./ULabel.vue_vue_type_script_setup_true_lang-B9XE8rwf.js";const N={checkboxLabel:"{ULabel}",checkbox:{base:`
      border border-gray-300 rounded-dynamic-sm bg-white cursor-pointer transition
      hover:border-gray-400
      active:border-{color}-600 active:bg-{color}-200
      checked:text-{color}-600
      focus:ring-0 focus:ring-offset-0
      focus-visible:outline-{color}-600 focus-visible:outline-dynamic focus-visible:outline-offset-2
      disabled:border-gray-300 disabled:bg-gray-100 disabled:cursor-not-allowed
      disabled:checked:bg-gray-400 disabled:checked:border-transparent
    `,variants:{size:{sm:"size-4",md:"size-5",lg:"size-6"},color:{grayscale:"focus-visible:outline-gray-900 active:bg-gray-200 checked:text-gray-900"},error:{true:"!border-red-600 focus:outline-red-600"}}},iconWrapper:{base:`
      flex items-center justify-center absolute rounded-dynamic-sm cursor-pointer transition
      bg-{color}-600 hover:bg-{color}-700 active:bg-{color}-800
    `,variants:{size:{sm:"size-4",md:"size-5",lg:"size-6"},color:{grayscale:"bg-gray-900 hover:bg-gray-800 active:bg-gray-700"},disabled:{true:"!border-gray-400 !bg-gray-400 cursor-not-allowed"}}},checkedIcon:{base:"{UIcon}",defaults:{size:{sm:"2xs",md:"xs",lg:"sm"}}},defaults:{color:"brand",size:"md",labelAlign:"right",partial:!1,disabled:!1,partiallyCheckedIcon:"remove",checkedIcon:"check"}},Z="UCheckbox",ee=["id","value","true-value","false-value","name","checked","disabled","data-test"],ae=["for"],te=L({inheritAttrs:!1,__name:"UCheckbox",props:P({modelValue:{type:[Boolean,String,Number,Array,Object]},value:{type:[Boolean,String,Number,Array,Object]},trueValue:{type:[Boolean,String,Number,Array,Object]},falseValue:{type:[Boolean,String,Number,Array,Object]},name:{},label:{},description:{},error:{},labelAlign:{},color:{},size:{},disabled:{type:Boolean},partial:{type:Boolean},id:{},config:{},dataTest:{}},{...R(N,Z),modelValue:!1,value:"",trueValue:!0,falseValue:!1,label:""}),emits:["update:modelValue","input"],setup(G,{emit:S}){const d=u("getCheckboxGroupName",null),w=u("getCheckboxGroupCheckedItems",null),p=u("setCheckboxGroupCheckedItems",null),j=u("getCheckboxGroupColor",null),O=u("getCheckboxSize",null),a=G,k=S,y=g(""),b=g(a.size),C=g(a.color),m=a.id||T(),f=o(()=>!Array.isArray(a.modelValue)),r=o(()=>!!i(d)),t=o(()=>f.value&&!r.value?v(a.modelValue,a.trueValue):Array.isArray(c.value)?c.value.findIndex(e=>v(e,s.value))!==-1:!1),s=o(()=>a.value===""?"on":a.value),c=o(()=>r.value?i(w):a.modelValue);q(()=>{y.value=r.value&&d?i(d):a.name}),z(()=>C.value=i(j)||a.color),z(()=>b.value=i(O)||a.size);function _(){let e;f.value&&(e=t.value?a.falseValue:a.trueValue),(!f.value||r.value)&&(Array.isArray(c.value)?e=t.value?c.value.filter(A=>!v(s.value,A)):[...c.value,s.value]:e=t.value?[s.value]:[]),r.value&&p&&p(e),k("update:modelValue",e),k("input",e)}const E=o(()=>({color:C.value,size:b.value,label:!!a.label,error:!!a.error})),{getDataTest:V,config:x,checkboxAttrs:U,iconWrapperAttrs:D,checkboxLabelAttrs:M,checkedIconAttrs:$}=W(N,E);return(e,A)=>(I(),K(Y,n({for:l(m),label:e.label,error:e.error,size:b.value,align:e.labelAlign,disabled:e.disabled,description:e.description,interactive:""},l(M),{"data-test":l(V)("label")}),{label:h(()=>[B(e.$slots,"label",{label:e.label})]),bottom:h(()=>[B(e.$slots,"bottom")]),default:h(()=>[F("input",n({id:l(m),type:"checkbox",value:s.value,"true-value":e.trueValue,"false-value":e.falseValue,name:y.value,checked:t.value,disabled:e.disabled},l(U),{"data-test":l(V)(),onChange:_}),null,16,ee),t.value?(I(),H("label",n({key:0},l(D),{for:l(m)}),[Q(X,n({internal:"",name:e.partial?l(x).defaults.partiallyCheckedIcon:l(x).defaults.checkedIcon,color:"white"},l($)),null,16,["name"])],16,ae)):J("",!0)]),_:3},16,["for","label","error","size","align","disabled","description","data-test"]))}});export{te as _};
