@openchambery/web 1.19.0-beta.22 → 1.19.0-beta.24

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 (67) hide show
  1. package/dist/assets/AgentAvatar-mwB5XUVi.js +1 -0
  2. package/dist/assets/{AssistantView-COjPqVYN.js → AssistantView-sXVHiFbR.js} +1 -1
  3. package/dist/assets/{ChatContainer-1UfTcM7y.js → ChatContainer-BgWuCd4v.js} +41 -40
  4. package/dist/assets/{ContextPanel-DqFjhkep.js → ContextPanel-Cwb-zv5_.js} +7 -7
  5. package/dist/assets/{DiagramView-DTLmw9aQ.js → DiagramView-Db17geCg.js} +1 -1
  6. package/dist/assets/{MarkdownRendererImpl-DtDXVNL0.js → MarkdownRendererImpl-C9xpf-ma.js} +1 -1
  7. package/dist/assets/{MobileDetailNavigation-Cra616TS.js → MobileDetailNavigation-fLx4Hiu7.js} +1 -1
  8. package/dist/assets/{MobileShareBridge-CYfJx34q.js → MobileShareBridge-BeP-fM6F.js} +1 -1
  9. package/dist/assets/{MobileSurface-Cy_ouvVc.js → MobileSurface-DE2nXD5f.js} +1 -1
  10. package/dist/assets/{MultiRunWindow-DVs6MZjv.js → MultiRunWindow-BBXiUlyN.js} +1 -1
  11. package/dist/assets/{OnboardingScreen-CzxsmiJZ.js → OnboardingScreen-C0DduEDx.js} +1 -1
  12. package/dist/assets/OverlayScrollbar-VZKKu-cu.js +2 -0
  13. package/dist/assets/{SettingsView-C1KgXp3x.js → SettingsView-C2WEqIPo.js} +8 -8
  14. package/dist/assets/{SettingsWindow-BkiQFX0S.js → SettingsWindow-DKu3lqJo.js} +1 -1
  15. package/dist/assets/{TerminalView-CL9PoqxQ.js → TerminalView-BKlwsHCH.js} +1 -1
  16. package/dist/assets/{ToolOutputDialog-z6vyx5bl.js → ToolOutputDialog-C7Tt7HH0.js} +4 -4
  17. package/dist/assets/appThemeRegistry-rHrS-SUU.js +2 -0
  18. package/dist/assets/{clipboard-DyCy8o-j.js → clipboard-C7zcAKyC.js} +1 -1
  19. package/dist/assets/dialog-D1Ng5yQe.js +1 -0
  20. package/dist/assets/{es-L71xM_T9.js → es-CcbKrwi9.js} +1 -1
  21. package/dist/assets/{fr-DDeqVFFE.js → fr-D1YIDHP6.js} +1 -1
  22. package/dist/assets/{gitApi-BZs3g7kL.js → gitApi-DmD4N9vB.js} +1 -1
  23. package/dist/assets/{insertionBoundaries-B9vsqCQ4.js → insertionBoundaries-ZIre4gP2.js} +1 -1
  24. package/dist/assets/{ja-Cb5UuJfO.js → ja-xE7L_-ZU.js} +1 -1
  25. package/dist/assets/{ko-BOQuwJW9.js → ko-QUUzIgbd.js} +1 -1
  26. package/dist/assets/{main-BIT8b73F.js → main-BibweqwO.js} +6 -6
  27. package/dist/assets/{main-DVpZG9sL.js → main-BzZqwrKd.js} +2 -2
  28. package/dist/assets/{miniChat-DQDvDpWt.js → miniChat-DCBtWwND.js} +2 -2
  29. package/dist/assets/{mobile-BJPgbqSO.js → mobile-Dc8Rs5I3.js} +2 -2
  30. package/dist/assets/multirun-RvKWIsad.js +4 -0
  31. package/dist/assets/{pl-CPR51X8e.js → pl-BQfz-_HE.js} +1 -1
  32. package/dist/assets/platform-ulFAVx1H.js +2 -0
  33. package/dist/assets/projectMeta-DQaqRbHB.js +3 -0
  34. package/dist/assets/{pt-BR-CCmlB4Wg.js → pt-BR-DaY3UW5q.js} +1 -1
  35. package/dist/assets/radio-Backr6WL.js +1 -0
  36. package/dist/assets/{renderElectronMiniChatApp-jaPPkkBN.js → renderElectronMiniChatApp-Dz0mtON-.js} +2 -2
  37. package/dist/assets/renderMobileApp-BSAtVL_r.js +23 -0
  38. package/dist/assets/{runtimeConfig-X9sNIE9W.js → runtimeConfig-DAUbXiCp.js} +1 -1
  39. package/dist/assets/{runtimeEndpointReset-D-MaZgY5.js → runtimeEndpointReset-D7OXfqhZ.js} +2 -2
  40. package/dist/assets/{shikiHighlight-DZ1bj7ag.js → shikiHighlight-2z4B4nJl.js} +1 -1
  41. package/dist/assets/{sortable-tabs-strip-C_ZQ75rK.js → sortable-tabs-strip-DNO7X7-s.js} +1 -1
  42. package/dist/assets/{src-Brv0DCpZ.css → src-CQbD3-_X.css} +1 -1
  43. package/dist/assets/{store--ZgdDfa2.js → store-upwbPNfx.js} +2 -2
  44. package/dist/assets/{terminalApi-B36I-z14.js → terminalApi-HsIEks5U.js} +1 -1
  45. package/dist/assets/{uk-DWxkhZMt.js → uk-yWcUag_v.js} +1 -1
  46. package/dist/assets/{useAppFontEffects-C6Ghp0AX.js → useAppFontEffects-BTbh-LXW.js} +2 -2
  47. package/dist/assets/{useDesktopWindowControlsLayout-Cyxd6emd.js → useDesktopWindowControlsLayout-DkcYKVwU.js} +1 -1
  48. package/dist/assets/{useEffectiveDirectory-FcGKsobh.js → useEffectiveDirectory-D3xq5QOs.js} +1 -1
  49. package/dist/assets/{useFontPreferences-D9h4M7x4.js → useFontPreferences-DaFspdDd.js} +1 -1
  50. package/dist/assets/{useMobileNavigationStore-DkBMOv1J.js → useMobileNavigationStore-DJlSneN_.js} +8 -8
  51. package/dist/assets/{useSessionAutoCleanup-CbBIekcM.js → useSessionAutoCleanup-BSw9SIR2.js} +1 -1
  52. package/dist/assets/{useWorkerHighlightedLines-CwQpUpt5.js → useWorkerHighlightedLines-CV3DwSng.js} +1 -1
  53. package/dist/assets/{zh-CN-CnBbxYt8.js → zh-CN-jktTX6F0.js} +1 -1
  54. package/dist/assets/{zh-TW-B6McpMc8.js → zh-TW-DS3LNe1V.js} +1 -1
  55. package/dist/index.html +5 -5
  56. package/dist/mini-chat.html +5 -5
  57. package/dist/mobile.html +5 -5
  58. package/package.json +1 -1
  59. package/dist/assets/AgentAvatar-CWn_73qY.js +0 -1
  60. package/dist/assets/OverlayScrollbar-DEM7AQRU.js +0 -2
  61. package/dist/assets/appThemeRegistry-h64RD_n6.js +0 -2
  62. package/dist/assets/dialog-BpUGcA8h.js +0 -1
  63. package/dist/assets/multirun-CWV76MQl.js +0 -4
  64. package/dist/assets/platform-DxNH_0Fj.js +0 -2
  65. package/dist/assets/projectMeta-Ct-WdvZL.js +0 -3
  66. package/dist/assets/radio-C2gxi0gx.js +0 -1
  67. package/dist/assets/renderMobileApp-CVVQmLPI.js +0 -23
package/dist/index.html CHANGED
@@ -552,7 +552,7 @@
552
552
  opacity: 0.72;
553
553
  }
554
554
  </style>
555
- <script type="module" crossorigin src="/assets/main-DVpZG9sL.js"></script>
555
+ <script type="module" crossorigin src="/assets/main-BzZqwrKd.js"></script>
556
556
  <link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-C0FnF6B9.js">
557
557
  <link rel="modulepreload" crossorigin href="/assets/vendor-base-ui-CnHfUmDN.js">
558
558
  <link rel="modulepreload" crossorigin href="/assets/vendor-zustand-B4dlGEM2.js">
@@ -565,12 +565,12 @@
565
565
  <link rel="modulepreload" crossorigin href="/assets/desktopRelayRestore-B9S0Rp5s.js">
566
566
  <link rel="modulepreload" crossorigin href="/assets/vendor-opencode-sdk-C07HQypa.js">
567
567
  <link rel="modulepreload" crossorigin href="/assets/vendor-aparajita-capacitor-secure-storage-CjQdwfjS.js">
568
- <link rel="modulepreload" crossorigin href="/assets/platform-DxNH_0Fj.js">
569
- <link rel="modulepreload" crossorigin href="/assets/terminalApi-B36I-z14.js">
568
+ <link rel="modulepreload" crossorigin href="/assets/platform-ulFAVx1H.js">
569
+ <link rel="modulepreload" crossorigin href="/assets/terminalApi-HsIEks5U.js">
570
570
  <link rel="modulepreload" crossorigin href="/assets/types-BuiqMmh_.js">
571
571
  <link rel="modulepreload" crossorigin href="/assets/capgoAdapter-DCowZ2ab.js">
572
- <link rel="modulepreload" crossorigin href="/assets/runtimeConfig-X9sNIE9W.js">
573
- <link rel="stylesheet" crossorigin href="/assets/src-Brv0DCpZ.css">
572
+ <link rel="modulepreload" crossorigin href="/assets/runtimeConfig-DAUbXiCp.js">
573
+ <link rel="stylesheet" crossorigin href="/assets/src-CQbD3-_X.css">
574
574
  </head>
575
575
  <body class="h-full bg-background text-foreground">
576
576
  <!-- Keep the startup layer outside #root. React replaces every child of
@@ -74,7 +74,7 @@
74
74
  }
75
75
  </style>
76
76
 
77
- <script type="module" crossorigin src="/assets/miniChat-DQDvDpWt.js"></script>
77
+ <script type="module" crossorigin src="/assets/miniChat-DCBtWwND.js"></script>
78
78
  <link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-C0FnF6B9.js">
79
79
  <link rel="modulepreload" crossorigin href="/assets/vendor-base-ui-CnHfUmDN.js">
80
80
  <link rel="modulepreload" crossorigin href="/assets/vendor-zustand-B4dlGEM2.js">
@@ -87,12 +87,12 @@
87
87
  <link rel="modulepreload" crossorigin href="/assets/desktopRelayRestore-B9S0Rp5s.js">
88
88
  <link rel="modulepreload" crossorigin href="/assets/vendor-opencode-sdk-C07HQypa.js">
89
89
  <link rel="modulepreload" crossorigin href="/assets/vendor-aparajita-capacitor-secure-storage-CjQdwfjS.js">
90
- <link rel="modulepreload" crossorigin href="/assets/platform-DxNH_0Fj.js">
91
- <link rel="modulepreload" crossorigin href="/assets/terminalApi-B36I-z14.js">
90
+ <link rel="modulepreload" crossorigin href="/assets/platform-ulFAVx1H.js">
91
+ <link rel="modulepreload" crossorigin href="/assets/terminalApi-HsIEks5U.js">
92
92
  <link rel="modulepreload" crossorigin href="/assets/types-BuiqMmh_.js">
93
93
  <link rel="modulepreload" crossorigin href="/assets/capgoAdapter-DCowZ2ab.js">
94
- <link rel="modulepreload" crossorigin href="/assets/runtimeConfig-X9sNIE9W.js">
95
- <link rel="stylesheet" crossorigin href="/assets/src-Brv0DCpZ.css">
94
+ <link rel="modulepreload" crossorigin href="/assets/runtimeConfig-DAUbXiCp.js">
95
+ <link rel="stylesheet" crossorigin href="/assets/src-CQbD3-_X.css">
96
96
  </head>
97
97
  <body class="h-full bg-background text-foreground">
98
98
  <div id="root" class="h-full">
package/dist/mobile.html CHANGED
@@ -63,7 +63,7 @@
63
63
  })();
64
64
  </script>
65
65
 
66
- <script type="module" crossorigin src="/assets/mobile-BJPgbqSO.js"></script>
66
+ <script type="module" crossorigin src="/assets/mobile-Dc8Rs5I3.js"></script>
67
67
  <link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-C0FnF6B9.js">
68
68
  <link rel="modulepreload" crossorigin href="/assets/vendor-base-ui-CnHfUmDN.js">
69
69
  <link rel="modulepreload" crossorigin href="/assets/vendor-zustand-B4dlGEM2.js">
@@ -76,12 +76,12 @@
76
76
  <link rel="modulepreload" crossorigin href="/assets/desktopRelayRestore-B9S0Rp5s.js">
77
77
  <link rel="modulepreload" crossorigin href="/assets/vendor-opencode-sdk-C07HQypa.js">
78
78
  <link rel="modulepreload" crossorigin href="/assets/vendor-aparajita-capacitor-secure-storage-CjQdwfjS.js">
79
- <link rel="modulepreload" crossorigin href="/assets/platform-DxNH_0Fj.js">
80
- <link rel="modulepreload" crossorigin href="/assets/terminalApi-B36I-z14.js">
79
+ <link rel="modulepreload" crossorigin href="/assets/platform-ulFAVx1H.js">
80
+ <link rel="modulepreload" crossorigin href="/assets/terminalApi-HsIEks5U.js">
81
81
  <link rel="modulepreload" crossorigin href="/assets/types-BuiqMmh_.js">
82
82
  <link rel="modulepreload" crossorigin href="/assets/capgoAdapter-DCowZ2ab.js">
83
- <link rel="modulepreload" crossorigin href="/assets/runtimeConfig-X9sNIE9W.js">
84
- <link rel="stylesheet" crossorigin href="/assets/src-Brv0DCpZ.css">
83
+ <link rel="modulepreload" crossorigin href="/assets/runtimeConfig-DAUbXiCp.js">
84
+ <link rel="stylesheet" crossorigin href="/assets/src-CQbD3-_X.css">
85
85
  </head>
86
86
  <body class="h-full bg-background text-foreground">
87
87
  <div id="root" class="h-full"></div>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openchambery/web",
