@openchamber/web 1.24.0 → 1.24.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (131) hide show
  1. package/bin/cli.test.js +7 -6
  2. package/bin/lib/cli-http.js +5 -1
  3. package/dist/assets/{CodeMirrorCommentWidgets-C9kV-n7r.js → CodeMirrorCommentWidgets-DvUH815P.js} +1 -1
  4. package/dist/assets/DiffView-DkC3xlRJ.js +4 -0
  5. package/dist/assets/{FilesView-vjJx7VaM.js → FilesView-D0bM9FVB.js} +6 -6
  6. package/dist/assets/GitView-Bxuv3dfP.js +6 -0
  7. package/dist/assets/GuestAttachDialog-B0u3Q5uO.js +1 -0
  8. package/dist/assets/{JsonTreeView-D_4G5X6-.js → JsonTreeView-BBVPFM5K.js} +1 -1
  9. package/dist/assets/{LinearIssuesView-1uKhePfH.js → LinearIssuesView-UI1FcSC8.js} +1 -1
  10. package/dist/assets/{MarkdownImageGallery-Ix7N_2wp.js → MarkdownImageGallery-CUJxH8Le.js} +1 -1
  11. package/dist/assets/{MarkdownRendererImpl-Deel_y5S.js → MarkdownRendererImpl-D5BZOg8X.js} +1 -1
  12. package/dist/assets/{OnboardingScreen-ToIakxb_.js → OnboardingScreen-5Gou9cGD.js} +1 -1
  13. package/dist/assets/{PatchDiff-BjMgezr1.js → PatchDiff-C4rE5k6z.js} +1 -1
  14. package/dist/assets/{PierreDiffViewer-53Ghfnlr.js → PierreDiffViewer-ByRVu6ss.js} +1 -1
  15. package/dist/assets/{PlanView-BGAzxDwD.js → PlanView-u2yi5XGJ.js} +4 -4
  16. package/dist/assets/PluginPane-QxjsKYeO.js +3 -0
  17. package/dist/assets/SettingsView-Fo5ZqMaT.js +29 -0
  18. package/dist/assets/SettingsWindow-HVDVANjJ.js +1 -0
  19. package/dist/assets/{SubmoduleDiffSummary--YFqK6Ih.js → SubmoduleDiffSummary-D3hzkybB.js} +1 -1
  20. package/dist/assets/{ToolOutputDialog-DRWBvdaJ.js → ToolOutputDialog-3J6IRayW.js} +6 -6
  21. package/dist/assets/{ToolPartDiffPreview-BxZJCU28.js → ToolPartDiffPreview-DarxPjSd.js} +1 -1
  22. package/dist/assets/{VirtualizedFileDiff-DCXjBGRf.js → VirtualizedFileDiff-CZgXWHjU.js} +4 -4
  23. package/dist/assets/{WalkthroughView-CfIPvWWa.js → WalkthroughView-wSpED5L4.js} +2 -2
  24. package/dist/assets/{appThemeRegistry-DDROzcUO.js → appThemeRegistry-Cf8KitzT.js} +1 -1
  25. package/dist/assets/commitAndPush-DZnzlhvc.js +1 -0
  26. package/dist/assets/{computeVirtualFileMetrics-DHgQIkUq.js → computeVirtualFileMetrics-VYnT_A2h.js} +1 -1
  27. package/dist/assets/{de-CX_f-T5U.js → de-BM_8EDD3.js} +4 -4
  28. package/dist/assets/{es-BERmWNn_.js → es-CxZjlqpo.js} +3 -3
  29. package/dist/assets/{fr-BjYYE_-z.js → fr-VCixCnMW.js} +4 -4
  30. package/dist/assets/{index-WjufPkIV.js → index-3U4CtS9b.js} +1 -1
  31. package/dist/assets/index-B9Hvzjwl.css +1 -0
  32. package/dist/assets/index-DLHQogv8.js +40 -0
  33. package/dist/assets/{isDiffPlainText-D9faP70y.js → isDiffPlainText-ImDG3Uhg.js} +1 -1
  34. package/dist/assets/{isFilePlainText-6qOcz5Ky.js → isFilePlainText-D_YDVYDb.js} +1 -1
  35. package/dist/assets/{ja-DxqeAk9N.js → ja-CZ5k_GyD.js} +4 -4
  36. package/dist/assets/{ko-Dty1aUod.js → ko-7YM3A1Xh.js} +4 -4
  37. package/dist/assets/{main-Bjcre_GE.js → main-CycplCph.js} +2 -2
  38. package/dist/assets/main-DFYTCx5o.js +896 -0
  39. package/dist/assets/markdownCore-DHvqMxPn.js +5 -0
  40. package/dist/assets/{miniChat-Dz_bPgMc.js → miniChat-DIQKfY2V.js} +2 -2
  41. package/dist/assets/{mobile-BbZPBJrK.js → mobile-BMwz5q-m.js} +2 -2
  42. package/dist/assets/{patchFileDiff-BvU6KOQC.js → patchFileDiff-DDQ6Rq5e.js} +3 -3
  43. package/dist/assets/{pl-CX-_ROkr.js → pl-BcgDO_w5.js} +4 -4
  44. package/dist/assets/{pt-BR-DhRR1arx.js → pt-BR-CU2u_1q5.js} +3 -3
  45. package/dist/assets/renderElectronMiniChatApp-3_d6g6CU.js +2 -0
  46. package/dist/assets/renderMobileApp-D0Y8DtkA.js +25 -0
  47. package/dist/assets/runtimeEndpointReset-DhC3REb2.js +25 -0
  48. package/dist/assets/{scheduledTasksApi-DW3xqMQ8.js → scheduledTasksApi-D8pq6gQz.js} +1 -1
  49. package/dist/assets/{shikiHighlight-DsxD9QEa.js → shikiHighlight-1imXsir9.js} +1 -1
  50. package/dist/assets/{textMateThemeFromAppTheme-Da7ed8qM.js → textMateThemeFromAppTheme-Dgqc63LZ.js} +1 -1
  51. package/dist/assets/tr-DuYhOzNe.js +7 -0
  52. package/dist/assets/{uk-CD21CXFV.js → uk-Cuk7-uvq.js} +3 -3
  53. package/dist/assets/{useAppFontEffects-hfv2s6mZ.js → useAppFontEffects-BItUWdo4.js} +147 -147
  54. package/dist/assets/{useInlineCommentController-BmtfVbo8.js → useInlineCommentController-CkbKsm7m.js} +2 -2
  55. package/dist/assets/useRootScrollLock-vmzxZjWA.js +2 -0
  56. package/dist/assets/{vendor-codemirror-language-data-BPMJpOpT.js → vendor-codemirror-language-data-BDyxuqK4.js} +2 -2
  57. package/dist/assets/{vendor-tanstack-react-virtual-g05Cx3z9.js → vendor-tanstack-react-virtual-ClYN8CzB.js} +1 -1
  58. package/dist/assets/{vendor-tanstack-virtual-core-Dubg10g5.js → vendor-tanstack-virtual-core-BewVQryB.js} +1 -1
  59. package/dist/assets/{web-components-U-hWbgJo.js → web-components-D7FinaeH.js} +1 -1
  60. package/dist/assets/{zh-CN-BWvlPHY-.js → zh-CN-CUWoiRHd.js} +3 -3
  61. package/dist/assets/{zh-TW-CRp5dJU2.js → zh-TW-CQ8EBSBN.js} +3 -3
  62. package/dist/index.html +3 -3
  63. package/dist/mini-chat.html +3 -3
  64. package/dist/mobile.html +3 -3
  65. package/package.json +4 -3
  66. package/server/index.js +26 -7
  67. package/server/lib/changelog/update-notes.js +2 -1
  68. package/server/lib/changelog/update-notes.test.js +19 -0
  69. package/server/lib/event-stream/DOCUMENTATION.md +23 -0
  70. package/server/lib/event-stream/delta-coalescer.js +0 -0
  71. package/server/lib/event-stream/delta-coalescer.test.js +292 -0
  72. package/server/lib/event-stream/global-hub.js +53 -23
  73. package/server/lib/event-stream/global-hub.test.js +160 -0
  74. package/server/lib/event-stream/global-ws-bridge.js +1 -0
  75. package/server/lib/event-stream/index.js +4 -0
  76. package/server/lib/git/DOCUMENTATION.md +17 -4
  77. package/server/lib/git/routes.js +1 -1
  78. package/server/lib/git/serial-refresh.js +93 -0
  79. package/server/lib/git/serial-refresh.test.js +112 -0
  80. package/server/lib/git/service.js +232 -62
  81. package/server/lib/git/service.test.js +273 -0
  82. package/server/lib/github/pr-status.js +5 -5
  83. package/server/lib/github/pr-status.test.js +1 -1
  84. package/server/lib/github/routes.js +4 -4
  85. package/server/lib/guests/DOCUMENTATION.md +5 -3
  86. package/server/lib/guests/background.test.js +83 -0
  87. package/server/lib/guests/catalog.js +20 -9
  88. package/server/lib/guests/catalog.test.js +5 -5
  89. package/server/lib/guests/routes.js +2 -2
  90. package/server/lib/message-queue/DOCUMENTATION.md +6 -0
  91. package/server/lib/message-queue/runtime.js +5 -0
  92. package/server/lib/message-queue/runtime.test.js +32 -1
  93. package/server/lib/opencode/feature-routes-runtime.js +5 -0
  94. package/server/lib/opencode/settings-helpers.js +3 -0
  95. package/server/lib/opencode/settings-registry.json +8 -0
  96. package/server/lib/permission-auto-accept/DOCUMENTATION.md +8 -0
  97. package/server/lib/permission-auto-accept/runtime.js +13 -0
  98. package/server/lib/permission-auto-accept/runtime.test.js +37 -1
  99. package/server/lib/routing/DOCUMENTATION.md +81 -0
  100. package/server/lib/routing/defaults.js +98 -0
  101. package/server/lib/routing/feature-flag.js +11 -0
  102. package/server/lib/routing/history.js +34 -0
  103. package/server/lib/routing/jev.js +98 -0
  104. package/server/lib/routing/routes.http.test.js +100 -0
  105. package/server/lib/routing/routes.js +81 -0
  106. package/server/lib/routing/runtime.js +217 -0
  107. package/server/lib/routing/runtime.test.js +188 -0
  108. package/server/lib/routing/store.js +249 -0
  109. package/server/lib/routing/store.test.js +96 -0
  110. package/server/lib/security/request-security.js +9 -5
  111. package/server/lib/security/request-security.test.js +37 -0
  112. package/server/lib/ui-auth/DOCUMENTATION.md +8 -0
  113. package/server/lib/ui-auth/session-cookie.js +51 -0
  114. package/server/lib/ui-auth/session-cookie.test.js +46 -0
  115. package/server/lib/ui-auth/ui-auth.js +13 -9
  116. package/server/lib/ui-auth/ui-auth.test.js +56 -0
  117. package/dist/assets/DiffView-B7YkbY-u.js +0 -4
  118. package/dist/assets/DirtyBranchSwitchDialog-CU0A93Zx.js +0 -1
  119. package/dist/assets/GitView-BLhlMYEY.js +0 -6
  120. package/dist/assets/GuestAttachDialog-B-fwE8r3.js +0 -3
  121. package/dist/assets/SettingsView-n2X-jfBB.js +0 -29
  122. package/dist/assets/SettingsWindow-Bi8LE9XI.js +0 -1
  123. package/dist/assets/index-DpzTz2UH.css +0 -1
  124. package/dist/assets/index-Dy8xgawx.js +0 -40
  125. package/dist/assets/main-BOYSXfYn.js +0 -896
  126. package/dist/assets/markdownCore-DPrwM1rU.js +0 -5
  127. package/dist/assets/renderElectronMiniChatApp-uNEUkeAI.js +0 -2
  128. package/dist/assets/renderMobileApp-BK1kFlcJ.js +0 -25
  129. package/dist/assets/runtimeEndpointReset-BULHvOwb.js +0 -25
  130. package/dist/assets/tr-cIQtYBpg.js +0 -7
  131. package/dist/assets/useRootScrollLock-Cwc4kSl2.js +0 -1
