UNPKG

miniflare

Version:

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

1 lines 31.7 kB
import{c as e,s as t,z as n}from"./useRouterState-DkU0JPAO.js";import{Bt as r,Ht as i,r as a}from"./button-cdxnqcgzwko8ooha-DW4HgSd6.js";import{t as o}from"./ArrowClockwise.es-Cy5-iE5C.js";import{t as s}from"./CaretDown.es-Bia_8FMa.js";import{t as c}from"./DotsThree.es-DeZ0Dokf.js";import{n as l,r as u,t as d}from"./format-DrzR4skK.js";import{n as f,t as p}from"./async-BF-ZueHi.js";import{t as m}from"./checkbox-kt1uojk2f9e0d0h1-BEtkwwZ8.js";import{t as h}from"./Plus.es-BJdTPWhL.js";import{n as g,t as _}from"./dialog-oqh8l3l3zutpibxx-6QAIfPjB.js";import{t as v}from"./dropdown-ncwhcd912vmone8k-BMBcB-5m.js";import{t as y}from"./table-inweecadl3her7pd-BRHbXqg_.js";import{t as b}from"./text-nmyi1rkwdj37f30f-BJ_ccspZ.js";import{t as x}from"./Breadcrumbs-D11-yw8F.js";import{Nt as S,Ot as C,Rt as w,gt as T,ht as E,it as D,mt as O,o as k,ot as A}from"./index-CkemaNd1.js";var j=n(t(),1),M=new Map([[`bold`,j.createElement(j.Fragment,null,j.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`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M208,88H152V32Z`,opacity:`0.2`}),j.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`,j.createElement(j.Fragment,null,j.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`,j.createElement(j.Fragment,null,j.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`,j.createElement(j.Fragment,null,j.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`,j.createElement(j.Fragment,null,j.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`}))]]),N=new Map([[`bold`,j.createElement(j.Fragment,null,j.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`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M128,80H32V56a8,8,0,0,1,8-8H92.69a8,8,0,0,1,5.65,2.34Z`,opacity:`0.2`}),j.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`,j.createElement(j.Fragment,null,j.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`,j.createElement(j.Fragment,null,j.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`,j.createElement(j.Fragment,null,j.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`,j.createElement(j.Fragment,null,j.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`}))]]),P=new Map([[`bold`,j.createElement(j.Fragment,null,j.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`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M128,80H32V56a8,8,0,0,1,8-8H92.69a8,8,0,0,1,5.65,2.34Z`,opacity:`0.2`}),j.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`,j.createElement(j.Fragment,null,j.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`,j.createElement(j.Fragment,null,j.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`,j.createElement(j.Fragment,null,j.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`,j.createElement(j.Fragment,null,j.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`}))]]),F=new Map([[`bold`,j.createElement(j.Fragment,null,j.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`,j.createElement(j.Fragment,null,j.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`}),j.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`,j.createElement(j.Fragment,null,j.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`,j.createElement(j.Fragment,null,j.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`,j.createElement(j.Fragment,null,j.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`,j.createElement(j.Fragment,null,j.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`}))]]),I=new Map([[`bold`,j.createElement(j.Fragment,null,j.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`,j.createElement(j.Fragment,null,j.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`}),j.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`,j.createElement(j.Fragment,null,j.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`,j.createElement(j.Fragment,null,j.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`,j.createElement(j.Fragment,null,j.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`,j.createElement(j.Fragment,null,j.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`}))]]),L=j.forwardRef((e,t)=>j.createElement(r,{ref:t,...e,weights:M}));L.displayName=`FileIcon`;var R=j.forwardRef((e,t)=>j.createElement(r,{ref:t,...e,weights:N}));R.displayName=`FolderIcon`;var ee=j.forwardRef((e,t)=>j.createElement(r,{ref:t,...e,weights:P}));ee.displayName=`FolderPlusIcon`;var z=j.forwardRef((e,t)=>j.createElement(r,{ref:t,...e,weights:F}));z.displayName=`FoldersIcon`;var B=j.forwardRef((e,t)=>j.createElement(r,{ref:t,...e,weights:I}));B.displayName=`UploadIcon`;var V=e();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)(v,{children:[(0,V.jsx)(v.Trigger,{render:(0,V.jsx)(a,{"aria-label":`Actions`,className:`h-7! w-7!`,shape:`square`,variant:`ghost`,children:(0,V.jsx)(c,{size:16,weight:`bold`})})}),(0,V.jsxs)(v.Content,{align:`end`,sideOffset:4,children:[!e&&n&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(v.Item,{className:`flex items-center gap-2`,onClick:n,children:[(0,V.jsx)(u,{}),(0,V.jsx)(`span`,{children:`Download`})]}),(0,V.jsx)(v.Separator,{})]}),(0,V.jsxs)(v.Item,{className:`flex items-center gap-2 text-kumo-danger`,onClick:t,children:[(0,V.jsx)(g,{}),(0,V.jsx)(`span`,{children:`Delete`})]})]})]})}function G({disabled:e,onDelete:t,onDownload:n,selectedFileCount:r,selectedTotalCount:i}){return(0,V.jsxs)(v,{children:[(0,V.jsx)(v.Trigger,{render:(0,V.jsx)(a,{"aria-label":`Bulk actions`,className:`h-7! w-7!`,disabled:e,shape:`square`,variant:`ghost`,children:(0,V.jsx)(c,{size:16,weight:`bold`})})}),(0,V.jsxs)(v.Content,{align:`end`,sideOffset:4,children:[r>0&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(v.Item,{className:`flex items-center gap-2`,onClick:n,children:[(0,V.jsx)(u,{}),(0,V.jsxs)(`span`,{children:[`Download `,r,` `,r===1?`file`:`files`]})]}),(0,V.jsx)(v.Separator,{})]}),(0,V.jsxs)(v.Item,{className:`flex items-center gap-2 text-kumo-danger`,onClick:t,children:[(0,V.jsx)(g,{}),(0,V.jsxs)(`span`,{children:[`Delete `,i,` `,i===1?`item`:`items`]})]})]})]})}function te({bucketName:e,currentPrefix:t,delimitedPrefixes:n,objects:r,onDelete:a,onDownload:o,onNavigateToPrefix:s,onSelectionChange:c,selectedKeys:u}){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),h=Array.from(u).filter(e=>!n.includes(e)),g=p.length>0&&p.every(e=>u.has(e)),_=p.some(e=>u.has(e)),v=(0,j.useRef)(null);v.current!==null&&!p.includes(v.current)&&(v.current=null);function x(){if(g){v.current=null,c(new Set);return}c(new Set(p))}function S(e,t){if(t&&v.current!==null){let t=p.indexOf(v.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=!u.has(e),s=new Set(u);for(let e of a){if(o){s.add(e);continue}s.delete(e)}c(s);return}}let n=new Set(u);n.has(e)?n.delete(e):n.add(e),v.current=e,c(n)}return(0,V.jsx)(`div`,{className:`overflow-hidden rounded-lg border border-kumo-fill`,children:(0,V.jsxs)(y,{children:[(0,V.jsx)(y.Header,{children:(0,V.jsxs)(y.Row,{children:[(0,V.jsx)(y.Head,{className:`w-12`,children:(0,V.jsx)(m,{"aria-label":`Select all`,checked:g,className:`hover:cursor-pointer`,disabled:p.length===0,indeterminate:_&&!g,onCheckedChange:x})}),(0,V.jsx)(y.Head,{children:`Objects`}),(0,V.jsx)(y.Head,{children:`Type`}),(0,V.jsx)(y.Head,{children:`Size`}),(0,V.jsx)(y.Head,{children:`Modified`}),(0,V.jsx)(y.Head,{className:`w-12`,children:(0,V.jsx)(G,{disabled:u.size===0,onDelete:()=>a(Array.from(u)),onDownload:()=>o(h),selectedFileCount:h.length,selectedTotalCount:u.size})})]})}),(0,V.jsxs)(y.Body,{children:[f.length===0?(0,V.jsx)(y.Row,{children:(0,V.jsx)(y.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)(b,{size:`sm`,bold:!0,children:t?`No objects in this directory`:`No objects in this bucket`}),(0,V.jsx)(b,{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)(y.Row,{className:`group`,children:[(0,V.jsx)(y.Cell,{onClick:e=>{let t=e.target;(t.closest(`button[role='checkbox']`)||t.closest(`input[type='checkbox']`))&&(e.preventDefault(),S(n.prefix,e.shiftKey))},children:(0,V.jsx)(m,{"aria-label":`Select ${e}`,checked:u.has(n.prefix),className:`hover:cursor-pointer`})}),(0,V.jsx)(y.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:()=>s(n.prefix),children:[(0,V.jsx)(R,{size:16,className:`text-kumo-brand-hover`}),(0,V.jsx)(`span`,{className:`font-medium`,children:e})]})}),(0,V.jsx)(y.Cell,{className:`text-kumo-subtle`,children:`Directory`}),(0,V.jsx)(y.Cell,{className:`text-kumo-subtle`,children:`-`}),(0,V.jsx)(y.Cell,{className:`text-kumo-subtle`,children:`-`}),(0,V.jsx)(y.Cell,{className:`text-right whitespace-nowrap`,children:(0,V.jsx)(W,{isDirectory:!0,onDelete:()=>a([n.prefix])})})]},n.prefix)}let r=n.object,c=r.key??``,f=H(c,t),p=U(r);return(0,V.jsxs)(y.Row,{className:`group`,children:[(0,V.jsx)(y.Cell,{onClick:e=>{let t=e.target;(t.closest(`button[role='checkbox']`)||t.closest(`input[type='checkbox']`))&&(e.preventDefault(),S(c,e.shiftKey))},children:(0,V.jsx)(m,{"aria-label":`Select ${f}`,checked:u.has(c),className:`hover:cursor-pointer`})}),(0,V.jsx)(y.Cell,{children:(0,V.jsxs)(i,{to:`/r2/$bucketName/object/$`,params:{bucketName:e,_splat:c},search:e=>e,className:`flex items-center gap-2 text-kumo-default no-underline hover:text-kumo-link`,children:[(0,V.jsx)(L,{size:16,className:`text-kumo-subtle`}),(0,V.jsx)(`span`,{className:`font-medium`,children:f})]})}),(0,V.jsx)(y.Cell,{className:`font-mono text-xs text-kumo-subtle`,children:p}),(0,V.jsx)(y.Cell,{className:`text-kumo-subtle`,children:l(r.size)}),(0,V.jsx)(y.Cell,{className:`text-kumo-subtle`,children:d(r.last_modified)}),(0,V.jsx)(y.Cell,{className:`text-right whitespace-nowrap`,children:(0,V.jsx)(W,{onDownload:()=>o([c]),onDelete:()=>a([c])})})]},c)})]})]})})}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 ne({bucketName:e,currentPrefix:t,onOpenChange:n,onUploadComplete:r,open:i}){let[o,s]=(0,j.useState)(``),[c,l]=(0,j.useState)([]),[u,d]=(0,j.useState)(!1),[f,p]=(0,j.useState)(null),[m,v]=(0,j.useState)(null),[y,b]=(0,j.useState)(``),[x,S]=(0,j.useState)(!1),C=(0,j.useCallback)(()=>{v(null),b(``),s(``),l([]),p(null)},[]);function w(e){v(e),b(t+e.name),s(q(e))}function E(e){let[t]=e.target.files??[];t&&w(t)}function D(e){e.preventDefault(),d(!1);let t=e.dataTransfer.files[0];t&&w(t)}function O(e){e.preventDefault(),d(!0)}function k(e){e.preventDefault(),d(!1)}function A(){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(!m||!y.trim()){p(`Please select a file and provide an object key`);return}try{S(!0),p(null);let t={};for(let e of c)e.key.trim()&&(t[e.key.trim()]=e.value);await T({path:{bucket_name:e,object_key:y.trim()},body:m,headers:{"content-type":o||`application/octet-stream`,"cf-r2-custom-metadata":Object.keys(t).length>0?JSON.stringify(t):void 0}}),C(),r()}catch(e){p(e instanceof Error?e.message:`Failed to upload object`)}finally{S(!1)}}function F(e){e||C(),n(e)}return(0,V.jsx)(_.Root,{open:i,onOpenChange:F,children:(0,V.jsxs)(_,{className:`p-6`,size:`lg`,children:[(0,V.jsx)(_.Title,{className:`mb-4 text-lg font-semibold`,children:`Upload object`}),f&&(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:f}),(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 ${u?`border-kumo-brand bg-kumo-brand/5`:`border-kumo-fill hover:border-kumo-brand/50`}`,onClick:()=>document.getElementById(`file-input`)?.click(),onDragLeave:k,onDragOver:O,onDrop:D,children:[(0,V.jsx)(`input`,{className:`hidden`,id:`file-input`,onChange:E,type:`file`}),(0,V.jsx)(B,{size:32,className:`mb-2 text-kumo-subtle`}),m?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`p`,{className:`text-sm font-medium text-kumo-default`,children:m.name}),(0,V.jsxs)(`p`,{className:`text-xs text-kumo-subtle`,children:[(m.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=>b(e.target.value),placeholder:t+`file.png`,type:`text`,value:y}),(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)(a,{variant:`ghost`,onClick:A,children:[(0,V.jsx)(h,{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)(a,{variant:`ghost`,shape:`square`,onClick:()=>M(t),"aria-label":`Remove metadata`,children:(0,V.jsx)(g,{size:14})})]},t))})]}),(0,V.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,V.jsx)(a,{variant:`secondary`,onClick:()=>F(!1),disabled:x,children:`Cancel`}),(0,V.jsx)(a,{variant:`primary`,disabled:x||!m,loading:x,onClick:P,children:x?`Uploading...`:`Upload`})]})]})})}function J(){let e=k.useParams(),t=k.useSearch(),n=k.useLoaderData(),r=w(),[c,l]=(0,j.useState)(!1),[u,d]=(0,j.useState)(!1),[m,h]=(0,j.useState)(n.cursor),[g,y]=(0,j.useState)([]),[b,M]=(0,j.useState)(!1),[N,P]=(0,j.useState)(n.delimitedPrefixes),[F,I]=(0,j.useState)(n.isTruncated),[L,R]=(0,j.useState)(!1),[H,U]=(0,j.useState)(!1),[W,G]=(0,j.useState)(``),[K,q]=(0,j.useState)(n.objects),[J,Y]=(0,j.useState)(new Set),[re,X]=(0,j.useState)(!1),Z=C(),Q=t.delimiter!==!1;(0,j.useEffect)(()=>{q(n.objects),P(n.delimitedPrefixes),h(n.cursor),I(n.isTruncated),y([]),M(!1),Y(new Set)},[n]);let $=(0,j.useCallback)(async(n,r)=>{try{n?U(!0):R(!0);let i=E({path:{bucket_name:e.bucketName},query:{prefix:t.prefix||void 0,delimiter:r?`/`:void 0,cursor:n,per_page:100}}),a=n?await i:await p(i),o=a.data?.result??[],s=a.data?.result_info?.delimited??[];n?(q(e=>[...e,...o]),P(e=>[...e,...s])):(q(o),P(s));let c=a.data?.result_info?.cursor;h(c??null),I(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{R(!1),U(!1)}},[e.bucketName,t.prefix,Z]);async function ie(){await $(void 0,Q)}async function ae(){m&&!H&&await $(m,Q)}async function oe(n){await r({params:{bucketName:e.bucketName},search:e=>({...e,prefix:t.prefix&&n?t.prefix:void 0,delimiter:n?void 0:!1}),to:`/r2/$bucketName`})}async function se(t){await r({params:{bucketName:e.bucketName},search:e=>({...e,prefix:t||void 0}),to:`/r2/$bucketName`})}function ce(e){y(e)}function le(t){for(let n of t){let t=`${D}/r2/buckets/${encodeURIComponent(e.bucketName)}/objects/${encodeURIComponent(n)}`,r=document.createElement(`a`);r.href=t,r.download=n.split(`/`).pop()||`download`,document.body.appendChild(r),r.click(),document.body.removeChild(r)}t.length>1&&Z.add({title:`Downloads started`,description:`Downloading ${t.length} files`}),Y(new Set)}async function ue(){if(g.length!==0)try{M(!0),await O({path:{bucket_name:e.bucketName},body:g}),q(e=>e.filter(e=>!g.includes(e.key??``))),P(e=>e.filter(e=>!g.includes(e))),y([]),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`}),y([])}finally{M(!1)}}async function de(){X(!1),await $(void 0,Q)}async function fe(){if(W.trim())try{d(!0);let n=(t.prefix||``)+W.trim()+`/`;await T({path:{bucket_name:e.bucketName,object_key:n},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{d(!1)}}let pe=Q&&t.prefix?t.prefix.split(`/`).filter(Boolean):[];return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(x,{icon:A,title:`R2`,items:[(0,V.jsx)(i,{className:`text-kumo-default no-underline hover:text-kumo-link`,params:{bucketName:e.bucketName},search:{},to:`/r2/$bucketName`,children:e.bucketName},`bucket`),...pe.map((t,n)=>{let r=pe.slice(0,n+1).join(`/`)+`/`;return(0,V.jsxs)(i,{className:`text-kumo-default no-underline hover:text-kumo-link`,params:{bucketName:e.bucketName},search:{prefix:r},to:`/r2/$bucketName`,children:[t,`/`]},r)})],children:[(0,V.jsxs)(v,{children:[(0,V.jsx)(v.Trigger,{render:(0,V.jsxs)(a,{variant:`secondary`,children:[Q?(0,V.jsx)(z,{size:16}):(0,V.jsx)(f,{size:16}),Q?`Grouped`:`Ungrouped`,(0,V.jsx)(s,{size:14})]})}),(0,V.jsxs)(v.Content,{align:`end`,sideOffset:4,children:[(0,V.jsxs)(v.Item,{className:`flex items-center gap-2`,icon:z,onClick:()=>oe(!0),children:[(0,V.jsx)(`span`,{children:`Grouped`}),Q&&(0,V.jsx)(S,{className:`ml-auto`,size:14})]}),(0,V.jsxs)(v.Item,{className:`flex items-center gap-2`,icon:f,onClick:()=>oe(!1),children:[(0,V.jsx)(`span`,{children:`Ungrouped`}),!Q&&(0,V.jsx)(S,{className:`ml-auto`,size:14})]})]})]}),(0,V.jsx)(a,{icon:B,onClick:()=>X(!0),variant:`secondary`,children:`Upload`}),(0,V.jsx)(a,{icon:ee,onClick:()=>l(!0),variant:`secondary`,children:`Add directory`}),(0,V.jsx)(a,{"aria-label":`Refresh`,icon:o,loading:L,onClick:ie,shape:`square`,variant:`secondary`})]}),(0,V.jsxs)(`div`,{className:`px-6 py-6`,children:[(0,V.jsx)(te,{bucketName:e.bucketName,currentPrefix:t.prefix||``,delimitedPrefixes:N,objects:K,onDelete:ce,onDownload:le,onNavigateToPrefix:se,onSelectionChange:Y,selectedKeys:J}),F&&m&&(0,V.jsx)(`div`,{className:`p-4 text-center`,children:(0,V.jsx)(a,{disabled:H,loading:H,onClick:ae,variant:`secondary`,children:H?`Loading...`:`Load More`})}),(0,V.jsx)(_.Root,{onOpenChange:e=>!e&&y([]),open:g.length>0,children:(0,V.jsxs)(_,{className:`p-6`,children:[(0,V.jsxs)(_.Title,{className:`mb-4 text-lg font-semibold`,children:[`Delete `,g.length===1?`object`:`objects`,`?`]}),(0,V.jsx)(_.Description,{className:`mb-2 text-kumo-subtle`,children:g.length===1?(0,V.jsxs)(V.Fragment,{children:[`Are you sure you want to delete “`,g[0],`”? This cannot be undone.`]}):(0,V.jsxs)(V.Fragment,{children:[`Are you sure you want to delete `,g.length,` `,`objects? This cannot be undone.`]})}),(0,V.jsxs)(`div`,{className:`mt-6 flex justify-end gap-2`,children:[(0,V.jsx)(a,{disabled:b,onClick:()=>y([]),variant:`secondary`,children:`Cancel`}),(0,V.jsx)(a,{disabled:b,loading:b,onClick:ue,variant:`destructive`,children:b?`Deleting...`:`Delete`})]})]})}),(0,V.jsx)(_.Root,{onOpenChange:e=>{e||(l(!1),G(``))},open:c,children:(0,V.jsxs)(_,{className:`p-6`,children:[(0,V.jsx)(_.Title,{className:`mb-4 text-lg font-semibold`,children:`Add directory`}),(0,V.jsx)(_.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}),t.prefix&&(0,V.jsxs)(`p`,{className:`mt-1 text-xs text-kumo-subtle`,children:[`Will be created at: `,t.prefix,W||`...`,`/`]})]}),(0,V.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,V.jsx)(a,{disabled:u,onClick:()=>{l(!1),G(``)},variant:`secondary`,children:`Cancel`}),(0,V.jsx)(a,{disabled:u||!W.trim(),loading:u,onClick:fe,variant:`primary`,children:u?`Creating...`:`Create`})]})]})}),(0,V.jsx)(ne,{bucketName:e.bucketName,currentPrefix:t.prefix||``,onOpenChange:X,onUploadComplete:de,open:re})]})]})}export{J as component};