wiki-viewer 2.7.4 → 2.7.5

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.
Files changed (87) hide show
  1. package/.next/standalone/.next/BUILD_ID +1 -1
  2. package/.next/standalone/.next/build-manifest.json +3 -3
  3. package/.next/standalone/.next/prerender-manifest.json +3 -3
  4. package/.next/standalone/.next/required-server-files.json +3 -1
  5. package/.next/standalone/.next/server/app/_global-error.html +1 -1
  6. package/.next/standalone/.next/server/app/_global-error.rsc +1 -1
  7. package/.next/standalone/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
  8. package/.next/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  9. package/.next/standalone/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  10. package/.next/standalone/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  11. package/.next/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  12. package/.next/standalone/.next/server/app/_not-found.html +1 -1
  13. package/.next/standalone/.next/server/app/_not-found.rsc +1 -1
  14. package/.next/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +1 -1
  15. package/.next/standalone/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
  16. package/.next/standalone/.next/server/app/_not-found.segments/_index.segment.rsc +1 -1
  17. package/.next/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  18. package/.next/standalone/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
  19. package/.next/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
  20. package/.next/standalone/.next/server/app/api/agent/activity/route.js.nft.json +1 -1
  21. package/.next/standalone/.next/server/app/api/agent/events/[...path]/route.js.nft.json +1 -1
  22. package/.next/standalone/.next/server/app/api/agent/files/[...path]/route.js.nft.json +1 -1
  23. package/.next/standalone/.next/server/app/api/agent/fs/file/[...path]/route.js.nft.json +1 -1
  24. package/.next/standalone/.next/server/app/api/agent/fs/ls/[[...path]]/route.js.nft.json +1 -1
  25. package/.next/standalone/.next/server/app/api/agent/fs/move/route.js.nft.json +1 -1
  26. package/.next/standalone/.next/server/app/api/agent/fs/search/route.js.nft.json +1 -1
  27. package/.next/standalone/.next/server/app/api/agent/internal/span/route.js.nft.json +1 -1
  28. package/.next/standalone/.next/server/app/api/agent/settings/route.js.nft.json +1 -1
  29. package/.next/standalone/.next/server/app/api/agent/sidecar/[...path]/route.js.nft.json +1 -1
  30. package/.next/standalone/.next/server/app/api/assets/[...path]/route.js.nft.json +1 -1
  31. package/.next/standalone/.next/server/app/api/pdf/save/route.js.nft.json +1 -1
  32. package/.next/standalone/.next/server/app/api/share/[token]/asset/route.js.nft.json +1 -1
  33. package/.next/standalone/.next/server/app/api/share/[token]/route.js.nft.json +1 -1
  34. package/.next/standalone/.next/server/app/api/share/route.js.nft.json +1 -1
  35. package/.next/standalone/.next/server/app/api/system/reveal/route.js.nft.json +1 -1
  36. package/.next/standalone/.next/server/app/api/system/set-root/route.js.nft.json +1 -1
  37. package/.next/standalone/.next/server/app/api/system/workspaces/[id]/branch/route.js.nft.json +1 -1
  38. package/.next/standalone/.next/server/app/api/system/workspaces/[id]/open/route.js.nft.json +1 -1
  39. package/.next/standalone/.next/server/app/api/system/workspaces/[id]/refresh/route.js.nft.json +1 -1
  40. package/.next/standalone/.next/server/app/api/system/workspaces/[id]/route.js.nft.json +1 -1
  41. package/.next/standalone/.next/server/app/api/system/workspaces/route.js.nft.json +1 -1
  42. package/.next/standalone/.next/server/app/api/upload/[...path]/route.js.nft.json +1 -1
  43. package/.next/standalone/.next/server/app/api/wiki/app/route.js.nft.json +1 -1
  44. package/.next/standalone/.next/server/app/api/wiki/backlinks/route.js.nft.json +1 -1
  45. package/.next/standalone/.next/server/app/api/wiki/content/route.js.nft.json +1 -1
  46. package/.next/standalone/.next/server/app/api/wiki/download/route.js.nft.json +1 -1
  47. package/.next/standalone/.next/server/app/api/wiki/file/route.js.nft.json +1 -1
  48. package/.next/standalone/.next/server/app/api/wiki/folder/route.js.nft.json +1 -1
  49. package/.next/standalone/.next/server/app/api/wiki/git-branches/route.js.nft.json +1 -1
  50. package/.next/standalone/.next/server/app/api/wiki/git-checkout/route.js.nft.json +1 -1
  51. package/.next/standalone/.next/server/app/api/wiki/git-diff/route.js.nft.json +1 -1
  52. package/.next/standalone/.next/server/app/api/wiki/git-file-info/route.js.nft.json +1 -1
  53. package/.next/standalone/.next/server/app/api/wiki/git-history/route.js.nft.json +1 -1
  54. package/.next/standalone/.next/server/app/api/wiki/git-pull/route.js.nft.json +1 -1
  55. package/.next/standalone/.next/server/app/api/wiki/move/route.js.nft.json +1 -1
  56. package/.next/standalone/.next/server/app/api/wiki/new-file/route.js.nft.json +1 -1
  57. package/.next/standalone/.next/server/app/api/wiki/outlinks/route.js.nft.json +1 -1
  58. package/.next/standalone/.next/server/app/api/wiki/page/route.js.nft.json +1 -1
  59. package/.next/standalone/.next/server/app/api/wiki/presence/route.js.nft.json +1 -1
  60. package/.next/standalone/.next/server/app/api/wiki/route.js.nft.json +1 -1
  61. package/.next/standalone/.next/server/app/api/wiki/search/route.js.nft.json +1 -1
  62. package/.next/standalone/.next/server/app/api/wiki/slugs/route.js.nft.json +1 -1
  63. package/.next/standalone/.next/server/app/api/wiki/upload/route.js.nft.json +1 -1
  64. package/.next/standalone/.next/server/app/api/wiki/watch/route.js.nft.json +1 -1
  65. package/.next/standalone/.next/server/app/index.html +1 -1
  66. package/.next/standalone/.next/server/app/index.rsc +2 -2
  67. package/.next/standalone/.next/server/app/index.segments/__PAGE__.segment.rsc +2 -2
  68. package/.next/standalone/.next/server/app/index.segments/_full.segment.rsc +2 -2
  69. package/.next/standalone/.next/server/app/index.segments/_head.segment.rsc +1 -1
  70. package/.next/standalone/.next/server/app/index.segments/_index.segment.rsc +1 -1
  71. package/.next/standalone/.next/server/app/index.segments/_tree.segment.rsc +1 -1
  72. package/.next/standalone/.next/server/app/page_client-reference-manifest.js +1 -1
  73. package/.next/standalone/.next/server/chunks/ssr/_0v4uz-4._.js +1 -1
  74. package/.next/standalone/.next/server/middleware-build-manifest.js +3 -3
  75. package/.next/standalone/.next/server/middleware-manifest.json +5 -5
  76. package/.next/standalone/.next/server/pages/404.html +1 -1
  77. package/.next/standalone/.next/server/pages/500.html +1 -1
  78. package/.next/standalone/.next/server/server-reference-manifest.js +1 -1
  79. package/.next/standalone/.next/server/server-reference-manifest.json +1 -1
  80. package/.next/standalone/.next/static/chunks/{0p1blx45umac6.js → 0i-0jdw7dtj9c.js} +2 -2
  81. package/.next/standalone/next.config.ts +5 -0
  82. package/.next/standalone/package.json +1 -1
  83. package/.next/standalone/server.js +1 -1
  84. package/package.json +1 -1
  85. /package/.next/standalone/.next/static/{FGEHouLkusE6SPcSxOC3u → w6zxJ1-lNNl0jldTTzyLC}/_buildManifest.js +0 -0
  86. /package/.next/standalone/.next/static/{FGEHouLkusE6SPcSxOC3u → w6zxJ1-lNNl0jldTTzyLC}/_clientMiddlewareManifest.js +0 -0
  87. /package/.next/standalone/.next/static/{FGEHouLkusE6SPcSxOC3u → w6zxJ1-lNNl0jldTTzyLC}/_ssgManifest.js +0 -0
@@ -14,6 +14,6 @@ TOKEN=<paste token here>
14
14
  # 3. Read snapshot
15
15
  curl -s -H "Authorization: Bearer $TOKEN" \\
16
16
  -H "X-Agent-Id: ai:claude" \\