@@ -1 +1 @@
1
- import{R as r,j as s,f as tt}from"./vendor-react-BUCujlKS.js";import{f as bt,Z as vt,aE as xe,cw as jt,ca as It,t as b,kA as Nt,I as u,B as he,o as Ze,c4 as He,a5 as Ye,cf as Pt,cg as wt,ch as kt,ci as St,cj as Lt,cl as $e,h as K,W as Ct,au as Rt,aq as At,as as Ft,at as Et,ap as Tt}from"./useAppFontEffects-hfv2s6mZ.js";import{u as f,dQ as M}from"./index-Dy8xgawx.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-zod-fZppILAM.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-zustand-BAGL70zf.js";import"./vendor-base-ui-CsXYnR5c.js";import"./vendor-floating-ui-utils-D6FqdtJt.js";import"./vendor-floating-ui-react-dom-DxYCWdHj.js";import"./vendor-floating-ui-dom-BTvzWks8.js";import"./vendor-floating-ui-core-PuGzNPnN.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-framer-motion-Bq3iTZ6r.js";import"./vendor-motion-dom-DcCgeG69.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./vendor-tanstack-react-virtual-g05Cx3z9.js";import"./vendor-tanstack-virtual-core-Dubg10g5.js";import"./contextPanelEmbeddedChat-CirXEPJq.js";import"./vendor-sonner-DFyL3AvE.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-BgPj_McA.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-codemirror-state-C9awkmn-.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-codemirror-view-CiLROUVV.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-Cc2ZYbgX.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-codemirror-autocomplete-DzPz9Wgq.js";import"./vendor-codemirror-lang-json-CMBS2tG9.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-O0cZX78y.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-CfgK872x.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-BPGOH9ye.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-BPMJpOpT.js";import"./vendor-codemirror-lang-python-HahnQaAS.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-codemirror-commands-B7H_j0iU.js";import"./vendor-legendapp-list-BuBPBC3R.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./vendor-opencode-sdk-BJ73u-bH.js";const Je="[&_img]:max-w-full [&_img]:h-auto",st="flex h-8 min-w-0 flex-1 items-center gap-1.5 rounded-md px-2 typography-ui-label font-semibold text-foreground outline-none hover:bg-interactive-hover focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",Ae="flex h-8 w-8 shrink-0 items-center justify-center rounded-md text-foreground outline-none hover:bg-interactive-hover focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",Mt=520,Xe=t=>t.name?.trim()||t.urlKey?.trim()||t.id,Kt={0:"contextPanel.linear.priority.none",1:"contextPanel.linear.priority.urgent",2:"contextPanel.linear.priority.high",3:"contextPanel.linear.priority.medium",4:"contextPanel.linear.priority.low"},Dt={triage:0,backlog:1,unstarted:2,started:3,completed:4,canceled:5},et=t=>t==="triage"||t==="backlog"||t==="unstarted"||t==="started"||t==="completed"||t==="canceled"?Dt[t]:99,Ot=(t,n)=>{const o=et(t.type)-et(n.type);return o!==0?o:t.position!==n.position?t.position-n.position:t.name.localeCompare(n.name)},zt=t=>t!==0&&t!==1&&t!==2&&t!==3&&t!==4?null:Kt[t],ge=[{value:"all",labelKey:"contextPanel.linear.filter.status.all"},{value:"backlog",labelKey:"contextPanel.linear.filter.status.backlog"},{value:"todo",labelKey:"contextPanel.linear.filter.status.todo"},{value:"started",labelKey:"contextPanel.linear.filter.status.started"},{value:"inReview",labelKey:"contextPanel.linear.filter.status.inReview"},{value:"completed",labelKey:"contextPanel.linear.filter.status.completed"},{value:"canceled",labelKey:"contextPanel.linear.filter.status.canceled"},{value:"duplicate",labelKey:"contextPanel.linear.filter.status.duplicate"}],Ut=t=>ge.some(n=>n.value===t),ye=[{value:"all",labelKey:"contextPanel.linear.filter.priority.all"},{value:"urgent",labelKey:"contextPanel.linear.priority.urgent"},{value:"high",labelKey:"contextPanel.linear.priority.high"},{value:"medium",labelKey:"contextPanel.linear.priority.medium"},{value:"low",labelKey:"contextPanel.linear.priority.low"},{value:"none",labelKey:"contextPanel.linear.priority.none"}],_t=t=>ye.some(n=>n.value===t),Wt=t=>t?{color:t,backgroundColor:`color-mix(in srgb, ${t} 18%, transparent)`}:{backgroundColor:"color-mix(in srgb, var(--surface-muted-foreground) 12%, transparent)"},Vt=t=>{const n=tt.c(4),{labels:o}=t;if(o.length===0)return null;let c;n[0]!==o?(c=o.map(Qt),n[0]=o,n[1]=c):c=n[1];let y;return n[2]!==c?(y=s.jsx("div",{className:"flex min-w-0 flex-wrap items-center gap-1",children:c}),n[2]=c,n[3]=y):y=n[3],y},te=t=>{const n=tt.c(31),{icon:o,label:c,ariaLabel:y,value:W,items:V,disabled:v,compact:x,active:w,onValueChange:d}=t,[k,G]=r.useState(!1),q=v?!1:k;let F;n[0]!==v?(F=D=>{v||G(D)},n[0]=v,n[1]=F):F=n[1];const Z=w===!0,S=x?Ae:st,H=x?c:void 0,Y=w?"text-primary":"text-muted-foreground";let L;n[2]!==Y?(L=K("size-3.5 shrink-0",Y),n[2]=Y,n[3]=L):L=n[3];let C;n[4]!==o||n[5]!==L?(C=s.jsx(u,{name:o,className:L}),n[4]=o,n[5]=L,n[6]=C):C=n[6];let h;n[7]!==x||n[8]!==c?(h=x?null:s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"min-w-0 truncate",children:c}),s.jsx(u,{name:"arrow-down-s",className:"size-4 shrink-0 opacity-60"})]}),n[7]=x,n[8]=c,n[9]=h):h=n[9];let R;n[10]!==y||n[11]!==v||n[12]!==Z||n[13]!==S||n[14]!==H||n[15]!==C||n[16]!==h?(R=s.jsx(At,{asChild:!0,children:s.jsxs("button",{type:"button",disabled:v,"aria-pressed":Z,className:S,"aria-label":y,title:H,children:[C,h]})}),n[10]=y,n[11]=v,n[12]=Z,n[13]=S,n[14]=H,n[15]=C,n[16]=h,n[17]=R):R=n[17];let j;n[18]!==d?(j=D=>{d(D),G(!1)},n[18]=d,n[19]=j):j=n[19];let A;n[20]!==V?(A=V.map(Zt),n[20]=V,n[21]=A):A=n[21];let I;n[22]!==j||n[23]!==A||n[24]!==W?(I=s.jsx(Ft,{align:"start",className:"min-w-40",children:s.jsx(Et,{value:W,onValueChange:j,children:A})}),n[22]=j,n[23]=A,n[24]=W,n[25]=I):I=n[25];let N;return n[26]!==q||n[27]!==R||n[28]!==I||n[29]!==F?(N=s.jsxs(Tt,{open:q,onOpenChange:F,children:[R,I]}),n[26]=q,n[27]=R,n[28]=I,n[29]=F,n[30]=N):N=n[30],N},Gt=t=>{const n=t.trim();if(!n)return null;const o=n.match(/linear\.app\/(?:[^/]+\/)?issue\/([A-Za-z][A-Za-z0-9]*-\d+)/i);return o?o[1].toUpperCase():/^[A-Za-z][A-Za-z0-9]*-\d+$/.test(n)?n.toUpperCase():null},qt=t=>({id:t.id,identifier:t.identifier,title:t.title,url:t.url,state:t.state,assignee:t.assignee,team:t.team,priority:t.priority,labels:t.labels}),Bt=(t,n)=>{const o=qt(n);return t.map(c=>c.id===n.id?o:c)},Nn=()=>{const{t}=bt(),{linear:n}=vt(),o=xe(e=>e.status),c=xe(e=>e.hasChecked),y=xe(e=>e.refreshStatus),W=xe(e=>e.setStatus),V=f(e=>e.setSettingsDialogOpen),v=f(e=>e.setSettingsPage),x=f(e=>e.linearIssueListStatus),w=f(e=>e.linearIssueListAssignee),d=f(e=>e.linearIssueListTeamId),k=f(e=>e.linearIssueListPriority),G=f(e=>e.linearIssueFocus),q=f(e=>e.timeFormatPreference),F=f(e=>e.setLinearIssueListStatus),Z=f(e=>e.setLinearIssueListAssignee),S=f(e=>e.setLinearIssueListTeamId),H=f(e=>e.setLinearIssueListPriority),Y=f(e=>e.resetLinearIssueListFilters),L=f(e=>e.setLinearIssueFocus),C=f(e=>e.applyLinearIssueListFiltersForRuntime);r.useEffect(()=>{C()},[C]);const[h,R]=r.useState(""),[j,A]=r.useState(!1),[I,N]=r.useState([]),[D,se]=r.useState(null),[be,ne]=r.useState(!1),[O,z]=r.useState(!0),[ae,Fe]=r.useState(!1),[$,Ee]=r.useState(!1),[Te,re]=r.useState(null),[J,E]=r.useState(null),[l,X]=r.useState(null),[U,le]=r.useState([]),[nt,Me]=r.useState(!1),[B,Ke]=r.useState(!1),[ie,De]=r.useState(!1),[oe,ve]=r.useState(!1),[Q,ce]=r.useState([]),[ue,Oe]=r.useState(!1),P=r.useRef(0),je=r.useRef(null),ze=r.useRef(null),[Ue,at]=r.useState(0),de=r.useMemo(()=>Gt(h),[h]),Ie=jt(h,350),rt=r.useCallback(e=>{if(!e)return"";const a=Date.parse(e);return Number.isFinite(a)?It(a,q,{year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}):""},[q]),lt=r.useCallback(()=>{v("integrations"),V(!0)},[V,v]),me=r.useMemo(()=>({query:Ie.trim()||void 0,status:x,assignee:w,teamId:d===M?void 0:d,priority:k==="all"?void 0:k}),[Ie,w,k,x,d]),pe=o?.workspaces??[],_=pe.find(e=>e.current)?.id||o?.organization?.id||"",_e=r.useCallback(async()=>{if(c&&o?.connected===!1){z(!1),N([]),ne(!1),se(null),re(null);return}if(!n?.issuesList){z(!0),re(t("session.linearIssuePicker.error.runtimeUnavailable"));return}const e=P.current+1;P.current=e,Fe(!0),re(null);try{const a=await n.issuesList(me);if(e!==P.current)return;if(z(a.connected!==!1),a.connected===!1){N([]),ne(!1),se(null);return}N(a.issues??[]),se(a.cursor??null),ne(!!a.hasMore)}catch(a){if(e!==P.current)return;re(a instanceof Error?a.message:String(a))}finally{e===P.current&&Fe(!1)}},[n,c,o,me,t]);r.useEffect(()=>{n&&!c&&y(n)},[n,c,y]),r.useEffect(()=>{_e()},[_e]),r.useEffect(()=>{if(!n?.mappingGet||!O){ce([]);return}let e=!1;return n.mappingGet().then(a=>{if(!e){if(a.connected===!1){ce([]);return}ce(a.teams??[])}}).catch(()=>{e||ce([])}),()=>{e=!0}},[O,_,n]),r.useEffect(()=>{d===M||Q.length===0||Q.some(e=>e.id===d)||S(M)},[d,S,Q]);const it=r.useCallback(async()=>{if(!n?.issuesList||$||ae||!be||!D)return;const e=P.current+1;P.current=e,Ee(!0);try{const a=await n.issuesList({...me,cursor:D});if(e!==P.current||(z(a.connected!==!1),a.connected===!1))return;N(i=>[...i,...a.issues??[]]),se(a.cursor??null),ne(!!a.hasMore)}catch(a){if(e!==P.current)return;const i=a instanceof Error?a.message:String(a);b.error(t("session.linearIssuePicker.toast.loadMoreFailed"),{description:i})}finally{e===P.current&&Ee(!1)}},[D,be,ae,$,n,me,t]);r.useEffect(()=>{if(!J||!n?.issueGet)return;let e=!1;return Me(!0),X(null),le([]),(async()=>{try{const a=await n.issueGet(J);if(e)return;if(a.connected===!1){z(!1),E(null);return}const i=a.issue;if(!i){b.error(t("session.linearIssuePicker.error.issueNotFound")),E(null);return}X(i);const T=i.team?.id;if(!T||!n.issueStates)return;try{const g=await n.issueStates(T);if(e)return;if(g.connected===!1){z(!1);return}le(g.states??[])}catch(g){if(e)return;const fe=g instanceof Error?g.message:String(g);b.error(t("session.linearIssuePicker.toast.loadIssueDetailsFailed"),{description:fe})}}catch(a){if(e)return;const i=a instanceof Error?a.message:String(a);b.error(t("session.linearIssuePicker.toast.loadIssueDetailsFailed"),{description:i}),E(null)}finally{e||Me(!1)}})(),()=>{e=!0}},[n,J,t]),r.useEffect(()=>{G&&(E(G),L(null))},[G,L]);const We=r.useCallback(e=>{X(e),N(a=>Bt(a,e))},[]),Ne=r.useCallback(async(e,a)=>{if(!(!n?.issueUpdate||!l||B)&&l.state?.id!==e){Ke(!0);try{const i=await n.issueUpdate({id:l.id,stateId:e});if(i.connected===!1){z(!1),b.error(t(a));return}if(!i.issue){b.error(t(a));return}We(i.issue),b.success(t("contextPanel.linear.toast.statusUpdated"))}catch(i){const T=i instanceof Error?i.message:String(i);b.error(t(a),{description:T})}finally{Ke(!1)}}},[We,B,n,l,t]),ot=r.useCallback(()=>{const e=U.find(a=>a.type==="completed");if(!e){b.error(t("contextPanel.linear.error.noCompletedState"));return}Ne(e.id,"contextPanel.linear.toast.closeFailed")},[t,Ne,U]),ct=r.useCallback(async()=>{if(!(!l||ie)){De(!0);try{await Nt({linear:n,issueKey:l.id,createInWorktree:oe,t})}finally{De(!1)}}},[oe,ie,n,l,t]),ut=r.useCallback(async e=>{if(!(!n?.authActivate||!e||e===_||ue)){Oe(!0);try{const a=await n.authActivate(e);W(a),E(null),X(null),le([]),S(M),b.success(t("contextPanel.linear.toast.workspaceSwitched"))}catch(a){const i=a instanceof Error?a.message:String(a);b.error(t("contextPanel.linear.toast.workspaceSwitchFailed"),{description:i})}finally{Oe(!1)}}},[_,ue,n,W,S,t]),Pe=r.useMemo(()=>{const e=new Map(U.map(g=>[g.id,g])),a=l?.state?.id,i=l?.state?.name;return[...a&&i&&!e.has(a)?[{id:a,name:i,type:l.state?.type??null,position:0},...U]:U].sort(Ot)},[l,U]),dt=U.find(e=>e.type==="completed"),mt=l?.state?.type==="completed",Ve=c&&O===!1,pt=!n,Ge=!!J,qe=x==="all"&&w==="any"&&d===M&&k==="all",we=!!n&&O&&!Ve,ee=!we||ue,m=Ue>0&&Ue<Mt,ke=h.trim().length>0,ft=!qe||ke,Se=!m||j||ke,Le=r.useCallback(()=>{R(""),A(!1)},[]);r.useEffect(()=>{const e=je.current;if(!e||!globalThis.ResizeObserver)return;const a=new ResizeObserver(i=>{at(i[0]?.contentRect.width??0)});return a.observe(e),()=>a.disconnect()},[Ge]),r.useEffect(()=>{m&&j&&ze.current?.focus()},[m,j]);const xt=s.jsxs("div",{className:"flex items-center gap-2 cursor-pointer",role:"button",tabIndex:0,"aria-pressed":oe,onClick:()=>ve(e=>!e),onKeyDown:e=>{(e.key===" "||e.key==="Enter")&&(e.preventDefault(),ve(a=>!a))},children:[s.jsx("button",{type:"button",onClick:e=>{e.preventDefault(),e.stopPropagation(),ve(a=>!a)},"aria-label":t("session.linearIssuePicker.actions.toggleWorktreeAria"),className:"flex h-5 w-5 shrink-0 items-center justify-center rounded text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:oe?s.jsx(u,{name:"checkbox",className:"h-4 w-4 text-primary"}):s.jsx(u,{name:"checkbox-blank",className:"h-4 w-4"})}),s.jsx("span",{className:"typography-meta text-muted-foreground",children:t("session.linearIssuePicker.actions.createInWorktree")})]}),ht=e=>s.jsxs("div",{className:K("group flex items-center gap-2 py-1.5 px-1 rounded cursor-pointer hover:bg-interactive-hover/30 transition-colors",J===e.id&&"bg-interactive-selection/30"),onClick:()=>E(e.id),children:[s.jsx("span",{className:"typography-meta text-muted-foreground w-16 text-right flex-shrink-0",children:e.identifier}),s.jsx("p",{className:"flex-1 min-w-0 typography-small text-foreground truncate ml-0.5",children:e.title}),s.jsx("div",{className:"flex-shrink-0 h-5 flex items-center mr-1",children:s.jsx("button",{type:"button",className:"hidden group-hover:flex h-5 w-5 items-center justify-center text-muted-foreground hover:text-foreground transition-colors",onClick:a=>{a.stopPropagation(),Ze(e.url)},"aria-label":t("session.linearIssuePicker.actions.openInLinearAria"),children:s.jsx(u,{name:"external-link",className:"h-4 w-4"})})})]},e.id);if(Ge){const e=l?.assignee?.displayName||l?.assignee?.name,a=l?.comments??[],i=l?.description?.trim()||"",T=l?.state?.id||"",g=zt(l?.priority),fe=l?.labels??[];return s.jsxs("div",{ref:je,className:"flex h-full min-h-0 flex-col",children:[s.jsxs("div",{className:"flex items-center gap-2 border-b border-border px-3 py-2",children:[s.jsxs(he,{type:"button",variant:"ghost",size:"sm",className:"h-7 px-2",onClick:()=>{E(null),X(null),le([])},"aria-label":t("contextPanel.linear.actions.backToList"),children:[s.jsx(u,{name:"arrow-left-s",className:"h-4 w-4"}),t("contextPanel.linear.actions.backToList")]}),l?s.jsx("button",{type:"button",className:"ml-auto flex h-7 w-7 items-center justify-center text-muted-foreground hover:text-foreground",onClick:()=>{Ze(l.url)},"aria-label":t("session.linearIssuePicker.actions.openInLinearAria"),children:s.jsx(u,{name:"external-link",className:"h-4 w-4"})}):null]}),s.jsxs(He,{as:Ye,outerClassName:"h-full min-h-0 flex-1",className:"px-4 py-3",disableHorizontal:!0,preventOverscroll:!0,children:[nt&&!l?s.jsxs("div",{className:"flex items-center justify-center gap-2 py-8 text-muted-foreground",children:[s.jsx(u,{name:"loader-4",className:"h-4 w-4 animate-spin"}),t("contextPanel.linear.loading.issue")]}):null,l?s.jsx(r.Suspense,{fallback:s.jsxs("div",{className:"flex items-center justify-center gap-2 py-8 text-muted-foreground",children:[s.jsx(u,{name:"loader-4",className:"h-4 w-4 animate-spin"}),t("contextPanel.linear.loading.issue")]}),children:s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("div",{className:"typography-meta text-muted-foreground",children:l.identifier}),s.jsx("h2",{className:"typography-ui-header text-foreground mt-0.5",children:l.title})]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[Pe.length>0&&T?s.jsxs(Pt,{value:T,onValueChange:p=>{Ne(p,"contextPanel.linear.toast.statusUpdateFailed")},disabled:B,children:[s.jsx(wt,{size:"sm",className:"h-7 w-auto min-w-0","aria-label":t("contextPanel.linear.label.statusAria"),children:s.jsx(kt,{placeholder:t("contextPanel.linear.label.status"),children:p=>Pe.find(Ce=>Ce.id===p)?.name??p})}),s.jsx(St,{children:Pe.map(p=>s.jsx(Lt,{value:p.id,children:p.name},p.id))})]}):l.state?.name?s.jsx("span",{className:"typography-meta text-muted-foreground",children:l.state.name}):null,dt&&!mt?s.jsxs(he,{type:"button",variant:"outline",size:"sm",className:"h-7",onClick:ot,disabled:B,children:[B?s.jsx(u,{name:"loader-4",className:"h-4 w-4 animate-spin"}):null,t("contextPanel.linear.actions.closeIssue")]}):null]}),s.jsxs("dl",{className:"grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 typography-meta",children:[l.team?.name?s.jsxs(s.Fragment,{children:[s.jsx("dt",{className:"text-muted-foreground",children:t("contextPanel.linear.label.team")}),s.jsx("dd",{className:"text-foreground min-w-0 truncate",children:l.team.name})]}):null,s.jsx("dt",{className:"text-muted-foreground",children:t("contextPanel.linear.label.assignee")}),s.jsx("dd",{className:"text-foreground min-w-0 truncate",children:e||t("contextPanel.linear.label.unassigned")}),g?s.jsxs(s.Fragment,{children:[s.jsx("dt",{className:"text-muted-foreground",children:t("contextPanel.linear.label.priority")}),s.jsx("dd",{className:"text-foreground min-w-0 truncate",children:t(g)})]}):null,fe.length>0?s.jsxs(s.Fragment,{children:[s.jsx("dt",{className:"text-muted-foreground",children:t("contextPanel.linear.label.labels")}),s.jsx("dd",{className:"min-w-0",children:s.jsx(Vt,{labels:fe})})]}):null]}),s.jsx("div",{children:i?s.jsx($e,{content:i,className:Je,enableFileReferences:!1}):s.jsx("p",{className:"typography-meta text-muted-foreground",children:t("contextPanel.linear.empty.noDescription")})}),s.jsxs("div",{children:[s.jsx("h3",{className:"typography-ui-label text-foreground mb-2",children:t("contextPanel.linear.label.comments")}),a.length===0?s.jsx("p",{className:"typography-meta text-muted-foreground",children:t("contextPanel.linear.empty.noComments")}):s.jsx("div",{className:"relative pl-3",children:a.map((p,Ce)=>{const Re=p.user?.displayName||p.user?.name||t("contextPanel.linear.label.unassigned"),Be=p.user?.avatarUrl||null,gt=Re.charAt(0).toUpperCase(),yt=Ce===a.length-1,Qe=rt(p.createdAt);return s.jsxs("div",{className:"relative pl-10 pb-5 last:pb-0",children:[yt?null:s.jsx("div",{className:"absolute left-4 top-[2.375rem] bottom-[0.375rem] w-px bg-border/60"}),s.jsx("div",{className:"absolute left-0 top-0 z-10 flex size-8 items-center justify-center overflow-hidden rounded-full border border-border/60 bg-surface-elevated text-xs text-muted-foreground",children:Be?s.jsx("img",{src:Be,alt:Re,className:"h-full w-full object-cover",loading:"lazy",referrerPolicy:"no-referrer"}):s.jsx("span",{children:gt})}),s.jsxs("div",{className:"rounded-lg bg-surface-elevated px-3 pt-0 pb-3 space-y-2",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 typography-micro text-muted-foreground",children:[s.jsx("span",{className:"text-foreground whitespace-nowrap",children:Re}),Qe?s.jsx("span",{className:"whitespace-nowrap",children:Qe}):null]}),p.body.trim()?s.jsx($e,{content:p.body,className:K("typography-markdown-body text-foreground break-words",Je),enableFileReferences:!1}):null]})]},p.id)})})]})]})}):null]}),l?s.jsxs("div",{className:"shrink-0 border-t border-border px-4 py-3 flex flex-col gap-3",children:[xt,s.jsxs(he,{type:"button",onClick:()=>{ct()},disabled:ie||B,className:"w-full",children:[ie?s.jsx(u,{name:"loader-4",className:"h-4 w-4 animate-spin"}):null,t("contextPanel.linear.actions.startSession")]})]}):null]})}return s.jsxs("div",{ref:je,className:"flex h-full min-h-0 flex-col",children:[s.jsxs("div",{className:"px-3 pt-3 space-y-2",children:[Se?s.jsxs("div",{className:"relative",children:[s.jsx(u,{name:"search",className:K("absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4",ke?"text-primary":"text-muted-foreground")}),s.jsx(Ct,{ref:ze,placeholder:t("session.linearIssuePicker.searchPlaceholder"),value:h,onChange:e=>R(e.target.value),onKeyDown:e=>{e.key==="Escape"&&m&&(e.preventDefault(),Le())},className:K("pl-9 w-full",m&&"pr-9")}),m?s.jsx("button",{type:"button",className:"absolute right-1.5 top-1/2 flex h-7 w-7 -translate-y-1/2 items-center justify-center rounded-md text-muted-foreground outline-none hover:bg-interactive-hover hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring","aria-label":t("contextPanel.linear.actions.closeSearch"),title:t("contextPanel.linear.actions.closeSearch"),onClick:Le,children:s.jsx(u,{name:"close",className:"size-3.5"})}):null]}):null,we||m&&!Se?s.jsxs("div",{className:K("flex min-w-0 items-center",m&&"gap-0.5"),children:[we?s.jsxs(s.Fragment,{children:[s.jsx(te,{icon:"task",label:t((ge.find(e=>e.value===x)??ge[0]).labelKey),ariaLabel:t("contextPanel.linear.filter.statusAria"),value:x,active:x!=="all",disabled:ee,items:ge.map(e=>({value:e.value,label:t(e.labelKey)})),onValueChange:e=>{Ut(e)&&F(e)}}),s.jsx(te,{icon:"error-warning",compact:m,label:t((ye.find(e=>e.value===k)??ye[0]).labelKey),ariaLabel:t("contextPanel.linear.filter.priorityAria"),value:k,active:k!=="all",disabled:ee,items:ye.map(e=>({value:e.value,label:t(e.labelKey)})),onValueChange:e=>{_t(e)&&H(e)}}),s.jsx(te,{icon:"user-3",compact:m,label:t(w==="me"?"contextPanel.linear.filter.assignee.me":"contextPanel.linear.filter.assignee.any"),ariaLabel:t("contextPanel.linear.filter.assigneeAria"),value:w,active:w!=="any",disabled:ee,items:[{value:"any",label:t("contextPanel.linear.filter.assignee.any")},{value:"me",label:t("contextPanel.linear.filter.assignee.me")}],onValueChange:e=>{(e==="any"||e==="me")&&Z(e)}}),Q.length>0?s.jsx(te,{icon:"team",compact:m,label:d===M?t("contextPanel.linear.filter.team.all"):Q.find(e=>e.id===d)?.name??d,ariaLabel:t("contextPanel.linear.filter.teamAria"),value:d,active:d!==M,disabled:ee,items:[{value:M,label:t("contextPanel.linear.filter.team.all")},...Q.map(e=>({value:e.id,label:e.name}))],onValueChange:S}):null,pe.length>1&&_?s.jsx(te,{icon:"briefcase",compact:m,label:Xe(pe.find(e=>e.id===_)??{id:_,name:null,urlKey:null}),ariaLabel:t("contextPanel.linear.label.workspaceAria"),value:_,disabled:ue,items:pe.map(e=>({value:e.id,label:Xe(e)})),onValueChange:e=>{ut(e)}}):null,ft?s.jsxs("button",{type:"button",className:K(m?Ae:st,!m&&"flex-none"),"aria-label":t("contextPanel.linear.filter.clearAria"),title:t("contextPanel.linear.filter.clearAria"),disabled:ee,onClick:()=>{Y(),Le()},children:[s.jsx(u,{name:"close",className:"size-3.5 shrink-0 text-muted-foreground"}),m?null:s.jsx("span",{className:"min-w-0 truncate",children:t("contextPanel.linear.filter.clear")})]}):null]}):null,m&&!Se?s.jsx("button",{type:"button",className:Ae,"aria-label":t("contextPanel.linear.filter.searchAria"),title:t("contextPanel.linear.filter.searchAria"),onClick:()=>A(!0),children:s.jsx(u,{name:"search",className:"size-3.5 shrink-0 text-muted-foreground"})}):null]}):null]}),s.jsxs(He,{as:Ye,outerClassName:"h-full min-h-0 flex-1",className:"px-3 py-2",disableHorizontal:!0,preventOverscroll:!0,children:[pt?s.jsx("div",{className:"text-center text-muted-foreground py-8",children:t("session.linearIssuePicker.empty.runtimeUnavailable")}):null,ae&&I.length===0?s.jsxs("div",{className:"text-center text-muted-foreground py-8 flex items-center justify-center gap-2",children:[s.jsx(u,{name:"loader-4",className:"h-4 w-4 animate-spin"}),t("session.linearIssuePicker.loading.issues")]}):null,Ve?s.jsxs("div",{className:"text-center text-muted-foreground py-8 space-y-3",children:[s.jsx("div",{children:t("session.linearIssuePicker.empty.notConnected")}),s.jsx("div",{className:"flex justify-center",children:s.jsx(he,{variant:"outline",size:"sm",onClick:lt,children:t("session.linearIssuePicker.actions.openSettings")})})]}):null,Te?s.jsx("div",{className:"text-center text-muted-foreground py-8 break-words",children:Te}):null,de&&n&&O?s.jsxs("div",{className:"group flex items-center gap-2 py-1.5 px-1 hover:bg-interactive-hover/30 rounded transition-colors cursor-pointer",onClick:()=>E(de),children:[s.jsx("span",{className:"typography-meta text-muted-foreground w-16 text-right flex-shrink-0",children:de}),s.jsx("p",{className:"flex-1 min-w-0 typography-small text-foreground truncate ml-0.5",children:t("session.linearIssuePicker.actions.useIssue",{identifier:de})})]}):null,I.length===0&&!ae&&O&&n?s.jsx("div",{className:"text-center text-muted-foreground py-8",children:Ie.trim()?t("session.linearIssuePicker.empty.noIssuesFound"):t(qe?"session.linearIssuePicker.empty.noOpenIssuesFound":"contextPanel.linear.empty.noMatchingIssues")}):null,I.map(ht),be&&O&&n?s.jsx("div",{className:"py-2 flex justify-center",children:s.jsx("button",{type:"button",onClick:()=>{it()},disabled:$,className:K("typography-meta text-muted-foreground hover:text-foreground transition-colors underline underline-offset-4",$&&"opacity-50 cursor-not-allowed hover:text-muted-foreground"),children:$?s.jsxs("span",{className:"inline-flex items-center gap-2",children:[s.jsx(u,{name:"loader-4",className:"h-4 w-4 animate-spin"}),t("session.linearIssuePicker.loading.more")]}):t("session.linearIssuePicker.actions.loadMore")})}):null]})]})};function Qt(t){return s.jsx("span",{className:"inline-flex h-5 max-w-[8rem] items-center truncate rounded-md px-1.5 typography-meta text-muted-foreground",style:Wt(t.color),children:t.name},t.id)}function Zt(t){return s.jsx(Rt,{value:t.value,children:t.label},t.value)}export{Nn as LinearIssuesView};
1
+ import{R as r,j as s,f as tt}from"./vendor-react-BUCujlKS.js";import{f as yt,Z as vt,aE as xe,cx as jt,cb as It,t as y,kI as Nt,I as u,B as he,o as Ze,c5 as He,a5 as Ye,cg as Pt,ch as wt,ci as kt,cj as St,ck as Lt,cm as $e,h as K,W as Ct,au as Rt,aq as At,as as Ft,at as Et,ap as Tt}from"./useAppFontEffects-BItUWdo4.js";import{u as f,dQ as M}from"./index-DLHQogv8.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-zod-fZppILAM.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-zustand-BAGL70zf.js";import"./vendor-base-ui-CsXYnR5c.js";import"./vendor-floating-ui-utils-D6FqdtJt.js";import"./vendor-floating-ui-react-dom-DxYCWdHj.js";import"./vendor-floating-ui-dom-BTvzWks8.js";import"./vendor-floating-ui-core-PuGzNPnN.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-framer-motion-Bq3iTZ6r.js";import"./vendor-motion-dom-DcCgeG69.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./vendor-tanstack-react-virtual-ClYN8CzB.js";import"./vendor-tanstack-virtual-core-BewVQryB.js";import"./contextPanelEmbeddedChat-CirXEPJq.js";import"./vendor-sonner-DFyL3AvE.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-BgPj_McA.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-codemirror-state-C9awkmn-.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-codemirror-view-CiLROUVV.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-Cc2ZYbgX.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-codemirror-autocomplete-DzPz9Wgq.js";import"./vendor-codemirror-lang-json-CMBS2tG9.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-O0cZX78y.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-CfgK872x.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-BPGOH9ye.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-BDyxuqK4.js";import"./vendor-codemirror-lang-python-HahnQaAS.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-codemirror-commands-B7H_j0iU.js";import"./vendor-legendapp-list-BuBPBC3R.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./vendor-opencode-sdk-BJ73u-bH.js";const Je="[&_img]:max-w-full [&_img]:h-auto",st="flex h-8 min-w-0 flex-1 items-center gap-1.5 rounded-md px-2 typography-ui-label font-semibold text-foreground outline-none hover:bg-interactive-hover focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",Ae="flex h-8 w-8 shrink-0 items-center justify-center rounded-md text-foreground outline-none hover:bg-interactive-hover focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",Mt=520,Xe=t=>t.name?.trim()||t.urlKey?.trim()||t.id,Kt={0:"contextPanel.linear.priority.none",1:"contextPanel.linear.priority.urgent",2:"contextPanel.linear.priority.high",3:"contextPanel.linear.priority.medium",4:"contextPanel.linear.priority.low"},Dt={triage:0,backlog:1,unstarted:2,started:3,completed:4,canceled:5},et=t=>t==="triage"||t==="backlog"||t==="unstarted"||t==="started"||t==="completed"||t==="canceled"?Dt[t]:99,Ot=(t,n)=>{const o=et(t.type)-et(n.type);return o!==0?o:t.position!==n.position?t.position-n.position:t.name.localeCompare(n.name)},zt=t=>t!==0&&t!==1&&t!==2&&t!==3&&t!==4?null:Kt[t],ge=[{value:"all",labelKey:"contextPanel.linear.filter.status.all"},{value:"backlog",labelKey:"contextPanel.linear.filter.status.backlog"},{value:"todo",labelKey:"contextPanel.linear.filter.status.todo"},{value:"started",labelKey:"contextPanel.linear.filter.status.started"},{value:"inReview",labelKey:"contextPanel.linear.filter.status.inReview"},{value:"completed",labelKey:"contextPanel.linear.filter.status.completed"},{value:"canceled",labelKey:"contextPanel.linear.filter.status.canceled"},{value:"duplicate",labelKey:"contextPanel.linear.filter.status.duplicate"}],Ut=t=>ge.some(n=>n.value===t),be=[{value:"all",labelKey:"contextPanel.linear.filter.priority.all"},{value:"urgent",labelKey:"contextPanel.linear.priority.urgent"},{value:"high",labelKey:"contextPanel.linear.priority.high"},{value:"medium",labelKey:"contextPanel.linear.priority.medium"},{value:"low",labelKey:"contextPanel.linear.priority.low"},{value:"none",labelKey:"contextPanel.linear.priority.none"}],_t=t=>be.some(n=>n.value===t),Wt=t=>t?{color:t,backgroundColor:`color-mix(in srgb, ${t} 18%, transparent)`}:{backgroundColor:"color-mix(in srgb, var(--surface-muted-foreground) 12%, transparent)"},Vt=t=>{const n=tt.c(4),{labels:o}=t;if(o.length===0)return null;let c;n[0]!==o?(c=o.map(Qt),n[0]=o,n[1]=c):c=n[1];let b;return n[2]!==c?(b=s.jsx("div",{className:"flex min-w-0 flex-wrap items-center gap-1",children:c}),n[2]=c,n[3]=b):b=n[3],b},te=t=>{const n=tt.c(31),{icon:o,label:c,ariaLabel:b,value:W,items:V,disabled:v,compact:x,active:w,onValueChange:d}=t,[k,G]=r.useState(!1),q=v?!1:k;let F;n[0]!==v?(F=D=>{v||G(D)},n[0]=v,n[1]=F):F=n[1];const Z=w===!0,S=x?Ae:st,H=x?c:void 0,Y=w?"text-primary":"text-muted-foreground";let L;n[2]!==Y?(L=K("size-3.5 shrink-0",Y),n[2]=Y,n[3]=L):L=n[3];let C;n[4]!==o||n[5]!==L?(C=s.jsx(u,{name:o,className:L}),n[4]=o,n[5]=L,n[6]=C):C=n[6];let h;n[7]!==x||n[8]!==c?(h=x?null:s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"min-w-0 truncate",children:c}),s.jsx(u,{name:"arrow-down-s",className:"size-4 shrink-0 opacity-60"})]}),n[7]=x,n[8]=c,n[9]=h):h=n[9];let R;n[10]!==b||n[11]!==v||n[12]!==Z||n[13]!==S||n[14]!==H||n[15]!==C||n[16]!==h?(R=s.jsx(At,{asChild:!0,children:s.jsxs("button",{type:"button",disabled:v,"aria-pressed":Z,className:S,"aria-label":b,title:H,children:[C,h]})}),n[10]=b,n[11]=v,n[12]=Z,n[13]=S,n[14]=H,n[15]=C,n[16]=h,n[17]=R):R=n[17];let j;n[18]!==d?(j=D=>{d(D),G(!1)},n[18]=d,n[19]=j):j=n[19];let A;n[20]!==V?(A=V.map(Zt),n[20]=V,n[21]=A):A=n[21];let I;n[22]!==j||n[23]!==A||n[24]!==W?(I=s.jsx(Ft,{align:"start",className:"min-w-40",children:s.jsx(Et,{value:W,onValueChange:j,children:A})}),n[22]=j,n[23]=A,n[24]=W,n[25]=I):I=n[25];let N;return n[26]!==q||n[27]!==R||n[28]!==I||n[29]!==F?(N=s.jsxs(Tt,{open:q,onOpenChange:F,children:[R,I]}),n[26]=q,n[27]=R,n[28]=I,n[29]=F,n[30]=N):N=n[30],N},Gt=t=>{const n=t.trim();if(!n)return null;const o=n.match(/linear\.app\/(?:[^/]+\/)?issue\/([A-Za-z][A-Za-z0-9]*-\d+)/i);return o?o[1].toUpperCase():/^[A-Za-z][A-Za-z0-9]*-\d+$/.test(n)?n.toUpperCase():null},qt=t=>({id:t.id,identifier:t.identifier,title:t.title,url:t.url,state:t.state,assignee:t.assignee,team:t.team,priority:t.priority,labels:t.labels}),Bt=(t,n)=>{const o=qt(n);return t.map(c=>c.id===n.id?o:c)},Nn=()=>{const{t}=yt(),{linear:n}=vt(),o=xe(e=>e.status),c=xe(e=>e.hasChecked),b=xe(e=>e.refreshStatus),W=xe(e=>e.setStatus),V=f(e=>e.setSettingsDialogOpen),v=f(e=>e.setSettingsPage),x=f(e=>e.linearIssueListStatus),w=f(e=>e.linearIssueListAssignee),d=f(e=>e.linearIssueListTeamId),k=f(e=>e.linearIssueListPriority),G=f(e=>e.linearIssueFocus),q=f(e=>e.timeFormatPreference),F=f(e=>e.setLinearIssueListStatus),Z=f(e=>e.setLinearIssueListAssignee),S=f(e=>e.setLinearIssueListTeamId),H=f(e=>e.setLinearIssueListPriority),Y=f(e=>e.resetLinearIssueListFilters),L=f(e=>e.setLinearIssueFocus),C=f(e=>e.applyLinearIssueListFiltersForRuntime);r.useEffect(()=>{C()},[C]);const[h,R]=r.useState(""),[j,A]=r.useState(!1),[I,N]=r.useState([]),[D,se]=r.useState(null),[ye,ne]=r.useState(!1),[O,z]=r.useState(!0),[ae,Fe]=r.useState(!1),[$,Ee]=r.useState(!1),[Te,re]=r.useState(null),[J,E]=r.useState(null),[l,X]=r.useState(null),[U,le]=r.useState([]),[nt,Me]=r.useState(!1),[B,Ke]=r.useState(!1),[ie,De]=r.useState(!1),[oe,ve]=r.useState(!1),[Q,ce]=r.useState([]),[ue,Oe]=r.useState(!1),P=r.useRef(0),je=r.useRef(null),ze=r.useRef(null),[Ue,at]=r.useState(0),de=r.useMemo(()=>Gt(h),[h]),Ie=jt(h,350),rt=r.useCallback(e=>{if(!e)return"";const a=Date.parse(e);return Number.isFinite(a)?It(a,q,{year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}):""},[q]),lt=r.useCallback(()=>{v("integrations"),V(!0)},[V,v]),me=r.useMemo(()=>({query:Ie.trim()||void 0,status:x,assignee:w,teamId:d===M?void 0:d,priority:k==="all"?void 0:k}),[Ie,w,k,x,d]),pe=o?.workspaces??[],_=pe.find(e=>e.current)?.id||o?.organization?.id||"",_e=r.useCallback(async()=>{if(c&&o?.connected===!1){z(!1),N([]),ne(!1),se(null),re(null);return}if(!n?.issuesList){z(!0),re(t("session.linearIssuePicker.error.runtimeUnavailable"));return}const e=P.current+1;P.current=e,Fe(!0),re(null);try{const a=await n.issuesList(me);if(e!==P.current)return;if(z(a.connected!==!1),a.connected===!1){N([]),ne(!1),se(null);return}N(a.issues??[]),se(a.cursor??null),ne(!!a.hasMore)}catch(a){if(e!==P.current)return;re(a instanceof Error?a.message:String(a))}finally{e===P.current&&Fe(!1)}},[n,c,o,me,t]);r.useEffect(()=>{n&&!c&&b(n)},[n,c,b]),r.useEffect(()=>{_e()},[_e]),r.useEffect(()=>{if(!n?.mappingGet||!O){ce([]);return}let e=!1;return n.mappingGet().then(a=>{if(!e){if(a.connected===!1){ce([]);return}ce(a.teams??[])}}).catch(()=>{e||ce([])}),()=>{e=!0}},[O,_,n]),r.useEffect(()=>{d===M||Q.length===0||Q.some(e=>e.id===d)||S(M)},[d,S,Q]);const it=r.useCallback(async()=>{if(!n?.issuesList||$||ae||!ye||!D)return;const e=P.current+1;P.current=e,Ee(!0);try{const a=await n.issuesList({...me,cursor:D});if(e!==P.current||(z(a.connected!==!1),a.connected===!1))return;N(i=>[...i,...a.issues??[]]),se(a.cursor??null),ne(!!a.hasMore)}catch(a){if(e!==P.current)return;const i=a instanceof Error?a.message:String(a);y.error(t("session.linearIssuePicker.toast.loadMoreFailed"),{description:i})}finally{e===P.current&&Ee(!1)}},[D,ye,ae,$,n,me,t]);r.useEffect(()=>{if(!J||!n?.issueGet)return;let e=!1;return Me(!0),X(null),le([]),(async()=>{try{const a=await n.issueGet(J);if(e)return;if(a.connected===!1){z(!1),E(null);return}const i=a.issue;if(!i){y.error(t("session.linearIssuePicker.error.issueNotFound")),E(null);return}X(i);const T=i.team?.id;if(!T||!n.issueStates)return;try{const g=await n.issueStates(T);if(e)return;if(g.connected===!1){z(!1);return}le(g.states??[])}catch(g){if(e)return;const fe=g instanceof Error?g.message:String(g);y.error(t("session.linearIssuePicker.toast.loadIssueDetailsFailed"),{description:fe})}}catch(a){if(e)return;const i=a instanceof Error?a.message:String(a);y.error(t("session.linearIssuePicker.toast.loadIssueDetailsFailed"),{description:i}),E(null)}finally{e||Me(!1)}})(),()=>{e=!0}},[n,J,t]),r.useEffect(()=>{G&&(E(G),L(null))},[G,L]);const We=r.useCallback(e=>{X(e),N(a=>Bt(a,e))},[]),Ne=r.useCallback(async(e,a)=>{if(!(!n?.issueUpdate||!l||B)&&l.state?.id!==e){Ke(!0);try{const i=await n.issueUpdate({id:l.id,stateId:e});if(i.connected===!1){z(!1),y.error(t(a));return}if(!i.issue){y.error(t(a));return}We(i.issue),y.success(t("contextPanel.linear.toast.statusUpdated"))}catch(i){const T=i instanceof Error?i.message:String(i);y.error(t(a),{description:T})}finally{Ke(!1)}}},[We,B,n,l,t]),ot=r.useCallback(()=>{const e=U.find(a=>a.type==="completed");if(!e){y.error(t("contextPanel.linear.error.noCompletedState"));return}Ne(e.id,"contextPanel.linear.toast.closeFailed")},[t,Ne,U]),ct=r.useCallback(async()=>{if(!(!l||ie)){De(!0);try{await Nt({linear:n,issueKey:l.id,createInWorktree:oe,t})}finally{De(!1)}}},[oe,ie,n,l,t]),ut=r.useCallback(async e=>{if(!(!n?.authActivate||!e||e===_||ue)){Oe(!0);try{const a=await n.authActivate(e);W(a),E(null),X(null),le([]),S(M),y.success(t("contextPanel.linear.toast.workspaceSwitched"))}catch(a){const i=a instanceof Error?a.message:String(a);y.error(t("contextPanel.linear.toast.workspaceSwitchFailed"),{description:i})}finally{Oe(!1)}}},[_,ue,n,W,S,t]),Pe=r.useMemo(()=>{const e=new Map(U.map(g=>[g.id,g])),a=l?.state?.id,i=l?.state?.name;return[...a&&i&&!e.has(a)?[{id:a,name:i,type:l.state?.type??null,position:0},...U]:U].sort(Ot)},[l,U]),dt=U.find(e=>e.type==="completed"),mt=l?.state?.type==="completed",Ve=c&&O===!1,pt=!n,Ge=!!J,qe=x==="all"&&w==="any"&&d===M&&k==="all",we=!!n&&O&&!Ve,ee=!we||ue,m=Ue>0&&Ue<Mt,ke=h.trim().length>0,ft=!qe||ke,Se=!m||j||ke,Le=r.useCallback(()=>{R(""),A(!1)},[]);r.useEffect(()=>{const e=je.current;if(!e||!globalThis.ResizeObserver)return;const a=new ResizeObserver(i=>{at(i[0]?.contentRect.width??0)});return a.observe(e),()=>a.disconnect()},[Ge]),r.useEffect(()=>{m&&j&&ze.current?.focus()},[m,j]);const xt=s.jsxs("div",{className:"flex items-center gap-2 cursor-pointer",role:"button",tabIndex:0,"aria-pressed":oe,onClick:()=>ve(e=>!e),onKeyDown:e=>{(e.key===" "||e.key==="Enter")&&(e.preventDefault(),ve(a=>!a))},children:[s.jsx("button",{type:"button",onClick:e=>{e.preventDefault(),e.stopPropagation(),ve(a=>!a)},"aria-label":t("session.linearIssuePicker.actions.toggleWorktreeAria"),className:"flex h-5 w-5 shrink-0 items-center justify-center rounded text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:oe?s.jsx(u,{name:"checkbox",className:"h-4 w-4 text-primary"}):s.jsx(u,{name:"checkbox-blank",className:"h-4 w-4"})}),s.jsx("span",{className:"typography-meta text-muted-foreground",children:t("session.linearIssuePicker.actions.createInWorktree")})]}),ht=e=>s.jsxs("div",{className:K("group flex items-center gap-2 py-1.5 px-1 rounded cursor-pointer hover:bg-interactive-hover/30 transition-colors",J===e.id&&"bg-interactive-selection/30"),onClick:()=>E(e.id),children:[s.jsx("span",{className:"typography-meta text-muted-foreground w-16 text-right flex-shrink-0",children:e.identifier}),s.jsx("p",{className:"flex-1 min-w-0 typography-small text-foreground truncate ml-0.5",children:e.title}),s.jsx("div",{className:"flex-shrink-0 h-5 flex items-center mr-1",children:s.jsx("button",{type:"button",className:"hidden group-hover:flex h-5 w-5 items-center justify-center text-muted-foreground hover:text-foreground transition-colors",onClick:a=>{a.stopPropagation(),Ze(e.url)},"aria-label":t("session.linearIssuePicker.actions.openInLinearAria"),children:s.jsx(u,{name:"external-link",className:"h-4 w-4"})})})]},e.id);if(Ge){const e=l?.assignee?.displayName||l?.assignee?.name,a=l?.comments??[],i=l?.description?.trim()||"",T=l?.state?.id||"",g=zt(l?.priority),fe=l?.labels??[];return s.jsxs("div",{ref:je,className:"flex h-full min-h-0 flex-col",children:[s.jsxs("div",{className:"flex items-center gap-2 border-b border-border px-3 py-2",children:[s.jsxs(he,{type:"button",variant:"ghost",size:"sm",className:"h-7 px-2",onClick:()=>{E(null),X(null),le([])},"aria-label":t("contextPanel.linear.actions.backToList"),children:[s.jsx(u,{name:"arrow-left-s",className:"h-4 w-4"}),t("contextPanel.linear.actions.backToList")]}),l?s.jsx("button",{type:"button",className:"ml-auto flex h-7 w-7 items-center justify-center text-muted-foreground hover:text-foreground",onClick:()=>{Ze(l.url)},"aria-label":t("session.linearIssuePicker.actions.openInLinearAria"),children:s.jsx(u,{name:"external-link",className:"h-4 w-4"})}):null]}),s.jsxs(He,{as:Ye,outerClassName:"h-full min-h-0 flex-1",className:"px-4 py-3",disableHorizontal:!0,preventOverscroll:!0,children:[nt&&!l?s.jsxs("div",{className:"flex items-center justify-center gap-2 py-8 text-muted-foreground",children:[s.jsx(u,{name:"loader-4",className:"h-4 w-4 animate-spin"}),t("contextPanel.linear.loading.issue")]}):null,l?s.jsx(r.Suspense,{fallback:s.jsxs("div",{className:"flex items-center justify-center gap-2 py-8 text-muted-foreground",children:[s.jsx(u,{name:"loader-4",className:"h-4 w-4 animate-spin"}),t("contextPanel.linear.loading.issue")]}),children:s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("div",{className:"typography-meta text-muted-foreground",children:l.identifier}),s.jsx("h2",{className:"typography-ui-header text-foreground mt-0.5",children:l.title})]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[Pe.length>0&&T?s.jsxs(Pt,{value:T,onValueChange:p=>{Ne(p,"contextPanel.linear.toast.statusUpdateFailed")},disabled:B,children:[s.jsx(wt,{size:"sm",className:"h-7 w-auto min-w-0","aria-label":t("contextPanel.linear.label.statusAria"),children:s.jsx(kt,{placeholder:t("contextPanel.linear.label.status"),children:p=>Pe.find(Ce=>Ce.id===p)?.name??p})}),s.jsx(St,{children:Pe.map(p=>s.jsx(Lt,{value:p.id,children:p.name},p.id))})]}):l.state?.name?s.jsx("span",{className:"typography-meta text-muted-foreground",children:l.state.name}):null,dt&&!mt?s.jsxs(he,{type:"button",variant:"outline",size:"sm",className:"h-7",onClick:ot,disabled:B,children:[B?s.jsx(u,{name:"loader-4",className:"h-4 w-4 animate-spin"}):null,t("contextPanel.linear.actions.closeIssue")]}):null]}),s.jsxs("dl",{className:"grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 typography-meta",children:[l.team?.name?s.jsxs(s.Fragment,{children:[s.jsx("dt",{className:"text-muted-foreground",children:t("contextPanel.linear.label.team")}),s.jsx("dd",{className:"text-foreground min-w-0 truncate",children:l.team.name})]}):null,s.jsx("dt",{className:"text-muted-foreground",children:t("contextPanel.linear.label.assignee")}),s.jsx("dd",{className:"text-foreground min-w-0 truncate",children:e||t("contextPanel.linear.label.unassigned")}),g?s.jsxs(s.Fragment,{children:[s.jsx("dt",{className:"text-muted-foreground",children:t("contextPanel.linear.label.priority")}),s.jsx("dd",{className:"text-foreground min-w-0 truncate",children:t(g)})]}):null,fe.length>0?s.jsxs(s.Fragment,{children:[s.jsx("dt",{className:"text-muted-foreground",children:t("contextPanel.linear.label.labels")}),s.jsx("dd",{className:"min-w-0",children:s.jsx(Vt,{labels:fe})})]}):null]}),s.jsx("div",{children:i?s.jsx($e,{content:i,className:Je,enableFileReferences:!1}):s.jsx("p",{className:"typography-meta text-muted-foreground",children:t("contextPanel.linear.empty.noDescription")})}),s.jsxs("div",{children:[s.jsx("h3",{className:"typography-ui-label text-foreground mb-2",children:t("contextPanel.linear.label.comments")}),a.length===0?s.jsx("p",{className:"typography-meta text-muted-foreground",children:t("contextPanel.linear.empty.noComments")}):s.jsx("div",{className:"relative pl-3",children:a.map((p,Ce)=>{const Re=p.user?.displayName||p.user?.name||t("contextPanel.linear.label.unassigned"),Be=p.user?.avatarUrl||null,gt=Re.charAt(0).toUpperCase(),bt=Ce===a.length-1,Qe=rt(p.createdAt);return s.jsxs("div",{className:"relative pl-10 pb-5 last:pb-0",children:[bt?null:s.jsx("div",{className:"absolute left-4 top-[2.375rem] bottom-[0.375rem] w-px bg-border/60"}),s.jsx("div",{className:"absolute left-0 top-0 z-10 flex size-8 items-center justify-center overflow-hidden rounded-full border border-border/60 bg-surface-elevated text-xs text-muted-foreground",children:Be?s.jsx("img",{src:Be,alt:Re,className:"h-full w-full object-cover",loading:"lazy",referrerPolicy:"no-referrer"}):s.jsx("span",{children:gt})}),s.jsxs("div",{className:"rounded-lg bg-surface-elevated px-3 pt-0 pb-3 space-y-2",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 typography-micro text-muted-foreground",children:[s.jsx("span",{className:"text-foreground whitespace-nowrap",children:Re}),Qe?s.jsx("span",{className:"whitespace-nowrap",children:Qe}):null]}),p.body.trim()?s.jsx($e,{content:p.body,className:K("typography-markdown-body text-foreground break-words",Je),enableFileReferences:!1}):null]})]},p.id)})})]})]})}):null]}),l?s.jsxs("div",{className:"shrink-0 border-t border-border px-4 py-3 flex flex-col gap-3",children:[xt,s.jsxs(he,{type:"button",onClick:()=>{ct()},disabled:ie||B,className:"w-full",children:[ie?s.jsx(u,{name:"loader-4",className:"h-4 w-4 animate-spin"}):null,t("contextPanel.linear.actions.startSession")]})]}):null]})}return s.jsxs("div",{ref:je,className:"flex h-full min-h-0 flex-col",children:[s.jsxs("div",{className:"px-3 pt-3 space-y-2",children:[Se?s.jsxs("div",{className:"relative",children:[s.jsx(u,{name:"search",className:K("absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4",ke?"text-primary":"text-muted-foreground")}),s.jsx(Ct,{ref:ze,placeholder:t("session.linearIssuePicker.searchPlaceholder"),value:h,onChange:e=>R(e.target.value),onKeyDown:e=>{e.key==="Escape"&&m&&(e.preventDefault(),Le())},className:K("pl-9 w-full",m&&"pr-9")}),m?s.jsx("button",{type:"button",className:"absolute right-1.5 top-1/2 flex h-7 w-7 -translate-y-1/2 items-center justify-center rounded-md text-muted-foreground outline-none hover:bg-interactive-hover hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring","aria-label":t("contextPanel.linear.actions.closeSearch"),title:t("contextPanel.linear.actions.closeSearch"),onClick:Le,children:s.jsx(u,{name:"close",className:"size-3.5"})}):null]}):null,we||m&&!Se?s.jsxs("div",{className:K("flex min-w-0 items-center",m&&"gap-0.5"),children:[we?s.jsxs(s.Fragment,{children:[s.jsx(te,{icon:"task",label:t((ge.find(e=>e.value===x)??ge[0]).labelKey),ariaLabel:t("contextPanel.linear.filter.statusAria"),value:x,active:x!=="all",disabled:ee,items:ge.map(e=>({value:e.value,label:t(e.labelKey)})),onValueChange:e=>{Ut(e)&&F(e)}}),s.jsx(te,{icon:"error-warning",compact:m,label:t((be.find(e=>e.value===k)??be[0]).labelKey),ariaLabel:t("contextPanel.linear.filter.priorityAria"),value:k,active:k!=="all",disabled:ee,items:be.map(e=>({value:e.value,label:t(e.labelKey)})),onValueChange:e=>{_t(e)&&H(e)}}),s.jsx(te,{icon:"user-3",compact:m,label:t(w==="me"?"contextPanel.linear.filter.assignee.me":"contextPanel.linear.filter.assignee.any"),ariaLabel:t("contextPanel.linear.filter.assigneeAria"),value:w,active:w!=="any",disabled:ee,items:[{value:"any",label:t("contextPanel.linear.filter.assignee.any")},{value:"me",label:t("contextPanel.linear.filter.assignee.me")}],onValueChange:e=>{(e==="any"||e==="me")&&Z(e)}}),Q.length>0?s.jsx(te,{icon:"team",compact:m,label:d===M?t("contextPanel.linear.filter.team.all"):Q.find(e=>e.id===d)?.name??d,ariaLabel:t("contextPanel.linear.filter.teamAria"),value:d,active:d!==M,disabled:ee,items:[{value:M,label:t("contextPanel.linear.filter.team.all")},...Q.map(e=>({value:e.id,label:e.name}))],onValueChange:S}):null,pe.length>1&&_?s.jsx(te,{icon:"briefcase",compact:m,label:Xe(pe.find(e=>e.id===_)??{id:_,name:null,urlKey:null}),ariaLabel:t("contextPanel.linear.label.workspaceAria"),value:_,disabled:ue,items:pe.map(e=>({value:e.id,label:Xe(e)})),onValueChange:e=>{ut(e)}}):null,ft?s.jsxs("button",{type:"button",className:K(m?Ae:st,!m&&"flex-none"),"aria-label":t("contextPanel.linear.filter.clearAria"),title:t("contextPanel.linear.filter.clearAria"),disabled:ee,onClick:()=>{Y(),Le()},children:[s.jsx(u,{name:"close",className:"size-3.5 shrink-0 text-muted-foreground"}),m?null:s.jsx("span",{className:"min-w-0 truncate",children:t("contextPanel.linear.filter.clear")})]}):null]}):null,m&&!Se?s.jsx("button",{type:"button",className:Ae,"aria-label":t("contextPanel.linear.filter.searchAria"),title:t("contextPanel.linear.filter.searchAria"),onClick:()=>A(!0),children:s.jsx(u,{name:"search",className:"size-3.5 shrink-0 text-muted-foreground"})}):null]}):null]}),s.jsxs(He,{as:Ye,outerClassName:"h-full min-h-0 flex-1",className:"px-3 py-2",disableHorizontal:!0,preventOverscroll:!0,children:[pt?s.jsx("div",{className:"text-center text-muted-foreground py-8",children:t("session.linearIssuePicker.empty.runtimeUnavailable")}):null,ae&&I.length===0?s.jsxs("div",{className:"text-center text-muted-foreground py-8 flex items-center justify-center gap-2",children:[s.jsx(u,{name:"loader-4",className:"h-4 w-4 animate-spin"}),t("session.linearIssuePicker.loading.issues")]}):null,Ve?s.jsxs("div",{className:"text-center text-muted-foreground py-8 space-y-3",children:[s.jsx("div",{children:t("session.linearIssuePicker.empty.notConnected")}),s.jsx("div",{className:"flex justify-center",children:s.jsx(he,{variant:"outline",size:"sm",onClick:lt,children:t("session.linearIssuePicker.actions.openSettings")})})]}):null,Te?s.jsx("div",{className:"text-center text-muted-foreground py-8 break-words",children:Te}):null,de&&n&&O?s.jsxs("div",{className:"group flex items-center gap-2 py-1.5 px-1 hover:bg-interactive-hover/30 rounded transition-colors cursor-pointer",onClick:()=>E(de),children:[s.jsx("span",{className:"typography-meta text-muted-foreground w-16 text-right flex-shrink-0",children:de}),s.jsx("p",{className:"flex-1 min-w-0 typography-small text-foreground truncate ml-0.5",children:t("session.linearIssuePicker.actions.useIssue",{identifier:de})})]}):null,I.length===0&&!ae&&O&&n?s.jsx("div",{className:"text-center text-muted-foreground py-8",children:Ie.trim()?t("session.linearIssuePicker.empty.noIssuesFound"):t(qe?"session.linearIssuePicker.empty.noOpenIssuesFound":"contextPanel.linear.empty.noMatchingIssues")}):null,I.map(ht),ye&&O&&n?s.jsx("div",{className:"py-2 flex justify-center",children:s.jsx("button",{type:"button",onClick:()=>{it()},disabled:$,className:K("typography-meta text-muted-foreground hover:text-foreground transition-colors underline underline-offset-4",$&&"opacity-50 cursor-not-allowed hover:text-muted-foreground"),children:$?s.jsxs("span",{className:"inline-flex items-center gap-2",children:[s.jsx(u,{name:"loader-4",className:"h-4 w-4 animate-spin"}),t("session.linearIssuePicker.loading.more")]}):t("session.linearIssuePicker.actions.loadMore")})}):null]})]})};function Qt(t){return s.jsx("span",{className:"inline-flex h-5 max-w-[8rem] items-center truncate rounded-md px-1.5 typography-meta text-muted-foreground",style:Wt(t.color),children:t.name},t.id)}function Zt(t){return s.jsx(Rt,{value:t.value,children:t.label},t.value)}export{Nn as LinearIssuesView};
@@ -1 +1 @@
1
- import{f as B,R as h,j as P}from"./vendor-react-BUCujlKS.js";import{toast as H}from"./vendor-sonner-DFyL3AvE.js";import{gy as K,gv as J,af as Z,f as Q,I as W}from"./useAppFontEffects-hfv2s6mZ.js";import{h as G,a4 as Y,O as ee,e as te,dM as re,dN as oe,a3 as ae}from"./index-Dy8xgawx.js";import{extractMarkdownImageCandidates as se,MAX_MARKDOWN_IMAGE_COUNT as ne}from"./markdownCore-DPrwM1rU.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-zod-fZppILAM.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-zustand-BAGL70zf.js";import"./vendor-base-ui-CsXYnR5c.js";import"./vendor-floating-ui-utils-D6FqdtJt.js";import"./vendor-floating-ui-react-dom-DxYCWdHj.js";import"./vendor-floating-ui-dom-BTvzWks8.js";import"./vendor-floating-ui-core-PuGzNPnN.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-framer-motion-Bq3iTZ6r.js";import"./vendor-motion-dom-DcCgeG69.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./vendor-tanstack-react-virtual-g05Cx3z9.js";import"./vendor-tanstack-virtual-core-Dubg10g5.js";import"./contextPanelEmbeddedChat-CirXEPJq.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-BgPj_McA.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-codemirror-state-C9awkmn-.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-codemirror-view-CiLROUVV.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-Cc2ZYbgX.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-codemirror-autocomplete-DzPz9Wgq.js";import"./vendor-codemirror-lang-json-CMBS2tG9.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-O0cZX78y.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-CfgK872x.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-BPGOH9ye.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-BPMJpOpT.js";import"./vendor-codemirror-lang-python-HahnQaAS.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-codemirror-commands-B7H_j0iU.js";import"./vendor-legendapp-list-BuBPBC3R.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-marked-linkify-it-CXI_LHIE.js";import"./vendor-linkify-it-DZCzzDkK.js";import"./vendor-uc.micro-BAd0H0z4.js";import"./vendor-remend-BWYYytN3.js";import"./vendor-katex-k3Ppq1Ha.js";import"./vendor-dompurify-r8glNMJW.js";const L=10*1024*1024,ie=1024,le=3e4,ce=new Set(["image/png","image/jpeg","image/gif","image/webp"]),z=new WeakMap,$=r=>{if(r.aborted)throw new DOMException("Image load aborted","AbortError")},me=r=>{let e=r;if(/^file:\/\//i.test(e))try{const o=new URL(e);if(o.protocol!=="file:")return"";e=o.host&&o.host!=="localhost"?`//${o.host}${o.pathname}`:o.pathname,/^\/[A-Za-z]:\//.test(e)&&(e=e.slice(1))}catch{return""}const t=e.split(/[?#]/,1)[0]??"";try{return decodeURIComponent(t)}catch{return t}},ue=r=>new Promise((e,t)=>{const o=new FileReader;o.onload=()=>{typeof o.result=="string"?e(o.result):t(new Error("Unable to encode image"))},o.onerror=()=>t(o.error??new Error("Unable to encode image")),o.readAsDataURL(r)}),pe=async(r,e)=>{const t=new Uint8Array(await r.slice(0,12).arrayBuffer()),o=(n,u)=>String.fromCharCode(...t.slice(n,u));switch(e){case"image/png":return t[0]===137&&o(1,4)==="PNG"&&t[4]===13&&t[5]===10&&t[6]===26&&t[7]===10;case"image/jpeg":return t[0]===255&&t[1]===216&&t[2]===255;case"image/gif":{const n=o(0,6);return n==="GIF87a"||n==="GIF89a"}case"image/webp":return o(0,4)==="RIFF"&&o(8,12)==="WEBP";default:return!1}},V=async(r,e)=>{if(!ce.has(e))throw new Error("Unsupported image type");if(r.size>L)throw new Error("Image is too large");if(!await pe(r,e))throw new Error("Unsupported image data")},fe=async r=>{const e=/^data:(image\/(?:png|jpeg|gif|webp));base64,([\s\S]*)$/i.exec(r);if(!e?.[1]||e[2]===void 0)throw new Error("Invalid image data URL");if(e[2].length>Math.ceil(L*4/3)+4)throw new Error("Image is too large");let t;try{t=atob(e[2])}catch{throw new Error("Invalid image data URL")}const o=Uint8Array.from(t,n=>n.charCodeAt(0));await V(new Blob([o]),e[1].toLowerCase())},q=r=>!/^(?:https?:)?\/\//i.test(r)&&!/^data:image\/(?:png|jpeg|gif|webp);base64,/i.test(r),de=async({sources:r,directory:e,sessionId:t,messageId:o,signal:n})=>{const u=Y();let s=z.get(u);s||(s=new Map,z.set(u,s));const c=`${t}\0${o}\0${e}\0${r.join("\0")}`,i=s.get(c);if(i&&i.expiresAt>Date.now())return s.delete(c),s.set(c,i),i.result;i&&s.delete(c);const p=await G(`/api/openchamber/sessions/${encodeURIComponent(t)}/markdown-image-grants`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({directory:e,messageId:o,sources:r}),signal:n});if(!p.ok)throw new Error(`Unable to prepare images (${p.status})`);const m=await p.json(),l=new Map;for(const a of m.results??[])a.source&&(a.status==="ready"&&a.path?l.set(a.source,{status:"ready",path:a.path,outsideFileGrant:a.outsideFileGrant,expiresAt:a.expiresAt}):a.status==="missing"?l.set(a.source,{status:"missing"}):l.set(a.source,{status:"error"}));for(const a of r)l.has(a)||l.set(a,{status:"error"});for(;s.size>=ie;)s.delete(s.keys().next().value);const w=[...l.values()].every(a=>a.status==="ready"),y=Math.min(...[...l.values()].filter(a=>a.status==="ready").map(a=>a.expiresAt??Number.POSITIVE_INFINITY));return s.set(c,{result:l,expiresAt:w?y:Date.now()+le}),l},ge=async(r,e)=>{if($(e),/^(?:https?:)?\/\//i.test(r))return r;if(/^data:image\/(?:png|jpeg|gif|webp);base64,/i.test(r))return await fe(r),$(e),r;throw new Error("Local image has not been prepared")},he=async(r,e,t)=>{$(t);const o=me(r),n=K(e,o);if(!e||!o||!J(n,e))throw new Error("Image path is outside the active workspace");const u=await G("/api/fs/stat",{query:{path:n,directory:e,optional:"true"},signal:t});if(!u.ok)throw new Error(`Unable to inspect image (${u.status})`);const s=await u.json();if(!s.isFile)throw new Error("Image path is not a file");if(typeof s.size=="number"&&s.size>L)throw new Error("Image is too large");const c=await G("/api/fs/raw",{query:{path:n,directory:e},signal:t});if(!c.ok)throw new Error(`Unable to load image (${c.status})`);const i=(c.headers.get("content-type")??"").split(";",1)[0]?.toLowerCase()??"",p=Number(c.headers.get("content-length"));if(Number.isFinite(p)&&p>L)throw new Error("Image is too large");const m=await c.blob();return await V(m,i),$(t),ue(m)},we=(r,e)=>Y().authenticatedAsset("/api/fs/raw",{path:r.path,directory:e,allowOutsideWorkspace:r.outsideFileGrant?"true":void 0,outsideFileGrant:r.outsideFileGrant}),be=r=>{const e=B.c(7),[t,o]=h.useState(!1),[n,u]=h.useState(0);let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=te(),e[0]=s):s=e[0];const c=s;let i,p;e[1]!==r?(i=()=>{if(!r){o(!1);return}let w=!1,y;const a=re(c),g=oe(()=>{w||u(Ie)}),I=()=>{ae(c).then(()=>{w||o(!0)}).catch(()=>{w||(y=setTimeout(I,1e3))})};return I(),()=>{w=!0,y&&clearTimeout(y),a(),g()}},p=[c,r],e[1]=r,e[2]=i,e[3]=p):(i=e[2],p=e[3]),h.useEffect(i,p);const m=!r||t;let l;return e[4]!==n||e[5]!==m?(l={ready:m,nonce:n},e[4]=n,e[5]=m,e[6]=l):l=e[6],l},ye=r=>{const e=B.c(46),{candidate:t,preparation:o,directory:n,assetAuthReady:u,assetAuthNonce:s,useWorkspaceFsBridge:c,onShowPopup:i}=r,{t:p}=Q(),m=h.useRef(null),[l,w]=h.useState(!1);let y;e[0]===Symbol.for("react.memo_cache_sentinel")?(y={url:"",status:"loading"},e[0]=y):y=e[0];const[a,g]=h.useState(y);let I;e[1]!==t.source?(I=q(t.source),e[1]=t.source,e[2]=I):I=e[2];const b=I;let v,f;e[3]!==l?(v=()=>{const N=m.current;if(!N||l)return;if(typeof IntersectionObserver>"u"){w(!0);return}const E=new IntersectionObserver(F=>{F.some(Ee)&&(w(!0),E.disconnect())},{rootMargin:"200px"});return E.observe(N),()=>E.disconnect()},f=[l],e[3]=l,e[4]=v,e[5]=f):(v=e[4],f=e[5]),h.useEffect(v,f);let x;e[6]!==u||e[7]!==t.source||e[8]!==n||e[9]!==b||e[10]!==o||e[11]!==l||e[12]!==c?(x=()=>{if(!l||b&&!c&&!o)return;if(b&&c){const E=new AbortController;return g({url:"",status:"loading"}),he(t.source,n,E.signal).then(F=>{E.signal.aborted||g({url:F,status:"loading"})}).catch(()=>{E.signal.aborted||g({url:"",status:"error"})}),()=>E.abort()}if(b){if(o?.status!=="ready"){g({url:"",status:"error"});return}if(!u)return;g({url:we(o,n),status:"loading"});return}const N=new AbortController;return g({url:"",status:"loading"}),ge(t.source,N.signal).then(E=>{N.signal.aborted||g({url:E,status:"loading"})}).catch(()=>{N.signal.aborted||g({url:"",status:"error"})}),()=>N.abort()},e[6]=u,e[7]=t.source,e[8]=n,e[9]=b,e[10]=o,e[11]=l,e[12]=c,e[13]=x):x=e[13];let k;e[14]!==s||e[15]!==u||e[16]!==t.source||e[17]!==n||e[18]!==b||e[19]!==o||e[20]!==l||e[21]!==c?(k=[s,u,t.source,n,b,o,l,c],e[14]=s,e[15]=u,e[16]=t.source,e[17]=n,e[18]=b,e[19]=o,e[20]=l,e[21]=c,e[22]=k):k=e[22],h.useEffect(x,k);let R;e[23]!==t.filename||e[24]!==a.status||e[25]!==a.url||e[26]!==i||e[27]!==p?(R=()=>{if(a.status==="error"){H.error(p("filesView.error.previewUnavailable"));return}a.status!=="ready"||!i||i({open:!0,title:t.filename,content:"",metadata:{tool:"markdown-image-preview",filename:t.filename},image:{url:a.url,filename:t.filename}})},e[23]=t.filename,e[24]=a.status,e[25]=a.url,e[26]=i,e[27]=p,e[28]=R):R=e[28];const U=R,j=a.status==="loading";let A;e[29]!==t.filename||e[30]!==a.status||e[31]!==a.url?(A=P.jsx("span",{className:"flex h-[72px] w-[100px] items-center justify-center overflow-hidden rounded-lg border border-border/40 bg-muted/10",children:a.url&&a.status!=="error"?P.jsx("img",{src:a.url,alt:t.filename,className:"h-full w-full object-contain",loading:"lazy",decoding:"async",referrerPolicy:"no-referrer",onLoad:()=>g(Ae),onError:()=>g({url:"",status:"error"}),"data-openchamber-markdown-image":"true","data-openchamber-markdown-image-thumbnail":"true","data-openchamber-markdown-image-state":a.status}):P.jsx(W,{name:"file-image",className:"h-5 w-5 text-muted-foreground"})}),e[29]=t.filename,e[30]=a.status,e[31]=a.url,e[32]=A):A=e[32];let _;e[33]===Symbol.for("react.memo_cache_sentinel")?(_=P.jsx(W,{name:"file-image",className:"h-3 w-3 shrink-0"}),e[33]=_):_=e[33];let S;e[34]!==t.filename?(S=P.jsx("span",{className:"min-w-0 truncate typography-meta",children:t.filename}),e[34]=t.filename,e[35]=S):S=e[35];let C;e[36]!==t.filename||e[37]!==S?(C=P.jsxs("span",{className:"mt-1 flex w-[100px] items-center justify-center gap-1 text-muted-foreground",title:t.filename,"data-openchamber-markdown-image-caption":"true",children:[_,S]}),e[36]=t.filename,e[37]=S,e[38]=C):C=e[38];let M;return e[39]!==t.filename||e[40]!==t.source||e[41]!==U||e[42]!==C||e[43]!==j||e[44]!==A?(M=P.jsxs("button",{ref:m,type:"button",className:"w-[100px] shrink-0 text-left outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]","aria-label":t.filename,disabled:j,onClick:U,"data-openchamber-markdown-image-action":"true","data-openchamber-markdown-image-source":t.source,"data-openchamber-markdown-image-filename":t.filename,children:[A,C]}),e[39]=t.filename,e[40]=t.source,e[41]=U,e[42]=C,e[43]=j,e[44]=A,e[45]=M):M=e[45],M},pr=r=>{const e=B.c(34),{sessionId:t,messageId:o,contents:n,onShowPopup:u}=r,s=Z()??"",c=h.useRef(null),[i,p]=h.useState(!1),[m,l]=h.useState(null),[w,y]=h.useState(0);let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=ee(),e[0]=a):a=e[0];const g=a;let I;e[1]!==n?(I=se(n,ne),e[1]=n,e[2]=I):I=e[2];const b=I;let v;e[3]!==b?(v=g?[]:b.filter(ve).map(xe),e[3]=b,e[4]=v):v=e[4];const f=v;let x,k;e[5]!==f.length||e[6]!==i?(x=()=>{if(f.length===0||i)return;const d=c.current;if(!d||typeof IntersectionObserver>"u"){p(!0);return}const T=new IntersectionObserver(X=>{X.some(ke)&&(p(!0),T.disconnect())},{rootMargin:"200px"});return T.observe(d),()=>T.disconnect()},k=[f.length,i],e[5]=f.length,e[6]=i,e[7]=x,e[8]=k):(x=e[7],k=e[8]),h.useEffect(x,k);let R;e[9]!==s||e[10]!==o||e[11]!==f||e[12]!==t||e[13]!==i?(R=()=>{if(!i||!t||f.length===0)return;const d=new AbortController;return de({sources:f,directory:s,sessionId:t,messageId:o,signal:d.signal}).then(T=>{d.signal.aborted||l(T)}).catch(()=>{d.signal.aborted||l(new Map(f.map(Re)))}),()=>d.abort()},e[9]=s,e[10]=o,e[11]=f,e[12]=t,e[13]=i,e[14]=R):R=e[14];let U;e[15]!==s||e[16]!==o||e[17]!==w||e[18]!==f||e[19]!==t||e[20]!==i?(U=[s,o,w,f,t,i],e[15]=s,e[16]=o,e[17]=w,e[18]=f,e[19]=t,e[20]=i,e[21]=U):U=e[21],h.useEffect(R,U);let j,A;e[22]!==m?(j=()=>{const d=Math.min(...[...m?.values()??[]].filter(_e).map(Se));if(!Number.isFinite(d))return;const T=setTimeout(()=>y(Me),Math.max(0,d-Date.now()));return()=>clearTimeout(T)},A=[m],e[22]=m,e[23]=j,e[24]=A):(j=e[23],A=e[24]),h.useEffect(j,A);let _;e[25]!==m?(_=d=>m?.get(d.source)?.status!=="missing",e[25]=m,e[26]=_):_=e[26];const S=b.filter(_),C=[...m?.values()??[]].some(Ne),M=be(C);if(S.length===0)return null;const N="mt-3 flex max-w-full gap-2 overflow-x-auto pb-1",E="true";let F;e[27]!==M||e[28]!==s||e[29]!==u||e[30]!==m?(F=d=>P.jsx(ye,{candidate:d,preparation:m?.get(d.source),directory:s,assetAuthReady:M.ready,assetAuthNonce:M.nonce,useWorkspaceFsBridge:g,onShowPopup:u},d.source),e[27]=M,e[28]=s,e[29]=u,e[30]=m,e[31]=F):F=e[31];const D=S.map(F);let O;return e[32]!==D?(O=P.jsx("div",{ref:c,className:N,"data-openchamber-markdown-image-gallery":E,children:D}),e[32]=D,e[33]=O):O=e[33],O};function Ie(r){return r+1}function Ee(r){return r.isIntersecting}function Ae(r){return{...r,status:"ready"}}function ve(r){return q(r.source)}function xe(r){return r.source}function ke(r){return r.isIntersecting}function Re(r){return[r,{status:"error"}]}function _e(r){return r.status==="ready"}function Se(r){return r.expiresAt??Number.POSITIVE_INFINITY}function Me(r){return r+1}function Ne(r){return r.status==="ready"}export{pr as MarkdownImageGallery};
1
+ import{f as B,R as h,j as P}from"./vendor-react-BUCujlKS.js";import{toast as H}from"./vendor-sonner-DFyL3AvE.js";import{gC as K,gz as J,af as Z,f as Q,I as W}from"./useAppFontEffects-BItUWdo4.js";import{h as G,a4 as Y,O as ee,e as te,dM as re,dN as oe,a3 as ae}from"./index-DLHQogv8.js";import{extractMarkdownImageCandidates as se,MAX_MARKDOWN_IMAGE_COUNT as ne}from"./markdownCore-DHvqMxPn.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-zod-fZppILAM.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-zustand-BAGL70zf.js";import"./vendor-base-ui-CsXYnR5c.js";import"./vendor-floating-ui-utils-D6FqdtJt.js";import"./vendor-floating-ui-react-dom-DxYCWdHj.js";import"./vendor-floating-ui-dom-BTvzWks8.js";import"./vendor-floating-ui-core-PuGzNPnN.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-framer-motion-Bq3iTZ6r.js";import"./vendor-motion-dom-DcCgeG69.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./vendor-tanstack-react-virtual-ClYN8CzB.js";import"./vendor-tanstack-virtual-core-BewVQryB.js";import"./contextPanelEmbeddedChat-CirXEPJq.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-BgPj_McA.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-codemirror-state-C9awkmn-.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-codemirror-view-CiLROUVV.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-Cc2ZYbgX.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-codemirror-autocomplete-DzPz9Wgq.js";import"./vendor-codemirror-lang-json-CMBS2tG9.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-O0cZX78y.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-CfgK872x.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-BPGOH9ye.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-BDyxuqK4.js";import"./vendor-codemirror-lang-python-HahnQaAS.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-codemirror-commands-B7H_j0iU.js";import"./vendor-legendapp-list-BuBPBC3R.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-marked-linkify-it-CXI_LHIE.js";import"./vendor-linkify-it-DZCzzDkK.js";import"./vendor-uc.micro-BAd0H0z4.js";import"./vendor-remend-BWYYytN3.js";import"./vendor-katex-k3Ppq1Ha.js";import"./vendor-dompurify-r8glNMJW.js";const L=10*1024*1024,ie=1024,le=3e4,ce=new Set(["image/png","image/jpeg","image/gif","image/webp"]),z=new WeakMap,$=r=>{if(r.aborted)throw new DOMException("Image load aborted","AbortError")},me=r=>{let e=r;if(/^file:\/\//i.test(e))try{const o=new URL(e);if(o.protocol!=="file:")return"";e=o.host&&o.host!=="localhost"?`//${o.host}${o.pathname}`:o.pathname,/^\/[A-Za-z]:\//.test(e)&&(e=e.slice(1))}catch{return""}const t=e.split(/[?#]/,1)[0]??"";try{return decodeURIComponent(t)}catch{return t}},ue=r=>new Promise((e,t)=>{const o=new FileReader;o.onload=()=>{typeof o.result=="string"?e(o.result):t(new Error("Unable to encode image"))},o.onerror=()=>t(o.error??new Error("Unable to encode image")),o.readAsDataURL(r)}),pe=async(r,e)=>{const t=new Uint8Array(await r.slice(0,12).arrayBuffer()),o=(n,u)=>String.fromCharCode(...t.slice(n,u));switch(e){case"image/png":return t[0]===137&&o(1,4)==="PNG"&&t[4]===13&&t[5]===10&&t[6]===26&&t[7]===10;case"image/jpeg":return t[0]===255&&t[1]===216&&t[2]===255;case"image/gif":{const n=o(0,6);return n==="GIF87a"||n==="GIF89a"}case"image/webp":return o(0,4)==="RIFF"&&o(8,12)==="WEBP";default:return!1}},V=async(r,e)=>{if(!ce.has(e))throw new Error("Unsupported image type");if(r.size>L)throw new Error("Image is too large");if(!await pe(r,e))throw new Error("Unsupported image data")},fe=async r=>{const e=/^data:(image\/(?:png|jpeg|gif|webp));base64,([\s\S]*)$/i.exec(r);if(!e?.[1]||e[2]===void 0)throw new Error("Invalid image data URL");if(e[2].length>Math.ceil(L*4/3)+4)throw new Error("Image is too large");let t;try{t=atob(e[2])}catch{throw new Error("Invalid image data URL")}const o=Uint8Array.from(t,n=>n.charCodeAt(0));await V(new Blob([o]),e[1].toLowerCase())},q=r=>!/^(?:https?:)?\/\//i.test(r)&&!/^data:image\/(?:png|jpeg|gif|webp);base64,/i.test(r),de=async({sources:r,directory:e,sessionId:t,messageId:o,signal:n})=>{const u=Y();let s=z.get(u);s||(s=new Map,z.set(u,s));const c=`${t}\0${o}\0${e}\0${r.join("\0")}`,i=s.get(c);if(i&&i.expiresAt>Date.now())return s.delete(c),s.set(c,i),i.result;i&&s.delete(c);const p=await G(`/api/openchamber/sessions/${encodeURIComponent(t)}/markdown-image-grants`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({directory:e,messageId:o,sources:r}),signal:n});if(!p.ok)throw new Error(`Unable to prepare images (${p.status})`);const m=await p.json(),l=new Map;for(const a of m.results??[])a.source&&(a.status==="ready"&&a.path?l.set(a.source,{status:"ready",path:a.path,outsideFileGrant:a.outsideFileGrant,expiresAt:a.expiresAt}):a.status==="missing"?l.set(a.source,{status:"missing"}):l.set(a.source,{status:"error"}));for(const a of r)l.has(a)||l.set(a,{status:"error"});for(;s.size>=ie;)s.delete(s.keys().next().value);const w=[...l.values()].every(a=>a.status==="ready"),y=Math.min(...[...l.values()].filter(a=>a.status==="ready").map(a=>a.expiresAt??Number.POSITIVE_INFINITY));return s.set(c,{result:l,expiresAt:w?y:Date.now()+le}),l},ge=async(r,e)=>{if($(e),/^(?:https?:)?\/\//i.test(r))return r;if(/^data:image\/(?:png|jpeg|gif|webp);base64,/i.test(r))return await fe(r),$(e),r;throw new Error("Local image has not been prepared")},he=async(r,e,t)=>{$(t);const o=me(r),n=K(e,o);if(!e||!o||!J(n,e))throw new Error("Image path is outside the active workspace");const u=await G("/api/fs/stat",{query:{path:n,directory:e,optional:"true"},signal:t});if(!u.ok)throw new Error(`Unable to inspect image (${u.status})`);const s=await u.json();if(!s.isFile)throw new Error("Image path is not a file");if(typeof s.size=="number"&&s.size>L)throw new Error("Image is too large");const c=await G("/api/fs/raw",{query:{path:n,directory:e},signal:t});if(!c.ok)throw new Error(`Unable to load image (${c.status})`);const i=(c.headers.get("content-type")??"").split(";",1)[0]?.toLowerCase()??"",p=Number(c.headers.get("content-length"));if(Number.isFinite(p)&&p>L)throw new Error("Image is too large");const m=await c.blob();return await V(m,i),$(t),ue(m)},we=(r,e)=>Y().authenticatedAsset("/api/fs/raw",{path:r.path,directory:e,allowOutsideWorkspace:r.outsideFileGrant?"true":void 0,outsideFileGrant:r.outsideFileGrant}),be=r=>{const e=B.c(7),[t,o]=h.useState(!1),[n,u]=h.useState(0);let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=te(),e[0]=s):s=e[0];const c=s;let i,p;e[1]!==r?(i=()=>{if(!r){o(!1);return}let w=!1,y;const a=re(c),g=oe(()=>{w||u(Ie)}),I=()=>{ae(c).then(()=>{w||o(!0)}).catch(()=>{w||(y=setTimeout(I,1e3))})};return I(),()=>{w=!0,y&&clearTimeout(y),a(),g()}},p=[c,r],e[1]=r,e[2]=i,e[3]=p):(i=e[2],p=e[3]),h.useEffect(i,p);const m=!r||t;let l;return e[4]!==n||e[5]!==m?(l={ready:m,nonce:n},e[4]=n,e[5]=m,e[6]=l):l=e[6],l},ye=r=>{const e=B.c(46),{candidate:t,preparation:o,directory:n,assetAuthReady:u,assetAuthNonce:s,useWorkspaceFsBridge:c,onShowPopup:i}=r,{t:p}=Q(),m=h.useRef(null),[l,w]=h.useState(!1);let y;e[0]===Symbol.for("react.memo_cache_sentinel")?(y={url:"",status:"loading"},e[0]=y):y=e[0];const[a,g]=h.useState(y);let I;e[1]!==t.source?(I=q(t.source),e[1]=t.source,e[2]=I):I=e[2];const b=I;let x,f;e[3]!==l?(x=()=>{const N=m.current;if(!N||l)return;if(typeof IntersectionObserver>"u"){w(!0);return}const E=new IntersectionObserver(F=>{F.some(Ee)&&(w(!0),E.disconnect())},{rootMargin:"200px"});return E.observe(N),()=>E.disconnect()},f=[l],e[3]=l,e[4]=x,e[5]=f):(x=e[4],f=e[5]),h.useEffect(x,f);let v;e[6]!==u||e[7]!==t.source||e[8]!==n||e[9]!==b||e[10]!==o||e[11]!==l||e[12]!==c?(v=()=>{if(!l||b&&!c&&!o)return;if(b&&c){const E=new AbortController;return g({url:"",status:"loading"}),he(t.source,n,E.signal).then(F=>{E.signal.aborted||g({url:F,status:"loading"})}).catch(()=>{E.signal.aborted||g({url:"",status:"error"})}),()=>E.abort()}if(b){if(o?.status!=="ready"){g({url:"",status:"error"});return}if(!u)return;g({url:we(o,n),status:"loading"});return}const N=new AbortController;return g({url:"",status:"loading"}),ge(t.source,N.signal).then(E=>{N.signal.aborted||g({url:E,status:"loading"})}).catch(()=>{N.signal.aborted||g({url:"",status:"error"})}),()=>N.abort()},e[6]=u,e[7]=t.source,e[8]=n,e[9]=b,e[10]=o,e[11]=l,e[12]=c,e[13]=v):v=e[13];let k;e[14]!==s||e[15]!==u||e[16]!==t.source||e[17]!==n||e[18]!==b||e[19]!==o||e[20]!==l||e[21]!==c?(k=[s,u,t.source,n,b,o,l,c],e[14]=s,e[15]=u,e[16]=t.source,e[17]=n,e[18]=b,e[19]=o,e[20]=l,e[21]=c,e[22]=k):k=e[22],h.useEffect(v,k);let R;e[23]!==t.filename||e[24]!==a.status||e[25]!==a.url||e[26]!==i||e[27]!==p?(R=()=>{if(a.status==="error"){H.error(p("filesView.error.previewUnavailable"));return}a.status!=="ready"||!i||i({open:!0,title:t.filename,content:"",metadata:{tool:"markdown-image-preview",filename:t.filename},image:{url:a.url,filename:t.filename}})},e[23]=t.filename,e[24]=a.status,e[25]=a.url,e[26]=i,e[27]=p,e[28]=R):R=e[28];const U=R,j=a.status==="loading";let A;e[29]!==t.filename||e[30]!==a.status||e[31]!==a.url?(A=P.jsx("span",{className:"flex h-[72px] w-[100px] items-center justify-center overflow-hidden rounded-lg border border-border/40 bg-muted/10",children:a.url&&a.status!=="error"?P.jsx("img",{src:a.url,alt:t.filename,className:"h-full w-full object-contain",loading:"lazy",decoding:"async",referrerPolicy:"no-referrer",onLoad:()=>g(Ae),onError:()=>g({url:"",status:"error"}),"data-openchamber-markdown-image":"true","data-openchamber-markdown-image-thumbnail":"true","data-openchamber-markdown-image-state":a.status}):P.jsx(W,{name:"file-image",className:"h-5 w-5 text-muted-foreground"})}),e[29]=t.filename,e[30]=a.status,e[31]=a.url,e[32]=A):A=e[32];let _;e[33]===Symbol.for("react.memo_cache_sentinel")?(_=P.jsx(W,{name:"file-image",className:"h-3 w-3 shrink-0"}),e[33]=_):_=e[33];let S;e[34]!==t.filename?(S=P.jsx("span",{className:"min-w-0 truncate typography-meta",children:t.filename}),e[34]=t.filename,e[35]=S):S=e[35];let C;e[36]!==t.filename||e[37]!==S?(C=P.jsxs("span",{className:"mt-1 flex w-[100px] items-center justify-center gap-1 text-muted-foreground",title:t.filename,"data-openchamber-markdown-image-caption":"true",children:[_,S]}),e[36]=t.filename,e[37]=S,e[38]=C):C=e[38];let M;return e[39]!==t.filename||e[40]!==t.source||e[41]!==U||e[42]!==C||e[43]!==j||e[44]!==A?(M=P.jsxs("button",{ref:m,type:"button",className:"w-[100px] shrink-0 text-left outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]","aria-label":t.filename,disabled:j,onClick:U,"data-openchamber-markdown-image-action":"true","data-openchamber-markdown-image-source":t.source,"data-openchamber-markdown-image-filename":t.filename,children:[A,C]}),e[39]=t.filename,e[40]=t.source,e[41]=U,e[42]=C,e[43]=j,e[44]=A,e[45]=M):M=e[45],M},pr=r=>{const e=B.c(34),{sessionId:t,messageId:o,contents:n,onShowPopup:u}=r,s=Z()??"",c=h.useRef(null),[i,p]=h.useState(!1),[m,l]=h.useState(null),[w,y]=h.useState(0);let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=ee(),e[0]=a):a=e[0];const g=a;let I;e[1]!==n?(I=se(n,ne),e[1]=n,e[2]=I):I=e[2];const b=I;let x;e[3]!==b?(x=g?[]:b.filter(xe).map(ve),e[3]=b,e[4]=x):x=e[4];const f=x;let v,k;e[5]!==f.length||e[6]!==i?(v=()=>{if(f.length===0||i)return;const d=c.current;if(!d||typeof IntersectionObserver>"u"){p(!0);return}const T=new IntersectionObserver(X=>{X.some(ke)&&(p(!0),T.disconnect())},{rootMargin:"200px"});return T.observe(d),()=>T.disconnect()},k=[f.length,i],e[5]=f.length,e[6]=i,e[7]=v,e[8]=k):(v=e[7],k=e[8]),h.useEffect(v,k);let R;e[9]!==s||e[10]!==o||e[11]!==f||e[12]!==t||e[13]!==i?(R=()=>{if(!i||!t||f.length===0)return;const d=new AbortController;return de({sources:f,directory:s,sessionId:t,messageId:o,signal:d.signal}).then(T=>{d.signal.aborted||l(T)}).catch(()=>{d.signal.aborted||l(new Map(f.map(Re)))}),()=>d.abort()},e[9]=s,e[10]=o,e[11]=f,e[12]=t,e[13]=i,e[14]=R):R=e[14];let U;e[15]!==s||e[16]!==o||e[17]!==w||e[18]!==f||e[19]!==t||e[20]!==i?(U=[s,o,w,f,t,i],e[15]=s,e[16]=o,e[17]=w,e[18]=f,e[19]=t,e[20]=i,e[21]=U):U=e[21],h.useEffect(R,U);let j,A;e[22]!==m?(j=()=>{const d=Math.min(...[...m?.values()??[]].filter(_e).map(Se));if(!Number.isFinite(d))return;const T=setTimeout(()=>y(Me),Math.max(0,d-Date.now()));return()=>clearTimeout(T)},A=[m],e[22]=m,e[23]=j,e[24]=A):(j=e[23],A=e[24]),h.useEffect(j,A);let _;e[25]!==m?(_=d=>m?.get(d.source)?.status!=="missing",e[25]=m,e[26]=_):_=e[26];const S=b.filter(_),C=[...m?.values()??[]].some(Ne),M=be(C);if(S.length===0)return null;const N="mt-3 flex max-w-full gap-2 overflow-x-auto pb-1",E="true";let F;e[27]!==M||e[28]!==s||e[29]!==u||e[30]!==m?(F=d=>P.jsx(ye,{candidate:d,preparation:m?.get(d.source),directory:s,assetAuthReady:M.ready,assetAuthNonce:M.nonce,useWorkspaceFsBridge:g,onShowPopup:u},d.source),e[27]=M,e[28]=s,e[29]=u,e[30]=m,e[31]=F):F=e[31];const D=S.map(F);let O;return e[32]!==D?(O=P.jsx("div",{ref:c,className:N,"data-openchamber-markdown-image-gallery":E,children:D}),e[32]=D,e[33]=O):O=e[33],O};function Ie(r){return r+1}function Ee(r){return r.isIntersecting}function Ae(r){return{...r,status:"ready"}}function xe(r){return q(r.source)}function ve(r){return r.source}function ke(r){return r.isIntersecting}function Re(r){return[r,{status:"error"}]}function _e(r){return r.status==="ready"}function Se(r){return r.expiresAt??Number.POSITIVE_INFINITY}function Me(r){return r+1}function Ne(r){return r.status==="ready"}export{pr as MarkdownImageGallery};
@@ -1,4 +1,4 @@
1
- import{R as C,f as ae,j as re}from"./vendor-react-BUCujlKS.js";import{m as Ht}from"./vendor-morphdom-B7dS_VPB.js";import{r as Vt,a as Kt}from"./vendor-beautiful-mermaid-DztCUpLZ.js";import{gm as lt,gn as jt,go as Ut,gp as Zt,gq as Xt,g as we,bl as Gt,bo as Yt,gr as Jt,gs as Qt,Z as ct,af as dt,gt as ut,f as mt,h as pt,eL as en,eM as qe,gu as tn,gv as Be,gw as nn,gx as rn,gy as on,gz as sn,gA as an,o as ln}from"./useAppFontEffects-hfv2s6mZ.js";import{h as cn,O as ft,L as oe,cM as dn,u as Y,a as un,a$ as mn,E as pn,F as fn}from"./index-Dy8xgawx.js";import{getCachedMarkdownBlocks as $e,renderMarkdownSync as hn,renderMarkdownBlocks as gn}from"./markdownCore-DPrwM1rU.js";import{b as bn,r as wn}from"./textMateThemeFromAppTheme-Da7ed8qM.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-elkjs-BRwcR927.js";import"./vendor-entities-C3BA0AJP.js";import"./vendor-zod-fZppILAM.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-zustand-BAGL70zf.js";import"./vendor-base-ui-CsXYnR5c.js";import"./vendor-floating-ui-utils-D6FqdtJt.js";import"./vendor-floating-ui-react-dom-DxYCWdHj.js";import"./vendor-floating-ui-dom-BTvzWks8.js";import"./vendor-floating-ui-core-PuGzNPnN.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-framer-motion-Bq3iTZ6r.js";import"./vendor-motion-dom-DcCgeG69.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./vendor-tanstack-react-virtual-g05Cx3z9.js";import"./vendor-tanstack-virtual-core-Dubg10g5.js";import"./contextPanelEmbeddedChat-CirXEPJq.js";import"./vendor-sonner-DFyL3AvE.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-BgPj_McA.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-codemirror-state-C9awkmn-.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-codemirror-view-CiLROUVV.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-Cc2ZYbgX.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-codemirror-autocomplete-DzPz9Wgq.js";import"./vendor-codemirror-lang-json-CMBS2tG9.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-O0cZX78y.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-CfgK872x.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-BPGOH9ye.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-BPMJpOpT.js";import"./vendor-codemirror-lang-python-HahnQaAS.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-codemirror-commands-B7H_j0iU.js";import"./vendor-legendapp-list-BuBPBC3R.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-marked-linkify-it-CXI_LHIE.js";import"./vendor-linkify-it-DZCzzDkK.js";import"./vendor-uc.micro-BAd0H0z4.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 ht=t=>{const e=t.target;if(!(e instanceof Element))return null;const n=e.closest("a[href]");return!(n instanceof HTMLAnchorElement)||n.getAttribute("data-openchamber-file-link")==="true"?null:n},Ne=(t,e)=>{if(t.defaultPrevented)return!1;const r=ht(t)?.getAttribute("href")??"";return jt(r)?(t.preventDefault(),t.stopPropagation(),e?.(r),!0):!1},yn=t=>t.button===0&&!t.metaKey&&!t.ctrlKey&&!t.altKey&&!t.shiftKey,An=(t,e)=>{const n=o=>{if(Ne(o,e.openAppLink)||!e.allowExternalHttp||o.defaultPrevented||!yn(o))return;const i=ht(o)?.getAttribute("href")??"";lt(i)&&(o.preventDefault(),o.stopPropagation(),e.openExternalHttp(i))},r=o=>{o.button===1&&Ne(o,e.openAppLink)},s=o=>{Ne(o)};return t.addEventListener("click",n),t.addEventListener("auxclick",r),t.addEventListener("dragstart",s),()=>{t.removeEventListener("click",n),t.removeEventListener("auxclick",r),t.removeEventListener("dragstart",s)}},gt="openchamber-md",ye={background:"transparent",foreground:"var(--md-syntax-foreground)",comment:"var(--md-syntax-comment)",keyword:"var(--md-syntax-keyword)",string:"var(--md-syntax-string)",number:"var(--md-syntax-number)",function:"var(--md-syntax-function)",variable:"var(--md-syntax-variable)",type:"var(--md-syntax-type)",operator:"var(--md-syntax-operator)"},vn=Object.fromEntries(Object.keys(Ut({base:ye})).map(t=>[t,`var(--md-token-${t})`])),kn={name:gt,colors:{"editor.background":"transparent","editor.foreground":ye.foreground},tokenColors:[...bn({base:ye,tokens:vn}),{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:ye.keyword,fontStyle:"bold"}},{scope:["markup.inserted","punctuation.definition.inserted"],settings:{foreground:"var(--md-syntax-inserted)"}},{scope:["markup.deleted","punctuation.definition.deleted","invalid","invalid.illegal"],settings:{foreground:"var(--md-syntax-deleted)"}}]};let ze=!1;const Cn=()=>{ze||(ze=!0,wn(gt,()=>Promise.resolve(kn)))},T=t=>Number.isFinite(t)&&t>0,He=t=>{if(t==null)return null;const e=String(t).trim().match(/^([+-]?(?:(?:\d+\.?\d*)|(?:\.\d+))(?:[eE][+-]?\d+)?)(?:px)?$/);if(!e)return null;const n=Number(e[1]);return T(n)?n:null},Re=(t,e,n)=>Math.min(n,Math.max(e,t)),En=6,Ve=1.25,Sn=1.0015,Ln=.5,Mn=12,Ke=3,Nn=400,se='[data-markdown="mermaid-block"]',F=t=>t.querySelector(se)!==null,Rn=t=>[t.x,t.y,t.width,t.height].map(e=>{const n=Number(e.toFixed(En));return Object.is(n,-0)?"0":String(n)}).join(" "),Tn=t=>{const e=t.viewBox?.trim().split(/[\s,]+/).map(s=>Number.parseFloat(s));if(e?.length===4){const[s,o,i,a]=e;if(Number.isFinite(s)&&Number.isFinite(o)&&T(i)&&T(a))return{x:s,y:o,width:i,height:a}}const n=He(t.width),r=He(t.height);return n===null||r===null?null:{x:0,y:0,width:n,height:r}},_n=t=>{let e=2166136261;for(let n=0;n<t.length;n+=1)e^=t.charCodeAt(n),e=Math.imul(e,16777619);return(e>>>0).toString(36)},xn=t=>{const e=t.renderMode||"unknown",n=t.svgMarkup??"";if(!n){const r=[t.viewBox??"",t.width??"",t.height??""];return r.some(s=>s!=="")?`${e}:bounds:${r.join(":")}`:`${e}:no-svg`}return[e,_n(n)].join(":")},bt=(t,e)=>{if(!T(e.width)||!T(e.height))return t;const n=t.width/t.height,r=e.width/e.height;if(n>r){const o=t.width/r;return{x:t.x,y:t.y-(o-t.height)/2,width:t.width,height:o}}const s=t.height*r;return{x:t.x-(s-t.width)/2,y:t.y,width:s,height:t.height}},Pn=({currentBox:t,viewport:e,delta:n})=>!T(e.width)||!T(e.height)||!T(t.width)||!T(t.height)?t:{x:t.x-n.x/e.width*t.width,y:t.y-n.y/e.height*t.height,width:t.width,height:t.height},In=(t,e)=>{const n=e.x-t.x,r=e.y-t.y;return n*n+r*r>Ke*Ke},Fn=({currentBox:t,contentBox:e,viewport:n,pointer:r,zoomFactor:s,minScale:o,maxScale:i})=>{if(!T(n.width)||!T(n.height)||!T(s)||!T(t.width)||!T(t.height)||!T(e.width)||!T(e.height)||!T(o)||!T(i))return t;const a=Math.min(o,i),l=Math.max(o,i),c=bt(e,n),u=c.width/t.width,f=Re(u*s,a,l),m=c.width/f,g=m/(t.width/t.height),y=Re(r.x/n.width,0,1),v=Re(r.y/n.height,0,1),S=t.x+y*t.width,p=t.y+v*t.height;return{x:S-y*m,y:p-v*g,width:m,height:g}},Ae=new WeakMap,Fe=new WeakMap,j=new Set,ie=new Set;let K=null,ne=null,Q=null;const Dn=t=>t.querySelector('[data-markdown="mermaid-viewport"]')??t.querySelector('[data-markdown="mermaid"]'),wt=t=>{const e=t.querySelector('[data-markdown="mermaid"] svg'),n=t.querySelector('[data-markdown="mermaid"]');return xn({renderMode:t.getAttribute("data-mermaid-render"),svgMarkup:n?.getAttribute("data-md-original-svg")??e?.outerHTML??null,viewBox:e?.getAttribute("viewBox"),width:e?.getAttribute("width"),height:e?.getAttribute("height")})},G=t=>{const e=t.getBoundingClientRect();return{width:e.width,height:e.height}},On=(t,e)=>{const n=e.getBoundingClientRect();return{x:t.clientX-n.left,y:t.clientY-n.top}},Wn=t=>t instanceof Element&&!!t.closest('button, a, [role="button"]'),yt=t=>{const e=t.map(n=>G(n.viewport));t.forEach((n,r)=>{const s=e[r];s&&n.fitToViewport(s)})},At=()=>{Q!==null||j.size===0||(Q=window.requestAnimationFrame(()=>{Q=null,yt(Array.from(j))}))},qn=()=>{if(K)return K;const t=globalThis.ResizeObserver;return t?(K=new t(e=>{for(const n of e)n.target instanceof HTMLElement&&Fe.get(n.target)?.fitToViewport({width:n.contentRect.width,height:n.contentRect.height})}),K):null},Bn=t=>{if(j.has(t))return;const e=j.size===0;j.add(t),Fe.set(t.viewport,t),qn()?.observe(t.viewport),e&&window.addEventListener("resize",At)},$n=t=>{j.delete(t)&&(K?.unobserve(t.viewport),Fe.delete(t.viewport),!(j.size>0)&&(K?.disconnect(),K=null,window.removeEventListener("resize",At),Q!==null&&(window.cancelAnimationFrame(Q),Q=null)))},zn=t=>{const e=Dn(t),n=t.querySelector('[data-markdown="mermaid"] svg');if(!e||!n)return null;const r=Tn({viewBox:n.getAttribute("viewBox"),width:n.getAttribute("width"),height:n.getAttribute("height")});if(!r)return null;let s=r,o=null,i=null,a=null,l=null;const c=d=>{s=d,n.setAttribute("viewBox",Rn(d)),n.removeAttribute("width"),n.removeAttribute("height")},u=d=>{c(bt(r,d))},f=()=>{u(G(e))},m=(d,b)=>{c(Fn({currentBox:s,contentBox:r,viewport:G(e),pointer:d,zoomFactor:b,minScale:Ln,maxScale:Mn}))},g=()=>{const d=G(e);m({x:d.width/2,y:d.height/2},Ve)},y=()=>{const d=G(e);m({x:d.width/2,y:d.height/2},1/Ve)},v=d=>{!d.ctrlKey&&!d.metaKey||(d.preventDefault(),d.stopPropagation(),m(On(d,e),Math.pow(Sn,-d.deltaY)))},S=d=>{d.button!==0||Wn(d.target)||(o=d.pointerId,i={x:d.clientX,y:d.clientY},a=i,l!==null&&(window.clearTimeout(l),l=null),t.removeAttribute("data-mermaid-suppress-click"),e.setPointerCapture?.(d.pointerId),t.setAttribute("data-mermaid-panning","true"),d.preventDefault())},p=d=>{if(o!==d.pointerId||!a)return;const b={x:d.clientX,y:d.clientY};c(Pn({currentBox:s,viewport:G(e),delta:{x:b.x-a.x,y:b.y-a.y}})),a=b,i&&In(i,b)&&t.setAttribute("data-mermaid-suppress-click","true"),d.preventDefault()},h=d=>{o===d.pointerId&&(e.releasePointerCapture?.(d.pointerId),o=null,i=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},Nn)))};e.addEventListener("wheel",v,{passive:!1}),e.addEventListener("pointerdown",S),e.addEventListener("pointermove",p),e.addEventListener("pointerup",h),e.addEventListener("pointercancel",h);const k={viewport:e,zoomIn:g,zoomOut:y,fit:f,fitToViewport:u,cleanup:()=>{$n(k),e.removeEventListener("wheel",v),e.removeEventListener("pointerdown",S),e.removeEventListener("pointermove",p),e.removeEventListener("pointerup",h),e.removeEventListener("pointercancel",h),l!==null&&window.clearTimeout(l),t.removeAttribute("data-mermaid-panning"),t.removeAttribute("data-mermaid-suppress-click"),Ae.delete(t)}};return k},vt=t=>{for(const[e,n]of t.controllers){const r=wt(e);(!t.container.contains(e)||r!==t.signatures.get(e))&&(n.cleanup(),t.controllers.delete(e),t.signatures.delete(e))}},Hn=t=>{if(t.disposed)return[];const e=[];for(const n of Array.from(t.container.querySelectorAll(se))){if(t.controllers.has(n)||n.querySelector('[data-markdown="mermaid"] svg')===null)continue;const r=zn(n);r&&(t.controllers.set(n,r),t.signatures.set(n,wt(n)),Ae.set(n,r),e.push(r))}return e},kt=()=>{const t=Array.from(ie);ie.clear();const e=[];for(const n of t)n.disposed||(vt(n),e.push(...Hn(n)));yt(e);for(const n of e)Bn(n)},Vn=()=>{ne===null&&(ne=window.requestAnimationFrame(()=>{ne=null,ne=window.requestAnimationFrame(()=>{ne=null,kt()})}))},Kn=t=>{t.disposed||(vt(t),ie.add(t),Vn())},jn=t=>{if(!(t instanceof HTMLElement))return null;const e=Ae.get(t);if(e)return e;for(const n of ie)if(n.container.contains(t))return kt(),Ae.get(t)??null;return null},Un=t=>{const e={container:t,controllers:new Map,signatures:new Map,disposed:!1},n=()=>Kn(e),r=()=>{e.disposed=!0,ie.delete(e);for(const s of e.controllers.values())s.cleanup();e.controllers.clear(),e.signatures.clear()};return n(),{refresh:n,cleanup:r}},Zn={copy:"file-copy",check:"check",download:"download",zoomIn:"add",zoomOut:"subtract",fit:"refresh",textWrap:"text-wrap",image:"file-image",disclosure:"arrow-right-s"},Ct="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)]",ee=(t,e)=>{const n=Zn[e],r=t.ownerDocument.createElementNS("http://www.w3.org/2000/svg","svg");r.setAttribute("class","remixicon size-3.5"),r.setAttribute("viewBox","0 0 24 24"),r.setAttribute("aria-hidden","true");const s=t.ownerDocument.createElementNS("http://www.w3.org/2000/svg","use");s.setAttribute("href",`#oc-${n}`),r.appendChild(s),t.replaceChildren(r)},Xn=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 n=document.createElement("span");n.className="inline-flex shrink-0",n.setAttribute("aria-hidden","true"),n.setAttribute("data-openchamber-markdown-image-label-icon","true"),ee(n,"image"),e.prepend(n)}},Gn=t=>{for(const e of t.querySelectorAll("details[data-md-details] > summary")){if(e.querySelector("[data-md-disclosure-icon]"))continue;const n=document.createElement("span");n.append(...Array.from(e.childNodes));const r=document.createElement("span");r.setAttribute("data-md-disclosure-icon",""),r.setAttribute("aria-hidden","true"),ee(r,"disclosure"),e.append(r,n)}},B=(t,e,n)=>{const r=document.createElement("button");return r.type="button",r.className=Ct,r.setAttribute("data-md-action",n),r.setAttribute("title",e),r.setAttribute("aria-label",e),ee(r,t),r},Et=(t,e,n)=>{const r=t.querySelector("[data-md-code-body]"),s=t.querySelector("pre"),o=t.querySelector("pre code"),i=t.querySelectorAll("[data-md-code-line-content]"),a=t.querySelector('[data-md-action="toggle-code-wrap"]');t.setAttribute("data-code-wrap",e?"true":"false"),r?.classList.toggle("overflow-x-auto",!e),r?.classList.toggle("overflow-x-hidden",e),s?.classList.toggle("whitespace-pre-wrap",e),s?.classList.toggle("break-words",e),o?.classList.toggle("whitespace-pre-wrap",e),o?.classList.toggle("break-words",e),s&&(s.style.whiteSpace=e?"pre-wrap":"pre",s.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(i))l.style.whiteSpace=e?"pre-wrap":"pre",l.style.overflowWrap=e?"anywhere":"normal";if(a){const l=e?n.disableCodeWrap:n.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")}},St=t=>{const e=t.querySelector(":scope > code");if(!e||e.hasAttribute("data-md-code-lines"))return;t.removeAttribute("data-md-gutter-reserved");const n=e.textContent??"",r=n.endsWith(`
1
+ import{R as C,f as ae,j as re}from"./vendor-react-BUCujlKS.js";import{m as Ht}from"./vendor-morphdom-B7dS_VPB.js";import{r as Vt,a as Kt}from"./vendor-beautiful-mermaid-DztCUpLZ.js";import{gq as lt,gr as jt,gs as Ut,gt as Zt,gu as Xt,g as we,bm as Gt,bp as Yt,gv as Jt,gw as Qt,Z as ct,af as dt,gx as ut,f as mt,h as pt,eL as en,eM as qe,gy as tn,gz as Be,gA as nn,gB as rn,gC as on,gD as sn,gE as an,o as ln}from"./useAppFontEffects-BItUWdo4.js";import{h as cn,O as ft,L as oe,cM as dn,u as Y,a as un,a$ as mn,E as pn,F as fn}from"./index-DLHQogv8.js";import{getCachedMarkdownBlocks as $e,renderMarkdownSync as hn,renderMarkdownBlocks as gn}from"./markdownCore-DHvqMxPn.js";import{b as bn,r as wn}from"./textMateThemeFromAppTheme-Dgqc63LZ.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-elkjs-BRwcR927.js";import"./vendor-entities-C3BA0AJP.js";import"./vendor-zod-fZppILAM.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-zustand-BAGL70zf.js";import"./vendor-base-ui-CsXYnR5c.js";import"./vendor-floating-ui-utils-D6FqdtJt.js";import"./vendor-floating-ui-react-dom-DxYCWdHj.js";import"./vendor-floating-ui-dom-BTvzWks8.js";import"./vendor-floating-ui-core-PuGzNPnN.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-framer-motion-Bq3iTZ6r.js";import"./vendor-motion-dom-DcCgeG69.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./vendor-tanstack-react-virtual-ClYN8CzB.js";import"./vendor-tanstack-virtual-core-BewVQryB.js";import"./contextPanelEmbeddedChat-CirXEPJq.js";import"./vendor-sonner-DFyL3AvE.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-BgPj_McA.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-codemirror-state-C9awkmn-.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-codemirror-view-CiLROUVV.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-Cc2ZYbgX.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-codemirror-autocomplete-DzPz9Wgq.js";import"./vendor-codemirror-lang-json-CMBS2tG9.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-O0cZX78y.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-CfgK872x.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-BPGOH9ye.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-BDyxuqK4.js";import"./vendor-codemirror-lang-python-HahnQaAS.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-codemirror-commands-B7H_j0iU.js";import"./vendor-legendapp-list-BuBPBC3R.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-marked-linkify-it-CXI_LHIE.js";import"./vendor-linkify-it-DZCzzDkK.js";import"./vendor-uc.micro-BAd0H0z4.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 ht=t=>{const e=t.target;if(!(e instanceof Element))return null;const n=e.closest("a[href]");return!(n instanceof HTMLAnchorElement)||n.getAttribute("data-openchamber-file-link")==="true"?null:n},Ne=(t,e)=>{if(t.defaultPrevented)return!1;const r=ht(t)?.getAttribute("href")??"";return jt(r)?(t.preventDefault(),t.stopPropagation(),e?.(r),!0):!1},yn=t=>t.button===0&&!t.metaKey&&!t.ctrlKey&&!t.altKey&&!t.shiftKey,An=(t,e)=>{const n=o=>{if(Ne(o,e.openAppLink)||!e.allowExternalHttp||o.defaultPrevented||!yn(o))return;const i=ht(o)?.getAttribute("href")??"";lt(i)&&(o.preventDefault(),o.stopPropagation(),e.openExternalHttp(i))},r=o=>{o.button===1&&Ne(o,e.openAppLink)},s=o=>{Ne(o)};return t.addEventListener("click",n),t.addEventListener("auxclick",r),t.addEventListener("dragstart",s),()=>{t.removeEventListener("click",n),t.removeEventListener("auxclick",r),t.removeEventListener("dragstart",s)}},gt="openchamber-md",ye={background:"transparent",foreground:"var(--md-syntax-foreground)",comment:"var(--md-syntax-comment)",keyword:"var(--md-syntax-keyword)",string:"var(--md-syntax-string)",number:"var(--md-syntax-number)",function:"var(--md-syntax-function)",variable:"var(--md-syntax-variable)",type:"var(--md-syntax-type)",operator:"var(--md-syntax-operator)"},vn=Object.fromEntries(Object.keys(Ut({base:ye})).map(t=>[t,`var(--md-token-${t})`])),kn={name:gt,colors:{"editor.background":"transparent","editor.foreground":ye.foreground},tokenColors:[...bn({base:ye,tokens:vn}),{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:ye.keyword,fontStyle:"bold"}},{scope:["markup.inserted","punctuation.definition.inserted"],settings:{foreground:"var(--md-syntax-inserted)"}},{scope:["markup.deleted","punctuation.definition.deleted","invalid","invalid.illegal"],settings:{foreground:"var(--md-syntax-deleted)"}}]};let ze=!1;const Cn=()=>{ze||(ze=!0,wn(gt,()=>Promise.resolve(kn)))},T=t=>Number.isFinite(t)&&t>0,He=t=>{if(t==null)return null;const e=String(t).trim().match(/^([+-]?(?:(?:\d+\.?\d*)|(?:\.\d+))(?:[eE][+-]?\d+)?)(?:px)?$/);if(!e)return null;const n=Number(e[1]);return T(n)?n:null},Re=(t,e,n)=>Math.min(n,Math.max(e,t)),En=6,Ve=1.25,Sn=1.0015,Ln=.5,Mn=12,Ke=3,Nn=400,se='[data-markdown="mermaid-block"]',F=t=>t.querySelector(se)!==null,Rn=t=>[t.x,t.y,t.width,t.height].map(e=>{const n=Number(e.toFixed(En));return Object.is(n,-0)?"0":String(n)}).join(" "),Tn=t=>{const e=t.viewBox?.trim().split(/[\s,]+/).map(s=>Number.parseFloat(s));if(e?.length===4){const[s,o,i,a]=e;if(Number.isFinite(s)&&Number.isFinite(o)&&T(i)&&T(a))return{x:s,y:o,width:i,height:a}}const n=He(t.width),r=He(t.height);return n===null||r===null?null:{x:0,y:0,width:n,height:r}},_n=t=>{let e=2166136261;for(let n=0;n<t.length;n+=1)e^=t.charCodeAt(n),e=Math.imul(e,16777619);return(e>>>0).toString(36)},xn=t=>{const e=t.renderMode||"unknown",n=t.svgMarkup??"";if(!n){const r=[t.viewBox??"",t.width??"",t.height??""];return r.some(s=>s!=="")?`${e}:bounds:${r.join(":")}`:`${e}:no-svg`}return[e,_n(n)].join(":")},bt=(t,e)=>{if(!T(e.width)||!T(e.height))return t;const n=t.width/t.height,r=e.width/e.height;if(n>r){const o=t.width/r;return{x:t.x,y:t.y-(o-t.height)/2,width:t.width,height:o}}const s=t.height*r;return{x:t.x-(s-t.width)/2,y:t.y,width:s,height:t.height}},Pn=({currentBox:t,viewport:e,delta:n})=>!T(e.width)||!T(e.height)||!T(t.width)||!T(t.height)?t:{x:t.x-n.x/e.width*t.width,y:t.y-n.y/e.height*t.height,width:t.width,height:t.height},In=(t,e)=>{const n=e.x-t.x,r=e.y-t.y;return n*n+r*r>Ke*Ke},Fn=({currentBox:t,contentBox:e,viewport:n,pointer:r,zoomFactor:s,minScale:o,maxScale:i})=>{if(!T(n.width)||!T(n.height)||!T(s)||!T(t.width)||!T(t.height)||!T(e.width)||!T(e.height)||!T(o)||!T(i))return t;const a=Math.min(o,i),l=Math.max(o,i),c=bt(e,n),u=c.width/t.width,f=Re(u*s,a,l),m=c.width/f,g=m/(t.width/t.height),y=Re(r.x/n.width,0,1),v=Re(r.y/n.height,0,1),S=t.x+y*t.width,p=t.y+v*t.height;return{x:S-y*m,y:p-v*g,width:m,height:g}},Ae=new WeakMap,Fe=new WeakMap,j=new Set,ie=new Set;let K=null,ne=null,Q=null;const Dn=t=>t.querySelector('[data-markdown="mermaid-viewport"]')??t.querySelector('[data-markdown="mermaid"]'),wt=t=>{const e=t.querySelector('[data-markdown="mermaid"] svg'),n=t.querySelector('[data-markdown="mermaid"]');return xn({renderMode:t.getAttribute("data-mermaid-render"),svgMarkup:n?.getAttribute("data-md-original-svg")??e?.outerHTML??null,viewBox:e?.getAttribute("viewBox"),width:e?.getAttribute("width"),height:e?.getAttribute("height")})},G=t=>{const e=t.getBoundingClientRect();return{width:e.width,height:e.height}},On=(t,e)=>{const n=e.getBoundingClientRect();return{x:t.clientX-n.left,y:t.clientY-n.top}},Wn=t=>t instanceof Element&&!!t.closest('button, a, [role="button"]'),yt=t=>{const e=t.map(n=>G(n.viewport));t.forEach((n,r)=>{const s=e[r];s&&n.fitToViewport(s)})},At=()=>{Q!==null||j.size===0||(Q=window.requestAnimationFrame(()=>{Q=null,yt(Array.from(j))}))},qn=()=>{if(K)return K;const t=globalThis.ResizeObserver;return t?(K=new t(e=>{for(const n of e)n.target instanceof HTMLElement&&Fe.get(n.target)?.fitToViewport({width:n.contentRect.width,height:n.contentRect.height})}),K):null},Bn=t=>{if(j.has(t))return;const e=j.size===0;j.add(t),Fe.set(t.viewport,t),qn()?.observe(t.viewport),e&&window.addEventListener("resize",At)},$n=t=>{j.delete(t)&&(K?.unobserve(t.viewport),Fe.delete(t.viewport),!(j.size>0)&&(K?.disconnect(),K=null,window.removeEventListener("resize",At),Q!==null&&(window.cancelAnimationFrame(Q),Q=null)))},zn=t=>{const e=Dn(t),n=t.querySelector('[data-markdown="mermaid"] svg');if(!e||!n)return null;const r=Tn({viewBox:n.getAttribute("viewBox"),width:n.getAttribute("width"),height:n.getAttribute("height")});if(!r)return null;let s=r,o=null,i=null,a=null,l=null;const c=d=>{s=d,n.setAttribute("viewBox",Rn(d)),n.removeAttribute("width"),n.removeAttribute("height")},u=d=>{c(bt(r,d))},f=()=>{u(G(e))},m=(d,b)=>{c(Fn({currentBox:s,contentBox:r,viewport:G(e),pointer:d,zoomFactor:b,minScale:Ln,maxScale:Mn}))},g=()=>{const d=G(e);m({x:d.width/2,y:d.height/2},Ve)},y=()=>{const d=G(e);m({x:d.width/2,y:d.height/2},1/Ve)},v=d=>{!d.ctrlKey&&!d.metaKey||(d.preventDefault(),d.stopPropagation(),m(On(d,e),Math.pow(Sn,-d.deltaY)))},S=d=>{d.button!==0||Wn(d.target)||(o=d.pointerId,i={x:d.clientX,y:d.clientY},a=i,l!==null&&(window.clearTimeout(l),l=null),t.removeAttribute("data-mermaid-suppress-click"),e.setPointerCapture?.(d.pointerId),t.setAttribute("data-mermaid-panning","true"),d.preventDefault())},p=d=>{if(o!==d.pointerId||!a)return;const b={x:d.clientX,y:d.clientY};c(Pn({currentBox:s,viewport:G(e),delta:{x:b.x-a.x,y:b.y-a.y}})),a=b,i&&In(i,b)&&t.setAttribute("data-mermaid-suppress-click","true"),d.preventDefault()},h=d=>{o===d.pointerId&&(e.releasePointerCapture?.(d.pointerId),o=null,i=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},Nn)))};e.addEventListener("wheel",v,{passive:!1}),e.addEventListener("pointerdown",S),e.addEventListener("pointermove",p),e.addEventListener("pointerup",h),e.addEventListener("pointercancel",h);const k={viewport:e,zoomIn:g,zoomOut:y,fit:f,fitToViewport:u,cleanup:()=>{$n(k),e.removeEventListener("wheel",v),e.removeEventListener("pointerdown",S),e.removeEventListener("pointermove",p),e.removeEventListener("pointerup",h),e.removeEventListener("pointercancel",h),l!==null&&window.clearTimeout(l),t.removeAttribute("data-mermaid-panning"),t.removeAttribute("data-mermaid-suppress-click"),Ae.delete(t)}};return k},vt=t=>{for(const[e,n]of t.controllers){const r=wt(e);(!t.container.contains(e)||r!==t.signatures.get(e))&&(n.cleanup(),t.controllers.delete(e),t.signatures.delete(e))}},Hn=t=>{if(t.disposed)return[];const e=[];for(const n of Array.from(t.container.querySelectorAll(se))){if(t.controllers.has(n)||n.querySelector('[data-markdown="mermaid"] svg')===null)continue;const r=zn(n);r&&(t.controllers.set(n,r),t.signatures.set(n,wt(n)),Ae.set(n,r),e.push(r))}return e},kt=()=>{const t=Array.from(ie);ie.clear();const e=[];for(const n of t)n.disposed||(vt(n),e.push(...Hn(n)));yt(e);for(const n of e)Bn(n)},Vn=()=>{ne===null&&(ne=window.requestAnimationFrame(()=>{ne=null,ne=window.requestAnimationFrame(()=>{ne=null,kt()})}))},Kn=t=>{t.disposed||(vt(t),ie.add(t),Vn())},jn=t=>{if(!(t instanceof HTMLElement))return null;const e=Ae.get(t);if(e)return e;for(const n of ie)if(n.container.contains(t))return kt(),Ae.get(t)??null;return null},Un=t=>{const e={container:t,controllers:new Map,signatures:new Map,disposed:!1},n=()=>Kn(e),r=()=>{e.disposed=!0,ie.delete(e);for(const s of e.controllers.values())s.cleanup();e.controllers.clear(),e.signatures.clear()};return n(),{refresh:n,cleanup:r}},Zn={copy:"file-copy",check:"check",download:"download",zoomIn:"add",zoomOut:"subtract",fit:"refresh",textWrap:"text-wrap",image:"file-image",disclosure:"arrow-right-s"},Ct="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)]",ee=(t,e)=>{const n=Zn[e],r=t.ownerDocument.createElementNS("http://www.w3.org/2000/svg","svg");r.setAttribute("class","remixicon size-3.5"),r.setAttribute("viewBox","0 0 24 24"),r.setAttribute("aria-hidden","true");const s=t.ownerDocument.createElementNS("http://www.w3.org/2000/svg","use");s.setAttribute("href",`#oc-${n}`),r.appendChild(s),t.replaceChildren(r)},Xn=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 n=document.createElement("span");n.className="inline-flex shrink-0",n.setAttribute("aria-hidden","true"),n.setAttribute("data-openchamber-markdown-image-label-icon","true"),ee(n,"image"),e.prepend(n)}},Gn=t=>{for(const e of t.querySelectorAll("details[data-md-details] > summary")){if(e.querySelector("[data-md-disclosure-icon]"))continue;const n=document.createElement("span");n.append(...Array.from(e.childNodes));const r=document.createElement("span");r.setAttribute("data-md-disclosure-icon",""),r.setAttribute("aria-hidden","true"),ee(r,"disclosure"),e.append(r,n)}},B=(t,e,n)=>{const r=document.createElement("button");return r.type="button",r.className=Ct,r.setAttribute("data-md-action",n),r.setAttribute("title",e),r.setAttribute("aria-label",e),ee(r,t),r},Et=(t,e,n)=>{const r=t.querySelector("[data-md-code-body]"),s=t.querySelector("pre"),o=t.querySelector("pre code"),i=t.querySelectorAll("[data-md-code-line-content]"),a=t.querySelector('[data-md-action="toggle-code-wrap"]');t.setAttribute("data-code-wrap",e?"true":"false"),r?.classList.toggle("overflow-x-auto",!e),r?.classList.toggle("overflow-x-hidden",e),s?.classList.toggle("whitespace-pre-wrap",e),s?.classList.toggle("break-words",e),o?.classList.toggle("whitespace-pre-wrap",e),o?.classList.toggle("break-words",e),s&&(s.style.whiteSpace=e?"pre-wrap":"pre",s.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(i))l.style.whiteSpace=e?"pre-wrap":"pre",l.style.overflowWrap=e?"anywhere":"normal";if(a){const l=e?n.disableCodeWrap:n.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")}},St=t=>{const e=t.querySelector(":scope > code");if(!e||e.hasAttribute("data-md-code-lines"))return;t.removeAttribute("data-md-gutter-reserved");const n=e.textContent??"",r=n.endsWith(`
2
2
  `),s=r?n.slice(0,-1).split(`
