import{l as L,p as P,a1 as u,r as g,q as T,g as o,a2 as i,Q as v,J as q,a3 as A,s as W,h as J,o as I,t as n,u as l,w as h,b as Q,c as F,z as H,a as K,v as B,C as R}from"./index-CdEV5Lsj.js";import{b as X}from"./index-DruWBKkm.js";import{_ as Y}from"./ULabel.vue_vue_type_script_setup_true_lang-DmdMPZfT.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:w}){const d=u("getCheckboxGroupName",null),S=u("getCheckboxGroupCheckedItems",null),p=u("setCheckboxGroupCheckedItems",null),j=u("getCheckboxGroupColor",null),O=u("getCheckboxSize",null),a=G,k=w,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(S):a.modelValue);q(()=>{y.value=r.value&&d?i(d):a.name}),A(()=>C.value=i(j)||a.color),A(()=>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(x=>!v(s.value,x)):[...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:z,checkboxAttrs:U,iconWrapperAttrs:M,checkboxLabelAttrs:$,checkedIconAttrs:D}=W(N,E);return(e,x)=>(I(),J(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($),{"data-test":l(V)("label")}),{label:h(()=>[B(e.$slots,"label",{label:e.label})]),bottom:h(()=>[B(e.$slots,"bottom")]),default:h(()=>[Q("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(),F("label",n({key:0},l(M),{for:l(m)}),[K(X,n({internal:"",name:e.partial?l(z).defaults.partiallyCheckedIcon:l(z).defaults.checkedIcon,color:"white"},l(D)),null,16,["name"])],16,ae)):H("",!0)]),_:3},16,["for","label","error","size","align","disabled","description","data-test"]))}});export{te as _};