17
- ${b}/api/agent/files/${a??"<path/to/file.md>"}`;await navigator.clipboard.writeText(d),c(!0),setTimeout(()=>c(!1),1500)},[a])}}(a??null),[m,n]=(0,T.useState)(""),o=(0,T.useRef)(null),p="http://localhost:3000",q=(0,T.useCallback)(()=>de,[]),r=(0,T.useCallback)(()=>m.replace(/\$WIKI_URL/g,p),[m,p]),s=(0,T.useCallback)(()=>`npx wiki-viewer-mcp register --url ${p} --id ai:myagent --name "My Agent"`,[p]),t=(0,T.useCallback)(()=>JSON.stringify({servers:{"wiki-viewer":{command:"npx",args:["wiki-viewer-mcp"],env:{WIKI_VIEWER_URL:p,WIKI_VIEWER_TOKEN:"<token from register>",WIKI_VIEWER_AGENT_ID:"ai:myagent"}}}},null,2),[p]),u=df(q),v=df(r),w=df(s),x=df(t);return((0,T.useEffect)(()=>{if(c)return document.addEventListener("keydown",a),()=>document.removeEventListener("keydown",a);function a(a){"Escape"===a.key&&d()}},[c,d]),(0,T.useEffect)(()=>{c&&o.current?.focus()},[c]),(0,T.useEffect)(()=>{if(!c)return;j();let a=setInterval(()=>void j(),1e4);return()=>clearInterval(a)},[c,j]),(0,T.useEffect)(()=>{c&&fetch("/api/agents/install").then(a=>a.json()).then(a=>{a.bootstrapPrompt&&n(a.bootstrapPrompt)}).catch(()=>void 0)},[c]),c)?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)("div",{className:"fixed inset-0 z-40 bg-overlay backdrop-blur-[1px]",onClick:d,"aria-hidden":!0}),(0,b.jsxs)("aside",{ref:o,tabIndex:-1,role:"dialog","aria-modal":"true","aria-label":"AI Agent Panel",className:"fixed right-0 top-0 bottom-0 z-50 flex w-[90vw] max-w-sm md:w-80 flex-col border-l border-border bg-background shadow-xl outline-none",children:[(0,b.jsxs)("div",{className:"flex items-center justify-between border-b border-border px-4 py-3 shrink-0",children:[(0,b.jsxs)("div",{className:"flex items-center gap-2",children:[(0,b.jsx)(e,{className:"h-4 w-4 text-muted-foreground"}),(0,b.jsx)("span",{className:"text-sm font-semibold",children:"AI Agent"})]}),(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",onClick:d,title:"Close panel (Esc)",children:(0,b.jsx)(S.X,{className:"h-3.5 w-3.5"})})]}),(0,b.jsxs)("div",{className:"flex-1 overflow-y-auto space-y-5 px-4 py-4",children:[(0,b.jsxs)("section",{className:"rounded-md border border-border bg-muted/30 p-3",children:[(0,b.jsx)("p",{className:"text-sm font-medium text-foreground",children:"Work with this wiki using AI"}),(0,b.jsxs)("p",{className:"mt-1 text-xs leading-relaxed text-muted-foreground",children:["Connect Claude, Cursor, ChatGPT, and more. Pick by what you want — each option gives a copy-paste setup. You approve every assistant in ",(0,b.jsx)("span",{className:"font-medium text-foreground/80",children:"Agents"})," below before it gets access."]})]}),(0,b.jsxs)("section",{className:"space-y-3",children:[(0,b.jsxs)("div",{className:"rounded-md border border-border bg-muted/40 p-3 space-y-1.5",children:[(0,b.jsx)("p",{className:"text-xs font-semibold text-foreground",children:"Co-write docs with you"}),(0,b.jsx)("p",{className:"text-[10px] text-muted-foreground/70",children:"Edits arrive as suggestions with comments you accept or revert. No MCP needed."}),(0,b.jsx)(U.Button,{size:"sm",variant:"outline",className:"h-7 w-full text-xs gap-1.5",onClick:()=>void v.copy(),disabled:!m,children:v.copied?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(f.Check,{className:"h-3.5 w-3.5 text-green-500"})," Copied!"]}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(i.Copy,{className:"h-3.5 w-3.5"})," Paste into any chatbot"]})}),(0,b.jsxs)("p",{className:"text-[10px] text-muted-foreground/50 pt-1",children:["Or install once so it sticks"," ",(0,b.jsx)("span",{className:"text-muted-foreground/40",children:"· Claude, OpenCode"}),":"]}),(0,b.jsxs)("div",{className:"flex items-center gap-2",children:[(0,b.jsx)("code",{className:"flex-1 text-[10px] font-mono text-foreground/80 truncate bg-muted rounded px-1 py-0.5",children:de}),(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0 shrink-0",title:"Copy this command",onClick:()=>void u.copy(),children:u.copied?(0,b.jsx)(f.Check,{className:"h-3.5 w-3.5 text-green-500"}):(0,b.jsx)(i.Copy,{className:"h-3.5 w-3.5"})})]})]}),(0,b.jsxs)("div",{className:"rounded-md border border-border bg-muted/40 p-3 space-y-1.5",children:[(0,b.jsxs)("p",{className:"text-xs font-semibold text-foreground",children:["Edit files directly"," ",(0,b.jsx)("span",{className:"font-normal text-muted-foreground/60",children:"· Claude Code, Cursor, Codex"})]}),(0,b.jsx)("p",{className:"text-[10px] text-muted-foreground/70",children:"Native read / search / edit tools over MCP. Run to request access:"}),(0,b.jsxs)("div",{className:"flex items-center gap-2",children:[(0,b.jsx)("code",{className:"flex-1 text-[10px] font-mono text-foreground/80 truncate bg-muted rounded px-1 py-0.5",children:s()}),(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0 shrink-0",title:"Copy this command",onClick:()=>void w.copy(),children:w.copied?(0,b.jsx)(f.Check,{className:"h-3.5 w-3.5 text-green-500"}):(0,b.jsx)(i.Copy,{className:"h-3.5 w-3.5"})})]}),(0,b.jsxs)("p",{className:"text-[10px] text-muted-foreground/50",children:["Approve in ",(0,b.jsx)("span",{className:"font-medium text-foreground/70",children:"Agents"}),", then add to your tool:"]}),(0,b.jsx)(U.Button,{size:"sm",variant:"outline",className:"h-7 w-full text-xs gap-1.5",onClick:()=>void x.copy(),children:x.copied?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(f.Check,{className:"h-3.5 w-3.5 text-green-500"})," Copied!"]}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(i.Copy,{className:"h-3.5 w-3.5"})," Copy config (mcp.json)"]})})]}),(0,b.jsxs)("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1",children:[(0,b.jsx)("span",{className:"text-[10px] text-muted-foreground/50",children:"For developers:"}),(0,b.jsxs)("button",{type:"button",onClick:()=>void l(),className:"inline-flex items-center gap-1 text-[10px] text-primary hover:underline",children:[k?(0,b.jsx)(f.Check,{className:"h-3 w-3 text-green-500"}):(0,b.jsx)(i.Copy,{className:"h-3 w-3"})," curl example"]}),(0,b.jsxs)("a",{href:"/api/agents/skill",target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1 text-[10px] text-primary hover:underline",children:[(0,b.jsx)(ae.ExternalLink,{className:"h-3 w-3"})," skill"]}),(0,b.jsxs)("a",{href:"/api/agents/install",target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1 text-[10px] text-primary hover:underline",children:[(0,b.jsx)(ae.ExternalLink,{className:"h-3 w-3"})," install JSON"]})]})]}),(0,b.jsx)(c7,{}),(0,b.jsxs)("section",{className:"space-y-2",children:[(0,b.jsxs)("h3",{className:"text-xs font-semibold uppercase tracking-widest text-muted-foreground",children:["Active Connections"," ",(0,b.jsx)("span",{className:"normal-case font-normal text-muted-foreground/50",children:"(last 5 min)"})]}),(0,b.jsx)("div",{className:"rounded-md border border-border bg-muted/40 p-3",children:0===h.length?(0,b.jsxs)("p",{className:"text-xs text-muted-foreground/60 flex items-center gap-1.5",children:[(0,b.jsx)(c$,{className:"h-3.5 w-3.5"}),"No recent activity"]}):(0,b.jsx)("ul",{className:"space-y-1.5",children:h.map(a=>(0,b.jsxs)("li",{className:"flex items-center justify-between text-xs",children:[(0,b.jsx)("span",{className:"font-mono text-foreground/80 truncate",children:a.by}),(0,b.jsxs)("span",{className:"text-muted-foreground shrink-0",children:[a.opCount," op",1!==a.opCount?"s":""]})]},a.by))})})]}),(0,b.jsxs)("section",{className:"space-y-2",children:[(0,b.jsx)("h3",{className:"text-xs font-semibold uppercase tracking-widest text-muted-foreground",children:"Recent Activity"}),(0,b.jsx)("div",{className:"rounded-md border border-border bg-muted/40 px-3 py-2 max-h-72 overflow-y-auto",children:(0,b.jsx)(dd,{activity:g})})]}),(0,b.jsx)("section",{children:(0,b.jsx)("a",{href:"/docs/agent-collab-plan.md",target:"_blank",rel:"noreferrer",className:"text-xs text-primary underline hover:no-underline",children:"Agent collaboration docs →"})})]})]})]}):null}var dh=a.i(503442),di=a.i(670576),dj=/[\\\/_+.#"@\[\(\{&]/,dk=/[\\\/_+.#"@\[\(\{&]/g,dl=/[\s-]/,dm=/[\s-]/g;function dn(a){return a.toLowerCase().replace(dm," ")}var dp=a.i(105305),dq=a.i(359231),dr='[cmdk-group=""]',ds='[cmdk-group-items=""]',dt='[cmdk-item=""]',du=`${dt}:not([aria-disabled="true"])`,dv="cmdk-item-select",dw="data-value",dx=(a,b,c)=>{var d;return d=a,function a(b,c,d,e,f,g,h){if(g===c.length)return f===b.length?1:.99;var i=`${f},${g}`;if(void 0!==h[i])return h[i];for(var j,k,l,m,n=e.charAt(g),o=d.indexOf(n,f),p=0;o>=0;)(j=a(b,c,d,e,o+1,g+1,h))>p&&(o===f?j*=1:dj.test(b.charAt(o-1))?(j*=.8,(l=b.slice(f,o-1).match(dk))&&f>0&&(j*=Math.pow(.999,l.length))):dl.test(b.charAt(o-1))?(j*=.9,(m=b.slice(f,o-1).match(dm))&&f>0&&(j*=Math.pow(.999,m.length))):(j*=.17,f>0&&(j*=Math.pow(.999,o-f))),b.charAt(o)!==c.charAt(g)&&(j*=.9999)),(j<.1&&d.charAt(o-1)===e.charAt(g+1)||e.charAt(g+1)===e.charAt(g)&&d.charAt(o-1)!==e.charAt(g))&&.1*(k=a(b,c,d,e,o+1,g+2,h))>j&&(j=.1*k),j>p&&(p=j),o=d.indexOf(n,o+1);return h[i]=p,p}(d=c&&c.length>0?`${d+" "+c.join(" ")}`:d,b,dn(d),dn(b),0,0,{})},dy=T.createContext(void 0),dz=T.createContext(void 0),dA=T.createContext(void 0),dB=T.forwardRef((a,b)=>{let c=dL(()=>{var b,c;return{search:"",value:null!=(c=null!=(b=a.value)?b:a.defaultValue)?c:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),d=dL(()=>new Set),e=dL(()=>new Map),f=dL(()=>new Map),g=dL(()=>new Set),h=dJ(a),{label:i,children:j,value:k,onValueChange:l,filter:m,shouldFilter:n,loop:o,disablePointerSelection:p=!1,vimBindings:q=!0,...r}=a,s=(0,dq.useId)(),t=(0,dq.useId)(),u=(0,dq.useId)(),v=T.useRef(null),w=dO();dK(()=>{if(void 0!==k){let a=k.trim();c.current.value=a,x.emit()}},[k]),dK(()=>{w(6,D)},[]);let x=T.useMemo(()=>({subscribe:a=>(g.current.add(a),()=>g.current.delete(a)),snapshot:()=>c.current,setState:(a,b,d)=>{var e,f,g,i;if(!Object.is(c.current[a],b)){if(c.current[a]=b,"search"===a)C(),A(),w(1,B);else if("value"===a){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let a=document.getElementById(u);a?a.focus():null==(e=document.getElementById(s))||e.focus()}if(w(7,()=>{var a;c.current.selectedItemId=null==(a=E())?void 0:a.id,x.emit()}),d||w(5,D),(null==(f=h.current)?void 0:f.value)!==void 0){null==(i=(g=h.current).onValueChange)||i.call(g,null!=b?b:"");return}}x.emit()}},emit:()=>{g.current.forEach(a=>a())}}),[]),y=T.useMemo(()=>({value:(a,b,d)=>{var e;b!==(null==(e=f.current.get(a))?void 0:e.value)&&(f.current.set(a,{value:b,keywords:d}),c.current.filtered.items.set(a,z(b,d)),w(2,()=>{A(),x.emit()}))},item:(a,b)=>(d.current.add(a),b&&(e.current.has(b)?e.current.get(b).add(a):e.current.set(b,new Set([a]))),w(3,()=>{C(),A(),c.current.value||B(),x.emit()}),()=>{f.current.delete(a),d.current.delete(a),c.current.filtered.items.delete(a);let b=E();w(4,()=>{C(),(null==b?void 0:b.getAttribute("id"))===a&&B(),x.emit()})}),group:a=>(e.current.has(a)||e.current.set(a,new Set),()=>{f.current.delete(a),e.current.delete(a)}),filter:()=>h.current.shouldFilter,label:i||a["aria-label"],getDisablePointerSelection:()=>h.current.disablePointerSelection,listId:s,inputId:u,labelId:t,listInnerRef:v}),[]);function z(a,b){var d,e;let f=null!=(e=null==(d=h.current)?void 0:d.filter)?e:dx;return a?f(a,c.current.search,b):0}function A(){if(!c.current.search||!1===h.current.shouldFilter)return;let a=c.current.filtered.items,b=[];c.current.filtered.groups.forEach(c=>{let d=e.current.get(c),f=0;d.forEach(b=>{f=Math.max(a.get(b),f)}),b.push([c,f])});let d=v.current;F().sort((b,c)=>{var d,e;let f=b.getAttribute("id"),g=c.getAttribute("id");return(null!=(d=a.get(g))?d:0)-(null!=(e=a.get(f))?e:0)}).forEach(a=>{let b=a.closest(ds);b?b.appendChild(a.parentElement===b?a:a.closest(`${ds} > *`)):d.appendChild(a.parentElement===d?a:a.closest(`${ds} > *`))}),b.sort((a,b)=>b[1]-a[1]).forEach(a=>{var b;let c=null==(b=v.current)?void 0:b.querySelector(`${dr}[${dw}="${encodeURIComponent(a[0])}"]`);null==c||c.parentElement.appendChild(c)})}function B(){let a=F().find(a=>"true"!==a.getAttribute("aria-disabled")),b=null==a?void 0:a.getAttribute(dw);x.setState("value",b||void 0)}function C(){var a,b,g,i;if(!c.current.search||!1===h.current.shouldFilter){c.current.filtered.count=d.current.size;return}c.current.filtered.groups=new Set;let j=0;for(let e of d.current){let d=z(null!=(b=null==(a=f.current.get(e))?void 0:a.value)?b:"",null!=(i=null==(g=f.current.get(e))?void 0:g.keywords)?i:[]);c.current.filtered.items.set(e,d),d>0&&j++}for(let[a,b]of e.current)for(let d of b)if(c.current.filtered.items.get(d)>0){c.current.filtered.groups.add(a);break}c.current.filtered.count=j}function D(){var a,b,c;let d=E();d&&((null==(a=d.parentElement)?void 0:a.firstChild)===d&&(null==(c=null==(b=d.closest(dr))?void 0:b.querySelector('[cmdk-group-heading=""]'))||c.scrollIntoView({block:"nearest"})),d.scrollIntoView({block:"nearest"}))}function E(){var a;return null==(a=v.current)?void 0:a.querySelector(`${dt}[aria-selected="true"]`)}function F(){var a;return Array.from((null==(a=v.current)?void 0:a.querySelectorAll(du))||[])}function G(a){let b=F()[a];b&&x.setState("value",b.getAttribute(dw))}function H(a){var b;let c=E(),d=F(),e=d.findIndex(a=>a===c),f=d[e+a];null!=(b=h.current)&&b.loop&&(f=e+a<0?d[d.length-1]:e+a===d.length?d[0]:d[e+a]),f&&x.setState("value",f.getAttribute(dw))}function I(a){let b=E(),c=null==b?void 0:b.closest(dr),d;for(;c&&!d;)d=null==(c=a>0?function(a,b){let c=a.nextElementSibling;for(;c;){if(c.matches(b))return c;c=c.nextElementSibling}}(c,dr):function(a,b){let c=a.previousElementSibling;for(;c;){if(c.matches(b))return c;c=c.previousElementSibling}}(c,dr))?void 0:c.querySelector(du);d?x.setState("value",d.getAttribute(dw)):H(a)}let J=()=>G(F().length-1),K=a=>{a.preventDefault(),a.metaKey?J():a.altKey?I(1):H(1)},L=a=>{a.preventDefault(),a.metaKey?G(0):a.altKey?I(-1):H(-1)};return T.createElement(dp.Primitive.div,{ref:b,tabIndex:-1,...r,"cmdk-root":"",onKeyDown:a=>{var b;null==(b=r.onKeyDown)||b.call(r,a);let c=a.nativeEvent.isComposing||229===a.keyCode;if(!(a.defaultPrevented||c))switch(a.key){case"n":case"j":q&&a.ctrlKey&&K(a);break;case"ArrowDown":K(a);break;case"p":case"k":q&&a.ctrlKey&&L(a);break;case"ArrowUp":L(a);break;case"Home":a.preventDefault(),G(0);break;case"End":a.preventDefault(),J();break;case"Enter":{a.preventDefault();let b=E();if(b){let a=new Event(dv);b.dispatchEvent(a)}}}}},T.createElement("label",{"cmdk-label":"",htmlFor:y.inputId,id:y.labelId,style:dQ},i),dP(a,a=>T.createElement(dz.Provider,{value:x},T.createElement(dy.Provider,{value:y},a))))}),dC=T.forwardRef((a,b)=>{var c,d;let e=(0,dq.useId)(),f=T.useRef(null),g=T.useContext(dA),h=T.useContext(dy),i=dJ(a),j=null!=(d=null==(c=i.current)?void 0:c.forceMount)?d:null==g?void 0:g.forceMount;dK(()=>{if(!j)return h.item(e,null==g?void 0:g.id)},[j]);let k=dN(e,f,[a.value,a.children,f],a.keywords),l=T.useContext(dz),m=dM(a=>a.value&&a.value===k.current),n=dM(a=>!!j||!1===h.filter()||!a.search||a.filtered.items.get(e)>0);function o(){var a,b;p(),null==(b=(a=i.current).onSelect)||b.call(a,k.current)}function p(){l.setState("value",k.current,!0)}if(T.useEffect(()=>{let b=f.current;if(!(!b||a.disabled))return b.addEventListener(dv,o),()=>b.removeEventListener(dv,o)},[n,a.onSelect,a.disabled]),!n)return null;let{disabled:q,value:r,onSelect:s,forceMount:t,keywords:u,...v}=a;return T.createElement(dp.Primitive.div,{ref:(0,ce.composeRefs)(f,b),...v,id:e,"cmdk-item":"",role:"option","aria-disabled":!!q,"aria-selected":!!m,"data-disabled":!!q,"data-selected":!!m,onPointerMove:q||h.getDisablePointerSelection()?void 0:p,onClick:q?void 0:o},a.children)}),dD=T.forwardRef((a,b)=>{let{heading:c,children:d,forceMount:e,...f}=a,g=(0,dq.useId)(),h=T.useRef(null),i=T.useRef(null),j=(0,dq.useId)(),k=T.useContext(dy),l=dM(a=>!!e||!1===k.filter()||!a.search||a.filtered.groups.has(g));dK(()=>k.group(g),[]),dN(g,h,[a.value,a.heading,i]);let m=T.useMemo(()=>({id:g,forceMount:e}),[e]);return T.createElement(dp.Primitive.div,{ref:(0,ce.composeRefs)(h,b),...f,"cmdk-group":"",role:"presentation",hidden:!l||void 0},c&&T.createElement("div",{ref:i,"cmdk-group-heading":"","aria-hidden":!0,id:j},c),dP(a,a=>T.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":c?j:void 0},T.createElement(dA.Provider,{value:m},a))))}),dE=T.forwardRef((a,b)=>{let{alwaysRender:c,...d}=a,e=T.useRef(null),f=dM(a=>!a.search);return c||f?T.createElement(dp.Primitive.div,{ref:(0,ce.composeRefs)(e,b),...d,"cmdk-separator":"",role:"separator"}):null}),dF=T.forwardRef((a,b)=>{let{onValueChange:c,...d}=a,e=null!=a.value,f=T.useContext(dz),g=dM(a=>a.search),h=dM(a=>a.selectedItemId),i=T.useContext(dy);return T.useEffect(()=>{null!=a.value&&f.setState("search",a.value)},[a.value]),T.createElement(dp.Primitive.input,{ref:b,...d,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":i.listId,"aria-labelledby":i.labelId,"aria-activedescendant":h,id:i.inputId,type:"text",value:e?a.value:g,onChange:a=>{e||f.setState("search",a.target.value),null==c||c(a.target.value)}})}),dG=T.forwardRef((a,b)=>{let{children:c,label:d="Suggestions",...e}=a,f=T.useRef(null),g=T.useRef(null),h=dM(a=>a.selectedItemId),i=T.useContext(dy);return T.useEffect(()=>{if(g.current&&f.current){let a=g.current,b=f.current,c,d=new ResizeObserver(()=>{c=requestAnimationFrame(()=>{let c=a.offsetHeight;b.style.setProperty("--cmdk-list-height",c.toFixed(1)+"px")})});return d.observe(a),()=>{cancelAnimationFrame(c),d.unobserve(a)}}},[]),T.createElement(dp.Primitive.div,{ref:(0,ce.composeRefs)(f,b),...e,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":h,"aria-label":d,id:i.listId},dP(a,a=>T.createElement("div",{ref:(0,ce.composeRefs)(g,i.listInnerRef),"cmdk-list-sizer":""},a)))}),dH=T.forwardRef((a,b)=>{let{open:c,onOpenChange:d,overlayClassName:e,contentClassName:f,container:g,...h}=a;return T.createElement(bU.Root,{open:c,onOpenChange:d},T.createElement(bU.Portal,{container:g},T.createElement(bU.Overlay,{"cmdk-overlay":"",className:e}),T.createElement(bU.Content,{"aria-label":a.label,"cmdk-dialog":"",className:f},T.createElement(dB,{ref:b,...h}))))}),dI=Object.assign(dB,{List:dG,Item:dC,Input:dF,Group:dD,Separator:dE,Dialog:dH,Empty:T.forwardRef((a,b)=>dM(a=>0===a.filtered.count)?T.createElement(dp.Primitive.div,{ref:b,...a,"cmdk-empty":"",role:"presentation"}):null),Loading:T.forwardRef((a,b)=>{let{progress:c,children:d,label:e="Loading...",...f}=a;return T.createElement(dp.Primitive.div,{ref:b,...f,"cmdk-loading":"",role:"progressbar","aria-valuenow":c,"aria-valuemin":0,"aria-valuemax":100,"aria-label":e},dP(a,a=>T.createElement("div",{"aria-hidden":!0},a)))})});function dJ(a){let b=T.useRef(a);return dK(()=>{b.current=a}),b}var dK=T.useEffect;function dL(a){let b=T.useRef();return void 0===b.current&&(b.current=a()),b}function dM(a){let b=T.useContext(dz),c=()=>a(b.snapshot());return T.useSyncExternalStore(b.subscribe,c,c)}function dN(a,b,c,d=[]){let e=T.useRef(),f=T.useContext(dy);return dK(()=>{var g;let h=(()=>{var a;for(let b of c){if("string"==typeof b)return b.trim();if("object"==typeof b&&"current"in b)return b.current?null==(a=b.current.textContent)?void 0:a.trim():e.current}})(),i=d.map(a=>a.trim());f.value(a,h,i),null==(g=b.current)||g.setAttribute(dw,h),e.current=h}),e}var dO=()=>{let[a,b]=T.useState(),c=dL(()=>new Map);return dK(()=>{c.current.forEach(a=>a()),c.current=new Map},[a]),(a,d)=>{c.current.set(a,d),b({})}};function dP({asChild:a,children:b},c){let d;return a&&T.isValidElement(b)?T.cloneElement("function"==typeof(d=b.type)?d(b.props):"render"in d?d.render(b.props):b,{ref:b.ref},c(b.props.children)):c(b)}var dQ={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};let dR=(0,d.default)("search",[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]),dS=T.forwardRef(({className:a,...c},d)=>(0,b.jsx)(dI,{ref:d,className:(0,Z.cn)("flex h-full w-full flex-col overflow-hidden rounded-sm bg-popover text-popover-foreground",a),...c}));function dT({children:a,shouldFilter:c,...d}){return(0,b.jsx)(V.Dialog,{...d,children:(0,b.jsxs)(V.DialogContent,{className:"overflow-hidden p-0 shadow-golden max-w-lg",children:[(0,b.jsx)(V.DialogTitle,{className:"sr-only",children:"Search"}),(0,b.jsx)(dS,{shouldFilter:c,className:"[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-normal [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group]]:px-2 [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5",children:a})]})})}dS.displayName=dI.displayName;let dU=T.forwardRef(({className:a,...c},d)=>(0,b.jsxs)("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[(0,b.jsx)(dR,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),(0,b.jsx)(dI.Input,{ref:d,className:(0,Z.cn)("flex h-11 w-full rounded-sm bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",a),...c})]}));dU.displayName=dI.Input.displayName;let dV=T.forwardRef(({className:a,...c},d)=>(0,b.jsx)(dI.List,{ref:d,className:(0,Z.cn)("max-h-[300px] overflow-y-auto overflow-x-hidden",a),...c}));dV.displayName=dI.List.displayName;let dW=T.forwardRef((a,c)=>(0,b.jsx)(dI.Empty,{ref:c,className:"py-6 text-center text-sm text-muted-foreground",...a}));dW.displayName=dI.Empty.displayName;let dX=T.forwardRef(({className:a,...c},d)=>(0,b.jsx)(dI.Group,{ref:d,className:(0,Z.cn)("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-normal [&_[cmdk-group-heading]]:text-muted-foreground",a),...c}));dX.displayName=dI.Group.displayName;let dY=T.forwardRef(({className:a,...c},d)=>(0,b.jsx)(dI.Separator,{ref:d,className:(0,Z.cn)("-mx-1 h-px bg-border",a),...c}));dY.displayName=dI.Separator.displayName;let dZ=T.forwardRef(({className:a,...c},d)=>(0,b.jsx)(dI.Item,{ref:d,className:(0,Z.cn)("relative flex cursor-default gap-2 select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",a),...c}));dZ.displayName=dI.Item.displayName;let d$=null,d_=null,d0=(0,b1.create)(a=>({query:"",results:[],loading:!1,truncated:!1,open:!1,setQuery:b=>a({query:b}),setOpen:b=>a({open:b}),clear:()=>{d_&&clearTimeout(d_),d$?.abort(),a({query:"",results:[],loading:!1,truncated:!1})},search:b=>(d_&&clearTimeout(d_),b.trim())?(a({loading:!0}),new Promise(c=>{d_=setTimeout(()=>{d1(a,b).finally(c)},150)})):(d$?.abort(),a({results:[],loading:!1,truncated:!1}),Promise.resolve())}));async function d1(a,b){d$?.abort();let c=new AbortController;d$=c;try{let d=await (0,Y.wsFetch)("/api/wiki/search",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:b,limit:30}),signal:c.signal});if(!d.ok)return void a({results:[],loading:!1,truncated:!1});let e=await d.json();if(c.signal.aborted)return;a({results:e.matches??[],truncated:!!e.truncated,loading:!1})}catch(b){"AbortError"!==b.name&&a({loading:!1})}}var d2=a.i(713033);function d3({html:a}){let c=function(a){let b,c=[],d=/<mark>([\s\S]*?)<\/mark>/g,e=0;for(;null!==(b=d.exec(a));)b.index>e&&c.push({text:a.slice(e,b.index),mark:!1}),c.push({text:b[1]??"",mark:!0}),e=b.index+b[0].length;return e<a.length&&c.push({text:a.slice(e),mark:!1}),c}(a);return(0,b.jsx)(b.Fragment,{children:c.map((a,c)=>a.mark?(0,b.jsx)("mark",{className:"bg-yellow-200 dark:bg-yellow-700 rounded-[2px] px-[1px]",children:a.text},c):(0,b.jsx)("span",{children:a.text},c))})}function d4({onOpenFile:a,recents:c=[],onToggleSidebar:d=()=>void 0,onNewFile:f=()=>void 0,onCopyPath:g=()=>void 0}){let h=d0(a=>a.open),j=d0(a=>a.setOpen),k=d0(a=>a.query),l=d0(a=>a.setQuery),n=d0(a=>a.results),o=d0(a=>a.loading),p=d0(a=>a.truncated),q=d0(a=>a.search),{resolvedTheme:r,setTheme:s}=(0,bT.useTheme)(),t=(0,c_.useAIPanelStore)(a=>a.toggle),u=(0,d2.useViewWidthStore)(a=>a.width),v=(0,d2.useViewWidthStore)(a=>a.cycle),w=k.trimStart(),x=""===w||w.startsWith(">"),y=""===w&&c.length>0,z=x?"":k;function A(a){a(),j(!1),l("")}(0,T.useEffect)(()=>{function a(a){(a.metaKey||a.ctrlKey)&&"k"===a.key.toLowerCase()&&(a.preventDefault(),j(!h))}return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[h,j]),(0,T.useEffect)(()=>{if(!h||x)return;let a=setTimeout(()=>{q(z)},120);return()=>clearTimeout(a)},[z,x,h,q]);let B=(d2.VIEW_WIDTH_ORDER.indexOf(u)+1)%d2.VIEW_WIDTH_ORDER.length,D=d2.VIEW_WIDTH_LABEL[d2.VIEW_WIDTH_ORDER[B]];return(0,b.jsxs)(dT,{open:h,onOpenChange:a=>{j(a),a||l("")},shouldFilter:!1,children:[(0,b.jsx)(dU,{placeholder:"Search files… ( > for actions )",value:k,onValueChange:l}),(0,b.jsxs)(dV,{children:[y&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(dX,{heading:"Recent",children:c.map(c=>(0,b.jsxs)(dZ,{value:`recent:${c.path}`,onSelect:()=>{a(c.path),j(!1),l("")},children:[(0,b.jsx)(cb,{className:"mr-2 h-4 w-4"}),(0,b.jsxs)("div",{className:"flex min-w-0 flex-col gap-0.5",children:[(0,b.jsx)("span",{className:"truncate font-medium",children:c.name}),(0,b.jsx)("span",{className:"truncate text-xs text-muted-foreground",children:c.path})]})]},c.path))}),(0,b.jsx)(dY,{})]}),x&&(0,b.jsxs)(dX,{heading:"Actions",children:[(0,b.jsxs)(dZ,{value:"toggle-dark-mode",onSelect:()=>A(()=>s("dark"===r?"light":"dark")),children:["dark"===r?(0,b.jsx)(N.Sun,{className:"mr-2 h-4 w-4"}):(0,b.jsx)(C.Moon,{className:"mr-2 h-4 w-4"}),"dark"===r?"Switch to light mode":"Switch to dark mode"]}),(0,b.jsxs)(dZ,{value:"toggle-ai-panel",onSelect:()=>A(t),children:[(0,b.jsx)(e,{className:"mr-2 h-4 w-4"}),"Toggle AI panel"]}),(0,b.jsxs)(dZ,{value:"toggle-sidebar",onSelect:()=>A(d),children:[(0,b.jsx)(di.PanelLeft,{className:"mr-2 h-4 w-4"}),"Toggle sidebar"]}),(0,b.jsxs)(dZ,{value:"new-file",onSelect:()=>A(f),children:[(0,b.jsx)(m.FilePlus,{className:"mr-2 h-4 w-4"}),"New file"]}),(0,b.jsxs)(dZ,{value:"copy-path",onSelect:()=>A(g),children:[(0,b.jsx)(i.Copy,{className:"mr-2 h-4 w-4"}),"Copy current file path"]}),(0,b.jsxs)(dZ,{value:"cycle-view-width",onSelect:()=>A(v),children:[(0,b.jsx)(dh.AlignCenter,{className:"mr-2 h-4 w-4"}),(0,b.jsxs)("span",{children:["Change view width"," ",(0,b.jsxs)("span",{className:"text-muted-foreground",children:["(",d2.VIEW_WIDTH_LABEL[u]," → ",D,")"]})]})]})]}),!x&&(0,b.jsxs)(b.Fragment,{children:[o&&(0,b.jsx)("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:"Searching…"}),!o&&""!==z.trim()&&0===n.length&&(0,b.jsx)(dW,{children:"No matches."}),n.length>0&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(dY,{}),(0,b.jsx)(dX,{heading:p?"Top results (refine query for more)":"Results",children:n.map(c=>(0,b.jsx)(dZ,{value:c.path,onSelect:()=>{a(c.path),j(!1),l("")},children:(0,b.jsxs)("div",{className:"flex min-w-0 flex-col gap-0.5",children:[(0,b.jsx)("span",{className:"truncate font-mono text-xs",children:c.path}),c.snippet&&(0,b.jsx)("span",{className:"truncate text-xs text-muted-foreground",children:(0,b.jsx)(d3,{html:c.snippet})})]})},c.path))})]})]})]})]})}function d5({onOpenFile:a}){let c=d0(a=>a.query),d=d0(a=>a.setQuery),e=d0(a=>a.results),f=d0(a=>a.loading),g=d0(a=>a.search),h=d0(a=>a.clear),[i,j]=(0,T.useState)(0),k=(0,T.useRef)(null);function l(b){let c=e[b];c&&(a(c.path),h())}return(0,T.useEffect)(()=>{j(0)},[e]),(0,T.useEffect)(()=>{let a=k.current?.querySelector(`[data-idx="${i}"]`);a?.scrollIntoView({block:"nearest"})},[i]),(0,b.jsxs)("div",{className:"flex flex-col gap-1 px-2 py-1.5",children:[(0,b.jsxs)("div",{className:"relative",children:[(0,b.jsx)(dR,{className:"pointer-events-none absolute left-2 top-1/2 h-3.5 w-3.5 -translate-y-1/2 opacity-50"}),(0,b.jsx)("input",{type:"text",className:"w-full rounded-sm border bg-transparent py-1 pl-7 pr-2 text-xs outline-none focus:ring-1 focus:ring-ring",placeholder:"Search… (⌘K)",value:c,onChange:a=>{d(a.target.value),g(a.target.value)},onKeyDown:a=>{"Escape"===a.key?h():0!==e.length&&("ArrowDown"===a.key?(a.preventDefault(),j(a=>(a+1)%e.length)):"ArrowUp"===a.key?(a.preventDefault(),j(a=>(a-1+e.length)%e.length)):"Enter"===a.key&&(a.preventDefault(),l(i)))}})]}),""!==c.trim()&&(0,b.jsxs)("div",{ref:k,className:"max-h-64 overflow-y-auto rounded-sm border bg-popover",children:[f&&(0,b.jsx)("div",{className:"px-2 py-1 text-xs text-muted-foreground",children:"Searching…"}),!f&&0===e.length&&(0,b.jsx)("div",{className:"px-2 py-1 text-xs text-muted-foreground",children:"No matches"}),e.map((a,c)=>(0,b.jsxs)("button",{type:"button","data-idx":c,onClick:()=>l(c),onMouseEnter:()=>j(c),className:`block w-full px-2 py-1 text-left ${c===i?"bg-accent":"hover:bg-accent"}`,children:[(0,b.jsx)("div",{className:"truncate font-mono text-xs",children:a.path}),a.snippet&&(0,b.jsx)("div",{className:"truncate text-[10px] text-muted-foreground",children:(0,b.jsx)(d3,{html:a.snippet})})]},a.path))]})]})}let d6=(0,b1.create)(a=>({width:288,setWidth:b=>{a({width:Number.isNaN(b)?288:Math.min(600,Math.max(200,Math.round(b)))})}}));var d7=a.i(256233);let d8=(0,b1.create)((a,b)=>({showHidden:!1,toggle:()=>{a({showHidden:!b().showHidden})}})),d9=(0,b1.create)((a,b)=>({humanize:!1,toggle:()=>{a({humanize:!b().humanize})}}));function ea(a){let b=a.lastIndexOf("."),c=b>0&&b<a.length-1,d=c?a.slice(0,b):a,e=c?a.slice(b):"",f=d.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1 $2").split(/[\s_-]+/).filter(Boolean).map(a=>/^[A-Z0-9]+$/.test(a)?a:a[0].toUpperCase()+a.slice(1));return f.length?f.join(" ")+e:a}let eb=(0,bs.default)(async()=>{},{loadableGenerated:{modules:[904378]},ssr:!1});function ec(a){let b=new Date(a).getTime();if(!Number.isFinite(b))return"";let c=Math.floor(Math.max(0,Date.now()-b)/1e3);if(c<60)return"just now";let d=Math.floor(c/60);if(d<60)return`${d}m ago`;let e=Math.floor(d/60);return e<24?`${e}h ago`:`${Math.floor(e/24)}d ago`}let ed=new Set(["image","media","pdf","fallback","app","node-app","html"]);function ee(a){return a.split(".").pop()?.toLowerCase()??""}function ef(a,b){if("node-app"===b)return"node-app";if("app"===b)return"app";if("dir"===b)return"fallback";let c=a.split("/").pop()??a;if(c.startsWith(".")&&-1===c.indexOf(".",1))return"source";let d=ee(a);return d?["md","markdown"].includes(d)?"editor":"txt"===d?"text":["csv","tsv"].includes(d)?"csv":"pdf"===d?"pdf":["mmd","mermaid"].includes(d)?"mermaid":"ipynb"===d?"notebook":["png","jpg","jpeg","gif","webp","svg","avif","ico","bmp"].includes(d)?"image":["mp4","webm","mov","m4v","mp3","wav","ogg","m4a","aac"].includes(d)?"media":"docx"===d?"docx":["xlsx","xlsm"].includes(d)?"xlsx":"pptx"===d?"pptx":"html"===d?"html":(["py","js","ts","tsx","jsx","go","rs","java","c","cpp","h","sh","bash","zsh","rb","php","swift","kt","lua","sql","yaml","yml","toml","json","xml","css","scss"].includes(d),"source"):"source"}let eg=new Set(["txt","md","markdown","json","yaml","yml","toml","csv","tsv","xml","html","css","js","ts","tsx","jsx","sh","bash","zsh","rb","py","go","rs","java","c","cpp","h","php","swift","kt","lua","sql","scss","mmd","mermaid","ini","env","log","conf"]);function eh(a){let b=ef(a,"file");return"editor"===b||"text"===b||eg.has(ee(a))}function ei(a){return["md","markdown"].includes(ee(a))}function ej(a){return"image"===ef(a,"file")}function ek(a){return"html"===ef(a,"file")}async function el(a){let b=await (0,Y.wsFetch)(`/api/wiki?dir=${encodeURIComponent(a)}`);return b.ok?(await b.json()).entries.map(b=>({name:b.name,path:a?`${a}/${b.name}`:b.name,type:b.type,size:b.size,modifiedAt:b.modifiedAt,expanded:!1,git:b.git})):[]}let em=new Map,en=new Map;async function eo(a){let b=em.get(a);if(b)return em.delete(a),b;let c=en.get(a);if(c){let b=await c;return em.delete(a),b}return null}function ep(a,b,c){return a.map(a=>a.path===b?c(a):a.children?{...a,children:ep(a.children,b,c)}:a)}let eq={contentVisibility:"auto",containIntrinsicSize:"auto 32px"};function er({node:a,ctx:c,isPinned:d,activeWorkspaceId:e}){return(0,b.jsxs)(cV,{className:"w-48",children:[(0,b.jsxs)(cW,{onSelect:()=>c.copyPath(a.path),children:[(0,b.jsx)(i.Copy,{className:"mr-2 h-3.5 w-3.5"}),"Copy path"]}),ei(a.name)&&(0,b.jsxs)(cW,{onSelect:()=>c.copyWikiLink(a.name),children:[(0,b.jsx)(n.FileText,{className:"mr-2 h-3.5 w-3.5"}),"Copy wiki link"]}),(0,b.jsxs)(cW,{onSelect:()=>c.copyUrl(a.path),children:[(0,b.jsx)(y.Link,{className:"mr-2 h-3.5 w-3.5"}),"Copy URL"]}),"file"===a.type&&eh(a.name)&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(cW,{onSelect:()=>c.copyRawContent(a.path),children:[(0,b.jsx)(n.FileText,{className:"mr-2 h-3.5 w-3.5"}),"Copy raw content"]}),(0,b.jsxs)(cW,{onSelect:()=>c.copyFormattedContent(a.path,a.name),children:[(0,b.jsx)(n.FileText,{className:"mr-2 h-3.5 w-3.5"}),"Copy formatted content"]})]}),(0,b.jsx)(cX,{}),"dir"===a.type&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(cW,{onSelect:()=>{a.expanded||c.toggleFolder(a),c.setNewFileParent(a.path),c.setNewFileName(""),c.setFileCreateError(null)},children:[(0,b.jsx)(m.FilePlus,{className:"mr-2 h-3.5 w-3.5"}),"New file here"]}),(0,b.jsxs)(cW,{onSelect:()=>c.triggerUpload(a.path),children:[(0,b.jsx)(R.Upload,{className:"mr-2 h-3.5 w-3.5"}),"Upload here"]}),(0,b.jsxs)(cW,{onSelect:()=>{c.setNewFolderParent(a.path),c.setNewFolderName(""),c.setFolderError(null)},children:[(0,b.jsx)(q,{className:"mr-2 h-3.5 w-3.5"}),"New subfolder"]}),(0,b.jsx)(cX,{})]}),(0,b.jsxs)(cW,{onSelect:()=>c.handleDownload(a),children:[(0,b.jsx)(j.Download,{className:"mr-2 h-3.5 w-3.5"}),"file"===a.type?"Download":"Download as zip"]}),(0,b.jsxs)(cW,{onSelect:()=>c.togglePin(a,e),children:[(0,b.jsx)(I,{className:(0,Z.cn)("mr-2 h-3.5 w-3.5",d&&"fill-current text-amber-400")}),d?"Unpin":"Pin to top"]}),(0,b.jsx)(cX,{}),(0,b.jsxs)(cW,{className:"text-destructive focus:text-destructive",onSelect:()=>{c.setDeletingPath(a.path),c.setDeletingIsDir("file"!==a.type)},children:[(0,b.jsx)(Q.Trash2,{className:"mr-2 h-3.5 w-3.5"}),"Delete"]})]})}function es({name:a,type:c}){let d="h-3.5 w-3.5 shrink-0";return"dir"===c?(0,b.jsx)(o.Folder,{className:(0,Z.cn)(d,"text-warning")}):"app"===c?(0,b.jsx)(u.Globe,{className:(0,Z.cn)(d,"text-foreground/70")}):"node-app"===c?(0,b.jsx)(O,{className:(0,Z.cn)(d,"text-emerald-500")}):ek(a)?(0,b.jsx)(u.Globe,{className:(0,Z.cn)(d,"text-foreground/60")}):ej(a)?(0,b.jsx)(x.default,{className:(0,Z.cn)(d,"text-sunshine-700")}):eh(a)?(0,b.jsx)(n.FileText,{className:(0,Z.cn)(d,"text-foreground/70")}):(0,b.jsx)(l.File,{className:(0,Z.cn)(d,"text-foreground/60")})}let et=(0,T.memo)(function({node:a,depth:c,ctx:d,isMobile:e,activeWorkspaceId:f,sidebarScrollRef:g,isActive:k,isDragOver:s,isPinned:t,isAgentActive:v,isPulling:w,branchOpen:A,branchPos:C,branches:D,branchLoading:E,checkingOut:F,onHoverEnter:G,onHoverLeave:H}){let J=d9(a=>a.humanize);return(0,b.jsxs)(cF,{children:[(0,b.jsx)(cH,{asChild:!0,children:(0,b.jsxs)("div",{role:"treeitem",tabIndex:0,draggable:!e,onKeyDown:b=>{if("Enter"===b.key||" "===b.key)b.preventDefault(),"dir"===a.type?d.toggleFolder(a):"app"===a.type||"node-app"===a.type?(d.openViewer(a),d.toggleFolder(a)):d.openViewer(a);else if("ArrowDown"===b.key){b.preventDefault();let a=g.current;if(!a)return;let c=Array.from(a.querySelectorAll('[role="treeitem"]')),d=c.indexOf(b.currentTarget);c[d+1]?.focus()}else if("ArrowUp"===b.key){b.preventDefault();let a=g.current;if(!a)return;let c=Array.from(a.querySelectorAll('[role="treeitem"]')),d=c.indexOf(b.currentTarget);c[d-1]?.focus()}else if("ArrowRight"===b.key){if(b.preventDefault(),"dir"===a.type||"app"===a.type||"node-app"===a.type)if(a.expanded){let a=g.current;if(!a)return;let c=Array.from(a.querySelectorAll('[role="treeitem"]')),d=c.indexOf(b.currentTarget);c[d+1]?.focus()}else d.toggleFolder(a)}else if("ArrowLeft"===b.key){if(b.preventDefault(),("dir"===a.type||"app"===a.type||"node-app"===a.type)&&a.expanded)d.toggleFolder(a);else if(c>0){let a=g.current;if(!a)return;let c=Array.from(a.querySelectorAll('[role="treeitem"]')),d=b.currentTarget,e=c.indexOf(d),f=Number.parseInt(d.style.paddingLeft??"0",10);for(let a=e-1;a>=0;a--)if(Number.parseInt(c[a].style.paddingLeft??"0",10)<f){c[a].focus();break}}}},onDragStart:b=>d.handleDragStart(b,a),onDragOver:b=>"dir"===a.type?d.handleDragOver(b,a.path,"dir"):b.preventDefault(),onDragLeave:()=>d.setDragOverPath(null),onDrop:b=>"dir"===a.type?d.handleDropOnFolder(b,a.path):b.preventDefault(),onMouseEnter:()=>G(a),onMouseLeave:H,className:(0,Z.cn)("tree-row-reveal flex items-center gap-1.5 rounded-sm px-2 py-1 text-sm cursor-pointer group transition-colors select-none touch-target",k?"bg-accent-soft text-foreground font-medium":"hover:bg-muted",s&&"ring-2 ring-primary bg-primary-soft",a.name.startsWith(".")&&"opacity-40"),style:{paddingLeft:`${14*c+8}px`,...eq},onClick:()=>{"dir"===a.type?d.toggleFolder(a):("app"===a.type||"node-app"===a.type?(d.openViewer(a),d.toggleFolder(a)):d.openViewer(a),e&&d.setSidebarCollapsed(!0))},children:["dir"===a.type||"app"===a.type||"node-app"===a.type?a.loading?(0,b.jsx)(z.Loader2,{className:"h-3.5 w-3.5 shrink-0 animate-spin text-muted-foreground"}):(0,b.jsx)(h.ChevronRight,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground transition-transform duration-200 ease-out",style:{transform:a.expanded?"rotate(90deg)":"rotate(0deg)"}}):(0,b.jsx)("span",{className:"w-3.5 shrink-0"}),(0,b.jsx)("span",{className:"editorial-tree-typeicon",children:"dir"===a.type?a.expanded?(0,b.jsx)(p,{className:(0,Z.cn)("h-4 w-4 shrink-0",!k&&"text-warning")}):(0,b.jsx)(o.Folder,{className:(0,Z.cn)("h-4 w-4 shrink-0",!k&&"text-warning")}):"app"===a.type?(0,b.jsx)(u.Globe,{className:(0,Z.cn)("h-4 w-4 shrink-0",!k&&"text-foreground/70")}):"node-app"===a.type?(0,b.jsx)(O,{className:(0,Z.cn)("h-4 w-4 shrink-0",!k&&"text-emerald-500")}):ek(a.name)?(0,b.jsx)(u.Globe,{className:(0,Z.cn)("h-4 w-4 shrink-0",!k&&"text-foreground/60")}):ej(a.name)?(0,b.jsx)(x.default,{className:(0,Z.cn)("h-4 w-4 shrink-0",!k&&"text-sunshine-700")}):eh(a.name)?(0,b.jsx)(n.FileText,{className:(0,Z.cn)("h-4 w-4 shrink-0",!k&&"text-foreground/70")}):(0,b.jsx)(l.File,{className:(0,Z.cn)("h-4 w-4 shrink-0",!k&&"text-foreground/60")})}),(0,b.jsx)("span",{className:"min-w-0 flex-1 truncate",title:J?a.name:void 0,children:J?ea(a.name):a.name}),a.git&&(0,b.jsxs)("span",{className:"relative flex shrink-0 items-center gap-0.5 rounded-sm bg-muted px-1 py-0.5 text-[10px] text-muted-foreground",children:[(0,b.jsxs)("button",{"data-branch-trigger":!0,type:"button",className:"flex items-center gap-0.5 hover:text-foreground",title:"Switch branch",onClick:b=>{if(b.stopPropagation(),A){d.setBranchDropdownNode(null),d.setBranchDropdownPos(null);return}let c=b.currentTarget.getBoundingClientRect();d.setBranchDropdownPos({top:c.bottom+4,left:c.left}),d.setBranchDropdownNode(a.path),d.loadBranches(a.path)},children:[(0,b.jsx)(r,{className:"h-2.5 w-2.5"}),a.git.branch,a.git.dirty&&(0,b.jsx)("span",{className:"ml-0.5 text-warning",children:"*"})]}),w?(0,b.jsx)(z.Loader2,{className:"ml-0.5 h-2.5 w-2.5 animate-spin"}):(0,b.jsx)("button",{type:"button",onClick:b=>{b.stopPropagation();let c=a.path.includes("/")?a.path.substring(0,a.path.lastIndexOf("/")):"";d.handleGitPull(a.path,c)},className:"ml-0.5 text-muted-foreground hover:text-foreground",title:"Pull latest",children:(0,b.jsx)(K,{className:"h-2.5 w-2.5"})}),A&&C&&(0,b.jsx)(bS,{pos:C,branches:D,loading:E,busyName:F,disabled:null!==F,onPick:b=>{let c=a.path.includes("/")?a.path.substring(0,a.path.lastIndexOf("/")):"";d.handleCheckout(a.path,b,c)},onClose:()=>{d.setBranchDropdownNode(null),d.setBranchDropdownPos(null)}})]}),v&&(0,b.jsx)("span",{className:"ml-0.5 h-1.5 w-1.5 rounded-full bg-emerald-400 shrink-0 animate-pulse",title:"Agent recently active"}),(0,b.jsx)("div",{className:"hover-reveal flex max-w-0 shrink-0 items-center overflow-hidden opacity-0 transition-all duration-150 group-hover:max-w-7 group-hover:opacity-100 focus-within:max-w-7 focus-within:opacity-100",onClick:a=>a.stopPropagation(),onKeyDown:a=>a.stopPropagation(),children:(0,b.jsxs)(bJ.DropdownMenu,{children:[(0,b.jsx)(bJ.DropdownMenuTrigger,{asChild:!0,children:(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0 text-muted-foreground hover:text-foreground",title:"File actions",children:(0,b.jsx)(B,{className:"h-3.5 w-3.5"})})}),(0,b.jsxs)(bJ.DropdownMenuContent,{align:"end",className:"w-48",children:[(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>d.copyPath(a.path),children:[(0,b.jsx)(i.Copy,{className:"mr-2 h-3.5 w-3.5"}),"Copy path"]}),ei(a.name)&&(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>d.copyWikiLink(a.name),children:[(0,b.jsx)(n.FileText,{className:"mr-2 h-3.5 w-3.5"}),"Copy wiki link"]}),(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>d.copyUrl(a.path),children:[(0,b.jsx)(y.Link,{className:"mr-2 h-3.5 w-3.5"}),"Copy URL"]}),"file"===a.type&&eh(a.name)&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>d.copyRawContent(a.path),children:[(0,b.jsx)(n.FileText,{className:"mr-2 h-3.5 w-3.5"}),"Copy raw content"]}),(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>d.copyFormattedContent(a.path,a.name),children:[(0,b.jsx)(n.FileText,{className:"mr-2 h-3.5 w-3.5"}),"Copy formatted content"]})]}),(0,b.jsx)(bJ.DropdownMenuSeparator,{}),"dir"===a.type&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:async()=>{a.expanded||d.toggleFolder(a),d.setNewFileParent(a.path),d.setNewFileName(""),d.setFileCreateError(null)},children:[(0,b.jsx)(m.FilePlus,{className:"mr-2 h-3.5 w-3.5"}),"New file here"]}),(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>d.triggerUpload(a.path),children:[(0,b.jsx)(R.Upload,{className:"mr-2 h-3.5 w-3.5"}),"Upload here"]}),(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>{d.setNewFolderParent(a.path),d.setNewFolderName(""),d.setFolderError(null)},children:[(0,b.jsx)(q,{className:"mr-2 h-3.5 w-3.5"}),"New subfolder"]}),(0,b.jsx)(bJ.DropdownMenuSeparator,{})]}),(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>d.handleDownload(a),children:[(0,b.jsx)(j.Download,{className:"mr-2 h-3.5 w-3.5"}),"file"===a.type?"Download":"Download as zip"]}),(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>d.togglePin(a,f),children:[(0,b.jsx)(I,{className:(0,Z.cn)("mr-2 h-3.5 w-3.5",t&&"fill-current text-amber-400")}),t?"Unpin":"Pin to top"]}),(0,b.jsx)(bJ.DropdownMenuSeparator,{}),(0,b.jsxs)(bJ.DropdownMenuItem,{className:"text-destructive focus:text-destructive",onClick:()=>{d.setDeletingPath(a.path),d.setDeletingIsDir("file"!==a.type)},children:[(0,b.jsx)(Q.Trash2,{className:"mr-2 h-3.5 w-3.5"}),"Delete"]})]})]})})]})}),(0,b.jsx)(er,{node:a,ctx:d,isPinned:t,activeWorkspaceId:f})]})}),eu=(0,T.memo)(function(a){let{ctx:c,openPath:d,dragOverPath:e,branchDropdownNode:g,branchDropdownPos:h,nodeBranches:i,branchesLoading:j,checkingOutBranch:k,pullingRepo:l,activePaths:m,pins:p,isMobile:q,activeWorkspaceId:r,newFileParent:s,newFileName:t,fileCreateError:u,newFolderParent:v,newFolderName:w,folderError:x,sidebarScrollRef:y}=a,z=d8(a=>a.showHidden),A=(0,T.useRef)(null),B=(0,T.useCallback)(a=>{let b=("dir"===a.type||"app"===a.type||"node-app"===a.type)&&!a.expanded&&void 0===a.children;("file"===a.type||b)&&(A.current&&clearTimeout(A.current),A.current=setTimeout(()=>c.prefetch(a),120))},[c]),C=(0,T.useCallback)(()=>{A.current&&(clearTimeout(A.current),A.current=null)},[]),D=(0,T.useMemo)(()=>{let b=[],c=(a,d)=>{for(let e of a)!(!z&&e.name.startsWith("."))&&(b.push({kind:"row",node:e,depth:d}),"dir"===e.type&&(v===e.path&&b.push({kind:"newfolder",node:e,depth:d}),s===e.path&&b.push({kind:"newfile",node:e,depth:d})),("dir"===e.type||"app"===e.type||"node-app"===e.type)&&e.expanded&&(e.children&&e.children.length>0?c(e.children,d+1):e.children?.length===0&&b.push({kind:"empty",node:e,depth:d})))};return c(a.nodes,0),b},[a.nodes,s,v,z]);return(0,b.jsx)(b.Fragment,{children:D.map(a=>{let{node:s,depth:v}=a;if("row"===a.kind){let a=g===s.path;return(0,b.jsx)(et,{node:s,depth:v,ctx:c,isMobile:q,activeWorkspaceId:r,sidebarScrollRef:y,isActive:d===s.path,isDragOver:e===s.path,isPinned:p.some(a=>a.path===s.path),isAgentActive:m.has(s.path),isPulling:l===s.path,branchOpen:a,branchPos:a?h:null,branches:s.git?i[s.path]??[]:[],branchLoading:!!s.git&&!!j[s.path],checkingOut:a?k:null,onHoverEnter:B,onHoverLeave:C},s.path)}return"newfolder"===a.kind?(0,b.jsxs)("div",{className:"flex items-center gap-1.5 px-2 py-1",style:{paddingLeft:`${(v+1)*14+8}px`,...eq},children:[(0,b.jsx)("span",{className:"w-3.5 shrink-0"}),(0,b.jsx)(o.Folder,{className:"h-4 w-4 shrink-0 text-warning"}),(0,b.jsx)("input",{className:"flex-1 bg-transparent text-sm outline-none border-b border-border min-w-0",placeholder:"Folder name",value:w,onChange:a=>c.setNewFolderName(a.target.value),onKeyDown:a=>{"Enter"===a.key&&c.handleCreateFolder(),"Escape"===a.key&&(c.setNewFolderParent(null),c.setNewFolderName(""))}}),x&&(0,b.jsx)("span",{className:"text-xs text-destructive",children:x}),(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:c.handleCreateFolder,children:(0,b.jsx)(f.Check,{className:"h-3 w-3"})}),(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:()=>{c.setNewFolderParent(null),c.setNewFolderName("")},children:(0,b.jsx)(S.X,{className:"h-3 w-3"})})]},`nf-${s.path}`):"newfile"===a.kind?(0,b.jsxs)("div",{className:"flex items-center gap-1.5 px-2 py-1",style:{paddingLeft:`${(v+1)*14+8}px`,...eq},children:[(0,b.jsx)("span",{className:"w-3.5 shrink-0"}),(0,b.jsx)(n.FileText,{className:"h-4 w-4 shrink-0 text-accent"}),(0,b.jsx)("input",{autoFocus:!0,className:"flex-1 bg-transparent text-sm outline-none border-b border-border min-w-0",placeholder:"filename (default .md)",value:t,onChange:a=>c.setNewFileName(a.target.value),onKeyDown:a=>{"Enter"===a.key&&c.handleCreateFile(),"Escape"===a.key&&(c.setNewFileParent(null),c.setNewFileName(""))}}),u&&(0,b.jsx)("span",{className:"text-xs text-destructive",children:u}),(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:c.handleCreateFile,children:(0,b.jsx)(f.Check,{className:"h-3 w-3"})}),(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:()=>{c.setNewFileParent(null),c.setNewFileName("")},children:(0,b.jsx)(S.X,{className:"h-3 w-3"})})]},`ff-${s.path}`):(0,b.jsx)("div",{className:"text-xs text-muted-foreground/50 py-0.5",style:{paddingLeft:`${(v+1)*14+8+14+6+16+6}px`,...eq},children:"Empty"},`empty-${s.path}`)})})});a.s(["default",0,function(){let a;(0,d7.useWikiSlugsStore)(a=>a.loadedAt),(0,T.useEffect)(()=>{d7.useWikiSlugsStore.getState().load()},[]);let[d,j]=(0,T.useState)(null),[p,O]=(0,T.useState)(null),[V,X]=(0,T.useState)(()=>null),[$,_]=(0,T.useState)([]),[aa,ae]=(0,T.useState)(!1),[af,aj]=(0,T.useState)(!1),[al,am]=(0,T.useState)(null),[an,ao]=(0,T.useState)(null),[ap,aq]=(0,T.useState)({}),[ar,as]=(0,T.useState)(null),[at,au]=(0,T.useState)(null),[av,aw]=(0,T.useState)(null),[ax,ay]=(0,T.useState)(null),az=(0,T.useCallback)(async()=>{try{let a=await fetch("/api/system/workspaces");if(!a.ok)throw Error("Failed");let b=await a.json();if(_(b.workspaces),ae(b.isAdmin),b.workspaces.length>0){j(!0);let a=new URLSearchParams(window.location.search).get("ws"),c=a?b.workspaces.find(b=>b.id===a):null,d=c??[...b.workspaces].sort((a,b)=>(b.lastOpenedAt??b.createdAt).localeCompare(a.lastOpenedAt??a.createdAt))[0];if(X(d.id),O(d.rootDir),!c){let a=new URL(location.href);a.searchParams.set("ws",d.id),history.replaceState(null,"",a.toString())}}else j(!1)}catch{j(!1)}},[]);(0,T.useEffect)(()=>{az()},[az]);let aA=(0,c8.useEditorStore)(a=>a.currentPath),aB=cY(a=>a.recents),[aC,aD]=(0,T.useState)(!1),[aE,aF]=(0,T.useState)(!0),aG=cZ(a=>a.pins),aH=(0,T.useRef)(null),aI=(0,c_.useAIPanelStore)(a=>a.activity),aJ=(0,T.useMemo)(()=>{let a=new Date(Date.now()-6e4).toISOString(),b=new Set;for(let c of aI)c.at>=a&&c.path&&c.by?.startsWith("ai:")&&b.add(c.path);return b},[aI]);(0,T.useEffect)(()=>{let a=()=>{c_.useAIPanelStore.getState().loadActivity()};a();let b=setInterval(a,1e4);return()=>clearInterval(b)},[]),(0,T.useEffect)(()=>{cY.getState().loadForWorkspace(V),cZ.getState().loadForWorkspace(V)},[V]),(0,T.useEffect)(()=>{let a,b=[...aG.map(a=>a.path),...aB.slice(0,8).map(a=>a.path)].filter((a,b,c)=>ei(a)&&c.indexOf(a)===b).slice(0,12);if(0===b.length)return;let c=(a=()=>{for(let a of b)(0,c8.prefetchPage)(a)},window.setTimeout(a,400));return()=>{clearTimeout(c)}},[aG,aB]);let aK=(0,T.useRef)(null),aL=(0,T.useRef)(!1),[aM,aN]=(0,T.useState)([]),[aO,aP]=(0,T.useState)(!1),[aQ,aR]=(0,T.useState)(!1),aS=(0,T.useRef)(!1),[aT,aU]=(0,T.useState)(!1),[aV,aW]=(0,T.useState)(!1),[aX,aY]=(0,T.useState)(null),aZ=(0,T.useRef)(null),a$=(0,T.useRef)(""),[a_,a0]=(0,T.useState)(null),[a1,a2]=(0,T.useState)(""),[a3,a4]=(0,T.useState)(null),[a5,a6]=(0,T.useState)(null),[a7,a8]=(0,T.useState)(""),[a9,ba]=(0,T.useState)(null),[bb,bc]=(0,T.useState)(null),[bd,bf]=(0,T.useState)(!1),[bg,bh]=(0,T.useState)(null),[bi,bj]=(0,T.useState)(null),[bk,bl]=(0,T.useState)(!1),[bm,bo]=(0,T.useState)(0),[bs,bt]=(0,T.useState)(0),bu=function(a="(max-width: 767px)"){let[b,c]=(0,T.useState)(!1);return(0,T.useEffect)(()=>{let b=window.matchMedia(a),d=()=>c(b.matches);return d(),b.addEventListener("change",d),()=>b.removeEventListener("change",d)},[a]),b}(),[bv,bw]=(0,T.useState)(!1),bx=d6(a=>a.width),by=d8(a=>a.showHidden),bz=d9(a=>a.humanize),{resolvedTheme:bA,setTheme:bB}=(0,bT.useTheme)(),bC=d6(a=>a.setWidth);(0,T.useEffect)(()=>{bu&&bw(!0)},[bu]);let[bD,bF]=(0,T.useState)(!1),[bH,bI]=(0,T.useState)(!1),[bK,bM]=(0,T.useState)(!1),[bN,bO]=(0,T.useState)(null),[bP,bR]=(0,T.useState)(0),[bU,bV]=(0,T.useState)(!1),[bW,bX]=(0,T.useState)(!1),[bY,bZ]=(0,T.useState)(""),[b$,b0]=(0,T.useState)(!1),[b1,b2]=(0,T.useState)(!1),[b3,b4]=(0,T.useState)(null),b5=(0,T.useRef)(null),[b6,b7]=(0,T.useState)(null),b8=(0,T.useRef)(null),ca=(0,T.useRef)(!1),cb=(0,T.useRef)(async()=>{});(0,T.useEffect)(()=>{!V||aO||aS.current||(aS.current=!0,aR(!0),el("").then(a=>{aN(a),aP(!0),aR(!1)}).catch(()=>{aS.current=!1,aR(!1)}))},[aO,V]);let cc=(0,T.useCallback)(async a=>{let b=a.split("/");if(b.length<=1)return;let c=[],d="";for(let a=0;a<b.length-1;a++)d=d?`${d}/${b[a]}`:b[a],c.push({prefix:d,children:await el(d)});aN(a=>{let b=a;for(let{prefix:a,children:d}of c)b=ep(b,a,a=>({...a,children:d,expanded:!0}));return b})},[]),cd=(0,T.useCallback)(async a=>{let b=await el(a);""===a?aN(a=>{let c=new Map(a.map(a=>[a.path,a]));return b.map(a=>{let b=c.get(a.path);return b&&("dir"===b.type||"app"===b.type)?{...a,expanded:b.expanded,children:b.children}:a})}):aN(c=>ep(c,a,a=>({...a,children:b,expanded:!0})))},[]),[ce,cf]=(0,T.useState)(null),[cg,ch]=(0,T.useState)(null),[ci,cj]=(0,T.useState)(!1),[ck,cl]=(0,T.useState)([]),[cm,cn]=(0,T.useState)(!1),[co,cp]=(0,T.useState)(null),[cq,cr]=(0,T.useState)(null),[cs,ct]=(0,T.useState)(!1),[cu,cx]=(0,T.useState)({}),[cy,cz]=(0,T.useState)({}),[cA,cB]=(0,T.useState)(null),[cC,cD]=(0,T.useState)(null),[cE,cG]=(0,T.useState)(null),cI=(0,T.useCallback)(async(a,b)=>{if(!ce){cf(a);try{let c=await (0,Y.wsFetch)("/api/wiki/git-pull",{method:"POST",body:JSON.stringify({path:a})});if(!c.ok){let a=await c.json();(0,b_.showError)(a.message??a.error??"Pull failed");return}let d=await c.json();(0,b_.showSuccess)(`Pulled ${a} (${d.branch} @ ${d.sha.slice(0,7)})`),await cd(b)}catch{(0,b_.showError)("Pull failed")}finally{cf(null)}}},[ce,cd]);(0,T.useEffect)(()=>{cj(!1),cl([]),cp(null),cr(null)},[bg?.path]);let cJ=bg?.path;(0,T.useEffect)(()=>{if(!cJ)return void ch(null);let a=!1,b=setTimeout(()=>{(async()=>{try{let b=await (0,Y.wsFetch)(`/api/wiki/git-file-info?path=${encodeURIComponent(cJ)}`);if(a)return;if(!b.ok)return void ch(null);let c=await b.json();a||ch(c.info)}catch{a||ch(null)}})()},200);return()=>{a=!0,clearTimeout(b)}},[cJ]);let cK=(0,T.useCallback)(async()=>{if(!bg)return;let a=bg.path;cj(!0),cn(!0),cl([]),cp(null),cr(null);try{let b=await (0,Y.wsFetch)(`/api/wiki/git-history?path=${encodeURIComponent(a)}`);if(!b.ok)return void(0,b_.showError)("Could not load history");let c=await b.json();bg.path===a&&cl(c.commits)}catch{(0,b_.showError)("Could not load history")}finally{cn(!1)}},[bg]),cL=(0,T.useCallback)(async a=>{if(!bg)return;if(co===a){cp(null),cr(null);return}let b=bg.path;cp(a),ct(!0),cr(null);try{let c=await (0,Y.wsFetch)(`/api/wiki/git-diff?path=${encodeURIComponent(b)}&sha=${encodeURIComponent(a)}`);if(!c.ok)return void(0,b_.showError)("Could not load diff");let d=await c.json();bg.path===b&&co===a&&cr(d.diff)}catch{(0,b_.showError)("Could not load diff")}finally{ct(!1)}},[bg,co]),cM=(0,T.useCallback)(async a=>{if(cu[a]||cy[a])return;let b=!1;cz(b=>({...b,[a]:!0}));try{let c=await (0,Y.wsFetch)(`/api/wiki/git-branches?path=${encodeURIComponent(a)}`);if(b)return;if(!c.ok)return void(0,b_.showError)("Could not load branches");let d=await c.json();b||cx(b=>({...b,[a]:d.branches}))}catch{b||(0,b_.showError)("Could not load branches")}finally{b||cz(b=>({...b,[a]:!1}))}return()=>{b=!0}},[cu,cy]),cN=(0,T.useCallback)(async(a,b,c)=>{if(!cA){cB(b);try{let d=await (0,Y.wsFetch)("/api/wiki/git-checkout",{method:"POST",body:JSON.stringify({path:a,branch:b})});if(409===d.status)return void(0,b_.showError)("Repository has uncommitted changes");if(!d.ok){let a=await d.json();(0,b_.showError)(a.error??"Checkout failed");return}let e=await d.json();(0,b_.showSuccess)(`Switched to ${e.branch}`),cx(b=>{let c={...b};return delete c[a],c}),cD(null),cG(null),await cd(c)}catch{(0,b_.showError)("Checkout failed")}finally{cB(null)}}},[cA,cd]),cO=(0,T.useCallback)(a=>{let b=[];for(let c of a)("dir"===c.type||"app"===c.type||"node-app"===c.type)&&c.expanded&&c.children&&(b.push(c.path),b.push(...cO(c.children)));return b},[]),cP=(0,T.useCallback)(async()=>{aU(!0);try{let a=cO(aM),b=await el("");for(let c of(aN(b),a)){let a=await el(c);aN(b=>ep(b,c,b=>({...b,children:a,expanded:!0})))}}finally{aU(!1)}},[aM,cO]),cQ=(0,T.useCallback)(async()=>{if(bg){if(ei(bg.name)){bV(!0);try{await c8.useEditorStore.getState().loadPage(bg.path)}finally{bV(!1)}return}if(["editor","text"].includes(ef(bg.name,bg.nodeType))||eh(bg.name)){bV(!0);try{let a=await (0,Y.wsFetch)(`/api/wiki/content?path=${encodeURIComponent(bg.path)}`);if(a.ok){let b=await a.json();bO(b.content),bR(Number(a.headers.get("X-Wiki-Revision")??0))}}catch{}bV(!1)}}},[bg]),cR=(0,T.useCallback)(()=>{bt(a=>a+1),cQ()},[cQ]);async function cS(a){if("dir"===a.type||"app"===a.type||"node-app"===a.type)if(a.expanded)aN(b=>ep(b,a.path,a=>({...a,expanded:!1})));else if(void 0===a.children){let b=await eo(a.path);if(b)return void aN(c=>ep(c,a.path,a=>({...a,loading:!1,children:b,expanded:!0})));aN(b=>ep(b,a.path,a=>({...a,loading:!0})));let c=await el(a.path);aN(b=>ep(b,a.path,a=>({...a,loading:!1,children:c,expanded:!0})))}else aN(b=>ep(b,a.path,a=>({...a,expanded:!0})))}async function cT(a){if("file"===a.type&&cY.getState().push({path:a.path,name:a.name},V),bh({path:a.path,name:a.name,size:a.size,nodeType:"app"===a.type?"app":"node-app"===a.type?"node-app":"file"}),bX(!1),b0(!1),b4(null),bO(null),bR(0),"file"===a.type&&ei(a.name)){bV(!0);try{await c8.useEditorStore.getState().loadPage(a.path)}finally{bV(!1)}return}if(["editor","text"].includes(ef(a.name,a.type))||eh(a.name)){bV(!0);try{let b=await (0,Y.wsFetch)(`/api/wiki/content?path=${encodeURIComponent(a.path)}`);if(b.ok){let a=await b.json();bO(a.content),bR(Number(b.headers.get("X-Wiki-Revision")??0))}}catch{}bV(!1)}}(0,T.useEffect)(()=>{bg&&ei(bg.name)&&c8.useEditorStore.getState().currentPath!==bg.path&&c8.useEditorStore.getState().loadPage(bg.path)},[bg]),(0,T.useEffect)(()=>{b8.current=bg},[bg]),(0,T.useEffect)(()=>{ca.current=bW},[bW]),(0,T.useEffect)(()=>{cb.current=cQ},[cQ]),(0,T.useEffect)(()=>{if(!d||!V)return;let a=new Map,b=new EventSource((0,Y.withWs)("/api/wiki/watch"));return b.onmessage=b=>{var c;let d;try{d=JSON.parse(b.data)}catch{return}let{type:e,path:f}=d,g=f.split("/");if(c=g.length>1?g.slice(0,-1).join("/"):"",a.has(c)&&clearTimeout(a.get(c)),a.set(c,setTimeout(()=>{a.delete(c),cd(c)},300)),"change"===e&&b8.current?.path===f&&!ca.current){let b=`__file__${f}`;a.has(b)&&clearTimeout(a.get(b)),a.set(b,setTimeout(()=>{a.delete(b),cb.current()},400))}},()=>{for(let c of(b.close(),a.values()))clearTimeout(c)}},[d,cd,V]),(0,T.useEffect)(()=>{bl(!1)},[]);let cU=(0,T.useCallback)(a=>{let b=a.split("/").pop()??a;cc(a),cT({path:a,name:b,type:"file"})},[cc]),cV=(0,T.useCallback)(async a=>{let b=a.path.split("/").slice(0,-1).join("/"),c=(await el(b)).find(b=>b.path===a.path);if(c){if("dir"===c.type){await cc(a.path),await cS(c);return}if("app"===c.type||"node-app"===c.type){await cc(c.path),cT({path:c.path,name:c.name,type:c.type,modifiedAt:c.modifiedAt}),await cS(c),bu&&bw(!0);return}cT({path:c.path,name:c.name,type:c.type,modifiedAt:c.modifiedAt}),bu&&bw(!0)}},[bu,cT,cc,cS]);(0,T.useEffect)(()=>{if(!aA||bg&&bg.path===aA)return;let a=aA.split("/").pop()??aA;cT({path:aA,name:a,type:"file"})},[aA]);let cW=(0,T.useCallback)(async a=>{if(!a)return void bh(null);let b=a.split("/"),c=b[b.length-1],d=b.slice(0,-1).join("/"),e=(await el(d)).find(b=>b.path===a);e&&(await cc(a),cT({path:a,name:c,type:e.type,modifiedAt:e.modifiedAt}))},[cc]);(0,T.useEffect)(()=>{},[bg]),(0,T.useEffect)(()=>{},[cW]),(0,T.useEffect)(()=>{aL.current||aO&&(aL.current=!0,cW(aK.current))},[aO,cW]);let cX=(0,T.useCallback)(async a=>{if(a===V)return;try{await fetch(`/api/system/workspaces/${a}/open`,{method:"POST"})}catch{}let b=new URL(location.href);b.searchParams.set("ws",a),b.searchParams.delete("path"),history.pushState(null,"",b.toString()),bh(null),bO(null),bX(!1),aN([]),aP(!1),aS.current=!1,d7.useWikiSlugsStore.getState().invalidate();let c=$.find(b=>b.id===a);c&&O(c.rootDir),X(a)},[V,$]),c$=(0,T.useCallback)(async()=>{if(al)try{if(!(await fetch(`/api/system/workspaces/${al}`,{method:"DELETE"})).ok)throw Error("Failed");if(al===V){let a=$.filter(a=>a.id!==al);if(a.length>0){let b=[...a].sort((a,b)=>(b.lastOpenedAt??b.createdAt).localeCompare(a.lastOpenedAt??a.createdAt))[0];await cX(b.id)}else j(!1)}await az()}catch{}finally{am(null)}},[al,V,$,cX,az]),c0=(0,T.useCallback)(async a=>{if(!an){ao(a);try{let b=await fetch(`/api/system/workspaces/${a}/refresh`,{method:"POST"});if(!b.ok){let a=await b.json();(0,b_.showError)(a.error??"Refresh failed")}await az()}catch{(0,b_.showError)("Refresh failed")}finally{ao(null)}}},[an,az]),c1=(0,T.useCallback)(async a=>{if(!ap[a])try{let b=await fetch(`/api/system/workspaces/${a}/branch`);if(!b.ok)return;let c=await b.json();aq(b=>({...b,[a]:c.branches??[]}))}catch{}},[ap]),c2=(0,T.useCallback)(async(a,b)=>{if(!ar){as(a),au(b);try{let c=await fetch(`/api/system/workspaces/${a}/branch`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({branch:b})});if(!c.ok){let a=await c.json();(0,b_.showError)(a.error??"Branch switch failed");return}(0,b_.showSuccess)(`Switched to ${b}`),aw(null),ay(null),await az()}catch{(0,b_.showError)("Branch switch failed")}finally{as(null),au(null)}}},[ar,az]);async function c3(){if(!bg)return;b2(!0),b4(null);let a=await (0,Y.wsFetch)("/api/wiki/content",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:bg.path,content:bY,baseRevision:bP})});if(a.ok){let b=await a.json();"number"==typeof b.revision&&bR(b.revision),bO(bY),bX(!1)}else b4((await a.json()).error??"Save failed");b2(!1)}let c4=(0,T.useCallback)(async(a,b)=>{let c=Array.from(a);if(c.length){aW(!0),aY(null);try{for(let a of c){let c=new FormData;c.append("file",a),c.append("dir",b);let d=await (0,Y.wsFetch)("/api/wiki/upload",{method:"POST",body:c});if(!d.ok){let a=await d.json();aY(a.error??"Upload failed"),(0,b_.showError)(a.error??"Upload failed");break}}await cd(b)}catch{aY("Upload failed.")}finally{aW(!1),aZ.current&&(aZ.current.value="")}}},[cd]);function c5(a){a$.current=a,aZ.current?.click()}async function c6(){let a=a1.trim();if(!a||null===a_)return;a4(null);let b=a_?`${a_}/${a}`:a,c=await (0,Y.wsFetch)("/api/wiki/folder",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:b})});c.ok?(a0(null),a2(""),await cd(a_),""!==a_&&aN(a=>ep(a,a_,a=>({...a,expanded:!0})))):a4((await c.json()).error??"Failed")}async function c7(){let a=a7.trim();if(!a||null===a5)return;ba(null);let b=a.includes(".")?a:`${a}.md`,c=a5?`${a5}/${b}`:b,d=await (0,Y.wsFetch)("/api/wiki/new-file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:c})});d.ok?(a6(null),a8(""),await cd(a5),""!==a5&&aN(a=>ep(a,a5,a=>({...a,expanded:!0}))),cT({path:c,name:b,type:"file",modifiedAt:new Date().toISOString()})):ba((await d.json()).error??"Failed")}function c9(a){navigator.clipboard.writeText(a),(0,b_.showSuccess)("Path copied")}function da(a){let b=a.replace(/\.(md|markdown)$/i,"");navigator.clipboard.writeText(`[[${b}]]`),(0,b_.showSuccess)("Wiki link copied")}function db(a){let b=new URL(location.href);b.searchParams.set("path",a),V&&b.searchParams.set("ws",V),navigator.clipboard.writeText(b.toString()),(0,b_.showSuccess)("URL copied")}async function dc(a){if(bg?.path===a&&null!==bN)return bN;if(c8.useEditorStore.getState().currentPath===a)return c8.useEditorStore.getState().content;let b=await (0,Y.wsFetch)(`/api/wiki/content?path=${encodeURIComponent(a)}`);if(!b.ok)throw Error("Cannot copy content");return(await b.json()).content}async function dd(a){try{let b=await dc(a);await navigator.clipboard.writeText(b),(0,b_.showSuccess)("Raw content copied")}catch{(0,b_.showError)("Could not copy file content")}}async function de(a,b){try{let c=await dc(a);if(!ei(b)){await navigator.clipboard.writeText(c),(0,b_.showSuccess)("Content copied");return}let d=await (0,be.markdownToHtml)(c,{pagePath:a,sanitize:!0});"ClipboardItem"in window&&navigator.clipboard.write?await navigator.clipboard.write([new ClipboardItem({"text/html":new Blob([d],{type:"text/html"}),"text/plain":new Blob([c],{type:"text/plain"})})]):await navigator.clipboard.writeText(c),(0,b_.showSuccess)("Formatted content copied")}catch{(0,b_.showError)("Could not copy formatted content")}}function df(a,c){return(0,b.jsxs)(bJ.DropdownMenu,{children:[(0,b.jsx)(bJ.DropdownMenuTrigger,{asChild:!0,children:(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",title:"File actions",children:(0,b.jsx)(B,{className:"h-3.5 w-3.5"})})}),(0,b.jsxs)(bJ.DropdownMenuContent,{align:"end",className:"w-52",children:[(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>c9(a.path),children:[(0,b.jsx)(i.Copy,{className:"mr-2 h-3.5 w-3.5"}),"Copy path"]}),ei(a.name)&&(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>da(a.name),children:[(0,b.jsx)(n.FileText,{className:"mr-2 h-3.5 w-3.5"}),"Copy wiki link"]}),(0,b.jsx)(bJ.DropdownMenuSeparator,{}),(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>db(a.path),children:[(0,b.jsx)(y.Link,{className:"mr-2 h-3.5 w-3.5"}),"Copy URL"]}),eh(a.name)&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(bJ.DropdownMenuSeparator,{}),(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>void dd(a.path),children:[(0,b.jsx)(n.FileText,{className:"mr-2 h-3.5 w-3.5"}),"Copy raw content"]}),(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>void de(a.path,a.name),children:[(0,b.jsx)(n.FileText,{className:"mr-2 h-3.5 w-3.5"}),"Copy formatted content"]})]}),c&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(bJ.DropdownMenuSeparator,{}),c]})]})]})}async function dh(){bb&&(await (0,Y.wsFetch)("/api/wiki",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:bb})}),(bg?.path===bb||bg?.path.startsWith(`${bb}/`))&&(bh(null),bO(null)),aN(a=>(function a(b,c){return b.filter(a=>a.path!==c).map(b=>b.children?{...b,children:a(b.children,c)}:b)})(a,bb)),bc(null))}function di(a,b,c){a.preventDefault(),a.stopPropagation();let d=b5.current;if(!d){Array.from(a.dataTransfer.types).includes("Files")&&(a.dataTransfer.dropEffect="copy",b7("root"===c?"":b));return}d.path===b||b.startsWith(`${d.path}/`)||(a.dataTransfer.dropEffect="move",b7("root"===c?"":b))}async function dj(a,b){a.preventDefault(),a.stopPropagation(),b7(null);let c=b5.current;if(b5.current=null,!c){a.dataTransfer.files.length>0&&await c4(a.dataTransfer.files,b);return}if(c.path===b||b.startsWith(`${c.path}/`))return;let d=b?`${b}/${c.name}`:c.name;if(d!==c.path&&(await (0,Y.wsFetch)("/api/wiki/move",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({from:c.path,to:d})})).ok){let a=c.path.includes("/")?c.path.split("/").slice(0,-1).join("/"):"";await cd(a),b!==a&&await cd(b),bg?.path===c.path&&bh({path:d,name:c.name,nodeType:bg.nodeType,size:bg.size})}}let dk=bg?ef(bg.name,bg.nodeType):null,dl=!!bg&&null!==dk&&!ed.has(dk)&&(bg.size??0)>5242880&&bi!==bg.path,dm=(0,d2.useViewWidthStore)(a=>a.width),dn=(0,d2.useViewWidthStore)(a=>a.align),dp=(0,d2.useViewWidthStore)(a=>a.setWidth),dq=(0,d2.useViewWidthStore)(a=>a.setAlign),dr=null===dk||"editor"===dk||"text"===dk||"source"===dk||"notebook"===dk||"fallback"===dk,ds=dr?d2.VIEW_WIDTH_CLASS[dm]:"",dt=dr?d2.VIEW_ALIGN_CLASS[dn]:"",du=(0,T.useRef)(null);du.current={toggleFolder:a=>void cS(a),openViewer:a=>void cT(a),copyPath:c9,copyWikiLink:da,copyUrl:db,copyRawContent:a=>void dd(a),copyFormattedContent:(a,b)=>void de(a,b),handleDownload:function(a){let b=(0,Y.withWs)(`/api/wiki/download?path=${encodeURIComponent(a.path)}`),c=document.createElement("a");c.href=b,c.download="file"===a.type?a.name:`${a.name}.zip`,document.body.appendChild(c),c.click(),c.remove()},triggerUpload:c5,handleCreateFile:()=>void c7(),handleCreateFolder:()=>void c6(),handleDragStart:function(a,b){b5.current=b,a.dataTransfer.effectAllowed="move",a.dataTransfer.setData("text/plain",b.path)},handleDragOver:di,handleDropOnFolder:(a,b)=>void dj(a,b),handleGitPull:(a,b)=>void cI(a,b),handleCheckout:(a,b,c)=>void cN(a,b,c),loadBranches:a=>void cM(a),prefetch:a=>{"file"===a.type?ei(a.name)&&(0,c8.prefetchPage)(a.path):function(a){if(em.has(a)||en.has(a))return;let b=el(a).then(b=>(em.set(a,b),b)).finally(()=>en.delete(a));en.set(a,b),b.catch(()=>{})}(a.path)},togglePin:(a,b)=>cZ.getState().toggle({path:a.path,name:a.name,type:a.type},b),setDragOverPath:b7,setSidebarCollapsed:bw,setBranchDropdownNode:cD,setBranchDropdownPos:cG,setNewFileParent:a6,setNewFileName:a8,setFileCreateError:ba,setNewFolderParent:a0,setNewFolderName:a2,setFolderError:a4,setDeletingPath:bc,setDeletingIsDir:bf};let dv=(0,T.useMemo)(()=>({toggleFolder:a=>du.current.toggleFolder(a),openViewer:a=>du.current.openViewer(a),copyPath:a=>du.current.copyPath(a),copyWikiLink:a=>du.current.copyWikiLink(a),copyUrl:a=>du.current.copyUrl(a),copyRawContent:a=>du.current.copyRawContent(a),copyFormattedContent:(a,b)=>du.current.copyFormattedContent(a,b),handleDownload:a=>du.current.handleDownload(a),triggerUpload:a=>du.current.triggerUpload(a),handleCreateFile:()=>du.current.handleCreateFile(),handleCreateFolder:()=>du.current.handleCreateFolder(),handleDragStart:(a,b)=>du.current.handleDragStart(a,b),handleDragOver:(a,b,c)=>du.current.handleDragOver(a,b,c),handleDropOnFolder:(a,b)=>du.current.handleDropOnFolder(a,b),handleGitPull:(a,b)=>du.current.handleGitPull(a,b),handleCheckout:(a,b,c)=>du.current.handleCheckout(a,b,c),loadBranches:a=>du.current.loadBranches(a),prefetch:a=>du.current.prefetch(a),togglePin:(a,b)=>du.current.togglePin(a,b),setDragOverPath:a=>du.current.setDragOverPath(a),setSidebarCollapsed:a=>du.current.setSidebarCollapsed(a),setBranchDropdownNode:a=>du.current.setBranchDropdownNode(a),setBranchDropdownPos:a=>du.current.setBranchDropdownPos(a),setNewFileParent:a=>du.current.setNewFileParent(a),setNewFileName:a=>du.current.setNewFileName(a),setFileCreateError:a=>du.current.setFileCreateError(a),setNewFolderParent:a=>du.current.setNewFolderParent(a),setNewFolderName:a=>du.current.setNewFolderName(a),setFolderError:a=>du.current.setFolderError(a),setDeletingPath:a=>du.current.setDeletingPath(a),setDeletingIsDir:a=>du.current.setDeletingIsDir(a)}),[]);return(0,b.jsxs)("div",{className:"flex h-screen gap-0 overflow-hidden bg-background",children:[null===d&&(0,b.jsx)("div",{className:"flex-1 flex items-center justify-center",children:(0,b.jsx)(z.Loader2,{className:"h-5 w-5 animate-spin text-muted-foreground"})}),!1===d&&(0,b.jsx)(bQ,{onSelect:a=>{let b=new URL(location.href);b.searchParams.set("ws",a),b.searchParams.delete("path"),history.replaceState(null,"",b.toString()),aP(!1),aS.current=!1,X(a),j(!0),az()}}),!0===d&&af&&(0,b.jsxs)("div",{className:"flex-1 flex flex-col",children:[(0,b.jsx)("div",{className:"flex items-center justify-end border-b px-3 py-2 bg-muted shrink-0",children:(0,b.jsxs)(U.Button,{size:"sm",variant:"ghost",className:"h-7 gap-1.5 text-xs",onClick:()=>aj(!1),children:[(0,b.jsx)(S.X,{className:"h-3.5 w-3.5"})," Cancel"]})}),(0,b.jsx)(bQ,{onSelect:a=>{aj(!1),az(),cX(a)}})]}),!0===d&&!af&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(d4,{onOpenFile:cU,recents:aB,onToggleSidebar:()=>bw(a=>{let b=!a;return bu&&!1===b&&c_.useAIPanelStore.getState().close(),b}),onNewFile:()=>a6(""),onCopyPath:()=>{bg&&navigator.clipboard.writeText(bg.path)}}),!bv&&bu&&(0,b.jsx)("div",{className:"fixed inset-0 z-40 bg-overlay backdrop-blur-[1px] md:hidden",onClick:()=>bw(!0),"aria-hidden":!0}),!bv&&(0,b.jsxs)(cw.Card,{style:bu?void 0:{width:bx},className:"fixed inset-y-0 left-0 z-50 w-[85vw] max-w-[20rem] md:relative md:z-auto md:w-auto md:max-w-none flex flex-col shrink-0 overflow-hidden rounded-none border-r border-l-0 border-t-0 border-b-0",children:[(0,b.jsxs)("div",{className:"flex items-center justify-between gap-2 px-3 py-2 border-b bg-muted shrink-0",children:[(0,b.jsxs)("div",{className:"flex min-w-0 items-center gap-1.5",children:[(0,b.jsx)("img",{src:"/logo.svg",alt:"Wiki Viewer",className:"h-5 w-5 shrink-0"}),(0,b.jsx)("span",{className:"truncate text-xs font-semibold leading-5 tracking-tight translate-y-[0.5px]",children:"Wiki Viewer"})]}),(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0 shrink-0",title:"Collapse sidebar",onClick:()=>bw(!0),children:(0,b.jsx)(D,{className:"h-3.5 w-3.5"})})]}),(0,b.jsxs)("div",{className:"flex items-center justify-between gap-1 px-3 py-1.5 border-b bg-muted/50 shrink-0",children:[(0,b.jsxs)(bJ.DropdownMenu,{children:[(0,b.jsx)(bJ.DropdownMenuTrigger,{asChild:!0,children:(0,b.jsxs)(U.Button,{size:"sm",variant:"ghost",className:"h-7 gap-1 px-2 text-xs",disabled:aV,children:[aV?(0,b.jsx)(z.Loader2,{className:"h-3.5 w-3.5 animate-spin"}):(0,b.jsx)(J,{className:"h-3.5 w-3.5"}),"New",(0,b.jsx)(g.ChevronDown,{className:"h-3 w-3 opacity-60"})]})}),(0,b.jsxs)(bJ.DropdownMenuContent,{align:"start",className:"w-44",children:[(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>{a6(""),a8(""),ba(null)},children:[(0,b.jsx)(m.FilePlus,{className:"mr-2 h-3.5 w-3.5"}),"New file"]}),(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>{a0(""),a2(""),a4(null)},children:[(0,b.jsx)(q,{className:"mr-2 h-3.5 w-3.5"}),"New folder"]}),(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>c5(""),disabled:aV,children:[(0,b.jsx)(R.Upload,{className:"mr-2 h-3.5 w-3.5"}),"Upload"]})]})]}),(0,b.jsxs)("div",{className:"flex items-center gap-0.5",children:[(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",title:"Refresh tree",onClick:cP,disabled:aT,children:aT?(0,b.jsx)(z.Loader2,{className:"h-3.5 w-3.5 animate-spin"}):(0,b.jsx)(K,{className:"h-3.5 w-3.5"})}),(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",title:"AI Agent panel",onClick:()=>{c_.useAIPanelStore.getState().toggle(),bu&&bw(!0)},children:(0,b.jsx)(e,{className:"h-3.5 w-3.5"})}),(0,b.jsxs)(bJ.DropdownMenu,{children:[(0,b.jsx)(bJ.DropdownMenuTrigger,{asChild:!0,children:(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",title:"More actions",children:(0,b.jsx)(B,{className:"h-3.5 w-3.5"})})}),(0,b.jsxs)(bJ.DropdownMenuContent,{align:"end",className:"w-48",children:[aa&&$.find(a=>a.id===V)?.git&&(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>{V&&c0(V)},disabled:an===V,children:[an===V?(0,b.jsx)(z.Loader2,{className:"mr-2 h-3.5 w-3.5 animate-spin"}):(0,b.jsx)(k,{className:"mr-2 h-3.5 w-3.5"}),"Pull latest"]}),(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>d8.getState().toggle(),children:[by?(0,b.jsx)(H,{className:"mr-2 h-3.5 w-3.5"}):(0,b.jsx)(G.Eye,{className:"mr-2 h-3.5 w-3.5"}),by?"Hide hidden files":"Show hidden files"]}),(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>d9.getState().toggle(),children:[(0,b.jsx)(P.Type,{className:"mr-2 h-3.5 w-3.5"}),bz?"Raw file names":"Humanize names"]}),(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>bB("dark"===bA?"light":"dark"),children:["dark"===bA?(0,b.jsx)(N.Sun,{className:"mr-2 h-3.5 w-3.5"}):(0,b.jsx)(C.Moon,{className:"mr-2 h-3.5 w-3.5"}),"dark"===bA?"Light mode":"Dark mode"]}),(0,b.jsx)(bJ.DropdownMenuSeparator,{}),(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>bI(!0),children:[(0,b.jsx)(L,{className:"mr-2 h-3.5 w-3.5"}),"Settings"]})]})]})]})]}),aX&&(0,b.jsxs)("div",{className:"flex items-center gap-1.5 px-3 py-1.5 text-xs text-destructive bg-destructive/10 shrink-0",children:[(0,b.jsx)(c.AlertCircle,{className:"h-3.5 w-3.5 shrink-0"}),aX]}),""===a_&&(0,b.jsxs)("div",{className:"flex items-center gap-1.5 px-2 py-1 border-b shrink-0",children:[(0,b.jsx)(o.Folder,{className:"h-4 w-4 shrink-0 text-warning"}),(0,b.jsx)("input",{className:"flex-1 bg-transparent text-sm outline-none border-b border-border min-w-0",placeholder:"Folder name",value:a1,onChange:a=>a2(a.target.value),onKeyDown:a=>{"Enter"===a.key&&c6(),"Escape"===a.key&&(a0(null),a2(""))}}),a3&&(0,b.jsx)("span",{className:"text-xs text-destructive",children:a3}),(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:c6,children:(0,b.jsx)(f.Check,{className:"h-3 w-3"})}),(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:()=>{a0(null),a2("")},children:(0,b.jsx)(S.X,{className:"h-3 w-3"})})]}),""===a5&&(0,b.jsxs)("div",{className:"flex items-center gap-1.5 px-2 py-1 border-b shrink-0",children:[(0,b.jsx)(n.FileText,{className:"h-4 w-4 shrink-0 text-accent"}),(0,b.jsx)("input",{autoFocus:!0,className:"flex-1 bg-transparent text-sm outline-none border-b border-border min-w-0",placeholder:"filename (default .md)",value:a7,onChange:a=>a8(a.target.value),onKeyDown:a=>{"Enter"===a.key&&c7(),"Escape"===a.key&&(a6(null),a8(""))}}),a9&&(0,b.jsx)("span",{className:"text-xs text-destructive",children:a9}),(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:c7,children:(0,b.jsx)(f.Check,{className:"h-3 w-3"})}),(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:()=>{a6(null),a8("")},children:(0,b.jsx)(S.X,{className:"h-3 w-3"})})]}),(0,b.jsx)("div",{className:"border-b",children:(0,b.jsx)(d5,{onOpenFile:cU})}),(0,b.jsxs)("div",{ref:aH,className:(0,Z.cn)("flex-1 overflow-auto py-1 editorial-file-tree",""===b6&&"ring-2 ring-inset ring-primary bg-primary/5"),onDragOver:a=>di(a,"","root"),onDragLeave:a=>{a.currentTarget.contains(a.relatedTarget)||b7(null)},onDrop:a=>dj(a,""),children:[aG.length>0&&(0,b.jsxs)("div",{className:"border-b mb-1",children:[(0,b.jsxs)("button",{type:"button",className:"flex w-full items-center gap-1 px-2 py-1 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground hover:text-foreground",onClick:()=>aD(a=>!a),children:[aC?(0,b.jsx)(h.ChevronRight,{className:"h-3 w-3"}):(0,b.jsx)(g.ChevronDown,{className:"h-3 w-3"}),(0,b.jsx)(I,{className:"h-3 w-3"}),"Pinned",(0,b.jsx)("span",{className:"ml-auto text-[9px] tabular-nums opacity-60",children:aG.length})]}),!aC&&aG.map(a=>(0,b.jsxs)(cF,{children:[(0,b.jsx)(cH,{asChild:!0,children:(0,b.jsxs)("div",{role:"button",tabIndex:0,className:(0,Z.cn)("group flex items-center gap-1.5 rounded-sm px-2 py-1 text-sm cursor-pointer transition-colors select-none",bg?.path===a.path?"bg-accent-soft text-foreground font-medium":"hover:bg-muted"),onClick:()=>{cV(a)},onKeyDown:b=>{("Enter"===b.key||" "===b.key)&&(b.preventDefault(),cV(a))},children:[(0,b.jsx)(es,{name:a.name,type:a.type??"file"}),(0,b.jsx)("span",{className:"min-w-0 flex-1 truncate text-xs",title:bz?a.name:void 0,children:bz?ea(a.name):a.name}),(0,b.jsx)("span",{className:"max-w-[80px] truncate text-[10px] text-muted-foreground/60",children:a.path.split("/").slice(0,-1).join("/")}),(0,b.jsx)("button",{type:"button",className:"hover-reveal shrink-0 rounded p-0.5 text-muted-foreground/50 opacity-0 transition-colors hover:bg-muted hover:text-amber-400 group-hover:opacity-100 focus:opacity-100",title:"Remove from pinned",onClick:b=>{b.stopPropagation(),cZ.getState().toggle({path:a.path,name:a.name},V)},children:(0,b.jsx)(S.X,{className:"h-3 w-3"})})]})}),(0,b.jsx)(er,{node:{path:a.path,name:a.name,type:a.type??"file"},ctx:dv,isPinned:!0,activeWorkspaceId:V})]},a.path))]}),aB.length>0&&(0,b.jsxs)("div",{className:"border-b mb-1",children:[(0,b.jsxs)("button",{type:"button",className:"flex w-full items-center gap-1 px-2 py-1 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground hover:text-foreground",onClick:()=>aF(a=>!a),children:[aE?(0,b.jsx)(h.ChevronRight,{className:"h-3 w-3"}):(0,b.jsx)(g.ChevronDown,{className:"h-3 w-3"}),(0,b.jsx)(v,{className:"h-3 w-3"}),"Recent",(0,b.jsx)("span",{className:"ml-auto text-[9px] tabular-nums opacity-60",children:aB.length})]}),!aE&&aB.slice(0,8).map(a=>(0,b.jsxs)(cF,{children:[(0,b.jsx)(cH,{asChild:!0,children:(0,b.jsxs)("div",{role:"button",tabIndex:0,className:(0,Z.cn)("flex items-center gap-1.5 rounded-sm px-2 py-1 text-sm cursor-pointer transition-colors select-none",bg?.path===a.path?"bg-accent-soft text-foreground font-medium":"hover:bg-muted"),onClick:()=>{cT({path:a.path,name:a.name,type:a.type??"file",modifiedAt:""}),bu&&bw(!0)},onKeyDown:b=>{("Enter"===b.key||" "===b.key)&&(b.preventDefault(),cT({path:a.path,name:a.name,type:a.type??"file",modifiedAt:""}))},children:[(0,b.jsx)(es,{name:a.name,type:a.type??"file"}),(0,b.jsx)("span",{className:"flex-1 truncate text-xs",title:bz?a.name:void 0,children:bz?ea(a.name):a.name}),(0,b.jsx)("span",{className:"text-[10px] text-muted-foreground/60 truncate max-w-[80px]",children:a.path.split("/").slice(0,-1).join("/")})]})}),(0,b.jsx)(er,{node:{path:a.path,name:a.name,type:a.type??"file"},ctx:dv,isPinned:aG.some(b=>b.path===a.path),activeWorkspaceId:V})]},a.path))]}),aQ?(0,b.jsx)("div",{className:"flex justify-center py-6",children:(0,b.jsx)(z.Loader2,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):0===aM.length?(0,b.jsxs)("div",{className:"flex flex-col items-center gap-3 px-4 py-8 text-center",children:[(0,b.jsx)("div",{className:"rounded-full bg-muted p-3",children:(0,b.jsx)(n.FileText,{className:"h-6 w-6 text-muted-foreground"})}),(0,b.jsxs)("div",{className:"space-y-1",children:[(0,b.jsx)("p",{className:"text-sm font-medium",children:"No files yet"}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:"Upload files or add them to the configured directory"})]}),(0,b.jsxs)(U.Button,{size:"sm",variant:"outline",className:"w-full gap-1.5 max-w-[180px]",onClick:()=>c5(""),disabled:aV,children:[aV?(0,b.jsx)(z.Loader2,{className:"h-3.5 w-3.5 animate-spin"}):(0,b.jsx)(R.Upload,{className:"h-3.5 w-3.5"}),"Upload Files"]})]}):(0,b.jsx)(eu,{ctx:dv,nodes:aM,openPath:bg?.path??null,dragOverPath:b6,branchDropdownNode:cC,branchDropdownPos:cE,nodeBranches:cu,branchesLoading:cy,checkingOutBranch:cA,pullingRepo:ce,activePaths:aJ,pins:aG,isMobile:bu,activeWorkspaceId:V,newFileParent:a5,newFileName:a7,fileCreateError:a9,newFolderParent:a_,newFolderName:a1,folderError:a3,sidebarScrollRef:aH})]}),(0,b.jsxs)("div",{className:"border-t px-2 py-2 bg-muted shrink-0",children:[(0,b.jsxs)(bJ.DropdownMenu,{modal:!1,onOpenChange:a=>{a||(aw(null),ay(null))},children:[(0,b.jsx)(bJ.DropdownMenuTrigger,{asChild:!0,children:(0,b.jsxs)(U.Button,{size:"sm",variant:"ghost",className:"w-full h-auto justify-between gap-2 px-2 py-1.5 text-left",title:p??"",children:[(0,b.jsxs)("span",{className:"flex flex-col min-w-0",children:[(0,b.jsx)("span",{className:"truncate text-xs font-medium",children:$.find(a=>a.id===V)?.name??"Workspace"}),(0,b.jsx)("span",{className:"truncate text-[10px] text-muted-foreground font-mono",children:p??""})]}),(0,b.jsx)(g.ChevronDown,{className:"h-3.5 w-3.5 shrink-0 opacity-60"})]})}),(0,b.jsxs)(bJ.DropdownMenuContent,{align:"start",className:"w-[var(--radix-dropdown-menu-trigger-width)]",onInteractOutside:a=>{a.target?.closest?.("[data-branch-portal]")&&a.preventDefault()},children:[$.map(a=>(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>void cX(a.id),onPointerMove:a=>a.preventDefault(),onPointerLeave:a=>a.preventDefault(),className:(0,Z.cn)("gap-2",a.id===V&&"font-medium"),children:[a.id===V?(0,b.jsx)(f.Check,{className:"h-3.5 w-3.5 shrink-0"}):(0,b.jsx)("span",{className:"w-3.5 shrink-0"}),(0,b.jsxs)("span",{className:"flex flex-col min-w-0 flex-1",children:[(0,b.jsxs)("span",{className:"flex items-center gap-1.5 truncate",children:[(0,b.jsx)("span",{className:"truncate",children:a.name}),a.git?aa?(0,b.jsxs)("button",{"data-branch-trigger":!0,type:"button",className:"inline-flex items-center gap-0.5 rounded bg-muted px-1.5 text-[10px] text-muted-foreground font-normal shrink-0 hover:bg-accent",title:"Switch branch",disabled:ar===a.id,onClick:b=>{if(b.stopPropagation(),b.preventDefault(),av===a.id){aw(null),ay(null);return}let c=b.currentTarget.getBoundingClientRect();ay({top:c.bottom+4,left:c.left}),aw(a.id),c1(a.id)},children:[(0,b.jsx)(r,{className:"h-2.5 w-2.5"})," ",a.git.branch??"branch"]}):(0,b.jsxs)("span",{className:"inline-flex items-center gap-0.5 rounded bg-muted px-1.5 text-[10px] text-muted-foreground font-normal shrink-0",children:[(0,b.jsx)(r,{className:"h-2.5 w-2.5"})," ",a.git.branch??"read-only"]}):a.ssh?(0,b.jsxs)("span",{className:"inline-flex items-center gap-0.5 rounded bg-muted px-1.5 text-[10px] text-muted-foreground font-normal shrink-0",children:[(0,b.jsx)(s,{className:"h-2.5 w-2.5"})," ",a.ssh.host]}):a.readOnly?(0,b.jsxs)("span",{className:"inline-flex items-center gap-0.5 rounded bg-muted px-1.5 text-[10px] text-muted-foreground font-normal shrink-0",children:[(0,b.jsx)(r,{className:"h-2.5 w-2.5"})," read-only"]}):null]}),(0,b.jsx)("span",{className:"truncate text-[10px] text-muted-foreground font-mono",children:a.rootDir}),a.git?.lastPulledAt&&ec(a.git.lastPulledAt)&&(0,b.jsxs)("span",{className:"text-[10px] text-muted-foreground/70",children:["synced ",ec(a.git.lastPulledAt)]})]}),aa&&a.git&&(0,b.jsx)("button",{className:(0,Z.cn)("shrink-0 rounded p-0.5 hover:bg-accent transition-colors",a.git.lastError?"text-destructive":"text-muted-foreground hover:text-foreground"),title:a.git.lastError?`Last refresh failed: ${a.git.lastError}`:"Refresh",disabled:an===a.id,onClick:b=>{b.stopPropagation(),b.preventDefault(),c0(a.id)},children:(0,b.jsx)(K,{className:(0,Z.cn)("h-3.5 w-3.5",an===a.id&&"animate-spin")})}),aa&&(0,b.jsx)("button",{className:"shrink-0 rounded p-0.5 text-muted-foreground hover:text-destructive hover:bg-destructive/10 transition-colors",title:"Delete workspace (does not delete files)",onClick:b=>{b.stopPropagation(),am(a.id)},children:(0,b.jsx)(Q.Trash2,{className:"h-3.5 w-3.5"})})]},a.id)),aa&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(bJ.DropdownMenuSeparator,{}),(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>aj(!0),children:[(0,b.jsx)(q,{className:"mr-2 h-3.5 w-3.5"}),"Add workspace…"]})]})]})]}),(()=>{if(!av||!ax)return null;let a=$.find(a=>a.id===av);return a?(0,b.jsx)(bS,{pos:ax,branches:(ap[a.id]??[]).map(b=>({name:b,current:b===a.git?.branch})),loading:!ap[a.id],busyName:ar===a.id?at:null,disabled:ar===a.id,onPick:b=>{c2(a.id,b)},onClose:()=>{aw(null),ay(null)}}):null})()]}),(0,b.jsx)("div",{role:"separator","aria-orientation":"vertical","aria-label":"Resize sidebar",title:"Drag to resize",onMouseDown:a=>{a.preventDefault();let b=a.clientX;bF(!0);let c=document.body.style.cursor,d=document.body.style.userSelect;document.body.style.cursor="col-resize",document.body.style.userSelect="none";let e=a=>{bC(bx+(a.clientX-b))},f=()=>{bF(!1),document.body.style.cursor=c,document.body.style.userSelect=d,window.removeEventListener("mousemove",e),window.removeEventListener("mouseup",f)};window.addEventListener("mousemove",e),window.addEventListener("mouseup",f)},onDoubleClick:()=>bC(288),onKeyDown:a=>{"ArrowLeft"===a.key?(a.preventDefault(),bC(bx-16)):"ArrowRight"===a.key&&(a.preventDefault(),bC(bx+16))},tabIndex:0,"aria-valuemin":200,"aria-valuemax":600,"aria-valuenow":bx,className:(0,Z.cn)("absolute right-0 top-0 z-20 h-full w-1.5 cursor-col-resize -mr-px transition-colors hover:bg-primary/40 focus:bg-primary/40 focus:outline-none hidden md:block",bD&&"bg-primary/60")})]}),(0,b.jsxs)("div",{className:"flex-1 flex flex-col min-w-0 relative",children:[bv&&(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"hidden md:flex absolute left-2 top-2 z-10 h-7 w-7 p-0",title:"Show sidebar",onClick:()=>bw(!1),children:(0,b.jsx)(E,{className:"h-3.5 w-3.5"})}),(0,b.jsxs)("div",{className:"md:hidden flex h-11 shrink-0 items-center justify-between gap-2 border-b bg-muted px-1",children:[(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-9 w-9 p-0",title:"Show sidebar",onClick:()=>{bw(!1),c_.useAIPanelStore.getState().close()},children:(0,b.jsx)(E,{className:"h-4 w-4"})}),(0,b.jsxs)("span",{className:"flex min-w-0 items-center gap-1.5 text-xs font-semibold tracking-tight text-muted-foreground",title:bg?.path,children:[bg&&(0,b.jsx)("span",{className:"editorial-tree-typeicon shrink-0",children:"app"===dk||"html"===dk?(0,b.jsx)(u.Globe,{className:"h-4 w-4 text-foreground/70"}):ej(bg.name)?(0,b.jsx)(x.default,{className:"h-4 w-4 text-sunshine-700"}):eh(bg.name)?(0,b.jsx)(n.FileText,{className:"h-4 w-4 text-foreground/70"}):(0,b.jsx)(l.File,{className:"h-4 w-4 text-foreground/60"})}),(0,b.jsx)("span",{className:"truncate",children:bg?bg.name:"Wiki Viewer"})]}),(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-9 w-9 p-0",title:"AI Agent panel",onClick:()=>{c_.useAIPanelStore.getState().open(),bw(!0)},children:(0,b.jsx)(e,{className:"h-4 w-4"})})]}),bg?"node-app"===dk?(0,b.jsx)(bL,{path:bg.path,title:bg.name}):"app"===dk||"html"===dk?(a="html"===dk?`/api/assets/${bg.path}`:void 0,bk?(0,b.jsx)(bG,{path:bg.path,title:bg.name,src:a,fullscreen:!0,onExit:()=>bl(!1)}):(0,b.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden min-w-0",children:[(0,b.jsxs)("div",{className:(0,Z.cn)("flex items-center justify-between px-4 py-2 border-b bg-muted shrink-0 editorial-doc-header",!bu&&bv&&"pl-11"),children:[(0,b.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,b.jsx)("span",{className:"hidden md:inline-flex",children:(0,b.jsx)("span",{className:"editorial-tree-typeicon",children:(0,b.jsx)(u.Globe,{className:"h-4 w-4 shrink-0 text-foreground/70"})})}),(0,b.jsx)("span",{className:"hidden md:inline text-sm font-normal truncate",title:bg.path,children:bg.path})]}),(0,b.jsxs)("div",{className:"flex items-center gap-1 shrink-0",children:[df(bg,(0,b.jsxs)(b.Fragment,{children:["html"===dk&&!bW&&(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>b0(a=>!a),children:[b$?(0,b.jsx)(u.Globe,{className:"mr-2 h-3.5 w-3.5"}):(0,b.jsx)(t.Code2,{className:"mr-2 h-3.5 w-3.5"}),b$?"Show preview":"Show source"]}),(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>bo(a=>a+1),children:[(0,b.jsx)(K,{className:"mr-2 h-3.5 w-3.5"}),"Refresh"]}),(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>bl(!0),children:[(0,b.jsx)(A,{className:"mr-2 h-3.5 w-3.5"}),"Open fullscreen"]}),(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>bM(!0),children:[(0,b.jsx)(M,{className:"mr-2 h-3.5 w-3.5"}),"Share"]})]})),"html"===dk&&!bW&&null!==bN&&(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",title:"Edit source",onClick:()=>{bX(!0),bZ(bN),b4(null)},children:(0,b.jsx)(F,{className:"h-3.5 w-3.5"})}),(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",onClick:()=>{bh(null),bX(!1)},children:(0,b.jsx)(S.X,{className:"h-3.5 w-3.5"})})]})]}),bW&&"html"===dk?(0,b.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden min-h-0",children:[(0,b.jsx)("textarea",{value:bY,onChange:a=>bZ(a.target.value),spellCheck:!1,className:"flex-1 w-full min-h-0 resize-none bg-background text-foreground px-4 py-3 font-mono text-[13px] leading-relaxed outline-none border-0"}),(0,b.jsxs)("div",{className:"border-t px-4 py-2 flex items-center justify-end gap-2 bg-muted shrink-0",children:[b3&&(0,b.jsx)("span",{className:"text-xs text-destructive mr-auto",children:b3}),(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",onClick:()=>{bX(!1),b4(null)},children:"Cancel"}),(0,b.jsxs)(U.Button,{size:"sm",className:"gap-1",onClick:c3,disabled:b1,children:[b1&&(0,b.jsx)(z.Loader2,{className:"h-3 w-3 animate-spin"}),"Save"]})]})]}):b$&&"html"===dk?(0,b.jsx)(bE,{path:bg.path,title:bg.name}):(0,b.jsx)(bG,{path:bg.path,title:bg.name,src:a},bm)]})):(0,b.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden min-w-0",children:[(0,b.jsxs)("div",{className:(0,Z.cn)("flex items-center justify-between px-4 py-2 border-b bg-muted shrink-0 editorial-doc-header",!bu&&bv&&"pl-11"),children:[(0,b.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,b.jsx)("span",{className:"hidden md:inline-flex",children:(0,b.jsx)("span",{className:"editorial-tree-typeicon",children:ej(bg.name)?(0,b.jsx)(x.default,{className:"h-4 w-4 shrink-0 text-sunshine-700"}):eh(bg.name)?(0,b.jsx)(n.FileText,{className:"h-4 w-4 shrink-0 text-foreground/70"}):(0,b.jsx)(l.File,{className:"h-4 w-4 shrink-0 text-foreground/60"})})}),(0,b.jsx)("span",{className:"hidden md:inline text-sm font-normal truncate",title:bg.path,children:bg.path}),cg&&(0,b.jsxs)("span",{className:"hidden md:flex items-center gap-1 text-[11px] text-muted-foreground shrink-0 ml-1",children:[(0,b.jsx)(w,{className:"h-3 w-3 shrink-0"}),(0,b.jsx)("span",{className:"truncate max-w-[100px]",children:cg.author}),(0,b.jsx)("span",{title:new Date(cg.date).toLocaleString(),className:"shrink-0",children:ec(cg.date)})]})]}),(0,b.jsxs)("div",{className:"flex items-center gap-1 shrink-0",children:[df(bg,(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>{ci?cj(!1):cK()},children:[(0,b.jsx)(v,{className:"mr-2 h-3.5 w-3.5"}),ci?"Hide history":"File history"]}),(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>bM(!0),children:[(0,b.jsx)(M,{className:"mr-2 h-3.5 w-3.5"}),"Share"]}),!bW&&(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:cR,disabled:bU,children:[bU?(0,b.jsx)(z.Loader2,{className:"mr-2 h-3.5 w-3.5 animate-spin"}):(0,b.jsx)(K,{className:"mr-2 h-3.5 w-3.5"}),"Refresh"]}),dr&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(bJ.DropdownMenuSeparator,{}),(0,b.jsx)(bJ.DropdownMenuLabel,{className:"text-[11px] text-muted-foreground",children:"Width"}),d2.VIEW_WIDTH_ORDER.map(a=>(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>dp(a),className:"flex items-center justify-between text-xs",children:[d2.VIEW_WIDTH_LABEL[a],a===dm&&(0,b.jsx)(f.Check,{className:"h-3.5 w-3.5"})]},a)),(0,b.jsx)(bJ.DropdownMenuSeparator,{}),(0,b.jsx)(bJ.DropdownMenuLabel,{className:"text-[11px] text-muted-foreground",children:"Alignment"}),d2.VIEW_ALIGN_ORDER.map(a=>(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>dq(a),className:"flex items-center justify-between text-xs",children:[d2.VIEW_ALIGN_LABEL[a],a===dn&&(0,b.jsx)(f.Check,{className:"h-3.5 w-3.5"})]},a))]})]})),eh(bg.name)&&!bW&&(null!==bN||ei(bg.name))&&(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",onClick:()=>{bX(!0),bZ(bN??""),b4(null),ei(bg.name)&&c8.useEditorStore.getState().loadPage(bg.path)},children:(0,b.jsx)(F,{className:"h-3.5 w-3.5"})}),eh(bg.name)&&bW&&ei(bg.name)&&(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",title:"Done editing",onClick:()=>{bX(!1),b4(null)},children:(0,b.jsx)(G.Eye,{className:"h-3.5 w-3.5"})}),(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",onClick:()=>{bh(null),bO(null),bX(!1)},children:(0,b.jsx)(S.X,{className:"h-3.5 w-3.5"})})]})]}),ci&&(0,b.jsxs)("div",{className:"border-b bg-muted/30 shrink-0 max-h-[40vh] overflow-auto",children:[(0,b.jsxs)("div",{className:"flex items-center justify-between px-4 py-1.5 border-b",children:[(0,b.jsx)("span",{className:"text-xs font-semibold text-muted-foreground",children:"History"}),(0,b.jsx)("button",{type:"button",className:"text-muted-foreground hover:text-foreground",onClick:()=>cj(!1),children:(0,b.jsx)(S.X,{className:"h-3.5 w-3.5"})})]}),cm?(0,b.jsx)("div",{className:"flex justify-center py-4",children:(0,b.jsx)(z.Loader2,{className:"h-4 w-4 animate-spin text-muted-foreground"})}):0===ck.length?(0,b.jsx)("p",{className:"px-4 py-3 text-xs text-muted-foreground",children:"No history found."}):(0,b.jsx)("div",{children:ck.map(a=>(0,b.jsxs)("div",{children:[(0,b.jsx)("button",{type:"button",className:(0,Z.cn)("w-full text-left px-4 py-2 hover:bg-muted transition-colors",co===a.sha&&"bg-muted"),onClick:()=>void cL(a.sha),children:(0,b.jsxs)("div",{className:"flex items-center gap-2",children:[(0,b.jsx)("code",{className:"text-[11px] font-mono text-muted-foreground shrink-0",children:a.shortSha}),(0,b.jsx)("span",{className:"flex-1 truncate text-xs",children:a.message}),(0,b.jsx)("span",{className:"shrink-0 text-[11px] text-muted-foreground",children:a.author}),(0,b.jsx)("span",{className:"shrink-0 text-[11px] text-muted-foreground",title:new Date(a.date).toLocaleString(),children:ec(a.date)})]})}),co===a.sha&&(0,b.jsx)("div",{className:"border-t",children:cs?(0,b.jsx)("div",{className:"flex justify-center py-3",children:(0,b.jsx)(z.Loader2,{className:"h-4 w-4 animate-spin text-muted-foreground"})}):null!==cq?(0,b.jsx)("pre",{className:"overflow-auto px-4 py-2 text-[11px] font-mono leading-relaxed whitespace-pre text-foreground/80 max-h-60",children:cq}):null})]},a.sha))})]}),dl?(0,b.jsx)(ag,{path:bg.path,size:bg.size??0,onOpen:()=>bj(bg.path)}):bW?(0,b.jsx)("div",{className:"flex-1 flex flex-col overflow-hidden min-h-0",children:ei(bg.name)?(0,b.jsx)(ac.KBEditor,{}):(0,b.jsx)("textarea",{value:bY,onChange:a=>bZ(a.target.value),spellCheck:!1,className:"flex-1 w-full min-h-0 resize-none bg-background text-foreground px-4 py-3 font-mono text-[13px] leading-relaxed outline-none border-0"})}):ei(bg.name)?(0,b.jsx)("div",{className:"flex-1 flex flex-col overflow-hidden min-h-0",children:bU?(0,b.jsx)("div",{className:"flex justify-center py-8",children:(0,b.jsx)(z.Loader2,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):(0,b.jsx)(ac.KBEditor,{mode:"viewing"})}):"csv"===dk||"pdf"===dk||"mermaid"===dk||"notebook"===dk||"image"===dk||"media"===dk||"docx"===dk||"xlsx"===dk||"pptx"===dk||"source"===dk||"fallback"===dk?(0,b.jsx)("div",{className:"flex-1 flex flex-col overflow-hidden min-h-0",children:bU?(0,b.jsx)("div",{className:"flex justify-center py-8",children:(0,b.jsx)(z.Loader2,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):"csv"===dk?(0,b.jsx)(ab,{path:bg.path,title:bg.name}):"pdf"===dk?(0,b.jsx)(eb,{path:bg.path,title:bg.name}):"mermaid"===dk?(0,b.jsx)(ak,{path:bg.path,title:bg.name}):"notebook"===dk?(0,b.jsx)(bn,{path:bg.path,title:bg.name}):"image"===dk?(0,b.jsx)(ah,{path:bg.path,title:bg.name}):"media"===dk?(0,b.jsx)(ai,{path:bg.path,title:bg.name,type:["mp4","webm","mov","m4v"].includes(ee(bg.name))?"video":"audio"}):"docx"===dk?(0,b.jsx)(bp,{path:bg.path,title:bg.name}):"xlsx"===dk?(0,b.jsx)(br,{path:bg.path,title:bg.name}):"pptx"===dk?(0,b.jsx)(bq,{path:bg.path,title:bg.name}):"source"===dk?(0,b.jsx)(bE,{path:bg.path,title:bg.name}):(0,b.jsx)(ad,{path:bg.path,title:bg.name})},bs):(0,b.jsx)("div",{className:"flex-1 overflow-auto p-4 min-h-0",children:(0,b.jsx)("div",{className:(0,Z.cn)("w-full",dt,ds),children:bU?(0,b.jsx)("div",{className:"flex justify-center py-8",children:(0,b.jsx)(z.Loader2,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):null!==bN?(0,b.jsx)("pre",{className:"text-xs font-mono whitespace-pre-wrap break-words leading-relaxed",children:bN}):eh(bg.name)?(0,b.jsx)("p",{className:"text-sm text-muted-foreground",children:"Could not load file."}):(0,b.jsx)("p",{className:"text-sm text-muted-foreground",children:"Preview not available for this file type."})})}),bW&&!ei(bg.name)&&(0,b.jsxs)("div",{className:"border-t px-4 py-2 flex items-center justify-end gap-2 bg-muted shrink-0",children:[b3&&(0,b.jsx)("span",{className:"text-xs text-destructive mr-auto",children:b3}),(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",onClick:()=>{bX(!1),b4(null)},children:"Cancel"}),(0,b.jsxs)(U.Button,{size:"sm",className:"gap-1",onClick:c3,disabled:b1,children:[b1&&(0,b.jsx)(z.Loader2,{className:"h-3 w-3 animate-spin"}),"Save"]})]})]}):(0,b.jsx)("div",{className:"flex-1 flex flex-col items-center justify-center",children:(0,b.jsxs)("div",{className:"flex flex-col items-center gap-2 text-center px-4",children:[(0,b.jsx)(n.FileText,{className:"h-8 w-8 text-muted-foreground"}),(0,b.jsx)("p",{className:"text-sm text-muted-foreground",children:"Select a file to view or edit"})]})})]}),(0,b.jsx)(cv,{open:bK,onOpenChange:bM,filePath:bg?.path??""}),(0,b.jsx)(b9,{open:bH,onOpenChange:bI}),(0,b.jsx)(dg,{currentPath:bg?.path}),(0,b.jsx)("input",{ref:aZ,type:"file",multiple:!0,className:"hidden",onChange:a=>{a.target.files&&c4(a.target.files,a$.current)}}),(0,b.jsx)(W,{open:!!bb,onOpenChange:a=>{a||bc(null)},title:bd?"Delete folder?":"Delete file?",description:bd?`"${bb?.split("/").pop()}" and all its contents will be permanently deleted.`:`"${bb?.split("/").pop()}" will be permanently removed.`,onConfirm:dh}),(0,b.jsx)(W,{open:!!al,onOpenChange:a=>{a||am(null)},title:"Delete workspace?",description:`"${$.find(a=>a.id===al)?.name??""}" will be removed from the workspace list. Files on disk are NOT deleted.`,onConfirm:c$})]})]},V??"none")}],240777)}];
17
+ ${b}/api/agent/files/${a??"<path/to/file.md>"}`;await navigator.clipboard.writeText(d),c(!0),setTimeout(()=>c(!1),1500)},[a])}}(a??null),[m,n]=(0,T.useState)(""),o=(0,T.useRef)(null),p="http://localhost:3000",q=(0,T.useCallback)(()=>de,[]),r=(0,T.useCallback)(()=>m.replace(/\$WIKI_URL/g,p),[m,p]),s=(0,T.useCallback)(()=>`npx wiki-viewer-mcp register --url ${p} --id ai:myagent --name "My Agent"`,[p]),t=(0,T.useCallback)(()=>JSON.stringify({servers:{"wiki-viewer":{command:"npx",args:["wiki-viewer-mcp"],env:{WIKI_VIEWER_URL:p,WIKI_VIEWER_TOKEN:"<token from register>",WIKI_VIEWER_AGENT_ID:"ai:myagent"}}}},null,2),[p]),u=df(q),v=df(r),w=df(s),x=df(t);return((0,T.useEffect)(()=>{if(c)return document.addEventListener("keydown",a),()=>document.removeEventListener("keydown",a);function a(a){"Escape"===a.key&&d()}},[c,d]),(0,T.useEffect)(()=>{c&&o.current?.focus()},[c]),(0,T.useEffect)(()=>{if(!c)return;j();let a=setInterval(()=>void j(),1e4);return()=>clearInterval(a)},[c,j]),(0,T.useEffect)(()=>{c&&fetch("/api/agents/install").then(a=>a.json()).then(a=>{a.bootstrapPrompt&&n(a.bootstrapPrompt)}).catch(()=>void 0)},[c]),c)?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)("div",{className:"fixed inset-0 z-40 bg-overlay backdrop-blur-[1px]",onClick:d,"aria-hidden":!0}),(0,b.jsxs)("aside",{ref:o,tabIndex:-1,role:"dialog","aria-modal":"true","aria-label":"AI Agent Panel",className:"fixed right-0 top-0 bottom-0 z-50 flex w-[90vw] max-w-sm md:w-80 flex-col border-l border-border bg-background shadow-xl outline-none",children:[(0,b.jsxs)("div",{className:"flex items-center justify-between border-b border-border px-4 py-3 shrink-0",children:[(0,b.jsxs)("div",{className:"flex items-center gap-2",children:[(0,b.jsx)(e,{className:"h-4 w-4 text-muted-foreground"}),(0,b.jsx)("span",{className:"text-sm font-semibold",children:"AI Agent"})]}),(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",onClick:d,title:"Close panel (Esc)",children:(0,b.jsx)(S.X,{className:"h-3.5 w-3.5"})})]}),(0,b.jsxs)("div",{className:"flex-1 overflow-y-auto space-y-5 px-4 py-4",children:[(0,b.jsxs)("section",{className:"rounded-md border border-border bg-muted/30 p-3",children:[(0,b.jsx)("p",{className:"text-sm font-medium text-foreground",children:"Work with this wiki using AI"}),(0,b.jsxs)("p",{className:"mt-1 text-xs leading-relaxed text-muted-foreground",children:["Connect Claude, Cursor, ChatGPT, and more. Pick by what you want — each option gives a copy-paste setup. You approve every assistant in ",(0,b.jsx)("span",{className:"font-medium text-foreground/80",children:"Agents"})," below before it gets access."]})]}),(0,b.jsxs)("section",{className:"space-y-3",children:[(0,b.jsxs)("div",{className:"rounded-md border border-border bg-muted/40 p-3 space-y-1.5",children:[(0,b.jsx)("p",{className:"text-xs font-semibold text-foreground",children:"Co-write docs with you"}),(0,b.jsx)("p",{className:"text-[10px] text-muted-foreground/70",children:"Edits arrive as suggestions with comments you accept or revert. No MCP needed."}),(0,b.jsx)(U.Button,{size:"sm",variant:"outline",className:"h-7 w-full text-xs gap-1.5",onClick:()=>void v.copy(),disabled:!m,children:v.copied?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(f.Check,{className:"h-3.5 w-3.5 text-green-500"})," Copied!"]}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(i.Copy,{className:"h-3.5 w-3.5"})," Paste into any chatbot"]})}),(0,b.jsxs)("p",{className:"text-[10px] text-muted-foreground/50 pt-1",children:["Or install once so it sticks"," ",(0,b.jsx)("span",{className:"text-muted-foreground/40",children:"· Claude, OpenCode"}),":"]}),(0,b.jsxs)("div",{className:"flex items-center gap-2",children:[(0,b.jsx)("code",{className:"flex-1 text-[10px] font-mono text-foreground/80 truncate bg-muted rounded px-1 py-0.5",children:de}),(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0 shrink-0",title:"Copy this command",onClick:()=>void u.copy(),children:u.copied?(0,b.jsx)(f.Check,{className:"h-3.5 w-3.5 text-green-500"}):(0,b.jsx)(i.Copy,{className:"h-3.5 w-3.5"})})]})]}),(0,b.jsxs)("div",{className:"rounded-md border border-border bg-muted/40 p-3 space-y-1.5",children:[(0,b.jsxs)("p",{className:"text-xs font-semibold text-foreground",children:["Edit files directly"," ",(0,b.jsx)("span",{className:"font-normal text-muted-foreground/60",children:"· Claude Code, Cursor, Codex"})]}),(0,b.jsx)("p",{className:"text-[10px] text-muted-foreground/70",children:"Native read / search / edit tools over MCP. Run to request access:"}),(0,b.jsxs)("div",{className:"flex items-center gap-2",children:[(0,b.jsx)("code",{className:"flex-1 text-[10px] font-mono text-foreground/80 truncate bg-muted rounded px-1 py-0.5",children:s()}),(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0 shrink-0",title:"Copy this command",onClick:()=>void w.copy(),children:w.copied?(0,b.jsx)(f.Check,{className:"h-3.5 w-3.5 text-green-500"}):(0,b.jsx)(i.Copy,{className:"h-3.5 w-3.5"})})]}),(0,b.jsxs)("p",{className:"text-[10px] text-muted-foreground/50",children:["Approve in ",(0,b.jsx)("span",{className:"font-medium text-foreground/70",children:"Agents"}),", then add to your tool:"]}),(0,b.jsx)(U.Button,{size:"sm",variant:"outline",className:"h-7 w-full text-xs gap-1.5",onClick:()=>void x.copy(),children:x.copied?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(f.Check,{className:"h-3.5 w-3.5 text-green-500"})," Copied!"]}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(i.Copy,{className:"h-3.5 w-3.5"})," Copy config (mcp.json)"]})})]}),(0,b.jsxs)("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1",children:[(0,b.jsx)("span",{className:"text-[10px] text-muted-foreground/50",children:"For developers:"}),(0,b.jsxs)("button",{type:"button",onClick:()=>void l(),className:"inline-flex items-center gap-1 text-[10px] text-primary hover:underline",children:[k?(0,b.jsx)(f.Check,{className:"h-3 w-3 text-green-500"}):(0,b.jsx)(i.Copy,{className:"h-3 w-3"})," curl example"]}),(0,b.jsxs)("a",{href:"/api/agents/skill",target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1 text-[10px] text-primary hover:underline",children:[(0,b.jsx)(ae.ExternalLink,{className:"h-3 w-3"})," skill"]}),(0,b.jsxs)("a",{href:"/api/agents/install",target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1 text-[10px] text-primary hover:underline",children:[(0,b.jsx)(ae.ExternalLink,{className:"h-3 w-3"})," install JSON"]})]})]}),(0,b.jsx)(c7,{}),(0,b.jsxs)("section",{className:"space-y-2",children:[(0,b.jsxs)("h3",{className:"text-xs font-semibold uppercase tracking-widest text-muted-foreground",children:["Active Connections"," ",(0,b.jsx)("span",{className:"normal-case font-normal text-muted-foreground/50",children:"(last 5 min)"})]}),(0,b.jsx)("div",{className:"rounded-md border border-border bg-muted/40 p-3",children:0===h.length?(0,b.jsxs)("p",{className:"text-xs text-muted-foreground/60 flex items-center gap-1.5",children:[(0,b.jsx)(c$,{className:"h-3.5 w-3.5"}),"No recent activity"]}):(0,b.jsx)("ul",{className:"space-y-1.5",children:h.map(a=>(0,b.jsxs)("li",{className:"flex items-center justify-between text-xs",children:[(0,b.jsx)("span",{className:"font-mono text-foreground/80 truncate",children:a.by}),(0,b.jsxs)("span",{className:"text-muted-foreground shrink-0",children:[a.opCount," op",1!==a.opCount?"s":""]})]},a.by))})})]}),(0,b.jsxs)("section",{className:"space-y-2",children:[(0,b.jsx)("h3",{className:"text-xs font-semibold uppercase tracking-widest text-muted-foreground",children:"Recent Activity"}),(0,b.jsx)("div",{className:"rounded-md border border-border bg-muted/40 px-3 py-2 max-h-72 overflow-y-auto",children:(0,b.jsx)(dd,{activity:g})})]}),(0,b.jsx)("section",{children:(0,b.jsx)("a",{href:"/docs/agent-collab-plan.md",target:"_blank",rel:"noreferrer",className:"text-xs text-primary underline hover:no-underline",children:"Agent collaboration docs →"})})]})]})]}):null}var dh=a.i(503442),di=a.i(670576),dj=/[\\\/_+.#"@\[\(\{&]/,dk=/[\\\/_+.#"@\[\(\{&]/g,dl=/[\s-]/,dm=/[\s-]/g;function dn(a){return a.toLowerCase().replace(dm," ")}var dp=a.i(105305),dq=a.i(359231),dr='[cmdk-group=""]',ds='[cmdk-group-items=""]',dt='[cmdk-item=""]',du=`${dt}:not([aria-disabled="true"])`,dv="cmdk-item-select",dw="data-value",dx=(a,b,c)=>{var d;return d=a,function a(b,c,d,e,f,g,h){if(g===c.length)return f===b.length?1:.99;var i=`${f},${g}`;if(void 0!==h[i])return h[i];for(var j,k,l,m,n=e.charAt(g),o=d.indexOf(n,f),p=0;o>=0;)(j=a(b,c,d,e,o+1,g+1,h))>p&&(o===f?j*=1:dj.test(b.charAt(o-1))?(j*=.8,(l=b.slice(f,o-1).match(dk))&&f>0&&(j*=Math.pow(.999,l.length))):dl.test(b.charAt(o-1))?(j*=.9,(m=b.slice(f,o-1).match(dm))&&f>0&&(j*=Math.pow(.999,m.length))):(j*=.17,f>0&&(j*=Math.pow(.999,o-f))),b.charAt(o)!==c.charAt(g)&&(j*=.9999)),(j<.1&&d.charAt(o-1)===e.charAt(g+1)||e.charAt(g+1)===e.charAt(g)&&d.charAt(o-1)!==e.charAt(g))&&.1*(k=a(b,c,d,e,o+1,g+2,h))>j&&(j=.1*k),j>p&&(p=j),o=d.indexOf(n,o+1);return h[i]=p,p}(d=c&&c.length>0?`${d+" "+c.join(" ")}`:d,b,dn(d),dn(b),0,0,{})},dy=T.createContext(void 0),dz=T.createContext(void 0),dA=T.createContext(void 0),dB=T.forwardRef((a,b)=>{let c=dL(()=>{var b,c;return{search:"",value:null!=(c=null!=(b=a.value)?b:a.defaultValue)?c:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),d=dL(()=>new Set),e=dL(()=>new Map),f=dL(()=>new Map),g=dL(()=>new Set),h=dJ(a),{label:i,children:j,value:k,onValueChange:l,filter:m,shouldFilter:n,loop:o,disablePointerSelection:p=!1,vimBindings:q=!0,...r}=a,s=(0,dq.useId)(),t=(0,dq.useId)(),u=(0,dq.useId)(),v=T.useRef(null),w=dO();dK(()=>{if(void 0!==k){let a=k.trim();c.current.value=a,x.emit()}},[k]),dK(()=>{w(6,D)},[]);let x=T.useMemo(()=>({subscribe:a=>(g.current.add(a),()=>g.current.delete(a)),snapshot:()=>c.current,setState:(a,b,d)=>{var e,f,g,i;if(!Object.is(c.current[a],b)){if(c.current[a]=b,"search"===a)C(),A(),w(1,B);else if("value"===a){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let a=document.getElementById(u);a?a.focus():null==(e=document.getElementById(s))||e.focus()}if(w(7,()=>{var a;c.current.selectedItemId=null==(a=E())?void 0:a.id,x.emit()}),d||w(5,D),(null==(f=h.current)?void 0:f.value)!==void 0){null==(i=(g=h.current).onValueChange)||i.call(g,null!=b?b:"");return}}x.emit()}},emit:()=>{g.current.forEach(a=>a())}}),[]),y=T.useMemo(()=>({value:(a,b,d)=>{var e;b!==(null==(e=f.current.get(a))?void 0:e.value)&&(f.current.set(a,{value:b,keywords:d}),c.current.filtered.items.set(a,z(b,d)),w(2,()=>{A(),x.emit()}))},item:(a,b)=>(d.current.add(a),b&&(e.current.has(b)?e.current.get(b).add(a):e.current.set(b,new Set([a]))),w(3,()=>{C(),A(),c.current.value||B(),x.emit()}),()=>{f.current.delete(a),d.current.delete(a),c.current.filtered.items.delete(a);let b=E();w(4,()=>{C(),(null==b?void 0:b.getAttribute("id"))===a&&B(),x.emit()})}),group:a=>(e.current.has(a)||e.current.set(a,new Set),()=>{f.current.delete(a),e.current.delete(a)}),filter:()=>h.current.shouldFilter,label:i||a["aria-label"],getDisablePointerSelection:()=>h.current.disablePointerSelection,listId:s,inputId:u,labelId:t,listInnerRef:v}),[]);function z(a,b){var d,e;let f=null!=(e=null==(d=h.current)?void 0:d.filter)?e:dx;return a?f(a,c.current.search,b):0}function A(){if(!c.current.search||!1===h.current.shouldFilter)return;let a=c.current.filtered.items,b=[];c.current.filtered.groups.forEach(c=>{let d=e.current.get(c),f=0;d.forEach(b=>{f=Math.max(a.get(b),f)}),b.push([c,f])});let d=v.current;F().sort((b,c)=>{var d,e;let f=b.getAttribute("id"),g=c.getAttribute("id");return(null!=(d=a.get(g))?d:0)-(null!=(e=a.get(f))?e:0)}).forEach(a=>{let b=a.closest(ds);b?b.appendChild(a.parentElement===b?a:a.closest(`${ds} > *`)):d.appendChild(a.parentElement===d?a:a.closest(`${ds} > *`))}),b.sort((a,b)=>b[1]-a[1]).forEach(a=>{var b;let c=null==(b=v.current)?void 0:b.querySelector(`${dr}[${dw}="${encodeURIComponent(a[0])}"]`);null==c||c.parentElement.appendChild(c)})}function B(){let a=F().find(a=>"true"!==a.getAttribute("aria-disabled")),b=null==a?void 0:a.getAttribute(dw);x.setState("value",b||void 0)}function C(){var a,b,g,i;if(!c.current.search||!1===h.current.shouldFilter){c.current.filtered.count=d.current.size;return}c.current.filtered.groups=new Set;let j=0;for(let e of d.current){let d=z(null!=(b=null==(a=f.current.get(e))?void 0:a.value)?b:"",null!=(i=null==(g=f.current.get(e))?void 0:g.keywords)?i:[]);c.current.filtered.items.set(e,d),d>0&&j++}for(let[a,b]of e.current)for(let d of b)if(c.current.filtered.items.get(d)>0){c.current.filtered.groups.add(a);break}c.current.filtered.count=j}function D(){var a,b,c;let d=E();d&&((null==(a=d.parentElement)?void 0:a.firstChild)===d&&(null==(c=null==(b=d.closest(dr))?void 0:b.querySelector('[cmdk-group-heading=""]'))||c.scrollIntoView({block:"nearest"})),d.scrollIntoView({block:"nearest"}))}function E(){var a;return null==(a=v.current)?void 0:a.querySelector(`${dt}[aria-selected="true"]`)}function F(){var a;return Array.from((null==(a=v.current)?void 0:a.querySelectorAll(du))||[])}function G(a){let b=F()[a];b&&x.setState("value",b.getAttribute(dw))}function H(a){var b;let c=E(),d=F(),e=d.findIndex(a=>a===c),f=d[e+a];null!=(b=h.current)&&b.loop&&(f=e+a<0?d[d.length-1]:e+a===d.length?d[0]:d[e+a]),f&&x.setState("value",f.getAttribute(dw))}function I(a){let b=E(),c=null==b?void 0:b.closest(dr),d;for(;c&&!d;)d=null==(c=a>0?function(a,b){let c=a.nextElementSibling;for(;c;){if(c.matches(b))return c;c=c.nextElementSibling}}(c,dr):function(a,b){let c=a.previousElementSibling;for(;c;){if(c.matches(b))return c;c=c.previousElementSibling}}(c,dr))?void 0:c.querySelector(du);d?x.setState("value",d.getAttribute(dw)):H(a)}let J=()=>G(F().length-1),K=a=>{a.preventDefault(),a.metaKey?J():a.altKey?I(1):H(1)},L=a=>{a.preventDefault(),a.metaKey?G(0):a.altKey?I(-1):H(-1)};return T.createElement(dp.Primitive.div,{ref:b,tabIndex:-1,...r,"cmdk-root":"",onKeyDown:a=>{var b;null==(b=r.onKeyDown)||b.call(r,a);let c=a.nativeEvent.isComposing||229===a.keyCode;if(!(a.defaultPrevented||c))switch(a.key){case"n":case"j":q&&a.ctrlKey&&K(a);break;case"ArrowDown":K(a);break;case"p":case"k":q&&a.ctrlKey&&L(a);break;case"ArrowUp":L(a);break;case"Home":a.preventDefault(),G(0);break;case"End":a.preventDefault(),J();break;case"Enter":{a.preventDefault();let b=E();if(b){let a=new Event(dv);b.dispatchEvent(a)}}}}},T.createElement("label",{"cmdk-label":"",htmlFor:y.inputId,id:y.labelId,style:dQ},i),dP(a,a=>T.createElement(dz.Provider,{value:x},T.createElement(dy.Provider,{value:y},a))))}),dC=T.forwardRef((a,b)=>{var c,d;let e=(0,dq.useId)(),f=T.useRef(null),g=T.useContext(dA),h=T.useContext(dy),i=dJ(a),j=null!=(d=null==(c=i.current)?void 0:c.forceMount)?d:null==g?void 0:g.forceMount;dK(()=>{if(!j)return h.item(e,null==g?void 0:g.id)},[j]);let k=dN(e,f,[a.value,a.children,f],a.keywords),l=T.useContext(dz),m=dM(a=>a.value&&a.value===k.current),n=dM(a=>!!j||!1===h.filter()||!a.search||a.filtered.items.get(e)>0);function o(){var a,b;p(),null==(b=(a=i.current).onSelect)||b.call(a,k.current)}function p(){l.setState("value",k.current,!0)}if(T.useEffect(()=>{let b=f.current;if(!(!b||a.disabled))return b.addEventListener(dv,o),()=>b.removeEventListener(dv,o)},[n,a.onSelect,a.disabled]),!n)return null;let{disabled:q,value:r,onSelect:s,forceMount:t,keywords:u,...v}=a;return T.createElement(dp.Primitive.div,{ref:(0,ce.composeRefs)(f,b),...v,id:e,"cmdk-item":"",role:"option","aria-disabled":!!q,"aria-selected":!!m,"data-disabled":!!q,"data-selected":!!m,onPointerMove:q||h.getDisablePointerSelection()?void 0:p,onClick:q?void 0:o},a.children)}),dD=T.forwardRef((a,b)=>{let{heading:c,children:d,forceMount:e,...f}=a,g=(0,dq.useId)(),h=T.useRef(null),i=T.useRef(null),j=(0,dq.useId)(),k=T.useContext(dy),l=dM(a=>!!e||!1===k.filter()||!a.search||a.filtered.groups.has(g));dK(()=>k.group(g),[]),dN(g,h,[a.value,a.heading,i]);let m=T.useMemo(()=>({id:g,forceMount:e}),[e]);return T.createElement(dp.Primitive.div,{ref:(0,ce.composeRefs)(h,b),...f,"cmdk-group":"",role:"presentation",hidden:!l||void 0},c&&T.createElement("div",{ref:i,"cmdk-group-heading":"","aria-hidden":!0,id:j},c),dP(a,a=>T.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":c?j:void 0},T.createElement(dA.Provider,{value:m},a))))}),dE=T.forwardRef((a,b)=>{let{alwaysRender:c,...d}=a,e=T.useRef(null),f=dM(a=>!a.search);return c||f?T.createElement(dp.Primitive.div,{ref:(0,ce.composeRefs)(e,b),...d,"cmdk-separator":"",role:"separator"}):null}),dF=T.forwardRef((a,b)=>{let{onValueChange:c,...d}=a,e=null!=a.value,f=T.useContext(dz),g=dM(a=>a.search),h=dM(a=>a.selectedItemId),i=T.useContext(dy);return T.useEffect(()=>{null!=a.value&&f.setState("search",a.value)},[a.value]),T.createElement(dp.Primitive.input,{ref:b,...d,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":i.listId,"aria-labelledby":i.labelId,"aria-activedescendant":h,id:i.inputId,type:"text",value:e?a.value:g,onChange:a=>{e||f.setState("search",a.target.value),null==c||c(a.target.value)}})}),dG=T.forwardRef((a,b)=>{let{children:c,label:d="Suggestions",...e}=a,f=T.useRef(null),g=T.useRef(null),h=dM(a=>a.selectedItemId),i=T.useContext(dy);return T.useEffect(()=>{if(g.current&&f.current){let a=g.current,b=f.current,c,d=new ResizeObserver(()=>{c=requestAnimationFrame(()=>{let c=a.offsetHeight;b.style.setProperty("--cmdk-list-height",c.toFixed(1)+"px")})});return d.observe(a),()=>{cancelAnimationFrame(c),d.unobserve(a)}}},[]),T.createElement(dp.Primitive.div,{ref:(0,ce.composeRefs)(f,b),...e,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":h,"aria-label":d,id:i.listId},dP(a,a=>T.createElement("div",{ref:(0,ce.composeRefs)(g,i.listInnerRef),"cmdk-list-sizer":""},a)))}),dH=T.forwardRef((a,b)=>{let{open:c,onOpenChange:d,overlayClassName:e,contentClassName:f,container:g,...h}=a;return T.createElement(bU.Root,{open:c,onOpenChange:d},T.createElement(bU.Portal,{container:g},T.createElement(bU.Overlay,{"cmdk-overlay":"",className:e}),T.createElement(bU.Content,{"aria-label":a.label,"cmdk-dialog":"",className:f},T.createElement(dB,{ref:b,...h}))))}),dI=Object.assign(dB,{List:dG,Item:dC,Input:dF,Group:dD,Separator:dE,Dialog:dH,Empty:T.forwardRef((a,b)=>dM(a=>0===a.filtered.count)?T.createElement(dp.Primitive.div,{ref:b,...a,"cmdk-empty":"",role:"presentation"}):null),Loading:T.forwardRef((a,b)=>{let{progress:c,children:d,label:e="Loading...",...f}=a;return T.createElement(dp.Primitive.div,{ref:b,...f,"cmdk-loading":"",role:"progressbar","aria-valuenow":c,"aria-valuemin":0,"aria-valuemax":100,"aria-label":e},dP(a,a=>T.createElement("div",{"aria-hidden":!0},a)))})});function dJ(a){let b=T.useRef(a);return dK(()=>{b.current=a}),b}var dK=T.useEffect;function dL(a){let b=T.useRef();return void 0===b.current&&(b.current=a()),b}function dM(a){let b=T.useContext(dz),c=()=>a(b.snapshot());return T.useSyncExternalStore(b.subscribe,c,c)}function dN(a,b,c,d=[]){let e=T.useRef(),f=T.useContext(dy);return dK(()=>{var g;let h=(()=>{var a;for(let b of c){if("string"==typeof b)return b.trim();if("object"==typeof b&&"current"in b)return b.current?null==(a=b.current.textContent)?void 0:a.trim():e.current}})(),i=d.map(a=>a.trim());f.value(a,h,i),null==(g=b.current)||g.setAttribute(dw,h),e.current=h}),e}var dO=()=>{let[a,b]=T.useState(),c=dL(()=>new Map);return dK(()=>{c.current.forEach(a=>a()),c.current=new Map},[a]),(a,d)=>{c.current.set(a,d),b({})}};function dP({asChild:a,children:b},c){let d;return a&&T.isValidElement(b)?T.cloneElement("function"==typeof(d=b.type)?d(b.props):"render"in d?d.render(b.props):b,{ref:b.ref},c(b.props.children)):c(b)}var dQ={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};let dR=(0,d.default)("search",[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]),dS=T.forwardRef(({className:a,...c},d)=>(0,b.jsx)(dI,{ref:d,className:(0,Z.cn)("flex h-full w-full flex-col overflow-hidden rounded-sm bg-popover text-popover-foreground",a),...c}));function dT({children:a,shouldFilter:c,...d}){return(0,b.jsx)(V.Dialog,{...d,children:(0,b.jsxs)(V.DialogContent,{className:"overflow-hidden p-0 shadow-golden max-w-lg",children:[(0,b.jsx)(V.DialogTitle,{className:"sr-only",children:"Search"}),(0,b.jsx)(dS,{shouldFilter:c,className:"[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-normal [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group]]:px-2 [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5",children:a})]})})}dS.displayName=dI.displayName;let dU=T.forwardRef(({className:a,...c},d)=>(0,b.jsxs)("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[(0,b.jsx)(dR,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),(0,b.jsx)(dI.Input,{ref:d,className:(0,Z.cn)("flex h-11 w-full rounded-sm bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",a),...c})]}));dU.displayName=dI.Input.displayName;let dV=T.forwardRef(({className:a,...c},d)=>(0,b.jsx)(dI.List,{ref:d,className:(0,Z.cn)("max-h-[300px] overflow-y-auto overflow-x-hidden",a),...c}));dV.displayName=dI.List.displayName;let dW=T.forwardRef((a,c)=>(0,b.jsx)(dI.Empty,{ref:c,className:"py-6 text-center text-sm text-muted-foreground",...a}));dW.displayName=dI.Empty.displayName;let dX=T.forwardRef(({className:a,...c},d)=>(0,b.jsx)(dI.Group,{ref:d,className:(0,Z.cn)("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-normal [&_[cmdk-group-heading]]:text-muted-foreground",a),...c}));dX.displayName=dI.Group.displayName;let dY=T.forwardRef(({className:a,...c},d)=>(0,b.jsx)(dI.Separator,{ref:d,className:(0,Z.cn)("-mx-1 h-px bg-border",a),...c}));dY.displayName=dI.Separator.displayName;let dZ=T.forwardRef(({className:a,...c},d)=>(0,b.jsx)(dI.Item,{ref:d,className:(0,Z.cn)("relative flex cursor-default gap-2 select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",a),...c}));dZ.displayName=dI.Item.displayName;let d$=null,d_=null,d0=(0,b1.create)(a=>({query:"",results:[],loading:!1,truncated:!1,open:!1,setQuery:b=>a({query:b}),setOpen:b=>a({open:b}),clear:()=>{d_&&clearTimeout(d_),d$?.abort(),a({query:"",results:[],loading:!1,truncated:!1})},search:b=>(d_&&clearTimeout(d_),b.trim())?(a({loading:!0}),new Promise(c=>{d_=setTimeout(()=>{d1(a,b).finally(c)},150)})):(d$?.abort(),a({results:[],loading:!1,truncated:!1}),Promise.resolve())}));async function d1(a,b){d$?.abort();let c=new AbortController;d$=c;try{let d=await (0,Y.wsFetch)("/api/wiki/search",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:b,limit:30}),signal:c.signal});if(!d.ok)return void a({results:[],loading:!1,truncated:!1});let e=await d.json();if(c.signal.aborted)return;a({results:e.matches??[],truncated:!!e.truncated,loading:!1})}catch(b){"AbortError"!==b.name&&a({loading:!1})}}var d2=a.i(713033);function d3({html:a}){let c=function(a){let b,c=[],d=/<mark>([\s\S]*?)<\/mark>/g,e=0;for(;null!==(b=d.exec(a));)b.index>e&&c.push({text:a.slice(e,b.index),mark:!1}),c.push({text:b[1]??"",mark:!0}),e=b.index+b[0].length;return e<a.length&&c.push({text:a.slice(e),mark:!1}),c}(a);return(0,b.jsx)(b.Fragment,{children:c.map((a,c)=>a.mark?(0,b.jsx)("mark",{className:"bg-yellow-200 dark:bg-yellow-700 rounded-[2px] px-[1px]",children:a.text},c):(0,b.jsx)("span",{children:a.text},c))})}function d4({onOpenFile:a,recents:c=[],onToggleSidebar:d=()=>void 0,onNewFile:f=()=>void 0,onCopyPath:g=()=>void 0}){let h=d0(a=>a.open),j=d0(a=>a.setOpen),k=d0(a=>a.query),l=d0(a=>a.setQuery),n=d0(a=>a.results),o=d0(a=>a.loading),p=d0(a=>a.truncated),q=d0(a=>a.search),{resolvedTheme:r,setTheme:s}=(0,bT.useTheme)(),t=(0,c_.useAIPanelStore)(a=>a.toggle),u=(0,d2.useViewWidthStore)(a=>a.width),v=(0,d2.useViewWidthStore)(a=>a.cycle),w=k.trimStart(),x=""===w||w.startsWith(">"),y=""===w&&c.length>0,z=x?"":k;function A(a){a(),j(!1),l("")}(0,T.useEffect)(()=>{function a(a){(a.metaKey||a.ctrlKey)&&"k"===a.key.toLowerCase()&&(a.preventDefault(),j(!h))}return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[h,j]),(0,T.useEffect)(()=>{if(!h||x)return;let a=setTimeout(()=>{q(z)},120);return()=>clearTimeout(a)},[z,x,h,q]);let B=(d2.VIEW_WIDTH_ORDER.indexOf(u)+1)%d2.VIEW_WIDTH_ORDER.length,D=d2.VIEW_WIDTH_LABEL[d2.VIEW_WIDTH_ORDER[B]];return(0,b.jsxs)(dT,{open:h,onOpenChange:a=>{j(a),a||l("")},shouldFilter:!1,children:[(0,b.jsx)(dU,{placeholder:"Search files… ( > for actions )",value:k,onValueChange:l}),(0,b.jsxs)(dV,{children:[y&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(dX,{heading:"Recent",children:c.map(c=>(0,b.jsxs)(dZ,{value:`recent:${c.path}`,onSelect:()=>{a(c.path),j(!1),l("")},children:[(0,b.jsx)(cb,{className:"mr-2 h-4 w-4"}),(0,b.jsxs)("div",{className:"flex min-w-0 flex-col gap-0.5",children:[(0,b.jsx)("span",{className:"truncate font-medium",children:c.name}),(0,b.jsx)("span",{className:"truncate text-xs text-muted-foreground",children:c.path})]})]},c.path))}),(0,b.jsx)(dY,{})]}),x&&(0,b.jsxs)(dX,{heading:"Actions",children:[(0,b.jsxs)(dZ,{value:"toggle-dark-mode",onSelect:()=>A(()=>s("dark"===r?"light":"dark")),children:["dark"===r?(0,b.jsx)(N.Sun,{className:"mr-2 h-4 w-4"}):(0,b.jsx)(C.Moon,{className:"mr-2 h-4 w-4"}),"dark"===r?"Switch to light mode":"Switch to dark mode"]}),(0,b.jsxs)(dZ,{value:"toggle-ai-panel",onSelect:()=>A(t),children:[(0,b.jsx)(e,{className:"mr-2 h-4 w-4"}),"Toggle AI panel"]}),(0,b.jsxs)(dZ,{value:"toggle-sidebar",onSelect:()=>A(d),children:[(0,b.jsx)(di.PanelLeft,{className:"mr-2 h-4 w-4"}),"Toggle sidebar"]}),(0,b.jsxs)(dZ,{value:"new-file",onSelect:()=>A(f),children:[(0,b.jsx)(m.FilePlus,{className:"mr-2 h-4 w-4"}),"New file"]}),(0,b.jsxs)(dZ,{value:"copy-path",onSelect:()=>A(g),children:[(0,b.jsx)(i.Copy,{className:"mr-2 h-4 w-4"}),"Copy current file path"]}),(0,b.jsxs)(dZ,{value:"cycle-view-width",onSelect:()=>A(v),children:[(0,b.jsx)(dh.AlignCenter,{className:"mr-2 h-4 w-4"}),(0,b.jsxs)("span",{children:["Change view width"," ",(0,b.jsxs)("span",{className:"text-muted-foreground",children:["(",d2.VIEW_WIDTH_LABEL[u]," → ",D,")"]})]})]})]}),!x&&(0,b.jsxs)(b.Fragment,{children:[o&&(0,b.jsx)("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:"Searching…"}),!o&&""!==z.trim()&&0===n.length&&(0,b.jsx)(dW,{children:"No matches."}),n.length>0&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(dY,{}),(0,b.jsx)(dX,{heading:p?"Top results (refine query for more)":"Results",children:n.map(c=>(0,b.jsx)(dZ,{value:c.path,onSelect:()=>{a(c.path),j(!1),l("")},children:(0,b.jsxs)("div",{className:"flex min-w-0 flex-col gap-0.5",children:[(0,b.jsx)("span",{className:"truncate font-mono text-xs",children:c.path}),c.snippet&&(0,b.jsx)("span",{className:"truncate text-xs text-muted-foreground",children:(0,b.jsx)(d3,{html:c.snippet})})]})},c.path))})]})]})]})]})}function d5({onOpenFile:a}){let c=d0(a=>a.query),d=d0(a=>a.setQuery),e=d0(a=>a.results),f=d0(a=>a.loading),g=d0(a=>a.search),h=d0(a=>a.clear),[i,j]=(0,T.useState)(0),k=(0,T.useRef)(null);function l(b){let c=e[b];c&&(a(c.path),h())}return(0,T.useEffect)(()=>{j(0)},[e]),(0,T.useEffect)(()=>{let a=k.current?.querySelector(`[data-idx="${i}"]`);a?.scrollIntoView({block:"nearest"})},[i]),(0,b.jsxs)("div",{className:"flex flex-col gap-1 px-2 py-1.5",children:[(0,b.jsxs)("div",{className:"relative",children:[(0,b.jsx)(dR,{className:"pointer-events-none absolute left-2 top-1/2 h-3.5 w-3.5 -translate-y-1/2 opacity-50"}),(0,b.jsx)("input",{type:"text",className:"w-full rounded-sm border bg-transparent py-1 pl-7 pr-2 text-xs outline-none focus:ring-1 focus:ring-ring",placeholder:"Search… (⌘K)",value:c,onChange:a=>{d(a.target.value),g(a.target.value)},onKeyDown:a=>{"Escape"===a.key?h():0!==e.length&&("ArrowDown"===a.key?(a.preventDefault(),j(a=>(a+1)%e.length)):"ArrowUp"===a.key?(a.preventDefault(),j(a=>(a-1+e.length)%e.length)):"Enter"===a.key&&(a.preventDefault(),l(i)))}})]}),""!==c.trim()&&(0,b.jsxs)("div",{ref:k,className:"max-h-64 overflow-y-auto rounded-sm border bg-popover",children:[f&&(0,b.jsx)("div",{className:"px-2 py-1 text-xs text-muted-foreground",children:"Searching…"}),!f&&0===e.length&&(0,b.jsx)("div",{className:"px-2 py-1 text-xs text-muted-foreground",children:"No matches"}),e.map((a,c)=>(0,b.jsxs)("button",{type:"button","data-idx":c,onClick:()=>l(c),onMouseEnter:()=>j(c),className:`block w-full px-2 py-1 text-left ${c===i?"bg-accent":"hover:bg-accent"}`,children:[(0,b.jsx)("div",{className:"truncate font-mono text-xs",children:a.path}),a.snippet&&(0,b.jsx)("div",{className:"truncate text-[10px] text-muted-foreground",children:(0,b.jsx)(d3,{html:a.snippet})})]},a.path))]})]})}let d6=(0,b1.create)(a=>({width:288,setWidth:b=>{a({width:Number.isNaN(b)?288:Math.min(600,Math.max(200,Math.round(b)))})}}));var d7=a.i(256233);let d8=(0,b1.create)((a,b)=>({showHidden:!1,toggle:()=>{a({showHidden:!b().showHidden})}})),d9=(0,b1.create)((a,b)=>({humanize:!1,toggle:()=>{a({humanize:!b().humanize})}}));function ea(a){let b=a.lastIndexOf("."),c=b>0&&b<a.length-1,d=c?a.slice(0,b):a,e=c?a.slice(b):"",f=d.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1 $2").split(/[\s_-]+/).filter(Boolean).map(a=>/^[A-Z0-9]+$/.test(a)?a:a[0].toUpperCase()+a.slice(1));return f.length?f.join(" ")+e:a}let eb=(0,bs.default)(async()=>{},{loadableGenerated:{modules:[904378]},ssr:!1});function ec(a){let b=new Date(a).getTime();if(!Number.isFinite(b))return"";let c=Math.floor(Math.max(0,Date.now()-b)/1e3);if(c<60)return"just now";let d=Math.floor(c/60);if(d<60)return`${d}m ago`;let e=Math.floor(d/60);return e<24?`${e}h ago`:`${Math.floor(e/24)}d ago`}let ed=new Set(["image","media","pdf","fallback","app","node-app","html"]);function ee(a){return a.split(".").pop()?.toLowerCase()??""}function ef(a,b){if("node-app"===b)return"node-app";if("app"===b)return"app";if("dir"===b)return"fallback";let c=a.split("/").pop()??a;if(c.startsWith(".")&&-1===c.indexOf(".",1))return"source";let d=ee(a);return d?["md","markdown"].includes(d)?"editor":"txt"===d?"text":["csv","tsv"].includes(d)?"csv":"pdf"===d?"pdf":["mmd","mermaid"].includes(d)?"mermaid":"ipynb"===d?"notebook":["png","jpg","jpeg","gif","webp","svg","avif","ico","bmp"].includes(d)?"image":["mp4","webm","mov","m4v","mp3","wav","ogg","m4a","aac"].includes(d)?"media":"docx"===d?"docx":["xlsx","xlsm"].includes(d)?"xlsx":"pptx"===d?"pptx":"html"===d?"html":(["py","js","ts","tsx","jsx","go","rs","java","c","cpp","h","sh","bash","zsh","rb","php","swift","kt","lua","sql","yaml","yml","toml","json","xml","css","scss"].includes(d),"source"):"source"}let eg=new Set(["txt","md","markdown","json","yaml","yml","toml","csv","tsv","xml","html","css","js","ts","tsx","jsx","sh","bash","zsh","rb","py","go","rs","java","c","cpp","h","php","swift","kt","lua","sql","scss","mmd","mermaid","ini","env","log","conf"]);function eh(a){let b=ef(a,"file");return"editor"===b||"text"===b||eg.has(ee(a))}function ei(a){return["md","markdown"].includes(ee(a))}function ej(a){return"image"===ef(a,"file")}function ek(a){return"html"===ef(a,"file")}async function el(a){let b=await (0,Y.wsFetch)(`/api/wiki?dir=${encodeURIComponent(a)}`);return b.ok?(await b.json()).entries.map(b=>({name:b.name,path:a?`${a}/${b.name}`:b.name,type:b.type,size:b.size,modifiedAt:b.modifiedAt,expanded:!1,git:b.git})):[]}let em=new Map,en=new Map;async function eo(a){let b=em.get(a);if(b)return em.delete(a),b;let c=en.get(a);if(c){let b=await c;return em.delete(a),b}return null}function ep(a,b,c){return a.map(a=>a.path===b?c(a):a.children?{...a,children:ep(a.children,b,c)}:a)}let eq={contentVisibility:"auto",containIntrinsicSize:"auto 32px"};function er({node:a,ctx:c,isPinned:d,activeWorkspaceId:e}){return(0,b.jsxs)(cV,{className:"w-48",children:[(0,b.jsxs)(cW,{onSelect:()=>c.copyPath(a.path),children:[(0,b.jsx)(i.Copy,{className:"mr-2 h-3.5 w-3.5"}),"Copy path"]}),ei(a.name)&&(0,b.jsxs)(cW,{onSelect:()=>c.copyWikiLink(a.name),children:[(0,b.jsx)(n.FileText,{className:"mr-2 h-3.5 w-3.5"}),"Copy wiki link"]}),(0,b.jsxs)(cW,{onSelect:()=>c.copyUrl(a.path),children:[(0,b.jsx)(y.Link,{className:"mr-2 h-3.5 w-3.5"}),"Copy URL"]}),"file"===a.type&&eh(a.name)&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(cW,{onSelect:()=>c.copyRawContent(a.path),children:[(0,b.jsx)(n.FileText,{className:"mr-2 h-3.5 w-3.5"}),"Copy raw content"]}),(0,b.jsxs)(cW,{onSelect:()=>c.copyFormattedContent(a.path,a.name),children:[(0,b.jsx)(n.FileText,{className:"mr-2 h-3.5 w-3.5"}),"Copy formatted content"]})]}),(0,b.jsx)(cX,{}),"dir"===a.type&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(cW,{onSelect:()=>{a.expanded||c.toggleFolder(a),c.setNewFileParent(a.path),c.setNewFileName(""),c.setFileCreateError(null)},children:[(0,b.jsx)(m.FilePlus,{className:"mr-2 h-3.5 w-3.5"}),"New file here"]}),(0,b.jsxs)(cW,{onSelect:()=>c.triggerUpload(a.path),children:[(0,b.jsx)(R.Upload,{className:"mr-2 h-3.5 w-3.5"}),"Upload here"]}),(0,b.jsxs)(cW,{onSelect:()=>{c.setNewFolderParent(a.path),c.setNewFolderName(""),c.setFolderError(null)},children:[(0,b.jsx)(q,{className:"mr-2 h-3.5 w-3.5"}),"New subfolder"]}),(0,b.jsx)(cX,{})]}),(0,b.jsxs)(cW,{onSelect:()=>c.handleDownload(a),children:[(0,b.jsx)(j.Download,{className:"mr-2 h-3.5 w-3.5"}),"file"===a.type?"Download":"Download as zip"]}),(0,b.jsxs)(cW,{onSelect:()=>c.togglePin(a,e),children:[(0,b.jsx)(I,{className:(0,Z.cn)("mr-2 h-3.5 w-3.5",d&&"fill-current text-amber-400")}),d?"Unpin":"Pin to top"]}),(0,b.jsx)(cX,{}),(0,b.jsxs)(cW,{className:"text-destructive focus:text-destructive",onSelect:()=>{c.setDeletingPath(a.path),c.setDeletingIsDir("file"!==a.type)},children:[(0,b.jsx)(Q.Trash2,{className:"mr-2 h-3.5 w-3.5"}),"Delete"]})]})}function es({name:a,type:c}){let d="h-3.5 w-3.5 shrink-0";return"dir"===c?(0,b.jsx)(o.Folder,{className:(0,Z.cn)(d,"text-warning")}):"app"===c?(0,b.jsx)(u.Globe,{className:(0,Z.cn)(d,"text-foreground/70")}):"node-app"===c?(0,b.jsx)(O,{className:(0,Z.cn)(d,"text-emerald-500")}):ek(a)?(0,b.jsx)(u.Globe,{className:(0,Z.cn)(d,"text-foreground/60")}):ej(a)?(0,b.jsx)(x.default,{className:(0,Z.cn)(d,"text-sunshine-700")}):eh(a)?(0,b.jsx)(n.FileText,{className:(0,Z.cn)(d,"text-foreground/70")}):(0,b.jsx)(l.File,{className:(0,Z.cn)(d,"text-foreground/60")})}let et=(0,T.memo)(function({node:a,depth:c,ctx:d,isMobile:e,activeWorkspaceId:f,sidebarScrollRef:g,isActive:k,isDragOver:s,isPinned:t,isAgentActive:v,isPulling:w,branchOpen:A,branchPos:C,branches:D,branchLoading:E,checkingOut:F,onHoverEnter:G,onHoverLeave:H}){let J=d9(a=>a.humanize);return(0,b.jsxs)(cF,{children:[(0,b.jsx)(cH,{asChild:!0,children:(0,b.jsxs)("div",{role:"treeitem",tabIndex:0,draggable:!e,onKeyDown:b=>{if("Enter"===b.key||" "===b.key)b.preventDefault(),"dir"===a.type?d.toggleFolder(a):"app"===a.type||"node-app"===a.type?(d.openViewer(a),d.toggleFolder(a)):d.openViewer(a);else if("ArrowDown"===b.key){b.preventDefault();let a=g.current;if(!a)return;let c=Array.from(a.querySelectorAll('[role="treeitem"]')),d=c.indexOf(b.currentTarget);c[d+1]?.focus()}else if("ArrowUp"===b.key){b.preventDefault();let a=g.current;if(!a)return;let c=Array.from(a.querySelectorAll('[role="treeitem"]')),d=c.indexOf(b.currentTarget);c[d-1]?.focus()}else if("ArrowRight"===b.key){if(b.preventDefault(),"dir"===a.type||"app"===a.type||"node-app"===a.type)if(a.expanded){let a=g.current;if(!a)return;let c=Array.from(a.querySelectorAll('[role="treeitem"]')),d=c.indexOf(b.currentTarget);c[d+1]?.focus()}else d.toggleFolder(a)}else if("ArrowLeft"===b.key){if(b.preventDefault(),("dir"===a.type||"app"===a.type||"node-app"===a.type)&&a.expanded)d.toggleFolder(a);else if(c>0){let a=g.current;if(!a)return;let c=Array.from(a.querySelectorAll('[role="treeitem"]')),d=b.currentTarget,e=c.indexOf(d),f=Number.parseInt(d.style.paddingLeft??"0",10);for(let a=e-1;a>=0;a--)if(Number.parseInt(c[a].style.paddingLeft??"0",10)<f){c[a].focus();break}}}},onDragStart:b=>d.handleDragStart(b,a),onDragOver:b=>"dir"===a.type?d.handleDragOver(b,a.path,"dir"):b.preventDefault(),onDragLeave:()=>d.setDragOverPath(null),onDrop:b=>"dir"===a.type?d.handleDropOnFolder(b,a.path):b.preventDefault(),onMouseEnter:()=>G(a),onMouseLeave:H,className:(0,Z.cn)("tree-row-reveal flex items-center gap-1.5 rounded-sm px-2 py-1 text-sm cursor-pointer group transition-colors select-none touch-target",k?"bg-accent-soft text-foreground font-medium":"hover:bg-muted",s&&"ring-2 ring-primary bg-primary-soft",a.name.startsWith(".")&&"opacity-40"),style:{paddingLeft:`${14*c+8}px`,...eq},onClick:()=>{"dir"===a.type?d.toggleFolder(a):("app"===a.type||"node-app"===a.type?(d.openViewer(a),d.toggleFolder(a)):d.openViewer(a),e&&d.setSidebarCollapsed(!0))},children:["dir"===a.type||"app"===a.type||"node-app"===a.type?a.loading?(0,b.jsx)(z.Loader2,{className:"h-3.5 w-3.5 shrink-0 animate-spin text-muted-foreground"}):(0,b.jsx)(h.ChevronRight,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground transition-transform duration-200 ease-out",style:{transform:a.expanded?"rotate(90deg)":"rotate(0deg)"}}):(0,b.jsx)("span",{className:"w-3.5 shrink-0"}),(0,b.jsx)("span",{className:"editorial-tree-typeicon",children:"dir"===a.type?a.expanded?(0,b.jsx)(p,{className:(0,Z.cn)("h-4 w-4 shrink-0",!k&&"text-warning")}):(0,b.jsx)(o.Folder,{className:(0,Z.cn)("h-4 w-4 shrink-0",!k&&"text-warning")}):"app"===a.type?(0,b.jsx)(u.Globe,{className:(0,Z.cn)("h-4 w-4 shrink-0",!k&&"text-foreground/70")}):"node-app"===a.type?(0,b.jsx)(O,{className:(0,Z.cn)("h-4 w-4 shrink-0",!k&&"text-emerald-500")}):ek(a.name)?(0,b.jsx)(u.Globe,{className:(0,Z.cn)("h-4 w-4 shrink-0",!k&&"text-foreground/60")}):ej(a.name)?(0,b.jsx)(x.default,{className:(0,Z.cn)("h-4 w-4 shrink-0",!k&&"text-sunshine-700")}):eh(a.name)?(0,b.jsx)(n.FileText,{className:(0,Z.cn)("h-4 w-4 shrink-0",!k&&"text-foreground/70")}):(0,b.jsx)(l.File,{className:(0,Z.cn)("h-4 w-4 shrink-0",!k&&"text-foreground/60")})}),(0,b.jsx)("span",{className:"min-w-0 flex-1 truncate",title:J?a.name:void 0,children:J?ea(a.name):a.name}),a.git&&(0,b.jsxs)("span",{className:"relative flex shrink-0 items-center gap-0.5 rounded-sm bg-muted px-1 py-0.5 text-[10px] text-muted-foreground",children:[(0,b.jsxs)("button",{"data-branch-trigger":!0,type:"button",className:"flex items-center gap-0.5 hover:text-foreground",title:"Switch branch",onClick:b=>{if(b.stopPropagation(),A){d.setBranchDropdownNode(null),d.setBranchDropdownPos(null);return}let c=b.currentTarget.getBoundingClientRect();d.setBranchDropdownPos({top:c.bottom+4,left:c.left}),d.setBranchDropdownNode(a.path),d.loadBranches(a.path)},children:[(0,b.jsx)(r,{className:"h-2.5 w-2.5"}),a.git.branch,a.git.dirty&&(0,b.jsx)("span",{className:"ml-0.5 text-warning",children:"*"})]}),w?(0,b.jsx)(z.Loader2,{className:"ml-0.5 h-2.5 w-2.5 animate-spin"}):(0,b.jsx)("button",{type:"button",onClick:b=>{b.stopPropagation();let c=a.path.includes("/")?a.path.substring(0,a.path.lastIndexOf("/")):"";d.handleGitPull(a.path,c)},className:"ml-0.5 text-muted-foreground hover:text-foreground",title:"Pull latest",children:(0,b.jsx)(K,{className:"h-2.5 w-2.5"})}),A&&C&&(0,b.jsx)(bS,{pos:C,branches:D,loading:E,busyName:F,disabled:null!==F,onPick:b=>{let c=a.path.includes("/")?a.path.substring(0,a.path.lastIndexOf("/")):"";d.handleCheckout(a.path,b,c)},onClose:()=>{d.setBranchDropdownNode(null),d.setBranchDropdownPos(null)}})]}),v&&(0,b.jsx)("span",{className:"ml-0.5 h-1.5 w-1.5 rounded-full bg-emerald-400 shrink-0 animate-pulse",title:"Agent recently active"}),(0,b.jsx)("div",{className:"hover-reveal flex max-w-0 shrink-0 items-center overflow-hidden opacity-0 transition-all duration-150 group-hover:max-w-7 group-hover:opacity-100 focus-within:max-w-7 focus-within:opacity-100",onClick:a=>a.stopPropagation(),onKeyDown:a=>a.stopPropagation(),children:(0,b.jsxs)(bJ.DropdownMenu,{children:[(0,b.jsx)(bJ.DropdownMenuTrigger,{asChild:!0,children:(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0 text-muted-foreground hover:text-foreground",title:"File actions",children:(0,b.jsx)(B,{className:"h-3.5 w-3.5"})})}),(0,b.jsxs)(bJ.DropdownMenuContent,{align:"end",className:"w-48",children:[(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>d.copyPath(a.path),children:[(0,b.jsx)(i.Copy,{className:"mr-2 h-3.5 w-3.5"}),"Copy path"]}),ei(a.name)&&(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>d.copyWikiLink(a.name),children:[(0,b.jsx)(n.FileText,{className:"mr-2 h-3.5 w-3.5"}),"Copy wiki link"]}),(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>d.copyUrl(a.path),children:[(0,b.jsx)(y.Link,{className:"mr-2 h-3.5 w-3.5"}),"Copy URL"]}),"file"===a.type&&eh(a.name)&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>d.copyRawContent(a.path),children:[(0,b.jsx)(n.FileText,{className:"mr-2 h-3.5 w-3.5"}),"Copy raw content"]}),(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>d.copyFormattedContent(a.path,a.name),children:[(0,b.jsx)(n.FileText,{className:"mr-2 h-3.5 w-3.5"}),"Copy formatted content"]})]}),(0,b.jsx)(bJ.DropdownMenuSeparator,{}),"dir"===a.type&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:async()=>{a.expanded||d.toggleFolder(a),d.setNewFileParent(a.path),d.setNewFileName(""),d.setFileCreateError(null)},children:[(0,b.jsx)(m.FilePlus,{className:"mr-2 h-3.5 w-3.5"}),"New file here"]}),(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>d.triggerUpload(a.path),children:[(0,b.jsx)(R.Upload,{className:"mr-2 h-3.5 w-3.5"}),"Upload here"]}),(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>{d.setNewFolderParent(a.path),d.setNewFolderName(""),d.setFolderError(null)},children:[(0,b.jsx)(q,{className:"mr-2 h-3.5 w-3.5"}),"New subfolder"]}),(0,b.jsx)(bJ.DropdownMenuSeparator,{})]}),(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>d.handleDownload(a),children:[(0,b.jsx)(j.Download,{className:"mr-2 h-3.5 w-3.5"}),"file"===a.type?"Download":"Download as zip"]}),(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>d.togglePin(a,f),children:[(0,b.jsx)(I,{className:(0,Z.cn)("mr-2 h-3.5 w-3.5",t&&"fill-current text-amber-400")}),t?"Unpin":"Pin to top"]}),(0,b.jsx)(bJ.DropdownMenuSeparator,{}),(0,b.jsxs)(bJ.DropdownMenuItem,{className:"text-destructive focus:text-destructive",onClick:()=>{d.setDeletingPath(a.path),d.setDeletingIsDir("file"!==a.type)},children:[(0,b.jsx)(Q.Trash2,{className:"mr-2 h-3.5 w-3.5"}),"Delete"]})]})]})})]})}),(0,b.jsx)(er,{node:a,ctx:d,isPinned:t,activeWorkspaceId:f})]})}),eu=(0,T.memo)(function(a){let{ctx:c,openPath:d,dragOverPath:e,branchDropdownNode:g,branchDropdownPos:h,nodeBranches:i,branchesLoading:j,checkingOutBranch:k,pullingRepo:l,activePaths:m,pins:p,isMobile:q,activeWorkspaceId:r,newFileParent:s,newFileName:t,fileCreateError:u,newFolderParent:v,newFolderName:w,folderError:x,sidebarScrollRef:y}=a,z=d8(a=>a.showHidden),A=(0,T.useRef)(null),B=(0,T.useCallback)(a=>{let b=("dir"===a.type||"app"===a.type||"node-app"===a.type)&&!a.expanded&&void 0===a.children;("file"===a.type||b)&&(A.current&&clearTimeout(A.current),A.current=setTimeout(()=>c.prefetch(a),120))},[c]),C=(0,T.useCallback)(()=>{A.current&&(clearTimeout(A.current),A.current=null)},[]),D=(0,T.useMemo)(()=>{let b=[],c=(a,d)=>{for(let e of a)!(!z&&e.name.startsWith("."))&&(b.push({kind:"row",node:e,depth:d}),"dir"===e.type&&(v===e.path&&b.push({kind:"newfolder",node:e,depth:d}),s===e.path&&b.push({kind:"newfile",node:e,depth:d})),("dir"===e.type||"app"===e.type||"node-app"===e.type)&&e.expanded&&(e.children&&e.children.length>0?c(e.children,d+1):e.children?.length===0&&b.push({kind:"empty",node:e,depth:d})))};return c(a.nodes,0),b},[a.nodes,s,v,z]);return(0,b.jsx)(b.Fragment,{children:D.map(a=>{let{node:s,depth:v}=a;if("row"===a.kind){let a=g===s.path;return(0,b.jsx)(et,{node:s,depth:v,ctx:c,isMobile:q,activeWorkspaceId:r,sidebarScrollRef:y,isActive:d===s.path,isDragOver:e===s.path,isPinned:p.some(a=>a.path===s.path),isAgentActive:m.has(s.path),isPulling:l===s.path,branchOpen:a,branchPos:a?h:null,branches:s.git?i[s.path]??[]:[],branchLoading:!!s.git&&!!j[s.path],checkingOut:a?k:null,onHoverEnter:B,onHoverLeave:C},s.path)}return"newfolder"===a.kind?(0,b.jsxs)("div",{className:"flex items-center gap-1.5 px-2 py-1",style:{paddingLeft:`${(v+1)*14+8}px`,...eq},children:[(0,b.jsx)("span",{className:"w-3.5 shrink-0"}),(0,b.jsx)(o.Folder,{className:"h-4 w-4 shrink-0 text-warning"}),(0,b.jsx)("input",{className:"flex-1 bg-transparent text-sm outline-none border-b border-border min-w-0",placeholder:"Folder name",value:w,onChange:a=>c.setNewFolderName(a.target.value),onKeyDown:a=>{"Enter"===a.key&&c.handleCreateFolder(),"Escape"===a.key&&(c.setNewFolderParent(null),c.setNewFolderName(""))}}),x&&(0,b.jsx)("span",{className:"text-xs text-destructive",children:x}),(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:c.handleCreateFolder,children:(0,b.jsx)(f.Check,{className:"h-3 w-3"})}),(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:()=>{c.setNewFolderParent(null),c.setNewFolderName("")},children:(0,b.jsx)(S.X,{className:"h-3 w-3"})})]},`nf-${s.path}`):"newfile"===a.kind?(0,b.jsxs)("div",{className:"flex items-center gap-1.5 px-2 py-1",style:{paddingLeft:`${(v+1)*14+8}px`,...eq},children:[(0,b.jsx)("span",{className:"w-3.5 shrink-0"}),(0,b.jsx)(n.FileText,{className:"h-4 w-4 shrink-0 text-accent"}),(0,b.jsx)("input",{autoFocus:!0,className:"flex-1 bg-transparent text-sm outline-none border-b border-border min-w-0",placeholder:"filename (default .md)",value:t,onChange:a=>c.setNewFileName(a.target.value),onKeyDown:a=>{"Enter"===a.key&&c.handleCreateFile(),"Escape"===a.key&&(c.setNewFileParent(null),c.setNewFileName(""))}}),u&&(0,b.jsx)("span",{className:"text-xs text-destructive",children:u}),(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:c.handleCreateFile,children:(0,b.jsx)(f.Check,{className:"h-3 w-3"})}),(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:()=>{c.setNewFileParent(null),c.setNewFileName("")},children:(0,b.jsx)(S.X,{className:"h-3 w-3"})})]},`ff-${s.path}`):(0,b.jsx)("div",{className:"text-xs text-muted-foreground/50 py-0.5",style:{paddingLeft:`${(v+1)*14+8+14+6+16+6}px`,...eq},children:"Empty"},`empty-${s.path}`)})})});a.s(["default",0,function(){let a;(0,d7.useWikiSlugsStore)(a=>a.loadedAt),(0,T.useEffect)(()=>{d7.useWikiSlugsStore.getState().load()},[]);let[d,j]=(0,T.useState)(null),[p,O]=(0,T.useState)(null),[V,X]=(0,T.useState)(()=>null),[$,_]=(0,T.useState)([]),[aa,ae]=(0,T.useState)(!1),[af,aj]=(0,T.useState)(!1),[al,am]=(0,T.useState)(null),[an,ao]=(0,T.useState)(null),[ap,aq]=(0,T.useState)({}),[ar,as]=(0,T.useState)(null),[at,au]=(0,T.useState)(null),[av,aw]=(0,T.useState)(null),[ax,ay]=(0,T.useState)(null),az=(0,T.useCallback)(async()=>{try{let a=await fetch("/api/system/workspaces");if(!a.ok)throw Error("Failed");let b=await a.json();if(_(b.workspaces),ae(b.isAdmin),b.workspaces.length>0){j(!0);let a=new URLSearchParams(window.location.search).get("ws"),c=a?b.workspaces.find(b=>b.id===a):null,d=c??[...b.workspaces].sort((a,b)=>(b.lastOpenedAt??b.createdAt).localeCompare(a.lastOpenedAt??a.createdAt))[0];if(X(d.id),O(d.rootDir),!c){let a=new URL(location.href);a.searchParams.set("ws",d.id),history.replaceState(null,"",a.toString())}}else j(!1)}catch{j(!1)}},[]);(0,T.useEffect)(()=>{az()},[az]);let aA=(0,c8.useEditorStore)(a=>a.currentPath),aB=cY(a=>a.recents),[aC,aD]=(0,T.useState)(!1),[aE,aF]=(0,T.useState)(!0),aG=cZ(a=>a.pins),aH=(0,T.useRef)(null),aI=(0,c_.useAIPanelStore)(a=>a.activity),aJ=(0,T.useMemo)(()=>{let a=new Date(Date.now()-6e4).toISOString(),b=new Set;for(let c of aI)c.at>=a&&c.path&&c.by?.startsWith("ai:")&&b.add(c.path);return b},[aI]);(0,T.useEffect)(()=>{let a=()=>{c_.useAIPanelStore.getState().loadActivity()};a();let b=setInterval(a,1e4);return()=>clearInterval(b)},[]),(0,T.useEffect)(()=>{cY.getState().loadForWorkspace(V),cZ.getState().loadForWorkspace(V)},[V]),(0,T.useEffect)(()=>{let a,b=[...aG.map(a=>a.path),...aB.slice(0,8).map(a=>a.path)].filter((a,b,c)=>ei(a)&&c.indexOf(a)===b).slice(0,12);if(0===b.length)return;let c=(a=()=>{for(let a of b)(0,c8.prefetchPage)(a)},window.setTimeout(a,400));return()=>{clearTimeout(c)}},[aG,aB]);let aK=(0,T.useRef)(null),aL=(0,T.useRef)(!1),[aM,aN]=(0,T.useState)([]),[aO,aP]=(0,T.useState)(!1),[aQ,aR]=(0,T.useState)(!1),aS=(0,T.useRef)(!1),[aT,aU]=(0,T.useState)(!1),[aV,aW]=(0,T.useState)(!1),[aX,aY]=(0,T.useState)(null),aZ=(0,T.useRef)(null),a$=(0,T.useRef)(""),[a_,a0]=(0,T.useState)(null),[a1,a2]=(0,T.useState)(""),[a3,a4]=(0,T.useState)(null),[a5,a6]=(0,T.useState)(null),[a7,a8]=(0,T.useState)(""),[a9,ba]=(0,T.useState)(null),[bb,bc]=(0,T.useState)(null),[bd,bf]=(0,T.useState)(!1),[bg,bh]=(0,T.useState)(null),[bi,bj]=(0,T.useState)(null),[bk,bl]=(0,T.useState)(!1),[bm,bo]=(0,T.useState)(0),[bs,bt]=(0,T.useState)(0),bu=function(a="(max-width: 767px)"){let[b,c]=(0,T.useState)(!1);return(0,T.useEffect)(()=>{let b=window.matchMedia(a),d=()=>c(b.matches);return d(),b.addEventListener("change",d),()=>b.removeEventListener("change",d)},[a]),b}(),[bv,bw]=(0,T.useState)(!1),bx=d6(a=>a.width),by=d8(a=>a.showHidden),bz=d9(a=>a.humanize),{resolvedTheme:bA,setTheme:bB}=(0,bT.useTheme)(),bC=d6(a=>a.setWidth);(0,T.useEffect)(()=>{bu&&bw(!0)},[bu]);let[bD,bF]=(0,T.useState)(!1),[bH,bI]=(0,T.useState)(!1),[bK,bM]=(0,T.useState)(!1),[bN,bO]=(0,T.useState)(null),[bP,bR]=(0,T.useState)(0),[bU,bV]=(0,T.useState)(!1),[bW,bX]=(0,T.useState)(!1),[bY,bZ]=(0,T.useState)(""),[b$,b0]=(0,T.useState)(!1),[b1,b2]=(0,T.useState)(!1),[b3,b4]=(0,T.useState)(null),b5=(0,T.useRef)(null),[b6,b7]=(0,T.useState)(null),b8=(0,T.useRef)(null),ca=(0,T.useRef)(!1),cb=(0,T.useRef)(async()=>{});(0,T.useEffect)(()=>{!V||aO||aS.current||(aS.current=!0,aR(!0),el("").then(a=>{aN(a),aP(!0),aR(!1)}).catch(()=>{aS.current=!1,aR(!1)}))},[aO,V]);let cc=(0,T.useCallback)(async a=>{let b=a.split("/");if(b.length<=1)return;let c=[],d="";for(let a=0;a<b.length-1;a++)d=d?`${d}/${b[a]}`:b[a],c.push({prefix:d,children:await el(d)});aN(a=>{let b=a;for(let{prefix:a,children:d}of c)b=ep(b,a,a=>({...a,children:d,expanded:!0}));return b})},[]),cd=(0,T.useCallback)(async a=>{let b=await el(a);""===a?aN(a=>{let c=new Map(a.map(a=>[a.path,a]));return b.map(a=>{let b=c.get(a.path);return b&&("dir"===b.type||"app"===b.type)?{...a,expanded:b.expanded,children:b.children}:a})}):aN(c=>ep(c,a,a=>({...a,children:b,expanded:!0})))},[]),[ce,cf]=(0,T.useState)(null),[cg,ch]=(0,T.useState)(null),[ci,cj]=(0,T.useState)(!1),[ck,cl]=(0,T.useState)([]),[cm,cn]=(0,T.useState)(!1),[co,cp]=(0,T.useState)(null),[cq,cr]=(0,T.useState)(null),[cs,ct]=(0,T.useState)(!1),[cu,cx]=(0,T.useState)({}),[cy,cz]=(0,T.useState)({}),[cA,cB]=(0,T.useState)(null),[cC,cD]=(0,T.useState)(null),[cE,cG]=(0,T.useState)(null),cI=(0,T.useCallback)(async(a,b)=>{if(!ce){cf(a);try{let c=await (0,Y.wsFetch)("/api/wiki/git-pull",{method:"POST",body:JSON.stringify({path:a})});if(!c.ok){let a=await c.json();(0,b_.showError)(a.message??a.error??"Pull failed");return}let d=await c.json();(0,b_.showSuccess)(`Pulled ${a} (${d.branch} @ ${d.sha.slice(0,7)})`),await cd(b)}catch{(0,b_.showError)("Pull failed")}finally{cf(null)}}},[ce,cd]);(0,T.useEffect)(()=>{cj(!1),cl([]),cp(null),cr(null)},[bg?.path]);let cJ=bg?.path;(0,T.useEffect)(()=>{if(!cJ)return void ch(null);let a=!1,b=setTimeout(()=>{(async()=>{try{let b=await (0,Y.wsFetch)(`/api/wiki/git-file-info?path=${encodeURIComponent(cJ)}`);if(a)return;if(!b.ok)return void ch(null);let c=await b.json();a||ch(c.info)}catch{a||ch(null)}})()},200);return()=>{a=!0,clearTimeout(b)}},[cJ]);let cK=(0,T.useCallback)(async()=>{if(!bg)return;let a=bg.path;cj(!0),cn(!0),cl([]),cp(null),cr(null);try{let b=await (0,Y.wsFetch)(`/api/wiki/git-history?path=${encodeURIComponent(a)}`);if(!b.ok)return void(0,b_.showError)("Could not load history");let c=await b.json();bg.path===a&&cl(c.commits)}catch{(0,b_.showError)("Could not load history")}finally{cn(!1)}},[bg]),cL=(0,T.useCallback)(async a=>{if(!bg)return;if(co===a){cp(null),cr(null);return}let b=bg.path;cp(a),ct(!0),cr(null);try{let c=await (0,Y.wsFetch)(`/api/wiki/git-diff?path=${encodeURIComponent(b)}&sha=${encodeURIComponent(a)}`);if(!c.ok)return void(0,b_.showError)("Could not load diff");let d=await c.json();bg.path===b&&co===a&&cr(d.diff)}catch{(0,b_.showError)("Could not load diff")}finally{ct(!1)}},[bg,co]),cM=(0,T.useCallback)(async a=>{if(cu[a]||cy[a])return;let b=!1;cz(b=>({...b,[a]:!0}));try{let c=await (0,Y.wsFetch)(`/api/wiki/git-branches?path=${encodeURIComponent(a)}`);if(b)return;if(!c.ok)return void(0,b_.showError)("Could not load branches");let d=await c.json();b||cx(b=>({...b,[a]:d.branches}))}catch{b||(0,b_.showError)("Could not load branches")}finally{b||cz(b=>({...b,[a]:!1}))}return()=>{b=!0}},[cu,cy]),cN=(0,T.useCallback)(async(a,b,c)=>{if(!cA){cB(b);try{let d=await (0,Y.wsFetch)("/api/wiki/git-checkout",{method:"POST",body:JSON.stringify({path:a,branch:b})});if(409===d.status)return void(0,b_.showError)("Repository has uncommitted changes");if(!d.ok){let a=await d.json();(0,b_.showError)(a.error??"Checkout failed");return}let e=await d.json();(0,b_.showSuccess)(`Switched to ${e.branch}`),cx(b=>{let c={...b};return delete c[a],c}),cD(null),cG(null),await cd(c)}catch{(0,b_.showError)("Checkout failed")}finally{cB(null)}}},[cA,cd]),cO=(0,T.useCallback)(a=>{let b=[];for(let c of a)("dir"===c.type||"app"===c.type||"node-app"===c.type)&&c.expanded&&c.children&&(b.push(c.path),b.push(...cO(c.children)));return b},[]),cP=(0,T.useCallback)(async()=>{aU(!0);try{let a=cO(aM),b=await el("");for(let c of(aN(b),a)){let a=await el(c);aN(b=>ep(b,c,b=>({...b,children:a,expanded:!0})))}}finally{aU(!1)}},[aM,cO]),cQ=(0,T.useCallback)(async()=>{if(bg){if(ei(bg.name)){bV(!0);try{await c8.useEditorStore.getState().loadPage(bg.path)}finally{bV(!1)}return}if(["editor","text"].includes(ef(bg.name,bg.nodeType))||eh(bg.name)){bV(!0);try{let a=await (0,Y.wsFetch)(`/api/wiki/content?path=${encodeURIComponent(bg.path)}`);if(a.ok){let b=await a.json();bO(b.content),bR(Number(a.headers.get("X-Wiki-Revision")??0))}}catch{}bV(!1)}}},[bg]),cR=(0,T.useCallback)(()=>{bt(a=>a+1),cQ()},[cQ]);async function cS(a){if("dir"===a.type||"app"===a.type||"node-app"===a.type)if(a.expanded)aN(b=>ep(b,a.path,a=>({...a,expanded:!1})));else if(void 0===a.children){let b=await eo(a.path);if(b)return void aN(c=>ep(c,a.path,a=>({...a,loading:!1,children:b,expanded:!0})));aN(b=>ep(b,a.path,a=>({...a,loading:!0})));let c=await el(a.path);aN(b=>ep(b,a.path,a=>({...a,loading:!1,children:c,expanded:!0})))}else aN(b=>ep(b,a.path,a=>({...a,expanded:!0})))}async function cT(a){if("file"===a.type&&cY.getState().push({path:a.path,name:a.name},V),bh({path:a.path,name:a.name,size:a.size,nodeType:"app"===a.type?"app":"node-app"===a.type?"node-app":"file"}),bX(!1),b0(!1),b4(null),bO(null),bR(0),"file"===a.type&&ei(a.name)){bV(!0);try{await c8.useEditorStore.getState().loadPage(a.path)}finally{bV(!1)}return}if(["editor","text"].includes(ef(a.name,a.type))||eh(a.name)){bV(!0);try{let b=await (0,Y.wsFetch)(`/api/wiki/content?path=${encodeURIComponent(a.path)}`);if(b.ok){let a=await b.json();bO(a.content),bR(Number(b.headers.get("X-Wiki-Revision")??0))}}catch{}bV(!1)}}(0,T.useEffect)(()=>{bg&&ei(bg.name)&&c8.useEditorStore.getState().currentPath!==bg.path&&c8.useEditorStore.getState().loadPage(bg.path)},[bg]),(0,T.useEffect)(()=>{b8.current=bg},[bg]),(0,T.useEffect)(()=>{ca.current=bW},[bW]),(0,T.useEffect)(()=>{cb.current=cQ},[cQ]),(0,T.useEffect)(()=>{if(!d||!V)return;let a=new Map,b=new EventSource((0,Y.withWs)("/api/wiki/watch"));return b.onmessage=b=>{var c;let d;try{d=JSON.parse(b.data)}catch{return}let{type:e,path:f}=d,g=f.split("/");if(c=g.length>1?g.slice(0,-1).join("/"):"",a.has(c)&&clearTimeout(a.get(c)),a.set(c,setTimeout(()=>{a.delete(c),cd(c)},300)),"change"===e&&b8.current?.path===f&&!ca.current){let b=`__file__${f}`;a.has(b)&&clearTimeout(a.get(b)),a.set(b,setTimeout(()=>{a.delete(b),cb.current()},400))}},()=>{for(let c of(b.close(),a.values()))clearTimeout(c)}},[d,cd,V]),(0,T.useEffect)(()=>{bl(!1)},[]);let cU=(0,T.useCallback)(a=>{let b=a.split("/").pop()??a;cc(a),cT({path:a,name:b,type:"file"})},[cc]),cV=(0,T.useCallback)(async a=>{let b=a.path.split("/").slice(0,-1).join("/"),c=(await el(b)).find(b=>b.path===a.path);if(c){if("dir"===c.type){await cc(a.path),await cS(c);return}if("app"===c.type||"node-app"===c.type){await cc(c.path),cT({path:c.path,name:c.name,type:c.type,modifiedAt:c.modifiedAt}),await cS(c),bu&&bw(!0);return}cT({path:c.path,name:c.name,type:c.type,modifiedAt:c.modifiedAt}),bu&&bw(!0)}},[bu,cT,cc,cS]);(0,T.useEffect)(()=>{if(!aA||bg&&bg.path===aA)return;let a=aA.split("/").pop()??aA;cT({path:aA,name:a,type:"file"})},[aA]);let cW=(0,T.useCallback)(async a=>{if(!a)return void bh(null);let b=a.split("/"),c=b[b.length-1],d=b.slice(0,-1).join("/"),e=(await el(d)).find(b=>b.path===a);e&&(await cc(a),cT({path:a,name:c,type:e.type,modifiedAt:e.modifiedAt}))},[cc]);(0,T.useEffect)(()=>{},[bg]),(0,T.useEffect)(()=>{},[cW]),(0,T.useEffect)(()=>{aL.current||aO&&(aL.current=!0,cW(aK.current))},[aO,cW]);let cX=(0,T.useCallback)(async a=>{if(a===V)return;try{await fetch(`/api/system/workspaces/${a}/open`,{method:"POST"})}catch{}let b=new URL(location.href);b.searchParams.set("ws",a),b.searchParams.delete("path"),history.pushState(null,"",b.toString()),bh(null),bO(null),bX(!1),aN([]),aP(!1),aS.current=!1,d7.useWikiSlugsStore.getState().invalidate();let c=$.find(b=>b.id===a);c&&O(c.rootDir),X(a)},[V,$]),c$=(0,T.useCallback)(async()=>{if(al)try{if(!(await fetch(`/api/system/workspaces/${al}`,{method:"DELETE"})).ok)throw Error("Failed");if(al===V){let a=$.filter(a=>a.id!==al);if(a.length>0){let b=[...a].sort((a,b)=>(b.lastOpenedAt??b.createdAt).localeCompare(a.lastOpenedAt??a.createdAt))[0];await cX(b.id)}else j(!1)}await az()}catch{}finally{am(null)}},[al,V,$,cX,az]),c0=(0,T.useCallback)(async a=>{if(!an){ao(a);try{let b=await fetch(`/api/system/workspaces/${a}/refresh`,{method:"POST"});if(!b.ok){let a=await b.json();(0,b_.showError)(a.error??"Refresh failed")}await az()}catch{(0,b_.showError)("Refresh failed")}finally{ao(null)}}},[an,az]),c1=(0,T.useCallback)(async a=>{if(!ap[a])try{let b=await fetch(`/api/system/workspaces/${a}/branch`);if(!b.ok)return;let c=await b.json();aq(b=>({...b,[a]:c.branches??[]}))}catch{}},[ap]),c2=(0,T.useCallback)(async(a,b)=>{if(!ar){as(a),au(b);try{let c=await fetch(`/api/system/workspaces/${a}/branch`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({branch:b})});if(!c.ok){let a=await c.json();(0,b_.showError)(a.error??"Branch switch failed");return}(0,b_.showSuccess)(`Switched to ${b}`),aw(null),ay(null),await az()}catch{(0,b_.showError)("Branch switch failed")}finally{as(null),au(null)}}},[ar,az]);async function c3(){if(!bg)return;b2(!0),b4(null);let a=await (0,Y.wsFetch)("/api/wiki/content",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:bg.path,content:bY,baseRevision:bP})});if(a.ok){let b=await a.json();"number"==typeof b.revision&&bR(b.revision),bO(bY),bX(!1)}else b4((await a.json()).error??"Save failed");b2(!1)}let c4=(0,T.useCallback)(async(a,b)=>{let c=Array.from(a);if(c.length){aW(!0),aY(null);try{for(let a of c){let c=new FormData;c.append("file",a),c.append("dir",b);let d=await (0,Y.wsFetch)("/api/wiki/upload",{method:"POST",body:c});if(!d.ok){let a=await d.json();aY(a.error??"Upload failed"),(0,b_.showError)(a.error??"Upload failed");break}}await cd(b)}catch{aY("Upload failed.")}finally{aW(!1),aZ.current&&(aZ.current.value="")}}},[cd]);function c5(a){a$.current=a,aZ.current?.click()}async function c6(){let a=a1.trim();if(!a||null===a_)return;a4(null);let b=a_?`${a_}/${a}`:a,c=await (0,Y.wsFetch)("/api/wiki/folder",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:b})});c.ok?(a0(null),a2(""),await cd(a_),""!==a_&&aN(a=>ep(a,a_,a=>({...a,expanded:!0})))):a4((await c.json()).error??"Failed")}async function c7(){let a=a7.trim();if(!a||null===a5)return;ba(null);let b=a.includes(".")?a:`${a}.md`,c=a5?`${a5}/${b}`:b,d=await (0,Y.wsFetch)("/api/wiki/new-file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:c})});d.ok?(a6(null),a8(""),await cd(a5),""!==a5&&aN(a=>ep(a,a5,a=>({...a,expanded:!0}))),cT({path:c,name:b,type:"file",modifiedAt:new Date().toISOString()})):ba((await d.json()).error??"Failed")}function c9(a){navigator.clipboard.writeText(a),(0,b_.showSuccess)("Path copied")}function da(a){let b=a.replace(/\.(md|markdown)$/i,"");navigator.clipboard.writeText(`[[${b}]]`),(0,b_.showSuccess)("Wiki link copied")}function db(a){let b=new URL(location.href);b.searchParams.set("path",a),V&&b.searchParams.set("ws",V),navigator.clipboard.writeText(b.toString()),(0,b_.showSuccess)("URL copied")}async function dc(a){if(bg?.path===a&&null!==bN)return bN;if(c8.useEditorStore.getState().currentPath===a)return c8.useEditorStore.getState().content;let b=await (0,Y.wsFetch)(`/api/wiki/content?path=${encodeURIComponent(a)}`);if(!b.ok)throw Error("Cannot copy content");return(await b.json()).content}async function dd(a){try{let b=await dc(a);await navigator.clipboard.writeText(b),(0,b_.showSuccess)("Raw content copied")}catch{(0,b_.showError)("Could not copy file content")}}async function de(a,b){try{let c=await dc(a);if(!ei(b)){await navigator.clipboard.writeText(c),(0,b_.showSuccess)("Content copied");return}let d=await (0,be.markdownToHtml)(c,{pagePath:a,sanitize:!0});"ClipboardItem"in window&&navigator.clipboard.write?await navigator.clipboard.write([new ClipboardItem({"text/html":new Blob([d],{type:"text/html"}),"text/plain":new Blob([c],{type:"text/plain"})})]):await navigator.clipboard.writeText(c),(0,b_.showSuccess)("Formatted content copied")}catch{(0,b_.showError)("Could not copy formatted content")}}function df(a,c){return(0,b.jsxs)(bJ.DropdownMenu,{children:[(0,b.jsx)(bJ.DropdownMenuTrigger,{asChild:!0,children:(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",title:"File actions",children:(0,b.jsx)(B,{className:"h-3.5 w-3.5"})})}),(0,b.jsxs)(bJ.DropdownMenuContent,{align:"end",className:"w-52",children:[(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>c9(a.path),children:[(0,b.jsx)(i.Copy,{className:"mr-2 h-3.5 w-3.5"}),"Copy path"]}),ei(a.name)&&(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>da(a.name),children:[(0,b.jsx)(n.FileText,{className:"mr-2 h-3.5 w-3.5"}),"Copy wiki link"]}),(0,b.jsx)(bJ.DropdownMenuSeparator,{}),(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>db(a.path),children:[(0,b.jsx)(y.Link,{className:"mr-2 h-3.5 w-3.5"}),"Copy URL"]}),eh(a.name)&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(bJ.DropdownMenuSeparator,{}),(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>void dd(a.path),children:[(0,b.jsx)(n.FileText,{className:"mr-2 h-3.5 w-3.5"}),"Copy raw content"]}),(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>void de(a.path,a.name),children:[(0,b.jsx)(n.FileText,{className:"mr-2 h-3.5 w-3.5"}),"Copy formatted content"]})]}),c&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(bJ.DropdownMenuSeparator,{}),c]})]})]})}async function dh(){bb&&(await (0,Y.wsFetch)("/api/wiki",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:bb})}),(bg?.path===bb||bg?.path.startsWith(`${bb}/`))&&(bh(null),bO(null)),aN(a=>(function a(b,c){return b.filter(a=>a.path!==c).map(b=>b.children?{...b,children:a(b.children,c)}:b)})(a,bb)),bc(null))}function di(a,b,c){a.preventDefault(),a.stopPropagation();let d=b5.current;if(!d){Array.from(a.dataTransfer.types).includes("Files")&&(a.dataTransfer.dropEffect="copy",b7("root"===c?"":b));return}d.path===b||b.startsWith(`${d.path}/`)||(a.dataTransfer.dropEffect="move",b7("root"===c?"":b))}async function dj(a,b){a.preventDefault(),a.stopPropagation(),b7(null);let c=b5.current;if(b5.current=null,!c){a.dataTransfer.files.length>0&&await c4(a.dataTransfer.files,b);return}if(c.path===b||b.startsWith(`${c.path}/`))return;let d=b?`${b}/${c.name}`:c.name;if(d!==c.path&&(await (0,Y.wsFetch)("/api/wiki/move",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({from:c.path,to:d})})).ok){let a=c.path.includes("/")?c.path.split("/").slice(0,-1).join("/"):"";await cd(a),b!==a&&await cd(b),bg?.path===c.path&&bh({path:d,name:c.name,nodeType:bg.nodeType,size:bg.size})}}let dk=bg?ef(bg.name,bg.nodeType):null,dl=!!bg&&null!==dk&&!ed.has(dk)&&(bg.size??0)>5242880&&bi!==bg.path,dm=(0,d2.useViewWidthStore)(a=>a.width),dn=(0,d2.useViewWidthStore)(a=>a.align),dp=(0,d2.useViewWidthStore)(a=>a.setWidth),dq=(0,d2.useViewWidthStore)(a=>a.setAlign),dr=null===dk||"editor"===dk||"text"===dk||"source"===dk||"notebook"===dk||"fallback"===dk,ds=dr?d2.VIEW_WIDTH_CLASS[dm]:"",dt=dr?d2.VIEW_ALIGN_CLASS[dn]:"",du=(0,T.useRef)(null);du.current={toggleFolder:a=>void cS(a),openViewer:a=>void cT(a),copyPath:c9,copyWikiLink:da,copyUrl:db,copyRawContent:a=>void dd(a),copyFormattedContent:(a,b)=>void de(a,b),handleDownload:function(a){let b=(0,Y.withWs)(`/api/wiki/download?path=${encodeURIComponent(a.path)}`),c=document.createElement("a");c.href=b,c.download="file"===a.type?a.name:`${a.name}.zip`,document.body.appendChild(c),c.click(),c.remove()},triggerUpload:c5,handleCreateFile:()=>void c7(),handleCreateFolder:()=>void c6(),handleDragStart:function(a,b){b5.current=b,a.dataTransfer.effectAllowed="move",a.dataTransfer.setData("text/plain",b.path)},handleDragOver:di,handleDropOnFolder:(a,b)=>void dj(a,b),handleGitPull:(a,b)=>void cI(a,b),handleCheckout:(a,b,c)=>void cN(a,b,c),loadBranches:a=>void cM(a),prefetch:a=>{"file"===a.type?ei(a.name)&&(0,c8.prefetchPage)(a.path):function(a){if(em.has(a)||en.has(a))return;let b=el(a).then(b=>(em.set(a,b),b)).finally(()=>en.delete(a));en.set(a,b),b.catch(()=>{})}(a.path)},togglePin:(a,b)=>cZ.getState().toggle({path:a.path,name:a.name,type:a.type},b),setDragOverPath:b7,setSidebarCollapsed:bw,setBranchDropdownNode:cD,setBranchDropdownPos:cG,setNewFileParent:a6,setNewFileName:a8,setFileCreateError:ba,setNewFolderParent:a0,setNewFolderName:a2,setFolderError:a4,setDeletingPath:bc,setDeletingIsDir:bf};let dv=(0,T.useMemo)(()=>({toggleFolder:a=>du.current.toggleFolder(a),openViewer:a=>du.current.openViewer(a),copyPath:a=>du.current.copyPath(a),copyWikiLink:a=>du.current.copyWikiLink(a),copyUrl:a=>du.current.copyUrl(a),copyRawContent:a=>du.current.copyRawContent(a),copyFormattedContent:(a,b)=>du.current.copyFormattedContent(a,b),handleDownload:a=>du.current.handleDownload(a),triggerUpload:a=>du.current.triggerUpload(a),handleCreateFile:()=>du.current.handleCreateFile(),handleCreateFolder:()=>du.current.handleCreateFolder(),handleDragStart:(a,b)=>du.current.handleDragStart(a,b),handleDragOver:(a,b,c)=>du.current.handleDragOver(a,b,c),handleDropOnFolder:(a,b)=>du.current.handleDropOnFolder(a,b),handleGitPull:(a,b)=>du.current.handleGitPull(a,b),handleCheckout:(a,b,c)=>du.current.handleCheckout(a,b,c),loadBranches:a=>du.current.loadBranches(a),prefetch:a=>du.current.prefetch(a),togglePin:(a,b)=>du.current.togglePin(a,b),setDragOverPath:a=>du.current.setDragOverPath(a),setSidebarCollapsed:a=>du.current.setSidebarCollapsed(a),setBranchDropdownNode:a=>du.current.setBranchDropdownNode(a),setBranchDropdownPos:a=>du.current.setBranchDropdownPos(a),setNewFileParent:a=>du.current.setNewFileParent(a),setNewFileName:a=>du.current.setNewFileName(a),setFileCreateError:a=>du.current.setFileCreateError(a),setNewFolderParent:a=>du.current.setNewFolderParent(a),setNewFolderName:a=>du.current.setNewFolderName(a),setFolderError:a=>du.current.setFolderError(a),setDeletingPath:a=>du.current.setDeletingPath(a),setDeletingIsDir:a=>du.current.setDeletingIsDir(a)}),[]);return(0,b.jsxs)("div",{className:"flex h-screen gap-0 overflow-hidden bg-background",children:[null===d&&(0,b.jsx)("div",{className:"flex-1 flex items-center justify-center",children:(0,b.jsx)(z.Loader2,{className:"h-5 w-5 animate-spin text-muted-foreground"})}),!1===d&&(0,b.jsx)(bQ,{onSelect:a=>{let b=new URL(location.href);b.searchParams.set("ws",a),b.searchParams.delete("path"),history.replaceState(null,"",b.toString()),aP(!1),aS.current=!1,X(a),j(!0),az()}}),!0===d&&af&&(0,b.jsxs)("div",{className:"flex-1 flex flex-col",children:[(0,b.jsx)("div",{className:"flex items-center justify-end border-b px-3 py-2 bg-muted shrink-0",children:(0,b.jsxs)(U.Button,{size:"sm",variant:"ghost",className:"h-7 gap-1.5 text-xs",onClick:()=>aj(!1),children:[(0,b.jsx)(S.X,{className:"h-3.5 w-3.5"})," Cancel"]})}),(0,b.jsx)(bQ,{onSelect:a=>{aj(!1),az(),cX(a)}})]}),!0===d&&!af&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(d4,{onOpenFile:cU,recents:aB,onToggleSidebar:()=>bw(a=>{let b=!a;return bu&&!1===b&&c_.useAIPanelStore.getState().close(),b}),onNewFile:()=>a6(""),onCopyPath:()=>{bg&&navigator.clipboard.writeText(bg.path)}}),!bv&&bu&&(0,b.jsx)("div",{className:"fixed inset-0 z-40 bg-overlay backdrop-blur-[1px] md:hidden",onClick:()=>bw(!0),"aria-hidden":!0}),!bv&&(0,b.jsxs)(cw.Card,{style:bu?void 0:{width:bx},className:"fixed inset-y-0 left-0 z-50 w-[85vw] max-w-[20rem] md:relative md:z-auto md:w-auto md:max-w-none flex flex-col shrink-0 overflow-hidden rounded-none border-r border-l-0 border-t-0 border-b-0",children:[(0,b.jsxs)("div",{className:"flex items-center justify-between gap-2 px-3 py-2 border-b bg-muted shrink-0",children:[(0,b.jsxs)("div",{className:"flex min-w-0 items-center gap-1.5",title:"Wiki Viewer v2.7.5",children:[(0,b.jsx)("img",{src:"/logo.svg",alt:"Wiki Viewer",className:"h-5 w-5 shrink-0"}),(0,b.jsx)("span",{className:"truncate text-xs font-semibold leading-5 tracking-tight translate-y-[0.5px]",children:"Wiki Viewer"})]}),(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0 shrink-0",title:"Collapse sidebar",onClick:()=>bw(!0),children:(0,b.jsx)(D,{className:"h-3.5 w-3.5"})})]}),(0,b.jsxs)("div",{className:"flex items-center justify-between gap-1 px-3 py-1.5 border-b bg-muted/50 shrink-0",children:[(0,b.jsxs)(bJ.DropdownMenu,{children:[(0,b.jsx)(bJ.DropdownMenuTrigger,{asChild:!0,children:(0,b.jsxs)(U.Button,{size:"sm",variant:"ghost",className:"h-7 gap-1 px-2 text-xs",disabled:aV,children:[aV?(0,b.jsx)(z.Loader2,{className:"h-3.5 w-3.5 animate-spin"}):(0,b.jsx)(J,{className:"h-3.5 w-3.5"}),"New",(0,b.jsx)(g.ChevronDown,{className:"h-3 w-3 opacity-60"})]})}),(0,b.jsxs)(bJ.DropdownMenuContent,{align:"start",className:"w-44",children:[(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>{a6(""),a8(""),ba(null)},children:[(0,b.jsx)(m.FilePlus,{className:"mr-2 h-3.5 w-3.5"}),"New file"]}),(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>{a0(""),a2(""),a4(null)},children:[(0,b.jsx)(q,{className:"mr-2 h-3.5 w-3.5"}),"New folder"]}),(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>c5(""),disabled:aV,children:[(0,b.jsx)(R.Upload,{className:"mr-2 h-3.5 w-3.5"}),"Upload"]})]})]}),(0,b.jsxs)("div",{className:"flex items-center gap-0.5",children:[(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",title:"Refresh tree",onClick:cP,disabled:aT,children:aT?(0,b.jsx)(z.Loader2,{className:"h-3.5 w-3.5 animate-spin"}):(0,b.jsx)(K,{className:"h-3.5 w-3.5"})}),(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",title:"AI Agent panel",onClick:()=>{c_.useAIPanelStore.getState().toggle(),bu&&bw(!0)},children:(0,b.jsx)(e,{className:"h-3.5 w-3.5"})}),(0,b.jsxs)(bJ.DropdownMenu,{children:[(0,b.jsx)(bJ.DropdownMenuTrigger,{asChild:!0,children:(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",title:"More actions",children:(0,b.jsx)(B,{className:"h-3.5 w-3.5"})})}),(0,b.jsxs)(bJ.DropdownMenuContent,{align:"end",className:"w-48",children:[aa&&$.find(a=>a.id===V)?.git&&(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>{V&&c0(V)},disabled:an===V,children:[an===V?(0,b.jsx)(z.Loader2,{className:"mr-2 h-3.5 w-3.5 animate-spin"}):(0,b.jsx)(k,{className:"mr-2 h-3.5 w-3.5"}),"Pull latest"]}),(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>d8.getState().toggle(),children:[by?(0,b.jsx)(H,{className:"mr-2 h-3.5 w-3.5"}):(0,b.jsx)(G.Eye,{className:"mr-2 h-3.5 w-3.5"}),by?"Hide hidden files":"Show hidden files"]}),(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>d9.getState().toggle(),children:[(0,b.jsx)(P.Type,{className:"mr-2 h-3.5 w-3.5"}),bz?"Raw file names":"Humanize names"]}),(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>bB("dark"===bA?"light":"dark"),children:["dark"===bA?(0,b.jsx)(N.Sun,{className:"mr-2 h-3.5 w-3.5"}):(0,b.jsx)(C.Moon,{className:"mr-2 h-3.5 w-3.5"}),"dark"===bA?"Light mode":"Dark mode"]}),(0,b.jsx)(bJ.DropdownMenuSeparator,{}),(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>bI(!0),children:[(0,b.jsx)(L,{className:"mr-2 h-3.5 w-3.5"}),"Settings"]})]})]})]})]}),aX&&(0,b.jsxs)("div",{className:"flex items-center gap-1.5 px-3 py-1.5 text-xs text-destructive bg-destructive/10 shrink-0",children:[(0,b.jsx)(c.AlertCircle,{className:"h-3.5 w-3.5 shrink-0"}),aX]}),""===a_&&(0,b.jsxs)("div",{className:"flex items-center gap-1.5 px-2 py-1 border-b shrink-0",children:[(0,b.jsx)(o.Folder,{className:"h-4 w-4 shrink-0 text-warning"}),(0,b.jsx)("input",{className:"flex-1 bg-transparent text-sm outline-none border-b border-border min-w-0",placeholder:"Folder name",value:a1,onChange:a=>a2(a.target.value),onKeyDown:a=>{"Enter"===a.key&&c6(),"Escape"===a.key&&(a0(null),a2(""))}}),a3&&(0,b.jsx)("span",{className:"text-xs text-destructive",children:a3}),(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:c6,children:(0,b.jsx)(f.Check,{className:"h-3 w-3"})}),(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:()=>{a0(null),a2("")},children:(0,b.jsx)(S.X,{className:"h-3 w-3"})})]}),""===a5&&(0,b.jsxs)("div",{className:"flex items-center gap-1.5 px-2 py-1 border-b shrink-0",children:[(0,b.jsx)(n.FileText,{className:"h-4 w-4 shrink-0 text-accent"}),(0,b.jsx)("input",{autoFocus:!0,className:"flex-1 bg-transparent text-sm outline-none border-b border-border min-w-0",placeholder:"filename (default .md)",value:a7,onChange:a=>a8(a.target.value),onKeyDown:a=>{"Enter"===a.key&&c7(),"Escape"===a.key&&(a6(null),a8(""))}}),a9&&(0,b.jsx)("span",{className:"text-xs text-destructive",children:a9}),(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:c7,children:(0,b.jsx)(f.Check,{className:"h-3 w-3"})}),(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:()=>{a6(null),a8("")},children:(0,b.jsx)(S.X,{className:"h-3 w-3"})})]}),(0,b.jsx)("div",{className:"border-b",children:(0,b.jsx)(d5,{onOpenFile:cU})}),(0,b.jsxs)("div",{ref:aH,className:(0,Z.cn)("flex-1 overflow-auto py-1 editorial-file-tree",""===b6&&"ring-2 ring-inset ring-primary bg-primary/5"),onDragOver:a=>di(a,"","root"),onDragLeave:a=>{a.currentTarget.contains(a.relatedTarget)||b7(null)},onDrop:a=>dj(a,""),children:[aG.length>0&&(0,b.jsxs)("div",{className:"border-b mb-1",children:[(0,b.jsxs)("button",{type:"button",className:"flex w-full items-center gap-1 px-2 py-1 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground hover:text-foreground",onClick:()=>aD(a=>!a),children:[aC?(0,b.jsx)(h.ChevronRight,{className:"h-3 w-3"}):(0,b.jsx)(g.ChevronDown,{className:"h-3 w-3"}),(0,b.jsx)(I,{className:"h-3 w-3"}),"Pinned",(0,b.jsx)("span",{className:"ml-auto text-[9px] tabular-nums opacity-60",children:aG.length})]}),!aC&&aG.map(a=>(0,b.jsxs)(cF,{children:[(0,b.jsx)(cH,{asChild:!0,children:(0,b.jsxs)("div",{role:"button",tabIndex:0,className:(0,Z.cn)("group flex items-center gap-1.5 rounded-sm px-2 py-1 text-sm cursor-pointer transition-colors select-none",bg?.path===a.path?"bg-accent-soft text-foreground font-medium":"hover:bg-muted"),onClick:()=>{cV(a)},onKeyDown:b=>{("Enter"===b.key||" "===b.key)&&(b.preventDefault(),cV(a))},children:[(0,b.jsx)(es,{name:a.name,type:a.type??"file"}),(0,b.jsx)("span",{className:"min-w-0 flex-1 truncate text-xs",title:bz?a.name:void 0,children:bz?ea(a.name):a.name}),(0,b.jsx)("span",{className:"max-w-[80px] truncate text-[10px] text-muted-foreground/60",children:a.path.split("/").slice(0,-1).join("/")}),(0,b.jsx)("button",{type:"button",className:"hover-reveal shrink-0 rounded p-0.5 text-muted-foreground/50 opacity-0 transition-colors hover:bg-muted hover:text-amber-400 group-hover:opacity-100 focus:opacity-100",title:"Remove from pinned",onClick:b=>{b.stopPropagation(),cZ.getState().toggle({path:a.path,name:a.name},V)},children:(0,b.jsx)(S.X,{className:"h-3 w-3"})})]})}),(0,b.jsx)(er,{node:{path:a.path,name:a.name,type:a.type??"file"},ctx:dv,isPinned:!0,activeWorkspaceId:V})]},a.path))]}),aB.length>0&&(0,b.jsxs)("div",{className:"border-b mb-1",children:[(0,b.jsxs)("button",{type:"button",className:"flex w-full items-center gap-1 px-2 py-1 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground hover:text-foreground",onClick:()=>aF(a=>!a),children:[aE?(0,b.jsx)(h.ChevronRight,{className:"h-3 w-3"}):(0,b.jsx)(g.ChevronDown,{className:"h-3 w-3"}),(0,b.jsx)(v,{className:"h-3 w-3"}),"Recent",(0,b.jsx)("span",{className:"ml-auto text-[9px] tabular-nums opacity-60",children:aB.length})]}),!aE&&aB.slice(0,8).map(a=>(0,b.jsxs)(cF,{children:[(0,b.jsx)(cH,{asChild:!0,children:(0,b.jsxs)("div",{role:"button",tabIndex:0,className:(0,Z.cn)("flex items-center gap-1.5 rounded-sm px-2 py-1 text-sm cursor-pointer transition-colors select-none",bg?.path===a.path?"bg-accent-soft text-foreground font-medium":"hover:bg-muted"),onClick:()=>{cT({path:a.path,name:a.name,type:a.type??"file",modifiedAt:""}),bu&&bw(!0)},onKeyDown:b=>{("Enter"===b.key||" "===b.key)&&(b.preventDefault(),cT({path:a.path,name:a.name,type:a.type??"file",modifiedAt:""}))},children:[(0,b.jsx)(es,{name:a.name,type:a.type??"file"}),(0,b.jsx)("span",{className:"flex-1 truncate text-xs",title:bz?a.name:void 0,children:bz?ea(a.name):a.name}),(0,b.jsx)("span",{className:"text-[10px] text-muted-foreground/60 truncate max-w-[80px]",children:a.path.split("/").slice(0,-1).join("/")})]})}),(0,b.jsx)(er,{node:{path:a.path,name:a.name,type:a.type??"file"},ctx:dv,isPinned:aG.some(b=>b.path===a.path),activeWorkspaceId:V})]},a.path))]}),aQ?(0,b.jsx)("div",{className:"flex justify-center py-6",children:(0,b.jsx)(z.Loader2,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):0===aM.length?(0,b.jsxs)("div",{className:"flex flex-col items-center gap-3 px-4 py-8 text-center",children:[(0,b.jsx)("div",{className:"rounded-full bg-muted p-3",children:(0,b.jsx)(n.FileText,{className:"h-6 w-6 text-muted-foreground"})}),(0,b.jsxs)("div",{className:"space-y-1",children:[(0,b.jsx)("p",{className:"text-sm font-medium",children:"No files yet"}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:"Upload files or add them to the configured directory"})]}),(0,b.jsxs)(U.Button,{size:"sm",variant:"outline",className:"w-full gap-1.5 max-w-[180px]",onClick:()=>c5(""),disabled:aV,children:[aV?(0,b.jsx)(z.Loader2,{className:"h-3.5 w-3.5 animate-spin"}):(0,b.jsx)(R.Upload,{className:"h-3.5 w-3.5"}),"Upload Files"]})]}):(0,b.jsx)(eu,{ctx:dv,nodes:aM,openPath:bg?.path??null,dragOverPath:b6,branchDropdownNode:cC,branchDropdownPos:cE,nodeBranches:cu,branchesLoading:cy,checkingOutBranch:cA,pullingRepo:ce,activePaths:aJ,pins:aG,isMobile:bu,activeWorkspaceId:V,newFileParent:a5,newFileName:a7,fileCreateError:a9,newFolderParent:a_,newFolderName:a1,folderError:a3,sidebarScrollRef:aH})]}),(0,b.jsxs)("div",{className:"border-t px-2 py-2 bg-muted shrink-0",children:[(0,b.jsxs)(bJ.DropdownMenu,{modal:!1,onOpenChange:a=>{a||(aw(null),ay(null))},children:[(0,b.jsx)(bJ.DropdownMenuTrigger,{asChild:!0,children:(0,b.jsxs)(U.Button,{size:"sm",variant:"ghost",className:"w-full h-auto justify-between gap-2 px-2 py-1.5 text-left",title:p??"",children:[(0,b.jsxs)("span",{className:"flex flex-col min-w-0",children:[(0,b.jsx)("span",{className:"truncate text-xs font-medium",children:$.find(a=>a.id===V)?.name??"Workspace"}),(0,b.jsx)("span",{className:"truncate text-[10px] text-muted-foreground font-mono",children:p??""})]}),(0,b.jsx)(g.ChevronDown,{className:"h-3.5 w-3.5 shrink-0 opacity-60"})]})}),(0,b.jsxs)(bJ.DropdownMenuContent,{align:"start",className:"w-[var(--radix-dropdown-menu-trigger-width)]",onInteractOutside:a=>{a.target?.closest?.("[data-branch-portal]")&&a.preventDefault()},children:[$.map(a=>(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>void cX(a.id),onPointerMove:a=>a.preventDefault(),onPointerLeave:a=>a.preventDefault(),className:(0,Z.cn)("gap-2",a.id===V&&"font-medium"),children:[a.id===V?(0,b.jsx)(f.Check,{className:"h-3.5 w-3.5 shrink-0"}):(0,b.jsx)("span",{className:"w-3.5 shrink-0"}),(0,b.jsxs)("span",{className:"flex flex-col min-w-0 flex-1",children:[(0,b.jsxs)("span",{className:"flex items-center gap-1.5 truncate",children:[(0,b.jsx)("span",{className:"truncate",children:a.name}),a.git?aa?(0,b.jsxs)("button",{"data-branch-trigger":!0,type:"button",className:"inline-flex items-center gap-0.5 rounded bg-muted px-1.5 text-[10px] text-muted-foreground font-normal shrink-0 hover:bg-accent",title:"Switch branch",disabled:ar===a.id,onClick:b=>{if(b.stopPropagation(),b.preventDefault(),av===a.id){aw(null),ay(null);return}let c=b.currentTarget.getBoundingClientRect();ay({top:c.bottom+4,left:c.left}),aw(a.id),c1(a.id)},children:[(0,b.jsx)(r,{className:"h-2.5 w-2.5"})," ",a.git.branch??"branch"]}):(0,b.jsxs)("span",{className:"inline-flex items-center gap-0.5 rounded bg-muted px-1.5 text-[10px] text-muted-foreground font-normal shrink-0",children:[(0,b.jsx)(r,{className:"h-2.5 w-2.5"})," ",a.git.branch??"read-only"]}):a.ssh?(0,b.jsxs)("span",{className:"inline-flex items-center gap-0.5 rounded bg-muted px-1.5 text-[10px] text-muted-foreground font-normal shrink-0",children:[(0,b.jsx)(s,{className:"h-2.5 w-2.5"})," ",a.ssh.host]}):a.readOnly?(0,b.jsxs)("span",{className:"inline-flex items-center gap-0.5 rounded bg-muted px-1.5 text-[10px] text-muted-foreground font-normal shrink-0",children:[(0,b.jsx)(r,{className:"h-2.5 w-2.5"})," read-only"]}):null]}),(0,b.jsx)("span",{className:"truncate text-[10px] text-muted-foreground font-mono",children:a.rootDir}),a.git?.lastPulledAt&&ec(a.git.lastPulledAt)&&(0,b.jsxs)("span",{className:"text-[10px] text-muted-foreground/70",children:["synced ",ec(a.git.lastPulledAt)]})]}),aa&&a.git&&(0,b.jsx)("button",{className:(0,Z.cn)("shrink-0 rounded p-0.5 hover:bg-accent transition-colors",a.git.lastError?"text-destructive":"text-muted-foreground hover:text-foreground"),title:a.git.lastError?`Last refresh failed: ${a.git.lastError}`:"Refresh",disabled:an===a.id,onClick:b=>{b.stopPropagation(),b.preventDefault(),c0(a.id)},children:(0,b.jsx)(K,{className:(0,Z.cn)("h-3.5 w-3.5",an===a.id&&"animate-spin")})}),aa&&(0,b.jsx)("button",{className:"shrink-0 rounded p-0.5 text-muted-foreground hover:text-destructive hover:bg-destructive/10 transition-colors",title:"Delete workspace (does not delete files)",onClick:b=>{b.stopPropagation(),am(a.id)},children:(0,b.jsx)(Q.Trash2,{className:"h-3.5 w-3.5"})})]},a.id)),aa&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(bJ.DropdownMenuSeparator,{}),(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>aj(!0),children:[(0,b.jsx)(q,{className:"mr-2 h-3.5 w-3.5"}),"Add workspace…"]})]})]})]}),(()=>{if(!av||!ax)return null;let a=$.find(a=>a.id===av);return a?(0,b.jsx)(bS,{pos:ax,branches:(ap[a.id]??[]).map(b=>({name:b,current:b===a.git?.branch})),loading:!ap[a.id],busyName:ar===a.id?at:null,disabled:ar===a.id,onPick:b=>{c2(a.id,b)},onClose:()=>{aw(null),ay(null)}}):null})()]}),(0,b.jsx)("div",{role:"separator","aria-orientation":"vertical","aria-label":"Resize sidebar",title:"Drag to resize",onMouseDown:a=>{a.preventDefault();let b=a.clientX;bF(!0);let c=document.body.style.cursor,d=document.body.style.userSelect;document.body.style.cursor="col-resize",document.body.style.userSelect="none";let e=a=>{bC(bx+(a.clientX-b))},f=()=>{bF(!1),document.body.style.cursor=c,document.body.style.userSelect=d,window.removeEventListener("mousemove",e),window.removeEventListener("mouseup",f)};window.addEventListener("mousemove",e),window.addEventListener("mouseup",f)},onDoubleClick:()=>bC(288),onKeyDown:a=>{"ArrowLeft"===a.key?(a.preventDefault(),bC(bx-16)):"ArrowRight"===a.key&&(a.preventDefault(),bC(bx+16))},tabIndex:0,"aria-valuemin":200,"aria-valuemax":600,"aria-valuenow":bx,className:(0,Z.cn)("absolute right-0 top-0 z-20 h-full w-1.5 cursor-col-resize -mr-px transition-colors hover:bg-primary/40 focus:bg-primary/40 focus:outline-none hidden md:block",bD&&"bg-primary/60")})]}),(0,b.jsxs)("div",{className:"flex-1 flex flex-col min-w-0 relative",children:[bv&&(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"hidden md:flex absolute left-2 top-2 z-10 h-7 w-7 p-0",title:"Show sidebar",onClick:()=>bw(!1),children:(0,b.jsx)(E,{className:"h-3.5 w-3.5"})}),(0,b.jsxs)("div",{className:"md:hidden flex h-11 shrink-0 items-center justify-between gap-2 border-b bg-muted px-1",children:[(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-9 w-9 p-0",title:"Show sidebar",onClick:()=>{bw(!1),c_.useAIPanelStore.getState().close()},children:(0,b.jsx)(E,{className:"h-4 w-4"})}),(0,b.jsxs)("span",{className:"flex min-w-0 items-center gap-1.5 text-xs font-semibold tracking-tight text-muted-foreground",title:bg?.path,children:[bg&&(0,b.jsx)("span",{className:"editorial-tree-typeicon shrink-0",children:"app"===dk||"html"===dk?(0,b.jsx)(u.Globe,{className:"h-4 w-4 text-foreground/70"}):ej(bg.name)?(0,b.jsx)(x.default,{className:"h-4 w-4 text-sunshine-700"}):eh(bg.name)?(0,b.jsx)(n.FileText,{className:"h-4 w-4 text-foreground/70"}):(0,b.jsx)(l.File,{className:"h-4 w-4 text-foreground/60"})}),(0,b.jsx)("span",{className:"truncate",children:bg?bg.name:"Wiki Viewer"})]}),(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-9 w-9 p-0",title:"AI Agent panel",onClick:()=>{c_.useAIPanelStore.getState().open(),bw(!0)},children:(0,b.jsx)(e,{className:"h-4 w-4"})})]}),bg?"node-app"===dk?(0,b.jsx)(bL,{path:bg.path,title:bg.name}):"app"===dk||"html"===dk?(a="html"===dk?`/api/assets/${bg.path}`:void 0,bk?(0,b.jsx)(bG,{path:bg.path,title:bg.name,src:a,fullscreen:!0,onExit:()=>bl(!1)}):(0,b.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden min-w-0",children:[(0,b.jsxs)("div",{className:(0,Z.cn)("flex items-center justify-between px-4 py-2 border-b bg-muted shrink-0 editorial-doc-header",!bu&&bv&&"pl-11"),children:[(0,b.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,b.jsx)("span",{className:"hidden md:inline-flex",children:(0,b.jsx)("span",{className:"editorial-tree-typeicon",children:(0,b.jsx)(u.Globe,{className:"h-4 w-4 shrink-0 text-foreground/70"})})}),(0,b.jsx)("span",{className:"hidden md:inline text-sm font-normal truncate",title:bg.path,children:bg.path})]}),(0,b.jsxs)("div",{className:"flex items-center gap-1 shrink-0",children:[df(bg,(0,b.jsxs)(b.Fragment,{children:["html"===dk&&!bW&&(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>b0(a=>!a),children:[b$?(0,b.jsx)(u.Globe,{className:"mr-2 h-3.5 w-3.5"}):(0,b.jsx)(t.Code2,{className:"mr-2 h-3.5 w-3.5"}),b$?"Show preview":"Show source"]}),(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>bo(a=>a+1),children:[(0,b.jsx)(K,{className:"mr-2 h-3.5 w-3.5"}),"Refresh"]}),(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>bl(!0),children:[(0,b.jsx)(A,{className:"mr-2 h-3.5 w-3.5"}),"Open fullscreen"]}),(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>bM(!0),children:[(0,b.jsx)(M,{className:"mr-2 h-3.5 w-3.5"}),"Share"]})]})),"html"===dk&&!bW&&null!==bN&&(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",title:"Edit source",onClick:()=>{bX(!0),bZ(bN),b4(null)},children:(0,b.jsx)(F,{className:"h-3.5 w-3.5"})}),(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",onClick:()=>{bh(null),bX(!1)},children:(0,b.jsx)(S.X,{className:"h-3.5 w-3.5"})})]})]}),bW&&"html"===dk?(0,b.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden min-h-0",children:[(0,b.jsx)("textarea",{value:bY,onChange:a=>bZ(a.target.value),spellCheck:!1,className:"flex-1 w-full min-h-0 resize-none bg-background text-foreground px-4 py-3 font-mono text-[13px] leading-relaxed outline-none border-0"}),(0,b.jsxs)("div",{className:"border-t px-4 py-2 flex items-center justify-end gap-2 bg-muted shrink-0",children:[b3&&(0,b.jsx)("span",{className:"text-xs text-destructive mr-auto",children:b3}),(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",onClick:()=>{bX(!1),b4(null)},children:"Cancel"}),(0,b.jsxs)(U.Button,{size:"sm",className:"gap-1",onClick:c3,disabled:b1,children:[b1&&(0,b.jsx)(z.Loader2,{className:"h-3 w-3 animate-spin"}),"Save"]})]})]}):b$&&"html"===dk?(0,b.jsx)(bE,{path:bg.path,title:bg.name}):(0,b.jsx)(bG,{path:bg.path,title:bg.name,src:a},bm)]})):(0,b.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden min-w-0",children:[(0,b.jsxs)("div",{className:(0,Z.cn)("flex items-center justify-between px-4 py-2 border-b bg-muted shrink-0 editorial-doc-header",!bu&&bv&&"pl-11"),children:[(0,b.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,b.jsx)("span",{className:"hidden md:inline-flex",children:(0,b.jsx)("span",{className:"editorial-tree-typeicon",children:ej(bg.name)?(0,b.jsx)(x.default,{className:"h-4 w-4 shrink-0 text-sunshine-700"}):eh(bg.name)?(0,b.jsx)(n.FileText,{className:"h-4 w-4 shrink-0 text-foreground/70"}):(0,b.jsx)(l.File,{className:"h-4 w-4 shrink-0 text-foreground/60"})})}),(0,b.jsx)("span",{className:"hidden md:inline text-sm font-normal truncate",title:bg.path,children:bg.path}),cg&&(0,b.jsxs)("span",{className:"hidden md:flex items-center gap-1 text-[11px] text-muted-foreground shrink-0 ml-1",children:[(0,b.jsx)(w,{className:"h-3 w-3 shrink-0"}),(0,b.jsx)("span",{className:"truncate max-w-[100px]",children:cg.author}),(0,b.jsx)("span",{title:new Date(cg.date).toLocaleString(),className:"shrink-0",children:ec(cg.date)})]})]}),(0,b.jsxs)("div",{className:"flex items-center gap-1 shrink-0",children:[df(bg,(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>{ci?cj(!1):cK()},children:[(0,b.jsx)(v,{className:"mr-2 h-3.5 w-3.5"}),ci?"Hide history":"File history"]}),(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>bM(!0),children:[(0,b.jsx)(M,{className:"mr-2 h-3.5 w-3.5"}),"Share"]}),!bW&&(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:cR,disabled:bU,children:[bU?(0,b.jsx)(z.Loader2,{className:"mr-2 h-3.5 w-3.5 animate-spin"}):(0,b.jsx)(K,{className:"mr-2 h-3.5 w-3.5"}),"Refresh"]}),dr&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(bJ.DropdownMenuSeparator,{}),(0,b.jsx)(bJ.DropdownMenuLabel,{className:"text-[11px] text-muted-foreground",children:"Width"}),d2.VIEW_WIDTH_ORDER.map(a=>(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>dp(a),className:"flex items-center justify-between text-xs",children:[d2.VIEW_WIDTH_LABEL[a],a===dm&&(0,b.jsx)(f.Check,{className:"h-3.5 w-3.5"})]},a)),(0,b.jsx)(bJ.DropdownMenuSeparator,{}),(0,b.jsx)(bJ.DropdownMenuLabel,{className:"text-[11px] text-muted-foreground",children:"Alignment"}),d2.VIEW_ALIGN_ORDER.map(a=>(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>dq(a),className:"flex items-center justify-between text-xs",children:[d2.VIEW_ALIGN_LABEL[a],a===dn&&(0,b.jsx)(f.Check,{className:"h-3.5 w-3.5"})]},a))]})]})),eh(bg.name)&&!bW&&(null!==bN||ei(bg.name))&&(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",onClick:()=>{bX(!0),bZ(bN??""),b4(null),ei(bg.name)&&c8.useEditorStore.getState().loadPage(bg.path)},children:(0,b.jsx)(F,{className:"h-3.5 w-3.5"})}),eh(bg.name)&&bW&&ei(bg.name)&&(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",title:"Done editing",onClick:()=>{bX(!1),b4(null)},children:(0,b.jsx)(G.Eye,{className:"h-3.5 w-3.5"})}),(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",onClick:()=>{bh(null),bO(null),bX(!1)},children:(0,b.jsx)(S.X,{className:"h-3.5 w-3.5"})})]})]}),ci&&(0,b.jsxs)("div",{className:"border-b bg-muted/30 shrink-0 max-h-[40vh] overflow-auto",children:[(0,b.jsxs)("div",{className:"flex items-center justify-between px-4 py-1.5 border-b",children:[(0,b.jsx)("span",{className:"text-xs font-semibold text-muted-foreground",children:"History"}),(0,b.jsx)("button",{type:"button",className:"text-muted-foreground hover:text-foreground",onClick:()=>cj(!1),children:(0,b.jsx)(S.X,{className:"h-3.5 w-3.5"})})]}),cm?(0,b.jsx)("div",{className:"flex justify-center py-4",children:(0,b.jsx)(z.Loader2,{className:"h-4 w-4 animate-spin text-muted-foreground"})}):0===ck.length?(0,b.jsx)("p",{className:"px-4 py-3 text-xs text-muted-foreground",children:"No history found."}):(0,b.jsx)("div",{children:ck.map(a=>(0,b.jsxs)("div",{children:[(0,b.jsx)("button",{type:"button",className:(0,Z.cn)("w-full text-left px-4 py-2 hover:bg-muted transition-colors",co===a.sha&&"bg-muted"),onClick:()=>void cL(a.sha),children:(0,b.jsxs)("div",{className:"flex items-center gap-2",children:[(0,b.jsx)("code",{className:"text-[11px] font-mono text-muted-foreground shrink-0",children:a.shortSha}),(0,b.jsx)("span",{className:"flex-1 truncate text-xs",children:a.message}),(0,b.jsx)("span",{className:"shrink-0 text-[11px] text-muted-foreground",children:a.author}),(0,b.jsx)("span",{className:"shrink-0 text-[11px] text-muted-foreground",title:new Date(a.date).toLocaleString(),children:ec(a.date)})]})}),co===a.sha&&(0,b.jsx)("div",{className:"border-t",children:cs?(0,b.jsx)("div",{className:"flex justify-center py-3",children:(0,b.jsx)(z.Loader2,{className:"h-4 w-4 animate-spin text-muted-foreground"})}):null!==cq?(0,b.jsx)("pre",{className:"overflow-auto px-4 py-2 text-[11px] font-mono leading-relaxed whitespace-pre text-foreground/80 max-h-60",children:cq}):null})]},a.sha))})]}),dl?(0,b.jsx)(ag,{path:bg.path,size:bg.size??0,onOpen:()=>bj(bg.path)}):bW?(0,b.jsx)("div",{className:"flex-1 flex flex-col overflow-hidden min-h-0",children:ei(bg.name)?(0,b.jsx)(ac.KBEditor,{}):(0,b.jsx)("textarea",{value:bY,onChange:a=>bZ(a.target.value),spellCheck:!1,className:"flex-1 w-full min-h-0 resize-none bg-background text-foreground px-4 py-3 font-mono text-[13px] leading-relaxed outline-none border-0"})}):ei(bg.name)?(0,b.jsx)("div",{className:"flex-1 flex flex-col overflow-hidden min-h-0",children:bU?(0,b.jsx)("div",{className:"flex justify-center py-8",children:(0,b.jsx)(z.Loader2,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):(0,b.jsx)(ac.KBEditor,{mode:"viewing"})}):"csv"===dk||"pdf"===dk||"mermaid"===dk||"notebook"===dk||"image"===dk||"media"===dk||"docx"===dk||"xlsx"===dk||"pptx"===dk||"source"===dk||"fallback"===dk?(0,b.jsx)("div",{className:"flex-1 flex flex-col overflow-hidden min-h-0",children:bU?(0,b.jsx)("div",{className:"flex justify-center py-8",children:(0,b.jsx)(z.Loader2,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):"csv"===dk?(0,b.jsx)(ab,{path:bg.path,title:bg.name}):"pdf"===dk?(0,b.jsx)(eb,{path:bg.path,title:bg.name}):"mermaid"===dk?(0,b.jsx)(ak,{path:bg.path,title:bg.name}):"notebook"===dk?(0,b.jsx)(bn,{path:bg.path,title:bg.name}):"image"===dk?(0,b.jsx)(ah,{path:bg.path,title:bg.name}):"media"===dk?(0,b.jsx)(ai,{path:bg.path,title:bg.name,type:["mp4","webm","mov","m4v"].includes(ee(bg.name))?"video":"audio"}):"docx"===dk?(0,b.jsx)(bp,{path:bg.path,title:bg.name}):"xlsx"===dk?(0,b.jsx)(br,{path:bg.path,title:bg.name}):"pptx"===dk?(0,b.jsx)(bq,{path:bg.path,title:bg.name}):"source"===dk?(0,b.jsx)(bE,{path:bg.path,title:bg.name}):(0,b.jsx)(ad,{path:bg.path,title:bg.name})},bs):(0,b.jsx)("div",{className:"flex-1 overflow-auto p-4 min-h-0",children:(0,b.jsx)("div",{className:(0,Z.cn)("w-full",dt,ds),children:bU?(0,b.jsx)("div",{className:"flex justify-center py-8",children:(0,b.jsx)(z.Loader2,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):null!==bN?(0,b.jsx)("pre",{className:"text-xs font-mono whitespace-pre-wrap break-words leading-relaxed",children:bN}):eh(bg.name)?(0,b.jsx)("p",{className:"text-sm text-muted-foreground",children:"Could not load file."}):(0,b.jsx)("p",{className:"text-sm text-muted-foreground",children:"Preview not available for this file type."})})}),bW&&!ei(bg.name)&&(0,b.jsxs)("div",{className:"border-t px-4 py-2 flex items-center justify-end gap-2 bg-muted shrink-0",children:[b3&&(0,b.jsx)("span",{className:"text-xs text-destructive mr-auto",children:b3}),(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",onClick:()=>{bX(!1),b4(null)},children:"Cancel"}),(0,b.jsxs)(U.Button,{size:"sm",className:"gap-1",onClick:c3,disabled:b1,children:[b1&&(0,b.jsx)(z.Loader2,{className:"h-3 w-3 animate-spin"}),"Save"]})]})]}):(0,b.jsx)("div",{className:"flex-1 flex flex-col items-center justify-center",children:(0,b.jsxs)("div",{className:"flex flex-col items-center gap-2 text-center px-4",children:[(0,b.jsx)(n.FileText,{className:"h-8 w-8 text-muted-foreground"}),(0,b.jsx)("p",{className:"text-sm text-muted-foreground",children:"Select a file to view or edit"})]})})]}),(0,b.jsx)(cv,{open:bK,onOpenChange:bM,filePath:bg?.path??""}),(0,b.jsx)(b9,{open:bH,onOpenChange:bI}),(0,b.jsx)(dg,{currentPath:bg?.path}),(0,b.jsx)("input",{ref:aZ,type:"file",multiple:!0,className:"hidden",onChange:a=>{a.target.files&&c4(a.target.files,a$.current)}}),(0,b.jsx)(W,{open:!!bb,onOpenChange:a=>{a||bc(null)},title:bd?"Delete folder?":"Delete file?",description:bd?`"${bb?.split("/").pop()}" and all its contents will be permanently deleted.`:`"${bb?.split("/").pop()}" will be permanently removed.`,onConfirm:dh}),(0,b.jsx)(W,{open:!!al,onOpenChange:a=>{a||am(null)},title:"Delete workspace?",description:`"${$.find(a=>a.id===al)?.name??""}" will be removed from the workspace list. Files on disk are NOT deleted.`,onConfirm:c$})]})]},V??"none")}],240777)}];
18
18
 
19
19
  //# sourceMappingURL=_0v4uz-4._.js.map
@@ -7,9 +7,9 @@ globalThis.__BUILD_MANIFEST = {
7
7
  "static/chunks/03~yq9q893hmn.js"
8
8
  ],
9
9
  "lowPriorityFiles": [
10
- "static/FGEHouLkusE6SPcSxOC3u/_buildManifest.js",
11
- "static/FGEHouLkusE6SPcSxOC3u/_ssgManifest.js",
12
- "static/FGEHouLkusE6SPcSxOC3u/_clientMiddlewareManifest.js"
10
+ "static/w6zxJ1-lNNl0jldTTzyLC/_buildManifest.js",
11
+ "static/w6zxJ1-lNNl0jldTTzyLC/_ssgManifest.js",
12
+ "static/w6zxJ1-lNNl0jldTTzyLC/_clientMiddlewareManifest.js"
13
13
  ],
14
14
  "rootMainFiles": [
15
15
  "static/chunks/057l2ju6dh43x.js",
@@ -19,11 +19,11 @@
19
19
  "wasm": [],
20
20
  "assets": [],
21
21
  "env": {
22
- "__NEXT_BUILD_ID": "FGEHouLkusE6SPcSxOC3u",
23
- "NEXT_SERVER_ACTIONS_ENCRYPTION_KEY": "rxzfe8rcJTPpRKi1oVsSlQXw51jOA/flD1/NcaIlGNI=",
24
- "__NEXT_PREVIEW_MODE_ID": "84eb9de0448c248ea5c518bba40c131e",
25
- "__NEXT_PREVIEW_MODE_ENCRYPTION_KEY": "4e160907cef31c458e979b9e0efbd3ebc3a686de54f380d05616f9002eb8cca6",
26
- "__NEXT_PREVIEW_MODE_SIGNING_KEY": "56ad98dd33ade68b34b8135995a4f3595ae2ee08f6701daaf8c42467a6d94408"
22
+ "__NEXT_BUILD_ID": "w6zxJ1-lNNl0jldTTzyLC",
23
+ "NEXT_SERVER_ACTIONS_ENCRYPTION_KEY": "aXOvA7cZEADx943E82oy2gSY8YqDsL3SSuCy/Hf7HqQ=",
24
+ "__NEXT_PREVIEW_MODE_ID": "5dfcbfd05e2fe00dbad386d5a836ba14",
25
+ "__NEXT_PREVIEW_MODE_ENCRYPTION_KEY": "92d03fac8b97ffe7af12fcca1582c0f0849171d97cedfc49ddc1e4048352923d",
26
+ "__NEXT_PREVIEW_MODE_SIGNING_KEY": "43c53ba3f211ee6c0f8b163fa15ae89a62ae917a1190df8ff26c95f8938b2ed5"
27
27
  }
28
28
  }
29
29
  },