(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[32805],{54669:(e,t,r)=>{Promise.resolve().then(r.bind(r,55165))},55165:(e,t,r)=>{"use strict";r.r(t),r.d(t,{default:()=>h});var n=r(95155),s=r(64577),c=r(99314),a=r(81402),l=r(73321),o=r(12115),u=r(3765),d=r(98757),i=r(45160),f=r(89239);let m={user:{title:"~/.claude/CLAUDE.md",badge:"Global"},project:{title:"CLAUDE.md",badge:"Project"},"project-hidden":{title:".claude/CLAUDE.md",badge:"Project"}};function h(){let e=(0,l.useSearchParams)(),t=e.get("scope")||"user",r=e.get("cwd")||void 0,h=m[t];(0,u.si)("Edit CLAUDE.md");let[x,p]=(0,o.useState)(""),[g,v]=(0,o.useState)(""),[b,j]=(0,o.useState)(!0),[w,y]=(0,o.useState)(!1),[C,E]=(0,o.useState)(null),[N,k]=(0,o.useState)(!1),S=x!==g;(0,o.useEffect)(()=>{let e=new URLSearchParams({scope:t});r&&e.set("cwd",r),fetch(`/api/claude-md?${e}`).then(e=>e.json()).then(e=>{p(e.content),v(e.content)}).catch(()=>E("Failed to load")).finally(()=>j(!1))},[t,r]);let L=(0,o.useCallback)(async()=>{y(!0),E(null);try{if(!(await fetch("/api/claude-md",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({scope:t,cwd:r,content:x})})).ok)throw Error("Save failed");v(x),E("Saved")}catch{E("Failed to save")}finally{y(!1)}},[t,r,x]);return b?(0,n.jsx)("div",{className:"flex-1 min-h-0 p-4",children:(0,n.jsx)("p",{className:"text-sm text-muted-foreground",children:"Loading..."})}):(0,n.jsxs)("div",{className:"flex-1 min-h-0 flex flex-col p-4 gap-3",children:[(0,n.jsxs)("div",{className:"flex items-center gap-3",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[(0,n.jsx)("span",{className:"font-mono font-bold text-sm truncate",children:h.title}),(0,n.jsx)(i.E,{variant:"secondary",className:"shrink-0",children:h.badge})]}),(0,n.jsxs)("div",{className:"flex items-center gap-2 shrink-0",children:[C&&(0,n.jsx)("p",{className:`text-sm ${"Saved"===C?"text-green-600":"text-destructive"}`,children:C}),(0,n.jsxs)(f.$,{size:"sm",variant:"outline",onClick:()=>{let e=document.createElement("textarea");e.value=x,e.style.position="fixed",e.style.opacity="0",document.body.appendChild(e),e.select(),document.execCommand("copy"),document.body.removeChild(e),k(!0),setTimeout(()=>k(!1),1500)},children:[N?(0,n.jsx)(s.A,{className:"h-4 w-4 mr-1"}):(0,n.jsx)(c.A,{className:"h-4 w-4 mr-1"}),N?"Copied":"Copy"]}),(0,n.jsxs)(f.$,{size:"sm",onClick:L,disabled:w||!S,children:[(0,n.jsx)(a.A,{className:"h-4 w-4 mr-1"}),w?"Saving...":"Save"]})]})]}),(0,n.jsx)("div",{className:"flex-1 min-h-0",children:(0,n.jsx)(d.B,{value:x,onChange:e=>{p(e),E(null)},language:"markdown",onSave:L,className:"h-full [&_.cm-editor]:min-h-[400px]"})})]})}},98757:(e,t,r)=>{"use strict";r.d(t,{B:()=>h});var n=r(95155),s=r(13748),c=r(53649),a=r(27071),l=r(74059),o=r(89561),u=r(62465),d=r(12115);let i=o.Lz.theme({"&":{backgroundColor:"transparent"},".cm-gutters":{backgroundColor:"transparent",borderRight:"1px solid hsl(var(--border))"}});function f(){return!("u"<typeof document)&&document.documentElement.classList.contains("dark")}function m(e){switch(e){case"markdown":default:return(0,s.wD)();case"yaml":return(0,c.oQ)()}}function h({value:e,onChange:t,language:r,readOnly:s,className:c,onSave:x}){let p=(0,d.useRef)(null),g=(0,d.useRef)(null),v=(0,d.useRef)(new a.xx),b=(0,d.useRef)(new a.xx),j=(0,d.useRef)(new a.xx),w=(0,d.useRef)(t),y=(0,d.useRef)(x),C=(0,d.useRef)(e);return w.current=t,y.current=x,(0,d.useEffect)(()=>{if(!p.current)return;let e=a.$t.create({doc:C.current,extensions:[u.oQ,o.Lz.lineWrapping,v.current.of(f()?l.bM:i),b.current.of(m(r)),j.current.of(a.$t.readOnly.of(!!s)),o.w4.of([{key:"Mod-s",run:()=>(y.current?.(),!0)}]),o.Lz.updateListener.of(e=>{if(e.docChanged){let t=e.state.doc.toString();C.current=t,w.current(t)}})]}),t=new o.Lz({state:e,parent:p.current});return g.current=t,()=>{t.destroy(),g.current=null}},[]),(0,d.useEffect)(()=>{let t=g.current;t&&e!==C.current&&(C.current=e,t.dispatch({changes:{from:0,to:t.state.doc.length,insert:e}}))},[e]),(0,d.useEffect)(()=>{let e=g.current;if(!e)return;let t=new MutationObserver(()=>{e.dispatch({effects:v.current.reconfigure(f()?l.bM:i)})});return t.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>t.disconnect()},[]),(0,d.useEffect)(()=>{let e=g.current;e&&e.dispatch({effects:b.current.reconfigure(m(r))})},[r]),(0,d.useEffect)(()=>{let e=g.current;e&&e.dispatch({effects:j.current.reconfigure(a.$t.readOnly.of(!!s))})},[s]),(0,n.jsx)("div",{ref:p,className:`overflow-auto rounded-md border bg-background text-sm [&_.cm-editor]:min-h-[200px] [&_.cm-editor.cm-focused]:outline-none ${c||""}`})}}},e=>{e.O(0,[6079,989,11242,6802,3765,28441,93794,77358],()=>e(e.s=54669)),_N_E=e.O()}]);