@dudousxd/nestjs-media-dashboard 0.3.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -76,4 +76,4 @@ Error generating stack: `+s.message+`
76
76
  `,o=l.charCodeAt(0),c=new RegExp((s=="|"?"\\|":s)+"+$"),u="",f=[];n.dense=Array.isArray(e);for(var h=n.skipHidden&&e["!cols"]||[],x=n.skipHidden&&e["!rows"]||[],m=a.s.c;m<=a.e.c;++m)(h[m]||{}).hidden||(f[m]=pr(m));for(var d=0,v=a.s.r;v<=a.e.r;++v)(x[v]||{}).hidden||(u=PC(e,a,v,f,i,o,s,n),u!=null&&(n.strip&&(u=u.replace(c,"")),(u||n.blankrows!==!1)&&t.push((d++?l:"")+u)));return delete n.dense,t.join("")}function IC(e,r){r||(r={}),r.FS=" ",r.RS=`
77
77
  `;var t=hg(e,r);return t}function LC(e){var r="",t,n="";if(e==null||e["!ref"]==null)return[];var a=Ze(e["!ref"]),s="",i=[],l,o=[],c=Array.isArray(e);for(l=a.s.c;l<=a.e.c;++l)i[l]=pr(l);for(var u=a.s.r;u<=a.e.r;++u)for(s=Sr(u),l=a.s.c;l<=a.e.c;++l)if(r=i[l]+s,t=c?(e[u]||[])[l]:e[r],n="",t!==void 0){if(t.F!=null){if(r=t.F,!t.f)continue;n=t.f,r.indexOf(":")==-1&&(r=r+":"+r)}if(t.f!=null)n=t.f;else{if(t.t=="z")continue;if(t.t=="n"&&t.v!=null)n=""+t.v;else if(t.t=="b")n=t.v?"TRUE":"FALSE";else if(t.w!==void 0)n="'"+t.w;else{if(t.v===void 0)continue;t.t=="s"?n="'"+t.v:n=""+t.v}}o[o.length]=r+"="+n}return o}function dg(e,r,t){var n=t||{},a=+!n.skipHeader,s=e||{},i=0,l=0;if(s&&n.origin!=null)if(typeof n.origin=="number")i=n.origin;else{var o=typeof n.origin=="string"?Gr(n.origin):n.origin;i=o.r,l=o.c}var c,u={s:{c:0,r:0},e:{c:l,r:i+r.length-1+a}};if(s["!ref"]){var f=Ze(s["!ref"]);u.e.c=Math.max(u.e.c,f.e.c),u.e.r=Math.max(u.e.r,f.e.r),i==-1&&(i=f.e.r+1,u.e.r=i+r.length-1+a)}else i==-1&&(i=0,u.e.r=r.length-1+a);var h=n.header||[],x=0;r.forEach(function(d,v){cn(d).forEach(function(g){(x=h.indexOf(g))==-1&&(h[x=h.length]=g);var y=d[g],p="z",T="",I=we({c:l+x,r:i+v+a});c=A0(s,I),y&&typeof y=="object"&&!(y instanceof Date)?s[I]=y:(typeof y=="number"?p="n":typeof y=="boolean"?p="b":typeof y=="string"?p="s":y instanceof Date?(p="d",n.cellDates||(p="n",y=Qr(y)),T=n.dateNF||_e[14]):y===null&&n.nullError&&(p="e",y=0),c?(c.t=p,c.v=y,delete c.w,delete c.R,T&&(c.z=T)):s[I]=c={t:p,v:y},T&&(c.z=T))})}),u.e.c=Math.max(u.e.c,l+h.length-1);var m=Sr(i);if(a)for(x=0;x<h.length;++x)s[pr(x+l)+m]={t:"s",v:h[x]};return s["!ref"]=Oe(u),s}function MC(e,r){return dg(null,e,r)}function A0(e,r,t){if(typeof r=="string"){if(Array.isArray(e)){var n=Gr(r);return e[n.r]||(e[n.r]=[]),e[n.r][n.c]||(e[n.r][n.c]={t:"z"})}return e[r]||(e[r]={t:"z"})}return typeof r!="number"?A0(e,we(r)):A0(e,we({r,c:t||0}))}function BC(e,r){if(typeof r=="number"){if(r>=0&&e.SheetNames.length>r)return r;throw new Error("Cannot find sheet # "+r)}else if(typeof r=="string"){var t=e.SheetNames.indexOf(r);if(t>-1)return t;throw new Error("Cannot find sheet name |"+r+"|")}else throw new Error("Cannot find sheet |"+r+"|")}function gh(){return{SheetNames:[],Sheets:{}}}function yh(e,r,t,n){var a=1;if(!t)for(;a<=65535&&e.SheetNames.indexOf(t="Sheet"+a)!=-1;++a,t=void 0);if(!t||e.SheetNames.length>=65535)throw new Error("Too many worksheets");if(n&&e.SheetNames.indexOf(t)>=0){var s=t.match(/(^.*?)(\d+)$/);a=s&&+s[2]||0;var i=s&&s[1]||t;for(++a;a<=65535&&e.SheetNames.indexOf(t=i+a)!=-1;++a);}if(kF(t),e.SheetNames.indexOf(t)>=0)throw new Error("Worksheet with name |"+t+"| already exists!");return e.SheetNames.push(t),e.Sheets[t]=r,t}function bC(e,r,t){e.Workbook||(e.Workbook={}),e.Workbook.Sheets||(e.Workbook.Sheets=[]);var n=BC(e,r);switch(e.Workbook.Sheets[n]||(e.Workbook.Sheets[n]={}),t){case 0:case 1:case 2:break;default:throw new Error("Bad sheet visibility setting "+t)}e.Workbook.Sheets[n].Hidden=t}function UC(e,r){return e.z=r,e}function xg(e,r,t){return r?(e.l={Target:r},t&&(e.l.Tooltip=t)):delete e.l,e}function jC(e,r,t){return xg(e,"#"+r,t)}function zC(e,r,t){e.c||(e.c=[]),e.c.push({t:r,a:t||"SheetJS"})}function HC(e,r,t,n){for(var a=typeof r!="string"?r:Ze(r),s=typeof r=="string"?r:Oe(r),i=a.s.r;i<=a.e.r;++i)for(var l=a.s.c;l<=a.e.c;++l){var o=A0(e,i,l);o.t="n",o.F=s,delete o.v,i==a.s.r&&l==a.s.c&&(o.f=t,n&&(o.D=!0))}return e}var VC={encode_col:pr,encode_row:Sr,encode_cell:we,encode_range:Oe,decode_col:ah,decode_row:nh,split_cell:e_,decode_cell:Gr,decode_range:di,format_cell:Dn,sheet_add_aoa:gv,sheet_add_json:dg,sheet_add_dom:og,aoa_to_sheet:xi,json_to_sheet:MC,table_to_sheet:cg,table_to_book:sC,sheet_to_csv:hg,sheet_to_txt:IC,sheet_to_json:Wu,sheet_to_html:aC,sheet_to_formulae:LC,sheet_to_row_object_array:Wu,sheet_get_cell:A0,book_new:gh,book_append_sheet:yh,book_set_sheet_visibility:bC,cell_set_number_format:UC,cell_set_hyperlink:xg,cell_set_internal_link:jC,cell_add_comment:zC,sheet_set_array_formula:HC,consts:{SHEET_VISIBLE:0,SHEET_HIDDEN:1,SHEET_VERY_HIDDEN:2}};const Ai=26,K1=12;function WC(e,r){const t=Number(e),n=Number(r);return e.trim()!==""&&r.trim()!==""&&!Number.isNaN(t)&&!Number.isNaN(n)?t-n:e.localeCompare(r,void 0,{numeric:!0,sensitivity:"base"})}function pg({header:e,body:r}){const[t,n]=ve.useState(""),[a,s]=ve.useState({}),[i,l]=ve.useState(null),o=ve.useRef(null),[c,u]=ve.useState(0),[f,h]=ve.useState(0);ve.useEffect(()=>{const N=o.current;if(!N)return;const j=new ResizeObserver(()=>h(N.clientHeight));return j.observe(N),h(N.clientHeight),()=>j.disconnect()},[]);const x=ve.useMemo(()=>{const N=t.trim().toLowerCase(),j=Object.entries(a).map(([B,Y])=>[Number(B),Y.trim().toLowerCase()]).filter(([,B])=>B!=="");let z=r.filter(B=>N&&!B.some(Y=>Y.toLowerCase().includes(N))?!1:j.every(([Y,he])=>(B[Y]??"").toLowerCase().includes(he)));if(i){const B=i.dir==="asc"?1:-1;z=[...z].sort((Y,he)=>B*WC(Y[i.index]??"",he[i.index]??""))}return z},[r,t,a,i]),m=x.length,d=Math.max(0,Math.floor(c/Ai)-K1),v=(f>0?Math.ceil(f/Ai):40)+K1*2,g=Math.min(m,d+v),y=d*Ai,p=Math.max(0,(m-g)*Ai),T=x.slice(d,g),I=t.trim()!==""||Object.values(a).some(N=>N.trim()!==""),O=i!==null||I;function _(N){l(j=>!j||j.index!==N?{index:N,dir:"asc"}:j.dir==="asc"?{index:N,dir:"desc"}:null)}function L(){l(null),s({}),n("")}return w.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-2",children:[w.jsxs("div",{className:"flex items-center gap-2",children:[w.jsxs("div",{className:"flex flex-1 items-center gap-1.5 rounded-md border border-[var(--line)] px-2",children:[w.jsx("span",{className:"text-zinc-600",children:"⌕"}),w.jsx("input",{value:t,onChange:N=>n(N.target.value),placeholder:"filter all columns…",className:"mono w-full bg-transparent py-1.5 text-xs text-zinc-200 placeholder:text-zinc-600 focus:outline-none"})]}),O&&w.jsx("button",{type:"button",onClick:L,className:"mono shrink-0 rounded-md border border-[var(--line)] px-2 py-1 text-[10px] text-zinc-400 transition-colors hover:bg-zinc-800 hover:text-zinc-100",children:"reset"}),w.jsxs("span",{className:"mono tnum shrink-0 text-[10px] text-zinc-600",children:[m,I?` / ${r.length}`:""," ",r.length===1?"row":"rows"]})]}),w.jsx("div",{ref:o,onScroll:N=>u(N.currentTarget.scrollTop),className:"min-h-0 flex-1 overflow-auto rounded-md border border-[var(--line)]",children:w.jsxs("table",{className:"w-full text-left text-xs",children:[w.jsx("thead",{className:"sticky top-0 z-10 bg-[var(--panel)]",children:w.jsx("tr",{className:"border-b border-[var(--line)]",children:e.map((N,j)=>{const z=(i==null?void 0:i.index)===j;return w.jsxs("th",{className:"px-3 py-1.5 align-top",children:[w.jsxs("button",{type:"button",onClick:()=>_(j),className:"mono flex max-w-full items-center gap-1 whitespace-nowrap uppercase tracking-wider text-zinc-500 transition-colors hover:text-zinc-200",children:[w.jsx("span",{className:"truncate",children:N}),w.jsx("span",{className:"shrink-0 text-[9px] text-zinc-600",children:z?(i==null?void 0:i.dir)==="asc"?"▲":"▼":"↕"})]}),w.jsx("input",{value:a[j]??"",onChange:B=>s(Y=>({...Y,[j]:B.target.value})),placeholder:"filter",className:"mono mt-1 w-full min-w-[5rem] rounded border border-[var(--line)] bg-transparent px-1 py-0.5 text-[10px] font-normal normal-case tracking-normal text-zinc-300 placeholder:text-zinc-700 focus:border-emerald-500/40 focus:outline-none"})]},j)})})}),w.jsxs("tbody",{className:"divide-y divide-[var(--line-soft)]",children:[y>0&&w.jsx("tr",{"aria-hidden":!0,children:w.jsx("td",{colSpan:e.length,style:{height:y}})}),T.map((N,j)=>w.jsx("tr",{style:{height:Ai},className:"hover:bg-zinc-900/40",children:e.map((z,B)=>w.jsx("td",{className:"mono whitespace-nowrap px-3 text-zinc-300",children:N[B]??""},B))},d+j)),p>0&&w.jsx("tr",{"aria-hidden":!0,children:w.jsx("td",{colSpan:e.length,style:{height:p}})})]})]})})]})}const $C=[[/\.(png|jpe?g|gif|webp|avif|svg|bmp|ico)$/i,"image"],[/\.pdf$/i,"pdf"],[/\.(mp4|webm|mov|m4v|ogv)$/i,"video"],[/\.(mp3|wav|ogg|oga|flac|m4a|aac)$/i,"audio"],[/\.(xlsx|xls|xlsm|ods)$/i,"sheet"],[/\.(txt|json|csv|tsv|md|log|xml|ya?ml)$/i,"text"]];function GC(e){return e.includes("spreadsheetml")||e==="application/vnd.ms-excel"||e==="application/vnd.oasis.opendocument.spreadsheet"}function KC(e){var t;const r=((t=e.contentType)==null?void 0:t.toLowerCase())??"";if(r.startsWith("image/"))return"image";if(r==="application/pdf")return"pdf";if(r.startsWith("video/"))return"video";if(r.startsWith("audio/"))return"audio";if(GC(r))return"sheet";if(r.startsWith("text/")||r==="application/json")return"text";for(const[n,a]of $C)if(n.test(e.name))return a;return"other"}function XC(e){var t;const r=((t=e.contentType)==null?void 0:t.toLowerCase())??"";return r.includes("csv")||/\.csv$/i.test(e.name)?"csv":r.includes("tab-separated")||/\.tsv$/i.test(e.name)?"tsv":r.includes("json")||/\.json$/i.test(e.name)?"json":"plain"}const QC=8*1024*1024;function go({item:e,message:r}){return w.jsx("div",{className:"grid h-full min-h-[320px] place-items-center gap-4 px-6 text-center",children:w.jsxs("div",{className:"flex flex-col items-center gap-4",children:[w.jsx("div",{className:"grid h-14 w-14 place-items-center rounded-lg border border-[var(--line)] bg-zinc-900 text-2xl text-zinc-600",children:"⬡"}),w.jsx("div",{className:"mono max-w-md text-sm text-zinc-400",children:r}),w.jsx("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",className:"mono rounded-md border border-emerald-500/30 bg-emerald-500/10 px-3 py-1.5 text-xs text-emerald-300 transition-colors hover:bg-emerald-500/20",children:"Open original ↗"})]})})}function YC(e,r){const t=[];let n=[],a="",s=!1;for(let i=0;i<e.length;i++){const l=e[i];s?l==='"'?e[i+1]==='"'?(a+='"',i++):s=!1:a+=l:l==='"'?s=!0:l===r?(n.push(a),a=""):l===`
