import{Ct as e,E as t,Tt as n}from"./vue-vendor-DMUmTARL.js";import{I as r,ct as i,h as a,lt as o,wt as s,y as c}from"./index-y6crcKNt.js";import{n as l,t as u}from"./home-CJ8x5tlQ.js";var d=e({expireTime:null,customKey:``}),f=n(``),{storageKey:p}=i(),{selectFiles:m}=s(),h=o(),g=n([]),_=t(()=>g.value.length>0?g.value[0]:null),v=n(!1),y=()=>({storageKey:``,files:[]}),b=n(y()),x=t(()=>b.value.files),S=t(()=>x.value.length);function C(){let e=c(),t=e=>e===`pathLink`?!!h.permission.pathLink:e===`shortLink`?!!h.permission.shortLink:e===`all`?!!h.permission.bothLink:!1,n=t=>{let n=t===`pathLink`?`直链`:t===`shortLink`?`短链`:`直链和短链`;e.warning(`没有生成${n}的权限`)},i=e=>String(e??b.value.storageKey??p.value??``),o=()=>({storageKey:String(p.value??``),files:m.value.map(e=>({name:e.name,size:e.size,time:e.time,path:e.path,type:e.type,icon:e.icon,fileType:e.fileType}))}),s=()=>{b.value=y()};return{currentLinkDialogType:f,openGenerateLinkDialog:r=>{if(!t(r)){n(r);return}let i=o();if(!i.files.length){e.warning(`请至少选择一个文件`);return}f.value=r,b.value=i,d.customKey=``,v.value=!0},generateLinkFormData:d,selectedLinkFiles:x,selectedLinkFileCount:S,generateLinkResultDialogVisible:v,closeGenerateLinkResultDialog:()=>{v.value=!1,g.value=[],s()},copyText:e=>a(e),data:_,dataList:g,batchGetFilePathLink:async(e,t)=>{let a=[];if(!h.permission.pathLink)return n(`pathLink`),a;let o=i(t),s={storageKey:o,paths:[],expireTime:0};return e.forEach(e=>{let t=r(e.path,e.name);s.paths.push(t)}),o?(((await u(s)).data||[]).forEach(e=>{a.push(e.address||``)}),a):(console.warn(`[file-link] 缺少 storageKey，已跳过批量生成直链`,{paths:s.paths}),a)},batchGetShortLink:async(e,t)=>{let a=[];if(!h.permission.shortLink)return n(`shortLink`),a;let o=i(t),s={storageKey:o,paths:[],expireTime:d.expireTime};return e.forEach(e=>{let t=r(e.path,e.name);s.paths.push(t)}),o?(h.permission.customShortLinkKey&&e.length===1&&d.customKey&&(s.customKey=d.customKey.trim()),((await l(s)).data||[]).forEach(e=>{a.push(e.address||``)}),a):(console.warn(`[file-link] 缺少 storageKey，已跳过批量生成短链`,{paths:s.paths}),a)}}}export{C as t};