@openchamber/web 1.18.3 → 1.18.4

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 (60) hide show
  1. package/dist/assets/{CodeMirrorCommentWidgets-DbUi6I9s.js → CodeMirrorCommentWidgets-4qZbrEXU.js} +1 -1
  2. package/dist/assets/{CommitSection-Jc2_hNPE.js → CommitSection-MJmntVPJ.js} +1 -1
  3. package/dist/assets/{DiagramEditor-PCrYHBko.js → DiagramEditor-jnG3Hbxg.js} +1 -1
  4. package/dist/assets/{DiagramView-CndEcZNu.js → DiagramView-CFXxgg_a.js} +1 -1
  5. package/dist/assets/{DiffView-DEGlNjMH.js → DiffView-DZIoOnV7.js} +1 -1
  6. package/dist/assets/{FilesView-CzUgIvUm.js → FilesView-BKL6YlKG.js} +1 -1
  7. package/dist/assets/{GitView-C-n17voy.js → GitView-DBFrDDBv.js} +1 -1
  8. package/dist/assets/{JsonTreeView-BYcgdTOQ.js → JsonTreeView-DLW2Wy1g.js} +1 -1
  9. package/dist/assets/MarkdownImageGallery-DKIylIK7.js +1 -0
  10. package/dist/assets/MarkdownRendererImpl-CLv8hxvv.js +12 -0
  11. package/dist/assets/{OnboardingScreen-BmN0lhk4.js → OnboardingScreen-D2Y6djMw.js} +1 -1
  12. package/dist/assets/{PatchDiff-Bn7bfgUv.js → PatchDiff-BuLPx7AN.js} +1 -1
  13. package/dist/assets/{PierreDiffViewer-D1fWvrUn.js → PierreDiffViewer-BHm4Yr0X.js} +1 -1
  14. package/dist/assets/{PlanView-CWM0iyFk.js → PlanView-ZYEJn8A_.js} +1 -1
  15. package/dist/assets/{SessionSwitcherDropdown-Cez-9xRh.js → SessionSwitcherDropdown-rro-SsaO.js} +1 -1
  16. package/dist/assets/{SettingsView-Bl1drwPw.js → SettingsView-5RmswFZe.js} +1 -1
  17. package/dist/assets/{SettingsWindow-DL5axjDZ.js → SettingsWindow-BZhAYFdS.js} +1 -1
  18. package/dist/assets/{ToolOutputDialog-BtIJkFno.js → ToolOutputDialog-Za6V4VMJ.js} +1 -1
  19. package/dist/assets/{ToolPartDiffPreview-i3PQo6_0.js → ToolPartDiffPreview-BL-9ixyC.js} +1 -1
  20. package/dist/assets/{VirtualizedFileDiff-DkcusvMa.js → VirtualizedFileDiff-CwGocYQd.js} +1 -1
  21. package/dist/assets/{WalkthroughView-Cc5Hd6P5.js → WalkthroughView-5DyvN03T.js} +1 -1
  22. package/dist/assets/{computeVirtualFileMetrics-xPena3W2.js → computeVirtualFileMetrics-Da00Jg7M.js} +1 -1
  23. package/dist/assets/{contextPanelEmbeddedChat-tQekJUAF.js → contextPanelEmbeddedChat-B-bSg3P5.js} +1 -1
  24. package/dist/assets/index-BzIpNlNE.css +1 -0
  25. package/dist/assets/{index-Crz1YOFl.js → index-C0yNhuZw.js} +1 -1
  26. package/dist/assets/{index-iFY_N5aO.js → index-DRpChWux.js} +1 -1
  27. package/dist/assets/{isDiffPlainText-Dudf-dWx.js → isDiffPlainText-D9YpoLrV.js} +1 -1
  28. package/dist/assets/{isFilePlainText-DS4QV1dd.js → isFilePlainText-gTibdNIe.js} +1 -1
  29. package/dist/assets/{main-C0DyIwTb.js → main-D7UcL3VQ.js} +2 -2
  30. package/dist/assets/{main-CAxX6DAN.js → main-DPMd2iKS.js} +4 -4
  31. package/dist/assets/markdownCore-DDrHVneM.js +2 -0
  32. package/dist/assets/{miniChat-CGfrxKpJ.js → miniChat-O_GVoEbc.js} +2 -2
  33. package/dist/assets/{mobile-DEmhwNcV.js → mobile-Br4TtAqc.js} +2 -2
  34. package/dist/assets/{patchFileDiff-C5D1OPCa.js → patchFileDiff-KNkxM1C1.js} +1 -1
  35. package/dist/assets/{renderElectronMiniChatApp-Dpbswpom.js → renderElectronMiniChatApp-CJpdxTT1.js} +2 -2
  36. package/dist/assets/{renderMobileApp-B5HA4qbi.js → renderMobileApp-toj9cXoh.js} +4 -4
  37. package/dist/assets/{runtimeEndpointReset-cbahJ3hD.js → runtimeEndpointReset-BVmispdD.js} +2 -2
  38. package/dist/assets/{scheduledTasksApi-BxgGWTL8.js → scheduledTasksApi-ByKya3Un.js} +1 -1
  39. package/dist/assets/{shikiHighlight-CmanopUB.js → shikiHighlight-C7LTbwFx.js} +1 -1
  40. package/dist/assets/{useAppFontEffects-sHmU5b8u.js → useAppFontEffects-BikB6enL.js} +131 -131
  41. package/dist/assets/{useInlineCommentController-gt56WkxJ.js → useInlineCommentController-CYPvYJDt.js} +1 -1
  42. package/dist/assets/{vendor-codemirror-language-data-Dihw9MtL.js → vendor-codemirror-language-data-CLHw8NWn.js} +2 -2
  43. package/dist/assets/{web-components-BL-Ur2Tb.js → web-components-GMc3oR3i.js} +1 -1
  44. package/dist/index.html +4 -4
  45. package/dist/mini-chat.html +3 -3
  46. package/dist/mobile.html +3 -3
  47. package/package.json +1 -1
  48. package/server/lib/dev-tunnel/client.js +20 -1
  49. package/server/lib/dev-tunnel/tunnel.test.js +9 -0
  50. package/server/lib/markdown-image-grants/DOCUMENTATION.md +36 -0
  51. package/server/lib/markdown-image-grants/routes.js +340 -0
  52. package/server/lib/markdown-image-grants/routes.test.js +221 -0
  53. package/server/lib/opencode/feature-routes-runtime.js +11 -0
  54. package/server/lib/opencode/server-startup-runtime.js +22 -1
  55. package/server/lib/opencode/server-startup-runtime.test.js +44 -0
  56. package/dist/assets/MarkdownImageGallery-DzHwkVIH.js +0 -1
  57. package/dist/assets/MarkdownRendererImpl-DUcIcWgs.js +0 -12
  58. package/dist/assets/index-CVNuER6G.css +0 -1
  59. package/dist/assets/markdownCore-DhfzuGXu.js +0 -2
  60. package/dist/assets/markdownImageAssets-BTNlRyjd.js +0 -1