78
78
  `?(n.push(a),t.push(n),n=[],a=""):l!=="\r"&&(a+=l)}return(a.length>0||n.length>0)&&(n.push(a),t.push(n)),t}function X1({text:e,delimiter:r}){const t=YC(e.trimEnd(),r),n=t[0];return n?w.jsx(pg,{header:n,body:t.slice(1)}):w.jsx(dr,{children:"Empty file."})}const qC=15*1024*1024;function JC({item:e}){const r=e.size>qC,t=on({queryKey:["object-bytes",e.disk,e.key],queryFn:()=>be.objectBytes(e.disk,e.key),retry:!1,staleTime:6e4,enabled:!r}),[n,a]=ve.useState(0),s=ve.useMemo(()=>t.data?Vu(t.data,{type:"array"}):void 0,[t.data]),i=ve.useMemo(()=>{if(!s)return;const l=s.SheetNames[Math.min(n,s.SheetNames.length-1)],o=l?s.Sheets[l]:void 0;if(!o)return{header:[],body:[]};const u=VC.sheet_to_json(o,{header:1,blankrows:!1,defval:""}).map(f=>f.map(h=>h==null?"":String(h)));return{header:u[0]??[],body:u.slice(1)}},[s,n]);return r?w.jsx(go,{item:e,message:`Too large to preview inline (${Rn(e.size)}). Open the original to view it.`}):t.isLoading?w.jsx(dr,{children:"Loading…"}):t.isError||!s||!i?w.jsx(go,{item:e,message:"Could not read this spreadsheet."}):w.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-2",children:[s.SheetNames.length>1&&w.jsx("div",{className:"flex flex-wrap gap-1",children:s.SheetNames.map((l,o)=>w.jsx("button",{type:"button",onClick:()=>a(o),className:`mono rounded-md border px-2 py-0.5 text-[11px] transition-colors ${o===n?"border-zinc-600 bg-zinc-900 text-zinc-100":"border-transparent text-zinc-500 hover:text-zinc-300"}`,children:l},l))}),w.jsx(pg,{header:i.header,body:i.body})]})}function ZC(e){try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}}function eA({item:e}){const r=on({queryKey:["object-text-head",e.disk,e.key],queryFn:()=>be.objectTextHead(e.disk,e.key,QC),retry:!1,staleTime:6e4});if(r.isLoading)return w.jsx(dr,{children:"Loading…"});if(r.isError||!r.data)return w.jsx(go,{item:e,message:"Could not read this file."});const{text:t,bytesRead:n}=r.data,a=n<e.size,s=a?t.slice(0,Math.max(0,t.lastIndexOf(`
