@pi-chamber/web 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/README.md +1 -1
  2. package/dist/assets/{CommitSection-LewzHfDH.js → CommitSection-BQBmpPVE.js} +1 -1
  3. package/dist/assets/{DiagramEditor-BOIJVnh3.js → DiagramEditor-Cp22TGpq.js} +1 -1
  4. package/dist/assets/{DiagramView-CdNHezna.js → DiagramView-E4HJ4ZPU.js} +1 -1
  5. package/dist/assets/{DiffView-Cmw-RHIH.js → DiffView-d23o9CKP.js} +1 -1
  6. package/dist/assets/{FilesView-BODbL0Xm.js → FilesView-DIDB-xK7.js} +1 -1
  7. package/dist/assets/{GitView-DqYF-n_h.js → GitView-CkUONO1-.js} +3 -3
  8. package/dist/assets/{JsonTreeView-DzEjA1ht.js → JsonTreeView-By2oGMNK.js} +1 -1
  9. package/dist/assets/{MarkdownRendererImpl-Bfq0bOSM.js → MarkdownRendererImpl-DUghE55t.js} +1 -1
  10. package/dist/assets/{PatchDiff-CtVByTC4.js → PatchDiff-BjN6zMtK.js} +1 -1
  11. package/dist/assets/{PierreDiffViewer-Cwoewmiu.js → PierreDiffViewer-B38_7NnU.js} +1 -1
  12. package/dist/assets/{SessionSwitcherDropdown-DNjCJjzF.js → SessionSwitcherDropdown-NbVfnqQQ.js} +102 -102
  13. package/dist/assets/{SettingsView-BtLvHlj4.js → SettingsView-C2dCv0r7.js} +1 -1
  14. package/dist/assets/{SettingsWindow-CPd7JmJs.js → SettingsWindow-DsMhdX5H.js} +1 -1
  15. package/dist/assets/{ToolOutputDialog-CFFC5eI-.js → ToolOutputDialog-DVesARmI.js} +1 -1
  16. package/dist/assets/{ToolPartDiffPreview-yFq1DKSA.js → ToolPartDiffPreview-C2N_oIO-.js} +1 -1
  17. package/dist/assets/{VirtualizedFileDiff-CC5lTPJS.js → VirtualizedFileDiff-B7eVR6Pt.js} +1 -1
  18. package/dist/assets/{collapsible-D_555Hw_.js → collapsible-CPkWB1VR.js} +1 -1
  19. package/dist/assets/{computeVirtualFileMetrics-BcVuV0Ic.js → computeVirtualFileMetrics-BsZulefS.js} +1 -1
  20. package/dist/assets/{contextFileOpenGuard-BygvjHuE.js → contextFileOpenGuard-BmmlK5E3.js} +1 -1
  21. package/dist/assets/{index-DYrJXRkU.css → index-BZXqJcua.css} +1 -1
  22. package/dist/assets/{index-C9CLY-is.js → index-C84KrQoy.js} +1 -1
  23. package/dist/assets/{isDiffPlainText-Bher0UxW.js → isDiffPlainText-DsuyxFXo.js} +1 -1
  24. package/dist/assets/{isFilePlainText-EIViqOlI.js → isFilePlainText-CCYoe7us.js} +1 -1
  25. package/dist/assets/{main-1bIgjP48.js → main-ClYgYVm1.js} +2 -2
  26. package/dist/assets/{main-JDtt2bQS.js → main-CmrF_CaW.js} +4 -4
  27. package/dist/assets/{markdownCore-Bm4FxtK1.js → markdownCore-D2uqals1.js} +1 -1
  28. package/dist/assets/{miniChat-B7kKqKHH.js → miniChat-DmX9SjxM.js} +2 -2
  29. package/dist/assets/{mobile-DZPRce5z.js → mobile-C-PCxN62.js} +2 -2
  30. package/dist/assets/{renderElectronMiniChatApp-Dq0GdThJ.js → renderElectronMiniChatApp-BhXZtZlU.js} +1 -1
  31. package/dist/assets/{renderMobileApp-DlKnjObC.js → renderMobileApp-DUSTAPWw.js} +4 -4
  32. package/dist/assets/{runtimeSurface-B6sKTjo7.js → runtimeSurface-CouGjZ3A.js} +1 -1
  33. package/dist/assets/{useInlineCommentController-CSR_Ju0a.js → useInlineCommentController-buNJ3xB4.js} +1 -1
  34. package/dist/assets/{usePanelSlide-BkonU4LS.js → usePanelSlide-BRwyEEzi.js} +9 -9
  35. package/dist/assets/{useWindowTitle-rt_8xbd9.js → useWindowTitle-CnF4pKz0.js} +1 -1
  36. package/dist/assets/{vendor-codemirror-language-data-Be-zDX0u.js → vendor-codemirror-language-data-qBLdzwMc.js} +2 -2
  37. package/dist/assets/{web-components-DgFD1Jms.js → web-components-BhO08KaW.js} +1 -1
  38. package/dist/index.html +4 -4
  39. package/dist/mini-chat.html +3 -3
  40. package/dist/mobile.html +3 -3
  41. package/package.json +1 -1
  42. package/server/index.js +6 -1
  43. package/server/lib/pi/routes.js +13 -1
  44. package/server/lib/pi/routes.test.js +4 -0
  45. package/server/lib/pi/session-daemon/DOCUMENTATION.md +6 -5
  46. package/server/lib/pi/session-daemon/daemon-process.js +4 -1
  47. package/server/lib/pi/session-daemon/session-daemon.js +138 -20
  48. package/server/lib/pi/session-daemon/session-daemon.test.js +208 -0
  49. package/server/lib/pi/session-daemon/session-jsonl.js +258 -6
  50. package/server/lib/pi/session-daemon/session-jsonl.test.js +69 -1
  51. package/server/lib/pi/session-daemon/supervisor.js +41 -21
  52. package/server/lib/pi/session-daemon/supervisor.test.js +28 -0
  53. /package/dist/assets/{index-DQr8-8RF.js → index-BhXma4dv.js} +0 -0
package/README.md CHANGED
@@ -8,7 +8,7 @@ PiChamber's web server and browser UI for the Pi coding-agent runtime.
8
8
  pichamber serve --port 3000
