"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const r=require("vue"),D=require("@aplus-frontend/antdv"),d=require("lodash-unified");require("../../config-provider/index.js");require("./components/help-message/index.vue.js");require("./components/mask-wrapper/index.vue.js");const a=require("./helper.js"),A=require("./hooks/use-descriptions-context.js"),T=require("./style/index.js"),y=require("../../config-provider/hooks/use-global-config.js"),K=require("../../config-provider/hooks/use-namespace.js"),w=require("./components/help-message/index.vue2.js"),B=require("./components/mask-wrapper/index.vue2.js");function E(o){return typeof o=="function"||Object.prototype.toString.call(o)==="[object Object]"&&!r.isVNode(o)}const O=r.defineComponent({name:"ApDescriptions",__name:"ap-descriptions",props:{descriptionsProps:{},schemas:{},dataSource:{},defaultMask:{},style:{type:[Boolean,null,String,Object,Array]},className:{}},setup(o,{expose:g}){const n=o,b=y.useGlobalConfig("apDescriptions"),S=y.useGlobalConfig("downloadCenterTriggerConfig"),{b:v,be:c}=K.useNamespace("ap-descriptions"),m=T.default("ap-descriptions"),x=r.useSlots(),u=r.reactive({}),_=r.computed(e=>a.genDefaultMaskStatus(n.schemas,e,n.defaultMask));A.useDescriptionsProvider({maskStatus:r.computed(()=>Object.assign({},_.value,u)),setStatusByKey(e,t){u[e]=t}});const k=(e={})=>{let t="";return n.descriptionsProps?.layout==="vertical"&&(t="start"),{justifyContent:t,...e}},f=e=>{const t=d.get(n.dataSource,e.field);if(e.customRender)return e.customRender(n.dataSource);e.valueType==="attachment"&&(e.extraProps=a.mixinsAttachmentExtraProps(e.extraProps,{fromConfig:b.value?.downloadFile,fromGlobal:S.value?.trigger}));const s=e.format?e.format(t,n.dataSource||{}):t;return a.transformValue({value:s,record:n.dataSource},e)},C=e=>e.valueType==="text"&&!!e.extraProps?.ellipsis,M=(e,t)=>{if(e.visible!=null){if(typeof e.visible=="boolean")return e.visible;if(typeof e.visible=="function")return e.visible({record:t||{},schema:e})}return!0},N=(e,t,s)=>e.valueType==="empty"?null:a.isEmptyWithType(d.get(s,e.field),e)?r.createVNode("span",null,[r.createTextVNode("--")]):e.contentSlotName?x?.[e.contentSlotName]?.({index:t,record:s,item:f(e)}):r.createVNode(r.Fragment,null,[e.prefix,f(e),e.suffix&&r.createVNode("span",{class:c("content","suffix")},[e.suffix])]),q=(e=[],t)=>e.filter(s=>M(s,t)).map((s,i)=>{let l;return{label:s.label&&r.createVNode(w.default,{helpMessage:s.helpMessage,label:s.label},null),span:s.span,style:s.style,contentStyle:s.contentStyle,labelStyle:s.labelStyle,key:s.field?.toString()||"empty"+i,class:C(s)?c("item","ellipsis"):"",children:r.createVNode(B.default,{item:s,data:t,defaultMask:n.defaultMask},E(l=N(s,i,t))?l:{default:()=>[l]})}}),p=r.shallowRef([]),P=e=>{if(e!=null)return typeof e=="string"?[e]:e.some(t=>Array.isArray(t))?e.map(t=>Array.isArray(t)?t.join("."):t):e},V=()=>(n.schemas||[]).map(e=>{const t=a.getSchemaKey(e),s=a.getMaskConfigBySchema(e,n.defaultMask);if(!(!t||!s))return t}).filter(e=>!!e),j=(e,t)=>{const s=P(t),i=s?new Set(s):void 0;V().forEach(l=>{(!i||i.has(l))&&(u[l]=e)})};return r.watch([()=>n.schemas,()=>n.dataSource],()=>{p.value=q(n.schemas,n.dataSource)},{immediate:!0,deep:!0}),g({setMaskStatus:j}),(e,t)=>(r.openBlock(),r.createElementBlock("div",{class:r.normalizeClass([o.className,r.unref(v)(),r.unref(m)]),style:r.normalizeStyle(o.style)},[r.createVNode(r.unref(D.Descriptions),r.mergeProps(o.descriptionsProps,{"label-style":k({...o.descriptionsProps?.labelStyle||{}}),items:p.value}),null,16,["label-style","items"])],6))}});exports.default=O;