79
- `))):t,i=XC(e),l=i==="csv"?w.jsx(X1,{text:s,delimiter:","}):i==="tsv"?w.jsx(X1,{text:s,delimiter:" "}):w.jsx("pre",{className:"mono min-h-0 flex-1 overflow-auto whitespace-pre-wrap break-words rounded-md border border-[var(--line)] bg-black/30 p-3 text-xs text-zinc-300",children:i==="json"?ZC(s):s});return w.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-2",children:[a&&w.jsxs("div",{className:"mono shrink-0 rounded-md border border-amber-500/30 bg-amber-500/10 px-3 py-1.5 text-[11px] text-amber-300",children:["Sample — the first ",Rn(n)," of ",Rn(e.size),". Filters and sort apply to this sample; open the original ↗ for the whole file."]}),l]})}function rA({item:e,kind:r}){switch(r){case"image":return w.jsx("div",{className:"grid min-h-0 flex-1 place-items-center",children:w.jsx("img",{src:e.url,alt:e.name,className:"max-h-full max-w-full rounded-md object-contain"})});case"video":return w.jsx("div",{className:"grid min-h-0 flex-1 place-items-center",children:w.jsx("video",{src:e.url,controls:!0,className:"max-h-full max-w-full rounded-md"})});case"audio":return w.jsx("div",{className:"grid min-h-0 flex-1 place-items-center",children:w.jsx("audio",{src:e.url,controls:!0,className:"w-full max-w-md"})});case"pdf":return w.jsx("iframe",{src:be.objectRawUrl(e.disk,e.key),title:e.name,className:"min-h-0 w-full flex-1 rounded-md border border-[var(--line)] bg-white"});case"text":return w.jsx(eA,{item:e});case"sheet":return w.jsx(JC,{item:e});default:return w.jsx(go,{item:e,message:`No inline preview for ${e.contentType??"this type"}`})}}function tA({item:e,onClose:r}){if(ve.useEffect(()=>{if(!e)return;const n=a=>{a.key==="Escape"&&r()};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[e,r]),!e)return null;const t=KC(e);return Wf.createPortal(w.jsx("div",{className:"fixed inset-0 z-50 flex flex-col items-center justify-center bg-black/80 p-6 backdrop-blur-sm",onClick:n=>{n.target===n.currentTarget&&r()},children:w.jsxs("div",{className:"flex h-[86vh] max-h-full w-full max-w-5xl flex-col overflow-hidden rounded-lg border border-[var(--line)] bg-[var(--panel)] shadow-2xl","aria-label":`Preview of ${e.name}`,children:[w.jsxs("div",{className:"flex items-center gap-3 border-b border-[var(--line)] px-4 py-2.5",children:[w.jsxs("div",{className:"min-w-0 flex-1",children:[w.jsx("div",{className:"mono truncate text-sm text-zinc-200",children:e.name}),w.jsxs("div",{className:"mono tnum mt-0.5 flex items-center gap-2 text-[10px] text-zinc-600",children:[w.jsx("span",{children:Rn(e.size)}),e.contentType&&w.jsx("span",{className:"rounded border border-[var(--line)] px-1 text-zinc-500",children:e.contentType})]})]}),w.jsx("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",className:"mono shrink-0 rounded-md border border-[var(--line)] px-2 py-1 text-[11px] text-zinc-400 transition-colors hover:bg-zinc-800 hover:text-zinc-100",children:"Open ↗"}),w.jsx("button",{type:"button",onClick:r,"aria-label":"Close preview",className:"mono shrink-0 rounded-md border border-[var(--line)] px-2 py-1 text-[11px] text-zinc-400 transition-colors hover:bg-zinc-800 hover:text-zinc-100",children:"✕"})]}),w.jsx("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden p-4",children:w.jsx(rA,{item:e,kind:t})})]})}),document.body)}function nA(e){if(!e)return[];const r=e.split("/").filter(a=>a.length>0),t=[];let n="";for(const a of r)n=n?`${n}/${a}`:a,t.push({label:a,prefix:n});return t}function aA(e){window.location.hash=`#/disks/${encodeURIComponent(e)}`}function Fc(e,r){const t=r?`?prefix=${encodeURIComponent(r)}`:"";window.location.hash=`#/disks/${encodeURIComponent(e)}${t}`}function sA(e,r){const t={};return e!==void 0&&(t.prefix=e),r!==void 0&&(t.cursor=r),t}function Vn(e){return e instanceof Error?e.message:String(e)}function wh(e,r){return e?`${e}/${r}`:r}function iA({disk:e,prefix:r,onClose:t,onUploaded:n}){const[a,s]=ve.useState([]),[i,l]=ve.useState(null),[o,c]=ve.useState(null),[u,f]=ve.useState(!1),h=ve.useRef(null);function x(v){s(g=>[...g,...Array.from(v)])}async function m(){if(a.length!==0){l({done:0,total:a.length}),c(null);try{for(let v=0;v<a.length;v++){const g=a[v];g&&(await be.uploadObject(e,wh(r,g.name),g),l({done:v+1,total:a.length}))}await n(),t()}catch(v){c(Vn(v)),l(null)}}}const d=i!==null;return w.jsxs($f,{title:`Upload to ${r?`/${r}`:e}`,onClose:t,footer:w.jsxs(w.Fragment,{children:[w.jsx(si,{onClick:t,disabled:d,children:"Cancel"}),w.jsx(si,{tone:"emerald",onClick:m,disabled:d||a.length===0,children:d?`Uploading ${i.done}/${i.total}…`:"Upload"})]}),children:[w.jsxs("div",{onClick:()=>{var v;return(v=h.current)==null?void 0:v.click()},onDragOver:v=>{v.preventDefault(),f(!0)},onDragLeave:()=>f(!1),onDrop:v=>{v.preventDefault(),f(!1),x(v.dataTransfer.files)},className:`mono cursor-pointer rounded-md border border-dashed px-3 py-6 text-center text-xs transition-colors ${u?"border-emerald-500/50 bg-emerald-500/5 text-emerald-300":"border-[var(--line)] text-zinc-500 hover:text-zinc-300"}`,children:["Drop files here, or click to choose",w.jsx("input",{ref:h,type:"file",multiple:!0,className:"hidden",onChange:v=>{v.target.files&&x(v.target.files),v.target.value=""}})]}),a.length>0&&w.jsx("ul",{className:"mt-3 max-h-48 space-y-1 overflow-auto",children:a.map((v,g)=>w.jsxs("li",{className:"mono flex items-center justify-between gap-2 rounded border border-[var(--line)] px-2 py-1 text-[11px]",children:[w.jsx("span",{className:"truncate text-zinc-300",children:v.name}),w.jsxs("span",{className:"flex shrink-0 items-center gap-2",children:[w.jsx("span",{className:"tnum text-zinc-600",children:Rn(v.size)}),!d&&w.jsx("button",{type:"button","aria-label":`Remove ${v.name}`,onClick:()=>s(y=>y.filter((p,T)=>T!==g)),className:"text-zinc-600 hover:text-rose-400",children:"✕"})]})]},`${v.name}-${g}`))}),o&&w.jsx("p",{className:"mono mt-3 text-[11px] s-error",children:o})]})}function lA({disk:e,prefix:r,onClose:t,onCreated:n}){const[a,s]=ve.useState(""),[i,l]=ve.useState(!1),[o,c]=ve.useState(null),u=ve.useRef(null);ve.useEffect(()=>{var h;(h=u.current)==null||h.focus()},[]);async function f(){const h=a.trim();if(h!==""){l(!0),c(null);try{await be.createFolder(e,wh(r,h)),await n(),t()}catch(x){c(Vn(x)),l(!1)}}}return w.jsxs($f,{title:"New folder",onClose:t,footer:w.jsxs(w.Fragment,{children:[w.jsx(si,{onClick:t,disabled:i,children:"Cancel"}),w.jsx(si,{tone:"emerald",onClick:f,disabled:i||a.trim()==="",children:i?"Creating…":"Create"})]}),children:[w.jsxs("label",{className:"mono flex flex-col gap-1 text-[10px] uppercase tracking-wider text-zinc-600",children:["Folder name",w.jsx("input",{ref:u,value:a,onChange:h=>s(h.target.value),onKeyDown:h=>{h.key==="Enter"&&f()},placeholder:"reports",className:"mono rounded-md border border-[var(--line)] bg-black/30 px-3 py-2 text-sm normal-case tracking-normal text-zinc-100 focus:border-emerald-500/40 focus:outline-none"})]}),w.jsxs("p",{className:"mono mt-2 text-[10px] text-zinc-600",children:["Creates ",r?`/${r}/`:"",w.jsx("span",{className:"text-zinc-400",children:a.trim()||"name"}),"/"]}),o&&w.jsx("p",{className:"mono mt-3 text-[11px] s-error",children:o})]})}function oA({route:e,actions:r}){var ce,J;const t=ns(),n=on({queryKey:["disks"],queryFn:()=>be.disks()}),a=((ce=n.data)==null?void 0:ce.disks)??[],s=e.disk??((J=a[0])==null?void 0:J.name),i=e.prefix,l=`${s??""}::${i??""}`,[o,c]=ve.useState(void 0),[u,f]=ve.useState({key:l,folders:[],files:[],cursor:void 0,lastData:void 0}),[h,x]=ve.useState(null),[m,d]=ve.useState(null),[v,g]=ve.useState(null),[y,p]=ve.useState(!1);u.key!==l&&(f({key:l,folders:[],files:[],cursor:void 0,lastData:void 0}),c(void 0));const T=a.find(D=>D.name===s),I=T?T.capabilities.list:!0,O=on({queryKey:["objects",s,i,o],queryFn:()=>{if(!s)throw new Error("No disk selected");return be.objects(s,sA(i,o))},enabled:!!s&&I}),_=O.data;_&&u.key===l&&u.lastData!==_&&f(o===void 0?{key:l,folders:_.folders,files:_.files,cursor:_.cursor,lastData:_}:{key:l,folders:[...u.folders,..._.folders],files:[...u.files,..._.files],cursor:_.cursor,lastData:_});function L(){c(void 0),f({key:l,folders:[],files:[],cursor:void 0,lastData:void 0})}async function N(D){await t.invalidateQueries({queryKey:["objects",D]}),L()}async function j(D,q,ne){x(q);try{const F=await be.object(D,q);d({...F,disk:D,name:ne})}catch(F){window.alert(`Failed to open "${q}": ${Vn(F)}`)}finally{x(null)}}async function z(D){await navigator.clipboard.writeText(D)}async function B(D,q,ne){const F=window.prompt(`${D==="copy"?"Copy":"Move"} "${ne}" to key:`,ne);if(!(!F||F===ne)){x(ne);try{D==="copy"?await be.copyObject(q,ne,F):await be.moveObject(q,ne,F),await N(q)}catch(V){window.alert(`Failed to ${D} "${ne}": ${Vn(V)}`)}finally{x(null)}}}async function Y(D,q){const ne=Array.from(q);if(ne.length!==0){x("__drop__");try{for(const F of ne)await be.uploadObject(D,wh(i,F.name),F);await N(D)}catch(F){window.alert(`Upload failed: ${Vn(F)}`)}finally{x(null)}}}async function he(D){if(!v||v.kind!=="delete-file"&&v.kind!=="delete-folder")return;const q=v;x("__delete__");try{q.kind==="delete-file"?await be.deleteObject(D,q.key):await be.deleteFolder(D,q.prefix),await N(D),g(null)}catch(ne){window.alert(`Failed to delete: ${Vn(ne)}`)}finally{x(null)}}const se=nA(i),de=!O.isLoading&&!O.isError&&u.folders.length===0&&u.files.length===0;return w.jsxs("section",{className:"rise",children:[w.jsxs("div",{className:"grid grid-cols-[220px_1fr] gap-4",children:[w.jsxs(ai,{className:"h-fit p-2",children:[w.jsx("h3",{className:"mono px-2 py-1 text-[10px] uppercase tracking-wider text-zinc-600",children:"disks"}),n.isLoading&&w.jsx(dr,{children:"Loading…"}),n.isError&&w.jsx("p",{className:"px-2 py-1 text-sm s-error",children:Vn(n.error)}),!n.isLoading&&a.length===0&&w.jsx(dr,{children:"No disks configured."}),w.jsx("ul",{className:"space-y-0.5",children:a.map(D=>{const q=D.name===s;return w.jsx("li",{children:w.jsxs("button",{type:"button",onClick:()=>aA(D.name),className:`mono flex w-full items-center justify-between gap-2 rounded-md border px-2 py-1.5 text-left text-xs transition-colors ${q?"border-[var(--line)] bg-zinc-900 text-zinc-100":"border-transparent text-zinc-400 hover:bg-zinc-900/50 hover:text-zinc-200"}`,children:[w.jsx("span",{className:"truncate",children:D.name}),w.jsxs("span",{className:"flex shrink-0 items-center gap-1.5",children:[D.default&&w.jsx("span",{className:"text-[9px] uppercase tracking-wider text-zinc-600",children:"default"}),!D.capabilities.list&&w.jsx("span",{title:"Listing unsupported on this disk",children:w.jsx(so,{tone:"warn"})})]})]})},D.name)})})]}),w.jsxs(ai,{className:"p-3",children:[!s&&w.jsx(dr,{children:"Select a disk to browse its objects."}),s&&!I&&w.jsxs(dr,{children:["Listing is not supported on disk"," ",w.jsx("span",{className:"mono text-zinc-300",children:s}),"."]}),s&&I&&w.jsxs("div",{onDragOver:r?D=>{D.preventDefault(),p(!0)}:void 0,onDragLeave:r?()=>p(!1):void 0,onDrop:r?D=>{D.preventDefault(),p(!1),Y(s,D.dataTransfer.files)}:void 0,className:`rounded-md ${y?"ring-2 ring-inset ring-emerald-500/50":""}`,children:[w.jsxs("div",{className:"mb-3 flex items-center justify-between gap-2",children:[w.jsxs("nav",{className:"mono flex flex-wrap items-center gap-1 text-xs text-zinc-500",children:[w.jsx("button",{type:"button",onClick:()=>Fc(s,""),className:`rounded px-1.5 py-0.5 hover:bg-zinc-800/60 ${i?"":"text-zinc-100"}`,children:s}),se.map((D,q)=>w.jsxs("span",{className:"flex items-center gap-1",children:[w.jsx("span",{className:"text-zinc-700",children:"/"}),w.jsx("button",{type:"button",onClick:()=>Fc(s,D.prefix),className:`rounded px-1.5 py-0.5 hover:bg-zinc-800/60 ${q===se.length-1?"text-zinc-100":""}`,children:D.label})]},D.prefix))]}),r&&w.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[w.jsx(kt,{tone:"emerald",onClick:()=>g({kind:"upload"}),children:"↑ Upload"}),w.jsx(kt,{onClick:()=>g({kind:"folder"}),children:"+ New folder"})]})]}),O.isLoading&&w.jsx(dr,{children:"Loading objects…"}),O.isError&&w.jsx("p",{className:"text-sm s-error",children:Vn(O.error)}),de&&w.jsx(dr,{children:"This folder is empty."}),(u.folders.length>0||u.files.length>0)&&w.jsxs("table",{className:"w-full text-left text-sm",children:[w.jsx("thead",{children:w.jsxs("tr",{className:"mono border-b border-[var(--line)] text-[10px] uppercase tracking-wider text-zinc-600",children:[w.jsx("th",{className:"py-2 pr-2 font-normal",children:"Name"}),w.jsx("th",{className:"py-2 pr-2 font-normal",children:"Size"}),w.jsx("th",{className:"py-2 pr-2 font-normal",children:"Last modified"}),w.jsx("th",{className:"py-2 pr-2 font-normal",children:"Actions"})]})}),w.jsxs("tbody",{className:"divide-y divide-[var(--line-soft)]",children:[u.folders.map(D=>w.jsxs("tr",{className:"hover:bg-zinc-900/40",children:[w.jsx("td",{className:"py-2 pr-2",children:w.jsxs("button",{type:"button",onClick:()=>Fc(s,D.prefix),className:"flex items-center gap-2 text-zinc-200 hover:text-emerald-300",children:[w.jsx("span",{className:"text-zinc-600",children:"▸"}),D.name]})}),w.jsx("td",{className:"py-2 pr-2 text-zinc-700",children:"—"}),w.jsx("td",{className:"py-2 pr-2 text-zinc-700",children:"—"}),w.jsx("td",{className:"py-2 pr-2",children:r&&w.jsx(kt,{tone:"rose",onClick:()=>g({kind:"delete-folder",prefix:D.prefix,name:D.name}),children:"Delete"})})]},D.prefix)),u.files.map(D=>w.jsxs("tr",{className:"hover:bg-zinc-900/40",children:[w.jsx("td",{className:"mono py-2 pr-2 text-[13px] text-zinc-200",children:D.name}),w.jsx("td",{className:"mono tnum py-2 pr-2 text-xs text-zinc-500",children:Rn(D.sizeBytes)}),w.jsx("td",{className:"py-2 pr-2 text-xs text-zinc-500",children:Gf(D.lastModified)}),w.jsx("td",{className:"py-2 pr-2",children:w.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[w.jsx(kt,{disabled:h===D.key,onClick:()=>j(s,D.key,D.name),children:"Preview"}),w.jsx(kt,{onClick:()=>z(D.key),children:"Copy key"}),r&&w.jsxs(w.Fragment,{children:[w.jsx(kt,{disabled:h===D.key,onClick:()=>B("copy",s,D.key),children:"Copy to…"}),w.jsx(kt,{disabled:h===D.key,onClick:()=>B("move",s,D.key),children:"Move to…"}),w.jsx(kt,{tone:"rose",onClick:()=>g({kind:"delete-file",key:D.key,name:D.name}),children:"Delete"})]})]})})]},D.key))]})]}),u.cursor!==void 0&&w.jsx("div",{className:"mt-3",children:w.jsx(kt,{disabled:O.isFetching,onClick:()=>c(u.cursor),children:O.isFetching?"Loading…":"Load more"})}),r&&y&&w.jsxs("p",{className:"mono mt-3 rounded-md border border-dashed border-emerald-500/40 bg-emerald-500/5 px-3 py-4 text-center text-xs text-emerald-300/80",children:["Drop files to upload to ",i?`/${i}`:s]})]})]})]}),s&&(v==null?void 0:v.kind)==="upload"&&w.jsx(iA,{disk:s,prefix:i,onClose:()=>g(null),onUploaded:()=>N(s)}),s&&(v==null?void 0:v.kind)==="folder"&&w.jsx(lA,{disk:s,prefix:i,onClose:()=>g(null),onCreated:()=>N(s)}),s&&((v==null?void 0:v.kind)==="delete-file"||(v==null?void 0:v.kind)==="delete-folder")&&w.jsxs($f,{title:v.kind==="delete-folder"?"Delete folder":"Delete object",onClose:()=>g(null),footer:w.jsxs(w.Fragment,{children:[w.jsx(si,{onClick:()=>g(null),disabled:h==="__delete__",children:"Cancel"}),w.jsx(si,{tone:"rose",onClick:()=>he(s),disabled:h==="__delete__",children:h==="__delete__"?"Deleting…":"Delete"})]}),children:[w.jsxs("p",{className:"text-sm text-zinc-300",children:["Delete ",w.jsx("span",{className:"mono text-zinc-100",children:v.name}),"?"]}),w.jsx("p",{className:"mono mt-2 text-[11px] text-zinc-600",children:v.kind==="delete-folder"?"Every object inside this folder is removed. This cannot be undone.":"This cannot be undone."})]}),w.jsx(tA,{item:m,onClose:()=>d(null)})]})}function yo(e){return e===void 0?"#/library":`#/library?collection=${encodeURIComponent(e)}`}function cA(e){return e.startsWith("image/")}function uA({collections:e,selected:r}){const t=n=>`mono flex items-center gap-1.5 rounded-md border px-2.5 py-1 text-xs transition-colors ${n?"border-zinc-600 bg-zinc-900 text-zinc-100":"border-transparent text-zinc-500 hover:text-zinc-300"}`;return w.jsxs("div",{className:"mb-4 flex flex-wrap gap-1",children:[w.jsx("a",{href:yo(void 0),className:t(r===void 0),children:"all"}),e.map(n=>w.jsxs("a",{href:yo(n.key),className:t(r===n.key),children:[n.key,w.jsxs("span",{className:"tnum text-zinc-600",children:[n.count," · ",Rn(n.sumSize)]})]},n.key))]})}function fA({records:e,collection:r}){return e.length===0?w.jsxs(dr,{children:["No records",r?` in "${r}"`:"","."]}):w.jsx("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4",children:e.map(t=>w.jsxs("a",{href:`#/library/${encodeURIComponent(t.id)}${r?`?collection=${encodeURIComponent(r)}`:""}`,className:"rounded-lg border border-[var(--line)] bg-[var(--panel)] p-3 text-sm transition-colors hover:border-zinc-600",children:[w.jsx("div",{className:"truncate font-medium text-zinc-200",children:t.fileName}),w.jsx("div",{className:"mono mt-1 text-[10px] text-zinc-500",children:t.mimeType}),w.jsxs("div",{className:"mono tnum mt-2 flex justify-between text-[10px] text-zinc-600",children:[w.jsx("span",{children:Rn(t.size)}),w.jsx("span",{children:Gf(t.createdAt)})]})]},t.id))})}function Fa({label:e,children:r}){return w.jsxs(w.Fragment,{children:[w.jsx("dt",{className:"mono text-[10px] uppercase tracking-wider text-zinc-600",children:e}),w.jsx("dd",{className:"truncate text-zinc-200",children:r})]})}function hA({route:e}){const r=ns(),[t,n]=ve.useState(void 0),a=e.recordId,s=on({queryKey:["libraryRecord",a??null],queryFn:()=>a===void 0?Promise.reject(new Error("missing record id")):be.libraryRecord(a),enabled:a!==void 0});async function i(){if(a!==void 0){n(void 0);try{await be.deleteLibraryRecord(a),await r.invalidateQueries({queryKey:["library"]}),await r.invalidateQueries({queryKey:["collections"]}),window.location.hash=yo(e.collection)}catch{n("Delete failed (actions may be disabled)")}}}const l=s.data;return w.jsxs("div",{children:[w.jsx("a",{href:yo(e.collection),className:"mono text-xs text-zinc-500 hover:text-zinc-300",children:"← back to library"}),s.isLoading&&w.jsx(dr,{children:"Loading record…"}),s.isError&&w.jsx("p",{className:"mt-3 text-sm s-error",children:"Failed to load record."}),l&&w.jsxs("div",{className:"mt-3",children:[w.jsxs(ai,{className:"p-4",children:[w.jsx("h3",{className:"font-semibold text-zinc-100",children:l.record.fileName}),w.jsxs("dl",{className:"mt-3 grid grid-cols-[110px_1fr] gap-x-4 gap-y-2 text-xs",children:[w.jsx(Fa,{label:"Collection",children:l.record.collection}),w.jsx(Fa,{label:"Mime type",children:w.jsx("span",{className:"mono",children:l.record.mimeType})}),w.jsx(Fa,{label:"Size",children:Rn(l.record.size)}),w.jsx(Fa,{label:"Disk",children:w.jsx("span",{className:"mono",children:l.record.disk})}),w.jsx(Fa,{label:"Path",children:w.jsx("span",{className:"mono",children:l.record.path})}),w.jsxs(Fa,{label:"Owner",children:[l.record.ownerType," · ",l.record.ownerId]}),w.jsx(Fa,{label:"Created",children:Gf(l.record.createdAt)})]}),w.jsxs("div",{className:"mt-4",children:[w.jsx(kt,{tone:"rose",onClick:i,children:"Delete"}),t&&w.jsx("p",{className:"mt-2 text-xs s-error",children:t})]})]}),w.jsx("h4",{className:"mono mb-2 mt-4 text-[10px] uppercase tracking-wider text-zinc-600",children:"variants"}),l.variants.length===0?w.jsx(dr,{children:"No variants."}):w.jsx("div",{className:"flex flex-wrap gap-3",children:l.variants.map(o=>w.jsxs("div",{className:"rounded-lg border border-[var(--line)] bg-[var(--panel)] p-2 text-xs",children:[w.jsx("div",{className:"mono mb-1.5 text-[10px] uppercase tracking-wider text-zinc-500",children:o.name}),cA(l.record.mimeType)?w.jsx("img",{src:o.url,alt:o.name,className:"max-h-40 rounded border border-[var(--line)]"}):w.jsx("a",{href:o.url,target:"_blank",rel:"noreferrer",className:"text-emerald-300 hover:text-emerald-200",children:"Open ↗"})]},o.name))})]})]})}function dA(e,r){const t={};return e!==void 0&&(t.collection=e),r!==void 0&&(t.cursor=r),t}function xA({route:e,hasStore:r}){var s;const t=on({queryKey:["collections"],queryFn:()=>be.collections(),enabled:r}),n=O2({queryKey:["library",e.collection??null],queryFn:({pageParam:i})=>be.library(dA(e.collection,i)),initialPageParam:"",getNextPageParam:i=>i.cursor,enabled:r}),a=n.data?n.data.pages.flatMap(i=>i.records):[];return w.jsxs("div",{children:[w.jsx(uA,{collections:((s=t.data)==null?void 0:s.collections)??[],selected:e.collection}),n.isLoading&&w.jsx(dr,{children:"Loading library…"}),n.isError&&w.jsx("p",{className:"text-sm s-error",children:"Failed to load library."}),w.jsx(fA,{records:a,collection:e.collection}),n.hasNextPage&&w.jsx("div",{className:"mt-4",children:w.jsx(kt,{onClick:()=>n.fetchNextPage(),disabled:n.isFetchingNextPage,children:n.isFetchingNextPage?"Loading…":"Load more"})})]})}function pA({route:e,hasStore:r}){return r?w.jsx("section",{className:"rise",children:e.recordId?w.jsx(hA,{route:e}):w.jsx(xA,{route:e,hasStore:r})}):w.jsx("section",{className:"rise",children:w.jsx("div",{className:"grid place-items-center py-16 text-center",children:w.jsxs("div",{className:"max-w-sm",children:[w.jsx("div",{className:"mono mb-2 text-[10px] uppercase tracking-[0.2em] text-zinc-600",children:"library"}),w.jsxs("p",{className:"text-sm text-zinc-500",children:["No media store configured. Bind a"," ",w.jsx("code",{className:"mono text-zinc-300",children:"MediaStore"})," to browse collections and their variants here."]})]})})})}const mg=["uploads"];function vg({percent:e}){if(e===null)return w.jsx("span",{className:"mono text-[10px] text-zinc-600",children:"unknown size"});const r=Math.min(100,Math.max(0,e));return w.jsxs("div",{className:"flex items-center gap-2",children:[w.jsx("div",{className:"h-1.5 w-28 overflow-hidden rounded-full bg-zinc-800",children:w.jsx("div",{className:"h-full rounded-full bg-emerald-500/80 transition-[width]",style:{width:`${r}%`}})}),w.jsxs("span",{className:"mono tnum text-[10px] text-zinc-500",children:[r,"%"]})]})}function mA({actions:e}){var n;const r=on({queryKey:mg,queryFn:()=>be.uploads({}),refetchInterval:2e3});if(r.isLoading)return w.jsx(dr,{children:"Loading uploads…"});if(r.isError)return w.jsx(dr,{children:"Failed to load uploads."});const t=((n=r.data)==null?void 0:n.uploads)??[];return w.jsxs("section",{className:"rise",children:[w.jsxs("div",{className:"mb-3 flex items-center gap-2",children:[w.jsx(so,{tone:"live",pulse:!0}),w.jsxs("span",{className:"mono text-[11px] text-zinc-500",children:["Live resumable sessions · refreshed every 2s",e?" · cancel from a session detail":""]})]}),t.length===0?w.jsx(dr,{children:"No uploads in progress."}):w.jsx(ai,{className:"overflow-hidden",children:w.jsxs("table",{className:"w-full text-left text-sm",children:[w.jsx("thead",{children:w.jsxs("tr",{className:"mono border-b border-[var(--line)] text-[10px] uppercase tracking-wider text-zinc-600",children:[w.jsx("th",{className:"px-4 py-2 font-normal",children:"Key"}),w.jsx("th",{className:"px-4 py-2 font-normal",children:"Disk"}),w.jsx("th",{className:"px-4 py-2 font-normal",children:"Progress"}),w.jsx("th",{className:"px-4 py-2 font-normal",children:"Parts"}),w.jsx("th",{className:"px-4 py-2 font-normal",children:"Age"})]})}),w.jsx("tbody",{className:"divide-y divide-[var(--line-soft)]",children:t.map(a=>w.jsxs("tr",{className:"hover:bg-zinc-900/40",children:[w.jsx("td",{className:"max-w-xs truncate px-4 py-2",children:w.jsx("a",{href:`#/uploads/${encodeURIComponent(a.id)}`,className:"mono text-xs text-zinc-200 hover:text-emerald-300",children:a.key})}),w.jsx("td",{className:"mono px-4 py-2 text-xs text-zinc-400",children:a.disk}),w.jsx("td",{className:"px-4 py-2",children:w.jsx(vg,{percent:a.percent})}),w.jsx("td",{className:"mono tnum px-4 py-2 text-xs text-zinc-400",children:a.parts}),w.jsx("td",{className:"px-4 py-2 text-xs text-zinc-500",children:Im(a.createdAt)??"—"})]},a.id))})]})})]})}function Ca({label:e,children:r}){return w.jsxs(w.Fragment,{children:[w.jsx("dt",{className:"mono text-[10px] uppercase tracking-wider text-zinc-600",children:e}),w.jsx("dd",{className:"text-zinc-200",children:r})]})}function vA({uploadId:e,actions:r}){const t=ns(),n=on({queryKey:["upload",e],queryFn:()=>be.upload(e)}),a=N2({mutationFn:()=>be.abortUpload(e),onSuccess:async()=>{await t.invalidateQueries({queryKey:mg}),window.location.hash="#/uploads"}});return w.jsxs("section",{className:"rise",children:[w.jsx("a",{href:"#/uploads",className:"mono text-xs text-zinc-500 hover:text-zinc-300",children:"← back"}),n.isLoading&&w.jsx(dr,{children:"Loading upload…"}),n.isError&&w.jsx(dr,{children:"Failed to load upload."}),n.data&&w.jsxs("div",{className:"mt-2",children:[w.jsxs(ai,{className:"p-4",children:[w.jsxs("dl",{className:"grid grid-cols-[120px_1fr] gap-x-4 gap-y-2 text-sm",children:[w.jsx(Ca,{label:"Key",children:w.jsx("span",{className:"mono truncate text-xs",children:n.data.upload.key})}),w.jsx(Ca,{label:"Disk",children:w.jsx("span",{className:"mono text-xs",children:n.data.upload.disk})}),w.jsx(Ca,{label:"Progress",children:w.jsx(vg,{percent:n.data.upload.percent})}),w.jsx(Ca,{label:"Offset",children:w.jsx("span",{className:"mono tnum text-xs",children:n.data.upload.offset})}),w.jsx(Ca,{label:"Size",children:w.jsx("span",{className:"mono tnum text-xs",children:n.data.upload.size??"unknown"})}),w.jsx(Ca,{label:"Multipart",children:n.data.upload.multipart?"yes":"no"}),w.jsx(Ca,{label:"Age",children:Im(n.data.upload.createdAt)??"—"})]}),r&&w.jsxs("div",{className:"mt-4",children:[w.jsx(kt,{tone:"rose",onClick:()=>a.mutate(),disabled:a.isPending,title:"Removes the resumable session so it stops here. An incomplete underlying multipart upload is reaped by the bucket lifecycle policy, not by this action.",children:a.isPending?"Canceling…":"Cancel session"}),a.isError&&w.jsx("p",{className:"mt-2 text-xs s-error",children:"Failed to cancel session."})]})]}),w.jsx("h3",{className:"mono mb-1 mt-4 text-[10px] uppercase tracking-wider text-zinc-600",children:"parts"}),n.data.parts.length===0?w.jsx(dr,{children:"No parts uploaded yet."}):w.jsx(ai,{className:"overflow-hidden",children:w.jsxs("table",{className:"w-full text-left text-sm",children:[w.jsx("thead",{children:w.jsxs("tr",{className:"mono border-b border-[var(--line)] text-[10px] uppercase tracking-wider text-zinc-600",children:[w.jsx("th",{className:"px-4 py-2 font-normal",children:"Part"}),w.jsx("th",{className:"px-4 py-2 font-normal",children:"ETag"})]})}),w.jsx("tbody",{className:"divide-y divide-[var(--line-soft)]",children:n.data.parts.map(s=>w.jsxs("tr",{className:"hover:bg-zinc-900/40",children:[w.jsx("td",{className:"mono tnum px-4 py-2 text-xs text-zinc-300",children:s.partNumber}),w.jsx("td",{className:"mono px-4 py-2 text-xs text-zinc-500",children:s.etag})]},s.partNumber))})]})})]})]})}function gA({route:e,actions:r}){return e.uploadId?w.jsx(vA,{uploadId:e.uploadId,actions:r}):w.jsx(mA,{actions:r})}const yA=[{id:"disks",label:"disks"},{id:"uploads",label:"uploads"},{id:"library",label:"library"}];function wA({className:e}){return w.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.8,strokeLinecap:"round",strokeLinejoin:"round",className:e,role:"img","aria-label":"media",children:[w.jsx("title",{children:"media"}),w.jsx("path",{d:"M12 3 21 7.5 12 12 3 7.5z",opacity:.9}),w.jsx("path",{d:"M3 12l9 4.5L21 12",opacity:.55}),w.jsx("path",{d:"M3 16.5 12 21l9-4.5",opacity:.3})]})}function SA(){var l,o,c,u,f,h;const e=zw(),r=ns(),t=on({queryKey:["me"],queryFn:()=>be.me()}),n=((l=t.data)==null?void 0:l.state)==="authenticated",a=on({queryKey:["topology"],queryFn:()=>be.topology(),enabled:t.data!==void 0&&t.data.state!=="login"});async function s(){await be.logout(),await r.invalidateQueries()}if(((o=t.data)==null?void 0:o.state)==="login")return w.jsx(bw,{modes:t.data.modes});const i=(x,m)=>w.jsxs("span",{className:`mono flex items-center gap-1 text-[10px] ${m?"text-zinc-400":"text-zinc-700"}`,children:[w.jsx(so,{tone:m?"ok":"idle"}),x]});return w.jsxs(w.Fragment,{children:[w.jsx("div",{className:"app-bg"}),w.jsxs("div",{className:"relative z-10 flex h-full flex-col",children:[w.jsxs("header",{className:"z-10 flex items-center gap-4 border-b border-[var(--line)] px-5 py-3",children:[w.jsxs("div",{className:"flex items-center gap-2.5",children:[w.jsx("div",{className:"grid h-7 w-7 place-items-center rounded-md border border-emerald-500/30 bg-emerald-500/10",children:w.jsx(wA,{className:"h-4 w-4 text-emerald-400"})}),w.jsxs("div",{className:"leading-none",children:[w.jsx("div",{className:"text-sm font-semibold tracking-tight",children:"media"}),w.jsx("div",{className:"mono text-[10px] uppercase tracking-[0.2em] text-zinc-600",children:"console"})]})]}),w.jsx("nav",{className:"ml-2 flex flex-wrap items-center gap-1",children:yA.map(x=>w.jsx("a",{href:`#/${x.id}`,className:`mono flex items-center gap-2 rounded-md border px-2.5 py-1 text-xs uppercase tracking-wide transition-colors ${e.tab===x.id?"border-zinc-600 bg-zinc-900 text-zinc-100":"border-transparent text-zinc-500 hover:text-zinc-300"}`,children:x.label},x.id))}),a.data&&w.jsxs("div",{className:"ml-auto flex items-center gap-3",children:[w.jsxs("span",{className:"mono tnum text-[10px] text-zinc-500",children:[a.data.disks," ",a.data.disks===1?"disk":"disks"]}),i("store",a.data.hasStore),i("uploads",a.data.hasUploads),i("actions",a.data.actions),w.jsxs("span",{className:"ml-1 flex items-center gap-1.5 text-xs text-zinc-500",children:[w.jsx(so,{tone:"ok",pulse:!0}),"live"]}),n&&w.jsx("button",{type:"button",onClick:s,className:"mono ml-1 rounded-md border border-[var(--line)] px-2 py-1 text-[10px] uppercase tracking-wider text-zinc-500 transition-colors hover:bg-zinc-800 hover:text-zinc-200",children:((c=t.data)==null?void 0:c.state)==="authenticated"&&t.data.user.name?`sign out · ${t.data.user.name}`:"sign out"})]})]}),w.jsxs("main",{className:"min-h-0 flex-1 overflow-auto p-6",children:[e.tab==="disks"&&w.jsx(oA,{route:e,actions:((u=a.data)==null?void 0:u.actions)??!1}),e.tab==="uploads"&&w.jsx(gA,{route:e,actions:((f=a.data)==null?void 0:f.actions)??!1}),e.tab==="library"&&w.jsx(pA,{route:e,hasStore:((h=a.data)==null?void 0:h.hasStore)??!1})]})]})]})}export{SA as A,_A as Q,TA as a,Lw as c,w as j,ve as r};
79
+ `))):t,i=XC(e),l=i==="csv"?w.jsx(X1,{text:s,delimiter:","}):i==="tsv"?w.jsx(X1,{text:s,delimiter:" "}):w.jsx("pre",{className:"mono min-h-0 flex-1 overflow-auto whitespace-pre-wrap break-words rounded-md border border-[var(--line)] bg-black/30 p-3 text-xs text-zinc-300",children:i==="json"?ZC(s):s});return w.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-2",children:[a&&w.jsxs("div",{className:"mono shrink-0 rounded-md border border-amber-500/30 bg-amber-500/10 px-3 py-1.5 text-[11px] text-amber-300",children:["Sample — the first ",Rn(n)," of ",Rn(e.size),". Filters and sort apply to this sample; open the original ↗ for the whole file."]}),l]})}function rA({item:e,kind:r}){switch(r){case"image":return w.jsx("div",{className:"grid min-h-0 flex-1 place-items-center",children:w.jsx("img",{src:e.url,alt:e.name,className:"max-h-full max-w-full rounded-md object-contain"})});case"video":return w.jsx("div",{className:"grid min-h-0 flex-1 place-items-center",children:w.jsx("video",{src:e.url,controls:!0,className:"max-h-full max-w-full rounded-md"})});case"audio":return w.jsx("div",{className:"grid min-h-0 flex-1 place-items-center",children:w.jsx("audio",{src:e.url,controls:!0,className:"w-full max-w-md"})});case"pdf":return w.jsx("iframe",{src:be.objectRawUrl(e.disk,e.key),title:e.name,className:"min-h-0 w-full flex-1 rounded-md border border-[var(--line)] bg-white"});case"text":return w.jsx(eA,{item:e});case"sheet":return w.jsx(JC,{item:e});default:return w.jsx(go,{item:e,message:`No inline preview for ${e.contentType??"this type"}`})}}function tA({item:e,onClose:r}){if(ve.useEffect(()=>{if(!e)return;const n=a=>{a.key==="Escape"&&r()};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[e,r]),!e)return null;const t=KC(e);return Wf.createPortal(w.jsx("div",{className:"fixed inset-0 z-50 flex flex-col items-center justify-center bg-black/80 p-6 backdrop-blur-sm",onClick:n=>{n.target===n.currentTarget&&r()},children:w.jsxs("div",{className:"flex h-[86vh] max-h-full w-full max-w-5xl flex-col overflow-hidden rounded-lg border border-[var(--line)] bg-[var(--panel)] shadow-2xl","aria-label":`Preview of ${e.name}`,children:[w.jsxs("div",{className:"flex items-center gap-3 border-b border-[var(--line)] px-4 py-2.5",children:[w.jsxs("div",{className:"min-w-0 flex-1",children:[w.jsx("div",{className:"mono truncate text-sm text-zinc-200",children:e.name}),w.jsxs("div",{className:"mono tnum mt-0.5 flex items-center gap-2 text-[10px] text-zinc-600",children:[w.jsx("span",{children:Rn(e.size)}),e.contentType&&w.jsx("span",{className:"rounded border border-[var(--line)] px-1 text-zinc-500",children:e.contentType})]})]}),w.jsx("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",className:"mono shrink-0 rounded-md border border-[var(--line)] px-2 py-1 text-[11px] text-zinc-400 transition-colors hover:bg-zinc-800 hover:text-zinc-100",children:"Open ↗"}),w.jsx("button",{type:"button",onClick:r,"aria-label":"Close preview",className:"mono shrink-0 rounded-md border border-[var(--line)] px-2 py-1 text-[11px] text-zinc-400 transition-colors hover:bg-zinc-800 hover:text-zinc-100",children:"✕"})]}),w.jsx("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden p-4",children:w.jsx(rA,{item:e,kind:t})})]})}),document.body)}function nA(e){if(!e)return[];const r=e.split("/").filter(a=>a.length>0),t=[];let n="";for(const a of r)n=n?`${n}/${a}`:a,t.push({label:a,prefix:n});return t}function aA(e){window.location.hash=`#/disks/${encodeURIComponent(e)}`}function Fc(e,r){const t=r?`?prefix=${encodeURIComponent(r)}`:"";window.location.hash=`#/disks/${encodeURIComponent(e)}${t}`}function sA(e,r){const t={};return e!==void 0&&(t.prefix=e),r!==void 0&&(t.cursor=r),t}function Vn(e){return e instanceof Error?e.message:String(e)}function wh(e,r){const t=e==null?void 0:e.replace(/\/+$/,"");return t?`${t}/${r}`:r}function iA({disk:e,prefix:r,onClose:t,onUploaded:n}){const[a,s]=ve.useState([]),[i,l]=ve.useState(null),[o,c]=ve.useState(null),[u,f]=ve.useState(!1),h=ve.useRef(null);function x(v){s(g=>[...g,...Array.from(v)])}async function m(){if(a.length!==0){l({done:0,total:a.length}),c(null);try{for(let v=0;v<a.length;v++){const g=a[v];g&&(await be.uploadObject(e,wh(r,g.name),g),l({done:v+1,total:a.length}))}await n(),t()}catch(v){c(Vn(v)),l(null)}}}const d=i!==null;return w.jsxs($f,{title:`Upload to ${r?`/${r}`:e}`,onClose:t,footer:w.jsxs(w.Fragment,{children:[w.jsx(si,{onClick:t,disabled:d,children:"Cancel"}),w.jsx(si,{tone:"emerald",onClick:m,disabled:d||a.length===0,children:d?`Uploading ${i.done}/${i.total}…`:"Upload"})]}),children:[w.jsxs("div",{onClick:()=>{var v;return(v=h.current)==null?void 0:v.click()},onDragOver:v=>{v.preventDefault(),f(!0)},onDragLeave:()=>f(!1),onDrop:v=>{v.preventDefault(),f(!1),x(v.dataTransfer.files)},className:`mono cursor-pointer rounded-md border border-dashed px-3 py-6 text-center text-xs transition-colors ${u?"border-emerald-500/50 bg-emerald-500/5 text-emerald-300":"border-[var(--line)] text-zinc-500 hover:text-zinc-300"}`,children:["Drop files here, or click to choose",w.jsx("input",{ref:h,type:"file",multiple:!0,className:"hidden",onChange:v=>{v.target.files&&x(v.target.files),v.target.value=""}})]}),a.length>0&&w.jsx("ul",{className:"mt-3 max-h-48 space-y-1 overflow-auto",children:a.map((v,g)=>w.jsxs("li",{className:"mono flex items-center justify-between gap-2 rounded border border-[var(--line)] px-2 py-1 text-[11px]",children:[w.jsx("span",{className:"truncate text-zinc-300",children:v.name}),w.jsxs("span",{className:"flex shrink-0 items-center gap-2",children:[w.jsx("span",{className:"tnum text-zinc-600",children:Rn(v.size)}),!d&&w.jsx("button",{type:"button","aria-label":`Remove ${v.name}`,onClick:()=>s(y=>y.filter((p,T)=>T!==g)),className:"text-zinc-600 hover:text-rose-400",children:"✕"})]})]},`${v.name}-${g}`))}),o&&w.jsx("p",{className:"mono mt-3 text-[11px] s-error",children:o})]})}function lA({disk:e,prefix:r,onClose:t,onCreated:n}){const[a,s]=ve.useState(""),[i,l]=ve.useState(!1),[o,c]=ve.useState(null),u=ve.useRef(null);ve.useEffect(()=>{var h;(h=u.current)==null||h.focus()},[]);async function f(){const h=a.trim();if(h!==""){l(!0),c(null);try{await be.createFolder(e,wh(r,h)),await n(),t()}catch(x){c(Vn(x)),l(!1)}}}return w.jsxs($f,{title:"New folder",onClose:t,footer:w.jsxs(w.Fragment,{children:[w.jsx(si,{onClick:t,disabled:i,children:"Cancel"}),w.jsx(si,{tone:"emerald",onClick:f,disabled:i||a.trim()==="",children:i?"Creating…":"Create"})]}),children:[w.jsxs("label",{className:"mono flex flex-col gap-1 text-[10px] uppercase tracking-wider text-zinc-600",children:["Folder name",w.jsx("input",{ref:u,value:a,onChange:h=>s(h.target.value),onKeyDown:h=>{h.key==="Enter"&&f()},placeholder:"reports",className:"mono rounded-md border border-[var(--line)] bg-black/30 px-3 py-2 text-sm normal-case tracking-normal text-zinc-100 focus:border-emerald-500/40 focus:outline-none"})]}),w.jsxs("p",{className:"mono mt-2 text-[10px] text-zinc-600",children:["Creates ",r?`/${r}/`:"",w.jsx("span",{className:"text-zinc-400",children:a.trim()||"name"}),"/"]}),o&&w.jsx("p",{className:"mono mt-3 text-[11px] s-error",children:o})]})}function oA({route:e,actions:r}){var ce,J;const t=ns(),n=on({queryKey:["disks"],queryFn:()=>be.disks()}),a=((ce=n.data)==null?void 0:ce.disks)??[],s=e.disk??((J=a[0])==null?void 0:J.name),i=e.prefix,l=`${s??""}::${i??""}`,[o,c]=ve.useState(void 0),[u,f]=ve.useState({key:l,folders:[],files:[],cursor:void 0,lastData:void 0}),[h,x]=ve.useState(null),[m,d]=ve.useState(null),[v,g]=ve.useState(null),[y,p]=ve.useState(!1);u.key!==l&&(f({key:l,folders:[],files:[],cursor:void 0,lastData:void 0}),c(void 0));const T=a.find(D=>D.name===s),I=T?T.capabilities.list:!0,O=on({queryKey:["objects",s,i,o],queryFn:()=>{if(!s)throw new Error("No disk selected");return be.objects(s,sA(i,o))},enabled:!!s&&I}),_=O.data;_&&u.key===l&&u.lastData!==_&&f(o===void 0?{key:l,folders:_.folders,files:_.files,cursor:_.cursor,lastData:_}:{key:l,folders:[...u.folders,..._.folders],files:[...u.files,..._.files],cursor:_.cursor,lastData:_});function L(){c(void 0),f({key:l,folders:[],files:[],cursor:void 0,lastData:void 0})}async function N(D){await t.invalidateQueries({queryKey:["objects",D]}),L()}async function j(D,q,ne){x(q);try{const F=await be.object(D,q);d({...F,disk:D,name:ne})}catch(F){window.alert(`Failed to open "${q}": ${Vn(F)}`)}finally{x(null)}}async function z(D){await navigator.clipboard.writeText(D)}async function B(D,q,ne){const F=window.prompt(`${D==="copy"?"Copy":"Move"} "${ne}" to key:`,ne);if(!(!F||F===ne)){x(ne);try{D==="copy"?await be.copyObject(q,ne,F):await be.moveObject(q,ne,F),await N(q)}catch(V){window.alert(`Failed to ${D} "${ne}": ${Vn(V)}`)}finally{x(null)}}}async function Y(D,q){const ne=Array.from(q);if(ne.length!==0){x("__drop__");try{for(const F of ne)await be.uploadObject(D,wh(i,F.name),F);await N(D)}catch(F){window.alert(`Upload failed: ${Vn(F)}`)}finally{x(null)}}}async function he(D){if(!v||v.kind!=="delete-file"&&v.kind!=="delete-folder")return;const q=v;x("__delete__");try{q.kind==="delete-file"?await be.deleteObject(D,q.key):await be.deleteFolder(D,q.prefix),await N(D),g(null)}catch(ne){window.alert(`Failed to delete: ${Vn(ne)}`)}finally{x(null)}}const se=nA(i),de=!O.isLoading&&!O.isError&&u.folders.length===0&&u.files.length===0;return w.jsxs("section",{className:"rise",children:[w.jsxs("div",{className:"grid grid-cols-[220px_1fr] gap-4",children:[w.jsxs(ai,{className:"h-fit p-2",children:[w.jsx("h3",{className:"mono px-2 py-1 text-[10px] uppercase tracking-wider text-zinc-600",children:"disks"}),n.isLoading&&w.jsx(dr,{children:"Loading…"}),n.isError&&w.jsx("p",{className:"px-2 py-1 text-sm s-error",children:Vn(n.error)}),!n.isLoading&&a.length===0&&w.jsx(dr,{children:"No disks configured."}),w.jsx("ul",{className:"space-y-0.5",children:a.map(D=>{const q=D.name===s;return w.jsx("li",{children:w.jsxs("button",{type:"button",onClick:()=>aA(D.name),className:`mono flex w-full items-center justify-between gap-2 rounded-md border px-2 py-1.5 text-left text-xs transition-colors ${q?"border-[var(--line)] bg-zinc-900 text-zinc-100":"border-transparent text-zinc-400 hover:bg-zinc-900/50 hover:text-zinc-200"}`,children:[w.jsx("span",{className:"truncate",children:D.name}),w.jsxs("span",{className:"flex shrink-0 items-center gap-1.5",children:[D.default&&w.jsx("span",{className:"text-[9px] uppercase tracking-wider text-zinc-600",children:"default"}),!D.capabilities.list&&w.jsx("span",{title:"Listing unsupported on this disk",children:w.jsx(so,{tone:"warn"})})]})]})},D.name)})})]}),w.jsxs(ai,{className:"p-3",children:[!s&&w.jsx(dr,{children:"Select a disk to browse its objects."}),s&&!I&&w.jsxs(dr,{children:["Listing is not supported on disk"," ",w.jsx("span",{className:"mono text-zinc-300",children:s}),"."]}),s&&I&&w.jsxs("div",{onDragOver:r?D=>{D.preventDefault(),p(!0)}:void 0,onDragLeave:r?()=>p(!1):void 0,onDrop:r?D=>{D.preventDefault(),p(!1),Y(s,D.dataTransfer.files)}:void 0,className:`rounded-md ${y?"ring-2 ring-inset ring-emerald-500/50":""}`,children:[w.jsxs("div",{className:"mb-3 flex items-center justify-between gap-2",children:[w.jsxs("nav",{className:"mono flex flex-wrap items-center gap-1 text-xs text-zinc-500",children:[w.jsx("button",{type:"button",onClick:()=>Fc(s,""),className:`rounded px-1.5 py-0.5 hover:bg-zinc-800/60 ${i?"":"text-zinc-100"}`,children:s}),se.map((D,q)=>w.jsxs("span",{className:"flex items-center gap-1",children:[w.jsx("span",{className:"text-zinc-700",children:"/"}),w.jsx("button",{type:"button",onClick:()=>Fc(s,D.prefix),className:`rounded px-1.5 py-0.5 hover:bg-zinc-800/60 ${q===se.length-1?"text-zinc-100":""}`,children:D.label})]},D.prefix))]}),r&&w.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[w.jsx(kt,{tone:"emerald",onClick:()=>g({kind:"upload"}),children:"↑ Upload"}),w.jsx(kt,{onClick:()=>g({kind:"folder"}),children:"+ New folder"})]})]}),O.isLoading&&w.jsx(dr,{children:"Loading objects…"}),O.isError&&w.jsx("p",{className:"text-sm s-error",children:Vn(O.error)}),de&&w.jsx(dr,{children:"This folder is empty."}),(u.folders.length>0||u.files.length>0)&&w.jsxs("table",{className:"w-full text-left text-sm",children:[w.jsx("thead",{children:w.jsxs("tr",{className:"mono border-b border-[var(--line)] text-[10px] uppercase tracking-wider text-zinc-600",children:[w.jsx("th",{className:"py-2 pr-2 font-normal",children:"Name"}),w.jsx("th",{className:"py-2 pr-2 font-normal",children:"Size"}),w.jsx("th",{className:"py-2 pr-2 font-normal",children:"Last modified"}),w.jsx("th",{className:"py-2 pr-2 font-normal",children:"Actions"})]})}),w.jsxs("tbody",{className:"divide-y divide-[var(--line-soft)]",children:[u.folders.map(D=>w.jsxs("tr",{className:"hover:bg-zinc-900/40",children:[w.jsx("td",{className:"py-2 pr-2",children:w.jsxs("button",{type:"button",onClick:()=>Fc(s,D.prefix),className:"flex items-center gap-2 text-zinc-200 hover:text-emerald-300",children:[w.jsx("span",{className:"text-zinc-600",children:"▸"}),D.name]})}),w.jsx("td",{className:"py-2 pr-2 text-zinc-700",children:"—"}),w.jsx("td",{className:"py-2 pr-2 text-zinc-700",children:"—"}),w.jsx("td",{className:"py-2 pr-2",children:r&&w.jsx(kt,{tone:"rose",onClick:()=>g({kind:"delete-folder",prefix:D.prefix,name:D.name}),children:"Delete"})})]},D.prefix)),u.files.map(D=>w.jsxs("tr",{className:"hover:bg-zinc-900/40",children:[w.jsx("td",{className:"mono py-2 pr-2 text-[13px] text-zinc-200",children:D.name}),w.jsx("td",{className:"mono tnum py-2 pr-2 text-xs text-zinc-500",children:Rn(D.sizeBytes)}),w.jsx("td",{className:"py-2 pr-2 text-xs text-zinc-500",children:Gf(D.lastModified)}),w.jsx("td",{className:"py-2 pr-2",children:w.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[w.jsx(kt,{disabled:h===D.key,onClick:()=>j(s,D.key,D.name),children:"Preview"}),w.jsx(kt,{onClick:()=>z(D.key),children:"Copy key"}),r&&w.jsxs(w.Fragment,{children:[w.jsx(kt,{disabled:h===D.key,onClick:()=>B("copy",s,D.key),children:"Copy to…"}),w.jsx(kt,{disabled:h===D.key,onClick:()=>B("move",s,D.key),children:"Move to…"}),w.jsx(kt,{tone:"rose",onClick:()=>g({kind:"delete-file",key:D.key,name:D.name}),children:"Delete"})]})]})})]},D.key))]})]}),u.cursor!==void 0&&w.jsx("div",{className:"mt-3",children:w.jsx(kt,{disabled:O.isFetching,onClick:()=>c(u.cursor),children:O.isFetching?"Loading…":"Load more"})}),r&&y&&w.jsxs("p",{className:"mono mt-3 rounded-md border border-dashed border-emerald-500/40 bg-emerald-500/5 px-3 py-4 text-center text-xs text-emerald-300/80",children:["Drop files to upload to ",i?`/${i}`:s]})]})]})]}),s&&(v==null?void 0:v.kind)==="upload"&&w.jsx(iA,{disk:s,prefix:i,onClose:()=>g(null),onUploaded:()=>N(s)}),s&&(v==null?void 0:v.kind)==="folder"&&w.jsx(lA,{disk:s,prefix:i,onClose:()=>g(null),onCreated:()=>N(s)}),s&&((v==null?void 0:v.kind)==="delete-file"||(v==null?void 0:v.kind)==="delete-folder")&&w.jsxs($f,{title:v.kind==="delete-folder"?"Delete folder":"Delete object",onClose:()=>g(null),footer:w.jsxs(w.Fragment,{children:[w.jsx(si,{onClick:()=>g(null),disabled:h==="__delete__",children:"Cancel"}),w.jsx(si,{tone:"rose",onClick:()=>he(s),disabled:h==="__delete__",children:h==="__delete__"?"Deleting…":"Delete"})]}),children:[w.jsxs("p",{className:"text-sm text-zinc-300",children:["Delete ",w.jsx("span",{className:"mono text-zinc-100",children:v.name}),"?"]}),w.jsx("p",{className:"mono mt-2 text-[11px] text-zinc-600",children:v.kind==="delete-folder"?"Every object inside this folder is removed. This cannot be undone.":"This cannot be undone."})]}),w.jsx(tA,{item:m,onClose:()=>d(null)})]})}function yo(e){return e===void 0?"#/library":`#/library?collection=${encodeURIComponent(e)}`}function cA(e){return e.startsWith("image/")}function uA({collections:e,selected:r}){const t=n=>`mono flex items-center gap-1.5 rounded-md border px-2.5 py-1 text-xs transition-colors ${n?"border-zinc-600 bg-zinc-900 text-zinc-100":"border-transparent text-zinc-500 hover:text-zinc-300"}`;return w.jsxs("div",{className:"mb-4 flex flex-wrap gap-1",children:[w.jsx("a",{href:yo(void 0),className:t(r===void 0),children:"all"}),e.map(n=>w.jsxs("a",{href:yo(n.key),className:t(r===n.key),children:[n.key,w.jsxs("span",{className:"tnum text-zinc-600",children:[n.count," · ",Rn(n.sumSize)]})]},n.key))]})}function fA({records:e,collection:r}){return e.length===0?w.jsxs(dr,{children:["No records",r?` in "${r}"`:"","."]}):w.jsx("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4",children:e.map(t=>w.jsxs("a",{href:`#/library/${encodeURIComponent(t.id)}${r?`?collection=${encodeURIComponent(r)}`:""}`,className:"rounded-lg border border-[var(--line)] bg-[var(--panel)] p-3 text-sm transition-colors hover:border-zinc-600",children:[w.jsx("div",{className:"truncate font-medium text-zinc-200",children:t.fileName}),w.jsx("div",{className:"mono mt-1 text-[10px] text-zinc-500",children:t.mimeType}),w.jsxs("div",{className:"mono tnum mt-2 flex justify-between text-[10px] text-zinc-600",children:[w.jsx("span",{children:Rn(t.size)}),w.jsx("span",{children:Gf(t.createdAt)})]})]},t.id))})}function Fa({label:e,children:r}){return w.jsxs(w.Fragment,{children:[w.jsx("dt",{className:"mono text-[10px] uppercase tracking-wider text-zinc-600",children:e}),w.jsx("dd",{className:"truncate text-zinc-200",children:r})]})}function hA({route:e}){const r=ns(),[t,n]=ve.useState(void 0),a=e.recordId,s=on({queryKey:["libraryRecord",a??null],queryFn:()=>a===void 0?Promise.reject(new Error("missing record id")):be.libraryRecord(a),enabled:a!==void 0});async function i(){if(a!==void 0){n(void 0);try{await be.deleteLibraryRecord(a),await r.invalidateQueries({queryKey:["library"]}),await r.invalidateQueries({queryKey:["collections"]}),window.location.hash=yo(e.collection)}catch{n("Delete failed (actions may be disabled)")}}}const l=s.data;return w.jsxs("div",{children:[w.jsx("a",{href:yo(e.collection),className:"mono text-xs text-zinc-500 hover:text-zinc-300",children:"← back to library"}),s.isLoading&&w.jsx(dr,{children:"Loading record…"}),s.isError&&w.jsx("p",{className:"mt-3 text-sm s-error",children:"Failed to load record."}),l&&w.jsxs("div",{className:"mt-3",children:[w.jsxs(ai,{className:"p-4",children:[w.jsx("h3",{className:"font-semibold text-zinc-100",children:l.record.fileName}),w.jsxs("dl",{className:"mt-3 grid grid-cols-[110px_1fr] gap-x-4 gap-y-2 text-xs",children:[w.jsx(Fa,{label:"Collection",children:l.record.collection}),w.jsx(Fa,{label:"Mime type",children:w.jsx("span",{className:"mono",children:l.record.mimeType})}),w.jsx(Fa,{label:"Size",children:Rn(l.record.size)}),w.jsx(Fa,{label:"Disk",children:w.jsx("span",{className:"mono",children:l.record.disk})}),w.jsx(Fa,{label:"Path",children:w.jsx("span",{className:"mono",children:l.record.path})}),w.jsxs(Fa,{label:"Owner",children:[l.record.ownerType," · ",l.record.ownerId]}),w.jsx(Fa,{label:"Created",children:Gf(l.record.createdAt)})]}),w.jsxs("div",{className:"mt-4",children:[w.jsx(kt,{tone:"rose",onClick:i,children:"Delete"}),t&&w.jsx("p",{className:"mt-2 text-xs s-error",children:t})]})]}),w.jsx("h4",{className:"mono mb-2 mt-4 text-[10px] uppercase tracking-wider text-zinc-600",children:"variants"}),l.variants.length===0?w.jsx(dr,{children:"No variants."}):w.jsx("div",{className:"flex flex-wrap gap-3",children:l.variants.map(o=>w.jsxs("div",{className:"rounded-lg border border-[var(--line)] bg-[var(--panel)] p-2 text-xs",children:[w.jsx("div",{className:"mono mb-1.5 text-[10px] uppercase tracking-wider text-zinc-500",children:o.name}),cA(l.record.mimeType)?w.jsx("img",{src:o.url,alt:o.name,className:"max-h-40 rounded border border-[var(--line)]"}):w.jsx("a",{href:o.url,target:"_blank",rel:"noreferrer",className:"text-emerald-300 hover:text-emerald-200",children:"Open ↗"})]},o.name))})]})]})}function dA(e,r){const t={};return e!==void 0&&(t.collection=e),r!==void 0&&(t.cursor=r),t}function xA({route:e,hasStore:r}){var s;const t=on({queryKey:["collections"],queryFn:()=>be.collections(),enabled:r}),n=O2({queryKey:["library",e.collection??null],queryFn:({pageParam:i})=>be.library(dA(e.collection,i)),initialPageParam:"",getNextPageParam:i=>i.cursor,enabled:r}),a=n.data?n.data.pages.flatMap(i=>i.records):[];return w.jsxs("div",{children:[w.jsx(uA,{collections:((s=t.data)==null?void 0:s.collections)??[],selected:e.collection}),n.isLoading&&w.jsx(dr,{children:"Loading library…"}),n.isError&&w.jsx("p",{className:"text-sm s-error",children:"Failed to load library."}),w.jsx(fA,{records:a,collection:e.collection}),n.hasNextPage&&w.jsx("div",{className:"mt-4",children:w.jsx(kt,{onClick:()=>n.fetchNextPage(),disabled:n.isFetchingNextPage,children:n.isFetchingNextPage?"Loading…":"Load more"})})]})}function pA({route:e,hasStore:r}){return r?w.jsx("section",{className:"rise",children:e.recordId?w.jsx(hA,{route:e}):w.jsx(xA,{route:e,hasStore:r})}):w.jsx("section",{className:"rise",children:w.jsx("div",{className:"grid place-items-center py-16 text-center",children:w.jsxs("div",{className:"max-w-sm",children:[w.jsx("div",{className:"mono mb-2 text-[10px] uppercase tracking-[0.2em] text-zinc-600",children:"library"}),w.jsxs("p",{className:"text-sm text-zinc-500",children:["No media store configured. Bind a"," ",w.jsx("code",{className:"mono text-zinc-300",children:"MediaStore"})," to browse collections and their variants here."]})]})})})}const mg=["uploads"];function vg({percent:e}){if(e===null)return w.jsx("span",{className:"mono text-[10px] text-zinc-600",children:"unknown size"});const r=Math.min(100,Math.max(0,e));return w.jsxs("div",{className:"flex items-center gap-2",children:[w.jsx("div",{className:"h-1.5 w-28 overflow-hidden rounded-full bg-zinc-800",children:w.jsx("div",{className:"h-full rounded-full bg-emerald-500/80 transition-[width]",style:{width:`${r}%`}})}),w.jsxs("span",{className:"mono tnum text-[10px] text-zinc-500",children:[r,"%"]})]})}function mA({actions:e}){var n;const r=on({queryKey:mg,queryFn:()=>be.uploads({}),refetchInterval:2e3});if(r.isLoading)return w.jsx(dr,{children:"Loading uploads…"});if(r.isError)return w.jsx(dr,{children:"Failed to load uploads."});const t=((n=r.data)==null?void 0:n.uploads)??[];return w.jsxs("section",{className:"rise",children:[w.jsxs("div",{className:"mb-3 flex items-center gap-2",children:[w.jsx(so,{tone:"live",pulse:!0}),w.jsxs("span",{className:"mono text-[11px] text-zinc-500",children:["Live resumable sessions · refreshed every 2s",e?" · cancel from a session detail":""]})]}),t.length===0?w.jsx(dr,{children:"No uploads in progress."}):w.jsx(ai,{className:"overflow-hidden",children:w.jsxs("table",{className:"w-full text-left text-sm",children:[w.jsx("thead",{children:w.jsxs("tr",{className:"mono border-b border-[var(--line)] text-[10px] uppercase tracking-wider text-zinc-600",children:[w.jsx("th",{className:"px-4 py-2 font-normal",children:"Key"}),w.jsx("th",{className:"px-4 py-2 font-normal",children:"Disk"}),w.jsx("th",{className:"px-4 py-2 font-normal",children:"Progress"}),w.jsx("th",{className:"px-4 py-2 font-normal",children:"Parts"}),w.jsx("th",{className:"px-4 py-2 font-normal",children:"Age"})]})}),w.jsx("tbody",{className:"divide-y divide-[var(--line-soft)]",children:t.map(a=>w.jsxs("tr",{className:"hover:bg-zinc-900/40",children:[w.jsx("td",{className:"max-w-xs truncate px-4 py-2",children:w.jsx("a",{href:`#/uploads/${encodeURIComponent(a.id)}`,className:"mono text-xs text-zinc-200 hover:text-emerald-300",children:a.key})}),w.jsx("td",{className:"mono px-4 py-2 text-xs text-zinc-400",children:a.disk}),w.jsx("td",{className:"px-4 py-2",children:w.jsx(vg,{percent:a.percent})}),w.jsx("td",{className:"mono tnum px-4 py-2 text-xs text-zinc-400",children:a.parts}),w.jsx("td",{className:"px-4 py-2 text-xs text-zinc-500",children:Im(a.createdAt)??"—"})]},a.id))})]})})]})}function Ca({label:e,children:r}){return w.jsxs(w.Fragment,{children:[w.jsx("dt",{className:"mono text-[10px] uppercase tracking-wider text-zinc-600",children:e}),w.jsx("dd",{className:"text-zinc-200",children:r})]})}function vA({uploadId:e,actions:r}){const t=ns(),n=on({queryKey:["upload",e],queryFn:()=>be.upload(e)}),a=N2({mutationFn:()=>be.abortUpload(e),onSuccess:async()=>{await t.invalidateQueries({queryKey:mg}),window.location.hash="#/uploads"}});return w.jsxs("section",{className:"rise",children:[w.jsx("a",{href:"#/uploads",className:"mono text-xs text-zinc-500 hover:text-zinc-300",children:"← back"}),n.isLoading&&w.jsx(dr,{children:"Loading upload…"}),n.isError&&w.jsx(dr,{children:"Failed to load upload."}),n.data&&w.jsxs("div",{className:"mt-2",children:[w.jsxs(ai,{className:"p-4",children:[w.jsxs("dl",{className:"grid grid-cols-[120px_1fr] gap-x-4 gap-y-2 text-sm",children:[w.jsx(Ca,{label:"Key",children:w.jsx("span",{className:"mono truncate text-xs",children:n.data.upload.key})}),w.jsx(Ca,{label:"Disk",children:w.jsx("span",{className:"mono text-xs",children:n.data.upload.disk})}),w.jsx(Ca,{label:"Progress",children:w.jsx(vg,{percent:n.data.upload.percent})}),w.jsx(Ca,{label:"Offset",children:w.jsx("span",{className:"mono tnum text-xs",children:n.data.upload.offset})}),w.jsx(Ca,{label:"Size",children:w.jsx("span",{className:"mono tnum text-xs",children:n.data.upload.size??"unknown"})}),w.jsx(Ca,{label:"Multipart",children:n.data.upload.multipart?"yes":"no"}),w.jsx(Ca,{label:"Age",children:Im(n.data.upload.createdAt)??"—"})]}),r&&w.jsxs("div",{className:"mt-4",children:[w.jsx(kt,{tone:"rose",onClick:()=>a.mutate(),disabled:a.isPending,title:"Removes the resumable session so it stops here. An incomplete underlying multipart upload is reaped by the bucket lifecycle policy, not by this action.",children:a.isPending?"Canceling…":"Cancel session"}),a.isError&&w.jsx("p",{className:"mt-2 text-xs s-error",children:"Failed to cancel session."})]})]}),w.jsx("h3",{className:"mono mb-1 mt-4 text-[10px] uppercase tracking-wider text-zinc-600",children:"parts"}),n.data.parts.length===0?w.jsx(dr,{children:"No parts uploaded yet."}):w.jsx(ai,{className:"overflow-hidden",children:w.jsxs("table",{className:"w-full text-left text-sm",children:[w.jsx("thead",{children:w.jsxs("tr",{className:"mono border-b border-[var(--line)] text-[10px] uppercase tracking-wider text-zinc-600",children:[w.jsx("th",{className:"px-4 py-2 font-normal",children:"Part"}),w.jsx("th",{className:"px-4 py-2 font-normal",children:"ETag"})]})}),w.jsx("tbody",{className:"divide-y divide-[var(--line-soft)]",children:n.data.parts.map(s=>w.jsxs("tr",{className:"hover:bg-zinc-900/40",children:[w.jsx("td",{className:"mono tnum px-4 py-2 text-xs text-zinc-300",children:s.partNumber}),w.jsx("td",{className:"mono px-4 py-2 text-xs text-zinc-500",children:s.etag})]},s.partNumber))})]})})]})]})}function gA({route:e,actions:r}){return e.uploadId?w.jsx(vA,{uploadId:e.uploadId,actions:r}):w.jsx(mA,{actions:r})}const yA=[{id:"disks",label:"disks"},{id:"uploads",label:"uploads"},{id:"library",label:"library"}];function wA({className:e}){return w.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.8,strokeLinecap:"round",strokeLinejoin:"round",className:e,role:"img","aria-label":"media",children:[w.jsx("title",{children:"media"}),w.jsx("path",{d:"M12 3 21 7.5 12 12 3 7.5z",opacity:.9}),w.jsx("path",{d:"M3 12l9 4.5L21 12",opacity:.55}),w.jsx("path",{d:"M3 16.5 12 21l9-4.5",opacity:.3})]})}function SA(){var l,o,c,u,f,h;const e=zw(),r=ns(),t=on({queryKey:["me"],queryFn:()=>be.me()}),n=((l=t.data)==null?void 0:l.state)==="authenticated",a=on({queryKey:["topology"],queryFn:()=>be.topology(),enabled:t.data!==void 0&&t.data.state!=="login"});async function s(){await be.logout(),await r.invalidateQueries()}if(((o=t.data)==null?void 0:o.state)==="login")return w.jsx(bw,{modes:t.data.modes});const i=(x,m)=>w.jsxs("span",{className:`mono flex items-center gap-1 text-[10px] ${m?"text-zinc-400":"text-zinc-700"}`,children:[w.jsx(so,{tone:m?"ok":"idle"}),x]});return w.jsxs(w.Fragment,{children:[w.jsx("div",{className:"app-bg"}),w.jsxs("div",{className:"relative z-10 flex h-full flex-col",children:[w.jsxs("header",{className:"z-10 flex items-center gap-4 border-b border-[var(--line)] px-5 py-3",children:[w.jsxs("div",{className:"flex items-center gap-2.5",children:[w.jsx("div",{className:"grid h-7 w-7 place-items-center rounded-md border border-emerald-500/30 bg-emerald-500/10",children:w.jsx(wA,{className:"h-4 w-4 text-emerald-400"})}),w.jsxs("div",{className:"leading-none",children:[w.jsx("div",{className:"text-sm font-semibold tracking-tight",children:"media"}),w.jsx("div",{className:"mono text-[10px] uppercase tracking-[0.2em] text-zinc-600",children:"console"})]})]}),w.jsx("nav",{className:"ml-2 flex flex-wrap items-center gap-1",children:yA.map(x=>w.jsx("a",{href:`#/${x.id}`,className:`mono flex items-center gap-2 rounded-md border px-2.5 py-1 text-xs uppercase tracking-wide transition-colors ${e.tab===x.id?"border-zinc-600 bg-zinc-900 text-zinc-100":"border-transparent text-zinc-500 hover:text-zinc-300"}`,children:x.label},x.id))}),a.data&&w.jsxs("div",{className:"ml-auto flex items-center gap-3",children:[w.jsxs("span",{className:"mono tnum text-[10px] text-zinc-500",children:[a.data.disks," ",a.data.disks===1?"disk":"disks"]}),i("store",a.data.hasStore),i("uploads",a.data.hasUploads),i("actions",a.data.actions),w.jsxs("span",{className:"ml-1 flex items-center gap-1.5 text-xs text-zinc-500",children:[w.jsx(so,{tone:"ok",pulse:!0}),"live"]}),n&&w.jsx("button",{type:"button",onClick:s,className:"mono ml-1 rounded-md border border-[var(--line)] px-2 py-1 text-[10px] uppercase tracking-wider text-zinc-500 transition-colors hover:bg-zinc-800 hover:text-zinc-200",children:((c=t.data)==null?void 0:c.state)==="authenticated"&&t.data.user.name?`sign out · ${t.data.user.name}`:"sign out"})]})]}),w.jsxs("main",{className:"min-h-0 flex-1 overflow-auto p-6",children:[e.tab==="disks"&&w.jsx(oA,{route:e,actions:((u=a.data)==null?void 0:u.actions)??!1}),e.tab==="uploads"&&w.jsx(gA,{route:e,actions:((f=a.data)==null?void 0:f.actions)??!1}),e.tab==="library"&&w.jsx(pA,{route:e,hasStore:((h=a.data)==null?void 0:h.hasStore)??!1})]})]})]})}export{SA as A,_A as Q,TA as a,Lw as c,w as j,ve as r};
@@ -10,8 +10,8 @@
10
10
  rel="stylesheet"
