import{K as h,R as V}from"./index.K_MFulpu.js";import"./elementPlus.CSBdF9Zt.js";import{d as w,k as d,r as x,w as P,o as s,c as t,F as p,a8 as g,a as y,T as v,K as u,M as R,O as U,Q as _}from"./vue.1RczIYhx.js";const B=w({name:"FsFilesFormat",props:{modelValue:{},color:{default:""},type:{default:"tag"},a:{},tag:{},buildUrl:{},buildUrls:{},getFileName:{}},setup(a,b){const{ui:i}=V(),f=d(()=>a.getFileName||function(e){return typeof e!="string"?(console.warn("获取文件名失败，请配置getFileName"),e):(e==null?void 0:e.lastIndexOf("/"))>=0?e.substring(e.lastIndexOf("/")+1):e});function n(e){return{url:void 0,value:e,name:f.value(e),color:a.color}}async function m(e){if(a.buildUrls){const r=e.map(o=>o.value),F=await a.buildUrls(r);for(let o=0;o<e.length;o++)e[o].url=F[o]}else if(a.buildUrl)for(let r of e)r.url=await a.buildUrl(r.value);else for(let r=0;r<e.length;r++)e[r].url=e[r].value}async function l(){if(a.modelValue==null||a.modelValue==="")return[];let e=[];if(typeof a.modelValue=="string")e=[n(a.modelValue)];else if(a.modelValue instanceof Array){e=[];for(const r of a.modelValue)e.push(n(r))}return await m(e),e}const c=x([]);P(()=>a.modelValue,async()=>{c.value=await l()},{immediate:!0});const k=d(()=>({...a}));return{ui:i,itemsRef:c,computedProps:k}}}),C={class:"fs-files-format"},N=["href"],O=["href"];function D(a,b,i,f,n,m){return s(),t("div",C,[a.computedProps.type==="text"?(s(!0),t(p,{key:0},g(a.itemsRef,l=>(s(),t("span",{key:l.url,class:"fs-files-item"},[y("a",u({href:l.url,target:"_blank",ref_for:!0},a.computedProps.a),v(l.name),17,N)]))),128)):(s(!0),t(p,{key:1},g(a.itemsRef,l=>(s(),R(_(a.ui.tag.name),u({key:l.url,class:"fs-tag-item",color:l.color,ref_for:!0},a.computedProps.tag),{default:U(()=>[y("a",u({href:l.url,target:"_blank",ref_for:!0},a.computedProps.a),v(l.name),17,O)]),_:2},1040,["color"]))),128))])}const A=h(B,[["render",D]]);export{A as default};
