UNPKG

miniflare

Version:

Fun, full-featured, fully-local simulator for Cloudflare Workers

1 lines 31.5 kB
import{t as e}from"./ArrowClockwise.es-UUpGcY4b.js";import{n as t,t as n}from"./Plus.es-qZNU5IMj.js";import{t as r}from"./DotsThree.es-Dn447PGr.js";import{n as i,r as a,t as o}from"./format-1KsnZgl0.js";import{n as s,t as c}from"./async-CTvDQt0Y.js";import{t as l}from"./checkbox-kt1uojk2f9e0d0h1-CLGaD9_Q.js";import{n as u,t as d}from"./dialog-oqh8l3l3zutpibxx-TbiRttKB.js";import{t as f}from"./dropdown-ncwhcd912vmone8k-tH8fYxp1.js";import{t as p}from"./Breadcrumbs-7fG3Aw2e.js";import{t as m}from"./table-inweecadl3her7pd-DtVlobCl.js";import{t as h}from"./text-nmyi1rkwdj37f30f-BTaBQYwf.js";import{Ct as g,Fn as _,Gn as v,Vn as y,Wn as b,dt as x,jn as S,lt as C,o as w,qn as T,rt as E,ut as D,wt as O,zn as k}from"./index-BwGGYgiP.js";var A=T(b(),1),j=new Map([[`bold`,A.createElement(A.Fragment,null,A.createElement(`path`,{d:`M216.49,79.52l-56-56A12,12,0,0,0,152,20H56A20,20,0,0,0,36,40V216a20,20,0,0,0,20,20H200a20,20,0,0,0,20-20V88A12,12,0,0,0,216.49,79.52ZM160,57l23,23H160ZM60,212V44h76V92a12,12,0,0,0,12,12h48V212Z`}))],[`duotone`,A.createElement(A.Fragment,null,A.createElement(`path`,{d:`M208,88H152V32Z`,opacity:`0.2`}),A.createElement(`path`,{d:`M213.66,82.34l-56-56A8,8,0,0,0,152,24H56A16,16,0,0,0,40,40V216a16,16,0,0,0,16,16H200a16,16,0,0,0,16-16V88A8,8,0,0,0,213.66,82.34ZM160,51.31,188.69,80H160ZM200,216H56V40h88V88a8,8,0,0,0,8,8h48V216Z`}))],[`fill`,A.createElement(A.Fragment,null,A.createElement(`path`,{d:`M213.66,82.34l-56-56A8,8,0,0,0,152,24H56A16,16,0,0,0,40,40V216a16,16,0,0,0,16,16H200a16,16,0,0,0,16-16V88A8,8,0,0,0,213.66,82.34ZM152,88V44l44,44Z`}))],[`light`,A.createElement(A.Fragment,null,A.createElement(`path`,{d:`M212.24,83.76l-56-56A6,6,0,0,0,152,26H56A14,14,0,0,0,42,40V216a14,14,0,0,0,14,14H200a14,14,0,0,0,14-14V88A6,6,0,0,0,212.24,83.76ZM158,46.48,193.52,82H158ZM200,218H56a2,2,0,0,1-2-2V40a2,2,0,0,1,2-2h90V88a6,6,0,0,0,6,6h50V216A2,2,0,0,1,200,218Z`}))],[`regular`,A.createElement(A.Fragment,null,A.createElement(`path`,{d:`M213.66,82.34l-56-56A8,8,0,0,0,152,24H56A16,16,0,0,0,40,40V216a16,16,0,0,0,16,16H200a16,16,0,0,0,16-16V88A8,8,0,0,0,213.66,82.34ZM160,51.31,188.69,80H160ZM200,216H56V40h88V88a8,8,0,0,0,8,8h48V216Z`}))],[`thin`,A.createElement(A.Fragment,null,A.createElement(`path`,{d:`M210.83,85.17l-56-56A4,4,0,0,0,152,28H56A12,12,0,0,0,44,40V216a12,12,0,0,0,12,12H200a12,12,0,0,0,12-12V88A4,4,0,0,0,210.83,85.17ZM156,41.65,198.34,84H156ZM200,220H56a4,4,0,0,1-4-4V40a4,4,0,0,1,4-4h92V88a4,4,0,0,0,4,4h52V216A4,4,0,0,1,200,220Z`}))]]),M=new Map([[`bold`,A.createElement(A.Fragment,null,A.createElement(`path`,{d:`M216,68H133.39l-26-29.29a20,20,0,0,0-15-6.71H40A20,20,0,0,0,20,52V200.62A19.41,19.41,0,0,0,39.38,220H216.89A19.13,19.13,0,0,0,236,200.89V88A20,20,0,0,0,216,68ZM44,56H90.61l10.67,12H44ZM212,196H44V92H212Z`}))],[`duotone`,A.createElement(A.Fragment,null,A.createElement(`path`,{d:`M128,80H32V56a8,8,0,0,1,8-8H92.69a8,8,0,0,1,5.65,2.34Z`,opacity:`0.2`}),A.createElement(`path`,{d:`M216,72H131.31L104,44.69A15.86,15.86,0,0,0,92.69,40H40A16,16,0,0,0,24,56V200.62A15.4,15.4,0,0,0,39.38,216H216.89A15.13,15.13,0,0,0,232,200.89V88A16,16,0,0,0,216,72ZM92.69,56l16,16H40V56ZM216,200H40V88H216Z`}))],[`fill`,A.createElement(A.Fragment,null,A.createElement(`path`,{d:`M216,72H131.31L104,44.69A15.88,15.88,0,0,0,92.69,40H40A16,16,0,0,0,24,56V200.62A15.41,15.41,0,0,0,39.39,216h177.5A15.13,15.13,0,0,0,232,200.89V88A16,16,0,0,0,216,72ZM40,56H92.69l16,16H40Z`}))],[`light`,A.createElement(A.Fragment,null,A.createElement(`path`,{d:`M216,74H130.49l-27.9-27.9a13.94,13.94,0,0,0-9.9-4.1H40A14,14,0,0,0,26,56V200.62A13.39,13.39,0,0,0,39.38,214H216.89A13.12,13.12,0,0,0,230,200.89V88A14,14,0,0,0,216,74ZM40,54H92.69a2,2,0,0,1,1.41.59L113.51,74H38V56A2,2,0,0,1,40,54ZM218,200.89a1.11,1.11,0,0,1-1.11,1.11H39.38A1.4,1.4,0,0,1,38,200.62V86H216a2,2,0,0,1,2,2Z`}))],[`regular`,A.createElement(A.Fragment,null,A.createElement(`path`,{d:`M216,72H131.31L104,44.69A15.86,15.86,0,0,0,92.69,40H40A16,16,0,0,0,24,56V200.62A15.4,15.4,0,0,0,39.38,216H216.89A15.13,15.13,0,0,0,232,200.89V88A16,16,0,0,0,216,72ZM40,56H92.69l16,16H40ZM216,200H40V88H216Z`}))],[`thin`,A.createElement(A.Fragment,null,A.createElement(`path`,{d:`M216,76H129.66L101.17,47.52A11.9,11.9,0,0,0,92.69,44H40A12,12,0,0,0,28,56V200.62A11.4,11.4,0,0,0,39.38,212H216.89A11.12,11.12,0,0,0,228,200.89V88A12,12,0,0,0,216,76ZM36,56a4,4,0,0,1,4-4H92.69a4,4,0,0,1,2.82,1.17L118.34,76H36ZM220,200.89a3.12,3.12,0,0,1-3.11,3.11H39.38A3.39,3.39,0,0,1,36,200.62V84H216a4,4,0,0,1,4,4Z`}))]]),N=new Map([[`bold`,A.createElement(A.Fragment,null,A.createElement(`path`,{d:`M216,68H133.39l-26-29.29a20,20,0,0,0-15-6.71H40A20,20,0,0,0,20,52V200.62A19.41,19.41,0,0,0,39.38,220H216.89A19.13,19.13,0,0,0,236,200.89V88A20,20,0,0,0,216,68ZM90.61,56l10.67,12H44V56ZM212,196H44V92H212Zm-72-76v12h12a12,12,0,0,1,0,24H140v12a12,12,0,0,1-24,0V156H104a12,12,0,0,1,0-24h12V120a12,12,0,0,1,24,0Z`}))],[`duotone`,A.createElement(A.Fragment,null,A.createElement(`path`,{d:`M128,80H32V56a8,8,0,0,1,8-8H92.69a8,8,0,0,1,5.65,2.34Z`,opacity:`0.2`}),A.createElement(`path`,{d:`M216,72H131.31L104,44.69A15.86,15.86,0,0,0,92.69,40H40A16,16,0,0,0,24,56V200.62A15.4,15.4,0,0,0,39.38,216H216.89A15.13,15.13,0,0,0,232,200.89V88A16,16,0,0,0,216,72ZM92.69,56l16,16H40V56ZM216,200H40V88H216Zm-88-88a8,8,0,0,1,8,8v16h16a8,8,0,0,1,0,16H136v16a8,8,0,0,1-16,0V152H104a8,8,0,0,1,0-16h16V120A8,8,0,0,1,128,112Z`}))],[`fill`,A.createElement(A.Fragment,null,A.createElement(`path`,{d:`M216,72H131.31L104,44.69A15.88,15.88,0,0,0,92.69,40H40A16,16,0,0,0,24,56V200.62A15.41,15.41,0,0,0,39.39,216h177.5A15.13,15.13,0,0,0,232,200.89V88A16,16,0,0,0,216,72ZM40,56H92.69l16,16H40Zm112,96H136v16a8,8,0,0,1-16,0V152H104a8,8,0,0,1,0-16h16V120a8,8,0,0,1,16,0v16h16a8,8,0,0,1,0,16Z`}))],[`light`,A.createElement(A.Fragment,null,A.createElement(`path`,{d:`M216,74H130.49l-27.9-27.9a13.94,13.94,0,0,0-9.9-4.1H40A14,14,0,0,0,26,56V200.62A13.39,13.39,0,0,0,39.38,214H216.89A13.12,13.12,0,0,0,230,200.89V88A14,14,0,0,0,216,74ZM40,54H92.69a2,2,0,0,1,1.41.59L113.51,74H38V56A2,2,0,0,1,40,54ZM218,200.89a1.11,1.11,0,0,1-1.11,1.11H39.38A1.4,1.4,0,0,1,38,200.62V86H216a2,2,0,0,1,2,2ZM158,144a6,6,0,0,1-6,6H134v18a6,6,0,0,1-12,0V150H104a6,6,0,0,1,0-12h18V120a6,6,0,0,1,12,0v18h18A6,6,0,0,1,158,144Z`}))],[`regular`,A.createElement(A.Fragment,null,A.createElement(`path`,{d:`M216,72H131.31L104,44.69A15.86,15.86,0,0,0,92.69,40H40A16,16,0,0,0,24,56V200.62A15.4,15.4,0,0,0,39.38,216H216.89A15.13,15.13,0,0,0,232,200.89V88A16,16,0,0,0,216,72ZM92.69,56l16,16H40V56ZM216,200H40V88H216Zm-88-88a8,8,0,0,1,8,8v16h16a8,8,0,0,1,0,16H136v16a8,8,0,0,1-16,0V152H104a8,8,0,0,1,0-16h16V120A8,8,0,0,1,128,112Z`}))],[`thin`,A.createElement(A.Fragment,null,A.createElement(`path`,{d:`M216,76H129.66L101.17,47.52A11.9,11.9,0,0,0,92.69,44H40A12,12,0,0,0,28,56V200.62A11.4,11.4,0,0,0,39.38,212H216.89A11.12,11.12,0,0,0,228,200.89V88A12,12,0,0,0,216,76ZM40,52H92.69a4,4,0,0,1,2.82,1.17L118.34,76H36V56A4,4,0,0,1,40,52ZM220,200.89a3.12,3.12,0,0,1-3.11,3.11H39.38A3.39,3.39,0,0,1,36,200.62V84H216a4,4,0,0,1,4,4ZM156,144a4,4,0,0,1-4,4H132v20a4,4,0,0,1-8,0V148H104a4,4,0,0,1,0-8h20V120a4,4,0,0,1,8,0v20h20A4,4,0,0,1,156,144Z`}))]]),P=new Map([[`bold`,A.createElement(A.Fragment,null,A.createElement(`path`,{d:`M228,56H160L133.33,36a20.12,20.12,0,0,0-12-4H76A20,20,0,0,0,56,52V72H36A20,20,0,0,0,16,92V204a20,20,0,0,0,20,20H188.89A19.13,19.13,0,0,0,208,204.89V184h20.89A19.13,19.13,0,0,0,248,164.89V76A20,20,0,0,0,228,56ZM184,200H40V96H80l28.8,21.6A12,12,0,0,0,116,120h68Zm40-40H208V116a20,20,0,0,0-20-20H120L93.33,76a20.12,20.12,0,0,0-12-4H80V56h40l28.8,21.6A12,12,0,0,0,156,80h68Z`}))],[`duotone`,A.createElement(A.Fragment,null,A.createElement(`path`,{d:`M232,80v88.89a7.11,7.11,0,0,1-7.11,7.11H200V112a8,8,0,0,0-8-8H120L90.13,81.6a8,8,0,0,0-4.8-1.6H64V56a8,8,0,0,1,8-8h45.33a8,8,0,0,1,4.8,1.6L152,72h72A8,8,0,0,1,232,80Z`,opacity:`0.2`}),A.createElement(`path`,{d:`M224,64H154.67L126.93,43.2a16.12,16.12,0,0,0-9.6-3.2H72A16,16,0,0,0,56,56V72H40A16,16,0,0,0,24,88V200a16,16,0,0,0,16,16H192.89A15.13,15.13,0,0,0,208,200.89V184h16.89A15.13,15.13,0,0,0,240,168.89V80A16,16,0,0,0,224,64ZM192,200H40V88H85.33l29.87,22.4A8,8,0,0,0,120,112h72Zm32-32H208V112a16,16,0,0,0-16-16H122.67L94.93,75.2a16.12,16.12,0,0,0-9.6-3.2H72V56h45.33L147.2,78.4A8,8,0,0,0,152,80h72Z`}))],[`fill`,A.createElement(A.Fragment,null,A.createElement(`path`,{d:`M224,64H154.67L126.93,43.2a16.12,16.12,0,0,0-9.6-3.2H72A16,16,0,0,0,56,56V72H40A16,16,0,0,0,24,88V200a16,16,0,0,0,16,16H192.89A15.13,15.13,0,0,0,208,200.89V184h16.89A15.13,15.13,0,0,0,240,168.89V80A16,16,0,0,0,224,64Zm0,104H208V112a16,16,0,0,0-16-16H122.67L94.93,75.2a16.12,16.12,0,0,0-9.6-3.2H72V56h45.33L147.2,78.4A8,8,0,0,0,152,80h72Z`}))],[`light`,A.createElement(A.Fragment,null,A.createElement(`path`,{d:`M224,66H154L125.73,44.8a14,14,0,0,0-8.4-2.8H72A14,14,0,0,0,58,56V74H40A14,14,0,0,0,26,88V200a14,14,0,0,0,14,14H192.89A13.12,13.12,0,0,0,206,200.89V182h18.89A13.12,13.12,0,0,0,238,168.89V80A14,14,0,0,0,224,66ZM194,200.89a1.11,1.11,0,0,1-1.11,1.11H40a2,2,0,0,1-2-2V88a2,2,0,0,1,2-2H85.33a2,2,0,0,1,1.2.4l29.87,22.4A6,6,0,0,0,120,110h72a2,2,0,0,1,2,2Zm32-32a1.11,1.11,0,0,1-1.11,1.11H206V112a14,14,0,0,0-14-14H122L93.73,76.8a14,14,0,0,0-8.4-2.8H70V56a2,2,0,0,1,2-2h45.33a2,2,0,0,1,1.2.4L148.4,76.8A6,6,0,0,0,152,78h72a2,2,0,0,1,2,2Z`}))],[`regular`,A.createElement(A.Fragment,null,A.createElement(`path`,{d:`M224,64H154.67L126.93,43.2a16.12,16.12,0,0,0-9.6-3.2H72A16,16,0,0,0,56,56V72H40A16,16,0,0,0,24,88V200a16,16,0,0,0,16,16H192.89A15.13,15.13,0,0,0,208,200.89V184h16.89A15.13,15.13,0,0,0,240,168.89V80A16,16,0,0,0,224,64ZM192,200H40V88H85.33l29.87,22.4A8,8,0,0,0,120,112h72Zm32-32H208V112a16,16,0,0,0-16-16H122.67L94.93,75.2a16.12,16.12,0,0,0-9.6-3.2H72V56h45.33L147.2,78.4A8,8,0,0,0,152,80h72Z`}))],[`thin`,A.createElement(A.Fragment,null,A.createElement(`path`,{d:`M224,68H153.33l-28.8-21.6a12.05,12.05,0,0,0-7.2-2.4H72A12,12,0,0,0,60,56V76H40A12,12,0,0,0,28,88V200a12,12,0,0,0,12,12H192.89A11.12,11.12,0,0,0,204,200.89V180h20.89A11.12,11.12,0,0,0,236,168.89V80A12,12,0,0,0,224,68ZM196,200.89a3.12,3.12,0,0,1-3.11,3.11H40a4,4,0,0,1-4-4V88a4,4,0,0,1,4-4H85.33a4,4,0,0,1,2.4.8l29.87,22.4a4,4,0,0,0,2.4.8h72a4,4,0,0,1,4,4Zm32-32a3.12,3.12,0,0,1-3.11,3.11H204V112a12,12,0,0,0-12-12H121.33L92.53,78.4a12.05,12.05,0,0,0-7.2-2.4H68V56a4,4,0,0,1,4-4h45.33a4,4,0,0,1,2.4.8L149.6,75.2a4,4,0,0,0,2.4.8h72a4,4,0,0,1,4,4Z`}))]]),F=new Map([[`bold`,A.createElement(A.Fragment,null,A.createElement(`path`,{d:`M188,184a16,16,0,1,1,16-16A16,16,0,0,1,188,184Zm36-68H180a12,12,0,0,0,0,24h40v56H36V140H76a12,12,0,0,0,0-24H32a20,20,0,0,0-20,20v64a20,20,0,0,0,20,20H224a20,20,0,0,0,20-20V136A20,20,0,0,0,224,116ZM88.49,80.49,116,53v75a12,12,0,0,0,24,0V53l27.51,27.52a12,12,0,1,0,17-17l-48-48a12,12,0,0,0-17,0l-48,48a12,12,0,1,0,17,17Z`}))],[`duotone`,A.createElement(A.Fragment,null,A.createElement(`path`,{d:`M232,136v64a8,8,0,0,1-8,8H32a8,8,0,0,1-8-8V136a8,8,0,0,1,8-8H224A8,8,0,0,1,232,136Z`,opacity:`0.2`}),A.createElement(`path`,{d:`M240,136v64a16,16,0,0,1-16,16H32a16,16,0,0,1-16-16V136a16,16,0,0,1,16-16H80a8,8,0,0,1,0,16H32v64H224V136H176a8,8,0,0,1,0-16h48A16,16,0,0,1,240,136ZM85.66,77.66,120,43.31V128a8,8,0,0,0,16,0V43.31l34.34,34.35a8,8,0,0,0,11.32-11.32l-48-48a8,8,0,0,0-11.32,0l-48,48A8,8,0,0,0,85.66,77.66ZM200,168a12,12,0,1,0-12,12A12,12,0,0,0,200,168Z`}))],[`fill`,A.createElement(A.Fragment,null,A.createElement(`path`,{d:`M74.34,77.66a8,8,0,0,1,0-11.32l48-48a8,8,0,0,1,11.32,0l48,48a8,8,0,0,1-11.32,11.32L136,43.31V128a8,8,0,0,1-16,0V43.31L85.66,77.66A8,8,0,0,1,74.34,77.66ZM240,136v64a16,16,0,0,1-16,16H32a16,16,0,0,1-16-16V136a16,16,0,0,1,16-16h68a4,4,0,0,1,4,4v3.46c0,13.45,11,24.79,24.46,24.54A24,24,0,0,0,152,128v-4a4,4,0,0,1,4-4h68A16,16,0,0,1,240,136Zm-40,32a12,12,0,1,0-12,12A12,12,0,0,0,200,168Z`}))],[`light`,A.createElement(A.Fragment,null,A.createElement(`path`,{d:`M238,136v64a14,14,0,0,1-14,14H32a14,14,0,0,1-14-14V136a14,14,0,0,1,14-14H80a6,6,0,0,1,0,12H32a2,2,0,0,0-2,2v64a2,2,0,0,0,2,2H224a2,2,0,0,0,2-2V136a2,2,0,0,0-2-2H176a6,6,0,0,1,0-12h48A14,14,0,0,1,238,136ZM84.24,76.24,122,38.49V128a6,6,0,0,0,12,0V38.49l37.76,37.75a6,6,0,0,0,8.48-8.48l-48-48a6,6,0,0,0-8.48,0l-48,48a6,6,0,0,0,8.48,8.48ZM198,168a10,10,0,1,0-10,10A10,10,0,0,0,198,168Z`}))],[`regular`,A.createElement(A.Fragment,null,A.createElement(`path`,{d:`M240,136v64a16,16,0,0,1-16,16H32a16,16,0,0,1-16-16V136a16,16,0,0,1,16-16H80a8,8,0,0,1,0,16H32v64H224V136H176a8,8,0,0,1,0-16h48A16,16,0,0,1,240,136ZM85.66,77.66,120,43.31V128a8,8,0,0,0,16,0V43.31l34.34,34.35a8,8,0,0,0,11.32-11.32l-48-48a8,8,0,0,0-11.32,0l-48,48A8,8,0,0,0,85.66,77.66ZM200,168a12,12,0,1,0-12,12A12,12,0,0,0,200,168Z`}))],[`thin`,A.createElement(A.Fragment,null,A.createElement(`path`,{d:`M236,136v64a12,12,0,0,1-12,12H32a12,12,0,0,1-12-12V136a12,12,0,0,1,12-12H80a4,4,0,0,1,0,8H32a4,4,0,0,0-4,4v64a4,4,0,0,0,4,4H224a4,4,0,0,0,4-4V136a4,4,0,0,0-4-4H176a4,4,0,0,1,0-8h48A12,12,0,0,1,236,136ZM82.83,74.83,124,33.66V128a4,4,0,0,0,8,0V33.66l41.17,41.17a4,4,0,1,0,5.66-5.66l-48-48a4,4,0,0,0-5.66,0l-48,48a4,4,0,0,0,5.66,5.66ZM196,168a8,8,0,1,0-8,8A8,8,0,0,0,196,168Z`}))]]),I=A.forwardRef((e,t)=>A.createElement(_,{ref:t,...e,weights:j}));I.displayName=`FileIcon`;var L=A.forwardRef((e,t)=>A.createElement(_,{ref:t,...e,weights:M}));L.displayName=`FolderIcon`;var R=A.forwardRef((e,t)=>A.createElement(_,{ref:t,...e,weights:N}));R.displayName=`FolderPlusIcon`;var z=A.forwardRef((e,t)=>A.createElement(_,{ref:t,...e,weights:P}));z.displayName=`FoldersIcon`;var B=A.forwardRef((e,t)=>A.createElement(_,{ref:t,...e,weights:F}));B.displayName=`UploadIcon`;var V=v();function H(e,t){return e.startsWith(t)?e.slice(t.length):e}function U(e){return e.http_metadata?.contentType??`application/octet-stream`}function W({isDirectory:e,onDelete:t,onDownload:n}){return(0,V.jsxs)(f,{children:[(0,V.jsx)(f.Trigger,{render:(0,V.jsx)(O,{"aria-label":`Actions`,className:`h-7! w-7!`,shape:`square`,variant:`ghost`,children:(0,V.jsx)(r,{size:16,weight:`bold`})})}),(0,V.jsxs)(f.Content,{align:`end`,sideOffset:4,children:[!e&&n&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(f.Item,{className:`flex items-center gap-2`,onClick:n,children:[(0,V.jsx)(a,{}),(0,V.jsx)(`span`,{children:`Download`})]}),(0,V.jsx)(f.Separator,{})]}),(0,V.jsxs)(f.Item,{className:`flex items-center gap-2 text-kumo-danger`,onClick:t,children:[(0,V.jsx)(u,{}),(0,V.jsx)(`span`,{children:`Delete`})]})]})]})}function G({disabled:e,onDelete:t,onDownload:n,selectedFileCount:i,selectedTotalCount:o}){return(0,V.jsxs)(f,{children:[(0,V.jsx)(f.Trigger,{render:(0,V.jsx)(O,{"aria-label":`Bulk actions`,className:`h-7! w-7!`,disabled:e,shape:`square`,variant:`ghost`,children:(0,V.jsx)(r,{size:16,weight:`bold`})})}),(0,V.jsxs)(f.Content,{align:`end`,sideOffset:4,children:[i>0&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(f.Item,{className:`flex items-center gap-2`,onClick:n,children:[(0,V.jsx)(a,{}),(0,V.jsxs)(`span`,{children:[`Download `,i,` `,i===1?`file`:`files`]})]}),(0,V.jsx)(f.Separator,{})]}),(0,V.jsxs)(f.Item,{className:`flex items-center gap-2 text-kumo-danger`,onClick:t,children:[(0,V.jsx)(u,{}),(0,V.jsxs)(`span`,{children:[`Delete `,o,` `,o===1?`item`:`items`]})]})]})]})}function ee({bucketName:e,currentPrefix:t,delimitedPrefixes:n,objects:r,onDelete:a,onDownload:s,onNavigateToPrefix:c,onSelectionChange:u,selectedKeys:d}){let f=[...n.map(e=>({prefix:e,type:`directory`})),...r.filter(e=>!((e.key??``).endsWith(`/`)&&e.size===0)).map(e=>({object:e,type:`file`}))],p=f.map(e=>e.type===`directory`?e.prefix:e.object.key).filter(e=>e!==void 0),g=Array.from(d).filter(e=>!n.includes(e)),_=p.length>0&&p.every(e=>d.has(e)),v=p.some(e=>d.has(e)),y=(0,A.useRef)(null);y.current!==null&&!p.includes(y.current)&&(y.current=null);function b(){if(_){y.current=null,u(new Set);return}u(new Set(p))}function x(e,t){if(t&&y.current!==null){let t=p.indexOf(y.current),n=p.indexOf(e);if(t!==-1&&n!==-1){let r=Math.min(t,n),i=Math.max(t,n),a=p.slice(r,i+1),o=!d.has(e),s=new Set(d);for(let e of a){if(o){s.add(e);continue}s.delete(e)}u(s);return}}let n=new Set(d);n.has(e)?n.delete(e):n.add(e),y.current=e,u(n)}return(0,V.jsx)(`div`,{className:`overflow-hidden rounded-lg border border-kumo-fill`,children:(0,V.jsxs)(m,{children:[(0,V.jsx)(m.Header,{children:(0,V.jsxs)(m.Row,{children:[(0,V.jsx)(m.Head,{className:`w-12`,children:(0,V.jsx)(l,{"aria-label":`Select all`,checked:_,className:`hover:cursor-pointer`,disabled:p.length===0,indeterminate:v&&!_,onCheckedChange:b})}),(0,V.jsx)(m.Head,{children:`Objects`}),(0,V.jsx)(m.Head,{children:`Type`}),(0,V.jsx)(m.Head,{children:`Size`}),(0,V.jsx)(m.Head,{children:`Modified`}),(0,V.jsx)(m.Head,{className:`w-12`,children:(0,V.jsx)(G,{disabled:d.size===0,onDelete:()=>a(Array.from(d)),onDownload:()=>s(g),selectedFileCount:g.length,selectedTotalCount:d.size})})]})}),(0,V.jsxs)(m.Body,{children:[f.length===0?(0,V.jsx)(m.Row,{children:(0,V.jsx)(m.Cell,{colSpan:6,className:`py-20! text-center`,children:(0,V.jsxs)(`div`,{className:`flex flex-col items-center justify-center gap-1`,children:[(0,V.jsx)(h,{size:`sm`,bold:!0,children:t?`No objects in this directory`:`No objects in this bucket`}),(0,V.jsx)(h,{variant:`secondary`,size:`xs`,children:`Upload an object using the button above.`})]})})}):null,f.map(n=>{if(n.type===`directory`){let e=H(n.prefix,t);return(0,V.jsxs)(m.Row,{className:`group`,children:[(0,V.jsx)(m.Cell,{onClick:e=>{let t=e.target;(t.closest(`button[role='checkbox']`)||t.closest(`input[type='checkbox']`))&&(e.preventDefault(),x(n.prefix,e.shiftKey))},children:(0,V.jsx)(l,{"aria-label":`Select ${e}`,checked:d.has(n.prefix),className:`hover:cursor-pointer`})}),(0,V.jsx)(m.Cell,{children:(0,V.jsxs)(`button`,{className:`flex cursor-pointer items-center gap-2 border-none bg-transparent p-0 text-left text-kumo-default hover:text-kumo-link`,onClick:()=>c(n.prefix),children:[(0,V.jsx)(L,{size:16,className:`text-kumo-brand-hover`}),(0,V.jsx)(`span`,{className:`font-medium`,children:e})]})}),(0,V.jsx)(m.Cell,{className:`text-kumo-subtle`,children:`Directory`}),(0,V.jsx)(m.Cell,{className:`text-kumo-subtle`,children:`-`}),(0,V.jsx)(m.Cell,{className:`text-kumo-subtle`,children:`-`}),(0,V.jsx)(m.Cell,{className:`text-right whitespace-nowrap`,children:(0,V.jsx)(W,{isDirectory:!0,onDelete:()=>a([n.prefix])})})]},n.prefix)}let r=n.object,u=r.key??``,f=H(u,t),p=U(r);return(0,V.jsxs)(m.Row,{className:`group`,children:[(0,V.jsx)(m.Cell,{onClick:e=>{let t=e.target;(t.closest(`button[role='checkbox']`)||t.closest(`input[type='checkbox']`))&&(e.preventDefault(),x(u,e.shiftKey))},children:(0,V.jsx)(l,{"aria-label":`Select ${f}`,checked:d.has(u),className:`hover:cursor-pointer`})}),(0,V.jsx)(m.Cell,{children:(0,V.jsxs)(k,{to:`/r2/$bucketName/object/$`,params:{bucketName:e,_splat:u},search:e=>e,className:`flex items-center gap-2 text-kumo-default no-underline hover:text-kumo-link`,children:[(0,V.jsx)(I,{size:16,className:`text-kumo-subtle`}),(0,V.jsx)(`span`,{className:`font-medium`,children:f})]})}),(0,V.jsx)(m.Cell,{className:`font-mono text-xs text-kumo-subtle`,children:p}),(0,V.jsx)(m.Cell,{className:`text-kumo-subtle`,children:i(r.size)}),(0,V.jsx)(m.Cell,{className:`text-kumo-subtle`,children:o(r.last_modified)}),(0,V.jsx)(m.Cell,{className:`text-right whitespace-nowrap`,children:(0,V.jsx)(W,{onDownload:()=>s([u]),onDelete:()=>a([u])})})]},u)})]})]})})}var K={css:`text/css`,gif:`image/gif`,html:`text/html`,jpeg:`image/jpeg`,jpg:`image/jpeg`,js:`application/javascript`,json:`application/json`,mp3:`audio/mpeg`,mp4:`video/mp4`,pdf:`application/pdf`,png:`image/png`,svg:`image/svg+xml`,txt:`text/plain`,wasm:`application/wasm`,webp:`image/webp`,xml:`application/xml`,zip:`application/zip`};function q(e){return e.type?e.type:K[e.name.split(`.`).pop()?.toLowerCase()]??`application/octet-stream`}function te({bucketName:e,currentPrefix:t,onOpenChange:r,onUploadComplete:i,open:a}){let[o,s]=(0,A.useState)(``),[c,l]=(0,A.useState)([]),[f,p]=(0,A.useState)(!1),[m,h]=(0,A.useState)(null),[g,_]=(0,A.useState)(null),[v,y]=(0,A.useState)(``),[b,S]=(0,A.useState)(!1),C=(0,A.useCallback)(()=>{_(null),y(``),s(``),l([]),h(null)},[]);function w(e){_(e),y(t+e.name),s(q(e))}function T(e){let[t]=e.target.files??[];t&&w(t)}function E(e){e.preventDefault(),p(!1);let t=e.dataTransfer.files[0];t&&w(t)}function D(e){e.preventDefault(),p(!0)}function k(e){e.preventDefault(),p(!1)}function j(){l([...c,{key:``,value:``}])}function M(e){l(c.filter((t,n)=>n!==e))}function N(e,t,n){let r=[...c],i=r[e];i&&(i[t]=n,l(r))}async function P(){if(!g||!v.trim()){h(`Please select a file and provide an object key`);return}try{S(!0),h(null);let t={};for(let e of c)e.key.trim()&&(t[e.key.trim()]=e.value);await x({path:{bucket_name:e,object_key:v.trim()},body:g,headers:{"content-type":o||`application/octet-stream`,"cf-r2-custom-metadata":Object.keys(t).length>0?JSON.stringify(t):void 0}}),C(),i()}catch(e){h(e instanceof Error?e.message:`Failed to upload object`)}finally{S(!1)}}function F(e){e||C(),r(e)}return(0,V.jsx)(d.Root,{open:a,onOpenChange:F,children:(0,V.jsxs)(d,{className:`p-6`,size:`lg`,children:[(0,V.jsx)(d.Title,{className:`mb-4 text-lg font-semibold`,children:`Upload object`}),m&&(0,V.jsx)(`div`,{className:`mb-4 rounded-md border border-kumo-danger/20 bg-kumo-danger/8 p-3 text-sm text-kumo-danger`,children:m}),(0,V.jsxs)(`div`,{className:`mb-4 flex min-h-32 cursor-pointer flex-col items-center justify-center rounded-lg border-2 border-dashed p-6 transition-colors duration-200 ${f?`border-kumo-brand bg-kumo-brand/5`:`border-kumo-fill hover:border-kumo-brand/50`}`,onClick:()=>document.getElementById(`file-input`)?.click(),onDragLeave:k,onDragOver:D,onDrop:E,children:[(0,V.jsx)(`input`,{className:`hidden`,id:`file-input`,onChange:T,type:`file`}),(0,V.jsx)(B,{size:32,className:`mb-2 text-kumo-subtle`}),g?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`p`,{className:`text-sm font-medium text-kumo-default`,children:g.name}),(0,V.jsxs)(`p`,{className:`text-xs text-kumo-subtle`,children:[(g.size/1024).toFixed(1),` KB`]})]}):(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`p`,{className:`text-sm text-kumo-default`,children:`Drop a file here or click to browse`}),(0,V.jsx)(`p`,{className:`text-xs text-kumo-subtle`,children:`Any file type supported`})]})]}),(0,V.jsxs)(`div`,{className:`mb-4`,children:[(0,V.jsx)(`label`,{className:`mb-2 block text-sm font-medium text-kumo-default`,children:`Object key`}),(0,V.jsx)(`input`,{className:`focus-visible:ring-kumo-ring w-full rounded-md border border-kumo-fill bg-kumo-base px-3 py-2 font-mono text-sm text-kumo-default placeholder:text-kumo-subtle focus:border-kumo-brand focus:outline-none focus-visible:ring-2`,onChange:e=>y(e.target.value),placeholder:t+`file.png`,type:`text`,value:v}),(0,V.jsx)(`p`,{className:`mt-1 text-xs text-kumo-subtle`,children:`The full path where the object will be stored`})]}),(0,V.jsxs)(`div`,{className:`mb-4`,children:[(0,V.jsx)(`label`,{className:`mb-2 block text-sm font-medium text-kumo-default`,children:`Content-Type`}),(0,V.jsx)(`input`,{className:`focus-visible:ring-kumo-ring w-full rounded-md border border-kumo-fill bg-kumo-base px-3 py-2 font-mono text-sm text-kumo-default placeholder:text-kumo-subtle focus:border-kumo-brand focus:outline-none focus-visible:ring-2`,onChange:e=>s(e.target.value),placeholder:`image/png`,type:`text`,value:o})]}),(0,V.jsxs)(`div`,{className:`mb-4`,children:[(0,V.jsxs)(`div`,{className:`mb-2 flex items-center justify-between`,children:[(0,V.jsx)(`label`,{className:`text-sm font-medium text-kumo-default`,children:`Custom metadata`}),(0,V.jsxs)(O,{variant:`ghost`,onClick:j,children:[(0,V.jsx)(n,{size:12}),`Add`]})]}),c.length===0?(0,V.jsx)(`p`,{className:`text-sm text-kumo-subtle italic`,children:`No custom metadata`}):(0,V.jsx)(`div`,{className:`space-y-2`,children:c.map((e,t)=>(0,V.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,V.jsx)(`input`,{className:`focus-visible:ring-kumo-ring flex-1 rounded-md border border-kumo-fill bg-kumo-base px-2 py-1.5 font-mono text-sm text-kumo-default focus:border-kumo-brand focus:outline-none focus-visible:ring-2`,onChange:e=>N(t,`key`,e.target.value),placeholder:`key`,type:`text`,value:e.key}),(0,V.jsx)(`input`,{className:`focus-visible:ring-kumo-ring flex-1 rounded-md border border-kumo-fill bg-kumo-base px-2 py-1.5 font-mono text-sm text-kumo-default focus:border-kumo-brand focus:outline-none focus-visible:ring-2`,onChange:e=>N(t,`value`,e.target.value),placeholder:`value`,type:`text`,value:e.value}),(0,V.jsx)(O,{variant:`ghost`,shape:`square`,onClick:()=>M(t),"aria-label":`Remove metadata`,children:(0,V.jsx)(u,{size:14})})]},t))})]}),(0,V.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,V.jsx)(O,{variant:`secondary`,onClick:()=>F(!1),disabled:b,children:`Cancel`}),(0,V.jsx)(O,{variant:`primary`,disabled:b||!g,loading:b,onClick:P,children:b?`Uploading...`:`Upload`})]})]})})}function J(){let n=w.useParams(),r=w.useSearch(),i=w.useLoaderData(),a=y(),[o,l]=(0,A.useState)(!1),[u,m]=(0,A.useState)(!1),[h,_]=(0,A.useState)(i.cursor),[v,b]=(0,A.useState)([]),[T,j]=(0,A.useState)(!1),[M,N]=(0,A.useState)(i.delimitedPrefixes),[P,F]=(0,A.useState)(i.isTruncated),[I,L]=(0,A.useState)(!1),[H,U]=(0,A.useState)(!1),[W,G]=(0,A.useState)(``),[K,q]=(0,A.useState)(i.objects),[J,Y]=(0,A.useState)(new Set),[ne,X]=(0,A.useState)(!1),Z=g(),Q=r.delimiter!==!1;(0,A.useEffect)(()=>{q(i.objects),N(i.delimitedPrefixes),_(i.cursor),F(i.isTruncated),b([]),j(!1),Y(new Set)},[i]);let $=(0,A.useCallback)(async(e,t)=>{try{e?U(!0):L(!0);let i=D({path:{bucket_name:n.bucketName},query:{prefix:r.prefix||void 0,delimiter:t?`/`:void 0,cursor:e,per_page:100}}),a=e?await i:await c(i),o=a.data?.result??[],s=a.data?.result_info?.delimited??[];e?(q(e=>[...e,...o]),N(e=>[...e,...s])):(q(o),N(s));let l=a.data?.result_info?.cursor;_(l??null),F(a.data?.result_info?.is_truncated===`true`)}catch(e){Z.add({title:`Failed to fetch objects`,description:e instanceof Error?e.message:`An unknown error occurred`,variant:`error`})}finally{L(!1),U(!1)}},[n.bucketName,r.prefix,Z]);async function re(){await $(void 0,Q)}async function ie(){h&&!H&&await $(h,Q)}async function ae(e){await a({params:{bucketName:n.bucketName},search:t=>({...t,prefix:r.prefix&&e?r.prefix:void 0,delimiter:e?void 0:!1}),to:`/r2/$bucketName`})}async function oe(e){await a({params:{bucketName:n.bucketName},search:t=>({...t,prefix:e||void 0}),to:`/r2/$bucketName`})}function se(e){b(e)}function ce(e){for(let t of e){let e=`/cdn-cgi/explorer/api/r2/buckets/${encodeURIComponent(n.bucketName)}/objects/${encodeURIComponent(t)}`,r=document.createElement(`a`);r.href=e,r.download=t.split(`/`).pop()||`download`,document.body.appendChild(r),r.click(),document.body.removeChild(r)}e.length>1&&Z.add({title:`Downloads started`,description:`Downloading ${e.length} files`}),Y(new Set)}async function le(){if(v.length!==0)try{j(!0),await C({path:{bucket_name:n.bucketName},body:v}),q(e=>e.filter(e=>!v.includes(e.key??``))),N(e=>e.filter(e=>!v.includes(e))),b([]),Y(new Set)}catch(e){let t=`Failed to delete objects`;if(e instanceof Error)t=e.message;else if(typeof e==`object`&&e&&`errors`in e&&Array.isArray(e.errors)){let n=e;n.errors[0]?.message&&(t=n.errors[0].message)}Z.add({title:`Delete failed`,description:t,variant:`error`}),b([])}finally{j(!1)}}async function ue(){X(!1),await $(void 0,Q)}async function de(){if(W.trim())try{m(!0);let e=(r.prefix||``)+W.trim()+`/`;await x({path:{bucket_name:n.bucketName,object_key:e},body:new Blob([])}),l(!1),G(``),$(void 0,Q)}catch(e){Z.add({title:`Failed to create directory`,description:e instanceof Error?e.message:`An unknown error occurred`,variant:`error`})}finally{m(!1)}}let fe=Q&&r.prefix?r.prefix.split(`/`).filter(Boolean):[];return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(p,{icon:E,title:`R2`,items:[(0,V.jsx)(k,{className:`text-kumo-default no-underline hover:text-kumo-link`,params:{bucketName:n.bucketName},search:{},to:`/r2/$bucketName`,children:n.bucketName},`bucket`),...fe.map((e,t)=>{let r=fe.slice(0,t+1).join(`/`)+`/`;return(0,V.jsxs)(k,{className:`text-kumo-default no-underline hover:text-kumo-link`,params:{bucketName:n.bucketName},search:{prefix:r},to:`/r2/$bucketName`,children:[e,`/`]},r)})],children:[(0,V.jsxs)(f,{children:[(0,V.jsx)(f.Trigger,{render:(0,V.jsxs)(O,{variant:`secondary`,children:[Q?(0,V.jsx)(z,{size:16}):(0,V.jsx)(s,{size:16}),Q?`Grouped`:`Ungrouped`,(0,V.jsx)(t,{size:14})]})}),(0,V.jsxs)(f.Content,{align:`end`,sideOffset:4,children:[(0,V.jsxs)(f.Item,{className:`flex items-center gap-2`,icon:z,onClick:()=>ae(!0),children:[(0,V.jsx)(`span`,{children:`Grouped`}),Q&&(0,V.jsx)(S,{className:`ml-auto`,size:14})]}),(0,V.jsxs)(f.Item,{className:`flex items-center gap-2`,icon:s,onClick:()=>ae(!1),children:[(0,V.jsx)(`span`,{children:`Ungrouped`}),!Q&&(0,V.jsx)(S,{className:`ml-auto`,size:14})]})]})]}),(0,V.jsx)(O,{icon:B,onClick:()=>X(!0),variant:`secondary`,children:`Upload`}),(0,V.jsx)(O,{icon:R,onClick:()=>l(!0),variant:`secondary`,children:`Add directory`}),(0,V.jsx)(O,{"aria-label":`Refresh`,icon:e,loading:I,onClick:re,shape:`square`,variant:`secondary`})]}),(0,V.jsxs)(`div`,{className:`px-6 py-6`,children:[(0,V.jsx)(ee,{bucketName:n.bucketName,currentPrefix:r.prefix||``,delimitedPrefixes:M,objects:K,onDelete:se,onDownload:ce,onNavigateToPrefix:oe,onSelectionChange:Y,selectedKeys:J}),P&&h&&(0,V.jsx)(`div`,{className:`p-4 text-center`,children:(0,V.jsx)(O,{disabled:H,loading:H,onClick:ie,variant:`secondary`,children:H?`Loading...`:`Load More`})}),(0,V.jsx)(d.Root,{onOpenChange:e=>!e&&b([]),open:v.length>0,children:(0,V.jsxs)(d,{className:`p-6`,children:[(0,V.jsxs)(d.Title,{className:`mb-4 text-lg font-semibold`,children:[`Delete `,v.length===1?`object`:`objects`,`?`]}),(0,V.jsx)(d.Description,{className:`mb-2 text-kumo-subtle`,children:v.length===1?(0,V.jsxs)(V.Fragment,{children:[`Are you sure you want to delete “`,v[0],`”? This cannot be undone.`]}):(0,V.jsxs)(V.Fragment,{children:[`Are you sure you want to delete `,v.length,` `,`objects? This cannot be undone.`]})}),(0,V.jsxs)(`div`,{className:`mt-6 flex justify-end gap-2`,children:[(0,V.jsx)(O,{disabled:T,onClick:()=>b([]),variant:`secondary`,children:`Cancel`}),(0,V.jsx)(O,{disabled:T,loading:T,onClick:le,variant:`destructive`,children:T?`Deleting...`:`Delete`})]})]})}),(0,V.jsx)(d.Root,{onOpenChange:e=>{e||(l(!1),G(``))},open:o,children:(0,V.jsxs)(d,{className:`p-6`,children:[(0,V.jsx)(d.Title,{className:`mb-4 text-lg font-semibold`,children:`Add directory`}),(0,V.jsx)(d.Description,{className:`mb-4 text-kumo-subtle`,children:`Enter a name for the new directory.`}),(0,V.jsxs)(`div`,{className:`mb-4`,children:[(0,V.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-kumo-default`,children:`Directory name`}),(0,V.jsx)(`input`,{type:`text`,className:`focus-visible:ring-kumo-ring w-full rounded-md border border-kumo-fill bg-kumo-base px-3 py-2 text-sm text-kumo-default focus:border-kumo-brand focus:outline-none focus-visible:ring-2`,value:W,onChange:e=>G(e.target.value),placeholder:`my-directory`,autoFocus:!0}),r.prefix&&(0,V.jsxs)(`p`,{className:`mt-1 text-xs text-kumo-subtle`,children:[`Will be created at: `,r.prefix,W||`...`,`/`]})]}),(0,V.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,V.jsx)(O,{disabled:u,onClick:()=>{l(!1),G(``)},variant:`secondary`,children:`Cancel`}),(0,V.jsx)(O,{disabled:u||!W.trim(),loading:u,onClick:de,variant:`primary`,children:u?`Creating...`:`Create`})]})]})}),(0,V.jsx)(te,{bucketName:n.bucketName,currentPrefix:r.prefix||``,onOpenChange:X,onUploadComplete:ue,open:ne})]})]})}export{J as component};