import{aF as k,a4 as V}from"./index.CL7yl-Wb.js";import{a as w,c as s,o as t,R as d,a9 as p,b as g,Q as y,H as n,J as x,K as P,O as U,f as b,r as _,w as B}from"./vue.D1BjjNmv.js";const R=w({name:"FsFilesFormat",props:{modelValue:{},color:{default:""},type:{default:"tag"},a:{},tag:{},buildUrl:{},buildUrls:{},getFileName:{}},setup(a,v){const{ui:i}=V(),f=b(()=>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 u(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),h=await a.buildUrls(r);for(let o=0;o<e.length;o++)e[o].url=h[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=[u(a.modelValue)];else if(a.modelValue instanceof Array){e=[];for(const r of a.modelValue)e.push(u(r))}return await m(e),e}const c=_([]);B(()=>a.modelValue,async()=>{c.value=await l()},{immediate:!0});const F=b(()=>({...a}));return{ui:i,itemsRef:c,computedProps:F}}}),C={class:"fs-files-format"},N=["href"],O=["href"];function D(a,v,i,f,u,m){return t(),s("div",C,[a.computedProps.type==="text"?(t(!0),s(d,{key:0},p(a.itemsRef,l=>(t(),s("span",{key:l.url,class:"fs-files-item"},[g("a",n({href:l.url,target:"_blank",ref_for:!0},a.computedProps.a),y(l.name),17,N)]))),128)):(t(!0),s(d,{key:1},p(a.itemsRef,l=>(t(),x(U(a.ui.tag.name),n({key:l.url,class:"fs-tag-item",color:l.color,ref_for:!0},a.computedProps.tag),{default:P(()=>[g("a",n({href:l.url,target:"_blank",ref_for:!0},a.computedProps.a),y(l.name),17,O)]),_:2},1040,["color"]))),128))])}const E=k(R,[["render",D]]);export{E as default};
