(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[29604],{38316:(e,s,t)=>{Promise.resolve().then(t.bind(t,80520))},80520:(e,s,t)=>{"use strict";t.r(s),t.d(s,{default:()=>h});var n=t(95155),l=t(2125),c=t(73321),r=t(12115),a=t(3765),i=t(45160),o=t(89239),d=t(81477),u=t(42763),x=t(53972);function h(){(0,a.si)("CLAUDE.md");let{files:e,cwds:s,loading:t}=function(){let[e,s]=(0,r.useState)([]),[t,n]=(0,r.useState)([]),[l,c]=(0,r.useState)(!0),a=(0,r.useCallback)(()=>{c(!0),fetch("/api/claude-md").then(e=>e.json()).then(e=>{s(e.files),n(e.cwds)}).catch(()=>{s([]),n([])}).finally(()=>c(!1))},[]);return(0,r.useEffect)(()=>{a()},[a]),{files:e,cwds:t,loading:l,refresh:a}}(),i=(0,c.useRouter)(),[u,h]=(0,r.useState)(!1);function f(e){let s=new URLSearchParams({scope:e.scope});e.cwd&&s.set("cwd",e.cwd),i.push(`/claude-md/edit?${s}`)}let j=e.find(e=>"user"===e.scope),w=e.filter(e=>"user"!==e.scope),N=new Map;for(let e of w){if(!e.cwd)continue;let s=N.get(e.cwd)||[];s.push(e),N.set(e.cwd,s)}let C=new Set;for(let e of w)e.cwd&&e.exists&&C.add(e.cwd);let g=s.filter(e=>(N.get(e)||[]).filter(e=>e.exists).length<2);return(0,n.jsxs)("div",{className:"flex-1 min-h-0 overflow-y-auto p-4 space-y-4",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between",children:[(0,n.jsx)("div",{}),g.length>0&&(0,n.jsxs)(o.$,{size:"sm",onClick:()=>h(!0),children:[(0,n.jsx)(l.A,{className:"h-4 w-4 mr-1"}),"New"]})]}),t&&(0,n.jsx)("p",{className:"text-sm text-muted-foreground",children:"Loading..."}),!t&&j&&(0,n.jsxs)(d.Zp,{children:[(0,n.jsx)(d.aR,{children:(0,n.jsx)(d.ZB,{className:"text-base",children:"Global"})}),(0,n.jsx)(d.Wu,{className:"space-y-1",children:(0,n.jsx)(m,{file:j,onClick:()=>f(j)})})]}),!t&&Array.from(N.entries()).map(([e,s])=>{let t=s.filter(e=>e.exists);if(0===t.length)return null;let l=(0,x.uk)(e)||e;return(0,n.jsxs)(d.Zp,{children:[(0,n.jsx)(d.aR,{children:(0,n.jsx)(d.ZB,{className:"text-base",children:l})}),(0,n.jsx)(d.Wu,{className:"space-y-1",children:t.map(e=>(0,n.jsx)(m,{file:e,onClick:()=>f(e)},e.scope))})]},e)}),(0,n.jsx)(p,{open:u,onOpenChange:h,cwds:g,byCwd:N,onSelect:function(e,s){h(!1);let t=new URLSearchParams({scope:e,cwd:s});i.push(`/claude-md/edit?${t}`)}})]})}function m({file:e,onClick:s}){return(0,n.jsx)("button",{type:"button",className:"flex w-full items-center gap-3 rounded px-2 py-2 hover:bg-muted transition-colors text-left",onClick:s,children:(0,n.jsx)("div",{className:"flex-1 min-w-0",children:(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)("span",{className:"font-mono font-bold text-sm",children:function(e){switch(e){case"user":return"~/.claude/CLAUDE.md";case"project":return"CLAUDE.md";case"project-hidden":return".claude/CLAUDE.md"}}(e.scope)}),(0,n.jsx)(i.E,{variant:"secondary",className:"text-[10px]",children:"user"===e.scope?"Global":"Project"})]})})})}function p({open:e,onOpenChange:s,cwds:t,byCwd:l,onSelect:c}){let[a,i]=(0,r.useState)(null);function d(e){let s=l.get(e)||[],t=[];return s.some(e=>"project"===e.scope&&e.exists)||t.push("project"),s.some(e=>"project-hidden"===e.scope&&e.exists)||t.push("project-hidden"),t}return(0,n.jsx)(u.lG,{open:e,onOpenChange:e=>{s(e),e||i(null)},children:(0,n.jsxs)(u.Cf,{children:[(0,n.jsx)(u.c7,{children:(0,n.jsx)(u.L3,{children:a?"Choose type":"Choose project"})}),!a&&(0,n.jsx)("div",{className:"space-y-1 max-h-64 overflow-y-auto",children:t.map(e=>{let s=(0,x.uk)(e)||e;return(0,n.jsxs)("button",{className:"flex w-full items-center rounded px-3 py-2 text-sm hover:bg-muted transition-colors text-left",onClick:()=>{let s;1===(s=d(e)).length?c(s[0],e):i(e)},children:[(0,n.jsx)("span",{className:"font-mono",children:s}),(0,n.jsx)("span",{className:"ml-2 text-xs text-muted-foreground truncate",children:e})]},e)})}),a&&(0,n.jsx)("div",{className:"flex gap-2",children:d(a).map(e=>(0,n.jsx)(o.$,{variant:"outline",className:"flex-1",onClick:()=>c(e,a),children:"project"===e?"CLAUDE.md":".claude/CLAUDE.md"},e))})]})})}}},e=>{e.O(0,[989,11242,3765,28441,93794,77358],()=>e(e.s=38316)),_N_E=e.O()}]);