wiki-viewer 1.8.3 → 1.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.next/standalone/.next/BUILD_ID +1 -1
- package/.next/standalone/.next/build-manifest.json +3 -3
- package/.next/standalone/.next/server/app/_global-error.html +1 -1
- package/.next/standalone/.next/server/app/_global-error.rsc +1 -1
- package/.next/standalone/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_not-found.html +1 -1
- package/.next/standalone/.next/server/app/_not-found.rsc +1 -1
- package/.next/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_not-found.segments/_index.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/api/wiki/upload/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/index.html +1 -1
- package/.next/standalone/.next/server/app/index.rsc +2 -2
- package/.next/standalone/.next/server/app/index.segments/__PAGE__.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/index.segments/_full.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/index.segments/_head.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/index.segments/_index.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/index.segments/_tree.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__00lep-u._.js +1 -1
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__00qu86p._.js +1 -1
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__036mhjp._.js +2 -2
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__05t~v6l._.js +1 -1
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__09cqzem._.js +1 -1
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0_0_601._.js +1 -1
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0ae3dk6._.js +1 -1
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0d7x3e1._.js +1 -1
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0e7vs98._.js +1 -1
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0fxzg4v._.js +1 -1
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0gda_iu._.js +1 -1
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0hu~q20._.js +1 -1
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0l-8clq._.js +1 -1
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0otb8ra._.js +1 -1
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0p0-p__._.js +1 -1
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0piofm3._.js +1 -1
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0rrf-jr._.js +1 -1
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0s6_lzw._.js +1 -1
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0sh13v5._.js +1 -1
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0ta~flu._.js +1 -1
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0v4im4p._.js +1 -1
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0vatqe-._.js +1 -1
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0vdb2nr._.js +1 -1
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__123._fe._.js +1 -1
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__1377.79._.js +1 -1
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__1378-ox._.js +1 -1
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__13hp4tw._.js +2 -2
- package/.next/standalone/.next/server/chunks/node_modules__pnpm_0aj5g-w._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/_0pqaawz._.js +1 -1
- package/.next/standalone/.next/server/edge/chunks/0p91_next_dist_0nh.6nc._.js +2 -2
- package/.next/standalone/.next/server/middleware-build-manifest.js +3 -3
- package/.next/standalone/.next/server/middleware-manifest.json +1 -1
- package/.next/standalone/.next/server/pages/404.html +1 -1
- package/.next/standalone/.next/server/pages/500.html +1 -1
- package/.next/standalone/.next/static/chunks/{0d~o0h0ssgra7.js → 125_k3o0s4cid.js} +1 -1
- package/.next/standalone/README.md +4 -3
- package/.next/standalone/bin/wiki-viewer.js +6 -3
- package/.next/standalone/package.json +1 -1
- package/.next/standalone/src/app/page.tsx +8 -6
- package/.next/standalone/src/lib/auth/admin.ts +8 -0
- package/.next/standalone/src/lib/workspace-context.ts +13 -0
- package/.next/standalone/src/middleware.ts +5 -0
- package/.next/standalone/src/stores/pin-store.ts +1 -0
- package/.next/standalone/src/stores/recent-store.ts +1 -0
- package/.next/standalone/tsconfig.tsbuildinfo +1 -1
- package/README.md +4 -3
- package/bin/wiki-viewer.js +6 -3
- package/package.json +1 -1
- /package/.next/standalone/.next/static/{Pkj31aCfRVk0Zy2rKA1wf → YQHDns_jLqFd_bbnLafs0}/_buildManifest.js +0 -0
- /package/.next/standalone/.next/static/{Pkj31aCfRVk0Zy2rKA1wf → YQHDns_jLqFd_bbnLafs0}/_clientMiddlewareManifest.js +0 -0
- /package/.next/standalone/.next/static/{Pkj31aCfRVk0Zy2rKA1wf → YQHDns_jLqFd_bbnLafs0}/_ssgManifest.js +0 -0
|
@@ -126,6 +126,6 @@ TOKEN=<paste token here>
|
|
|
126
126
|
# 3. Read snapshot
|
|
127
127
|
curl -s -H "Authorization: Bearer $TOKEN" \\
|
|
128
128
|
-H "X-Agent-Id: ai:claude" \\
|
|
129
|
-
${b}/api/agent/files/${a??"<path/to/file.md>"}`;await navigator.clipboard.writeText(d),c(!0),setTimeout(()=>c(!1),1500)},[a])}}(a??null),[i,j]=(0,$.useState)(""),k=(0,$.useRef)(null),l="http://localhost:3000",m=(0,$.useCallback)(()=>G$,[]),n=(0,$.useCallback)(()=>i.replace(/\$WIKI_URL/g,l),[i,l]),o=(0,$.useCallback)(()=>`npx wiki-viewer-mcp register --url ${l} --id ai:myagent --name "My Agent"`,[l]),p=(0,$.useCallback)(()=>JSON.stringify({servers:{"wiki-viewer":{command:"npx",args:["wiki-viewer-mcp"],env:{WIKI_VIEWER_URL:l,WIKI_VIEWER_TOKEN:"<token from register>",WIKI_VIEWER_AGENT_ID:"ai:myagent"}}}},null,2),[l]),q=G_(m),r=G_(n),s=G_(o),t=G_(p);return((0,$.useEffect)(()=>{if(b)return document.addEventListener("keydown",a),()=>document.removeEventListener("keydown",a);function a(a){"Escape"===a.key&&c()}},[b,c]),(0,$.useEffect)(()=>{b&&k.current?.focus()},[b]),(0,$.useEffect)(()=>{if(!b)return;f();let a=setInterval(()=>void f(),1e4);return()=>clearInterval(a)},[b,f]),(0,$.useEffect)(()=>{b&&fetch("/api/agents/install").then(a=>a.json()).then(a=>{a.bootstrapPrompt&&j(a.bootstrapPrompt)}).catch(()=>void 0)},[b]),b)?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)("div",{className:"fixed inset-0 z-40 bg-black/20 backdrop-blur-[1px]",onClick:c,"aria-hidden":!0}),(0,Z.jsxs)("aside",{ref:k,tabIndex:-1,role:"dialog","aria-modal":"true","aria-label":"AI Agent Panel",className:"fixed right-0 top-0 bottom-0 z-50 flex w-80 flex-col border-l border-border bg-background shadow-xl outline-none",children:[(0,Z.jsxs)("div",{className:"flex items-center justify-between border-b border-border px-4 py-3 shrink-0",children:[(0,Z.jsxs)("div",{className:"flex items-center gap-2",children:[(0,Z.jsx)(af,{className:"h-4 w-4 text-muted-foreground"}),(0,Z.jsx)("span",{className:"text-sm font-semibold",children:"AI Agent"})]}),(0,Z.jsx)(bZ,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",onClick:c,title:"Close panel (Esc)",children:(0,Z.jsx)(aI,{className:"h-3.5 w-3.5"})})]}),(0,Z.jsxs)("div",{className:"flex-1 overflow-y-auto space-y-5 px-4 py-4",children:[(0,Z.jsxs)("section",{className:"rounded-md border border-border bg-muted/30 p-3",children:[(0,Z.jsx)("p",{className:"text-sm font-medium text-foreground",children:"Work with this wiki using AI"}),(0,Z.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,Z.jsx)("span",{className:"font-medium text-foreground/80",children:"Agents"})," below before it gets access."]})]}),(0,Z.jsxs)("section",{className:"space-y-3",children:[(0,Z.jsxs)("div",{className:"rounded-md border border-border bg-muted/40 p-3 space-y-1.5",children:[(0,Z.jsx)("p",{className:"text-xs font-semibold text-foreground",children:"Co-write docs with you"}),(0,Z.jsx)("p",{className:"text-[10px] text-muted-foreground/70",children:"Edits arrive as suggestions with comments you accept or revert. No MCP needed."}),(0,Z.jsx)(bZ,{size:"sm",variant:"outline",className:"h-7 w-full text-xs gap-1.5",onClick:()=>void r.copy(),disabled:!i,children:r.copied?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(ag,{className:"h-3.5 w-3.5 text-green-500"})," Copied!"]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(aj,{className:"h-3.5 w-3.5"})," Paste into any chatbot"]})}),(0,Z.jsxs)("p",{className:"text-[10px] text-muted-foreground/50 pt-1",children:["Or install once so it sticks"," ",(0,Z.jsx)("span",{className:"text-muted-foreground/40",children:"· Claude, OpenCode"}),":"]}),(0,Z.jsxs)("div",{className:"flex items-center gap-2",children:[(0,Z.jsx)("code",{className:"flex-1 text-[10px] font-mono text-foreground/80 truncate bg-muted rounded px-1 py-0.5",children:G$}),(0,Z.jsx)(bZ,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0 shrink-0",title:"Copy this command",onClick:()=>void q.copy(),children:q.copied?(0,Z.jsx)(ag,{className:"h-3.5 w-3.5 text-green-500"}):(0,Z.jsx)(aj,{className:"h-3.5 w-3.5"})})]})]}),(0,Z.jsxs)("div",{className:"rounded-md border border-border bg-muted/40 p-3 space-y-1.5",children:[(0,Z.jsxs)("p",{className:"text-xs font-semibold text-foreground",children:["Edit files directly"," ",(0,Z.jsx)("span",{className:"font-normal text-muted-foreground/60",children:"· Claude Code, Cursor, Codex"})]}),(0,Z.jsx)("p",{className:"text-[10px] text-muted-foreground/70",children:"Native read / search / edit tools over MCP. Run to request access:"}),(0,Z.jsxs)("div",{className:"flex items-center gap-2",children:[(0,Z.jsx)("code",{className:"flex-1 text-[10px] font-mono text-foreground/80 truncate bg-muted rounded px-1 py-0.5",children:o()}),(0,Z.jsx)(bZ,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0 shrink-0",title:"Copy this command",onClick:()=>void s.copy(),children:s.copied?(0,Z.jsx)(ag,{className:"h-3.5 w-3.5 text-green-500"}):(0,Z.jsx)(aj,{className:"h-3.5 w-3.5"})})]}),(0,Z.jsxs)("p",{className:"text-[10px] text-muted-foreground/50",children:["Approve in ",(0,Z.jsx)("span",{className:"font-medium text-foreground/70",children:"Agents"}),", then add to your tool:"]}),(0,Z.jsx)(bZ,{size:"sm",variant:"outline",className:"h-7 w-full text-xs gap-1.5",onClick:()=>void t.copy(),children:t.copied?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(ag,{className:"h-3.5 w-3.5 text-green-500"})," Copied!"]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(aj,{className:"h-3.5 w-3.5"})," Copy config (mcp.json)"]})})]}),(0,Z.jsxs)("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1",children:[(0,Z.jsx)("span",{className:"text-[10px] text-muted-foreground/50",children:"For developers:"}),(0,Z.jsxs)("button",{type:"button",onClick:()=>void h(),className:"inline-flex items-center gap-1 text-[10px] text-primary hover:underline",children:[g?(0,Z.jsx)(ag,{className:"h-3 w-3 text-green-500"}):(0,Z.jsx)(aj,{className:"h-3 w-3"})," curl example"]}),(0,Z.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,Z.jsx)(w7,{className:"h-3 w-3"})," skill"]}),(0,Z.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,Z.jsx)(w7,{className:"h-3 w-3"})," install JSON"]})]})]}),(0,Z.jsx)(GY,{}),(0,Z.jsxs)("section",{className:"space-y-2",children:[(0,Z.jsxs)("h3",{className:"text-xs font-semibold uppercase tracking-widest text-muted-foreground",children:["Active Connections"," ",(0,Z.jsx)("span",{className:"normal-case font-normal text-muted-foreground/50",children:"(last 5 min)"})]}),(0,Z.jsx)("div",{className:"rounded-md border border-border bg-muted/40 p-3",children:0===e.length?(0,Z.jsxs)("p",{className:"text-xs text-muted-foreground/60 flex items-center gap-1.5",children:[(0,Z.jsx)(GQ,{className:"h-3.5 w-3.5"}),"No recent activity"]}):(0,Z.jsx)("ul",{className:"space-y-1.5",children:e.map(a=>(0,Z.jsxs)("li",{className:"flex items-center justify-between text-xs",children:[(0,Z.jsx)("span",{className:"font-mono text-foreground/80 truncate",children:a.by}),(0,Z.jsxs)("span",{className:"text-muted-foreground shrink-0",children:[a.opCount," op",1!==a.opCount?"s":""]})]},a.by))})})]}),(0,Z.jsxs)("section",{className:"space-y-2",children:[(0,Z.jsx)("h3",{className:"text-xs font-semibold uppercase tracking-widest text-muted-foreground",children:"Recent Activity"}),(0,Z.jsx)("div",{className:"rounded-md border border-border bg-muted/40 px-3 py-1 max-h-72 overflow-y-auto",children:0===d.length?(0,Z.jsx)("p",{className:"text-xs text-muted-foreground/60 py-2",children:"No events recorded"}):d.map(a=>(0,Z.jsx)(GZ,{event:a},`${a.path}-${a.id}`))})]}),(0,Z.jsx)("section",{children:(0,Z.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 G1=/[\\\/_+.#"@\[\(\{&]/,G2=/[\\\/_+.#"@\[\(\{&]/g,G3=/[\s-]/,G4=/[\s-]/g;function G5(a){return a.toLowerCase().replace(G4," ")}var G6='[cmdk-group=""]',G7='[cmdk-group-items=""]',G8='[cmdk-item=""]',G9=`${G8}:not([aria-disabled="true"])`,Ha="cmdk-item-select",Hb="data-value",Hc=(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:G1.test(b.charAt(o-1))?(j*=.8,(l=b.slice(f,o-1).match(G2))&&f>0&&(j*=Math.pow(.999,l.length))):G3.test(b.charAt(o-1))?(j*=.9,(m=b.slice(f,o-1).match(G4))&&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,G5(d),G5(b),0,0,{})},Hd=$.createContext(void 0),He=$.createContext(void 0),Hf=$.createContext(void 0),Hg=$.forwardRef((a,b)=>{let c=Hq(()=>{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=Hq(()=>new Set),e=Hq(()=>new Map),f=Hq(()=>new Map),g=Hq(()=>new Set),h=Ho(a),{label:i,children:j,value:k,onValueChange:l,filter:m,shouldFilter:n,loop:o,disablePointerSelection:p=!1,vimBindings:q=!0,...r}=a,s=b3(),t=b3(),u=b3(),v=$.useRef(null),w=Ht();Hp(()=>{if(void 0!==k){let a=k.trim();c.current.value=a,x.emit()}},[k]),Hp(()=>{w(6,D)},[]);let x=$.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=$.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:Hc;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(G7);b?b.appendChild(a.parentElement===b?a:a.closest(`${G7} > *`)):d.appendChild(a.parentElement===d?a:a.closest(`${G7} > *`))}),b.sort((a,b)=>b[1]-a[1]).forEach(a=>{var b;let c=null==(b=v.current)?void 0:b.querySelector(`${G6}[${Hb}="${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(Hb);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(G6))?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(`${G8}[aria-selected="true"]`)}function F(){var a;return Array.from((null==(a=v.current)?void 0:a.querySelectorAll(G9))||[])}function G(a){let b=F()[a];b&&x.setState("value",b.getAttribute(Hb))}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(Hb))}function I(a){let b=E(),c=null==b?void 0:b.closest(G6),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,G6):function(a,b){let c=a.previousElementSibling;for(;c;){if(c.matches(b))return c;c=c.previousElementSibling}}(c,G6))?void 0:c.querySelector(G9);d?x.setState("value",d.getAttribute(Hb)):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 $.createElement(xp.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(Ha);b.dispatchEvent(a)}}}}},$.createElement("label",{"cmdk-label":"",htmlFor:y.inputId,id:y.labelId,style:Hv},i),Hu(a,a=>$.createElement(He.Provider,{value:x},$.createElement(Hd.Provider,{value:y},a))))}),Hh=$.forwardRef((a,b)=>{var c,d;let e=b3(),f=$.useRef(null),g=$.useContext(Hf),h=$.useContext(Hd),i=Ho(a),j=null!=(d=null==(c=i.current)?void 0:c.forceMount)?d:null==g?void 0:g.forceMount;Hp(()=>{if(!j)return h.item(e,null==g?void 0:g.id)},[j]);let k=Hs(e,f,[a.value,a.children,f],a.keywords),l=$.useContext(He),m=Hr(a=>a.value&&a.value===k.current),n=Hr(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($.useEffect(()=>{let b=f.current;if(!(!b||a.disabled))return b.addEventListener(Ha,o),()=>b.removeEventListener(Ha,o)},[n,a.onSelect,a.disabled]),!n)return null;let{disabled:q,value:r,onSelect:s,forceMount:t,keywords:u,...v}=a;return $.createElement(xp.div,{ref:aK(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)}),Hi=$.forwardRef((a,b)=>{let{heading:c,children:d,forceMount:e,...f}=a,g=b3(),h=$.useRef(null),i=$.useRef(null),j=b3(),k=$.useContext(Hd),l=Hr(a=>!!e||!1===k.filter()||!a.search||a.filtered.groups.has(g));Hp(()=>k.group(g),[]),Hs(g,h,[a.value,a.heading,i]);let m=$.useMemo(()=>({id:g,forceMount:e}),[e]);return $.createElement(xp.div,{ref:aK(h,b),...f,"cmdk-group":"",role:"presentation",hidden:!l||void 0},c&&$.createElement("div",{ref:i,"cmdk-group-heading":"","aria-hidden":!0,id:j},c),Hu(a,a=>$.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":c?j:void 0},$.createElement(Hf.Provider,{value:m},a))))}),Hj=$.forwardRef((a,b)=>{let{alwaysRender:c,...d}=a,e=$.useRef(null),f=Hr(a=>!a.search);return c||f?$.createElement(xp.div,{ref:aK(e,b),...d,"cmdk-separator":"",role:"separator"}):null}),Hk=$.forwardRef((a,b)=>{let{onValueChange:c,...d}=a,e=null!=a.value,f=$.useContext(He),g=Hr(a=>a.search),h=Hr(a=>a.selectedItemId),i=$.useContext(Hd);return $.useEffect(()=>{null!=a.value&&f.setState("search",a.value)},[a.value]),$.createElement(xp.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)}})}),Hl=$.forwardRef((a,b)=>{let{children:c,label:d="Suggestions",...e}=a,f=$.useRef(null),g=$.useRef(null),h=Hr(a=>a.selectedItemId),i=$.useContext(Hd);return $.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)}}},[]),$.createElement(xp.div,{ref:aK(f,b),...e,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":h,"aria-label":d,id:i.listId},Hu(a,a=>$.createElement("div",{ref:aK(g,i.listInnerRef),"cmdk-list-sizer":""},a)))}),Hm=$.forwardRef((a,b)=>{let{open:c,onOpenChange:d,overlayClassName:e,contentClassName:f,container:g,...h}=a;return $.createElement(dd,{open:c,onOpenChange:d},$.createElement(di,{container:g},$.createElement(dk,{"cmdk-overlay":"",className:e}),$.createElement(dp,{"aria-label":a.label,"cmdk-dialog":"",className:f},$.createElement(Hg,{ref:b,...h}))))}),Hn=Object.assign(Hg,{List:Hl,Item:Hh,Input:Hk,Group:Hi,Separator:Hj,Dialog:Hm,Empty:$.forwardRef((a,b)=>Hr(a=>0===a.filtered.count)?$.createElement(xp.div,{ref:b,...a,"cmdk-empty":"",role:"presentation"}):null),Loading:$.forwardRef((a,b)=>{let{progress:c,children:d,label:e="Loading...",...f}=a;return $.createElement(xp.div,{ref:b,...f,"cmdk-loading":"",role:"progressbar","aria-valuenow":c,"aria-valuemin":0,"aria-valuemax":100,"aria-label":e},Hu(a,a=>$.createElement("div",{"aria-hidden":!0},a)))})});function Ho(a){let b=$.useRef(a);return Hp(()=>{b.current=a}),b}var Hp=$.useEffect;function Hq(a){let b=$.useRef();return void 0===b.current&&(b.current=a()),b}function Hr(a){let b=$.useContext(He),c=()=>a(b.snapshot());return $.useSyncExternalStore(b.subscribe,c,c)}function Hs(a,b,c,d=[]){let e=$.useRef(),f=$.useContext(Hd);return Hp(()=>{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(Hb,h),e.current=h}),e}var Ht=()=>{let[a,b]=$.useState(),c=Hq(()=>new Map);return Hp(()=>{c.current.forEach(a=>a()),c.current=new Map},[a]),(a,d)=>{c.current.set(a,d),b({})}};function Hu({asChild:a,children:b},c){let d;return a&&$.isValidElement(b)?$.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 Hv={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};let Hw=ad("search",[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]),Hx=$.forwardRef(({className:a,...b},c)=>(0,Z.jsx)(Hn,{ref:c,className:bX("flex h-full w-full flex-col overflow-hidden rounded-sm bg-popover text-popover-foreground",a),...b}));function Hy({children:a,shouldFilter:b,...c}){return(0,Z.jsx)(dd,{...c,children:(0,Z.jsxs)(dG,{className:"overflow-hidden p-0 shadow-golden max-w-lg",children:[(0,Z.jsx)(dJ,{className:"sr-only",children:"Search"}),(0,Z.jsx)(Hx,{shouldFilter:b,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})]})})}Hx.displayName=Hn.displayName;let Hz=$.forwardRef(({className:a,...b},c)=>(0,Z.jsxs)("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[(0,Z.jsx)(Hw,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),(0,Z.jsx)(Hn.Input,{ref:c,className:bX("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),...b})]}));Hz.displayName=Hn.Input.displayName;let HA=$.forwardRef(({className:a,...b},c)=>(0,Z.jsx)(Hn.List,{ref:c,className:bX("max-h-[300px] overflow-y-auto overflow-x-hidden",a),...b}));HA.displayName=Hn.List.displayName;let HB=$.forwardRef((a,b)=>(0,Z.jsx)(Hn.Empty,{ref:b,className:"py-6 text-center text-sm text-muted-foreground",...a}));HB.displayName=Hn.Empty.displayName;let HC=$.forwardRef(({className:a,...b},c)=>(0,Z.jsx)(Hn.Group,{ref:c,className:bX("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),...b}));HC.displayName=Hn.Group.displayName;let HD=$.forwardRef(({className:a,...b},c)=>(0,Z.jsx)(Hn.Separator,{ref:c,className:bX("-mx-1 h-px bg-border",a),...b}));HD.displayName=Hn.Separator.displayName;let HE=$.forwardRef(({className:a,...b},c)=>(0,Z.jsx)(Hn.Item,{ref:c,className:bX("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),...b}));HE.displayName=Hn.Item.displayName;let HF=null,HG=u8(a=>({query:"",results:[],loading:!1,truncated:!1,open:!1,setQuery:b=>a({query:b}),setOpen:b=>a({open:b}),clear:()=>{HF?.abort(),a({query:"",results:[],loading:!1,truncated:!1})},search:async b=>{HF?.abort();let c=new AbortController;if(HF=c,!b.trim())return void a({results:[],loading:!1,truncated:!1});a({loading:!0});try{let d=await dO("/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})}}}));function HH({html:a}){let b=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,Z.jsx)(Z.Fragment,{children:b.map((a,b)=>a.mark?(0,Z.jsx)("mark",{className:"bg-yellow-200 dark:bg-yellow-700 rounded-[2px] px-[1px]",children:a.text},b):(0,Z.jsx)("span",{children:a.text},b))})}function HI({onOpenFile:a,onToggleSidebar:b=()=>void 0,onNewFile:c=()=>void 0,onCopyPath:d=()=>void 0}){let e=HG(a=>a.open),f=HG(a=>a.setOpen),g=HG(a=>a.query),h=HG(a=>a.setQuery),i=HG(a=>a.results),j=HG(a=>a.loading),k=HG(a=>a.truncated),l=HG(a=>a.search),{resolvedTheme:m,setTheme:n}=(0,Gh.useTheme)(),o=u9(a=>a.toggle),p=vo(a=>a.width),q=vo(a=>a.cycle),r=g.trimStart(),s=""===r||r.startsWith(">"),t=s?"":g;function u(a){a(),f(!1),h("")}(0,$.useEffect)(()=>{function a(a){(a.metaKey||a.ctrlKey)&&"k"===a.key.toLowerCase()&&(a.preventDefault(),f(!e))}return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[e,f]),(0,$.useEffect)(()=>{if(!e||s)return;let a=setTimeout(()=>{l(t)},120);return()=>clearTimeout(a)},[t,s,e,l]);let v=(vn.indexOf(p)+1)%vn.length,w=vm[vn[v]];return(0,Z.jsxs)(Hy,{open:e,onOpenChange:a=>{f(a),a||h("")},shouldFilter:!1,children:[(0,Z.jsx)(Hz,{placeholder:"Search files… ( > for actions )",value:g,onValueChange:h}),(0,Z.jsxs)(HA,{children:[s&&(0,Z.jsxs)(HC,{heading:"Actions",children:[(0,Z.jsxs)(HE,{value:"toggle-dark-mode",onSelect:()=>u(()=>n("dark"===m?"light":"dark")),children:["dark"===m?(0,Z.jsx)(Gg,{className:"mr-2 h-4 w-4"}):(0,Z.jsx)(Gf,{className:"mr-2 h-4 w-4"}),"dark"===m?"Switch to light mode":"Switch to dark mode"]}),(0,Z.jsxs)(HE,{value:"toggle-ai-panel",onSelect:()=>u(o),children:[(0,Z.jsx)(af,{className:"mr-2 h-4 w-4"}),"Toggle AI panel"]}),(0,Z.jsxs)(HE,{value:"toggle-sidebar",onSelect:()=>u(b),children:[(0,Z.jsx)(C0,{className:"mr-2 h-4 w-4"}),"Toggle sidebar"]}),(0,Z.jsxs)(HE,{value:"new-file",onSelect:()=>u(c),children:[(0,Z.jsx)(am,{className:"mr-2 h-4 w-4"}),"New file"]}),(0,Z.jsxs)(HE,{value:"copy-path",onSelect:()=>u(d),children:[(0,Z.jsx)(aj,{className:"mr-2 h-4 w-4"}),"Copy current file path"]}),(0,Z.jsxs)(HE,{value:"cycle-view-width",onSelect:()=>u(q),children:[(0,Z.jsx)(wW,{className:"mr-2 h-4 w-4"}),(0,Z.jsxs)("span",{children:["Change view width"," ",(0,Z.jsxs)("span",{className:"text-muted-foreground",children:["(",vm[p]," → ",w,")"]})]})]})]}),!s&&(0,Z.jsxs)(Z.Fragment,{children:[j&&(0,Z.jsx)("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:"Searching…"}),!j&&""!==t.trim()&&0===i.length&&(0,Z.jsx)(HB,{children:"No matches."}),i.length>0&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(HD,{}),(0,Z.jsx)(HC,{heading:k?"Top results (refine query for more)":"Results",children:i.map(b=>(0,Z.jsx)(HE,{value:b.path,onSelect:()=>{a(b.path),f(!1),h("")},children:(0,Z.jsxs)("div",{className:"flex min-w-0 flex-col gap-0.5",children:[(0,Z.jsx)("span",{className:"truncate font-mono text-xs",children:b.path}),b.snippet&&(0,Z.jsx)("span",{className:"truncate text-xs text-muted-foreground",children:(0,Z.jsx)(HH,{html:b.snippet})})]})},b.path))})]})]})]})]})}function HJ({onOpenFile:a}){let b=HG(a=>a.query),c=HG(a=>a.setQuery),d=HG(a=>a.results),e=HG(a=>a.loading),f=HG(a=>a.search),g=HG(a=>a.clear),[h,i]=(0,$.useState)(0),j=(0,$.useRef)(null);function k(b){let c=d[b];c&&(a(c.path),g())}return(0,$.useEffect)(()=>{i(0)},[d]),(0,$.useEffect)(()=>{let a=j.current?.querySelector(`[data-idx="${h}"]`);a?.scrollIntoView({block:"nearest"})},[h]),(0,Z.jsxs)("div",{className:"flex flex-col gap-1 px-2 py-1.5",children:[(0,Z.jsxs)("div",{className:"relative",children:[(0,Z.jsx)(Hw,{className:"pointer-events-none absolute left-2 top-1/2 h-3.5 w-3.5 -translate-y-1/2 opacity-50"}),(0,Z.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:b,onChange:a=>{c(a.target.value),f(a.target.value)},onKeyDown:a=>{"Escape"===a.key?g():0!==d.length&&("ArrowDown"===a.key?(a.preventDefault(),i(a=>(a+1)%d.length)):"ArrowUp"===a.key?(a.preventDefault(),i(a=>(a-1+d.length)%d.length)):"Enter"===a.key&&(a.preventDefault(),k(h)))}})]}),""!==b.trim()&&(0,Z.jsxs)("div",{ref:j,className:"max-h-64 overflow-y-auto rounded-sm border bg-popover",children:[e&&(0,Z.jsx)("div",{className:"px-2 py-1 text-xs text-muted-foreground",children:"Searching…"}),!e&&0===d.length&&(0,Z.jsx)("div",{className:"px-2 py-1 text-xs text-muted-foreground",children:"No matches"}),d.map((a,b)=>(0,Z.jsxs)("button",{type:"button","data-idx":b,onClick:()=>k(b),onMouseEnter:()=>i(b),className:`block w-full px-2 py-1 text-left ${b===h?"bg-accent":"hover:bg-accent"}`,children:[(0,Z.jsx)("div",{className:"truncate font-mono text-xs",children:a.path}),a.snippet&&(0,Z.jsx)("div",{className:"truncate text-[10px] text-muted-foreground",children:(0,Z.jsx)(HH,{html:a.snippet})})]},a.path))]})]})}function HK({className:a}){let b=vo(a=>a.width),c=vo(a=>a.setWidth);return(0,Z.jsxs)(FS,{children:[(0,Z.jsx)(FU,{asChild:!0,children:(0,Z.jsx)(bZ,{size:"sm",variant:"ghost",className:`h-7 w-7 p-0 ${a??""}`,title:`Content width: ${vm[b]}`,children:(0,Z.jsx)(wX,{className:"h-3.5 w-3.5"})})}),(0,Z.jsx)(F5,{align:"end",className:"w-36",children:vn.map(a=>(0,Z.jsxs)(F6,{onClick:()=>c(a),className:"flex items-center justify-between text-xs",children:[vm[a],a===b&&(0,Z.jsx)(ag,{className:"h-3.5 w-3.5"})]},a))})]})}function HL(a){return a.split(".").pop()?.toLowerCase()??""}function HM(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=HL(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 HN=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 HO(a){let b=HM(a,"file");return"editor"===b||"text"===b||HN.has(HL(a))}function HP(a){return["md","markdown"].includes(HL(a))}function HQ(a){return"image"===HM(a,"file")}async function HR(a){let b=await dO(`/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})):[]}function HS(a,b,c){return a.map(a=>a.path===b?c(a):a.children?{...a,children:HS(a.children,b,c)}:a)}a.s(["default",0,function(){let a;vp(a=>a.loadedAt),(0,$.useEffect)(()=>{vp.getState().load()},[]);let[b,c]=(0,$.useState)(null),[d,e]=(0,$.useState)(null),[f,g]=(0,$.useState)(()=>null),[h,i]=(0,$.useState)([]),[j,k]=(0,$.useState)(!1),[l,m]=(0,$.useState)(!1),[n,o]=(0,$.useState)(null),p=(0,$.useCallback)(async()=>{try{let a=await fetch("/api/system/workspaces");if(!a.ok)throw Error("Failed");let b=await a.json();if(i(b.workspaces),k(b.isAdmin),b.workspaces.length>0){c(!0);let a=new URLSearchParams(window.location.search).get("ws"),d=a?b.workspaces.find(b=>b.id===a):null,f=d??[...b.workspaces].sort((a,b)=>(b.lastOpenedAt??b.createdAt).localeCompare(a.lastOpenedAt??a.createdAt))[0];if(g(f.id),e(f.rootDir),!d){let a=new URL(location.href);a.searchParams.set("ws",f.id),history.replaceState(null,"",a.toString())}}else c(!1)}catch{c(!1)}},[]);(0,$.useEffect)(()=>{p()},[p]);let q=vi(a=>a.currentPath),r=GO(a=>a.recents),[s,t]=(0,$.useState)(!1),[u,v]=(0,$.useState)(!1),w=GP(a=>a.pins),x=(0,$.useRef)(null),y=u9(a=>a.activity),z=(0,$.useMemo)(()=>{let a=new Date(Date.now()-6e4).toISOString(),b=new Set;for(let c of y)c.at>=a&&c.path&&c.by?.startsWith("ai:")&&b.add(c.path);return b},[y]);(0,$.useEffect)(()=>{let a=()=>{u9.getState().loadActivity()};a();let b=setInterval(a,1e4);return()=>clearInterval(b)},[]),(0,$.useEffect)(()=>{GO.getState().loadForWorkspace(f),GP.getState().loadForWorkspace(f)},[f]);let A=(0,$.useRef)(null),B=(0,$.useRef)(!1),[C,D]=(0,$.useState)([]),[E,F]=(0,$.useState)(!1),[G,H]=(0,$.useState)(!1),I=(0,$.useRef)(!1),[J,K]=(0,$.useState)(!1),[L,M]=(0,$.useState)(!1),[N,O]=(0,$.useState)(null),P=(0,$.useRef)(null),Q=(0,$.useRef)(""),[R,S]=(0,$.useState)(null),[T,U]=(0,$.useState)(""),[V,W]=(0,$.useState)(null),[X,Y]=(0,$.useState)(null),[_,aa]=(0,$.useState)(""),[ab,ac]=(0,$.useState)(null),[ad,aJ]=(0,$.useState)(null),[aK,aL]=(0,$.useState)(!1),[aM,aN]=(0,$.useState)(null),[aO,aP]=(0,$.useState)(!1),[aQ,aR]=(0,$.useState)(0),[aS,aT]=(0,$.useState)(!1),[aU,aV]=(0,$.useState)(!1),[aW,aX]=(0,$.useState)(null),[aY,aZ]=(0,$.useState)(0),[a$,a_]=(0,$.useState)(!1),[a0,a1]=(0,$.useState)(!1),[a2,a3]=(0,$.useState)(""),[a4,a5]=(0,$.useState)(!1),[a6,a7]=(0,$.useState)(null),a8=(0,$.useRef)(null),[a9,ba]=(0,$.useState)(null),bb=(0,$.useRef)(null),bc=(0,$.useRef)(!1),bd=(0,$.useRef)(async()=>{});(0,$.useEffect)(()=>{E||I.current||(I.current=!0,H(!0),HR("").then(a=>{D(a),F(!0),H(!1)}).catch(()=>{I.current=!1,H(!1)}))},[E]);let be=(0,$.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 HR(d)});D(a=>{let b=a;for(let{prefix:a,children:d}of c)b=HS(b,a,a=>({...a,children:d,expanded:!0}));return b})},[]),bf=(0,$.useCallback)(async a=>{let b=await HR(a);""===a?D(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})}):D(c=>HS(c,a,a=>({...a,children:b,expanded:!0})))},[]),bg=(0,$.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(...bg(c.children)));return b},[]),bh=(0,$.useCallback)(async()=>{K(!0);try{let a=bg(C),b=await HR("");for(let c of(D(b),a)){let a=await HR(c);D(b=>HS(b,c,b=>({...b,children:a,expanded:!0})))}}finally{K(!1)}},[C,bg]),bi=(0,$.useCallback)(async()=>{if(aM){if(HP(aM.name)){a_(!0);try{await vi.getState().loadPage(aM.path)}finally{a_(!1)}return}if(["editor","text"].includes(HM(aM.name,aM.nodeType))||HO(aM.name)){a_(!0);try{let a=await dO(`/api/wiki/content?path=${encodeURIComponent(aM.path)}`);if(a.ok){let b=await a.json();aX(b.content),aZ(Number(a.headers.get("X-Wiki-Revision")??0))}}catch{}a_(!1)}}},[aM]);async function bj(a){if("dir"===a.type||"app"===a.type||"node-app"===a.type)if(a.expanded)D(b=>HS(b,a.path,a=>({...a,expanded:!1})));else if(void 0===a.children){D(b=>HS(b,a.path,a=>({...a,loading:!0})));let b=await HR(a.path);D(c=>HS(c,a.path,a=>({...a,loading:!1,children:b,expanded:!0})))}else D(b=>HS(b,a.path,a=>({...a,expanded:!0})))}async function bk(a){if("file"===a.type&&GO.getState().push({path:a.path,name:a.name},f),aN({path:a.path,name:a.name,nodeType:"app"===a.type?"app":"node-app"===a.type?"node-app":"file"}),a1(!1),a7(null),aX(null),aZ(0),"file"===a.type&&HP(a.name)){a_(!0);try{await vi.getState().loadPage(a.path)}finally{a_(!1)}return}if(["editor","text"].includes(HM(a.name,a.type))||HO(a.name)){a_(!0);try{let b=await dO(`/api/wiki/content?path=${encodeURIComponent(a.path)}`);if(b.ok){let a=await b.json();aX(a.content),aZ(Number(b.headers.get("X-Wiki-Revision")??0))}}catch{}a_(!1)}}(0,$.useEffect)(()=>{aM&&HP(aM.name)&&vi.getState().currentPath!==aM.path&&vi.getState().loadPage(aM.path)},[aM]),(0,$.useEffect)(()=>{bb.current=aM},[aM]),(0,$.useEffect)(()=>{bc.current=a0},[a0]),(0,$.useEffect)(()=>{bd.current=bi},[bi]),(0,$.useEffect)(()=>{if(!b)return;let a=new Map,c=new EventSource("/api/wiki/watch");return c.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),bf(c)},300)),"change"===e&&bb.current?.path===f&&!bc.current){let b=`__file__${f}`;a.has(b)&&clearTimeout(a.get(b)),a.set(b,setTimeout(()=>{a.delete(b),bd.current()},400))}},()=>{for(let b of(c.close(),a.values()))clearTimeout(b)}},[b,bf]),(0,$.useEffect)(()=>{aP(!1)},[]);let bl=(0,$.useCallback)(a=>{let b=a.split("/").pop()??a;be(a),bk({path:a,name:b,type:"file"})},[be]);(0,$.useEffect)(()=>{if(!q||aM&&aM.path===q)return;let a=q.split("/").pop()??q;bk({path:q,name:a,type:"file"})},[q]),(0,$.useEffect)(()=>{},[aM]),(0,$.useEffect)(()=>{if(B.current||!E)return;let a=A.current;if(!a){B.current=!0;return}B.current=!0,(async()=>{let b=a.split("/"),c=b[b.length-1],d=b.slice(0,-1).join("/"),e=(await HR(d)).find(b=>b.path===a);e&&(await be(a),bk({path:a,name:c,type:e.type,modifiedAt:e.modifiedAt}))})()},[E,be]);let bm=(0,$.useCallback)(async a=>{if(a===f)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()),aN(null),aX(null),a1(!1),D([]),F(!1),I.current=!1,vp.getState().invalidate();let c=h.find(b=>b.id===a);c&&e(c.rootDir),g(a)},[f,h]),bn=(0,$.useCallback)(async()=>{if(n)try{if(!(await fetch(`/api/system/workspaces/${n}`,{method:"DELETE"})).ok)throw Error("Failed");if(n===f){let a=h.filter(a=>a.id!==n);if(a.length>0){let b=[...a].sort((a,b)=>(b.lastOpenedAt??b.createdAt).localeCompare(a.lastOpenedAt??a.createdAt))[0];await bm(b.id)}else c(!1)}await p()}catch{}finally{o(null)}},[n,f,h,bm,p]);async function bo(){if(!aM)return;a5(!0),a7(null);let a=await dO("/api/wiki/content",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:aM.path,content:a2,baseRevision:aY})});if(a.ok){let b=await a.json();"number"==typeof b.revision&&aZ(b.revision),aX(a2),a1(!1)}else a7((await a.json()).error??"Save failed");a5(!1)}let bp=(0,$.useCallback)(async(a,b)=>{let c=Array.from(a);if(c.length){M(!0),O(null);try{for(let a of c){let c=new FormData;c.append("file",a),c.append("dir",b);let d=await dO("/api/wiki/upload",{method:"POST",body:c});if(!d.ok){let a=await d.json();O(a.error??"Upload failed"),vw(a.error??"Upload failed");break}}await bf(b)}catch{O("Upload failed.")}finally{M(!1),P.current&&(P.current.value="")}}},[bf]);function bq(a){Q.current=a,P.current?.click()}async function br(){let a=T.trim();if(!a||null===R)return;W(null);let b=R?`${R}/${a}`:a,c=await dO("/api/wiki/folder",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:b})});c.ok?(S(null),U(""),await bf(R),""!==R&&D(a=>HS(a,R,a=>({...a,expanded:!0})))):W((await c.json()).error??"Failed")}async function bs(){let a=_.trim();if(!a||null===X)return;ac(null);let b=a.includes(".")?a:`${a}.md`,c=X?`${X}/${b}`:b,d=await dO("/api/wiki/new-file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:c})});d.ok?(Y(null),aa(""),await bf(X),""!==X&&D(a=>HS(a,X,a=>({...a,expanded:!0}))),bk({path:c,name:b,type:"file",modifiedAt:new Date().toISOString()})):ac((await d.json()).error??"Failed")}function bt(a){navigator.clipboard.writeText(a),vv("Path copied")}function bu(a){let b=a.replace(/\.(md|markdown)$/i,"");navigator.clipboard.writeText(`[[${b}]]`),vv("Wiki link copied")}function bv(a){let b=new URL(location.href);b.searchParams.set("path",a),f&&b.searchParams.set("ws",f),navigator.clipboard.writeText(b.toString()),vv("URL copied")}async function bw(a){if(aM?.path===a&&null!==aW)return aW;if(vi.getState().currentPath===a)return vi.getState().content;let b=await dO(`/api/wiki/content?path=${encodeURIComponent(a)}`);if(!b.ok)throw Error("Cannot copy content");return(await b.json()).content}async function bx(a){try{let b=await bw(a);await navigator.clipboard.writeText(b),vv("Raw content copied")}catch{vw("Could not copy file content")}}async function by(a,b){try{let c=await bw(a);if(!HP(b)){await navigator.clipboard.writeText(c),vv("Content copied");return}let d=await un(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),vv("Formatted content copied")}catch{vw("Could not copy formatted content")}}function bz(a){return(0,Z.jsxs)(FS,{children:[(0,Z.jsx)(FU,{asChild:!0,children:(0,Z.jsxs)(bZ,{size:"sm",variant:"ghost",className:"h-7 gap-1.5 px-2 text-xs",title:"Copy path, wiki link, or URL",children:[(0,Z.jsx)(aj,{className:"h-3.5 w-3.5"}),"Copy",(0,Z.jsx)(ah,{className:"h-3 w-3 opacity-60"})]})}),(0,Z.jsxs)(F5,{align:"end",className:"w-44",children:[(0,Z.jsxs)(F6,{onClick:()=>bt(a.path),children:[(0,Z.jsx)(aj,{className:"mr-2 h-3.5 w-3.5"}),"Copy path"]}),HP(a.name)&&(0,Z.jsxs)(F6,{onClick:()=>bu(a.name),children:[(0,Z.jsx)(an,{className:"mr-2 h-3.5 w-3.5"}),"Copy wiki link"]}),(0,Z.jsx)(F8,{}),(0,Z.jsxs)(F6,{onClick:()=>bv(a.path),children:[(0,Z.jsx)(at,{className:"mr-2 h-3.5 w-3.5"}),"Copy URL"]}),HO(a.name)&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(F8,{}),(0,Z.jsxs)(F6,{onClick:()=>void bx(a.path),children:[(0,Z.jsx)(an,{className:"mr-2 h-3.5 w-3.5"}),"Copy raw content"]}),(0,Z.jsxs)(F6,{onClick:()=>void by(a.path,a.name),children:[(0,Z.jsx)(an,{className:"mr-2 h-3.5 w-3.5"}),"Copy formatted content"]})]})]})]})}async function bA(){ad&&(await dO("/api/wiki",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:ad})}),(aM?.path===ad||aM?.path.startsWith(`${ad}/`))&&(aN(null),aX(null)),D(a=>(function a(b,c){return b.filter(a=>a.path!==c).map(b=>b.children?{...b,children:a(b.children,c)}:b)})(a,ad)),aJ(null))}function bB(a,b,c){a.preventDefault(),a.stopPropagation();let d=a8.current;!d||d.path===b||b.startsWith(`${d.path}/`)||(a.dataTransfer.dropEffect="move",ba("root"===c?"":b))}async function bC(a,b){a.preventDefault(),a.stopPropagation(),ba(null);let c=a8.current;if(a8.current=null,!c||c.path===b||b.startsWith(`${c.path}/`))return;let d=b?`${b}/${c.name}`:c.name;if(d!==c.path&&(await dO("/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 bf(a),b!==a&&await bf(b),aM?.path===c.path&&aN({path:d,name:c.name,nodeType:aM.nodeType})}}let bD=aM?HM(aM.name,aM.nodeType):null,bE=vo(a=>a.width),bF=null===bD||"editor"===bD||"text"===bD||"source"===bD||"notebook"===bD||"fallback"===bD,bG=bF?vk[bE]:"";return(0,Z.jsxs)("div",{className:"flex h-screen gap-0 overflow-hidden bg-background",children:[null===b&&(0,Z.jsx)("div",{className:"flex-1 flex items-center justify-center",children:(0,Z.jsx)(au,{className:"h-5 w-5 animate-spin text-muted-foreground"})}),!1===b&&(0,Z.jsx)(Ge,{onSelect:a=>{let b=new URL(location.href);b.searchParams.set("ws",a),b.searchParams.delete("path"),history.replaceState(null,"",b.toString()),F(!1),I.current=!1,g(a),c(!0),p()}}),!0===b&&l&&(0,Z.jsxs)("div",{className:"flex-1 flex flex-col",children:[(0,Z.jsx)("div",{className:"flex items-center justify-end border-b px-3 py-2 bg-muted shrink-0",children:(0,Z.jsxs)(bZ,{size:"sm",variant:"ghost",className:"h-7 gap-1.5 text-xs",onClick:()=>m(!1),children:[(0,Z.jsx)(aI,{className:"h-3.5 w-3.5"})," Cancel"]})}),(0,Z.jsx)(Ge,{onSelect:a=>{m(!1),p(),bm(a)}})]}),!0===b&&!l&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(HI,{onOpenFile:bl,onToggleSidebar:()=>aT(a=>!a),onNewFile:()=>Y(""),onCopyPath:()=>{aM&&navigator.clipboard.writeText(aM.path)}}),!aS&&(0,Z.jsxs)(Gp,{className:"flex flex-col w-72 shrink-0 overflow-hidden rounded-none border-r border-l-0 border-t-0 border-b-0",children:[(0,Z.jsxs)("div",{className:"flex items-center justify-between gap-2 px-3 py-2 border-b bg-muted shrink-0",children:[(0,Z.jsxs)("div",{className:"flex min-w-0 items-center gap-1.5",children:[(0,Z.jsx)("img",{src:"/logo.svg",alt:"Wiki Viewer",className:"h-5 w-5 shrink-0"}),(0,Z.jsx)("span",{className:"truncate text-xs font-semibold tracking-tight",children:"Wiki Viewer"})]}),(0,Z.jsx)(bZ,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0 shrink-0",title:"Collapse sidebar",onClick:()=>aT(!0),children:(0,Z.jsx)(ax,{className:"h-3.5 w-3.5"})})]}),(0,Z.jsxs)("div",{className:"flex items-center justify-between gap-1 px-3 py-1.5 border-b bg-muted/50 shrink-0",children:[(0,Z.jsxs)(FS,{children:[(0,Z.jsx)(FU,{asChild:!0,children:(0,Z.jsxs)(bZ,{size:"sm",variant:"ghost",className:"h-7 gap-1 px-2 text-xs",disabled:L,children:[L?(0,Z.jsx)(au,{className:"h-3.5 w-3.5 animate-spin"}):(0,Z.jsx)(aB,{className:"h-3.5 w-3.5"}),"New",(0,Z.jsx)(ah,{className:"h-3 w-3 opacity-60"})]})}),(0,Z.jsxs)(F5,{align:"start",className:"w-44",children:[(0,Z.jsxs)(F6,{onClick:()=>{Y(""),aa(""),ac(null)},children:[(0,Z.jsx)(am,{className:"mr-2 h-3.5 w-3.5"}),"New file"]}),(0,Z.jsxs)(F6,{onClick:()=>{S(""),U(""),W(null)},children:[(0,Z.jsx)(aq,{className:"mr-2 h-3.5 w-3.5"}),"New folder"]}),(0,Z.jsxs)(F6,{onClick:()=>bq(""),disabled:L,children:[(0,Z.jsx)(aH,{className:"mr-2 h-3.5 w-3.5"}),"Upload"]})]})]}),(0,Z.jsxs)("div",{className:"flex items-center gap-0.5",children:[(0,Z.jsx)(bZ,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",title:"Refresh tree",onClick:bh,disabled:J,children:J?(0,Z.jsx)(au,{className:"h-3.5 w-3.5 animate-spin"}):(0,Z.jsx)(aC,{className:"h-3.5 w-3.5"})}),(0,Z.jsx)(Gi,{}),(0,Z.jsx)(bZ,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",title:"AI Agent panel",onClick:()=>u9.getState().toggle(),children:(0,Z.jsx)(af,{className:"h-3.5 w-3.5"})}),(0,Z.jsx)(bZ,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",title:"Settings",onClick:()=>aV(!0),children:(0,Z.jsx)(aD,{className:"h-3.5 w-3.5"})})]})]}),N&&(0,Z.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,Z.jsx)(ae,{className:"h-3.5 w-3.5 shrink-0"}),N]}),""===R&&(0,Z.jsxs)("div",{className:"flex items-center gap-1.5 px-2 py-1 border-b shrink-0",children:[(0,Z.jsx)(ao,{className:"h-4 w-4 shrink-0 text-warning"}),(0,Z.jsx)("input",{className:"flex-1 bg-transparent text-sm outline-none border-b border-border min-w-0",placeholder:"Folder name",value:T,onChange:a=>U(a.target.value),onKeyDown:a=>{"Enter"===a.key&&br(),"Escape"===a.key&&(S(null),U(""))}}),V&&(0,Z.jsx)("span",{className:"text-xs text-destructive",children:V}),(0,Z.jsx)(bZ,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:br,children:(0,Z.jsx)(ag,{className:"h-3 w-3"})}),(0,Z.jsx)(bZ,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:()=>{S(null),U("")},children:(0,Z.jsx)(aI,{className:"h-3 w-3"})})]}),""===X&&(0,Z.jsxs)("div",{className:"flex items-center gap-1.5 px-2 py-1 border-b shrink-0",children:[(0,Z.jsx)(an,{className:"h-4 w-4 shrink-0 text-accent"}),(0,Z.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:_,onChange:a=>aa(a.target.value),onKeyDown:a=>{"Enter"===a.key&&bs(),"Escape"===a.key&&(Y(null),aa(""))}}),ab&&(0,Z.jsx)("span",{className:"text-xs text-destructive",children:ab}),(0,Z.jsx)(bZ,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:bs,children:(0,Z.jsx)(ag,{className:"h-3 w-3"})}),(0,Z.jsx)(bZ,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:()=>{Y(null),aa("")},children:(0,Z.jsx)(aI,{className:"h-3 w-3"})})]}),(0,Z.jsx)("div",{className:"border-b",children:(0,Z.jsx)(HJ,{onOpenFile:bl})}),(0,Z.jsxs)("div",{ref:x,className:bX("flex-1 overflow-auto py-1",""===a9&&"ring-2 ring-inset ring-primary bg-primary/5"),onDragOver:a=>bB(a,"","root"),onDragLeave:a=>{a.currentTarget.contains(a.relatedTarget)||ba(null)},onDrop:a=>bC(a,""),children:[w.length>0&&(0,Z.jsxs)("div",{className:"border-b mb-1",children:[(0,Z.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:()=>t(a=>!a),children:[s?(0,Z.jsx)(ai,{className:"h-3 w-3"}):(0,Z.jsx)(ah,{className:"h-3 w-3"}),(0,Z.jsx)(aA,{className:"h-3 w-3"}),"Pinned"]}),!s&&w.map(a=>(0,Z.jsxs)("div",{role:"button",tabIndex:0,className:bX("group flex items-center gap-1.5 rounded-sm px-2 py-1 text-sm cursor-pointer transition-colors select-none",aM?.path===a.path?"bg-accent-soft text-foreground font-medium":"hover:bg-muted"),onClick:()=>void bk({path:a.path,name:a.name,type:"file",modifiedAt:""}),onKeyDown:b=>{("Enter"===b.key||" "===b.key)&&(b.preventDefault(),bk({path:a.path,name:a.name,type:"file",modifiedAt:""}))},children:[(0,Z.jsx)(aE,{className:"h-3 w-3 shrink-0 fill-current text-amber-400"}),(0,Z.jsx)("span",{className:"min-w-0 flex-1 truncate text-xs",children:a.name}),(0,Z.jsx)("span",{className:"max-w-[80px] truncate text-[10px] text-muted-foreground/60",children:a.path.split("/").slice(0,-1).join("/")}),(0,Z.jsx)("button",{type:"button",className:"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(),GP.getState().toggle({path:a.path,name:a.name},f)},children:(0,Z.jsx)(aI,{className:"h-3 w-3"})})]},a.path))]}),r.length>0&&(0,Z.jsxs)("div",{className:"border-b mb-1",children:[(0,Z.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:()=>v(a=>!a),children:[u?(0,Z.jsx)(ai,{className:"h-3 w-3"}):(0,Z.jsx)(ah,{className:"h-3 w-3"}),"Recent"]}),!u&&r.slice(0,8).map(a=>(0,Z.jsxs)("div",{role:"button",tabIndex:0,className:bX("flex items-center gap-1.5 rounded-sm px-2 py-1 text-sm cursor-pointer transition-colors select-none",aM?.path===a.path?"bg-accent-soft text-foreground font-medium":"hover:bg-muted"),onClick:()=>void bk({path:a.path,name:a.name,type:"file",modifiedAt:""}),onKeyDown:b=>{("Enter"===b.key||" "===b.key)&&(b.preventDefault(),bk({path:a.path,name:a.name,type:"file",modifiedAt:""}))},children:[(0,Z.jsx)(an,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),(0,Z.jsx)("span",{className:"flex-1 truncate text-xs",children:a.name}),(0,Z.jsx)("span",{className:"text-[10px] text-muted-foreground/60 truncate max-w-[80px]",children:a.path.split("/").slice(0,-1).join("/")})]},a.path))]}),G?(0,Z.jsx)("div",{className:"flex justify-center py-6",children:(0,Z.jsx)(au,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):0===C.length?(0,Z.jsxs)("div",{className:"flex flex-col items-center gap-3 px-4 py-8 text-center",children:[(0,Z.jsx)("div",{className:"rounded-full bg-muted p-3",children:(0,Z.jsx)(an,{className:"h-6 w-6 text-muted-foreground"})}),(0,Z.jsxs)("div",{className:"space-y-1",children:[(0,Z.jsx)("p",{className:"text-sm font-medium",children:"No files yet"}),(0,Z.jsx)("p",{className:"text-xs text-muted-foreground",children:"Upload files or add them to the configured directory"})]}),(0,Z.jsxs)(bZ,{size:"sm",variant:"outline",className:"w-full gap-1.5 max-w-[180px]",onClick:()=>bq(""),disabled:L,children:[L?(0,Z.jsx)(au,{className:"h-3.5 w-3.5 animate-spin"}):(0,Z.jsx)(aH,{className:"h-3.5 w-3.5"}),"Upload Files"]})]}):function a(b,c=0){return b.map(b=>{let d=w.some(a=>a.path===b.path);return(0,Z.jsxs)(Gw,{children:[(0,Z.jsx)(Gy,{asChild:!0,children:(0,Z.jsxs)("div",{children:[(0,Z.jsxs)("div",{role:"treeitem",tabIndex:0,draggable:!0,onKeyDown:a=>{if("Enter"===a.key||" "===a.key)a.preventDefault(),"dir"===b.type?bj(b):"app"===b.type||"node-app"===b.type?(bk(b),bj(b)):bk(b);else if("ArrowDown"===a.key){a.preventDefault();let b=x.current;if(!b)return;let c=Array.from(b.querySelectorAll('[role="treeitem"]')),d=c.indexOf(a.currentTarget);c[d+1]?.focus()}else if("ArrowUp"===a.key){a.preventDefault();let b=x.current;if(!b)return;let c=Array.from(b.querySelectorAll('[role="treeitem"]')),d=c.indexOf(a.currentTarget);c[d-1]?.focus()}else if("ArrowRight"===a.key){if(a.preventDefault(),"dir"===b.type||"app"===b.type||"node-app"===b.type)if(b.expanded){let b=x.current;if(!b)return;let c=Array.from(b.querySelectorAll('[role="treeitem"]')),d=c.indexOf(a.currentTarget);c[d+1]?.focus()}else bj(b)}else if("ArrowLeft"===a.key){if(a.preventDefault(),("dir"===b.type||"app"===b.type||"node-app"===b.type)&&b.expanded)bj(b);else if(c>0){let b=x.current;if(!b)return;let c=Array.from(b.querySelectorAll('[role="treeitem"]')),d=a.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:a=>{a8.current=b,a.dataTransfer.effectAllowed="move",a.dataTransfer.setData("text/plain",b.path)},onDragOver:a=>"dir"===b.type?bB(a,b.path,"dir"):a.preventDefault(),onDragLeave:()=>ba(null),onDrop:a=>"dir"===b.type?bC(a,b.path):a.preventDefault(),className:bX("flex items-center gap-1.5 rounded-sm px-2 py-1 text-sm cursor-pointer group transition-colors select-none",aM?.path===b.path?"bg-accent-soft text-foreground font-medium":"hover:bg-muted",a9===b.path&&"ring-2 ring-primary bg-primary-soft",b.name.startsWith(".")&&"opacity-40"),style:{paddingLeft:`${14*c+8}px`},onClick:()=>{"dir"===b.type?bj(b):"app"===b.type||"node-app"===b.type?(bk(b),bj(b)):bk(b)},children:["dir"===b.type||"app"===b.type||"node-app"===b.type?b.loading?(0,Z.jsx)(au,{className:"h-3.5 w-3.5 shrink-0 animate-spin text-muted-foreground"}):b.expanded?(0,Z.jsx)(ah,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}):(0,Z.jsx)(ai,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}):(0,Z.jsx)("span",{className:"w-3.5 shrink-0"}),"dir"===b.type?b.expanded?(0,Z.jsx)(ap,{className:bX("h-4 w-4 shrink-0",aM?.path!==b.path&&"text-warning")}):(0,Z.jsx)(ao,{className:bX("h-4 w-4 shrink-0",aM?.path!==b.path&&"text-warning")}):"app"===b.type?(0,Z.jsx)(ar,{className:bX("h-4 w-4 shrink-0",aM?.path!==b.path&&"text-foreground/70")}):"node-app"===b.type?(0,Z.jsx)(aF,{className:bX("h-4 w-4 shrink-0",aM?.path!==b.path&&"text-emerald-500")}):"html"===HM(b.name,"file")?(0,Z.jsx)(ar,{className:bX("h-4 w-4 shrink-0",aM?.path!==b.path&&"text-foreground/60")}):HQ(b.name)?(0,Z.jsx)(as,{className:bX("h-4 w-4 shrink-0",aM?.path!==b.path&&"text-sunshine-700")}):HO(b.name)?(0,Z.jsx)(an,{className:bX("h-4 w-4 shrink-0",aM?.path!==b.path&&"text-foreground/70")}):(0,Z.jsx)(al,{className:bX("h-4 w-4 shrink-0",aM?.path!==b.path&&"text-foreground/60")}),(0,Z.jsx)("span",{className:"min-w-0 flex-1 truncate",children:b.name}),z.has(b.path)&&(0,Z.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,Z.jsx)("div",{className:"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,Z.jsxs)(FS,{children:[(0,Z.jsx)(FU,{asChild:!0,children:(0,Z.jsx)(bZ,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0 text-muted-foreground hover:text-foreground",title:"File actions",children:(0,Z.jsx)(aw,{className:"h-3.5 w-3.5"})})}),(0,Z.jsxs)(F5,{align:"end",className:"w-48",children:[(0,Z.jsxs)(F6,{onClick:()=>bt(b.path),children:[(0,Z.jsx)(aj,{className:"mr-2 h-3.5 w-3.5"}),"Copy path"]}),HP(b.name)&&(0,Z.jsxs)(F6,{onClick:()=>bu(b.name),children:[(0,Z.jsx)(an,{className:"mr-2 h-3.5 w-3.5"}),"Copy wiki link"]}),(0,Z.jsxs)(F6,{onClick:()=>bv(b.path),children:[(0,Z.jsx)(at,{className:"mr-2 h-3.5 w-3.5"}),"Copy URL"]}),"file"===b.type&&HO(b.name)&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(F6,{onClick:()=>void bx(b.path),children:[(0,Z.jsx)(an,{className:"mr-2 h-3.5 w-3.5"}),"Copy raw content"]}),(0,Z.jsxs)(F6,{onClick:()=>void by(b.path,b.name),children:[(0,Z.jsx)(an,{className:"mr-2 h-3.5 w-3.5"}),"Copy formatted content"]})]}),(0,Z.jsx)(F8,{}),"dir"===b.type&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(F6,{onClick:async()=>{b.expanded||await bj(b),Y(b.path),aa(""),ac(null)},children:[(0,Z.jsx)(am,{className:"mr-2 h-3.5 w-3.5"}),"New file here"]}),(0,Z.jsxs)(F6,{onClick:()=>bq(b.path),children:[(0,Z.jsx)(aH,{className:"mr-2 h-3.5 w-3.5"}),"Upload here"]}),(0,Z.jsxs)(F6,{onClick:()=>{S(b.path),U(""),W(null)},children:[(0,Z.jsx)(aq,{className:"mr-2 h-3.5 w-3.5"}),"New subfolder"]}),(0,Z.jsx)(F8,{})]}),(0,Z.jsxs)(F6,{onClick:()=>{let a,c;return a=`/api/wiki/download?path=${encodeURIComponent(b.path)}`,void((c=document.createElement("a")).href=a,c.download="file"===b.type?b.name:`${b.name}.zip`,document.body.appendChild(c),c.click(),c.remove())},children:[(0,Z.jsx)(ak,{className:"mr-2 h-3.5 w-3.5"}),"file"===b.type?"Download":"Download as zip"]}),(0,Z.jsxs)(F6,{onClick:()=>GP.getState().toggle({path:b.path,name:b.name},f),children:[(0,Z.jsx)(aE,{className:bX("mr-2 h-3.5 w-3.5",d&&"fill-current text-amber-400")}),d?"Unpin":"Pin to top"]}),(0,Z.jsx)(F8,{}),(0,Z.jsxs)(F6,{className:"text-destructive focus:text-destructive",onClick:()=>{aJ(b.path),aL("file"!==b.type)},children:[(0,Z.jsx)(aG,{className:"mr-2 h-3.5 w-3.5"}),"Delete"]})]})]})})]}),R===b.path&&"dir"===b.type&&(0,Z.jsxs)("div",{className:"flex items-center gap-1.5 px-2 py-1",style:{paddingLeft:`${(c+1)*14+8}px`},children:[(0,Z.jsx)("span",{className:"w-3.5 shrink-0"}),(0,Z.jsx)(ao,{className:"h-4 w-4 shrink-0 text-warning"}),(0,Z.jsx)("input",{className:"flex-1 bg-transparent text-sm outline-none border-b border-border min-w-0",placeholder:"Folder name",value:T,onChange:a=>U(a.target.value),onKeyDown:a=>{"Enter"===a.key&&br(),"Escape"===a.key&&(S(null),U(""))}}),V&&(0,Z.jsx)("span",{className:"text-xs text-destructive",children:V}),(0,Z.jsx)(bZ,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:br,children:(0,Z.jsx)(ag,{className:"h-3 w-3"})}),(0,Z.jsx)(bZ,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:()=>{S(null),U("")},children:(0,Z.jsx)(aI,{className:"h-3 w-3"})})]}),X===b.path&&"dir"===b.type&&(0,Z.jsxs)("div",{className:"flex items-center gap-1.5 px-2 py-1",style:{paddingLeft:`${(c+1)*14+8}px`},children:[(0,Z.jsx)("span",{className:"w-3.5 shrink-0"}),(0,Z.jsx)(an,{className:"h-4 w-4 shrink-0 text-accent"}),(0,Z.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:_,onChange:a=>aa(a.target.value),onKeyDown:a=>{"Enter"===a.key&&bs(),"Escape"===a.key&&(Y(null),aa(""))}}),ab&&(0,Z.jsx)("span",{className:"text-xs text-destructive",children:ab}),(0,Z.jsx)(bZ,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:bs,children:(0,Z.jsx)(ag,{className:"h-3 w-3"})}),(0,Z.jsx)(bZ,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:()=>{Y(null),aa("")},children:(0,Z.jsx)(aI,{className:"h-3 w-3"})})]}),("dir"===b.type||"app"===b.type||"node-app"===b.type)&&b.expanded&&b.children&&b.children.length>0&&a(b.children,c+1),("dir"===b.type||"app"===b.type||"node-app"===b.type)&&b.expanded&&b.children?.length===0&&(0,Z.jsx)("div",{className:"text-xs text-muted-foreground/50 py-0.5",style:{paddingLeft:`${(c+1)*14+8+14+6+16+6}px`},children:"Empty"})]})}),(0,Z.jsxs)(GL,{children:[(0,Z.jsx)(GM,{onSelect:()=>bt(b.path),children:"Copy path"}),HP(b.name)&&(0,Z.jsx)(GM,{onSelect:()=>bu(b.name),children:"Copy wiki link"}),(0,Z.jsx)(GN,{}),(0,Z.jsx)(GM,{onSelect:()=>bv(b.path),children:"Copy URL"}),"file"===b.type&&HO(b.name)&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(GN,{}),(0,Z.jsx)(GM,{onSelect:()=>void bx(b.path),children:"Copy raw content"}),(0,Z.jsx)(GM,{onSelect:()=>void by(b.path,b.name),children:"Copy formatted content"})]})]})]},b.path)})}(C)]}),(0,Z.jsx)("div",{className:"border-t px-2 py-2 bg-muted shrink-0",children:(0,Z.jsxs)(FS,{children:[(0,Z.jsx)(FU,{asChild:!0,children:(0,Z.jsxs)(bZ,{size:"sm",variant:"ghost",className:"w-full h-auto justify-between gap-2 px-2 py-1.5 text-left",title:d??"",children:[(0,Z.jsxs)("span",{className:"flex flex-col min-w-0",children:[(0,Z.jsx)("span",{className:"truncate text-xs font-medium",children:h.find(a=>a.id===f)?.name??"Workspace"}),(0,Z.jsx)("span",{className:"truncate text-[10px] text-muted-foreground font-mono",children:d??""})]}),(0,Z.jsx)(ah,{className:"h-3.5 w-3.5 shrink-0 opacity-60"})]})}),(0,Z.jsxs)(F5,{align:"start",className:"w-60",children:[h.map(a=>(0,Z.jsxs)(F6,{onClick:()=>void bm(a.id),className:bX("gap-2",a.id===f&&"font-medium"),children:[a.id===f?(0,Z.jsx)(ag,{className:"h-3.5 w-3.5 shrink-0"}):(0,Z.jsx)("span",{className:"w-3.5 shrink-0"}),(0,Z.jsxs)("span",{className:"flex flex-col min-w-0 flex-1",children:[(0,Z.jsx)("span",{className:"truncate",children:a.name}),(0,Z.jsx)("span",{className:"truncate text-[10px] text-muted-foreground font-mono",children:a.rootDir})]}),j&&(0,Z.jsx)("button",{className:"ml-auto 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(),o(a.id)},children:(0,Z.jsx)(aG,{className:"h-3.5 w-3.5"})})]},a.id)),j&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(F8,{}),(0,Z.jsxs)(F6,{onClick:()=>m(!0),children:[(0,Z.jsx)(aq,{className:"mr-2 h-3.5 w-3.5"}),"Add workspace…"]})]})]})]})})]}),(0,Z.jsxs)("div",{className:"flex-1 flex flex-col min-w-0 relative",children:[aS&&(0,Z.jsx)(bZ,{size:"sm",variant:"ghost",className:"absolute left-0 top-1/2 -translate-y-1/2 z-10 h-7 w-7 p-0 rounded-full bg-background/50 backdrop-blur-xl backdrop-saturate-150 border border-white/[0.08] text-foreground/60 hover:text-foreground/90 hover:bg-background/70 shadow-[0_0_12px_rgba(0,0,0,0.15)] [transform:translate(-50%,-50%)_translateZ(0)]",title:"Show sidebar",onClick:()=>aT(!1),children:(0,Z.jsx)(ay,{className:"h-3.5 w-3.5"})}),aM?"node-app"===bD?(0,Z.jsx)(Ga,{path:aM.path,title:aM.name}):"app"===bD||"html"===bD?(a="html"===bD?`/api/assets/${aM.path}`:void 0,aO?(0,Z.jsx)(Eq,{path:aM.path,title:aM.name,src:a,fullscreen:!0,onExit:()=>aP(!1)}):(0,Z.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden min-w-0",children:[(0,Z.jsxs)("div",{className:"flex items-center justify-between px-4 py-2 border-b bg-muted shrink-0",children:[(0,Z.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,Z.jsx)(ar,{className:"h-4 w-4 shrink-0 text-accent"}),(0,Z.jsx)("span",{className:"text-sm font-normal truncate",title:aM.path,children:aM.path})]}),(0,Z.jsxs)("div",{className:"flex items-center gap-1 shrink-0",children:[bz(aM),"html"===bD&&!a0&&null!==aW&&(0,Z.jsx)(bZ,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",title:"Edit source",onClick:()=>{a1(!0),a3(aW),a7(null)},children:(0,Z.jsx)(az,{className:"h-3.5 w-3.5"})}),(0,Z.jsx)(bZ,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",title:"Refresh",onClick:()=>aR(a=>a+1),children:(0,Z.jsx)(aC,{className:"h-3.5 w-3.5"})}),(0,Z.jsxs)(bZ,{size:"sm",variant:"ghost",className:"h-7 gap-1.5 text-xs",onClick:()=>aP(!0),children:[(0,Z.jsx)(av,{className:"h-3.5 w-3.5"}),"Open fullscreen"]}),(0,Z.jsx)(bZ,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",onClick:()=>{aN(null),a1(!1)},children:(0,Z.jsx)(aI,{className:"h-3.5 w-3.5"})})]})]}),a0&&"html"===bD?(0,Z.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden min-h-0",children:[(0,Z.jsx)("textarea",{value:a2,onChange:a=>a3(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,Z.jsxs)("div",{className:"border-t px-4 py-2 flex items-center justify-end gap-2 bg-muted shrink-0",children:[a6&&(0,Z.jsx)("span",{className:"text-xs text-destructive mr-auto",children:a6}),(0,Z.jsx)(bZ,{size:"sm",variant:"ghost",onClick:()=>{a1(!1),a7(null)},children:"Cancel"}),(0,Z.jsxs)(bZ,{size:"sm",className:"gap-1",onClick:bo,disabled:a4,children:[a4&&(0,Z.jsx)(au,{className:"h-3 w-3 animate-spin"}),"Save"]})]})]}):(0,Z.jsx)(Eq,{path:aM.path,title:aM.name,src:a},aQ)]})):(0,Z.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden min-w-0",children:[(0,Z.jsxs)("div",{className:"flex items-center justify-between px-4 py-2 border-b bg-muted shrink-0",children:[(0,Z.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[HQ(aM.name)?(0,Z.jsx)(as,{className:"h-4 w-4 shrink-0 text-sunshine-700"}):HO(aM.name)?(0,Z.jsx)(an,{className:"h-4 w-4 shrink-0 text-accent"}):(0,Z.jsx)(al,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),(0,Z.jsx)("span",{className:"text-sm font-normal truncate",title:aM.path,children:aM.path})]}),(0,Z.jsxs)("div",{className:"flex items-center gap-1 shrink-0",children:[bz(aM),HO(aM.name)&&!a0&&(null!==aW||HP(aM.name))&&(0,Z.jsx)(bZ,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",onClick:()=>{a1(!0),a3(aW??""),a7(null),HP(aM.name)&&vi.getState().loadPage(aM.path)},children:(0,Z.jsx)(az,{className:"h-3.5 w-3.5"})}),HO(aM.name)&&!a0&&(null!==aW||HP(aM.name))&&(0,Z.jsx)(bZ,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",title:"Refresh",onClick:bi,disabled:a$,children:a$?(0,Z.jsx)(au,{className:"h-3.5 w-3.5 animate-spin"}):(0,Z.jsx)(aC,{className:"h-3.5 w-3.5"})}),bF&&(0,Z.jsx)(HK,{}),(0,Z.jsx)(bZ,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",onClick:()=>{aN(null),aX(null),a1(!1)},children:(0,Z.jsx)(aI,{className:"h-3.5 w-3.5"})})]})]}),a0?(0,Z.jsx)("div",{className:"flex-1 flex flex-col overflow-hidden min-h-0",children:HP(aM.name)?(0,Z.jsx)(Dl,{}):(0,Z.jsx)("textarea",{value:a2,onChange:a=>a3(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"})}):HP(aM.name)?(0,Z.jsx)("div",{className:"flex-1 flex flex-col overflow-hidden min-h-0",children:a$?(0,Z.jsx)("div",{className:"flex justify-center py-8",children:(0,Z.jsx)(au,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):(0,Z.jsx)(Dl,{mode:"viewing"})}):(0,Z.jsx)("div",{className:"flex-1 overflow-auto p-4 min-h-0",children:(0,Z.jsx)("div",{className:bX("mx-auto w-full",bG),children:a$?(0,Z.jsx)("div",{className:"flex justify-center py-8",children:(0,Z.jsx)(au,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):"csv"===bD?(0,Z.jsx)(dS,{path:aM.path,title:aM.name}):"pdf"===bD?(0,Z.jsx)(El,{path:aM.path,title:aM.name}):"mermaid"===bD?(0,Z.jsx)(Dt,{path:aM.path,title:aM.name}):"notebook"===bD?(0,Z.jsx)(Eg,{path:aM.path,title:aM.name}):"image"===bD?(0,Z.jsx)(Dn,{path:aM.path,title:aM.name}):"media"===bD?(0,Z.jsx)(Do,{path:aM.path,title:aM.name,type:["mp4","webm","mov","m4v"].includes(HL(aM.name))?"video":"audio"}):"docx"===bD?(0,Z.jsx)(Ei,{path:aM.path,title:aM.name}):"xlsx"===bD?(0,Z.jsx)(Ek,{path:aM.path,title:aM.name}):"pptx"===bD?(0,Z.jsx)(Ej,{path:aM.path,title:aM.name}):"source"===bD?(0,Z.jsx)(Ep,{path:aM.path,title:aM.name}):"fallback"===bD?(0,Z.jsx)(Dm,{path:aM.path,title:aM.name}):null!==aW?(0,Z.jsx)("pre",{className:"text-xs font-mono whitespace-pre-wrap break-words leading-relaxed",children:aW}):HO(aM.name)?(0,Z.jsx)("p",{className:"text-sm text-muted-foreground",children:"Could not load file."}):(0,Z.jsx)("p",{className:"text-sm text-muted-foreground",children:"Preview not available for this file type."})})}),a0&&!HP(aM.name)&&(0,Z.jsxs)("div",{className:"border-t px-4 py-2 flex items-center justify-end gap-2 bg-muted shrink-0",children:[a6&&(0,Z.jsx)("span",{className:"text-xs text-destructive mr-auto",children:a6}),(0,Z.jsx)(bZ,{size:"sm",variant:"ghost",onClick:()=>{a1(!1),a7(null)},children:"Cancel"}),(0,Z.jsxs)(bZ,{size:"sm",className:"gap-1",onClick:bo,disabled:a4,children:[a4&&(0,Z.jsx)(au,{className:"h-3 w-3 animate-spin"}),"Save"]})]})]}):(0,Z.jsx)("div",{className:"flex-1 flex flex-col items-center justify-center",children:(0,Z.jsxs)("div",{className:"flex flex-col items-center gap-2 text-center px-4",children:[(0,Z.jsx)(an,{className:"h-8 w-8 text-muted-foreground"}),(0,Z.jsx)("p",{className:"text-sm text-muted-foreground",children:"Select a file to view or edit"})]})})]}),(0,Z.jsx)(Go,{open:aU,onOpenChange:aV}),(0,Z.jsx)(G0,{currentPath:aM?.path}),(0,Z.jsx)("input",{ref:P,type:"file",multiple:!0,className:"hidden",onChange:a=>{a.target.files&&bp(a.target.files,Q.current)}}),(0,Z.jsx)(dL,{open:!!ad,onOpenChange:a=>{a||aJ(null)},title:aK?"Delete folder?":"Delete file?",description:aK?`"${ad?.split("/").pop()}" and all its contents will be permanently deleted.`:`"${ad?.split("/").pop()}" will be permanently removed.`,onConfirm:bA}),(0,Z.jsx)(dL,{open:!!n,onOpenChange:a=>{a||o(null)},title:"Delete workspace?",description:`"${h.find(a=>a.id===n)?.name??""}" will be removed from the workspace list. Files on disk are NOT deleted.`,onConfirm:bn})]})]},f??"none")}],240777)}];
|
|
129
|
+
${b}/api/agent/files/${a??"<path/to/file.md>"}`;await navigator.clipboard.writeText(d),c(!0),setTimeout(()=>c(!1),1500)},[a])}}(a??null),[i,j]=(0,$.useState)(""),k=(0,$.useRef)(null),l="http://localhost:3000",m=(0,$.useCallback)(()=>G$,[]),n=(0,$.useCallback)(()=>i.replace(/\$WIKI_URL/g,l),[i,l]),o=(0,$.useCallback)(()=>`npx wiki-viewer-mcp register --url ${l} --id ai:myagent --name "My Agent"`,[l]),p=(0,$.useCallback)(()=>JSON.stringify({servers:{"wiki-viewer":{command:"npx",args:["wiki-viewer-mcp"],env:{WIKI_VIEWER_URL:l,WIKI_VIEWER_TOKEN:"<token from register>",WIKI_VIEWER_AGENT_ID:"ai:myagent"}}}},null,2),[l]),q=G_(m),r=G_(n),s=G_(o),t=G_(p);return((0,$.useEffect)(()=>{if(b)return document.addEventListener("keydown",a),()=>document.removeEventListener("keydown",a);function a(a){"Escape"===a.key&&c()}},[b,c]),(0,$.useEffect)(()=>{b&&k.current?.focus()},[b]),(0,$.useEffect)(()=>{if(!b)return;f();let a=setInterval(()=>void f(),1e4);return()=>clearInterval(a)},[b,f]),(0,$.useEffect)(()=>{b&&fetch("/api/agents/install").then(a=>a.json()).then(a=>{a.bootstrapPrompt&&j(a.bootstrapPrompt)}).catch(()=>void 0)},[b]),b)?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)("div",{className:"fixed inset-0 z-40 bg-black/20 backdrop-blur-[1px]",onClick:c,"aria-hidden":!0}),(0,Z.jsxs)("aside",{ref:k,tabIndex:-1,role:"dialog","aria-modal":"true","aria-label":"AI Agent Panel",className:"fixed right-0 top-0 bottom-0 z-50 flex w-80 flex-col border-l border-border bg-background shadow-xl outline-none",children:[(0,Z.jsxs)("div",{className:"flex items-center justify-between border-b border-border px-4 py-3 shrink-0",children:[(0,Z.jsxs)("div",{className:"flex items-center gap-2",children:[(0,Z.jsx)(af,{className:"h-4 w-4 text-muted-foreground"}),(0,Z.jsx)("span",{className:"text-sm font-semibold",children:"AI Agent"})]}),(0,Z.jsx)(bZ,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",onClick:c,title:"Close panel (Esc)",children:(0,Z.jsx)(aI,{className:"h-3.5 w-3.5"})})]}),(0,Z.jsxs)("div",{className:"flex-1 overflow-y-auto space-y-5 px-4 py-4",children:[(0,Z.jsxs)("section",{className:"rounded-md border border-border bg-muted/30 p-3",children:[(0,Z.jsx)("p",{className:"text-sm font-medium text-foreground",children:"Work with this wiki using AI"}),(0,Z.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,Z.jsx)("span",{className:"font-medium text-foreground/80",children:"Agents"})," below before it gets access."]})]}),(0,Z.jsxs)("section",{className:"space-y-3",children:[(0,Z.jsxs)("div",{className:"rounded-md border border-border bg-muted/40 p-3 space-y-1.5",children:[(0,Z.jsx)("p",{className:"text-xs font-semibold text-foreground",children:"Co-write docs with you"}),(0,Z.jsx)("p",{className:"text-[10px] text-muted-foreground/70",children:"Edits arrive as suggestions with comments you accept or revert. No MCP needed."}),(0,Z.jsx)(bZ,{size:"sm",variant:"outline",className:"h-7 w-full text-xs gap-1.5",onClick:()=>void r.copy(),disabled:!i,children:r.copied?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(ag,{className:"h-3.5 w-3.5 text-green-500"})," Copied!"]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(aj,{className:"h-3.5 w-3.5"})," Paste into any chatbot"]})}),(0,Z.jsxs)("p",{className:"text-[10px] text-muted-foreground/50 pt-1",children:["Or install once so it sticks"," ",(0,Z.jsx)("span",{className:"text-muted-foreground/40",children:"· Claude, OpenCode"}),":"]}),(0,Z.jsxs)("div",{className:"flex items-center gap-2",children:[(0,Z.jsx)("code",{className:"flex-1 text-[10px] font-mono text-foreground/80 truncate bg-muted rounded px-1 py-0.5",children:G$}),(0,Z.jsx)(bZ,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0 shrink-0",title:"Copy this command",onClick:()=>void q.copy(),children:q.copied?(0,Z.jsx)(ag,{className:"h-3.5 w-3.5 text-green-500"}):(0,Z.jsx)(aj,{className:"h-3.5 w-3.5"})})]})]}),(0,Z.jsxs)("div",{className:"rounded-md border border-border bg-muted/40 p-3 space-y-1.5",children:[(0,Z.jsxs)("p",{className:"text-xs font-semibold text-foreground",children:["Edit files directly"," ",(0,Z.jsx)("span",{className:"font-normal text-muted-foreground/60",children:"· Claude Code, Cursor, Codex"})]}),(0,Z.jsx)("p",{className:"text-[10px] text-muted-foreground/70",children:"Native read / search / edit tools over MCP. Run to request access:"}),(0,Z.jsxs)("div",{className:"flex items-center gap-2",children:[(0,Z.jsx)("code",{className:"flex-1 text-[10px] font-mono text-foreground/80 truncate bg-muted rounded px-1 py-0.5",children:o()}),(0,Z.jsx)(bZ,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0 shrink-0",title:"Copy this command",onClick:()=>void s.copy(),children:s.copied?(0,Z.jsx)(ag,{className:"h-3.5 w-3.5 text-green-500"}):(0,Z.jsx)(aj,{className:"h-3.5 w-3.5"})})]}),(0,Z.jsxs)("p",{className:"text-[10px] text-muted-foreground/50",children:["Approve in ",(0,Z.jsx)("span",{className:"font-medium text-foreground/70",children:"Agents"}),", then add to your tool:"]}),(0,Z.jsx)(bZ,{size:"sm",variant:"outline",className:"h-7 w-full text-xs gap-1.5",onClick:()=>void t.copy(),children:t.copied?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(ag,{className:"h-3.5 w-3.5 text-green-500"})," Copied!"]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(aj,{className:"h-3.5 w-3.5"})," Copy config (mcp.json)"]})})]}),(0,Z.jsxs)("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1",children:[(0,Z.jsx)("span",{className:"text-[10px] text-muted-foreground/50",children:"For developers:"}),(0,Z.jsxs)("button",{type:"button",onClick:()=>void h(),className:"inline-flex items-center gap-1 text-[10px] text-primary hover:underline",children:[g?(0,Z.jsx)(ag,{className:"h-3 w-3 text-green-500"}):(0,Z.jsx)(aj,{className:"h-3 w-3"})," curl example"]}),(0,Z.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,Z.jsx)(w7,{className:"h-3 w-3"})," skill"]}),(0,Z.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,Z.jsx)(w7,{className:"h-3 w-3"})," install JSON"]})]})]}),(0,Z.jsx)(GY,{}),(0,Z.jsxs)("section",{className:"space-y-2",children:[(0,Z.jsxs)("h3",{className:"text-xs font-semibold uppercase tracking-widest text-muted-foreground",children:["Active Connections"," ",(0,Z.jsx)("span",{className:"normal-case font-normal text-muted-foreground/50",children:"(last 5 min)"})]}),(0,Z.jsx)("div",{className:"rounded-md border border-border bg-muted/40 p-3",children:0===e.length?(0,Z.jsxs)("p",{className:"text-xs text-muted-foreground/60 flex items-center gap-1.5",children:[(0,Z.jsx)(GQ,{className:"h-3.5 w-3.5"}),"No recent activity"]}):(0,Z.jsx)("ul",{className:"space-y-1.5",children:e.map(a=>(0,Z.jsxs)("li",{className:"flex items-center justify-between text-xs",children:[(0,Z.jsx)("span",{className:"font-mono text-foreground/80 truncate",children:a.by}),(0,Z.jsxs)("span",{className:"text-muted-foreground shrink-0",children:[a.opCount," op",1!==a.opCount?"s":""]})]},a.by))})})]}),(0,Z.jsxs)("section",{className:"space-y-2",children:[(0,Z.jsx)("h3",{className:"text-xs font-semibold uppercase tracking-widest text-muted-foreground",children:"Recent Activity"}),(0,Z.jsx)("div",{className:"rounded-md border border-border bg-muted/40 px-3 py-1 max-h-72 overflow-y-auto",children:0===d.length?(0,Z.jsx)("p",{className:"text-xs text-muted-foreground/60 py-2",children:"No events recorded"}):d.map(a=>(0,Z.jsx)(GZ,{event:a},`${a.path}-${a.id}`))})]}),(0,Z.jsx)("section",{children:(0,Z.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 G1=/[\\\/_+.#"@\[\(\{&]/,G2=/[\\\/_+.#"@\[\(\{&]/g,G3=/[\s-]/,G4=/[\s-]/g;function G5(a){return a.toLowerCase().replace(G4," ")}var G6='[cmdk-group=""]',G7='[cmdk-group-items=""]',G8='[cmdk-item=""]',G9=`${G8}:not([aria-disabled="true"])`,Ha="cmdk-item-select",Hb="data-value",Hc=(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:G1.test(b.charAt(o-1))?(j*=.8,(l=b.slice(f,o-1).match(G2))&&f>0&&(j*=Math.pow(.999,l.length))):G3.test(b.charAt(o-1))?(j*=.9,(m=b.slice(f,o-1).match(G4))&&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,G5(d),G5(b),0,0,{})},Hd=$.createContext(void 0),He=$.createContext(void 0),Hf=$.createContext(void 0),Hg=$.forwardRef((a,b)=>{let c=Hq(()=>{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=Hq(()=>new Set),e=Hq(()=>new Map),f=Hq(()=>new Map),g=Hq(()=>new Set),h=Ho(a),{label:i,children:j,value:k,onValueChange:l,filter:m,shouldFilter:n,loop:o,disablePointerSelection:p=!1,vimBindings:q=!0,...r}=a,s=b3(),t=b3(),u=b3(),v=$.useRef(null),w=Ht();Hp(()=>{if(void 0!==k){let a=k.trim();c.current.value=a,x.emit()}},[k]),Hp(()=>{w(6,D)},[]);let x=$.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=$.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:Hc;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(G7);b?b.appendChild(a.parentElement===b?a:a.closest(`${G7} > *`)):d.appendChild(a.parentElement===d?a:a.closest(`${G7} > *`))}),b.sort((a,b)=>b[1]-a[1]).forEach(a=>{var b;let c=null==(b=v.current)?void 0:b.querySelector(`${G6}[${Hb}="${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(Hb);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(G6))?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(`${G8}[aria-selected="true"]`)}function F(){var a;return Array.from((null==(a=v.current)?void 0:a.querySelectorAll(G9))||[])}function G(a){let b=F()[a];b&&x.setState("value",b.getAttribute(Hb))}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(Hb))}function I(a){let b=E(),c=null==b?void 0:b.closest(G6),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,G6):function(a,b){let c=a.previousElementSibling;for(;c;){if(c.matches(b))return c;c=c.previousElementSibling}}(c,G6))?void 0:c.querySelector(G9);d?x.setState("value",d.getAttribute(Hb)):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 $.createElement(xp.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(Ha);b.dispatchEvent(a)}}}}},$.createElement("label",{"cmdk-label":"",htmlFor:y.inputId,id:y.labelId,style:Hv},i),Hu(a,a=>$.createElement(He.Provider,{value:x},$.createElement(Hd.Provider,{value:y},a))))}),Hh=$.forwardRef((a,b)=>{var c,d;let e=b3(),f=$.useRef(null),g=$.useContext(Hf),h=$.useContext(Hd),i=Ho(a),j=null!=(d=null==(c=i.current)?void 0:c.forceMount)?d:null==g?void 0:g.forceMount;Hp(()=>{if(!j)return h.item(e,null==g?void 0:g.id)},[j]);let k=Hs(e,f,[a.value,a.children,f],a.keywords),l=$.useContext(He),m=Hr(a=>a.value&&a.value===k.current),n=Hr(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($.useEffect(()=>{let b=f.current;if(!(!b||a.disabled))return b.addEventListener(Ha,o),()=>b.removeEventListener(Ha,o)},[n,a.onSelect,a.disabled]),!n)return null;let{disabled:q,value:r,onSelect:s,forceMount:t,keywords:u,...v}=a;return $.createElement(xp.div,{ref:aK(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)}),Hi=$.forwardRef((a,b)=>{let{heading:c,children:d,forceMount:e,...f}=a,g=b3(),h=$.useRef(null),i=$.useRef(null),j=b3(),k=$.useContext(Hd),l=Hr(a=>!!e||!1===k.filter()||!a.search||a.filtered.groups.has(g));Hp(()=>k.group(g),[]),Hs(g,h,[a.value,a.heading,i]);let m=$.useMemo(()=>({id:g,forceMount:e}),[e]);return $.createElement(xp.div,{ref:aK(h,b),...f,"cmdk-group":"",role:"presentation",hidden:!l||void 0},c&&$.createElement("div",{ref:i,"cmdk-group-heading":"","aria-hidden":!0,id:j},c),Hu(a,a=>$.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":c?j:void 0},$.createElement(Hf.Provider,{value:m},a))))}),Hj=$.forwardRef((a,b)=>{let{alwaysRender:c,...d}=a,e=$.useRef(null),f=Hr(a=>!a.search);return c||f?$.createElement(xp.div,{ref:aK(e,b),...d,"cmdk-separator":"",role:"separator"}):null}),Hk=$.forwardRef((a,b)=>{let{onValueChange:c,...d}=a,e=null!=a.value,f=$.useContext(He),g=Hr(a=>a.search),h=Hr(a=>a.selectedItemId),i=$.useContext(Hd);return $.useEffect(()=>{null!=a.value&&f.setState("search",a.value)},[a.value]),$.createElement(xp.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)}})}),Hl=$.forwardRef((a,b)=>{let{children:c,label:d="Suggestions",...e}=a,f=$.useRef(null),g=$.useRef(null),h=Hr(a=>a.selectedItemId),i=$.useContext(Hd);return $.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)}}},[]),$.createElement(xp.div,{ref:aK(f,b),...e,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":h,"aria-label":d,id:i.listId},Hu(a,a=>$.createElement("div",{ref:aK(g,i.listInnerRef),"cmdk-list-sizer":""},a)))}),Hm=$.forwardRef((a,b)=>{let{open:c,onOpenChange:d,overlayClassName:e,contentClassName:f,container:g,...h}=a;return $.createElement(dd,{open:c,onOpenChange:d},$.createElement(di,{container:g},$.createElement(dk,{"cmdk-overlay":"",className:e}),$.createElement(dp,{"aria-label":a.label,"cmdk-dialog":"",className:f},$.createElement(Hg,{ref:b,...h}))))}),Hn=Object.assign(Hg,{List:Hl,Item:Hh,Input:Hk,Group:Hi,Separator:Hj,Dialog:Hm,Empty:$.forwardRef((a,b)=>Hr(a=>0===a.filtered.count)?$.createElement(xp.div,{ref:b,...a,"cmdk-empty":"",role:"presentation"}):null),Loading:$.forwardRef((a,b)=>{let{progress:c,children:d,label:e="Loading...",...f}=a;return $.createElement(xp.div,{ref:b,...f,"cmdk-loading":"",role:"progressbar","aria-valuenow":c,"aria-valuemin":0,"aria-valuemax":100,"aria-label":e},Hu(a,a=>$.createElement("div",{"aria-hidden":!0},a)))})});function Ho(a){let b=$.useRef(a);return Hp(()=>{b.current=a}),b}var Hp=$.useEffect;function Hq(a){let b=$.useRef();return void 0===b.current&&(b.current=a()),b}function Hr(a){let b=$.useContext(He),c=()=>a(b.snapshot());return $.useSyncExternalStore(b.subscribe,c,c)}function Hs(a,b,c,d=[]){let e=$.useRef(),f=$.useContext(Hd);return Hp(()=>{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(Hb,h),e.current=h}),e}var Ht=()=>{let[a,b]=$.useState(),c=Hq(()=>new Map);return Hp(()=>{c.current.forEach(a=>a()),c.current=new Map},[a]),(a,d)=>{c.current.set(a,d),b({})}};function Hu({asChild:a,children:b},c){let d;return a&&$.isValidElement(b)?$.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 Hv={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};let Hw=ad("search",[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]),Hx=$.forwardRef(({className:a,...b},c)=>(0,Z.jsx)(Hn,{ref:c,className:bX("flex h-full w-full flex-col overflow-hidden rounded-sm bg-popover text-popover-foreground",a),...b}));function Hy({children:a,shouldFilter:b,...c}){return(0,Z.jsx)(dd,{...c,children:(0,Z.jsxs)(dG,{className:"overflow-hidden p-0 shadow-golden max-w-lg",children:[(0,Z.jsx)(dJ,{className:"sr-only",children:"Search"}),(0,Z.jsx)(Hx,{shouldFilter:b,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})]})})}Hx.displayName=Hn.displayName;let Hz=$.forwardRef(({className:a,...b},c)=>(0,Z.jsxs)("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[(0,Z.jsx)(Hw,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),(0,Z.jsx)(Hn.Input,{ref:c,className:bX("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),...b})]}));Hz.displayName=Hn.Input.displayName;let HA=$.forwardRef(({className:a,...b},c)=>(0,Z.jsx)(Hn.List,{ref:c,className:bX("max-h-[300px] overflow-y-auto overflow-x-hidden",a),...b}));HA.displayName=Hn.List.displayName;let HB=$.forwardRef((a,b)=>(0,Z.jsx)(Hn.Empty,{ref:b,className:"py-6 text-center text-sm text-muted-foreground",...a}));HB.displayName=Hn.Empty.displayName;let HC=$.forwardRef(({className:a,...b},c)=>(0,Z.jsx)(Hn.Group,{ref:c,className:bX("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),...b}));HC.displayName=Hn.Group.displayName;let HD=$.forwardRef(({className:a,...b},c)=>(0,Z.jsx)(Hn.Separator,{ref:c,className:bX("-mx-1 h-px bg-border",a),...b}));HD.displayName=Hn.Separator.displayName;let HE=$.forwardRef(({className:a,...b},c)=>(0,Z.jsx)(Hn.Item,{ref:c,className:bX("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),...b}));HE.displayName=Hn.Item.displayName;let HF=null,HG=u8(a=>({query:"",results:[],loading:!1,truncated:!1,open:!1,setQuery:b=>a({query:b}),setOpen:b=>a({open:b}),clear:()=>{HF?.abort(),a({query:"",results:[],loading:!1,truncated:!1})},search:async b=>{HF?.abort();let c=new AbortController;if(HF=c,!b.trim())return void a({results:[],loading:!1,truncated:!1});a({loading:!0});try{let d=await dO("/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})}}}));function HH({html:a}){let b=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,Z.jsx)(Z.Fragment,{children:b.map((a,b)=>a.mark?(0,Z.jsx)("mark",{className:"bg-yellow-200 dark:bg-yellow-700 rounded-[2px] px-[1px]",children:a.text},b):(0,Z.jsx)("span",{children:a.text},b))})}function HI({onOpenFile:a,onToggleSidebar:b=()=>void 0,onNewFile:c=()=>void 0,onCopyPath:d=()=>void 0}){let e=HG(a=>a.open),f=HG(a=>a.setOpen),g=HG(a=>a.query),h=HG(a=>a.setQuery),i=HG(a=>a.results),j=HG(a=>a.loading),k=HG(a=>a.truncated),l=HG(a=>a.search),{resolvedTheme:m,setTheme:n}=(0,Gh.useTheme)(),o=u9(a=>a.toggle),p=vo(a=>a.width),q=vo(a=>a.cycle),r=g.trimStart(),s=""===r||r.startsWith(">"),t=s?"":g;function u(a){a(),f(!1),h("")}(0,$.useEffect)(()=>{function a(a){(a.metaKey||a.ctrlKey)&&"k"===a.key.toLowerCase()&&(a.preventDefault(),f(!e))}return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[e,f]),(0,$.useEffect)(()=>{if(!e||s)return;let a=setTimeout(()=>{l(t)},120);return()=>clearTimeout(a)},[t,s,e,l]);let v=(vn.indexOf(p)+1)%vn.length,w=vm[vn[v]];return(0,Z.jsxs)(Hy,{open:e,onOpenChange:a=>{f(a),a||h("")},shouldFilter:!1,children:[(0,Z.jsx)(Hz,{placeholder:"Search files… ( > for actions )",value:g,onValueChange:h}),(0,Z.jsxs)(HA,{children:[s&&(0,Z.jsxs)(HC,{heading:"Actions",children:[(0,Z.jsxs)(HE,{value:"toggle-dark-mode",onSelect:()=>u(()=>n("dark"===m?"light":"dark")),children:["dark"===m?(0,Z.jsx)(Gg,{className:"mr-2 h-4 w-4"}):(0,Z.jsx)(Gf,{className:"mr-2 h-4 w-4"}),"dark"===m?"Switch to light mode":"Switch to dark mode"]}),(0,Z.jsxs)(HE,{value:"toggle-ai-panel",onSelect:()=>u(o),children:[(0,Z.jsx)(af,{className:"mr-2 h-4 w-4"}),"Toggle AI panel"]}),(0,Z.jsxs)(HE,{value:"toggle-sidebar",onSelect:()=>u(b),children:[(0,Z.jsx)(C0,{className:"mr-2 h-4 w-4"}),"Toggle sidebar"]}),(0,Z.jsxs)(HE,{value:"new-file",onSelect:()=>u(c),children:[(0,Z.jsx)(am,{className:"mr-2 h-4 w-4"}),"New file"]}),(0,Z.jsxs)(HE,{value:"copy-path",onSelect:()=>u(d),children:[(0,Z.jsx)(aj,{className:"mr-2 h-4 w-4"}),"Copy current file path"]}),(0,Z.jsxs)(HE,{value:"cycle-view-width",onSelect:()=>u(q),children:[(0,Z.jsx)(wW,{className:"mr-2 h-4 w-4"}),(0,Z.jsxs)("span",{children:["Change view width"," ",(0,Z.jsxs)("span",{className:"text-muted-foreground",children:["(",vm[p]," → ",w,")"]})]})]})]}),!s&&(0,Z.jsxs)(Z.Fragment,{children:[j&&(0,Z.jsx)("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:"Searching…"}),!j&&""!==t.trim()&&0===i.length&&(0,Z.jsx)(HB,{children:"No matches."}),i.length>0&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(HD,{}),(0,Z.jsx)(HC,{heading:k?"Top results (refine query for more)":"Results",children:i.map(b=>(0,Z.jsx)(HE,{value:b.path,onSelect:()=>{a(b.path),f(!1),h("")},children:(0,Z.jsxs)("div",{className:"flex min-w-0 flex-col gap-0.5",children:[(0,Z.jsx)("span",{className:"truncate font-mono text-xs",children:b.path}),b.snippet&&(0,Z.jsx)("span",{className:"truncate text-xs text-muted-foreground",children:(0,Z.jsx)(HH,{html:b.snippet})})]})},b.path))})]})]})]})]})}function HJ({onOpenFile:a}){let b=HG(a=>a.query),c=HG(a=>a.setQuery),d=HG(a=>a.results),e=HG(a=>a.loading),f=HG(a=>a.search),g=HG(a=>a.clear),[h,i]=(0,$.useState)(0),j=(0,$.useRef)(null);function k(b){let c=d[b];c&&(a(c.path),g())}return(0,$.useEffect)(()=>{i(0)},[d]),(0,$.useEffect)(()=>{let a=j.current?.querySelector(`[data-idx="${h}"]`);a?.scrollIntoView({block:"nearest"})},[h]),(0,Z.jsxs)("div",{className:"flex flex-col gap-1 px-2 py-1.5",children:[(0,Z.jsxs)("div",{className:"relative",children:[(0,Z.jsx)(Hw,{className:"pointer-events-none absolute left-2 top-1/2 h-3.5 w-3.5 -translate-y-1/2 opacity-50"}),(0,Z.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:b,onChange:a=>{c(a.target.value),f(a.target.value)},onKeyDown:a=>{"Escape"===a.key?g():0!==d.length&&("ArrowDown"===a.key?(a.preventDefault(),i(a=>(a+1)%d.length)):"ArrowUp"===a.key?(a.preventDefault(),i(a=>(a-1+d.length)%d.length)):"Enter"===a.key&&(a.preventDefault(),k(h)))}})]}),""!==b.trim()&&(0,Z.jsxs)("div",{ref:j,className:"max-h-64 overflow-y-auto rounded-sm border bg-popover",children:[e&&(0,Z.jsx)("div",{className:"px-2 py-1 text-xs text-muted-foreground",children:"Searching…"}),!e&&0===d.length&&(0,Z.jsx)("div",{className:"px-2 py-1 text-xs text-muted-foreground",children:"No matches"}),d.map((a,b)=>(0,Z.jsxs)("button",{type:"button","data-idx":b,onClick:()=>k(b),onMouseEnter:()=>i(b),className:`block w-full px-2 py-1 text-left ${b===h?"bg-accent":"hover:bg-accent"}`,children:[(0,Z.jsx)("div",{className:"truncate font-mono text-xs",children:a.path}),a.snippet&&(0,Z.jsx)("div",{className:"truncate text-[10px] text-muted-foreground",children:(0,Z.jsx)(HH,{html:a.snippet})})]},a.path))]})]})}function HK({className:a}){let b=vo(a=>a.width),c=vo(a=>a.setWidth);return(0,Z.jsxs)(FS,{children:[(0,Z.jsx)(FU,{asChild:!0,children:(0,Z.jsx)(bZ,{size:"sm",variant:"ghost",className:`h-7 w-7 p-0 ${a??""}`,title:`Content width: ${vm[b]}`,children:(0,Z.jsx)(wX,{className:"h-3.5 w-3.5"})})}),(0,Z.jsx)(F5,{align:"end",className:"w-36",children:vn.map(a=>(0,Z.jsxs)(F6,{onClick:()=>c(a),className:"flex items-center justify-between text-xs",children:[vm[a],a===b&&(0,Z.jsx)(ag,{className:"h-3.5 w-3.5"})]},a))})]})}function HL(a){return a.split(".").pop()?.toLowerCase()??""}function HM(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=HL(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 HN=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 HO(a){let b=HM(a,"file");return"editor"===b||"text"===b||HN.has(HL(a))}function HP(a){return["md","markdown"].includes(HL(a))}function HQ(a){return"image"===HM(a,"file")}async function HR(a){let b=await dO(`/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})):[]}function HS(a,b,c){return a.map(a=>a.path===b?c(a):a.children?{...a,children:HS(a.children,b,c)}:a)}a.s(["default",0,function(){let a;vp(a=>a.loadedAt),(0,$.useEffect)(()=>{vp.getState().load()},[]);let[b,c]=(0,$.useState)(null),[d,e]=(0,$.useState)(null),[f,g]=(0,$.useState)(()=>null),[h,i]=(0,$.useState)([]),[j,k]=(0,$.useState)(!1),[l,m]=(0,$.useState)(!1),[n,o]=(0,$.useState)(null),p=(0,$.useCallback)(async()=>{try{let a=await fetch("/api/system/workspaces");if(!a.ok)throw Error("Failed");let b=await a.json();if(i(b.workspaces),k(b.isAdmin),b.workspaces.length>0){c(!0);let a=new URLSearchParams(window.location.search).get("ws"),d=a?b.workspaces.find(b=>b.id===a):null,f=d??[...b.workspaces].sort((a,b)=>(b.lastOpenedAt??b.createdAt).localeCompare(a.lastOpenedAt??a.createdAt))[0];if(g(f.id),e(f.rootDir),!d){let a=new URL(location.href);a.searchParams.set("ws",f.id),history.replaceState(null,"",a.toString())}}else c(!1)}catch{c(!1)}},[]);(0,$.useEffect)(()=>{p()},[p]);let q=vi(a=>a.currentPath),r=GO(a=>a.recents),[s,t]=(0,$.useState)(!1),[u,v]=(0,$.useState)(!0),w=GP(a=>a.pins),x=(0,$.useRef)(null),y=u9(a=>a.activity),z=(0,$.useMemo)(()=>{let a=new Date(Date.now()-6e4).toISOString(),b=new Set;for(let c of y)c.at>=a&&c.path&&c.by?.startsWith("ai:")&&b.add(c.path);return b},[y]);(0,$.useEffect)(()=>{let a=()=>{u9.getState().loadActivity()};a();let b=setInterval(a,1e4);return()=>clearInterval(b)},[]),(0,$.useEffect)(()=>{GO.getState().loadForWorkspace(f),GP.getState().loadForWorkspace(f)},[f]);let A=(0,$.useRef)(null),B=(0,$.useRef)(!1),[C,D]=(0,$.useState)([]),[E,F]=(0,$.useState)(!1),[G,H]=(0,$.useState)(!1),I=(0,$.useRef)(!1),[J,K]=(0,$.useState)(!1),[L,M]=(0,$.useState)(!1),[N,O]=(0,$.useState)(null),P=(0,$.useRef)(null),Q=(0,$.useRef)(""),[R,S]=(0,$.useState)(null),[T,U]=(0,$.useState)(""),[V,W]=(0,$.useState)(null),[X,Y]=(0,$.useState)(null),[_,aa]=(0,$.useState)(""),[ab,ac]=(0,$.useState)(null),[ad,aJ]=(0,$.useState)(null),[aK,aL]=(0,$.useState)(!1),[aM,aN]=(0,$.useState)(null),[aO,aP]=(0,$.useState)(!1),[aQ,aR]=(0,$.useState)(0),[aS,aT]=(0,$.useState)(!1),[aU,aV]=(0,$.useState)(!1),[aW,aX]=(0,$.useState)(null),[aY,aZ]=(0,$.useState)(0),[a$,a_]=(0,$.useState)(!1),[a0,a1]=(0,$.useState)(!1),[a2,a3]=(0,$.useState)(""),[a4,a5]=(0,$.useState)(!1),[a6,a7]=(0,$.useState)(null),a8=(0,$.useRef)(null),[a9,ba]=(0,$.useState)(null),bb=(0,$.useRef)(null),bc=(0,$.useRef)(!1),bd=(0,$.useRef)(async()=>{});(0,$.useEffect)(()=>{E||I.current||(I.current=!0,H(!0),HR("").then(a=>{D(a),F(!0),H(!1)}).catch(()=>{I.current=!1,H(!1)}))},[E]);let be=(0,$.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 HR(d)});D(a=>{let b=a;for(let{prefix:a,children:d}of c)b=HS(b,a,a=>({...a,children:d,expanded:!0}));return b})},[]),bf=(0,$.useCallback)(async a=>{let b=await HR(a);""===a?D(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})}):D(c=>HS(c,a,a=>({...a,children:b,expanded:!0})))},[]),bg=(0,$.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(...bg(c.children)));return b},[]),bh=(0,$.useCallback)(async()=>{K(!0);try{let a=bg(C),b=await HR("");for(let c of(D(b),a)){let a=await HR(c);D(b=>HS(b,c,b=>({...b,children:a,expanded:!0})))}}finally{K(!1)}},[C,bg]),bi=(0,$.useCallback)(async()=>{if(aM){if(HP(aM.name)){a_(!0);try{await vi.getState().loadPage(aM.path)}finally{a_(!1)}return}if(["editor","text"].includes(HM(aM.name,aM.nodeType))||HO(aM.name)){a_(!0);try{let a=await dO(`/api/wiki/content?path=${encodeURIComponent(aM.path)}`);if(a.ok){let b=await a.json();aX(b.content),aZ(Number(a.headers.get("X-Wiki-Revision")??0))}}catch{}a_(!1)}}},[aM]);async function bj(a){if("dir"===a.type||"app"===a.type||"node-app"===a.type)if(a.expanded)D(b=>HS(b,a.path,a=>({...a,expanded:!1})));else if(void 0===a.children){D(b=>HS(b,a.path,a=>({...a,loading:!0})));let b=await HR(a.path);D(c=>HS(c,a.path,a=>({...a,loading:!1,children:b,expanded:!0})))}else D(b=>HS(b,a.path,a=>({...a,expanded:!0})))}async function bk(a){if("file"===a.type&&GO.getState().push({path:a.path,name:a.name},f),aN({path:a.path,name:a.name,nodeType:"app"===a.type?"app":"node-app"===a.type?"node-app":"file"}),a1(!1),a7(null),aX(null),aZ(0),"file"===a.type&&HP(a.name)){a_(!0);try{await vi.getState().loadPage(a.path)}finally{a_(!1)}return}if(["editor","text"].includes(HM(a.name,a.type))||HO(a.name)){a_(!0);try{let b=await dO(`/api/wiki/content?path=${encodeURIComponent(a.path)}`);if(b.ok){let a=await b.json();aX(a.content),aZ(Number(b.headers.get("X-Wiki-Revision")??0))}}catch{}a_(!1)}}(0,$.useEffect)(()=>{aM&&HP(aM.name)&&vi.getState().currentPath!==aM.path&&vi.getState().loadPage(aM.path)},[aM]),(0,$.useEffect)(()=>{bb.current=aM},[aM]),(0,$.useEffect)(()=>{bc.current=a0},[a0]),(0,$.useEffect)(()=>{bd.current=bi},[bi]),(0,$.useEffect)(()=>{if(!b)return;let a=new Map,c=new EventSource("/api/wiki/watch");return c.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),bf(c)},300)),"change"===e&&bb.current?.path===f&&!bc.current){let b=`__file__${f}`;a.has(b)&&clearTimeout(a.get(b)),a.set(b,setTimeout(()=>{a.delete(b),bd.current()},400))}},()=>{for(let b of(c.close(),a.values()))clearTimeout(b)}},[b,bf]),(0,$.useEffect)(()=>{aP(!1)},[]);let bl=(0,$.useCallback)(a=>{let b=a.split("/").pop()??a;be(a),bk({path:a,name:b,type:"file"})},[be]);(0,$.useEffect)(()=>{if(!q||aM&&aM.path===q)return;let a=q.split("/").pop()??q;bk({path:q,name:a,type:"file"})},[q]),(0,$.useEffect)(()=>{},[aM]),(0,$.useEffect)(()=>{if(B.current||!E)return;let a=A.current;if(!a){B.current=!0;return}B.current=!0,(async()=>{let b=a.split("/"),c=b[b.length-1],d=b.slice(0,-1).join("/"),e=(await HR(d)).find(b=>b.path===a);e&&(await be(a),bk({path:a,name:c,type:e.type,modifiedAt:e.modifiedAt}))})()},[E,be]);let bm=(0,$.useCallback)(async a=>{if(a===f)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()),aN(null),aX(null),a1(!1),D([]),F(!1),I.current=!1,vp.getState().invalidate();let c=h.find(b=>b.id===a);c&&e(c.rootDir),g(a)},[f,h]),bn=(0,$.useCallback)(async()=>{if(n)try{if(!(await fetch(`/api/system/workspaces/${n}`,{method:"DELETE"})).ok)throw Error("Failed");if(n===f){let a=h.filter(a=>a.id!==n);if(a.length>0){let b=[...a].sort((a,b)=>(b.lastOpenedAt??b.createdAt).localeCompare(a.lastOpenedAt??a.createdAt))[0];await bm(b.id)}else c(!1)}await p()}catch{}finally{o(null)}},[n,f,h,bm,p]);async function bo(){if(!aM)return;a5(!0),a7(null);let a=await dO("/api/wiki/content",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:aM.path,content:a2,baseRevision:aY})});if(a.ok){let b=await a.json();"number"==typeof b.revision&&aZ(b.revision),aX(a2),a1(!1)}else a7((await a.json()).error??"Save failed");a5(!1)}let bp=(0,$.useCallback)(async(a,b)=>{let c=Array.from(a);if(c.length){M(!0),O(null);try{for(let a of c){let c=new FormData;c.append("file",a),c.append("dir",b);let d=await dO("/api/wiki/upload",{method:"POST",body:c});if(!d.ok){let a=await d.json();O(a.error??"Upload failed"),vw(a.error??"Upload failed");break}}await bf(b)}catch{O("Upload failed.")}finally{M(!1),P.current&&(P.current.value="")}}},[bf]);function bq(a){Q.current=a,P.current?.click()}async function br(){let a=T.trim();if(!a||null===R)return;W(null);let b=R?`${R}/${a}`:a,c=await dO("/api/wiki/folder",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:b})});c.ok?(S(null),U(""),await bf(R),""!==R&&D(a=>HS(a,R,a=>({...a,expanded:!0})))):W((await c.json()).error??"Failed")}async function bs(){let a=_.trim();if(!a||null===X)return;ac(null);let b=a.includes(".")?a:`${a}.md`,c=X?`${X}/${b}`:b,d=await dO("/api/wiki/new-file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:c})});d.ok?(Y(null),aa(""),await bf(X),""!==X&&D(a=>HS(a,X,a=>({...a,expanded:!0}))),bk({path:c,name:b,type:"file",modifiedAt:new Date().toISOString()})):ac((await d.json()).error??"Failed")}function bt(a){navigator.clipboard.writeText(a),vv("Path copied")}function bu(a){let b=a.replace(/\.(md|markdown)$/i,"");navigator.clipboard.writeText(`[[${b}]]`),vv("Wiki link copied")}function bv(a){let b=new URL(location.href);b.searchParams.set("path",a),f&&b.searchParams.set("ws",f),navigator.clipboard.writeText(b.toString()),vv("URL copied")}async function bw(a){if(aM?.path===a&&null!==aW)return aW;if(vi.getState().currentPath===a)return vi.getState().content;let b=await dO(`/api/wiki/content?path=${encodeURIComponent(a)}`);if(!b.ok)throw Error("Cannot copy content");return(await b.json()).content}async function bx(a){try{let b=await bw(a);await navigator.clipboard.writeText(b),vv("Raw content copied")}catch{vw("Could not copy file content")}}async function by(a,b){try{let c=await bw(a);if(!HP(b)){await navigator.clipboard.writeText(c),vv("Content copied");return}let d=await un(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),vv("Formatted content copied")}catch{vw("Could not copy formatted content")}}function bz(a){return(0,Z.jsxs)(FS,{children:[(0,Z.jsx)(FU,{asChild:!0,children:(0,Z.jsxs)(bZ,{size:"sm",variant:"ghost",className:"h-7 gap-1.5 px-2 text-xs",title:"Copy path, wiki link, or URL",children:[(0,Z.jsx)(aj,{className:"h-3.5 w-3.5"}),"Copy",(0,Z.jsx)(ah,{className:"h-3 w-3 opacity-60"})]})}),(0,Z.jsxs)(F5,{align:"end",className:"w-44",children:[(0,Z.jsxs)(F6,{onClick:()=>bt(a.path),children:[(0,Z.jsx)(aj,{className:"mr-2 h-3.5 w-3.5"}),"Copy path"]}),HP(a.name)&&(0,Z.jsxs)(F6,{onClick:()=>bu(a.name),children:[(0,Z.jsx)(an,{className:"mr-2 h-3.5 w-3.5"}),"Copy wiki link"]}),(0,Z.jsx)(F8,{}),(0,Z.jsxs)(F6,{onClick:()=>bv(a.path),children:[(0,Z.jsx)(at,{className:"mr-2 h-3.5 w-3.5"}),"Copy URL"]}),HO(a.name)&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(F8,{}),(0,Z.jsxs)(F6,{onClick:()=>void bx(a.path),children:[(0,Z.jsx)(an,{className:"mr-2 h-3.5 w-3.5"}),"Copy raw content"]}),(0,Z.jsxs)(F6,{onClick:()=>void by(a.path,a.name),children:[(0,Z.jsx)(an,{className:"mr-2 h-3.5 w-3.5"}),"Copy formatted content"]})]})]})]})}async function bA(){ad&&(await dO("/api/wiki",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:ad})}),(aM?.path===ad||aM?.path.startsWith(`${ad}/`))&&(aN(null),aX(null)),D(a=>(function a(b,c){return b.filter(a=>a.path!==c).map(b=>b.children?{...b,children:a(b.children,c)}:b)})(a,ad)),aJ(null))}function bB(a,b,c){a.preventDefault(),a.stopPropagation();let d=a8.current;!d||d.path===b||b.startsWith(`${d.path}/`)||(a.dataTransfer.dropEffect="move",ba("root"===c?"":b))}async function bC(a,b){a.preventDefault(),a.stopPropagation(),ba(null);let c=a8.current;if(a8.current=null,!c||c.path===b||b.startsWith(`${c.path}/`))return;let d=b?`${b}/${c.name}`:c.name;if(d!==c.path&&(await dO("/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 bf(a),b!==a&&await bf(b),aM?.path===c.path&&aN({path:d,name:c.name,nodeType:aM.nodeType})}}let bD=aM?HM(aM.name,aM.nodeType):null,bE=vo(a=>a.width),bF=null===bD||"editor"===bD||"text"===bD||"source"===bD||"notebook"===bD||"fallback"===bD,bG=bF?vk[bE]:"";return(0,Z.jsxs)("div",{className:"flex h-screen gap-0 overflow-hidden bg-background",children:[null===b&&(0,Z.jsx)("div",{className:"flex-1 flex items-center justify-center",children:(0,Z.jsx)(au,{className:"h-5 w-5 animate-spin text-muted-foreground"})}),!1===b&&(0,Z.jsx)(Ge,{onSelect:a=>{let b=new URL(location.href);b.searchParams.set("ws",a),b.searchParams.delete("path"),history.replaceState(null,"",b.toString()),F(!1),I.current=!1,g(a),c(!0),p()}}),!0===b&&l&&(0,Z.jsxs)("div",{className:"flex-1 flex flex-col",children:[(0,Z.jsx)("div",{className:"flex items-center justify-end border-b px-3 py-2 bg-muted shrink-0",children:(0,Z.jsxs)(bZ,{size:"sm",variant:"ghost",className:"h-7 gap-1.5 text-xs",onClick:()=>m(!1),children:[(0,Z.jsx)(aI,{className:"h-3.5 w-3.5"})," Cancel"]})}),(0,Z.jsx)(Ge,{onSelect:a=>{m(!1),p(),bm(a)}})]}),!0===b&&!l&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(HI,{onOpenFile:bl,onToggleSidebar:()=>aT(a=>!a),onNewFile:()=>Y(""),onCopyPath:()=>{aM&&navigator.clipboard.writeText(aM.path)}}),!aS&&(0,Z.jsxs)(Gp,{className:"flex flex-col w-72 shrink-0 overflow-hidden rounded-none border-r border-l-0 border-t-0 border-b-0",children:[(0,Z.jsxs)("div",{className:"flex items-center justify-between gap-2 px-3 py-2 border-b bg-muted shrink-0",children:[(0,Z.jsxs)("div",{className:"flex min-w-0 items-center gap-1.5",children:[(0,Z.jsx)("img",{src:"/logo.svg",alt:"Wiki Viewer",className:"h-5 w-5 shrink-0"}),(0,Z.jsx)("span",{className:"truncate text-xs font-semibold tracking-tight",children:"Wiki Viewer"})]}),(0,Z.jsx)(bZ,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0 shrink-0",title:"Collapse sidebar",onClick:()=>aT(!0),children:(0,Z.jsx)(ax,{className:"h-3.5 w-3.5"})})]}),(0,Z.jsxs)("div",{className:"flex items-center justify-between gap-1 px-3 py-1.5 border-b bg-muted/50 shrink-0",children:[(0,Z.jsxs)(FS,{children:[(0,Z.jsx)(FU,{asChild:!0,children:(0,Z.jsxs)(bZ,{size:"sm",variant:"ghost",className:"h-7 gap-1 px-2 text-xs",disabled:L,children:[L?(0,Z.jsx)(au,{className:"h-3.5 w-3.5 animate-spin"}):(0,Z.jsx)(aB,{className:"h-3.5 w-3.5"}),"New",(0,Z.jsx)(ah,{className:"h-3 w-3 opacity-60"})]})}),(0,Z.jsxs)(F5,{align:"start",className:"w-44",children:[(0,Z.jsxs)(F6,{onClick:()=>{Y(""),aa(""),ac(null)},children:[(0,Z.jsx)(am,{className:"mr-2 h-3.5 w-3.5"}),"New file"]}),(0,Z.jsxs)(F6,{onClick:()=>{S(""),U(""),W(null)},children:[(0,Z.jsx)(aq,{className:"mr-2 h-3.5 w-3.5"}),"New folder"]}),(0,Z.jsxs)(F6,{onClick:()=>bq(""),disabled:L,children:[(0,Z.jsx)(aH,{className:"mr-2 h-3.5 w-3.5"}),"Upload"]})]})]}),(0,Z.jsxs)("div",{className:"flex items-center gap-0.5",children:[(0,Z.jsx)(bZ,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",title:"Refresh tree",onClick:bh,disabled:J,children:J?(0,Z.jsx)(au,{className:"h-3.5 w-3.5 animate-spin"}):(0,Z.jsx)(aC,{className:"h-3.5 w-3.5"})}),(0,Z.jsx)(Gi,{}),(0,Z.jsx)(bZ,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",title:"AI Agent panel",onClick:()=>u9.getState().toggle(),children:(0,Z.jsx)(af,{className:"h-3.5 w-3.5"})}),(0,Z.jsx)(bZ,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",title:"Settings",onClick:()=>aV(!0),children:(0,Z.jsx)(aD,{className:"h-3.5 w-3.5"})})]})]}),N&&(0,Z.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,Z.jsx)(ae,{className:"h-3.5 w-3.5 shrink-0"}),N]}),""===R&&(0,Z.jsxs)("div",{className:"flex items-center gap-1.5 px-2 py-1 border-b shrink-0",children:[(0,Z.jsx)(ao,{className:"h-4 w-4 shrink-0 text-warning"}),(0,Z.jsx)("input",{className:"flex-1 bg-transparent text-sm outline-none border-b border-border min-w-0",placeholder:"Folder name",value:T,onChange:a=>U(a.target.value),onKeyDown:a=>{"Enter"===a.key&&br(),"Escape"===a.key&&(S(null),U(""))}}),V&&(0,Z.jsx)("span",{className:"text-xs text-destructive",children:V}),(0,Z.jsx)(bZ,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:br,children:(0,Z.jsx)(ag,{className:"h-3 w-3"})}),(0,Z.jsx)(bZ,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:()=>{S(null),U("")},children:(0,Z.jsx)(aI,{className:"h-3 w-3"})})]}),""===X&&(0,Z.jsxs)("div",{className:"flex items-center gap-1.5 px-2 py-1 border-b shrink-0",children:[(0,Z.jsx)(an,{className:"h-4 w-4 shrink-0 text-accent"}),(0,Z.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:_,onChange:a=>aa(a.target.value),onKeyDown:a=>{"Enter"===a.key&&bs(),"Escape"===a.key&&(Y(null),aa(""))}}),ab&&(0,Z.jsx)("span",{className:"text-xs text-destructive",children:ab}),(0,Z.jsx)(bZ,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:bs,children:(0,Z.jsx)(ag,{className:"h-3 w-3"})}),(0,Z.jsx)(bZ,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:()=>{Y(null),aa("")},children:(0,Z.jsx)(aI,{className:"h-3 w-3"})})]}),(0,Z.jsx)("div",{className:"border-b",children:(0,Z.jsx)(HJ,{onOpenFile:bl})}),(0,Z.jsxs)("div",{ref:x,className:bX("flex-1 overflow-auto py-1",""===a9&&"ring-2 ring-inset ring-primary bg-primary/5"),onDragOver:a=>bB(a,"","root"),onDragLeave:a=>{a.currentTarget.contains(a.relatedTarget)||ba(null)},onDrop:a=>bC(a,""),children:[w.length>0&&(0,Z.jsxs)("div",{className:"border-b mb-1",children:[(0,Z.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:()=>t(a=>!a),children:[s?(0,Z.jsx)(ai,{className:"h-3 w-3"}):(0,Z.jsx)(ah,{className:"h-3 w-3"}),(0,Z.jsx)(aA,{className:"h-3 w-3"}),"Pinned",(0,Z.jsx)("span",{className:"ml-auto text-[9px] tabular-nums opacity-60",children:w.length})]}),!s&&w.map(a=>(0,Z.jsxs)("div",{role:"button",tabIndex:0,className:bX("group flex items-center gap-1.5 rounded-sm px-2 py-1 text-sm cursor-pointer transition-colors select-none",aM?.path===a.path?"bg-accent-soft text-foreground font-medium":"hover:bg-muted"),onClick:()=>void bk({path:a.path,name:a.name,type:a.type??"file",modifiedAt:""}),onKeyDown:b=>{("Enter"===b.key||" "===b.key)&&(b.preventDefault(),bk({path:a.path,name:a.name,type:a.type??"file",modifiedAt:""}))},children:[(0,Z.jsx)(aE,{className:"h-3 w-3 shrink-0 fill-current text-amber-400"}),(0,Z.jsx)("span",{className:"min-w-0 flex-1 truncate text-xs",children:a.name}),(0,Z.jsx)("span",{className:"max-w-[80px] truncate text-[10px] text-muted-foreground/60",children:a.path.split("/").slice(0,-1).join("/")}),(0,Z.jsx)("button",{type:"button",className:"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(),GP.getState().toggle({path:a.path,name:a.name},f)},children:(0,Z.jsx)(aI,{className:"h-3 w-3"})})]},a.path))]}),r.length>0&&(0,Z.jsxs)("div",{className:"border-b mb-1",children:[(0,Z.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:()=>v(a=>!a),children:[u?(0,Z.jsx)(ai,{className:"h-3 w-3"}):(0,Z.jsx)(ah,{className:"h-3 w-3"}),"Recent",(0,Z.jsx)("span",{className:"ml-auto text-[9px] tabular-nums opacity-60",children:r.length})]}),!u&&r.slice(0,8).map(a=>(0,Z.jsxs)("div",{role:"button",tabIndex:0,className:bX("flex items-center gap-1.5 rounded-sm px-2 py-1 text-sm cursor-pointer transition-colors select-none",aM?.path===a.path?"bg-accent-soft text-foreground font-medium":"hover:bg-muted"),onClick:()=>void bk({path:a.path,name:a.name,type:a.type??"file",modifiedAt:""}),onKeyDown:b=>{("Enter"===b.key||" "===b.key)&&(b.preventDefault(),bk({path:a.path,name:a.name,type:a.type??"file",modifiedAt:""}))},children:[(0,Z.jsx)(an,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),(0,Z.jsx)("span",{className:"flex-1 truncate text-xs",children:a.name}),(0,Z.jsx)("span",{className:"text-[10px] text-muted-foreground/60 truncate max-w-[80px]",children:a.path.split("/").slice(0,-1).join("/")})]},a.path))]}),G?(0,Z.jsx)("div",{className:"flex justify-center py-6",children:(0,Z.jsx)(au,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):0===C.length?(0,Z.jsxs)("div",{className:"flex flex-col items-center gap-3 px-4 py-8 text-center",children:[(0,Z.jsx)("div",{className:"rounded-full bg-muted p-3",children:(0,Z.jsx)(an,{className:"h-6 w-6 text-muted-foreground"})}),(0,Z.jsxs)("div",{className:"space-y-1",children:[(0,Z.jsx)("p",{className:"text-sm font-medium",children:"No files yet"}),(0,Z.jsx)("p",{className:"text-xs text-muted-foreground",children:"Upload files or add them to the configured directory"})]}),(0,Z.jsxs)(bZ,{size:"sm",variant:"outline",className:"w-full gap-1.5 max-w-[180px]",onClick:()=>bq(""),disabled:L,children:[L?(0,Z.jsx)(au,{className:"h-3.5 w-3.5 animate-spin"}):(0,Z.jsx)(aH,{className:"h-3.5 w-3.5"}),"Upload Files"]})]}):function a(b,c=0){return b.map(b=>{let d=w.some(a=>a.path===b.path);return(0,Z.jsxs)(Gw,{children:[(0,Z.jsx)(Gy,{asChild:!0,children:(0,Z.jsxs)("div",{children:[(0,Z.jsxs)("div",{role:"treeitem",tabIndex:0,draggable:!0,onKeyDown:a=>{if("Enter"===a.key||" "===a.key)a.preventDefault(),"dir"===b.type?bj(b):"app"===b.type||"node-app"===b.type?(bk(b),bj(b)):bk(b);else if("ArrowDown"===a.key){a.preventDefault();let b=x.current;if(!b)return;let c=Array.from(b.querySelectorAll('[role="treeitem"]')),d=c.indexOf(a.currentTarget);c[d+1]?.focus()}else if("ArrowUp"===a.key){a.preventDefault();let b=x.current;if(!b)return;let c=Array.from(b.querySelectorAll('[role="treeitem"]')),d=c.indexOf(a.currentTarget);c[d-1]?.focus()}else if("ArrowRight"===a.key){if(a.preventDefault(),"dir"===b.type||"app"===b.type||"node-app"===b.type)if(b.expanded){let b=x.current;if(!b)return;let c=Array.from(b.querySelectorAll('[role="treeitem"]')),d=c.indexOf(a.currentTarget);c[d+1]?.focus()}else bj(b)}else if("ArrowLeft"===a.key){if(a.preventDefault(),("dir"===b.type||"app"===b.type||"node-app"===b.type)&&b.expanded)bj(b);else if(c>0){let b=x.current;if(!b)return;let c=Array.from(b.querySelectorAll('[role="treeitem"]')),d=a.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:a=>{a8.current=b,a.dataTransfer.effectAllowed="move",a.dataTransfer.setData("text/plain",b.path)},onDragOver:a=>"dir"===b.type?bB(a,b.path,"dir"):a.preventDefault(),onDragLeave:()=>ba(null),onDrop:a=>"dir"===b.type?bC(a,b.path):a.preventDefault(),className:bX("flex items-center gap-1.5 rounded-sm px-2 py-1 text-sm cursor-pointer group transition-colors select-none",aM?.path===b.path?"bg-accent-soft text-foreground font-medium":"hover:bg-muted",a9===b.path&&"ring-2 ring-primary bg-primary-soft",b.name.startsWith(".")&&"opacity-40"),style:{paddingLeft:`${14*c+8}px`},onClick:()=>{"dir"===b.type?bj(b):"app"===b.type||"node-app"===b.type?(bk(b),bj(b)):bk(b)},children:["dir"===b.type||"app"===b.type||"node-app"===b.type?b.loading?(0,Z.jsx)(au,{className:"h-3.5 w-3.5 shrink-0 animate-spin text-muted-foreground"}):b.expanded?(0,Z.jsx)(ah,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}):(0,Z.jsx)(ai,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}):(0,Z.jsx)("span",{className:"w-3.5 shrink-0"}),"dir"===b.type?b.expanded?(0,Z.jsx)(ap,{className:bX("h-4 w-4 shrink-0",aM?.path!==b.path&&"text-warning")}):(0,Z.jsx)(ao,{className:bX("h-4 w-4 shrink-0",aM?.path!==b.path&&"text-warning")}):"app"===b.type?(0,Z.jsx)(ar,{className:bX("h-4 w-4 shrink-0",aM?.path!==b.path&&"text-foreground/70")}):"node-app"===b.type?(0,Z.jsx)(aF,{className:bX("h-4 w-4 shrink-0",aM?.path!==b.path&&"text-emerald-500")}):"html"===HM(b.name,"file")?(0,Z.jsx)(ar,{className:bX("h-4 w-4 shrink-0",aM?.path!==b.path&&"text-foreground/60")}):HQ(b.name)?(0,Z.jsx)(as,{className:bX("h-4 w-4 shrink-0",aM?.path!==b.path&&"text-sunshine-700")}):HO(b.name)?(0,Z.jsx)(an,{className:bX("h-4 w-4 shrink-0",aM?.path!==b.path&&"text-foreground/70")}):(0,Z.jsx)(al,{className:bX("h-4 w-4 shrink-0",aM?.path!==b.path&&"text-foreground/60")}),(0,Z.jsx)("span",{className:"min-w-0 flex-1 truncate",children:b.name}),z.has(b.path)&&(0,Z.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,Z.jsx)("div",{className:"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,Z.jsxs)(FS,{children:[(0,Z.jsx)(FU,{asChild:!0,children:(0,Z.jsx)(bZ,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0 text-muted-foreground hover:text-foreground",title:"File actions",children:(0,Z.jsx)(aw,{className:"h-3.5 w-3.5"})})}),(0,Z.jsxs)(F5,{align:"end",className:"w-48",children:[(0,Z.jsxs)(F6,{onClick:()=>bt(b.path),children:[(0,Z.jsx)(aj,{className:"mr-2 h-3.5 w-3.5"}),"Copy path"]}),HP(b.name)&&(0,Z.jsxs)(F6,{onClick:()=>bu(b.name),children:[(0,Z.jsx)(an,{className:"mr-2 h-3.5 w-3.5"}),"Copy wiki link"]}),(0,Z.jsxs)(F6,{onClick:()=>bv(b.path),children:[(0,Z.jsx)(at,{className:"mr-2 h-3.5 w-3.5"}),"Copy URL"]}),"file"===b.type&&HO(b.name)&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(F6,{onClick:()=>void bx(b.path),children:[(0,Z.jsx)(an,{className:"mr-2 h-3.5 w-3.5"}),"Copy raw content"]}),(0,Z.jsxs)(F6,{onClick:()=>void by(b.path,b.name),children:[(0,Z.jsx)(an,{className:"mr-2 h-3.5 w-3.5"}),"Copy formatted content"]})]}),(0,Z.jsx)(F8,{}),"dir"===b.type&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(F6,{onClick:async()=>{b.expanded||await bj(b),Y(b.path),aa(""),ac(null)},children:[(0,Z.jsx)(am,{className:"mr-2 h-3.5 w-3.5"}),"New file here"]}),(0,Z.jsxs)(F6,{onClick:()=>bq(b.path),children:[(0,Z.jsx)(aH,{className:"mr-2 h-3.5 w-3.5"}),"Upload here"]}),(0,Z.jsxs)(F6,{onClick:()=>{S(b.path),U(""),W(null)},children:[(0,Z.jsx)(aq,{className:"mr-2 h-3.5 w-3.5"}),"New subfolder"]}),(0,Z.jsx)(F8,{})]}),(0,Z.jsxs)(F6,{onClick:()=>{let a,c;return a=`/api/wiki/download?path=${encodeURIComponent(b.path)}`,void((c=document.createElement("a")).href=a,c.download="file"===b.type?b.name:`${b.name}.zip`,document.body.appendChild(c),c.click(),c.remove())},children:[(0,Z.jsx)(ak,{className:"mr-2 h-3.5 w-3.5"}),"file"===b.type?"Download":"Download as zip"]}),(0,Z.jsxs)(F6,{onClick:()=>GP.getState().toggle({path:b.path,name:b.name,type:"dir"===b.type?"file":b.type},f),children:[(0,Z.jsx)(aE,{className:bX("mr-2 h-3.5 w-3.5",d&&"fill-current text-amber-400")}),d?"Unpin":"Pin to top"]}),(0,Z.jsx)(F8,{}),(0,Z.jsxs)(F6,{className:"text-destructive focus:text-destructive",onClick:()=>{aJ(b.path),aL("file"!==b.type)},children:[(0,Z.jsx)(aG,{className:"mr-2 h-3.5 w-3.5"}),"Delete"]})]})]})})]}),R===b.path&&"dir"===b.type&&(0,Z.jsxs)("div",{className:"flex items-center gap-1.5 px-2 py-1",style:{paddingLeft:`${(c+1)*14+8}px`},children:[(0,Z.jsx)("span",{className:"w-3.5 shrink-0"}),(0,Z.jsx)(ao,{className:"h-4 w-4 shrink-0 text-warning"}),(0,Z.jsx)("input",{className:"flex-1 bg-transparent text-sm outline-none border-b border-border min-w-0",placeholder:"Folder name",value:T,onChange:a=>U(a.target.value),onKeyDown:a=>{"Enter"===a.key&&br(),"Escape"===a.key&&(S(null),U(""))}}),V&&(0,Z.jsx)("span",{className:"text-xs text-destructive",children:V}),(0,Z.jsx)(bZ,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:br,children:(0,Z.jsx)(ag,{className:"h-3 w-3"})}),(0,Z.jsx)(bZ,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:()=>{S(null),U("")},children:(0,Z.jsx)(aI,{className:"h-3 w-3"})})]}),X===b.path&&"dir"===b.type&&(0,Z.jsxs)("div",{className:"flex items-center gap-1.5 px-2 py-1",style:{paddingLeft:`${(c+1)*14+8}px`},children:[(0,Z.jsx)("span",{className:"w-3.5 shrink-0"}),(0,Z.jsx)(an,{className:"h-4 w-4 shrink-0 text-accent"}),(0,Z.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:_,onChange:a=>aa(a.target.value),onKeyDown:a=>{"Enter"===a.key&&bs(),"Escape"===a.key&&(Y(null),aa(""))}}),ab&&(0,Z.jsx)("span",{className:"text-xs text-destructive",children:ab}),(0,Z.jsx)(bZ,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:bs,children:(0,Z.jsx)(ag,{className:"h-3 w-3"})}),(0,Z.jsx)(bZ,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:()=>{Y(null),aa("")},children:(0,Z.jsx)(aI,{className:"h-3 w-3"})})]}),("dir"===b.type||"app"===b.type||"node-app"===b.type)&&b.expanded&&b.children&&b.children.length>0&&a(b.children,c+1),("dir"===b.type||"app"===b.type||"node-app"===b.type)&&b.expanded&&b.children?.length===0&&(0,Z.jsx)("div",{className:"text-xs text-muted-foreground/50 py-0.5",style:{paddingLeft:`${(c+1)*14+8+14+6+16+6}px`},children:"Empty"})]})}),(0,Z.jsxs)(GL,{children:[(0,Z.jsx)(GM,{onSelect:()=>bt(b.path),children:"Copy path"}),HP(b.name)&&(0,Z.jsx)(GM,{onSelect:()=>bu(b.name),children:"Copy wiki link"}),(0,Z.jsx)(GN,{}),(0,Z.jsx)(GM,{onSelect:()=>bv(b.path),children:"Copy URL"}),"file"===b.type&&HO(b.name)&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(GN,{}),(0,Z.jsx)(GM,{onSelect:()=>void bx(b.path),children:"Copy raw content"}),(0,Z.jsx)(GM,{onSelect:()=>void by(b.path,b.name),children:"Copy formatted content"})]})]})]},b.path)})}(C)]}),(0,Z.jsx)("div",{className:"border-t px-2 py-2 bg-muted shrink-0",children:(0,Z.jsxs)(FS,{children:[(0,Z.jsx)(FU,{asChild:!0,children:(0,Z.jsxs)(bZ,{size:"sm",variant:"ghost",className:"w-full h-auto justify-between gap-2 px-2 py-1.5 text-left",title:d??"",children:[(0,Z.jsxs)("span",{className:"flex flex-col min-w-0",children:[(0,Z.jsx)("span",{className:"truncate text-xs font-medium",children:h.find(a=>a.id===f)?.name??"Workspace"}),(0,Z.jsx)("span",{className:"truncate text-[10px] text-muted-foreground font-mono",children:d??""})]}),(0,Z.jsx)(ah,{className:"h-3.5 w-3.5 shrink-0 opacity-60"})]})}),(0,Z.jsxs)(F5,{align:"start",className:"w-60",children:[h.map(a=>(0,Z.jsxs)(F6,{onClick:()=>void bm(a.id),className:bX("gap-2",a.id===f&&"font-medium"),children:[a.id===f?(0,Z.jsx)(ag,{className:"h-3.5 w-3.5 shrink-0"}):(0,Z.jsx)("span",{className:"w-3.5 shrink-0"}),(0,Z.jsxs)("span",{className:"flex flex-col min-w-0 flex-1",children:[(0,Z.jsx)("span",{className:"truncate",children:a.name}),(0,Z.jsx)("span",{className:"truncate text-[10px] text-muted-foreground font-mono",children:a.rootDir})]}),j&&(0,Z.jsx)("button",{className:"ml-auto 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(),o(a.id)},children:(0,Z.jsx)(aG,{className:"h-3.5 w-3.5"})})]},a.id)),j&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(F8,{}),(0,Z.jsxs)(F6,{onClick:()=>m(!0),children:[(0,Z.jsx)(aq,{className:"mr-2 h-3.5 w-3.5"}),"Add workspace…"]})]})]})]})})]}),(0,Z.jsxs)("div",{className:"flex-1 flex flex-col min-w-0 relative",children:[aS&&(0,Z.jsx)(bZ,{size:"sm",variant:"ghost",className:"absolute left-0 top-1/2 -translate-y-1/2 z-10 h-7 w-7 p-0 rounded-full bg-background/50 backdrop-blur-xl backdrop-saturate-150 border border-white/[0.08] text-foreground/60 hover:text-foreground/90 hover:bg-background/70 shadow-[0_0_12px_rgba(0,0,0,0.15)] [transform:translate(-50%,-50%)_translateZ(0)]",title:"Show sidebar",onClick:()=>aT(!1),children:(0,Z.jsx)(ay,{className:"h-3.5 w-3.5"})}),aM?"node-app"===bD?(0,Z.jsx)(Ga,{path:aM.path,title:aM.name}):"app"===bD||"html"===bD?(a="html"===bD?`/api/assets/${aM.path}`:void 0,aO?(0,Z.jsx)(Eq,{path:aM.path,title:aM.name,src:a,fullscreen:!0,onExit:()=>aP(!1)}):(0,Z.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden min-w-0",children:[(0,Z.jsxs)("div",{className:"flex items-center justify-between px-4 py-2 border-b bg-muted shrink-0",children:[(0,Z.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,Z.jsx)(ar,{className:"h-4 w-4 shrink-0 text-accent"}),(0,Z.jsx)("span",{className:"text-sm font-normal truncate",title:aM.path,children:aM.path})]}),(0,Z.jsxs)("div",{className:"flex items-center gap-1 shrink-0",children:[bz(aM),"html"===bD&&!a0&&null!==aW&&(0,Z.jsx)(bZ,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",title:"Edit source",onClick:()=>{a1(!0),a3(aW),a7(null)},children:(0,Z.jsx)(az,{className:"h-3.5 w-3.5"})}),(0,Z.jsx)(bZ,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",title:"Refresh",onClick:()=>aR(a=>a+1),children:(0,Z.jsx)(aC,{className:"h-3.5 w-3.5"})}),(0,Z.jsxs)(bZ,{size:"sm",variant:"ghost",className:"h-7 gap-1.5 text-xs",onClick:()=>aP(!0),children:[(0,Z.jsx)(av,{className:"h-3.5 w-3.5"}),"Open fullscreen"]}),(0,Z.jsx)(bZ,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",onClick:()=>{aN(null),a1(!1)},children:(0,Z.jsx)(aI,{className:"h-3.5 w-3.5"})})]})]}),a0&&"html"===bD?(0,Z.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden min-h-0",children:[(0,Z.jsx)("textarea",{value:a2,onChange:a=>a3(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,Z.jsxs)("div",{className:"border-t px-4 py-2 flex items-center justify-end gap-2 bg-muted shrink-0",children:[a6&&(0,Z.jsx)("span",{className:"text-xs text-destructive mr-auto",children:a6}),(0,Z.jsx)(bZ,{size:"sm",variant:"ghost",onClick:()=>{a1(!1),a7(null)},children:"Cancel"}),(0,Z.jsxs)(bZ,{size:"sm",className:"gap-1",onClick:bo,disabled:a4,children:[a4&&(0,Z.jsx)(au,{className:"h-3 w-3 animate-spin"}),"Save"]})]})]}):(0,Z.jsx)(Eq,{path:aM.path,title:aM.name,src:a},aQ)]})):(0,Z.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden min-w-0",children:[(0,Z.jsxs)("div",{className:"flex items-center justify-between px-4 py-2 border-b bg-muted shrink-0",children:[(0,Z.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[HQ(aM.name)?(0,Z.jsx)(as,{className:"h-4 w-4 shrink-0 text-sunshine-700"}):HO(aM.name)?(0,Z.jsx)(an,{className:"h-4 w-4 shrink-0 text-accent"}):(0,Z.jsx)(al,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),(0,Z.jsx)("span",{className:"text-sm font-normal truncate",title:aM.path,children:aM.path})]}),(0,Z.jsxs)("div",{className:"flex items-center gap-1 shrink-0",children:[bz(aM),HO(aM.name)&&!a0&&(null!==aW||HP(aM.name))&&(0,Z.jsx)(bZ,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",onClick:()=>{a1(!0),a3(aW??""),a7(null),HP(aM.name)&&vi.getState().loadPage(aM.path)},children:(0,Z.jsx)(az,{className:"h-3.5 w-3.5"})}),HO(aM.name)&&!a0&&(null!==aW||HP(aM.name))&&(0,Z.jsx)(bZ,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",title:"Refresh",onClick:bi,disabled:a$,children:a$?(0,Z.jsx)(au,{className:"h-3.5 w-3.5 animate-spin"}):(0,Z.jsx)(aC,{className:"h-3.5 w-3.5"})}),bF&&(0,Z.jsx)(HK,{}),(0,Z.jsx)(bZ,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",onClick:()=>{aN(null),aX(null),a1(!1)},children:(0,Z.jsx)(aI,{className:"h-3.5 w-3.5"})})]})]}),a0?(0,Z.jsx)("div",{className:"flex-1 flex flex-col overflow-hidden min-h-0",children:HP(aM.name)?(0,Z.jsx)(Dl,{}):(0,Z.jsx)("textarea",{value:a2,onChange:a=>a3(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"})}):HP(aM.name)?(0,Z.jsx)("div",{className:"flex-1 flex flex-col overflow-hidden min-h-0",children:a$?(0,Z.jsx)("div",{className:"flex justify-center py-8",children:(0,Z.jsx)(au,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):(0,Z.jsx)(Dl,{mode:"viewing"})}):(0,Z.jsx)("div",{className:"flex-1 overflow-auto p-4 min-h-0",children:(0,Z.jsx)("div",{className:bX("mx-auto w-full",bG),children:a$?(0,Z.jsx)("div",{className:"flex justify-center py-8",children:(0,Z.jsx)(au,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):"csv"===bD?(0,Z.jsx)(dS,{path:aM.path,title:aM.name}):"pdf"===bD?(0,Z.jsx)(El,{path:aM.path,title:aM.name}):"mermaid"===bD?(0,Z.jsx)(Dt,{path:aM.path,title:aM.name}):"notebook"===bD?(0,Z.jsx)(Eg,{path:aM.path,title:aM.name}):"image"===bD?(0,Z.jsx)(Dn,{path:aM.path,title:aM.name}):"media"===bD?(0,Z.jsx)(Do,{path:aM.path,title:aM.name,type:["mp4","webm","mov","m4v"].includes(HL(aM.name))?"video":"audio"}):"docx"===bD?(0,Z.jsx)(Ei,{path:aM.path,title:aM.name}):"xlsx"===bD?(0,Z.jsx)(Ek,{path:aM.path,title:aM.name}):"pptx"===bD?(0,Z.jsx)(Ej,{path:aM.path,title:aM.name}):"source"===bD?(0,Z.jsx)(Ep,{path:aM.path,title:aM.name}):"fallback"===bD?(0,Z.jsx)(Dm,{path:aM.path,title:aM.name}):null!==aW?(0,Z.jsx)("pre",{className:"text-xs font-mono whitespace-pre-wrap break-words leading-relaxed",children:aW}):HO(aM.name)?(0,Z.jsx)("p",{className:"text-sm text-muted-foreground",children:"Could not load file."}):(0,Z.jsx)("p",{className:"text-sm text-muted-foreground",children:"Preview not available for this file type."})})}),a0&&!HP(aM.name)&&(0,Z.jsxs)("div",{className:"border-t px-4 py-2 flex items-center justify-end gap-2 bg-muted shrink-0",children:[a6&&(0,Z.jsx)("span",{className:"text-xs text-destructive mr-auto",children:a6}),(0,Z.jsx)(bZ,{size:"sm",variant:"ghost",onClick:()=>{a1(!1),a7(null)},children:"Cancel"}),(0,Z.jsxs)(bZ,{size:"sm",className:"gap-1",onClick:bo,disabled:a4,children:[a4&&(0,Z.jsx)(au,{className:"h-3 w-3 animate-spin"}),"Save"]})]})]}):(0,Z.jsx)("div",{className:"flex-1 flex flex-col items-center justify-center",children:(0,Z.jsxs)("div",{className:"flex flex-col items-center gap-2 text-center px-4",children:[(0,Z.jsx)(an,{className:"h-8 w-8 text-muted-foreground"}),(0,Z.jsx)("p",{className:"text-sm text-muted-foreground",children:"Select a file to view or edit"})]})})]}),(0,Z.jsx)(Go,{open:aU,onOpenChange:aV}),(0,Z.jsx)(G0,{currentPath:aM?.path}),(0,Z.jsx)("input",{ref:P,type:"file",multiple:!0,className:"hidden",onChange:a=>{a.target.files&&bp(a.target.files,Q.current)}}),(0,Z.jsx)(dL,{open:!!ad,onOpenChange:a=>{a||aJ(null)},title:aK?"Delete folder?":"Delete file?",description:aK?`"${ad?.split("/").pop()}" and all its contents will be permanently deleted.`:`"${ad?.split("/").pop()}" will be permanently removed.`,onConfirm:bA}),(0,Z.jsx)(dL,{open:!!n,onOpenChange:a=>{a||o(null)},title:"Delete workspace?",description:`"${h.find(a=>a.id===n)?.name??""}" will be removed from the workspace list. Files on disk are NOT deleted.`,onConfirm:bn})]})]},f??"none")}],240777)}];
|
|
130
130
|
|
|
131
131
|
//# sourceMappingURL=_0pqaawz._.js.map
|