11
11
  />
12
12
  <title>Media Console</title>
13
- <script type="module" crossorigin src="/media/assets/index-BpOCnhgy.js"></script>
14
- <link rel="modulepreload" crossorigin href="/media/assets/styles-CxcTF3Rj.js">
13
+ <script type="module" crossorigin src="/media/assets/index-wHwW-Wwx.js"></script>
14
+ <link rel="modulepreload" crossorigin href="/media/assets/styles-Cwmg5XNS.js">
15
15
  <link rel="stylesheet" crossorigin href="/media/assets/styles-86vIiczE.css">
16
16
  </head>
17
17
  <body>
@@ -10,8 +10,8 @@
10
10
  rel="stylesheet"
11
11
  />
12
12
  <title>Media Console — Preview</title>
13
- <script type="module" crossorigin src="/media/assets/preview-DSd0oaFq.js"></script>
14
- <link rel="modulepreload" crossorigin href="/media/assets/styles-CxcTF3Rj.js">
13
+ <script type="module" crossorigin src="/media/assets/preview-DnEjUZ0I.js"></script>
14
+ <link rel="modulepreload" crossorigin href="/media/assets/styles-Cwmg5XNS.js">
15
15
  <link rel="stylesheet" crossorigin href="/media/assets/styles-86vIiczE.css">
16
16
  </head>
17
17
  <body>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dudousxd/nestjs-media-dashboard",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "Standalone navigable /media console (disks, live uploads, media library) for nestjs-media — a bundled React SPA served by NestJS",
5
5
  "license": "MIT",
6
6
  "author": "Davide Carvalho",