opencami 1.8.13 → 1.9.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.
- package/README.md +4 -2
- package/dist/client/assets/{CSPContext-DATmz4sz.js → CSPContext-B3PAVjBL.js} +1 -1
- package/dist/client/assets/{DirectionContext-FHFKdJq_.js → DirectionContext-CR5CCisG.js} +1 -1
- package/dist/client/assets/_sessionKey-Bg_9uype.js +23 -0
- package/dist/client/assets/agents-BiTHBb6Z.js +2 -0
- package/dist/client/assets/{agents-screen-C58VLjES.js → agents-screen--ZMzN5cB.js} +1 -1
- package/dist/client/assets/bots-DxhRnQp5.js +2 -0
- package/dist/client/assets/{bots-screen-B8h4Y1VL.js → bots-screen-C_uJBNwI.js} +1 -1
- package/dist/client/assets/{button-BcUmP7JL.js → button-BciDmec0.js} +1 -1
- package/dist/client/assets/{composite--BBbKdxm.js → composite-DArWbFHm.js} +1 -1
- package/dist/client/assets/{connect-BmwKnEFP.js → connect-B48HecjN.js} +1 -1
- package/dist/client/assets/{dashboard-BWQl_-2-.js → dashboard-BVKx9FMy.js} +1 -1
- package/dist/client/assets/{event-BxzjTPjG.js → event-BCwqPPkP.js} +1 -1
- package/dist/client/assets/{file-explorer-screen-BAbbb_R4.js → file-explorer-screen-DPs-FWeA.js} +1 -1
- package/dist/client/assets/files-SEycwYCa.js +2 -0
- package/dist/client/assets/{follow-up-suggestions-Bq-xR5GV.js → follow-up-suggestions-BPjWBpiy.js} +1 -1
- package/dist/client/assets/{index-rOr2i8gW.js → index-0gdwm1_H.js} +1 -1
- package/dist/client/assets/{index-BTtT4Vbb.js → index-CGeJcqZ3.js} +1 -1
- package/dist/client/assets/{keyboard-shortcuts-dialog-BA8cBwWm.js → keyboard-shortcuts-dialog-CK_XTzLr.js} +1 -1
- package/dist/client/assets/{main-_1IghVZn.js → main-B2CrcRuC.js} +3 -3
- package/dist/client/assets/{markdown-CqIcraPO.js → markdown-CdkuX06F.js} +1 -1
- package/dist/client/assets/memory-C7lKdkmc.js +2 -0
- package/dist/client/assets/{memory-screen-GBzowsnE.js → memory-screen-C1RfLy-d.js} +1 -1
- package/dist/client/assets/{menu--FXN_JCl.js → menu-CIwnliij.js} +1 -1
- package/dist/client/assets/{opencami-logo-BFo87CeM.js → opencami-logo-SVuYD55V.js} +1 -1
- package/dist/client/assets/{proxy-CJ6-TEKD.js → proxy-BijR8W1L.js} +1 -1
- package/dist/client/assets/{react-BRYbnjMp.js → react-DWx7OvUo.js} +1 -1
- package/dist/client/assets/{search-dialog-CJS2GUnE.js → search-dialog-CB4KE8ec.js} +1 -1
- package/dist/client/assets/{search-sources-badge-D0YArqfp.js → search-sources-badge-B8Z-8sSf.js} +1 -1
- package/dist/client/assets/{session-export-dialog-Bc9YEPLs.js → session-export-dialog-tDiFuv3a.js} +1 -1
- package/dist/client/assets/{settings-dialog-SDzqDXsx.js → settings-dialog-aL-AH4Rt.js} +1 -1
- package/dist/client/assets/skills-D1T6uemU.js +2 -0
- package/dist/client/assets/{skills-panel-DIalYvpW.js → skills-panel-fjJQVMog.js} +1 -1
- package/dist/client/assets/styles-D0L88B64.css +1 -0
- package/dist/client/assets/{switch-BwmDNR0d.js → switch-Bn5uei2k.js} +1 -1
- package/dist/client/assets/{tabs-T1fJbUsm.js → tabs-DOBNAUVE.js} +1 -1
- package/dist/client/assets/{thinking-DUdE6Iej.js → thinking-dfGrFAMV.js} +1 -1
- package/dist/client/assets/{tooltip-DexBPu8g.js → tooltip-DOKkNFvu.js} +1 -1
- package/dist/client/assets/{use-file-explorer-state-eXs92yKN.js → use-file-explorer-state-BAa6Cxyr.js} +1 -1
- package/dist/client/assets/{useBaseUiId-DN9cOflS.js → useBaseUiId-DFpBD0sg.js} +1 -1
- package/dist/client/assets/{useCompositeItem-B_J-cnZX.js → useCompositeItem-B-Axq9-D.js} +1 -1
- package/dist/client/assets/{useControlled-DeDLOsPR.js → useControlled-CQHE0ITz.js} +1 -1
- package/dist/client/assets/{useMutation-TzgejsE_.js → useMutation-BFl-7GnD.js} +1 -1
- package/dist/client/assets/{useOnFirstRender-S4-xcV93.js → useOnFirstRender-DlXHIIGk.js} +1 -1
- package/dist/client/assets/{useQuery-BdjM5kzn.js → useQuery-D-sF8Tld.js} +1 -1
- package/dist/server/assets/{_sessionKey-DBzlGMo3.js → _sessionKey-D8TGrDRM.js} +429 -131
- package/dist/server/assets/{_tanstack-start-manifest_v-CX4xb59U.js → _tanstack-start-manifest_v-DalBo2bY.js} +1 -1
- package/dist/server/assets/{follow-up-suggestions-BmSFSY87.js → follow-up-suggestions-C65ptDij.js} +2 -2
- package/dist/server/assets/{index-C1dylvu-.js → index-gRco4Ina.js} +1 -1
- package/dist/server/assets/{router-CL6A11qi.js → router-DaKDqc9w.js} +72 -251
- package/dist/server/assets/{search-dialog-D8DvpPZw.js → search-dialog-DSSK93kq.js} +2 -2
- package/dist/server/assets/{settings-dialog-CeP-J_NJ.js → settings-dialog-DyWNblva.js} +2 -2
- package/dist/server/assets/{thinking-ClIWjSbx.js → thinking-CU0FRlzT.js} +2 -2
- package/dist/server/server.js +2 -2
- package/package.json +1 -1
- package/dist/client/assets/_sessionKey-D2ZMdqJ0.js +0 -23
- package/dist/client/assets/agents-9A0buuwT.js +0 -2
- package/dist/client/assets/bots-Lqt92ma0.js +0 -2
- package/dist/client/assets/files-DvIFms9G.js +0 -2
- package/dist/client/assets/memory-B3LyVZwO.js +0 -2
- package/dist/client/assets/skills-BVLjvrPU.js +0 -2
- package/dist/client/assets/styles-b2XYKZYx.css +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as p,j as e}from"./main-
|
|
1
|
+
import{r as p,j as e}from"./main-B2CrcRuC.js";import{u as c}from"./useQuery-D-sF8Tld.js";async function l(a){const r=await fetch(a);if(!r.ok){const s=await r.json().catch(()=>({}));throw new Error(s.error||`Request failed: ${r.status}`)}return await r.json()}function n(a){return`${(a/1024**3).toFixed(1)} GB`}function f(a){return new Intl.NumberFormat(void 0,{notation:"compact",maximumFractionDigits:1}).format(a)}function b(a){return`$${a.toFixed(3)}`}function v(a){if(!a)return"—";const r=new Date(a);return Number.isNaN(r.getTime())?"—":r.toLocaleString()}function N(a){return a<60?"#10b981":a<=80?"#f59e0b":"#ef4444"}function o({percent:a}){const r=Math.max(0,Math.min(100,a));return e.jsx("div",{className:"h-2 w-full rounded-full bg-primary-200 overflow-hidden",children:e.jsx("div",{className:"h-full rounded-full transition-all duration-300",style:{width:`${r}%`,backgroundColor:N(r)}})})}function m(){return e.jsxs("div",{className:"rounded-xl border border-primary-200 bg-primary-100 p-4 animate-pulse space-y-3",children:[e.jsx("div",{className:"h-4 w-32 bg-primary-200 rounded"}),e.jsx("div",{className:"h-10 bg-primary-200 rounded"}),e.jsx("div",{className:"h-10 bg-primary-200 rounded"}),e.jsx("div",{className:"h-10 bg-primary-200 rounded"})]})}function k(){const[a,r]=p.useState(()=>typeof document>"u"?!0:document.visibilityState==="visible");p.useEffect(()=>{if(typeof document>"u")return;function t(){r(document.visibilityState==="visible")}return t(),document.addEventListener("visibilitychange",t),()=>{document.removeEventListener("visibilitychange",t)}},[]);const s=c({queryKey:["dashboard","system"],queryFn:()=>l("/api/dashboard/system"),refetchInterval:a?1e4:!1}),i=c({queryKey:["dashboard","gateway"],queryFn:()=>l("/api/dashboard/gateway"),refetchInterval:a?1e4:!1}),d=c({queryKey:["dashboard","crons"],queryFn:async()=>(await l("/api/dashboard/crons")).jobs,refetchInterval:a?1e4:!1}),u=s.isError||i.isError||d.isError,x=s.data?.cpu??0,h=(s.data?.ram.total??0)>0?(s.data?.ram.used??0)/(s.data?.ram.total??1)*100:0,y=(s.data?.disk.total??0)>0?(s.data?.disk.used??0)/(s.data?.disk.total??1)*100:0;return e.jsxs("div",{className:"flex h-screen flex-col bg-surface text-primary-900",children:[e.jsxs("div",{className:"px-4 pt-4 pb-3 border-b border-primary-100",children:[e.jsx("h2",{className:"text-base font-semibold text-primary-900",children:"Dashboard"}),e.jsx("p",{className:"text-xs text-primary-500",children:"Live system and gateway overview (refreshes every 10s)"})]}),e.jsxs("div",{className:"min-h-0 flex-1 overflow-auto p-4",children:[u&&e.jsx("div",{className:"mb-4 rounded-lg border border-red-300/40 bg-red-500/10 px-3 py-2 text-sm text-red-400",children:"Failed to load one or more widgets. Retrying automatically…"}),e.jsxs("div",{className:"grid grid-cols-1 gap-4 lg:grid-cols-3",children:[s.isLoading?e.jsx(m,{}):e.jsxs("div",{className:"rounded-xl border border-primary-200 bg-primary-100 p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-sm font-semibold",children:"💻 System Stats"}),e.jsx("span",{className:"text-xs text-primary-500",children:"↻ auto-refresh"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs text-primary-500",children:[e.jsx("span",{children:"CPU"}),e.jsxs("span",{children:[x.toFixed(1),"% · ",s.data?.cores??0," ","cores"]})]}),e.jsx(o,{percent:x})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs text-primary-500",children:[e.jsx("span",{children:"RAM"}),e.jsxs("span",{children:[n(s.data?.ram.used??0)," /"," ",n(s.data?.ram.total??0)]})]}),e.jsx(o,{percent:h})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs text-primary-500",children:[e.jsx("span",{children:"Disk"}),e.jsxs("span",{children:[n(s.data?.disk.used??0)," /"," ",n(s.data?.disk.total??0)]})]}),e.jsx(o,{percent:y})]}),e.jsxs("div",{className:"border-t border-primary-200 pt-3 space-y-1.5 text-xs text-primary-500",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{children:"Load (1m/5m/15m)"}),e.jsxs("span",{children:[(s.data?.load?.[0]??0).toFixed(2)," ·"," ",(s.data?.load?.[1]??0).toFixed(2)," ·"," ",(s.data?.load?.[2]??0).toFixed(2)]})]}),e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{children:"Uptime"}),e.jsx("span",{children:s.data?.uptime??"0m"})]}),e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{children:"Net ↓ / ↑"}),e.jsxs("span",{children:[s.data?.network.rx??"0 MB"," /"," ",s.data?.network.tx??"0 MB"]})]}),e.jsxs("div",{className:"truncate",title:s.data?.cpuModel??"",children:["CPU: ",s.data?.cpuModel??"Unknown CPU"]})]}),e.jsxs("div",{className:"border-t border-primary-200 pt-3",children:[e.jsx("div",{className:"text-xs font-semibold text-primary-700 mb-2",children:"Top Processes"}),e.jsxs("div",{className:"space-y-1 text-xs",children:[(s.data?.topProcesses??[]).map((t,j)=>e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"truncate text-primary-700",children:t.name}),e.jsxs("span",{className:"text-primary-500 shrink-0",children:[t.cpu.toFixed(1),"% CPU · ",t.mem.toFixed(1),"% MEM"]})]},`${t.name}-${j}`)),(s.data?.topProcesses.length??0)===0&&e.jsx("div",{className:"text-primary-500",children:"No process data."})]})]})]}),i.isLoading?e.jsx(m,{}):e.jsxs("div",{className:"rounded-xl border border-primary-200 bg-primary-100 p-4 space-y-4",children:[e.jsx("h3",{className:"text-sm font-semibold",children:"Gateway Status"}),e.jsxs("div",{className:"space-y-3 text-sm",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-primary-500",children:"Active sessions"}),e.jsx("span",{children:i.data?.activeSessions??0})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-primary-500",children:"Tokens today"}),e.jsx("span",{children:f(i.data?.tokensToday??0)})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-primary-500",children:"Estimated cost"}),e.jsx("span",{children:b(i.data?.costToday??0)})]})]})]}),d.isLoading?e.jsx(m,{}):e.jsxs("div",{className:"rounded-xl border border-primary-200 bg-primary-100 p-4 flex flex-col min-h-[340px] max-h-[70vh]",children:[e.jsxs("h3",{className:"text-sm font-semibold mb-3",children:["🕐 Cron Jobs (",d.data?.length??0,")"]}),e.jsxs("div",{className:"space-y-2 overflow-auto pr-1",children:[(d.data??[]).map(t=>e.jsxs("div",{className:`rounded-md border border-primary-200 px-2.5 py-2 ${t.enabled?"opacity-100":"opacity-50 grayscale"}`,children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:"text-sm truncate",children:t.name}),e.jsx("div",{className:"text-xs",children:t.enabled?t.lastStatus==="ok"?"✅":t.lastStatus==="error"?"❌":"—":"⏸️"})]}),e.jsxs("div",{className:"mt-1 text-xs text-primary-500",children:["Next: ",v(t.nextRun)]})]},t.id)),(d.data?.length??0)===0&&e.jsx("div",{className:"text-xs text-primary-500",children:"No cron jobs found."})]})]})]})]})]})}export{k as component};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as l}from"./main-
|
|
1
|
+
import{r as l}from"./main-B2CrcRuC.js";import{c as d,i as p,d as m}from"./useBaseUiId-DFpBD0sg.js";const e=typeof navigator<"u",a=g(),u=T(),c=h(),R=typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter:none"),S=a.platform==="MacIntel"&&a.maxTouchPoints>1?!0:/iP(hone|ad|od)|iOS/.test(a.platform),x=e&&/apple/i.test(navigator.vendor),s=e&&/android/i.test(u)||/android/i.test(c),D=e&&u.toLowerCase().startsWith("mac")&&!navigator.maxTouchPoints,f=c.includes("jsdom/");function g(){if(!e)return{platform:"",maxTouchPoints:-1};const t=navigator.userAgentData;return t?.platform?{platform:t.platform,maxTouchPoints:navigator.maxTouchPoints}:{platform:navigator.platform??"",maxTouchPoints:navigator.maxTouchPoints??-1}}function h(){if(!e)return"";const t=navigator.userAgentData;return t&&Array.isArray(t.brands)?t.brands.map(({brand:r,version:n})=>`${r}/${n}`).join(" "):navigator.userAgent}function T(){if(!e)return"";const t=navigator.userAgentData;return t?.platform?t.platform:navigator.platform??""}function k(t){return t?.ownerDocument||document}const b=[];function C(t){l.useEffect(t,b)}const i="data-base-ui-focusable",O="active",v="selected",E="input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])",L="ArrowLeft",_="ArrowRight",W="ArrowUp",M="ArrowDown";function F(t){let r=t.activeElement;for(;r?.shadowRoot?.activeElement!=null;)r=r.shadowRoot.activeElement;return r}function A(t,r){if(!t||!r)return!1;const n=r.getRootNode?.();if(t.contains(r))return!0;if(n&&d(n)){let o=r;for(;o;){if(t===o)return!0;o=o.parentNode||o.host}}return!1}function I(t,r){if(!m(t))return!1;const n=t;if(r.hasElement(n))return!n.hasAttribute("data-trigger-disabled");for(const[,o]of r.entries())if(A(o,n))return!o.hasAttribute("data-trigger-disabled");return!1}function N(t){return"composedPath"in t?t.composedPath()[0]:t.target}function U(t,r){if(r==null)return!1;if("composedPath"in t)return t.composedPath().includes(r);const n=t;return n.target!=null&&r.contains(n.target)}function V(t){return t.matches("html,body")}function y(t){return p(t)&&t.matches(E)}function Y(t){return t?t.getAttribute("role")==="combobox"&&y(t):!1}function j(t){if(!t||f)return!0;try{return t.matches(":focus-visible")}catch{return!0}}function B(t){return t?t.hasAttribute(i)?t:t.querySelector(`[${i}]`)||t:null}function K(t){t.preventDefault(),t.stopPropagation()}function $(t){return"nativeEvent"in t}function q(t){return t.pointerType===""&&t.isTrusted?!0:s&&t.pointerType?t.type==="click"&&t.buttons===1:t.detail===0&&!t.pointerType}function H(t){return f?!1:!s&&t.width===0&&t.height===0||s&&t.width===1&&t.height===1&&t.pressure===0&&t.detail===0&&t.pointerType==="mouse"||t.width<1&&t.height<1&&t.pressure===0&&t.detail===0&&t.pointerType==="touch"}function z(t,r){const n=["mouse","pen"];return r||n.push("",void 0),n.includes(t)}function G(t){const r=t.type;return r==="click"||r==="mousedown"||r==="keydown"||r==="keyup"}export{W as A,i as F,v as S,E as T,M as a,L as b,_ as c,F as d,A as e,G as f,y as g,B as h,z as i,Y as j,N as k,q as l,H as m,S as n,k as o,R as p,I as q,j as r,K as s,D as t,C as u,x as v,$ as w,V as x,U as y,O as z};
|
package/dist/client/assets/{file-explorer-screen-BAbbb_R4.js → file-explorer-screen-DPs-FWeA.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e,r,L as se,u as L}from"./main-_1IghVZn.js";import{u as ie}from"./useQuery-BdjM5kzn.js";import{M as be,c as h,b as ne,B as k,H as j,I as ye,r as ve,N as je,l as we,O as Ne,Q as Ce,W as ke,Y as ae,T as re,Z as ce,_ as De,$ as Se,D as Ee,a0 as Fe,a1 as ze,a2 as de,a3 as ue,a4 as Me,a5 as Re,a6 as Te,a7 as Le,a8 as $e,a9 as Ke,u as ee,aa as Ue,V as Ie}from"./button-BcUmP7JL.js";import{T as P,a as W,b as B,c as O,s as Ae,d as Pe,g as te}from"./tooltip-DexBPu8g.js";import{u as F,D as Q,a as _,b as V,c as H,d as G}from"./use-file-explorer-state-eXs92yKN.js";import{m as E,A}from"./proxy-CJ6-TEKD.js";import{M as We,a as Be,b as Oe,c as le}from"./menu--FXN_JCl.js";import{u as $}from"./useMutation-TzgejsE_.js";import"./useOnFirstRender-S4-xcV93.js";import"./useBaseUiId-DN9cOflS.js";import"./event-BxzjTPjG.js";import"./visuallyHidden-COI6QeQH.js";import"./DirectionContext-FHFKdJq_.js";import"./composite--BBbKdxm.js";import"./react-BRYbnjMp.js";import"./useCompositeItem-B_J-cnZX.js";function qe({className:i}){return e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"80",height:"80",viewBox:"0 0 80 80",fill:"none",className:i,children:[e.jsx("rect",{width:"80",height:"80",fill:"currentColor",className:"text-transparent"}),e.jsx("path",{d:"M61.9624 45.5729C62.5862 44.3371 63.0907 43.3377 63.4782 41.9826C69.8221 28.8286 70.5847 14.0975 67.1723 4.32469C65.8317 0.249835 62.7688 0.254311 62.6374 3.58605C61.355 12.189 58.9061 17.6275 57.1756 21.0554C52.8087 29.7058 45.9949 37.7278 39.3706 42.7305C28.6217 50.8021 25.0716 44.614 24.3711 37.8823C23.8822 32.1203 24.7206 25.5721 26.24 18.2889C27.102 15.3261 24.3944 13.9592 22.5223 16.4122C20.4062 19.3487 18.5586 22.4209 17.1838 25.7318C12.9928 33.4462 10.3896 45.3332 11.4505 57.6273C12.2296 63.5357 13.1688 68.4057 14.1079 73.2757C15.2695 79.0941 19.1598 79.5073 24.3117 78.0088C39.7921 74.0789 54.143 58.872 59.7093 49.1011C60.7255 48.0229 61.3494 46.7872 61.9624 45.5729Z",fill:"currentColor",className:"text-primary-950"})]})}function Qe(){return r.useMemo(()=>typeof window>"u"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches,[])}function _e({isCollapsed:i,onToggleCollapse:s,onSelectAction:n}){const{navigateTo:a,currentPath:o}=F(),c=Qe(),t=r.useMemo(()=>({duration:c?0:.15,ease:i?"easeIn":"easeOut"}),[i,c]),l=r.useCallback(d=>{a(d)},[a]),m=r.useCallback((d,C)=>{(d.key==="Enter"||d.key===" ")&&(d.preventDefault(),C())},[]),v=r.useMemo(()=>[{path:"/",icon:be,label:"Home",id:"home"}],[]),y=r.useMemo(()=>({className:"border-r border-primary-200 h-full overflow-hidden bg-primary-100 flex flex-col"}),[]),f=48,u=300;return e.jsxs(E.aside,{initial:!1,animate:{width:c?i?f:u:void 0},style:{width:c?void 0:i?f:u},transition:t,className:y.className,role:"navigation","aria-label":"File explorer navigation",children:[e.jsxs(E.div,{layout:!0,transition:{layout:t},className:h("flex items-center h-12 px-2 justify-between"),children:[e.jsx(A,{initial:!1,children:i?null:e.jsx(E.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:t,children:e.jsxs(se,{to:"/new",className:h(ne({variant:"ghost",size:"sm"}),"w-full pl-1.5 justify-start","focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation"),children:[e.jsx(qe,{className:"size-5 rounded-sm","aria-hidden":"true"}),e.jsx("span",{children:"WebClaw"})]})})}),e.jsx(P,{children:e.jsxs(W,{children:[e.jsx(B,{onClick:s,onKeyDown:d=>m(d,s),render:e.jsx(k,{size:"icon-sm",variant:"ghost","aria-label":i?"Expand sidebar":"Collapse sidebar",className:h("focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation"),children:e.jsx(j,{icon:ye,size:20,strokeWidth:1.5,"aria-hidden":"true"})})}),e.jsx(O,{side:"right",children:i?"Expand sidebar":"Collapse sidebar"})]})})]}),e.jsx("div",{className:"px-2 mb-4",children:e.jsx(E.div,{layout:!0,transition:{layout:t},className:"w-full",children:e.jsx(P,{children:e.jsxs(W,{children:[e.jsx(B,{asChild:!0,children:e.jsxs(se,{to:"/chat/$sessionKey",params:{sessionKey:"main"},className:h(ne({variant:"ghost",size:"sm"}),"w-full pl-1.5 justify-start","focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation"),onClick:n,children:[e.jsx(j,{icon:ve,size:20,strokeWidth:1.5,className:"min-w-5","aria-hidden":"true"}),e.jsx(A,{initial:!1,mode:"wait",children:i?null:e.jsx(E.span,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:t,className:"overflow-hidden whitespace-nowrap",children:"Back to Chat"})})]})}),i?e.jsx(O,{side:"right",children:"Back to Chat"}):null]})})})}),e.jsx("div",{className:"flex-1 min-h-0 relative overflow-hidden",children:e.jsx(A,{initial:!1,children:i?e.jsx(E.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:t,className:"px-2 space-y-1",children:v.map(d=>e.jsx(P,{children:e.jsxs(W,{children:[e.jsx(B,{onClick:()=>l(d.path),onKeyDown:C=>m(C,()=>l(d.path)),render:e.jsx(k,{size:"icon-sm",variant:"ghost","aria-current":o===d.path?"page":void 0,"aria-label":`Navigate to ${d.label}`,className:h("w-full text-primary-600 hover:text-primary-900","focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation",o===d.path&&"bg-primary-200 text-primary-900"),children:e.jsx(j,{icon:d.icon,size:20,strokeWidth:1.5,"aria-hidden":"true"})})}),e.jsx(O,{side:"right",children:d.label})]})},d.id))},"collapsed-content"):e.jsx(E.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:t,className:"absolute inset-0 pt-0 flex flex-col w-[300px] min-h-0",children:e.jsxs("div",{className:"flex-1 min-h-0 px-2",children:[e.jsx("div",{className:"mb-4",children:e.jsx("h2",{className:"text-sm font-medium text-primary-700 mb-3 px-1.5",children:"Quick Access"})}),e.jsx("nav",{className:"space-y-1",role:"list","aria-label":"Quick access folders",children:v.map(d=>e.jsx("div",{role:"listitem",children:e.jsxs(k,{variant:"ghost",size:"sm",onClick:()=>l(d.path),onKeyDown:C=>m(C,()=>l(d.path)),"aria-current":o===d.path?"page":void 0,className:h("w-full pl-1.5 justify-start text-primary-600 hover:text-primary-900","focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation",o===d.path&&"bg-primary-200 text-primary-900 font-medium"),"aria-label":`Navigate to ${d.label}`,children:[e.jsx(j,{icon:d.icon,size:20,strokeWidth:1.5,className:"min-w-5","aria-hidden":"true"}),e.jsx("span",{className:"overflow-hidden whitespace-nowrap min-w-0 truncate",children:d.label})]})},d.id))})]})},"content")})}),e.jsx("div",{className:"px-2 py-3 border-t border-primary-200 bg-primary-100",children:e.jsx(E.div,{layout:!0,transition:{layout:t},className:"w-full",children:e.jsx(P,{children:e.jsxs(W,{children:[e.jsx(B,{asChild:!0,children:e.jsxs(k,{variant:"ghost",size:i?"icon-sm":"sm",className:h(i?"w-full":"w-full justify-start pl-1.5","focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation"),"aria-label":"Settings",children:[e.jsx(j,{icon:je,size:20,strokeWidth:1.5,className:"min-w-5","aria-hidden":"true"}),e.jsx(A,{initial:!1,mode:"wait",children:i?null:e.jsx(E.span,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:t,className:"overflow-hidden whitespace-nowrap",children:"Settings"})})]})}),i?e.jsx(O,{side:"right",children:"Settings"}):null]})})})})]})}function Ve(i,s){return i.isCollapsed===s.isCollapsed}const He=r.memo(_e,Ve);function Ge({path:i}){const{navigateTo:s}=F(),n=i==="/"?[]:i.split("/").filter(Boolean),a=[{name:"Home",path:"/"},...n.map((t,l)=>({name:t,path:"/"+n.slice(0,l+1).join("/")}))],o=r.useCallback(t=>{s(t)},[s]),c=r.useCallback((t,l)=>{(t.key==="Enter"||t.key===" ")&&(t.preventDefault(),s(l))},[s]);return e.jsx("nav",{"aria-label":"File navigation",className:"text-sm text-primary-600",children:e.jsx("ol",{className:"flex items-center gap-1",children:a.map((t,l)=>e.jsxs("li",{className:"flex items-center gap-1",children:[l>0?e.jsx(j,{icon:we,size:16,strokeWidth:1.5,className:"text-primary-400","aria-hidden":"true"}):null,e.jsxs("button",{type:"button",onClick:()=>o(t.path),onKeyDown:m=>c(m,t.path),"aria-current":l===a.length-1?"page":void 0,className:h("flex items-center gap-1.5 rounded-md px-2 py-1","transition-colors duration-150 ease-out","hover:bg-primary-100 hover:text-primary-900","focus-visible:bg-primary-100 focus-visible:text-primary-900","focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation",l===a.length-1?"text-primary-900 font-medium":"text-primary-600"),children:[l===0?e.jsx(j,{icon:Ne,size:16,strokeWidth:1.5,"aria-hidden":"true"}):null,e.jsx("span",{className:"whitespace-nowrap",children:t.name})]})]},t.path))})})}const Z=[{label:"Name",value:"name"},{label:"Size",value:"size"},{label:"Modified",value:"modified"}];function Je({onUpload:i,onCreateFolder:s}){const{viewMode:n,sortBy:a,sortAsc:o,setViewMode:c,setSortBy:t,toggleSort:l}=F(),m=r.useCallback(()=>{c("list")},[c]),v=r.useCallback(()=>{c("grid")},[c]),y=r.useCallback(u=>{t(u)},[t]),f=r.useCallback((u,d)=>{(u.key==="Enter"||u.key===" ")&&(u.preventDefault(),d())},[]);return e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"flex items-center border border-primary-200 rounded-lg overflow-hidden",role:"group","aria-label":"View mode",children:[e.jsx(k,{size:"sm",variant:n==="list"?"default":"ghost",onClick:m,onKeyDown:u=>f(u,m),"aria-label":"Switch to list view","aria-pressed":n==="list",className:h("rounded-none border-0","focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation"),children:e.jsx(j,{icon:Ce,size:18,strokeWidth:1.5,"aria-hidden":"true"})}),e.jsx(k,{size:"sm",variant:n==="grid"?"default":"ghost",onClick:v,onKeyDown:u=>f(u,v),"aria-label":"Switch to grid view","aria-pressed":n==="grid",className:h("rounded-none border-0 border-l border-primary-200","focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation"),children:e.jsx(j,{icon:ke,size:18,strokeWidth:1.5,"aria-hidden":"true"})})]}),e.jsxs(We,{children:[e.jsx(Be,{render:e.jsxs(k,{variant:"ghost",size:"sm",className:h("gap-1","focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation"),"aria-label":`Sort by ${Z.find(u=>u.value===a)?.label}, ${o?"ascending":"descending"}`,children:[e.jsxs("span",{children:["Sort: ",Z.find(u=>u.value===a)?.label]}),e.jsx(j,{icon:o?ae:re,size:16,strokeWidth:1.5,"aria-hidden":"true"})]})}),e.jsxs(Oe,{side:"bottom",align:"start",children:[Z.map(u=>e.jsx(le,{onClick:()=>y(u.value),className:h(a===u.value&&"bg-primary-100 text-primary-900","focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none"),"aria-current":a===u.value?"true":"false",children:u.label},u.value)),e.jsxs(le,{onClick:l,className:"focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none",children:[e.jsx(j,{icon:o?re:ae,size:16,strokeWidth:1.5,"aria-hidden":"true"}),o?"Sort Descending":"Sort Ascending"]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(k,{variant:"ghost",size:"sm",onClick:i,onKeyDown:u=>f(u,i),className:h("gap-2","focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation"),"aria-label":"Upload files",children:[e.jsx(j,{icon:ce,size:18,strokeWidth:1.5,"aria-hidden":"true"}),e.jsx("span",{children:"Upload"})]}),e.jsxs(k,{variant:"ghost",size:"sm",onClick:s,onKeyDown:u=>f(u,s),className:h("gap-2","focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation"),"aria-label":"Create new folder",children:[e.jsx(j,{icon:De,size:18,strokeWidth:1.5,"aria-hidden":"true"}),e.jsx("span",{children:"New Folder"})]})]})]})}const z={all:["files"],listing:i=>["files","listing",i],content:i=>["files","content",i]};function Xe(i){return ie({queryKey:z.content(i||""),queryFn:async({signal:s})=>{const n=await fetch(`/api/files/read?path=${encodeURIComponent(i)}`,{signal:s});if(!n.ok){const a=await n.json().catch(()=>({error:"Failed to read file"}));throw new Error(a.error||"Failed to read file")}return n.json()},enabled:!!i,staleTime:30*1e3,gcTime:300*1e3})}function Ye(){const i=L(),s=r.useRef(null);return r.useEffect(()=>()=>{s.current?.abort()},[]),$({mutationFn:async({path:n,content:a})=>{s.current?.abort();const o=new AbortController;s.current=o;const c=await fetch("/api/files/save",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:n,content:a}),signal:o.signal});if(!c.ok){const t=await c.json().catch(()=>({error:"Failed to save file"}));throw new Error(t.error||"Failed to save file")}return c.json()},onSuccess:(n,a)=>{i.invalidateQueries({queryKey:z.content(a.path)});const o=a.path.split("/").slice(0,-1).join("/")||"/";i.invalidateQueries({queryKey:z.listing(o)})}})}function Ze(i){return ie({queryKey:z.listing(i),queryFn:async({signal:s})=>{const n=await fetch(`/api/files/list?path=${encodeURIComponent(i)}`,{signal:s});if(!n.ok){const a=await n.text();throw new Error(`Failed to load files: ${a}`)}return n.json()},staleTime:300*1e3,gcTime:600*1e3,retry:3})}function ei(){const i=new Set,s=r.useRef(null);return r.useEffect(()=>()=>{s.current?.abort(),i.forEach(n=>URL.revokeObjectURL(n)),i.clear()},[]),$({mutationFn:async n=>{s.current?.abort();const a=new AbortController;s.current=a;const o=await fetch(`/api/files/download?path=${encodeURIComponent(n)}`,{signal:a.signal});if(!o.ok){const v=await o.text();throw new Error(`Download failed: ${v}`)}const c=await o.blob(),t=window.URL.createObjectURL(c);i.add(t);const l=n.split("/").pop()||"download",m=document.createElement("a");m.href=t,m.download=l,document.body.appendChild(m),m.click(),document.body.removeChild(m),setTimeout(()=>{i.has(t)&&(URL.revokeObjectURL(t),i.delete(t))},100)},onError:n=>{n instanceof Error&&n.name==="AbortError"||console.error("Download failed:",n)}})}function ii(){const i=L(),s=r.useRef(null);return r.useEffect(()=>()=>{s.current?.abort()},[]),$({mutationFn:async({files:n,path:a})=>{s.current?.abort();const o=new AbortController;s.current=o;const c=[];for(let t=0;t<n.length;t++){const l=new FormData;l.append("path",a),l.append("file",n[t]);const m=await fetch("/api/files/upload",{method:"POST",body:l,signal:o.signal});if(!m.ok){const v=await m.text();throw new Error(`Upload failed for ${n[t].name}: ${v}`)}c.push(await m.json())}return c},onSuccess:(n,a)=>{i.invalidateQueries({queryKey:z.listing(a.path)})},onError:n=>{n instanceof Error&&n.name==="AbortError"||console.error("Upload failed:",n)}})}function si(){const i=L(),s=r.useRef(null);return r.useEffect(()=>()=>{s.current?.abort()},[]),$({mutationFn:async n=>{s.current?.abort();const a=new AbortController;s.current=a;const o=await fetch(`/api/files/delete?path=${encodeURIComponent(n)}`,{method:"DELETE",signal:a.signal});if(!o.ok){const c=await o.text();throw new Error(`Delete failed: ${c}`)}return o.json()},onSuccess:(n,a)=>{const o=a.split("/").slice(0,-1).join("/")||"/";i.invalidateQueries({queryKey:z.listing(o)})},onError:n=>{n instanceof Error&&n.name==="AbortError"||console.error("Delete failed:",n)}})}function ni(){const i=L(),s=r.useRef(null);return r.useEffect(()=>()=>{s.current?.abort()},[]),$({mutationFn:async({path:n,name:a})=>{s.current?.abort();const o=new AbortController;s.current=o;const c=await fetch("/api/files/mkdir",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:`${n}/${a}`}),signal:o.signal});if(!c.ok){const t=await c.text();throw new Error(`Create folder failed: ${t}`)}return c.json()},onSuccess:(n,a)=>{i.invalidateQueries({queryKey:z.listing(a.path)})},onError:n=>{n instanceof Error&&n.name==="AbortError"||console.error("Create folder failed:",n)}})}function ai(){const i=L(),s=r.useRef(null);return r.useEffect(()=>()=>{s.current?.abort()},[]),$({mutationFn:async({oldPath:n,newName:a})=>{s.current?.abort();const o=new AbortController;s.current=o;const t=`${n.split("/").slice(0,-1).join("/")}/${a}`,l=await fetch("/api/files/rename",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({src:n,dst:t}),signal:o.signal});if(!l.ok){const m=await l.text();throw new Error(`Rename failed: ${m}`)}return l.json()},onSuccess:(n,a)=>{const o=a.oldPath.split("/").slice(0,-1).join("/")||"/";i.invalidateQueries({queryKey:z.listing(o)})},onError:n=>{n instanceof Error&&n.name==="AbortError"||console.error("Rename failed:",n)}})}const ri=new Set(["txt","md","log","json","xml","yaml","yml","csv","ini","conf","cfg","js","ts","jsx","tsx","py","java","cpp","c","h","css","html","htm","php","rb","go","rs","sh","bash","zsh","toml","env","gitignore","dockerfile","makefile","sql","graphql","svelte","vue","scss","less"]);function me({item:i,children:s,onOpenFile:n}){const[a,o]=r.useState(!1),[c,t]=r.useState({x:0,y:0}),[l,m]=r.useState(!1),[v,y]=r.useState(!1),[f,u]=r.useState(i.name),[d,C]=r.useState(""),N=r.useRef(null),{navigateTo:w}=F(),p=ei(),x=si(),D=ai(),M=r.useCallback(b=>{switch(b){case"open":i.isDir&&w(i.path);break;case"edit":n&&n(i.path);break;case"download":i.isDir||p.mutate(i.path);break;case"rename":u(i.name),C(""),m(!0);break;case"delete":y(!0);break}},[i,p,w]),X=r.useCallback(b=>{b.preventDefault(),b.stopPropagation(),t({x:b.clientX,y:b.clientY}),o(!0)},[]),K=r.useCallback(async()=>{if(!f||f===i.name){m(!1);return}C("");try{await D.mutateAsync({oldPath:i.path,newName:f.trim()}),m(!1)}catch(b){const T=b instanceof Error?b.message:"Failed to rename";C(T)}},[f,i,D]),U=r.useCallback(async()=>{try{await x.mutateAsync(i.path),y(!1)}catch(b){console.error("Delete failed:",b)}},[i.path,x]),Y=r.useCallback(b=>{b.key==="Enter"?(b.preventDefault(),K()):b.key==="Escape"&&(b.preventDefault(),m(!1))},[K]),g=r.useCallback(b=>{u(b.target.value),d&&C("")},[d]);r.useEffect(()=>{if(l&&N.current){const b=N.current;if(b.focus(),!i.isDir&&i.extension){const T=i.name.replace(new RegExp(`\\.${i.extension}$`),"");b.setSelectionRange(0,T.length)}else b.select()}},[l,i]);const S=f.trim().length>0&&!/[<>:"/\\|?*]/.test(f)&&!f.includes("..")&&f!==i.name,R=()=>p.isPending?"Downloading…":"Download",fe=()=>D.isPending?"Renaming…":"Rename",he=()=>x.isPending?"Deleting…":"Delete";r.useEffect(()=>{if(!a)return;const b=()=>o(!1),T=ge=>{ge.key==="Escape"&&o(!1)},xe=setTimeout(()=>{document.addEventListener("click",b),document.addEventListener("contextmenu",b),document.addEventListener("keydown",T)},0);return()=>{clearTimeout(xe),document.removeEventListener("click",b),document.removeEventListener("contextmenu",b),document.removeEventListener("keydown",T)}},[a]);const I=r.useCallback(b=>{o(!1),M(b)},[M]);return e.jsxs(e.Fragment,{children:[e.jsx("div",{onContextMenu:X,children:s}),a?e.jsx("div",{className:"fixed inset-0 z-50","aria-modal":"true",role:"dialog",children:e.jsxs("div",{className:"fixed min-w-[140px] rounded-lg bg-primary-50 p-1 text-sm text-primary-900 shadow-lg outline outline-primary-900/10 z-50",style:{left:c.x,top:c.y},role:"menu",onClick:b=>b.stopPropagation(),children:[i.isDir?e.jsxs("button",{type:"button",role:"menuitem",onClick:()=>I("open"),className:h("flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-sm text-primary-900","hover:bg-primary-100 select-none font-[450]","focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none"),children:[e.jsx(j,{icon:Se,size:16,strokeWidth:1.5,"aria-hidden":"true"}),"Open"]}):null,i.isDir?null:e.jsxs("button",{type:"button",role:"menuitem",onClick:()=>I("download"),disabled:p.isPending,className:h("flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-sm text-primary-900","hover:bg-primary-100 select-none font-[450]","focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none"),children:[e.jsx(j,{icon:Ee,size:16,strokeWidth:1.5,"aria-hidden":"true"}),R()]}),!i.isDir&&ri.has(i.extension.toLowerCase())?e.jsxs("button",{type:"button",role:"menuitem",onClick:()=>I("edit"),className:h("flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-sm text-primary-900","hover:bg-primary-100 select-none font-[450]","focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none"),children:[e.jsx(j,{icon:Fe,size:16,strokeWidth:1.5,"aria-hidden":"true"}),"Edit"]}):null,e.jsxs("button",{type:"button",role:"menuitem",onClick:()=>I("rename"),className:h("flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-sm text-primary-900","hover:bg-primary-100 select-none font-[450]","focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none"),children:[e.jsx(j,{icon:ze,size:16,strokeWidth:1.5,"aria-hidden":"true"}),"Rename"]}),e.jsxs("button",{type:"button",role:"menuitem",onClick:()=>I("delete"),className:h("flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-sm","text-red-600 hover:bg-red-50 select-none font-[450]","focus-visible:ring-2 focus-visible:ring-red-300 focus-visible:outline-none"),children:[e.jsx(j,{icon:de,size:16,strokeWidth:1.5,"aria-hidden":"true"}),"Delete"]})]})}):null,e.jsx(Q,{open:l,onOpenChange:m,children:e.jsx(_,{children:e.jsxs("div",{className:"p-6",children:[e.jsxs(V,{className:"mb-2",children:["Rename ",i.isDir?"Folder":"File"]}),e.jsxs(H,{className:"mb-4",children:['Enter a new name for "',i.name,'"']}),e.jsxs("div",{className:"mb-6",children:[e.jsxs("label",{htmlFor:"rename-input",className:"block text-sm font-medium text-primary-900 mb-2",children:[i.isDir?"Folder":"File"," Name"]}),e.jsx("input",{id:"rename-input",ref:N,type:"text",value:f,onChange:g,onKeyDown:Y,autoFocus:!0,spellCheck:!1,"aria-describedby":d?"rename-error":void 0,"aria-invalid":d?"true":"false",className:h("w-full px-3 py-2 border rounded-lg","transition-colors duration-150 ease-out","focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation",d?"border-red-300 focus-visible:ring-red-300":"border-primary-200 focus:border-primary-300")}),d?e.jsx("p",{id:"rename-error",className:"text-sm text-red-600 mt-1",role:"alert","aria-live":"polite",children:d}):null]}),D.isPending?e.jsx("div",{className:"mb-4 p-3 bg-primary-50 rounded-lg","aria-live":"polite",children:e.jsx("p",{className:"text-sm text-primary-600",children:"Renaming…"})}):null,e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(G,{disabled:D.isPending,className:h("focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation"),children:"Cancel"}),e.jsx(k,{onClick:K,disabled:!S||D.isPending,className:h("focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation",(!S||D.isPending)&&"opacity-50 cursor-not-allowed"),children:fe()})]})]})})}),e.jsx(Q,{open:v,onOpenChange:y,children:e.jsx(_,{children:e.jsxs("div",{className:"p-6",children:[e.jsxs(V,{className:"mb-2",children:["Delete ",i.isDir?"Folder":"File"]}),e.jsxs(H,{className:"mb-4",children:['Are you sure you want to delete "',i.name,'"?',i.isDir?" This will delete the folder and all its contents.":""," ","This action cannot be undone."]}),x.isPending?e.jsx("div",{className:"mb-4 p-3 bg-red-50 rounded-lg","aria-live":"polite",children:e.jsx("p",{className:"text-sm text-red-700",children:"Deleting…"})}):null,e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(G,{disabled:x.isPending,className:h("focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation"),children:"Cancel"}),e.jsx(k,{variant:"destructive",onClick:U,disabled:x.isPending,className:h("focus-visible:ring-2 focus-visible:ring-red-300 focus-visible:outline-none","touch-manipulation",x.isPending&&"opacity-50 cursor-not-allowed"),children:he()})]})]})})})]})}const ti=new Set(["txt","md","log","json","xml","yaml","yml","csv","ini","conf","cfg","js","ts","jsx","tsx","py","java","cpp","c","h","css","html","htm","php","rb","go","rs","sh","bash","zsh","toml","env","gitignore","dockerfile","makefile","sql","graphql","svelte","vue","scss","less"]);function J(i){if(i===0)return"0 B";const s=1024,n=["B","KB","MB","GB","TB"],a=Math.floor(Math.log(i)/Math.log(s));return parseFloat((i/Math.pow(s,a)).toFixed(1))+" "+n[a]}function q(i){const s=new Date(i),a=new Date().getTime()-s.getTime(),o=Math.floor(a/1e3),c=Math.floor(o/60),t=Math.floor(c/60),l=Math.floor(t/24);return l>7?s.toLocaleDateString():l>0?l===1?"yesterday":`${l} days ago`:t>0?t===1?"1 hour ago":`${t} hours ago`:c>0?c===1?"1 minute ago":`${c} minutes ago`:"just now"}function pe(i){if(i.isDir)return ue;const s=i.extension.toLowerCase();return["jpg","jpeg","png","gif","webp","svg","bmp"].includes(s)?Me:["mp4","avi","mkv","mov","wmv","flv","webm"].includes(s)?Re:["mp3","wav","flac","aac","ogg","m4a"].includes(s)?Te:["zip","rar","7z","tar","gz","bz2"].includes(s)?Le:["txt","md","log","json","xml","yaml","yml"].includes(s)?$e:["js","ts","jsx","tsx","py","java","cpp","c","h","css","html","php","rb","go","rs"].includes(s)?Ke:ee}function li(i,s,n){return r.useMemo(()=>[...i].sort((o,c)=>{if(o.isDir&&!c.isDir)return-1;if(!o.isDir&&c.isDir)return 1;let t=0;switch(s){case"name":t=o.name.localeCompare(c.name);break;case"size":t=o.size-c.size;break;case"modified":t=new Date(o.modified).getTime()-new Date(c.modified).getTime();break;default:t=o.name.localeCompare(c.name)}return n?t:-t}),[i,s,n])}function oi(){return r.useMemo(()=>typeof window>"u"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches,[])}function ci({viewMode:i}){const s=i==="grid"?12:8;return i==="grid"?e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-6 xl:grid-cols-8 gap-3 p-4","aria-busy":"true","aria-label":"Loading files",children:Array.from({length:s},(n,a)=>e.jsxs("div",{className:"flex flex-col items-center p-3 rounded-lg",children:[e.jsx("div",{className:"w-12 h-12 bg-primary-200 rounded animate-pulse mb-2"}),e.jsx("div",{className:"w-16 h-4 bg-primary-200 rounded animate-pulse"})]},a))}):e.jsx("div",{className:"divide-y divide-primary-200","aria-busy":"true","aria-label":"Loading files",children:Array.from({length:s},(n,a)=>e.jsxs("div",{className:"flex items-center gap-3 px-4 py-3",children:[e.jsx("div",{className:"w-6 h-6 bg-primary-200 rounded animate-pulse"}),e.jsx("div",{className:"flex-1 min-w-0 h-4 bg-primary-200 rounded animate-pulse"}),e.jsx("div",{className:"w-16 h-4 bg-primary-200 rounded animate-pulse"}),e.jsx("div",{className:"w-20 h-4 bg-primary-200 rounded animate-pulse"})]},a))})}const di=r.memo(function({item:s,isSelected:n,onClick:a,onDoubleClick:o,onKeyDown:c,onOpenFile:t,reduceMotion:l}){const m=r.useCallback(()=>{a(s)},[a,s]),v=r.useCallback(()=>{o(s)},[o,s]),y=r.useCallback(d=>{c(d,s)},[c,s]),f=()=>s.isDir?`${s.name}, folder`:`${s.name}, ${s.extension} file, ${J(s.size)}, modified ${q(s.modified)}`,u=e.jsxs(E.button,{type:"button",whileHover:l?{}:{scale:1.02},whileTap:l?{}:{scale:.98},transition:{duration:l?0:.15},onClick:m,onDoubleClick:v,onKeyDown:y,"aria-label":f(),className:h("flex flex-col items-center p-3 rounded-lg w-full border border-transparent","transition-all duration-150 ease-out","hover:bg-primary-50 hover:border-primary-100 focus-visible:bg-primary-50","focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation",n&&"bg-primary-100 border-primary-200"),children:[e.jsx(j,{icon:pe(s),size:40,strokeWidth:1,className:h("mb-2",s.isDir?"text-sky-500":"text-primary-500"),"aria-hidden":"true"}),e.jsx("span",{className:"text-[11px] text-center text-primary-900 font-medium truncate w-full min-w-0",children:s.name}),s.isDir?null:e.jsx("span",{className:"text-[10px] text-primary-400 mt-0.5 tabular-nums",children:J(s.size)})]});return e.jsx(me,{item:s,onOpenFile:t,children:u})}),ui=r.memo(function({item:s,isSelected:n,onClick:a,onDoubleClick:o,onKeyDown:c,onOpenFile:t,reduceMotion:l}){const m=r.useCallback(()=>{a(s)},[a,s]),v=r.useCallback(()=>{o(s)},[o,s]),y=r.useCallback(d=>{c(d,s)},[c,s]),f=()=>s.isDir?`${s.name}, folder, modified ${q(s.modified)}`:`${s.name}, ${s.extension} file, ${J(s.size)}, modified ${q(s.modified)}`,u=e.jsxs(E.button,{type:"button",whileHover:l?{}:{backgroundColor:"rgb(248 250 252)"},transition:{duration:l?0:.15},onClick:m,onDoubleClick:v,onKeyDown:y,"aria-label":f(),className:h("w-full grid grid-cols-[auto_1fr_auto_auto] gap-4 px-4 py-2.5 text-left","transition-all duration-150 ease-out","hover:bg-primary-50 focus-visible:bg-primary-50","focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation",n&&"bg-primary-100"),children:[e.jsx(j,{icon:pe(s),size:18,strokeWidth:1.5,className:h("mt-0.5 shrink-0",s.isDir?"text-sky-500":"text-primary-500"),"aria-hidden":"true"}),e.jsx("div",{className:"min-w-0 flex-1",children:e.jsx("span",{className:"text-[13px] text-primary-900 font-medium truncate block",children:s.name})}),e.jsx("div",{className:"text-xs text-primary-500 text-right w-16 tabular-nums shrink-0",children:s.isDir?"—":J(s.size)}),e.jsx("div",{className:"text-xs text-primary-500 text-right w-20 tabular-nums shrink-0",children:q(s.modified)})]});return e.jsx(me,{item:s,onOpenFile:t,children:u})}),mi=e.jsx("div",{className:"flex items-center justify-center h-full py-12",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"inline-flex items-center justify-center w-12 h-12 rounded-lg bg-primary-50 mb-3",children:e.jsx(j,{icon:ue,size:24,strokeWidth:1.5,className:"text-primary-400","aria-hidden":"true"})}),e.jsx("p",{className:"text-sm text-primary-500",children:"This folder is empty"}),e.jsx("p",{className:"text-xs text-primary-400 mt-1",children:"Upload files or create a new folder to get started"})]})});function pi({listing:i,loading:s,onOpenFile:n}){const{viewMode:a,sortBy:o,sortAsc:c,selectedFiles:t,navigateTo:l,toggleFileSelection:m}=F(),[v,y]=r.useState(0),f=r.useRef(null),u=oi(),d=li(i?.items||[],o,c),C=r.useCallback(p=>{m(p.path)},[m]),N=r.useCallback(p=>{p.isDir?l(p.path):n&&ti.has(p.extension.toLowerCase())&&n(p.path)},[l,n]),w=r.useCallback((p,x)=>{p.key==="Enter"?(p.preventDefault(),x.isDir?l(x.path):m(x.path)):p.key===" "&&(p.preventDefault(),m(x.path))},[l,m]);return r.useEffect(()=>{const p=x=>{if(d.length)switch(x.key){case"ArrowDown":x.preventDefault(),y(D=>Math.min(D+1,d.length-1));break;case"ArrowUp":x.preventDefault(),y(D=>Math.max(D-1,0));break;case"Home":x.preventDefault(),y(0);break;case"End":x.preventDefault(),y(d.length-1);break}};if(f.current)return f.current.addEventListener("keydown",p),()=>{f.current?.removeEventListener("keydown",p)}},[d.length]),s?e.jsx(ci,{viewMode:a}):i?d.length===0?mi:a==="grid"?e.jsx("div",{ref:f,className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-6 xl:grid-cols-8 gap-3 p-4 overflow-y-auto",role:"grid","aria-label":"Files grid",tabIndex:0,children:d.map((p,x)=>e.jsx("div",{role:"gridcell",children:e.jsx(di,{item:p,isSelected:t.has(p.path),onClick:C,onDoubleClick:N,onKeyDown:w,onOpenFile:n,reduceMotion:u})},p.path))}):e.jsx("div",{ref:f,className:"overflow-y-auto",role:"table","aria-label":"Files list",tabIndex:0,children:e.jsxs("div",{className:"divide-y divide-primary-100",children:[e.jsxs("div",{className:"grid grid-cols-[auto_1fr_auto_auto] gap-4 px-4 py-2 text-xs font-medium text-primary-400 uppercase tracking-wider bg-primary-50/50",role:"row",children:[e.jsx("div",{className:"w-6",role:"columnheader","aria-label":"File type"}),e.jsx("div",{role:"columnheader",children:"Name"}),e.jsx("div",{className:"w-16 text-right",role:"columnheader",children:"Size"}),e.jsx("div",{className:"w-20 text-right",role:"columnheader",children:"Modified"})]}),d.map((p,x)=>e.jsx("div",{role:"row",children:e.jsx(ui,{item:p,isSelected:t.has(p.path),onClick:C,onDoubleClick:N,onKeyDown:w,onOpenFile:n,reduceMotion:u})},p.path))]})}):e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsx("p",{className:"text-primary-500",children:"No listing available"})})}function oe(i){if(i===0)return"0 B";const s=1024,n=["B","KB","MB","GB"],a=Math.floor(Math.log(i)/Math.log(s));return parseFloat((i/Math.pow(s,a)).toFixed(1))+" "+n[a]}function fi({open:i,onOpenChange:s,currentPath:n}){const[a,o]=r.useState([]),[c,t]=r.useState(!1),[l,m]=r.useState("idle"),v=r.useRef(null),y=ii(),f=r.useCallback(()=>{o([]),m("idle"),v.current&&(v.current.value="")},[]),u=r.useCallback(g=>{if(!g)return;const S=Array.from(g).map(R=>({file:R,id:Math.random().toString(36).substr(2,9)}));o(R=>[...R,...S])},[]),d=r.useCallback(g=>{u(g.target.files)},[u]),C=r.useCallback(g=>{g.preventDefault(),t(!1),u(g.dataTransfer.files)},[u]),N=r.useCallback(g=>{g.preventDefault(),t(!0)},[]),w=r.useCallback(g=>{g.preventDefault(),t(!1)},[]),p=r.useCallback(g=>{o(S=>S.filter(R=>R.id!==g))},[]),x=r.useCallback(()=>{v.current?.click()},[]),D=r.useCallback(g=>{(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),x())},[x]),M=r.useCallback(async()=>{if(a.length===0)return;const g=new DataTransfer;a.forEach(({file:S})=>{g.items.add(S)}),m("uploading");try{await y.mutateAsync({files:g.files,path:n}),m("success"),f(),s(!1)}catch(S){m("error"),console.error("Upload failed:",S)}},[a,n,y,f,s]),X=r.useCallback(g=>{g||f(),s(g)},[f,s]),K=a.reduce((g,{file:S})=>g+S.size,0),U=a.length,Y=()=>y.isPending||l==="uploading"?"Uploading…":U===0?"Upload":U===1?"Upload 1 File":`Upload ${U} Files`;return e.jsx(Q,{open:i,onOpenChange:X,children:e.jsx(_,{className:"w-[min(500px,92vw)]",children:e.jsxs("div",{className:"p-6",children:[e.jsx(V,{className:"mb-2",children:"Upload Files"}),e.jsxs(H,{className:"mb-6",children:["Upload files to ",n==="/"?"root directory":n]}),e.jsxs("div",{onDrop:C,onDragOver:N,onDragLeave:w,onClick:x,onKeyDown:D,tabIndex:0,role:"button","aria-label":"Drop files here or click to choose files",className:h("border-2 border-dashed rounded-lg p-8 text-center cursor-pointer","transition-colors duration-150 ease-out","focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation",c?"border-primary-400 bg-primary-50":"border-primary-200 hover:border-primary-300 hover:bg-primary-50"),children:[e.jsx(j,{icon:ce,size:48,strokeWidth:1,className:"mx-auto text-primary-400 mb-4","aria-hidden":"true"}),e.jsx("p",{className:"text-primary-600 font-medium mb-2",children:"Drag and drop files here"}),e.jsx("p",{className:"text-sm text-primary-500 mb-4",children:"or"}),e.jsxs(k,{variant:"outline",className:h("gap-2","focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation"),"aria-label":"Choose files from computer",children:[e.jsx(j,{icon:ee,size:18,strokeWidth:1.5,"aria-hidden":"true"}),e.jsx("span",{children:"Choose Files"})]}),e.jsx("input",{ref:v,type:"file",multiple:!0,onChange:d,className:"hidden","aria-hidden":"true"})]}),e.jsx(A,{children:a.length>0?e.jsxs(E.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},className:"mt-6",children:[e.jsxs("h4",{className:"text-sm font-medium text-primary-900 mb-3",children:["Selected Files (",a.length,")"]}),e.jsx("div",{className:"max-h-32 overflow-y-auto border border-primary-200 rounded-lg",children:a.map(({file:g,id:S})=>e.jsxs(E.div,{initial:{opacity:0,x:-10},animate:{opacity:1,x:0},exit:{opacity:0,x:10},className:"flex items-center justify-between p-2 border-b border-primary-100 last:border-b-0",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[e.jsx(j,{icon:ee,size:16,strokeWidth:1.5,className:"text-primary-600 shrink-0","aria-hidden":"true"}),e.jsx("span",{className:"text-sm text-primary-900 truncate min-w-0",children:g.name}),e.jsx("span",{className:"text-xs text-primary-500 shrink-0 tabular-nums",children:oe(g.size)})]}),e.jsx(k,{size:"icon-sm",variant:"ghost",onClick:()=>p(S),className:h("text-primary-500 hover:text-red-600 shrink-0","focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation"),"aria-label":`Remove ${g.name} from upload list`,children:e.jsx(j,{icon:de,size:14,strokeWidth:1.5,"aria-hidden":"true"})})]},S))}),e.jsxs("p",{className:"text-xs text-primary-600 mt-2 tabular-nums",children:["Total size: ",oe(K)]})]}):null}),y.isPending||l==="uploading"?e.jsxs(E.div,{initial:{opacity:0},animate:{opacity:1},className:"mt-4 p-3 bg-primary-50 rounded-lg","aria-live":"polite",children:[e.jsx("p",{className:"text-sm text-primary-600 mb-2",children:"Uploading files…"}),e.jsx("div",{className:"bg-primary-200 rounded-full h-2",role:"progressbar","aria-label":"Upload progress",children:e.jsx("div",{className:"bg-primary-600 h-2 rounded-full w-1/2 animate-pulse"})})]}):null,l==="success"?e.jsx("div",{className:"mt-4 p-3 bg-green-50 rounded-lg","aria-live":"polite",children:e.jsx("p",{className:"text-sm text-green-700",children:"Files uploaded successfully!"})}):null,l==="error"?e.jsx("div",{className:"mt-4 p-3 bg-red-50 rounded-lg","aria-live":"polite",children:e.jsx("p",{className:"text-sm text-red-700",children:"Upload failed. Please try again."})}):null,e.jsxs("div",{className:"flex justify-end gap-2 mt-6",children:[e.jsx(G,{disabled:y.isPending||l==="uploading",className:h("focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation"),children:"Cancel"}),e.jsx(k,{onClick:M,disabled:a.length===0||y.isPending||l==="uploading",className:h("focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation"),children:Y()})]})]})})})}function hi({open:i,onOpenChange:s,currentPath:n}){const[a,o]=r.useState(""),[c,t]=r.useState(""),l=ni(),m=r.useCallback(async()=>{if(a.trim()){t("");try{await l.mutateAsync({path:n,name:a.trim()}),o(""),s(!1)}catch(p){const x=p instanceof Error?p.message:"Failed to create folder";t(x),console.error("Create folder failed:",p)}}},[a,n,l,s]),v=r.useCallback(p=>{p||(o(""),t("")),s(p)},[s]),y=r.useCallback(p=>{p.key==="Enter"&&(p.preventDefault(),m())},[m]),f=r.useCallback(p=>{const x=p.target.value;o(x),c&&t("")},[c]),u=a.trim().length>0&&!/[<>:"/\\|?*]/.test(a)&&!a.includes(".."),d=()=>l.isPending?"Creating…":"Create Folder",N=a.trim()?a.includes("..")?'Folder name cannot contain ".."':/[<>:"/\\|?*]/.test(a)?'Invalid characters: < > : " / \\ | ? *':"":"",w=c||N;return e.jsx(Q,{open:i,onOpenChange:v,children:e.jsx(_,{children:e.jsxs("div",{className:"p-6",children:[e.jsx(V,{className:"mb-2",children:"Create New Folder"}),e.jsxs(H,{className:"mb-4",children:["Create a new folder in ",n==="/"?"root directory":n]}),e.jsxs("div",{className:"mb-6",children:[e.jsx("label",{htmlFor:"folder-name",className:"block text-sm font-medium text-primary-900 mb-2",children:"Folder Name"}),e.jsx("input",{id:"folder-name",type:"text",value:a,onChange:f,onKeyDown:y,placeholder:"Enter folder name",autoComplete:"off",spellCheck:!1,autoFocus:!0,"aria-describedby":w?"folder-name-error":void 0,"aria-invalid":w?"true":"false",className:h("w-full px-3 py-2 border rounded-lg","transition-colors duration-150 ease-out","focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation",w?"border-red-300 focus-visible:ring-red-300":"border-primary-200 focus:border-primary-300")}),w?e.jsx("p",{id:"folder-name-error",className:"text-sm text-red-600 mt-1",role:"alert","aria-live":"polite",children:c||N}):null]}),l.isPending?e.jsx("div",{className:"mb-4 p-3 bg-primary-50 rounded-lg","aria-live":"polite",children:e.jsx("p",{className:"text-sm text-primary-600",children:"Creating folder…"})}):null,e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(G,{disabled:l.isPending,className:h("focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation"),children:"Cancel"}),e.jsx(k,{onClick:m,disabled:!u||l.isPending,className:h("focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation",(!u||l.isPending)&&"opacity-50 cursor-not-allowed"),"aria-describedby":u?void 0:"create-button-help",children:d()})]}),!u&&a.length>0?e.jsx("p",{id:"create-button-help",className:"text-xs text-primary-500 mt-2",children:"Please enter a valid folder name"}):null]})})})}const xi={js:"JavaScript",ts:"TypeScript",jsx:"JSX",tsx:"TSX",py:"Python",json:"JSON",yaml:"YAML",yml:"YAML",md:"Markdown",html:"HTML",css:"CSS",scss:"SCSS",sh:"Shell",bash:"Bash",sql:"SQL",xml:"XML",toml:"TOML",ini:"INI",conf:"Config",cfg:"Config",env:"Env",txt:"Text",log:"Log",csv:"CSV",go:"Go",rs:"Rust",rb:"Ruby",php:"PHP",java:"Java",c:"C",cpp:"C++",h:"Header",dockerfile:"Dockerfile",makefile:"Makefile",graphql:"GraphQL",svelte:"Svelte",vue:"Vue"};function gi({filePath:i,onClose:s}){const n=Xe(i),a=Ye(),o=r.useRef(null),[c,t]=r.useState(null),[l,m]=r.useState(!1);r.useEffect(()=>{n.data&&c===null&&t(n.data.content)},[n.data,c]);const v=r.useMemo(()=>n.data?xi[n.data.extension.toLowerCase()]||n.data.extension.toUpperCase():"",[n.data]),y=r.useCallback(N=>{t(N.target.value),m(N.target.value!==n.data?.content)},[n.data]),f=r.useCallback(async()=>{if(c!==null)try{await a.mutateAsync({path:i,content:c}),m(!1)}catch{}},[i,c,a]),u=r.useCallback(()=>{l&&!window.confirm("You have unsaved changes. Discard them?")||s()},[l,s]);r.useEffect(()=>{const N=w=>{(w.ctrlKey||w.metaKey)&&w.key==="s"&&(w.preventDefault(),l&&f()),w.key==="Escape"&&u()};return window.addEventListener("keydown",N),()=>window.removeEventListener("keydown",N)},[f,u,l]);const d=r.useCallback(N=>{if(N.key==="Tab"){N.preventDefault();const w=N.currentTarget,p=w.selectionStart,x=w.selectionEnd,D=w.value,M=D.substring(0,p)+" "+D.substring(x);t(M),m(M!==n.data?.content),requestAnimationFrame(()=>{w.selectionStart=w.selectionEnd=p+2})}},[n.data]),C=i.split("/").pop()||i;return e.jsxs("div",{className:"fixed inset-0 z-50 bg-surface flex flex-col",children:[e.jsxs("header",{className:"flex items-center justify-between px-4 py-2 border-b border-primary-200 bg-primary-50",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx("h2",{className:"text-sm font-semibold text-primary-900 truncate",children:C}),v?e.jsx("span",{className:"text-xs text-primary-500 bg-primary-100 px-2 py-0.5 rounded-full shrink-0",children:v}):null,l?e.jsx("span",{className:"text-xs text-amber-600 bg-amber-50 px-2 py-0.5 rounded-full shrink-0",children:"Unsaved"}):null,a.isError?e.jsx("span",{className:"text-xs text-red-600",children:a.error.message}):null]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsxs(k,{size:"sm",variant:"default",onClick:f,disabled:!l||a.isPending,className:h((!l||a.isPending)&&"opacity-50 cursor-not-allowed"),children:[e.jsx(j,{icon:Ue,size:16,strokeWidth:1.5,"aria-hidden":"true"}),a.isPending?"Saving…":"Save"]}),e.jsx(k,{size:"icon-sm",variant:"ghost",onClick:u,"aria-label":"Close editor",children:e.jsx(j,{icon:Ie,size:20,strokeWidth:1.5,"aria-hidden":"true"})})]})]}),e.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:n.isLoading?e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsx("p",{className:"text-primary-500 text-sm",children:"Loading file…"})}):n.isError?e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-red-600 text-sm mb-2",children:n.error instanceof Error?n.error.message:"Failed to load file"}),e.jsx(k,{size:"sm",variant:"secondary",onClick:()=>{n.refetch()},children:"Retry"})]})}):e.jsx("textarea",{ref:o,value:c??"",onChange:y,onKeyDown:d,spellCheck:!1,autoFocus:!0,className:h("w-full h-full p-4 resize-none","bg-primary-950 text-primary-100","font-mono text-sm leading-relaxed","focus:outline-none","selection:bg-blue-800/50")})}),n.data?e.jsxs("footer",{className:"flex items-center justify-between px-4 py-1 border-t border-primary-200 bg-primary-50 text-xs text-primary-500",children:[e.jsx("span",{children:i}),e.jsx("span",{children:bi(n.data.size)})]}):null]})}function bi(i){return i<1024?`${i} B`:i<1024*1024?`${(i/1024).toFixed(1)} KB`:`${(i/(1024*1024)).toFixed(1)} MB`}function $i(){const i=L(),{currentPath:s,editingFile:n}=F(),[a,o]=r.useState(!1),[c,t]=r.useState(!1),l=Ze(s),v=ie({queryKey:Pe,queryFn:function(){return te(i)},initialData:function(){return te(i)},staleTime:1/0}).data?.isSidebarCollapsed??!1,y=r.useCallback(()=>{Ae(i,function(x){return{...x,isSidebarCollapsed:!x.isSidebarCollapsed}})},[i]),f=r.useCallback(()=>{o(!0)},[]),u=r.useCallback(()=>{t(!0)},[]),d=r.useCallback(p=>{F.getState().openInEditor(p)},[]),C=r.useCallback(()=>{F.getState().closeEditor()},[]),N=r.useMemo(()=>({display:"flex",flexDirection:"column",height:"100%",minHeight:0}),[]),w=e.jsx(He,{isCollapsed:v,onToggleCollapse:y,onSelectAction:()=>{}});return e.jsxs("div",{className:"h-screen bg-surface text-primary-900",children:[e.jsxs("div",{className:h("h-full overflow-hidden grid grid-cols-[auto_1fr]"),children:[w,e.jsxs("main",{"aria-label":"File explorer",style:N,children:[e.jsxs("header",{className:"border-b border-primary-100 px-4 py-3",children:[e.jsx("div",{className:"flex items-center justify-between mb-3",children:e.jsx(Ge,{path:s})}),e.jsx(Je,{onUpload:f,onCreateFolder:u})]}),e.jsxs("div",{className:"flex-1 min-h-0 overflow-auto",children:[e.jsx(pi,{listing:l.data,loading:l.isLoading,onOpenFile:d}),l.isError?e.jsxs("div",{className:"p-4 text-center","aria-live":"polite",children:[e.jsx("p",{className:"text-red-600 text-sm",children:l.error instanceof Error?l.error.message:"Failed to load files"}),e.jsx("button",{onClick:()=>{l.refetch()},className:"mt-2 text-sm text-primary-600 hover:text-primary-900 underline focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none rounded-sm",children:"Retry"})]}):null]}),e.jsx(fi,{open:a,onOpenChange:o,currentPath:s}),e.jsx(hi,{open:c,onOpenChange:t,currentPath:s})]})]}),n?e.jsx(gi,{filePath:n,onClose:C}):null]})}export{$i as FileExplorerScreen};
|
|
1
|
+
import{j as e,r,L as se,u as L}from"./main-B2CrcRuC.js";import{u as ie}from"./useQuery-D-sF8Tld.js";import{M as be,c as h,b as ne,B as k,H as j,I as ye,r as ve,N as je,l as we,O as Ne,Q as Ce,W as ke,Y as ae,T as re,Z as ce,_ as De,$ as Se,D as Ee,a0 as Fe,a1 as ze,a2 as de,a3 as ue,a4 as Me,a5 as Re,a6 as Te,a7 as Le,a8 as $e,a9 as Ke,u as ee,aa as Ue,V as Ie}from"./button-BciDmec0.js";import{T as P,a as W,b as B,c as O,s as Ae,d as Pe,g as te}from"./tooltip-DOKkNFvu.js";import{u as F,D as Q,a as _,b as V,c as H,d as G}from"./use-file-explorer-state-BAa6Cxyr.js";import{m as E,A}from"./proxy-BijR8W1L.js";import{M as We,a as Be,b as Oe,c as le}from"./menu-CIwnliij.js";import{u as $}from"./useMutation-BFl-7GnD.js";import"./useOnFirstRender-DlXHIIGk.js";import"./useBaseUiId-DFpBD0sg.js";import"./event-BCwqPPkP.js";import"./visuallyHidden-COI6QeQH.js";import"./DirectionContext-CR5CCisG.js";import"./composite-DArWbFHm.js";import"./react-DWx7OvUo.js";import"./useCompositeItem-B-Axq9-D.js";function qe({className:i}){return e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"80",height:"80",viewBox:"0 0 80 80",fill:"none",className:i,children:[e.jsx("rect",{width:"80",height:"80",fill:"currentColor",className:"text-transparent"}),e.jsx("path",{d:"M61.9624 45.5729C62.5862 44.3371 63.0907 43.3377 63.4782 41.9826C69.8221 28.8286 70.5847 14.0975 67.1723 4.32469C65.8317 0.249835 62.7688 0.254311 62.6374 3.58605C61.355 12.189 58.9061 17.6275 57.1756 21.0554C52.8087 29.7058 45.9949 37.7278 39.3706 42.7305C28.6217 50.8021 25.0716 44.614 24.3711 37.8823C23.8822 32.1203 24.7206 25.5721 26.24 18.2889C27.102 15.3261 24.3944 13.9592 22.5223 16.4122C20.4062 19.3487 18.5586 22.4209 17.1838 25.7318C12.9928 33.4462 10.3896 45.3332 11.4505 57.6273C12.2296 63.5357 13.1688 68.4057 14.1079 73.2757C15.2695 79.0941 19.1598 79.5073 24.3117 78.0088C39.7921 74.0789 54.143 58.872 59.7093 49.1011C60.7255 48.0229 61.3494 46.7872 61.9624 45.5729Z",fill:"currentColor",className:"text-primary-950"})]})}function Qe(){return r.useMemo(()=>typeof window>"u"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches,[])}function _e({isCollapsed:i,onToggleCollapse:s,onSelectAction:n}){const{navigateTo:a,currentPath:o}=F(),c=Qe(),t=r.useMemo(()=>({duration:c?0:.15,ease:i?"easeIn":"easeOut"}),[i,c]),l=r.useCallback(d=>{a(d)},[a]),m=r.useCallback((d,C)=>{(d.key==="Enter"||d.key===" ")&&(d.preventDefault(),C())},[]),v=r.useMemo(()=>[{path:"/",icon:be,label:"Home",id:"home"}],[]),y=r.useMemo(()=>({className:"border-r border-primary-200 h-full overflow-hidden bg-primary-100 flex flex-col"}),[]),f=48,u=300;return e.jsxs(E.aside,{initial:!1,animate:{width:c?i?f:u:void 0},style:{width:c?void 0:i?f:u},transition:t,className:y.className,role:"navigation","aria-label":"File explorer navigation",children:[e.jsxs(E.div,{layout:!0,transition:{layout:t},className:h("flex items-center h-12 px-2 justify-between"),children:[e.jsx(A,{initial:!1,children:i?null:e.jsx(E.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:t,children:e.jsxs(se,{to:"/new",className:h(ne({variant:"ghost",size:"sm"}),"w-full pl-1.5 justify-start","focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation"),children:[e.jsx(qe,{className:"size-5 rounded-sm","aria-hidden":"true"}),e.jsx("span",{children:"WebClaw"})]})})}),e.jsx(P,{children:e.jsxs(W,{children:[e.jsx(B,{onClick:s,onKeyDown:d=>m(d,s),render:e.jsx(k,{size:"icon-sm",variant:"ghost","aria-label":i?"Expand sidebar":"Collapse sidebar",className:h("focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation"),children:e.jsx(j,{icon:ye,size:20,strokeWidth:1.5,"aria-hidden":"true"})})}),e.jsx(O,{side:"right",children:i?"Expand sidebar":"Collapse sidebar"})]})})]}),e.jsx("div",{className:"px-2 mb-4",children:e.jsx(E.div,{layout:!0,transition:{layout:t},className:"w-full",children:e.jsx(P,{children:e.jsxs(W,{children:[e.jsx(B,{asChild:!0,children:e.jsxs(se,{to:"/chat/$sessionKey",params:{sessionKey:"main"},className:h(ne({variant:"ghost",size:"sm"}),"w-full pl-1.5 justify-start","focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation"),onClick:n,children:[e.jsx(j,{icon:ve,size:20,strokeWidth:1.5,className:"min-w-5","aria-hidden":"true"}),e.jsx(A,{initial:!1,mode:"wait",children:i?null:e.jsx(E.span,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:t,className:"overflow-hidden whitespace-nowrap",children:"Back to Chat"})})]})}),i?e.jsx(O,{side:"right",children:"Back to Chat"}):null]})})})}),e.jsx("div",{className:"flex-1 min-h-0 relative overflow-hidden",children:e.jsx(A,{initial:!1,children:i?e.jsx(E.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:t,className:"px-2 space-y-1",children:v.map(d=>e.jsx(P,{children:e.jsxs(W,{children:[e.jsx(B,{onClick:()=>l(d.path),onKeyDown:C=>m(C,()=>l(d.path)),render:e.jsx(k,{size:"icon-sm",variant:"ghost","aria-current":o===d.path?"page":void 0,"aria-label":`Navigate to ${d.label}`,className:h("w-full text-primary-600 hover:text-primary-900","focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation",o===d.path&&"bg-primary-200 text-primary-900"),children:e.jsx(j,{icon:d.icon,size:20,strokeWidth:1.5,"aria-hidden":"true"})})}),e.jsx(O,{side:"right",children:d.label})]})},d.id))},"collapsed-content"):e.jsx(E.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:t,className:"absolute inset-0 pt-0 flex flex-col w-[300px] min-h-0",children:e.jsxs("div",{className:"flex-1 min-h-0 px-2",children:[e.jsx("div",{className:"mb-4",children:e.jsx("h2",{className:"text-sm font-medium text-primary-700 mb-3 px-1.5",children:"Quick Access"})}),e.jsx("nav",{className:"space-y-1",role:"list","aria-label":"Quick access folders",children:v.map(d=>e.jsx("div",{role:"listitem",children:e.jsxs(k,{variant:"ghost",size:"sm",onClick:()=>l(d.path),onKeyDown:C=>m(C,()=>l(d.path)),"aria-current":o===d.path?"page":void 0,className:h("w-full pl-1.5 justify-start text-primary-600 hover:text-primary-900","focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation",o===d.path&&"bg-primary-200 text-primary-900 font-medium"),"aria-label":`Navigate to ${d.label}`,children:[e.jsx(j,{icon:d.icon,size:20,strokeWidth:1.5,className:"min-w-5","aria-hidden":"true"}),e.jsx("span",{className:"overflow-hidden whitespace-nowrap min-w-0 truncate",children:d.label})]})},d.id))})]})},"content")})}),e.jsx("div",{className:"px-2 py-3 border-t border-primary-200 bg-primary-100",children:e.jsx(E.div,{layout:!0,transition:{layout:t},className:"w-full",children:e.jsx(P,{children:e.jsxs(W,{children:[e.jsx(B,{asChild:!0,children:e.jsxs(k,{variant:"ghost",size:i?"icon-sm":"sm",className:h(i?"w-full":"w-full justify-start pl-1.5","focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation"),"aria-label":"Settings",children:[e.jsx(j,{icon:je,size:20,strokeWidth:1.5,className:"min-w-5","aria-hidden":"true"}),e.jsx(A,{initial:!1,mode:"wait",children:i?null:e.jsx(E.span,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:t,className:"overflow-hidden whitespace-nowrap",children:"Settings"})})]})}),i?e.jsx(O,{side:"right",children:"Settings"}):null]})})})})]})}function Ve(i,s){return i.isCollapsed===s.isCollapsed}const He=r.memo(_e,Ve);function Ge({path:i}){const{navigateTo:s}=F(),n=i==="/"?[]:i.split("/").filter(Boolean),a=[{name:"Home",path:"/"},...n.map((t,l)=>({name:t,path:"/"+n.slice(0,l+1).join("/")}))],o=r.useCallback(t=>{s(t)},[s]),c=r.useCallback((t,l)=>{(t.key==="Enter"||t.key===" ")&&(t.preventDefault(),s(l))},[s]);return e.jsx("nav",{"aria-label":"File navigation",className:"text-sm text-primary-600",children:e.jsx("ol",{className:"flex items-center gap-1",children:a.map((t,l)=>e.jsxs("li",{className:"flex items-center gap-1",children:[l>0?e.jsx(j,{icon:we,size:16,strokeWidth:1.5,className:"text-primary-400","aria-hidden":"true"}):null,e.jsxs("button",{type:"button",onClick:()=>o(t.path),onKeyDown:m=>c(m,t.path),"aria-current":l===a.length-1?"page":void 0,className:h("flex items-center gap-1.5 rounded-md px-2 py-1","transition-colors duration-150 ease-out","hover:bg-primary-100 hover:text-primary-900","focus-visible:bg-primary-100 focus-visible:text-primary-900","focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation",l===a.length-1?"text-primary-900 font-medium":"text-primary-600"),children:[l===0?e.jsx(j,{icon:Ne,size:16,strokeWidth:1.5,"aria-hidden":"true"}):null,e.jsx("span",{className:"whitespace-nowrap",children:t.name})]})]},t.path))})})}const Z=[{label:"Name",value:"name"},{label:"Size",value:"size"},{label:"Modified",value:"modified"}];function Je({onUpload:i,onCreateFolder:s}){const{viewMode:n,sortBy:a,sortAsc:o,setViewMode:c,setSortBy:t,toggleSort:l}=F(),m=r.useCallback(()=>{c("list")},[c]),v=r.useCallback(()=>{c("grid")},[c]),y=r.useCallback(u=>{t(u)},[t]),f=r.useCallback((u,d)=>{(u.key==="Enter"||u.key===" ")&&(u.preventDefault(),d())},[]);return e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"flex items-center border border-primary-200 rounded-lg overflow-hidden",role:"group","aria-label":"View mode",children:[e.jsx(k,{size:"sm",variant:n==="list"?"default":"ghost",onClick:m,onKeyDown:u=>f(u,m),"aria-label":"Switch to list view","aria-pressed":n==="list",className:h("rounded-none border-0","focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation"),children:e.jsx(j,{icon:Ce,size:18,strokeWidth:1.5,"aria-hidden":"true"})}),e.jsx(k,{size:"sm",variant:n==="grid"?"default":"ghost",onClick:v,onKeyDown:u=>f(u,v),"aria-label":"Switch to grid view","aria-pressed":n==="grid",className:h("rounded-none border-0 border-l border-primary-200","focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation"),children:e.jsx(j,{icon:ke,size:18,strokeWidth:1.5,"aria-hidden":"true"})})]}),e.jsxs(We,{children:[e.jsx(Be,{render:e.jsxs(k,{variant:"ghost",size:"sm",className:h("gap-1","focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation"),"aria-label":`Sort by ${Z.find(u=>u.value===a)?.label}, ${o?"ascending":"descending"}`,children:[e.jsxs("span",{children:["Sort: ",Z.find(u=>u.value===a)?.label]}),e.jsx(j,{icon:o?ae:re,size:16,strokeWidth:1.5,"aria-hidden":"true"})]})}),e.jsxs(Oe,{side:"bottom",align:"start",children:[Z.map(u=>e.jsx(le,{onClick:()=>y(u.value),className:h(a===u.value&&"bg-primary-100 text-primary-900","focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none"),"aria-current":a===u.value?"true":"false",children:u.label},u.value)),e.jsxs(le,{onClick:l,className:"focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none",children:[e.jsx(j,{icon:o?re:ae,size:16,strokeWidth:1.5,"aria-hidden":"true"}),o?"Sort Descending":"Sort Ascending"]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(k,{variant:"ghost",size:"sm",onClick:i,onKeyDown:u=>f(u,i),className:h("gap-2","focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation"),"aria-label":"Upload files",children:[e.jsx(j,{icon:ce,size:18,strokeWidth:1.5,"aria-hidden":"true"}),e.jsx("span",{children:"Upload"})]}),e.jsxs(k,{variant:"ghost",size:"sm",onClick:s,onKeyDown:u=>f(u,s),className:h("gap-2","focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation"),"aria-label":"Create new folder",children:[e.jsx(j,{icon:De,size:18,strokeWidth:1.5,"aria-hidden":"true"}),e.jsx("span",{children:"New Folder"})]})]})]})}const z={all:["files"],listing:i=>["files","listing",i],content:i=>["files","content",i]};function Xe(i){return ie({queryKey:z.content(i||""),queryFn:async({signal:s})=>{const n=await fetch(`/api/files/read?path=${encodeURIComponent(i)}`,{signal:s});if(!n.ok){const a=await n.json().catch(()=>({error:"Failed to read file"}));throw new Error(a.error||"Failed to read file")}return n.json()},enabled:!!i,staleTime:30*1e3,gcTime:300*1e3})}function Ye(){const i=L(),s=r.useRef(null);return r.useEffect(()=>()=>{s.current?.abort()},[]),$({mutationFn:async({path:n,content:a})=>{s.current?.abort();const o=new AbortController;s.current=o;const c=await fetch("/api/files/save",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:n,content:a}),signal:o.signal});if(!c.ok){const t=await c.json().catch(()=>({error:"Failed to save file"}));throw new Error(t.error||"Failed to save file")}return c.json()},onSuccess:(n,a)=>{i.invalidateQueries({queryKey:z.content(a.path)});const o=a.path.split("/").slice(0,-1).join("/")||"/";i.invalidateQueries({queryKey:z.listing(o)})}})}function Ze(i){return ie({queryKey:z.listing(i),queryFn:async({signal:s})=>{const n=await fetch(`/api/files/list?path=${encodeURIComponent(i)}`,{signal:s});if(!n.ok){const a=await n.text();throw new Error(`Failed to load files: ${a}`)}return n.json()},staleTime:300*1e3,gcTime:600*1e3,retry:3})}function ei(){const i=new Set,s=r.useRef(null);return r.useEffect(()=>()=>{s.current?.abort(),i.forEach(n=>URL.revokeObjectURL(n)),i.clear()},[]),$({mutationFn:async n=>{s.current?.abort();const a=new AbortController;s.current=a;const o=await fetch(`/api/files/download?path=${encodeURIComponent(n)}`,{signal:a.signal});if(!o.ok){const v=await o.text();throw new Error(`Download failed: ${v}`)}const c=await o.blob(),t=window.URL.createObjectURL(c);i.add(t);const l=n.split("/").pop()||"download",m=document.createElement("a");m.href=t,m.download=l,document.body.appendChild(m),m.click(),document.body.removeChild(m),setTimeout(()=>{i.has(t)&&(URL.revokeObjectURL(t),i.delete(t))},100)},onError:n=>{n instanceof Error&&n.name==="AbortError"||console.error("Download failed:",n)}})}function ii(){const i=L(),s=r.useRef(null);return r.useEffect(()=>()=>{s.current?.abort()},[]),$({mutationFn:async({files:n,path:a})=>{s.current?.abort();const o=new AbortController;s.current=o;const c=[];for(let t=0;t<n.length;t++){const l=new FormData;l.append("path",a),l.append("file",n[t]);const m=await fetch("/api/files/upload",{method:"POST",body:l,signal:o.signal});if(!m.ok){const v=await m.text();throw new Error(`Upload failed for ${n[t].name}: ${v}`)}c.push(await m.json())}return c},onSuccess:(n,a)=>{i.invalidateQueries({queryKey:z.listing(a.path)})},onError:n=>{n instanceof Error&&n.name==="AbortError"||console.error("Upload failed:",n)}})}function si(){const i=L(),s=r.useRef(null);return r.useEffect(()=>()=>{s.current?.abort()},[]),$({mutationFn:async n=>{s.current?.abort();const a=new AbortController;s.current=a;const o=await fetch(`/api/files/delete?path=${encodeURIComponent(n)}`,{method:"DELETE",signal:a.signal});if(!o.ok){const c=await o.text();throw new Error(`Delete failed: ${c}`)}return o.json()},onSuccess:(n,a)=>{const o=a.split("/").slice(0,-1).join("/")||"/";i.invalidateQueries({queryKey:z.listing(o)})},onError:n=>{n instanceof Error&&n.name==="AbortError"||console.error("Delete failed:",n)}})}function ni(){const i=L(),s=r.useRef(null);return r.useEffect(()=>()=>{s.current?.abort()},[]),$({mutationFn:async({path:n,name:a})=>{s.current?.abort();const o=new AbortController;s.current=o;const c=await fetch("/api/files/mkdir",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:`${n}/${a}`}),signal:o.signal});if(!c.ok){const t=await c.text();throw new Error(`Create folder failed: ${t}`)}return c.json()},onSuccess:(n,a)=>{i.invalidateQueries({queryKey:z.listing(a.path)})},onError:n=>{n instanceof Error&&n.name==="AbortError"||console.error("Create folder failed:",n)}})}function ai(){const i=L(),s=r.useRef(null);return r.useEffect(()=>()=>{s.current?.abort()},[]),$({mutationFn:async({oldPath:n,newName:a})=>{s.current?.abort();const o=new AbortController;s.current=o;const t=`${n.split("/").slice(0,-1).join("/")}/${a}`,l=await fetch("/api/files/rename",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({src:n,dst:t}),signal:o.signal});if(!l.ok){const m=await l.text();throw new Error(`Rename failed: ${m}`)}return l.json()},onSuccess:(n,a)=>{const o=a.oldPath.split("/").slice(0,-1).join("/")||"/";i.invalidateQueries({queryKey:z.listing(o)})},onError:n=>{n instanceof Error&&n.name==="AbortError"||console.error("Rename failed:",n)}})}const ri=new Set(["txt","md","log","json","xml","yaml","yml","csv","ini","conf","cfg","js","ts","jsx","tsx","py","java","cpp","c","h","css","html","htm","php","rb","go","rs","sh","bash","zsh","toml","env","gitignore","dockerfile","makefile","sql","graphql","svelte","vue","scss","less"]);function me({item:i,children:s,onOpenFile:n}){const[a,o]=r.useState(!1),[c,t]=r.useState({x:0,y:0}),[l,m]=r.useState(!1),[v,y]=r.useState(!1),[f,u]=r.useState(i.name),[d,C]=r.useState(""),N=r.useRef(null),{navigateTo:w}=F(),p=ei(),x=si(),D=ai(),M=r.useCallback(b=>{switch(b){case"open":i.isDir&&w(i.path);break;case"edit":n&&n(i.path);break;case"download":i.isDir||p.mutate(i.path);break;case"rename":u(i.name),C(""),m(!0);break;case"delete":y(!0);break}},[i,p,w]),X=r.useCallback(b=>{b.preventDefault(),b.stopPropagation(),t({x:b.clientX,y:b.clientY}),o(!0)},[]),K=r.useCallback(async()=>{if(!f||f===i.name){m(!1);return}C("");try{await D.mutateAsync({oldPath:i.path,newName:f.trim()}),m(!1)}catch(b){const T=b instanceof Error?b.message:"Failed to rename";C(T)}},[f,i,D]),U=r.useCallback(async()=>{try{await x.mutateAsync(i.path),y(!1)}catch(b){console.error("Delete failed:",b)}},[i.path,x]),Y=r.useCallback(b=>{b.key==="Enter"?(b.preventDefault(),K()):b.key==="Escape"&&(b.preventDefault(),m(!1))},[K]),g=r.useCallback(b=>{u(b.target.value),d&&C("")},[d]);r.useEffect(()=>{if(l&&N.current){const b=N.current;if(b.focus(),!i.isDir&&i.extension){const T=i.name.replace(new RegExp(`\\.${i.extension}$`),"");b.setSelectionRange(0,T.length)}else b.select()}},[l,i]);const S=f.trim().length>0&&!/[<>:"/\\|?*]/.test(f)&&!f.includes("..")&&f!==i.name,R=()=>p.isPending?"Downloading…":"Download",fe=()=>D.isPending?"Renaming…":"Rename",he=()=>x.isPending?"Deleting…":"Delete";r.useEffect(()=>{if(!a)return;const b=()=>o(!1),T=ge=>{ge.key==="Escape"&&o(!1)},xe=setTimeout(()=>{document.addEventListener("click",b),document.addEventListener("contextmenu",b),document.addEventListener("keydown",T)},0);return()=>{clearTimeout(xe),document.removeEventListener("click",b),document.removeEventListener("contextmenu",b),document.removeEventListener("keydown",T)}},[a]);const I=r.useCallback(b=>{o(!1),M(b)},[M]);return e.jsxs(e.Fragment,{children:[e.jsx("div",{onContextMenu:X,children:s}),a?e.jsx("div",{className:"fixed inset-0 z-50","aria-modal":"true",role:"dialog",children:e.jsxs("div",{className:"fixed min-w-[140px] rounded-lg bg-primary-50 p-1 text-sm text-primary-900 shadow-lg outline outline-primary-900/10 z-50",style:{left:c.x,top:c.y},role:"menu",onClick:b=>b.stopPropagation(),children:[i.isDir?e.jsxs("button",{type:"button",role:"menuitem",onClick:()=>I("open"),className:h("flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-sm text-primary-900","hover:bg-primary-100 select-none font-[450]","focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none"),children:[e.jsx(j,{icon:Se,size:16,strokeWidth:1.5,"aria-hidden":"true"}),"Open"]}):null,i.isDir?null:e.jsxs("button",{type:"button",role:"menuitem",onClick:()=>I("download"),disabled:p.isPending,className:h("flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-sm text-primary-900","hover:bg-primary-100 select-none font-[450]","focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none"),children:[e.jsx(j,{icon:Ee,size:16,strokeWidth:1.5,"aria-hidden":"true"}),R()]}),!i.isDir&&ri.has(i.extension.toLowerCase())?e.jsxs("button",{type:"button",role:"menuitem",onClick:()=>I("edit"),className:h("flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-sm text-primary-900","hover:bg-primary-100 select-none font-[450]","focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none"),children:[e.jsx(j,{icon:Fe,size:16,strokeWidth:1.5,"aria-hidden":"true"}),"Edit"]}):null,e.jsxs("button",{type:"button",role:"menuitem",onClick:()=>I("rename"),className:h("flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-sm text-primary-900","hover:bg-primary-100 select-none font-[450]","focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none"),children:[e.jsx(j,{icon:ze,size:16,strokeWidth:1.5,"aria-hidden":"true"}),"Rename"]}),e.jsxs("button",{type:"button",role:"menuitem",onClick:()=>I("delete"),className:h("flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-sm","text-red-600 hover:bg-red-50 select-none font-[450]","focus-visible:ring-2 focus-visible:ring-red-300 focus-visible:outline-none"),children:[e.jsx(j,{icon:de,size:16,strokeWidth:1.5,"aria-hidden":"true"}),"Delete"]})]})}):null,e.jsx(Q,{open:l,onOpenChange:m,children:e.jsx(_,{children:e.jsxs("div",{className:"p-6",children:[e.jsxs(V,{className:"mb-2",children:["Rename ",i.isDir?"Folder":"File"]}),e.jsxs(H,{className:"mb-4",children:['Enter a new name for "',i.name,'"']}),e.jsxs("div",{className:"mb-6",children:[e.jsxs("label",{htmlFor:"rename-input",className:"block text-sm font-medium text-primary-900 mb-2",children:[i.isDir?"Folder":"File"," Name"]}),e.jsx("input",{id:"rename-input",ref:N,type:"text",value:f,onChange:g,onKeyDown:Y,autoFocus:!0,spellCheck:!1,"aria-describedby":d?"rename-error":void 0,"aria-invalid":d?"true":"false",className:h("w-full px-3 py-2 border rounded-lg","transition-colors duration-150 ease-out","focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation",d?"border-red-300 focus-visible:ring-red-300":"border-primary-200 focus:border-primary-300")}),d?e.jsx("p",{id:"rename-error",className:"text-sm text-red-600 mt-1",role:"alert","aria-live":"polite",children:d}):null]}),D.isPending?e.jsx("div",{className:"mb-4 p-3 bg-primary-50 rounded-lg","aria-live":"polite",children:e.jsx("p",{className:"text-sm text-primary-600",children:"Renaming…"})}):null,e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(G,{disabled:D.isPending,className:h("focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation"),children:"Cancel"}),e.jsx(k,{onClick:K,disabled:!S||D.isPending,className:h("focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation",(!S||D.isPending)&&"opacity-50 cursor-not-allowed"),children:fe()})]})]})})}),e.jsx(Q,{open:v,onOpenChange:y,children:e.jsx(_,{children:e.jsxs("div",{className:"p-6",children:[e.jsxs(V,{className:"mb-2",children:["Delete ",i.isDir?"Folder":"File"]}),e.jsxs(H,{className:"mb-4",children:['Are you sure you want to delete "',i.name,'"?',i.isDir?" This will delete the folder and all its contents.":""," ","This action cannot be undone."]}),x.isPending?e.jsx("div",{className:"mb-4 p-3 bg-red-50 rounded-lg","aria-live":"polite",children:e.jsx("p",{className:"text-sm text-red-700",children:"Deleting…"})}):null,e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(G,{disabled:x.isPending,className:h("focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation"),children:"Cancel"}),e.jsx(k,{variant:"destructive",onClick:U,disabled:x.isPending,className:h("focus-visible:ring-2 focus-visible:ring-red-300 focus-visible:outline-none","touch-manipulation",x.isPending&&"opacity-50 cursor-not-allowed"),children:he()})]})]})})})]})}const ti=new Set(["txt","md","log","json","xml","yaml","yml","csv","ini","conf","cfg","js","ts","jsx","tsx","py","java","cpp","c","h","css","html","htm","php","rb","go","rs","sh","bash","zsh","toml","env","gitignore","dockerfile","makefile","sql","graphql","svelte","vue","scss","less"]);function J(i){if(i===0)return"0 B";const s=1024,n=["B","KB","MB","GB","TB"],a=Math.floor(Math.log(i)/Math.log(s));return parseFloat((i/Math.pow(s,a)).toFixed(1))+" "+n[a]}function q(i){const s=new Date(i),a=new Date().getTime()-s.getTime(),o=Math.floor(a/1e3),c=Math.floor(o/60),t=Math.floor(c/60),l=Math.floor(t/24);return l>7?s.toLocaleDateString():l>0?l===1?"yesterday":`${l} days ago`:t>0?t===1?"1 hour ago":`${t} hours ago`:c>0?c===1?"1 minute ago":`${c} minutes ago`:"just now"}function pe(i){if(i.isDir)return ue;const s=i.extension.toLowerCase();return["jpg","jpeg","png","gif","webp","svg","bmp"].includes(s)?Me:["mp4","avi","mkv","mov","wmv","flv","webm"].includes(s)?Re:["mp3","wav","flac","aac","ogg","m4a"].includes(s)?Te:["zip","rar","7z","tar","gz","bz2"].includes(s)?Le:["txt","md","log","json","xml","yaml","yml"].includes(s)?$e:["js","ts","jsx","tsx","py","java","cpp","c","h","css","html","php","rb","go","rs"].includes(s)?Ke:ee}function li(i,s,n){return r.useMemo(()=>[...i].sort((o,c)=>{if(o.isDir&&!c.isDir)return-1;if(!o.isDir&&c.isDir)return 1;let t=0;switch(s){case"name":t=o.name.localeCompare(c.name);break;case"size":t=o.size-c.size;break;case"modified":t=new Date(o.modified).getTime()-new Date(c.modified).getTime();break;default:t=o.name.localeCompare(c.name)}return n?t:-t}),[i,s,n])}function oi(){return r.useMemo(()=>typeof window>"u"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches,[])}function ci({viewMode:i}){const s=i==="grid"?12:8;return i==="grid"?e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-6 xl:grid-cols-8 gap-3 p-4","aria-busy":"true","aria-label":"Loading files",children:Array.from({length:s},(n,a)=>e.jsxs("div",{className:"flex flex-col items-center p-3 rounded-lg",children:[e.jsx("div",{className:"w-12 h-12 bg-primary-200 rounded animate-pulse mb-2"}),e.jsx("div",{className:"w-16 h-4 bg-primary-200 rounded animate-pulse"})]},a))}):e.jsx("div",{className:"divide-y divide-primary-200","aria-busy":"true","aria-label":"Loading files",children:Array.from({length:s},(n,a)=>e.jsxs("div",{className:"flex items-center gap-3 px-4 py-3",children:[e.jsx("div",{className:"w-6 h-6 bg-primary-200 rounded animate-pulse"}),e.jsx("div",{className:"flex-1 min-w-0 h-4 bg-primary-200 rounded animate-pulse"}),e.jsx("div",{className:"w-16 h-4 bg-primary-200 rounded animate-pulse"}),e.jsx("div",{className:"w-20 h-4 bg-primary-200 rounded animate-pulse"})]},a))})}const di=r.memo(function({item:s,isSelected:n,onClick:a,onDoubleClick:o,onKeyDown:c,onOpenFile:t,reduceMotion:l}){const m=r.useCallback(()=>{a(s)},[a,s]),v=r.useCallback(()=>{o(s)},[o,s]),y=r.useCallback(d=>{c(d,s)},[c,s]),f=()=>s.isDir?`${s.name}, folder`:`${s.name}, ${s.extension} file, ${J(s.size)}, modified ${q(s.modified)}`,u=e.jsxs(E.button,{type:"button",whileHover:l?{}:{scale:1.02},whileTap:l?{}:{scale:.98},transition:{duration:l?0:.15},onClick:m,onDoubleClick:v,onKeyDown:y,"aria-label":f(),className:h("flex flex-col items-center p-3 rounded-lg w-full border border-transparent","transition-all duration-150 ease-out","hover:bg-primary-50 hover:border-primary-100 focus-visible:bg-primary-50","focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation",n&&"bg-primary-100 border-primary-200"),children:[e.jsx(j,{icon:pe(s),size:40,strokeWidth:1,className:h("mb-2",s.isDir?"text-sky-500":"text-primary-500"),"aria-hidden":"true"}),e.jsx("span",{className:"text-[11px] text-center text-primary-900 font-medium truncate w-full min-w-0",children:s.name}),s.isDir?null:e.jsx("span",{className:"text-[10px] text-primary-400 mt-0.5 tabular-nums",children:J(s.size)})]});return e.jsx(me,{item:s,onOpenFile:t,children:u})}),ui=r.memo(function({item:s,isSelected:n,onClick:a,onDoubleClick:o,onKeyDown:c,onOpenFile:t,reduceMotion:l}){const m=r.useCallback(()=>{a(s)},[a,s]),v=r.useCallback(()=>{o(s)},[o,s]),y=r.useCallback(d=>{c(d,s)},[c,s]),f=()=>s.isDir?`${s.name}, folder, modified ${q(s.modified)}`:`${s.name}, ${s.extension} file, ${J(s.size)}, modified ${q(s.modified)}`,u=e.jsxs(E.button,{type:"button",whileHover:l?{}:{backgroundColor:"rgb(248 250 252)"},transition:{duration:l?0:.15},onClick:m,onDoubleClick:v,onKeyDown:y,"aria-label":f(),className:h("w-full grid grid-cols-[auto_1fr_auto_auto] gap-4 px-4 py-2.5 text-left","transition-all duration-150 ease-out","hover:bg-primary-50 focus-visible:bg-primary-50","focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation",n&&"bg-primary-100"),children:[e.jsx(j,{icon:pe(s),size:18,strokeWidth:1.5,className:h("mt-0.5 shrink-0",s.isDir?"text-sky-500":"text-primary-500"),"aria-hidden":"true"}),e.jsx("div",{className:"min-w-0 flex-1",children:e.jsx("span",{className:"text-[13px] text-primary-900 font-medium truncate block",children:s.name})}),e.jsx("div",{className:"text-xs text-primary-500 text-right w-16 tabular-nums shrink-0",children:s.isDir?"—":J(s.size)}),e.jsx("div",{className:"text-xs text-primary-500 text-right w-20 tabular-nums shrink-0",children:q(s.modified)})]});return e.jsx(me,{item:s,onOpenFile:t,children:u})}),mi=e.jsx("div",{className:"flex items-center justify-center h-full py-12",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"inline-flex items-center justify-center w-12 h-12 rounded-lg bg-primary-50 mb-3",children:e.jsx(j,{icon:ue,size:24,strokeWidth:1.5,className:"text-primary-400","aria-hidden":"true"})}),e.jsx("p",{className:"text-sm text-primary-500",children:"This folder is empty"}),e.jsx("p",{className:"text-xs text-primary-400 mt-1",children:"Upload files or create a new folder to get started"})]})});function pi({listing:i,loading:s,onOpenFile:n}){const{viewMode:a,sortBy:o,sortAsc:c,selectedFiles:t,navigateTo:l,toggleFileSelection:m}=F(),[v,y]=r.useState(0),f=r.useRef(null),u=oi(),d=li(i?.items||[],o,c),C=r.useCallback(p=>{m(p.path)},[m]),N=r.useCallback(p=>{p.isDir?l(p.path):n&&ti.has(p.extension.toLowerCase())&&n(p.path)},[l,n]),w=r.useCallback((p,x)=>{p.key==="Enter"?(p.preventDefault(),x.isDir?l(x.path):m(x.path)):p.key===" "&&(p.preventDefault(),m(x.path))},[l,m]);return r.useEffect(()=>{const p=x=>{if(d.length)switch(x.key){case"ArrowDown":x.preventDefault(),y(D=>Math.min(D+1,d.length-1));break;case"ArrowUp":x.preventDefault(),y(D=>Math.max(D-1,0));break;case"Home":x.preventDefault(),y(0);break;case"End":x.preventDefault(),y(d.length-1);break}};if(f.current)return f.current.addEventListener("keydown",p),()=>{f.current?.removeEventListener("keydown",p)}},[d.length]),s?e.jsx(ci,{viewMode:a}):i?d.length===0?mi:a==="grid"?e.jsx("div",{ref:f,className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-6 xl:grid-cols-8 gap-3 p-4 overflow-y-auto",role:"grid","aria-label":"Files grid",tabIndex:0,children:d.map((p,x)=>e.jsx("div",{role:"gridcell",children:e.jsx(di,{item:p,isSelected:t.has(p.path),onClick:C,onDoubleClick:N,onKeyDown:w,onOpenFile:n,reduceMotion:u})},p.path))}):e.jsx("div",{ref:f,className:"overflow-y-auto",role:"table","aria-label":"Files list",tabIndex:0,children:e.jsxs("div",{className:"divide-y divide-primary-100",children:[e.jsxs("div",{className:"grid grid-cols-[auto_1fr_auto_auto] gap-4 px-4 py-2 text-xs font-medium text-primary-400 uppercase tracking-wider bg-primary-50/50",role:"row",children:[e.jsx("div",{className:"w-6",role:"columnheader","aria-label":"File type"}),e.jsx("div",{role:"columnheader",children:"Name"}),e.jsx("div",{className:"w-16 text-right",role:"columnheader",children:"Size"}),e.jsx("div",{className:"w-20 text-right",role:"columnheader",children:"Modified"})]}),d.map((p,x)=>e.jsx("div",{role:"row",children:e.jsx(ui,{item:p,isSelected:t.has(p.path),onClick:C,onDoubleClick:N,onKeyDown:w,onOpenFile:n,reduceMotion:u})},p.path))]})}):e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsx("p",{className:"text-primary-500",children:"No listing available"})})}function oe(i){if(i===0)return"0 B";const s=1024,n=["B","KB","MB","GB"],a=Math.floor(Math.log(i)/Math.log(s));return parseFloat((i/Math.pow(s,a)).toFixed(1))+" "+n[a]}function fi({open:i,onOpenChange:s,currentPath:n}){const[a,o]=r.useState([]),[c,t]=r.useState(!1),[l,m]=r.useState("idle"),v=r.useRef(null),y=ii(),f=r.useCallback(()=>{o([]),m("idle"),v.current&&(v.current.value="")},[]),u=r.useCallback(g=>{if(!g)return;const S=Array.from(g).map(R=>({file:R,id:Math.random().toString(36).substr(2,9)}));o(R=>[...R,...S])},[]),d=r.useCallback(g=>{u(g.target.files)},[u]),C=r.useCallback(g=>{g.preventDefault(),t(!1),u(g.dataTransfer.files)},[u]),N=r.useCallback(g=>{g.preventDefault(),t(!0)},[]),w=r.useCallback(g=>{g.preventDefault(),t(!1)},[]),p=r.useCallback(g=>{o(S=>S.filter(R=>R.id!==g))},[]),x=r.useCallback(()=>{v.current?.click()},[]),D=r.useCallback(g=>{(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),x())},[x]),M=r.useCallback(async()=>{if(a.length===0)return;const g=new DataTransfer;a.forEach(({file:S})=>{g.items.add(S)}),m("uploading");try{await y.mutateAsync({files:g.files,path:n}),m("success"),f(),s(!1)}catch(S){m("error"),console.error("Upload failed:",S)}},[a,n,y,f,s]),X=r.useCallback(g=>{g||f(),s(g)},[f,s]),K=a.reduce((g,{file:S})=>g+S.size,0),U=a.length,Y=()=>y.isPending||l==="uploading"?"Uploading…":U===0?"Upload":U===1?"Upload 1 File":`Upload ${U} Files`;return e.jsx(Q,{open:i,onOpenChange:X,children:e.jsx(_,{className:"w-[min(500px,92vw)]",children:e.jsxs("div",{className:"p-6",children:[e.jsx(V,{className:"mb-2",children:"Upload Files"}),e.jsxs(H,{className:"mb-6",children:["Upload files to ",n==="/"?"root directory":n]}),e.jsxs("div",{onDrop:C,onDragOver:N,onDragLeave:w,onClick:x,onKeyDown:D,tabIndex:0,role:"button","aria-label":"Drop files here or click to choose files",className:h("border-2 border-dashed rounded-lg p-8 text-center cursor-pointer","transition-colors duration-150 ease-out","focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation",c?"border-primary-400 bg-primary-50":"border-primary-200 hover:border-primary-300 hover:bg-primary-50"),children:[e.jsx(j,{icon:ce,size:48,strokeWidth:1,className:"mx-auto text-primary-400 mb-4","aria-hidden":"true"}),e.jsx("p",{className:"text-primary-600 font-medium mb-2",children:"Drag and drop files here"}),e.jsx("p",{className:"text-sm text-primary-500 mb-4",children:"or"}),e.jsxs(k,{variant:"outline",className:h("gap-2","focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation"),"aria-label":"Choose files from computer",children:[e.jsx(j,{icon:ee,size:18,strokeWidth:1.5,"aria-hidden":"true"}),e.jsx("span",{children:"Choose Files"})]}),e.jsx("input",{ref:v,type:"file",multiple:!0,onChange:d,className:"hidden","aria-hidden":"true"})]}),e.jsx(A,{children:a.length>0?e.jsxs(E.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},className:"mt-6",children:[e.jsxs("h4",{className:"text-sm font-medium text-primary-900 mb-3",children:["Selected Files (",a.length,")"]}),e.jsx("div",{className:"max-h-32 overflow-y-auto border border-primary-200 rounded-lg",children:a.map(({file:g,id:S})=>e.jsxs(E.div,{initial:{opacity:0,x:-10},animate:{opacity:1,x:0},exit:{opacity:0,x:10},className:"flex items-center justify-between p-2 border-b border-primary-100 last:border-b-0",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[e.jsx(j,{icon:ee,size:16,strokeWidth:1.5,className:"text-primary-600 shrink-0","aria-hidden":"true"}),e.jsx("span",{className:"text-sm text-primary-900 truncate min-w-0",children:g.name}),e.jsx("span",{className:"text-xs text-primary-500 shrink-0 tabular-nums",children:oe(g.size)})]}),e.jsx(k,{size:"icon-sm",variant:"ghost",onClick:()=>p(S),className:h("text-primary-500 hover:text-red-600 shrink-0","focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation"),"aria-label":`Remove ${g.name} from upload list`,children:e.jsx(j,{icon:de,size:14,strokeWidth:1.5,"aria-hidden":"true"})})]},S))}),e.jsxs("p",{className:"text-xs text-primary-600 mt-2 tabular-nums",children:["Total size: ",oe(K)]})]}):null}),y.isPending||l==="uploading"?e.jsxs(E.div,{initial:{opacity:0},animate:{opacity:1},className:"mt-4 p-3 bg-primary-50 rounded-lg","aria-live":"polite",children:[e.jsx("p",{className:"text-sm text-primary-600 mb-2",children:"Uploading files…"}),e.jsx("div",{className:"bg-primary-200 rounded-full h-2",role:"progressbar","aria-label":"Upload progress",children:e.jsx("div",{className:"bg-primary-600 h-2 rounded-full w-1/2 animate-pulse"})})]}):null,l==="success"?e.jsx("div",{className:"mt-4 p-3 bg-green-50 rounded-lg","aria-live":"polite",children:e.jsx("p",{className:"text-sm text-green-700",children:"Files uploaded successfully!"})}):null,l==="error"?e.jsx("div",{className:"mt-4 p-3 bg-red-50 rounded-lg","aria-live":"polite",children:e.jsx("p",{className:"text-sm text-red-700",children:"Upload failed. Please try again."})}):null,e.jsxs("div",{className:"flex justify-end gap-2 mt-6",children:[e.jsx(G,{disabled:y.isPending||l==="uploading",className:h("focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation"),children:"Cancel"}),e.jsx(k,{onClick:M,disabled:a.length===0||y.isPending||l==="uploading",className:h("focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation"),children:Y()})]})]})})})}function hi({open:i,onOpenChange:s,currentPath:n}){const[a,o]=r.useState(""),[c,t]=r.useState(""),l=ni(),m=r.useCallback(async()=>{if(a.trim()){t("");try{await l.mutateAsync({path:n,name:a.trim()}),o(""),s(!1)}catch(p){const x=p instanceof Error?p.message:"Failed to create folder";t(x),console.error("Create folder failed:",p)}}},[a,n,l,s]),v=r.useCallback(p=>{p||(o(""),t("")),s(p)},[s]),y=r.useCallback(p=>{p.key==="Enter"&&(p.preventDefault(),m())},[m]),f=r.useCallback(p=>{const x=p.target.value;o(x),c&&t("")},[c]),u=a.trim().length>0&&!/[<>:"/\\|?*]/.test(a)&&!a.includes(".."),d=()=>l.isPending?"Creating…":"Create Folder",N=a.trim()?a.includes("..")?'Folder name cannot contain ".."':/[<>:"/\\|?*]/.test(a)?'Invalid characters: < > : " / \\ | ? *':"":"",w=c||N;return e.jsx(Q,{open:i,onOpenChange:v,children:e.jsx(_,{children:e.jsxs("div",{className:"p-6",children:[e.jsx(V,{className:"mb-2",children:"Create New Folder"}),e.jsxs(H,{className:"mb-4",children:["Create a new folder in ",n==="/"?"root directory":n]}),e.jsxs("div",{className:"mb-6",children:[e.jsx("label",{htmlFor:"folder-name",className:"block text-sm font-medium text-primary-900 mb-2",children:"Folder Name"}),e.jsx("input",{id:"folder-name",type:"text",value:a,onChange:f,onKeyDown:y,placeholder:"Enter folder name",autoComplete:"off",spellCheck:!1,autoFocus:!0,"aria-describedby":w?"folder-name-error":void 0,"aria-invalid":w?"true":"false",className:h("w-full px-3 py-2 border rounded-lg","transition-colors duration-150 ease-out","focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation",w?"border-red-300 focus-visible:ring-red-300":"border-primary-200 focus:border-primary-300")}),w?e.jsx("p",{id:"folder-name-error",className:"text-sm text-red-600 mt-1",role:"alert","aria-live":"polite",children:c||N}):null]}),l.isPending?e.jsx("div",{className:"mb-4 p-3 bg-primary-50 rounded-lg","aria-live":"polite",children:e.jsx("p",{className:"text-sm text-primary-600",children:"Creating folder…"})}):null,e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(G,{disabled:l.isPending,className:h("focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation"),children:"Cancel"}),e.jsx(k,{onClick:m,disabled:!u||l.isPending,className:h("focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none","touch-manipulation",(!u||l.isPending)&&"opacity-50 cursor-not-allowed"),"aria-describedby":u?void 0:"create-button-help",children:d()})]}),!u&&a.length>0?e.jsx("p",{id:"create-button-help",className:"text-xs text-primary-500 mt-2",children:"Please enter a valid folder name"}):null]})})})}const xi={js:"JavaScript",ts:"TypeScript",jsx:"JSX",tsx:"TSX",py:"Python",json:"JSON",yaml:"YAML",yml:"YAML",md:"Markdown",html:"HTML",css:"CSS",scss:"SCSS",sh:"Shell",bash:"Bash",sql:"SQL",xml:"XML",toml:"TOML",ini:"INI",conf:"Config",cfg:"Config",env:"Env",txt:"Text",log:"Log",csv:"CSV",go:"Go",rs:"Rust",rb:"Ruby",php:"PHP",java:"Java",c:"C",cpp:"C++",h:"Header",dockerfile:"Dockerfile",makefile:"Makefile",graphql:"GraphQL",svelte:"Svelte",vue:"Vue"};function gi({filePath:i,onClose:s}){const n=Xe(i),a=Ye(),o=r.useRef(null),[c,t]=r.useState(null),[l,m]=r.useState(!1);r.useEffect(()=>{n.data&&c===null&&t(n.data.content)},[n.data,c]);const v=r.useMemo(()=>n.data?xi[n.data.extension.toLowerCase()]||n.data.extension.toUpperCase():"",[n.data]),y=r.useCallback(N=>{t(N.target.value),m(N.target.value!==n.data?.content)},[n.data]),f=r.useCallback(async()=>{if(c!==null)try{await a.mutateAsync({path:i,content:c}),m(!1)}catch{}},[i,c,a]),u=r.useCallback(()=>{l&&!window.confirm("You have unsaved changes. Discard them?")||s()},[l,s]);r.useEffect(()=>{const N=w=>{(w.ctrlKey||w.metaKey)&&w.key==="s"&&(w.preventDefault(),l&&f()),w.key==="Escape"&&u()};return window.addEventListener("keydown",N),()=>window.removeEventListener("keydown",N)},[f,u,l]);const d=r.useCallback(N=>{if(N.key==="Tab"){N.preventDefault();const w=N.currentTarget,p=w.selectionStart,x=w.selectionEnd,D=w.value,M=D.substring(0,p)+" "+D.substring(x);t(M),m(M!==n.data?.content),requestAnimationFrame(()=>{w.selectionStart=w.selectionEnd=p+2})}},[n.data]),C=i.split("/").pop()||i;return e.jsxs("div",{className:"fixed inset-0 z-50 bg-surface flex flex-col",children:[e.jsxs("header",{className:"flex items-center justify-between px-4 py-2 border-b border-primary-200 bg-primary-50",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx("h2",{className:"text-sm font-semibold text-primary-900 truncate",children:C}),v?e.jsx("span",{className:"text-xs text-primary-500 bg-primary-100 px-2 py-0.5 rounded-full shrink-0",children:v}):null,l?e.jsx("span",{className:"text-xs text-amber-600 bg-amber-50 px-2 py-0.5 rounded-full shrink-0",children:"Unsaved"}):null,a.isError?e.jsx("span",{className:"text-xs text-red-600",children:a.error.message}):null]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsxs(k,{size:"sm",variant:"default",onClick:f,disabled:!l||a.isPending,className:h((!l||a.isPending)&&"opacity-50 cursor-not-allowed"),children:[e.jsx(j,{icon:Ue,size:16,strokeWidth:1.5,"aria-hidden":"true"}),a.isPending?"Saving…":"Save"]}),e.jsx(k,{size:"icon-sm",variant:"ghost",onClick:u,"aria-label":"Close editor",children:e.jsx(j,{icon:Ie,size:20,strokeWidth:1.5,"aria-hidden":"true"})})]})]}),e.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:n.isLoading?e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsx("p",{className:"text-primary-500 text-sm",children:"Loading file…"})}):n.isError?e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-red-600 text-sm mb-2",children:n.error instanceof Error?n.error.message:"Failed to load file"}),e.jsx(k,{size:"sm",variant:"secondary",onClick:()=>{n.refetch()},children:"Retry"})]})}):e.jsx("textarea",{ref:o,value:c??"",onChange:y,onKeyDown:d,spellCheck:!1,autoFocus:!0,className:h("w-full h-full p-4 resize-none","bg-primary-950 text-primary-100","font-mono text-sm leading-relaxed","focus:outline-none","selection:bg-blue-800/50")})}),n.data?e.jsxs("footer",{className:"flex items-center justify-between px-4 py-1 border-t border-primary-200 bg-primary-50 text-xs text-primary-500",children:[e.jsx("span",{children:i}),e.jsx("span",{children:bi(n.data.size)})]}):null]})}function bi(i){return i<1024?`${i} B`:i<1024*1024?`${(i/1024).toFixed(1)} KB`:`${(i/(1024*1024)).toFixed(1)} MB`}function $i(){const i=L(),{currentPath:s,editingFile:n}=F(),[a,o]=r.useState(!1),[c,t]=r.useState(!1),l=Ze(s),v=ie({queryKey:Pe,queryFn:function(){return te(i)},initialData:function(){return te(i)},staleTime:1/0}).data?.isSidebarCollapsed??!1,y=r.useCallback(()=>{Ae(i,function(x){return{...x,isSidebarCollapsed:!x.isSidebarCollapsed}})},[i]),f=r.useCallback(()=>{o(!0)},[]),u=r.useCallback(()=>{t(!0)},[]),d=r.useCallback(p=>{F.getState().openInEditor(p)},[]),C=r.useCallback(()=>{F.getState().closeEditor()},[]),N=r.useMemo(()=>({display:"flex",flexDirection:"column",height:"100%",minHeight:0}),[]),w=e.jsx(He,{isCollapsed:v,onToggleCollapse:y,onSelectAction:()=>{}});return e.jsxs("div",{className:"h-screen bg-surface text-primary-900",children:[e.jsxs("div",{className:h("h-full overflow-hidden grid grid-cols-[auto_1fr]"),children:[w,e.jsxs("main",{"aria-label":"File explorer",style:N,children:[e.jsxs("header",{className:"border-b border-primary-100 px-4 py-3",children:[e.jsx("div",{className:"flex items-center justify-between mb-3",children:e.jsx(Ge,{path:s})}),e.jsx(Je,{onUpload:f,onCreateFolder:u})]}),e.jsxs("div",{className:"flex-1 min-h-0 overflow-auto",children:[e.jsx(pi,{listing:l.data,loading:l.isLoading,onOpenFile:d}),l.isError?e.jsxs("div",{className:"p-4 text-center","aria-live":"polite",children:[e.jsx("p",{className:"text-red-600 text-sm",children:l.error instanceof Error?l.error.message:"Failed to load files"}),e.jsx("button",{onClick:()=>{l.refetch()},className:"mt-2 text-sm text-primary-600 hover:text-primary-900 underline focus-visible:ring-2 focus-visible:ring-primary-300 focus-visible:outline-none rounded-sm",children:"Retry"})]}):null]}),e.jsx(fi,{open:a,onOpenChange:o,currentPath:s}),e.jsx(hi,{open:c,onOpenChange:t,currentPath:s})]})]}),n?e.jsx(gi,{filePath:n,onClose:C}):null]})}export{$i as FileExplorerScreen};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/file-explorer-screen-DPs-FWeA.js","assets/main-B2CrcRuC.js","assets/useQuery-D-sF8Tld.js","assets/button-BciDmec0.js","assets/tooltip-DOKkNFvu.js","assets/useOnFirstRender-DlXHIIGk.js","assets/useBaseUiId-DFpBD0sg.js","assets/event-BCwqPPkP.js","assets/visuallyHidden-COI6QeQH.js","assets/DirectionContext-CR5CCisG.js","assets/use-file-explorer-state-BAa6Cxyr.js","assets/composite-DArWbFHm.js","assets/react-DWx7OvUo.js","assets/proxy-BijR8W1L.js","assets/menu-CIwnliij.js","assets/useCompositeItem-B-Axq9-D.js","assets/useMutation-BFl-7GnD.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{j as e,r,_ as s}from"./main-B2CrcRuC.js";const n=r.lazy(()=>s(()=>import("./file-explorer-screen-DPs-FWeA.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16])).then(t=>({default:t.FileExplorerScreen})));function o(){return e.jsx(r.Suspense,{fallback:e.jsx("div",{className:"flex h-screen items-center justify-center text-primary-500 text-sm",children:"Loading…"}),children:e.jsx(n,{})})}export{o as component};
|
package/dist/client/assets/{follow-up-suggestions-Bq-xR5GV.js → follow-up-suggestions-BPjWBpiy.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as l,j as n}from"./main-
|
|
1
|
+
import{r as l,j as n}from"./main-B2CrcRuC.js";import{H as v,p as F,l as N,c as S}from"./button-BciDmec0.js";import{d as U,e as R}from"./_sessionKey-Bg_9uype.js";import"./useQuery-D-sF8Tld.js";import"./tooltip-DOKkNFvu.js";import"./useOnFirstRender-DlXHIIGk.js";import"./useBaseUiId-DFpBD0sg.js";import"./event-BCwqPPkP.js";import"./visuallyHidden-COI6QeQH.js";import"./DirectionContext-CR5CCisG.js";import"./useMutation-BFl-7GnD.js";import"./use-file-explorer-state-BAa6Cxyr.js";import"./composite-DArWbFHm.js";import"./react-DWx7OvUo.js";import"./useControlled-CQHE0ITz.js";import"./CSPContext-B3PAVjBL.js";import"./menu-CIwnliij.js";import"./useCompositeItem-B-Axq9-D.js";import"./opencami-logo-SVuYD55V.js";import"./proxy-BijR8W1L.js";import"./markdown-CdkuX06F.js";import"./index-CGeJcqZ3.js";import"./index-T4TOjvD0.js";const H=[/```[\s\S]*?```/g,/`[^`]+`/g,/\b(function|const|let|var|class|import|export|return|async|await)\b/g];function I(t){const e=[],r=t.match(/"([^"]+)"|'([^']+)'/g);r&&e.push(...r.map(s=>s.replace(/['"]/g,"")));const o=t.match(/\b[A-Z][a-z]+(?:\s+[A-Z][a-z]+)*\b/g);o&&e.push(...o.filter(s=>!["I","The","A","An","This"].includes(s)));const i=t.match(/`([^`]+)`/g);return i&&e.push(...i.map(s=>s.replace(/`/g,""))),[...new Set(e)].slice(0,5)}function W(t){return H.some(e=>e.test(t))}function $(t){return/^[\s]*[-*•\d]+[.)\s]/m.test(t)||/\b(first|second|third|1\.|2\.|3\.)/i.test(t)}function z(t){return/\b(alternatively|another|other option|could also|you might|consider)\b/i.test(t)}function O(t){return/\b(because|since|due to|reason|why|how|what|when|where)\b/i.test(t)}function M(t){return/\b(however|but|note|warning|caution|careful|important|keep in mind|be aware)\b/i.test(t)}function P(t){const e=[],r=I(t);if(W(t)&&(e.push({text:"Can you explain this code step by step?",type:"clarify"}),e.push({text:"How would I modify this for my use case?",type:"actionable"})),$(t)&&(e.push({text:"Can you elaborate on the first point?",type:"expand"}),e.push({text:"Which of these is most important to start with?",type:"actionable"})),z(t)&&(e.push({text:"What are the pros and cons of each approach?",type:"alternative"}),e.push({text:"Which option would you recommend and why?",type:"clarify"})),O(t)&&e.length<3&&e.push({text:"Can you give me a practical example?",type:"example"}),M(t)&&e.length<3&&e.push({text:"What potential issues should I watch out for?",type:"clarify"}),r.length>0&&e.length<3){const s=r[0];e.push({text:`Tell me more about ${s}`,type:"expand"})}const o=[{text:"Can you give me a concrete example?",type:"example"},{text:"What would be the next steps?",type:"actionable"},{text:"How does this work in practice?",type:"expand"},{text:"Are there any common mistakes to avoid?",type:"clarify"},{text:"Can you simplify this explanation?",type:"clarify"}],i=new Set(e.map(s=>s.type));for(const s of o){if(e.length>=3)break;i.has(s.type)||(e.push(s),i.add(s.type))}for(const s of o){if(e.length>=3)break;e.some(c=>c.text===s.text)||e.push(s)}return e.slice(0,3)}function k(t){return P(t).map(e=>e.text)}async function K(t,e){const r={"Content-Type":"application/json",...R()},o=await fetch("/api/llm-features",{method:"POST",headers:r,body:JSON.stringify({action:"followups",conversationContext:t}),signal:e});if(!o.ok)throw new Error(`API error: ${o.status}`);const i=await o.json();return i.ok&&Array.isArray(i.suggestions)&&i.suggestions.length>0?i.suggestions:[]}function Z(t,e,r){const o=U(g=>g.settings),i=o.useLlmFollowUps,{minResponseLength:s=50,timeoutMs:c=8e3,heuristicsOnly:y}=r??{},p=y??!i,[x,m]=l.useState([]),[A,u]=l.useState(!1),[C,h]=l.useState(null),[j,f]=l.useState(null),w=l.useRef(""),b=l.useRef(null);return l.useEffect(()=>{if(!t||t.trim().length<s){m([]),f(null),u(!1),h(null);return}const g=t.slice(0,200)+t.length;if(g===w.current)return;if(w.current=g,b.current&&b.current.abort(),p){const a=k(t);m(a),f("heuristic"),u(!1),h(null);return}const d=new AbortController;b.current=d,u(!0),h(null);const L=k(t);m(L),f("heuristic");const E=e?`Context: ${e}
|
|
2
2
|
|
|
3
3
|
Assistant's response:
|
|
4
4
|
${t.slice(0,2e3)}`:`Assistant's response:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{R as t,r as s,j as a}from"./main-
|
|
1
|
+
import{R as t,r as s,j as a}from"./main-B2CrcRuC.js";function n(){const e=t.useNavigate();return s.useEffect(()=>{e({to:"/chat/$sessionKey",params:{sessionKey:"main"},replace:!0})},[e]),a.jsx("div",{className:"h-screen flex items-center justify-center text-primary-600",children:"Loading…"})}export{n as component};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/cpp-B-lmv-kZ.js","assets/regexp-CDVJQ6XC.js","assets/c-BIGW1oBm.js","assets/sql-BLtJtn59.js","assets/graphql-ChdNCCLP.js","assets/javascript-wDzz0qaB.js","assets/typescript-BPQ3VLAy.js","assets/jsx-g9-lgVsj.js","assets/tsx-COt5Ahok.js","assets/html-GMplVEZG.js","assets/css-DPfMkruS.js","assets/php-Dhbhpdrm.js","assets/xml-sdJ4AIDG.js","assets/java-CylS5w8V.js","assets/json-Cp-IABpG.js","assets/ruby-NiQIzKut.js","assets/shell-DfDnw5Jg.js","assets/yaml-Buea-lGh.js","assets/core-BrHBc0Zp.js","assets/index-T4TOjvD0.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{r as m,j as u,_ as r}from"./main-
|
|
2
|
+
import{r as m,j as u,_ as r}from"./main-B2CrcRuC.js";import{H as A,u as z,B as N,F as U,X as G,x as X,c as P}from"./button-BciDmec0.js";import{c as $}from"./react-DWx7OvUo.js";function Q(e,o){let t;try{t=e()}catch{return}return{getItem:i=>{var s;const f=h=>h===null?null:JSON.parse(h,void 0),d=(s=t.getItem(i))!=null?s:null;return d instanceof Promise?d.then(f):f(d)},setItem:(i,s)=>t.setItem(i,JSON.stringify(s,void 0)),removeItem:i=>t.removeItem(i)}}const j=e=>o=>{try{const t=e(o);return t instanceof Promise?t:{then(n){return j(n)(t)},catch(n){return this}}}catch(t){return{then(n){return this},catch(n){return j(n)(t)}}}},Y=(e,o)=>(t,n,i)=>{let s={storage:Q(()=>window.localStorage),partialize:a=>a,version:0,merge:(a,v)=>({...v,...a}),...o},f=!1,d=0;const h=new Set,y=new Set;let c=s.storage;if(!c)return e((...a)=>{console.warn(`[zustand persist middleware] Unable to update item '${s.name}', the given storage is currently unavailable.`),t(...a)},n,i);const I=()=>{const a=s.partialize({...n()});return c.setItem(s.name,{state:a,version:s.version})},T=i.setState;i.setState=(a,v)=>(T(a,v),I());const x=e((...a)=>(t(...a),I()),n,i);i.getInitialState=()=>x;let g;const E=()=>{var a,v;if(!c)return;const L=++d;f=!1,h.forEach(l=>{var _;return l((_=n())!=null?_:x)});const w=((v=s.onRehydrateStorage)==null?void 0:v.call(s,(a=n())!=null?a:x))||void 0;return j(c.getItem.bind(c))(s.name).then(l=>{if(l)if(typeof l.version=="number"&&l.version!==s.version){if(s.migrate){const _=s.migrate(l.state,l.version);return _ instanceof Promise?_.then(S=>[!0,S]):[!0,_]}console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return[!1,l.state];return[!1,void 0]}).then(l=>{var _;if(L!==d)return;const[S,O]=l;if(g=s.merge(O,(_=n())!=null?_:x),t(g,!0),S)return I()}).then(()=>{L===d&&(w?.(g,void 0),g=n(),f=!0,y.forEach(l=>l(g)))}).catch(l=>{L===d&&w?.(void 0,l)})};return i.persist={setOptions:a=>{s={...s,...a},a.storage&&(c=a.storage)},clearStorage:()=>{c?.removeItem(s.name)},getOptions:()=>s,rehydrate:()=>E(),hasHydrated:()=>f,onHydrate:a=>(h.add(a),()=>{h.delete(a)}),onFinishHydration:a=>(y.add(a),()=>{y.delete(a)})},s.skipHydration||E(),g||x},K=Y,D=$()(K(e=>({settings:{showToolMessages:!0,showReasoningBlocks:!0,showSearchSources:!0,inlineFilePreview:!1,theme:"system",fontFamily:"system",density:"comfortable",accentColor:"green",chatWidth:"wide",sidebarWidth:"normal",bubbleStyle:"default"},updateSettings:o=>e(t=>({settings:{...t.settings,...o}}))}),{name:"chat-settings",merge:(e,o)=>{const t=e;return{...o,...t,settings:{...o.settings,...t?.settings??{}}}}}));function de(){const e=D(t=>t.settings),o=D(t=>t.updateSettings);return{settings:e,updateSettings:o}}function Z(){const e=D(n=>n.settings.theme),[o,t]=m.useState(!1);return m.useEffect(()=>{if(typeof window>"u")return;const n=window.matchMedia("(prefers-color-scheme: dark)");t(n.matches);function i(s){t(s.matches)}return n.addEventListener("change",i),()=>n.removeEventListener("change",i)},[]),m.useMemo(()=>e==="dark"?"dark":e==="light"||e==="frost-light"?"light":e==="frost-dark"||o?"dark":"light",[e,o])}const ee=new Set(["bash","c","cpp","csharp","css","diff","dockerfile","go","graphql","html","java","javascript","json","jsx","kotlin","markdown","php","python","regexp","ruby","rust","shell","sql","swift","toml","typescript","tsx","xml","yaml"]),te={js:"javascript",ts:"typescript",tsx:"tsx",jsx:"jsx",typescriptreact:"tsx",javascriptreact:"jsx",react:"jsx",sh:"bash",shell:"bash",yml:"yaml",md:"markdown",txt:"text"};function M(e){const t=e.trim().toLowerCase().replace(/^language-/,"").replace(/^\[|\]$/g,"").split(/[\s,]+/)[0]||"text";return te[t]??t}function re(e){const o=M(e);return ee.has(o)?o:"text"}function ne(e){return{bash:"Bash",python:"Python",javascript:"JavaScript",typescript:"TypeScript",tsx:"TSX",jsx:"JSX",json:"JSON",html:"HTML",css:"CSS",sql:"SQL",yaml:"YAML",markdown:"Markdown",text:"Plain Text"}[e]||e.charAt(0).toUpperCase()+e.slice(1)}const se={bash:()=>r(()=>import("./shell-DfDnw5Jg.js").then(e=>e.b),[]).then(e=>e.default),c:()=>r(()=>import("./c-BIGW1oBm.js"),[]).then(e=>e.default),cpp:()=>r(()=>import("./cpp-B-lmv-kZ.js"),__vite__mapDeps([0,1,2,3])).then(e=>e.default),csharp:()=>r(()=>import("./csharp-COcwbKMJ.js"),[]).then(e=>e.default),css:()=>r(()=>import("./css-DPfMkruS.js"),[]).then(e=>e.default),diff:()=>r(()=>import("./diff-D97Zzqfu.js"),[]).then(e=>e.default),dockerfile:()=>r(()=>import("./dockerfile-BcOcwvcX.js"),[]).then(e=>e.default),go:()=>r(()=>import("./go-CxLEBnE3.js"),[]).then(e=>e.default),graphql:()=>r(()=>import("./graphql-ChdNCCLP.js"),__vite__mapDeps([4,5,6,7,8])).then(e=>e.default),html:()=>r(()=>import("./html-GMplVEZG.js"),__vite__mapDeps([9,5,10])).then(e=>e.default),java:()=>r(()=>import("./java-CylS5w8V.js"),[]).then(e=>e.default),javascript:()=>r(()=>import("./javascript-wDzz0qaB.js"),[]).then(e=>e.default),json:()=>r(()=>import("./json-Cp-IABpG.js"),[]).then(e=>e.default),jsx:()=>r(()=>import("./jsx-g9-lgVsj.js"),[]).then(e=>e.default),kotlin:()=>r(()=>import("./kotlin-BdnUsdx6.js"),[]).then(e=>e.default),markdown:()=>r(()=>import("./markdown-Cvjx9yec.js"),[]).then(e=>e.default),php:()=>r(()=>import("./php-Dhbhpdrm.js"),__vite__mapDeps([11,9,5,10,12,13,3,14])).then(e=>e.default),python:()=>r(()=>import("./python-B6aJPvgy.js"),[]).then(e=>e.default),regexp:()=>r(()=>import("./regexp-CDVJQ6XC.js"),[]).then(e=>e.default),ruby:()=>r(()=>import("./ruby-NiQIzKut.js"),__vite__mapDeps([15,9,5,10,12,13,3,4,6,7,8,0,1,2,16,17])).then(e=>e.default),rust:()=>r(()=>import("./rust-B1yitclQ.js"),[]).then(e=>e.default),shell:()=>r(()=>import("./shell-DfDnw5Jg.js").then(e=>e.a),[]).then(e=>e.default),sql:()=>r(()=>import("./sql-BLtJtn59.js"),[]).then(e=>e.default),swift:()=>r(()=>import("./swift-D82vCrfD.js"),[]).then(e=>e.default),toml:()=>r(()=>import("./toml-vGWfd6FD.js"),[]).then(e=>e.default),typescript:()=>r(()=>import("./typescript-BPQ3VLAy.js"),[]).then(e=>e.default),tsx:()=>r(()=>import("./tsx-COt5Ahok.js"),[]).then(e=>e.default),xml:()=>r(()=>import("./xml-sdJ4AIDG.js"),__vite__mapDeps([12,13])).then(e=>e.default),yaml:()=>r(()=>import("./yaml-Buea-lGh.js"),[]).then(e=>e.default)},ae={sh:"bash",zsh:"bash",js:"javascript",ts:"typescript",py:"python",rb:"ruby",rs:"rust",cs:"csharp","c++":"cpp",yml:"yaml",md:"markdown",docker:"dockerfile"};let k=null;const H=new Set;async function oe(){if(!k){const[{createHighlighterCore:e},{createJavaScriptRegexEngine:o},t,n]=await Promise.all([r(()=>import("./core-BrHBc0Zp.js"),__vite__mapDeps([18,19])),r(()=>import("./engine-javascript-PwbX1GN8.js"),[]),r(()=>import("./vitesse-dark-D0r3Knsf.js"),[]).then(i=>i.default),r(()=>import("./vitesse-light-CVO1_9PV.js"),[]).then(i=>i.default)]);k=e({themes:[t,n],langs:[],engine:o()})}return k}async function ie(e,o){const t=ae[o]||o;if(H.has(t))return t;const n=se[t];if(!n)return"text";try{const i=await n();return await e.loadLanguage(i),H.add(t),t}catch{return"text"}}function _e({content:e,ariaLabel:o,language:t="text",filename:n,className:i,isStreaming:s=!1}){const f=Z(),[d,h]=m.useState(!1),[y,c]=m.useState(null),[I,T]=m.useState("text"),[x,g]=m.useState(),[E,a]=m.useState(!1),v=m.useMemo(()=>e,[e]),L=M(t||"text"),w=f==="dark"?"vitesse-dark":"vitesse-light";m.useEffect(()=>{let p=!0,b=null;const V=re(L);if(T(V),s)return c(null),()=>{p=!1};async function B(){try{const R=await oe();if(!p)return;const C=await ie(R,V);if(!p)return;const J=R.codeToHtml(e,{lang:C,theme:w});if(p){T(C),c(J);const q=R.getTheme(w);g(q.bg)}}catch{p&&c(null)}}return b=window.setTimeout(()=>{B()},160),()=>{p=!1,b&&window.clearTimeout(b)}},[e,s,L,w]),m.useEffect(()=>{if(typeof window>"u")return;const p=window.localStorage.getItem("opencami-code-wrap");a(p==="1")},[]);function l(){a(p=>{const b=!p;return typeof window<"u"&&window.localStorage.setItem("opencami-code-wrap",b?"1":"0"),b})}async function _(){try{await navigator.clipboard.writeText(e),h(!0),window.setTimeout(()=>h(!1),1600)}catch{h(!1)}}const F=!(e.replace(/\n$/,"").split(`
|
|
3
3
|
`).length<=1),W=ne(I);return u.jsxs("div",{className:P("code-block group relative w-full min-w-0 max-w-full overflow-hidden rounded-lg border border-primary-200",i),children:[u.jsxs("div",{className:P("flex items-center justify-between px-3 pt-2"),style:{backgroundColor:x},children:[u.jsx("span",{className:"text-xs font-medium text-primary-500 flex items-center gap-1.5 min-w-0",children:n?u.jsxs(u.Fragment,{children:[u.jsx(A,{icon:z,size:14,strokeWidth:1.8}),u.jsx("span",{className:"truncate",children:n})]}):W}),u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsxs(N,{variant:"ghost","aria-label":E?"Disable wrap":"Enable wrap",className:"h-auto px-0 text-xs font-medium text-primary-500 hover:text-primary-800 hover:bg-transparent",onClick:l,children:[u.jsx(A,{icon:U,size:14,strokeWidth:1.8}),E?"No wrap":"Wrap"]}),u.jsxs(N,{variant:"ghost","aria-label":o??"Copy code",className:"h-auto px-0 text-xs font-medium text-primary-500 hover:text-primary-800 hover:bg-transparent",onClick:()=>{_().catch(()=>{})},children:[u.jsx(A,{icon:d?G:X,size:14,strokeWidth:1.8}),d?"Copied":"Copy"]})]})]}),y?u.jsx("div",{className:P("w-full min-w-0 max-w-full text-sm text-primary-900 overflow-x-hidden [&>pre]:w-full [&>pre]:min-w-0 [&>pre]:max-w-full [&>pre]:px-3 [&>pre]:py-3",E?"[&>pre]:whitespace-pre-wrap [&>pre]:break-words [&_.line]:whitespace-pre-wrap [&_.line]:break-words":"overflow-x-auto [&>pre]:whitespace-pre [&>pre]:overflow-x-auto",F&&"[&>pre]:[counter-reset:line] [&_.line]:before:content-[counter(line)] [&_.line]:before:[counter-increment:line] [&_.line]:before:inline-block [&_.line]:before:w-8 [&_.line]:before:mr-4 [&_.line]:before:text-right [&_.line]:before:select-none [&_.line]:before:text-primary-500/60"),dangerouslySetInnerHTML:{__html:y}}):u.jsx("pre",{className:P("w-full min-w-0 max-w-full text-sm px-3 py-3 overflow-x-auto",E?"whitespace-pre-wrap break-words":"whitespace-pre overflow-x-auto"),children:u.jsx("code",{className:"block",children:v})})]})}export{_e as C,K as p,re as r,de as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./main-
|
|
1
|
+
import{j as e}from"./main-B2CrcRuC.js";import{D as l,a as c,b as p,c as d,d as m}from"./use-file-explorer-state-BAa6Cxyr.js";import{B as x}from"./button-BciDmec0.js";import"./useOnFirstRender-DlXHIIGk.js";import"./useBaseUiId-DFpBD0sg.js";import"./event-BCwqPPkP.js";import"./visuallyHidden-COI6QeQH.js";import"./composite-DArWbFHm.js";import"./react-DWx7OvUo.js";const s=typeof navigator<"u"&&navigator.platform.toUpperCase().indexOf("MAC")>=0,h=[{keys:[s?"⌘":"Ctrl","K"],description:"Start a new chat"},{keys:[s?"⌘":"Ctrl","F"],description:"Search current conversation"},{keys:[s?"⌘":"Ctrl","Shift","F"],description:"Search all conversations"},{keys:[s?"⌘":"Ctrl","/"],description:"Focus message input"},{keys:["Esc"],description:"Close dialogs / Clear focus"},{keys:[s?"⌘":"Ctrl","Shift","C"],description:"Copy last response"},{keys:["?"],description:"Show this help dialog"}];function v({open:t,onOpenChange:a}){return e.jsx(l,{open:t,onOpenChange:a,children:e.jsx(c,{className:"w-[min(500px,92vw)]",children:e.jsxs("div",{className:"p-6",children:[e.jsx(p,{className:"mb-2",children:"Keyboard Shortcuts"}),e.jsx(d,{className:"mb-6",children:"Speed up your workflow with these keyboard shortcuts"}),e.jsx("div",{className:"space-y-3",children:h.map((r,o)=>e.jsxs("div",{className:"flex items-center justify-between py-2 border-b border-primary-100 last:border-0",children:[e.jsx("span",{className:"text-sm text-primary-700",children:r.description}),e.jsx("div",{className:"flex items-center gap-1",children:r.keys.map((n,i)=>e.jsxs("span",{className:"inline-flex items-center",children:[e.jsx("kbd",{className:"px-2 py-1 text-xs font-semibold text-primary-800 bg-primary-100 border border-primary-200 rounded",children:n}),i<r.keys.length-1&&e.jsx("span",{className:"mx-1 text-primary-400",children:"+"})]},i))})]},o))}),e.jsx("div",{className:"mt-6 flex justify-end",children:e.jsx(m,{children:e.jsx(x,{variant:"outline",children:"Close"})})})]})})})}export{v as KeyboardShortcutsDialog};
|