9
9
  ```
10
10
 
11
- The server starts the local Pi session daemon, serves the browser UI, and exposes authenticated Pi routes under `/api/pi/*`.
11
+ The server starts warming the local Pi session daemon as soon as HTTP is listening, serves the browser UI, and exposes authenticated Pi routes under `/api/pi/*`. HTTP readiness does not wait for Pi provider/model initialization; early Pi requests share the supervisor's in-flight startup.
12
12
 
13
13
  ```bash
14
14
  pichamber serve --port 8080
@@ -1 +1 @@
1
- import{R as C,j as e}from"./vendor-react-DYyjh7Q0.js";import{f as z,T as y,y as _,B as c,I as a,z as v,aW as I}from"./SessionSwitcherDropdown-DNjCJjzF.js";import{u as H}from"./index-DQr8-8RF.js";const N=38,h=200,k=({value:t,onChange:o,placeholder:m,disabled:i=!1,hasTouchInput:r=!1,isMobile:u=!1})=>{const n=C.useRef(null),j=H(s=>s.inputSpellcheckEnabled);return C.useLayoutEffect(()=>{const s=n.current;if(!s)return;const l=document.activeElement===s,d=()=>{s.style.height=`${N}px`;const p=s.scrollHeight,x=Math.min(Math.max(p,N),h);s.style.height=`${x}px`,s.style.overflowY=p>h?"auto":"hidden",p>h&&!l&&(s.scrollTop=s.scrollHeight)};d();const f=window.requestAnimationFrame(d);return()=>{window.cancelAnimationFrame(f)}},[t]),e.jsx("textarea",{ref:n,value:t,onChange:s=>o(s.target.value),placeholder:m??"Commit message",rows:1,disabled:i,autoCorrect:r?"on":"off",autoCapitalize:r?"sentences":"off",spellCheck:u||j,className:z("w-full rounded-lg border border-border/60 bg-surface-elevated px-3 py-2 typography-ui-label text-foreground placeholder:text-muted-foreground","resize-none outline-none transition-[border-color,box-shadow] duration-150","focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]",i&&"opacity-50"),style:{minHeight:N,maxHeight:h}})},F=({highlights:t,onInsert:o})=>{if(t.length===0)return null;const m=()=>{o(t)};return e.jsxs("div",{className:"space-y-2 rounded-xl border border-border/60 bg-transparent px-3 py-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("p",{className:"typography-micro text-muted-foreground",children:"Highlights"}),e.jsxs(y,{children:[e.jsx(_,{asChild:!0,children:e.jsx(c,{variant:"ghost",size:"icon",className:"size-6",onClick:m,"aria-label":"Insert aria label",children:e.jsx(a,{name:"arrow-down",className:"size-4"})})}),e.jsx(v,{sideOffset:8,children:"Insert tooltip"})]})]}),e.jsx("ul",{className:"space-y-1",children:t.map((i,r)=>e.jsx("li",{className:"typography-meta text-foreground",children:i},`${i}-${r}`))})]})},q=({stagedCount:t,commitMessage:o,onCommitMessageChange:m,generatedHighlights:i,onInsertHighlights:r,onGenerateMessage:u,isGeneratingMessage:n,onCommit:j,onCommitAndPush:s,commitAction:l,hasPendingIndexMutation:d=!1,gitmojiEnabled:f,onOpenGitmojiPicker:p})=>{const x=t>0,b=o.trim()&&x&&l===null&&!d,{isMobile:g,hasTouchInput:w}=I();return e.jsxs("section",{className:"border-0 bg-transparent rounded-none",children:[e.jsxs("div",{className:"flex w-full items-baseline gap-2 px-0 pt-2 pb-1",children:[e.jsx("h3",{className:"typography-ui-header font-semibold text-foreground",children:"Commit"}),x?null:e.jsx("span",{className:"min-w-0 truncate typography-meta text-muted-foreground",children:"Stage files to enable commit."})]}),e.jsxs("div",{className:"flex flex-col gap-3 px-0 pt-1 pb-3",children:[e.jsx(F,{highlights:i,onInsert:r}),e.jsx(k,{value:o,onChange:m,placeholder:"Commit message",disabled:l!==null,hasTouchInput:w,isMobile:g}),f&&e.jsxs(c,{variant:"outline",size:"sm",onClick:p,className:"w-fit",type:"button",children:[e.jsx(a,{name:"emotion-happy",className:"size-4"}),"Add gitmoji"]}),e.jsxs("div",{className:"@container/commit-actions flex items-center gap-2 min-w-0",children:[e.jsxs(c,{variant:"outline",size:"sm",onClick:u,disabled:n||l!==null||d||t===0,type:"button","aria-label":"Generate commit message",className:"commit-actions__btn",children:[n?e.jsx(a,{name:"loader-4",className:"size-4 animate-spin"}):e.jsx(a,{name:"ai-generate-2",className:"size-4 text-primary"}),e.jsx("span",{className:"commit-actions__label",children:"Generate"})]}),e.jsx("div",{className:"flex-1"}),e.jsx(c,{size:"sm",variant:"outline",onClick:j,disabled:!b||n,className:"commit-actions__btn whitespace-nowrap","aria-label":"Commit aria label",children:l==="commit"?e.jsxs(e.Fragment,{children:[e.jsx(a,{name:"loader-4",className:"size-4 animate-spin"}),e.jsx("span",{className:"commit-actions__label",children:"Committing..."})]}):e.jsxs(e.Fragment,{children:[e.jsx(a,{name:"git-commit",className:"size-4"}),e.jsx("span",{className:"commit-actions__label",children:"Commit"})]})}),g?e.jsxs(y,{children:[e.jsx(_,{asChild:!0,children:e.jsx(c,{variant:"default",size:"sm",onClick:()=>s(),disabled:!b||n,className:"h-7 w-7 p-0","aria-label":"Commit and sync",children:l==="commitAndPush"?e.jsx(a,{name:"loader-4",className:"size-4 animate-spin"}):e.jsx(a,{name:"arrow-up",className:"size-3.5"})})}),e.jsx(v,{side:"top",children:e.jsx("p",{children:"Commit & sync"})})]}):e.jsx(c,{size:"sm",variant:"default",onClick:()=>s(),disabled:!b||n,className:"commit-actions__btn","aria-label":"Commit and sync",children:l==="commitAndPush"?e.jsxs(e.Fragment,{children:[e.jsx(a,{name:"loader-4",className:"size-4 animate-spin"}),e.jsx("span",{className:"commit-actions__label commit-actions__label--push",children:"Syncing..."})]}):e.jsxs(e.Fragment,{children:[e.jsx(a,{name:"arrow-up",className:"size-3.5"}),e.jsx("span",{className:"commit-actions__label commit-actions__label--push",children:"Commit & sync"})]})})]})]})]})};export{q as C};
1
+ import{R as C,j as e}from"./vendor-react-DYyjh7Q0.js";import{f as z,T as y,y as _,B as c,I as a,z as v,aW as I}from"./SessionSwitcherDropdown-NbVfnqQQ.js";import{u as H}from"./index-BhXma4dv.js";const N=38,h=200,k=({value:t,onChange:o,placeholder:m,disabled:i=!1,hasTouchInput:r=!1,isMobile:u=!1})=>{const n=C.useRef(null),j=H(s=>s.inputSpellcheckEnabled);return C.useLayoutEffect(()=>{const s=n.current;if(!s)return;const l=document.activeElement===s,d=()=>{s.style.height=`${N}px`;const p=s.scrollHeight,x=Math.min(Math.max(p,N),h);s.style.height=`${x}px`,s.style.overflowY=p>h?"auto":"hidden",p>h&&!l&&(s.scrollTop=s.scrollHeight)};d();const f=window.requestAnimationFrame(d);return()=>{window.cancelAnimationFrame(f)}},[t]),e.jsx("textarea",{ref:n,value:t,onChange:s=>o(s.target.value),placeholder:m??"Commit message",rows:1,disabled:i,autoCorrect:r?"on":"off",autoCapitalize:r?"sentences":"off",spellCheck:u||j,className:z("w-full rounded-lg border border-border/60 bg-surface-elevated px-3 py-2 typography-ui-label text-foreground placeholder:text-muted-foreground","resize-none outline-none transition-[border-color,box-shadow] duration-150","focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]",i&&"opacity-50"),style:{minHeight:N,maxHeight:h}})},F=({highlights:t,onInsert:o})=>{if(t.length===0)return null;const m=()=>{o(t)};return e.jsxs("div",{className:"space-y-2 rounded-xl border border-border/60 bg-transparent px-3 py-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("p",{className:"typography-micro text-muted-foreground",children:"Highlights"}),e.jsxs(y,{children:[e.jsx(_,{asChild:!0,children:e.jsx(c,{variant:"ghost",size:"icon",className:"size-6",onClick:m,"aria-label":"Insert aria label",children:e.jsx(a,{name:"arrow-down",className:"size-4"})})}),e.jsx(v,{sideOffset:8,children:"Insert tooltip"})]})]}),e.jsx("ul",{className:"space-y-1",children:t.map((i,r)=>e.jsx("li",{className:"typography-meta text-foreground",children:i},`${i}-${r}`))})]})},q=({stagedCount:t,commitMessage:o,onCommitMessageChange:m,generatedHighlights:i,onInsertHighlights:r,onGenerateMessage:u,isGeneratingMessage:n,onCommit:j,onCommitAndPush:s,commitAction:l,hasPendingIndexMutation:d=!1,gitmojiEnabled:f,onOpenGitmojiPicker:p})=>{const x=t>0,b=o.trim()&&x&&l===null&&!d,{isMobile:g,hasTouchInput:w}=I();return e.jsxs("section",{className:"border-0 bg-transparent rounded-none",children:[e.jsxs("div",{className:"flex w-full items-baseline gap-2 px-0 pt-2 pb-1",children:[e.jsx("h3",{className:"typography-ui-header font-semibold text-foreground",children:"Commit"}),x?null:e.jsx("span",{className:"min-w-0 truncate typography-meta text-muted-foreground",children:"Stage files to enable commit."})]}),e.jsxs("div",{className:"flex flex-col gap-3 px-0 pt-1 pb-3",children:[e.jsx(F,{highlights:i,onInsert:r}),e.jsx(k,{value:o,onChange:m,placeholder:"Commit message",disabled:l!==null,hasTouchInput:w,isMobile:g}),f&&e.jsxs(c,{variant:"outline",size:"sm",onClick:p,className:"w-fit",type:"button",children:[e.jsx(a,{name:"emotion-happy",className:"size-4"}),"Add gitmoji"]}),e.jsxs("div",{className:"@container/commit-actions flex items-center gap-2 min-w-0",children:[e.jsxs(c,{variant:"outline",size:"sm",onClick:u,disabled:n||l!==null||d||t===0,type:"button","aria-label":"Generate commit message",className:"commit-actions__btn",children:[n?e.jsx(a,{name:"loader-4",className:"size-4 animate-spin"}):e.jsx(a,{name:"ai-generate-2",className:"size-4 text-primary"}),e.jsx("span",{className:"commit-actions__label",children:"Generate"})]}),e.jsx("div",{className:"flex-1"}),e.jsx(c,{size:"sm",variant:"outline",onClick:j,disabled:!b||n,className:"commit-actions__btn whitespace-nowrap","aria-label":"Commit aria label",children:l==="commit"?e.jsxs(e.Fragment,{children:[e.jsx(a,{name:"loader-4",className:"size-4 animate-spin"}),e.jsx("span",{className:"commit-actions__label",children:"Committing..."})]}):e.jsxs(e.Fragment,{children:[e.jsx(a,{name:"git-commit",className:"size-4"}),e.jsx("span",{className:"commit-actions__label",children:"Commit"})]})}),g?e.jsxs(y,{children:[e.jsx(_,{asChild:!0,children:e.jsx(c,{variant:"default",size:"sm",onClick:()=>s(),disabled:!b||n,className:"h-7 w-7 p-0","aria-label":"Commit and sync",children:l==="commitAndPush"?e.jsx(a,{name:"loader-4",className:"size-4 animate-spin"}):e.jsx(a,{name:"arrow-up",className:"size-3.5"})})}),e.jsx(v,{side:"top",children:e.jsx("p",{children:"Commit & sync"})})]}):e.jsx(c,{size:"sm",variant:"default",onClick:()=>s(),disabled:!b||n,className:"commit-actions__btn","aria-label":"Commit and sync",children:l==="commitAndPush"?e.jsxs(e.Fragment,{children:[e.jsx(a,{name:"loader-4",className:"size-4 animate-spin"}),e.jsx("span",{className:"commit-actions__label commit-actions__label--push",children:"Syncing..."})]}):e.jsxs(e.Fragment,{children:[e.jsx(a,{name:"arrow-up",className:"size-3.5"}),e.jsx("span",{className:"commit-actions__label commit-actions__label--push",children:"Commit & sync"})]})})]})]})]})};export{q as C};
@@ -1 +1 @@
1
- import{R as e,j as h}from"./vendor-react-DYyjh7Q0.js";import{D as E}from"./vendor-react-drawio-Boqanm0j.js";import{f as x}from"./SessionSwitcherDropdown-DNjCJjzF.js";const D='<mxfile><diagram id="new" name="Page-1"><mxGraphModel dx="0" dy="0" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="827" pageHeight="1169" math="0" shadow="0"><root><mxCell id="0"/><mxCell id="1" parent="0"/></root></mxGraphModel></diagram></mxfile>';function g(){if(typeof document>"u")return!1;const o=document.documentElement.getAttribute("data-theme");return o==="dark"||!o&&window.matchMedia("(prefers-color-scheme: dark)").matches}const X=e.forwardRef(function({xml:t,readOnly:a,className:R,onChange:c},v){const s=e.useRef(t),i=e.useRef(null),m=e.useRef(!1),[n,k]=e.useState(g),u=e.useRef(t),d=e.useRef(t);d.current!==t&&(d.current=t,u.current=t,s.current=t);const f=e.useRef(n);f.current!==n&&(f.current=n,u.current=s.current);const l=e.useRef(null);e.useEffect(()=>{const r=()=>k(g());r();const p=new MutationObserver(r);return p.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]}),()=>p.disconnect()},[]),e.useEffect(()=>{const r=setTimeout(()=>{l.current?.querySelector(".diagrams-iframe")?.focus()},600);return()=>clearTimeout(r)},[]),e.useImperativeHandle(v,()=>({getXml:()=>s.current}));const b=e.useCallback(()=>{!t&&!m.current&&(m.current=!0,setTimeout(()=>{i.current?.template({})},500))},[t]),w=e.useCallback(r=>{s.current=r.xml,c?.(r.xml)},[c]);return h.jsx("div",{ref:l,className:x("h-full w-full",R),children:h.jsx(E,{ref:i,xml:u.current||D,autosave:!0,urlParameters:{ui:a?"simple":n?"dark":"kennedy",spin:!0,libraries:!a,chrome:a,nav:a,layers:a,noSaveBtn:!0,noExitBtn:!0,saveAndExit:!1},onLoad:b,onAutoSave:w},n?"dark":"light")})});export{X as D};
1
+ import{R as e,j as h}from"./vendor-react-DYyjh7Q0.js";import{D as E}from"./vendor-react-drawio-Boqanm0j.js";import{f as x}from"./SessionSwitcherDropdown-NbVfnqQQ.js";const D='<mxfile><diagram id="new" name="Page-1"><mxGraphModel dx="0" dy="0" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="827" pageHeight="1169" math="0" shadow="0"><root><mxCell id="0"/><mxCell id="1" parent="0"/></root></mxGraphModel></diagram></mxfile>';function g(){if(typeof document>"u")return!1;const o=document.documentElement.getAttribute("data-theme");return o==="dark"||!o&&window.matchMedia("(prefers-color-scheme: dark)").matches}const X=e.forwardRef(function({xml:t,readOnly:a,className:R,onChange:c},v){const s=e.useRef(t),i=e.useRef(null),m=e.useRef(!1),[n,k]=e.useState(g),u=e.useRef(t),d=e.useRef(t);d.current!==t&&(d.current=t,u.current=t,s.current=t);const f=e.useRef(n);f.current!==n&&(f.current=n,u.current=s.current);const l=e.useRef(null);e.useEffect(()=>{const r=()=>k(g());r();const p=new MutationObserver(r);return p.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]}),()=>p.disconnect()},[]),e.useEffect(()=>{const r=setTimeout(()=>{l.current?.querySelector(".diagrams-iframe")?.focus()},600);return()=>clearTimeout(r)},[]),e.useImperativeHandle(v,()=>({getXml:()=>s.current}));const b=e.useCallback(()=>{!t&&!m.current&&(m.current=!0,setTimeout(()=>{i.current?.template({})},500))},[t]),w=e.useCallback(r=>{s.current=r.xml,c?.(r.xml)},[c]);return h.jsx("div",{ref:l,className:x("h-full w-full",R),children:h.jsx(E,{ref:i,xml:u.current||D,autosave:!0,urlParameters:{ui:a?"simple":n?"dark":"kennedy",spin:!0,libraries:!a,chrome:a,nav:a,layers:a,noSaveBtn:!0,noExitBtn:!0,saveAndExit:!1},onLoad:b,onAutoSave:w},n?"dark":"light")})});export{X as D};
@@ -1 +1 @@
1
- import{R as r,j as t}from"./vendor-react-DYyjh7Q0.js";import{u as a}from"./index-DQr8-8RF.js";import{K as v,I as m}from"./SessionSwitcherDropdown-DNjCJjzF.js";import{D as j}from"./DiagramEditor-BOIJVnh3.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-zustand-CnsBKjP5.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./runtimeSurface-B6sKTjo7.js";import"./vendor-dnd-kit-core-GipZW2tY.js";import"./vendor-dnd-kit-utilities-CrOcp0Bp.js";import"./vendor-dnd-kit-accessibility-Cv52zwWT.js";import"./vendor-dnd-kit-sortable-Ct2QxIHb.js";import"./vendor-base-ui-DwfTg5wD.js";import"./vendor-floating-ui-utils-BzXdqYpP.js";import"./vendor-floating-ui-react-dom-sVFnuruh.js";import"./vendor-floating-ui-dom-Bkw82kL9.js";import"./vendor-floating-ui-core-CXmKXOXc.js";import"./vendor-use-sync-external-store-B7OScDIw.js";import"./vendor-cmdk-BCEUzcHE.js";import"./vendor-radix-ui-react-dialog-jX3Dld8c.js";import"./vendor-radix-ui-primitive-Dc_FVRD7.js";import"./vendor-radix-ui-react-compose-refs-D1GnwnP9.js";import"./vendor-radix-ui-react-context-CM4yFQ2I.js";import"./vendor-radix-ui-react-id-BcxRjnbX.js";import"./vendor-radix-ui-react-use-layout-effect-0fyGwS2_.js";import"./vendor-radix-ui-react-use-controllable-state-C_ecoh35.js";import"./vendor-radix-ui-react-dismissable-layer-M7LsH3yL.js";import"./vendor-radix-ui-react-primitive-CfpW6_IT.js";import"./vendor-radix-ui-react-slot-BxUc3Pvz.js";import"./vendor-radix-ui-react-use-callback-ref-UKEWHtoP.js";import"./vendor-radix-ui-react-use-escape-keydown-Co13lHGj.js";import"./vendor-radix-ui-react-focus-scope-C2K7lNPv.js";import"./vendor-radix-ui-react-portal-xlJWBfDg.js";import"./vendor-radix-ui-react-presence-Btn-Dp7L.js";import"./vendor-radix-ui-react-focus-guards-D5MZ0nQs.js";import"./vendor-react-remove-scroll-CfeMe0DL.js";import"./vendor-tslib-De9GV7Vy.js";import"./vendor-react-remove-scroll-bar-C9YRs2nU.js";import"./vendor-react-style-singleton-B1H4bWSG.js";import"./vendor-get-nonce-C-Z93AgS.js";import"./vendor-use-sidecar-C-AuTczP.js";import"./vendor-use-callback-ref-CJB0R85I.js";import"./vendor-aria-hidden-DvXkyWUv.js";import"./vendor-codemirror-language-BuDklWi8.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-codemirror-state-Wdz6Qsow.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-codemirror-view-pXtfpqbT.js";import"./vendor-style-mod-NZ5MEPvj.js";import"./vendor-w3c-keyname-Vcq4gwWv.js";import"./vendor-crelt-C8TCjufn.js";import"./vendor-lezer-highlight-CDMHUZ74.js";import"./vendor-codemirror-lang-javascript-CrbeaEAU.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-codemirror-autocomplete-3xMyV7a2.js";import"./vendor-codemirror-lang-json-BTvAjwkJ.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-C4jEScp7.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-C1Svvdey.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-BloD9GN-.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-Be-zDX0u.js";import"./vendor-codemirror-lang-python-CR2g6ukK.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-codemirror-commands-Bzf12ODH.js";import"./vendor-class-variance-authority-5VPnzWs2.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-tanstack-react-virtual-IrbCBGJ4.js";import"./vendor-tanstack-virtual-core-Dubg10g5.js";import"./vendor-framer-motion-DJASDzNt.js";import"./vendor-motion-dom-DJLgZh4Q.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./vendor-sonner-dWA7qvjr.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./vendor-react-drawio-Boqanm0j.js";function Jt(){const{files:o}=v(),[e,d]=r.useState(null),[s,p]=r.useState(""),[x,n]=r.useState(!0),l=r.useRef(null),c=a(i=>i.pendingDiagramFile),u=r.useCallback(async i=>{n(!0),d(i);try{const f=await o?.readFile?.(i);f&&p(f.content)}catch{p("")}finally{n(!1)}},[o]);r.useEffect(()=>{if(!c)return;const i=a.getState().consumePendingDiagramFile();i&&u(i)},[u,c]);const g=r.useCallback(async()=>{const i=l.current?.getXml();e&&o?.writeFile&&i&&i!==s&&(await o.writeFile(e,i),p(i))},[e,o,s]),h=e?e.split("/").pop()||e:"";return e?x?t.jsx("div",{className:"flex h-full items-center justify-center p-3",children:t.jsx(m,{name:"loader-4",className:"size-4 animate-spin"})}):t.jsxs("div",{className:"flex h-full flex-col",children:[t.jsxs("div",{className:"flex items-center gap-2 border-b border-border/30 px-3 py-1.5",children:[t.jsx(m,{name:"file",className:"size-4 shrink-0 text-muted-foreground"}),t.jsx("span",{className:"typography-ui text-muted-foreground truncate flex-1",children:h}),t.jsx("button",{type:"button",onClick:()=>{g()},className:"size-6 flex items-center justify-center rounded-md text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",title:"Save diagram",children:t.jsx(m,{name:"save-3",className:"size-4"})}),t.jsx("button",{type:"button",onClick:()=>a.getState().setActiveMainTab("chat"),className:"size-6 flex items-center justify-center rounded-md text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",title:"Close diagram view",children:t.jsx(m,{name:"close",className:"size-4"})})]}),t.jsx("div",{className:"flex-1 min-h-0",children:t.jsx(j,{ref:l,xml:s,className:"h-full"})})]}):t.jsx("div",{className:"flex h-full items-center justify-center p-3",children:t.jsx("div",{className:"typography-ui text-muted-foreground",children:"Pick a file from the tree."})})}export{Jt as DiagramView};
1
+ import{R as r,j as t}from"./vendor-react-DYyjh7Q0.js";import{u as a}from"./index-BhXma4dv.js";import{K as v,I as m}from"./SessionSwitcherDropdown-NbVfnqQQ.js";import{D as j}from"./DiagramEditor-Cp22TGpq.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-zustand-CnsBKjP5.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./runtimeSurface-CouGjZ3A.js";import"./vendor-dnd-kit-core-GipZW2tY.js";import"./vendor-dnd-kit-utilities-CrOcp0Bp.js";import"./vendor-dnd-kit-accessibility-Cv52zwWT.js";import"./vendor-dnd-kit-sortable-Ct2QxIHb.js";import"./vendor-base-ui-DwfTg5wD.js";import"./vendor-floating-ui-utils-BzXdqYpP.js";import"./vendor-floating-ui-react-dom-sVFnuruh.js";import"./vendor-floating-ui-dom-Bkw82kL9.js";import"./vendor-floating-ui-core-CXmKXOXc.js";import"./vendor-use-sync-external-store-B7OScDIw.js";import"./vendor-cmdk-BCEUzcHE.js";import"./vendor-radix-ui-react-dialog-jX3Dld8c.js";import"./vendor-radix-ui-primitive-Dc_FVRD7.js";import"./vendor-radix-ui-react-compose-refs-D1GnwnP9.js";import"./vendor-radix-ui-react-context-CM4yFQ2I.js";import"./vendor-radix-ui-react-id-BcxRjnbX.js";import"./vendor-radix-ui-react-use-layout-effect-0fyGwS2_.js";import"./vendor-radix-ui-react-use-controllable-state-C_ecoh35.js";import"./vendor-radix-ui-react-dismissable-layer-M7LsH3yL.js";import"./vendor-radix-ui-react-primitive-CfpW6_IT.js";import"./vendor-radix-ui-react-slot-BxUc3Pvz.js";import"./vendor-radix-ui-react-use-callback-ref-UKEWHtoP.js";import"./vendor-radix-ui-react-use-escape-keydown-Co13lHGj.js";import"./vendor-radix-ui-react-focus-scope-C2K7lNPv.js";import"./vendor-radix-ui-react-portal-xlJWBfDg.js";import"./vendor-radix-ui-react-presence-Btn-Dp7L.js";import"./vendor-radix-ui-react-focus-guards-D5MZ0nQs.js";import"./vendor-react-remove-scroll-CfeMe0DL.js";import"./vendor-tslib-De9GV7Vy.js";import"./vendor-react-remove-scroll-bar-C9YRs2nU.js";import"./vendor-react-style-singleton-B1H4bWSG.js";import"./vendor-get-nonce-C-Z93AgS.js";import"./vendor-use-sidecar-C-AuTczP.js";import"./vendor-use-callback-ref-CJB0R85I.js";import"./vendor-aria-hidden-DvXkyWUv.js";import"./vendor-codemirror-language-BuDklWi8.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-codemirror-state-Wdz6Qsow.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-codemirror-view-pXtfpqbT.js";import"./vendor-style-mod-NZ5MEPvj.js";import"./vendor-w3c-keyname-Vcq4gwWv.js";import"./vendor-crelt-C8TCjufn.js";import"./vendor-lezer-highlight-CDMHUZ74.js";import"./vendor-codemirror-lang-javascript-CrbeaEAU.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-codemirror-autocomplete-3xMyV7a2.js";import"./vendor-codemirror-lang-json-BTvAjwkJ.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-C4jEScp7.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-C1Svvdey.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-BloD9GN-.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-qBLdzwMc.js";import"./vendor-codemirror-lang-python-CR2g6ukK.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-codemirror-commands-Bzf12ODH.js";import"./vendor-class-variance-authority-5VPnzWs2.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-tanstack-react-virtual-IrbCBGJ4.js";import"./vendor-tanstack-virtual-core-Dubg10g5.js";import"./vendor-framer-motion-DJASDzNt.js";import"./vendor-motion-dom-DJLgZh4Q.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./vendor-sonner-dWA7qvjr.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./vendor-react-drawio-Boqanm0j.js";function Jt(){const{files:o}=v(),[e,d]=r.useState(null),[s,p]=r.useState(""),[x,n]=r.useState(!0),l=r.useRef(null),c=a(i=>i.pendingDiagramFile),u=r.useCallback(async i=>{n(!0),d(i);try{const f=await o?.readFile?.(i);f&&p(f.content)}catch{p("")}finally{n(!1)}},[o]);r.useEffect(()=>{if(!c)return;const i=a.getState().consumePendingDiagramFile();i&&u(i)},[u,c]);const g=r.useCallback(async()=>{const i=l.current?.getXml();e&&o?.writeFile&&i&&i!==s&&(await o.writeFile(e,i),p(i))},[e,o,s]),h=e?e.split("/").pop()||e:"";return e?x?t.jsx("div",{className:"flex h-full items-center justify-center p-3",children:t.jsx(m,{name:"loader-4",className:"size-4 animate-spin"})}):t.jsxs("div",{className:"flex h-full flex-col",children:[t.jsxs("div",{className:"flex items-center gap-2 border-b border-border/30 px-3 py-1.5",children:[t.jsx(m,{name:"file",className:"size-4 shrink-0 text-muted-foreground"}),t.jsx("span",{className:"typography-ui text-muted-foreground truncate flex-1",children:h}),t.jsx("button",{type:"button",onClick:()=>{g()},className:"size-6 flex items-center justify-center rounded-md text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",title:"Save diagram",children:t.jsx(m,{name:"save-3",className:"size-4"})}),t.jsx("button",{type:"button",onClick:()=>a.getState().setActiveMainTab("chat"),className:"size-6 flex items-center justify-center rounded-md text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",title:"Close diagram view",children:t.jsx(m,{name:"close",className:"size-4"})})]}),t.jsx("div",{className:"flex-1 min-h-0",children:t.jsx(j,{ref:l,xml:s,className:"h-full"})})]}):t.jsx("div",{className:"flex h-full items-center justify-center p-3",children:t.jsx("div",{className:"typography-ui text-muted-foreground",children:"Pick a file from the tree."})})}export{Jt as DiagramView};
@@ -1,4 +1,4 @@
1
- import{R as o,j as n}from"./vendor-react-DYyjh7Q0.js";import{u as _,a as ut}from"./index-DQr8-8RF.js";import{dt as Pt,du as Wt,dv as Ot,K as dt,L as zt,aW as Gt,N as Ht,M as Ut,Q as Kt,R as Q,m as Vt,g as qt,dw as Xt,dx as Qt,b2 as Yt,$ as ve,t as ft,B as Ne,I as A,f as P,T as Jt,y as Zt,z as en,dy as mt,ds as tn,aw as nn,ax as sn,ay as rn,dz as on,dA as je,aC as pt,F as ht,_ as an}from"./SessionSwitcherDropdown-DNjCJjzF.js";import{P as ln}from"./PierreDiffViewer-Cwoewmiu.js";import{v as cn,g as un}from"./contextFileOpenGuard-BygvjHuE.js";import{p as dn}from"./VirtualizedFileDiff-CC5lTPJS.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-zustand-CnsBKjP5.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./runtimeSurface-B6sKTjo7.js";import"./vendor-dnd-kit-core-GipZW2tY.js";import"./vendor-dnd-kit-utilities-CrOcp0Bp.js";import"./vendor-dnd-kit-accessibility-Cv52zwWT.js";import"./vendor-dnd-kit-sortable-Ct2QxIHb.js";import"./vendor-base-ui-DwfTg5wD.js";import"./vendor-floating-ui-utils-BzXdqYpP.js";import"./vendor-floating-ui-react-dom-sVFnuruh.js";import"./vendor-floating-ui-dom-Bkw82kL9.js";import"./vendor-floating-ui-core-CXmKXOXc.js";import"./vendor-use-sync-external-store-B7OScDIw.js";import"./vendor-cmdk-BCEUzcHE.js";import"./vendor-radix-ui-react-dialog-jX3Dld8c.js";import"./vendor-radix-ui-primitive-Dc_FVRD7.js";import"./vendor-radix-ui-react-compose-refs-D1GnwnP9.js";import"./vendor-radix-ui-react-context-CM4yFQ2I.js";import"./vendor-radix-ui-react-id-BcxRjnbX.js";import"./vendor-radix-ui-react-use-layout-effect-0fyGwS2_.js";import"./vendor-radix-ui-react-use-controllable-state-C_ecoh35.js";import"./vendor-radix-ui-react-dismissable-layer-M7LsH3yL.js";import"./vendor-radix-ui-react-primitive-CfpW6_IT.js";import"./vendor-radix-ui-react-slot-BxUc3Pvz.js";import"./vendor-radix-ui-react-use-callback-ref-UKEWHtoP.js";import"./vendor-radix-ui-react-use-escape-keydown-Co13lHGj.js";import"./vendor-radix-ui-react-focus-scope-C2K7lNPv.js";import"./vendor-radix-ui-react-portal-xlJWBfDg.js";import"./vendor-radix-ui-react-presence-Btn-Dp7L.js";import"./vendor-radix-ui-react-focus-guards-D5MZ0nQs.js";import"./vendor-react-remove-scroll-CfeMe0DL.js";import"./vendor-tslib-De9GV7Vy.js";import"./vendor-react-remove-scroll-bar-C9YRs2nU.js";import"./vendor-react-style-singleton-B1H4bWSG.js";import"./vendor-get-nonce-C-Z93AgS.js";import"./vendor-use-sidecar-C-AuTczP.js";import"./vendor-use-callback-ref-CJB0R85I.js";import"./vendor-aria-hidden-DvXkyWUv.js";import"./vendor-codemirror-language-BuDklWi8.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-codemirror-state-Wdz6Qsow.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-codemirror-view-pXtfpqbT.js";import"./vendor-style-mod-NZ5MEPvj.js";import"./vendor-w3c-keyname-Vcq4gwWv.js";import"./vendor-crelt-C8TCjufn.js";import"./vendor-lezer-highlight-CDMHUZ74.js";import"./vendor-codemirror-lang-javascript-CrbeaEAU.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-codemirror-autocomplete-3xMyV7a2.js";import"./vendor-codemirror-lang-json-BTvAjwkJ.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-C4jEScp7.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-C1Svvdey.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-BloD9GN-.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-Be-zDX0u.js";import"./vendor-codemirror-lang-python-CR2g6ukK.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-codemirror-commands-Bzf12ODH.js";import"./vendor-class-variance-authority-5VPnzWs2.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-tanstack-react-virtual-IrbCBGJ4.js";import"./vendor-tanstack-virtual-core-Dubg10g5.js";import"./vendor-framer-motion-DJASDzNt.js";import"./vendor-motion-dom-DJLgZh4Q.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./vendor-sonner-dWA7qvjr.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./web-components-DgFD1Jms.js";import"./computeVirtualFileMetrics-BcVuV0Ic.js";import"./vendor-shiki-Bbf2GEcE.js";import"./vendor-shikijs-core-CGM_jqPK.js";import"./vendor-shikijs-types-CPSbSeK6.js";import"./vendor-shikijs-vscode-textmate-BgLrS_2D.js";import"./vendor-hast-util-to-html-BKBhbTDb.js";import"./vendor-html-void-elements-CkdplsNl.js";import"./vendor-property-information-rJCbAzvX.js";import"./vendor-zwitch-C2o2j-tx.js";import"./vendor-stringify-entities-CsH1VEn9.js";import"./vendor-character-entities-legacy-BpoLgcEt.js";import"./vendor-character-entities-html4-D7taRCQ7.js";import"./vendor-ccount-c2V3InAJ.js";import"./vendor-comma-separated-tokens-D8TqSuIK.js";import"./vendor-space-separated-tokens-DD3iYX1K.js";import"./vendor-hast-util-whitespace-D4Wp6AEg.js";import"./vendor-shikijs-engine-oniguruma-DPWuIF1G.js";import"./themeResolver-BmJyTmjJ.js";import"./vendor-pierre-theming-C6Z4M5_u.js";import"./vendor-shikijs-engine-javascript-Cme4830A.js";import"./vendor-oniguruma-to-es-DLBnFDCE.js";import"./vendor-oniguruma-parser-C0D4_9rT.js";import"./vendor-regex-BBWcyTkg.js";import"./vendor-regex-utilities-2BQyy0xI.js";import"./vendor-regex-recursion-JU4mF-dD.js";import"./vendor-shikijs-transformers-CZWsLLKm.js";import"./usePanelSlide-BkonU4LS.js";import"./permissionStore-BRcQ9Jgt.js";import"./useInlineCommentController-CSR_Ju0a.js";import"./collapsible-D_555Hw_.js";import"./appThemeRegistry-BK0dHKa6.js";import"./registerCustomTheme-BBXUCRnG.js";import"./isDiffPlainText-Bher0UxW.js";import"./vendor-diff-C3JhlQdm.js";function fn(t,e=10){const a=[];let i;for(const u of t.split(`
1
+ import{R as o,j as n}from"./vendor-react-DYyjh7Q0.js";import{u as _,a as ut}from"./index-BhXma4dv.js";import{dt as Pt,du as Wt,dv as Ot,K as dt,L as zt,aW as Gt,N as Ht,M as Ut,Q as Kt,R as Q,m as Vt,g as qt,dw as Xt,dx as Qt,b2 as Yt,$ as ve,t as ft,B as Ne,I as A,f as P,T as Jt,y as Zt,z as en,dy as mt,ds as tn,aw as nn,ax as sn,ay as rn,dz as on,dA as je,aC as pt,F as ht,_ as an}from"./SessionSwitcherDropdown-NbVfnqQQ.js";import{P as ln}from"./PierreDiffViewer-B38_7NnU.js";import{v as cn,g as un}from"./contextFileOpenGuard-BmmlK5E3.js";import{p as dn}from"./VirtualizedFileDiff-B7eVR6Pt.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-zustand-CnsBKjP5.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./runtimeSurface-CouGjZ3A.js";import"./vendor-dnd-kit-core-GipZW2tY.js";import"./vendor-dnd-kit-utilities-CrOcp0Bp.js";import"./vendor-dnd-kit-accessibility-Cv52zwWT.js";import"./vendor-dnd-kit-sortable-Ct2QxIHb.js";import"./vendor-base-ui-DwfTg5wD.js";import"./vendor-floating-ui-utils-BzXdqYpP.js";import"./vendor-floating-ui-react-dom-sVFnuruh.js";import"./vendor-floating-ui-dom-Bkw82kL9.js";import"./vendor-floating-ui-core-CXmKXOXc.js";import"./vendor-use-sync-external-store-B7OScDIw.js";import"./vendor-cmdk-BCEUzcHE.js";import"./vendor-radix-ui-react-dialog-jX3Dld8c.js";import"./vendor-radix-ui-primitive-Dc_FVRD7.js";import"./vendor-radix-ui-react-compose-refs-D1GnwnP9.js";import"./vendor-radix-ui-react-context-CM4yFQ2I.js";import"./vendor-radix-ui-react-id-BcxRjnbX.js";import"./vendor-radix-ui-react-use-layout-effect-0fyGwS2_.js";import"./vendor-radix-ui-react-use-controllable-state-C_ecoh35.js";import"./vendor-radix-ui-react-dismissable-layer-M7LsH3yL.js";import"./vendor-radix-ui-react-primitive-CfpW6_IT.js";import"./vendor-radix-ui-react-slot-BxUc3Pvz.js";import"./vendor-radix-ui-react-use-callback-ref-UKEWHtoP.js";import"./vendor-radix-ui-react-use-escape-keydown-Co13lHGj.js";import"./vendor-radix-ui-react-focus-scope-C2K7lNPv.js";import"./vendor-radix-ui-react-portal-xlJWBfDg.js";import"./vendor-radix-ui-react-presence-Btn-Dp7L.js";import"./vendor-radix-ui-react-focus-guards-D5MZ0nQs.js";import"./vendor-react-remove-scroll-CfeMe0DL.js";import"./vendor-tslib-De9GV7Vy.js";import"./vendor-react-remove-scroll-bar-C9YRs2nU.js";import"./vendor-react-style-singleton-B1H4bWSG.js";import"./vendor-get-nonce-C-Z93AgS.js";import"./vendor-use-sidecar-C-AuTczP.js";import"./vendor-use-callback-ref-CJB0R85I.js";import"./vendor-aria-hidden-DvXkyWUv.js";import"./vendor-codemirror-language-BuDklWi8.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-codemirror-state-Wdz6Qsow.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-codemirror-view-pXtfpqbT.js";import"./vendor-style-mod-NZ5MEPvj.js";import"./vendor-w3c-keyname-Vcq4gwWv.js";import"./vendor-crelt-C8TCjufn.js";import"./vendor-lezer-highlight-CDMHUZ74.js";import"./vendor-codemirror-lang-javascript-CrbeaEAU.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-codemirror-autocomplete-3xMyV7a2.js";import"./vendor-codemirror-lang-json-BTvAjwkJ.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-C4jEScp7.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-C1Svvdey.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-BloD9GN-.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-qBLdzwMc.js";import"./vendor-codemirror-lang-python-CR2g6ukK.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-codemirror-commands-Bzf12ODH.js";import"./vendor-class-variance-authority-5VPnzWs2.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-tanstack-react-virtual-IrbCBGJ4.js";import"./vendor-tanstack-virtual-core-Dubg10g5.js";import"./vendor-framer-motion-DJASDzNt.js";import"./vendor-motion-dom-DJLgZh4Q.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./vendor-sonner-dWA7qvjr.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./web-components-BhO08KaW.js";import"./computeVirtualFileMetrics-BsZulefS.js";import"./vendor-shiki-Bbf2GEcE.js";import"./vendor-shikijs-core-CGM_jqPK.js";import"./vendor-shikijs-types-CPSbSeK6.js";import"./vendor-shikijs-vscode-textmate-BgLrS_2D.js";import"./vendor-hast-util-to-html-BKBhbTDb.js";import"./vendor-html-void-elements-CkdplsNl.js";import"./vendor-property-information-rJCbAzvX.js";import"./vendor-zwitch-C2o2j-tx.js";import"./vendor-stringify-entities-CsH1VEn9.js";import"./vendor-character-entities-legacy-BpoLgcEt.js";import"./vendor-character-entities-html4-D7taRCQ7.js";import"./vendor-ccount-c2V3InAJ.js";import"./vendor-comma-separated-tokens-D8TqSuIK.js";import"./vendor-space-separated-tokens-DD3iYX1K.js";import"./vendor-hast-util-whitespace-D4Wp6AEg.js";import"./vendor-shikijs-engine-oniguruma-DPWuIF1G.js";import"./themeResolver-BmJyTmjJ.js";import"./vendor-pierre-theming-C6Z4M5_u.js";import"./vendor-shikijs-engine-javascript-Cme4830A.js";import"./vendor-oniguruma-to-es-DLBnFDCE.js";import"./vendor-oniguruma-parser-C0D4_9rT.js";import"./vendor-regex-BBWcyTkg.js";import"./vendor-regex-utilities-2BQyy0xI.js";import"./vendor-regex-recursion-JU4mF-dD.js";import"./vendor-shikijs-transformers-CZWsLLKm.js";import"./usePanelSlide-BRwyEEzi.js";import"./permissionStore-BRcQ9Jgt.js";import"./useInlineCommentController-buNJ3xB4.js";import"./collapsible-CPkWB1VR.js";import"./appThemeRegistry-BK0dHKa6.js";import"./registerCustomTheme-BBXUCRnG.js";import"./isDiffPlainText-DsuyxFXo.js";import"./vendor-diff-C3JhlQdm.js";function fn(t,e=10){const a=[];let i;for(const u of t.split(`
2
2
  `)){const x=u.match(Pt);if(x!=null){i!=null&&(i.hunkLines.length>0&&(Me(i,e,"trailing"),Ge(i,a)),i=void 0);const b=parseInt(x[3]),N=parseInt(x[1]),v=parseInt(x[4]??"1"),h=parseInt(x[2]??"1");isNaN(b)||isNaN(N)||isNaN(v)||isNaN(h)?a.push(u):i={additionStart:b,deletionStart:N,additionCount:0,deletionCount:0,hunkLines:[],contextLines:[]};continue}if(i==null){a.push(u);continue}if(u.startsWith(" "))i.contextLines.push(u);else if(u!==""){if(i.hunkLines.length>0&&i.contextLines.length>e*2){const b=i.contextLines.length-e*2,N=i.contextLines.slice(-e);Me(i,e,"trailing");const{additionCount:v,deletionCount:h}=i;Ge(i,a),i={additionStart:i.additionStart+v+b,deletionStart:i.deletionStart+h+b,deletionCount:0,additionCount:0,contextLines:N,hunkLines:[]}}Me(i,e,i.hunkLines.length===0?"leading":"before-change"),i.hunkLines.push(u),u.startsWith("+")?i.additionCount+=1:u.startsWith("-")&&(i.deletionCount+=1)}}i!=null&&i.hunkLines.length>0&&(Me(i,e,"trailing"),Ge(i,a));const c=a.join(`
3
3
  `);return t.endsWith(`
4
4
  `)?`${c}
@@ -1,4 +1,4 @@
1
- import{j as t,R as n,b as bo}from"./vendor-react-DYyjh7Q0.js";import{x as wo,y as yo,z as jo,A as No,M as Es,n as Ee,u as ue,bG as ko,a7 as Rs,B as Co,r as Ds,H as rn,e as So,bH as Fo,G as Eo,bI as Ro}from"./index-DQr8-8RF.js";import{f as $,a1 as vr,B as S,T as Ye,y as Xe,I as v,z as Ze,dE as Do,K as zo,aK as Po,aW as Mo,L as To,M as Lo,aB as Oo,dF as zs,t as A,h as Ao,_ as nn,dB as fr,b2 as Io,dG as sn,$ as Ps,dH as Ms,dC as Ts,dD as Bo,dI as $o,dJ as Wo,b6 as Vo,dK as Ls,D as da,C as fa,E as ma,G as pa,H as ha,J as ga,aw as pn,ax as hn,F as hr,ay as gn,aD as gr,aC as an,a0 as on,bk as Os,cX as _o,cY as Ho,dL as _t,az as br,aA as qo,aE as Ko}from"./SessionSwitcherDropdown-DNjCJjzF.js";import{q as mr,h as Go,i as Uo,j as Jo,k as Yo,l as Xo}from"./usePanelSlide-BkonU4LS.js";import{E as Zo,o as ut,k as xn,i as xa,a as Qo,S as ei}from"./vendor-codemirror-state-Wdz6Qsow.js";import{s as ti,d as ri,E as se,e as ni,f as As,k as cn,V as va,D as yr,W as si}from"./vendor-codemirror-view-pXtfpqbT.js";import{h as ai,k as oi,l as ii,j as ci}from"./vendor-codemirror-commands-Bzf12ODH.js";import{i as li,y as ui,H as Is,x as pr,z as di}from"./vendor-codemirror-language-BuDklWi8.js";import{a as Bs,g as wr,b as $s,c as Ws,o as fi,d as mi}from"./vendor-codemirror-search-BzyfPoRb.js";import{v as pi,g as hi}from"./vendor-replit-codemirror-vim-BUqe2Slv.js";import{F as gi,J as xi}from"./JsonTreeView-DzEjA1ht.js";import{a as d,c as vi}from"./vendor-lezer-highlight-CDMHUZ74.js";import{ensurePierreThemeRegistered as Vs,getResolvedShikiTheme as bi}from"./appThemeRegistry-BK0dHKa6.js";import{D as wi}from"./DiagramEditor-BOIJVnh3.js";import{I as _s,a as yi,u as ji,n as Ni}from"./useInlineCommentController-CSR_Ju0a.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-zustand-CnsBKjP5.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./runtimeSurface-B6sKTjo7.js";import"./vendor-dnd-kit-core-GipZW2tY.js";import"./vendor-dnd-kit-utilities-CrOcp0Bp.js";import"./vendor-dnd-kit-accessibility-Cv52zwWT.js";import"./vendor-dnd-kit-sortable-Ct2QxIHb.js";import"./vendor-base-ui-DwfTg5wD.js";import"./vendor-floating-ui-utils-BzXdqYpP.js";import"./vendor-floating-ui-react-dom-sVFnuruh.js";import"./vendor-floating-ui-dom-Bkw82kL9.js";import"./vendor-floating-ui-core-CXmKXOXc.js";import"./vendor-use-sync-external-store-B7OScDIw.js";import"./vendor-cmdk-BCEUzcHE.js";import"./vendor-radix-ui-react-dialog-jX3Dld8c.js";import"./vendor-radix-ui-primitive-Dc_FVRD7.js";import"./vendor-radix-ui-react-compose-refs-D1GnwnP9.js";import"./vendor-radix-ui-react-context-CM4yFQ2I.js";import"./vendor-radix-ui-react-id-BcxRjnbX.js";import"./vendor-radix-ui-react-use-layout-effect-0fyGwS2_.js";import"./vendor-radix-ui-react-use-controllable-state-C_ecoh35.js";import"./vendor-radix-ui-react-dismissable-layer-M7LsH3yL.js";import"./vendor-radix-ui-react-primitive-CfpW6_IT.js";import"./vendor-radix-ui-react-slot-BxUc3Pvz.js";import"./vendor-radix-ui-react-use-callback-ref-UKEWHtoP.js";import"./vendor-radix-ui-react-use-escape-keydown-Co13lHGj.js";import"./vendor-radix-ui-react-focus-scope-C2K7lNPv.js";import"./vendor-radix-ui-react-portal-xlJWBfDg.js";import"./vendor-radix-ui-react-presence-Btn-Dp7L.js";import"./vendor-radix-ui-react-focus-guards-D5MZ0nQs.js";import"./vendor-react-remove-scroll-CfeMe0DL.js";import"./vendor-tslib-De9GV7Vy.js";import"./vendor-react-remove-scroll-bar-C9YRs2nU.js";import"./vendor-react-style-singleton-B1H4bWSG.js";import"./vendor-get-nonce-C-Z93AgS.js";import"./vendor-use-sidecar-C-AuTczP.js";import"./vendor-use-callback-ref-CJB0R85I.js";import"./vendor-aria-hidden-DvXkyWUv.js";import"./vendor-codemirror-lang-javascript-CrbeaEAU.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-codemirror-autocomplete-3xMyV7a2.js";import"./vendor-style-mod-NZ5MEPvj.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-w3c-keyname-Vcq4gwWv.js";import"./vendor-crelt-C8TCjufn.js";import"./vendor-codemirror-lang-json-BTvAjwkJ.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-C4jEScp7.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-C1Svvdey.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-BloD9GN-.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-Be-zDX0u.js";import"./vendor-codemirror-lang-python-CR2g6ukK.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-class-variance-authority-5VPnzWs2.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-tanstack-react-virtual-IrbCBGJ4.js";import"./vendor-tanstack-virtual-core-Dubg10g5.js";import"./vendor-framer-motion-DJASDzNt.js";import"./vendor-motion-dom-DJLgZh4Q.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./vendor-sonner-dWA7qvjr.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./permissionStore-BRcQ9Jgt.js";import"./web-components-DgFD1Jms.js";import"./computeVirtualFileMetrics-BcVuV0Ic.js";import"./vendor-shiki-Bbf2GEcE.js";import"./vendor-shikijs-core-CGM_jqPK.js";import"./vendor-shikijs-types-CPSbSeK6.js";import"./vendor-shikijs-vscode-textmate-BgLrS_2D.js";import"./vendor-hast-util-to-html-BKBhbTDb.js";import"./vendor-html-void-elements-CkdplsNl.js";import"./vendor-property-information-rJCbAzvX.js";import"./vendor-zwitch-C2o2j-tx.js";import"./vendor-stringify-entities-CsH1VEn9.js";import"./vendor-character-entities-legacy-BpoLgcEt.js";import"./vendor-character-entities-html4-D7taRCQ7.js";import"./vendor-ccount-c2V3InAJ.js";import"./vendor-comma-separated-tokens-D8TqSuIK.js";import"./vendor-space-separated-tokens-DD3iYX1K.js";import"./vendor-hast-util-whitespace-D4Wp6AEg.js";import"./vendor-shikijs-engine-oniguruma-DPWuIF1G.js";import"./themeResolver-BmJyTmjJ.js";import"./vendor-pierre-theming-C6Z4M5_u.js";import"./vendor-shikijs-engine-javascript-Cme4830A.js";import"./vendor-oniguruma-to-es-DLBnFDCE.js";import"./vendor-oniguruma-parser-C0D4_9rT.js";import"./vendor-regex-BBWcyTkg.js";import"./vendor-regex-utilities-2BQyy0xI.js";import"./vendor-regex-recursion-JU4mF-dD.js";import"./vendor-shikijs-transformers-CZWsLLKm.js";import"./Virtualizer-BxW2CJGB.js";import"./isFilePlainText-EIViqOlI.js";import"./registerCustomTheme-BBXUCRnG.js";import"./vendor-react-drawio-Boqanm0j.js";import"./collapsible-D_555Hw_.js";function ki(r){const{drafts:a,editingDraftId:u,commentText:f,onTextChange:x,selection:p,isDragging:b,fileLabel:g,newWidgetId:y,mapDraftToRange:E,onSave:k,onCancel:L,onEdit:M,onDelete:R}=r,P=[];for(const o of a){const K=E(o);if(o.id===u){P.push({afterLine:K.end,id:`edit-${o.id}`,content:t.jsx(_s,{initialText:f,onTextChange:x,fileLabel:g,lineRange:K,isEditing:!0,onSave:k,onCancel:L},`edit-${o.id}`)});continue}P.push({afterLine:K.end,id:`card-${o.id}`,content:t.jsx(yi,{draft:o,onEdit:()=>M(o),onDelete:()=>R(o)},`card-${o.id}`)})}if(p&&!u&&!b){const o={...p,start:Math.min(p.start,p.end),end:Math.max(p.start,p.end)};P.push({afterLine:o.end,id:y,content:t.jsx(_s,{initialText:f,onTextChange:x,fileLabel:g,lineRange:o,isEditing:!1,onSave:k,onCancel:L},y)})}return P}const Ci=r=>r!==null&&typeof r=="object"&&"updateStatus"in r&&typeof r.updateStatus=="function",Si=r=>{const a=document.createElement("div");a.className="cm-vim-panel";const u=hi(r);if(!u)return{top:!1,dom:a};u.state.statusbar=a;const f=u.state.vimPlugin;return Ci(f)&&f.updateStatus(),{top:!1,dom:a,destroy(){u.state.statusbar===a&&(u.state.statusbar=null)}}};function Hs(r){return r?[pi(),ti.of(Si),ri()]:[]}const Fi={next:"Next match",prev:"Previous match",select:"Select all matches",replace:"Replace",replaceAll:"Replace all",close:"Close"},Ei={case:"Match case",re:"Regular expression",word:"Match whole word"};function Ri(r){const a=r.querySelector(".cm-search");if(a){for(const[u,f]of Object.entries(Fi)){const x=a.querySelector(`button[name="${u}"]`);x&&!x.title&&(x.title=f)}for(const[u,f]of Object.entries(Ei)){const p=a.querySelector(`input[name="${u}"]`)?.parentElement;p&&!p.title&&(p.title=f)}}}const ln=new WeakMap;function Di(r,a){const u=wr(r.state);if(!u.valid)return ln.delete(r),0;const f=ln.get(r);if(!a&&f?.doc===r.state.doc&&f.query.eq(u))return f.total;const x=u.getCursor(r.state);let p=0;for(let b=x.next();!b.done;b=x.next())p+=1;return ln.set(r,{query:u,doc:r.state.doc,total:p}),p}function zi(r){const a=wr(r.state);if(!a.valid)return 0;const u=r.state.selection.main,f=a.getCursor(r.state);let x=0,p=0;for(let b=f.next();!b.done;b=f.next()){const g=b.value;if(x+=1,p===0&&(p=x),u.from===g.from&&u.to===g.to||u.from<g.to&&u.to>g.from||g.from>=u.head)return x}return p}function qs(r,a,u=!1){const f=r.querySelector(".cm-search");if(!f)return;let x=f.querySelector(".cm-search-message");if(!x){x=document.createElement("span"),x.className="cm-search-message",x.setAttribute("aria-live","polite");const g=f.querySelector('button[name="next"]'),y=g?.parentNode===f?g:f.firstChild;f.insertBefore(x,y)}const p=Di(a,u),b=p===0?0:zi(a);x.textContent=p===0?"":`${b}/${p}`}const Ks=new ut,Gs=new ut,Us=new ut,Js=new ut,Ys=new ut,Xs=new ut,Zs=new ut,Qs=r=>r,un=ui,Pi=fi,Mi=mi;class Ti extends si{constructor(a,u){super(),this.id=a,this.containerMap=u}toDOM(){let a=this.containerMap.get(this.id);return a||(a=document.createElement("div"),a.className="oc-block-widget",a.dataset.widgetId=this.id,this.containerMap.set(this.id,a)),a}eq(a){return a.id===this.id}destroy(){}}const ea=(r,a)=>!r||r.length===0?[]:xa.define({create(u){const f=new xn,x=[...r].sort((p,b)=>p.afterLine-b.afterLine);for(const p of x){const b=u.doc.lines;if(p.afterLine>b)continue;const g=u.doc.line(p.afterLine);f.add(g.to,g.to,yr.widget({widget:new Ti(p.id,a),block:!0,side:1}))}return f.finish()},update(u,f){return u.map(f.changes)},provide:u=>se.decorations.from(u)}),ta=r=>{if(!r)return[];const a=Math.max(1,r.start),u=Math.max(a,r.end);return va.fromClass(class{decorations;constructor(f){this.decorations=this.build(f)}update(f){(f.docChanged||f.viewportChanged)&&(this.decorations=this.build(f.view))}build(f){const x=new xn;for(let p=a;p<=u&&p<=f.state.doc.lines;p+=1){const b=f.state.doc.line(p);x.add(b.from,b.from,yr.line({class:"oc-cm-selected-line"}))}return x.finish()}},{decorations:f=>f.decorations})};function ra({value:r,onChange:a,extensions:u,className:f,readOnly:x,lineNumbersConfig:p,highlightLines:b,onViewReady:g,onViewDestroy:y,blockWidgets:E,enableSearch:k,searchOpen:L,onSearchOpenChange:M,vimMode:R}){const P=n.useRef(null),o=n.useRef(null),K=n.useRef(r),xe=n.useRef(a),de=n.useRef(g),B=n.useRef(y),Ne=n.useRef(M),ae=n.useRef(E),Re=n.useRef(R),Oe=n.useRef(new Map),[dt,G]=n.useState([]),W=n.useCallback(w=>{const U=(w??[]).map(N=>{const T=Oe.current.get(N.id);return T?{id:N.id,content:N.content,container:T}:null}).filter(N=>N!==null);G(N=>N.length===U.length&&N.every((T,C)=>{const oe=U[C];return T.id===oe.id&&T.content===oe.content&&T.container===oe.container})?N:U)},[]),fe=n.useCallback(w=>{const U=P.current,N=w??o.current;if(!U||!N)return;const T=N.dom.querySelector(".cm-gutters"),C=T instanceof HTMLElement?T.getBoundingClientRect().width:0;U.style.setProperty("--oc-editor-gutter-width",`${C}px`)},[]);return n.useEffect(()=>{K.current=r},[r]),n.useEffect(()=>{xe.current=a},[a]),n.useEffect(()=>{de.current=g,B.current=y},[g,y]),n.useEffect(()=>{Ne.current=M},[M]),n.useEffect(()=>{ae.current=E,W(E)},[E,W]),n.useEffect(()=>{if(!P.current)return;const w=(()=>{if(typeof document>"u")return null;const N=document.querySelector('meta[name="csp-nonce"]')?.getAttribute("content");if(N)return N;const T=window.__PICHAMBER_CSP_NONCE__;return typeof T=="string"&&T.length>0?T:null})(),U=Zo.create({doc:K.current,extensions:[...w?[se.cspNonce.of(w)]:[],ni({fixed:!0}),Ks.of(As(p)),ai(),li.of(" "),Zs.of(Hs(R)),cn.of([oi,...ii,...ci]),se.updateListener.of(N=>{fe(N.view),(N.viewportChanged||N.geometryChanged)&&W(ae.current);const T=Bs(N.startState),C=Bs(N.state);T!==C&&Ne.current?.(C);const oe=!wr(N.startState).eq(wr(N.state));if(C&&(T!==C||oe||N.docChanged||N.selectionSet)&&qs(N.view.dom,N.view,T!==C||oe||N.docChanged),!N.docChanged)return;const O=N.state.doc.toString();K.current=O,xe.current(O),W(ae.current)}),Gs.of(se.editable.of(!x)),Us.of(u??[]),Js.of(ta(b)),Ys.of(ea(E,Oe.current)),Xs.of(k?[$s({top:!0}),cn.of(Qs(Ws))]:[])]});return o.current=new se({state:U,parent:P.current}),un(o.current,o.current.state.doc.length,200),o.current.requestMeasure(),requestAnimationFrame(()=>{fe(o.current),W(ae.current)}),o.current&&de.current?.(o.current),()=>{B.current?.(),o.current?.destroy(),o.current=null,G([])}},[ae,fe,W]),n.useEffect(()=>{const w=o.current;w&&(w.dispatch({effects:[Ks.reconfigure(As(p)),Gs.reconfigure(se.editable.of(!x)),Us.reconfigure(u??[]),Js.reconfigure(ta(b)),Ys.reconfigure(ea(E,Oe.current)),Xs.reconfigure(k?[$s({top:!0}),cn.of(Qs(Ws))]:[])]}),un(w,w.state.doc.length,200),w.requestMeasure(),requestAnimationFrame(()=>{fe(w),W(ae.current)}))},[u,b,p,x,E,k,fe,W]),n.useEffect(()=>{const w=o.current;if(!w){Re.current=R;return}Re.current!==R&&(Re.current=R,w.dispatch({effects:Zs.reconfigure(Hs(R))}))},[R]),n.useEffect(()=>{const w=o.current;!w||k===!1||(L?(Pi(w),requestAnimationFrame(()=>{Ri(w.dom),qs(w.dom,w,!0)})):Mi(w))},[L,k]),n.useEffect(()=>{const w=o.current;if(!w)return;const U=w.state.doc.toString();U!==r&&(w.dispatch({changes:{from:0,to:U.length,insert:r}}),un(w,w.state.doc.length,300),w.requestMeasure(),requestAnimationFrame(()=>fe(w)))},[r,fe]),t.jsxs(t.Fragment,{children:[t.jsx("div",{ref:P,className:$("h-full w-full","[&_.cm-editor]:h-full [&_.cm-editor]:w-full","[&_.cm-scroller]:font-mono [&_.cm-scroller]:text-[var(--text-code)] [&_.cm-scroller]:leading-6","[&_.cm-lineNumbers]:text-[var(--tools-edit-line-number)]",f)}),dt.map(w=>bo.createPortal(w.content,w.container,w.id))]})}const Li=(r,a)=>{if(!a)return null;const u=Number.parseInt(r.trim(),10);return!Number.isFinite(u)||u<1?null:Math.min(u,a.state.doc.lines)},na=(r,a)=>{const u=r.state.doc.lineAt(a.main.head);return{lineNumber:u.number,character:a.main.head-u.from+1,selection:a}},sa=(r,a,u)=>{const f=r.state.doc.line(a),x=Math.max(1,Math.min(u,f.length+1)),p=f.from+x-1;r.dispatch({selection:Qo.cursor(p),effects:se.scrollIntoView(p,{y:"center"})})};function Oi({open:r,onOpenChange:a,view:u,variant:f="overlay"}){const[x,p]=n.useState(""),b=n.useRef(null),g=n.useRef(!1),y=n.useRef(null),E=n.useRef(null),k=n.useMemo(()=>Li(x,u),[x,u]);n.useEffect(()=>{!r||!u||(g.current=!1,b.current=na(u,u.state.selection),p(""))},[r,u]),n.useEffect(()=>{r&&window.requestAnimationFrame(()=>{E.current?.focus(),E.current?.select()})},[r]),n.useEffect(()=>{if(!(!r||!u||!b.current)){if(k===null){const{selection:o}=b.current;u.dispatch({selection:o,effects:se.scrollIntoView(o.main.from,{y:"center"})});return}sa(u,k,b.current.character)}},[k,r,u]);const L=n.useCallback(()=>{if(!u||g.current||!b.current)return;const{selection:o}=b.current;u.dispatch({selection:o,effects:se.scrollIntoView(o.main.from,{y:"center"})})},[u]),M=n.useCallback(o=>{o||L(),a(o)},[a,L]),R=n.useCallback(()=>{!u||k===null||!b.current||(g.current=!0,sa(u,k,b.current.character),a(!1),u.focus())},[k,a,u]);n.useEffect(()=>{if(!r)return;const o=xe=>{const de=y.current,B=xe.target;!de||!(B instanceof Node)||de.contains(B)||M(!1)},K=xe=>{xe.key==="Escape"&&(xe.preventDefault(),M(!1))};return document.addEventListener("pointerdown",o,!0),document.addEventListener("keydown",K,!0),()=>{document.removeEventListener("pointerdown",o,!0),document.removeEventListener("keydown",K,!0)}},[M,r,f]);const P=n.useMemo(()=>u?k===null?`Current Line: ${(b.current??na(u,u.state.selection)).lineNumber}. Type a line number between 1 and ${u.state.doc.lines} to navigate to.`:`Go to line ${k}`:"Editor unavailable.",[k,u]);return f==="inline"?r?t.jsxs("div",{ref:y,className:"ml-1 flex h-6 items-center gap-1",children:[t.jsx(vr,{ref:E,type:"number",min:1,step:1,inputMode:"numeric",value:x,onChange:o=>p(o.target.value),onKeyDown:o=>{o.key==="Enter"&&(o.preventDefault(),R())},placeholder:"Line",className:"h-6 w-20 rounded-md border-border/70 bg-transparent px-2 typography-meta"}),t.jsx(S,{variant:"outline",size:"xs",onClick:R,disabled:!u||k===null,className:"h-6 px-2",children:"Go"})]}):null:t.jsx("div",{ref:y,className:$("absolute left-3 top-3 z-40 w-[min(32rem,calc(100%-1.5rem))] rounded-xl border border-[var(--interactive-border)] bg-[color:color-mix(in_srgb,var(--surface-elevated)_94%,transparent)] p-2.5 shadow-lg backdrop-blur-sm transition-all",r?"pointer-events-auto translate-y-0 opacity-100":"pointer-events-none -translate-y-1 opacity-0"),children:t.jsxs("div",{className:"min-w-0",children:[t.jsx(vr,{ref:E,type:"number",min:1,step:1,inputMode:"numeric",value:x,onChange:o=>p(o.target.value),onKeyDown:o=>{o.key==="Enter"&&(o.preventDefault(),R())},placeholder:"Line number",className:"h-8 w-full rounded-md border-border/70 bg-background/60 typography-ui-label"}),t.jsx("div",{className:"mt-2 rounded-md bg-primary/15 px-3 py-1.5 typography-ui-label text-foreground/95",children:P})]})})}const dn=({currentMode:r,onToggle:a})=>{const u=r==="preview",f=u?"Switch to edit mode":"Switch to preview mode",x=u?"Edit":"Preview";return t.jsxs(Ye,{children:[t.jsx(Xe,{asChild:!0,children:t.jsx(S,{variant:"ghost",size:"sm",onClick:a,"aria-label":f,className:"h-5 w-5 p-0",children:u?t.jsx(v,{name:"eye",className:"size-4","aria-hidden":"true"}):t.jsx(v,{name:"eye-off",className:"size-4","aria-hidden":"true"})})}),t.jsx(Ze,{sideOffset:8,children:x})]})};function aa(r,a){const u=r.metadata.variant==="dark",f=r.config?.fonts?.mono||"monospace",x=r.colors.syntax.highlights||{},p=r.colors.syntax.tokens||{},b=a?.fontSize?`${a.fontSize}px`:"var(--text-code)",g=se.theme({"&":{backgroundColor:"var(--background)",color:r.colors.syntax.base.foreground,fontSize:b,lineHeight:"1.5",position:"relative"},".cm-scroller":{fontFamily:f,backgroundColor:"var(--background)"},".cm-comment":{color:r.colors.syntax.base.comment},".cm-keyword":{color:r.colors.syntax.base.keyword},".cm-string":{color:r.colors.syntax.base.string},".cm-string-2":{color:p.stringEscape||r.colors.syntax.base.string},".cm-number":{color:r.colors.syntax.base.number},".cm-operator":{color:r.colors.syntax.base.operator},".cm-punctuation":{color:p.punctuation||r.colors.syntax.base.comment},".cm-atom":{color:p.boolean||r.colors.syntax.base.number},".cm-builtin":{color:p.functionCall||r.colors.syntax.base.function},".cm-def":{color:p.variableGlobal||r.colors.syntax.base.variable},".cm-attribute":{color:p.variableOther||p.variableProperty||r.colors.syntax.base.operator},".cm-meta":{color:r.colors.syntax.base.comment},".cm-property":{color:p.variableProperty||r.colors.syntax.base.keyword},".cm-variable":{color:r.colors.syntax.base.variable},".cm-variable-2":{color:p.variableOther||r.colors.syntax.base.function},".cm-variable-3":{color:p.variableGlobal||r.colors.syntax.base.type},".cm-tag":{color:p.tag||r.colors.syntax.base.keyword},".cm-link":{color:p.url||r.colors.syntax.base.keyword,textDecoration:"underline"},".cm-content":{caretColor:r.colors.interactive.cursor},".cm-cursor, .cm-dropCursor":{borderLeftColor:r.colors.interactive.cursor},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, ::selection":{backgroundColor:r.colors.interactive.selection},".cm-gutters":{backgroundColor:"var(--background)",color:x.lineNumber||r.colors.syntax.base.comment,borderRight:`1px solid ${r.colors.interactive.border}`,position:"sticky",paddingRight:"8px",left:0,zIndex:2,boxShadow:"0 0 0 var(--background)"},".cm-gutter":{backgroundColor:"var(--background)"},".cm-gutterElement":{backgroundColor:"var(--background)"},".cm-lineNumbers":{backgroundColor:"var(--background)"},".cm-lineNumbers .cm-gutterElement":{paddingLeft:"8px",paddingRight:"8px",minWidth:"42px"},".cm-activeLineGutter":{color:x.lineNumberActive||r.colors.syntax.base.foreground},".cm-activeLine":{backgroundColor:r.colors.surface.overlay},".cm-panels":{backgroundColor:"transparent",color:r.colors.surface.foreground,position:"absolute",top:"0",right:"0",left:"auto",width:"auto",zIndex:10,pointerEvents:"none"},".cm-panels-top":{borderBottom:"none",position:"absolute",top:"6px",right:"14px",left:"auto",width:"auto"},".cm-panels-bottom":{position:"static",width:"100%",pointerEvents:"auto"},".cm-panels-bottom .cm-vim-panel":{borderTop:`1px solid ${r.colors.interactive.border}`,backgroundColor:r.colors.surface.elevated,color:r.colors.surface.mutedForeground,fontFamily:"var(--font-mono)",fontSize:"12px",minHeight:"22px",padding:"2px 8px"},".cm-panel.cm-search":{pointerEvents:"auto",padding:"4px",backgroundColor:`color-mix(in srgb, ${r.colors.surface.elevated} 85%, transparent)`,border:`1px solid ${r.colors.interactive.border}`,borderRadius:"10px",boxShadow:`0 2px 8px color-mix(in srgb, ${r.colors.surface.background} 60%, transparent)`,width:"auto",minWidth:"360px",maxWidth:"480px"},".cm-search":{display:"flex",flexWrap:"wrap",alignItems:"center",gap:"0",width:"100%",color:r.colors.surface.foreground,fontFamily:"inherit",fontSize:"13px",lineHeight:"1"},".cm-search br":{display:"none"},".cm-search .cm-textfield":{appearance:"none",height:"26px",margin:0,padding:"0 8px",borderRadius:"6px !important",border:`1px solid ${r.colors.interactive.border}`,backgroundColor:r.colors.surface.background,color:r.colors.surface.foreground,fontFamily:"inherit",fontSize:"12px",lineHeight:"1",outline:"none",transition:"border-color 150ms ease"},".cm-search .cm-textfield::placeholder":{color:r.colors.surface.mutedForeground,opacity:1},".cm-search .cm-textfield:focus":{borderColor:r.colors.primary.base},'.cm-search .cm-textfield[name="search"]':{order:1,flex:"1 1 120px",maxWidth:"calc(100% - 142px)",minWidth:"100px"},".cm-search label":{order:2,display:"inline-flex",alignItems:"center",justifyContent:"center",width:"26px",height:"26px",minWidth:"26px",flexShrink:"0",margin:0,marginLeft:"1px",padding:0,borderRadius:"4px",border:"1px solid transparent",backgroundColor:"transparent",color:"transparent",cursor:"pointer",userSelect:"none",fontSize:"1px",lineHeight:"0",overflow:"hidden",position:"relative",transition:"background-color 120ms ease, border-color 120ms ease"},".cm-search label:hover":{backgroundColor:r.colors.interactive.hover},'.cm-search label:has(input[type="checkbox"]:checked)':{backgroundColor:r.colors.interactive.hover,borderColor:r.colors.interactive.border},'.cm-search [type="checkbox"]':{appearance:"none",WebkitAppearance:"none",width:"0",height:"0",margin:"0",padding:"0",border:"none",position:"absolute",opacity:"0",pointerEvents:"none"},".cm-search label::after":{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",fontSize:"13px",fontWeight:"600",lineHeight:"1",fontFamily:"inherit",color:r.colors.surface.mutedForeground,pointerEvents:"none"},".cm-search label:hover::after":{color:r.colors.surface.foreground},'.cm-search label:has(input[type="checkbox"]:checked)::after':{color:r.colors.surface.foreground},'.cm-search label:has(input[name="case"])::after':{content:'"Aa"',fontSize:"12px",letterSpacing:"-0.5px"},'.cm-search label:has(input[name="re"])::after':{content:'".*"',fontSize:"13px",fontFamily:"monospace"},'.cm-search label:has(input[name="word"])::after':{content:'"ab"',fontSize:"12px",textDecoration:"underline",textUnderlineOffset:"2px"},".cm-search .cm-search-message":{order:3,color:r.colors.surface.mutedForeground,backgroundColor:"transparent",border:"none",borderRadius:"0",padding:"0 6px",fontSize:"11px",whiteSpace:"nowrap",lineHeight:"26px"},".cm-search .cm-button":{appearance:"none",WebkitAppearance:"none",display:"inline-flex",alignItems:"center",justifyContent:"center",width:"26px",height:"26px",minWidth:"26px",flexShrink:"0",margin:0,marginLeft:"1px",padding:0,borderRadius:"4px",border:"none",backgroundColor:"transparent",backgroundImage:"none",color:"transparent",cursor:"pointer",fontSize:"1px",fontWeight:"400",lineHeight:"0",overflow:"hidden",position:"relative",boxShadow:"none",transition:"background-color 120ms ease"},".cm-search .cm-button::after":{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",fontSize:"15px",lineHeight:"1",color:r.colors.surface.mutedForeground,pointerEvents:"none"},".cm-search .cm-button:hover":{backgroundColor:r.colors.interactive.hover},".cm-search .cm-button:hover::after":{color:r.colors.surface.foreground},".cm-search .cm-button:active":{backgroundColor:r.colors.interactive.active},".cm-search .cm-button:focus-visible":{outline:"none",boxShadow:`0 0 0 1px ${r.colors.interactive.focusRing}`},".cm-search .cm-button:disabled":{opacity:.4,cursor:"default",pointerEvents:"none"},'.cm-search .cm-button[name="prev"]':{order:21,marginTop:"2px"},'.cm-search .cm-button[name="prev"]::after':{content:'"↑"'},'.cm-search .cm-button[name="next"]':{order:22,marginTop:"2px"},'.cm-search .cm-button[name="next"]::after':{content:'"↓"'},'.cm-search .cm-button[name="select"]':{order:23,marginTop:"2px"},'.cm-search .cm-button[name="select"]::after':{content:'"≡"',fontSize:"17px"},'.cm-panel.cm-search button[name="close"]':{order:5,appearance:"none",WebkitAppearance:"none",display:"inline-flex",alignItems:"center",justifyContent:"center",width:"26px",height:"26px",minWidth:"26px",flexShrink:"0",margin:"0 0 0 auto",padding:"0",borderRadius:"4px",border:"none",backgroundColor:"transparent",backgroundImage:"none",color:r.colors.surface.mutedForeground,cursor:"pointer",fontSize:"16px",lineHeight:"1",boxShadow:"none",position:"relative",overflow:"visible",transition:"background-color 120ms ease, color 120ms ease"},'.cm-panel.cm-search button[name="close"]:hover':{backgroundColor:r.colors.interactive.hover,color:r.colors.surface.foreground},'.cm-search .cm-button[name="replace"]':{order:24,marginTop:"2px"},'.cm-search .cm-button[name="replace"]::after':{content:'"⇄"'},'.cm-search .cm-button[name="replaceAll"], .cm-search .cm-button[name="replace-all"]':{order:25,marginTop:"2px"},'.cm-search .cm-button[name="replaceAll"]::after, .cm-search .cm-button[name="replace-all"]::after':{content:'"⇉"'},'.cm-search .cm-textfield[name="replace"]':{order:20,flex:"1 1 100%",maxWidth:"calc(100% - 142px)",minWidth:"80px",marginTop:"2px"},".cm-searchMatch":{backgroundColor:r.colors.status.infoBackground,boxShadow:`inset 0 0 0 1px ${r.colors.status.infoBorder}`,borderRadius:"2px"},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:r.colors.interactive.selection,color:r.colors.interactive.selectionForeground,boxShadow:`inset 0 0 0 1px ${r.colors.interactive.borderFocus}`},"&.cm-focused":{outline:"none"}},{dark:u}),y=Is.define([{tag:[d.comment,d.docComment,d.meta,d.documentMeta],class:"cm-comment"},{tag:[d.keyword,d.controlKeyword,d.moduleKeyword,d.definitionKeyword,d.modifier],class:"cm-keyword"},{tag:[d.operatorKeyword,d.operator,d.derefOperator,d.updateOperator,d.definitionOperator,d.typeOperator,d.controlOperator,d.logicOperator,d.bitwiseOperator,d.arithmeticOperator,d.compareOperator],class:"cm-operator"},{tag:[d.punctuation,d.separator,d.bracket,d.paren,d.brace,d.squareBracket,d.angleBracket],class:"cm-punctuation"},{tag:[d.string,d.regexp,d.attributeValue,d.special(d.string),d.monospace],class:"cm-string"},{tag:d.escape,class:"cm-string-2"},{tag:[d.number,d.bool,d.atom,d.null,d.self],class:"cm-number"},{tag:[d.function(d.variableName),d.function(d.definition(d.variableName)),d.function(d.propertyName),d.standard(d.variableName),d.special(d.variableName)],class:"cm-builtin"},{tag:d.definition(d.variableName),class:"cm-def"},{tag:[d.variableName,d.local(d.variableName),d.constant(d.variableName),d.literal],class:"cm-variable"},{tag:d.propertyName,class:"cm-property"},{tag:d.attributeName,class:"cm-attribute"},{tag:[d.className,d.typeName,d.namespace],class:"cm-variable-3"},{tag:[d.tagName,d.labelName,d.annotation,d.macroName],class:"cm-tag"},{tag:d.link,class:"cm-link"},{tag:[d.heading,d.heading1,d.heading2,d.heading3,d.heading4,d.heading5,d.heading6],class:"cm-keyword"}]),E=Is.define([{tag:[d.comment,d.docComment,d.meta,d.documentMeta],color:r.colors.syntax.base.comment},{tag:[d.keyword,d.controlKeyword,d.moduleKeyword,d.definitionKeyword,d.modifier],color:r.colors.syntax.base.keyword},{tag:[d.operatorKeyword,d.operator,d.derefOperator,d.updateOperator,d.definitionOperator,d.typeOperator,d.controlOperator,d.logicOperator,d.bitwiseOperator,d.arithmeticOperator,d.compareOperator],color:r.colors.syntax.base.operator},{tag:[d.string,d.regexp,d.attributeValue,d.special(d.string),d.monospace],color:r.colors.syntax.base.string},{tag:d.escape,color:p.stringEscape||r.colors.syntax.base.string},{tag:[d.number,d.bool,d.atom,d.null,d.self],color:r.colors.syntax.base.number},{tag:[d.function(d.variableName),d.function(d.definition(d.variableName)),d.function(d.propertyName),d.standard(d.variableName),d.special(d.variableName)],color:r.colors.syntax.base.function},{tag:d.definition(d.variableName),color:p.variableGlobal||r.colors.syntax.base.variable},{tag:[d.variableName,d.local(d.variableName),d.constant(d.variableName),d.literal],color:r.colors.syntax.base.variable},{tag:d.propertyName,color:p.variableProperty||r.colors.syntax.base.variable},{tag:d.attributeName,color:p.variableOther||r.colors.syntax.base.variable},{tag:[d.className,d.typeName,d.namespace],color:r.colors.syntax.base.type},{tag:[d.tagName,d.labelName,d.annotation,d.macroName],color:p.tag||r.colors.syntax.base.keyword},{tag:d.link,color:p.url||r.colors.syntax.base.function,textDecoration:"underline"},{tag:[d.punctuation,d.separator,d.bracket,d.paren,d.brace,d.squareBracket,d.angleBracket],color:p.punctuation||r.colors.syntax.base.comment}]);return a?.syntaxColors===!1?[g]:[g,pr(di,{fallback:!0}),pr(vi),pr(y),pr(E)]}const Ai=180,ba=ei.define(),Ii=1,Bi=2,$i=4,oa=new Map,Wi=(r,a)=>{const u=`${r}|${a}`,f=oa.get(u);if(f)return f;let x="";r&&(x+=`color:${r};`),a&Ii&&(x+="font-style:italic;"),a&Bi&&(x+="font-weight:bold;"),a&$i&&(x+="text-decoration:underline;");const p=yr.mark({attributes:{style:x}});return oa.set(u,p),p},Vi=(r,a)=>{const u=new xn,f=r.state.doc,x=Math.min(a.length,f.lines);for(let p=0;p<x;p+=1){const b=a[p];if(!b||b.length===0)continue;const g=f.line(p+1);let y=g.from;for(const[E,k,L]of b){if(E<=0)continue;const M=y,R=Math.min(y+E,g.to);y+=E,!(R<=M)&&(!k&&!L||u.add(M,R,Wi(k,L)))}}return u.finish()},_i=xa.define({create(){return yr.none},update(r,a){let u=r.map(a.changes);for(const f of a.effects)f.is(ba)&&(u=f.value);return u},provide:r=>se.decorations.from(r)}),Hi=r=>va.fromClass(class{timer;generation=0;constructor(a){this.tokenize(a)}update(a){a.docChanged&&this.schedule(a.view)}schedule(a){this.timer&&clearTimeout(this.timer),this.timer=setTimeout(()=>{this.timer=void 0,this.tokenize(a)},Ai)}async tokenize(a){const u=++this.generation,f=a.state.doc.toString(),x=await Do(f,r.language,r.themeName,r.theme);x&&u===this.generation&&a.state.doc.length===f.length&&a.dispatch({effects:ba.of(Vi(a,x))})}destroy(){this.timer&&clearTimeout(this.timer)}}),qi=r=>[_i,Hi(r)];function Ki(r){return!(!r.autoSaveEnabled||!r.isDirty||!r.canWrite||r.isSaving||r.fileLoading||r.isNonEditableBinary||!r.selectedFilePath||r.loadedFilePath!==r.selectedFilePath)}function Gi(r){return r.selectedFilePath?r.isDirty?!(r.fileLoading||r.loadedFilePath!==r.selectedFilePath||r.isNonEditableBinary||r.draftContent===""&&r.fileContent!==""&&r.loadedFilePath!==r.selectedFilePath):!0:!1}const Ui=r=>{const a=I(r);if(!a)return"";if(a==="/"||/^[A-Za-z]:\/$/.test(a))return a;const u=a.lastIndexOf("/");if(u<0)return a;if(u===0)return"/";const f=a.slice(0,u);return/^[A-Za-z]:$/.test(f)?`${f}/`:f},Ji=({label:r,iconDataUrl:a})=>{const[u,f]=n.useState(!1),x=r.trim().slice(0,1).toUpperCase()||"?";return a&&!u?t.jsx("img",{src:a,alt:"",className:"size-4 rounded-sm",onError:()=>f(!0)}):t.jsx("span",{className:$("size-4 rounded-sm flex items-center justify-center","bg-[var(--surface-muted)] text-[9px] font-medium text-muted-foreground"),children:x})},Yi=r=>r.slice().sort((a,u)=>a.type!==u.type?a.type==="directory"?-1:1:a.name.localeCompare(u.name)),I=r=>{if(!r)return"";const a=r.replace(/\\/g,"/"),u=a.startsWith("//");let f=a.replace(/\/+/g,"/");u&&!f.startsWith("//")&&(f=`/${f}`);const x=f==="/",p=/^[A-Za-z]:\/$/.test(f);return!x&&!p&&(f=f.replace(/\/+$/,"")),f},Xi=r=>r.startsWith("/")||r.startsWith("//")||/^[A-Za-z]:\//.test(r),Et=r=>/^[A-Za-z]:\//.test(r)?r.toLowerCase():r,qt=(r,a)=>{const u=I(a),f=I(r);if(!u||!f)return!1;const x=Et(u),p=Et(f);return p===x||p.startsWith(`${x}/`)},ia=(r,a)=>{const u=I(a),f=I(r);if(!qt(f,u))return[];const p=f.slice(u.length).replace(/^\//,"").split("/"),b=[];let g=u;for(let y=0;y<p.length-1;y++)g=g?`${g}/${p[y]}`:p[y],b.push(g);return b},xr=(r,a)=>{if(!a)return"";const u=I(a);if(!r||!qt(u,r))return u;const f=u.slice(r.length);return f.startsWith("/")?f.slice(1):f},Zi=new Set(["node_modules"]),Qi=({status:r})=>{const a={open:"var(--status-info)",modified:"var(--status-warning)","git-modified":"var(--status-warning)","git-added":"var(--status-success)","git-deleted":"var(--status-error)"}[r];return t.jsx("span",{className:"size-2 rounded-full",style:{backgroundColor:a}})},ca=({name:r})=>{const a=n.useRef(null),u=n.useRef(null),[f,x]=n.useState(!1);return n.useLayoutEffect(()=>{const p=a.current,b=u.current;if(!p||!b)return;const g=()=>{x(b.scrollWidth>p.clientWidth+1)};g();const y=new ResizeObserver(g);return y.observe(p),y.observe(b),()=>{y.disconnect()}},[r]),t.jsxs("span",{ref:a,className:"relative block min-w-0 flex-1 overflow-hidden whitespace-nowrap",children:[t.jsx("span",{ref:u,"aria-hidden":"true",className:"invisible absolute whitespace-nowrap",children:r}),f?t.jsxs("span",{className:"open-file-name-marquee-track",children:[t.jsx("span",{className:"open-file-name-marquee-item",children:r}),t.jsx("span",{className:"open-file-name-marquee-item","aria-hidden":"true",children:r})]}):t.jsx("span",{className:"block min-w-0 truncate",children:r})]})},ec=r=>Zi.has(r),tc=r=>{const a=I(r);return a==="node_modules"||a.endsWith("/node_modules")||a.includes("/node_modules/")},rc=r=>{const u=(r instanceof Error?r.message:String(r??"")).toLowerCase();return u.includes("is a directory")||u.includes("eisdir")},la=r=>{const u=(r instanceof Error?r.message:String(r??"")).toLowerCase();return u.includes("file not found")||u.includes("enoent")||u.includes("no such file")||u.includes("does not exist")},Ht=2e5,nc=r=>{let a=0,u=0;for(let f=0;f<r.length;f+=1)r.charCodeAt(f)===10&&(f>0&&r.charCodeAt(f-1)===13?a+=1:u+=1);return a>u?`\r
1
+ import{j as t,R as n,b as bo}from"./vendor-react-DYyjh7Q0.js";import{x as wo,y as yo,z as jo,A as No,M as Es,n as Ee,u as ue,bG as ko,a7 as Rs,B as Co,r as Ds,H as rn,e as So,bH as Fo,G as Eo,bI as Ro}from"./index-BhXma4dv.js";import{f as $,a1 as vr,B as S,T as Ye,y as Xe,I as v,z as Ze,dE as Do,K as zo,aK as Po,aW as Mo,L as To,M as Lo,aB as Oo,dF as zs,t as A,h as Ao,_ as nn,dB as fr,b2 as Io,dG as sn,$ as Ps,dH as Ms,dC as Ts,dD as Bo,dI as $o,dJ as Wo,b6 as Vo,dK as Ls,D as da,C as fa,E as ma,G as pa,H as ha,J as ga,aw as pn,ax as hn,F as hr,ay as gn,aD as gr,aC as an,a0 as on,bk as Os,cX as _o,cY as Ho,dL as _t,az as br,aA as qo,aE as Ko}from"./SessionSwitcherDropdown-NbVfnqQQ.js";import{q as mr,h as Go,i as Uo,j as Jo,k as Yo,l as Xo}from"./usePanelSlide-BRwyEEzi.js";import{E as Zo,o as ut,k as xn,i as xa,a as Qo,S as ei}from"./vendor-codemirror-state-Wdz6Qsow.js";import{s as ti,d as ri,E as se,e as ni,f as As,k as cn,V as va,D as yr,W as si}from"./vendor-codemirror-view-pXtfpqbT.js";import{h as ai,k as oi,l as ii,j as ci}from"./vendor-codemirror-commands-Bzf12ODH.js";import{i as li,y as ui,H as Is,x as pr,z as di}from"./vendor-codemirror-language-BuDklWi8.js";import{a as Bs,g as wr,b as $s,c as Ws,o as fi,d as mi}from"./vendor-codemirror-search-BzyfPoRb.js";import{v as pi,g as hi}from"./vendor-replit-codemirror-vim-BUqe2Slv.js";import{F as gi,J as xi}from"./JsonTreeView-By2oGMNK.js";import{a as d,c as vi}from"./vendor-lezer-highlight-CDMHUZ74.js";import{ensurePierreThemeRegistered as Vs,getResolvedShikiTheme as bi}from"./appThemeRegistry-BK0dHKa6.js";import{D as wi}from"./DiagramEditor-Cp22TGpq.js";import{I as _s,a as yi,u as ji,n as Ni}from"./useInlineCommentController-buNJ3xB4.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-zustand-CnsBKjP5.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./runtimeSurface-CouGjZ3A.js";import"./vendor-dnd-kit-core-GipZW2tY.js";import"./vendor-dnd-kit-utilities-CrOcp0Bp.js";import"./vendor-dnd-kit-accessibility-Cv52zwWT.js";import"./vendor-dnd-kit-sortable-Ct2QxIHb.js";import"./vendor-base-ui-DwfTg5wD.js";import"./vendor-floating-ui-utils-BzXdqYpP.js";import"./vendor-floating-ui-react-dom-sVFnuruh.js";import"./vendor-floating-ui-dom-Bkw82kL9.js";import"./vendor-floating-ui-core-CXmKXOXc.js";import"./vendor-use-sync-external-store-B7OScDIw.js";import"./vendor-cmdk-BCEUzcHE.js";import"./vendor-radix-ui-react-dialog-jX3Dld8c.js";import"./vendor-radix-ui-primitive-Dc_FVRD7.js";import"./vendor-radix-ui-react-compose-refs-D1GnwnP9.js";import"./vendor-radix-ui-react-context-CM4yFQ2I.js";import"./vendor-radix-ui-react-id-BcxRjnbX.js";import"./vendor-radix-ui-react-use-layout-effect-0fyGwS2_.js";import"./vendor-radix-ui-react-use-controllable-state-C_ecoh35.js";import"./vendor-radix-ui-react-dismissable-layer-M7LsH3yL.js";import"./vendor-radix-ui-react-primitive-CfpW6_IT.js";import"./vendor-radix-ui-react-slot-BxUc3Pvz.js";import"./vendor-radix-ui-react-use-callback-ref-UKEWHtoP.js";import"./vendor-radix-ui-react-use-escape-keydown-Co13lHGj.js";import"./vendor-radix-ui-react-focus-scope-C2K7lNPv.js";import"./vendor-radix-ui-react-portal-xlJWBfDg.js";import"./vendor-radix-ui-react-presence-Btn-Dp7L.js";import"./vendor-radix-ui-react-focus-guards-D5MZ0nQs.js";import"./vendor-react-remove-scroll-CfeMe0DL.js";import"./vendor-tslib-De9GV7Vy.js";import"./vendor-react-remove-scroll-bar-C9YRs2nU.js";import"./vendor-react-style-singleton-B1H4bWSG.js";import"./vendor-get-nonce-C-Z93AgS.js";import"./vendor-use-sidecar-C-AuTczP.js";import"./vendor-use-callback-ref-CJB0R85I.js";import"./vendor-aria-hidden-DvXkyWUv.js";import"./vendor-codemirror-lang-javascript-CrbeaEAU.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-codemirror-autocomplete-3xMyV7a2.js";import"./vendor-style-mod-NZ5MEPvj.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-w3c-keyname-Vcq4gwWv.js";import"./vendor-crelt-C8TCjufn.js";import"./vendor-codemirror-lang-json-BTvAjwkJ.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-C4jEScp7.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-C1Svvdey.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-BloD9GN-.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-qBLdzwMc.js";import"./vendor-codemirror-lang-python-CR2g6ukK.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-class-variance-authority-5VPnzWs2.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-tanstack-react-virtual-IrbCBGJ4.js";import"./vendor-tanstack-virtual-core-Dubg10g5.js";import"./vendor-framer-motion-DJASDzNt.js";import"./vendor-motion-dom-DJLgZh4Q.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./vendor-sonner-dWA7qvjr.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./permissionStore-BRcQ9Jgt.js";import"./web-components-BhO08KaW.js";import"./computeVirtualFileMetrics-BsZulefS.js";import"./vendor-shiki-Bbf2GEcE.js";import"./vendor-shikijs-core-CGM_jqPK.js";import"./vendor-shikijs-types-CPSbSeK6.js";import"./vendor-shikijs-vscode-textmate-BgLrS_2D.js";import"./vendor-hast-util-to-html-BKBhbTDb.js";import"./vendor-html-void-elements-CkdplsNl.js";import"./vendor-property-information-rJCbAzvX.js";import"./vendor-zwitch-C2o2j-tx.js";import"./vendor-stringify-entities-CsH1VEn9.js";import"./vendor-character-entities-legacy-BpoLgcEt.js";import"./vendor-character-entities-html4-D7taRCQ7.js";import"./vendor-ccount-c2V3InAJ.js";import"./vendor-comma-separated-tokens-D8TqSuIK.js";import"./vendor-space-separated-tokens-DD3iYX1K.js";import"./vendor-hast-util-whitespace-D4Wp6AEg.js";import"./vendor-shikijs-engine-oniguruma-DPWuIF1G.js";import"./themeResolver-BmJyTmjJ.js";import"./vendor-pierre-theming-C6Z4M5_u.js";import"./vendor-shikijs-engine-javascript-Cme4830A.js";import"./vendor-oniguruma-to-es-DLBnFDCE.js";import"./vendor-oniguruma-parser-C0D4_9rT.js";import"./vendor-regex-BBWcyTkg.js";import"./vendor-regex-utilities-2BQyy0xI.js";import"./vendor-regex-recursion-JU4mF-dD.js";import"./vendor-shikijs-transformers-CZWsLLKm.js";import"./Virtualizer-BxW2CJGB.js";import"./isFilePlainText-CCYoe7us.js";import"./registerCustomTheme-BBXUCRnG.js";import"./vendor-react-drawio-Boqanm0j.js";import"./collapsible-CPkWB1VR.js";function ki(r){const{drafts:a,editingDraftId:u,commentText:f,onTextChange:x,selection:p,isDragging:b,fileLabel:g,newWidgetId:y,mapDraftToRange:E,onSave:k,onCancel:L,onEdit:M,onDelete:R}=r,P=[];for(const o of a){const K=E(o);if(o.id===u){P.push({afterLine:K.end,id:`edit-${o.id}`,content:t.jsx(_s,{initialText:f,onTextChange:x,fileLabel:g,lineRange:K,isEditing:!0,onSave:k,onCancel:L},`edit-${o.id}`)});continue}P.push({afterLine:K.end,id:`card-${o.id}`,content:t.jsx(yi,{draft:o,onEdit:()=>M(o),onDelete:()=>R(o)},`card-${o.id}`)})}if(p&&!u&&!b){const o={...p,start:Math.min(p.start,p.end),end:Math.max(p.start,p.end)};P.push({afterLine:o.end,id:y,content:t.jsx(_s,{initialText:f,onTextChange:x,fileLabel:g,lineRange:o,isEditing:!1,onSave:k,onCancel:L},y)})}return P}const Ci=r=>r!==null&&typeof r=="object"&&"updateStatus"in r&&typeof r.updateStatus=="function",Si=r=>{const a=document.createElement("div");a.className="cm-vim-panel";const u=hi(r);if(!u)return{top:!1,dom:a};u.state.statusbar=a;const f=u.state.vimPlugin;return Ci(f)&&f.updateStatus(),{top:!1,dom:a,destroy(){u.state.statusbar===a&&(u.state.statusbar=null)}}};function Hs(r){return r?[pi(),ti.of(Si),ri()]:[]}const Fi={next:"Next match",prev:"Previous match",select:"Select all matches",replace:"Replace",replaceAll:"Replace all",close:"Close"},Ei={case:"Match case",re:"Regular expression",word:"Match whole word"};function Ri(r){const a=r.querySelector(".cm-search");if(a){for(const[u,f]of Object.entries(Fi)){const x=a.querySelector(`button[name="${u}"]`);x&&!x.title&&(x.title=f)}for(const[u,f]of Object.entries(Ei)){const p=a.querySelector(`input[name="${u}"]`)?.parentElement;p&&!p.title&&(p.title=f)}}}const ln=new WeakMap;function Di(r,a){const u=wr(r.state);if(!u.valid)return ln.delete(r),0;const f=ln.get(r);if(!a&&f?.doc===r.state.doc&&f.query.eq(u))return f.total;const x=u.getCursor(r.state);let p=0;for(let b=x.next();!b.done;b=x.next())p+=1;return ln.set(r,{query:u,doc:r.state.doc,total:p}),p}function zi(r){const a=wr(r.state);if(!a.valid)return 0;const u=r.state.selection.main,f=a.getCursor(r.state);let x=0,p=0;for(let b=f.next();!b.done;b=f.next()){const g=b.value;if(x+=1,p===0&&(p=x),u.from===g.from&&u.to===g.to||u.from<g.to&&u.to>g.from||g.from>=u.head)return x}return p}function qs(r,a,u=!1){const f=r.querySelector(".cm-search");if(!f)return;let x=f.querySelector(".cm-search-message");if(!x){x=document.createElement("span"),x.className="cm-search-message",x.setAttribute("aria-live","polite");const g=f.querySelector('button[name="next"]'),y=g?.parentNode===f?g:f.firstChild;f.insertBefore(x,y)}const p=Di(a,u),b=p===0?0:zi(a);x.textContent=p===0?"":`${b}/${p}`}const Ks=new ut,Gs=new ut,Us=new ut,Js=new ut,Ys=new ut,Xs=new ut,Zs=new ut,Qs=r=>r,un=ui,Pi=fi,Mi=mi;class Ti extends si{constructor(a,u){super(),this.id=a,this.containerMap=u}toDOM(){let a=this.containerMap.get(this.id);return a||(a=document.createElement("div"),a.className="oc-block-widget",a.dataset.widgetId=this.id,this.containerMap.set(this.id,a)),a}eq(a){return a.id===this.id}destroy(){}}const ea=(r,a)=>!r||r.length===0?[]:xa.define({create(u){const f=new xn,x=[...r].sort((p,b)=>p.afterLine-b.afterLine);for(const p of x){const b=u.doc.lines;if(p.afterLine>b)continue;const g=u.doc.line(p.afterLine);f.add(g.to,g.to,yr.widget({widget:new Ti(p.id,a),block:!0,side:1}))}return f.finish()},update(u,f){return u.map(f.changes)},provide:u=>se.decorations.from(u)}),ta=r=>{if(!r)return[];const a=Math.max(1,r.start),u=Math.max(a,r.end);return va.fromClass(class{decorations;constructor(f){this.decorations=this.build(f)}update(f){(f.docChanged||f.viewportChanged)&&(this.decorations=this.build(f.view))}build(f){const x=new xn;for(let p=a;p<=u&&p<=f.state.doc.lines;p+=1){const b=f.state.doc.line(p);x.add(b.from,b.from,yr.line({class:"oc-cm-selected-line"}))}return x.finish()}},{decorations:f=>f.decorations})};function ra({value:r,onChange:a,extensions:u,className:f,readOnly:x,lineNumbersConfig:p,highlightLines:b,onViewReady:g,onViewDestroy:y,blockWidgets:E,enableSearch:k,searchOpen:L,onSearchOpenChange:M,vimMode:R}){const P=n.useRef(null),o=n.useRef(null),K=n.useRef(r),xe=n.useRef(a),de=n.useRef(g),B=n.useRef(y),Ne=n.useRef(M),ae=n.useRef(E),Re=n.useRef(R),Oe=n.useRef(new Map),[dt,G]=n.useState([]),W=n.useCallback(w=>{const U=(w??[]).map(N=>{const T=Oe.current.get(N.id);return T?{id:N.id,content:N.content,container:T}:null}).filter(N=>N!==null);G(N=>N.length===U.length&&N.every((T,C)=>{const oe=U[C];return T.id===oe.id&&T.content===oe.content&&T.container===oe.container})?N:U)},[]),fe=n.useCallback(w=>{const U=P.current,N=w??o.current;if(!U||!N)return;const T=N.dom.querySelector(".cm-gutters"),C=T instanceof HTMLElement?T.getBoundingClientRect().width:0;U.style.setProperty("--oc-editor-gutter-width",`${C}px`)},[]);return n.useEffect(()=>{K.current=r},[r]),n.useEffect(()=>{xe.current=a},[a]),n.useEffect(()=>{de.current=g,B.current=y},[g,y]),n.useEffect(()=>{Ne.current=M},[M]),n.useEffect(()=>{ae.current=E,W(E)},[E,W]),n.useEffect(()=>{if(!P.current)return;const w=(()=>{if(typeof document>"u")return null;const N=document.querySelector('meta[name="csp-nonce"]')?.getAttribute("content");if(N)return N;const T=window.__PICHAMBER_CSP_NONCE__;return typeof T=="string"&&T.length>0?T:null})(),U=Zo.create({doc:K.current,extensions:[...w?[se.cspNonce.of(w)]:[],ni({fixed:!0}),Ks.of(As(p)),ai(),li.of(" "),Zs.of(Hs(R)),cn.of([oi,...ii,...ci]),se.updateListener.of(N=>{fe(N.view),(N.viewportChanged||N.geometryChanged)&&W(ae.current);const T=Bs(N.startState),C=Bs(N.state);T!==C&&Ne.current?.(C);const oe=!wr(N.startState).eq(wr(N.state));if(C&&(T!==C||oe||N.docChanged||N.selectionSet)&&qs(N.view.dom,N.view,T!==C||oe||N.docChanged),!N.docChanged)return;const O=N.state.doc.toString();K.current=O,xe.current(O),W(ae.current)}),Gs.of(se.editable.of(!x)),Us.of(u??[]),Js.of(ta(b)),Ys.of(ea(E,Oe.current)),Xs.of(k?[$s({top:!0}),cn.of(Qs(Ws))]:[])]});return o.current=new se({state:U,parent:P.current}),un(o.current,o.current.state.doc.length,200),o.current.requestMeasure(),requestAnimationFrame(()=>{fe(o.current),W(ae.current)}),o.current&&de.current?.(o.current),()=>{B.current?.(),o.current?.destroy(),o.current=null,G([])}},[ae,fe,W]),n.useEffect(()=>{const w=o.current;w&&(w.dispatch({effects:[Ks.reconfigure(As(p)),Gs.reconfigure(se.editable.of(!x)),Us.reconfigure(u??[]),Js.reconfigure(ta(b)),Ys.reconfigure(ea(E,Oe.current)),Xs.reconfigure(k?[$s({top:!0}),cn.of(Qs(Ws))]:[])]}),un(w,w.state.doc.length,200),w.requestMeasure(),requestAnimationFrame(()=>{fe(w),W(ae.current)}))},[u,b,p,x,E,k,fe,W]),n.useEffect(()=>{const w=o.current;if(!w){Re.current=R;return}Re.current!==R&&(Re.current=R,w.dispatch({effects:Zs.reconfigure(Hs(R))}))},[R]),n.useEffect(()=>{const w=o.current;!w||k===!1||(L?(Pi(w),requestAnimationFrame(()=>{Ri(w.dom),qs(w.dom,w,!0)})):Mi(w))},[L,k]),n.useEffect(()=>{const w=o.current;if(!w)return;const U=w.state.doc.toString();U!==r&&(w.dispatch({changes:{from:0,to:U.length,insert:r}}),un(w,w.state.doc.length,300),w.requestMeasure(),requestAnimationFrame(()=>fe(w)))},[r,fe]),t.jsxs(t.Fragment,{children:[t.jsx("div",{ref:P,className:$("h-full w-full","[&_.cm-editor]:h-full [&_.cm-editor]:w-full","[&_.cm-scroller]:font-mono [&_.cm-scroller]:text-[var(--text-code)] [&_.cm-scroller]:leading-6","[&_.cm-lineNumbers]:text-[var(--tools-edit-line-number)]",f)}),dt.map(w=>bo.createPortal(w.content,w.container,w.id))]})}const Li=(r,a)=>{if(!a)return null;const u=Number.parseInt(r.trim(),10);return!Number.isFinite(u)||u<1?null:Math.min(u,a.state.doc.lines)},na=(r,a)=>{const u=r.state.doc.lineAt(a.main.head);return{lineNumber:u.number,character:a.main.head-u.from+1,selection:a}},sa=(r,a,u)=>{const f=r.state.doc.line(a),x=Math.max(1,Math.min(u,f.length+1)),p=f.from+x-1;r.dispatch({selection:Qo.cursor(p),effects:se.scrollIntoView(p,{y:"center"})})};function Oi({open:r,onOpenChange:a,view:u,variant:f="overlay"}){const[x,p]=n.useState(""),b=n.useRef(null),g=n.useRef(!1),y=n.useRef(null),E=n.useRef(null),k=n.useMemo(()=>Li(x,u),[x,u]);n.useEffect(()=>{!r||!u||(g.current=!1,b.current=na(u,u.state.selection),p(""))},[r,u]),n.useEffect(()=>{r&&window.requestAnimationFrame(()=>{E.current?.focus(),E.current?.select()})},[r]),n.useEffect(()=>{if(!(!r||!u||!b.current)){if(k===null){const{selection:o}=b.current;u.dispatch({selection:o,effects:se.scrollIntoView(o.main.from,{y:"center"})});return}sa(u,k,b.current.character)}},[k,r,u]);const L=n.useCallback(()=>{if(!u||g.current||!b.current)return;const{selection:o}=b.current;u.dispatch({selection:o,effects:se.scrollIntoView(o.main.from,{y:"center"})})},[u]),M=n.useCallback(o=>{o||L(),a(o)},[a,L]),R=n.useCallback(()=>{!u||k===null||!b.current||(g.current=!0,sa(u,k,b.current.character),a(!1),u.focus())},[k,a,u]);n.useEffect(()=>{if(!r)return;const o=xe=>{const de=y.current,B=xe.target;!de||!(B instanceof Node)||de.contains(B)||M(!1)},K=xe=>{xe.key==="Escape"&&(xe.preventDefault(),M(!1))};return document.addEventListener("pointerdown",o,!0),document.addEventListener("keydown",K,!0),()=>{document.removeEventListener("pointerdown",o,!0),document.removeEventListener("keydown",K,!0)}},[M,r,f]);const P=n.useMemo(()=>u?k===null?`Current Line: ${(b.current??na(u,u.state.selection)).lineNumber}. Type a line number between 1 and ${u.state.doc.lines} to navigate to.`:`Go to line ${k}`:"Editor unavailable.",[k,u]);return f==="inline"?r?t.jsxs("div",{ref:y,className:"ml-1 flex h-6 items-center gap-1",children:[t.jsx(vr,{ref:E,type:"number",min:1,step:1,inputMode:"numeric",value:x,onChange:o=>p(o.target.value),onKeyDown:o=>{o.key==="Enter"&&(o.preventDefault(),R())},placeholder:"Line",className:"h-6 w-20 rounded-md border-border/70 bg-transparent px-2 typography-meta"}),t.jsx(S,{variant:"outline",size:"xs",onClick:R,disabled:!u||k===null,className:"h-6 px-2",children:"Go"})]}):null:t.jsx("div",{ref:y,className:$("absolute left-3 top-3 z-40 w-[min(32rem,calc(100%-1.5rem))] rounded-xl border border-[var(--interactive-border)] bg-[color:color-mix(in_srgb,var(--surface-elevated)_94%,transparent)] p-2.5 shadow-lg backdrop-blur-sm transition-all",r?"pointer-events-auto translate-y-0 opacity-100":"pointer-events-none -translate-y-1 opacity-0"),children:t.jsxs("div",{className:"min-w-0",children:[t.jsx(vr,{ref:E,type:"number",min:1,step:1,inputMode:"numeric",value:x,onChange:o=>p(o.target.value),onKeyDown:o=>{o.key==="Enter"&&(o.preventDefault(),R())},placeholder:"Line number",className:"h-8 w-full rounded-md border-border/70 bg-background/60 typography-ui-label"}),t.jsx("div",{className:"mt-2 rounded-md bg-primary/15 px-3 py-1.5 typography-ui-label text-foreground/95",children:P})]})})}const dn=({currentMode:r,onToggle:a})=>{const u=r==="preview",f=u?"Switch to edit mode":"Switch to preview mode",x=u?"Edit":"Preview";return t.jsxs(Ye,{children:[t.jsx(Xe,{asChild:!0,children:t.jsx(S,{variant:"ghost",size:"sm",onClick:a,"aria-label":f,className:"h-5 w-5 p-0",children:u?t.jsx(v,{name:"eye",className:"size-4","aria-hidden":"true"}):t.jsx(v,{name:"eye-off",className:"size-4","aria-hidden":"true"})})}),t.jsx(Ze,{sideOffset:8,children:x})]})};function aa(r,a){const u=r.metadata.variant==="dark",f=r.config?.fonts?.mono||"monospace",x=r.colors.syntax.highlights||{},p=r.colors.syntax.tokens||{},b=a?.fontSize?`${a.fontSize}px`:"var(--text-code)",g=se.theme({"&":{backgroundColor:"var(--background)",color:r.colors.syntax.base.foreground,fontSize:b,lineHeight:"1.5",position:"relative"},".cm-scroller":{fontFamily:f,backgroundColor:"var(--background)"},".cm-comment":{color:r.colors.syntax.base.comment},".cm-keyword":{color:r.colors.syntax.base.keyword},".cm-string":{color:r.colors.syntax.base.string},".cm-string-2":{color:p.stringEscape||r.colors.syntax.base.string},".cm-number":{color:r.colors.syntax.base.number},".cm-operator":{color:r.colors.syntax.base.operator},".cm-punctuation":{color:p.punctuation||r.colors.syntax.base.comment},".cm-atom":{color:p.boolean||r.colors.syntax.base.number},".cm-builtin":{color:p.functionCall||r.colors.syntax.base.function},".cm-def":{color:p.variableGlobal||r.colors.syntax.base.variable},".cm-attribute":{color:p.variableOther||p.variableProperty||r.colors.syntax.base.operator},".cm-meta":{color:r.colors.syntax.base.comment},".cm-property":{color:p.variableProperty||r.colors.syntax.base.keyword},".cm-variable":{color:r.colors.syntax.base.variable},".cm-variable-2":{color:p.variableOther||r.colors.syntax.base.function},".cm-variable-3":{color:p.variableGlobal||r.colors.syntax.base.type},".cm-tag":{color:p.tag||r.colors.syntax.base.keyword},".cm-link":{color:p.url||r.colors.syntax.base.keyword,textDecoration:"underline"},".cm-content":{caretColor:r.colors.interactive.cursor},".cm-cursor, .cm-dropCursor":{borderLeftColor:r.colors.interactive.cursor},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, ::selection":{backgroundColor:r.colors.interactive.selection},".cm-gutters":{backgroundColor:"var(--background)",color:x.lineNumber||r.colors.syntax.base.comment,borderRight:`1px solid ${r.colors.interactive.border}`,position:"sticky",paddingRight:"8px",left:0,zIndex:2,boxShadow:"0 0 0 var(--background)"},".cm-gutter":{backgroundColor:"var(--background)"},".cm-gutterElement":{backgroundColor:"var(--background)"},".cm-lineNumbers":{backgroundColor:"var(--background)"},".cm-lineNumbers .cm-gutterElement":{paddingLeft:"8px",paddingRight:"8px",minWidth:"42px"},".cm-activeLineGutter":{color:x.lineNumberActive||r.colors.syntax.base.foreground},".cm-activeLine":{backgroundColor:r.colors.surface.overlay},".cm-panels":{backgroundColor:"transparent",color:r.colors.surface.foreground,position:"absolute",top:"0",right:"0",left:"auto",width:"auto",zIndex:10,pointerEvents:"none"},".cm-panels-top":{borderBottom:"none",position:"absolute",top:"6px",right:"14px",left:"auto",width:"auto"},".cm-panels-bottom":{position:"static",width:"100%",pointerEvents:"auto"},".cm-panels-bottom .cm-vim-panel":{borderTop:`1px solid ${r.colors.interactive.border}`,backgroundColor:r.colors.surface.elevated,color:r.colors.surface.mutedForeground,fontFamily:"var(--font-mono)",fontSize:"12px",minHeight:"22px",padding:"2px 8px"},".cm-panel.cm-search":{pointerEvents:"auto",padding:"4px",backgroundColor:`color-mix(in srgb, ${r.colors.surface.elevated} 85%, transparent)`,border:`1px solid ${r.colors.interactive.border}`,borderRadius:"10px",boxShadow:`0 2px 8px color-mix(in srgb, ${r.colors.surface.background} 60%, transparent)`,width:"auto",minWidth:"360px",maxWidth:"480px"},".cm-search":{display:"flex",flexWrap:"wrap",alignItems:"center",gap:"0",width:"100%",color:r.colors.surface.foreground,fontFamily:"inherit",fontSize:"13px",lineHeight:"1"},".cm-search br":{display:"none"},".cm-search .cm-textfield":{appearance:"none",height:"26px",margin:0,padding:"0 8px",borderRadius:"6px !important",border:`1px solid ${r.colors.interactive.border}`,backgroundColor:r.colors.surface.background,color:r.colors.surface.foreground,fontFamily:"inherit",fontSize:"12px",lineHeight:"1",outline:"none",transition:"border-color 150ms ease"},".cm-search .cm-textfield::placeholder":{color:r.colors.surface.mutedForeground,opacity:1},".cm-search .cm-textfield:focus":{borderColor:r.colors.primary.base},'.cm-search .cm-textfield[name="search"]':{order:1,flex:"1 1 120px",maxWidth:"calc(100% - 142px)",minWidth:"100px"},".cm-search label":{order:2,display:"inline-flex",alignItems:"center",justifyContent:"center",width:"26px",height:"26px",minWidth:"26px",flexShrink:"0",margin:0,marginLeft:"1px",padding:0,borderRadius:"4px",border:"1px solid transparent",backgroundColor:"transparent",color:"transparent",cursor:"pointer",userSelect:"none",fontSize:"1px",lineHeight:"0",overflow:"hidden",position:"relative",transition:"background-color 120ms ease, border-color 120ms ease"},".cm-search label:hover":{backgroundColor:r.colors.interactive.hover},'.cm-search label:has(input[type="checkbox"]:checked)':{backgroundColor:r.colors.interactive.hover,borderColor:r.colors.interactive.border},'.cm-search [type="checkbox"]':{appearance:"none",WebkitAppearance:"none",width:"0",height:"0",margin:"0",padding:"0",border:"none",position:"absolute",opacity:"0",pointerEvents:"none"},".cm-search label::after":{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",fontSize:"13px",fontWeight:"600",lineHeight:"1",fontFamily:"inherit",color:r.colors.surface.mutedForeground,pointerEvents:"none"},".cm-search label:hover::after":{color:r.colors.surface.foreground},'.cm-search label:has(input[type="checkbox"]:checked)::after':{color:r.colors.surface.foreground},'.cm-search label:has(input[name="case"])::after':{content:'"Aa"',fontSize:"12px",letterSpacing:"-0.5px"},'.cm-search label:has(input[name="re"])::after':{content:'".*"',fontSize:"13px",fontFamily:"monospace"},'.cm-search label:has(input[name="word"])::after':{content:'"ab"',fontSize:"12px",textDecoration:"underline",textUnderlineOffset:"2px"},".cm-search .cm-search-message":{order:3,color:r.colors.surface.mutedForeground,backgroundColor:"transparent",border:"none",borderRadius:"0",padding:"0 6px",fontSize:"11px",whiteSpace:"nowrap",lineHeight:"26px"},".cm-search .cm-button":{appearance:"none",WebkitAppearance:"none",display:"inline-flex",alignItems:"center",justifyContent:"center",width:"26px",height:"26px",minWidth:"26px",flexShrink:"0",margin:0,marginLeft:"1px",padding:0,borderRadius:"4px",border:"none",backgroundColor:"transparent",backgroundImage:"none",color:"transparent",cursor:"pointer",fontSize:"1px",fontWeight:"400",lineHeight:"0",overflow:"hidden",position:"relative",boxShadow:"none",transition:"background-color 120ms ease"},".cm-search .cm-button::after":{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",fontSize:"15px",lineHeight:"1",color:r.colors.surface.mutedForeground,pointerEvents:"none"},".cm-search .cm-button:hover":{backgroundColor:r.colors.interactive.hover},".cm-search .cm-button:hover::after":{color:r.colors.surface.foreground},".cm-search .cm-button:active":{backgroundColor:r.colors.interactive.active},".cm-search .cm-button:focus-visible":{outline:"none",boxShadow:`0 0 0 1px ${r.colors.interactive.focusRing}`},".cm-search .cm-button:disabled":{opacity:.4,cursor:"default",pointerEvents:"none"},'.cm-search .cm-button[name="prev"]':{order:21,marginTop:"2px"},'.cm-search .cm-button[name="prev"]::after':{content:'"↑"'},'.cm-search .cm-button[name="next"]':{order:22,marginTop:"2px"},'.cm-search .cm-button[name="next"]::after':{content:'"↓"'},'.cm-search .cm-button[name="select"]':{order:23,marginTop:"2px"},'.cm-search .cm-button[name="select"]::after':{content:'"≡"',fontSize:"17px"},'.cm-panel.cm-search button[name="close"]':{order:5,appearance:"none",WebkitAppearance:"none",display:"inline-flex",alignItems:"center",justifyContent:"center",width:"26px",height:"26px",minWidth:"26px",flexShrink:"0",margin:"0 0 0 auto",padding:"0",borderRadius:"4px",border:"none",backgroundColor:"transparent",backgroundImage:"none",color:r.colors.surface.mutedForeground,cursor:"pointer",fontSize:"16px",lineHeight:"1",boxShadow:"none",position:"relative",overflow:"visible",transition:"background-color 120ms ease, color 120ms ease"},'.cm-panel.cm-search button[name="close"]:hover':{backgroundColor:r.colors.interactive.hover,color:r.colors.surface.foreground},'.cm-search .cm-button[name="replace"]':{order:24,marginTop:"2px"},'.cm-search .cm-button[name="replace"]::after':{content:'"⇄"'},'.cm-search .cm-button[name="replaceAll"], .cm-search .cm-button[name="replace-all"]':{order:25,marginTop:"2px"},'.cm-search .cm-button[name="replaceAll"]::after, .cm-search .cm-button[name="replace-all"]::after':{content:'"⇉"'},'.cm-search .cm-textfield[name="replace"]':{order:20,flex:"1 1 100%",maxWidth:"calc(100% - 142px)",minWidth:"80px",marginTop:"2px"},".cm-searchMatch":{backgroundColor:r.colors.status.infoBackground,boxShadow:`inset 0 0 0 1px ${r.colors.status.infoBorder}`,borderRadius:"2px"},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:r.colors.interactive.selection,color:r.colors.interactive.selectionForeground,boxShadow:`inset 0 0 0 1px ${r.colors.interactive.borderFocus}`},"&.cm-focused":{outline:"none"}},{dark:u}),y=Is.define([{tag:[d.comment,d.docComment,d.meta,d.documentMeta],class:"cm-comment"},{tag:[d.keyword,d.controlKeyword,d.moduleKeyword,d.definitionKeyword,d.modifier],class:"cm-keyword"},{tag:[d.operatorKeyword,d.operator,d.derefOperator,d.updateOperator,d.definitionOperator,d.typeOperator,d.controlOperator,d.logicOperator,d.bitwiseOperator,d.arithmeticOperator,d.compareOperator],class:"cm-operator"},{tag:[d.punctuation,d.separator,d.bracket,d.paren,d.brace,d.squareBracket,d.angleBracket],class:"cm-punctuation"},{tag:[d.string,d.regexp,d.attributeValue,d.special(d.string),d.monospace],class:"cm-string"},{tag:d.escape,class:"cm-string-2"},{tag:[d.number,d.bool,d.atom,d.null,d.self],class:"cm-number"},{tag:[d.function(d.variableName),d.function(d.definition(d.variableName)),d.function(d.propertyName),d.standard(d.variableName),d.special(d.variableName)],class:"cm-builtin"},{tag:d.definition(d.variableName),class:"cm-def"},{tag:[d.variableName,d.local(d.variableName),d.constant(d.variableName),d.literal],class:"cm-variable"},{tag:d.propertyName,class:"cm-property"},{tag:d.attributeName,class:"cm-attribute"},{tag:[d.className,d.typeName,d.namespace],class:"cm-variable-3"},{tag:[d.tagName,d.labelName,d.annotation,d.macroName],class:"cm-tag"},{tag:d.link,class:"cm-link"},{tag:[d.heading,d.heading1,d.heading2,d.heading3,d.heading4,d.heading5,d.heading6],class:"cm-keyword"}]),E=Is.define([{tag:[d.comment,d.docComment,d.meta,d.documentMeta],color:r.colors.syntax.base.comment},{tag:[d.keyword,d.controlKeyword,d.moduleKeyword,d.definitionKeyword,d.modifier],color:r.colors.syntax.base.keyword},{tag:[d.operatorKeyword,d.operator,d.derefOperator,d.updateOperator,d.definitionOperator,d.typeOperator,d.controlOperator,d.logicOperator,d.bitwiseOperator,d.arithmeticOperator,d.compareOperator],color:r.colors.syntax.base.operator},{tag:[d.string,d.regexp,d.attributeValue,d.special(d.string),d.monospace],color:r.colors.syntax.base.string},{tag:d.escape,color:p.stringEscape||r.colors.syntax.base.string},{tag:[d.number,d.bool,d.atom,d.null,d.self],color:r.colors.syntax.base.number},{tag:[d.function(d.variableName),d.function(d.definition(d.variableName)),d.function(d.propertyName),d.standard(d.variableName),d.special(d.variableName)],color:r.colors.syntax.base.function},{tag:d.definition(d.variableName),color:p.variableGlobal||r.colors.syntax.base.variable},{tag:[d.variableName,d.local(d.variableName),d.constant(d.variableName),d.literal],color:r.colors.syntax.base.variable},{tag:d.propertyName,color:p.variableProperty||r.colors.syntax.base.variable},{tag:d.attributeName,color:p.variableOther||r.colors.syntax.base.variable},{tag:[d.className,d.typeName,d.namespace],color:r.colors.syntax.base.type},{tag:[d.tagName,d.labelName,d.annotation,d.macroName],color:p.tag||r.colors.syntax.base.keyword},{tag:d.link,color:p.url||r.colors.syntax.base.function,textDecoration:"underline"},{tag:[d.punctuation,d.separator,d.bracket,d.paren,d.brace,d.squareBracket,d.angleBracket],color:p.punctuation||r.colors.syntax.base.comment}]);return a?.syntaxColors===!1?[g]:[g,pr(di,{fallback:!0}),pr(vi),pr(y),pr(E)]}const Ai=180,ba=ei.define(),Ii=1,Bi=2,$i=4,oa=new Map,Wi=(r,a)=>{const u=`${r}|${a}`,f=oa.get(u);if(f)return f;let x="";r&&(x+=`color:${r};`),a&Ii&&(x+="font-style:italic;"),a&Bi&&(x+="font-weight:bold;"),a&$i&&(x+="text-decoration:underline;");const p=yr.mark({attributes:{style:x}});return oa.set(u,p),p},Vi=(r,a)=>{const u=new xn,f=r.state.doc,x=Math.min(a.length,f.lines);for(let p=0;p<x;p+=1){const b=a[p];if(!b||b.length===0)continue;const g=f.line(p+1);let y=g.from;for(const[E,k,L]of b){if(E<=0)continue;const M=y,R=Math.min(y+E,g.to);y+=E,!(R<=M)&&(!k&&!L||u.add(M,R,Wi(k,L)))}}return u.finish()},_i=xa.define({create(){return yr.none},update(r,a){let u=r.map(a.changes);for(const f of a.effects)f.is(ba)&&(u=f.value);return u},provide:r=>se.decorations.from(r)}),Hi=r=>va.fromClass(class{timer;generation=0;constructor(a){this.tokenize(a)}update(a){a.docChanged&&this.schedule(a.view)}schedule(a){this.timer&&clearTimeout(this.timer),this.timer=setTimeout(()=>{this.timer=void 0,this.tokenize(a)},Ai)}async tokenize(a){const u=++this.generation,f=a.state.doc.toString(),x=await Do(f,r.language,r.themeName,r.theme);x&&u===this.generation&&a.state.doc.length===f.length&&a.dispatch({effects:ba.of(Vi(a,x))})}destroy(){this.timer&&clearTimeout(this.timer)}}),qi=r=>[_i,Hi(r)];function Ki(r){return!(!r.autoSaveEnabled||!r.isDirty||!r.canWrite||r.isSaving||r.fileLoading||r.isNonEditableBinary||!r.selectedFilePath||r.loadedFilePath!==r.selectedFilePath)}function Gi(r){return r.selectedFilePath?r.isDirty?!(r.fileLoading||r.loadedFilePath!==r.selectedFilePath||r.isNonEditableBinary||r.draftContent===""&&r.fileContent!==""&&r.loadedFilePath!==r.selectedFilePath):!0:!1}const Ui=r=>{const a=I(r);if(!a)return"";if(a==="/"||/^[A-Za-z]:\/$/.test(a))return a;const u=a.lastIndexOf("/");if(u<0)return a;if(u===0)return"/";const f=a.slice(0,u);return/^[A-Za-z]:$/.test(f)?`${f}/`:f},Ji=({label:r,iconDataUrl:a})=>{const[u,f]=n.useState(!1),x=r.trim().slice(0,1).toUpperCase()||"?";return a&&!u?t.jsx("img",{src:a,alt:"",className:"size-4 rounded-sm",onError:()=>f(!0)}):t.jsx("span",{className:$("size-4 rounded-sm flex items-center justify-center","bg-[var(--surface-muted)] text-[9px] font-medium text-muted-foreground"),children:x})},Yi=r=>r.slice().sort((a,u)=>a.type!==u.type?a.type==="directory"?-1:1:a.name.localeCompare(u.name)),I=r=>{if(!r)return"";const a=r.replace(/\\/g,"/"),u=a.startsWith("//");let f=a.replace(/\/+/g,"/");u&&!f.startsWith("//")&&(f=`/${f}`);const x=f==="/",p=/^[A-Za-z]:\/$/.test(f);return!x&&!p&&(f=f.replace(/\/+$/,"")),f},Xi=r=>r.startsWith("/")||r.startsWith("//")||/^[A-Za-z]:\//.test(r),Et=r=>/^[A-Za-z]:\//.test(r)?r.toLowerCase():r,qt=(r,a)=>{const u=I(a),f=I(r);if(!u||!f)return!1;const x=Et(u),p=Et(f);return p===x||p.startsWith(`${x}/`)},ia=(r,a)=>{const u=I(a),f=I(r);if(!qt(f,u))return[];const p=f.slice(u.length).replace(/^\//,"").split("/"),b=[];let g=u;for(let y=0;y<p.length-1;y++)g=g?`${g}/${p[y]}`:p[y],b.push(g);return b},xr=(r,a)=>{if(!a)return"";const u=I(a);if(!r||!qt(u,r))return u;const f=u.slice(r.length);return f.startsWith("/")?f.slice(1):f},Zi=new Set(["node_modules"]),Qi=({status:r})=>{const a={open:"var(--status-info)",modified:"var(--status-warning)","git-modified":"var(--status-warning)","git-added":"var(--status-success)","git-deleted":"var(--status-error)"}[r];return t.jsx("span",{className:"size-2 rounded-full",style:{backgroundColor:a}})},ca=({name:r})=>{const a=n.useRef(null),u=n.useRef(null),[f,x]=n.useState(!1);return n.useLayoutEffect(()=>{const p=a.current,b=u.current;if(!p||!b)return;const g=()=>{x(b.scrollWidth>p.clientWidth+1)};g();const y=new ResizeObserver(g);return y.observe(p),y.observe(b),()=>{y.disconnect()}},[r]),t.jsxs("span",{ref:a,className:"relative block min-w-0 flex-1 overflow-hidden whitespace-nowrap",children:[t.jsx("span",{ref:u,"aria-hidden":"true",className:"invisible absolute whitespace-nowrap",children:r}),f?t.jsxs("span",{className:"open-file-name-marquee-track",children:[t.jsx("span",{className:"open-file-name-marquee-item",children:r}),t.jsx("span",{className:"open-file-name-marquee-item","aria-hidden":"true",children:r})]}):t.jsx("span",{className:"block min-w-0 truncate",children:r})]})},ec=r=>Zi.has(r),tc=r=>{const a=I(r);return a==="node_modules"||a.endsWith("/node_modules")||a.includes("/node_modules/")},rc=r=>{const u=(r instanceof Error?r.message:String(r??"")).toLowerCase();return u.includes("is a directory")||u.includes("eisdir")},la=r=>{const u=(r instanceof Error?r.message:String(r??"")).toLowerCase();return u.includes("file not found")||u.includes("enoent")||u.includes("no such file")||u.includes("does not exist")},Ht=2e5,nc=r=>{let a=0,u=0;for(let f=0;f<r.length;f+=1)r.charCodeAt(f)===10&&(f>0&&r.charCodeAt(f-1)===13?a+=1:u+=1);return a>u?`\r
2
2
  `:`
3
3
  `},wa=r=>r.replace(/\r\n/g,`
4
4
  `).replace(/\r/g,`