import{p as A,u as E}from"./useEvent-WUlsM6MC.js";import{t as S}from"./compiler-runtime-B3qBwwSJ.js";import{t as k}from"./createReducer-BcTiTw8T.js";import{t as y}from"./requests-DZy_SQ_v.js";import{t as q}from"./createLucideIcon-BvP5LBIs.js";import{t as g}from"./DeferredRequestRegistry-CMZsNx4R.js";import{n as b}from"./useAsyncData-DVm0BCFt.js";var C=q("arrow-left",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);const v=new g("storage-list-entries",async(r,t)=>{await y().listStorageEntries({requestId:r,...t})}),I=new g("storage-download",async(r,t)=>{await y().downloadStorage({requestId:r,...t})});function w(r,t){return`${r}::${t??""}`}function N(r){return`${r}::`}function _(r,t,e){let a=[t,e].filter(Boolean).join("/").replaceAll(/\/+/g,"/");return new URL(`${r}://${a}`)}var j=S();function z(){return{namespaces:[],entriesByPath:new Map}}var{reducer:K,createActions:O,valueAtom:x,useActions:F}=k(z,{setNamespaces:(r,t)=>{let e=new Map(r.namespaces.map(a=>[a.name,a]));for(let a of t.namespaces)e.set(a.name,a);return{...r,namespaces:[...e.values()]}},setEntries:(r,t)=>{let e=w(t.namespace,t.prefix),a=new Map(r.entriesByPath);return a.set(e,t.entries),{...r,entriesByPath:a}},clearNamespaceCache:(r,t)=>{let e=new Map(r.entriesByPath),a=N(t);for(let s of e.keys())s.startsWith(a)&&e.delete(s);return{...r,entriesByPath:e}},filterFromVariables:(r,t)=>{let e=new Set(t),a=r.namespaces.filter(s=>e.has(s.name));return{...r,namespaces:a}}});const P=()=>E(x),H=A(r=>r(x).namespaces);function B(){return F()}function L(r,t){let e=(0,j.c)(20),{entriesByPath:a}=P(),{setEntries:s}=B(),o;e[0]!==a||e[1]!==r||e[2]!==t?(o=a.get(w(r,t)),e[0]=a,e[1]=r,e[2]=t,e[3]=o):o=e[3];let n=o,c;e[4]!==n||e[5]!==r||e[6]!==t||e[7]!==s?(c=async()=>{if(n)return;let d=await v.request({namespace:r,prefix:t??"",limit:150});if(d.error)throw Error(d.error);s({namespace:r,prefix:t,entries:d.entries})},e[4]=n,e[5]=r,e[6]=t,e[7]=s,e[8]=c):c=e[8];let p=n===void 0,l;e[9]!==r||e[10]!==t||e[11]!==p?(l=[r,t,p],e[9]=r,e[10]=t,e[11]=p,e[12]=l):l=e[12];let{isPending:M,error:$,refetch:f}=b(c,l),i;e[13]===n?i=e[14]:(i=n??[],e[13]=n,e[14]=i);let u=M&&!n,h=n?void 0:$,m;return e[15]!==f||e[16]!==i||e[17]!==u||e[18]!==h?(m={entries:i,isPending:u,error:h,refetch:f},e[15]=f,e[16]=i,e[17]=u,e[18]=h,e[19]=m):m=e[19],m}export{w as a,v as c,L as i,C as l,P as n,_ as o,B as r,I as s,H as t};