@@ -0,0 +1,12 @@
1
+ import{R as _,f as K,j as ee}from"./vendor-react-BUCujlKS.js";import{m as lt}from"./vendor-morphdom-B7dS_VPB.js";import{r as ct,a as dt}from"./vendor-beautiful-mermaid-DztCUpLZ.js";import{eZ as De,e_ as mt,e$ as ut,g as de,d3 as pt,d4 as ft,f0 as ht,f1 as gt,V as We,a0 as $e,f2 as qe,h as Be,dZ as bt,f as wt,f3 as yt,o as vt,f4 as be,f5 as At,f6 as kt,f7 as Et}from"./useAppFontEffects-BikB6enL.js";import{G as we,cf as Ct,u as G,ag as ye,C as ze,x as St,y as Lt,r as Mt}from"./index-DRpChWux.js";import{d as Nt}from"./contextPanelEmbeddedChat-B-bSg3P5.js";import{renderMarkdownSync as Rt,renderMarkdownBlocks as xt}from"./markdownCore-DDrHVneM.js";import{r as _t}from"./registerCustomTheme-BBXUCRnG.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-elkjs-BRwcR927.js";import"./vendor-entities-C3BA0AJP.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-zustand-BAGL70zf.js";import"./vendor-base-ui-D_V6hAcE.js";import"./vendor-floating-ui-utils-BzXdqYpP.js";import"./vendor-floating-ui-dom-WyXykhNi.js";import"./vendor-floating-ui-core-CXmKXOXc.js";import"./vendor-floating-ui-react-dom-DKpLs02S.js";import"./vendor-use-sync-external-store-D6wYuSt-.js";import"./vendor-class-variance-authority-5VPnzWs2.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-dnd-kit-core-BZknOX2w.js";import"./vendor-dnd-kit-utilities-B_MdXhJC.js";import"./vendor-dnd-kit-accessibility-BHxJPORy.js";import"./vendor-dnd-kit-sortable-CsEagZ81.js";import"./vendor-cmdk-DgLInKvT.js";import"./vendor-radix-ui-react-dialog-B94Bt2qq.js";import"./vendor-radix-ui-primitive-Dc_FVRD7.js";import"./vendor-radix-ui-react-compose-refs-DcAh5WdT.js";import"./vendor-radix-ui-react-context-Czxm7Z62.js";import"./vendor-radix-ui-react-id-f5BLKEVw.js";import"./vendor-radix-ui-react-use-layout-effect-D_3IhJdJ.js";import"./vendor-radix-ui-react-use-controllable-state-BFT5YmkA.js";import"./vendor-radix-ui-react-dismissable-layer-D7kXcwgJ.js";import"./vendor-radix-ui-react-primitive-DhVoX9SD.js";import"./vendor-radix-ui-react-slot-BQgQOasS.js";import"./vendor-radix-ui-react-use-callback-ref-BZPnuXAC.js";import"./vendor-radix-ui-react-use-escape-keydown-oph88g-F.js";import"./vendor-radix-ui-react-focus-scope-CiaxW4dD.js";import"./vendor-radix-ui-react-portal-BMJYHWck.js";import"./vendor-radix-ui-react-presence-CNxf-uq4.js";import"./vendor-radix-ui-react-focus-guards-B6qJXYua.js";import"./vendor-react-remove-scroll-DO7dCTnK.js";import"./vendor-tslib-De9GV7Vy.js";import"./vendor-react-remove-scroll-bar-BcFYyj3E.js";import"./vendor-react-style-singleton-q6EMHnwf.js";import"./vendor-get-nonce-C-Z93AgS.js";import"./vendor-use-sidecar-zDC0RhA3.js";import"./vendor-use-callback-ref-D3RC8gqK.js";import"./vendor-aria-hidden-DvXkyWUv.js";import"./vendor-codemirror-language-DUOssd4j.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-codemirror-state-CNWM3Q8V.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-codemirror-view-DSzLbZiS.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-Bbw3D7r0.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-codemirror-autocomplete-BjbBRsUA.js";import"./vendor-codemirror-lang-json-ryCw7nab.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-VgNqFSH-.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-B3Qe3OpS.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-FGQydhTc.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-CLHw8NWn.js";import"./vendor-codemirror-lang-python-N414WYK-.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-codemirror-commands-ARAOgp1x.js";import"./vendor-tanstack-react-virtual-g05Cx3z9.js";import"./vendor-tanstack-virtual-core-Dubg10g5.js";import"./vendor-framer-motion-CRSgBxjL.js";import"./vendor-motion-dom-DJLgZh4Q.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./vendor-sonner-DFyL3AvE.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./vendor-opencode-sdk-BJ73u-bH.js";import"./vendor-marked-CX41MkDF.js";import"./vendor-remend-BWYYytN3.js";import"./vendor-katex-k3Ppq1Ha.js";import"./vendor-dompurify-r8glNMJW.js";import"./themeResolver-BmJyTmjJ.js";import"./vendor-pierre-theming-C6Z4M5_u.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";const Ve="openchamber-md",Tt={name:Ve,colors:{"editor.background":"transparent","editor.foreground":"var(--md-syntax-foreground)"},tokenColors:[{scope:["comment","punctuation.definition.comment","string.comment"],settings:{foreground:"var(--md-syntax-comment)",fontStyle:"italic"}},{scope:["string","punctuation.definition.string","string.template"],settings:{foreground:"var(--md-syntax-string)"}},{scope:["constant.numeric","constant.language","constant.character","constant"],settings:{foreground:"var(--md-syntax-number)"}},{scope:["keyword","storage","storage.type","storage.modifier","keyword.control"],settings:{foreground:"var(--md-syntax-keyword)"}},{scope:["keyword.operator","punctuation.separator","punctuation.terminator"],settings:{foreground:"var(--md-syntax-operator)"}},{scope:["entity.name.function","support.function","meta.function-call"],settings:{foreground:"var(--md-syntax-function)"}},{scope:["entity.name.type","entity.name.class","support.type","support.class","entity.other.inherited-class"],settings:{foreground:"var(--md-syntax-type)"}},{scope:["variable","variable.other","variable.parameter","meta.definition.variable"],settings:{foreground:"var(--md-syntax-variable)"}},{scope:["variable.other.property","meta.property-name","support.type.property-name"],settings:{foreground:"var(--md-syntax-property)"}},{scope:["entity.name.tag","punctuation.definition.tag"],settings:{foreground:"var(--md-syntax-keyword)"}},{scope:["entity.other.attribute-name"],settings:{foreground:"var(--md-syntax-property)"}},{scope:["markup.bold","punctuation.definition.bold"],settings:{fontStyle:"bold"}},{scope:["markup.italic","punctuation.definition.italic"],settings:{fontStyle:"italic"}},{scope:["markup.heading","markup.heading entity.name"],settings:{foreground:"var(--md-syntax-keyword)",fontStyle:"bold"}},{scope:["markup.inserted","punctuation.definition.inserted"],settings:{foreground:"var(--md-syntax-inserted)"}},{scope:["markup.deleted","punctuation.definition.deleted"],settings:{foreground:"var(--md-syntax-deleted)"}},{scope:["invalid","invalid.illegal"],settings:{foreground:"var(--md-syntax-deleted)"}}]};let ve=!1;const Pt=()=>{ve||(ve=!0,_t(Ve,()=>Promise.resolve(Tt)))},x=t=>Number.isFinite(t)&&t>0,Ae=t=>{if(typeof t=="number")return x(t)?t:null;if(typeof t!="string")return null;const e=t.trim().match(/^([+-]?(?:(?:\d+\.?\d*)|(?:\.\d+))(?:[eE][+-]?\d+)?)(?:px)?$/);if(!e)return null;const r=Number(e[1]);return x(r)?r:null},me=(t,e,r)=>Math.min(r,Math.max(e,t)),Ft=6,ke=1.25,It=1.0015,Ot=.5,Dt=12,Ee=3,Wt=400,te='[data-markdown="mermaid-block"]',z=t=>t.querySelector(te)!==null,$t=t=>[t.x,t.y,t.width,t.height].map(e=>{const r=Number(e.toFixed(Ft));return Object.is(r,-0)?"0":String(r)}).join(" "),qt=t=>{const e=t.viewBox?.trim().split(/[\s,]+/).map(i=>Number.parseFloat(i));if(e?.length===4){const[i,o,s,a]=e;if(Number.isFinite(i)&&Number.isFinite(o)&&x(s)&&x(a))return{x:i,y:o,width:s,height:a}}const r=Ae(t.width),n=Ae(t.height);return r===null||n===null?null:{x:0,y:0,width:r,height:n}},Bt=t=>{let e=2166136261;for(let r=0;r<t.length;r+=1)e^=t.charCodeAt(r),e=Math.imul(e,16777619);return(e>>>0).toString(36)},zt=t=>{const e=t.renderMode||"unknown",r=t.svgMarkup??"";if(!r){const n=[t.viewBox??"",t.width??"",t.height??""];return n.some(i=>i!=="")?`${e}:bounds:${n.join(":")}`:`${e}:no-svg`}return[e,Bt(r)].join(":")},He=(t,e)=>{if(!x(e.width)||!x(e.height))return t;const r=t.width/t.height,n=e.width/e.height;if(r>n){const o=t.width/n;return{x:t.x,y:t.y-(o-t.height)/2,width:t.width,height:o}}const i=t.height*n;return{x:t.x-(i-t.width)/2,y:t.y,width:i,height:t.height}},Vt=({currentBox:t,viewport:e,delta:r})=>!x(e.width)||!x(e.height)||!x(t.width)||!x(t.height)?t:{x:t.x-r.x/e.width*t.width,y:t.y-r.y/e.height*t.height,width:t.width,height:t.height},Ht=(t,e)=>{const r=e.x-t.x,n=e.y-t.y;return r*r+n*n>Ee*Ee},Kt=({currentBox:t,contentBox:e,viewport:r,pointer:n,zoomFactor:i,minScale:o,maxScale:s})=>{if(!x(r.width)||!x(r.height)||!x(i)||!x(t.width)||!x(t.height)||!x(e.width)||!x(e.height)||!x(o)||!x(s))return t;const a=Math.min(o,s),l=Math.max(o,s),c=He(e,r),d=c.width/t.width,f=me(d*i,a,l),u=c.width/f,m=u/(t.width/t.height),g=me(n.x/r.width,0,1),A=me(n.y/r.height,0,1),k=t.x+g*t.width,v=t.y+A*t.height;return{x:k-g*u,y:v-A*m,width:u,height:m}},he=new WeakMap,jt=t=>t instanceof HTMLElement?he.get(t)??null:null,Ut=t=>t.querySelector('[data-markdown="mermaid-viewport"]')??t.querySelector('[data-markdown="mermaid"]'),Ce=t=>{const e=t.querySelector('[data-markdown="mermaid"] svg'),r=t.querySelector('[data-markdown="mermaid"]');return zt({renderMode:t.getAttribute("data-mermaid-render"),svgMarkup:r?.getAttribute("data-md-original-svg")??e?.outerHTML??null,viewBox:e?.getAttribute("viewBox"),width:e?.getAttribute("width"),height:e?.getAttribute("height")})},Q=t=>{const e=t.getBoundingClientRect();return{width:e.width,height:e.height}},Zt=(t,e)=>{const r=e.getBoundingClientRect();return{x:t.clientX-r.left,y:t.clientY-r.top}},Xt=t=>t instanceof Element&&!!t.closest('button, a, [role="button"]'),Gt=t=>{const e=Ut(t),r=t.querySelector('[data-markdown="mermaid"] svg');if(!e||!r)return null;const n=qt({viewBox:r.getAttribute("viewBox"),width:r.getAttribute("width"),height:r.getAttribute("height")});if(!n)return null;let i=n,o=null,s=null,a=null,l=null;const c=p=>{i=p,r.setAttribute("viewBox",$t(p)),r.removeAttribute("width"),r.removeAttribute("height")},d=()=>{c(He(n,Q(e)))},f=(p,C)=>{c(Kt({currentBox:i,contentBox:n,viewport:Q(e),pointer:p,zoomFactor:C,minScale:Ot,maxScale:Dt}))},u=()=>{const p=Q(e);f({x:p.width/2,y:p.height/2},ke)},m=()=>{const p=Q(e);f({x:p.width/2,y:p.height/2},1/ke)},g=p=>{!p.ctrlKey&&!p.metaKey||(p.preventDefault(),p.stopPropagation(),f(Zt(p,e),Math.pow(It,-p.deltaY)))},A=p=>{p.button!==0||Xt(p.target)||(o=p.pointerId,s={x:p.clientX,y:p.clientY},a=s,l!==null&&(window.clearTimeout(l),l=null),t.removeAttribute("data-mermaid-suppress-click"),e.setPointerCapture?.(p.pointerId),t.setAttribute("data-mermaid-panning","true"),p.preventDefault())},k=p=>{if(o!==p.pointerId||!a)return;const C={x:p.clientX,y:p.clientY};c(Vt({currentBox:i,viewport:Q(e),delta:{x:C.x-a.x,y:C.y-a.y}})),a=C,s&&Ht(s,C)&&t.setAttribute("data-mermaid-suppress-click","true"),p.preventDefault()},v=p=>{o===p.pointerId&&(e.releasePointerCapture?.(p.pointerId),o=null,s=null,a=null,t.removeAttribute("data-mermaid-panning"),t.hasAttribute("data-mermaid-suppress-click")&&(l=window.setTimeout(()=>{t.removeAttribute("data-mermaid-suppress-click"),l=null},Wt)))},S=()=>{d()};e.addEventListener("wheel",g,{passive:!1}),e.addEventListener("pointerdown",A),e.addEventListener("pointermove",k),e.addEventListener("pointerup",v),e.addEventListener("pointercancel",v),window.addEventListener("resize",S);const M=typeof ResizeObserver>"u"?null:new ResizeObserver(S);return M?.observe(e),d(),{zoomIn:u,zoomOut:m,fit:d,cleanup:()=>{e.removeEventListener("wheel",g),e.removeEventListener("pointerdown",A),e.removeEventListener("pointermove",k),e.removeEventListener("pointerup",v),e.removeEventListener("pointercancel",v),window.removeEventListener("resize",S),M?.disconnect(),l!==null&&window.clearTimeout(l),t.removeAttribute("data-mermaid-panning"),t.removeAttribute("data-mermaid-suppress-click"),he.delete(t)}}},Yt=t=>{const e=new Map,r=new Map,n=()=>{for(const[o,s]of Array.from(e.entries())){const a=Ce(o);(!t.contains(o)||a!==r.get(o))&&(s.cleanup(),e.delete(o),r.delete(o))}for(const o of Array.from(t.querySelectorAll(te))){if(e.has(o)||o.querySelector('[data-markdown="mermaid"] svg')===null)continue;const s=Gt(o);s&&(e.set(o,s),r.set(o,Ce(o)),he.set(o,s))}},i=()=>{for(const o of e.values())o.cleanup();e.clear(),r.clear()};return n(),{refresh:n,cleanup:i}},B=t=>`<svg class="remixicon size-3.5" viewBox="0 0 24 24" aria-hidden="true"><use href="#oc-${t}"></use></svg>`,re={copy:B("file-copy"),check:B("check"),download:B("download"),zoomIn:B("add"),zoomOut:B("subtract"),fit:B("refresh"),textWrap:B("text-wrap"),image:B("file-image")},Ke="p-1 rounded hover:bg-interactive-hover/60 text-muted-foreground hover:text-foreground transition-colors focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--interactive-focus-ring)]",ne=(t,e)=>{t.innerHTML=e},Jt=t=>{for(const e of Array.from(t.querySelectorAll('[data-openchamber-markdown-image-label="true"]'))){if(e.querySelector("[data-openchamber-markdown-image-label-icon]"))continue;const r=document.createElement("span");r.className="inline-flex shrink-0",r.setAttribute("aria-hidden","true"),r.setAttribute("data-openchamber-markdown-image-label-icon","true"),ne(r,re.image),e.prepend(r)}},W=(t,e,r)=>{const n=document.createElement("button");return n.type="button",n.className=Ke,n.setAttribute("data-md-action",r),n.setAttribute("title",e),n.setAttribute("aria-label",e),ne(n,re[t]),n},je=(t,e,r)=>{const n=t.querySelector("[data-md-code-body]"),i=t.querySelector("pre"),o=t.querySelector("pre code"),s=t.querySelectorAll("[data-md-code-line-content]"),a=t.querySelector('[data-md-action="toggle-code-wrap"]');t.setAttribute("data-code-wrap",e?"true":"false"),n?.classList.toggle("overflow-x-auto",!e),n?.classList.toggle("overflow-x-hidden",e),i?.classList.toggle("whitespace-pre-wrap",e),i?.classList.toggle("break-words",e),o?.classList.toggle("whitespace-pre-wrap",e),o?.classList.toggle("break-words",e),i&&(i.style.whiteSpace=e?"pre-wrap":"pre",i.style.overflowWrap=e?"anywhere":"normal"),o&&(o.style.whiteSpace=e?"pre-wrap":"pre",o.style.overflowWrap=e?"anywhere":"normal");for(const l of Array.from(s))l.style.whiteSpace=e?"pre-wrap":"pre",l.style.overflowWrap=e?"anywhere":"normal";if(a){const l=e?r.disableCodeWrap:r.enableCodeWrap;a.setAttribute("title",l),a.setAttribute("aria-label",l),a.classList.toggle("text-foreground",e),a.classList.toggle("opacity-100",e),a.classList.toggle("text-muted-foreground",!e),a.classList.toggle("opacity-65",!e),a.setAttribute("aria-pressed",e?"true":"false")}},Ue=t=>{const e=t.querySelector(":scope > code");if(!e||e.hasAttribute("data-md-code-lines"))return;const r=e.textContent??"",n=r.endsWith(`
2
+ `),i=n?r.slice(0,-1).split(`
3
+ `):r.split(`
4
+ `),o=i.length>0?i:[""],s=Array.from(e.children).filter(c=>c.classList.contains("line"));n&&s.length===o.length+1&&s.at(-1)?.textContent===""&&s.pop();const a=s.length===o.length,l=document.createDocumentFragment();o.forEach((c,d)=>{const f=document.createElement("span");f.setAttribute("data-md-code-line","");const u=document.createElement("span");u.setAttribute("data-md-code-line-number",""),u.setAttribute("aria-hidden","true"),u.textContent=String(d+1);const m=document.createElement("span");if(m.setAttribute("data-md-code-line-content",""),a){const g=s[d];g&&m.append(...Array.from(g.childNodes))}else m.textContent=c;if(f.append(u,m),l.appendChild(f),d<o.length-1||n){const g=document.createElement("span");g.setAttribute("data-md-code-line-break",""),g.textContent=`
5
+ `,l.appendChild(g)}}),e.replaceChildren(l),e.setAttribute("data-md-code-lines",""),e.toggleAttribute("data-md-code-trailing-newline",n)},Ze=t=>{const e=Array.from(t.querySelectorAll("[data-md-code-line-content]"));if(e.length===0)return t.textContent??"";const r=e.map(n=>n.textContent??"").join(`
6
+ `);return t.hasAttribute("data-md-code-trailing-newline")?`${r}
7
+ `:r},Qt=(t,e,r)=>{const n=t.querySelectorAll('[data-component="markdown-code"]');for(const i of Array.from(n)){const o=i.querySelector("pre");o&&Ue(o),je(i,e,r)}},Se=(t,e,r,n)=>{ne(t,re.check),t.setAttribute("title",e),t.setAttribute("aria-label",e),window.setTimeout(()=>{ne(t,re[r]),t.setAttribute("title",n),t.setAttribute("aria-label",n)},2e3)},er=t=>{const e=t.querySelectorAll(":not(pre) > code");for(const r of Array.from(e))r.getAttribute("data-markdown")!=="inline-code"&&r.setAttribute("data-markdown","inline-code")},tr=(t,e)=>{const r=t.querySelectorAll("pre");for(const n of Array.from(r)){if(n.querySelector("code.language-mermaid"))continue;const i=n.parentElement;if(!i||i.closest('[data-component="markdown-code"]'))continue;const o=n.querySelector("code")?.className.match(/language-([\w+#.-]+)/)?.[1],s=n.getAttribute("data-md-lang")??o??"text",a=document.createElement("div");a.setAttribute("data-component","markdown-code"),a.className="my-4 group overflow-hidden rounded-2xl border border-border/80 bg-[var(--surface-elevated)]";const l=document.createElement("div");l.className="flex items-center justify-between border-b border-border/70 px-3 py-1.5";const c=document.createElement("span");c.className="font-mono text-[13px] text-muted-foreground",c.textContent=s;const d=W("copy",e.labels.copy,"copy-code"),f=W("textWrap",e.codeBlockLineWrap?e.labels.disableCodeWrap:e.labels.enableCodeWrap,"toggle-code-wrap");l.appendChild(c);const u=document.createElement("div");u.className="flex items-center gap-1",u.setAttribute("data-md-code-actions",""),u.appendChild(f),u.appendChild(d),l.appendChild(u);const m=document.createElement("div");m.setAttribute("data-md-code-body",""),m.className="px-3 py-2.5 overflow-x-auto",i.replaceChild(a,n),n.style.margin="0",n.style.background="transparent",n.classList.add("min-w-0","w-full","flex-1"),e.deferCodeLineNumberSync||Ue(n),m.appendChild(n),a.appendChild(l),a.appendChild(m),je(a,e.codeBlockLineWrap,e.labels)}},Le=t=>{const e=[],r=[],n=t.querySelectorAll("thead th");for(const o of Array.from(n))e.push((o.textContent??"").trim());const i=t.querySelectorAll("tbody tr");for(const o of Array.from(i)){const s=Array.from(o.querySelectorAll("td")).map(a=>(a.textContent??"").trim());s.length>0&&r.push(s)}return{headers:e,rows:r}},rr=t=>/[",\n]/.test(t)?`"${t.replace(/"/g,'""')}"`:t,Me=({headers:t,rows:e})=>[t,...e].map(r=>r.map(rr).join(",")).join(`
8
+ `),nr=({headers:t,rows:e})=>[t,...e].map(r=>r.join(" ")).join(`
9
+ `),Ne=({headers:t,rows:e})=>{const r=`| ${t.join(" | ")} |`,n=`| ${t.map(()=>"---").join(" | ")} |`,i=e.map(o=>`| ${o.join(" | ")} |`).join(`
10
+ `);return`${r}
11
+ ${n}
12
+ ${i}`},Re=(t,e)=>{const r=document.createElement("div");r.className=`absolute top-full right-0 mt-1 hidden ${pt}`,r.style.backgroundColor="var(--surface-elevated)",r.style.color="var(--surface-elevated-foreground)",r.setAttribute("data-md-menu",t);for(const n of e){const i=document.createElement("button");i.type="button",i.className=`w-full text-left ${ft}`,i.setAttribute("data-md-action",`${t}-${n.key}`),i.textContent=n.label,r.appendChild(i)}return r},or=(t,e)=>{const r=t.querySelectorAll("table");for(const n of Array.from(r)){if(n.closest('[data-markdown="table-wrapper"]'))continue;const o=document.createElement("div");o.className="group my-4 flex flex-col space-y-2",o.setAttribute("data-markdown","table-wrapper");const s=document.createElement("div");s.className="flex items-center justify-end gap-1";const a=document.createElement("div");a.className="relative",a.appendChild(W("copy",e.copyTable,"table-copy-toggle")),a.appendChild(Re("table-copy",[{key:"csv",label:"CSV"},{key:"tsv",label:"TSV"},{key:"markdown",label:"Markdown"}]));const l=document.createElement("div");l.className="relative",l.appendChild(W("download",e.downloadTable,"table-download-toggle")),l.appendChild(Re("table-download",[{key:"csv",label:"CSV"},{key:"markdown",label:"Markdown"}])),s.appendChild(a),s.appendChild(l);const c=document.createElement("div");c.className="overflow-x-auto rounded-lg border border-border/80 bg-[var(--surface-elevated)]";const d=n.parentElement;if(!d)continue;d.replaceChild(o,n),n.setAttribute("data-markdown","table"),n.classList.add("w-full","border-collapse","text-sm");for(const u of Array.from(n.querySelectorAll("tr")))u.classList.add("border-b","border-border/60");const f=n.querySelector("tbody tr:last-child");f?.classList.remove("border-b"),f?.classList.add("border-0");for(const u of Array.from(n.querySelectorAll("th")))u.classList.add("border-r","border-border/60","px-4","py-2.5","text-left","align-middle","font-semibold","text-foreground","last:border-r-0");for(const u of Array.from(n.querySelectorAll("td")))u.classList.add("border-r","border-border/60","px-4","py-2.5","align-middle","text-foreground/90","last:border-r-0");c.appendChild(n),o.appendChild(s),o.appendChild(c)}},ir=(t,e)=>{const r=t.querySelectorAll("pre > code.language-mermaid");for(const n of Array.from(r)){const i=n.parentElement;if(!i)continue;const o=(n.textContent??"").replace(/\s+$/,""),s=e.renderMermaid(o),a=document.createElement("div");a.setAttribute("data-markdown","mermaid-block"),a.setAttribute("data-md-source",o),a.className="group relative";const l=document.createElement("div");l.setAttribute("data-markdown","mermaid-scroll");const c=document.createElement("div");if(c.setAttribute("data-markdown","mermaid-toolbar"),c.className="absolute top-1 right-2 flex items-center gap-1 opacity-0 group-hover:opacity-100 group-focus-within:opacity-100 transition-opacity",s.svg){a.setAttribute("data-mermaid-render","svg");const f=document.createElement("div");f.setAttribute("data-markdown","mermaid-viewport");const u=document.createElement("div");if(u.setAttribute("data-markdown","mermaid"),u.setAttribute("data-md-original-svg",s.svg),u.innerHTML=s.svg,f.appendChild(u),l.appendChild(f),e.mermaidControls.showPanZoomControls&&(c.appendChild(W("zoomIn",e.labels.zoomInDiagram,"mermaid-zoom-in")),c.appendChild(W("zoomOut",e.labels.zoomOutDiagram,"mermaid-zoom-out")),c.appendChild(W("fit",e.labels.resetDiagramView,"mermaid-fit"))),e.mermaidControls.copy){const m=W("copy",e.labels.copyDiagram,"mermaid-copy");m.setAttribute("data-md-source",o),c.appendChild(m)}if(e.mermaidControls.download){const m=W("download",e.labels.downloadDiagram,"mermaid-download");m.setAttribute("data-md-svg","1"),c.appendChild(m)}}else{a.setAttribute("data-mermaid-render","ascii");const f=document.createElement("pre");if(f.setAttribute("data-markdown","mermaid-ascii"),f.textContent=s.ascii||o,l.appendChild(f),e.mermaidControls.copy){const u=W("copy",e.labels.copyDiagram,"mermaid-copy");u.setAttribute("data-md-source",s.ascii||o),c.appendChild(u)}}a.appendChild(l),a.appendChild(c);const d=i.parentElement;d&&d.replaceChild(a,i)}},ar=(t,e)=>{const r=t.querySelectorAll("a[href]");for(const n of Array.from(r)){if(n.getAttribute("data-md-link-decorated")==="true"||n.getAttribute("data-openchamber-file-link")==="true")continue;const i=n.getAttribute("href")??"";if(!De(i))continue;n.setAttribute("data-md-link-decorated","true");const o=mt(i);if(o){const s=document.createElement("span");s.className="mr-1 inline-flex size-[18px] items-center justify-center rounded border border-[var(--border)] bg-[var(--interactive-hover)] align-middle";const a=document.createElement("img");a.src=o,a.alt="",a.setAttribute("aria-hidden","true"),a.loading="lazy",a.decoding="async",a.className="size-3.5 rounded-sm",a.addEventListener("error",()=>s.remove(),{once:!0}),s.appendChild(a),n.parentNode?.insertBefore(s,n)}if(e.onPreviewLoopback&&ut(i)){const s=document.createElement("button");s.type="button",s.className=`ml-1 align-middle ${Ke}`,s.setAttribute("data-md-action","preview-loopback"),s.setAttribute("data-md-url",i),s.setAttribute("title",e.labels.previewTitle),s.setAttribute("aria-label",e.labels.previewLabel),ne(s,re.download),n.parentNode?.insertBefore(s,n.nextSibling)}}},xe=(t,e)=>{Jt(t),er(t),ir(t,e),tr(t,e),or(t,e.labels),ar(t,e)},_e=(t,e,r)=>{const n=new Blob([e],{type:r}),i=URL.createObjectURL(n),o=document.createElement("a");o.href=i,o.download=t,document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(i)},ae=t=>{for(const e of Array.from(t.querySelectorAll("[data-md-menu]")))e.classList.add("hidden")},sr=(t,e)=>{const r=n=>{const i=n.target;if(!(i instanceof Element))return;const o=i.closest("[data-md-action]");if(!o){ae(t);return}const s=o.getAttribute("data-md-action")??"";if(s==="copy-code"){const a=o.closest('[data-component="markdown-code"]')?.querySelector("code"),l=a?Ze(a):"";l&&de(l).then(()=>Se(o,e.labels.copied,"copy",e.labels.copy));return}if(s==="toggle-code-wrap"){n.preventDefault(),e.onToggleCodeBlockLineWrap?.();return}if(s==="table-copy-toggle"||s==="table-download-toggle"){n.preventDefault();const a=o.parentElement?.querySelector("[data-md-menu]")??null,l=a?.classList.contains("hidden")??!1;ae(t),a&&l&&a.classList.remove("hidden");return}if(s.startsWith("table-copy-")){const a=s.replace("table-copy-",""),l=o.closest('[data-markdown="table-wrapper"]')?.querySelector("table");if(l instanceof HTMLTableElement){const c=Le(l),d=a==="csv"?Me(c):a==="tsv"?nr(c):Ne(c);de(d)}ae(t);return}if(s.startsWith("table-download-")){const a=s.replace("table-download-",""),l=o.closest('[data-markdown="table-wrapper"]')?.querySelector("table");if(l instanceof HTMLTableElement){const c=Le(l),d=a==="csv"?Me(c):Ne(c);_e(a==="csv"?"table.csv":"table.md",d,a==="csv"?"text/csv":"text/markdown")}ae(t);return}if(s==="mermaid-copy"){const a=o.getAttribute("data-md-source")??"";a&&de(a).then(()=>Se(o,e.labels.copied,"copy",e.labels.copyDiagram));return}if(s==="mermaid-zoom-in"||s==="mermaid-zoom-out"||s==="mermaid-fit"){n.preventDefault();const a=o.closest('[data-markdown="mermaid-block"]'),l=jt(a);s==="mermaid-zoom-in"?l?.zoomIn():s==="mermaid-zoom-out"?l?.zoomOut():l?.fit();return}if(s==="mermaid-download"){const a=o.closest('[data-markdown="mermaid-block"]')?.querySelector('[data-markdown="mermaid"]'),l=a?.getAttribute("data-md-original-svg")??a?.innerHTML??"";l&&_e("diagram.svg",l,"image/svg+xml;charset=utf-8");return}if(s==="preview-loopback"){n.preventDefault();const a=o.getAttribute("data-md-url")??"";a&&e.onPreviewLoopback?.(a);return}};return t.addEventListener("click",r),()=>t.removeEventListener("click",r)},Te=(t,e,r)=>{let n=0;for(const o of t){const s=n+o.data.length;if(e<s||e===s&&r==="left")return{node:o,offset:Math.max(0,e-n)};n=s}const i=t.at(-1);return i?{node:i,offset:i.data.length}:null},lr=new Set(["dockerfile","makefile","readme","license",".env",".gitignore",".npmrc"]),Pe=Array.from(lr).map(t=>t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("|"),cr=t=>gt(t),dr=t=>ht(t),mr=t=>{let e;try{e=new URL(t.trim())}catch{return null}if(e.protocol!=="file:"||e.hostname&&e.hostname!=="localhost")return null;try{const r=decodeURIComponent(e.pathname);return/^\/[A-Za-z]:\//.test(r)?r.slice(1):r.startsWith("/")?r:null}catch{return null}},ce=t=>{let e=(t||"").trim();return e?((e.startsWith("`")&&e.endsWith("`")||e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))&&(e=e.slice(1,-1).trim()),e=e.replace(/[.,;!?]+$/g,""),e.endsWith(")")&&!e.includes("(")&&(e=e.slice(0,-1)),e.endsWith("]")&&!e.includes("[")&&(e=e.slice(0,-1)),e):""},se=t=>{let e=ce(t);if(!e)return"";const r=e.indexOf(";");r>=0&&(e=e.slice(0,r)),e=e.replace(/#.*$/,"");const n=e.match(/^(.*\.[A-Za-z0-9_-]{1,16}):.*$/);n&&(e=n[1]??e);const i=Pe.length>0?e.match(new RegExp(`^(.*(?:/|^)(${Pe})):.*$`,"i")):null;return i&&(e=i[1]??e),ce(e)},Xe=t=>{const e=ce(t);if(!e)return null;const r=e.indexOf(";"),n=r>=0?ce(e.slice(0,r)):e;if(!n)return null;const i=n.match(/^(.*?):(\d+)-(\d+)$/);if(i){const l=se(i[1]??""),c=Number.parseInt(i[2]??"",10),d=Number.parseInt(i[3]??"",10);return!l||!Number.isFinite(c)||!Number.isFinite(d)||d<c?null:{path:l,line:c,endLine:d}}const o=n.match(/^(.*)#L(\d+)(?:C(\d+))?$/i);if(o){const l=se(o[1]??""),c=Number.parseInt(o[2]??"",10),d=o[3]?Number.parseInt(o[3],10):void 0;return!l||!Number.isFinite(c)?null:{path:l,line:c,column:Number.isFinite(d??Number.NaN)?d:void 0}}const s=n.match(/^(.*?):(\d+)(?::(\d+))?$/);if(s){const l=se(s[1]??""),c=Number.parseInt(s[2]??"",10),d=s[3]?Number.parseInt(s[3],10):void 0;return!l||!Number.isFinite(c)?null:{path:l,line:c,column:Number.isFinite(d??Number.NaN)?d:void 0}}const a=se(n);return a?{path:a}:null},ue=/(?:[A-Za-z]:[\\/])?[\w.\-/@+]*[\w\-/@+]\.[A-Za-z0-9]{1,8}(?::\d+(?:-\d+)?(?::\d+)?)?/g,Ge=()=>{const t=K.c(4),e=bt();let r;t[0]===Symbol.for("react.memo_cache_sentinel")?(r=ye(!1),t[0]=r):r=t[0];const n=r;let i;t[1]===Symbol.for("react.memo_cache_sentinel")?(i=ye(!0),t[1]=i):i=t[1];const o=i;let s;return t[2]!==e?.currentTheme?(s=e?.currentTheme??(typeof window<"u"&&window.matchMedia("(prefers-color-scheme: dark)").matches?o:n),t[2]=e?.currentTheme,t[3]=s):s=t[3],s},Ye=t=>{const e=K.c(4),{containerRef:r,enabled:n}=t;let i,o;e[0]!==r||e[1]!==n?(i=()=>{if(n===!1)return;const s=r.current;if(!s)return;const a=Fr;return s.addEventListener("click",a),()=>{s.removeEventListener("click",a)}},o=[r,n],e[0]=r,e[1]=n,e[2]=i,e[3]=o):(i=e[2],o=e[3]),_.useEffect(i,o)},J={download:!0,copy:!0,showPanZoomControls:!0},Je=!0,ur=t=>{const e=t.match(/^(?:\uFEFF)?(---|\+\+\+)[^\S\r\n]*\r?\n[\s\S]*?\r?\n\1[^\S\r\n]*(?:\r?\n|$)/);return e?t.slice(e[0].length):t},Fe='[data-openchamber-file-link="true"]',Qe="data-openchamber-block-path-token",et=`[${Qe}]`,Y="data-openchamber-block-paths-scanned",pr=2e5,fr=4,hr=1e3,gr=200,br=80,wr=40,Ie=160,V=new Map;let le=0;const Oe=[],yr=()=>ze()?gr:hr,vr=()=>ze()?wr:br,Ar=new Set(["dockerfile","makefile","readme","license",".env",".gitignore",".npmrc"]),ge=t=>cr(t),kr=t=>dr(t),Er=(t,e)=>Et(t,e),Cr=t=>{const e=t.split("/").filter(Boolean).pop()??"";return!e||e.endsWith(".")?!1:/\.[A-Za-z0-9_-]{1,16}$/.test(e)},tt=t=>{if(!t||t.startsWith("--")||t.includes("://")||/[<>]/.test(t)||/\s{2,}/.test(t))return!1;const e=ge(t),r=e.split("/").filter(Boolean).pop()??e;if(!r||r==="."||r==="..")return!1;const n=r.toLowerCase();return Ar.has(n)||n.startsWith(".")&&n.length>1?!0:Cr(e)},rt=t=>{const e=Xe(t);return e?tt(e.path):!1},Sr=t=>{const e=t.querySelectorAll(et);for(const n of Array.from(e))n.replaceWith(t.ownerDocument.createTextNode(n.textContent??""));const r=t.querySelectorAll(`code[${Y}]`);for(const n of Array.from(r))n.removeAttribute(Y),n.normalize()},pe=t=>{if(t.tagName.toLowerCase()==="a"){const e=t.getAttribute("href")?.trim(),r=e?mr(e):null;if(r)return r;if(e&&rt(e))return e}return(t.textContent||"").trim()},Lr=t=>{const e=t.querySelectorAll("pre code");if(e.length===0)return;const r=t.ownerDocument;if(r)for(const n of Array.from(e)){if(n.getAttribute(Y)==="true")continue;if((n.textContent??"").length>pr){n.setAttribute(Y,"true");continue}const i=r.createTreeWalker(n,NodeFilter.SHOW_TEXT),o=[];let s=i.nextNode();for(;s;){const d=s;d.parentElement?.closest("[data-md-code-line-number]")||o.push(d),s=i.nextNode()}const a=Ze(n);if(!a.includes(".")){n.setAttribute(Y,"true");continue}ue.lastIndex=0;const l=[];let c=ue.exec(a);for(;c;){const d=c[0];d&&rt(d)&&l.push({start:c.index,end:c.index+d.length,raw:d}),c=ue.exec(a)}for(const{start:d,end:f,raw:u}of l.reverse()){const m=Te(o,d,"right"),g=Te(o,f,"left");if(!m||!g)continue;const A=r.createRange();A.setStart(m.node,m.offset),A.setEnd(g.node,g.offset);const k=r.createElement("span");k.setAttribute(Qe,"true"),k.textContent=u,A.deleteContents(),A.insertNode(k)}n.setAttribute(Y,"true")}},fe=(t,e)=>{const r=Xe(t);if(!r||!tt(r.path))return null;const n=kr(r.path)?ge(r.path):Er(e,r.path);return n?{...r,resolvedPath:n}:null},Mr=t=>{const e=ge(t);if(!e)return Promise.resolve(!1);const r=V.get(e);if(r)return V.delete(e),V.set(e,r),r;const n=new Promise(o=>{const s=()=>{le+=1,Mt(`/api/fs/stat?path=${encodeURIComponent(e)}&optional=true`,{method:"GET",cache:"no-store"}).then(async a=>{if(!a.ok){o(!1);return}const l=await a.json().catch(()=>null);o(l?.exists!==!1)}).catch(()=>o(!1)).finally(()=>{le=Math.max(0,le-1),Oe.shift()?.()})};if(le<fr){s();return}Oe.push(s)}),i=yr();for(;V.size>=i;){const o=V.keys().next().value;if(typeof o!="string")break;V.delete(o)}return V.set(e,n),n},Nr=(t,e)=>t||kt(t,e),nt=t=>{const e=K.c(7),{containerRef:r,effectiveDirectory:n,editor:i,preferRuntimeEditor:o,enabled:s}=t,a=_.useRef(null);let l,c;e[0]!==r||e[1]!==i||e[2]!==n||e[3]!==s||e[4]!==o?(l=()=>{const d=r.current;if(!d)return;let f=!1;const u=vr(),m=s&&!Nt(),g=Ir,A=()=>{const y=d.querySelectorAll(Fe);for(const b of Array.from(y))g(b);Sr(d)};if(!m){A();return}const k=y=>{const b=y;if(a.current!==null&&typeof window<"u"&&window.clearTimeout(a.current),typeof window>"u"){v();return}a.current=window.setTimeout(()=>{a.current=null,window.requestAnimationFrame(()=>{f||v()})},b)},v=()=>{m&&Lr(d);const y=d.querySelectorAll(`[data-markdown="inline-code"], a, ${et}`);let b=0;for(const h of Array.from(y)){const T=pe(h),w=fe(T,n);if(g(h),!w||b>=u)continue;b=b+1,(St()&&Lt()&&!be(w.resolvedPath,n)?Promise.resolve(!0):Mr(w.resolvedPath)).then(I=>{if(f||!I||!d.contains(h))return;const P=pe(h),O=fe(P,n);!O||O.resolvedPath!==w.resolvedPath||(h.setAttribute("data-openchamber-file-link","true"),h.setAttribute("data-openchamber-file-ref",P),h.setAttribute("data-openchamber-file-path",O.resolvedPath),h.setAttribute("title","Open file"),h.tagName.toLowerCase()!=="a"&&(h.setAttribute("role","button"),h.setAttribute("tabindex","0")))})}},S=async y=>{const b=y.getAttribute("data-openchamber-file-ref")||pe(y),h=fe(b,n);if(!h)return;const T=Nr(n,h.resolvedPath);if(o&&i){i.openFile(h.resolvedPath,Number.isFinite(h.line??Number.NaN)?Math.max(1,Math.trunc(h.line)):void 0,Number.isFinite(h.column??Number.NaN)?Math.max(1,Math.trunc(h.column)):void 0);return}be(h.resolvedPath,n)||await At(h.resolvedPath,n);const w=G.getState();Number.isFinite(h.line??Number.NaN)?w.openContextFileAtLine(T,h.resolvedPath,Math.max(1,Math.trunc(h.line)),Number.isFinite(h.column??Number.NaN)?Math.max(1,Math.trunc(h.column)):1):w.openContextFile(T,h.resolvedPath)},M=y=>{const b=y.target;if(!(b instanceof Element))return;const h=b.closest(Fe);h instanceof HTMLElement&&(y.preventDefault(),y.stopPropagation(),S(h))},p=y=>{if(y.key!=="Enter"&&y.key!==" ")return;const b=y.target;!(b instanceof HTMLElement)||b.getAttribute("data-openchamber-file-link")!=="true"||(y.preventDefault(),y.stopPropagation(),S(b))};k(Ie);const C=new MutationObserver(()=>{k(Ie)});return C.observe(d,{childList:!0,subtree:!0}),d.addEventListener("click",M),d.addEventListener("keydown",p),()=>{f=!0,a.current!==null&&typeof window<"u"&&window.clearTimeout(a.current),a.current=null,C.disconnect(),d.removeEventListener("click",M),d.removeEventListener("keydown",p)}},c=[r,i,n,o,s],e[0]=r,e[1]=i,e[2]=n,e[3]=s,e[4]=o,e[5]=l,e[6]=c):(l=e[5],c=e[6]),_.useEffect(l,c)},ot=t=>{const e=K.c(7),{containerRef:r,onShowPopup:n,enableFullscreen:i,enablePanZoom:o,allowMermaidWheelEvents:s}=t;let a,l;e[0]!==s||e[1]!==r||e[2]!==i||e[3]!==o||e[4]!==n?(a=()=>{const c=r.current;if(!c)return;const d=u=>{if(!i||!n)return;const m=u.target;if(!(m instanceof Element)||m.closest('button, a, [role="button"]'))return;const g=m.closest(te);if(!g)return;if(g instanceof HTMLElement&&g.hasAttribute("data-mermaid-suppress-click")){g.removeAttribute("data-mermaid-suppress-click");return}const k=Array.from(c.querySelectorAll(te)).indexOf(g);if(k<0)return;const v=g instanceof HTMLElement?g.getAttribute("data-md-source"):null;if(!v||v.trim().length===0)return;const S=`Diagram ${k+1}`;n({open:!0,title:S,content:"",metadata:{tool:"mermaid-preview",filename:S},mermaid:{url:`data:text/plain;charset=utf-8,${encodeURIComponent(v)}`,source:v,filename:S}})},f=u=>{if(s||(u.ctrlKey||u.metaKey)&&o)return;const m=u.target;!(m instanceof Element)||!m.closest(te)||u.stopPropagation()};return c.addEventListener("click",d),c.addEventListener("wheel",f,{capture:!0,passive:!0}),()=>{c.removeEventListener("click",d),c.removeEventListener("wheel",f,!0)}},l=[s,r,i,o,n],e[0]=s,e[1]=r,e[2]=i,e[3]=o,e[4]=n,e[5]=a,e[6]=l):(a=e[5],l=e[6]),_.useEffect(a,l)},H=new Map,Rr=100,xr=(t,e)=>{const r=H.get(t);if(r)return H.delete(t),H.set(t,r),r;const n=e();if(H.set(t,n),H.size>Rr){const i=H.keys().next().value;i&&H.delete(i)}return n},_r=t=>({bg:t.colors.surface.elevated,fg:t.colors.surface.foreground,line:t.colors.interactive.border,accent:t.colors.primary.base,muted:t.colors.surface.mutedForeground,surface:t.colors.surface.muted,border:t.colors.interactive.border,transparent:!0,font:"system-ui, sans-serif"}),it=(t,e,r,n=J)=>{const{t:i}=wt(),o=_.useMemo(()=>({copy:i("markdownRenderer.code.actions.copyTitle"),copied:i("markdownRenderer.code.actions.copiedTitle"),enableCodeWrap:i("markdownRenderer.code.actions.enableWrapTitle"),disableCodeWrap:i("markdownRenderer.code.actions.disableWrapTitle"),copyTable:i("markdownRenderer.table.actions.copyTitle"),downloadTable:i("markdownRenderer.table.actions.downloadTitle"),copyDiagram:i("markdownRenderer.mermaid.actions.copySourceTitle"),downloadDiagram:i("markdownRenderer.mermaid.actions.downloadSvgTitle"),zoomInDiagram:i("markdownRenderer.mermaid.actions.zoomInTitle"),zoomOutDiagram:i("markdownRenderer.mermaid.actions.zoomOutTitle"),resetDiagramView:i("markdownRenderer.mermaid.actions.resetViewTitle"),previewLabel:i("terminalView.preview.open"),previewTitle:i("terminalView.preview.openTitle")}),[i]),s=G(c=>c.codeBlockLineWrap),a=G(c=>c.setCodeBlockLineWrap),l=_.useCallback(()=>{a(!G.getState().codeBlockLineWrap)},[a]);return _.useMemo(()=>{const c=_r(t),d=G.getState().mermaidRenderingMode,f=t.metadata?.id??"theme";return{labels:o,mermaidControls:n,codeBlockLineWrap:s,deferCodeLineNumberSync:e,onToggleCodeBlockLineWrap:l,renderMermaid:m=>xr(`${f}:${d}:${m}`,()=>{try{return d==="ascii"?{ascii:ct(m)}:{svg:dt(m,c)}}catch{return{}}}),onPreviewLoopback:r}},[t,o,n,s,e,l,r])},at=t=>{const e=K.c(35),{containerRef:r,text:n,streaming:i,cacheKey:o,imageMode:s,syntaxVars:a,ctx:l}=t,c=s===void 0?"inline":s;let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d=[],e[0]=d):d=e[0],_.useEffect(Or,d);const f=_.useRef(null);let u;e[1]!==r?(u=()=>{const w=r.current;if(w){if(!f.current){if(!z(w))return;f.current=Yt(w);return}f.current.refresh()}},e[1]=r,e[2]=u):u=e[2];const m=u;let g,A;e[3]!==r||e[4]!==l||e[5]!==c||e[6]!==m||e[7]!==n?(g=()=>{const w=r.current,E=w?.querySelector("[data-markdown-content]")??w;if(E&&n&&E.childNodes.length===0){const N=document.createElement("div");N.setAttribute("data-md-block",""),N.style.display="contents",N.innerHTML=Rt(n,c),xe(N,l),E.appendChild(N),z(N)&&m()}},A=[r,n,c,l,m],e[3]=r,e[4]=l,e[5]=c,e[6]=m,e[7]=n,e[8]=g,e[9]=A):(g=e[8],A=e[9]),_.useLayoutEffect(g,A);let k,v;e[10]===Symbol.for("react.memo_cache_sentinel")?(k=()=>()=>{f.current?.cleanup(),f.current=null},v=[],e[10]=k,e[11]=v):(k=e[10],v=e[11]),_.useEffect(k,v);let S,M;e[12]!==o||e[13]!==r||e[14]!==l||e[15]!==c||e[16]!==m||e[17]!==i||e[18]!==n?(S=()=>{const w=r.current;if(!w)return;const E=w.querySelector("[data-markdown-content]")??w;let N=!0;return xt(n,i,o,c).then(I=>{if(!N)return;const P=Array.from(E.children);I.forEach((R,F)=>{let L=P[F];if(L||(L=document.createElement("div"),L.setAttribute("data-md-block",""),L.style.display="contents",E.appendChild(L)),L.getAttribute("data-md-id")===R.id)return;const $=document.createElement("div");$.innerHTML=R.html,xe($,l);const j=z(L),q=z($);lt(L,$,{childrenOnly:!0,onBeforeElUpdated:Dr}),L.setAttribute("data-md-id",R.id),(j||q||z(L))&&m()});const O=z(E);let D=!1;for(let R=P.length-1;R>=I.length;R=R-1,R){const F=P[R];F&&z(F)&&(D=!0),F?.remove()}(D||P.length>I.length&&O)&&m()}),()=>{N=!1}},M=[r,n,i,o,c,l,m],e[12]=o,e[13]=r,e[14]=l,e[15]=c,e[16]=m,e[17]=i,e[18]=n,e[19]=S,e[20]=M):(S=e[19],M=e[20]),_.useEffect(S,M);let p,C;e[21]!==r||e[22]!==l?(p=()=>{const w=r.current;if(w)return sr(w,l)},C=[r,l],e[21]=r,e[22]=l,e[23]=p,e[24]=C):(p=e[23],C=e[24]),_.useEffect(p,C);let y,b;e[25]!==r||e[26]!==a?(y=()=>{const w=r.current,E=w?.querySelector("[data-markdown-content]")??w;if(E)for(const[N,I]of Object.entries(a))E.style.setProperty(N,I)},b=[r,a],e[25]=r,e[26]=a,e[27]=y,e[28]=b):(y=e[27],b=e[28]),_.useEffect(y,b);let h,T;e[29]!==r||e[30]!==l.codeBlockLineWrap||e[31]!==l.deferCodeLineNumberSync||e[32]!==l.labels?(h=()=>{const w=r.current,E=w?.querySelector("[data-markdown-content]")??w;E&&(l.deferCodeLineNumberSync||Qt(E,l.codeBlockLineWrap,l.labels))},T=[r,l.codeBlockLineWrap,l.deferCodeLineNumberSync,l.labels],e[29]=r,e[30]=l.codeBlockLineWrap,e[31]=l.deferCodeLineNumberSync,e[32]=l.labels,e[33]=h,e[34]=T):(h=e[33],T=e[34]),_.useEffect(h,T)},st=t=>t==="tool"?"markdown-content markdown-tool":t==="reasoning"?"markdown-content markdown-reasoning":"markdown-content leading-relaxed",Tr=t=>{const e=K.c(33),{content:r,part:n,messageId:i,isAnimated:o,skipFadeIn:s,className:a,isStreaming:l,disableStreamAnimation:c,variant:d,onShowPopup:f,enableFileReferences:u}=t,m=o===void 0?!0:o,g=s===void 0?!1:s,A=l===void 0?!1:l,k=c===void 0?!1:c,v=d===void 0?"assistant":d,S=u===void 0?!0:u;we("ui.markdown_renderer.render"),A&&we("ui.markdown_renderer.render.streaming"),Ct("ui.markdown_renderer.content_len",r.length);const M=Ge(),{editor:p,runtime:C}=We(),y=_.useRef(null),b=$e()??"",h=G(Wr);let T;e[0]!==b||e[1]!==h?(T=X=>{b&&h(b,X)},e[0]=b,e[1]=h,e[2]=T):T=e[2];const w=T,E=A&&!k;let N;e[3]!==f?(N={containerRef:y,onShowPopup:f,enableFullscreen:Je,enablePanZoom:J.showPanZoomControls},e[3]=f,e[4]=N):N=e[4],ot(N);const I=S&&!A;let P;e[5]!==p||e[6]!==b||e[7]!==C.isVSCode||e[8]!==I?(P={containerRef:y,effectiveDirectory:b,editor:p,preferRuntimeEditor:C.isVSCode,enabled:I},e[5]=p,e[6]=b,e[7]=C.isVSCode,e[8]=I,e[9]=P):P=e[9],nt(P);let O;e[10]===Symbol.for("react.memo_cache_sentinel")?(O={containerRef:y},e[10]=O):O=e[10],Ye(O);let D;e[11]!==M?(D=qe(M),e[11]=M,e[12]=D):D=e[12];const R=D,F=it(M,E,b?w:void 0,J),L=`markdown-${n?.id?`part-${n.id}`:`message-${i}`}`,$=v==="assistant"?"label":"inline";let j;e[13]!==L||e[14]!==r||e[15]!==F||e[16]!==E||e[17]!==R||e[18]!==$?(j={containerRef:y,text:r,streaming:E,cacheKey:L,imageMode:$,syntaxVars:R,ctx:F},e[13]=L,e[14]=r,e[15]=F,e[16]=E,e[17]=R,e[18]=$,e[19]=j):j=e[19],at(j);let q;e[20]!==a?(q=Be("break-words w-full min-w-0",a),e[20]=a,e[21]=q):q=e[21];let U;e[22]!==v?(U=st(v),e[22]=v,e[23]=U):U=e[23];let Z;e[24]!==U?(Z=ee.jsx("div",{className:U,"data-markdown-content":!0}),e[24]=U,e[25]=Z):Z=e[25];let oe;e[26]!==q||e[27]!==Z?(oe=ee.jsx("div",{className:q,ref:y,children:Z}),e[26]=q,e[27]=Z,e[28]=oe):oe=e[28];const ie=oe;if(m){let X;return e[29]!==L||e[30]!==ie||e[31]!==g?(X=ee.jsx(yt,{skipAnimation:g,children:ie},L),e[29]=L,e[30]=ie,e[31]=g,e[32]=X):X=e[32],X}return ie},Wo=_.memo(Tr,(t,e)=>t.content===e.content&&t.isStreaming===e.isStreaming&&t.disableStreamAnimation===e.disableStreamAnimation&&t.variant===e.variant&&t.isAnimated===e.isAnimated&&t.skipFadeIn===e.skipFadeIn&&t.className===e.className&&t.messageId===e.messageId&&t.onShowPopup===e.onShowPopup&&t.enableFileReferences===e.enableFileReferences&&t.part?.id===e.part?.id),Pr=t=>{const e=K.c(30),{content:r,className:n,variant:i,disableLinkSafety:o,stripFrontmatter:s,onShowPopup:a,mermaidControls:l,allowMermaidWheelEvents:c,enableFileReferences:d}=t,f=i===void 0?"assistant":i,u=s===void 0?!1:s,m=l===void 0?J:l,g=c===void 0?!1:c,A=d===void 0?!0:d,{editor:k,runtime:v}=We(),S=Ge(),M=_.useRef(null),p=$e()??"";let C;e[0]!==r||e[1]!==u?(C=u?ur(r):r,e[0]=r,e[1]=u,e[2]=C):C=e[2];const y=C;let b;e[3]!==g||e[4]!==m.showPanZoomControls||e[5]!==a?(b={containerRef:M,onShowPopup:a,enableFullscreen:Je,enablePanZoom:m.showPanZoomControls,allowMermaidWheelEvents:g},e[3]=g,e[4]=m.showPanZoomControls,e[5]=a,e[6]=b):b=e[6],ot(b);let h;e[7]!==k||e[8]!==p||e[9]!==A||e[10]!==v.isVSCode?(h={containerRef:M,effectiveDirectory:p,editor:k,preferRuntimeEditor:v.isVSCode,enabled:A},e[7]=k,e[8]=p,e[9]=A,e[10]=v.isVSCode,e[11]=h):h=e[11],nt(h);const T=!o;let w;e[12]!==T?(w={containerRef:M,enabled:T},e[12]=T,e[13]=w):w=e[13],Ye(w);let E;e[14]!==S?(E=qe(S),e[14]=S,e[15]=E):E=e[15];const N=E,I=it(S,!1,void 0,m),P=`simple:${f}`;let O;e[16]!==I||e[17]!==y||e[18]!==N||e[19]!==P?(O={containerRef:M,text:y,streaming:!1,cacheKey:P,syntaxVars:N,ctx:I},e[16]=I,e[17]=y,e[18]=N,e[19]=P,e[20]=O):O=e[20],at(O);let D;e[21]!==n?(D=Be("break-words w-full min-w-0",n),e[21]=n,e[22]=D):D=e[22];let R;e[23]!==f?(R=st(f),e[23]=f,e[24]=R):R=e[24];let F;e[25]!==R?(F=ee.jsx("div",{className:R,"data-markdown-content":!0}),e[25]=R,e[26]=F):F=e[26];let L;return e[27]!==D||e[28]!==F?(L=ee.jsx("div",{className:D,ref:M,children:F}),e[27]=D,e[28]=F,e[29]=L):L=e[29],L},$o=_.memo(Pr,(t,e)=>{const r=t.mermaidControls??J,n=e.mermaidControls??J;return t.content===e.content&&t.variant===e.variant&&t.className===e.className&&t.disableLinkSafety===e.disableLinkSafety&&t.stripFrontmatter===e.stripFrontmatter&&t.onShowPopup===e.onShowPopup&&r.download===n.download&&r.copy===n.copy&&r.showPanZoomControls===n.showPanZoomControls&&t.allowMermaidWheelEvents===e.allowMermaidWheelEvents&&t.enableFileReferences===e.enableFileReferences});function Fr(t){if(t.defaultPrevented||t.button!==0||t.metaKey||t.ctrlKey||t.altKey||t.shiftKey)return;const e=t.target;if(!(e instanceof Element))return;const r=e.closest("a[href]");if(!(r instanceof HTMLAnchorElement)||r.getAttribute("data-openchamber-file-link")==="true")return;const n=r.getAttribute("href")??"";De(n)&&(t.preventDefault(),t.stopPropagation(),vt(n))}function Ir(t){t.removeAttribute("data-openchamber-file-link"),t.removeAttribute("data-openchamber-file-ref"),t.removeAttribute("data-openchamber-file-path"),t.getAttribute("title")==="Open file"&&t.removeAttribute("title"),t.tagName.toLowerCase()!=="a"&&(t.removeAttribute("role"),t.removeAttribute("tabindex"))}function Or(){Pt()}function Dr(t,e){return!t.isEqualNode(e)}function Wr(t){return t.openContextPreview}export{Wo as MarkdownRenderer,$o as SimpleMarkdownRenderer};
@@ -1 +1 @@
1
- import{r as _,j as e,R as i,f as J}from"./vendor-react-BUCujlKS.js";import{I as V,b$ as we,b_ as le,bY as Y,x as $,af as P,cT as je,r as W,N as ue,ap as me,K as pe,J as ne}from"./index-iFY_N5aO.js";import{f as Q,B as L,S as G,g as he,h as re,I as A}from"./useAppFontEffects-sHmU5b8u.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-opencode-sdk-BJ73u-bH.js";import"./vendor-zustand-BAGL70zf.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-base-ui-D_V6hAcE.js";import"./vendor-floating-ui-utils-BzXdqYpP.js";import"./vendor-floating-ui-dom-WyXykhNi.js";import"./vendor-floating-ui-core-CXmKXOXc.js";import"./vendor-floating-ui-react-dom-DKpLs02S.js";import"./vendor-use-sync-external-store-D6wYuSt-.js";import"./contextPanelEmbeddedChat-tQekJUAF.js";import"./vendor-class-variance-authority-5VPnzWs2.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-dnd-kit-core-BZknOX2w.js";import"./vendor-dnd-kit-utilities-B_MdXhJC.js";import"./vendor-dnd-kit-accessibility-BHxJPORy.js";import"./vendor-dnd-kit-sortable-CsEagZ81.js";import"./vendor-cmdk-DgLInKvT.js";import"./vendor-radix-ui-react-dialog-B94Bt2qq.js";import"./vendor-radix-ui-primitive-Dc_FVRD7.js";import"./vendor-radix-ui-react-compose-refs-DcAh5WdT.js";import"./vendor-radix-ui-react-context-Czxm7Z62.js";import"./vendor-radix-ui-react-id-f5BLKEVw.js";import"./vendor-radix-ui-react-use-layout-effect-D_3IhJdJ.js";import"./vendor-radix-ui-react-use-controllable-state-BFT5YmkA.js";import"./vendor-radix-ui-react-dismissable-layer-D7kXcwgJ.js";import"./vendor-radix-ui-react-primitive-DhVoX9SD.js";import"./vendor-radix-ui-react-slot-BQgQOasS.js";import"./vendor-radix-ui-react-use-callback-ref-BZPnuXAC.js";import"./vendor-radix-ui-react-use-escape-keydown-oph88g-F.js";import"./vendor-radix-ui-react-focus-scope-CiaxW4dD.js";import"./vendor-radix-ui-react-portal-BMJYHWck.js";import"./vendor-radix-ui-react-presence-CNxf-uq4.js";import"./vendor-radix-ui-react-focus-guards-B6qJXYua.js";import"./vendor-react-remove-scroll-DO7dCTnK.js";import"./vendor-tslib-De9GV7Vy.js";import"./vendor-react-remove-scroll-bar-BcFYyj3E.js";import"./vendor-react-style-singleton-q6EMHnwf.js";import"./vendor-get-nonce-C-Z93AgS.js";import"./vendor-use-sidecar-zDC0RhA3.js";import"./vendor-use-callback-ref-D3RC8gqK.js";import"./vendor-aria-hidden-DvXkyWUv.js";import"./vendor-codemirror-language-DUOssd4j.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-codemirror-state-CNWM3Q8V.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-codemirror-view-DSzLbZiS.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-Bbw3D7r0.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-codemirror-autocomplete-BjbBRsUA.js";import"./vendor-codemirror-lang-json-ryCw7nab.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-VgNqFSH-.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-B3Qe3OpS.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-FGQydhTc.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-Dihw9MtL.js";import"./vendor-codemirror-lang-python-N414WYK-.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-codemirror-commands-ARAOgp1x.js";import"./vendor-tanstack-react-virtual-g05Cx3z9.js";import"./vendor-tanstack-virtual-core-Dubg10g5.js";import"./vendor-framer-motion-CRSgBxjL.js";import"./vendor-motion-dom-DJLgZh4Q.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./vendor-sonner-DFyL3AvE.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";function ke(a){switch(a){case"ok":return null;case"auth":return"onboarding.remoteConnection.probe.authMessage";case"update-recommended":return"onboarding.remoteConnection.probe.updateRecommendedMessage";case"incompatible":return"onboarding.remoteConnection.probe.incompatibleMessage";case"wrong-service":return"onboarding.remoteConnection.probe.wrongServiceMessage";case"unreachable":return"onboarding.remoteConnection.probe.unreachableMessage";default:return null}}function oe(a){return a==="wrong-service"||a==="unreachable"||a==="incompatible"}function xe({onBack:a,showBackButton:t=!0,initialUrl:s="",initialLabel:r="",isRecoveryMode:n=!1,onConnect:l,onSwitchToLocal:u,showInstancePicker:h=!1}){const{t:o}=Q(),[w,S]=_.useState(s),[j,U]=_.useState(r),[K,x]=_.useState("idle"),[m,k]=_.useState(null),[C,g]=_.useState(""),[T,I]=_.useState([]),[y,f]=_.useState(()=>h?"instances":"add"),[b,R]=_.useState("");_.useEffect(()=>{h&&V().then(p=>I(p.hosts)).catch(p=>{g(p instanceof Error?p.message:String(p))})},[h]);const N=we(w),E=N?.persistedUrl??null,F=_.useCallback(p=>{S(p.target.value),x("idle"),k(null),g("")},[]),O=_.useCallback(p=>{U(p.target.value)},[]),c=_.useCallback(async()=>{if(E){x("testing"),k(null),g("");try{const p=await le(E);k(p),x(p.status==="ok"||p.status==="update-recommended"?"success":"error")}catch(p){g(p instanceof Error?p.message:o("onboarding.remoteConnection.errors.connectionTestFailed")),x("error")}}},[E,o]),D=_.useCallback(async()=>{if(!N)return;const p=N.persistedUrl;x("testing"),k(null),g("");try{const H=await le(p);if(k(H),oe(H.status)){x("error");return}const Z=await V(),ye=j.trim()||p,ee=Z.hosts.find(X=>X.url===p),te=ee?ee.id:`host-${Date.now().toString(16)}`,ie={id:te,label:ye,url:p,apiUrl:p},ve=ee?Z.hosts.map(X=>X.id===te?ie:X):[...Z.hosts,ie];if(await Y({hosts:ve,defaultHostId:te,initialHostChoiceCompleted:!0}),l?.(),N.redeemUrl){window.location.assign(N.redeemUrl);return}$()&&await P()}catch(H){g(H instanceof Error?H.message:o("onboarding.remoteConnection.errors.failedToSaveConnection")),x("error")}},[N,j,l,o]),B=_.useCallback(async p=>{const H=await V();await Y({hosts:H.hosts,defaultHostId:p,initialHostChoiceCompleted:!0}),await P()},[]),d=_.useCallback(async()=>{x("testing"),g("");try{const p=await V(),H=await je(b,p.hosts);await Y({hosts:H.hosts,defaultHostId:H.hostId,initialHostChoiceCompleted:!0}),await P()}catch(p){g(p instanceof Error&&p.message==="invalid-connect-link"?o("settings.remoteInstances.direct.error.invalidConnectLink"):o("onboarding.remoteConnection.errors.failedToSaveConnection")),x("error")}},[b,o]),v=K==="testing",M=E!==null&&!v,z=E!==null&&!v&&!oe(m?.status??null),q=ke(m?.status??null),fe=m?.status==="ok",be=m?.status==="update-recommended",ge=m?.status==="auth",ae=oe(m?.status??null);return h&&y==="instances"?e.jsx("div",{className:"flex flex-col items-center justify-center h-full p-8",children:e.jsxs("div",{className:"w-full max-w-md space-y-6",children:[e.jsxs("div",{className:"space-y-2 text-center",children:[e.jsx("h1",{className:"typography-ui-header text-xl font-semibold text-foreground",children:o("desktopHostSwitcher.actions.switchInstance")}),e.jsx("p",{className:"text-muted-foreground text-sm",children:o("settings.remoteInstances.direct.description")})]}),C?e.jsx("div",{className:"text-sm text-[var(--status-error)]",children:C}):null,e.jsx("div",{className:"space-y-2",children:T.length===0?e.jsx("div",{className:"py-4 text-center text-sm text-muted-foreground",children:o("settings.remoteInstances.direct.state.empty")}):T.map(p=>e.jsx(L,{variant:"outline",className:"w-full justify-start",onClick:()=>{B(p.id)},children:e.jsx("span",{className:"min-w-0 truncate",children:p.label})},p.id))}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(L,{variant:"outline",className:"flex-1",onClick:()=>f("import"),children:o("settings.remoteInstances.direct.import.action")}),e.jsx(L,{className:"flex-1",onClick:()=>f("add"),children:o("settings.remoteInstances.direct.actions.add")})]})]})}):h&&y==="import"?e.jsx("div",{className:"flex flex-col items-center justify-center h-full p-8",children:e.jsxs("div",{className:"w-full max-w-md space-y-6",children:[e.jsx(L,{variant:"ghost",onClick:()=>f("instances"),className:"p-0 text-muted-foreground",children:o("onboarding.common.actions.back")}),e.jsxs("div",{className:"space-y-2 text-center",children:[e.jsx("h1",{className:"typography-ui-header text-xl font-semibold text-foreground",children:o("settings.remoteInstances.direct.import.action")}),e.jsx("p",{className:"text-muted-foreground text-sm",children:o("settings.remoteInstances.direct.import.description")})]}),e.jsx(G,{value:b,onChange:p=>R(p.target.value),placeholder:o("settings.remoteInstances.direct.import.placeholder"),disabled:v,autoFocus:!0}),C?e.jsx("div",{className:"text-sm text-[var(--status-error)]",children:C}):null,e.jsx(L,{onClick:()=>{d()},disabled:v||!b.trim(),children:o("settings.remoteInstances.direct.import.action")})]})}):e.jsx("div",{className:"flex flex-col items-center justify-center h-full p-8",children:e.jsxs("div",{className:"w-full max-w-md space-y-6",children:[(t||h)&&e.jsx("div",{className:"flex items-center",children:e.jsx(L,{variant:"ghost",onClick:h?()=>f("instances"):a,className:"p-0 text-muted-foreground hover:text-foreground",children:o("onboarding.common.actions.back")})}),e.jsxs("div",{className:"space-y-2 text-center",children:[e.jsx("h1",{className:"typography-ui-header text-xl font-semibold text-foreground",children:o(n?"onboarding.remoteConnection.titleRecovery":"onboarding.remoteConnection.title")}),e.jsx("p",{className:"text-muted-foreground text-sm",children:o("onboarding.remoteConnection.description")})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{htmlFor:"remote-url",className:"text-sm text-foreground",children:o("onboarding.remoteConnection.field.serverAddress")}),e.jsx(G,{id:"remote-url",type:"url",value:w,onChange:F,placeholder:o("onboarding.remoteConnection.field.serverAddressPlaceholder"),disabled:v})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{htmlFor:"remote-label",className:"text-sm text-foreground",children:o("onboarding.remoteConnection.field.nameOptional")}),e.jsx(G,{id:"remote-label",type:"text",value:j,onChange:O,placeholder:o("onboarding.remoteConnection.field.namePlaceholder"),disabled:v})]})]}),m&&fe&&e.jsx("div",{className:"rounded-lg border p-3 text-sm",style:{borderColor:"var(--status-success)",color:"var(--status-success)"},children:o("onboarding.remoteConnection.status.connectedSuccessfully",{latencyMs:m.latencyMs})}),m&&ge&&e.jsx("div",{className:"rounded-lg border p-3 text-sm",style:{borderColor:"var(--status-warning)",color:"var(--status-warning)"},children:o("onboarding.remoteConnection.status.authWarning")}),m&&be&&e.jsx("div",{className:"rounded-lg border p-3 text-sm",style:{borderColor:"var(--status-warning)",color:"var(--status-warning)"},children:q?o(q):null}),m&&ae&&e.jsxs("div",{className:"rounded-lg border p-3 text-sm space-y-3",style:{borderColor:"var(--status-error)",color:"var(--status-error)"},children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-semibold mb-1",children:o("onboarding.remoteConnection.status.connectionFailed")}),e.jsx("div",{className:"opacity-90",children:q?o(q):null})]}),e.jsx("div",{className:"text-xs opacity-80",children:m.status==="unreachable"?o("onboarding.remoteConnection.status.suggestionsUnreachable"):o("onboarding.remoteConnection.status.suggestionsWrongService")})]}),C&&e.jsx("div",{className:"rounded-lg border p-3 text-sm",style:{borderColor:"var(--status-error)",color:"var(--status-error)"},children:C}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx(L,{variant:"outline",onClick:c,disabled:!M,children:o(v?"onboarding.remoteConnection.actions.testing":"onboarding.remoteConnection.actions.testConnection")}),e.jsx(L,{onClick:D,disabled:!z,children:o("onboarding.remoteConnection.actions.connectAndRestart")})]}),ae&&e.jsxs("div",{className:"flex flex-col gap-2 pt-2 border-t border-border",children:[e.jsx("div",{className:"text-xs text-muted-foreground text-center",children:o("onboarding.remoteConnection.actions.whatToDo")}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(L,{variant:"outline",size:"sm",onClick:a,className:"flex-1",children:o("onboarding.remoteConnection.actions.chooseDifferentServer")}),!n&&u&&e.jsx(L,{variant:"outline",size:"sm",onClick:u,className:"flex-1",children:o("onboarding.remoteConnection.actions.useLocalInstead")})]})]})]})})}const Ce="curl -fsSL https://opencode.ai/install | bash",Ne="https://opencode.ai/docs",ce=2500;function Se(a){const t=J.c(5),{onCopy:s,copyTitle:r}=a;let n;t[0]===Symbol.for("react.memo_cache_sentinel")?(n=e.jsxs("code",{className:"flex-1 text-left overflow-x-auto whitespace-nowrap",children:[e.jsx("span",{style:{color:"var(--syntax-keyword)"},children:"curl"}),e.jsx("span",{className:"text-muted-foreground",children:" -fsSL "}),e.jsx("span",{style:{color:"var(--syntax-string)"},children:"https://opencode.ai/install"}),e.jsx("span",{className:"text-muted-foreground",children:" | "}),e.jsx("span",{style:{color:"var(--syntax-keyword)"},children:"bash"})]}),t[0]=n):n=t[0];let l;t[1]===Symbol.for("react.memo_cache_sentinel")?(l=e.jsx(A,{name:"file-copy",className:"h-4 w-4"}),t[1]=l):l=t[1];let u;return t[2]!==r||t[3]!==s?(u=e.jsxs("div",{className:"flex items-center justify-between gap-3 w-full",children:[n,e.jsx("button",{onClick:s,className:"inline-flex items-center text-muted-foreground hover:text-foreground transition-colors shrink-0",title:r,"aria-label":r,children:l})]}),t[2]=r,t[3]=s,t[4]=u):u=t[4],u}function Re({onCliAvailable:a,localAvailable:t=!0}){const{t:s}=Q(),[r,n]=i.useState(!1),[l,u]=i.useState(!1),[h,o]=i.useState(!1),[w,S]=i.useState(!1),[j,U]=i.useState(""),[K,x]=i.useState("unknown"),[m,k]=i.useState(()=>t?"local":"remote"),[C,g]=i.useState(!1),[T,I]=i.useState(!1);i.useEffect(()=>{u($())},[]),i.useEffect(()=>{if(typeof navigator>"u"){x("unknown");return}const d=navigator.userAgent||"";/Windows/i.test(d)?x("windows"):/Macintosh|Mac OS X/i.test(d)?x("macos"):/Linux/i.test(d)?x("linux"):x("unknown")},[]),i.useEffect(()=>{let d=!1;return(async()=>{try{const v=await W("/api/config/settings",{method:"GET",headers:{Accept:"application/json"}});if(!v.ok)return;const M=await v.json().catch(()=>null);if(!M||d)return;const z=typeof M.opencodeBinary=="string"?M.opencodeBinary.trim():"";z&&U(z)}catch{}})(),()=>{d=!0}},[]);const y=i.useCallback(async d=>{const v=d.target;v.closest(".app-region-no-drag")||v.closest("button, a, input, select, textarea, code, summary, details")||d.button===0&&l&&await ue()},[l]),f=i.useCallback(async()=>{try{const d=await W("/health");if(!d.ok)return!1;const v=await d.json();return v.openCodeRunning===!0||v.isOpenCodeReady===!0}catch{return!1}},[]),b=i.useCallback(async d=>{if(!l)return;const v=await V();await Y({...v,...d==="local"?{defaultHostId:"local"}:{},initialHostChoiceCompleted:!0})},[l]),R=i.useCallback(async()=>{l&&await b("local"),a?.()},[l,a,b]);i.useEffect(()=>{if(!t||m!=="local")return;let d=!1,v=null;const M=async()=>{if(!d){try{const z=await f();if(d)return;if(z){await R();return}}catch{}d||(v=setTimeout(M,ce))}};return v=setTimeout(M,ce),()=>{d=!0,v&&clearTimeout(v)}},[m,f,R,t]);const N=i.useCallback(async()=>{S(!0);try{await f()&&await R()}finally{S(!1)}},[f,R]),E=i.useCallback(async()=>{if(!(typeof window>"u")&&l)try{const d=await me();d.success&&d.path&&d.path.trim().length>0&&U(d.path.trim())}catch{}},[l]),F=i.useCallback(async()=>{o(!0);try{if(await pe({opencodeBinary:j.trim()}),l){await b("local"),await P();return}await W("/api/config/reload",{method:"POST"})}finally{setTimeout(()=>o(!1),1e3)}},[l,j,b]),O=i.useCallback(async()=>{const d=await he(Ce);d.ok?(n(!0),setTimeout(()=>n(!1),2e3)):console.error("Failed to copy:",d.error)},[]),c=Ne,D=K==="windows"?"C:\\Users\\you\\AppData\\Roaming\\npm\\opencode.cmd":K==="linux"?"/home/you/.bun/bin/opencode":"/Users/you/.bun/bin/opencode",B=t&&(!l||m==="local");return e.jsx("div",{className:"app-region-drag h-full flex items-center justify-center bg-transparent p-8 cursor-default select-none overflow-y-auto",onMouseDown:y,children:e.jsxs("div",{className:"w-full max-w-md space-y-7",children:[e.jsxs("header",{className:"text-center space-y-1.5",children:[e.jsx("h1",{className:"text-2xl font-semibold tracking-tight text-foreground",children:s("onboarding.chooser.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("onboarding.chooser.description")})]}),l&&t&&e.jsxs("div",{className:"app-region-no-drag flex gap-1.5",children:[e.jsx("button",{type:"button",className:re("flex-1 px-4 py-2 rounded-lg border transition-colors text-sm",m==="local"?"border-[var(--interactive-selection)] text-foreground bg-[var(--interactive-selection)]/10":"border-border text-muted-foreground hover:text-foreground hover:border-muted-foreground"),onClick:()=>k("local"),children:s("onboarding.chooser.tabs.localInstall")}),e.jsx("button",{type:"button",className:re("flex-1 px-4 py-2 rounded-lg border transition-colors text-sm",m==="remote"?"border-[var(--interactive-selection)] text-foreground bg-[var(--interactive-selection)]/10":"border-border text-muted-foreground hover:text-foreground hover:border-muted-foreground"),onClick:()=>k("remote"),children:s("onboarding.chooser.tabs.connectRemote")})]}),l&&m==="remote"?e.jsx("div",{className:"app-region-no-drag",children:e.jsx(xe,{onBack:()=>t&&k("local"),showBackButton:!1,showInstancePicker:!t,onSwitchToLocal:t?()=>k("local"):void 0})}):null,B&&e.jsxs("div",{className:"space-y-4",children:[K==="windows"&&e.jsxs("div",{className:"rounded-lg border border-border bg-background/50 p-4",children:[e.jsx("div",{className:"text-sm text-foreground",children:s("onboarding.localSetup.windows.title")}),e.jsxs("ol",{className:"mt-2 list-decimal space-y-1 pl-5 text-sm text-muted-foreground",children:[e.jsx("li",{children:s("onboarding.localSetup.windows.stepRunInstallInWsl")}),e.jsx("li",{children:s("onboarding.localSetup.windows.stepSetBinaryPath")})]})]}),e.jsx("p",{className:"text-sm text-muted-foreground text-center leading-relaxed",children:s("onboarding.localSetup.intro")}),e.jsx("div",{className:"app-region-no-drag rounded-lg border border-border bg-background/60 backdrop-blur-sm px-4 py-3 font-mono text-sm",children:r?e.jsxs("div",{className:"flex items-center gap-2",style:{color:"var(--status-success)"},children:[e.jsx(A,{name:"check",className:"h-4 w-4"}),s("onboarding.common.status.copiedToClipboard")]}):e.jsx(Se,{onCopy:O,copyTitle:s("onboarding.common.copyToClipboard")})}),e.jsxs("div",{className:"app-region-no-drag flex items-center justify-between",children:[e.jsxs("a",{href:c,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-muted-foreground hover:text-foreground transition-colors inline-flex items-center gap-1",children:[s(K==="windows"?"onboarding.localSetup.docs.windows":"onboarding.localSetup.docs.default"),e.jsx(A,{name:"external-link",className:"h-3 w-3"})]}),e.jsx("button",{type:"button",onClick:N,disabled:w,className:"text-xs text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50",children:s(w?"onboarding.localSetup.actions.checking":"onboarding.localSetup.actions.checkNow")})]}),e.jsxs("div",{className:"rounded-lg border px-4 py-3 flex items-center gap-3",style:{borderColor:"color-mix(in srgb, var(--primary-base) 20%, transparent)",backgroundColor:"color-mix(in srgb, var(--primary-base) 6%, transparent)"},role:"status","aria-live":"polite",children:[e.jsxs("span",{className:"relative inline-flex h-2.5 w-2.5 shrink-0","aria-hidden":!0,children:[e.jsx("span",{className:"absolute inset-0 rounded-full",style:{backgroundColor:"var(--primary-base)",animation:"pulse-opacity 1.6s ease-in-out infinite"}}),e.jsx("span",{className:"absolute inset-[-4px] rounded-full",style:{backgroundColor:"var(--primary-base)",animation:"pulse-opacity-dim 1.6s ease-in-out infinite",opacity:0}})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-sm text-foreground leading-tight",children:s("onboarding.localSetup.status.watching")}),e.jsx("div",{className:"text-xs text-muted-foreground leading-tight mt-0.5",children:s("onboarding.localSetup.status.autoContinue")})]})]}),e.jsxs("details",{className:"app-region-no-drag group rounded-lg border border-border/60 px-4 open:bg-background/40 transition-colors",open:C,onToggle:d=>g(d.currentTarget.open),children:[e.jsxs("summary",{className:"flex items-center justify-between cursor-pointer py-2.5 text-sm text-muted-foreground hover:text-foreground transition-colors list-none [&::-webkit-details-marker]:hidden",children:[e.jsx("span",{children:s("onboarding.localSetup.advanced.title")}),e.jsx(A,{name:"arrow-down-s",className:"h-4 w-4 transition-transform group-open:rotate-180"})]}),e.jsxs("div",{className:"pb-4 space-y-2",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(G,{value:j,onChange:d=>U(d.target.value),placeholder:D,disabled:h,className:"flex-1 font-mono text-xs"}),e.jsx(L,{type:"button",variant:"secondary",size:"sm",onClick:E,disabled:h||!l,children:s("onboarding.localSetup.actions.browse")}),e.jsx(L,{type:"button",size:"sm",onClick:F,disabled:h||!j.trim(),children:s("onboarding.localSetup.actions.apply")})]}),e.jsx("p",{className:"text-xs text-muted-foreground/70",children:s("onboarding.localSetup.helper.saveAndReload")})]})]}),e.jsxs("details",{className:"app-region-no-drag group rounded-lg border border-border/60 px-4 open:bg-background/40 transition-colors",open:T,onToggle:d=>I(d.currentTarget.open),children:[e.jsxs("summary",{className:"flex items-center justify-between cursor-pointer py-2.5 text-sm text-muted-foreground hover:text-foreground transition-colors list-none [&::-webkit-details-marker]:hidden",children:[e.jsx("span",{children:s("onboarding.localSetup.troubleshoot.title")}),e.jsx(A,{name:"arrow-down-s",className:"h-4 w-4 transition-transform group-open:rotate-180"})]}),e.jsx("ul",{className:"pb-4 space-y-1.5 text-xs text-muted-foreground list-disc pl-4",children:K==="windows"?e.jsx(e.Fragment,{children:e.jsx("li",{children:s("onboarding.localSetup.windows.hintDetectionFailed")})}):e.jsxs(e.Fragment,{children:[e.jsx("li",{children:s("onboarding.localSetup.hint.ensurePath")}),e.jsx("li",{children:s("onboarding.localSetup.hint.setEnv")}),e.jsx("li",{children:s("onboarding.localSetup.hint.missingRuntime")})]})})]})]})]})})}const Le="curl -fsSL https://opencode.ai/install | bash",Ue="https://opencode.ai/docs";function Te(a){const t=J.c(5),{onCopy:s,copyTitle:r}=a;let n;t[0]===Symbol.for("react.memo_cache_sentinel")?(n=e.jsxs("code",{children:[e.jsx("span",{style:{color:"var(--syntax-keyword)"},children:"curl"}),e.jsx("span",{className:"text-muted-foreground",children:" -fsSL "}),e.jsx("span",{style:{color:"var(--syntax-string)"},children:"https://opencode.ai/install"}),e.jsx("span",{className:"text-muted-foreground",children:" | "}),e.jsx("span",{style:{color:"var(--syntax-keyword)"},children:"bash"})]}),t[0]=n):n=t[0];let l;t[1]===Symbol.for("react.memo_cache_sentinel")?(l=e.jsx(A,{name:"file-copy",className:"h-4 w-4"}),t[1]=l):l=t[1];let u;return t[2]!==r||t[3]!==s?(u=e.jsxs("div",{className:"flex items-center justify-center gap-3",children:[n,e.jsx("button",{onClick:s,className:"inline-flex items-center text-muted-foreground hover:text-foreground transition-colors",title:r,children:l})]}),t[2]=r,t[3]=s,t[4]=u):u=t[4],u}const Ke=3e4;function Ie({onBack:a,onCliAvailable:t,isFromRecovery:s=!1,onSwitchToRemote:r}){const{t:n}=Q(),[l,u]=i.useState(!1),[h,o]=i.useState(!1),[w,S]=i.useState(!1),[j,U]=i.useState(!1),[K,x]=i.useState(!1),[m,k]=i.useState(null),[C,g]=i.useState(""),[T,I]=i.useState("unknown");i.useEffect(()=>{const c=setTimeout(()=>o(!0),Ke);return()=>clearTimeout(c)},[]),i.useEffect(()=>{S($())},[]),i.useEffect(()=>{if(typeof navigator>"u"){I("unknown");return}const c=navigator.userAgent||"";if(/Windows/i.test(c)){I("windows");return}if(/Macintosh|Mac OS X/i.test(c)){I("macos");return}if(/Linux/i.test(c)){I("linux");return}I("unknown")},[]),i.useEffect(()=>{let c=!1;return(async()=>{try{const D=await W("/api/config/settings",{method:"GET",headers:{Accept:"application/json"}});if(!D.ok)return;const B=await D.json().catch(()=>null);if(!B||c)return;const d=typeof B.opencodeBinary=="string"?B.opencodeBinary.trim():"";d&&g(d)}catch{}})(),()=>{c=!0}},[]);const y=i.useCallback(async c=>{c.target.closest("button, a, input, select, textarea, code")||c.button===0&&w&&await ue()},[w]),f=i.useCallback(async()=>{try{const c=await W("/health");if(!c.ok)return!1;const D=await c.json();return D.openCodeRunning===!0||D.isOpenCodeReady===!0}catch{return!1}},[]),b=i.useCallback(async()=>{if(!(typeof window>"u")&&w)try{const c=await me();c.success&&c.path&&c.path.trim().length>0&&g(c.path.trim())}catch{}},[w]),R=i.useCallback(async()=>{U(!0);try{if(await pe({opencodeBinary:C.trim()}),w){await P();return}await W("/api/config/reload",{method:"POST"})}finally{setTimeout(()=>U(!1),1e3)}},[w,C]),N=i.useCallback(async()=>{const c=await he(Le);c.ok?(u(!0),setTimeout(()=>u(!1),2e3)):console.error("Failed to copy:",c.error)},[]),E=i.useCallback(async()=>{x(!0),k(null);try{await f()?t?.():k(n("onboarding.localSetup.errors.cliNotReady"))}catch(c){k(c instanceof Error?c.message:n("onboarding.localSetup.errors.detectionFailed"))}finally{x(!1)}},[f,t,n]),F=Ue,O=T==="windows"?"C:\\Users\\you\\AppData\\Roaming\\npm\\opencode.cmd":T==="linux"?"/home/you/.bun/bin/opencode":"/Users/you/.bun/bin/opencode";return e.jsxs("div",{className:"h-full flex items-center justify-center bg-transparent p-8 relative cursor-default select-none",onMouseDown:y,children:[e.jsxs("div",{className:"w-full max-w-lg space-y-4 text-center",children:[e.jsx("div",{className:"flex items-center",children:e.jsx(L,{variant:"ghost",onClick:a,className:"p-0 text-muted-foreground hover:text-foreground",children:n("onboarding.common.actions.back")})}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h1",{className:"text-3xl font-semibold tracking-tight text-foreground",children:n("onboarding.localSetup.title")}),e.jsx("p",{className:"text-muted-foreground",children:n("onboarding.localSetup.description")})]}),T==="windows"&&e.jsxs("div",{className:"mx-auto max-w-2xl rounded-lg border border-border bg-background/50 p-4 text-left",children:[e.jsx("div",{className:"text-sm text-foreground",children:n("onboarding.localSetup.windows.title")}),e.jsxs("ol",{className:"mt-2 list-decimal space-y-1 pl-5 text-sm text-muted-foreground",children:[e.jsx("li",{children:n("onboarding.localSetup.windows.stepRunInstallInWsl")}),e.jsx("li",{children:n("onboarding.localSetup.windows.stepSetBinaryPath")})]})]}),e.jsx("div",{className:"flex justify-center",children:e.jsx("div",{className:"bg-background/60 backdrop-blur-sm border border-border rounded-lg px-5 py-3 font-mono text-sm w-fit",children:l?e.jsxs("div",{className:"flex items-center justify-center gap-2",style:{color:"var(--status-success)"},children:[e.jsx(A,{name:"check",className:"h-4 w-4"}),n("onboarding.common.status.copiedToClipboard")]}):e.jsx(Te,{onCopy:N,copyTitle:n("onboarding.common.copyToClipboard")})})}),e.jsxs("a",{href:F,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-muted-foreground hover:text-foreground transition-colors inline-flex items-center gap-1 justify-center",children:[n(T==="windows"?"onboarding.localSetup.docs.windows":"onboarding.localSetup.docs.default"),e.jsx(A,{name:"external-link",className:"h-3 w-3"})]}),m&&e.jsx("div",{className:"mx-auto max-w-md rounded-lg border border-destructive/50 bg-destructive/10 p-3 text-sm text-destructive",children:m}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(L,{type:"button",onClick:E,disabled:K,className:"w-full max-w-xs",size:"lg",children:n(K?"onboarding.localSetup.actions.checking":"onboarding.localSetup.actions.checkAndContinue")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:n("onboarding.localSetup.helper.checkAndContinue")})]}),e.jsx("div",{className:"mx-auto w-full max-w-xl pt-4",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:n("onboarding.localSetup.field.alreadyInstalled")}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(G,{value:C,onChange:c=>g(c.target.value),placeholder:O,disabled:j,className:"flex-1 font-mono text-xs"}),e.jsx(L,{type:"button",variant:"secondary",onClick:b,disabled:j||!w,children:n("onboarding.localSetup.actions.browse")}),e.jsx(L,{type:"button",onClick:R,disabled:j,children:n("onboarding.localSetup.actions.apply")})]}),e.jsx("div",{className:"text-xs text-muted-foreground/70",children:n("onboarding.localSetup.helper.saveAndReload")})]})}),s&&r&&e.jsxs("div",{className:"text-center pt-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:n("onboarding.localSetup.remotePreference")}),e.jsx(L,{variant:"link",onClick:r,children:n("onboarding.localSetup.actions.connectRemoteServer")})]})]}),h&&e.jsx("div",{className:"absolute bottom-8 left-0 right-0 text-center space-y-1",children:T==="windows"?e.jsx(e.Fragment,{children:e.jsx("p",{className:"text-sm text-muted-foreground/70",children:n("onboarding.localSetup.windows.hintDetectionFailed")})}):e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-sm text-muted-foreground/70",children:n("onboarding.localSetup.hint.ensurePath")}),e.jsx("p",{className:"text-sm text-muted-foreground/70",children:n("onboarding.localSetup.hint.setEnv")}),e.jsx("p",{className:"text-sm text-muted-foreground/70",children:n("onboarding.localSetup.hint.missingRuntime")})]})})]})}function se(a,t){if(a?.trim())return ne(a.trim());if(t)return ne(t)}function _e(a,t,s){switch(a){case"local-unavailable":return{title:"Local OpenCode Unavailable",description:"OpenCode CLI could not be started or is not installed. Install OpenCode or connect to a remote server instead.",titleKey:"onboarding.desktopRecovery.localUnavailable.title",descriptionKey:"onboarding.desktopRecovery.localUnavailable.description",iconKey:"local",showRetry:!0,retryLabel:"Retry Local",retryLabelKey:"onboarding.desktopRecovery.localUnavailable.retry",showUseLocal:!0,showUseRemote:!0,useLocalLabel:"Set Up Local",useLocalLabelKey:"onboarding.desktopRecovery.localUnavailable.useLocal",useRemoteLabel:"Use Remote",useRemoteLabelKey:"onboarding.desktopRecovery.common.useRemote"};case"remote-missing":return{title:"No Default Connection",description:"Your saved default connection could not be found. Choose how you want to connect.",titleKey:"onboarding.desktopRecovery.noDefaultConnection.title",descriptionKey:"onboarding.desktopRecovery.noDefaultConnection.description",iconKey:"local",showRetry:!1,showUseLocal:!0,showUseRemote:!0,useLocalLabel:"Use Local",useLocalLabelKey:"onboarding.desktopRecovery.common.useLocal",useRemoteLabel:"Use Remote",useRemoteLabelKey:"onboarding.desktopRecovery.common.useRemote"};case"remote-unreachable":{const r=se(t,s);return{title:"Remote Server Unreachable",description:`Could not connect to "${r||"the remote server"}". Check your network connection and verify the server address.`,titleKey:"onboarding.desktopRecovery.remoteUnreachable.title",descriptionKey:"onboarding.desktopRecovery.remoteUnreachable.description",descriptionParams:r?{host:r}:void 0,iconKey:"remote",showRetry:!0,retryLabel:"Retry Connection",retryLabelKey:"onboarding.desktopRecovery.remoteUnreachable.retry",showUseLocal:!0,showUseRemote:!0,useLocalLabel:"Use Local",useLocalLabelKey:"onboarding.desktopRecovery.common.useLocal",useRemoteLabel:"Use Remote",useRemoteLabelKey:"onboarding.desktopRecovery.common.useRemote"}}case"remote-wrong-service":{const r=se(t,s);return{title:"Incompatible Server",description:`The server at "${r||"unknown"}" is not running OpenChamber. Verify the address points to an OpenChamber server.`,titleKey:"onboarding.desktopRecovery.incompatibleServer.title",descriptionKey:"onboarding.desktopRecovery.incompatibleServer.description",descriptionParams:r?{host:r}:void 0,iconKey:"remote",showRetry:!1,showUseLocal:!0,showUseRemote:!0,useLocalLabel:"Use Local",useLocalLabelKey:"onboarding.desktopRecovery.common.useLocal",useRemoteLabel:"Use Remote",useRemoteLabelKey:"onboarding.desktopRecovery.common.useRemote"}}case"remote-incompatible":{const r=se(t,s);return{title:"Server Update Required",description:`The OpenChamber server at "${r||"unknown"}" is not compatible with this app version. Update OpenChamber on the server, then try again.`,titleKey:"onboarding.desktopRecovery.remoteIncompatible.title",descriptionKey:"onboarding.desktopRecovery.remoteIncompatible.description",descriptionParams:r?{host:r}:void 0,iconKey:"remote",showRetry:!0,retryLabel:"Retry Connection",retryLabelKey:"onboarding.desktopRecovery.remoteUnreachable.retry",showUseLocal:!0,showUseRemote:!0,useLocalLabel:"Use Local",useLocalLabelKey:"onboarding.desktopRecovery.common.useLocal",useRemoteLabel:"Use Remote",useRemoteLabelKey:"onboarding.desktopRecovery.common.useRemote"}}case"missing-default-host":return{title:"No Default Connection",description:"Your saved default connection could not be found. Choose how you want to connect.",titleKey:"onboarding.desktopRecovery.noDefaultConnection.title",descriptionKey:"onboarding.desktopRecovery.noDefaultConnection.description",iconKey:"local",showRetry:!1,showUseLocal:!0,showUseRemote:!0,useLocalLabel:"Use Local",useLocalLabelKey:"onboarding.desktopRecovery.common.useLocal",useRemoteLabel:"Use Remote",useRemoteLabelKey:"onboarding.desktopRecovery.common.useRemote"};default:{const r=a;throw new Error(`Unknown recovery variant: ${r}`)}}}function De(a){switch(a){case"local":return e.jsx(A,{name:"macbook",className:"h-8 w-8"});case"remote":return e.jsx(A,{name:"server",className:"h-8 w-8"})}}function Ee({variant:a,hostLabel:t,hostUrl:s,onRetry:r,onUseLocal:n,onUseRemote:l,isRetrying:u=!1}){const{t:h}=Q(),o=_e(a,t,s),w=o.retryLabelKey??"onboarding.desktopRecovery.actions.retryConnection",S=i.useMemo(()=>{if(o.descriptionParams?.host)return o.descriptionParams;if(a==="remote-unreachable")return{host:h("onboarding.desktopRecovery.placeholders.remoteServer")};if(a==="remote-wrong-service"||a==="remote-incompatible")return{host:h("onboarding.desktopRecovery.placeholders.unknownServer")}},[o.descriptionParams,h,a]);return e.jsx("div",{className:"flex flex-col items-center justify-center h-full p-8",children:e.jsxs("div",{className:"w-full max-w-md space-y-6",children:[e.jsxs("div",{className:"flex flex-col items-center space-y-3 text-center",children:[e.jsx("div",{className:"p-3 rounded-full",style:{backgroundColor:"var(--status-warning)",opacity:.15},children:e.jsx("div",{style:{color:"var(--status-warning)"},children:De(o.iconKey)})}),e.jsx("h1",{className:"typography-ui-header text-xl font-semibold text-foreground",children:h(o.titleKey)}),e.jsx("p",{className:"text-muted-foreground text-sm max-w-sm",children:h(o.descriptionKey,S)})]}),s&&(a==="remote-unreachable"||a==="remote-wrong-service"||a==="remote-incompatible")&&e.jsxs("div",{className:"rounded-lg border border-border bg-background/50 p-3",children:[e.jsx("div",{className:"text-xs text-muted-foreground mb-1",children:h("onboarding.remoteConnection.field.serverAddress")}),e.jsx("div",{className:"font-mono text-sm text-foreground truncate",children:ne(s)})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[o.showRetry&&r&&e.jsxs(L,{onClick:r,disabled:u,className:"w-full",children:[e.jsx(A,{name:"refresh",className:re("h-4 w-4",u&&"animate-spin")}),h(u?"onboarding.desktopRecovery.actions.retrying":w)]}),e.jsxs("div",{className:"flex gap-2",children:[o.showUseLocal&&n&&e.jsxs(L,{variant:"outline",onClick:n,disabled:u,className:"flex-1",children:[e.jsx(A,{name:"macbook",className:"h-4 w-4"}),h(o.useLocalLabelKey)]}),o.showUseRemote&&l&&e.jsxs(L,{variant:"outline",onClick:l,disabled:u,className:"flex-1",children:[e.jsx(A,{name:"server",className:"h-4 w-4"}),h(o.useRemoteLabelKey)]})]})]})]})})}function de(a,t){if(t==="use-remote")return{kind:"remote-form"};switch(a){case"local-unavailable":return{kind:"local-setup"};case"remote-unreachable":case"remote-incompatible":case"remote-wrong-service":case"remote-missing":case"missing-default-host":return{kind:"switch-default-to-local"};default:{const s=a;throw new Error(`Unhandled RecoveryVariant: ${s}`)}}}function Ae(a){const t=J.c(29),{variant:s,hostUrl:r,hostLabel:n,onRetry:l,onChooseRemote:u,showRemoteForm:h,onCloseRemoteForm:o,onSwitchToLocalFromRemote:w,onEnterLocalSetup:S,isRetrying:j,localAvailable:U}=a,K=h===void 0?!1:h,x=j===void 0?!1:j,m=U===void 0?!0:U,k=Fe;let C;t[0]!==l?(C=async()=>{if($()){await P();return}await W("/api/config/reload",{method:"POST"}),l?.()},t[0]=l,t[1]=C):C=t[1];const g=C;let T;t[2]!==S||t[3]!==s?(T=async()=>{if(de(s,"use-local").kind==="local-setup"){S?.();return}if(await k("local"),$()){await P();return}window.location.reload()},t[2]=S,t[3]=s,t[4]=T):T=t[4];const I=T;let y;t[5]!==u||t[6]!==s?(y=()=>{de(s,"use-remote").kind==="remote-form"&&u?.()},t[5]=u,t[6]=s,t[7]=y):y=t[7];const f=y;if(K){const N=s==="remote-wrong-service"?"":r||"",E=s==="remote-wrong-service"?"":n||"";let F;t[8]!==u||t[9]!==o?(F=o||(()=>u?.()),t[8]=u,t[9]=o,t[10]=F):F=t[10];const O=!m;let c;t[11]!==m||t[12]!==S||t[13]!==w?(c=m?w||(()=>{k("local").then(()=>{$()?P():S?.()})}):void 0,t[11]=m,t[12]=S,t[13]=w,t[14]=c):c=t[14];let D;return t[15]!==E||t[16]!==N||t[17]!==F||t[18]!==O||t[19]!==c?(D=e.jsx(xe,{onBack:F,initialUrl:N,initialLabel:E,isRecoveryMode:!0,showInstancePicker:O,onSwitchToLocal:c}),t[15]=E,t[16]=N,t[17]=F,t[18]=O,t[19]=c,t[20]=D):D=t[20],D}const b=m?I:void 0;let R;return t[21]!==g||t[22]!==f||t[23]!==n||t[24]!==r||t[25]!==x||t[26]!==b||t[27]!==s?(R=e.jsx(Ee,{variant:s,hostLabel:n,hostUrl:r,onRetry:g,onUseLocal:b,onUseRemote:f,isRetrying:x}),t[21]=g,t[22]=f,t[23]=n,t[24]=r,t[25]=x,t[26]=b,t[27]=s,t[28]=R):R=t[28],R}async function Fe(a){if(!$())return;const t=await V();await Y({...t,...a==="local"?{defaultHostId:"local"}:{},initialHostChoiceCompleted:!0})}function co(a){const t=J.c(29),{onBack:s,onCliAvailable:r,mode:n,recoveryVariant:l,recoveryHostUrl:u,recoveryHostLabel:h,onEnterLocalSetup:o,localAvailable:w}=a,S=n===void 0?"first-launch":n,j=l===void 0?"missing-default-host":l,U=w===void 0?!0:w,[K,x]=i.useState(!1),[m,k]=i.useState(!1);let C;t[0]===Symbol.for("react.memo_cache_sentinel")?(C=()=>{k(!1),x(!1)},t[0]=C):C=t[0];let g;t[1]!==S||t[2]!==h||t[3]!==u||t[4]!==j?(g=[S,j,u,h],t[1]=S,t[2]=h,t[3]=u,t[4]=j,t[5]=g):g=t[5],i.useEffect(C,g);const T=m?"local-setup":S;if(T==="recovery"){let y;t[6]===Symbol.for("react.memo_cache_sentinel")?(y=()=>x(!0),t[6]=y):y=t[6];let f,b;t[7]===Symbol.for("react.memo_cache_sentinel")?(f=()=>x(!1),b=()=>{x(!1),k(!0)},t[7]=f,t[8]=b):(f=t[7],b=t[8]);let R;t[9]!==o?(R=()=>{k(!0),o?.()},t[9]=o,t[10]=R):R=t[10];let N;return t[11]!==U||t[12]!==h||t[13]!==u||t[14]!==j||t[15]!==K||t[16]!==R?(N=e.jsx(Ae,{variant:j,hostUrl:u,hostLabel:h,onChooseRemote:y,showRemoteForm:K,onCloseRemoteForm:f,onSwitchToLocalFromRemote:b,onEnterLocalSetup:R,localAvailable:U}),t[11]=U,t[12]=h,t[13]=u,t[14]=j,t[15]=K,t[16]=R,t[17]=N):N=t[17],N}if(T==="local-setup"){let y;t[18]!==s||t[19]!==m?(y=()=>{m?k(!1):s?.()},t[18]=s,t[19]=m,t[20]=y):y=t[20];let f;t[21]===Symbol.for("react.memo_cache_sentinel")?(f=()=>x(!0),t[21]=f):f=t[21];let b;return t[22]!==r||t[23]!==m||t[24]!==y?(b=e.jsx(Ie,{onBack:y,onCliAvailable:r,isFromRecovery:m,onSwitchToRemote:f}),t[22]=r,t[23]=m,t[24]=y,t[25]=b):b=t[25],b}let I;return t[26]!==U||t[27]!==r?(I=e.jsx(Re,{onCliAvailable:r,localAvailable:U}),t[26]=U,t[27]=r,t[28]=I):I=t[28],I}export{co as OnboardingScreen};
1
+ import{r as _,j as e,R as i,f as J}from"./vendor-react-BUCujlKS.js";import{I as V,b$ as we,b_ as le,bY as Y,x as $,af as P,cT as je,r as W,N as ue,ap as me,K as pe,J as ne}from"./index-DRpChWux.js";import{f as Q,B as L,S as G,g as he,h as re,I as A}from"./useAppFontEffects-BikB6enL.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-opencode-sdk-BJ73u-bH.js";import"./vendor-zustand-BAGL70zf.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-base-ui-D_V6hAcE.js";import"./vendor-floating-ui-utils-BzXdqYpP.js";import"./vendor-floating-ui-dom-WyXykhNi.js";import"./vendor-floating-ui-core-CXmKXOXc.js";import"./vendor-floating-ui-react-dom-DKpLs02S.js";import"./vendor-use-sync-external-store-D6wYuSt-.js";import"./contextPanelEmbeddedChat-B-bSg3P5.js";import"./vendor-class-variance-authority-5VPnzWs2.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-dnd-kit-core-BZknOX2w.js";import"./vendor-dnd-kit-utilities-B_MdXhJC.js";import"./vendor-dnd-kit-accessibility-BHxJPORy.js";import"./vendor-dnd-kit-sortable-CsEagZ81.js";import"./vendor-cmdk-DgLInKvT.js";import"./vendor-radix-ui-react-dialog-B94Bt2qq.js";import"./vendor-radix-ui-primitive-Dc_FVRD7.js";import"./vendor-radix-ui-react-compose-refs-DcAh5WdT.js";import"./vendor-radix-ui-react-context-Czxm7Z62.js";import"./vendor-radix-ui-react-id-f5BLKEVw.js";import"./vendor-radix-ui-react-use-layout-effect-D_3IhJdJ.js";import"./vendor-radix-ui-react-use-controllable-state-BFT5YmkA.js";import"./vendor-radix-ui-react-dismissable-layer-D7kXcwgJ.js";import"./vendor-radix-ui-react-primitive-DhVoX9SD.js";import"./vendor-radix-ui-react-slot-BQgQOasS.js";import"./vendor-radix-ui-react-use-callback-ref-BZPnuXAC.js";import"./vendor-radix-ui-react-use-escape-keydown-oph88g-F.js";import"./vendor-radix-ui-react-focus-scope-CiaxW4dD.js";import"./vendor-radix-ui-react-portal-BMJYHWck.js";import"./vendor-radix-ui-react-presence-CNxf-uq4.js";import"./vendor-radix-ui-react-focus-guards-B6qJXYua.js";import"./vendor-react-remove-scroll-DO7dCTnK.js";import"./vendor-tslib-De9GV7Vy.js";import"./vendor-react-remove-scroll-bar-BcFYyj3E.js";import"./vendor-react-style-singleton-q6EMHnwf.js";import"./vendor-get-nonce-C-Z93AgS.js";import"./vendor-use-sidecar-zDC0RhA3.js";import"./vendor-use-callback-ref-D3RC8gqK.js";import"./vendor-aria-hidden-DvXkyWUv.js";import"./vendor-codemirror-language-DUOssd4j.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-codemirror-state-CNWM3Q8V.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-codemirror-view-DSzLbZiS.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-Bbw3D7r0.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-codemirror-autocomplete-BjbBRsUA.js";import"./vendor-codemirror-lang-json-ryCw7nab.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-VgNqFSH-.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-B3Qe3OpS.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-FGQydhTc.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-CLHw8NWn.js";import"./vendor-codemirror-lang-python-N414WYK-.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-codemirror-commands-ARAOgp1x.js";import"./vendor-tanstack-react-virtual-g05Cx3z9.js";import"./vendor-tanstack-virtual-core-Dubg10g5.js";import"./vendor-framer-motion-CRSgBxjL.js";import"./vendor-motion-dom-DJLgZh4Q.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./vendor-sonner-DFyL3AvE.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";function ke(a){switch(a){case"ok":return null;case"auth":return"onboarding.remoteConnection.probe.authMessage";case"update-recommended":return"onboarding.remoteConnection.probe.updateRecommendedMessage";case"incompatible":return"onboarding.remoteConnection.probe.incompatibleMessage";case"wrong-service":return"onboarding.remoteConnection.probe.wrongServiceMessage";case"unreachable":return"onboarding.remoteConnection.probe.unreachableMessage";default:return null}}function oe(a){return a==="wrong-service"||a==="unreachable"||a==="incompatible"}function xe({onBack:a,showBackButton:t=!0,initialUrl:s="",initialLabel:r="",isRecoveryMode:n=!1,onConnect:l,onSwitchToLocal:u,showInstancePicker:h=!1}){const{t:o}=Q(),[w,S]=_.useState(s),[j,U]=_.useState(r),[K,x]=_.useState("idle"),[m,k]=_.useState(null),[C,g]=_.useState(""),[T,I]=_.useState([]),[y,f]=_.useState(()=>h?"instances":"add"),[b,R]=_.useState("");_.useEffect(()=>{h&&V().then(p=>I(p.hosts)).catch(p=>{g(p instanceof Error?p.message:String(p))})},[h]);const N=we(w),E=N?.persistedUrl??null,F=_.useCallback(p=>{S(p.target.value),x("idle"),k(null),g("")},[]),O=_.useCallback(p=>{U(p.target.value)},[]),c=_.useCallback(async()=>{if(E){x("testing"),k(null),g("");try{const p=await le(E);k(p),x(p.status==="ok"||p.status==="update-recommended"?"success":"error")}catch(p){g(p instanceof Error?p.message:o("onboarding.remoteConnection.errors.connectionTestFailed")),x("error")}}},[E,o]),D=_.useCallback(async()=>{if(!N)return;const p=N.persistedUrl;x("testing"),k(null),g("");try{const H=await le(p);if(k(H),oe(H.status)){x("error");return}const Z=await V(),ye=j.trim()||p,ee=Z.hosts.find(X=>X.url===p),te=ee?ee.id:`host-${Date.now().toString(16)}`,ie={id:te,label:ye,url:p,apiUrl:p},ve=ee?Z.hosts.map(X=>X.id===te?ie:X):[...Z.hosts,ie];if(await Y({hosts:ve,defaultHostId:te,initialHostChoiceCompleted:!0}),l?.(),N.redeemUrl){window.location.assign(N.redeemUrl);return}$()&&await P()}catch(H){g(H instanceof Error?H.message:o("onboarding.remoteConnection.errors.failedToSaveConnection")),x("error")}},[N,j,l,o]),B=_.useCallback(async p=>{const H=await V();await Y({hosts:H.hosts,defaultHostId:p,initialHostChoiceCompleted:!0}),await P()},[]),d=_.useCallback(async()=>{x("testing"),g("");try{const p=await V(),H=await je(b,p.hosts);await Y({hosts:H.hosts,defaultHostId:H.hostId,initialHostChoiceCompleted:!0}),await P()}catch(p){g(p instanceof Error&&p.message==="invalid-connect-link"?o("settings.remoteInstances.direct.error.invalidConnectLink"):o("onboarding.remoteConnection.errors.failedToSaveConnection")),x("error")}},[b,o]),v=K==="testing",M=E!==null&&!v,z=E!==null&&!v&&!oe(m?.status??null),q=ke(m?.status??null),fe=m?.status==="ok",be=m?.status==="update-recommended",ge=m?.status==="auth",ae=oe(m?.status??null);return h&&y==="instances"?e.jsx("div",{className:"flex flex-col items-center justify-center h-full p-8",children:e.jsxs("div",{className:"w-full max-w-md space-y-6",children:[e.jsxs("div",{className:"space-y-2 text-center",children:[e.jsx("h1",{className:"typography-ui-header text-xl font-semibold text-foreground",children:o("desktopHostSwitcher.actions.switchInstance")}),e.jsx("p",{className:"text-muted-foreground text-sm",children:o("settings.remoteInstances.direct.description")})]}),C?e.jsx("div",{className:"text-sm text-[var(--status-error)]",children:C}):null,e.jsx("div",{className:"space-y-2",children:T.length===0?e.jsx("div",{className:"py-4 text-center text-sm text-muted-foreground",children:o("settings.remoteInstances.direct.state.empty")}):T.map(p=>e.jsx(L,{variant:"outline",className:"w-full justify-start",onClick:()=>{B(p.id)},children:e.jsx("span",{className:"min-w-0 truncate",children:p.label})},p.id))}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(L,{variant:"outline",className:"flex-1",onClick:()=>f("import"),children:o("settings.remoteInstances.direct.import.action")}),e.jsx(L,{className:"flex-1",onClick:()=>f("add"),children:o("settings.remoteInstances.direct.actions.add")})]})]})}):h&&y==="import"?e.jsx("div",{className:"flex flex-col items-center justify-center h-full p-8",children:e.jsxs("div",{className:"w-full max-w-md space-y-6",children:[e.jsx(L,{variant:"ghost",onClick:()=>f("instances"),className:"p-0 text-muted-foreground",children:o("onboarding.common.actions.back")}),e.jsxs("div",{className:"space-y-2 text-center",children:[e.jsx("h1",{className:"typography-ui-header text-xl font-semibold text-foreground",children:o("settings.remoteInstances.direct.import.action")}),e.jsx("p",{className:"text-muted-foreground text-sm",children:o("settings.remoteInstances.direct.import.description")})]}),e.jsx(G,{value:b,onChange:p=>R(p.target.value),placeholder:o("settings.remoteInstances.direct.import.placeholder"),disabled:v,autoFocus:!0}),C?e.jsx("div",{className:"text-sm text-[var(--status-error)]",children:C}):null,e.jsx(L,{onClick:()=>{d()},disabled:v||!b.trim(),children:o("settings.remoteInstances.direct.import.action")})]})}):e.jsx("div",{className:"flex flex-col items-center justify-center h-full p-8",children:e.jsxs("div",{className:"w-full max-w-md space-y-6",children:[(t||h)&&e.jsx("div",{className:"flex items-center",children:e.jsx(L,{variant:"ghost",onClick:h?()=>f("instances"):a,className:"p-0 text-muted-foreground hover:text-foreground",children:o("onboarding.common.actions.back")})}),e.jsxs("div",{className:"space-y-2 text-center",children:[e.jsx("h1",{className:"typography-ui-header text-xl font-semibold text-foreground",children:o(n?"onboarding.remoteConnection.titleRecovery":"onboarding.remoteConnection.title")}),e.jsx("p",{className:"text-muted-foreground text-sm",children:o("onboarding.remoteConnection.description")})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{htmlFor:"remote-url",className:"text-sm text-foreground",children:o("onboarding.remoteConnection.field.serverAddress")}),e.jsx(G,{id:"remote-url",type:"url",value:w,onChange:F,placeholder:o("onboarding.remoteConnection.field.serverAddressPlaceholder"),disabled:v})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{htmlFor:"remote-label",className:"text-sm text-foreground",children:o("onboarding.remoteConnection.field.nameOptional")}),e.jsx(G,{id:"remote-label",type:"text",value:j,onChange:O,placeholder:o("onboarding.remoteConnection.field.namePlaceholder"),disabled:v})]})]}),m&&fe&&e.jsx("div",{className:"rounded-lg border p-3 text-sm",style:{borderColor:"var(--status-success)",color:"var(--status-success)"},children:o("onboarding.remoteConnection.status.connectedSuccessfully",{latencyMs:m.latencyMs})}),m&&ge&&e.jsx("div",{className:"rounded-lg border p-3 text-sm",style:{borderColor:"var(--status-warning)",color:"var(--status-warning)"},children:o("onboarding.remoteConnection.status.authWarning")}),m&&be&&e.jsx("div",{className:"rounded-lg border p-3 text-sm",style:{borderColor:"var(--status-warning)",color:"var(--status-warning)"},children:q?o(q):null}),m&&ae&&e.jsxs("div",{className:"rounded-lg border p-3 text-sm space-y-3",style:{borderColor:"var(--status-error)",color:"var(--status-error)"},children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-semibold mb-1",children:o("onboarding.remoteConnection.status.connectionFailed")}),e.jsx("div",{className:"opacity-90",children:q?o(q):null})]}),e.jsx("div",{className:"text-xs opacity-80",children:m.status==="unreachable"?o("onboarding.remoteConnection.status.suggestionsUnreachable"):o("onboarding.remoteConnection.status.suggestionsWrongService")})]}),C&&e.jsx("div",{className:"rounded-lg border p-3 text-sm",style:{borderColor:"var(--status-error)",color:"var(--status-error)"},children:C}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx(L,{variant:"outline",onClick:c,disabled:!M,children:o(v?"onboarding.remoteConnection.actions.testing":"onboarding.remoteConnection.actions.testConnection")}),e.jsx(L,{onClick:D,disabled:!z,children:o("onboarding.remoteConnection.actions.connectAndRestart")})]}),ae&&e.jsxs("div",{className:"flex flex-col gap-2 pt-2 border-t border-border",children:[e.jsx("div",{className:"text-xs text-muted-foreground text-center",children:o("onboarding.remoteConnection.actions.whatToDo")}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(L,{variant:"outline",size:"sm",onClick:a,className:"flex-1",children:o("onboarding.remoteConnection.actions.chooseDifferentServer")}),!n&&u&&e.jsx(L,{variant:"outline",size:"sm",onClick:u,className:"flex-1",children:o("onboarding.remoteConnection.actions.useLocalInstead")})]})]})]})})}const Ce="curl -fsSL https://opencode.ai/install | bash",Ne="https://opencode.ai/docs",ce=2500;function Se(a){const t=J.c(5),{onCopy:s,copyTitle:r}=a;let n;t[0]===Symbol.for("react.memo_cache_sentinel")?(n=e.jsxs("code",{className:"flex-1 text-left overflow-x-auto whitespace-nowrap",children:[e.jsx("span",{style:{color:"var(--syntax-keyword)"},children:"curl"}),e.jsx("span",{className:"text-muted-foreground",children:" -fsSL "}),e.jsx("span",{style:{color:"var(--syntax-string)"},children:"https://opencode.ai/install"}),e.jsx("span",{className:"text-muted-foreground",children:" | "}),e.jsx("span",{style:{color:"var(--syntax-keyword)"},children:"bash"})]}),t[0]=n):n=t[0];let l;t[1]===Symbol.for("react.memo_cache_sentinel")?(l=e.jsx(A,{name:"file-copy",className:"h-4 w-4"}),t[1]=l):l=t[1];let u;return t[2]!==r||t[3]!==s?(u=e.jsxs("div",{className:"flex items-center justify-between gap-3 w-full",children:[n,e.jsx("button",{onClick:s,className:"inline-flex items-center text-muted-foreground hover:text-foreground transition-colors shrink-0",title:r,"aria-label":r,children:l})]}),t[2]=r,t[3]=s,t[4]=u):u=t[4],u}function Re({onCliAvailable:a,localAvailable:t=!0}){const{t:s}=Q(),[r,n]=i.useState(!1),[l,u]=i.useState(!1),[h,o]=i.useState(!1),[w,S]=i.useState(!1),[j,U]=i.useState(""),[K,x]=i.useState("unknown"),[m,k]=i.useState(()=>t?"local":"remote"),[C,g]=i.useState(!1),[T,I]=i.useState(!1);i.useEffect(()=>{u($())},[]),i.useEffect(()=>{if(typeof navigator>"u"){x("unknown");return}const d=navigator.userAgent||"";/Windows/i.test(d)?x("windows"):/Macintosh|Mac OS X/i.test(d)?x("macos"):/Linux/i.test(d)?x("linux"):x("unknown")},[]),i.useEffect(()=>{let d=!1;return(async()=>{try{const v=await W("/api/config/settings",{method:"GET",headers:{Accept:"application/json"}});if(!v.ok)return;const M=await v.json().catch(()=>null);if(!M||d)return;const z=typeof M.opencodeBinary=="string"?M.opencodeBinary.trim():"";z&&U(z)}catch{}})(),()=>{d=!0}},[]);const y=i.useCallback(async d=>{const v=d.target;v.closest(".app-region-no-drag")||v.closest("button, a, input, select, textarea, code, summary, details")||d.button===0&&l&&await ue()},[l]),f=i.useCallback(async()=>{try{const d=await W("/health");if(!d.ok)return!1;const v=await d.json();return v.openCodeRunning===!0||v.isOpenCodeReady===!0}catch{return!1}},[]),b=i.useCallback(async d=>{if(!l)return;const v=await V();await Y({...v,...d==="local"?{defaultHostId:"local"}:{},initialHostChoiceCompleted:!0})},[l]),R=i.useCallback(async()=>{l&&await b("local"),a?.()},[l,a,b]);i.useEffect(()=>{if(!t||m!=="local")return;let d=!1,v=null;const M=async()=>{if(!d){try{const z=await f();if(d)return;if(z){await R();return}}catch{}d||(v=setTimeout(M,ce))}};return v=setTimeout(M,ce),()=>{d=!0,v&&clearTimeout(v)}},[m,f,R,t]);const N=i.useCallback(async()=>{S(!0);try{await f()&&await R()}finally{S(!1)}},[f,R]),E=i.useCallback(async()=>{if(!(typeof window>"u")&&l)try{const d=await me();d.success&&d.path&&d.path.trim().length>0&&U(d.path.trim())}catch{}},[l]),F=i.useCallback(async()=>{o(!0);try{if(await pe({opencodeBinary:j.trim()}),l){await b("local"),await P();return}await W("/api/config/reload",{method:"POST"})}finally{setTimeout(()=>o(!1),1e3)}},[l,j,b]),O=i.useCallback(async()=>{const d=await he(Ce);d.ok?(n(!0),setTimeout(()=>n(!1),2e3)):console.error("Failed to copy:",d.error)},[]),c=Ne,D=K==="windows"?"C:\\Users\\you\\AppData\\Roaming\\npm\\opencode.cmd":K==="linux"?"/home/you/.bun/bin/opencode":"/Users/you/.bun/bin/opencode",B=t&&(!l||m==="local");return e.jsx("div",{className:"app-region-drag h-full flex items-center justify-center bg-transparent p-8 cursor-default select-none overflow-y-auto",onMouseDown:y,children:e.jsxs("div",{className:"w-full max-w-md space-y-7",children:[e.jsxs("header",{className:"text-center space-y-1.5",children:[e.jsx("h1",{className:"text-2xl font-semibold tracking-tight text-foreground",children:s("onboarding.chooser.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("onboarding.chooser.description")})]}),l&&t&&e.jsxs("div",{className:"app-region-no-drag flex gap-1.5",children:[e.jsx("button",{type:"button",className:re("flex-1 px-4 py-2 rounded-lg border transition-colors text-sm",m==="local"?"border-[var(--interactive-selection)] text-foreground bg-[var(--interactive-selection)]/10":"border-border text-muted-foreground hover:text-foreground hover:border-muted-foreground"),onClick:()=>k("local"),children:s("onboarding.chooser.tabs.localInstall")}),e.jsx("button",{type:"button",className:re("flex-1 px-4 py-2 rounded-lg border transition-colors text-sm",m==="remote"?"border-[var(--interactive-selection)] text-foreground bg-[var(--interactive-selection)]/10":"border-border text-muted-foreground hover:text-foreground hover:border-muted-foreground"),onClick:()=>k("remote"),children:s("onboarding.chooser.tabs.connectRemote")})]}),l&&m==="remote"?e.jsx("div",{className:"app-region-no-drag",children:e.jsx(xe,{onBack:()=>t&&k("local"),showBackButton:!1,showInstancePicker:!t,onSwitchToLocal:t?()=>k("local"):void 0})}):null,B&&e.jsxs("div",{className:"space-y-4",children:[K==="windows"&&e.jsxs("div",{className:"rounded-lg border border-border bg-background/50 p-4",children:[e.jsx("div",{className:"text-sm text-foreground",children:s("onboarding.localSetup.windows.title")}),e.jsxs("ol",{className:"mt-2 list-decimal space-y-1 pl-5 text-sm text-muted-foreground",children:[e.jsx("li",{children:s("onboarding.localSetup.windows.stepRunInstallInWsl")}),e.jsx("li",{children:s("onboarding.localSetup.windows.stepSetBinaryPath")})]})]}),e.jsx("p",{className:"text-sm text-muted-foreground text-center leading-relaxed",children:s("onboarding.localSetup.intro")}),e.jsx("div",{className:"app-region-no-drag rounded-lg border border-border bg-background/60 backdrop-blur-sm px-4 py-3 font-mono text-sm",children:r?e.jsxs("div",{className:"flex items-center gap-2",style:{color:"var(--status-success)"},children:[e.jsx(A,{name:"check",className:"h-4 w-4"}),s("onboarding.common.status.copiedToClipboard")]}):e.jsx(Se,{onCopy:O,copyTitle:s("onboarding.common.copyToClipboard")})}),e.jsxs("div",{className:"app-region-no-drag flex items-center justify-between",children:[e.jsxs("a",{href:c,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-muted-foreground hover:text-foreground transition-colors inline-flex items-center gap-1",children:[s(K==="windows"?"onboarding.localSetup.docs.windows":"onboarding.localSetup.docs.default"),e.jsx(A,{name:"external-link",className:"h-3 w-3"})]}),e.jsx("button",{type:"button",onClick:N,disabled:w,className:"text-xs text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50",children:s(w?"onboarding.localSetup.actions.checking":"onboarding.localSetup.actions.checkNow")})]}),e.jsxs("div",{className:"rounded-lg border px-4 py-3 flex items-center gap-3",style:{borderColor:"color-mix(in srgb, var(--primary-base) 20%, transparent)",backgroundColor:"color-mix(in srgb, var(--primary-base) 6%, transparent)"},role:"status","aria-live":"polite",children:[e.jsxs("span",{className:"relative inline-flex h-2.5 w-2.5 shrink-0","aria-hidden":!0,children:[e.jsx("span",{className:"absolute inset-0 rounded-full",style:{backgroundColor:"var(--primary-base)",animation:"pulse-opacity 1.6s ease-in-out infinite"}}),e.jsx("span",{className:"absolute inset-[-4px] rounded-full",style:{backgroundColor:"var(--primary-base)",animation:"pulse-opacity-dim 1.6s ease-in-out infinite",opacity:0}})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-sm text-foreground leading-tight",children:s("onboarding.localSetup.status.watching")}),e.jsx("div",{className:"text-xs text-muted-foreground leading-tight mt-0.5",children:s("onboarding.localSetup.status.autoContinue")})]})]}),e.jsxs("details",{className:"app-region-no-drag group rounded-lg border border-border/60 px-4 open:bg-background/40 transition-colors",open:C,onToggle:d=>g(d.currentTarget.open),children:[e.jsxs("summary",{className:"flex items-center justify-between cursor-pointer py-2.5 text-sm text-muted-foreground hover:text-foreground transition-colors list-none [&::-webkit-details-marker]:hidden",children:[e.jsx("span",{children:s("onboarding.localSetup.advanced.title")}),e.jsx(A,{name:"arrow-down-s",className:"h-4 w-4 transition-transform group-open:rotate-180"})]}),e.jsxs("div",{className:"pb-4 space-y-2",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(G,{value:j,onChange:d=>U(d.target.value),placeholder:D,disabled:h,className:"flex-1 font-mono text-xs"}),e.jsx(L,{type:"button",variant:"secondary",size:"sm",onClick:E,disabled:h||!l,children:s("onboarding.localSetup.actions.browse")}),e.jsx(L,{type:"button",size:"sm",onClick:F,disabled:h||!j.trim(),children:s("onboarding.localSetup.actions.apply")})]}),e.jsx("p",{className:"text-xs text-muted-foreground/70",children:s("onboarding.localSetup.helper.saveAndReload")})]})]}),e.jsxs("details",{className:"app-region-no-drag group rounded-lg border border-border/60 px-4 open:bg-background/40 transition-colors",open:T,onToggle:d=>I(d.currentTarget.open),children:[e.jsxs("summary",{className:"flex items-center justify-between cursor-pointer py-2.5 text-sm text-muted-foreground hover:text-foreground transition-colors list-none [&::-webkit-details-marker]:hidden",children:[e.jsx("span",{children:s("onboarding.localSetup.troubleshoot.title")}),e.jsx(A,{name:"arrow-down-s",className:"h-4 w-4 transition-transform group-open:rotate-180"})]}),e.jsx("ul",{className:"pb-4 space-y-1.5 text-xs text-muted-foreground list-disc pl-4",children:K==="windows"?e.jsx(e.Fragment,{children:e.jsx("li",{children:s("onboarding.localSetup.windows.hintDetectionFailed")})}):e.jsxs(e.Fragment,{children:[e.jsx("li",{children:s("onboarding.localSetup.hint.ensurePath")}),e.jsx("li",{children:s("onboarding.localSetup.hint.setEnv")}),e.jsx("li",{children:s("onboarding.localSetup.hint.missingRuntime")})]})})]})]})]})})}const Le="curl -fsSL https://opencode.ai/install | bash",Ue="https://opencode.ai/docs";function Te(a){const t=J.c(5),{onCopy:s,copyTitle:r}=a;let n;t[0]===Symbol.for("react.memo_cache_sentinel")?(n=e.jsxs("code",{children:[e.jsx("span",{style:{color:"var(--syntax-keyword)"},children:"curl"}),e.jsx("span",{className:"text-muted-foreground",children:" -fsSL "}),e.jsx("span",{style:{color:"var(--syntax-string)"},children:"https://opencode.ai/install"}),e.jsx("span",{className:"text-muted-foreground",children:" | "}),e.jsx("span",{style:{color:"var(--syntax-keyword)"},children:"bash"})]}),t[0]=n):n=t[0];let l;t[1]===Symbol.for("react.memo_cache_sentinel")?(l=e.jsx(A,{name:"file-copy",className:"h-4 w-4"}),t[1]=l):l=t[1];let u;return t[2]!==r||t[3]!==s?(u=e.jsxs("div",{className:"flex items-center justify-center gap-3",children:[n,e.jsx("button",{onClick:s,className:"inline-flex items-center text-muted-foreground hover:text-foreground transition-colors",title:r,children:l})]}),t[2]=r,t[3]=s,t[4]=u):u=t[4],u}const Ke=3e4;function Ie({onBack:a,onCliAvailable:t,isFromRecovery:s=!1,onSwitchToRemote:r}){const{t:n}=Q(),[l,u]=i.useState(!1),[h,o]=i.useState(!1),[w,S]=i.useState(!1),[j,U]=i.useState(!1),[K,x]=i.useState(!1),[m,k]=i.useState(null),[C,g]=i.useState(""),[T,I]=i.useState("unknown");i.useEffect(()=>{const c=setTimeout(()=>o(!0),Ke);return()=>clearTimeout(c)},[]),i.useEffect(()=>{S($())},[]),i.useEffect(()=>{if(typeof navigator>"u"){I("unknown");return}const c=navigator.userAgent||"";if(/Windows/i.test(c)){I("windows");return}if(/Macintosh|Mac OS X/i.test(c)){I("macos");return}if(/Linux/i.test(c)){I("linux");return}I("unknown")},[]),i.useEffect(()=>{let c=!1;return(async()=>{try{const D=await W("/api/config/settings",{method:"GET",headers:{Accept:"application/json"}});if(!D.ok)return;const B=await D.json().catch(()=>null);if(!B||c)return;const d=typeof B.opencodeBinary=="string"?B.opencodeBinary.trim():"";d&&g(d)}catch{}})(),()=>{c=!0}},[]);const y=i.useCallback(async c=>{c.target.closest("button, a, input, select, textarea, code")||c.button===0&&w&&await ue()},[w]),f=i.useCallback(async()=>{try{const c=await W("/health");if(!c.ok)return!1;const D=await c.json();return D.openCodeRunning===!0||D.isOpenCodeReady===!0}catch{return!1}},[]),b=i.useCallback(async()=>{if(!(typeof window>"u")&&w)try{const c=await me();c.success&&c.path&&c.path.trim().length>0&&g(c.path.trim())}catch{}},[w]),R=i.useCallback(async()=>{U(!0);try{if(await pe({opencodeBinary:C.trim()}),w){await P();return}await W("/api/config/reload",{method:"POST"})}finally{setTimeout(()=>U(!1),1e3)}},[w,C]),N=i.useCallback(async()=>{const c=await he(Le);c.ok?(u(!0),setTimeout(()=>u(!1),2e3)):console.error("Failed to copy:",c.error)},[]),E=i.useCallback(async()=>{x(!0),k(null);try{await f()?t?.():k(n("onboarding.localSetup.errors.cliNotReady"))}catch(c){k(c instanceof Error?c.message:n("onboarding.localSetup.errors.detectionFailed"))}finally{x(!1)}},[f,t,n]),F=Ue,O=T==="windows"?"C:\\Users\\you\\AppData\\Roaming\\npm\\opencode.cmd":T==="linux"?"/home/you/.bun/bin/opencode":"/Users/you/.bun/bin/opencode";return e.jsxs("div",{className:"h-full flex items-center justify-center bg-transparent p-8 relative cursor-default select-none",onMouseDown:y,children:[e.jsxs("div",{className:"w-full max-w-lg space-y-4 text-center",children:[e.jsx("div",{className:"flex items-center",children:e.jsx(L,{variant:"ghost",onClick:a,className:"p-0 text-muted-foreground hover:text-foreground",children:n("onboarding.common.actions.back")})}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h1",{className:"text-3xl font-semibold tracking-tight text-foreground",children:n("onboarding.localSetup.title")}),e.jsx("p",{className:"text-muted-foreground",children:n("onboarding.localSetup.description")})]}),T==="windows"&&e.jsxs("div",{className:"mx-auto max-w-2xl rounded-lg border border-border bg-background/50 p-4 text-left",children:[e.jsx("div",{className:"text-sm text-foreground",children:n("onboarding.localSetup.windows.title")}),e.jsxs("ol",{className:"mt-2 list-decimal space-y-1 pl-5 text-sm text-muted-foreground",children:[e.jsx("li",{children:n("onboarding.localSetup.windows.stepRunInstallInWsl")}),e.jsx("li",{children:n("onboarding.localSetup.windows.stepSetBinaryPath")})]})]}),e.jsx("div",{className:"flex justify-center",children:e.jsx("div",{className:"bg-background/60 backdrop-blur-sm border border-border rounded-lg px-5 py-3 font-mono text-sm w-fit",children:l?e.jsxs("div",{className:"flex items-center justify-center gap-2",style:{color:"var(--status-success)"},children:[e.jsx(A,{name:"check",className:"h-4 w-4"}),n("onboarding.common.status.copiedToClipboard")]}):e.jsx(Te,{onCopy:N,copyTitle:n("onboarding.common.copyToClipboard")})})}),e.jsxs("a",{href:F,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-muted-foreground hover:text-foreground transition-colors inline-flex items-center gap-1 justify-center",children:[n(T==="windows"?"onboarding.localSetup.docs.windows":"onboarding.localSetup.docs.default"),e.jsx(A,{name:"external-link",className:"h-3 w-3"})]}),m&&e.jsx("div",{className:"mx-auto max-w-md rounded-lg border border-destructive/50 bg-destructive/10 p-3 text-sm text-destructive",children:m}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(L,{type:"button",onClick:E,disabled:K,className:"w-full max-w-xs",size:"lg",children:n(K?"onboarding.localSetup.actions.checking":"onboarding.localSetup.actions.checkAndContinue")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:n("onboarding.localSetup.helper.checkAndContinue")})]}),e.jsx("div",{className:"mx-auto w-full max-w-xl pt-4",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:n("onboarding.localSetup.field.alreadyInstalled")}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(G,{value:C,onChange:c=>g(c.target.value),placeholder:O,disabled:j,className:"flex-1 font-mono text-xs"}),e.jsx(L,{type:"button",variant:"secondary",onClick:b,disabled:j||!w,children:n("onboarding.localSetup.actions.browse")}),e.jsx(L,{type:"button",onClick:R,disabled:j,children:n("onboarding.localSetup.actions.apply")})]}),e.jsx("div",{className:"text-xs text-muted-foreground/70",children:n("onboarding.localSetup.helper.saveAndReload")})]})}),s&&r&&e.jsxs("div",{className:"text-center pt-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:n("onboarding.localSetup.remotePreference")}),e.jsx(L,{variant:"link",onClick:r,children:n("onboarding.localSetup.actions.connectRemoteServer")})]})]}),h&&e.jsx("div",{className:"absolute bottom-8 left-0 right-0 text-center space-y-1",children:T==="windows"?e.jsx(e.Fragment,{children:e.jsx("p",{className:"text-sm text-muted-foreground/70",children:n("onboarding.localSetup.windows.hintDetectionFailed")})}):e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-sm text-muted-foreground/70",children:n("onboarding.localSetup.hint.ensurePath")}),e.jsx("p",{className:"text-sm text-muted-foreground/70",children:n("onboarding.localSetup.hint.setEnv")}),e.jsx("p",{className:"text-sm text-muted-foreground/70",children:n("onboarding.localSetup.hint.missingRuntime")})]})})]})}function se(a,t){if(a?.trim())return ne(a.trim());if(t)return ne(t)}function _e(a,t,s){switch(a){case"local-unavailable":return{title:"Local OpenCode Unavailable",description:"OpenCode CLI could not be started or is not installed. Install OpenCode or connect to a remote server instead.",titleKey:"onboarding.desktopRecovery.localUnavailable.title",descriptionKey:"onboarding.desktopRecovery.localUnavailable.description",iconKey:"local",showRetry:!0,retryLabel:"Retry Local",retryLabelKey:"onboarding.desktopRecovery.localUnavailable.retry",showUseLocal:!0,showUseRemote:!0,useLocalLabel:"Set Up Local",useLocalLabelKey:"onboarding.desktopRecovery.localUnavailable.useLocal",useRemoteLabel:"Use Remote",useRemoteLabelKey:"onboarding.desktopRecovery.common.useRemote"};case"remote-missing":return{title:"No Default Connection",description:"Your saved default connection could not be found. Choose how you want to connect.",titleKey:"onboarding.desktopRecovery.noDefaultConnection.title",descriptionKey:"onboarding.desktopRecovery.noDefaultConnection.description",iconKey:"local",showRetry:!1,showUseLocal:!0,showUseRemote:!0,useLocalLabel:"Use Local",useLocalLabelKey:"onboarding.desktopRecovery.common.useLocal",useRemoteLabel:"Use Remote",useRemoteLabelKey:"onboarding.desktopRecovery.common.useRemote"};case"remote-unreachable":{const r=se(t,s);return{title:"Remote Server Unreachable",description:`Could not connect to "${r||"the remote server"}". Check your network connection and verify the server address.`,titleKey:"onboarding.desktopRecovery.remoteUnreachable.title",descriptionKey:"onboarding.desktopRecovery.remoteUnreachable.description",descriptionParams:r?{host:r}:void 0,iconKey:"remote",showRetry:!0,retryLabel:"Retry Connection",retryLabelKey:"onboarding.desktopRecovery.remoteUnreachable.retry",showUseLocal:!0,showUseRemote:!0,useLocalLabel:"Use Local",useLocalLabelKey:"onboarding.desktopRecovery.common.useLocal",useRemoteLabel:"Use Remote",useRemoteLabelKey:"onboarding.desktopRecovery.common.useRemote"}}case"remote-wrong-service":{const r=se(t,s);return{title:"Incompatible Server",description:`The server at "${r||"unknown"}" is not running OpenChamber. Verify the address points to an OpenChamber server.`,titleKey:"onboarding.desktopRecovery.incompatibleServer.title",descriptionKey:"onboarding.desktopRecovery.incompatibleServer.description",descriptionParams:r?{host:r}:void 0,iconKey:"remote",showRetry:!1,showUseLocal:!0,showUseRemote:!0,useLocalLabel:"Use Local",useLocalLabelKey:"onboarding.desktopRecovery.common.useLocal",useRemoteLabel:"Use Remote",useRemoteLabelKey:"onboarding.desktopRecovery.common.useRemote"}}case"remote-incompatible":{const r=se(t,s);return{title:"Server Update Required",description:`The OpenChamber server at "${r||"unknown"}" is not compatible with this app version. Update OpenChamber on the server, then try again.`,titleKey:"onboarding.desktopRecovery.remoteIncompatible.title",descriptionKey:"onboarding.desktopRecovery.remoteIncompatible.description",descriptionParams:r?{host:r}:void 0,iconKey:"remote",showRetry:!0,retryLabel:"Retry Connection",retryLabelKey:"onboarding.desktopRecovery.remoteUnreachable.retry",showUseLocal:!0,showUseRemote:!0,useLocalLabel:"Use Local",useLocalLabelKey:"onboarding.desktopRecovery.common.useLocal",useRemoteLabel:"Use Remote",useRemoteLabelKey:"onboarding.desktopRecovery.common.useRemote"}}case"missing-default-host":return{title:"No Default Connection",description:"Your saved default connection could not be found. Choose how you want to connect.",titleKey:"onboarding.desktopRecovery.noDefaultConnection.title",descriptionKey:"onboarding.desktopRecovery.noDefaultConnection.description",iconKey:"local",showRetry:!1,showUseLocal:!0,showUseRemote:!0,useLocalLabel:"Use Local",useLocalLabelKey:"onboarding.desktopRecovery.common.useLocal",useRemoteLabel:"Use Remote",useRemoteLabelKey:"onboarding.desktopRecovery.common.useRemote"};default:{const r=a;throw new Error(`Unknown recovery variant: ${r}`)}}}function De(a){switch(a){case"local":return e.jsx(A,{name:"macbook",className:"h-8 w-8"});case"remote":return e.jsx(A,{name:"server",className:"h-8 w-8"})}}function Ee({variant:a,hostLabel:t,hostUrl:s,onRetry:r,onUseLocal:n,onUseRemote:l,isRetrying:u=!1}){const{t:h}=Q(),o=_e(a,t,s),w=o.retryLabelKey??"onboarding.desktopRecovery.actions.retryConnection",S=i.useMemo(()=>{if(o.descriptionParams?.host)return o.descriptionParams;if(a==="remote-unreachable")return{host:h("onboarding.desktopRecovery.placeholders.remoteServer")};if(a==="remote-wrong-service"||a==="remote-incompatible")return{host:h("onboarding.desktopRecovery.placeholders.unknownServer")}},[o.descriptionParams,h,a]);return e.jsx("div",{className:"flex flex-col items-center justify-center h-full p-8",children:e.jsxs("div",{className:"w-full max-w-md space-y-6",children:[e.jsxs("div",{className:"flex flex-col items-center space-y-3 text-center",children:[e.jsx("div",{className:"p-3 rounded-full",style:{backgroundColor:"var(--status-warning)",opacity:.15},children:e.jsx("div",{style:{color:"var(--status-warning)"},children:De(o.iconKey)})}),e.jsx("h1",{className:"typography-ui-header text-xl font-semibold text-foreground",children:h(o.titleKey)}),e.jsx("p",{className:"text-muted-foreground text-sm max-w-sm",children:h(o.descriptionKey,S)})]}),s&&(a==="remote-unreachable"||a==="remote-wrong-service"||a==="remote-incompatible")&&e.jsxs("div",{className:"rounded-lg border border-border bg-background/50 p-3",children:[e.jsx("div",{className:"text-xs text-muted-foreground mb-1",children:h("onboarding.remoteConnection.field.serverAddress")}),e.jsx("div",{className:"font-mono text-sm text-foreground truncate",children:ne(s)})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[o.showRetry&&r&&e.jsxs(L,{onClick:r,disabled:u,className:"w-full",children:[e.jsx(A,{name:"refresh",className:re("h-4 w-4",u&&"animate-spin")}),h(u?"onboarding.desktopRecovery.actions.retrying":w)]}),e.jsxs("div",{className:"flex gap-2",children:[o.showUseLocal&&n&&e.jsxs(L,{variant:"outline",onClick:n,disabled:u,className:"flex-1",children:[e.jsx(A,{name:"macbook",className:"h-4 w-4"}),h(o.useLocalLabelKey)]}),o.showUseRemote&&l&&e.jsxs(L,{variant:"outline",onClick:l,disabled:u,className:"flex-1",children:[e.jsx(A,{name:"server",className:"h-4 w-4"}),h(o.useRemoteLabelKey)]})]})]})]})})}function de(a,t){if(t==="use-remote")return{kind:"remote-form"};switch(a){case"local-unavailable":return{kind:"local-setup"};case"remote-unreachable":case"remote-incompatible":case"remote-wrong-service":case"remote-missing":case"missing-default-host":return{kind:"switch-default-to-local"};default:{const s=a;throw new Error(`Unhandled RecoveryVariant: ${s}`)}}}function Ae(a){const t=J.c(29),{variant:s,hostUrl:r,hostLabel:n,onRetry:l,onChooseRemote:u,showRemoteForm:h,onCloseRemoteForm:o,onSwitchToLocalFromRemote:w,onEnterLocalSetup:S,isRetrying:j,localAvailable:U}=a,K=h===void 0?!1:h,x=j===void 0?!1:j,m=U===void 0?!0:U,k=Fe;let C;t[0]!==l?(C=async()=>{if($()){await P();return}await W("/api/config/reload",{method:"POST"}),l?.()},t[0]=l,t[1]=C):C=t[1];const g=C;let T;t[2]!==S||t[3]!==s?(T=async()=>{if(de(s,"use-local").kind==="local-setup"){S?.();return}if(await k("local"),$()){await P();return}window.location.reload()},t[2]=S,t[3]=s,t[4]=T):T=t[4];const I=T;let y;t[5]!==u||t[6]!==s?(y=()=>{de(s,"use-remote").kind==="remote-form"&&u?.()},t[5]=u,t[6]=s,t[7]=y):y=t[7];const f=y;if(K){const N=s==="remote-wrong-service"?"":r||"",E=s==="remote-wrong-service"?"":n||"";let F;t[8]!==u||t[9]!==o?(F=o||(()=>u?.()),t[8]=u,t[9]=o,t[10]=F):F=t[10];const O=!m;let c;t[11]!==m||t[12]!==S||t[13]!==w?(c=m?w||(()=>{k("local").then(()=>{$()?P():S?.()})}):void 0,t[11]=m,t[12]=S,t[13]=w,t[14]=c):c=t[14];let D;return t[15]!==E||t[16]!==N||t[17]!==F||t[18]!==O||t[19]!==c?(D=e.jsx(xe,{onBack:F,initialUrl:N,initialLabel:E,isRecoveryMode:!0,showInstancePicker:O,onSwitchToLocal:c}),t[15]=E,t[16]=N,t[17]=F,t[18]=O,t[19]=c,t[20]=D):D=t[20],D}const b=m?I:void 0;let R;return t[21]!==g||t[22]!==f||t[23]!==n||t[24]!==r||t[25]!==x||t[26]!==b||t[27]!==s?(R=e.jsx(Ee,{variant:s,hostLabel:n,hostUrl:r,onRetry:g,onUseLocal:b,onUseRemote:f,isRetrying:x}),t[21]=g,t[22]=f,t[23]=n,t[24]=r,t[25]=x,t[26]=b,t[27]=s,t[28]=R):R=t[28],R}async function Fe(a){if(!$())return;const t=await V();await Y({...t,...a==="local"?{defaultHostId:"local"}:{},initialHostChoiceCompleted:!0})}function co(a){const t=J.c(29),{onBack:s,onCliAvailable:r,mode:n,recoveryVariant:l,recoveryHostUrl:u,recoveryHostLabel:h,onEnterLocalSetup:o,localAvailable:w}=a,S=n===void 0?"first-launch":n,j=l===void 0?"missing-default-host":l,U=w===void 0?!0:w,[K,x]=i.useState(!1),[m,k]=i.useState(!1);let C;t[0]===Symbol.for("react.memo_cache_sentinel")?(C=()=>{k(!1),x(!1)},t[0]=C):C=t[0];let g;t[1]!==S||t[2]!==h||t[3]!==u||t[4]!==j?(g=[S,j,u,h],t[1]=S,t[2]=h,t[3]=u,t[4]=j,t[5]=g):g=t[5],i.useEffect(C,g);const T=m?"local-setup":S;if(T==="recovery"){let y;t[6]===Symbol.for("react.memo_cache_sentinel")?(y=()=>x(!0),t[6]=y):y=t[6];let f,b;t[7]===Symbol.for("react.memo_cache_sentinel")?(f=()=>x(!1),b=()=>{x(!1),k(!0)},t[7]=f,t[8]=b):(f=t[7],b=t[8]);let R;t[9]!==o?(R=()=>{k(!0),o?.()},t[9]=o,t[10]=R):R=t[10];let N;return t[11]!==U||t[12]!==h||t[13]!==u||t[14]!==j||t[15]!==K||t[16]!==R?(N=e.jsx(Ae,{variant:j,hostUrl:u,hostLabel:h,onChooseRemote:y,showRemoteForm:K,onCloseRemoteForm:f,onSwitchToLocalFromRemote:b,onEnterLocalSetup:R,localAvailable:U}),t[11]=U,t[12]=h,t[13]=u,t[14]=j,t[15]=K,t[16]=R,t[17]=N):N=t[17],N}if(T==="local-setup"){let y;t[18]!==s||t[19]!==m?(y=()=>{m?k(!1):s?.()},t[18]=s,t[19]=m,t[20]=y):y=t[20];let f;t[21]===Symbol.for("react.memo_cache_sentinel")?(f=()=>x(!0),t[21]=f):f=t[21];let b;return t[22]!==r||t[23]!==m||t[24]!==y?(b=e.jsx(Ie,{onBack:y,onCliAvailable:r,isFromRecovery:m,onSwitchToRemote:f}),t[22]=r,t[23]=m,t[24]=y,t[25]=b):b=t[25],b}let I;return t[26]!==U||t[27]!==r?(I=e.jsx(Re,{onCliAvailable:r,localAvailable:U}),t[26]=U,t[27]=r,t[28]=I):I=t[28],I}export{co as OnboardingScreen};
@@ -1 +1 @@
1
- import{h2 as j,gt as k,gB as y}from"./useAppFontEffects-sHmU5b8u.js";import{k as D,a as C}from"./web-components-BL-Ur2Tb.js";import{M as P,G as O,u as L,W as A,a as M,b as R,n as F,t as H}from"./Virtualizer-X_7XPoTH.js";import{j as d,r as w}from"./vendor-react-BUCujlKS.js";import{V as _,F as N}from"./VirtualizedFileDiff-DkcusvMa.js";function T({hunkIndex:e,lineIndex:t,conflictIndex:n}){return`merge-conflict-action-${e}-${t}-${n}`}function V(e,t){const n=t.hunks[e.hunkIndex];if(n!=null)return{hunkIndex:e.hunkIndex,lineIndex:z(n,e.startContentIndex)}}function z(e,t){let n=e.unifiedLineStart;for(let l=0;l<t;l++){const o=e.hunkContent[l];n+=o.type==="context"?o.lines:o.deletions+o.additions}return n}function U(e){const t=j(e);if(t.length!==1)throw console.error(t),new Error("PatchDiff: Provided patch must include only 1 patch, with 1 diff");const{files:n}=t[0];if(n.length!==1)throw console.error(n),new Error("FileDiff: Provided patch must contain exactly 1 file diff");return n[0]}function $({fileDiff:e,actions:t,renderCustomHeader:n,renderHeaderPrefix:l,renderHeaderFilenameSuffix:o,renderHeaderMetadata:x,renderAnnotation:f,renderGutterUtility:u,renderMergeConflictUtility:s,lineAnnotations:a,getHoveredLine:p,getInstance:m}){const g=n?.(e),c=l?.(e),i=o?.(e),v=x?.(e);return d.jsxs(d.Fragment,{children:[g!=null?d.jsx("div",{slot:k,children:g}):d.jsxs(d.Fragment,{children:[c!=null&&d.jsx("div",{slot:"header-prefix",children:c}),i!=null&&d.jsx("div",{slot:"header-filename-suffix",children:i}),v!=null&&d.jsx("div",{slot:"header-metadata",children:v})]}),f!=null&&a?.map((r,h)=>d.jsx("div",{slot:D(r),children:f(r)},h)),t!=null&&s!=null&&m!=null&&t.map(r=>{if(r==null)return;const h=b(r,e);return d.jsx("div",{slot:h,style:P,children:s(r,m)},h)}),u!=null&&d.jsx("div",{slot:"gutter-utility-slot",style:O,children:u(p)})]})}function b(e,t){const n=V(e,t);return n!=null?T({hunkIndex:n.hunkIndex,lineIndex:n.lineIndex,conflictIndex:e.conflictIndex}):void 0}const S=typeof window>"u"?w.useEffect:w.useLayoutEffect;function G({fileDiff:e,options:t,lineAnnotations:n,selectedLines:l,prerenderedHTML:o,metrics:x,hasGutterRenderUtility:f,hasCustomHeader:u,disableWorkerPool:s,contentEditable:a}){const p=L(),m=l!==void 0,g=w.useContext(A),c=M(),i=w.useRef(null),v=R(r=>{if(r!=null){if(i.current!=null)throw new Error("useFileDiffInstance: An instance should not already exist when a node is created");p!=null?i.current=new _(E({controlledSelection:m,contentEditable:a,hasCustomHeader:u,hasEditor:c!==void 0,hasGutterRenderUtility:f,options:t}),p,x,s?void 0:g,!0):i.current=new N(E({controlledSelection:m,contentEditable:a,hasCustomHeader:u,hasEditor:c!==void 0,hasGutterRenderUtility:f,options:t}),s?void 0:g,!0),i.current.hydrate({fileDiff:e,fileContainer:r,lineAnnotations:n,prerenderedHTML:o})}else{if(i.current==null)throw new Error("useFileDiffInstance: A FileDiff instance should exist when unmounting");i.current.cleanUp(),i.current=null}});return S(()=>{const{current:r}=i;if(r==null)return;const h=E({controlledSelection:m,contentEditable:a,hasCustomHeader:u,hasEditor:c!==void 0,hasGutterRenderUtility:f,options:t}),I=!C(r.options,h);r.setOptions(h),r.render({forceRender:I,fileDiff:e,lineAnnotations:n}),l!==void 0&&r.setSelectedLines(l)}),S(()=>{if(a&&i.current!=null){if(c===void 0)throw new Error("FileDiff: Editor is not attached");return c.edit(i.current)}},[a,c]),{ref:v,getHoveredLine:w.useCallback(()=>i.current?.getHoveredLine(),[])}}function E({options:e,controlledSelection:t,contentEditable:n,hasCustomHeader:l,hasEditor:o,hasGutterRenderUtility:x}){const f=n&&o,u=t||x||l;if(!u&&!f)return e;let s={...e};return u&&(s={...s,controlledSelection:t,renderCustomHeader:l?F:e?.renderCustomHeader,renderGutterUtility:x?F:e?.renderGutterUtility}),f&&(s={...s,useTokenTransformer:!0,enableGutterUtility:!1,enableLineSelection:!1,expandUnchanged:!0,lineHoverHighlight:"disabled"}),s}function X({patch:e,options:t,metrics:n,lineAnnotations:l,selectedLines:o,className:x,style:f,prerenderedHTML:u,renderAnnotation:s,renderCustomHeader:a,renderHeaderPrefix:p,renderHeaderFilenameSuffix:m,renderHeaderMetadata:g,renderGutterUtility:c,disableWorkerPool:i=!1,contentEditable:v=!1}){const r=q(e),{ref:h,getHoveredLine:I}=G({fileDiff:r,options:t,metrics:n,lineAnnotations:l,selectedLines:o,prerenderedHTML:u,hasGutterRenderUtility:c!=null,hasCustomHeader:a!=null,disableWorkerPool:i,contentEditable:v});return d.jsx(y,{ref:h,className:x,style:f,children:H($({fileDiff:r,renderCustomHeader:a,renderHeaderPrefix:p,renderHeaderFilenameSuffix:m,renderHeaderMetadata:g,renderAnnotation:s,lineAnnotations:l,renderGutterUtility:c,getHoveredLine:I}),u)})}function q(e){return w.useMemo(()=>U(e),[e])}export{X as P};
1
+ import{h2 as j,gt as k,gB as y}from"./useAppFontEffects-BikB6enL.js";import{k as D,a as C}from"./web-components-GMc3oR3i.js";import{M as P,G as O,u as L,W as A,a as M,b as R,n as F,t as H}from"./Virtualizer-X_7XPoTH.js";import{j as d,r as w}from"./vendor-react-BUCujlKS.js";import{V as _,F as N}from"./VirtualizedFileDiff-CwGocYQd.js";function T({hunkIndex:e,lineIndex:t,conflictIndex:n}){return`merge-conflict-action-${e}-${t}-${n}`}function V(e,t){const n=t.hunks[e.hunkIndex];if(n!=null)return{hunkIndex:e.hunkIndex,lineIndex:z(n,e.startContentIndex)}}function z(e,t){let n=e.unifiedLineStart;for(let l=0;l<t;l++){const o=e.hunkContent[l];n+=o.type==="context"?o.lines:o.deletions+o.additions}return n}function U(e){const t=j(e);if(t.length!==1)throw console.error(t),new Error("PatchDiff: Provided patch must include only 1 patch, with 1 diff");const{files:n}=t[0];if(n.length!==1)throw console.error(n),new Error("FileDiff: Provided patch must contain exactly 1 file diff");return n[0]}function $({fileDiff:e,actions:t,renderCustomHeader:n,renderHeaderPrefix:l,renderHeaderFilenameSuffix:o,renderHeaderMetadata:x,renderAnnotation:f,renderGutterUtility:u,renderMergeConflictUtility:s,lineAnnotations:a,getHoveredLine:p,getInstance:m}){const g=n?.(e),c=l?.(e),i=o?.(e),v=x?.(e);return d.jsxs(d.Fragment,{children:[g!=null?d.jsx("div",{slot:k,children:g}):d.jsxs(d.Fragment,{children:[c!=null&&d.jsx("div",{slot:"header-prefix",children:c}),i!=null&&d.jsx("div",{slot:"header-filename-suffix",children:i}),v!=null&&d.jsx("div",{slot:"header-metadata",children:v})]}),f!=null&&a?.map((r,h)=>d.jsx("div",{slot:D(r),children:f(r)},h)),t!=null&&s!=null&&m!=null&&t.map(r=>{if(r==null)return;const h=b(r,e);return d.jsx("div",{slot:h,style:P,children:s(r,m)},h)}),u!=null&&d.jsx("div",{slot:"gutter-utility-slot",style:O,children:u(p)})]})}function b(e,t){const n=V(e,t);return n!=null?T({hunkIndex:n.hunkIndex,lineIndex:n.lineIndex,conflictIndex:e.conflictIndex}):void 0}const S=typeof window>"u"?w.useEffect:w.useLayoutEffect;function G({fileDiff:e,options:t,lineAnnotations:n,selectedLines:l,prerenderedHTML:o,metrics:x,hasGutterRenderUtility:f,hasCustomHeader:u,disableWorkerPool:s,contentEditable:a}){const p=L(),m=l!==void 0,g=w.useContext(A),c=M(),i=w.useRef(null),v=R(r=>{if(r!=null){if(i.current!=null)throw new Error("useFileDiffInstance: An instance should not already exist when a node is created");p!=null?i.current=new _(E({controlledSelection:m,contentEditable:a,hasCustomHeader:u,hasEditor:c!==void 0,hasGutterRenderUtility:f,options:t}),p,x,s?void 0:g,!0):i.current=new N(E({controlledSelection:m,contentEditable:a,hasCustomHeader:u,hasEditor:c!==void 0,hasGutterRenderUtility:f,options:t}),s?void 0:g,!0),i.current.hydrate({fileDiff:e,fileContainer:r,lineAnnotations:n,prerenderedHTML:o})}else{if(i.current==null)throw new Error("useFileDiffInstance: A FileDiff instance should exist when unmounting");i.current.cleanUp(),i.current=null}});return S(()=>{const{current:r}=i;if(r==null)return;const h=E({controlledSelection:m,contentEditable:a,hasCustomHeader:u,hasEditor:c!==void 0,hasGutterRenderUtility:f,options:t}),I=!C(r.options,h);r.setOptions(h),r.render({forceRender:I,fileDiff:e,lineAnnotations:n}),l!==void 0&&r.setSelectedLines(l)}),S(()=>{if(a&&i.current!=null){if(c===void 0)throw new Error("FileDiff: Editor is not attached");return c.edit(i.current)}},[a,c]),{ref:v,getHoveredLine:w.useCallback(()=>i.current?.getHoveredLine(),[])}}function E({options:e,controlledSelection:t,contentEditable:n,hasCustomHeader:l,hasEditor:o,hasGutterRenderUtility:x}){const f=n&&o,u=t||x||l;if(!u&&!f)return e;let s={...e};return u&&(s={...s,controlledSelection:t,renderCustomHeader:l?F:e?.renderCustomHeader,renderGutterUtility:x?F:e?.renderGutterUtility}),f&&(s={...s,useTokenTransformer:!0,enableGutterUtility:!1,enableLineSelection:!1,expandUnchanged:!0,lineHoverHighlight:"disabled"}),s}function X({patch:e,options:t,metrics:n,lineAnnotations:l,selectedLines:o,className:x,style:f,prerenderedHTML:u,renderAnnotation:s,renderCustomHeader:a,renderHeaderPrefix:p,renderHeaderFilenameSuffix:m,renderHeaderMetadata:g,renderGutterUtility:c,disableWorkerPool:i=!1,contentEditable:v=!1}){const r=q(e),{ref:h,getHoveredLine:I}=G({fileDiff:r,options:t,metrics:n,lineAnnotations:l,selectedLines:o,prerenderedHTML:u,hasGutterRenderUtility:c!=null,hasCustomHeader:a!=null,disableWorkerPool:i,contentEditable:v});return d.jsx(y,{ref:h,className:x,style:f,children:H($({fileDiff:r,renderCustomHeader:a,renderHeaderPrefix:p,renderHeaderFilenameSuffix:m,renderHeaderMetadata:g,renderAnnotation:s,lineAnnotations:l,renderGutterUtility:c,getHoveredLine:I}),u)})}function q(e){return w.useMemo(()=>U(e),[e])}export{X as P};
@@ -1,4 +1,4 @@
1
- import{R as F,j as O,c as we,r as d}from"./vendor-react-BUCujlKS.js";import{a as $e}from"./web-components-BL-Ur2Tb.js";import{f as Te}from"./computeVirtualFileMetrics-xPena3W2.js";import{V as Ne,F as Be}from"./VirtualizedFileDiff-DkcusvMa.js";import{dZ as je,aV as Ue,bU as Ge,h as ke}from"./useAppFontEffects-sHmU5b8u.js";import{I as Ce,a as Qe,u as Ke}from"./useInlineCommentController-gt56WkxJ.js";import{V as Ye}from"./runtimeEndpointReset-cbahJ3hD.js";import{ensurePierreThemeRegistered as Me,getResolvedShikiTheme as Oe}from"./appThemeRegistry-BK0dHKa6.js";import{ag as Le}from"./index-iFY_N5aO.js";const he=new Set;let Re=null;function I(s){he.add(s),Re??=requestAnimationFrame(Pe)}function Pe(s){const e=new Set(he);he.clear();for(const t of e)try{t(s)}catch(n){console.error(n)}he.size>0?Re=requestAnimationFrame(Pe):Re=null}function De({scrollTop:s,scrollHeight:e,height:t,fitPerfectly:n=!1,fitPerfectlyOverscroll:r=0,overscrollSize:l}){const u=t+l*2,h=n?t+r*2:u;if(e=Math.max(e,h),u>=e||n){const m=Math.max(s-r,0),S=Math.min(s+h,e);return{top:m,bottom:Math.max(S,m)}}let a=s+t/2-u/2,g=a+u;return a<0&&(a=0),g>e&&(g=e),a=Math.floor(Math.max(a,0)),{top:a,bottom:Math.ceil(Math.max(Math.min(g,e),a))}}function Ze(s,e){return s==null||e==null?s===e:s.top===e.top&&s.bottom===e.bottom}const He=1e3,Xe=He*4,Je=[0,1e-6,.99999,1],et={overscrollSize:He,intersectionObserverMargin:Xe,resizeDebugging:!1};let ue=0,tt=-1;var nt=class H{static __STOP=!1;static __lastScrollPosition=0;__id=`virtualizer-${++tt}`;config;type="simple";intersectionObserver;scrollTop=0;height=0;scrollHeight=0;windowSpecs={top:0,bottom:0};root;contentContainer;resizeObserver;observers=new Map;visibleInstances=new Map;visibleInstancesDirty=!1;instancesChanged=new Set;scrollDirty=!0;heightDirty=!0;scrollHeightDirty=!0;renderedObservers=0;connectQueue=new Map;constructor(e){this.config={...et,...e}}setup(e,t){if(this.root==null){this.root=e,this.resizeObserver=new ResizeObserver(this.handleContainerResize),this.intersectionObserver=new IntersectionObserver(this.handleIntersectionChange,{root:this.root,threshold:Je,rootMargin:`${this.config.intersectionObserverMargin}px 0px ${this.config.intersectionObserverMargin}px 0px`}),e instanceof Document?this.setupWindow():this.setupElement(t),window.__INSTANCE=this,window.__TOGGLE=()=>{H.__STOP?(H.__STOP=!1,(this.getScrollContainerElement()??window).scrollTo({top:H.__lastScrollPosition}),I(this.computeRenderRangeAndEmit)):(H.__lastScrollPosition=this.getScrollTop(),H.__STOP=!0)};for(const[n,r]of this.connectQueue.entries())this.connect(n,r);this.connectQueue.clear(),this.markDOMDirty(),I(this.computeRenderRangeAndEmit)}}instanceChanged(e,t){this.instancesChanged.add(e),t&&this.markDOMDirty(),I(this.computeRenderRangeAndEmit)}getWindowSpecs(){return this.windowSpecs.top===0&&this.windowSpecs.bottom===0&&(this.windowSpecs=De({scrollTop:this.getScrollTop(),height:this.getHeight(),scrollHeight:this.getScrollHeight(),overscrollSize:this.config.overscrollSize})),this.windowSpecs}isInstanceVisible(e,t){const n=this.getScrollTop(),r=this.getHeight(),l=this.config.intersectionObserverMargin,u=n-l,h=n+r+l;return!(e<u-t||e>h)}handleContainerResize=e=>{if(this.root==null)return;let t=!1;for(const n of e){const r=n.borderBoxSize[0].blockSize;this.root instanceof Document?r!==this.scrollHeight&&(this.scrollHeightDirty=!0,t=!0,this.config.resizeDebugging&&(console.log("Virtualizer: content size change",this.__id,{sizeChange:r-ue,newSize:r}),ue=r)):n.target===this.root?r!==this.height&&(this.heightDirty=!0,t=!0):n.target===this.contentContainer&&(this.scrollHeightDirty=!0,t=!0,this.config.resizeDebugging&&(console.log("Virtualizer: scroller size change",this.__id,{sizeChange:r-ue,newSize:r}),ue=r))}t&&I(this.computeRenderRangeAndEmit)};setupWindow(){if(this.root==null||!(this.root instanceof Document))throw new Error("Virtualizer.setupWindow: Invalid setup method");window.addEventListener("scroll",this.handleWindowScroll,{passive:!0}),window.addEventListener("resize",this.handleWindowResize,{passive:!0}),this.resizeObserver?.observe(this.root.documentElement)}setupElement(e){if(this.root==null||this.root instanceof Document)throw new Error("Virtualizer.setupElement: Invalid setup method");this.root.addEventListener("scroll",this.handleElementScroll,{passive:!0}),this.resizeObserver?.observe(this.root),e??=this.root.firstElementChild??void 0,e instanceof HTMLElement&&(this.contentContainer=e,this.resizeObserver?.observe(e))}cleanUp(){this.resizeObserver?.disconnect(),this.resizeObserver=void 0,this.intersectionObserver?.disconnect(),this.intersectionObserver=void 0,this.root?.removeEventListener("scroll",this.handleElementScroll),window.removeEventListener("scroll",this.handleWindowScroll),window.removeEventListener("resize",this.handleWindowResize),this.root=void 0,this.contentContainer=void 0,this.observers.clear(),this.visibleInstances.clear(),this.instancesChanged.clear(),this.connectQueue.clear(),this.visibleInstancesDirty=!1,this.windowSpecs={top:0,bottom:0},this.scrollTop=0,this.height=0,this.scrollHeight=0}getOffsetInScrollContainer(e){return this.getScrollTop()+se(e,this.getScrollContainerElement())}connect(e,t){if(this.observers.has(e))throw new Error("Virtualizer.connect: instance is already connected...");return this.intersectionObserver==null?this.connectQueue.set(e,t):(this.intersectionObserver.observe(e),this.observers.set(e,t),this.instancesChanged.add(t),this.markDOMDirty(),I(this.computeRenderRangeAndEmit)),()=>this.disconnect(e)}disconnect(e){const t=this.observers.get(e);this.connectQueue.delete(e),t!=null&&(this.intersectionObserver?.unobserve(e),this.observers.delete(e),this.visibleInstances.delete(e)&&(this.visibleInstancesDirty=!0),this.markDOMDirty(),I(this.computeRenderRangeAndEmit))}handleWindowResize=()=>{H.__STOP||window.innerHeight===this.height||(this.heightDirty=!0,I(this.computeRenderRangeAndEmit))};handleWindowScroll=()=>{H.__STOP||this.root==null||!(this.root instanceof Document)||(this.scrollDirty=!0,I(this.computeRenderRangeAndEmit))};handleElementScroll=()=>{H.__STOP||this.root==null||this.root instanceof Document||(this.scrollDirty=!0,I(this.computeRenderRangeAndEmit))};computeRenderRangeAndEmit=()=>{if(H.__STOP)return;const e=this.heightDirty||this.scrollHeightDirty;if(!this.scrollDirty&&!this.scrollHeightDirty&&!this.heightDirty&&this.renderedObservers===this.observers.size&&!this.visibleInstancesDirty&&this.instancesChanged.size===0)return;let t=this.instancesChanged.size>0;if(this.instancesChanged.size===0){const l=De({scrollTop:this.getScrollTop(),height:this.getHeight(),scrollHeight:this.getScrollHeight(),overscrollSize:this.config.overscrollSize});if(!e&&Ze(this.windowSpecs,l)&&this.renderedObservers===this.observers.size&&!this.visibleInstancesDirty)return;this.windowSpecs=l}this.visibleInstancesDirty=!1,this.renderedObservers=this.observers.size;const n=this.getScrollAnchor(this.height),r=new Set;for(const l of e?this.observers.values():this.visibleInstances.values())l.onRender(e)&&r.add(l);for(const l of this.instancesChanged)r.has(l)||l.onRender(e)&&r.add(l);this.scrollFix(n);for(const l of r)l.reconcileHeights();t||=this.instancesChanged.size>0,t&&this.markDOMDirty(),(t||e)&&I(this.computeRenderRangeAndEmit),r.clear(),this.instancesChanged.clear()};scrollFix(e){if(e==null)return;const t=this.getScrollContainerElement(),{lineIndex:n,lineOffset:r,fileElement:l,fileOffset:u,fileTypeOffset:h}=e;if(n!=null&&r!=null){const g=l.shadowRoot?.querySelector(`[data-line][data-line-index="${n}"]`);if(g instanceof HTMLElement){const m=se(g,t);if(m!==r){const S=m-r;this.applyScrollFix(S)}return}}const a=se(l,t);if(h==="top")a!==u&&this.applyScrollFix(a-u);else{const g=a+l.getBoundingClientRect().height;g!==u&&this.applyScrollFix(g-u)}}applyScrollFix(e){this.root==null||this.root instanceof Document?window.scrollTo({top:window.scrollY+e,behavior:"instant"}):this.root.scrollTo({top:this.root.scrollTop+e,behavior:"instant"}),this.markDOMDirty()}getScrollAnchor(e){const t=this.getScrollContainerElement();let n;for(const[r]of this.visibleInstances.entries()){const l=se(r,t),u=l+r.offsetHeight;let h,a;u<=0?(h=u,a="bottom"):(h=l,a="top");let g,m;if(u>0&&l<e)for(const L of r.shadowRoot?.querySelectorAll("[data-line][data-line-index]")??[]){if(!(L instanceof HTMLElement))continue;const B=L.dataset.lineIndex;if(B==null)continue;const j=se(L,t);if(!(j<0)){g=B,m=j;break}}if(n?.lineOffset!=null&&m==null)continue;let S=!1;(n==null||m!=null&&(n.lineOffset==null||m<n.lineOffset)||m==null&&n.lineOffset==null&&(h>=0&&(n.fileOffset<0||h<n.fileOffset)||h<0&&n.fileOffset<0&&h>n.fileOffset))&&(S=!0),S&&(n={fileElement:r,fileTypeOffset:a,fileOffset:h,lineIndex:g,lineOffset:m})}return n}handleIntersectionChange=e=>{this.scrollDirty=!0;for(const{target:t,isIntersecting:n}of e){if(!(t instanceof HTMLElement))throw new Error("Virtualizer.handleIntersectionChange: target not an HTMLElement");const r=this.observers.get(t);r!=null&&(n&&!this.visibleInstances.has(t)?(r.setVisibility(!0),this.visibleInstances.set(t,r),this.visibleInstancesDirty=!0):!n&&this.visibleInstances.has(t)&&(r.setVisibility(!1),this.visibleInstances.delete(t),this.visibleInstancesDirty=!0))}this.visibleInstancesDirty&&I(this.computeRenderRangeAndEmit)};getScrollTop(){if(!this.scrollDirty)return this.scrollTop;this.scrollDirty=!1;let e=this.root==null?0:this.root instanceof Document?window.scrollY:this.root.scrollTop;return e=Math.max(0,Math.min(e,this.getScrollHeight()-this.getHeight())),this.scrollTop=e,e}getScrollHeight(){return this.scrollHeightDirty?(this.scrollHeightDirty=!1,this.scrollHeight=this.root==null?0:this.root instanceof Document?this.root.documentElement.scrollHeight:this.root.scrollHeight,this.scrollHeight):this.scrollHeight}getHeight(){return this.heightDirty?(this.heightDirty=!1,this.height=this.root==null?0:this.root instanceof Document?globalThis.innerHeight:this.root.getBoundingClientRect().height,this.height):this.height}markDOMDirty(){this.scrollDirty=!0,this.scrollHeightDirty=!0,this.heightDirty=!0}getScrollContainerElement(){return this.root==null||this.root instanceof Document?void 0:this.root}};function se(s,e){const t=s.getBoundingClientRect(),n=e?.getBoundingClientRect().top??0;return t.top-n}const pe=s=>{if(s.type==="new"){const e=Math.min(s.selection.start,s.selection.end),t=Math.max(s.selection.start,s.selection.end);return`new-comment-${s.selection.side??"additions"}-${e}-${t}`}return`draft-${s.draft.id}`},it=s=>{const{drafts:e,editingDraftId:t,selection:n}=s,r=[];for(const l of e){if(!Number.isFinite(l.endLine))continue;const u=Math.max(1,Math.floor(l.endLine)),h=l.side==="original"?"deletions":"additions";r.push({lineNumber:u,side:h,metadata:{type:l.id===t?"edit":"saved",draft:l}})}return n&&!t&&r.push({lineNumber:Math.max(n.start,n.end),side:n.side??"additions",metadata:{type:"new",selection:n}}),r};function rt(s){const e=s.trim();if(!e)return null;if(/^-?\d+(\.\d+)?$/.test(e)){const t=Number.parseFloat(e);return Number.isFinite(t)?t:null}if(e.endsWith("px")){const t=Number.parseFloat(e.slice(0,-2));return Number.isFinite(t)?t:null}return null}function ze(s){if(!(!s||s<=0))return Math.max(200,Math.floor(s))}function st(s){const{diffRootRef:e,drafts:t,selection:n,editingDraftId:r,commentText:l,onTextChange:u,fileLabel:h,onSave:a,onCancel:g,onEdit:m,onDelete:S}=s,[L,B]=F.useState(0),[j,X]=F.useState(null),b=F.useMemo(()=>!n||r?null:pe({type:"new",selection:n}),[r,n]),_=F.useMemo(()=>{const c=t.map(y=>pe({type:y.id===r?"edit":"saved",draft:y}));return b&&c.push(b),c},[t,r,b]),$=F.useCallback(c=>{const y=e.current;if(!y)return null;const w=y.querySelector("diffs-container");if(!(w instanceof HTMLElement))return null;const k=w.querySelector(`[data-annotation-id="${c}"]`);if(k instanceof HTMLElement)return k;const A=w.shadowRoot;return A?A.querySelector(`[data-annotation-id="${c}"]`):null},[e]);F.useEffect(()=>{if(_.length===0)return;let c=!1,y=0;const w=12,k=()=>{c||_.every(D=>!!$(D))||y>=w||(y+=1,requestAnimationFrame(()=>{c||(B(D=>D+1),k())}))};return k(),()=>{c=!0}},[_,$]),F.useEffect(()=>{const c=e.current;if(!c)return;const y=()=>{const k=getComputedStyle(c),A=rt(k.getPropertyValue("--oc-context-panel-width")),D=c.getBoundingClientRect(),N=A??D.width;X(N>0?N:null)};y();const w=new ResizeObserver(()=>{y()});return w.observe(c),window.addEventListener("resize",y),()=>{w.disconnect(),window.removeEventListener("resize",y)}},[e]);const G=F.useCallback(c=>{const w=e.current?.getBoundingClientRect(),k=c.closest("[data-annotation-content]"),A=k instanceof HTMLElement?k.getBoundingClientRect():c.getBoundingClientRect(),D=[A.width];w&&D.push(w.right-A.left);const N=D.filter(J=>Number.isFinite(J)&&J>0);return N.length>0?ze(Math.min(...N)):ze(j)},[e,j]);return O.jsxs(O.Fragment,{children:[t.map(c=>{const y=pe({type:c.id===r?"edit":"saved",draft:c}),w=$(y);if(!w)return null;const k=G(w);return c.id===r?we.createPortal(O.jsx(Ce,{initialText:l,onTextChange:u,fileLabel:h,lineRange:{start:c.startLine,end:c.endLine,side:c.side==="original"?"deletions":"additions"},isEditing:!0,onSave:a,onCancel:g,maxWidth:k}),w,`draft-edit-${c.id}`):we.createPortal(O.jsx(Qe,{draft:c,onEdit:()=>m(c),onDelete:()=>S(c),maxWidth:k}),w,`draft-card-${c.id}`)}),n&&!r&&b&&(()=>{const c=$(b);if(!c)return null;const y=G(c);return we.createPortal(O.jsx(Ce,{initialText:l,onTextChange:u,fileLabel:h,lineRange:n,isEditing:!1,onSave:a,onCancel:g,maxWidth:y}),c,b)})()]})}const Ie=5e5,ot=`
1
+ import{R as F,j as O,c as we,r as d}from"./vendor-react-BUCujlKS.js";import{a as $e}from"./web-components-GMc3oR3i.js";import{f as Te}from"./computeVirtualFileMetrics-Da00Jg7M.js";import{V as Ne,F as Be}from"./VirtualizedFileDiff-CwGocYQd.js";import{dZ as je,aV as Ue,bU as Ge,h as ke}from"./useAppFontEffects-BikB6enL.js";import{I as Ce,a as Qe,u as Ke}from"./useInlineCommentController-CYPvYJDt.js";import{V as Ye}from"./runtimeEndpointReset-BVmispdD.js";import{ensurePierreThemeRegistered as Me,getResolvedShikiTheme as Oe}from"./appThemeRegistry-BK0dHKa6.js";import{ag as Le}from"./index-DRpChWux.js";const he=new Set;let Re=null;function I(s){he.add(s),Re??=requestAnimationFrame(Pe)}function Pe(s){const e=new Set(he);he.clear();for(const t of e)try{t(s)}catch(n){console.error(n)}he.size>0?Re=requestAnimationFrame(Pe):Re=null}function De({scrollTop:s,scrollHeight:e,height:t,fitPerfectly:n=!1,fitPerfectlyOverscroll:r=0,overscrollSize:l}){const u=t+l*2,h=n?t+r*2:u;if(e=Math.max(e,h),u>=e||n){const m=Math.max(s-r,0),S=Math.min(s+h,e);return{top:m,bottom:Math.max(S,m)}}let a=s+t/2-u/2,g=a+u;return a<0&&(a=0),g>e&&(g=e),a=Math.floor(Math.max(a,0)),{top:a,bottom:Math.ceil(Math.max(Math.min(g,e),a))}}function Ze(s,e){return s==null||e==null?s===e:s.top===e.top&&s.bottom===e.bottom}const He=1e3,Xe=He*4,Je=[0,1e-6,.99999,1],et={overscrollSize:He,intersectionObserverMargin:Xe,resizeDebugging:!1};let ue=0,tt=-1;var nt=class H{static __STOP=!1;static __lastScrollPosition=0;__id=`virtualizer-${++tt}`;config;type="simple";intersectionObserver;scrollTop=0;height=0;scrollHeight=0;windowSpecs={top:0,bottom:0};root;contentContainer;resizeObserver;observers=new Map;visibleInstances=new Map;visibleInstancesDirty=!1;instancesChanged=new Set;scrollDirty=!0;heightDirty=!0;scrollHeightDirty=!0;renderedObservers=0;connectQueue=new Map;constructor(e){this.config={...et,...e}}setup(e,t){if(this.root==null){this.root=e,this.resizeObserver=new ResizeObserver(this.handleContainerResize),this.intersectionObserver=new IntersectionObserver(this.handleIntersectionChange,{root:this.root,threshold:Je,rootMargin:`${this.config.intersectionObserverMargin}px 0px ${this.config.intersectionObserverMargin}px 0px`}),e instanceof Document?this.setupWindow():this.setupElement(t),window.__INSTANCE=this,window.__TOGGLE=()=>{H.__STOP?(H.__STOP=!1,(this.getScrollContainerElement()??window).scrollTo({top:H.__lastScrollPosition}),I(this.computeRenderRangeAndEmit)):(H.__lastScrollPosition=this.getScrollTop(),H.__STOP=!0)};for(const[n,r]of this.connectQueue.entries())this.connect(n,r);this.connectQueue.clear(),this.markDOMDirty(),I(this.computeRenderRangeAndEmit)}}instanceChanged(e,t){this.instancesChanged.add(e),t&&this.markDOMDirty(),I(this.computeRenderRangeAndEmit)}getWindowSpecs(){return this.windowSpecs.top===0&&this.windowSpecs.bottom===0&&(this.windowSpecs=De({scrollTop:this.getScrollTop(),height:this.getHeight(),scrollHeight:this.getScrollHeight(),overscrollSize:this.config.overscrollSize})),this.windowSpecs}isInstanceVisible(e,t){const n=this.getScrollTop(),r=this.getHeight(),l=this.config.intersectionObserverMargin,u=n-l,h=n+r+l;return!(e<u-t||e>h)}handleContainerResize=e=>{if(this.root==null)return;let t=!1;for(const n of e){const r=n.borderBoxSize[0].blockSize;this.root instanceof Document?r!==this.scrollHeight&&(this.scrollHeightDirty=!0,t=!0,this.config.resizeDebugging&&(console.log("Virtualizer: content size change",this.__id,{sizeChange:r-ue,newSize:r}),ue=r)):n.target===this.root?r!==this.height&&(this.heightDirty=!0,t=!0):n.target===this.contentContainer&&(this.scrollHeightDirty=!0,t=!0,this.config.resizeDebugging&&(console.log("Virtualizer: scroller size change",this.__id,{sizeChange:r-ue,newSize:r}),ue=r))}t&&I(this.computeRenderRangeAndEmit)};setupWindow(){if(this.root==null||!(this.root instanceof Document))throw new Error("Virtualizer.setupWindow: Invalid setup method");window.addEventListener("scroll",this.handleWindowScroll,{passive:!0}),window.addEventListener("resize",this.handleWindowResize,{passive:!0}),this.resizeObserver?.observe(this.root.documentElement)}setupElement(e){if(this.root==null||this.root instanceof Document)throw new Error("Virtualizer.setupElement: Invalid setup method");this.root.addEventListener("scroll",this.handleElementScroll,{passive:!0}),this.resizeObserver?.observe(this.root),e??=this.root.firstElementChild??void 0,e instanceof HTMLElement&&(this.contentContainer=e,this.resizeObserver?.observe(e))}cleanUp(){this.resizeObserver?.disconnect(),this.resizeObserver=void 0,this.intersectionObserver?.disconnect(),this.intersectionObserver=void 0,this.root?.removeEventListener("scroll",this.handleElementScroll),window.removeEventListener("scroll",this.handleWindowScroll),window.removeEventListener("resize",this.handleWindowResize),this.root=void 0,this.contentContainer=void 0,this.observers.clear(),this.visibleInstances.clear(),this.instancesChanged.clear(),this.connectQueue.clear(),this.visibleInstancesDirty=!1,this.windowSpecs={top:0,bottom:0},this.scrollTop=0,this.height=0,this.scrollHeight=0}getOffsetInScrollContainer(e){return this.getScrollTop()+se(e,this.getScrollContainerElement())}connect(e,t){if(this.observers.has(e))throw new Error("Virtualizer.connect: instance is already connected...");return this.intersectionObserver==null?this.connectQueue.set(e,t):(this.intersectionObserver.observe(e),this.observers.set(e,t),this.instancesChanged.add(t),this.markDOMDirty(),I(this.computeRenderRangeAndEmit)),()=>this.disconnect(e)}disconnect(e){const t=this.observers.get(e);this.connectQueue.delete(e),t!=null&&(this.intersectionObserver?.unobserve(e),this.observers.delete(e),this.visibleInstances.delete(e)&&(this.visibleInstancesDirty=!0),this.markDOMDirty(),I(this.computeRenderRangeAndEmit))}handleWindowResize=()=>{H.__STOP||window.innerHeight===this.height||(this.heightDirty=!0,I(this.computeRenderRangeAndEmit))};handleWindowScroll=()=>{H.__STOP||this.root==null||!(this.root instanceof Document)||(this.scrollDirty=!0,I(this.computeRenderRangeAndEmit))};handleElementScroll=()=>{H.__STOP||this.root==null||this.root instanceof Document||(this.scrollDirty=!0,I(this.computeRenderRangeAndEmit))};computeRenderRangeAndEmit=()=>{if(H.__STOP)return;const e=this.heightDirty||this.scrollHeightDirty;if(!this.scrollDirty&&!this.scrollHeightDirty&&!this.heightDirty&&this.renderedObservers===this.observers.size&&!this.visibleInstancesDirty&&this.instancesChanged.size===0)return;let t=this.instancesChanged.size>0;if(this.instancesChanged.size===0){const l=De({scrollTop:this.getScrollTop(),height:this.getHeight(),scrollHeight:this.getScrollHeight(),overscrollSize:this.config.overscrollSize});if(!e&&Ze(this.windowSpecs,l)&&this.renderedObservers===this.observers.size&&!this.visibleInstancesDirty)return;this.windowSpecs=l}this.visibleInstancesDirty=!1,this.renderedObservers=this.observers.size;const n=this.getScrollAnchor(this.height),r=new Set;for(const l of e?this.observers.values():this.visibleInstances.values())l.onRender(e)&&r.add(l);for(const l of this.instancesChanged)r.has(l)||l.onRender(e)&&r.add(l);this.scrollFix(n);for(const l of r)l.reconcileHeights();t||=this.instancesChanged.size>0,t&&this.markDOMDirty(),(t||e)&&I(this.computeRenderRangeAndEmit),r.clear(),this.instancesChanged.clear()};scrollFix(e){if(e==null)return;const t=this.getScrollContainerElement(),{lineIndex:n,lineOffset:r,fileElement:l,fileOffset:u,fileTypeOffset:h}=e;if(n!=null&&r!=null){const g=l.shadowRoot?.querySelector(`[data-line][data-line-index="${n}"]`);if(g instanceof HTMLElement){const m=se(g,t);if(m!==r){const S=m-r;this.applyScrollFix(S)}return}}const a=se(l,t);if(h==="top")a!==u&&this.applyScrollFix(a-u);else{const g=a+l.getBoundingClientRect().height;g!==u&&this.applyScrollFix(g-u)}}applyScrollFix(e){this.root==null||this.root instanceof Document?window.scrollTo({top:window.scrollY+e,behavior:"instant"}):this.root.scrollTo({top:this.root.scrollTop+e,behavior:"instant"}),this.markDOMDirty()}getScrollAnchor(e){const t=this.getScrollContainerElement();let n;for(const[r]of this.visibleInstances.entries()){const l=se(r,t),u=l+r.offsetHeight;let h,a;u<=0?(h=u,a="bottom"):(h=l,a="top");let g,m;if(u>0&&l<e)for(const L of r.shadowRoot?.querySelectorAll("[data-line][data-line-index]")??[]){if(!(L instanceof HTMLElement))continue;const B=L.dataset.lineIndex;if(B==null)continue;const j=se(L,t);if(!(j<0)){g=B,m=j;break}}if(n?.lineOffset!=null&&m==null)continue;let S=!1;(n==null||m!=null&&(n.lineOffset==null||m<n.lineOffset)||m==null&&n.lineOffset==null&&(h>=0&&(n.fileOffset<0||h<n.fileOffset)||h<0&&n.fileOffset<0&&h>n.fileOffset))&&(S=!0),S&&(n={fileElement:r,fileTypeOffset:a,fileOffset:h,lineIndex:g,lineOffset:m})}return n}handleIntersectionChange=e=>{this.scrollDirty=!0;for(const{target:t,isIntersecting:n}of e){if(!(t instanceof HTMLElement))throw new Error("Virtualizer.handleIntersectionChange: target not an HTMLElement");const r=this.observers.get(t);r!=null&&(n&&!this.visibleInstances.has(t)?(r.setVisibility(!0),this.visibleInstances.set(t,r),this.visibleInstancesDirty=!0):!n&&this.visibleInstances.has(t)&&(r.setVisibility(!1),this.visibleInstances.delete(t),this.visibleInstancesDirty=!0))}this.visibleInstancesDirty&&I(this.computeRenderRangeAndEmit)};getScrollTop(){if(!this.scrollDirty)return this.scrollTop;this.scrollDirty=!1;let e=this.root==null?0:this.root instanceof Document?window.scrollY:this.root.scrollTop;return e=Math.max(0,Math.min(e,this.getScrollHeight()-this.getHeight())),this.scrollTop=e,e}getScrollHeight(){return this.scrollHeightDirty?(this.scrollHeightDirty=!1,this.scrollHeight=this.root==null?0:this.root instanceof Document?this.root.documentElement.scrollHeight:this.root.scrollHeight,this.scrollHeight):this.scrollHeight}getHeight(){return this.heightDirty?(this.heightDirty=!1,this.height=this.root==null?0:this.root instanceof Document?globalThis.innerHeight:this.root.getBoundingClientRect().height,this.height):this.height}markDOMDirty(){this.scrollDirty=!0,this.scrollHeightDirty=!0,this.heightDirty=!0}getScrollContainerElement(){return this.root==null||this.root instanceof Document?void 0:this.root}};function se(s,e){const t=s.getBoundingClientRect(),n=e?.getBoundingClientRect().top??0;return t.top-n}const pe=s=>{if(s.type==="new"){const e=Math.min(s.selection.start,s.selection.end),t=Math.max(s.selection.start,s.selection.end);return`new-comment-${s.selection.side??"additions"}-${e}-${t}`}return`draft-${s.draft.id}`},it=s=>{const{drafts:e,editingDraftId:t,selection:n}=s,r=[];for(const l of e){if(!Number.isFinite(l.endLine))continue;const u=Math.max(1,Math.floor(l.endLine)),h=l.side==="original"?"deletions":"additions";r.push({lineNumber:u,side:h,metadata:{type:l.id===t?"edit":"saved",draft:l}})}return n&&!t&&r.push({lineNumber:Math.max(n.start,n.end),side:n.side??"additions",metadata:{type:"new",selection:n}}),r};function rt(s){const e=s.trim();if(!e)return null;if(/^-?\d+(\.\d+)?$/.test(e)){const t=Number.parseFloat(e);return Number.isFinite(t)?t:null}if(e.endsWith("px")){const t=Number.parseFloat(e.slice(0,-2));return Number.isFinite(t)?t:null}return null}function ze(s){if(!(!s||s<=0))return Math.max(200,Math.floor(s))}function st(s){const{diffRootRef:e,drafts:t,selection:n,editingDraftId:r,commentText:l,onTextChange:u,fileLabel:h,onSave:a,onCancel:g,onEdit:m,onDelete:S}=s,[L,B]=F.useState(0),[j,X]=F.useState(null),b=F.useMemo(()=>!n||r?null:pe({type:"new",selection:n}),[r,n]),_=F.useMemo(()=>{const c=t.map(y=>pe({type:y.id===r?"edit":"saved",draft:y}));return b&&c.push(b),c},[t,r,b]),$=F.useCallback(c=>{const y=e.current;if(!y)return null;const w=y.querySelector("diffs-container");if(!(w instanceof HTMLElement))return null;const k=w.querySelector(`[data-annotation-id="${c}"]`);if(k instanceof HTMLElement)return k;const A=w.shadowRoot;return A?A.querySelector(`[data-annotation-id="${c}"]`):null},[e]);F.useEffect(()=>{if(_.length===0)return;let c=!1,y=0;const w=12,k=()=>{c||_.every(D=>!!$(D))||y>=w||(y+=1,requestAnimationFrame(()=>{c||(B(D=>D+1),k())}))};return k(),()=>{c=!0}},[_,$]),F.useEffect(()=>{const c=e.current;if(!c)return;const y=()=>{const k=getComputedStyle(c),A=rt(k.getPropertyValue("--oc-context-panel-width")),D=c.getBoundingClientRect(),N=A??D.width;X(N>0?N:null)};y();const w=new ResizeObserver(()=>{y()});return w.observe(c),window.addEventListener("resize",y),()=>{w.disconnect(),window.removeEventListener("resize",y)}},[e]);const G=F.useCallback(c=>{const w=e.current?.getBoundingClientRect(),k=c.closest("[data-annotation-content]"),A=k instanceof HTMLElement?k.getBoundingClientRect():c.getBoundingClientRect(),D=[A.width];w&&D.push(w.right-A.left);const N=D.filter(J=>Number.isFinite(J)&&J>0);return N.length>0?ze(Math.min(...N)):ze(j)},[e,j]);return O.jsxs(O.Fragment,{children:[t.map(c=>{const y=pe({type:c.id===r?"edit":"saved",draft:c}),w=$(y);if(!w)return null;const k=G(w);return c.id===r?we.createPortal(O.jsx(Ce,{initialText:l,onTextChange:u,fileLabel:h,lineRange:{start:c.startLine,end:c.endLine,side:c.side==="original"?"deletions":"additions"},isEditing:!0,onSave:a,onCancel:g,maxWidth:k}),w,`draft-edit-${c.id}`):we.createPortal(O.jsx(Qe,{draft:c,onEdit:()=>m(c),onDelete:()=>S(c),maxWidth:k}),w,`draft-card-${c.id}`)}),n&&!r&&b&&(()=>{const c=$(b);if(!c)return null;const y=G(c);return we.createPortal(O.jsx(Ce,{initialText:l,onTextChange:u,fileLabel:h,lineRange:n,isEditing:!1,onSave:a,onCancel:g,maxWidth:y}),c,b)})()]})}const Ie=5e5,ot=`
2
2
  :host {
3
3
  font-family: var(--font-mono);
4
4
  font-size: var(--text-code);
@@ -1,4 +1,4 @@
1
- import{R as s,j as r}from"./vendor-react-BUCujlKS.js";import{l as et,u as ee,r as Ve,n as tt}from"./index-iFY_N5aO.js";import{c as rt,s as st,P as nt,C as it}from"./shikiHighlight-CmanopUB.js";import{f as ot,y as z,c0 as at,ak as lt,b as Ie,a4 as ct,a0 as ut,V as mt,aV as dt,L as pt,gm as ft,l as Fe,gn as ht,aa as Le,fI as gt,cR as Ae,eL as wt,eM as vt,m as St,go as xt,aU as $e,aX as te,aY as re,aR as ze,B as K,I,aZ as se,aT as We,aQ as J,g as yt,bU as bt,ac as jt,bQ as Ct}from"./useAppFontEffects-sHmU5b8u.js";import{u as Mt,n as Tt}from"./useInlineCommentController-gt56WkxJ.js";import{b as kt}from"./CodeMirrorCommentWidgets-DbUi6I9s.js";import{getResolvedShikiTheme as Nt}from"./appThemeRegistry-BK0dHKa6.js";import{E as Et}from"./vendor-codemirror-view-DSzLbZiS.js";import{R as Pt}from"./runtimeEndpointReset-cbahJ3hD.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-opencode-sdk-BJ73u-bH.js";import"./vendor-zustand-BAGL70zf.js";import"./vendor-codemirror-state-CNWM3Q8V.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-codemirror-commands-ARAOgp1x.js";import"./vendor-codemirror-language-DUOssd4j.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-lezer-highlight-CDMHUZ74.js";import"./vendor-style-mod-NZ5MEPvj.js";import"./vendor-codemirror-search-8kyQdB3f.js";import"./vendor-crelt-C8TCjufn.js";import"./vendor-replit-codemirror-vim-B0Ecqnlh.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-base-ui-D_V6hAcE.js";import"./vendor-floating-ui-utils-BzXdqYpP.js";import"./vendor-floating-ui-dom-WyXykhNi.js";import"./vendor-floating-ui-core-CXmKXOXc.js";import"./vendor-floating-ui-react-dom-DKpLs02S.js";import"./vendor-use-sync-external-store-D6wYuSt-.js";import"./contextPanelEmbeddedChat-tQekJUAF.js";import"./vendor-class-variance-authority-5VPnzWs2.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-dnd-kit-core-BZknOX2w.js";import"./vendor-dnd-kit-utilities-B_MdXhJC.js";import"./vendor-dnd-kit-accessibility-BHxJPORy.js";import"./vendor-dnd-kit-sortable-CsEagZ81.js";import"./vendor-cmdk-DgLInKvT.js";import"./vendor-radix-ui-react-dialog-B94Bt2qq.js";import"./vendor-radix-ui-primitive-Dc_FVRD7.js";import"./vendor-radix-ui-react-compose-refs-DcAh5WdT.js";import"./vendor-radix-ui-react-context-Czxm7Z62.js";import"./vendor-radix-ui-react-id-f5BLKEVw.js";import"./vendor-radix-ui-react-use-layout-effect-D_3IhJdJ.js";import"./vendor-radix-ui-react-use-controllable-state-BFT5YmkA.js";import"./vendor-radix-ui-react-dismissable-layer-D7kXcwgJ.js";import"./vendor-radix-ui-react-primitive-DhVoX9SD.js";import"./vendor-radix-ui-react-slot-BQgQOasS.js";import"./vendor-radix-ui-react-use-callback-ref-BZPnuXAC.js";import"./vendor-radix-ui-react-use-escape-keydown-oph88g-F.js";import"./vendor-radix-ui-react-focus-scope-CiaxW4dD.js";import"./vendor-radix-ui-react-portal-BMJYHWck.js";import"./vendor-radix-ui-react-presence-CNxf-uq4.js";import"./vendor-radix-ui-react-focus-guards-B6qJXYua.js";import"./vendor-react-remove-scroll-DO7dCTnK.js";import"./vendor-tslib-De9GV7Vy.js";import"./vendor-react-remove-scroll-bar-BcFYyj3E.js";import"./vendor-react-style-singleton-q6EMHnwf.js";import"./vendor-get-nonce-C-Z93AgS.js";import"./vendor-use-sidecar-zDC0RhA3.js";import"./vendor-use-callback-ref-D3RC8gqK.js";import"./vendor-aria-hidden-DvXkyWUv.js";import"./vendor-codemirror-lang-javascript-Bbw3D7r0.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-codemirror-autocomplete-BjbBRsUA.js";import"./vendor-w3c-keyname-Vcq4gwWv.js";import"./vendor-codemirror-lang-json-ryCw7nab.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-VgNqFSH-.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-B3Qe3OpS.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-FGQydhTc.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-Dihw9MtL.js";import"./vendor-codemirror-lang-python-N414WYK-.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-tanstack-react-virtual-g05Cx3z9.js";import"./vendor-tanstack-virtual-core-Dubg10g5.js";import"./vendor-framer-motion-CRSgBxjL.js";import"./vendor-motion-dom-DJLgZh4Q.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./vendor-sonner-DFyL3AvE.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./registerCustomTheme-BBXUCRnG.js";import"./themeResolver-BmJyTmjJ.js";import"./vendor-pierre-theming-C6Z4M5_u.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";const x=u=>{if(!u)return"";const l=u.replace(/\\/g,"/");return l==="/"?"/":l.replace(/\/+$/,"")},ne=(u,l)=>{const t=x(u),p=l.replace(/\\/g,"/").replace(/^\/+/,"").replace(/\/+$/,"");return!t||t==="/"?`/${p}`:`${t}/${p}`},Dt=(u,l,t)=>ne(ne(ne(u,".opencode"),"plans"),`${l}-${t}.md`),Rt=(u,l)=>`~/.opencode/plans/${u}-${l}.md`,Vt=(u,l)=>{const t=u.trim();return t.startsWith("~")?t==="~"?l||t:(t.startsWith("~/")||t.startsWith("~\\"))&&l?`${l}${t.slice(1)}`:t:t},It=(u,l)=>{const t=x(l.currentDirectory),p=x(l.homeDirectory),h=x(u);return t&&h.startsWith(t+"/")?h.slice(t.length+1):p&&h===p?"~":p&&h.startsWith(p+"/")?`~${h.slice(p.length)}`:h},Ft=(u,l,t)=>{const p=x(u.trim());if(!p)return null;const h=t?l.find(g=>g.id===t)??null:null;if(h?.path){const g=x(h.path);if(p===g||p.startsWith(`${g}/`))return{id:h.id,path:h.path}}const E=l.filter(g=>{const k=x(g.path);return p===k||p.startsWith(`${k}/`)}).sort((g,k)=>x(k.path).length-x(g.path).length)[0];return E?{id:E.id,path:E.path}:null},Ds=({targetPath:u=null,onNavigatedToChat:l})=>{const{t}=ot(),p=z(e=>e.currentSessionId),h=z(e=>e.createSession),E=z(e=>e.initializeNewOpenChamberSession),g=z(e=>e.sendMessage),k=z(e=>e.setCurrentSession),ie=at(),F=et(e=>e.homeDirectory),oe=lt(e=>e.planModeEnabled),ae=Ie(e=>e.projects),le=Ie(e=>e.activeProjectId),ce=ct(e=>e.directories),ue=ut()??"",me=ee(e=>e.setActiveMainTab),de=ee(e=>e.setSessionSwitcherOpen),P=mt(),{isMobile:pe}=dt(),{currentTheme:W}=pt(),w=s.useMemo(()=>p?ie.find(e=>e.id===p)??null:null,[p,ie]),j=s.useMemo(()=>{const e=typeof w?.directory=="string"?w.directory:"";return x(e||"")},[w?.directory]),fe=s.useMemo(()=>x(ue||j),[ue,j]),y=s.useMemo(()=>Ft(fe,ae,le),[le,fe,ae]),O=s.useMemo(()=>y?ce.get(y.path)?.isGitRepo===!0:!1,[y,ce]),[N,D]=s.useState(null),[he,ge]=s.useState(!1),[m,C]=s.useState(null),Q=s.useMemo(()=>!m||!j||!F?m:It(m,{currentDirectory:j,homeDirectory:F}),[m,j,F]),[f,b]=s.useState(""),{isPlaying:_,play:Oe,stop:_e}=ft(),Be=Fe(e=>e.showMessageTTSButtons),[we,B]=s.useState(null),Y=s.useMemo(()=>Q&&Q.split("/").pop()||t("planView.file.defaultName"),[Q,t]),X=s.useMemo(()=>f.trim()&&ht(f).title||t("planView.title.default"),[f,t]),G=s.useMemo(()=>X.trim()||t("planView.title.default"),[X,t]),[Ge,L]=s.useState(!1),[Ue,ve]=s.useState(!1),[U,Se]=s.useState("edit"),A=s.useRef(null),[o,v]=s.useState(null),xe=s.useRef(null),He=s.useRef(null),ye="openchamber:plan:md-viewer-mode";s.useEffect(()=>{try{const e=localStorage.getItem(ye);if(!e)return;const i=JSON.parse(e);(i==="preview"||i==="edit")&&Se(i)}catch{}},[]);const Ke=s.useCallback(e=>{Se(e);try{localStorage.setItem(ye,JSON.stringify(e))}catch{}},[]),R=s.useRef(!1),M=s.useRef(null),[be,V]=s.useState(!1);s.useEffect(()=>{const e=()=>{R.current=!1,M.current=null,V(!1)};return document.addEventListener("mouseup",e),()=>document.removeEventListener("mouseup",e)},[]);const Je=s.useCallback((e,i)=>{const c=e.split(`
1
+ import{R as s,j as r}from"./vendor-react-BUCujlKS.js";import{l as et,u as ee,r as Ve,n as tt}from"./index-DRpChWux.js";import{c as rt,s as st,P as nt,C as it}from"./shikiHighlight-C7LTbwFx.js";import{f as ot,y as z,c0 as at,ak as lt,b as Ie,a4 as ct,a0 as ut,V as mt,aV as dt,L as pt,gm as ft,l as Fe,gn as ht,aa as Le,fI as gt,cR as Ae,eL as wt,eM as vt,m as St,go as xt,aU as $e,aX as te,aY as re,aR as ze,B as K,I,aZ as se,aT as We,aQ as J,g as yt,bU as bt,ac as jt,bQ as Ct}from"./useAppFontEffects-BikB6enL.js";import{u as Mt,n as Tt}from"./useInlineCommentController-CYPvYJDt.js";import{b as kt}from"./CodeMirrorCommentWidgets-4qZbrEXU.js";import{getResolvedShikiTheme as Nt}from"./appThemeRegistry-BK0dHKa6.js";import{E as Et}from"./vendor-codemirror-view-DSzLbZiS.js";import{R as Pt}from"./runtimeEndpointReset-BVmispdD.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-opencode-sdk-BJ73u-bH.js";import"./vendor-zustand-BAGL70zf.js";import"./vendor-codemirror-state-CNWM3Q8V.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-codemirror-commands-ARAOgp1x.js";import"./vendor-codemirror-language-DUOssd4j.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-lezer-highlight-CDMHUZ74.js";import"./vendor-style-mod-NZ5MEPvj.js";import"./vendor-codemirror-search-8kyQdB3f.js";import"./vendor-crelt-C8TCjufn.js";import"./vendor-replit-codemirror-vim-B0Ecqnlh.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-base-ui-D_V6hAcE.js";import"./vendor-floating-ui-utils-BzXdqYpP.js";import"./vendor-floating-ui-dom-WyXykhNi.js";import"./vendor-floating-ui-core-CXmKXOXc.js";import"./vendor-floating-ui-react-dom-DKpLs02S.js";import"./vendor-use-sync-external-store-D6wYuSt-.js";import"./contextPanelEmbeddedChat-B-bSg3P5.js";import"./vendor-class-variance-authority-5VPnzWs2.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-dnd-kit-core-BZknOX2w.js";import"./vendor-dnd-kit-utilities-B_MdXhJC.js";import"./vendor-dnd-kit-accessibility-BHxJPORy.js";import"./vendor-dnd-kit-sortable-CsEagZ81.js";import"./vendor-cmdk-DgLInKvT.js";import"./vendor-radix-ui-react-dialog-B94Bt2qq.js";import"./vendor-radix-ui-primitive-Dc_FVRD7.js";import"./vendor-radix-ui-react-compose-refs-DcAh5WdT.js";import"./vendor-radix-ui-react-context-Czxm7Z62.js";import"./vendor-radix-ui-react-id-f5BLKEVw.js";import"./vendor-radix-ui-react-use-layout-effect-D_3IhJdJ.js";import"./vendor-radix-ui-react-use-controllable-state-BFT5YmkA.js";import"./vendor-radix-ui-react-dismissable-layer-D7kXcwgJ.js";import"./vendor-radix-ui-react-primitive-DhVoX9SD.js";import"./vendor-radix-ui-react-slot-BQgQOasS.js";import"./vendor-radix-ui-react-use-callback-ref-BZPnuXAC.js";import"./vendor-radix-ui-react-use-escape-keydown-oph88g-F.js";import"./vendor-radix-ui-react-focus-scope-CiaxW4dD.js";import"./vendor-radix-ui-react-portal-BMJYHWck.js";import"./vendor-radix-ui-react-presence-CNxf-uq4.js";import"./vendor-radix-ui-react-focus-guards-B6qJXYua.js";import"./vendor-react-remove-scroll-DO7dCTnK.js";import"./vendor-tslib-De9GV7Vy.js";import"./vendor-react-remove-scroll-bar-BcFYyj3E.js";import"./vendor-react-style-singleton-q6EMHnwf.js";import"./vendor-get-nonce-C-Z93AgS.js";import"./vendor-use-sidecar-zDC0RhA3.js";import"./vendor-use-callback-ref-D3RC8gqK.js";import"./vendor-aria-hidden-DvXkyWUv.js";import"./vendor-codemirror-lang-javascript-Bbw3D7r0.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-codemirror-autocomplete-BjbBRsUA.js";import"./vendor-w3c-keyname-Vcq4gwWv.js";import"./vendor-codemirror-lang-json-ryCw7nab.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-VgNqFSH-.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-B3Qe3OpS.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-FGQydhTc.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-CLHw8NWn.js";import"./vendor-codemirror-lang-python-N414WYK-.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-tanstack-react-virtual-g05Cx3z9.js";import"./vendor-tanstack-virtual-core-Dubg10g5.js";import"./vendor-framer-motion-CRSgBxjL.js";import"./vendor-motion-dom-DJLgZh4Q.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./vendor-sonner-DFyL3AvE.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./registerCustomTheme-BBXUCRnG.js";import"./themeResolver-BmJyTmjJ.js";import"./vendor-pierre-theming-C6Z4M5_u.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";const x=u=>{if(!u)return"";const l=u.replace(/\\/g,"/");return l==="/"?"/":l.replace(/\/+$/,"")},ne=(u,l)=>{const t=x(u),p=l.replace(/\\/g,"/").replace(/^\/+/,"").replace(/\/+$/,"");return!t||t==="/"?`/${p}`:`${t}/${p}`},Dt=(u,l,t)=>ne(ne(ne(u,".opencode"),"plans"),`${l}-${t}.md`),Rt=(u,l)=>`~/.opencode/plans/${u}-${l}.md`,Vt=(u,l)=>{const t=u.trim();return t.startsWith("~")?t==="~"?l||t:(t.startsWith("~/")||t.startsWith("~\\"))&&l?`${l}${t.slice(1)}`:t:t},It=(u,l)=>{const t=x(l.currentDirectory),p=x(l.homeDirectory),h=x(u);return t&&h.startsWith(t+"/")?h.slice(t.length+1):p&&h===p?"~":p&&h.startsWith(p+"/")?`~${h.slice(p.length)}`:h},Ft=(u,l,t)=>{const p=x(u.trim());if(!p)return null;const h=t?l.find(g=>g.id===t)??null:null;if(h?.path){const g=x(h.path);if(p===g||p.startsWith(`${g}/`))return{id:h.id,path:h.path}}const E=l.filter(g=>{const k=x(g.path);return p===k||p.startsWith(`${k}/`)}).sort((g,k)=>x(k.path).length-x(g.path).length)[0];return E?{id:E.id,path:E.path}:null},Ds=({targetPath:u=null,onNavigatedToChat:l})=>{const{t}=ot(),p=z(e=>e.currentSessionId),h=z(e=>e.createSession),E=z(e=>e.initializeNewOpenChamberSession),g=z(e=>e.sendMessage),k=z(e=>e.setCurrentSession),ie=at(),F=et(e=>e.homeDirectory),oe=lt(e=>e.planModeEnabled),ae=Ie(e=>e.projects),le=Ie(e=>e.activeProjectId),ce=ct(e=>e.directories),ue=ut()??"",me=ee(e=>e.setActiveMainTab),de=ee(e=>e.setSessionSwitcherOpen),P=mt(),{isMobile:pe}=dt(),{currentTheme:W}=pt(),w=s.useMemo(()=>p?ie.find(e=>e.id===p)??null:null,[p,ie]),j=s.useMemo(()=>{const e=typeof w?.directory=="string"?w.directory:"";return x(e||"")},[w?.directory]),fe=s.useMemo(()=>x(ue||j),[ue,j]),y=s.useMemo(()=>Ft(fe,ae,le),[le,fe,ae]),O=s.useMemo(()=>y?ce.get(y.path)?.isGitRepo===!0:!1,[y,ce]),[N,D]=s.useState(null),[he,ge]=s.useState(!1),[m,C]=s.useState(null),Q=s.useMemo(()=>!m||!j||!F?m:It(m,{currentDirectory:j,homeDirectory:F}),[m,j,F]),[f,b]=s.useState(""),{isPlaying:_,play:Oe,stop:_e}=ft(),Be=Fe(e=>e.showMessageTTSButtons),[we,B]=s.useState(null),Y=s.useMemo(()=>Q&&Q.split("/").pop()||t("planView.file.defaultName"),[Q,t]),X=s.useMemo(()=>f.trim()&&ht(f).title||t("planView.title.default"),[f,t]),G=s.useMemo(()=>X.trim()||t("planView.title.default"),[X,t]),[Ge,L]=s.useState(!1),[Ue,ve]=s.useState(!1),[U,Se]=s.useState("edit"),A=s.useRef(null),[o,v]=s.useState(null),xe=s.useRef(null),He=s.useRef(null),ye="openchamber:plan:md-viewer-mode";s.useEffect(()=>{try{const e=localStorage.getItem(ye);if(!e)return;const i=JSON.parse(e);(i==="preview"||i==="edit")&&Se(i)}catch{}},[]);const Ke=s.useCallback(e=>{Se(e);try{localStorage.setItem(ye,JSON.stringify(e))}catch{}},[]),R=s.useRef(!1),M=s.useRef(null),[be,V]=s.useState(!1);s.useEffect(()=>{const e=()=>{R.current=!1,M.current=null,V(!1)};return document.addEventListener("mouseup",e),()=>document.removeEventListener("mouseup",e)},[]);const Je=s.useCallback((e,i)=>{const c=e.split(`
2
2
  `),n=Math.max(1,i.start),a=Math.min(c.length,i.end);return n>a?"":c.slice(n-1,a).join(`
3
3
  `)},[]),Qe=Mt({source:"plan",fileLabel:Y,language:m&&Le(m)||"markdown",getCodeForRange:e=>Je(f,Tt(e)),toStoreRange:e=>({startLine:e.start,endLine:e.end}),fromDraftRange:e=>({start:e.startLine,end:e.endLine})}),{drafts:je,commentText:H,setCommentText:Ce,editingDraftId:Z,setSelection:Me,saveComment:Te,cancel:$,reset:ke,startEdit:Ne,deleteDraft:Ee}=Qe;s.useEffect(()=>{v(null),ke()},[f,ke]),s.useEffect(()=>{Me(o)},[o,Me]);const Pe=s.useCallback(()=>{v(null),$()},[$]),De=s.useCallback((e,i)=>{i&&v(i),Te(e,i??o??void 0),v(null)},[o,Te]);s.useEffect(()=>{if(!o)return;const e=c=>{const n=c.target;n.closest('[data-comment-card="true"]')||n.closest('[data-comment-input="true"]')||n.closest(".oc-block-widget")||n.closest(".cm-gutterElement")||n.closest("[data-sonner-toast]")||n.closest("[data-sonner-toaster]")||H.trim()||(v(null),$())},i=window.setTimeout(()=>{document.addEventListener("click",e)},100);return()=>{window.clearTimeout(i),document.removeEventListener("click",e)}},[$,H,Z,pe,o]);const q=ee(e=>e.editorFontSize),Ye=s.useMemo(()=>{const e=m?Le(m):null,i=!!e&&e!=="markdown",c=[rt(W,i?{syntaxColors:!1,fontSize:q}:{fontSize:q})],n=gt(m||"plan.md");return n&&c.push(n),i&&e&&c.push(st({language:e,themeName:W.metadata.id,theme:Nt(W)})),c.push(Et.lineWrapping),c},[W,m,q]);s.useEffect(()=>{if(!oe&&!u){C(null),b(""),L(!1);return}let e=!1;const i=async n=>{if(P.files?.readFile)return(await P.files.readFile(n))?.content??"";const a=tt()?.files;if(a?.readFile)return(await a.readFile(n,{optional:!0}))?.content??"";const d=await Ve(`/api/fs/read?path=${encodeURIComponent(n)}&optional=true`,{cache:"no-store"});if(!d.ok)throw new Error(`Failed to read plan file (${d.status})`);return d.text()};return(async()=>{if(C(null),b(""),B(null),u){L(!0);try{const n=await i(u);if(e)return;C(u),b(n)}catch{if(e)return;C(null),b("")}finally{e||L(!1)}return}if(!w?.slug||!w?.time?.created||!j){C(null),b("");return}L(!0);try{const n=Dt(j,w.time.created,w.slug),a=Vt(Rt(w.time.created,w.slug),F||null);let d=null,S=null;try{S=await i(n),d=n}catch{}if(!d)try{S=await i(a),d=a}catch{}if(e)return;if(!d||S===null){C(null),b("");return}C(d),b(S)}catch{if(e)return;C(null),b("")}finally{e||L(!1)}})(),()=>{e=!0}},[F,oe,P.files,j,w?.slug,w?.time?.created,u]),s.useEffect(()=>{if(!m){B(null);return}const e=window.setTimeout(async()=>{B(null);try{if(P.files?.writeFile){if(!(await P.files.writeFile(m,f))?.success)throw new Error(t("planView.error.writeFailed"))}else{const i=await Ve("/api/fs/write",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:m,content:f})});if(!i.ok)throw new Error(t("planView.error.writePlanFileFailed",{status:i.status}))}}catch(i){B(i instanceof Error?i.message:t("planView.error.saveFailed"))}},350);return()=>{window.clearTimeout(e)}},[f,m,P.files,t]),s.useEffect(()=>()=>{A.current!==null&&window.clearTimeout(A.current)},[]);const Re=s.useCallback(()=>{me("chat"),de(!1),l?.()},[l,me,de]),Xe=s.useCallback(async e=>{if(!y||!N)return;const i=await Ae(N.action==="improve"?"plan.improve.visible":"plan.implement.visible",{plan_title:G}),n=[{synthetic:!0,text:await Ae(N.action==="improve"?"plan.improve.instructions":"plan.implement.instructions",{plan_title:G,plan_path:m??""})}];ge(!0);try{Re();let a=null,d=y.path;if(N.target==="worktree"){if(!O)return;const T=await wt(y.path,vt());if(!T?.id)return;a=T.id,d=T.path}else{const T=await h(void 0,y.path,null);if(!T?.id)return;a=T.id,d=T.directory??y.path,E(T.id,Fe.getState().agents??[])}if(!a)return;const S=St.getState();S.saveSessionModelSelection(a,e.providerID,e.modelID),e.agent.trim()&&(S.saveSessionAgentSelection(a,e.agent),S.saveAgentModelForSession(a,e.agent,e.providerID,e.modelID),S.saveAgentModelVariantForSession(a,e.agent,e.providerID,e.modelID,e.variant||void 0)),k(a,d);const qe=e.runAsGoal===!0?[`Implement the plan "${G}" end-to-end${m?` (plan file: ${m})`:""}.`,"Re-read that file for full details — it is the source of truth.","",f].join(`
4
4
  `):null;xt.getState().setArmed(e.runAsGoal===!0,qe),await g(i,e.providerID,e.modelID,e.agent.trim()||void 0,void 0,void 0,n,e.variant||void 0),D(null)}finally{ge(!1)}},[O,f,h,y,E,N,m,Re,g,G,k]),Ze=s.useMemo(()=>kt({drafts:je,editingDraftId:Z,commentText:H,onTextChange:Ce,selection:o,isDragging:be,fileLabel:Y,newWidgetId:"plan-new-comment-input",mapDraftToRange:e=>({start:e.startLine,end:e.endLine}),onSave:De,onCancel:Pe,onEdit:e=>{Ne(e),v({start:e.startLine,end:e.endLine})},onDelete:Ee}),[H,Ee,Z,Pe,De,be,o,je,Y,Ce,Ne]);return r.jsxs("div",{className:"relative flex h-full min-h-0 min-w-0 w-full flex-col overflow-hidden bg-background",children:[r.jsxs("div",{className:"flex min-w-0 items-center gap-2 border-b border-border/40 px-3 py-1.5 flex-shrink-0",children:[r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx("div",{className:"typography-ui-label font-medium truncate",children:X}),we?r.jsx("div",{className:"typography-micro text-[color:var(--status-error)] truncate",title:we,children:t("planView.error.saveFailed")}):null]}),m?r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsxs($e,{children:[r.jsxs(te,{children:[r.jsx(re,{asChild:!0,children:r.jsx(ze,{asChild:!0,children:r.jsx(K,{variant:"ghost",size:"sm",className:"h-5 w-5 p-0","aria-label":t("planView.actions.improvePlanAria"),disabled:!f.trim(),children:r.jsx(I,{name:"loop-right-ai",className:"size-4"})})})}),r.jsx(se,{sideOffset:8,children:t("planView.actions.improve")})]}),r.jsxs(We,{align:"end",children:[r.jsx(J,{onClick:()=>D({action:"improve",target:"session"}),children:t("planView.actions.sendToNewSession")}),r.jsx(J,{onClick:()=>D({action:"improve",target:"worktree"}),disabled:!O,children:t("planView.actions.sendToNewWorktreeSession")})]})]}),r.jsxs($e,{children:[r.jsxs(te,{children:[r.jsx(re,{asChild:!0,children:r.jsx(ze,{asChild:!0,children:r.jsx(K,{variant:"ghost",size:"sm",className:"h-5 w-5 p-0","aria-label":t("planView.actions.implementPlanAria"),disabled:!f.trim(),children:r.jsx(I,{name:"code-ai",className:"size-4"})})})}),r.jsx(se,{sideOffset:8,children:t("planView.actions.implement")})]}),r.jsxs(We,{align:"end",children:[r.jsx(J,{onClick:()=>D({action:"implement",target:"session"}),children:t("planView.actions.sendToNewSession")}),r.jsx(J,{onClick:()=>D({action:"implement",target:"worktree"}),disabled:!O,children:t("planView.actions.sendToNewWorktreeSession")})]})]}),r.jsx(nt,{currentMode:U,onToggle:()=>Ke(U==="preview"?"edit":"preview")}),U==="preview"&&Be&&r.jsxs(te,{children:[r.jsx(re,{asChild:!0,children:r.jsx(K,{variant:"ghost",size:"sm",className:"h-5 w-5 p-0","aria-label":t(_?"planView.tts.stopSpeaking":"planView.tts.readAloud"),onClick:()=>{_?_e():f.trim()&&Oe(f)},children:_?r.jsx(I,{name:"stop",className:"h-4 w-4 text-[color:var(--status-success)]"}):r.jsx(I,{name:"volume-up",className:"h-4 w-4"})})}),r.jsx(se,{sideOffset:8,children:t(_?"planView.tts.stopSpeaking":"planView.tts.readAloud")})]}),r.jsx(K,{variant:"ghost",size:"sm",onClick:async()=>{(await yt(f)).ok&&(ve(!0),A.current!==null&&window.clearTimeout(A.current),A.current=window.setTimeout(()=>{ve(!1)},1200))},className:"h-5 w-5 p-0",title:t("planView.actions.copyPlanContents"),"aria-label":t("planView.actions.copyPlanContents"),children:Ue?r.jsx(I,{name:"check",className:"h-4 w-4 text-[color:var(--status-success)]"}):r.jsx(I,{name:"clipboard",className:"h-4 w-4"})})]}):null]}),r.jsx(Pt,{open:N!==null,onOpenChange:e=>{!e&&!he&&D(null)},target:N?.target??"session",projectDirectory:y?.path??null,submitting:he,allowRunAsGoal:!0,onConfirm:Xe}),r.jsx("div",{className:"flex-1 min-h-0 min-w-0 relative",children:r.jsx(bt,{outerClassName:"h-full min-w-0",className:"h-full min-w-0",children:Ge?r.jsx("div",{className:"p-3 typography-ui text-muted-foreground",children:t("planView.state.loading")}):r.jsx("div",{className:"relative h-full",children:r.jsx("div",{className:"h-full",children:U==="preview"?r.jsx("div",{className:"h-full overflow-auto p-3",children:r.jsx(jt,{fallback:r.jsxs("div",{className:"rounded-md border border-destructive/20 bg-destructive/10 px-3 py-2",children:[r.jsx("div",{className:"mb-1 font-medium text-destructive",children:t("planView.error.previewUnavailable")}),r.jsx("div",{className:"text-sm text-muted-foreground",children:t("planView.error.switchToEditMode")})]}),children:r.jsx(Ct,{content:f,className:"typography-markdown-body",enableFileReferences:!1})})}):r.jsx("div",{className:"relative h-full",ref:He,children:r.jsx(it,{value:f,onChange:b,readOnly:!1,className:"h-full",extensions:Ye,onViewReady:e=>{xe.current=e},onViewDestroy:()=>{xe.current=null},blockWidgets:Ze,highlightLines:o?{start:Math.min(o.start,o.end),end:Math.max(o.start,o.end)}:void 0,lineNumbersConfig:{domEventHandlers:{mousedown:(e,i,c)=>{if(!(c instanceof MouseEvent)||c.button!==0)return!1;c.preventDefault();const n=e.state.doc.lineAt(i.from).number;if(o&&!c.shiftKey&&Math.min(o.start,o.end)===n&&Math.max(o.start,o.end)===n)return v(null),$(),R.current=!1,M.current=null,V(!1),!0;if(pe&&o&&!c.shiftKey){const a=Math.min(o.start,o.end,n),d=Math.max(o.start,o.end,n);return v({start:a,end:d}),R.current=!1,M.current=null,V(!1),!0}if(R.current=!0,M.current=n,V(!0),o&&c.shiftKey){const a=Math.min(o.start,n),d=Math.max(o.end,n);v({start:a,end:d})}else v({start:n,end:n});return!0},mouseover:(e,i,c)=>{if(!(c instanceof MouseEvent)||c.buttons!==1||!R.current||M.current===null)return!1;const n=e.state.doc.lineAt(i.from).number,a=Math.min(M.current,n),d=Math.max(M.current,n);return v({start:a,end:d}),V(!0),!1},mouseup:()=>(R.current=!1,M.current=null,V(!1),!1)}}})})})})})})]})};export{Ds as PlanView};