3
- "version": "1.19.0-beta.22",
3
+ "version": "1.19.0-beta.24",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "./server/index.js",
@@ -1 +0,0 @@
1
- import"./rolldown-runtime-C0FnF6B9.js";import{nt as e,rt as t}from"./vendor-base-ui-CnHfUmDN.js";import{n}from"./vendor-react-DLPElpoQ.js";import{t as r}from"./utils-CJdWZupK.js";t();var i=n(),a=[{var:`--status-success`,class:`agent-success`},{var:`--syntax-keyword`,class:`agent-keyword`},{var:`--syntax-type`,class:`agent-type`},{var:`--syntax-function`,class:`agent-function`},{var:`--syntax-number`,class:`agent-number`},{var:`--status-info`,class:`agent-info`},{var:`--status-warning`,class:`agent-warning`},{var:`--syntax-variable`,class:`agent-variable`}];function o(e){if(!e||e===`build`)return a[0];let t=0;for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);t=(t<<5)-t+r,t&=t}return a[1+Math.abs(t)%(a.length-1)]}var s=5,c=Math.ceil(s/2);function l(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return t>>>0}function u(e){let t=Array.from({length:s},()=>Array.from({length:s},()=>!1));if(!e)return t;let n=l(e);for(let e=0;e<s;e++)for(let r=0;r<c;r++){let i=(n&1)==1;n>>>=1,t[e][r]=i,t[e][4-r]=i}return t}var d=e(),f=e=>{let t=(0,i.c)(27),{name:n,emoji:a,size:s,className:c,label:l}=e,f=s===void 0?16:s,m,h,g;if(t[0]!==c||t[1]!==a||t[2]!==n){m=o(n);let e;t[6]===n?e=t[7]:(e=u(n),t[6]=n,t[7]=e),h=e,g=r(`inline-flex aspect-square shrink-0 overflow-hidden rounded-sm`,a&&`items-center justify-center select-none`,m.class,c),t[0]=c,t[1]=a,t[2]=n,t[3]=m,t[4]=h,t[5]=g}else m=t[3],h=t[4],g=t[5];let _=`calc(${f}px * var(--dpt-n, 1))`,v=`calc(${f}px * var(--dpt-n, 1))`,y=`calc(${f}px * var(--dpt-n, 1))`,b=`calc(${f}px * var(--dpt-n, 1))`,x=`calc(${f}px * var(--dpt-n, 1))`,S=`calc(${f}px * var(--dpt-n, 1))`,C=`var(${m.var})`,w;t[8]!==_||t[9]!==v||t[10]!==y||t[11]!==b||t[12]!==x||t[13]!==S||t[14]!==C?(w={width:_,minWidth:v,maxWidth:y,height:b,minHeight:x,maxHeight:S,color:C},t[8]=_,t[9]=v,t[10]=y,t[11]=b,t[12]=x,t[13]=S,t[14]=C,t[15]=w):w=t[15];let T=l?`img`:void 0,E=!l||void 0,D;t[16]!==a||t[17]!==h||t[18]!==f?(D=a?(0,d.jsx)(`span`,{"aria-hidden":`true`,style:{fontSize:`calc(${f*.75}px * var(--dpt-n, 1))`,lineHeight:1},children:a}):(0,d.jsxs)(`svg`,{width:f,height:f,viewBox:`0 0 5 5`,shapeRendering:`crispEdges`,className:`oc-agent-avatar block h-full w-full`,"aria-hidden":`true`,children:[(0,d.jsx)(`rect`,{width:`5`,height:`5`,fill:`currentColor`,opacity:.14}),h.map(p)]}),t[16]=a,t[17]=h,t[18]=f,t[19]=D):D=t[19];let O;return t[20]!==l||t[21]!==w||t[22]!==T||t[23]!==E||t[24]!==D||t[25]!==g?(O=(0,d.jsx)(`span`,{className:g,style:w,role:T,"aria-label":l,"aria-hidden":E,children:D}),t[20]=l,t[21]=w,t[22]=T,t[23]=E,t[24]=D,t[25]=g,t[26]=O):O=t[26],O};function p(e,t){return e.map((e,n)=>e?(0,d.jsx)(`rect`,{x:n,y:t,width:`1`,height:`1`,fill:`currentColor`},`${n}-${t}`):null)}export{o as n,f as t};
@@ -1,2 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-aparajita-capacitor-secure-storage-CjQdwfjS.js","assets/rolldown-runtime-C0FnF6B9.js"])))=>i.map(i=>d[i]);
2
- import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{$t as t,Xt as n}from"./persistence-aCOlo6ew.js";import{nt as r,rt as i}from"./vendor-base-ui-CnHfUmDN.js";import{n as a}from"./platform-DxNH_0Fj.js";import{o}from"./vendor-aparajita-capacitor-secure-storage-CjQdwfjS.js";import{n as s}from"./vendor-react-DLPElpoQ.js";import{t as c}from"./utils-CJdWZupK.js";var l=e(i(),1),u=s(),ee=.85,d=1.2,f=10/9,p=.9,m=`openchamber.designPtScale.v6`;function h(e){return!Number.isFinite(e)||e<=0?1:Math.min(d,Math.max(ee,e))}function g(e){if(!e)return p;let t=e.density,n=(e.xdpi+e.ydpi)/2;return!(t>0)||!(n>=50)||n>800?p:Math.min(p,h(n/t/163))}function _(){if(typeof window>`u`)return 1;try{let e=Number.parseFloat(window.localStorage.getItem(`openchamber.designPtScale.v6`)??``),t=window.Capacitor?.getPlatform?.();return t===`android`?Math.min(p,h(e)):t===`ios`?f:h(e)}catch{return 1}}function v(e){if(!(typeof window>`u`))try{window.localStorage.setItem(m,String(e))}catch{}}function y(e,t=document.documentElement){let n=h(e);t.style.setProperty(`--dpt`,`${n}px`),t.style.setProperty(`--dpt-n`,String(n))}async function b(){if(typeof document>`u`)return 1;y(_());let{Capacitor:e,registerPlugin:t}=await o(async()=>{let{Capacitor:e,registerPlugin:t}=await import(`./vendor-aparajita-capacitor-secure-storage-CjQdwfjS.js`).then(e=>e.i);return{Capacitor:e,registerPlugin:t}},__vite__mapDeps([0,1]));if(!e.isNativePlatform())return y(1),1;if(e.getPlatform()===`ios`)return y(f),v(f),f;if(e.getPlatform()!==`android`)return y(1),1;if(!e.isPluginAvailable(`OpenChamberPhysicalScale`))return y(p),v(p),p;try{let e=g(await t(`OpenChamberPhysicalScale`).getMetrics());return v(e),y(e),e}catch{return y(p),v(p),p}}var x={xs:0,sm:640,md:768,lg:1024,xl:1280,"2xl":1536},te={isMobile:!1,isTablet:!1,isDesktop:!0,deviceType:`desktop`,screenWidth:1024,breakpoint:`lg`,hasTouchInput:!1,hasTouchOnlyPointer:!1},S=()=>typeof window>`u`?!1:new URLSearchParams(window.location.search).get(`surface`)===`desktop`,C=e=>{if(typeof navigator>`u`)return{isExplicitTablet:!1};let t=navigator.userAgent||``,n=navigator.platform||``,r=/iPad/i.test(t)||(/Macintosh|MacIntel/i.test(t)||/MacIntel/i.test(n))&&e>1,i=/Android/i.test(t)&&!/Mobile/i.test(t),a=/Tablet/i.test(t);return{isExplicitTablet:r||i||a}},ne=(e,t,n)=>{if(typeof window>`u`)return;let r=document.documentElement,i=t===`mobile`,a=t===`tablet`;r.classList.remove(`device-mobile`,`device-tablet`,`device-desktop`),r.classList.add(t===`mobile`?`device-mobile`:t===`tablet`?`device-tablet`:`device-desktop`),e?(r.classList.add(`desktop-runtime`),r.style.setProperty(`--is-mobile`,`0`),r.style.setProperty(`--device-type`,`desktop`),r.style.setProperty(`--font-scale`,`1`),r.style.setProperty(`--has-coarse-pointer`,`0`),r.style.setProperty(`--has-touch-input`,`0`),r.classList.remove(`mobile-pointer`)):(r.classList.remove(`desktop-runtime`),r.style.setProperty(`--is-mobile`,i?`1`:`0`),r.style.setProperty(`--device-type`,t),r.style.setProperty(`--font-scale`,i?`0.9`:a?`0.95`:`1`),r.style.setProperty(`--has-coarse-pointer`,n?`1`:`0`),r.style.setProperty(`--has-touch-input`,n?`1`:`0`),n?r.classList.add(`mobile-pointer`):r.classList.remove(`mobile-pointer`)),y(e?1:_(),r)};function w(){let e=window.innerWidth,r=typeof window.matchMedia==`function`,i=r?window.matchMedia(`(pointer: coarse)`):null,o=r?window.matchMedia(`(hover: none)`):null,s=i?.matches??!1,c=o?.matches??!1,l=typeof navigator<`u`?navigator.maxTouchPoints??0:0,u=n()||t()||S(),{isExplicitTablet:ee}=C(l),d=s||c||l>0,f=s||c,p=e>x.md&&e<=x.lg,m=e<=x.md,h=d&&m,g=d&&!h&&(p||ee),_=!d||!g&&e>x.lg,v=`desktop`;u?(h=!1,g=!1,_=!0,v=`desktop`):a()?(h=!0,g=!1,_=!1,v=`mobile`):h?v=`mobile`:g?v=`tablet`:(_=!0,v=`desktop`),ne(u,v,d);let y=`xs`;for(let[t,n]of Object.entries(x))e>=n&&(y=t);return{isMobile:h,isTablet:g,isDesktop:_,deviceType:v,screenWidth:e,breakpoint:y,hasTouchInput:d,hasTouchOnlyPointer:f}}var T=(e,t)=>e.isMobile===t.isMobile&&e.isTablet===t.isTablet&&e.isDesktop===t.isDesktop&&e.deviceType===t.deviceType&&e.screenWidth===t.screenWidth&&e.breakpoint===t.breakpoint&&e.hasTouchInput===t.hasTouchInput&&e.hasTouchOnlyPointer===t.hasTouchOnlyPointer,E=new Set,D=null,O,k=null,A=()=>typeof window>`u`?te:(D||=w(),D),re=()=>{for(let e of E)e()},ie=()=>{O=void 0;let e=w();D&&T(D,e)||(D=e,re())},j=()=>{typeof window>`u`||O!==void 0||(O=window.requestAnimationFrame(ie))},M=(e,t)=>e?typeof e.addEventListener==`function`?(e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)):typeof e.addListener==`function`?(e.addListener(t),()=>e.removeListener(t)):()=>{}:()=>{},N=()=>{if(typeof window>`u`)return()=>{};D=w(),window.addEventListener(`resize`,j);let e=typeof window.matchMedia==`function`?window.matchMedia(`(pointer: coarse)`):null,t=typeof window.matchMedia==`function`?window.matchMedia(`(hover: none)`):null,n=M(e,j),r=M(t,j);return()=>{window.removeEventListener(`resize`,j),n(),r(),O!==void 0&&(window.cancelAnimationFrame(O),O=void 0)}},P=e=>typeof window>`u`?()=>{}:(E.add(e),k||=N(),()=>{E.delete(e),E.size===0&&k&&(k(),k=null,D=null)});function F(){if(typeof window>`u`||typeof window<`u`&&n())return!1;let e=document.documentElement,t=e.style.getPropertyValue(`--is-mobile`)||getComputedStyle(e).getPropertyValue(`--is-mobile`);return t===`1`||t===`true`}var I=()=>typeof window>`u`?!1:!!(navigator.standalone===!0||window.matchMedia?.(`(display-mode: standalone)`)?.matches||window.matchMedia?.(`(display-mode: fullscreen)`)?.matches),L=()=>{if(typeof window>`u`||n())return!1;let e=typeof navigator<`u`?navigator.maxTouchPoints??0:0;return I()&&e>0&&window.innerWidth>x.md};function ae(){let e=(0,u.c)(2),[t,n]=l.useState(R),r,i;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>{if(typeof window>`u`)return;let e=()=>n(L()),t=window.matchMedia?.(`(display-mode: standalone)`),r=window.matchMedia?.(`(display-mode: fullscreen)`);e(),window.addEventListener(`resize`,e),window.addEventListener(`focus`,e);let i=t=>{t&&(typeof t.addEventListener==`function`?t.addEventListener(`change`,e):typeof t.addListener==`function`&&t.addListener(e))},a=t=>{t&&(typeof t.removeEventListener==`function`?t.removeEventListener(`change`,e):typeof t.removeListener==`function`&&t.removeListener(e))};return i(t),i(r),()=>{window.removeEventListener(`resize`,e),window.removeEventListener(`focus`,e),a(t),a(r)}},i=[],e[0]=r,e[1]=i):(r=e[0],i=e[1]),l.useEffect(r,i),t}function R(){return L()}var z=()=>typeof window>`u`?`portrait`:window.matchMedia?.(`(orientation: landscape)`)?.matches?`landscape`:`portrait`;function B(){let e=(0,u.c)(2),[t,n]=l.useState(z),r,i;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>{if(typeof window>`u`||typeof window.matchMedia!=`function`)return;let e=window.matchMedia(`(orientation: landscape)`),t=()=>n(e.matches?`landscape`:`portrait`);return t(),M(e,t)},i=[],e[0]=r,e[1]=i):(r=e[0],i=e[1]),l.useEffect(r,i),t}function V(){return l.useSyncExternalStore(P,A,H)}function H(){return te}var oe=r(),se=1e3,U=.5,ce={length:0,offset:0},le=(e,t)=>Math.abs(e.length-t.length)<U&&Math.abs(e.offset-t.offset)<U,W=e=>{let t=(0,u.c)(66),{containerRef:n,minThumbSize:r,hideDelayMs:i,className:a,disableHorizontal:o,observeMutations:s,suppressVisibility:ee,userIntentOnly:d}=e,f=r===void 0?32:r,p=i===void 0?1e3:i,m=o!==void 0&&o,h=s===void 0||s,g=ee!==void 0&&ee,_=d!==void 0&&d,[v,y]=l.useState(!1),b;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(b={length:0,offset:0},t[0]=b):b=t[0];let[x,te]=l.useState(b),S;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(S={length:0,offset:0},t[1]=S):S=t[1];let[C,ne]=l.useState(S),w=l.useRef(null),T=l.useRef(null),E=l.useRef(null),D=l.useRef(!1),O=l.useRef(!1),k=l.useRef(0),A;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(A={pointerX:0,pointerY:0,scrollTop:0,scrollLeft:0},t[2]=A):A=t[2];let re=l.useRef(A),ie=l.useRef(null),j;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(j=new Set,t[3]=j):j=t[3];let M=l.useRef(j),N;t[4]!==n||t[5]!==m||t[6]!==f?(N=()=>{let e=n.current;if(!e)return;let{scrollHeight:t,clientHeight:r,scrollTop:i,scrollWidth:a,clientWidth:o,scrollLeft:s}=e,c=ce;if(t>r){let e=Math.max(r-16,0),n=r/t*e,a=Math.max(f,Math.min(e,n)),o=Math.max(e-a,0);c={length:a,offset:i/Math.max(t-r,1)*o}}te(e=>le(e,c)?e:c);let l=ce;if(!m&&a>o){let e=Math.max(o-16,0),t=o/a*e,n=Math.max(f,Math.min(e,t)),r=Math.max(e-n,0);l={length:n,offset:s/Math.max(a-o,1)*r}}ne(e=>le(e,l)?e:l)},t[4]=n,t[5]=m,t[6]=f,t[7]=N):N=t[7];let P=N,F;t[8]===P?F=t[9]:(F=()=>{E.current===null&&(E.current=requestAnimationFrame(()=>{E.current=null,P()}))},t[8]=P,t[9]=F);let I=F,L;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(L=(e,t)=>{if(!t){M.current.clear();return}let n=new Set;n.add(e),Array.from(e.children).forEach(e=>{n.add(e)}),M.current.forEach(e=>{n.has(e)||t.unobserve(e)}),n.forEach(e=>{M.current.has(e)||t.observe(e)}),M.current=n},t[10]=L):L=t[10];let ae=L,R;t[11]===p?R=t[12]:(R=()=>{w.current&&clearTimeout(w.current),!O.current&&(w.current=setTimeout(()=>y(!1),p))},t[11]=p,t[12]=R);let z=R,B;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(B=()=>{k.current=Date.now()},t[13]=B):B=t[13];let V=B,H;t[14]!==z||t[15]!==g||t[16]!==P||t[17]!==_?(H=()=>{T.current&&cancelAnimationFrame(T.current),T.current=requestAnimationFrame(()=>{if(P(),g&&!D.current){y(!1);return}if(_&&!D.current&&!(Date.now()-k.current<=se)){y(!1);return}y(!0),z()})},t[14]=z,t[15]=g,t[16]=P,t[17]=_,t[18]=H):H=t[18];let U=H,W,G;t[19]!==n||t[20]!==U||t[21]!==h||t[22]!==I||t[23]!==P||t[24]!==_?(W=()=>{let e=n.current;if(!e)return;P(),y(!1);let t=()=>U(),r=e=>{(e.key===`ArrowUp`||e.key===`ArrowDown`||e.key===`PageUp`||e.key===`PageDown`||e.key===`Home`||e.key===`End`||e.key===` `)&&V()};e.addEventListener(`scroll`,t,{passive:!0}),_&&(e.addEventListener(`wheel`,V,{passive:!0}),e.addEventListener(`touchstart`,V,{passive:!0}),e.addEventListener(`touchmove`,V,{passive:!0}),e.addEventListener(`keydown`,r));let i=typeof ResizeObserver<`u`?new ResizeObserver(()=>{I()}):null;ae(e,i);let a=h&&typeof MutationObserver<`u`?new MutationObserver(()=>{ae(e,i),I()}):null;a?.observe(e,{childList:!0});let o=()=>I(),s=()=>I();return e.addEventListener(`input`,o,!0),e.addEventListener(`load`,s,!0),()=>{e.removeEventListener(`scroll`,t),e.removeEventListener(`input`,o,!0),e.removeEventListener(`load`,s,!0),_&&(e.removeEventListener(`wheel`,V),e.removeEventListener(`touchstart`,V),e.removeEventListener(`touchmove`,V),e.removeEventListener(`keydown`,r)),i?.disconnect(),a?.disconnect(),M.current.clear(),w.current&&clearTimeout(w.current),T.current&&cancelAnimationFrame(T.current),E.current&&cancelAnimationFrame(E.current)}},G=[n,U,V,h,I,ae,P,_],t[19]=n,t[20]=U,t[21]=h,t[22]=I,t[23]=P,t[24]=_,t[25]=W,t[26]=G):(W=t[25],G=t[26]),l.useEffect(W,G);let ue,de;t[27]===g?(ue=t[28],de=t[29]):(ue=()=>{g&&(D.current||(y(!1),w.current&&=(clearTimeout(w.current),null)))},de=[g],t[27]=g,t[28]=ue,t[29]=de),l.useEffect(ue,de);let fe;t[30]===n?fe=t[31]:(fe=(e,t)=>{let r=n.current;r&&(D.current=!0,re.current={pointerX:e.clientX,pointerY:e.clientY,scrollTop:r.scrollTop,scrollLeft:r.scrollLeft},ie.current=t,V(),y(!0),w.current&&clearTimeout(w.current),e.currentTarget.setPointerCapture(e.pointerId))},t[30]=n,t[31]=fe);let K=fe,pe;t[32]!==n||t[33]!==C.length||t[34]!==x.length?(pe=e=>{if(!D.current)return;let t=n.current;if(!t)return;let r=ie.current;if(r===`vertical`){let{pointerY:n,scrollTop:r}=re.current,i=e.clientY-n,a=t.clientHeight,o=Math.max(a-x.length,1),s=Math.max(t.scrollHeight-t.clientHeight,1);t.scrollTop=r+i/o*s}else if(r===`horizontal`){let{pointerX:n,scrollLeft:r}=re.current,i=e.clientX-n,a=t.clientWidth,o=Math.max(a-C.length,1),s=Math.max(t.scrollWidth-t.clientWidth,1);t.scrollLeft=r+i/o*s}},t[32]=n,t[33]=C.length,t[34]=x.length,t[35]=pe):pe=t[35];let q=pe,me;t[36]===z?me=t[37]:(me=e=>{D.current&&(D.current=!1,e.currentTarget.releasePointerCapture(e.pointerId),z())},t[36]=z,t[37]=me);let J=me,he;t[38]===Symbol.for(`react.memo_cache_sentinel`)?(he=()=>{O.current=!0,w.current&&=(clearTimeout(w.current),null)},t[38]=he):he=t[38];let ge=he,_e;t[39]===z?_e=t[40]:(_e=()=>{O.current=!1,z()},t[39]=z,t[40]=_e);let Y=_e,ve=x.length>0,ye=C.length>0;if(!ve&&!ye)return null;let X;t[41]===a?X=t[42]:(X=c(`overlay-scrollbar`,a),t[41]=a,t[42]=X);let be=+!!v,Z;t[43]===be?Z=t[44]:(Z={opacity:be},t[43]=be,t[44]=Z);let Q;t[45]!==K||t[46]!==q||t[47]!==J||t[48]!==Y||t[49]!==ve||t[50]!==x.length||t[51]!==x.offset?(Q=ve&&(0,oe.jsx)(`div`,{className:`overlay-scrollbar__thumb overlay-scrollbar__thumb--vertical`,"data-overlay-scrollbar-thumb":`vertical`,style:{height:`${x.length}px`,top:`${8+x.offset}px`,right:`4px`},onPointerDown:e=>K(e,`vertical`),onPointerMove:q,onPointerUp:J,onPointerCancel:J,onMouseEnter:ge,onMouseLeave:Y}),t[45]=K,t[46]=q,t[47]=J,t[48]=Y,t[49]=ve,t[50]=x.length,t[51]=x.offset,t[52]=Q):Q=t[52];let $;t[53]!==K||t[54]!==q||t[55]!==J||t[56]!==Y||t[57]!==C.length||t[58]!==C.offset||t[59]!==ye?($=ye&&(0,oe.jsx)(`div`,{className:`overlay-scrollbar__thumb overlay-scrollbar__thumb--horizontal`,"data-overlay-scrollbar-thumb":`horizontal`,style:{width:`${C.length}px`,left:`${8+C.offset}px`,bottom:`4px`},onPointerDown:e=>K(e,`horizontal`),onPointerMove:q,onPointerUp:J,onPointerCancel:J,onMouseEnter:ge,onMouseLeave:Y}),t[53]=K,t[54]=q,t[55]=J,t[56]=Y,t[57]=C.length,t[58]=C.offset,t[59]=ye,t[60]=$):$=t[60];let xe;return t[61]!==X||t[62]!==Z||t[63]!==Q||t[64]!==$?(xe=(0,oe.jsxs)(`div`,{className:X,"aria-hidden":`true`,style:Z,children:[Q,$]}),t[61]=X,t[62]=Z,t[63]=Q,t[64]=$,t[65]=xe):xe=t[65],xe};W.displayName=`OverlayScrollbar`;var G=W;export{B as a,V as i,w as n,ae as o,F as r,b as s,G as t};
@@ -1,2 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MarkdownRendererImpl-DtDXVNL0.js","assets/rolldown-runtime-C0FnF6B9.js","assets/useUIStore-Wyu09VUF.js","assets/vendor-zustand-B4dlGEM2.js","assets/vendor-base-ui-CnHfUmDN.js","assets/persistence-aCOlo6ew.js","assets/vendor-pathe-vBmvQE8f.js","assets/vendor-react-DLPElpoQ.js","assets/vendor-tanstack-query-core-BWz0ose6.js","assets/platform-DxNH_0Fj.js","assets/vendor-opencode-sdk-C07HQypa.js","assets/vendor-aparajita-capacitor-secure-storage-CjQdwfjS.js","assets/vendor-reactuses-core-DDoDDyM9.js","assets/vendor-lodash-es-DfLbG5Af.js","assets/vendor-js-cookie-hSOiFTtX.js","assets/clipboard-DyCy8o-j.js","assets/store--ZgdDfa2.js","assets/useMobileNavigationStore-DkBMOv1J.js","assets/vendor-tanstack-react-query-D7pys_c9.js","assets/vendor-sonner-DVzioF3d.js","assets/useAssistantUIStore-DxZsjSPQ.js","assets/vendor-fuse.js-DB5wDJbI.js","assets/utils-CJdWZupK.js","assets/vendor-class-variance-authority-BLUaYARZ.js","assets/vendor-tailwind-merge-BicNWLTg.js","assets/useThemeSystem-DMzWVJaW.js","assets/markdownTheme-DidS-jC5.js","assets/vendor-pierre-diffs-BenIz2TM.js","assets/vendor-hast-util-to-html-B0p1k5Xa.js","assets/vendor-character-entities-legacy-Wut6vMuj.js","assets/vendor-character-entities-html4-DlN_yAFd.js","assets/vendor-ccount-CyGsA0u7.js","assets/vendor-comma-separated-tokens-B9ouxNNS.js","assets/vendor-oniguruma-to-es-CrHzjjSU.js","assets/vendor-oniguruma-parser-D2DIvhSP.js","assets/vendor-diff-Dq7CZNim.js","assets/vendor-lru_map-DpDied8H.js","assets/useRuntimeAPIs-DSLXJybW.js","assets/url-BQHM4bC4.js","assets/markdown-worker-9Sn2jsDp.js","assets/useEffectiveDirectory-FcGKsobh.js","assets/FadeInOnReveal-BpIMrqet.js","assets/vendor-morphdom-BbKiNDAu.js","assets/vendor-beautiful-mermaid-DykqIK5D.js","assets/vendor-marked-WVekxjAN.js","assets/vendor-remend-C3cXc-tf.js","assets/vendor-katex-CNGgSigB.js","assets/vendor-dompurify-CeJNOzik.js"])))=>i.map(i=>d[i]);
2
- import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{nt as t,rt as n}from"./vendor-base-ui-CnHfUmDN.js";import{n as r}from"./platform-DxNH_0Fj.js";import{a as i,n as a,o}from"./vendor-aparajita-capacitor-secure-storage-CjQdwfjS.js";import{n as s}from"./vendor-react-DLPElpoQ.js";import{n as c}from"./vendor-reactuses-core-DDoDDyM9.js";import{t as l}from"./utils-CJdWZupK.js";import{a as u,c as d,i as f}from"./markdown-worker-9Sn2jsDp.js";import{r as p}from"./vendor-pierre-diffs-BenIz2TM.js";var m=s(),h=e(n(),1),g=`openchamber:chunk-import-reload`,_=250,v=3e4,y=[/Importing a module script failed/i,/Failed to fetch dynamically imported module/i,/error loading dynamically imported module/i,/Loading chunk \S+ failed/i,/ChunkLoadError/i];function b(e){if(e instanceof Error)return`${e.name}\n${e.message}\n${e.stack??``}`;if(typeof e==`string`)return e;try{return JSON.stringify(e)}catch{return String(e)}}function x(e){let t=b(e);return y.some(e=>e.test(t))}function ee(e){return`1.19.0-beta.22:${b(e).slice(0,500)}`}function S(e){if(typeof window>`u`)return;let t=Date.now(),n=ee(e),r=null;try{let e=window.sessionStorage.getItem(g);if(e)try{r=JSON.parse(e)}catch{r=null}}catch{return}let i=typeof r?.timestamp==`number`?r.timestamp:0;if(!(r?.signature===n&&t-i<v)){try{window.sessionStorage.setItem(g,JSON.stringify({signature:n,timestamp:t}))}catch{return}console.error(`[refresh-debug] chunk-import-reload`,{error:b(e).slice(0,1e3)}),window.setTimeout(()=>{window.location.reload()},0)}}async function te(e,t={}){let n=t.retries??1,r;for(let t=0;t<=n;t+=1)try{return await e()}catch(e){if(r=e,!x(e)||t>=n)break;await new Promise(e=>setTimeout(e,_*(t+1)))}throw x(r)&&S(r),r}var C=e=>(0,h.lazy)(()=>te(e)),w=`__openchamberMobileBackRoute`,T=()=>typeof window>`u`||r()?null:{currentState:()=>window.history.state&&typeof window.history.state==`object`?window.history.state:null,pushState:e=>window.history.pushState(e,``,window.location.href),back:()=>window.history.back(),subscribe:e=>{let t=t=>e(t.state&&typeof t.state==`object`?t.state:null);return window.addEventListener(`popstate`,t),()=>window.removeEventListener(`popstate`,t)}},E=e=>{let t=e?.[w];return typeof t==`number`&&Number.isFinite(t)?t:null},D=new class{routes=[];listeners=new Set;nextToken=1;history;removeHistoryListener=null;programmaticHistoryBackToken=null;pendingHistoryRemovals=new Map;animatedBackDriver=null;presentationCancelDriver=null;constructor(e=T()){this.history=e}subscribe=e=>(this.listeners.add(e),()=>this.listeners.delete(e));getTopRoute=()=>this.routes.at(-1)??null;register=e=>{let t=this.pendingHistoryRemovals.get(e.id);this.pendingHistoryRemovals.delete(e.id);let n=!!(this.history&&t!==void 0&&E(this.history.currentState())===t),r={...e,token:n&&t!==void 0?t:this.nextToken++};this.routes.push(r),this.ensureHistoryListener(),this.history&&!n&&this.history.pushState({...this.history.currentState()??{},[w]:r.token}),this.notify();let i=!0;return()=>{if(!i)return;i=!1;let e=this.routes.indexOf(r);e<0||(this.routes.splice(e,1),this.history&&E(this.history.currentState())===r.token?(this.pendingHistoryRemovals.set(r.id,r.token),queueMicrotask(()=>{if(this.pendingHistoryRemovals.get(r.id)===r.token){if(this.pendingHistoryRemovals.delete(r.id),!this.history||E(this.history.currentState())!==r.token){this.routes.length===0&&this.pendingHistoryRemovals.size===0&&this.disposeHistoryListener();return}this.programmaticHistoryBackToken=r.token,this.history.back(),this.routes.length===0&&this.pendingHistoryRemovals.size===0&&this.disposeHistoryListener()}})):this.routes.length===0&&this.pendingHistoryRemovals.size===0&&this.disposeHistoryListener(),this.notify())}};backImmediately=e=>{let t=this.getTopRoute();return!t||e&&t.layer!==e?!1:t.onBack()!==!1};requestAnimatedBack=e=>{let t=this.getTopRoute();return!t||e&&t.layer!==e?!1:this.animatedBackDriver?.(t)?!0:this.backImmediately(e)};setAnimatedBackDriver=e=>(this.animatedBackDriver=e,()=>{this.animatedBackDriver===e&&(this.animatedBackDriver=null)});setPresentationCancelDriver=e=>(this.presentationCancelDriver=e,()=>{this.presentationCancelDriver===e&&(this.presentationCancelDriver=null)});cancelPresentation=()=>{this.presentationCancelDriver?.()};requestBrowserBack=()=>{let e=this.getTopRoute();return e?this.history&&E(this.history.currentState())===e.token?(this.history.back(),!0):e.onBack()!==!1:!1};ensureHistoryListener(){!this.history||this.removeHistoryListener||(this.removeHistoryListener=this.history.subscribe(e=>{if(this.programmaticHistoryBackToken!==null){this.programmaticHistoryBackToken=null;return}let t=this.getTopRoute();t&&E(e)!==t.token&&t.onBack()===!1&&this.history&&this.history.pushState({...this.history.currentState()??{},[w]:t.token})}))}disposeHistoryListener(){this.removeHistoryListener?.(),this.removeHistoryListener=null,this.programmaticHistoryBackToken=null,this.pendingHistoryRemovals.clear()}notify(){this.listeners.forEach(e=>e())}},ne=e=>{let t=(0,m.c)(8),{id:n,active:r,layer:i,onBack:a,surfaceRef:o,underlayRef:s}=e,l=i===void 0?`root`:i,u=c(a),d,f;t[0]!==r||t[1]!==u||t[2]!==n||t[3]!==l||t[4]!==o||t[5]!==s?(d=()=>{if(r)return D.register({id:n,layer:l,onBack:u,getSurface:()=>o.current,getUnderlay:()=>s?.current??null})},f=[r,u,n,l,o,s],t[0]=r,t[1]=u,t[2]=n,t[3]=l,t[4]=o,t[5]=s,t[6]=d,t[7]=f):(d=t[6],f=t[7]),h.useEffect(d,f)},O=i(`OpenChamberNavigation`),k=e=>Math.min(1,Math.max(0,Number.isFinite(e)?e:0)),A=(e,t)=>!e||!t?!1:e.onBack()!==!1,j=e=>{let t=k(e.progress),n=e.commit?1-t:t;if(n<=.001)return 0;let r=Math.max(1,e.viewportWidth??390),i=Math.abs(e.velocityX??0)/r,a=n/Math.max(e.commit?2.4:2.8,i)*1e3,o=e.commit?90:100,s=e.commit?320:260;return Math.round(Math.min(s,Math.max(o,a)))},M=e=>{let{surface:t,underlay:n,surfaceTransition:r,surfaceAnimation:i,underlayTransition:a,underlayAnimation:o}=e;t.style.removeProperty(`transform`),t.style.removeProperty(`opacity`),t.style.removeProperty(`will-change`),t.style.removeProperty(`box-shadow`),t.style.transition=r,t.style.animation=i,n&&(n.style.removeProperty(`transform`),n.style.removeProperty(`opacity`),n.style.removeProperty(`will-change`),n.style.transition=a??``,n.style.animation=o??``)},N=(e,t)=>{let n=k(t),{surface:r}=e;r.style.transform=`translate3d(${n*100}%, 0, 0)`},re=e=>!e.surfaceConnected||e.topRouteToken!==e.routeToken||e.routeSurface!==e.outgoingSurface,ie=async(e,t,n,r)=>{if(!r&&typeof e.animate==`function`){let r=e.style.transform||`translate3d(0%, 0, 0)`,i=`translate3d(${t}%, 0, 0)`,a=e.animate([{transform:r},{transform:i}],{duration:n,easing:`cubic-bezier(0.22, 1, 0.36, 1)`,fill:`forwards`}),o=!1;try{await a.finished,o=!0}catch{}finally{o&&(e.style.transform=i),a.cancel()}return}e.style.transform=`translate3d(${t}%, 0, 0)`},ae=async(e,t,n=typeof window<`u`&&window.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches,r=j({progress:Number.parseFloat(e.style.transform.match(/translate3d\(([-\d.]+)%/)?.[1]??`0`)/100,commit:t}))=>ie(e,t?100:0,r,n),oe=class{pending=0;enqueue(){this.pending+=1}take(){return this.pending!==0&&(--this.pending,!0)}clear(){this.pending=0}},se=e=>{let t=(0,m.c)(4),{enabled:n,rootRoutesBlocked:i}=e,o,s;t[0]!==n||t[1]!==i?(o=()=>{if(!n||!r()||a.getPlatform()===`web`)return;let e=!1,t=null,o=null,s=0,c=0,l=0,u=new oe,d=[],f=e=>!!e&&(!i||e?.layer===`overlay`),p=()=>{let e=f(D.getTopRoute());O.setEnabled({enabled:e}).catch(ce)},m=()=>{if(D.cancelPresentation(),o)return;let e=D.getTopRoute();if(!f(e))return;let n=e.getSurface();if(!n)return;n.getAnimations().forEach(le),o=null;let r=e.layer===`root`?e.getUnderlay():null,i=n.style.transition,a=n.style.animation,s=r?.style.transition??null,c=r?.style.animation??null;r?.getAnimations().forEach(P),n.style.transition=`none`,n.style.animation=`none`,n.style.willChange=`transform`,r&&(r.style.removeProperty(`transform`),r.style.removeProperty(`will-change`)),l+=1,t={route:e,surface:n,underlay:r,surfaceTransition:i,surfaceAnimation:a,underlayTransition:s,underlayAnimation:c},N(t,0)},h=e=>{c=k(e),!s&&(s=window.requestAnimationFrame(()=>{s=0,t&&N(t,c)}))},g=F,_=(n,r,i)=>{if(o)return n&&f(D.getTopRoute())?(u.enqueue(),!0):!1;s&&=(window.cancelAnimationFrame(s),0),t||m(),t&&r!==void 0&&N(t,r);let a=t,d=l;if(t=null,!a){if(!n)return!1;let e=D.getTopRoute();return A(e,f(e))}o=a;let p=window.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches??!1,h=j({progress:k(r??c),commit:n,velocityX:i,viewportWidth:window.innerWidth});return ae(a.surface,n,p,h).then(async()=>{d===l&&(!e&&n&&(a.route.onBack(),await g(a)),d===l&&(M(a),o===a&&(o=null),!e&&u.take()&&_(!0,0,0)))}),!0},v=D.setAnimatedBackDriver(e=>e!==D.getTopRoute()||!f(e)?!1:_(!0,0,0)),y=D.subscribe(p);return(async()=>{let t=await O.addListener(`backStarted`,m),n=await O.addListener(`backProgressed`,e=>h(e.progress??0)),r=await O.addListener(`backCancelled`,e=>_(!1,e.progress,e.velocityX)),i=await O.addListener(`backInvoked`,e=>_(!0,e.progress,e.velocityX));if(e){await Promise.all([t.remove(),n.remove(),r.remove(),i.remove()]);return}d.push(t,n,r,i),p()})().catch(I),p(),()=>{e=!0,l+=1,u.clear(),y(),v(),s&&window.cancelAnimationFrame(s),t&&M(t),o&&(o.surface.getAnimations().forEach(L),o.underlay?.getAnimations().forEach(R),M(o)),t=null,o=null,O.setEnabled({enabled:!1}).catch(z),d.forEach(B)}},s=[n,i],t[0]=n,t[1]=i,t[2]=o,t[3]=s):(o=t[2],s=t[3]),h.useEffect(o,s)};function ce(){}function le(e){return e.cancel()}function P(e){return e.cancel()}function F(e){return new Promise(t=>{let n=0,r=12,i=!1,a=()=>{i||(i=!0,c(),n&&window.cancelAnimationFrame(n),t())},o=()=>{let t=D.getTopRoute();return re({surfaceConnected:e.surface.isConnected,routeToken:e.route.token,topRouteToken:t?.token??null,routeSurface:e.route.getSurface(),outgoingSurface:e.surface})},s=()=>{if(o()||r<=0){a();return}--r,n=window.requestAnimationFrame(s)},c=D.subscribe(()=>{o()&&a()});s()})}function I(){}function L(e){return e.cancel()}function R(e){return e.cancel()}function z(){}function B(e){e.remove()}var V=null,H=()=>(V??=o(()=>import(`./MarkdownRendererImpl-DtDXVNL0.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47])).catch(e=>{throw V=null,e}),V),U=()=>{H().catch(()=>void 0)},W=h.createContext(!0),G=()=>h.useContext(W),K=t(),ue=C(()=>H().then(e=>({default:e.MarkdownRenderer}))),de=C(()=>H().then(e=>({default:e.SimpleMarkdownRenderer}))),fe=e=>e===`tool`?`markdown-content markdown-tool`:e===`reasoning`?`markdown-content markdown-reasoning`:`markdown-content leading-relaxed`,q=e=>{let t=(0,m.c)(14),n=typeof e.content==`string`?e.content:``,r=typeof e.variant==`string`?e.variant:`assistant`,i;t[0]!==n||t[1]!==e.reserveMeasuredHeight||t[2]!==r?(i=e.reserveMeasuredHeight?u(f(n,r)):void 0,t[0]=n,t[1]=e.reserveMeasuredHeight,t[2]=r,t[3]=i):i=t[3];let a=i,o;t[4]!==e.className||t[5]!==e.variant?(o=l(`relative break-words w-full min-w-0`,fe(e.variant),typeof e.className==`string`?e.className:void 0),t[4]=e.className,t[5]=e.variant,t[6]=o):o=t[6];let s;t[7]!==n||t[8]!==e.animated||t[9]!==a?(s=(0,K.jsx)(d,{animated:e.animated,content:n,reservedHeight:a}),t[7]=n,t[8]=e.animated,t[9]=a,t[10]=s):s=t[10];let c;return t[11]!==o||t[12]!==s?(c=(0,K.jsx)(`div`,{className:o,"aria-busy":`true`,"data-markdown-hydration":`deferred`,children:s}),t[11]=o,t[12]=s,t[13]=c):c=t[13],c},pe=e=>{let t=(0,m.c)(4);if(!G()&&e.isStreaming!==!0){let n;return t[0]===e?n=t[1]:(n=(0,K.jsx)(q,{...e,animated:!1,reserveMeasuredHeight:!0}),t[0]=e,t[1]=n),n}let n;return t[2]===e?n=t[3]:(n=(0,K.jsx)(h.Suspense,{fallback:(0,K.jsx)(q,{...e,reserveMeasuredHeight:!0}),children:(0,K.jsx)(ue,{...e})}),t[2]=e,t[3]=n),n},me=e=>{let t=(0,m.c)(4);if(!G()){let n;return t[0]===e?n=t[1]:(n=(0,K.jsx)(q,{...e,animated:!1}),t[0]=e,t[1]=n),n}let n;return t[2]===e?n=t[3]:(n=(0,K.jsx)(h.Suspense,{fallback:(0,K.jsx)(q,{...e}),children:(0,K.jsx)(de,{...e})}),t[2]=e,t[3]=n),n},he=e=>/^#[0-9a-fA-F]{6}$/.test(e),ge=e=>/^#[0-9a-fA-F]{8}$/.test(e),_e=(e,t)=>/^[0-9a-fA-F]{2}$/.test(t)?he(e)?`${e}${t}`:ge(e)?`${e.slice(0,7)}${t}`:e:e,J=(e,t)=>typeof e==`string`&&e.trim().length>0?e:t,Y=e=>{let t=e.colors.syntax.base,n=e.colors.syntax.tokens??{},r=(e,t)=>J(n[e],t);return[{name:`plain`,scope:[`source`,`support.type.property-name.css`],settings:{foreground:t.foreground}},{name:`classes`,scope:[`entity.name.type.class`],settings:{foreground:r(`className`,r(`class`,t.function))}},{name:`interfaces`,scope:[`entity.name.type.interface`,`entity.name.type`],settings:{foreground:r(`interface`,t.type)}},{name:`structs`,scope:[`entity.name.type.struct`],settings:{foreground:r(`struct`,t.function)}},{name:`enums`,scope:[`entity.name.type.enum`],settings:{foreground:r(`enum`,t.function)}},{name:`keys`,scope:[`meta.object-literal.key`,`support.type.property-name`],settings:{foreground:r(`key`,t.function)}},{name:`methods`,scope:[`entity.name.function.method`,`meta.function.method`],settings:{foreground:r(`method`,e.colors.status.success)}},{name:`functions`,scope:[`entity.name.function`,`support.function`,`meta.function-call.generic`],settings:{foreground:t.function,fontStyle:`bold`}},{name:`variables`,scope:[`variable`,`meta.variable`,`variable.other.object.property`],settings:{foreground:t.variable}},{name:`variablesOther`,scope:[`variable.other.object`,`variable.other.readwrite.alias`],settings:{foreground:r(`variableOther`,r(`method`,e.colors.status.success))}},{name:`globalVariables`,scope:[`variable.other.global`,`variable.language.this`],settings:{foreground:r(`variableGlobal`,t.number)}},{name:`localVariables`,scope:[`variable.other.local`],settings:{foreground:r(`variableLocal`,e.colors.surface.elevated)}},{name:`parameters`,scope:[`variable.parameter`,`meta.parameter`],settings:{foreground:r(`parameter`,t.foreground)}},{name:`properties`,scope:[`variable.other.property`,`meta.property`],settings:{foreground:r(`variableProperty`,e.colors.status.info)}},{name:`strings`,scope:[`string`,`string.other.link`,`markup.inline.raw.string.markdown`],settings:{foreground:t.string}},{name:`stringEscapeSequences`,scope:[`constant.character.escape`,`constant.other.placeholder`],settings:{foreground:r(`stringEscape`,t.foreground)}},{name:`keywords`,scope:[`keyword`],settings:{foreground:t.keyword}},{name:`keywordsControl`,scope:[`keyword.control.import`,`keyword.control.from`,`keyword.import`],settings:{foreground:r(`keywordImport`,t.operator)}},{name:`storageModifiers`,scope:[`storage.modifier`,`keyword.modifier`,`storage.type`],settings:{foreground:r(`storageModifier`,t.keyword)}},{name:`comments`,scope:[`comment`,`punctuation.definition.comment`],settings:{foreground:t.comment}},{name:`docComments`,scope:[`comment.documentation`,`comment.line.documentation`],settings:{foreground:r(`commentDoc`,e.colors.surface.mutedForeground)}},{name:`numbers`,scope:[`constant.numeric`],settings:{foreground:t.number}},{name:`booleans`,scope:[`constant.language`],settings:{foreground:r(`boolean`,t.type)}},{name:`operators`,scope:[`keyword.operator`],settings:{foreground:t.operator}},{name:`macros`,scope:[`entity.name.function.preprocessor`,`meta.preprocessor`],settings:{foreground:r(`macro`,t.keyword)}},{name:`preprocessor`,scope:[`meta.preprocessor`],settings:{foreground:r(`preprocessor`,r(`label`,t.number))}},{name:`urls`,scope:[`markup.underline.link`],settings:{foreground:r(`url`,e.colors.status.info)}},{name:`tags`,scope:[`entity.name.tag`],settings:{foreground:r(`tag`,t.keyword)}},{name:`jsxTags`,scope:[`support.class.component`],settings:{foreground:r(`jsxTag`,r(`label`,t.number))}},{name:`attributes`,scope:[`entity.other.attribute-name`,`meta.attribute`],settings:{foreground:r(`tagAttribute`,t.type)}},{name:`types`,scope:[`support.type`],settings:{foreground:t.type}},{name:`constants`,scope:[`variable.other.constant`,`variable.readonly`],settings:{foreground:r(`constant`,t.foreground)}},{name:`labels`,scope:[`entity.name.label`,`punctuation.definition.label`],settings:{foreground:r(`label`,r(`variableGlobal`,t.number))}},{name:`namespaces`,scope:[`entity.name.namespace`,`storage.modifier.namespace`,`markup.bold.markdown`],settings:{foreground:r(`namespace`,t.type)}},{name:`modules`,scope:[`entity.name.module`,`storage.modifier.module`],settings:{foreground:r(`module`,t.operator)}},{name:`typeParameters`,scope:[`variable.type.parameter`,`variable.parameter.type`],settings:{foreground:r(`typeParameter`,t.function)}},{name:`exceptions`,scope:[`keyword.control.exception`,`keyword.control.trycatch`],settings:{foreground:r(`exception`,r(`label`,t.number))}},{name:`decorators`,scope:[`meta.decorator`,`punctuation.decorator`,`entity.name.function.decorator`],settings:{foreground:r(`decorator`,t.type)}},{name:`calls`,scope:[`variable.function`],settings:{foreground:t.foreground}},{name:`punctuation`,scope:[`punctuation`,`punctuation.terminator`,`punctuation.definition.tag`,`punctuation.separator`,`punctuation.definition.string`,`punctuation.section.block`],settings:{foreground:r(`punctuation`,t.comment)}},{name:`yellow`,scope:[`storage.type.numeric.go`,`storage.type.byte.go`,`storage.type.boolean.go`,`storage.type.string.go`,`storage.type.uintptr.go`,`storage.type.error.go`,`storage.type.rune.go`,`constant.language.go`,`support.class.dart`,`keyword.other.documentation`,`storage.modifier.import.java`,`punctuation.definition.list.begin.markdown`,`punctuation.definition.quote.begin.markdown`,`meta.separator.markdown`,`entity.name.section.markdown`],settings:{foreground:t.type}},{name:`green`,scope:[],settings:{foreground:r(`method`,e.colors.status.success)}},{name:`cyan`,scope:[`markup.italic.markdown`,`support.type.python`,`variable.legacy.builtin.python`,`support.constant.property-value.css`,`storage.modifier.attribute.swift`],settings:{foreground:t.string}},{name:`blue`,scope:[],settings:{foreground:t.keyword}},{name:`purple`,scope:[`keyword.channel.go`,`keyword.other.platform.os.swift`],settings:{foreground:t.number}},{name:`magenta`,scope:[`punctuation.definition.heading.markdown`],settings:{foreground:r(`label`,r(`variableGlobal`,t.number))}},{name:`red`,scope:[],settings:{foreground:t.operator}},{name:`orange`,scope:[],settings:{foreground:t.function}}]},ve=e=>{let t=e.colors.surface,n=e.colors.interactive,r=e.colors.status,i=e.colors.syntax.base,a=e.colors.syntax.highlights??{},o=J(a.diffAddedBackground,r.successBackground),s=J(a.diffRemovedBackground,r.errorBackground);return{"editor.background":t.background,"editor.foreground":t.foreground,"editor.hoverHighlightBackground":J(n.hover,t.subtle),"editor.lineHighlightBackground":t.muted,"editor.selectionBackground":n.selection,"editor.selectionHighlightBackground":n.selection,"editor.findMatchBackground":i.type,"editor.findMatchHighlightBackground":_e(i.type,`cc`),"editor.findRangeHighlightBackground":t.muted,"editor.inactiveSelectionBackground":t.elevated,"editor.lineHighlightBorder":t.elevated,"editor.rangeHighlightBackground":J(n.active,n.borderHover),"notifications.background":t.elevated,"editorInlayHint.typeBackground":t.subtle,"editorInlayHint.typeForeground":t.foreground,"editorWhitespace.foreground":n.borderHover,"editorIndentGuide.background1":t.subtle,"editorHoverWidget.background":t.elevated,"editorLineNumber.activeForeground":J(a.lineNumberActive,t.foreground),"editorLineNumber.foreground":J(a.lineNumber,t.mutedForeground),"editorGutter.background":t.background,"editorGutter.modifiedBackground":r.info,"editorGutter.addedBackground":r.success,"editorGutter.deletedBackground":r.error,"editorBracketMatch.background":t.elevated,"editorBracketMatch.border":t.subtle,"editorError.foreground":r.error,"editorWarning.foreground":r.warning,"editorInfo.foreground":r.info,"diffEditor.insertedTextBackground":o,"diffEditor.removedTextBackground":s,"editorGroupHeader.tabsBackground":t.background,"editorGroup.border":n.border,"tab.activeBackground":t.background,"tab.inactiveBackground":t.muted,"tab.inactiveForeground":t.mutedForeground,"tab.activeForeground":t.foreground,"tab.hoverBackground":t.subtle,"tab.unfocusedHoverBackground":t.subtle,"tab.border":n.border,"tab.activeModifiedBorder":i.type,"tab.inactiveModifiedBorder":r.info,"tab.unfocusedActiveModifiedBorder":i.type,"tab.unfocusedInactiveModifiedBorder":r.info,"editorWidget.background":t.muted,"editorWidget.border":n.border,"editorSuggestWidget.background":t.background,"editorSuggestWidget.border":n.border,"editorSuggestWidget.foreground":t.foreground,"editorSuggestWidget.highlightForeground":t.mutedForeground,"editorSuggestWidget.selectedBackground":t.subtle,"peekView.border":n.border,"peekViewEditor.background":t.background,"peekViewEditor.matchHighlightBackground":t.subtle,"peekViewResult.background":t.muted,"peekViewResult.fileForeground":t.foreground,"peekViewResult.lineForeground":t.mutedForeground,"peekViewResult.matchHighlightBackground":t.subtle,"peekViewResult.selectionBackground":t.elevated,"peekViewResult.selectionForeground":t.mutedForeground,"peekViewTitle.background":t.subtle,"peekViewTitleDescription.foreground":t.mutedForeground,"peekViewTitleLabel.foreground":t.foreground,"merge.currentHeaderBackground":r.success,"merge.currentContentBackground":J(a.diffAdded,r.success),"merge.incomingHeaderBackground":r.info,"merge.incomingContentBackground":J(a.diffModified,r.info),"merge.border":n.border,"merge.commonContentBackground":t.subtle,"merge.commonHeaderBackground":t.muted,"panel.background":t.background,"panel.border":n.border,"panelTitle.activeBorder":n.borderHover,"panelTitle.activeForeground":t.foreground,"panelTitle.inactiveForeground":t.mutedForeground,"statusBar.background":t.background,"statusBar.foreground":t.foreground,"statusBar.border":n.border,"statusBar.debuggingBackground":r.error,"statusBar.debuggingForeground":r.errorForeground,"statusBar.noFolderBackground":t.subtle,"statusBar.noFolderForeground":t.mutedForeground,"titleBar.activeBackground":t.background,"titleBar.activeForeground":t.foreground,"titleBar.inactiveBackground":t.muted,"titleBar.inactiveForeground":t.mutedForeground,"titleBar.border":n.border,"menu.foreground":t.foreground,"menu.background":t.background,"menu.selectionForeground":t.foreground,"menu.selectionBackground":t.subtle,"menu.border":n.border,"editorInlayHint.foreground":t.mutedForeground,"editorInlayHint.background":t.subtle,"terminal.foreground":t.foreground,"terminal.background":t.background,"terminalCursor.foreground":t.foreground,"terminalCursor.background":t.background,"terminal.ansiRed":J(a.diffRemoved,r.error),"terminal.ansiGreen":J(a.diffAdded,r.success),"terminal.ansiYellow":r.warning,"terminal.ansiBlue":J(a.diffModified,r.info),"terminal.ansiMagenta":i.keyword,"terminal.ansiCyan":i.type,"activityBar.background":t.background,"activityBar.foreground":t.foreground,"activityBar.inactiveForeground":t.mutedForeground,"activityBar.activeBorder":t.foreground,"activityBar.border":n.border,"sideBar.background":t.background,"sideBar.foreground":t.foreground,"sideBar.border":n.border,"sideBarTitle.foreground":t.foreground,"sideBarSectionHeader.background":t.muted,"sideBarSectionHeader.foreground":t.foreground,"sideBarSectionHeader.border":n.border,"sideBar.activeBackground":t.subtle,"sideBar.activeForeground":t.foreground,"sideBar.hoverBackground":t.muted,"sideBar.hoverForeground":t.foreground,"list.warningForeground":r.warning,"list.errorForeground":r.error,"list.inactiveSelectionBackground":t.subtle,"list.activeSelectionBackground":t.elevated,"list.inactiveSelectionForeground":t.foreground,"list.activeSelectionForeground":t.foreground,"list.hoverForeground":t.foreground,"list.hoverBackground":t.muted,"input.background":t.muted,"input.foreground":t.foreground,"input.border":n.border,"input.placeholderForeground":t.mutedForeground,"inputOption.activeBorder":n.border,"inputOption.activeBackground":t.elevated,"inputOption.activeForeground":t.foreground,"inputValidation.infoBackground":r.infoBackground,"inputValidation.infoBorder":r.infoBorder,"inputValidation.warningBackground":r.warningBackground,"inputValidation.warningBorder":r.warningBorder,"inputValidation.errorBackground":r.errorBackground,"inputValidation.errorBorder":r.errorBorder,"dropdown.background":t.muted,"dropdown.foreground":t.foreground,"dropdown.border":n.border,"dropdown.listBackground":t.background,"badge.background":e.colors.primary.base,"activityBarBadge.background":e.colors.primary.base,"button.background":e.colors.primary.base,"button.foreground":J(e.colors.primary.foreground,t.background),"badge.foreground":J(e.colors.primary.foreground,t.background),"activityBarBadge.foreground":J(e.colors.primary.foreground,t.background)}};function ye(e){return{name:e.metadata.name,type:e.metadata.variant,colors:ve(e),tokenColors:Y(e)}}var be=e=>/^#[0-9a-fA-F]{8}$/.test(e),X=e=>be(e)?e.slice(0,7):e;function xe(e,t){return Object.defineProperty(e,"toString",{value:()=>t,enumerable:!1,configurable:!0}),Object.defineProperty(e,Symbol.toPrimitive,{value:()=>t,enumerable:!1,configurable:!0}),e}var Z=new Map,Q=new Set,Se=(e,t)=>{let n=e.colors?.[`editor.background`],r=e.colors?.[`editor.foreground`],i=n?X(n):void 0,a=r?X(r):void 0;if(!i||!a)throw Error(`Theme "${t}" is missing editor.background/editor.foreground`);let o=e.tokenColors??[];return xe({...e,name:t,fg:a,bg:i,settings:o},t)},Ce=e=>ye(e),$=e=>{let t=Z.get(e.metadata.id);if(t)return t;let n=Se(Ce(e),e.metadata.id);return Z.set(e.metadata.id,n),n},we=e=>{let t=e.metadata.id;if(Q.has(t))return;let n=$(e);p(t,async()=>n),Q.add(t)};export{W as a,ne as c,me as i,se as l,$ as n,U as o,pe as r,D as s,we as t,C as u};
@@ -1 +0,0 @@
1
- import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{$ as t,J as n,K as r,Q as i,X as a,Y as o,Z as s,nt as c,q as l,rt as u}from"./vendor-base-ui-CnHfUmDN.js";import{n as d}from"./vendor-react-DLPElpoQ.js";import{n as f}from"./clipboard-DyCy8o-j.js";import{t as p}from"./utils-CJdWZupK.js";import{n as m}from"./Icon-BAf2hhrw.js";var h=d(),g=e(u(),1),_=c(),v=0;function y(e,t){return e&&g.isValidElement(t)?{render:t}:{children:t}}function b(e){let t=(0,h.c)(4),r;t[0]===e?r=t[1]:({...r}=e,t[0]=e,t[1]=r);let i;return t[2]===r?i=t[3]:(i=(0,_.jsx)(n,{...r}),t[2]=r,t[3]=i),i}function x(e){let t=(0,h.c)(10),n,i,a;t[0]===e?(n=t[1],i=t[2],a=t[3]):({asChild:n,children:i,...a}=e,t[0]=e,t[1]=n,t[2]=i,t[3]=a);let o;t[4]!==n||t[5]!==i?(o=y(n,i),t[4]=n,t[5]=i,t[6]=o):o=t[6];let s=o,c;return t[7]!==a||t[8]!==s?(c=(0,_.jsx)(r,{"data-slot":`dialog-trigger`,...a,...s}),t[7]=a,t[8]=s,t[9]=c):c=t[9],c}function S(e){let t=(0,h.c)(4),n;t[0]===e?n=t[1]:({...n}=e,t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r=(0,_.jsx)(o,{...n}),t[2]=n,t[3]=r),r}var C=g.forwardRef((e,n)=>{let r=(0,h.c)(10),i,a;r[0]===e?(i=r[1],a=r[2]):({className:i,...a}=e,r[0]=e,r[1]=i,r[2]=a);let o;r[3]===Symbol.for(`react.memo_cache_sentinel`)?(o=[],r[3]=o):o=r[3],g.useEffect(A,o);let s=n,c;r[4]===i?c=r[5]:(c=p(`fixed inset-0 z-50 bg-black/50 dark:bg-black/75`,`transition-opacity duration-150 ease-out`,`data-[starting-style]:opacity-0 data-[ending-style]:opacity-0`,i),r[4]=i,r[5]=c);let l;return r[6]!==a||r[7]!==s||r[8]!==c?(l=(0,_.jsx)(t,{ref:s,"data-slot":`dialog-overlay`,className:c,...a}),r[6]=a,r[7]=s,r[8]=c,r[9]=l):l=r[9],l});C.displayName=`DialogOverlay`;function w(e){let t=(0,h.c)(29),n,r,o,s,c,l;t[0]===e?(n=t[1],r=t[2],o=t[3],s=t[4],c=t[5],l=t[6]):({className:r,overlayClassName:s,containerClassName:o,children:n,showCloseButton:l,...c}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=o,t[4]=s,t[5]=c,t[6]=l);let u=l===void 0||l,{t:d}=f(),g;t[7]===s?g=t[8]:(g=p(`rounded-none`,s),t[7]=s,t[8]=g);let v;t[9]===g?v=t[10]:(v=(0,_.jsx)(C,{className:g}),t[9]=g,t[10]=v);let y=o??`items-center p-4`,b;t[11]===y?b=t[12]:(b=p(`fixed inset-0 z-50 flex justify-center pointer-events-none`,y),t[11]=y,t[12]=b);let x;t[13]===r?x=t[14]:(x=p(`relative pointer-events-auto bg-background text-foreground flex flex-col w-full max-w-lg max-h-full gap-4 rounded-xl border p-6 shadow-none overflow-y-auto pwa-dialog-content origin-center`,`transition-all duration-150 ease-out`,`data-[starting-style]:opacity-0 data-[starting-style]:scale-[0.98]`,`data-[ending-style]:opacity-0 data-[ending-style]:scale-[0.98]`,`data-[nested-dialog-open]:brightness-[0.55] dark:data-[nested-dialog-open]:brightness-[0.4]`,r),t[13]=r,t[14]=x);let w;t[15]!==u||t[16]!==d?(w=u&&(0,_.jsxs)(i,{"data-slot":`dialog-close`,className:`ring-offset-background focus:ring-ring data-[open]:bg-interactive-active data-[open]:text-foreground absolute top-2 right-2 rounded-lg opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none text-muted-foreground hover:text-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,children:[(0,_.jsx)(m,{name:`close`}),(0,_.jsx)(`span`,{className:`sr-only`,children:d(`dialog.common.actions.close`)})]}),t[15]=u,t[16]=d,t[17]=w):w=t[17];let T;t[18]!==n||t[19]!==c||t[20]!==x||t[21]!==w?(T=(0,_.jsxs)(a,{"data-slot":`dialog-content`,"data-state-slot":`dialog`,className:x,...c,children:[n,w]}),t[18]=n,t[19]=c,t[20]=x,t[21]=w,t[22]=T):T=t[22];let E;t[23]!==b||t[24]!==T?(E=(0,_.jsx)(`div`,{className:b,children:T}),t[23]=b,t[24]=T,t[25]=E):E=t[25];let D;return t[26]!==v||t[27]!==E?(D=(0,_.jsxs)(S,{children:[v,E]}),t[26]=v,t[27]=E,t[28]=D):D=t[28],D}function T(e){let t=(0,h.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=p(`flex flex-col gap-2 text-center sm:text-left`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,_.jsx)(`div`,{"data-slot":`dialog-header`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function E(e){let t=(0,h.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=p(`flex flex-col-reverse gap-2 bottom-safe-area sm:flex-row sm:justify-end`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,_.jsx)(`div`,{"data-slot":`dialog-footer`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function D(e){let t=(0,h.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=p(`typography-markdown leading-none font-semibold text-foreground`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,_.jsx)(l,{"data-slot":`dialog-title`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function O(e){let t=(0,h.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=p(`text-muted-foreground typography-ui-label`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,_.jsx)(s,{"data-slot":`dialog-description`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function k(){v=Math.max(0,v-1),v===0&&document.documentElement.classList.remove(`oc-dialog-open`)}function A(){return v+=1,document.documentElement.classList.add(`oc-dialog-open`),k}export{T as a,E as i,w as n,D as o,O as r,x as s,b as t};
@@ -1,4 +0,0 @@
1
- import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{t}from"./useUIStore-Wyu09VUF.js";import{Xt as n}from"./persistence-aCOlo6ew.js";import{a as r,r as i}from"./vendor-zustand-B4dlGEM2.js";import{nt as a,rt as o}from"./vendor-base-ui-CnHfUmDN.js";import{Ct as s,Nt as c}from"./platform-DxNH_0Fj.js";import{n as l}from"./vendor-react-DLPElpoQ.js";import{n as u}from"./vendor-reactuses-core-DDoDDyM9.js";import{l as d,n as f}from"./clipboard-DyCy8o-j.js";import{Kn as p,Rn as m,To as h,Ya as g,Za as _,_r as v,br as y,c as b,l as x,la as S,nr as C,oa as w,pa as T,zn as E}from"./useMobileNavigationStore-DkBMOv1J.js";import{n as D,t as ee}from"./utils-CJdWZupK.js";import{n as O}from"./Icon-BAf2hhrw.js";import{t as te}from"./button-DfF088a8.js";import{n as ne}from"./gitApi-BZs3g7kL.js";import{C as re,M as ie,N as k,O as ae,S as A,_ as j,a as oe,b as se,g as ce,h as le,i as M,j as ue,k as de,n as N,o as P,p as F,v as fe,x as pe,y as I}from"./projectMeta-Ct-WdvZL.js";import{t as L}from"./input-Ca2tUhgN.js";import{i as R,n as me,t as z}from"./tooltip-GC3dg3gO.js";import{o as he}from"./OverlayScrollbar-DEM7AQRU.js";import{n as B}from"./useRuntimeAPIs-DSLXJybW.js";import{E as ge,T as _e,a as V,b as H,c as ve,g as U,k as ye,l as W,m as G,o as K,p as q,r as be,x as J}from"./insertionBoundaries-B9vsqCQ4.js";import{n as Y,r as xe,t as Se}from"./collapsible-CVL-5iEB.js";var X=e(o(),1),Ce=l(),Z=/^[a-z0-9](?:[a-z0-9-]{0,48}[a-z0-9])?$/,Q=/^g[1-9]\d*$/,we=(e,t,n,r,i)=>{if(!Z.test(e)||t!==void 0&&!Q.test(t)||!n?.trim()||!r?.trim()||n!==n.trim()||r!==r.trim())return null;if(i===void 0)return{groupSlug:e,runGroup:t,providerID:n,modelID:r,fusion:!1};if(i===`fusion`)return{groupSlug:e,runGroup:t,providerID:n,modelID:r,fusion:!0};if(!/^\d+$/.test(i))return null;let a=Number.parseInt(i,10);return!Number.isSafeInteger(a)||a<=0?null:{groupSlug:e,runGroup:t,providerID:n,modelID:r,index:a,fusion:!1}},Te=e=>{if(!e)return null;let t=e.split(`/`);if(t.length<3||t.length>5)return null;let[n]=t;if(t.length===3)return we(n,void 0,t[1],t[2],void 0);if(t.length===4){let[,e,r,i]=t;return Q.test(e)?we(n,e,r,i,void 0):we(n,void 0,e,r,i)}let[,r,i,a,o]=t;return r===``?we(n,void 0,i,a,o):we(n,r,i,a,o)},Ee=e=>{let t=[e.groupSlug];return e.runGroup&&t.push(e.runGroup),t.push(e.providerID,e.modelID),e.index!==void 0&&t.push(String(e.index)),t.join(`/`)},De=(e,t,n,r)=>{let i=[e];return r&&i.push(r),i.push(t,n,`fusion`),i.join(`/`)},Oe=e=>e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``).substring(0,50),ke=(e,t)=>`${Oe(e)}-${Oe(t)}`.substring(0,60),Ae=(e,t)=>`${e}/${t}`,je=e=>{let t=e.replace(/\\/g,`/`);return t===`/`?`/`:t.length>1?t.replace(/\/+$/,``):t},Me=(e,t)=>{let n=je(t),r=e.directory,i=typeof r==`string`&&r.trim().length>0?e:{...e,directory:n};T(e.id,n),x.getState().markSessionAsOpenChamberCreated(e.id),v.getState().upsertSession(i);try{S().ensureChild(n,{bootstrap:!1}).setState(t=>{let n=t.session.findIndex(t=>t.id===e.id);if(n>=0&&t.session[n]===i)return t;let r=n>=0?t.session.map((e,t)=>t===n?i:e):[...t.session,i].sort((e,t)=>e.id.localeCompare(t.id));return{session:r,sessionTotal:Math.max(t.sessionTotal,r.length),limit:Math.max(t.limit,r.length)}})}catch{}return i},Ne=()=>{let e=h.getState(),t=e.activeProjectId;if(!t)return null;let n=e.projects.find(e=>e.id===t);if(n?.path)return{id:n.id,path:n.path};let r=s.getState().currentDirectory??null;if(r&&r.trim().length>0){let e=r.replace(/\\/g,`/`).replace(/\/+$/,``)||r;return{id:`path:${e}`,path:e}}return null},Pe=r()(i(e=>({isLoading:!1,error:null,createMultiRun:async t=>{let n=t.name.trim(),{groups:r,agent:i,files:a,setupCommands:o}=t;if(!n)return e({error:`Group name is required`}),null;if(!r||r.length===0)return e({error:`At least one run group is required`}),null;for(let t=0;t<r.length;t++){if(!r[t].prompt.trim())return e({error:`Group ${t+1}: prompt is required`}),null;if(r[t].models.length<1)return e({error:`Group ${t+1}: select at least 1 model`}),null;if(r[t].models.length>5)return e({error:`Group ${t+1}: maximum 5 models allowed`}),null}e({isLoading:!0,error:null});try{let s=Ne();if(!s)return e({error:`Select a project`,isLoading:!1}),null;let l=s.path,u=await ne(l)&&t.isolateRuns!==!1,d=Oe(n),f=u?await F(l):void 0,m=u?await W(l):null,h=[],g=o?.filter(e=>e.trim().length>0)??[];for(let e=0;e<r.length;e++){let n=r[e],i=n.prompt,a=new Map;for(let e of n.models){let t=`${e.providerID}:${e.modelID}`;a.set(t,(a.get(t)||0)+1)}let o=new Map;for(let p of n.models){let n=`${p.providerID}:${p.modelID}`,_=a.get(n)||1,v=(o.get(n)||0)+1;o.set(n,v);let y=ke(p.providerID,p.modelID),b=r.length>1?`g${e+1}`:void 0,S=_>1?Ae(d,`${y}/${v}`):Ae(d,y),w=b?`${b}/${S}`:S,T=Ee({groupSlug:d,runGroup:b,providerID:p.providerID,modelID:p.modelID,index:_>1?v:void 0});try{if(!u){let e=await c.withDirectory(l,()=>c.createSession({title:T}));Me(e,l),h.push({sessionId:e.id,worktreePath:l,providerID:p.providerID,modelID:p.modelID,variant:p.variant,prompt:i});continue}let e=await ve(s,{preferredName:w,mode:`new`,branchName:w,worktreeName:w,startRef:t.worktreeBaseBranch||`HEAD`,setupCommands:g,returnAfterDirectoryCreated:!0},{resolvedRootTrackingRemote:m}),n={...e,createdFromBranch:f,kind:`standard`};await E(s)&&await C(e.path);let r=await c.withDirectory(e.path,()=>c.createSession({title:T}));Me(r,e.path),x.getState().setWorktreeMetadata(r.id,n),h.push({sessionId:r.id,worktreePath:e.path,providerID:p.providerID,modelID:p.modelID,variant:p.variant,prompt:i})}catch(e){console.warn(`[MultiRun] Failed to create session:`,e)}}}let _=o?.filter(e=>e.trim().length>0)??[];_.length>0&&p(s,_).catch(()=>{console.warn(`[MultiRun] Failed to save worktree setup commands`)});let v=h.map(e=>e.sessionId),y=h[0]?.sessionId??null;if(v.length===0)return e({error:`Failed to create any sessions`,isLoading:!1}),null;let S=a?.map(e=>({type:`file`,mime:e.mime,filename:e.filename,url:e.url}));return(async()=>{try{let e=ie.getState().expandText;await Promise.allSettled(h.map(async t=>{try{let n=await e(t.prompt).catch(()=>t.prompt);await b({sessionId:t.sessionId,directory:t.worktreePath,content:n,providerID:t.providerID,modelID:t.modelID,variant:t.variant,agent:i,files:S})}catch(e){console.warn(`[MultiRun] Failed to start run:`,e)}}))}catch(e){console.warn(`[MultiRun] Failed to start runs:`,e)}})(),e({isLoading:!1}),{groupSlug:d,sessionIds:v,firstSessionId:y}}catch(t){return e({error:t instanceof Error?t.message:`Failed to create Multi-Run`,isLoading:!1}),null}},clearError:()=>{e({error:null})}}),{name:`multirun-store`})),$=a(),Fe=`h-7`,Ie=()=>`${Date.now()}-${Math.random().toString(36).substring(2,9)}`,Le=e=>{let t=(0,Ce.c)(13),{model:n,instanceIndex:r,totalSameModel:i,onRemove:a}=e,o=n.displayName||`${n.providerID}/${n.modelID}`,s=i>1?`${o} (${r})`:o,c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=ee(`flex items-center gap-1.5 px-2 rounded-md bg-interactive-selection/20 border border-border/30`,Fe),t[0]=c):c=t[0];let l;t[1]!==n.modelID||t[2]!==n.providerID?(l=(0,$.jsx)(de,{modelId:n.modelID,providerId:n.providerID,className:`h-3.5 w-3.5`}),t[1]=n.modelID,t[2]=n.providerID,t[3]=l):l=t[3];let u;t[4]===s?u=t[5]:(u=(0,$.jsx)(`span`,{className:`typography-meta font-medium truncate max-w-[140px]`,children:s}),t[4]=s,t[5]=u);let d;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,$.jsx)(O,{name:`close`,className:`h-3.5 w-3.5`}),t[6]=d):d=t[6];let f;t[7]===a?f=t[8]:(f=(0,$.jsx)(`button`,{type:`button`,onClick:a,className:`text-muted-foreground hover:text-foreground ml-0.5`,children:d}),t[7]=a,t[8]=f);let p;return t[9]!==l||t[10]!==u||t[11]!==f?(p=(0,$.jsxs)(`div`,{className:c,children:[l,u,f]}),t[9]=l,t[10]=u,t[11]=f,t[12]=p):p=t[12],p},Re=e=>{let n=(0,Ce.c)(131),{selectedModels:r,onAdd:i,onRemove:a,onUpdate:o,minModels:s,addButtonLabel:c,showChips:l,maxModels:u,addButtonClassName:d,dropdownSide:p,dropdownClassName:m,containerClassName:h,triggerIcon:g}=e,v=l===void 0||l,y=p===void 0?`top`:p,{t:b}=f(),x=w(ze),S=w(Be),C=t(Ve),T=t(He),{favoriteModelsList:E,recentModelsList:D}=ae(),ne=t(Ue),ie=t(We),[k,j]=X.useState(!1),[oe,se]=X.useState(``),[M,ue]=X.useState(null),de=X.useRef(null),N=X.useRef(null),P=u===1,F=u===void 0||r.length<u||P,I;if(n[0]!==r){I=new Map;for(let e of r){let t=`${e.providerID}:${e.modelID}`;I.set(t,(I.get(t)||0)+1)}n[0]=r,n[1]=I}else I=n[1];let L=I,R;n[2]===r?R=n[3]:(R=e=>r.filter(t=>t.providerID===e.providerID&&t.modelID===e.modelID).findIndex(t=>t.instanceId===e.instanceId)+1,n[2]=r,n[3]=R);let me=R,z,he;n[4]!==y||n[5]!==k?(z=()=>{if(!k||!N.current)return;let e=N.current.getBoundingClientRect();if(y===`bottom`){let t=(window.visualViewport?.height??document.documentElement.clientHeight??window.innerHeight)-e.bottom-16-112;ue(Math.max(160,Math.min(320,t)));return}let t=N.current.parentElement;for(;t&&!(t.getAttribute(`role`)===`dialog`||t.hasAttribute(`data-scroll-shadow`));){let e=getComputedStyle(t);if(e.overflow===`auto`||e.overflow===`hidden`||e.overflowY===`auto`||e.overflowY===`hidden`)break;t=t.parentElement}let n=t?t.getBoundingClientRect().top:0,r=e.top-n-16;ue(Math.max(150,Math.min(300,r)))},he=[y,k],n[4]=y,n[5]=k,n[6]=z,n[7]=he):(z=n[6],he=n[7]),X.useEffect(z,he);let B,ge;n[8]!==F||n[9]!==k?(B=()=>{!F&&k&&(j(!1),se(``))},ge=[F,k],n[8]=F,n[9]=k,n[10]=B,n[11]=ge):(B=n[10],ge=n[11]),X.useEffect(B,ge);let _e,V;n[12]===k?(_e=n[13],V=n[14]):(_e=()=>{if(!k)return;let e=e=>{de.current&&!de.current.contains(e.target)&&(j(!1),se(``))};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},V=[k],n[12]=k,n[13]=_e,n[14]=V),X.useEffect(_e,V);let H;n[15]!==P||n[16]!==i||n[17]!==o||n[18]!==r.length?(H=e=>{let t={providerID:e.providerID,modelID:e.modelID,displayName:_(e.model,e.modelID)||e.modelID,instanceId:Ie()};P&&r.length>0&&o?o(0,t):i(t),P&&(j(!1),se(``))},n[15]=P,n[16]=i,n[17]=o,n[18]=r.length,n[19]=H):H=n[19];let ve=H,U;n[20]===b?U=n[21]:(U=b(`multirun.modelMultiSelect.search.placeholder`),n[20]=b,n[21]=U);let ye;n[22]===b?ye=n[23]:(ye=b(`multirun.modelMultiSelect.search.noResults`),n[22]=b,n[23]=ye);let W;n[24]===b?W=n[25]:(W=b(`multirun.modelMultiSelect.sections.favorites`),n[24]=b,n[25]=W);let G;n[26]===b?G=n[27]:(G=b(`multirun.modelMultiSelect.sections.recent`),n[26]=b,n[27]=G);let K;n[28]===b?K=n[29]:(K=b(`multirun.modelMultiSelect.keyboard.hint`),n[28]=b,n[29]=K);let q;n[30]===b?q=n[31]:(q=b(`settings.agents.modelSelector.actions.favorite`),n[30]=b,n[31]=q);let be;n[32]===b?be=n[33]:(be=b(`settings.agents.modelSelector.actions.unfavorite`),n[32]=b,n[33]=be);let J;n[34]===b?J=n[35]:(J=b(`chat.modelControls.provider`),n[34]=b,n[35]=J);let Y;n[36]===b?Y=n[37]:(Y=b(`chat.modelControls.capabilities`),n[36]=b,n[37]=Y);let xe;n[38]===b?xe=n[39]:(xe=b(`chat.modelControls.capability.toolCalling`),n[38]=b,n[39]=xe);let Se;n[40]===b?Se=n[41]:(Se=b(`chat.modelControls.capability.reasoning`),n[40]=b,n[41]=Se);let Z;n[42]===b?Z=n[43]:(Z=b(`chat.modelControls.modality.image`),n[42]=b,n[43]=Z);let Q;n[44]===b?Q=n[45]:(Q=b(`chat.modelControls.modality.video`),n[44]=b,n[45]=Q);let we;n[46]===b?we=n[47]:(we=b(`chat.modelControls.modality.audio`),n[46]=b,n[47]=we);let Te;n[48]===b?Te=n[49]:(Te=b(`chat.modelControls.costPerMillion`),n[48]=b,n[49]=Te);let Ee;n[50]===b?Ee=n[51]:(Ee=b(`chat.modelControls.costInput`),n[50]=b,n[51]=Ee);let De;n[52]===b?De=n[53]:(De=b(`chat.modelControls.costOutput`),n[52]=b,n[53]=De);let Oe;n[54]!==U||n[55]!==ye||n[56]!==W||n[57]!==G||n[58]!==K||n[59]!==q||n[60]!==be||n[61]!==J||n[62]!==Y||n[63]!==xe||n[64]!==Se||n[65]!==Z||n[66]!==Q||n[67]!==we||n[68]!==Te||n[69]!==Ee||n[70]!==De?(Oe={searchPlaceholder:U,noResults:ye,favorites:W,recent:G,keyboardHint:K,favorite:q,unfavorite:be,provider:J,capabilities:Y,capabilityToolCalling:xe,capabilityReasoning:Se,modalityImage:Z,modalityVideo:Q,modalityAudio:we,costPerMillion:Te,costInput:Ee,costOutput:De},n[54]=U,n[55]=ye,n[56]=W,n[57]=G,n[58]=K,n[59]=q,n[60]=be,n[61]=J,n[62]=Y,n[63]=xe,n[64]=Se,n[65]=Z,n[66]=Q,n[67]=we,n[68]=Te,n[69]=Ee,n[70]=De,n[71]=Oe):Oe=n[71];let ke=Oe,Ae;n[72]===h?Ae=n[73]:(Ae=ee(`relative`,h),n[72]=h,n[73]=Ae);let je;n[74]===d?je=n[75]:(je=ee(Fe,`!border-border/80 !bg-[var(--surface-subtle)] hover:!bg-[var(--interactive-hover)]/70`,d),n[74]=d,n[75]=je);let Me=!F,Ne;n[76]===k?Ne=n[77]:(Ne=()=>{j(!k)},n[76]=k,n[77]=Ne);let Pe;n[78]===g?Pe=n[79]:(Pe=g??(0,$.jsx)(O,{name:`add`,className:`h-3.5 w-3.5 mr-1`}),n[78]=g,n[79]=Pe);let Re;n[80]!==c||n[81]!==b?(Re=c??b(`multirun.modelMultiSelect.actions.addModel`),n[80]=c,n[81]=b,n[82]=Re):Re=n[82];let Ke;n[83]!==je||n[84]!==Me||n[85]!==Ne||n[86]!==Pe||n[87]!==Re?(Ke=(0,$.jsxs)(te,{ref:N,type:`button`,variant:`outline`,size:`sm`,className:je,disabled:Me,onClick:Ne,children:[Pe,Re]}),n[83]=je,n[84]=Me,n[85]=Ne,n[86]=Pe,n[87]=Re,n[88]=Ke):Ke=n[88];let qe;n[89]!==M||n[90]!==F||n[91]!==m||n[92]!==y||n[93]!==E||n[94]!==S||n[95]!==ve||n[96]!==ne||n[97]!==T||n[98]!==k||n[99]!==ke||n[100]!==L||n[101]!==ie||n[102]!==x||n[103]!==D||n[104]!==oe||n[105]!==C?(qe=k?(0,$.jsx)(`div`,{className:ee(`absolute left-0 z-50 w-[min(420px,calc(100vw-2rem))] max-w-[calc(100vw-2rem)] flex flex-col overflow-hidden rounded-xl border border-border/50 shadow-lg`,y===`top`?`bottom-full mb-1`:`top-full mt-1`,m),style:{background:`linear-gradient(var(--surface-elevated),var(--surface-elevated)),linear-gradient(var(--surface-background),var(--surface-background))`},children:(0,$.jsx)(re,{providers:x,providerOrder:ie,favoriteModels:E,recentModels:D,getMetadata:S,hiddenModels:ne,searchQuery:oe,onSearchQueryChange:se,onSelect:ve,labels:ke,selectionCount:e=>L.get(`${e.providerID}:${e.modelID}`)||0,disabled:!F,maxHeightClassName:`flex-1`,maxHeightStyle:{maxHeight:M?`${M}px`:`300px`},stickyHeaders:!0,tooltipsEnabled:k,isFavorite:e=>T(e.providerID,e.modelID),onToggleFavorite:e=>C(e.providerID,e.modelID),onEscape:()=>{j(!1),se(``)}})}):null,n[89]=M,n[90]=F,n[91]=m,n[92]=y,n[93]=E,n[94]=S,n[95]=ve,n[96]=ne,n[97]=T,n[98]=k,n[99]=ke,n[100]=L,n[101]=ie,n[102]=x,n[103]=D,n[104]=oe,n[105]=C,n[106]=qe):qe=n[106];let Je;n[107]!==Ae||n[108]!==Ke||n[109]!==qe?(Je=(0,$.jsxs)(`div`,{className:Ae,ref:de,children:[Ke,qe]}),n[107]=Ae,n[108]=Ke,n[109]=qe,n[110]=Je):Je=n[110];let Ye;n[111]!==me||n[112]!==L||n[113]!==a||n[114]!==o||n[115]!==x||n[116]!==r||n[117]!==v||n[118]!==b?(Ye=v&&r.length>0&&(0,$.jsx)(`div`,{className:`flex flex-col gap-2 w-full`,children:r.map((e,t)=>{let n=`${e.providerID}:${e.modelID}`,r=L.get(n)||1,i=me(e),s=x.find(t=>t.id===e.providerID)?.models?.find(t=>t.id===e.modelID),c=s?.variants?Object.keys(s.variants):[],l=c.length>0,u=e.variant??`__default__`;return(0,$.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,$.jsx)(Le,{model:e,instanceIndex:i,totalSameModel:r,onRemove:()=>a(t)}),l&&(0,$.jsxs)(le,{value:u,onValueChange:n=>{if(!o)return;let r=n===`__default__`?void 0:n;o(t,{...e,variant:r})},children:[(0,$.jsxs)(pe,{size:`chip`,className:`px-2 gap-1.5 rounded-md !border-border/80 !bg-[var(--surface-subtle)] hover:!bg-[var(--interactive-hover)]/70 typography-meta font-medium text-foreground`,children:[(0,$.jsx)(O,{name:`brain-ai-3`,className:ee(`h-3.5 w-3.5 flex-shrink-0`,u===`__default__`?`text-muted-foreground`:`text-[color:var(--status-info)]`)}),(0,$.jsx)(A,{placeholder:b(`multirun.modelMultiSelect.variant.placeholder`),children:e=>e===`__default__`?b(`multirun.modelMultiSelect.variant.default`):e})]}),(0,$.jsxs)(ce,{fitContent:!0,children:[(0,$.jsx)(fe,{value:`__default__`,className:`pr-2 [&>span:first-child]:hidden`,children:b(`multirun.modelMultiSelect.variant.default`)}),c.map(Ge)]})]})]},e.instanceId)})}),n[111]=me,n[112]=L,n[113]=a,n[114]=o,n[115]=x,n[116]=r,n[117]=v,n[118]=b,n[119]=Ye):Ye=n[119];let Xe;n[120]!==Je||n[121]!==Ye?(Xe=(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-1.5 items-center`,children:[Je,Ye]}),n[120]=Je,n[121]=Ye,n[122]=Xe):Xe=n[122];let Ze;n[123]!==u||n[124]!==s||n[125]!==r.length||n[126]!==b?(Ze=s!==void 0&&r.length<s&&(0,$.jsx)(`p`,{className:`typography-micro text-muted-foreground`,children:u===void 0?b(`multirun.modelMultiSelect.validation.minOnly`,{min:s}):b(`multirun.modelMultiSelect.validation.minToMax`,{min:s,max:u})}),n[123]=u,n[124]=s,n[125]=r.length,n[126]=b,n[127]=Ze):Ze=n[127];let Qe;return n[128]!==Xe||n[129]!==Ze?(Qe=(0,$.jsxs)(`div`,{className:`space-y-2`,children:[Xe,Ze]}),n[128]=Xe,n[129]=Ze,n[130]=Qe):Qe=n[130],Qe};function ze(e){return e.providers}function Be(e){return e.getModelMetadata}function Ve(e){return e.toggleFavoriteModel}function He(e){return e.isFavoriteModel}function Ue(e){return e.hiddenModels}function We(e){return e.providerOrder}function Ge(e){return(0,$.jsx)(fe,{value:e,className:`pr-2 [&>span:first-child]:hidden`,children:e},e)}function Ke(e){let t=(0,Ce.c)(30),{git:n}=B(),r=q(e),i=J(e),a=U(e),o=G(e),s=H(Ze),c=H(Xe),l,u;t[0]!==e||t[1]!==c||t[2]!==n||t[3]!==i||t[4]!==a?(l=()=>{!e||!n||i!==null||a||c(e,n,{silent:!0})},u=[e,n,c,i,a],t[0]=e,t[1]=c,t[2]=n,t[3]=i,t[4]=a,t[5]=l,t[6]=u):(l=t[5],u=t[6]),X.useEffect(l,u);let d;t[7]!==r?.all||t[8]!==e||t[9]!==s||t[10]!==n||t[11]!==i?(d=()=>{!e||!n||i===!0&&(r?.all||s(e,n))},t[7]=r?.all,t[8]=e,t[9]=s,t[10]=n,t[11]=i,t[12]=d):d=t[12];let f=r?.all,p;t[13]!==e||t[14]!==s||t[15]!==n||t[16]!==i||t[17]!==f?(p=[e,n,i,f,s],t[13]=e,t[14]=s,t[15]=n,t[16]=i,t[17]=f,t[18]=p):p=t[18],X.useEffect(d,p);let m=a||i===!0&&o,h;bb0:{if(!r?.all){let e;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[19]=e):e=t[19],h=e;break bb0}let e;t[20]===r.all?e=t[21]:(e=r.all.filter(Ye).sort(),t[20]=r.all,t[21]=e),h=e}let g=h,_;bb1:{if(!r?.all){let e;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[22]=e):e=t[22],_=e;break bb1}let e;t[23]===r.all?e=t[24]:(e=r.all.filter(Je).map(qe).sort(),t[23]=r.all,t[24]=e),_=e}let v=_,y;bb2:{if(!e){y=null;break bb2}if(i!==null){y=i;break bb2}if(m){y=null;break bb2}y=r?.all?!0:null}let b=y,x;return t[25]!==b||t[26]!==m||t[27]!==g||t[28]!==v?(x={localBranches:g,remoteBranches:v,isLoading:m,isGitRepository:b},t[25]=b,t[26]=m,t[27]=g,t[28]=v,t[29]=x):x=t[29],x}function qe(e){return e.replace(/^remotes\//,``)}function Je(e){return e.startsWith(`remotes/`)}function Ye(e){return!e.startsWith(`remotes/`)}function Xe(e){return e.fetchStatus}function Ze(e){return e.fetchBranches}var Qe=({directory:e,value:t,onChange:n,className:r,disabled:i,id:a})=>{let{t:o}=f(),{localBranches:s,remoteBranches:c,isLoading:l,isGitRepository:u}=Ke(e),d=X.useMemo(()=>[...s,...c.map(e=>`remotes/${e}`)],[s,c]);return X.useEffect(()=>{if(i||l||d.length===0||t&&d.includes(t))return;let r=t,a=!1;return(async()=>{try{let t=e?await F(e).catch(()=>null):null;if(a)return;let i=localStorage.getItem(V),{sourceBranch:o,shouldClearSavedSourceBranch:s}=K({branches:d,savedSourceBranch:i,rootBranch:t});if(s&&localStorage.removeItem(V),a||r&&d.includes(r))return;o&&n(o)}catch{}})(),()=>{a=!0}},[d,e,i,l,n,t]),(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(le,{value:t,onValueChange:n,disabled:i||!u||l,children:[(0,$.jsx)(pe,{id:a,size:`lg`,className:r??`w-fit typography-meta text-foreground`,children:(0,$.jsx)(A,{placeholder:o(l?`multiRun.branchSelector.status.loadingBranches`:`multiRun.branchSelector.placeholder.selectSourceBranch`)})}),(0,$.jsx)(ce,{className:`max-h-[280px] max-w-[320px]`,children:l?(0,$.jsx)(`div`,{className:`px-2 py-4 text-center typography-meta text-muted-foreground`,children:o(`multiRun.branchSelector.status.loadingBranches`)}):s.length===0&&c.length===0?(0,$.jsx)(`div`,{className:`px-2 py-4 text-center typography-meta text-muted-foreground`,children:o(`multiRun.branchSelector.status.noBranchesFound`)}):(0,$.jsxs)($.Fragment,{children:[s.length>0&&(0,$.jsxs)(j,{children:[(0,$.jsx)(I,{className:`font-semibold text-foreground`,children:o(`multiRun.branchSelector.groups.localBranches`)}),s.map(e=>(0,$.jsx)(fe,{value:e,className:`whitespace-normal break-all`,children:e},e))]}),s.length>0&&c.length>0&&(0,$.jsx)(se,{}),c.length>0&&(0,$.jsxs)(j,{children:[(0,$.jsx)(I,{className:`font-semibold text-foreground`,children:o(`multiRun.branchSelector.groups.remoteBranches`)}),c.map(e=>(0,$.jsx)(fe,{value:`remotes/${e}`,className:`whitespace-normal break-all`,children:e},`remotes/${e}`))]})]})})]}),u===!1&&(0,$.jsx)(`p`,{className:`typography-micro text-muted-foreground/70 mt-2`,children:o(`multiRun.branchSelector.status.notInGitRepository`)})]})},$e=e=>{let t=(0,Ce.c)(36),{value:n,onChange:r,className:i,disabled:a,id:o,portalToBody:s}=e,{t:c}=f(),l=w(et),u=w(tt),d=w(nt),p;t[0]===l?p=t[1]:(p=l(),t[0]=l,t[1]=p);let m=p,h;t[2]===m?h=t[3]:(h=m.filter(rt),t[2]=m,t[3]=h);let g=h,_,v;t[4]!==m.length||t[5]!==u?(_=()=>{m.length===0&&u()},v=[m.length,u],t[4]=m.length,t[5]=u,t[6]=_,t[7]=v):(_=t[6],v=t[7]),X.useEffect(_,v);let y,b;t[8]!==d||t[9]!==a||t[10]!==r||t[11]!==g||t[12]!==n?(y=()=>{if(a)return;let e=n.trim();if(e.length>0&&g.some(t=>t.name===e))return;let t=typeof d==`string`&&d.trim().length>0?d.trim():null;if(t&&g.some(e=>e.name===t)){r(t);return}let i=g[0]?.name;i&&r(i)},b=[d,a,r,g,n],t[8]=d,t[9]=a,t[10]=r,t[11]=g,t[12]=n,t[13]=y,t[14]=b):(y=t[13],b=t[14]),X.useEffect(y,b);let x=n.trim().length>0?n:void 0,S;t[15]===i?S=t[16]:(S=ee(`max-w-full typography-meta text-foreground !border-border/80 !bg-[var(--surface-subtle)] hover:!bg-[var(--interactive-hover)]/70 data-[popup-open]:!bg-[var(--interactive-active)]/70`,i),t[15]=i,t[16]=S);let C;t[17]===c?C=t[18]:(C=c(`multirun.agentSelector.placeholder`),t[17]=c,t[18]=C);let T;t[19]===C?T=t[20]:(T=(0,$.jsx)(A,{placeholder:C}),t[19]=C,t[20]=T);let E;t[21]!==o||t[22]!==S||t[23]!==T?(E=(0,$.jsx)(pe,{id:o,size:`lg`,className:S,children:T}),t[21]=o,t[22]=S,t[23]=T,t[24]=E):E=t[24];let D;t[25]===g?D=t[26]:(D=g.length>0&&(0,$.jsx)(j,{children:g.map(it)}),t[25]=g,t[26]=D);let O;t[27]!==s||t[28]!==D?(O=(0,$.jsx)(ce,{fitContent:!0,portalToBody:s,children:D}),t[27]=s,t[28]=D,t[29]=O):O=t[29];let te;return t[30]!==a||t[31]!==r||t[32]!==x||t[33]!==E||t[34]!==O?(te=(0,$.jsxs)(le,{value:x,onValueChange:r,disabled:a,children:[E,O]}),t[30]=a,t[31]=r,t[32]=x,t[33]=E,t[34]=O,t[35]=te):te=t[35],te};function et(e){return e.getVisibleAgents}function tt(e){return e.loadAgents}function nt(e){return e.currentAgentName}function rt(e){return g(e.mode)}function it(e){return(0,$.jsx)(fe,{value:e.name,className:`w-auto whitespace-nowrap`,children:e.name},e.name)}var at=10485760,ot=5,st=e=>{let t=(0,Ce.c)(3),{children:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsx)(R,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,tabIndex:-1,className:`inline-flex items-center justify-center text-muted-foreground/50 hover:text-muted-foreground transition-colors`,children:(0,$.jsx)(O,{name:`information`,className:`h-3.5 w-3.5`})})}),t[0]=r):r=t[0];let i;return t[1]===n?i=t[2]:(i=(0,$.jsxs)(z,{children:[r,(0,$.jsx)(me,{side:`top`,className:`max-w-[240px]`,children:n})]}),t[1]=n,t[2]=i),i},ct=e=>{let t=(0,Ce.c)(9),{htmlFor:n,required:r,children:i,info:a}=e,o;t[0]===r?o=t[1]:(o=r&&(0,$.jsx)(`span`,{className:`text-destructive ml-0.5`,children:`*`}),t[0]=r,t[1]=o);let s;t[2]!==i||t[3]!==n||t[4]!==o?(s=(0,$.jsxs)(`label`,{htmlFor:n,className:`typography-meta font-medium text-foreground`,children:[i,o]}),t[2]=i,t[3]=n,t[4]=o,t[5]=s):s=t[5];let c=a&&a,l;return t[6]!==s||t[7]!==c?(l=(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[s,c]}),t[6]=s,t[7]=c,t[8]=l):l=t[8],l},lt=e=>{let t=D(e.path),n=e.icon?M[e.icon]:null,r=e.color?N[e.color]:void 0,i=(0,$.jsx)(O,{name:n??`folder`,className:`h-3.5 w-3.5`,style:r?{color:r}:void 0});return(0,$.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-1.5`,children:[(0,$.jsx)(`span`,{className:`flex h-4 w-4 shrink-0 items-center justify-center overflow-hidden text-muted-foreground`,children:e.iconImage?(0,$.jsx)(oe,{project:e,className:`size-full object-contain`,fallback:i}):i}),(0,$.jsx)(`span`,{className:`truncate`,children:t})]})},ut=({initialPrompt:e,onCreated:t,onCancel:r,isWindowed:i=!1})=>{let{t:a}=f(),[o,c]=X.useState(``),[l,p]=X.useState(()=>[{id:Ie(),prompt:``,models:[]}]),[g,_]=X.useState(``),[v,b]=X.useState([]),[S,C]=X.useState(!1),[w,T]=X.useState([]),[E,D]=X.useState(!1),[ne,re]=X.useState(!1),[ie,ae]=X.useState(!0),j=X.useRef(null),oe=s(e=>e.currentDirectory??null),se=X.useMemo(()=>{if(typeof window>`u`)return null;let e=window.__VSCODE_CONFIG__?.workspaceFolder;return typeof e==`string`&&e.trim().length>0?e.trim():null},[]),M=h(e=>e.activeProjectId),de=h(e=>e.setActiveProjectIdOnly),N=h(e=>e.projects),[P,F]=X.useState(()=>M??null);X.useEffect(()=>{if(M){F(M);return}!P&&N.length>0&&F(N[0].id)},[M,N,P]);let I=X.useMemo(()=>P?N.find(e=>e.id===P)??null:null,[N,P]),B=I?.path??oe,ge=u(e=>{F(e),e!==M&&de(e)}),_e=X.useMemo(()=>{if(I?.path)return{id:I.id,path:I.path};let e=oe??se;return e?{id:`path:${e}`,path:e}:null},[I,oe,se]),[V]=X.useState(()=>typeof window<`u`&&n()),H=X.useMemo(()=>typeof navigator>`u`?!1:/Macintosh|Mac OS X/.test(navigator.userAgent||``),[]),ve=he(),U=X.useMemo(()=>{if(typeof window>`u`)return null;let e=window.__OPENCHAMBER_MACOS_MAJOR__;if(typeof e==`number`&&Number.isFinite(e)&&e>0)return e;if(typeof navigator>`u`)return null;let t=(navigator.userAgent||``).match(/Mac OS X (\d+)[._](\d+)/);if(!t)return null;let n=Number.parseInt(t[1],10),r=Number.parseInt(t[2],10);return Number.isNaN(n)?null:n===10?r:n},[]),ye=X.useMemo(()=>V&&H||ve?`pl-[5.5rem]`:`pl-3`,[V,H,ve]),W=X.useMemo(()=>!V||!H||U===null?``:U>=26?`h-12`:U<=15?`h-14`:``,[V,H,U]),G=u(async e=>{e.target.closest(`button, a, input, select, textarea`)||e.button===0&&V&&await d()}),K=u(e=>{r&&e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),r())}),q=!!r;X.useEffect(()=>{if(q)return window.addEventListener(`keydown`,K,!0),()=>window.removeEventListener(`keydown`,K,!0)},[q]);let[be,J]=X.useState(``),{isLoading:Ce,isGitRepository:Z}=Ke(B),Q=X.useRef(!1),we=Z===!0,Te=we&&ie;X.useEffect(()=>{if(Z===!1){Q.current=!0,ae(!1);return}Z===!0&&Q.current&&(Q.current=!1,ae(!0))},[Z]);let Ee=Pe(e=>e.createMultiRun),De=Pe(e=>e.error),Oe=Pe(e=>e.clearError);X.useEffect(()=>{typeof e==`string`&&e.trim().length>0&&p(t=>{let n=[...t];return n.length>0&&!n[0].prompt.trim()&&(n[0]={...n[0],prompt:e}),n})},[e]),X.useEffect(()=>{if(!_e)return;let e=!1;return re(!0),(async()=>{try{let t=await m(_e);e||T(t)}catch{}finally{e||re(!1)}})(),()=>{e=!0}},[_e]);let ke=u((e,t)=>{p(n=>n.map(n=>n.id===e?{...n,...t}:n))}),Ae=u(e=>{p(t=>t.filter(t=>t.id!==e))}),je=u(()=>{p(e=>[...e,{id:Ie(),prompt:``,models:[]}])}),Me=async e=>{let t=e.target.files;if(!t)return;let n=0;for(let e=0;e<t.length;e++){let r=t[e];if(r.size>at){y.error(a(`multirun.launcher.toast.fileTooLarge`,{fileName:r.name}));continue}try{let e=await new Promise((e,t)=>{let n=new FileReader;n.onload=()=>e(n.result),n.onerror=t,n.readAsDataURL(r)});b(t=>[...t,{id:Ie(),filename:r.name,mimeType:r.type||`application/octet-stream`,size:r.size,dataUrl:e}]),n++}catch(e){console.error(`File attach failed`,e),y.error(a(`multirun.launcher.toast.attachFailed`,{fileName:r.name}))}}n>0&&y.success(a(n===1?`multirun.launcher.toast.attachedSingle`:`multirun.launcher.toast.attachedPlural`,{count:n})),j.current&&(j.current.value=``)},Ne=e=>{b(t=>t.filter(t=>t.id!==e))},Fe=X.useMemo(()=>l.reduce((e,t)=>e+t.models.length,0),[l]),Le=async e=>{e.preventDefault();let n=l.filter(e=>e.prompt.trim()&&e.models.length>=1);if(n.length!==0&&!(Fe<1)){C(!0),Oe();try{P&&P!==M&&de(P);let e=v.map(e=>({mime:e.mimeType,filename:e.filename,url:e.dataUrl})),r=w.filter(e=>e.trim().length>0),i=n.map(e=>({prompt:e.prompt.trim(),models:e.models.map(e=>({providerID:e.providerID,modelID:e.modelID,displayName:e.displayName,variant:e.variant}))})),a={name:o.trim(),groups:i,agent:g||void 0,worktreeBaseBranch:Te?be:void 0,isolateRuns:Te,files:e.length>0?e:void 0,setupCommands:r.length>0?r:void 0},s=await Ee(a);s&&(s.firstSessionId&&x.getState().setCurrentSession(s.firstSessionId),t?.())}finally{C(!1)}}},Re=!!(o.trim()&&l.some(e=>e.prompt.trim()&&e.models.length>=1)&&Fe>=1&&B&&!Ce&&(Z===!1||!Te||be)),ze=w.filter(e=>e.trim()).length;return(0,$.jsxs)(`form`,{onSubmit:Le,className:`flex flex-col h-full bg-background`,children:[i?null:(0,$.jsxs)(`header`,{onMouseDown:G,className:ee(`relative flex h-12 shrink-0 items-center justify-center border-b app-region-drag select-none`,ye,W),style:{borderColor:`var(--interactive-border)`},children:[(0,$.jsx)(`h1`,{className:`typography-ui-label font-medium`,children:a(`multirun.launcher.title`)}),r&&(0,$.jsx)(`div`,{className:`absolute right-0 flex items-center pr-3`,children:(0,$.jsxs)(z,{children:[(0,$.jsx)(R,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,onClick:r,"aria-label":a(`multirun.launcher.actions.closeEsc`),className:`inline-flex h-9 w-9 items-center justify-center p-2 rounded-lg text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary app-region-no-drag`,children:(0,$.jsx)(O,{name:`close`,className:`h-5 w-5`})})}),(0,$.jsx)(me,{children:(0,$.jsx)(`p`,{children:a(`multirun.launcher.actions.closeEsc`)})})]})})]}),(0,$.jsx)(ue,{className:`flex-1 min-h-0 overflow-auto`,size:64,hideTopShadow:!0,children:(0,$.jsx)(`div`,{className:`mx-auto w-full max-w-2xl px-4 sm:px-6 py-5`,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-x-4 gap-y-3`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(ct,{htmlFor:`multirun-project`,required:!0,children:a(`multirun.launcher.project.label`)}),N.length>0?(0,$.jsxs)(le,{value:P??void 0,onValueChange:ge,children:[(0,$.jsx)(pe,{id:`multirun-project`,size:`lg`,className:`w-fit max-w-full`,children:I?(0,$.jsx)(A,{children:lt(I)}):(0,$.jsx)(A,{placeholder:a(`multirun.launcher.project.placeholder`)})}),(0,$.jsx)(ce,{fitContent:!0,children:N.map(e=>(0,$.jsx)(fe,{value:e.id,className:`max-w-[24rem]`,children:lt(e)},e.id))})]}):(0,$.jsx)(`p`,{className:`typography-micro text-muted-foreground py-2`,children:a(`multirun.launcher.project.empty`)})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(ct,{htmlFor:`group-name`,required:!0,info:(0,$.jsx)(st,{children:a(`multirun.launcher.groupName.info`)}),children:a(`multirun.launcher.groupName.label`)}),(0,$.jsx)(L,{id:`group-name`,value:o,onChange:e=>c(e.target.value),placeholder:a(`multirun.launcher.groupName.placeholder`),className:`typography-meta w-full`,required:!0})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(ct,{htmlFor:`multirun-worktree-base-branch`,info:(0,$.jsx)(st,{children:a(`multirun.launcher.baseBranch.info`)}),children:a(`multirun.launcher.baseBranch.label`)}),(0,$.jsx)(Qe,{directory:B,value:be,onChange:J,disabled:!Te,id:`multirun-worktree-base-branch`}),(0,$.jsxs)(`label`,{className:`mt-1.5 flex w-fit items-center gap-1.5 typography-micro text-muted-foreground`,children:[(0,$.jsx)(k,{checked:ie,onChange:ae,disabled:!we,ariaLabel:a(`multirun.launcher.isolateRuns.label`)}),(0,$.jsx)(`span`,{children:a(`multirun.launcher.isolateRuns.label`)})]})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(ct,{htmlFor:`multirun-agent`,info:(0,$.jsx)(st,{children:a(`multirun.launcher.agent.info`)}),children:a(`multirun.launcher.agent.label`)}),(0,$.jsx)($e,{value:g,onChange:_,id:`multirun-agent`})]})]}),(0,$.jsxs)(Se,{open:E,onOpenChange:D,children:[(0,$.jsxs)(xe,{className:`w-full flex items-center gap-2 py-1.5 px-2 -mx-2 rounded-lg hover:bg-[var(--interactive-hover)]/50 transition-colors group`,children:[(0,$.jsx)(O,{name:`terminal`,className:`h-3.5 w-3.5 text-muted-foreground/70`}),(0,$.jsx)(`span`,{className:`typography-meta font-medium text-muted-foreground group-hover:text-foreground transition-colors`,children:a(`multirun.launcher.setupCommands.label`)}),ze>0&&(0,$.jsx)(`span`,{className:`inline-flex items-center justify-center h-4 min-w-4 px-1 rounded-full typography-micro font-medium`,style:{backgroundColor:`var(--primary-base)`,color:`var(--primary-foreground)`,fontSize:`0.625rem`,lineHeight:1},children:ze}),(0,$.jsx)(O,{name:`arrow-down-s`,className:ee(`h-3.5 w-3.5 text-muted-foreground/50 transition-transform duration-200 ml-auto`,E&&`rotate-180`)})]}),(0,$.jsx)(Y,{children:(0,$.jsx)(`div`,{className:`pt-2 space-y-1.5`,children:ne?(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground/70 px-2`,children:a(`multirun.launcher.setupCommands.loading`)}):(0,$.jsxs)($.Fragment,{children:[w.map((e,t)=>(0,$.jsxs)(`div`,{className:`flex gap-1.5`,children:[(0,$.jsx)(L,{value:e,onChange:e=>{let n=[...w];n[t]=e.target.value,T(n)},placeholder:a(`multirun.launcher.setupCommands.commandPlaceholder`),className:`h-8 flex-1 font-mono text-xs`}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>T(w.filter((e,n)=>n!==t)),className:`flex-shrink-0 flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground hover:text-destructive hover:bg-destructive/10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,"aria-label":a(`multirun.launcher.setupCommands.removeCommandAria`),children:(0,$.jsx)(O,{name:`close`,className:`h-3.5 w-3.5`})})]},`${e}-${t}`)),(0,$.jsxs)(`button`,{type:`button`,onClick:()=>T([...w,``]),className:`flex items-center gap-1 typography-meta text-muted-foreground hover:text-foreground transition-colors px-1`,children:[(0,$.jsx)(O,{name:`add`,className:`h-3 w-3`}),a(`multirun.launcher.setupCommands.addCommand`)]})]})})})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(ct,{htmlFor:`prompt`,required:!0,children:a(`multirun.launcher.attachments.label`)}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,$.jsx)(`input`,{ref:j,type:`file`,multiple:!0,className:`hidden`,onChange:Me,accept:`*/*`}),(0,$.jsxs)(z,{children:[(0,$.jsx)(R,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,onClick:()=>j.current?.click(),className:`inline-flex items-center gap-1 h-6 px-2 rounded-md typography-micro text-muted-foreground hover:text-foreground hover:bg-[var(--interactive-hover)]/50 transition-colors`,children:[(0,$.jsx)(O,{name:`attachment-2`,className:`h-3 w-3`}),a(`multirun.launcher.attachments.attach`)]})}),(0,$.jsx)(me,{children:a(`multirun.launcher.attachments.tooltip`)})]}),v.map(e=>(0,$.jsxs)(`div`,{className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded-md typography-micro border`,style:{backgroundColor:`var(--surface-elevated)`,borderColor:`var(--interactive-border)`},children:[e.mimeType.startsWith(`image/`)?(0,$.jsx)(O,{name:`file-image`,className:`h-3 w-3 text-muted-foreground`}):(0,$.jsx)(O,{name:`file`,className:`h-3 w-3 text-muted-foreground`}),(0,$.jsx)(`span`,{className:`truncate max-w-[100px]`,title:e.filename,children:e.filename}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>Ne(e.id),className:`text-muted-foreground hover:text-destructive`,children:(0,$.jsx)(O,{name:`close`,className:`h-3 w-3`})})]},e.id))]})]}),l.map((e,t)=>(0,$.jsx)(dt,{group:e,groupIndex:t,canRemove:l.length>1,onUpdate:ke,onRemove:Ae},e.id)),(0,$.jsxs)(`button`,{type:`button`,onClick:je,className:`flex items-center gap-1.5 py-2 px-3 -mx-3 rounded-lg typography-meta font-medium text-muted-foreground hover:text-foreground hover:bg-[var(--interactive-hover)]/50 transition-colors`,children:[(0,$.jsx)(O,{name:`add`,className:`h-3.5 w-3.5`}),a(`multirun.launcher.groups.addGroup`)]}),De&&(0,$.jsx)(`div`,{className:`px-3 py-2 rounded-lg typography-meta`,style:{backgroundColor:`var(--status-error-background)`,color:`var(--status-error)`,borderWidth:1,borderColor:`var(--status-error-border)`},children:De})]})})}),(0,$.jsx)(`div`,{className:`shrink-0 px-4 sm:px-6 py-3`,children:(0,$.jsxs)(`div`,{className:`mx-auto w-full max-w-2xl flex items-center justify-end gap-2`,children:[!Te&&Z!==null?(0,$.jsxs)(`div`,{className:`mr-auto flex min-w-0 items-center gap-1.5 typography-micro text-muted-foreground`,children:[(0,$.jsx)(O,{name:`information`,className:`h-3.5 w-3.5 shrink-0`}),(0,$.jsx)(`span`,{className:`truncate`,children:a(`multirun.launcher.project.gitRequired`)})]}):null,(0,$.jsx)(te,{type:`button`,variant:`ghost`,size:`sm`,onClick:r,children:a(`multirun.launcher.actions.cancel`)}),(0,$.jsx)(te,{type:`submit`,size:`sm`,disabled:!Re||S,children:S?a(`multirun.launcher.actions.creating`):(0,$.jsx)($.Fragment,{children:a(`multirun.launcher.actions.startWithRunCount`,{count:Fe})})})]})})]})},dt=e=>{let t=(0,Ce.c)(104),{group:n,groupIndex:r,canRemove:i,onUpdate:a,onRemove:o}=e,{t:s}=f(),[c,l]=X.useState(!1),[d,p]=X.useState(``),[m,h]=X.useState(!1),[g,_]=X.useState(``),[v,y]=X.useState(!1),[b,x]=X.useState(``),S=X.useRef(null),C=X.useRef(null),w=X.useRef(null),T=X.useRef(null),E;t[0]!==n.id||t[1]!==n.models||t[2]!==a?(E=e=>{n.models.length>=ot||a(n.id,{models:[...n.models,e]})},t[0]=n.id,t[1]=n.models,t[2]=a,t[3]=E):E=t[3];let D=u(E),ee;t[4]!==n.id||t[5]!==n.models||t[6]!==a?(ee=e=>{a(n.id,{models:n.models.filter((t,n)=>n!==e)})},t[4]=n.id,t[5]=n.models,t[6]=a,t[7]=ee):ee=t[7];let te=u(ee),ne;t[8]!==n.id||t[9]!==n.models||t[10]!==a?(ne=(e,t)=>{a(n.id,{models:n.models.map((n,r)=>r===e?t:n)})},t[8]=n.id,t[9]=n.models,t[10]=a,t[11]=ne):ne=t[11];let re=u(ne),ie;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(ie=(e,t)=>{if(e.startsWith(`/`)){let n=e.indexOf(` `),r=e.indexOf(`
2
- `),i=Math.min(n===-1?e.length:n,r===-1?e.length:r);if(t<=i&&n===-1){_(e.substring(1,i)),h(!0),l(!1),y(!1);return}}h(!1);let n=e.substring(0,t),r=n.lastIndexOf(`#`);if(r!==-1){let e=r>0?n[r-1]:null,t=n.substring(r+1);if((!e||/\s/.test(e))&&!t.includes(` `)&&!t.includes(`
3
- `)){x(t),y(!0),l(!1);return}}y(!1);let i=n.lastIndexOf(`@`);if(i!==-1){let e=i>0?n[i-1]:null,t=n.substring(i+1);(!e||/\s/.test(e))&&!t.includes(` `)&&!t.includes(`
4
- `)?(p(t),l(!0)):l(!1);return}l(!1)},t[12]=ie):ie=t[12];let k=u(ie),ae;t[13]!==n.id||t[14]!==a?(ae=e=>{a(n.id,{prompt:e})},t[13]=n.id,t[14]=a,t[15]=ae):ae=t[15];let A=u(ae),j;t[16]!==n.prompt||t[17]!==A||t[18]!==k?(j=e=>{let t=n.prompt,r=S.current?.selectionStart??t.length,i=t.substring(0,r).lastIndexOf(`@`),a=e.relativePath&&e.relativePath.trim().length>0?e.relativePath.trim():e.path||e.name,o=be(t,i===-1?r:i,r,`@${a}`);A(o.text),l(!1),p(``),requestAnimationFrame(()=>{let e=S.current;e&&(e.selectionStart=o.caret,e.selectionEnd=o.caret,e.focus()),k(o.text,o.caret)})},t[16]=n.prompt,t[17]=A,t[18]=k,t[19]=j):j=t[19];let oe=u(j),se;t[20]!==n.prompt||t[21]!==A||t[22]!==k?(se=e=>{let t=n.prompt,r=S.current?.selectionStart??t.length,i=t.substring(0,r).lastIndexOf(`@`),a=be(t,i===-1?r:i,r,`@${e}`);A(a.text),l(!1),p(``),requestAnimationFrame(()=>{let e=S.current;e&&(e.selectionStart=a.caret,e.selectionEnd=a.caret,e.focus()),k(a.text,a.caret)})},t[20]=n.prompt,t[21]=A,t[22]=k,t[23]=se):se=t[23];let ce=u(se),le;t[24]!==A||t[25]!==k?(le=e=>{let t=`/${e.name} `;A(t),h(!1),_(``),y(!1),requestAnimationFrame(()=>{let e=S.current;e&&(e.focus(),e.selectionStart=e.value.length,e.selectionEnd=e.value.length),k(t,t.length)})},t[24]=A,t[25]=k,t[26]=le):le=t[26];let M=u(le),ue;t[27]!==n.prompt||t[28]!==A||t[29]!==k?(ue=(e,t)=>{let r=n.prompt,i=S.current?.selectionStart??r.length,a=r.substring(0,i).lastIndexOf(`#`),o=a===-1?i:a,s=`${r.substring(0,o)}#${t} ${r.substring(i)}`,c=o+t.length+2;A(s),y(!1),x(``),requestAnimationFrame(()=>{let e=S.current;e&&(e.selectionStart=c,e.selectionEnd=c,e.focus()),k(s,c)})},t[27]=n.prompt,t[28]=A,t[29]=k,t[30]=ue):ue=t[30];let de=u(ue),N;t[31]!==m||t[32]!==c||t[33]!==v?(N=e=>{if(m&&w.current&&(e.key===`Enter`||e.key===`ArrowUp`||e.key===`ArrowDown`||e.key===`Escape`||e.key===`Tab`)){e.preventDefault(),w.current.handleKeyDown(e.key);return}c&&C.current&&(e.key===`Enter`||e.key===`ArrowUp`||e.key===`ArrowDown`||e.key===`Escape`||e.key===`Tab`)&&(e.preventDefault(),C.current.handleKeyDown(e.key)),v&&T.current&&(e.key===`Enter`||e.key===`ArrowUp`||e.key===`ArrowDown`||e.key===`Escape`||e.key===`Tab`)&&(e.preventDefault(),T.current.handleKeyDown(e.key))},t[31]=m,t[32]=c,t[33]=v,t[34]=N):N=t[34];let F=u(N),fe=r+1,pe;t[35]!==s||t[36]!==fe?(pe=s(`multirun.launcher.groups.groupLabel`,{index:fe}),t[35]=s,t[36]=fe,t[37]=pe):pe=t[37];let I;t[38]===pe?I=t[39]:(I=(0,$.jsx)(`span`,{className:`typography-meta font-medium text-foreground`,children:pe}),t[38]=pe,t[39]=I);let L;t[40]!==i||t[41]!==n.id||t[42]!==o||t[43]!==s?(L=i&&(0,$.jsx)(`button`,{type:`button`,onClick:()=>o(n.id),className:`inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:text-destructive hover:bg-destructive/10`,"aria-label":s(`multirun.launcher.groups.removeGroup`),children:(0,$.jsx)(O,{name:`close`,className:`h-3.5 w-3.5`})}),t[40]=i,t[41]=n.id,t[42]=o,t[43]=s,t[44]=L):L=t[44];let R;t[45]!==I||t[46]!==L?(R=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[I,L]}),t[45]=I,t[46]=L,t[47]=R):R=t[47];let me;t[48]===s?me=t[49]:(me=s(`multirun.launcher.groups.prompt.label`),t[48]=s,t[49]=me);let z;t[50]===me?z=t[51]:(z=(0,$.jsx)(ct,{required:!0,children:me}),t[50]=me,t[51]=z);let he=n.prompt,B;t[52]!==A||t[53]!==k?(B=e=>{let t=e.target.value;A(t);let n=e.target.selectionStart??t.length;k(t,n)},t[52]=A,t[53]=k,t[54]=B):B=t[54];let V;t[55]===s?V=t[56]:(V=s(`multirun.launcher.groups.prompt.placeholder`),t[55]=s,t[56]=V);let H;t[57]!==n.prompt||t[58]!==F||t[59]!==B||t[60]!==V?(H=(0,$.jsx)(P,{ref:S,value:he,onChange:B,onKeyDown:F,placeholder:V,className:`typography-meta min-h-[80px] max-h-[200px] resize-none overflow-y-auto field-sizing-content`,required:!0}),t[57]=n.prompt,t[58]=F,t[59]=B,t[60]=V,t[61]=H):H=t[61];let ve;t[62]!==g||t[63]!==M||t[64]!==m?(ve=m?(0,$.jsx)(ge,{ref:w,searchQuery:g,onCommandSelect:M,onClose:()=>h(!1),style:{left:0,top:`auto`,bottom:`calc(100% + 6px)`,marginBottom:0,maxWidth:`100%`}}):null,t[62]=g,t[63]=M,t[64]=m,t[65]=ve):ve=t[65];let U;t[66]!==ce||t[67]!==oe||t[68]!==d||t[69]!==c?(U=c?(0,$.jsx)(ye,{ref:C,searchQuery:d,onFileSelect:oe,onAgentSelect:ce,onClose:()=>l(!1),style:{left:0,top:`auto`,bottom:`calc(100% + 6px)`,marginBottom:0,maxWidth:`100%`}}):null,t[66]=ce,t[67]=oe,t[68]=d,t[69]=c,t[70]=U):U=t[70];let W;t[71]!==de||t[72]!==v||t[73]!==b?(W=v?(0,$.jsx)(_e,{ref:T,searchQuery:b,onSnippetSelect:de,onClose:()=>y(!1),style:{left:0,top:`auto`,bottom:`calc(100% + 6px)`,marginBottom:0,maxWidth:`100%`}}):null,t[71]=de,t[72]=v,t[73]=b,t[74]=W):W=t[74];let G;t[75]!==H||t[76]!==ve||t[77]!==U||t[78]!==W?(G=(0,$.jsxs)(`div`,{className:`relative`,children:[H,ve,U,W]}),t[75]=H,t[76]=ve,t[77]=U,t[78]=W,t[79]=G):G=t[79];let K;t[80]!==z||t[81]!==G?(K=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[z,G]}),t[80]=z,t[81]=G,t[82]=K):K=t[82];let q;t[83]===s?q=t[84]:(q=s(`multirun.launcher.models.info`,{max:ot}),t[83]=s,t[84]=q);let J;t[85]===q?J=t[86]:(J=(0,$.jsx)(st,{children:q}),t[85]=q,t[86]=J);let Y;t[87]===s?Y=t[88]:(Y=s(`multirun.launcher.models.label`),t[87]=s,t[88]=Y);let xe;t[89]!==J||t[90]!==Y?(xe=(0,$.jsx)(ct,{required:!0,info:J,children:Y}),t[89]=J,t[90]=Y,t[91]=xe):xe=t[91];let Se;t[92]!==n.models||t[93]!==D||t[94]!==te||t[95]!==re?(Se=(0,$.jsx)(Re,{selectedModels:n.models,onAdd:D,onRemove:te,onUpdate:re,minModels:1,maxModels:ot}),t[92]=n.models,t[93]=D,t[94]=te,t[95]=re,t[96]=Se):Se=t[96];let Z;t[97]!==xe||t[98]!==Se?(Z=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[xe,Se]}),t[97]=xe,t[98]=Se,t[99]=Z):Z=t[99];let Q;return t[100]!==R||t[101]!==K||t[102]!==Z?(Q=(0,$.jsxs)(`div`,{className:`rounded-lg border border-border p-3 space-y-3`,children:[R,K,Z]}),t[100]=R,t[101]=K,t[102]=Z,t[103]=Q):Q=t[103],Q};export{De as a,Ie as i,$e as n,Te as o,Re as r,ut as t};
@@ -1,2 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-heic2any-CUPf3g2A.js","assets/rolldown-runtime-C0FnF6B9.js"])))=>i.map(i=>d[i]);
2
- import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{$ as t,A as n,E as r,P as i,T as a,Y as o,b as s,k as c,tt as l,w as u}from"./useUIStore-Wyu09VUF.js";import{$t as d,Mt as f,Pt as p,Xt as m,kn as h,nt as g,ot as ee,pt as te,r as _,st as v,xn as ne,zt as re}from"./persistence-aCOlo6ew.js";import{a as ie,r as ae}from"./vendor-zustand-B4dlGEM2.js";import{t as oe}from"./vendor-opencode-sdk-C07HQypa.js";import{i as se}from"./vendor-pathe-vBmvQE8f.js";import{o as ce}from"./vendor-aparajita-capacitor-secure-storage-CjQdwfjS.js";var le=(e,t)=>e!==t,ue=new Set([`image/heic`,`image/heif`]),de=!1,fe=()=>{let e=globalThis.window?.Capacitor;return e&&typeof e==`object`?e:null},pe=e=>ue.has((e.type||``).toLowerCase()),me=async e=>{let t=new Uint8Array(await e.arrayBuffer()),n=``,r=32768;for(let e=0;e<t.byteLength;e+=r){let i=t.subarray(e,Math.min(e+r,t.byteLength));n+=String.fromCharCode(...i)}return btoa(n)},he=(e,t)=>{let n=atob(e),r=new Uint8Array(n.length);for(let e=0;e<n.length;e++)r[e]=n.charCodeAt(e);return new Blob([r],{type:t})},ge=async e=>{if(!pe(e)||de)return null;let t=fe();if(!t||typeof t.isNativePlatform!=`function`||!t.isNativePlatform())return null;let n=t.Plugins?.OpenChamberMedia?.transcode;if(typeof n!=`function`)return null;try{let t=await n({data:await me(e),mime:e.type.toLowerCase(),quality:.9});if(typeof t?.data!=`string`||!t.data)return null;let r=typeof t.mime==`string`&&t.mime?t.mime:`image/jpeg`;return he(t.data,r)}catch(e){return de=!0,console.warn(`Native HEIC transcode failed`,e),null}},_e=e=>e.trim().toLowerCase(),ve=e=>e.source===`local`||e.source===`server`||e.source===`vscode`,ye=(e,t)=>{if(!e||!e.includes(`[`)||t.length===0)return[];let n=new Set(t.map(_e)),r=[],i=0;for(;i<e.length;){let t=e.indexOf(`[`,i);if(t===-1)break;let a=e.indexOf(`]`,t+1);if(a===-1)break;if(e[a+1]!==`(`){let i=te(e.slice(t+1,a)).trim();n.has(_e(i))&&r.push({start:t,end:a+1})}i=a+1}return r},be=(e,t)=>{let n=t.start,r=t.end;return r<e.length&&/\s/.test(e[r])?r+=1:n>0&&/\s/.test(e[n-1])&&--n,{start:n,end:r}},xe=(e,t,n,r)=>{let i=ye(e,t);if(i.length===0)return{text:e,mentions:[...n],composerReferences:r===void 0?void 0:[...r],changed:!1};let a=e,o=[...n],s=r===void 0?[]:[...r];for(let e=i.length-1;e>=0;--e){let{start:t,end:n}=be(a,i[e]),r=n-t;a=`${a.slice(0,t)}${a.slice(n)}`,o=o.flatMap(e=>e.range.end<=t?[e]:e.range.start>=n?[{...e,range:{start:e.range.start-r,end:e.range.end-r}}]:[]),s=s.flatMap(e=>e.end<=t?[e]:e.start>=n?[{...e,start:e.start-r,end:e.end-r}]:[])}return{text:a,mentions:o,composerReferences:r===void 0?void 0:s,changed:!0}},Se=new Set([`image`,`screenshot`,`screen-shot`,`clipboard`,`pasted-image`,`pastedimage`,`untitled`,`unknown`,`file`,`blob`]),Ce={"image/avif":`avif`,"image/bmp":`bmp`,"image/gif":`gif`,"image/heic":`heic`,"image/heif":`heif`,"image/jpeg":`jpg`,"image/jpg":`jpg`,"image/png":`png`,"image/svg+xml":`svg`,"image/tiff":`tiff`,"image/webp":`webp`},y=e=>e.trim().toLowerCase(),we=e=>e.charCodeAt(0)<32||`<>:"/\\|?*[]`.includes(e),Te=e=>{let t=e.replace(/\\/g,`/`).split(`/`).pop()??``;return Array.from(t).map(e=>we(e)?`-`:e).join(``).replace(/\s+/g,` `).replace(/-+/g,`-`).trim()},Ee=e=>Ce[e?.trim().toLowerCase()??``]??`png`,De=e=>{let t=Te(e.name),n=Ee(e.type),r=t.lastIndexOf(`.`);if(r>0&&r<t.length-1){let e=t.slice(r+1).toLowerCase();if(/^[a-z0-9]{1,10}$/.test(e))return{base:t.slice(0,r).trim()||`image`,ext:e}}return{base:t.trim()||`image`,ext:n}},Oe=e=>{let{base:t}=De({name:e}),n=t.trim().toLowerCase().replace(/[\s_]+/g,`-`).replace(/-+/g,`-`).replace(/^-|-$/g,``);if(Se.has(n))return!0;let r=n.replace(/-\(\d+\)$/g,``);return r!==n&&Se.has(r)?!0:/^(image|file|unknown|untitled|blob)-\d+$/.test(n)},b=(e,t)=>`${e}.${t}`,ke=(e,t,n)=>{let r=b(e,t);if(!n.has(y(r)))return r;for(let r=2;r<2**53-1;r+=1){let i=b(`${e}-${r}`,t);if(!n.has(y(i)))return i}return b(`${e}-${Date.now()}`,t)},Ae=(e,t)=>{for(let n=1;n<2**53-1;n+=1){let r=b(`image-${n}`,e);if(!Array.from(t).some(e=>e.startsWith(`image-${n}.`))&&!t.has(y(r)))return r}return b(`image-${Date.now()}`,e)},je=(e,t)=>{let n=new Set(t.map(y));return e.map(e=>{let{base:t,ext:r}=De(e),i=Oe(b(t,r))?Ae(r,n):ke(t,r,n);return n.add(y(i)),i})},Me=e=>e.map(e=>v(e)).join(` `),Ne=(e,t,n)=>{if(t===n)return[];let r=[];for(let i of e){let e=[v(i),`[${i}]`],a=e.some(e=>t.includes(e)),o=e.some(e=>n.includes(e));a&&!o&&r.push(i)}return r},Pe=e=>e.replaceAll(`[${ee}`,`[`),Fe=/\.(?:png|jpe?g|gif|webp|svg|avif|bmp|heic|heif|tiff?)$/i,Ie=e=>{let t=e.trim();return t.startsWith(`/`)||/^[A-Za-z]:[\\/]/.test(t)||t.startsWith(`\\\\`)},Le=(e,t)=>{let n=e;for(let e of t){let t=e.filename.trim(),r=e.path.trim();if(!t||!r||t===r||Ie(t)||!Fe.test(t)&&!Fe.test(r))continue;let i=`[${r}]`;n=n.split(v(t)).join(i).split(`[${t}]`).join(i)}return n},Re=(e,t)=>{let n=e;for(let e of t??[]){if(e.source!==`vscode`||e.vscodeSource!==`selection`||!e.vscodePath)continue;let t=e.filename.match(/:(\d+(?:-\d+)?)$/)?.[1];if(!t)continue;let r=`[${e.vscodePath}:${t}]`;n=n.split(v(e.filename)).join(r).split(`[${e.filename}]`).join(r)}return n},ze=e=>e.mime===`text/plain`&&typeof e.filename==`string`&&/:\d+(?:-\d+)?$/.test(e.filename),Be=`application/x-directory`,Ve=e=>typeof e==`string`&&e.trim().toLowerCase()===`application/x-directory`,He=e=>typeof e==`string`&&/[/\\]$/.test(e.trim()),Ue=(e,t,n)=>{if(t===`Backspace`){let t=n;for(;t>0&&/\s/.test(e[t-1]);)--t;for(;t>0&&!/\s/.test(e[t-1]);)--t;return{start:t,end:n}}let r=n;for(;r<e.length&&/\s/.test(e[r]);)r+=1;for(;r<e.length&&!/\s/.test(e[r]);)r+=1;return{start:n,end:r}},We=(e,t,n)=>{let r=Math.max(0,Math.min(n.selectionStart,e.length)),i=Math.max(r,Math.min(n.selectionEnd,e.length)),a;if(a=r===i?n.altKey?Ue(e,n.key,r):n.key===`Backspace`?{start:Math.max(0,r-1),end:r}:{start:r,end:Math.min(e.length,r+1)}:{start:r,end:i},a.start===a.end)return null;let o=ye(e,t).filter(e=>e.start<a.end&&e.end>a.start);if(o.length===0)return null;let s=Math.min(a.start,...o.map(e=>e.start)),c=Math.max(a.end,...o.map(e=>e.end));return c<e.length&&/\s/.test(e[c])&&(s===0||/\s/.test(e[s-1]))?c+=1:c===e.length&&s>0&&/\s/.test(e[s-1])&&--s,{text:`${e.slice(0,s)}${e.slice(c)}`,caret:s,removedFilenames:o.map(t=>te(e.slice(t.start+1,t.end-1)).trim())}},x=class extends Error{status;code;constructor(e,t,n=`Failed to upload prompt attachment`){super(n),this.name=`PromptAttachmentUploadError`,this.status=e,this.code=t}},S=`file://`,Ge=e=>{let t=e.trim();if(t.toLowerCase().startsWith(S))return t;let n=se(t).split(`/`).map(e=>/^[A-Za-z]:$/.test(e)?e:encodeURIComponent(e)).join(`/`);return/^[A-Za-z]:/.test(n)?`${S}/${n}`:`${S}${n}`},Ke=e=>{let t=e.trim();if(!t.toLowerCase().startsWith(S))return t;let n=t.slice(7);n.toLowerCase().startsWith(`localhost/`)&&(n=n.slice(9));let r=n.split(`/`).map(e=>{if(/^[A-Za-z]:$/.test(e))return e;try{return decodeURIComponent(e)}catch{return e}}).join(`/`);return/^\/[A-Za-z]:/.test(r)?r.slice(1):r},qe=async e=>[...new Uint8Array(await crypto.subtle.digest(`SHA-256`,await e.arrayBuffer()))].map(e=>e.toString(16).padStart(2,`0`)).join(``),Je=e=>typeof e==`object`&&!!e&&!Array.isArray(e),Ye=async e=>{let t;try{t=await e.json()}catch{throw new x(e.status,`unavailable`)}if(!Je(t)||typeof t.path!=`string`||!t.path)throw new x(e.status,`unavailable`);let n=typeof t.mime==`string`&&t.mime?t.mime:`application/octet-stream`,r=typeof t.size==`number`&&Number.isSafeInteger(t.size)?t.size:0,i=typeof t.sha256==`string`?t.sha256:``;return{path:t.path,url:Ge(t.path),mime:n,size:r,sha256:i}},Xe=e=>{let t=typeof crypto.randomUUID==`function`?crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`,n=e?.replace(/[^a-z0-9._-]+/gi,`-`).replace(/^-+|-+$/g,``).slice(0,32);return n?`att-${t}-${n}`:`att-${t}`},Ze=(e,t)=>{if(!e.startsWith(`data:`))return null;let n=e.indexOf(`,`);if(n===-1)return null;let r=e.slice(5,n),i=e.slice(n+1),a=r.split(`;`,1)[0]?.trim()||t||`application/octet-stream`;try{if(r.toLowerCase().includes(`;base64`)){let e=atob(i),t=new Uint8Array(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n);return new Blob([t],{type:a})}return new Blob([decodeURIComponent(i)],{type:a})}catch{return null}},Qe=e=>e.startsWith(`data:`)||e.startsWith(`blob:`),$e=async e=>{let t=e.mime||e.body.type||`application/octet-stream`,n=e.body.type===t?e.body:new Blob([e.body],{type:t});if(!Number.isSafeInteger(n.size)||n.size<0||n.size>26214400)throw new x(413,`too-large`);let r=await qe(n),i=Xe(e.filename),a;try{a=await h(`/api/fs/prompt-attachments/${encodeURIComponent(i)}`,{method:`PUT`,headers:{"Content-Type":t,"Content-Length":String(n.size),"X-OpenChamber-Content-Length":String(n.size),"X-OpenChamber-Sha256":r,"X-OpenChamber-Mime":t,...e.filename?{"X-OpenChamber-Filename":encodeURIComponent(e.filename)}:{}},body:n,signal:e.signal})}catch{throw new x(0,`unavailable`)}if(a.status===413)throw new x(413,`too-large`);if(!a.ok)throw new x(a.status,a.status>=500||a.status===0?`unavailable`:`rejected`);let o=await Ye(a);if(o.size!==n.size)throw new x(a.status,`unavailable`);return{...o,mime:t}},et=500,tt=()=>{if(typeof window>`u`)return!1;try{return new URLSearchParams(window.location.search).get(`startupTrace`)===`1`||window.localStorage?.getItem(`OPENCHAMBER_STARTUP_TRACE`)===`1`}catch{return!1}},nt=()=>tt(),C=(e,t)=>{if(!tt())return;let n=typeof performance<`u`?performance.now():Date.now();window.__OPENCHAMBER_STARTUP_TRACE_START__??=n,window.__OPENCHAMBER_STARTUP_TRACE__??=[],window.__OPENCHAMBER_STARTUP_TRACE__.push({t:Math.round(n-window.__OPENCHAMBER_STARTUP_TRACE_START__),name:e,...t?{data:t}:{}}),window.__OPENCHAMBER_STARTUP_TRACE__.length>et&&window.__OPENCHAMBER_STARTUP_TRACE__.splice(0,window.__OPENCHAMBER_STARTUP_TRACE__.length-et)};typeof window<`u`&&(window.__OPENCHAMBER_STARTUP_TRACE_SUMMARY__=()=>{let e=typeof window<`u`?window.__OPENCHAMBER_STARTUP_TRACE__??[]:[],t=e.findIndex(e=>e.name===`ModelControls:ready`),n=t>=0?Math.min(e.length,t+8):e.length;return e.slice(0,n).filter(e=>e.name.includes(`checkConnection`)||e.name.includes(`checkHealth`)||e.name.includes(`initializeApp`)||e.name.includes(`initApp`)||e.name.includes(`loadProviders`)||e.name.includes(`loadAgents`)||e.name.includes(`config.defaults`)||e.name.includes(`ModelControls`)||e.name.includes(`activateDirectory`)||e.name.includes(`opencodeClient:setDirectory`))});var rt=async(e,t,n)=>{let r=typeof performance<`u`?performance.now():Date.now();C(`${e}:start`,n);try{let n=await t(),i=typeof performance<`u`?performance.now():Date.now();return C(`${e}:end`,{durationMs:Math.round(i-r)}),n}catch(t){let n=typeof performance<`u`?performance.now():Date.now();throw C(`${e}:error`,{durationMs:Math.round(n-r),error:t instanceof Error?t.message:String(t)}),t}},it=3,at=3e4,ot=32e3,st=36e5,ct=6e5,lt=new Set([429,502,503,504]),w=new Map;function ut(){let e=Date.now();for(let[t,n]of w)n.consecutiveErrors===0&&e-n.lastErrorAt>st&&w.delete(t)}typeof setInterval<`u`&&setInterval(ut,ct).unref?.();function dt(e){let t=w.get(e);return t||(t={consecutiveErrors:0,lastErrorAt:0,circuitOpen:!1,circuitOpenAt:0,circuitCooldownMs:at},w.set(e,t)),t}function ft(e){if(!e)return;let t=w.get(e);t&&(t.consecutiveErrors=0,t.lastErrorAt=0)}function pt(e,t){if(!e)return;let n=dt(e);n.consecutiveErrors+=1,n.lastErrorAt=Date.now(),mt(t)&&n.consecutiveErrors>=it&&(n.circuitOpen=!0,n.circuitOpenAt=Date.now(),console.warn(`[provider-tracker] Circuit opened for ${e} after ${n.consecutiveErrors} consecutive errors`))}function mt(e){return e!==void 0&&lt.has(e)}function ht(e){let t=w.get(e);return t?.circuitOpen?Date.now()-t.circuitOpenAt>=t.circuitCooldownMs?(t.circuitOpen=!1,t.consecutiveErrors=0,t.circuitCooldownMs=Math.min(t.circuitCooldownMs*2,ot*4),!1):!0:!1}function gt(e){if(!(!e||!ht(e)))throw Error(`Provider ${e} is temporarily unavailable after repeated errors. Please retry shortly.`)}var _t=`/api`,vt=1e4,yt=4e3,bt=3e3,xt=1e3,St=12e3;function T(e){if(e instanceof Error)return e.message;if(typeof e==`string`)return e;if(e&&typeof e==`object`&&`message`in e&&typeof e.message==`string`)return e.message;try{return JSON.stringify(e)}catch{return String(e)}}function E(e,t){if(e.error){let n=e.response?.status,r=Error(`${t} failed${n?` (${n})`:``}: ${T(e.error)}`);throw n!==void 0&&(r.status=n),r}if(e.data===void 0||e.data===null)throw Error(`${t} failed: empty response`);return e.data}function D(e,t){if(e.error){let n=e.response?.status,r=Error(`${t} failed${n?` (${n})`:``}: ${T(e.error)}`);throw n!==void 0&&(r.status=n),r}return e.data}var Ct=/^[a-zA-Z][a-zA-Z\d+\-.]*:\/\//,wt=e=>{let t=typeof e==`string`&&e.trim().length>0?e.trim():`/api`;if(Ct.test(t)||typeof window>`u`)return t;let n=window.location?.href||window.location?.origin;if(!n)return t;try{return new URL(t,n).toString()}catch(e){return console.warn(`Failed to normalize OpenCode base URL:`,e),t}},Tt=()=>{try{return i().api(`/api`)}catch{return null}},Et=()=>{try{return i().api(`/`)}catch{return null}},Dt=e=>{let t=typeof AbortSignal<`u`?AbortSignal:void 0;if(typeof t?.timeout==`function`)return{signal:t.timeout(e),cleanup:()=>void 0};let n=new AbortController,r=setTimeout(()=>n.abort(),e);return{signal:n.signal,cleanup:()=>clearTimeout(r)}},Ot=e=>{let t=e.filter(e=>e!=null);if(t.length===0)return{signal:new AbortController().signal,cleanup:()=>void 0};if(t.length===1)return{signal:t[0],cleanup:()=>void 0};let n=typeof AbortSignal<`u`?AbortSignal:void 0;if(typeof n?.any==`function`)return{signal:n.any(t),cleanup:()=>void 0};let r=new AbortController,i=()=>r.abort();for(let e of t){if(e.aborted){r.abort();break}e.addEventListener(`abort`,i)}return{signal:r.signal,cleanup:()=>{for(let e of t)e.removeEventListener(`abort`,i)}}},O=e=>oe({...e,fetch:h}),kt=e=>typeof e.mime==`string`&&e.mime.startsWith(`image/`)?!0:typeof e.filename==`string`&&/\.(?:png|jpe?g|gif|webp|svg|avif|bmp|heic|heif|tiff?)$/i.test(e.filename),At=e=>{let t=[];for(let n of e){if(!kt(n))continue;let e=typeof n.filename==`string`?n.filename.trim():``,r=typeof n.url==`string`?n.url:``;if(!e||!r.toLowerCase().startsWith(`file://`))continue;let i=Ke(r).trim();i&&t.push({filename:e,path:i})}return t},jt=async(e,t)=>{let n=[],r=e.files?.length?await Promise.all(e.files.map(e=>t(e))):[],i=e.additionalParts?.length?await Promise.all(e.additionalParts.map(async e=>({text:e.text,synthetic:e.synthetic,files:e.files?.length?await Promise.all(e.files.map(e=>t(e))):[]}))):[],a=e=>Le(e,At([...r,...i.flatMap(e=>e.files)]));if(e.prefaceText&&e.prefaceText.trim()&&n.push({type:`text`,text:a(e.prefaceText),synthetic:e.prefaceTextSynthetic!==!1}),e.text&&e.text.trim()&&n.push({type:`text`,text:a(e.text)}),n.push(...r),i.length>0)for(let e of i){if(e.text&&e.text.trim()){let t={type:`text`,text:a(e.text)};e.synthetic&&(t.synthetic=!0),n.push(t)}n.push(...e.files)}if(e.agentMentions&&e.agentMentions.length>0)for(let t of e.agentMentions){if(!t?.name)continue;let e={type:`agent`,name:t.name};t.source&&(e.source=t.source),n.push(e)}if(n.length===0)throw Error(`Message must have at least one part (text or file)`);return n},k=e=>e.replace(/\\/g,`/`),Mt=400,Nt=()=>{let e=ne();return e&&e.runtime?.isDesktop&&e.files?e.files:null},A=new class{client;baseUrl;scopedClients=new Map;currentDirectory=void 0;directoryContextQueue=Promise.resolve();listDirectoryInFlight=new Map;configProvidersInFlight=new Map;listAgentsInFlight=new Map;configInFlight=new Map;configCache=new Map;configCacheGeneration=0;listDirectoryCache=new Map;healthInFlight=new Map;healthCache=new Map;healthCacheGeneration=0;constructor(e=_t){let t=Tt()||e;this.baseUrl=wt(t),this.client=O({baseUrl:this.baseUrl})}getBaseUrl(){return this.baseUrl}reconnectToRuntimeBaseUrl(){let e=wt(Tt()||_t);e!==this.baseUrl&&(this.baseUrl=e,this.client=O({baseUrl:this.baseUrl}),this.scopedClients.clear(),this.listDirectoryInFlight.clear(),this.configProvidersInFlight.clear(),this.listAgentsInFlight.clear(),this.clearConfigCache(),this.listDirectoryCache.clear(),this.clearHealthCache())}getSdkClient(){return this.client}getScopedSdkClient(e){return this.getScopedApiClient(e)}getScopedApiClient(e){let t=this.normalizeCandidatePath(e)??e,n=t||``,r=this.scopedClients.get(n);if(r)return r;let i=O({baseUrl:this.baseUrl,directory:t});return this.scopedClients.set(n,i),i}normalizeCandidatePath(e){if(typeof e!=`string`)return null;let t=e.trim();if(!t)return null;let n=t.replace(/\\/g,`/`).replace(/^([a-z]):/,(e,t)=>t.toUpperCase()+`:`);return(n.length>1?n.replace(/\/+$/,``):n)||null}deriveHomeDirectory(e){let t=e.match(/^([A-Za-z]:)(?:\/|$)/);if(t){let n=t[1],r=e.slice(n.length+ +(e.charAt(n.length)===`/`)).split(`/`).filter(Boolean);return r.length>=2?{homeDirectory:`${n}/${r[0]}/${r[1]}`,username:r[1]}:r.length===1?{homeDirectory:`${n}/${r[0]}`,username:r[0]}:{homeDirectory:n,username:void 0}}let n=e.startsWith(`/`),r=e.split(`/`).filter(Boolean);return r.length>=2&&(r[0]===`Users`||r[0]===`home`)?{homeDirectory:`${n?`/`:``}${r[0]}/${r[1]}`,username:r[1]}:n?r.length===0?{homeDirectory:`/`,username:void 0}:{homeDirectory:`/${r.join(`/`)}`,username:r[r.length-1]}:r.length>0?{homeDirectory:`/${r.join(`/`)}`,username:r[r.length-1]}:{homeDirectory:`/`,username:void 0}}setDirectory(e){let t=this.normalizeCandidatePath(e)??e;this.currentDirectory!==t&&C(`opencodeClient:setDirectory`,{previous:this.currentDirectory??null,next:t??null}),this.currentDirectory=t}getDirectory(){return this.currentDirectory}async withDirectory(e,t){let n=async()=>{if(e==null)return t();let n=this.currentDirectory,r=this.normalizeCandidatePath(e)??e;this.currentDirectory=r;try{return await t()}finally{this.currentDirectory===r&&(this.currentDirectory=n)}},r=this.directoryContextQueue.then(n,n);return this.directoryContextQueue=r.then(()=>void 0,()=>void 0),r}getApiClient(){return this.client}async getSystemInfo(){let e=new Set,t=t=>{let n=this.normalizeCandidatePath(t);n&&e.add(n)};try{let e=(await this.client.path.get(this.currentDirectory?{directory:this.currentDirectory}:void 0)).data;e&&(t(e.directory),t(e.worktree),t(e.state))}catch{}if(!e.size)try{t((await this.client.project.current(this.currentDirectory?{directory:this.currentDirectory}:void 0)).data?.worktree)}catch{}if(!e.size)try{(await this.listSessions()).forEach(e=>t(e.directory))}catch{}if(t(this.currentDirectory),typeof window<`u`)try{t(f(`lastDirectory`)),t(f(`homeDirectory`))}catch{}if(!e.size&&typeof process<`u`&&typeof process.cwd==`function`&&t(process.cwd()),!e.size)return{homeDirectory:`/`,username:void 0};let[n]=Array.from(e);return this.deriveHomeDirectory(n)}async probeDirectory(e){let t=this.normalizeCandidatePath(e);if(!t)return!1;try{let e=(await this.client.path.get({directory:t})).data,n=typeof e?.directory==`string`?e.directory:null;return!!(n&&n.trim().length>0)}catch{return!1}}async listSessions(){let e=await this.client.session.list(this.currentDirectory?{directory:this.currentDirectory}:void 0);return Array.isArray(e.data)?e.data:[]}async createSession(e,t){let n=this.normalizeCandidatePath(t)??this.currentDirectory;return E(await this.client.session.create({...n?{directory:n}:{},parentID:e?.parentID,title:e?.title,metadata:e?.metadata}),`session.create`)}async getSession(e,t){let n=this.normalizeCandidatePath(t)??this.currentDirectory;return E(await this.client.session.get({sessionID:e,...n?{directory:n}:{}}),`session.get`)}async deleteSession(e,t){let n=this.normalizeCandidatePath(t)??this.currentDirectory;return D(await this.client.session.delete({sessionID:e,...n?{directory:n}:{}}),`session.delete`)===!0}async deleteSessionMessage(e,t,n){let r=this.normalizeCandidatePath(n)??this.currentDirectory;return D(await this.client.session.deleteMessage({sessionID:e,messageID:t,...r?{directory:r}:{}}),`session.deleteMessage`)===!0}async updateSession(e,t,n){let r=this.normalizeCandidatePath(n)??this.currentDirectory,i={...t.title===void 0?{}:{title:t.title},...t.metadata===void 0?{}:{metadata:t.metadata},...t.time?.archived!==void 0&&t.time.archived!==null?{time:{archived:t.time.archived}}:{}};return E(await this.client.session.update({sessionID:e,...r?{directory:r}:{},...i}),`session.update`)}async getSessionMessages(e,t){return E(await this.client.session.messages({sessionID:e,...this.currentDirectory?{directory:this.currentDirectory}:{},...typeof t==`number`?{limit:t}:{}}),`session.messages`)}async getSessionDiff(e,t){let n=this.normalizeCandidatePath(e.directory)??this.currentDirectory,r=typeof e.messageID==`string`&&e.messageID.trim().length>0?e.messageID.trim():void 0,i={sessionID:e.sessionID,...n?{directory:n}:{},...r?{messageID:r}:{}};return E(t?.signal?await this.client.session.diff(i,{signal:t.signal}):await this.client.session.diff(i),`session.diff`)}async getSessionTodos(e){try{let t=await this.client.session.todo({sessionID:e,...this.currentDirectory?{directory:this.currentDirectory}:{}});if(t.error)return[];let n=t.data;return!n||!Array.isArray(n)?[]:n}catch{return[]}}shouldNormalizeToTextPlain(e){if(!e)return!1;let t=e.toLowerCase();return t.startsWith(`text/`)&&t!==`text/plain`?!0:[`application/json`,`application/xml`,`application/javascript`,`application/typescript`,`application/x-yaml`,`application/yaml`,`application/toml`,`application/x-sh`,`application/x-shellscript`,`application/octet-stream`,`image/svg+xml`].includes(t)}isHeicMime(e){if(!e)return!1;let t=e.toLowerCase();return t===`image/heic`||t===`image/heif`}async convertHeicToJpeg(t){try{let n=Ze(t.url,t.mime);if(!n)return t;let r=await ge(n)??await(await ce(async()=>{let{default:t}=await import(`./vendor-heic2any-CUPf3g2A.js`).then(t=>e(t.t(),1));return{default:t}},__vite__mapDeps([0,1]))).default({blob:n,toType:`image/jpeg`,quality:.9}),i=await new Promise((e,t)=>{let n=new FileReader;n.onload=()=>e(n.result),n.onerror=t,n.readAsDataURL(r)}),a=t.filename;return a&&=a.replace(/\.heic$/i,`.jpg`).replace(/\.heif$/i,`.jpg`),{mime:`image/jpeg`,filename:a,url:i}}catch(e){return console.warn(`Failed to convert HEIC to JPEG:`,e),t}}async normalizeFilePart(e){if(this.isHeicMime(e.mime))return this.convertHeicToJpeg(e);if(!this.shouldNormalizeToTextPlain(e.mime))return e;let t=e.url;if(e.url.startsWith(`data:`)){let n=e.url.indexOf(`,`);if(n!==-1){let r=e.url.substring(5,n),i=e.url.substring(n);t=`data:${r.replace(/^[^;,]+/,`text/plain`)}${i}`}}return{mime:`text/plain`,filename:e.filename,url:t}}async toNormalizedFilePartInput(e){let t=await this.normalizeFilePart(e),n=t.url;if(Qe(n)){let e=Ze(n,t.mime);if(!e)throw Error(`Failed to materialize attachment bytes for ${t.filename??`file`}`);n=(await $e({body:e,mime:t.mime,filename:t.filename})).url}return{...e.id?{id:e.id}:{},type:`file`,mime:t.mime,filename:t.filename,url:n}}async buildMessageParts(e){return jt(e,e=>this.toNormalizedFilePartInput(e))}async sendMessage(e){let t=e.messageId??g(`msg`),n=await this.buildMessageParts({text:e.text,prefaceText:e.prefaceText,prefaceTextSynthetic:e.prefaceTextSynthetic,files:e.files,additionalParts:e.additionalParts,agentMentions:e.agentMentions}),r=this.normalizeCandidatePath(e.directory??null)??this.currentDirectory;e.format&&(e.id,e.providerID,e.modelID,e.agent,e.variant,this.baseUrl,e.format.type),gt(e.providerID);let i;try{let a=await this.client.session.promptAsync({sessionID:e.id,...r?{directory:r}:{},model:{providerID:e.providerID,modelID:e.modelID},agent:e.agent,variant:e.variant,messageID:t,...e.delivery?{delivery:e.delivery}:{},...e.format?{format:e.format}:{},parts:n});if(a.response instanceof Response)i=a.response;else if(a.error){let e=a.response?.status;if(!e)throw Error(`Message send transport failure: ${T(a.error)}`);i=new Response(JSON.stringify(a.error),{status:e})}else i=new Response(JSON.stringify(a.data??!0),{status:200})}catch(t){throw pt(e.providerID),t}if(i.ok)return ft(e.providerID),t;let a=``;try{a=await i.text()}catch{}let o=a&&a.trim().length>0?`: ${a.trim()}`:``,s=Error(`Failed to send message (${i.status})${o}`);throw s.status=i.status,pt(e.providerID,i.status),s}async sendCommand(e){let t=e.messageId??g(`msg`),n=[];if(e.files&&e.files.length>0)for(let t of e.files)n.push(await this.toNormalizedFilePartInput(t));let r=this.normalizeCandidatePath(e.directory??null)??this.currentDirectory;return D(await this.client.session.command({sessionID:e.id,...r?{directory:r}:{},command:e.command,arguments:e.arguments??``,model:`${e.providerID}/${e.modelID}`,agent:e.agent,variant:e.variant,...n.length>0?{parts:n}:{},messageID:t}),`session.command`),t}async abortSession(e){return!!(await this.client.session.abort({sessionID:e,...this.currentDirectory?{directory:this.currentDirectory}:{}},{throwOnError:!0})).data}async shellSession(e){let t=this.normalizeCandidatePath(e.directory??null)??this.currentDirectory;return E(await this.client.session.shell({sessionID:e.sessionId,...t?{directory:t}:{},messageID:e.messageId,agent:e.agent,model:e.model,command:e.command}),`session.shell`)}async revertSession(e,t,n,r){let i=this.normalizeCandidatePath(r)??this.currentDirectory;return E(await this.client.session.revert({sessionID:e,...i?{directory:i}:{},messageID:t,partID:n}),`session.revert`)}async summarizeSession(e,t,n,r){let i=this.normalizeCandidatePath(r)??this.currentDirectory;return D(await this.client.session.summarize({sessionID:e,...i?{directory:i}:{},providerID:t,modelID:n}),`session.summarize`)===!0}async unrevertSession(e){return E(await this.client.session.unrevert({sessionID:e,...this.currentDirectory?{directory:this.currentDirectory}:{}}),`session.unrevert`)}async forkSession(e,t,n){let r=this.normalizeCandidatePath(n)??this.currentDirectory,i=E(await this.client.session.fork({sessionID:e,...r?{directory:r}:{},messageID:t}),`session.fork`);return i.id,i}async getSessionStatus(){return await this.getSessionStatusForDirectory(this.currentDirectory??null)??{}}async getSessionStatusForDirectory(e,t){try{let n=typeof e==`string`?e.trim():``,r=await this.client.session.status(n?{directory:n}:void 0,t?{signal:t}:void 0);return r.error||!r.data||typeof r.data!=`object`?null:r.data}catch{return null}}async getSessionActive(e){try{let t=await O({baseUrl:wt(Et()||`/`)}).v2.session.active(e?{signal:e}:void 0),n=t.response?.status;if(t.error||n!==void 0&&n!==200)return n===404||n===405||n===501?{state:`unsupported`}:{state:`unknown`};let r=t.data,i=r&&typeof r==`object`&&`data`in r&&r.data!==void 0?r.data:r;if(!i||typeof i!=`object`||Array.isArray(i))return{state:`unknown`};let a={};for(let[e,t]of Object.entries(i)){if(typeof e!=`string`||e.length===0||!t||typeof t!=`object`||t.type!==`running`)return{state:`unknown`};a[e]={type:`running`}}return{state:`supported`,membership:a}}catch{return{state:`unknown`}}}async getGlobalSessionStatus(){return await this.getSessionStatusForDirectory(null)??{}}async getWebServerSessionActivity(){try{let e=await h(`/api/session-activity`,{method:`GET`,headers:{Accept:`application/json`}});if(!e.ok)return null;let t=await e.json().catch(()=>null);return!t||typeof t!=`object`?null:t}catch{return null}}async listToolIds(e){try{let t=typeof e?.directory==`string`?e.directory.trim():this.currentDirectory?this.currentDirectory.trim():``;return((await this.client.tool.ids(t?{directory:t}:void 0)).data||[]).filter(e=>typeof e==`string`&&e!==`invalid`)}catch{return[]}}async replyToPermission(e,t,n){let r=this.normalizeCandidatePath(n?.directory??null)??this.currentDirectory;return D(await this.client.permission.reply({requestID:e,...r?{directory:r}:{},reply:t,...n?.message?{message:n.message}:{}}),`permission.reply`)===!0}async createPermission(e,t,n,r){try{let i=await this.client.v2.session.permission.create({sessionID:e,action:t,resources:n,...r?.id?{id:r.id}:{},...r?.save?{save:r.save}:{},...r?.metadata?{metadata:r.metadata}:{},...r?.source?{source:r.source}:{},...r?.agent?{agent:r.agent}:{}});if(i.error!==void 0)return null;let a=i.data?.data;return a===void 0?null:{id:a.id,effect:a.effect}}catch{return null}}async fetchPermission(e,t){try{let n=await this.client.v2.session.permission.get({sessionID:e,requestID:t});if(n.error===void 0){let e=n.data?.data;if(e!==void 0)return{state:`ok`,permission:e}}return n.response?.status===404?{state:`resolved`}:{state:`unknown`}}catch{return{state:`unknown`}}}async listPendingPermissions(e){let t=[],n=async e=>{let t=typeof e==`string`?e.trim():``,n=await this.client.permission.list(t?{directory:t}:void 0);if(n.error)throw Error(`permission.list failed: ${T(n.error)}`);return n.data||[]};t.push(n(null));let r=new Set;for(let t of e?.directories??[]){let e=this.normalizeCandidatePath(t??null);e&&r.add(e)}for(let e of r)t.push(n(e));let i=await Promise.all(t),a=[],o=new Set;for(let e of i)for(let t of e){if(!t||typeof t!=`object`)continue;let e=t.id;typeof e==`string`&&e.length!==0&&(o.has(e)||(o.add(e),a.push(t)))}return a}async replyToQuestion(e,t,n){let r=!Array.isArray(t)||t.length===0?[]:Array.isArray(t[0])?t:[t],i=this.normalizeCandidatePath(n)??this.currentDirectory;return D(await this.client.question.reply({requestID:e,...i?{directory:i}:{},answers:r}),`question.reply`)===!0}async rejectQuestion(e){return D(await this.client.question.reject({requestID:e,...this.currentDirectory?{directory:this.currentDirectory}:{}}),`question.reject`)===!0}async listPendingQuestions(e){let t=[],n=async e=>{let t=typeof e==`string`?e.trim():``,n=await this.client.question.list(t?{directory:t}:void 0);if(n.error)throw Error(`question.list failed: ${T(n.error)}`);return n.data||[]};t.push(n(null));let r=new Set;for(let t of e?.directories??[]){let e=this.normalizeCandidatePath(t??null);e&&r.add(e)}for(let e of r)t.push(n(e));let i=await Promise.all(t),a=[],o=new Set;for(let e of i)for(let t of e){if(!t||typeof t!=`object`)continue;let e=t.id;typeof e==`string`&&e.length!==0&&(o.has(e)||(o.add(e),a.push(t)))}return a}clearConfigCache(){this.configCacheGeneration+=1,this.configInFlight.clear(),this.configCache.clear()}clearHealthCache(){this.healthCacheGeneration+=1,this.healthInFlight.clear(),this.healthCache.clear()}async getConfig(e){let t=this.normalizeCandidatePath(e)??e??this.currentDirectory??void 0,n=t??``,r=this.configCache.get(n);if(r&&r.expiresAt>Date.now())return C(`opencodeClient.getConfig:cacheHit`,{directory:t??null}),r.config;let i=this.configInFlight.get(n);if(i)return C(`opencodeClient.getConfig:deduped`,{directory:t??null}),i;let a=this.configCacheGeneration,o=(async()=>{C(`opencodeClient.getConfig:start`,{directory:t??null});let e=typeof performance<`u`?performance.now():Date.now(),r=await(t?this.getScopedApiClient(t):this.client).config.get();if(!r.data)throw Error(`Failed to get config`);let i=typeof performance<`u`?performance.now():Date.now();return C(`opencodeClient.getConfig:end`,{directory:t??null,durationMs:Math.round(i-e)}),a===this.configCacheGeneration&&this.configCache.set(n,{config:r.data,expiresAt:Date.now()+vt}),r.data})();this.configInFlight.set(n,o);try{return await o}finally{this.configInFlight.get(n)===o&&this.configInFlight.delete(n)}}async updateConfig(e){let t=E(await this.client.config.update({config:e}),`global.config.update`);return this.clearConfigCache(),t}async updateConfigPartial(e){let t=e(await this.getConfig());return await this.updateConfig(t)}async getProviders(){return this.getProvidersForConfig(this.currentDirectory)}async getProvidersForConfig(e){let t=e===void 0?this.currentDirectory??void 0:this.normalizeCandidatePath(e)??void 0,n=t??``,r=this.configProvidersInFlight.get(n);if(r)return r;let i=(async()=>E(await this.client.config.providers(t?{directory:t}:void 0),`config.providers`))();this.configProvidersInFlight.set(n,i);try{return await i}finally{this.configProvidersInFlight.delete(n)}}async getApp(){return{version:`0.0.3`,config:await this.getConfig()}}async initApp(){try{return await this.checkHealth()}catch{return!1}}async listAgents(e,t){let n=e===void 0?this.currentDirectory??void 0:this.normalizeCandidatePath(e)??void 0,r=n??``;if(!t){let e=this.listAgentsInFlight.get(r);if(e)return e}let i=(async()=>{let e=Dt(St),r=Ot(t?[t,e.signal]:[e.signal]);try{let e=n?{directory:n}:void 0,t=await this.client.app.agents(e,{signal:r.signal});if(!t.error&&Array.isArray(t.data)&&t.data.length>0)return t.data;let i=await h(`/api/agent`,{...n?{query:{directory:n}}:{},signal:r.signal});if(!i.ok)throw t.error?Error(`app.agents failed${t.response?.status?` (${t.response.status})`:``}: ${T(t.error)}`):Error(`agent.list failed (${i.status})`);let a=await i.json().catch(()=>null);if(!Array.isArray(a))throw Error(`agent.list failed: invalid response`);return a}finally{e.cleanup(),r.cleanup()}})();if(t)return i;this.listAgentsInFlight.set(r,i);try{return await i}finally{this.listAgentsInFlight.delete(r)}}async readFile(e){try{let t=await this.client.file.read({path:e,...this.currentDirectory?{directory:this.currentDirectory}:{}});return String(E(t,`file.read`))}catch{return`// Content of ${e}\n// This would be loaded from the server`}}async listFiles(e){try{let t=e||this.currentDirectory||`/`,n=E(await this.client.file.list({path:t,...this.currentDirectory?{directory:this.currentDirectory}:{}}),`file.list`);return Array.isArray(n)?n:[]}catch{return[]}}async listCommands(){return(E(await this.client.command.list(this.currentDirectory?{directory:this.currentDirectory}:void 0),`command.list`)||[]).map(e=>({name:e.name,description:e.description,agent:e.agent,model:e.model,source:e.source}))}async listCommandsWithDetails(){return(E(await this.client.command.list(this.currentDirectory?{directory:this.currentDirectory}:void 0),`command.list`)||[]).map(e=>({name:e.name,description:e.description,agent:e.agent,model:e.model,source:e.source,template:e.template}))}async listSkillsWithDetails(){try{let e=(await this.client.app.skills(this.currentDirectory?{directory:this.currentDirectory}:void 0)).data;if(!Array.isArray(e))return[];let t=[];for(let n of e){let e=typeof n.name==`string`?n.name.trim():``,r=typeof n.location==`string`?n.location:``;if(!e||!r)continue;let i={name:e,location:r};typeof n.description==`string`&&(i.description=n.description),typeof n.content==`string`&&(i.content=n.content),t.push(i)}return t}catch{return[]}}async getCommandDetails(e){try{let t=await this.client.command.list(this.currentDirectory?{directory:this.currentDirectory}:void 0);if(t.data){let n=t.data.find(t=>t.name===e);if(n)return{name:n.name,template:n.template,description:n.description,agent:n.agent,model:n.model}}return null}catch{return null}}async checkHealth(){let e=a(),t=this.healthCache.get(e);if(t&&t.expiresAt>Date.now())return t.healthy;let n=this.healthInFlight.get(e);if(n)return n;let r=this.healthCacheGeneration,i=(async()=>{let t=!1;try{let e=this.baseUrl.endsWith(`/`)?this.baseUrl.replace(/\/+$/,``):this.baseUrl,n=e===`/api`||e.endsWith(`/api`)?`/api/opencode/health`:`${e}/opencode/health`;C(`opencodeClient.checkHealth:url`,{baseUrl:this.baseUrl,healthUrl:n});let r=Dt(yt),i=await h(n,{signal:r.signal}).finally(r.cleanup);if(C(`opencodeClient.checkHealth:response`,{status:i.status}),i.ok){let e=await i.json();C(`opencodeClient.checkHealth:result`,{healthy:e?.healthy}),t=e?.healthy===!0}}catch{t=!1}return r!==this.healthCacheGeneration||e!==a()?!1:(this.healthCache.set(e,{healthy:t,expiresAt:Date.now()+(t?bt:xt)}),t)})();this.healthInFlight.set(e,i);try{return await i}finally{this.healthInFlight.get(e)===i&&this.healthInFlight.delete(e)}}async createDirectory(e,t){let n=Nt();if(n?.createDirectory)try{return await n.createDirectory(e)}catch(e){let t=e instanceof Error?e.message:String(e);throw Error(t||`Failed to create directory`)}let r={path:e,...t?.allowOutsideWorkspace?{allowOutsideWorkspace:!0}:{}},i=await h(`${this.baseUrl}/fs/mkdir`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(r)});if(!i.ok){let e=await i.json().catch(()=>({error:`Failed to create directory`}));throw Error(e.error||`Failed to create directory`)}return await i.json()}async cloneRepository(e){let t=await h(`${this.baseUrl}/fs/clone`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify(e)});if(!t.ok){let e=await t.json().catch(()=>({error:`Failed to clone repository`}));throw Error(e.error||`Failed to clone repository`)}return await t.json()}async listLocalDirectory(e,t){let n=`${typeof e==`string`?k(e.trim()):``}|${t?.respectGitignore?`1`:`0`}`,r=Date.now(),i=this.listDirectoryCache.get(n);if(i&&i.expiresAt>r)return i.entries;let a=this.listDirectoryInFlight.get(n);if(a)return a;let o=(async()=>{let r=Nt();if(r)try{let i=await r.listDirectory(e||``,t);if(!i||!Array.isArray(i.entries))return[];let a=i.entries.map(e=>({name:e.name,path:k(e.path),isDirectory:!!e.isDirectory,isFile:!e.isDirectory,isSymbolicLink:!1}));return this.listDirectoryCache.set(n,{entries:a,expiresAt:Date.now()+Mt}),a}catch(e){throw console.error(`Failed to list directory contents:`,e),e}try{let r=new URLSearchParams;e&&e.trim().length>0&&r.set(`path`,e),t?.respectGitignore&&r.set(`respectGitignore`,`true`);let i=r.toString(),a=await h(`${this.baseUrl}/fs/list${i?`?${i}`:``}`);if(!a.ok){let e=await a.json().catch(()=>({})),t=typeof e.error==`string`?e.error:`Failed to list directory`;throw Error(t)}let o=await a.json();if(!o||!Array.isArray(o.entries))return[];let s=o.entries;return this.listDirectoryCache.set(n,{entries:s,expiresAt:Date.now()+Mt}),s}catch(e){throw console.error(`Failed to list directory contents:`,e),e}})().finally(()=>{this.listDirectoryInFlight.get(n)===o&&this.listDirectoryInFlight.delete(n)});return this.listDirectoryInFlight.set(n,o),o}async searchFiles(e,t){let n=typeof t?.directory==`string`&&t.directory.trim().length>0?t.directory.trim():this.currentDirectory,r=n?k(n):null,i=n?this.getScopedApiClient(n):this.client;try{let n=await i.find.files({query:e,limit:typeof t?.limit==`number`&&Number.isFinite(t.limit)?t.limit:void 0,dirs:t?.dirs===!1||t?.type===`file`?`false`:`true`,type:t?.type});return(Array.isArray(n?.data)?n.data:[]).map(e=>{let t=k(e),n=t.split(`/`).filter(Boolean).pop()||t;return{name:n,path:k(r?`${r}/${t}`:t),relativePath:t,extension:n.includes(`.`)?n.split(`.`).pop()?.toLowerCase():void 0}})}catch(e){throw console.error(`Failed to search files:`,e),e}}async getFilesystemHome(){let e=a();if(!e||e===`local`){let e=await re();if(e)return e}try{let e=await h(`${this.baseUrl}/fs/home`,{method:`GET`,headers:{Accept:`application/json`}});if(!e.ok){let t=await e.json().catch(()=>({})),n=typeof t.error==`string`&&t.error.length>0?t.error:`Failed to resolve home directory`;throw Error(n)}let t=await e.json();return t&&typeof t.home==`string`&&t.home.length>0?t.home:null}catch(e){return console.warn(`Failed to resolve filesystem home directory:`,e),null}}async setOpenCodeWorkingDirectory(e){if(!e||typeof e!=`string`||!e.trim())return console.warn(`[OpencodeClient] setOpenCodeWorkingDirectory: invalid path`,e),null;let t=`${this.baseUrl}/opencode/directory`;try{let n=await h(t,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({path:e})}),r=await n.json().catch(()=>null);if(!n.ok){let e=r??{},t=typeof e.error==`string`&&e.error.length>0?e.error:`Failed to update OpenCode working directory`;throw Error(t)}return r&&typeof r==`object`?r:{success:!0,restarted:!1,path:e}}catch(e){throw console.warn(`Failed to update OpenCode working directory:`,e),e}}},Pt=3e4,Ft=40,It=60,Lt=(e,t,n,r,i,a)=>{let o=e.trim(),s=t.trim().toLowerCase();return JSON.stringify([o,s,n,r,i,a])},Rt=(e,t)=>{try{let n=JSON.parse(e);return Array.isArray(n)&&n[0]===t}catch{return!1}},zt=ie()(ae((e,t)=>({cache:{},cacheKeys:[],inFlight:{},async searchFiles(n,r,i=It,a){if(!n||n.trim().length===0)return[];let o=n.trim(),s=typeof r==`string`?r.trim():``,c=!!a?.includeHidden,l=a?.respectGitignore??!0,u=a?.type===`directory`?`directory`:`file`,d=Lt(o,s,i,c,l,u),f=Date.now(),p=t().cache[d];if(p&&f-p.timestamp<Pt)return p.files;let m=t().inFlight[d];if(m)return m;let h=A.searchFiles(s,{directory:o,limit:i,includeHidden:c,respectGitignore:l,dirs:u!==`file`,type:u}).then(t=>(e(e=>{if(e.inFlight[d]!==h)return e;let n={...e.cache,[d]:{files:t,timestamp:Date.now()}},r=e.cacheKeys.filter(e=>e!==d);for(r.push(d);r.length>Ft;){let e=r.shift();e&&delete n[e]}return{cache:n,cacheKeys:r}}),t)).finally(()=>{e(e=>{if(e.inFlight[d]!==h)return e;let t={...e.inFlight};return delete t[d],{inFlight:t}})});return e(e=>({inFlight:{...e.inFlight,[d]:h}})),h},invalidateDirectory(t){if(!t||t.trim().length===0){e({cache:{},cacheKeys:[],inFlight:{}});return}let n=t.trim();e(e=>{let t={...e.cache},r=e.cacheKeys.filter(e=>!Rt(e,n)||(delete t[e],!1)),i=Object.entries(e.inFlight).filter(([e])=>!Rt(e,n));return{cache:t,cacheKeys:r,inFlight:Object.fromEntries(i)}})}}),{name:`file-search-store`})),Bt=()=>{if(typeof window>`u`)return!1;try{return window.localStorage.getItem(`openchamber_stream_debug`)===`1`}catch{return!1}},Vt=`openchamber_stream_perf`,j=()=>{if(typeof window>`u`)return!1;try{return window.localStorage.getItem(Vt)===`1`}catch{return!1}},Ht=()=>typeof performance<`u`&&typeof performance.now==`function`?performance.now():Date.now(),Ut=()=>{if(!j()||typeof window>`u`)return null;if(!window.__openchamberStreamPerfState){let e=Date.now();window.__openchamberStreamPerfState={counters:new Map,startedAt:e,lastUpdatedAt:e}}return window.__openchamberStreamPerfState},Wt=e=>Array.from(e.entries()).map(([e,t])=>({metric:e,count:t.count,avg:t.count>0?Number((t.total/t.count).toFixed(3)):0,max:Number(t.max.toFixed(3)),total:Number(t.total.toFixed(3)),last:Number(t.last.toFixed(3))})).sort((e,t)=>t.total-e.total||t.count-e.count),Gt=(e,t)=>{let n=Ut();if(!n)return;let r=n.counters.get(e)??{count:0,total:0,max:0,last:0};r.count+=1,r.total+=t,r.max=Math.max(r.max,t),r.last=t,n.counters.set(e,r),n.lastUpdatedAt=Date.now()},Kt=e=>{if(!(typeof window>`u`))try{if(e){window.localStorage.setItem(Vt,`1`),window.__openchamberStreamPerfState={counters:new Map,startedAt:Date.now(),lastUpdatedAt:Date.now()};return}window.localStorage.removeItem(Vt),delete window.__openchamberStreamPerfState,delete window.__openchamberVsCodeStreamPerfState}catch{}},qt=()=>{typeof window>`u`||(j()&&(window.__openchamberStreamPerfState={counters:new Map,startedAt:Date.now(),lastUpdatedAt:Date.now()}),window.__openchamberVsCodeStreamPerfState&&(window.__openchamberVsCodeStreamPerfState={...window.__openchamberVsCodeStreamPerfState,counters:new Map,startedAt:Date.now(),lastUpdatedAt:Date.now()}))},Jt=()=>{if(typeof window>`u`)return{enabled:!1,startedAt:null,lastUpdatedAt:null,durationMs:0,entries:[]};let e=window.__openchamberStreamPerfState;return!j()||!e?{enabled:!1,startedAt:null,lastUpdatedAt:null,durationMs:0,entries:[]}:{enabled:!0,startedAt:e.startedAt,lastUpdatedAt:e.lastUpdatedAt,durationMs:Math.max(0,Date.now()-e.startedAt),entries:Wt(e.counters)}},Yt=()=>{if(typeof window>`u`)return{enabled:!1,startedAt:null,lastUpdatedAt:null,durationMs:0,entries:[]};let e=window.__openchamberVsCodeStreamPerfState;if(!j()||!e)return{enabled:!1,startedAt:null,lastUpdatedAt:null,durationMs:0,entries:[]};let t=typeof e.startedAt==`number`?e.startedAt:null;return{enabled:!0,startedAt:t,lastUpdatedAt:typeof e.lastUpdatedAt==`number`?e.lastUpdatedAt:null,durationMs:t?Math.max(0,Date.now()-t):0,entries:Wt(e.counters)}},Xt=(e,t=1)=>{Gt(e,t)},Zt=(e,t)=>{Gt(e,t)},Qt=(e,t)=>{if(!j())return t();let n=Ht();try{return t()}finally{Gt(e,Ht()-n)}},M=null,$t=0,N=s(),en=f(`lastDirectory`,{storage:N}),tn=typeof en==`string`&&en.length>0,P=e=>{try{zt.getState().invalidateDirectory(e)}catch(e){console.warn(`Failed to invalidate file search cache:`,e)}},F=e=>{let t=e.trim();if(!t)return t;let n=t.replace(/\\/g,`/`).replace(/^([a-z]):/,(e,t)=>t.toUpperCase()+`:`);return n.length>1?n.replace(/\/+$/,``):n},nn=(e,t)=>{let n=e.trim();return n.startsWith(`~`)?n===`~`?t||n:(n.startsWith(`~/`)||n.startsWith(`~\\`))&&t?`${t}${n.slice(1)}`:n:n},I=(e,t)=>F(nn(e,t)),rn=()=>{let e=f(`homeDirectory`,{storage:N});if(typeof e!=`string`||e.trim().length===0)return null;let t=F(e);return t.length>0?t:null},an=()=>{let e=f(`lastDirectory`,{storage:N});if(typeof e!=`string`||e.trim().length===0)return null;let t=F(e);return t.length>0?t:null},on=()=>{if(typeof process>`u`)return null;let e={},t=e?.HOME||e?.USERPROFILE||(e?.HOMEDRIVE&&e?.HOMEPATH?`${e.HOMEDRIVE}${e.HOMEPATH}`:void 0);if(typeof t==`string`&&t.trim().length>0){let e=F(t);return e.length>0?e:null}let n=process?.cwd?.();if(typeof n==`string`&&n.trim().length>0){let e=F(n);return e.length>0?e:null}return null},sn=()=>{if(typeof window<`u`){if(M)return M;let e=typeof window.__OPENCHAMBER_HOME__==`string`&&window.__OPENCHAMBER_HOME__.length>0?window.__OPENCHAMBER_HOME__:null;if(e&&e.length>0)return M=e,p(`homeDirectory`,e,{storage:N}),e;let t=rn();if(t&&!d())return M=t,t}return on()||`/`},cn=e=>{if(typeof e!=`string`)return null;let t=e.trim();if(!t)return null;let n=t.replace(/\\/g,`/`);if(n.length>1){let e=n.replace(/\/+$/,``);if(e&&e.length>0)return e===`/`?null:e}return n===`/`||n.length===0?null:n},ln=e=>(M=e,typeof window<`u`&&p(`homeDirectory`,e,{storage:N}),_({homeDirectory:e}),e),un=async()=>{let e=e=>{let t=cn(e);return t?ln(t):null};try{let t=e(await A.getFilesystemHome());if(t)return t}catch(e){console.warn(`Failed to obtain filesystem home directory:`,e)}try{let t=e((await A.getSystemInfo())?.homeDirectory);if(t)return t}catch(e){console.warn(`Failed to get home directory from system info:`,e)}try{let t=e(await re());if(t)return t}catch(e){console.warn(`Failed to obtain desktop-integrated home directory:`,e)}let t=sn();return e(t)||t},L=(()=>{if(!d())return null;let e=window.__VSCODE_CONFIG__?.workspaceFolder;if(typeof e!=`string`||e.trim().length===0)return null;let t=F(e);return t.length>0?t:null})()||sn(),R=(()=>{let e=an();return e&&!d()?I(e,L):L})();R&&A.setDirectory(R);var dn=!!(L&&L!==`/`),z=ie()(ae((e,t)=>({currentDirectory:R,directoryHistory:[R],historyIndex:0,homeDirectory:L,hasPersistedDirectory:tn,isHomeReady:dn,isSwitchingDirectory:!1,setDirectory:(n,r)=>{let i=I(n,M||t().homeDirectory||f(`homeDirectory`,{storage:N}));Bt(),le(t().currentDirectory,i)&&(A.setDirectory(i),P(),e(e=>{let t=[...e.directoryHistory.slice(0,e.historyIndex+1),i];return p(`lastDirectory`,i,{storage:N}),_({lastDirectory:i}),{currentDirectory:i,directoryHistory:t,historyIndex:t.length-1,hasPersistedDirectory:!0,isHomeReady:!0,isSwitchingDirectory:!1}}))},goBack:()=>{let n=t();if(n.historyIndex>0){let t=n.historyIndex-1,r=n.directoryHistory[t];A.setDirectory(r),P(),p(`lastDirectory`,r,{storage:N}),_({lastDirectory:r}),e({currentDirectory:r,historyIndex:t,hasPersistedDirectory:!0,isHomeReady:!0,isSwitchingDirectory:!1})}},goForward:()=>{let n=t();if(n.historyIndex<n.directoryHistory.length-1){let t=n.historyIndex+1,r=n.directoryHistory[t];A.setDirectory(r),P(),p(`lastDirectory`,r,{storage:N}),_({lastDirectory:r}),e({currentDirectory:r,historyIndex:t,hasPersistedDirectory:!0,isHomeReady:!0,isSwitchingDirectory:!1})}},goToParent:()=>{let{currentDirectory:e,setDirectory:n}=t();if(e===(M||t().homeDirectory||sn())||e===`/`)return;let r=e.endsWith(`/`)?e.slice(0,-1):e,i=r.lastIndexOf(`/`);n(i===-1?M||sn():i===0?`/`:r.substring(0,i))},goHome:async()=>{let e=M||t().homeDirectory||await un();t().setDirectory(e)},synchronizeHomeDirectory:n=>{let r=t(),i=n;M=i;let a=r.homeDirectory!==i,o=f(`lastDirectory`,{storage:N}),s=typeof o==`string`&&o.length>0,c=!s&&(r.currentDirectory===`/`||r.currentDirectory===r.homeDirectory||!r.currentDirectory);if(!a&&!c){r.isHomeReady||e({isHomeReady:!0});return}let l=typeof i==`string`&&i!==``&&i!==`/`,u=r.currentDirectory?I(r.currentDirectory,i):r.currentDirectory,d=r.directoryHistory.map(e=>I(e,i)),m=d.some((e,t)=>e!==r.directoryHistory[t]),h=!!(u&&u!==r.currentDirectory),g={homeDirectory:i,hasPersistedDirectory:s,isHomeReady:l};if(c?(g.currentDirectory=i,g.directoryHistory=[i],g.historyIndex=0,g.isSwitchingDirectory=!1):(h||m)&&(g.currentDirectory=u,g.directoryHistory=d,g.historyIndex=Math.min(r.historyIndex,d.length-1),g.isSwitchingDirectory=!1),e(()=>g),(c||h)&&l){let e=c?i:u;A.setDirectory(e),P(),p(`lastDirectory`,e,{storage:N}),_({lastDirectory:e})}_({homeDirectory:i})}}),{name:`directory-store`}));typeof window<`u`&&(un().then(e=>{z.getState().synchronizeHomeDirectory(e)}),n(e=>{M=null;let t=++$t;if(c(e)){let e=rn(),t=an(),n=e||`/`,r=t||n;M=e,z.setState({currentDirectory:r,directoryHistory:[r],historyIndex:0,homeDirectory:n,hasPersistedDirectory:!!t,isHomeReady:!!(e&&e!==`/`),isSwitchingDirectory:!1}),r&&(A.setDirectory(r),P())}un().then(e=>{t===$t&&z.getState().synchronizeHomeDirectory(e)})}));var fn=(e,n)=>{let r=o();return r?r.openWebSocket(l(e),n):t(n?new WebSocket(e,n):new WebSocket(e))},B=`/api/git`,pn=1200,mn=5e3,hn=2,gn=5e3,_n=`${B}/worktrees/queue-activation`,vn=`message_queue_activation_pending`,yn=`worktree_lifecycle_busy`,bn=`worktree_activation_stale`,xn=5e3,Sn=3e4,Cn=[0,500,1e3,2e3,4e3,8e3,14e3],V=new Map,H=new Map,wn=new Map,U=new Map,W=new Map,G=new Map,K=new Map,Tn=new Map,q=new Map,En=new Map,Dn=new Set,J=0,On=[],kn=()=>J<hn?(J+=1,Promise.resolve()):new Promise(e=>{On.push(e)}),An=()=>{let e=On.shift();if(e){e();return}J=Math.max(0,J-1)},Y=async e=>{await kn();try{return await e()}finally{An()}},jn=Symbol.for(`openchamber.git.discoveryGated`),Mn=e=>(Object.defineProperty(e,jn,{value:!0,configurable:!0}),e),Nn=e=>typeof e==`function`&&e[jn]===!0,X=e=>e.trim(),Pn=(e,t)=>t===`light`?`${X(e)}::light`:X(e),Fn=e=>wn.get(X(e))??0,Z=e=>{let t=X(e);wn.set(t,Fn(e)+1);for(let e of Array.from(V.keys()))(e===t||e.startsWith(`${t}::`))&&V.delete(e);for(let e of Array.from(H.keys()))(e===t||e.startsWith(`${t}::`))&&H.delete(e)},In=e=>En.get(X(e))??0,Q=e=>{let t=X(e);t&&(En.set(t,In(e)+1),Tn.delete(t),q.delete(t))};function $(e,t,n){let r={...n};return t&&(r.directory=t),i().api(e,r)}var Ln=(e,t,n)=>{let r=X(e);if(!r)return;let i=Date.now()+gn;U.set(r,{value:t,expiresAt:i});let a=typeof n==`string`&&n?n:e;G.set(r,{value:{root:a},expiresAt:i})};async function Rn(e){let t=Array.from(new Set(e.map(e=>X(e)).filter(Boolean))),n=new Map;if(t.length===0)return n;let r=Date.now(),a=[];for(let e of t){let t=U.get(e),i=G.get(e);if(t&&t.expiresAt>r&&i&&i.expiresAt>r){n.set(e,{isGitRepository:t.value,primaryRoot:i.value.root});continue}a.push(e)}if(a.length===0)return n;let o=e=>{for(let t of e){let e=typeof t.directory==`string`?X(t.directory):``;if(!e)continue;let r=!!t.isGitRepository,i=typeof t.primaryRoot==`string`&&t.primaryRoot?t.primaryRoot:null;Ln(e,r,i),n.set(e,{isGitRepository:r,primaryRoot:i})}},s=async e=>{await Promise.all(e.map(async e=>{try{let[t,r]=await Promise.all([zn(e),Vn(e).then(e=>e.root).catch(()=>e)]);Ln(e,t,t?r:null),n.set(e,{isGitRepository:t,primaryRoot:t?r:null})}catch{Ln(e,!1,null),n.set(e,{isGitRepository:!1,primaryRoot:null})}}))};try{await Y(async()=>{let e=new URLSearchParams;for(let t of a)e.append(`directories`,t);let t=i().api(`${B}/discover`),n=e.toString(),r=n?t.includes(`?`)?`${t}&${n}`:`${t}?${n}`:t,s=await h(r);if(s.status===501||!s.ok)throw Error(`Batch git discover unavailable: ${s.status} ${s.statusText}`);let c=await s.json().catch(()=>null),l=Array.isArray(c)?c:[];if(l.length===0&&a.length>0)throw Error(`Batch git discover returned empty payload`);o(l)})}catch{}let c=a.filter(e=>!n.has(e));return c.length>0&&await s(c),n}async function zn(e){let t=X(e),n=Date.now(),r=U.get(t);if(r&&r.expiresAt>n)return r.value;let i=W.get(t);if(i)return i;let a=(async()=>{let n=await h($(`${B}/check`,e));if(!n.ok)throw Error(`Failed to check git repository: ${n.statusText}`);let r=!!(await n.json()).isGitRepository;return U.set(t,{value:r,expiresAt:Date.now()+mn}),r})();W.set(t,a);try{return await a}finally{W.get(t)===a&&W.delete(t)}}async function Bn(e,t){let n=t?.mode,r=Pn(e,n),i=Date.now(),a=V.get(r);if(a&&a.expiresAt>i)return a.value;let o=H.get(r);if(o)return o;let s=(async()=>{let t=Fn(e),i=await h($(`${B}/status`,e,n?{mode:n}:void 0));if(!i.ok)throw Error(`Failed to get git status: ${i.statusText}`);let a=await i.json();return Fn(e)===t&&V.set(r,{value:a,expiresAt:Date.now()+pn}),a})();H.set(r,s);try{return await s}finally{H.get(r)===s&&H.delete(r)}}async function Vn(e){let t=X(e),n=Date.now(),r=G.get(t);if(r&&r.expiresAt>n)return r.value;let i=K.get(t);if(i)return i;let a=Y(async()=>{let n=await h($(`${B}/primary-root`,e));if(!n.ok)throw Error(`Failed to resolve git primary root: ${n.statusText}`);let r=await n.json().catch(()=>({})),i={root:typeof r.root==`string`&&r.root?r.root:e};return G.set(t,{value:i,expiresAt:Date.now()+gn}),i});K.set(t,a);try{return await a}finally{K.get(t)===a&&K.delete(t)}}async function Hn(e){let t=await h($(`${B}/toplevel`,e));if(!t.ok)throw Error(`Failed to resolve git toplevel: ${t.statusText}`);let n=await t.json().catch(()=>({}));return{root:typeof n.root==`string`&&n.root?n.root:e}}async function Un(e,t){let{path:n,staged:r,contextLines:i}=t;if(!n)throw Error(`path is required to fetch git diff`);let a=await h($(`${B}/diff`,e,{path:n,staged:r?`true`:void 0,context:i}));if(!a.ok)throw Error(`Failed to get git diff: ${a.statusText}`);return a.json()}async function Wn(e,t){let{path:n,staged:r}=t;if(!n)throw Error(`path is required to fetch git file diff`);let i=await h($(`${B}/file-diff`,e,{path:n,staged:r?`true`:void 0}));if(!i.ok)throw Error(`Failed to get git file diff: ${i.statusText}`);return i.json()}async function Gn(e,t,n){if(!t)throw Error(`path is required to revert git changes`);let r=await h($(`${B}/revert`,e),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({path:t,scope:n?.scope})});if(!r.ok){let e=await r.json().catch(()=>({error:r.statusText}));throw Error(e.error||`Failed to revert git changes`)}Z(e)}async function Kn(e,t){await qn(e,[t])}async function qn(e,t){let n=t.map(e=>e.trim()).filter(Boolean);if(n.length===0)throw Error(`path is required to stage git changes`);let r=await h($(`${B}/stage`,e),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({paths:n})});if(!r.ok){let e=await r.json().catch(()=>({error:r.statusText}));throw Error(e.error||`Failed to stage git changes`)}Z(e)}async function Jn(e,t){await Yn(e,[t])}async function Yn(e,t){let n=t.map(e=>e.trim()).filter(Boolean);if(n.length===0)throw Error(`path is required to unstage git changes`);let r=await h($(`${B}/unstage`,e),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({paths:n})});if(!r.ok){let e=await r.json().catch(()=>({error:r.statusText}));throw Error(e.error||`Failed to unstage git changes`)}Z(e)}async function Xn(e,t,n){await $n(e,t,n,`stage`)}async function Zn(e,t,n){await $n(e,t,n,`unstage`)}async function Qn(e,t,n){await $n(e,t,n,`discard`)}async function $n(e,t,n,r){if(!t)throw Error(`path is required to apply a git hunk`);if(typeof n!=`string`||!n.trim())throw Error(`patch is required to apply a git hunk`);let i=await h($(`${B}/apply-hunk`,e),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({path:t,patch:n,action:r})});if(!i.ok){let e=await i.json().catch(()=>({error:i.statusText}));throw Error(e.error||`Failed to apply git hunk`)}Z(e)}async function er(e){if(!e)return!1;let t=await h($(`${B}/worktree-type`,e));if(!t.ok)throw Error(`Failed to detect worktree type: ${t.statusText}`);return!!(await t.json()).linked}async function tr(e,t){let n=await h($(`${B}/branches`,e),{signal:t?.signal});if(!n.ok)throw Error(`Failed to get branches: ${n.statusText}`);return n.json()}async function nr(e,t){if(!t?.branch)throw Error(`branch is required to delete a branch`);let n=await h($(`${B}/branches`,e),{method:`DELETE`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)});if(!n.ok){let e=await n.json().catch(()=>({error:n.statusText}));throw Error(e.error||`Failed to delete branch`)}return n.json()}async function rr(e,t){if(!t?.branch)throw Error(`branch is required to delete remote branch`);let n=await h($(`${B}/remote-branches`,e),{method:`DELETE`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)});if(!n.ok){let e=await n.json().catch(()=>({error:n.statusText}));throw Error(e.error||`Failed to delete remote branch`)}return n.json()}async function ir(e,t){let n=t?.remote?.trim();if(!n)throw Error(`remote is required to remove a remote`);let r=await h($(`${B}/remotes`,e),{method:`DELETE`,headers:{"Content-Type":`application/json`},body:JSON.stringify({remote:n})});if(!r.ok){let e=await r.json().catch(()=>({error:r.statusText}));throw Error(e.error||`Failed to remove remote`)}return r.json()}async function ar(e,t,n){if(!Array.isArray(t)||t.length===0)throw Error(`No files provided to generate commit message`);let r={files:t};n?.zenModel&&(r.zenModel=n.zenModel),n?.providerId&&(r.providerId=n.providerId),n?.modelId&&(r.modelId=n.modelId);let i=await h($(`${B}/commit-message`,e),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(r)});if(!i.ok){let e=await i.json().catch(()=>({error:i.statusText}));console.error(`[git-generation][browser] http error`,{status:i.status,statusText:i.statusText,error:e});let t=typeof e?.traceId==`string`&&e.traceId?` (traceId: ${e.traceId})`:``;throw Error(`${e.error||`Failed to generate commit message`}${t}`)}let a=await i.json();if(!a?.message||typeof a.message!=`object`)throw Error(`Malformed commit generation response`);return{message:{subject:typeof a.message.subject==`string`&&a.message.subject.trim().length>0?a.message.subject.trim():``,highlights:Array.isArray(a.message.highlights)?a.message.highlights.filter(e=>typeof e==`string`&&e.trim().length>0).map(e=>e.trim()):[]}}}async function or(e,t){let{base:n,head:r,context:i,zenModel:a,providerId:o,modelId:s}=t;if(!n||!r)throw Error(`base and head are required`);let c={base:n,head:r};i?.trim()&&(c.context=i.trim()),a&&(c.zenModel=a),o&&(c.providerId=o),s&&(c.modelId=s);let l=await h($(`${B}/pr-description`,e),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(c)});if(!l.ok){let e=await l.json().catch(()=>({error:l.statusText}));throw Error(e.error||`Failed to generate PR description`)}let u=await l.json().catch(()=>null),d=typeof u?.title==`string`?u.title:``,f=typeof u?.body==`string`?u.body:``;if(!d&&!f)throw Error(`Malformed PR description response`);return{title:d,body:f}}async function sr(e){let t=X(e),n=Date.now(),r=Tn.get(t);if(r&&r.expiresAt>n)return r.value;let i=q.get(t);if(i)return i;let a=In(e),o=Y(async()=>{let n=await h($(`${B}/worktrees`,e));if(!n.ok){let e=await n.json().catch(()=>({error:n.statusText}));throw Error(e.error||`Failed to list worktrees`)}let r=await n.json();return a===In(e)&&Tn.set(t,{value:r,expiresAt:Date.now()+gn}),r});q.set(t,o);try{return await o}finally{q.get(t)===o&&q.delete(t)}}Mn(sr);async function cr(e,t){let n=await h($(`${B}/worktrees/validate`,e),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t??{})});if(!n.ok){let e=await n.json().catch(()=>({error:n.statusText}));throw Error(e.error||`Failed to validate worktree`)}return n.json()}async function lr(e){let t=await h($(`${B}/worktrees/bootstrap-status`,e));if(!t.ok){let e=await t.json().catch(()=>({error:t.statusText}));throw Error(e.error||`Failed to get worktree bootstrap status`)}return t.json()}async function ur(e,t){let n=await h($(`${B}/worktrees/preview`,e),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t??{})});if(!n.ok){let e=await n.json().catch(()=>({error:n.statusText}));throw Error(e.error||`Failed to preview worktree`)}return n.json()}var dr=e=>typeof e==`string`&&e.length>0,fr=e=>{if(!e||typeof e!=`object`)return null;let t=e;if(!dr(t.name)||!dr(t.path))return null;let n={head:typeof t.head==`string`?t.head:``,name:t.name,branch:typeof t.branch==`string`?t.branch:``,path:t.path};return t.directoryCreated===!0&&(n.directoryCreated=!0),t.bootstrapStatus&&typeof t.bootstrapStatus==`object`&&(n.bootstrapStatus=t.bootstrapStatus),n},pr=(e,t,n)=>{if(e!==503||!t||typeof t!=`object`)return null;let r=t;if(r.code!==vn)return null;let i=fr(r.worktree);if(!i)return null;let a=r.repair;if(!a||typeof a!=`object`)return null;let o=a;if(o.method!==`POST`||o.path!==_n)return null;let s=o.body;if(!s||typeof s!=`object`)return null;let c=s;return c.projectDirectory!==n||c.directory!==i.path?null:i},mr=(e,t,n,r)=>`${e}\u0000${t}\u0000${n}\u0000${r}`,hr=e=>new Promise(t=>{setTimeout(t,e)}),gr=async e=>{if(e.status===409){let t=await e.json().catch(()=>null);return t?.code===yn||t?.code===bn}return e.status===503&&(await e.json().catch(()=>null))?.code===vn},_r=e=>e===400||e===401||e===403||e===501,vr=(e,t)=>{let n=r(),i=u(),a=mr(n,i,e,t);if(Dn.has(a))return;Dn.add(a);let o=()=>r()===n&&u()===i;(async()=>{let n=Date.now(),r=0;for(;Date.now()-n<Sn;){if(!o())return;let i=Cn[Math.min(r,Cn.length-1)]??0;if(i>0){let e=Sn-(Date.now()-n);if(e<=0||(await hr(Math.min(i,e)),!o()))return}let a=new AbortController,s=setTimeout(()=>a.abort(),xn);try{let n=await h($(_n,void 0),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({projectDirectory:e,directory:t}),signal:a.signal});if(n.ok||_r(n.status))return;if(await gr(n)){r+=1;continue}return}catch{r+=1}finally{clearTimeout(s)}}})().catch(()=>{}).finally(()=>{Dn.delete(a)})};async function yr(e,t){let n=await h($(`${B}/worktrees`,e),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t??{})}),r=await n.json().catch(()=>null);if(n.ok){let t=fr(r);if(t)return Q(e),t;if(r&&typeof r==`object`)return Q(e),r;throw Error(`Failed to create worktree`)}let i=pr(n.status,r,e);if(i)return Q(e),vr(e,i.path),i;let a=r&&typeof r==`object`?r:{error:n.statusText};throw Error(a.error||`Failed to create worktree`)}async function br(e,t){let n=await h($(`${B}/worktrees`,e),{method:`DELETE`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t??{})});if(!n.ok){let e=await n.json().catch(()=>({error:n.statusText}));throw Error(e.error||`Failed to delete worktree`)}let r=await n.json();return Q(e),r}async function xr(e,t,n={}){let r=await h($(`${B}/commit`,e),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({message:t,addAll:n.addAll??!1,files:n.files,stageFiles:n.stageFiles})});if(!r.ok){let e=await r.json().catch(()=>({error:r.statusText}));throw Error(e.error||`Failed to create commit`)}let i=await r.json();return Z(e),i}async function Sr(e,t={}){let n=await h($(`${B}/push`,e),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)});if(!n.ok){let e=await n.json().catch(()=>({error:n.statusText}));throw Error(e.error||`Failed to push`)}let r=await n.json();return Z(e),r}async function Cr(e,t={}){let n=await h($(`${B}/pull`,e),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)});if(!n.ok){let e=await n.json().catch(()=>({error:n.statusText}));throw Error(e.error||`Failed to pull`)}let r=await n.json();return Z(e),r}async function wr(e,t={}){let n=await h($(`${B}/fetch`,e),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)});if(!n.ok){let e=await n.json().catch(()=>({error:n.statusText}));throw Error(e.error||`Failed to fetch`)}let r=await n.json();return Z(e),r}async function Tr(e){let t=await h($(`${B}/stashes`,e));if(!t.ok){let e=await t.json().catch(()=>({error:t.statusText}));throw Error(e.error||`Failed to list stashes`)}return t.json()}async function Er(e,t){let n=await h($(`${B}/stashes/file-counts`,e),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({refs:t})});if(!n.ok){let e=await n.json().catch(()=>({error:n.statusText}));throw Error(e.error||`Failed to count stash files`)}return n.json()}async function Dr(e,t={}){let n=await h($(`${B}/stash`,e),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)});if(!n.ok){let e=await n.json().catch(()=>({error:n.statusText}));throw Error(e.error||`Failed to stash changes`)}return n.json()}var Or=async(e,t,n)=>{let r=await h($(`${B}/${t}`,e),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(n)});if(!r.ok){let e=await r.json().catch(()=>({error:r.statusText}));throw Error(e.error||`Failed to ${t}`)}return r.json()},kr=(e,t)=>Or(e,`stash/apply`,t),Ar=(e,t)=>Or(e,`stash/pop`,t),jr=(e,t)=>Or(e,`stash/drop`,t);async function Mr(e,t){let n=await h($(`${B}/checkout`,e),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({branch:t})});if(!n.ok){let e=await n.json().catch(()=>({error:n.statusText}));throw Error(e.error||`Failed to checkout branch`)}return n.json()}async function Nr(e,t,n){let r=await h($(`${B}/branches`,e),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({name:t,startPoint:n})});if(!r.ok){let e=await r.json().catch(()=>({error:r.statusText}));throw Error(e.error||`Failed to create branch`)}return r.json()}async function Pr(e,t,n){let r=await h($(`${B}/branches/rename`,e),{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({oldName:t,newName:n})});if(!r.ok){let e=await r.json().catch(()=>({error:r.statusText}));throw Error(e.error||`Failed to rename branch`)}return r.json()}async function Fr(e,t={}){let n=await h($(`${B}/log`,e,{maxCount:t.maxCount,from:t.from,to:t.to,file:t.file,all:t.all?`true`:void 0}));if(!n.ok){let e=await n.json().catch(()=>({error:n.statusText}));throw Error(`Failed to get git log: ${e.error||n.statusText}`)}return n.json()}async function Ir(e,t){let n=await h($(`${B}/commit-files`,e,{hash:t}));if(!n.ok)throw Error(`Failed to get commit files: ${n.statusText}`);return n.json()}async function Lr(e,t,n,r){let i=await h($(`${B}/commit-file-diff`,e,{hash:t,path:n,binary:r?`true`:void 0}));if(!i.ok)throw Error(`Failed to get commit file diff: ${i.statusText}`);return i.json()}async function Rr(){let e=await h($(`${B}/identities`,void 0));if(!e.ok)throw Error(`Failed to get git identities: ${e.statusText}`);return e.json()}async function zr(e){let t=await h($(`${B}/identities`,void 0),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok){let e=await t.json().catch(()=>({error:t.statusText}));throw Error(e.error||`Failed to create git identity`)}return t.json()}async function Br(e,t){let n=await h($(`${B}/identities/${e}`,void 0),{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)});if(!n.ok){let e=await n.json().catch(()=>({error:n.statusText}));throw Error(e.error||`Failed to update git identity`)}return n.json()}async function Vr(e){let t=await h($(`${B}/identities/${e}`,void 0),{method:`DELETE`});if(!t.ok){let e=await t.json().catch(()=>({error:t.statusText}));throw Error(e.error||`Failed to delete git identity`)}}async function Hr(e){if(!e)return null;let t=await h($(`${B}/current-identity`,e));if(!t.ok)throw Error(`Failed to get current git identity: ${t.statusText}`);let n=await t.json();return n?{userName:n.userName??null,userEmail:n.userEmail??null,sshCommand:n.sshCommand??null}:null}async function Ur(e){if(!e)return!1;let t=await h($(`${B}/has-local-identity`,e));if(!t.ok)throw Error(`Failed to check local identity: ${t.statusText}`);return(await t.json().catch(()=>null))?.hasLocalIdentity===!0}async function Wr(){let e=await h($(`${B}/global-identity`,void 0));if(!e.ok)throw Error(`Failed to get global git identity: ${e.statusText}`);let t=await e.json();return!t||!t.userName&&!t.userEmail?null:{userName:t.userName??null,userEmail:t.userEmail??null,sshCommand:t.sshCommand??null}}async function Gr(e,t){let n=await h($(`${B}/set-identity`,e),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({profileId:t})});if(!n.ok){let e=await n.json().catch(()=>({error:n.statusText}));throw Error(e.error||`Failed to set git identity`)}return n.json()}async function Kr(){let e=await h($(`${B}/discover-credentials`,void 0));if(!e.ok)throw Error(`Failed to discover git credentials: ${e.statusText}`);return e.json()}async function qr(e,t){let n=await h($(`${B}/remotes`,e),{signal:t?.signal});if(!n.ok)throw Error(`Failed to get remotes: ${n.statusText}`);return n.json()}async function Jr(e,t){let n=await h($(`${B}/rebase`,e),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)});if(!n.ok){let e=await n.json().catch(()=>({error:n.statusText}));throw Error(e.error||`Failed to rebase`)}return n.json()}async function Yr(e){let t=await h($(`${B}/rebase/abort`,e),{method:`POST`});if(!t.ok){let e=await t.json().catch(()=>({error:t.statusText}));throw Error(e.error||`Failed to abort rebase`)}return t.json()}async function Xr(e,t){let n=await h($(`${B}/merge`,e),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)});if(!n.ok){let e=await n.json().catch(()=>({error:n.statusText}));throw Error(e.error||`Failed to merge`)}return n.json()}async function Zr(e,t){let n=await h($(`${B}/checkout-commit`,e),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({hash:t})});if(!n.ok){let e=await n.json().catch(()=>({error:n.statusText}));throw Error(e.error||`Failed to checkout commit`)}return n.json()}async function Qr(e,t){let n=await h($(`${B}/cherry-pick`,e),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({hash:t})});if(!n.ok){let e=await n.json().catch(()=>({error:n.statusText}));throw Error(e.error||`Failed to cherry-pick`)}return n.json()}async function $r(e,t){let n=await h($(`${B}/revert-commit`,e),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({hash:t})});if(!n.ok){let e=await n.json().catch(()=>({error:n.statusText}));throw Error(e.error||`Failed to revert commit`)}return n.json()}async function ei(e,t,n,r){let i=await h($(`${B}/reset-to-commit`,e),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({hash:t,mode:n,force:r})});if(!i.ok){let e=await i.json().catch(()=>({error:i.statusText}));throw Error(e.error||`Failed to reset`)}return i.json()}async function ti(e){let t=await h($(`${B}/merge/abort`,e),{method:`POST`});if(!t.ok){let e=await t.json().catch(()=>({error:t.statusText}));throw Error(e.error||`Failed to abort merge`)}return t.json()}async function ni(e){let t=await h($(`${B}/rebase/continue`,e),{method:`POST`});if(!t.ok){let e=await t.json().catch(()=>({error:t.statusText}));throw Error(e.error||`Failed to continue rebase`)}return t.json()}async function ri(e){let t=await h($(`${B}/merge/continue`,e),{method:`POST`});if(!t.ok){let e=await t.json().catch(()=>({error:t.statusText}));throw Error(e.error||`Failed to continue merge`)}return t.json()}async function ii(e,t){return await Dr(e,{message:t?.message}),{success:!0}}async function ai(e){return await Ar(e,{ref:`stash@{0}`}),{success:!0}}async function oi(e){let t=await h($(`${B}/conflict-details`,e));if(!t.ok)throw Error(`Failed to get conflict details: ${t.statusText}`);return t.json()}async function si(e,t){let n=await h(`${B}/validate-directory`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({directory:e,worktreeRoot:t})});if(!n.ok)throw Error(`Failed to validate worktree directory: ${n.statusText}`);return n.json()}async function ci(e){let t=await h(`${B}/canonicalize-worktree-state`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({directory:e})});if(!t.ok)throw Error(`Failed to canonicalize worktree state: ${t.statusText}`);return t.json()}var li=()=>typeof window>`u`?!1:window.Capacitor?.isNativePlatform?.()===!0||window.location.protocol===`capacitor:`,ui=()=>{if(typeof window>`u`||!li()||di()!==`ios`)return!1;let e=navigator.userAgent||``,t=navigator.maxTouchPoints??0;return/iPad/i.test(e)||/Macintosh|MacIntel/i.test(e)&&t>1},di=()=>{if(typeof window<`u`){let e=window.Capacitor?.getPlatform?.();if(e===`ios`||e===`android`)return e}return d()?`vscode`:m()?`desktop`:`web`};export{Jr as $,oi as A,Qt as At,qr as B,Ne as Bt,Kr as C,z as Ct,or as D,Kt as Dt,ar as E,qt as Et,Rr as F,rt as Ft,Q as G,We as Gt,Cr as H,ze as Ht,Fr as I,nt as It,Tr as J,ve as Jt,Nn as K,Pe as Kt,Bn as L,Be as Lt,tr as M,zt as Mt,Un as N,A as Nt,Lr as O,Bt as Ot,Wn as P,C as Pt,ur as Q,lr as R,je as Rt,rr as S,fn as St,jr as T,Yt as Tt,Sr as U,Ve as Ut,wr as V,Re as Vt,Ur as W,He as Wt,Xr as X,sr as Y,xe as Yt,Ar as Z,zr as _,Zn as _t,Yr as a,$r as at,Vr as b,si as bt,zn as c,Gr as ct,Qr as d,Xn as dt,ir as et,ri as f,ii as ft,xr as g,Yn as gt,Nr as h,Jn as ht,ti as i,Hn as it,Hr as j,Zt as jt,Ir as k,Xt as kt,Mr as l,Kn as lt,Er as m,ai as mt,li as n,ei as nt,kr as o,Gn as ot,ni as p,Dr as pt,er as q,ye as qt,ui as r,Vn as rt,ci as s,Qn as st,di as t,Pr as tt,Zr as u,qn as ut,yr as v,Br as vt,Rn as w,Jt as wt,br as x,Y as xt,nr as y,cr as yt,Wr as z,Me as zt};