3
3
  `):n.split(`
4
4
  `),o=s.length>0?s:[""],i=Array.from(e.children).filter(c=>c.classList.contains("line"));r&&i.length===o.length+1&&i.at(-1)?.textContent===""&&i.pop();const a=i.length===o.length,l=document.createDocumentFragment();o.forEach((c,u)=>{const f=document.createElement("span");f.setAttribute("data-md-code-line","");const m=document.createElement("span");m.setAttribute("data-md-code-line-number",String(u+1)),m.setAttribute("aria-hidden","true");const g=document.createElement("span");if(g.setAttribute("data-md-code-line-content",""),a){const y=i[u];y&&g.append(...Array.from(y.childNodes))}else g.textContent=c;if(f.append(m,g),l.appendChild(f),u<o.length-1||r){const y=document.createElement("span");y.setAttribute("data-md-code-line-break",""),y.textContent=`
@@ -1 +1 @@
1
- import{r as D,j as e,R as i,f as G}from"./vendor-react-BUCujlKS.js";import{P as W,cD as je,cA as le,cw as z,E as B,az as O,dP as ke,aF as ue,X as me,h as X,aK as pe,t as he,U as ne}from"./index-Dy8xgawx.js";import{f as J,B as L,W as V,g as xe,h as re,I as A}from"./useAppFontEffects-hfv2s6mZ.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-zod-fZppILAM.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-zustand-BAGL70zf.js";import"./vendor-opencode-sdk-BJ73u-bH.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-base-ui-CsXYnR5c.js";import"./vendor-floating-ui-utils-D6FqdtJt.js";import"./vendor-floating-ui-react-dom-DxYCWdHj.js";import"./vendor-floating-ui-dom-BTvzWks8.js";import"./vendor-floating-ui-core-PuGzNPnN.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-framer-motion-Bq3iTZ6r.js";import"./vendor-motion-dom-DcCgeG69.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./vendor-tanstack-react-virtual-g05Cx3z9.js";import"./vendor-tanstack-virtual-core-Dubg10g5.js";import"./contextPanelEmbeddedChat-CirXEPJq.js";import"./vendor-sonner-DFyL3AvE.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-BgPj_McA.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-codemirror-state-C9awkmn-.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-codemirror-view-CiLROUVV.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-Cc2ZYbgX.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-codemirror-autocomplete-DzPz9Wgq.js";import"./vendor-codemirror-lang-json-CMBS2tG9.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-O0cZX78y.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-CfgK872x.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-BPGOH9ye.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-BPMJpOpT.js";import"./vendor-codemirror-lang-python-HahnQaAS.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-codemirror-commands-B7H_j0iU.js";import"./vendor-legendapp-list-BuBPBC3R.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";function Ce(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 fe({onBack:a,showBackButton:t=!0,initialUrl:s="",initialLabel:r="",isRecoveryMode:n=!1,onConnect:l,onSwitchToLocal:d,showInstancePicker:h=!1}){const{t:o}=J(),[w,S]=D.useState(s),[j,U]=D.useState(r),[K,x]=D.useState("idle"),[u,k]=D.useState(null),[C,g]=D.useState(""),[T,I]=D.useState([]),[y,f]=D.useState(()=>h?"instances":"add"),[b,R]=D.useState("");D.useEffect(()=>{h&&W().then(p=>I(p.hosts)).catch(p=>{g(p instanceof Error?p.message:String(p))})},[h]);const N=je(w),E=N?.persistedUrl??null,F=D.useCallback(p=>{S(p.target.value),x("idle"),k(null),g("")},[]),H=D.useCallback(p=>{U(p.target.value)},[]),c=D.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 P=await le(p);if(k(P),oe(P.status)){x("error");return}const Z=await W(),ve=j.trim()||p,ee=Z.hosts.find(q=>q.url===p),te=ee?ee.id:`host-${Date.now().toString(16)}`,ie={id:te,label:ve,url:p,apiUrl:p},we=ee?Z.hosts.map(q=>q.id===te?ie:q):[...Z.hosts,ie];if(await z({hosts:we,defaultHostId:te,initialHostChoiceCompleted:!0}),l?.(),N.redeemUrl){window.location.assign(N.redeemUrl);return}B()&&await O()}catch(P){g(P instanceof Error?P.message:o("onboarding.remoteConnection.errors.failedToSaveConnection")),x("error")}},[N,j,l,o]),$=D.useCallback(async p=>{const P=await W();await z({hosts:P.hosts,defaultHostId:p,initialHostChoiceCompleted:!0}),await O()},[]),m=D.useCallback(async()=>{x("testing"),g("");try{const p=await W(),P=await ke(b,p.hosts);await z({hosts:P.hosts,defaultHostId:P.hostId,initialHostChoiceCompleted:!0}),await O()}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,Q=E!==null&&!v&&!oe(u?.status??null),Y=Ce(u?.status??null),be=u?.status==="ok",ge=u?.status==="update-recommended",ye=u?.status==="auth",ae=oe(u?.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:()=>{$(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(V,{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:()=>{m()},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(V,{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(V,{id:"remote-label",type:"text",value:j,onChange:H,placeholder:o("onboarding.remoteConnection.field.namePlaceholder"),disabled:v})]})]}),u&&be&&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:u.latencyMs})}),u&&ye&&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")}),u&&ge&&e.jsx("div",{className:"rounded-lg border p-3 text-sm",style:{borderColor:"var(--status-warning)",color:"var(--status-warning)"},children:Y?o(Y):null}),u&&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:Y?o(Y):null})]}),e.jsx("div",{className:"text-xs opacity-80",children:u.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:_,disabled:!Q,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&&d&&e.jsx(L,{variant:"outline",size:"sm",onClick:d,className:"flex-1",children:o("onboarding.remoteConnection.actions.useLocalInstead")})]})]})]})})}const Ne="curl -fsSL https://opencode.ai/install | bash",Se="https://opencode.ai/docs",ce=2500;function Re(a){const t=G.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 d;return t[2]!==r||t[3]!==s?(d=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]=d):d=t[4],d}function Le({onCliAvailable:a,localAvailable:t=!0}){const{t:s}=J(),[r,n]=i.useState(!1),[l,d]=i.useState(!1),[h,o]=i.useState(!1),[w,S]=i.useState(!1),[j,U]=i.useState(""),[K,x]=i.useState("unknown"),[u,k]=i.useState(()=>t?"local":"remote"),[C,g]=i.useState(!1),[T,I]=i.useState(!1);i.useEffect(()=>{d(B())},[]),i.useEffect(()=>{if(typeof navigator>"u"){x("unknown");return}const m=navigator.userAgent||"";/Windows/i.test(m)?x("windows"):/Macintosh|Mac OS X/i.test(m)?x("macos"):/Linux/i.test(m)?x("linux"):x("unknown")},[]),i.useEffect(()=>{let m=!1;return(async()=>{try{const v=await ue();if(!v||m)return;const M=v.opencodeBinary??"";M&&U(M)}catch{}})(),()=>{m=!0}},[]);const y=i.useCallback(async m=>{const v=m.target;v.closest(".app-region-no-drag")||v.closest("button, a, input, select, textarea, code, summary, details")||m.button===0&&l&&await me()},[l]),f=i.useCallback(async()=>{try{const m=await X("/health");if(!m.ok)return!1;const v=await m.json();return v.openCodeRunning===!0||v.isOpenCodeReady===!0}catch{return!1}},[]),b=i.useCallback(async m=>{if(!l)return;const v=await W();await z({...v,...m==="local"?{defaultHostId:"local"}:{},initialHostChoiceCompleted:!0})},[l]),R=i.useCallback(async()=>{l&&await b("local"),a?.()},[l,a,b]);i.useEffect(()=>{if(!t||u!=="local")return;let m=!1,v=null;const M=async()=>{if(!m){try{const Q=await f();if(m)return;if(Q){await R();return}}catch{}m||(v=setTimeout(M,ce))}};return v=setTimeout(M,ce),()=>{m=!0,v&&clearTimeout(v)}},[u,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 m=await pe();m.success&&m.path&&m.path.trim().length>0&&U(m.path.trim())}catch{}},[l]),F=i.useCallback(async()=>{o(!0);try{if(await he({opencodeBinary:j.trim()}),l){await b("local"),await O();return}await X("/api/config/reload",{method:"POST"})}finally{setTimeout(()=>o(!1),1e3)}},[l,j,b]),H=i.useCallback(async()=>{const m=await xe(Ne);m.ok?(n(!0),setTimeout(()=>n(!1),2e3)):console.error("Failed to copy:",m.error)},[]),c=Se,_=K==="windows"?"C:\\Users\\you\\AppData\\Roaming\\npm\\opencode.cmd":K==="linux"?"/home/you/.bun/bin/opencode":"/Users/you/.bun/bin/opencode",$=t&&(!l||u==="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",u==="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",u==="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&&u==="remote"?e.jsx("div",{className:"app-region-no-drag",children:e.jsx(fe,{onBack:()=>t&&k("local"),showBackButton:!1,showInstancePicker:!t,onSwitchToLocal:t?()=>k("local"):void 0})}):null,$&&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(Re,{onCopy:H,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:m=>g(m.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(V,{value:j,onChange:m=>U(m.target.value),placeholder:_,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:m=>I(m.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 Ue="curl -fsSL https://opencode.ai/install | bash",Te="https://opencode.ai/docs";function Ke(a){const t=G.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 d;return t[2]!==r||t[3]!==s?(d=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]=d):d=t[4],d}const Ie=3e4;function De({onBack:a,onCliAvailable:t,isFromRecovery:s=!1,onSwitchToRemote:r}){const{t:n}=J(),[l,d]=i.useState(!1),[h,o]=i.useState(!1),[w,S]=i.useState(!1),[j,U]=i.useState(!1),[K,x]=i.useState(!1),[u,k]=i.useState(null),[C,g]=i.useState(""),[T,I]=i.useState("unknown");i.useEffect(()=>{const c=setTimeout(()=>o(!0),Ie);return()=>clearTimeout(c)},[]),i.useEffect(()=>{S(B())},[]),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 _=await ue();if(!_||c)return;const $=_.opencodeBinary??"";$&&g($)}catch{}})(),()=>{c=!0}},[]);const y=i.useCallback(async c=>{c.target.closest("button, a, input, select, textarea, code")||c.button===0&&w&&await me()},[w]),f=i.useCallback(async()=>{try{const c=await X("/health");if(!c.ok)return!1;const _=await c.json();return _.openCodeRunning===!0||_.isOpenCodeReady===!0}catch{return!1}},[]),b=i.useCallback(async()=>{if(!(typeof window>"u")&&w)try{const c=await pe();c.success&&c.path&&c.path.trim().length>0&&g(c.path.trim())}catch{}},[w]),R=i.useCallback(async()=>{U(!0);try{if(await he({opencodeBinary:C.trim()}),w){await O();return}await X("/api/config/reload",{method:"POST"})}finally{setTimeout(()=>U(!1),1e3)}},[w,C]),N=i.useCallback(async()=>{const c=await xe(Ue);c.ok?(d(!0),setTimeout(()=>d(!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=Te,H=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(Ke,{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"})]}),u&&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:u}),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(V,{value:C,onChange:c=>g(c.target.value),placeholder:H,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 Ee(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 Ae({variant:a,hostLabel:t,hostUrl:s,onRetry:r,onUseLocal:n,onUseRemote:l,isRetrying:d=!1}){const{t:h}=J(),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:Ee(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:d,className:"w-full",children:[e.jsx(A,{name:"refresh",className:re("h-4 w-4",d&&"animate-spin")}),h(d?"onboarding.desktopRecovery.actions.retrying":w)]}),e.jsxs("div",{className:"flex gap-2",children:[o.showUseLocal&&n&&e.jsxs(L,{variant:"outline",onClick:n,disabled:d,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:d,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 Fe(a){const t=G.c(29),{variant:s,hostUrl:r,hostLabel:n,onRetry:l,onChooseRemote:d,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,u=U===void 0?!0:U,k=Pe;let C;t[0]!==l?(C=async()=>{if(B()){await O();return}await X("/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"),B()){await O();return}window.location.reload()},t[2]=S,t[3]=s,t[4]=T):T=t[4];const I=T;let y;t[5]!==d||t[6]!==s?(y=()=>{de(s,"use-remote").kind==="remote-form"&&d?.()},t[5]=d,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]!==d||t[9]!==o?(F=o||(()=>d?.()),t[8]=d,t[9]=o,t[10]=F):F=t[10];const H=!u;let c;t[11]!==u||t[12]!==S||t[13]!==w?(c=u?w||(()=>{k("local").then(()=>{B()?O():S?.()})}):void 0,t[11]=u,t[12]=S,t[13]=w,t[14]=c):c=t[14];let _;return t[15]!==E||t[16]!==N||t[17]!==F||t[18]!==H||t[19]!==c?(_=e.jsx(fe,{onBack:F,initialUrl:N,initialLabel:E,isRecoveryMode:!0,showInstancePicker:H,onSwitchToLocal:c}),t[15]=E,t[16]=N,t[17]=F,t[18]=H,t[19]=c,t[20]=_):_=t[20],_}const b=u?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(Ae,{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 Pe(a){if(!B())return;const t=await W();await z({...t,...a==="local"?{defaultHostId:"local"}:{},initialHostChoiceCompleted:!0})}function po(a){const t=G.c(29),{onBack:s,onCliAvailable:r,mode:n,recoveryVariant:l,recoveryHostUrl:d,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),[u,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]!==d||t[4]!==j?(g=[S,j,d,h],t[1]=S,t[2]=h,t[3]=d,t[4]=j,t[5]=g):g=t[5],i.useEffect(C,g);const T=u?"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]!==d||t[14]!==j||t[15]!==K||t[16]!==R?(N=e.jsx(Fe,{variant:j,hostUrl:d,hostLabel:h,onChooseRemote:y,showRemoteForm:K,onCloseRemoteForm:f,onSwitchToLocalFromRemote:b,onEnterLocalSetup:R,localAvailable:U}),t[11]=U,t[12]=h,t[13]=d,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]!==u?(y=()=>{u?k(!1):s?.()},t[18]=s,t[19]=u,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]!==u||t[24]!==y?(b=e.jsx(De,{onBack:y,onCliAvailable:r,isFromRecovery:u,onSwitchToRemote:f}),t[22]=r,t[23]=u,t[24]=y,t[25]=b):b=t[25],b}let I;return t[26]!==U||t[27]!==r?(I=e.jsx(Le,{onCliAvailable:r,localAvailable:U}),t[26]=U,t[27]=r,t[28]=I):I=t[28],I}export{po as OnboardingScreen};
1
+ import{r as D,j as e,R as i,f as G}from"./vendor-react-BUCujlKS.js";import{P as W,cD as je,cA as le,cw as z,E as B,ay as O,dP as ke,aE as ue,X as me,h as X,aJ as pe,t as he,U as ne}from"./index-DLHQogv8.js";import{f as J,B as L,W as V,g as xe,h as re,I as A}from"./useAppFontEffects-BItUWdo4.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-zod-fZppILAM.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-zustand-BAGL70zf.js";import"./vendor-opencode-sdk-BJ73u-bH.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-base-ui-CsXYnR5c.js";import"./vendor-floating-ui-utils-D6FqdtJt.js";import"./vendor-floating-ui-react-dom-DxYCWdHj.js";import"./vendor-floating-ui-dom-BTvzWks8.js";import"./vendor-floating-ui-core-PuGzNPnN.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-framer-motion-Bq3iTZ6r.js";import"./vendor-motion-dom-DcCgeG69.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./vendor-tanstack-react-virtual-ClYN8CzB.js";import"./vendor-tanstack-virtual-core-BewVQryB.js";import"./contextPanelEmbeddedChat-CirXEPJq.js";import"./vendor-sonner-DFyL3AvE.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-BgPj_McA.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-codemirror-state-C9awkmn-.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-codemirror-view-CiLROUVV.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-Cc2ZYbgX.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-codemirror-autocomplete-DzPz9Wgq.js";import"./vendor-codemirror-lang-json-CMBS2tG9.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-O0cZX78y.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-CfgK872x.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-BPGOH9ye.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-BDyxuqK4.js";import"./vendor-codemirror-lang-python-HahnQaAS.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-codemirror-commands-B7H_j0iU.js";import"./vendor-legendapp-list-BuBPBC3R.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";function Ce(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 fe({onBack:a,showBackButton:t=!0,initialUrl:s="",initialLabel:r="",isRecoveryMode:n=!1,onConnect:l,onSwitchToLocal:d,showInstancePicker:h=!1}){const{t:o}=J(),[w,S]=D.useState(s),[j,U]=D.useState(r),[K,x]=D.useState("idle"),[u,k]=D.useState(null),[C,g]=D.useState(""),[T,I]=D.useState([]),[y,f]=D.useState(()=>h?"instances":"add"),[b,R]=D.useState("");D.useEffect(()=>{h&&W().then(p=>I(p.hosts)).catch(p=>{g(p instanceof Error?p.message:String(p))})},[h]);const N=je(w),E=N?.persistedUrl??null,F=D.useCallback(p=>{S(p.target.value),x("idle"),k(null),g("")},[]),H=D.useCallback(p=>{U(p.target.value)},[]),c=D.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 P=await le(p);if(k(P),oe(P.status)){x("error");return}const Z=await W(),ve=j.trim()||p,ee=Z.hosts.find(q=>q.url===p),te=ee?ee.id:`host-${Date.now().toString(16)}`,ie={id:te,label:ve,url:p,apiUrl:p},we=ee?Z.hosts.map(q=>q.id===te?ie:q):[...Z.hosts,ie];if(await z({hosts:we,defaultHostId:te,initialHostChoiceCompleted:!0}),l?.(),N.redeemUrl){window.location.assign(N.redeemUrl);return}B()&&await O()}catch(P){g(P instanceof Error?P.message:o("onboarding.remoteConnection.errors.failedToSaveConnection")),x("error")}},[N,j,l,o]),$=D.useCallback(async p=>{const P=await W();await z({hosts:P.hosts,defaultHostId:p,initialHostChoiceCompleted:!0}),await O()},[]),m=D.useCallback(async()=>{x("testing"),g("");try{const p=await W(),P=await ke(b,p.hosts);await z({hosts:P.hosts,defaultHostId:P.hostId,initialHostChoiceCompleted:!0}),await O()}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,Q=E!==null&&!v&&!oe(u?.status??null),Y=Ce(u?.status??null),be=u?.status==="ok",ge=u?.status==="update-recommended",ye=u?.status==="auth",ae=oe(u?.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:()=>{$(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(V,{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:()=>{m()},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(V,{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(V,{id:"remote-label",type:"text",value:j,onChange:H,placeholder:o("onboarding.remoteConnection.field.namePlaceholder"),disabled:v})]})]}),u&&be&&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:u.latencyMs})}),u&&ye&&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")}),u&&ge&&e.jsx("div",{className:"rounded-lg border p-3 text-sm",style:{borderColor:"var(--status-warning)",color:"var(--status-warning)"},children:Y?o(Y):null}),u&&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:Y?o(Y):null})]}),e.jsx("div",{className:"text-xs opacity-80",children:u.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:_,disabled:!Q,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&&d&&e.jsx(L,{variant:"outline",size:"sm",onClick:d,className:"flex-1",children:o("onboarding.remoteConnection.actions.useLocalInstead")})]})]})]})})}const Ne="curl -fsSL https://opencode.ai/install | bash",Se="https://opencode.ai/docs",ce=2500;function Re(a){const t=G.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 d;return t[2]!==r||t[3]!==s?(d=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]=d):d=t[4],d}function Le({onCliAvailable:a,localAvailable:t=!0}){const{t:s}=J(),[r,n]=i.useState(!1),[l,d]=i.useState(!1),[h,o]=i.useState(!1),[w,S]=i.useState(!1),[j,U]=i.useState(""),[K,x]=i.useState("unknown"),[u,k]=i.useState(()=>t?"local":"remote"),[C,g]=i.useState(!1),[T,I]=i.useState(!1);i.useEffect(()=>{d(B())},[]),i.useEffect(()=>{if(typeof navigator>"u"){x("unknown");return}const m=navigator.userAgent||"";/Windows/i.test(m)?x("windows"):/Macintosh|Mac OS X/i.test(m)?x("macos"):/Linux/i.test(m)?x("linux"):x("unknown")},[]),i.useEffect(()=>{let m=!1;return(async()=>{try{const v=await ue();if(!v||m)return;const M=v.opencodeBinary??"";M&&U(M)}catch{}})(),()=>{m=!0}},[]);const y=i.useCallback(async m=>{const v=m.target;v.closest(".app-region-no-drag")||v.closest("button, a, input, select, textarea, code, summary, details")||m.button===0&&l&&await me()},[l]),f=i.useCallback(async()=>{try{const m=await X("/health");if(!m.ok)return!1;const v=await m.json();return v.openCodeRunning===!0||v.isOpenCodeReady===!0}catch{return!1}},[]),b=i.useCallback(async m=>{if(!l)return;const v=await W();await z({...v,...m==="local"?{defaultHostId:"local"}:{},initialHostChoiceCompleted:!0})},[l]),R=i.useCallback(async()=>{l&&await b("local"),a?.()},[l,a,b]);i.useEffect(()=>{if(!t||u!=="local")return;let m=!1,v=null;const M=async()=>{if(!m){try{const Q=await f();if(m)return;if(Q){await R();return}}catch{}m||(v=setTimeout(M,ce))}};return v=setTimeout(M,ce),()=>{m=!0,v&&clearTimeout(v)}},[u,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 m=await pe();m.success&&m.path&&m.path.trim().length>0&&U(m.path.trim())}catch{}},[l]),F=i.useCallback(async()=>{o(!0);try{if(await he({opencodeBinary:j.trim()}),l){await b("local"),await O();return}await X("/api/config/reload",{method:"POST"})}finally{setTimeout(()=>o(!1),1e3)}},[l,j,b]),H=i.useCallback(async()=>{const m=await xe(Ne);m.ok?(n(!0),setTimeout(()=>n(!1),2e3)):console.error("Failed to copy:",m.error)},[]),c=Se,_=K==="windows"?"C:\\Users\\you\\AppData\\Roaming\\npm\\opencode.cmd":K==="linux"?"/home/you/.bun/bin/opencode":"/Users/you/.bun/bin/opencode",$=t&&(!l||u==="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",u==="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",u==="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&&u==="remote"?e.jsx("div",{className:"app-region-no-drag",children:e.jsx(fe,{onBack:()=>t&&k("local"),showBackButton:!1,showInstancePicker:!t,onSwitchToLocal:t?()=>k("local"):void 0})}):null,$&&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(Re,{onCopy:H,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:m=>g(m.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(V,{value:j,onChange:m=>U(m.target.value),placeholder:_,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:m=>I(m.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 Ue="curl -fsSL https://opencode.ai/install | bash",Te="https://opencode.ai/docs";function Ke(a){const t=G.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 d;return t[2]!==r||t[3]!==s?(d=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]=d):d=t[4],d}const Ie=3e4;function De({onBack:a,onCliAvailable:t,isFromRecovery:s=!1,onSwitchToRemote:r}){const{t:n}=J(),[l,d]=i.useState(!1),[h,o]=i.useState(!1),[w,S]=i.useState(!1),[j,U]=i.useState(!1),[K,x]=i.useState(!1),[u,k]=i.useState(null),[C,g]=i.useState(""),[T,I]=i.useState("unknown");i.useEffect(()=>{const c=setTimeout(()=>o(!0),Ie);return()=>clearTimeout(c)},[]),i.useEffect(()=>{S(B())},[]),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 _=await ue();if(!_||c)return;const $=_.opencodeBinary??"";$&&g($)}catch{}})(),()=>{c=!0}},[]);const y=i.useCallback(async c=>{c.target.closest("button, a, input, select, textarea, code")||c.button===0&&w&&await me()},[w]),f=i.useCallback(async()=>{try{const c=await X("/health");if(!c.ok)return!1;const _=await c.json();return _.openCodeRunning===!0||_.isOpenCodeReady===!0}catch{return!1}},[]),b=i.useCallback(async()=>{if(!(typeof window>"u")&&w)try{const c=await pe();c.success&&c.path&&c.path.trim().length>0&&g(c.path.trim())}catch{}},[w]),R=i.useCallback(async()=>{U(!0);try{if(await he({opencodeBinary:C.trim()}),w){await O();return}await X("/api/config/reload",{method:"POST"})}finally{setTimeout(()=>U(!1),1e3)}},[w,C]),N=i.useCallback(async()=>{const c=await xe(Ue);c.ok?(d(!0),setTimeout(()=>d(!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=Te,H=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(Ke,{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"})]}),u&&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:u}),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(V,{value:C,onChange:c=>g(c.target.value),placeholder:H,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 Ee(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 Ae({variant:a,hostLabel:t,hostUrl:s,onRetry:r,onUseLocal:n,onUseRemote:l,isRetrying:d=!1}){const{t:h}=J(),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:Ee(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:d,className:"w-full",children:[e.jsx(A,{name:"refresh",className:re("h-4 w-4",d&&"animate-spin")}),h(d?"onboarding.desktopRecovery.actions.retrying":w)]}),e.jsxs("div",{className:"flex gap-2",children:[o.showUseLocal&&n&&e.jsxs(L,{variant:"outline",onClick:n,disabled:d,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:d,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 Fe(a){const t=G.c(29),{variant:s,hostUrl:r,hostLabel:n,onRetry:l,onChooseRemote:d,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,u=U===void 0?!0:U,k=Pe;let C;t[0]!==l?(C=async()=>{if(B()){await O();return}await X("/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"),B()){await O();return}window.location.reload()},t[2]=S,t[3]=s,t[4]=T):T=t[4];const I=T;let y;t[5]!==d||t[6]!==s?(y=()=>{de(s,"use-remote").kind==="remote-form"&&d?.()},t[5]=d,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]!==d||t[9]!==o?(F=o||(()=>d?.()),t[8]=d,t[9]=o,t[10]=F):F=t[10];const H=!u;let c;t[11]!==u||t[12]!==S||t[13]!==w?(c=u?w||(()=>{k("local").then(()=>{B()?O():S?.()})}):void 0,t[11]=u,t[12]=S,t[13]=w,t[14]=c):c=t[14];let _;return t[15]!==E||t[16]!==N||t[17]!==F||t[18]!==H||t[19]!==c?(_=e.jsx(fe,{onBack:F,initialUrl:N,initialLabel:E,isRecoveryMode:!0,showInstancePicker:H,onSwitchToLocal:c}),t[15]=E,t[16]=N,t[17]=F,t[18]=H,t[19]=c,t[20]=_):_=t[20],_}const b=u?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(Ae,{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 Pe(a){if(!B())return;const t=await W();await z({...t,...a==="local"?{defaultHostId:"local"}:{},initialHostChoiceCompleted:!0})}function po(a){const t=G.c(29),{onBack:s,onCliAvailable:r,mode:n,recoveryVariant:l,recoveryHostUrl:d,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),[u,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]!==d||t[4]!==j?(g=[S,j,d,h],t[1]=S,t[2]=h,t[3]=d,t[4]=j,t[5]=g):g=t[5],i.useEffect(C,g);const T=u?"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]!==d||t[14]!==j||t[15]!==K||t[16]!==R?(N=e.jsx(Fe,{variant:j,hostUrl:d,hostLabel:h,onChooseRemote:y,showRemoteForm:K,onCloseRemoteForm:f,onSwitchToLocalFromRemote:b,onEnterLocalSetup:R,localAvailable:U}),t[11]=U,t[12]=h,t[13]=d,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]!==u?(y=()=>{u?k(!1):s?.()},t[18]=s,t[19]=u,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]!==u||t[24]!==y?(b=e.jsx(De,{onBack:y,onCliAvailable:r,isFromRecovery:u,onSwitchToRemote:f}),t[22]=r,t[23]=u,t[24]=y,t[25]=b):b=t[25],b}let I;return t[26]!==U||t[27]!==r?(I=e.jsx(Le,{onCliAvailable:r,localAvailable:U}),t[26]=U,t[27]=r,t[28]=I):I=t[28],I}export{po as OnboardingScreen};