import{c as e,f as a,aQ as t,W as r,v as i,Y as o,U as n,X as c,t as s,Z as l,aY as p,B as d,F as h,y as m,T as u,aT as f,P as x,N as y,as as b,S as v,b7 as S,x as g,aX as L}from"./index-D-1_V7j0.js";import{h as k}from"./hasRouteMatch-CnhjHmvr.js";import{B as w}from"./Background-vKerKkRx.js";import{R as A}from"./Refresh-CWqrXG9u.js";import{K as j}from"./KeyboardArrowLeft-BasR_jXs.js";import{A as z}from"./Article-B3sJn9jj.js";const H=e(a("path",{d:"M10 4H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2h-8l-2-2z"}),"Folder"),I=e(a("path",{d:"M21 19V5c0-1.1-.9-2-2-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2zM8.5 13.5l2.5 3.01L14.5 12l4.5 6H5l3.5-4.5z"}),"Image"),T=e(a("path",{d:"M6 2c-1.1 0-1.99.9-1.99 2L4 20c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8l-6-6H6zm7 7V3.5L18.5 9H13z"}),"InsertDriveFile"),C=[{type:l.Link,action:"back-action",label:a(j,{sx:{display:"block"}})},{type:l.Link,action:"back-action",label:"Main"},{type:l.Link,action:"back-action",label:"Dump Explorer"}],E=[{action:"update-now",label:"Refresh",icon:()=>a(m,{icon:A,color:"#4caf50"})}],M=e=>e.mimeType.startsWith("image/")?a(I,{sx:{color:"#f57c00",fontSize:20}}):"application/json"===e.mimeType?a(g,{sx:{color:"#7b1fa2",fontSize:20}}):e.mimeType.startsWith("text/")?a(z,{sx:{color:"#1976d2",fontSize:20}}):a(T,{sx:{color:"#546e7a",fontSize:20}}),V=new n,D=({params:e})=>{const[n,l]=t(e.search),[m,{loading:g,execute:L}]=r(async()=>await i.explorerViewService.getFolderTree(),{onLoadStart:()=>i.layoutService.setAppbarLoader(!0),onLoadEnd:()=>i.layoutService.setAppbarLoader(!1)});o(()=>V.subscribe(L));const k=c(m);return a(h,{children:[a(s,{items:C,actions:E,onAction:e=>{"back-action"===e&&i.routerService.push("/"),"update-now"===e&&(i.explorerViewService.clear(),V.next())}}),a(p,{withScrollbar:!0,hideOverflowX:!0,sx:{height:"calc(100vh - 150px)"},children:a(d,{pr:2,pl:2,children:g||!m?a(f,{children:a(u,{variant:"h6",sx:{opacity:.5},children:"Loading..."})}):a(S,{component:x,withExpandRoot:!0,search:n.current,onSearchChanged:e=>l(e),sx:{background:e=>e.palette.background.default,minHeight:"calc(100vh - 160px)",p:1},formatSearch:e=>{const a=k.current.map[e];return a?`${a.label}`:""},formatKey:e=>{const t=k.current.map[e];return t?a(v,{direction:"row",alignItems:"center",gap:1,children:["directory"===t.type&&a(H,{sx:{color:"#1976d2",fontSize:20}}),a(u,{children:t?t.label:e}),a(d,{sx:{flex:1}})]}):null},EmptyItem:()=>a("span",{children:"No files"}),CustomItem:({itemKey:e,index:t,withDarkParent:r})=>{const o=k.current.map[e];return o?"file"!==o.type?null:a(y,{sx:{width:"100%",display:"flex",alignItems:"center",justifyContent:"stretch",direction:"row",background:t%2==0?"transparent":r?"#fff6":"#ccc6",gap:1,p:1,mt:0===t?1:0},onClick:()=>{return a=e,void i.layoutService.pickDumpContent(a);var a},children:[M(o),a(d,{sx:{display:"flex",flexDirection:"column",alignItems:"stretch",justifyContent:"stretch","& > *":{width:"100%",textAlign:"start"}},children:[a(u,{variant:"body2",children:o.label}),a(u,{variant:"caption",sx:{opacity:.5},children:o.mimeType})]}),a(d,{sx:{flex:1}}),a(b,{sx:{mr:2,pointerEvents:"none"},variant:"text",children:"Open"})]}):null},data:m.record,keyWidth:3,valueWidth:9})})}),a(w,{})]})},R=[{id:"search",element:D,isActive:e=>k(["/dump/:search"],e)},{id:"main",element:D,isActive:e=>k(["/dump"],e)}],W=({search:e=""})=>a(L,{history:i.routerService,onLoadStart:()=>i.layoutService.setAppbarLoader(!0),onLoadEnd:()=>i.layoutService.setAppbarLoader(!1),routes:R,params:{search:e}});export{W as DumpPage,W as default};
