"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),i=require("@aplus-frontend/antdv"),c=require("lodash-unified");require("../../config-provider/index.js");require("../../hooks/index.js");const h=require("../hooks/use-options.js"),T=require("../style/index.js"),d=require("./helper.js"),V=require("../../hooks/useControllableValue.js"),C=require("../../config-provider/hooks/use-namespace.js"),O=e.defineComponent({name:"ApFieldRadio",__name:"index",props:{mode:{default:"edit"},class:{},style:{},emptyText:{default:"--"},customReadMode:{},prefixCls:{},value:{},size:{},options:{},disabled:{type:Boolean,default:void 0},name:{},buttonStyle:{},id:{},block:{type:Boolean},optionType:{},onChange:{},"onUpdate:value":{},vertical:{type:Boolean,default:!1},request:{}},emits:["update:value"],setup(n,{expose:p,emit:f}){const t=n,m=e.computed(()=>c.omit(t,["value","onUpdate:value","options","request","vertical"])),v=f,{options:l,updateOptions:y}=h.default(t),{value:u,updateValue:q}=V.useControllableValue(t,v),{b:k,m:g}=C.useNamespace("field-radio"),B=T.default("field"),a=e.ref(!1);async function r(){t.request&&(a.value=!0,t.request?.().then(o=>y(o)).finally(()=>{a.value=!1}))}e.onMounted(()=>{r()});const x=e.computed(()=>{const o=e.unref(u);if(c.isNil(o))return t.emptyText;const s=l.value?.find(b=>o===d.getOptionValue(b));return d.getOptionLabel(s)||t.emptyText});return p({request:r}),(o,s)=>n.mode==="read"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[e.createTextVNode(e.toDisplayString(x.value),1)],64)):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[a.value?(e.openBlock(),e.createBlock(e.unref(i.Spin),{key:0,size:"small"})):(e.openBlock(),e.createBlock(e.unref(i.RadioGroup),e.mergeProps({key:1},m.value,{ref:"radioGroupRef",value:e.unref(u),options:e.unref(l),class:[e.unref(k)(),n.vertical?e.unref(g)("vertical"):null,e.unref(B)],"onUpdate:value":e.unref(q)}),null,16,["value","options","class","onUpdate:value"]))],64))}});exports.default=O;
