import{n as e,t}from"./file-category-filter-BmGVvDiP.js";import{t as n}from"./file-DlDBClxy.js";import{t as r}from"./folder-input-lYe4JQ9T.js";import{t as i}from"./folder-DDlXKK_x.js";import{Ct as a,F as o,Hn as s,J as c,Qt as l,V as u,Vn as d,Zt as f,ct as p,ln as m,lt as h,pt as g,qn as _,st as v,tn as y,yn as b,zn as x}from"./index-CjPx3lfT.js";import{t as S}from"./directory-breadcrumb-BIvEu5Qr.js";import{t as C}from"./data-table-B1a8BMaf.js";import{t as w}from"./pagination-DP8LewWY.js";import{t as T}from"./use-fetch-files-CTmvUeuw.js";import{a as E,i as D,n as O,o as k,r as A,s as j,t as M}from"./dialog-ITi__DUr.js";import{t as N}from"./textarea-CVosTSyk.js";var P=s(((e,t)=>{t.exports=function(){var e=document.getSelection();if(!e.rangeCount)return function(){};for(var t=document.activeElement,n=[],r=0;r{var n=P(),r={"text/plain":`Text`,"text/html":`Url`,default:`Text`},i=`Copy to clipboard: #{key}, Enter`;function a(e){var t=(/mac os x/i.test(navigator.userAgent)?`⌘`:`Ctrl`)+`+C`;return e.replace(/#{\s*key\s*}/g,t)}function o(e,t){var o,s,c,l,u,d,f=!1;t||={},o=t.debug||!1;try{if(c=n(),l=document.createRange(),u=document.getSelection(),d=document.createElement(`span`),d.textContent=e,d.ariaHidden=`true`,d.style.all=`unset`,d.style.position=`fixed`,d.style.top=0,d.style.clip=`rect(0, 0, 0, 0)`,d.style.whiteSpace=`pre`,d.style.webkitUserSelect=`text`,d.style.MozUserSelect=`text`,d.style.msUserSelect=`text`,d.style.userSelect=`text`,d.addEventListener(`copy`,function(n){if(n.stopPropagation(),t.format)if(n.preventDefault(),n.clipboardData===void 0){o&&console.warn(`unable to use e.clipboardData`),o&&console.warn(`trying IE specific stuff`),window.clipboardData.clearData();var i=r[t.format]||r.default;window.clipboardData.setData(i,e)}else n.clipboardData.clearData(),n.clipboardData.setData(t.format,e);t.onCopy&&(n.preventDefault(),t.onCopy(n.clipboardData))}),document.body.appendChild(d),l.selectNodeContents(d),u.addRange(l),!document.execCommand(`copy`))throw Error(`copy command was unsuccessful`);f=!0}catch(n){o&&console.error(`unable to copy using execCommand: `,n),o&&console.warn(`trying IE specific stuff`);try{window.clipboardData.setData(t.format||`text`,e),t.onCopy&&t.onCopy(window.clipboardData),f=!0}catch(n){o&&console.error(`unable to copy using clipboardData: `,n),o&&console.error(`falling back to prompt`),s=a(`message`in t?t.message:i),window.prompt(s,e)}}finally{u&&(typeof u.removeRange==`function`?u.removeRange(l):u.removeAllRanges()),d&&document.body.removeChild(d),c()}return f}t.exports=o})),I=_(d(),1),L=_(F(),1),R=_(x(),1),z=``;function B({open:e,setOpen:t,data:r}){let a=e=>{(0,L.default)(e),m.success(`复制成功`)},o=(0,I.useMemo)(()=>`文件链接:${`${location.origin}${z}/#/extract?shareId=${r==null?void 0:r.id}`}\n\n提取码:${r==null?void 0:r.accessCode}`,[r]);return(0,R.jsx)(M,{open:e,onOpenChange:t,children:(0,R.jsxs)(A,{className:`w-[400px]`,children:[(0,R.jsx)(k,{children:(0,R.jsx)(j,{children:`分享文件`})}),(0,R.jsxs)(`div`,{className:`mt-1 flex items-center gap-1 text-sm p-2 rounded-md bg-gray-50`,children:[(r==null?void 0:r.fileType)===p.FILE?(0,R.jsx)(n,{size:14,className:`text-primary`}):(0,R.jsx)(i,{size:14,className:`text-amber-500`}),(0,R.jsx)(`span`,{children:r==null?void 0:r.fileName})]}),(0,R.jsxs)(`div`,{className:`space-y-4`,children:[(0,R.jsxs)(`div`,{className:`grid w-full items-center gap-2`,children:[(0,R.jsx)(c,{children:`有效日期`}),(0,R.jsx)(u,{value:r==null?void 0:r.endTime,disabled:!0})]}),(0,R.jsxs)(`div`,{className:`grid w-full items-center gap-2`,children:[(0,R.jsx)(c,{children:`分享内容`}),(0,R.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,R.jsx)(N,{value:o,disabled:!0,className:`min-h-[100px]`})})]})]}),(0,R.jsxs)(E,{children:[(0,R.jsx)(O,{asChild:!0,children:(0,R.jsx)(l,{variant:`outline`,children:`关闭`})}),(0,R.jsx)(l,{onClick:()=>a(o),children:`复制分享内容`})]})]})})}const V=e=>{let{mutateAsync:t,isPending:n}=b({mutationFn:a,...e||{}});return{cancelShare:e=>{m.promise(t(e),{loading:`提交中...`,success:`操作成功`})},cancelShareIsPending:n}};function H({open:e,setOpen:t,data:r,refetch:a}){let{cancelShare:o,cancelShareIsPending:s}=V({onSuccess(){a==null||a(),t(!1)}});return(0,R.jsx)(M,{open:e,onOpenChange:t,children:(0,R.jsxs)(A,{className:`w-[400px]`,children:[(0,R.jsxs)(k,{children:[(0,R.jsxs)(j,{children:[`您确定要取消分享该`,(r==null?void 0:r.fileType)===p.FILE?`文件`:`目录`,`?`]}),(0,R.jsxs)(D,{children:[`取消分享后,所有用户将无法访问该`,(r==null?void 0:r.fileType)===p.FILE?`文件`:`目录`]}),(0,R.jsxs)(`div`,{className:`mt-1 flex items-center gap-1 text-sm p-2 rounded-md bg-gray-50`,children:[(r==null?void 0:r.fileType)===p.FILE?(0,R.jsx)(n,{size:16,className:`text-primary flex-none`}):(0,R.jsx)(i,{size:16,className:`text-amber-500 flex-none`}),(0,R.jsx)(`span`,{className:`break-all`,children:r==null?void 0:r.fileName})]})]}),(0,R.jsxs)(E,{children:[(0,R.jsx)(O,{asChild:!0,children:(0,R.jsx)(l,{variant:`outline`,children:`取消`})}),(0,R.jsxs)(l,{type:`submit`,disabled:s,onClick:()=>{o(r==null?void 0:r.id)},children:[s&&(0,R.jsx)(f,{}),`确定`]})]})]})})}function U({handleChangeParentId:e,handleViewLink:t,handleCancelShare:a,handleFilePreview:s}){return[{accessorKey:`fileName`,header:`文件名`,cell:({row:t})=>{var a;return(0,R.jsxs)(`div`,{className:`flex items-center gap-1 break-all cursor-pointer hover:underline hover:text-primary group`,onClick:()=>{var n;(t==null||(n=t.original)==null?void 0:n.fileType)===p.DIRECTORY?e(t==null?void 0:t.original):s(t==null?void 0:t.original)},children:[(t==null||(a=t.original)==null?void 0:a.fileType)===p.FILE?(0,R.jsx)(R.Fragment,{children:(0,R.jsx)(n,{size:18,className:`text-primary`})}):(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(i,{size:18,className:`text-amber-500 group-hover:hidden`}),(0,R.jsx)(r,{size:18,className:`text-amber-500 group-hover:block hidden`})]}),(0,R.jsx)(`span`,{children:t.getValue(`fileName`)})]})}},{accessorKey:`createTime`,header:`创建日期`,cell:({row:e})=>(0,R.jsx)(`div`,{children:e.getValue(`createTime`)})},{accessorKey:`fileSize`,header:`文件大小`,cell:({row:e})=>(0,R.jsx)(`div`,{children:y(e.getValue(`fileSize`))})},{accessorKey:`fileCategory`,header:`文件种类`,cell:({row:e})=>(0,R.jsx)(`div`,{children:e.original.fileType===p.FILE?o(e.getValue(`fileCategory`)):`-`})},{id:`actions`,enableHiding:!1,header:`操作`,cell:({row:e})=>{var n;return e.original.parentId===0?(0,R.jsxs)(`div`,{className:`space-x-2`,children:[(0,R.jsx)(l,{size:`sm`,variant:`outline`,onClick:()=>t(e.original),children:`查看链接`}),(0,R.jsx)(l,{size:`sm`,variant:`outline`,onClick:()=>a(e.original),children:`取消分享`}),((n=e.original)==null?void 0:n.fileType)===p.FILE&&(0,R.jsx)(l,{variant:`outline`,size:`sm`,onClick:()=>{var t;g({code:(t=e.original)==null?void 0:t.fileCode})},children:`下载`})]}):null}}]}function W(){let[n,r]=(0,I.useState)(null),[i,a]=(0,I.useState)(!1),o=e=>{r(e),a(!0)},[s,c]=(0,I.useState)(!1),l=e=>{r(e),c(!0)},[u,d]=(0,I.useState)(!1),f=e=>{r(e),d(!0)},[p,m]=(0,I.useState)(`all`),{openDirectorys:g,changeOpenDirectorys:_,table:y,query:b,reset:x}=T({useColumns:e=>U({handleChangeParentId:e,handleCancelShare:l,handleViewLink:o,handleFilePreview:f}),queryKey:[`shareFiles`],params:(0,I.useMemo)(()=>({rootType:h.SHARE,fileStatus:v.VALID,fileCategory:p===`all`?void 0:p}),[p])});return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(B,{open:i,setOpen:a,data:n}),(0,R.jsx)(H,{open:s,setOpen:c,data:n,refetch:b==null?void 0:b.refetch}),(0,R.jsx)(e,{open:u,setOpen:d,data:n}),(0,R.jsxs)(`div`,{className:`p-4 box-border min-h-full space-y-4`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`div`,{className:`text-lg`,children:`我的分享`}),(0,R.jsx)(`div`,{className:`text-xs text-black/50`,children:`管理您分享的文件`})]}),(0,R.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,R.jsx)(t,{fileCategory:p,setFileCategory:m,reset:x})}),(0,R.jsxs)(`div`,{className:`p-4 rounded-lg border bg-white space-y-2`,children:[(0,R.jsx)(S,{directorys:g,onChangeDirectorys:_}),(0,R.jsxs)(`div`,{className:`relative overflow-hidden`,children:[(0,R.jsx)(C,{table:y,query:b}),(0,R.jsx)(w,{table:y,className:`justify-end p-2 sticky bottom-0 left-0 right-0 z-10 bg-white`})]})]})]})]})}export{W as component,U as useColumns};