import{defineComponent as C,shallowRef as g,computed as N,createVNode as i}from"vue";import h from"../../_util/classNames.mjs";import x from"../../_util/props-util/initDefaultProps.mjs";import{functionType as p,someType as k,stringType as T,booleanType as y,arrayType as I}from"../../_util/type.mjs";import R from"../../config-provider/hooks/useConfigInject.mjs";import j from"../style/index.mjs";import w from"./MotionThumb.mjs";function z(e){return e.map(l=>typeof l=="object"&&l!==null?l:{label:l?.toString(),title:l?.toString(),value:l})}const A=()=>({prefixCls:String,options:I(),block:y(),disabled:y(),size:T(),value:{...k([String,Number]),required:!0},motionName:String,onChange:p(),"onUpdate:value":p()}),S=(e,{slots:l,emit:v})=>{const{value:o,disabled:n,payload:c,title:s,prefixCls:r,label:u=l.label,checked:m,className:d}=e,f=b=>{n||v("change",b,o)};return i("label",{class:h({[`${r}-item-disabled`]:n},d)},[i("input",{class:`${r}-item-input`,type:"radio",disabled:n,checked:m,onChange:f},null),i("div",{class:`${r}-item-label`,title:typeof s=="string"?s:""},[typeof u=="function"?u({value:o,disabled:n,payload:c,title:s}):u??o])])};S.inheritAttrs=!1;const _=C({name:"ASegmented",inheritAttrs:!1,props:x(A(),{options:[],motionName:"thumb-motion"}),slots:Object,setup(e,{emit:l,slots:v,attrs:o}){const{prefixCls:n,direction:c,size:s}=R("segmented",e),[r,u]=j(n),m=g(),d=g(!1),f=N(()=>z(e.options)),b=(t,a)=>{e.disabled||(l("update:value",a),l("change",a))};return()=>{const t=n.value;return r(i("div",{...o,class:h(t,{[u.value]:!0,[`${t}-block`]:e.block,[`${t}-disabled`]:e.disabled,[`${t}-lg`]:s.value=="large",[`${t}-sm`]:s.value=="small",[`${t}-rtl`]:c.value==="rtl"},o.class),ref:m},[i("div",{class:`${t}-group`},[i(w,{containerRef:m,prefixCls:t,value:e.value,motionName:`${t}-${e.motionName}`,direction:c.value,getValueIndex:a=>f.value.findIndex($=>$.value===a),onMotionStart:()=>{d.value=!0},onMotionEnd:()=>{d.value=!1}},null),f.value.map(a=>i(S,{key:a.value,prefixCls:t,checked:a.value===e.value,onChange:b,...a,className:h(a.className,`${t}-item`,{[`${t}-item-selected`]:a.value===e.value&&!d.value}),disabled:!!e.disabled||!!a.disabled},v))])]))}}});export{_ as default,A as segmentedProps};
