@openchambery/web 1.19.0-beta.21 → 1.19.0-beta.22
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.
- package/dist/assets/AgentAvatar-CWn_73qY.js +1 -0
- package/dist/assets/{AssistantView-C7mpM6eZ.js → AssistantView-COjPqVYN.js} +1 -1
- package/dist/assets/{ChatContainer-obK8ZBxN.js → ChatContainer-1UfTcM7y.js} +40 -41
- package/dist/assets/{ContextPanel-zp0wnzQr.js → ContextPanel-DqFjhkep.js} +7 -7
- package/dist/assets/{DiagramView-D_UgqMBZ.js → DiagramView-DTLmw9aQ.js} +1 -1
- package/dist/assets/{MarkdownRendererImpl-BWsesd63.js → MarkdownRendererImpl-DtDXVNL0.js} +1 -1
- package/dist/assets/{MobileDetailNavigation-CsyOt6sI.js → MobileDetailNavigation-Cra616TS.js} +1 -1
- package/dist/assets/{MobileShareBridge-xFcAYp5Y.js → MobileShareBridge-CYfJx34q.js} +1 -1
- package/dist/assets/{MobileSurface-BDXyT5lH.js → MobileSurface-Cy_ouvVc.js} +1 -1
- package/dist/assets/{MultiRunWindow-VNCTQxir.js → MultiRunWindow-DVs6MZjv.js} +1 -1
- package/dist/assets/{OnboardingScreen-C0DduEDx.js → OnboardingScreen-CzxsmiJZ.js} +1 -1
- package/dist/assets/OverlayScrollbar-DEM7AQRU.js +2 -0
- package/dist/assets/{SettingsView-dSH_LSe8.js → SettingsView-C1KgXp3x.js} +8 -8
- package/dist/assets/{SettingsWindow-DTuDa8VV.js → SettingsWindow-BkiQFX0S.js} +1 -1
- package/dist/assets/{TerminalView-DqHOdqxB.js → TerminalView-CL9PoqxQ.js} +1 -1
- package/dist/assets/{ToolOutputDialog-KSB9plm-.js → ToolOutputDialog-z6vyx5bl.js} +4 -4
- package/dist/assets/appThemeRegistry-h64RD_n6.js +2 -0
- package/dist/assets/{clipboard-C7zcAKyC.js → clipboard-DyCy8o-j.js} +1 -1
- package/dist/assets/dialog-BpUGcA8h.js +1 -0
- package/dist/assets/{es-CcbKrwi9.js → es-L71xM_T9.js} +1 -1
- package/dist/assets/{fr-D1YIDHP6.js → fr-DDeqVFFE.js} +1 -1
- package/dist/assets/{gitApi-DGNLIAdE.js → gitApi-BZs3g7kL.js} +1 -1
- package/dist/assets/{insertionBoundaries-DXyrsxRu.js → insertionBoundaries-B9vsqCQ4.js} +1 -1
- package/dist/assets/{ja-xE7L_-ZU.js → ja-Cb5UuJfO.js} +1 -1
- package/dist/assets/{ko-QUUzIgbd.js → ko-BOQuwJW9.js} +1 -1
- package/dist/assets/{main-CRpXQ6WZ.js → main-BIT8b73F.js} +6 -6
- package/dist/assets/{main-DYLq9MqL.js → main-DVpZG9sL.js} +2 -2
- package/dist/assets/{miniChat-Ivb2We5Z.js → miniChat-DQDvDpWt.js} +2 -2
- package/dist/assets/{mobile-DPV00pm2.js → mobile-BJPgbqSO.js} +2 -2
- package/dist/assets/multirun-CWV76MQl.js +4 -0
- package/dist/assets/{pl-BQfz-_HE.js → pl-CPR51X8e.js} +1 -1
- package/dist/assets/platform-DxNH_0Fj.js +2 -0
- package/dist/assets/projectMeta-Ct-WdvZL.js +3 -0
- package/dist/assets/{pt-BR-DaY3UW5q.js → pt-BR-CCmlB4Wg.js} +1 -1
- package/dist/assets/radio-C2gxi0gx.js +1 -0
- package/dist/assets/{renderElectronMiniChatApp-DR5AYWAI.js → renderElectronMiniChatApp-jaPPkkBN.js} +2 -2
- package/dist/assets/renderMobileApp-CVVQmLPI.js +23 -0
- package/dist/assets/{runtimeConfig-DCTxn3UZ.js → runtimeConfig-X9sNIE9W.js} +1 -1
- package/dist/assets/{runtimeEndpointReset-BEH1It6F.js → runtimeEndpointReset-D-MaZgY5.js} +2 -2
- package/dist/assets/{shikiHighlight-D_nH5nU9.js → shikiHighlight-DZ1bj7ag.js} +1 -1
- package/dist/assets/{sortable-tabs-strip-BsIz5zKp.js → sortable-tabs-strip-C_ZQ75rK.js} +1 -1
- package/dist/assets/{src-Dlj9wgET.css → src-Brv0DCpZ.css} +1 -1
- package/dist/assets/{store-upwbPNfx.js → store--ZgdDfa2.js} +2 -2
- package/dist/assets/{terminalApi-HsIEks5U.js → terminalApi-B36I-z14.js} +1 -1
- package/dist/assets/{uk-yWcUag_v.js → uk-DWxkhZMt.js} +1 -1
- package/dist/assets/{useAppFontEffects-CVy0YR-R.js → useAppFontEffects-C6Ghp0AX.js} +2 -2
- package/dist/assets/{useDesktopWindowControlsLayout-Bk1__c3_.js → useDesktopWindowControlsLayout-Cyxd6emd.js} +1 -1
- package/dist/assets/{useEffectiveDirectory-D71yjOxf.js → useEffectiveDirectory-FcGKsobh.js} +1 -1
- package/dist/assets/{useFontPreferences-DaFspdDd.js → useFontPreferences-D9h4M7x4.js} +1 -1
- package/dist/assets/{useMobileNavigationStore-CBHZdTh6.js → useMobileNavigationStore-DkBMOv1J.js} +8 -8
- package/dist/assets/{useSessionAutoCleanup-BHDVDveQ.js → useSessionAutoCleanup-CbBIekcM.js} +1 -1
- package/dist/assets/{useWorkerHighlightedLines-C37YlH2o.js → useWorkerHighlightedLines-CwQpUpt5.js} +1 -1
- package/dist/assets/{zh-CN-jktTX6F0.js → zh-CN-CnBbxYt8.js} +1 -1
- package/dist/assets/{zh-TW-DS3LNe1V.js → zh-TW-B6McpMc8.js} +1 -1
- package/dist/index.html +5 -5
- package/dist/mini-chat.html +5 -5
- package/dist/mobile.html +5 -5
- package/package.json +1 -1
- package/dist/assets/AgentAvatar-mwB5XUVi.js +0 -1
- package/dist/assets/OverlayScrollbar-BR0ifid5.js +0 -2
- package/dist/assets/appThemeRegistry-DcWBea7B.js +0 -2
- package/dist/assets/dialog-D1Ng5yQe.js +0 -1
- package/dist/assets/multirun-CLWktezk.js +0 -4
- package/dist/assets/platform-ulFAVx1H.js +0 -2
- package/dist/assets/projectMeta-CGWgdtzY.js +0 -3
- package/dist/assets/radio-BJ-X57r_.js +0 -1
- package/dist/assets/renderMobileApp-BtLrFYfl.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-
|
|
555
|
+
<script type="module" crossorigin src="/assets/main-DVpZG9sL.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-
|
|
569
|
-
<link rel="modulepreload" crossorigin href="/assets/terminalApi-
|
|
568
|
+
<link rel="modulepreload" crossorigin href="/assets/platform-DxNH_0Fj.js">
|
|
569
|
+
<link rel="modulepreload" crossorigin href="/assets/terminalApi-B36I-z14.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-
|
|
573
|
-
<link rel="stylesheet" crossorigin href="/assets/src-
|
|
572
|
+
<link rel="modulepreload" crossorigin href="/assets/runtimeConfig-X9sNIE9W.js">
|
|
573
|
+
<link rel="stylesheet" crossorigin href="/assets/src-Brv0DCpZ.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
|
package/dist/mini-chat.html
CHANGED
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
}
|
|
75
75
|
</style>
|
|
76
76
|
|
|
77
|
-
<script type="module" crossorigin src="/assets/miniChat-
|
|
77
|
+
<script type="module" crossorigin src="/assets/miniChat-DQDvDpWt.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-
|
|
91
|
-
<link rel="modulepreload" crossorigin href="/assets/terminalApi-
|
|
90
|
+
<link rel="modulepreload" crossorigin href="/assets/platform-DxNH_0Fj.js">
|
|
91
|
+
<link rel="modulepreload" crossorigin href="/assets/terminalApi-B36I-z14.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-
|
|
95
|
-
<link rel="stylesheet" crossorigin href="/assets/src-
|
|
94
|
+
<link rel="modulepreload" crossorigin href="/assets/runtimeConfig-X9sNIE9W.js">
|
|
95
|
+
<link rel="stylesheet" crossorigin href="/assets/src-Brv0DCpZ.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-
|
|
66
|
+
<script type="module" crossorigin src="/assets/mobile-BJPgbqSO.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-
|
|
80
|
-
<link rel="modulepreload" crossorigin href="/assets/terminalApi-
|
|
79
|
+
<link rel="modulepreload" crossorigin href="/assets/platform-DxNH_0Fj.js">
|
|
80
|
+
<link rel="modulepreload" crossorigin href="/assets/terminalApi-B36I-z14.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-
|
|
84
|
-
<link rel="stylesheet" crossorigin href="/assets/src-
|
|
83
|
+
<link rel="modulepreload" crossorigin href="/assets/runtimeConfig-X9sNIE9W.js">
|
|
84
|
+
<link rel="stylesheet" crossorigin href="/assets/src-Brv0DCpZ.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 +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{c as r,l as i}from"./dialog-D1Ng5yQe.js";import{t as a}from"./utils-CJdWZupK.js";var o=n();t();var s=e(),c=e=>{let t=(0,o.c)(27),{name:n,emoji:c,size:u,className:d,label:f}=e,p=u===void 0?16:u,m,h,g;if(t[0]!==d||t[1]!==c||t[2]!==n){m=i(n);let e;t[6]===n?e=t[7]:(e=r(n),t[6]=n,t[7]=e),h=e,g=a(`inline-flex aspect-square shrink-0 overflow-hidden rounded-sm`,c&&`items-center justify-center select-none`,m.class,d),t[0]=d,t[1]=c,t[2]=n,t[3]=m,t[4]=h,t[5]=g}else m=t[3],h=t[4],g=t[5];let _=`calc(${p}px * var(--dpt-n, 1))`,v=`calc(${p}px * var(--dpt-n, 1))`,y=`calc(${p}px * var(--dpt-n, 1))`,b=`calc(${p}px * var(--dpt-n, 1))`,x=`calc(${p}px * var(--dpt-n, 1))`,S=`calc(${p}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=f?`img`:void 0,E=!f||void 0,D;t[16]!==c||t[17]!==h||t[18]!==p?(D=c?(0,s.jsx)(`span`,{"aria-hidden":`true`,style:{fontSize:`calc(${p*.75}px * var(--dpt-n, 1))`,lineHeight:1},children:c}):(0,s.jsxs)(`svg`,{width:p,height:p,viewBox:`0 0 5 5`,shapeRendering:`crispEdges`,className:`oc-agent-avatar block h-full w-full`,"aria-hidden":`true`,children:[(0,s.jsx)(`rect`,{width:`5`,height:`5`,fill:`currentColor`,opacity:.14}),h.map(l)]}),t[16]=c,t[17]=h,t[18]=p,t[19]=D):D=t[19];let O;return t[20]!==f||t[21]!==w||t[22]!==T||t[23]!==E||t[24]!==D||t[25]!==g?(O=(0,s.jsx)(`span`,{className:g,style:w,role:T,"aria-label":f,"aria-hidden":E,children:D}),t[20]=f,t[21]=w,t[22]=T,t[23]=E,t[24]=D,t[25]=g,t[26]=O):O=t[26],O};function l(e,t){return e.map((e,n)=>e?(0,s.jsx)(`rect`,{x:n,y:t,width:`1`,height:`1`,fill:`currentColor`},`${n}-${t}`):null)}export{c 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-ulFAVx1H.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=1.05,m=.9*p,h=`openchamber.designPtScale.v3`;function g(e){return!Number.isFinite(e)||e<=0?1:Math.min(d,Math.max(ee,e))}function _(e){if(!e)return m;let t=e.density,n=(e.xdpi+e.ydpi)/2;if(!(t>0)||!(n>=50)||n>800)return m;let r=g(n/t/163);return Math.min(1,r*p)}function v(){if(typeof window>`u`)return 1;try{let e=Number.parseFloat(window.localStorage.getItem(`openchamber.designPtScale.v3`)??``),t=window.Capacitor?.getPlatform?.();return t===`android`?!Number.isFinite(e)||e<=0?m:Math.min(1,g(e)):t===`ios`?f:g(e)}catch{return 1}}function y(e){if(!(typeof window>`u`))try{window.localStorage.setItem(h,String(e))}catch{}}function b(e,t=document.documentElement){let n=g(e);t.style.setProperty(`--dpt`,`${n}px`),t.style.setProperty(`--dpt-n`,String(n))}async function x(){if(typeof document>`u`)return 1;b(v());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 b(1),1;if(e.getPlatform()===`ios`)return b(f),y(f),f;if(e.getPlatform()!==`android`)return b(1),1;if(!e.isPluginAvailable(`OpenChamberPhysicalScale`))return b(m),y(m),m;try{let e=_(await t(`OpenChamberPhysicalScale`).getMetrics());return y(e),b(e),e}catch{return b(m),y(m),m}}var S={xs:0,sm:640,md:768,lg:1024,xl:1280,"2xl":1536},C={isMobile:!1,isTablet:!1,isDesktop:!0,deviceType:`desktop`,screenWidth:1024,breakpoint:`lg`,hasTouchInput:!1,hasTouchOnlyPointer:!1},w=()=>typeof window>`u`?!1:new URLSearchParams(window.location.search).get(`surface`)===`desktop`,te=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}},T=(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`)),b(e?1:v(),r)};function E(){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()||w(),{isExplicitTablet:ee}=te(l),d=s||c||l>0,f=s||c,p=e>S.md&&e<=S.lg,m=e<=S.md,h=d&&m,g=d&&!h&&(p||ee),_=!d||!g&&e>S.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`),T(u,v,d);let y=`xs`;for(let[t,n]of Object.entries(S))e>=n&&(y=t);return{isMobile:h,isTablet:g,isDesktop:_,deviceType:v,screenWidth:e,breakpoint:y,hasTouchInput:d,hasTouchOnlyPointer:f}}var D=(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,O=new Set,k=null,A,j=null,ne=()=>typeof window>`u`?C:(k||=E(),k),re=()=>{for(let e of O)e()},M=()=>{A=void 0;let e=E();k&&D(k,e)||(k=e,re())},N=()=>{typeof window>`u`||A!==void 0||(A=window.requestAnimationFrame(M))},P=(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)):()=>{}:()=>{},F=()=>{if(typeof window>`u`)return()=>{};k=E(),window.addEventListener(`resize`,N);let e=typeof window.matchMedia==`function`?window.matchMedia(`(pointer: coarse)`):null,t=typeof window.matchMedia==`function`?window.matchMedia(`(hover: none)`):null,n=P(e,N),r=P(t,N);return()=>{window.removeEventListener(`resize`,N),n(),r(),A!==void 0&&(window.cancelAnimationFrame(A),A=void 0)}},I=e=>typeof window>`u`?()=>{}:(O.add(e),j||=F(),()=>{O.delete(e),O.size===0&&j&&(j(),j=null,k=null)});function L(){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 R=()=>typeof window>`u`?!1:!!(navigator.standalone===!0||window.matchMedia?.(`(display-mode: standalone)`)?.matches||window.matchMedia?.(`(display-mode: fullscreen)`)?.matches),z=()=>{if(typeof window>`u`||n())return!1;let e=typeof navigator<`u`?navigator.maxTouchPoints??0:0;return R()&&e>0&&window.innerWidth>S.md};function B(){let e=(0,u.c)(2),[t,n]=l.useState(V),r,i;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>{if(typeof window>`u`)return;let e=()=>n(z()),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 V(){return z()}var H=()=>typeof window>`u`?`portrait`:window.matchMedia?.(`(orientation: landscape)`)?.matches?`landscape`:`portrait`;function U(){let e=(0,u.c)(2),[t,n]=l.useState(H),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(),P(e,t)},i=[],e[0]=r,e[1]=i):(r=e[0],i=e[1]),l.useEffect(r,i),t}function ie(){return l.useSyncExternalStore(I,ne,ae)}function ae(){return C}var oe=r(),se=1e3,W=.5,ce={length:0,offset:0},le=(e,t)=>Math.abs(e.length-t.length)<W&&Math.abs(e.offset-t.offset)<W,G=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,S]=l.useState(b),C;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(C={length:0,offset:0},t[1]=C):C=t[1];let[w,te]=l.useState(C),T=l.useRef(null),E=l.useRef(null),D=l.useRef(null),O=l.useRef(!1),k=l.useRef(!1),A=l.useRef(0),j;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(j={pointerX:0,pointerY:0,scrollTop:0,scrollLeft:0},t[2]=j):j=t[2];let ne=l.useRef(j),re=l.useRef(null),M;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(M=new Set,t[3]=M):M=t[3];let N=l.useRef(M),P;t[4]!==n||t[5]!==m||t[6]!==f?(P=()=>{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}}S(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}}te(e=>le(e,l)?e:l)},t[4]=n,t[5]=m,t[6]=f,t[7]=P):P=t[7];let F=P,I;t[8]===F?I=t[9]:(I=()=>{D.current===null&&(D.current=requestAnimationFrame(()=>{D.current=null,F()}))},t[8]=F,t[9]=I);let L=I,R;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(R=(e,t)=>{if(!t){N.current.clear();return}let n=new Set;n.add(e),Array.from(e.children).forEach(e=>{n.add(e)}),N.current.forEach(e=>{n.has(e)||t.unobserve(e)}),n.forEach(e=>{N.current.has(e)||t.observe(e)}),N.current=n},t[10]=R):R=t[10];let z=R,B;t[11]===p?B=t[12]:(B=()=>{T.current&&clearTimeout(T.current),!k.current&&(T.current=setTimeout(()=>y(!1),p))},t[11]=p,t[12]=B);let V=B,H;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(H=()=>{A.current=Date.now()},t[13]=H):H=t[13];let U=H,ie;t[14]!==V||t[15]!==g||t[16]!==F||t[17]!==_?(ie=()=>{E.current&&cancelAnimationFrame(E.current),E.current=requestAnimationFrame(()=>{if(F(),g&&!O.current){y(!1);return}if(_&&!O.current&&!(Date.now()-A.current<=se)){y(!1);return}y(!0),V()})},t[14]=V,t[15]=g,t[16]=F,t[17]=_,t[18]=ie):ie=t[18];let ae=ie,W,G;t[19]!==n||t[20]!==ae||t[21]!==h||t[22]!==L||t[23]!==F||t[24]!==_?(W=()=>{let e=n.current;if(!e)return;F(),y(!1);let t=()=>ae(),r=e=>{(e.key===`ArrowUp`||e.key===`ArrowDown`||e.key===`PageUp`||e.key===`PageDown`||e.key===`Home`||e.key===`End`||e.key===` `)&&U()};e.addEventListener(`scroll`,t,{passive:!0}),_&&(e.addEventListener(`wheel`,U,{passive:!0}),e.addEventListener(`touchstart`,U,{passive:!0}),e.addEventListener(`touchmove`,U,{passive:!0}),e.addEventListener(`keydown`,r));let i=typeof ResizeObserver<`u`?new ResizeObserver(()=>{L()}):null;z(e,i);let a=h&&typeof MutationObserver<`u`?new MutationObserver(()=>{z(e,i),L()}):null;a?.observe(e,{childList:!0});let o=()=>L(),s=()=>L();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`,U),e.removeEventListener(`touchstart`,U),e.removeEventListener(`touchmove`,U),e.removeEventListener(`keydown`,r)),i?.disconnect(),a?.disconnect(),N.current.clear(),T.current&&clearTimeout(T.current),E.current&&cancelAnimationFrame(E.current),D.current&&cancelAnimationFrame(D.current)}},G=[n,ae,U,h,L,z,F,_],t[19]=n,t[20]=ae,t[21]=h,t[22]=L,t[23]=F,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&&(O.current||(y(!1),T.current&&=(clearTimeout(T.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&&(O.current=!0,ne.current={pointerX:e.clientX,pointerY:e.clientY,scrollTop:r.scrollTop,scrollLeft:r.scrollLeft},re.current=t,U(),y(!0),T.current&&clearTimeout(T.current),e.currentTarget.setPointerCapture(e.pointerId))},t[30]=n,t[31]=fe);let K=fe,pe;t[32]!==n||t[33]!==w.length||t[34]!==x.length?(pe=e=>{if(!O.current)return;let t=n.current;if(!t)return;let r=re.current;if(r===`vertical`){let{pointerY:n,scrollTop:r}=ne.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}=ne.current,i=e.clientX-n,a=t.clientWidth,o=Math.max(a-w.length,1),s=Math.max(t.scrollWidth-t.clientWidth,1);t.scrollLeft=r+i/o*s}},t[32]=n,t[33]=w.length,t[34]=x.length,t[35]=pe):pe=t[35];let q=pe,me;t[36]===V?me=t[37]:(me=e=>{O.current&&(O.current=!1,e.currentTarget.releasePointerCapture(e.pointerId),V())},t[36]=V,t[37]=me);let J=me,he;t[38]===Symbol.for(`react.memo_cache_sentinel`)?(he=()=>{k.current=!0,T.current&&=(clearTimeout(T.current),null)},t[38]=he):he=t[38];let ge=he,_e;t[39]===V?_e=t[40]:(_e=()=>{k.current=!1,V()},t[39]=V,t[40]=_e);let Y=_e,ve=x.length>0,ye=w.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]!==w.length||t[58]!==w.offset||t[59]!==ye?($=ye&&(0,oe.jsx)(`div`,{className:`overlay-scrollbar__thumb overlay-scrollbar__thumb--horizontal`,"data-overlay-scrollbar-thumb":`horizontal`,style:{width:`${w.length}px`,left:`${8+w.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]=w.length,t[58]=w.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};G.displayName=`OverlayScrollbar`;var ue=G;export{U as a,ie as i,E as n,B as o,L as r,x as s,ue as t};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MarkdownRendererImpl-BWsesd63.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-ulFAVx1H.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-C7zcAKyC.js","assets/store-upwbPNfx.js","assets/useMobileNavigationStore-CBHZdTh6.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-D71yjOxf.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,t as i}from"./platform-ulFAVx1H.js";import{a,n as o,o as s}from"./vendor-aparajita-capacitor-secure-storage-CjQdwfjS.js";import{n as c}from"./vendor-react-DLPElpoQ.js";import{n as l}from"./vendor-reactuses-core-DDoDDyM9.js";import{r as u}from"./useMobileNavigationStore-CBHZdTh6.js";import{c as d,l as f}from"./dialog-D1Ng5yQe.js";import{t as p}from"./utils-CJdWZupK.js";import{a as m,c as h,i as g}from"./markdown-worker-9Sn2jsDp.js";import{r as _}from"./vendor-pierre-diffs-BenIz2TM.js";var v=e(n(),1),y=c(),ee=`oc-native-ios-composer`,b=`--oc-native-composer-height`,x=`--oc-native-composer-accessory`,te=33554432,S=`OpenChamberComposer`,C=`#22c55e`,w=32,ne=a(S),re=e=>e.isCapacitor&&e.platform===`ios`&&e.pluginAvailable&&e.isMobile;function ie(e){return typeof window>`u`?!1:re({isCapacitor:r(),platform:i(),pluginAvailable:o.isPluginAvailable(S),isMobile:e})}var ae=e=>e.classList.contains(`dark`)?`dark`:`light`,oe=e=>{let t=e?.height;return typeof t!=`number`||!Number.isFinite(t)||t<0?0:t},se=(e,t)=>{if(!(t>0)){e.style.removeProperty(b);return}e.style.setProperty(b,`${Math.round(t)}px`)},ce=(e,t)=>{if(!(t>0)){e.style.removeProperty(x);return}e.style.setProperty(x,`${Math.round(t)}px`)},T=(e,t)=>{e.classList.toggle(ee,t),t||(e.style.removeProperty(b),e.style.removeProperty(x))},le=e=>d(e).flat().map(e=>+!!e),ue=e=>{if(typeof document>`u`||typeof getComputedStyle>`u`)return C;let t=getComputedStyle(document.documentElement).getPropertyValue(e).trim(),n=document.createElement(`span`);n.style.color=t||`var(${e})`,document.documentElement.appendChild(n);let r=getComputedStyle(n).color;n.remove();let i=/rgba?\(\s*([\d.]+)(?:\s*,\s*|\s+)([\d.]+)(?:\s*,\s*|\s+)([\d.]+)/.exec(r);if(!i)return C;let a=e=>Math.max(0,Math.min(255,Math.round(Number(e)))).toString(16).padStart(2,`0`);return`#${a(i[1])}${a(i[2])}${a(i[3])}`},de=e=>ue(f(e).var),fe=(e,t)=>e.text===t.text&&e.placeholder===t.placeholder&&e.modelLabel===t.modelLabel&&e.modelVariantLabel===t.modelVariantLabel&&e.modelIcon===t.modelIcon&&e.canSend===t.canSend&&e.canAbort===t.canAbort&&e.attachmentCount===t.attachmentCount&&pe(e.attachmentPreviews,t.attachmentPreviews)&&me(e.citationRanges,t.citationRanges)&&e.appearance===t.appearance&&e.attachAria===t.attachAria&&e.attachTitle===t.attachTitle&&e.attachPhotosLabel===t.attachPhotosLabel&&e.attachFilesLabel===t.attachFilesLabel&&e.attachCancelLabel===t.attachCancelLabel&&e.sendAria===t.sendAria&&e.queueAria===t.queueAria&&e.stopAria===t.stopAria&&e.modelAria===t.modelAria&&e.agentAria===t.agentAria&&e.agentLabel===t.agentLabel&&e.agentColor===t.agentColor&&e.agentIdenticon.join(``)===t.agentIdenticon.join(``)&&e.suppressed===t.suppressed&&e.showScrollToBottom===t.showScrollToBottom&&e.scrollAria===t.scrollAria,pe=(e,t)=>e.length===t.length&&e.every((e,n)=>{let r=t[n];return!!(r&&e.id===r.id&&e.filename===r.filename&&e.mime===r.mime&&e.thumbnailBase64===r.thumbnailBase64&&e.removeAria===r.removeAria)}),me=(e,t)=>e.length===t.length&&e.every((e,n)=>e.start===t[n]?.start&&e.end===t[n]?.end),he=e=>e.map(e=>`${e.id}:${e.filename}:${e.mimeType}:${e.dataUrl?.length??0}`).join(`|`),ge=e=>{let t=e?.id;return typeof t==`string`&&t.trim()?t:``},_e=e=>e.echoingNative||e.nextText===e.nativeOwnedText?{omitText:!0,forceText:!1}:{omitText:!1,forceText:!0},ve=e=>{let t=Array.isArray(e?.skipped)?e.skipped:[],n=[];for(let e of t){if(!e||typeof e!=`object`)continue;let t=e.name;typeof t==`string`&&t.trim()&&n.push(t)}return n},ye=e=>{try{let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}catch{return null}},be=(e,t=te)=>{let n=Array.isArray(e?.files)?e.files:[],r=[];for(let e of n){if(!e||typeof e!=`object`)continue;let n=e;if(typeof n.dataBase64!=`string`||n.dataBase64.length===0)continue;let i=ye(n.dataBase64);if(!i||i.byteLength===0||i.byteLength>t)continue;let a=typeof n.name==`string`&&n.name.trim()?n.name:`file`,o=typeof n.mime==`string`&&n.mime.trim()?n.mime:`application/octet-stream`;r.push(new File([new Uint8Array(i)],a,{type:o}))}return r},E=80,xe=e=>typeof document>`u`||!e||!e.startsWith(`data:image/`)?Promise.resolve(null):new Promise(t=>{let n=new Image;n.decoding=`async`,n.onload=()=>{try{let e=document.createElement(`canvas`);e.width=E,e.height=E;let r=e.getContext(`2d`);if(!r){t(null);return}r.clearRect(0,0,E,E),r.drawImage(n,0,0,E,E);let i=e.toDataURL(`image/jpeg`,.72),a=i.indexOf(`,`);t(a>=0?i.slice(a+1):null)}catch{t(null)}},n.onerror=()=>t(null),n.src=e}),Se=e=>typeof document>`u`||!e?Promise.resolve(null):new Promise(t=>{let n=new Image;n.decoding=`async`,n.onload=()=>{try{let e=document.createElement(`canvas`);e.width=w,e.height=w;let r=e.getContext(`2d`);if(!r){t(null);return}r.clearRect(0,0,w,w),r.drawImage(n,0,0,w,w);let i=e.toDataURL(`image/png`),a=i.indexOf(`,`);t(a>=0?i.slice(a+1):null)}catch{t(null)}},n.onerror=()=>t(null),n.src=e}),D=()=>ne,O=((e=D)=>{let t=0,n=0,r=null,i=[],a=null,o=``,s=null,c=!1,l=()=>{r!==null&&(clearTimeout(r),r=null)},u=(e,...t)=>{let n=a;n&&n[e](...t)},d=async()=>{let r=n,a=e(),s=await Promise.all([a.addListener(`textChanged`,e=>{let t=typeof e.text==`string`?e.text:``;o=t,u(`onText`,t,e.composing===!0)}),a.addListener(`send`,e=>{let t=typeof e.text==`string`?e.text:o;o=t,u(`onSend`,t)}),a.addListener(`abort`,()=>{u(`onAbort`)}),a.addListener(`attach`,()=>{u(`onAttach`)}),a.addListener(`filesPicked`,t=>{u(`onFiles`,be(t),ve(t)),e().focus()}),a.addListener(`removeAttachment`,e=>{let t=ge(e);t&&u(`onRemoveAttachment`,t)}),a.addListener(`openModel`,()=>{u(`onOpenModel`)}),a.addListener(`cycleAgent`,()=>{u(`onCycleAgent`)}),a.addListener(`openAgent`,()=>{u(`onOpenAgent`)}),a.addListener(`heightChanged`,e=>{u(`onHeight`,oe(e))}),a.addListener(`scrollToBottom`,()=>{u(`onScrollToBottom`)})]);if(n!==r||t===0){for(let e of s)e.remove();return}i=s},f=r=>{if(!(t>0)){n+=1,a=null,c=!1,s=null;for(let e of i)e.remove();i=[],T(r,!1),e().dismiss()}};return{bind(e){a=e},rememberText(e){o=e},rememberState(e){s=e,o=e.text},conceal(){c||t===0||(c=!0,e().hide())},reveal(){!c||t===0||!s||(c=!1,e().present(s))},async retain(n,r){l(),t+=1,c=!1,s=r,o=r.text,T(n,!0),i.length===0&&await d(),await e().present(r)},release(e){t=Math.max(0,t-1),!(t>0)&&(l(),r=setTimeout(()=>{r=null,f(e)},0))},snapshot(){return{retainCount:t,listenerCount:i.length,hidePending:r!==null,concealed:c}}}})(),Ce=()=>a(`OpenChamberNavigation`),k=e=>e?.kind===`chat`||e?.kind===`draft`,A=e=>e?e.kind===`draft`||e.kind===`chat`&&e.routes.length<=1:!1,we=(e,t)=>k(e)&&!k(t),Te=(e=O)=>{A(u.getState().secondary)&&e.conceal()},Ee=(e=O)=>{let t=u.subscribe((t,n)=>{we(n.secondary,t.secondary)&&e.conceal()}),n=[],r=!1;return o.getPlatform()===`ios`&&(async()=>{let t=Ce(),i=await t.addListener(`backStarted`,()=>{A(u.getState().secondary)&&e.conceal()}),a=await t.addListener(`backCancelled`,()=>{e.reveal()});if(r){i.remove(),a.remove();return}n=[i,a]})(),()=>{r=!0,t();for(let e of n)e.remove();n=[]}},j=`openchamber:chunk-import-reload`,De=250,Oe=3e4,ke=[/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 M(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 N(e){let t=M(e);return ke.some(e=>e.test(t))}function Ae(e){return`1.19.0-beta.21:${M(e).slice(0,500)}`}function je(e){if(typeof window>`u`)return;let t=Date.now(),n=Ae(e),r=null;try{let e=window.sessionStorage.getItem(j);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<Oe)){try{window.sessionStorage.setItem(j,JSON.stringify({signature:n,timestamp:t}))}catch{return}console.error(`[refresh-debug] chunk-import-reload`,{error:M(e).slice(0,1e3)}),window.setTimeout(()=>{window.location.reload()},0)}}async function Me(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,!N(e)||t>=n)break;await new Promise(e=>setTimeout(e,De*(t+1)))}throw N(r)&&je(r),r}var P=e=>(0,v.lazy)(()=>Me(e)),F=`__openchamberMobileBackRoute`,Ne=()=>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)}},I=e=>{let t=e?.[F];return typeof t==`number`&&Number.isFinite(t)?t:null},L=new class{routes=[];listeners=new Set;nextToken=1;history;removeHistoryListener=null;programmaticHistoryBackToken=null;pendingHistoryRemovals=new Map;animatedBackDriver=null;presentationCancelDriver=null;constructor(e=Ne()){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&&I(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()??{},[F]: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&&I(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||I(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&&I(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&&I(e)!==t.token&&t.onBack()===!1&&this.history&&this.history.pushState({...this.history.currentState()??{},[F]:t.token})}))}disposeHistoryListener(){this.removeHistoryListener?.(),this.removeHistoryListener=null,this.programmaticHistoryBackToken=null,this.pendingHistoryRemovals.clear()}notify(){this.listeners.forEach(e=>e())}},Pe=e=>{let t=(0,y.c)(8),{id:n,active:r,layer:i,onBack:a,surfaceRef:o,underlayRef:s}=e,c=i===void 0?`root`:i,u=l(a),d,f;t[0]!==r||t[1]!==u||t[2]!==n||t[3]!==c||t[4]!==o||t[5]!==s?(d=()=>{if(r)return L.register({id:n,layer:c,onBack:u,getSurface:()=>o.current,getUnderlay:()=>s?.current??null})},f=[r,u,n,c,o,s],t[0]=r,t[1]=u,t[2]=n,t[3]=c,t[4]=o,t[5]=s,t[6]=d,t[7]=f):(d=t[6],f=t[7]),v.useEffect(d,f)},R=a(`OpenChamberNavigation`),z=e=>Math.min(1,Math.max(0,Number.isFinite(e)?e:0)),Fe=(e,t)=>!e||!t?!1:e.onBack()!==!1,B=e=>{let t=z(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)))},V=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??``)},H=(e,t)=>{let n=z(t),{surface:r}=e;r.style.transform=`translate3d(${n*100}%, 0, 0)`},Ie=e=>!e.surfaceConnected||e.topRouteToken!==e.routeToken||e.routeSurface!==e.outgoingSurface,Le=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)`},Re=async(e,t,n=typeof window<`u`&&window.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches,r=B({progress:Number.parseFloat(e.style.transform.match(/translate3d\(([-\d.]+)%/)?.[1]??`0`)/100,commit:t}))=>Le(e,t?100:0,r,n),ze=class{pending=0;enqueue(){this.pending+=1}take(){return this.pending!==0&&(--this.pending,!0)}clear(){this.pending=0}},Be=e=>{let t=(0,y.c)(4),{enabled:n,rootRoutesBlocked:i}=e,a,s;t[0]!==n||t[1]!==i?(a=()=>{if(!n||!r()||o.getPlatform()===`web`)return;let e=!1,t=null,a=null,s=0,c=0,l=0,u=new ze,d=[],f=e=>!!e&&(!i||e?.layer===`overlay`),p=()=>{let e=f(L.getTopRoute());R.setEnabled({enabled:e}).catch(Ve)},m=()=>{if(L.cancelPresentation(),a)return;let e=L.getTopRoute();if(!f(e))return;let n=e.getSurface();if(!n)return;n.getAnimations().forEach(He),a=null;let r=e.layer===`root`?e.getUnderlay():null,i=n.style.transition,o=n.style.animation,s=r?.style.transition??null,c=r?.style.animation??null;r?.getAnimations().forEach(Ue),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:o,underlayTransition:s,underlayAnimation:c},H(t,0)},h=e=>{c=z(e),!s&&(s=window.requestAnimationFrame(()=>{s=0,t&&H(t,c)}))},g=We,_=(n,r,i)=>{if(n&&Te(),a)return n&&f(L.getTopRoute())?(u.enqueue(),!0):!1;s&&=(window.cancelAnimationFrame(s),0),t||m(),t&&r!==void 0&&H(t,r);let o=t,d=l;if(t=null,!o){if(!n)return!1;let e=L.getTopRoute();return Fe(e,f(e))}a=o;let p=window.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches??!1,h=B({progress:z(r??c),commit:n,velocityX:i,viewportWidth:window.innerWidth});return Re(o.surface,n,p,h).then(async()=>{d===l&&(!e&&n&&(o.route.onBack(),await g(o)),d===l&&(V(o),a===o&&(a=null),!e&&u.take()&&_(!0,0,0)))}),!0},v=L.setAnimatedBackDriver(e=>e!==L.getTopRoute()||!f(e)?!1:_(!0,0,0)),y=L.subscribe(p);return(async()=>{let t=await R.addListener(`backStarted`,m),n=await R.addListener(`backProgressed`,e=>h(e.progress??0)),r=await R.addListener(`backCancelled`,e=>_(!1,e.progress,e.velocityX)),i=await R.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(Ge),p(),()=>{e=!0,l+=1,u.clear(),y(),v(),s&&window.cancelAnimationFrame(s),t&&V(t),a&&(a.surface.getAnimations().forEach(Ke),a.underlay?.getAnimations().forEach(qe),V(a)),t=null,a=null,R.setEnabled({enabled:!1}).catch(Je),d.forEach(Ye)}},s=[n,i],t[0]=n,t[1]=i,t[2]=a,t[3]=s):(a=t[2],s=t[3]),v.useEffect(a,s)};function Ve(){}function He(e){return e.cancel()}function Ue(e){return e.cancel()}function We(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=L.getTopRoute();return Ie({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=L.subscribe(()=>{o()&&a()});s()})}function Ge(){}function Ke(e){return e.cancel()}function qe(e){return e.cancel()}function Je(){}function Ye(e){e.remove()}var U=null,W=()=>(U??=s(()=>import(`./MarkdownRendererImpl-BWsesd63.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 U=null,e}),U),Xe=()=>{W().catch(()=>void 0)},G=v.createContext(!0),K=()=>v.useContext(G),q=t(),Ze=P(()=>W().then(e=>({default:e.MarkdownRenderer}))),Qe=P(()=>W().then(e=>({default:e.SimpleMarkdownRenderer}))),$e=e=>e===`tool`?`markdown-content markdown-tool`:e===`reasoning`?`markdown-content markdown-reasoning`:`markdown-content leading-relaxed`,J=e=>{let t=(0,y.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?m(g(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=p(`relative break-words w-full min-w-0`,$e(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,q.jsx)(h,{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,q.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},et=e=>{let t=(0,y.c)(4);if(!K()&&e.isStreaming!==!0){let n;return t[0]===e?n=t[1]:(n=(0,q.jsx)(J,{...e,animated:!1,reserveMeasuredHeight:!0}),t[0]=e,t[1]=n),n}let n;return t[2]===e?n=t[3]:(n=(0,q.jsx)(v.Suspense,{fallback:(0,q.jsx)(J,{...e,reserveMeasuredHeight:!0}),children:(0,q.jsx)(Ze,{...e})}),t[2]=e,t[3]=n),n},tt=e=>{let t=(0,y.c)(4);if(!K()){let n;return t[0]===e?n=t[1]:(n=(0,q.jsx)(J,{...e,animated:!1}),t[0]=e,t[1]=n),n}let n;return t[2]===e?n=t[3]:(n=(0,q.jsx)(v.Suspense,{fallback:(0,q.jsx)(J,{...e}),children:(0,q.jsx)(Qe,{...e})}),t[2]=e,t[3]=n),n},nt=e=>/^#[0-9a-fA-F]{6}$/.test(e),rt=e=>/^#[0-9a-fA-F]{8}$/.test(e),it=(e,t)=>/^[0-9a-fA-F]{2}$/.test(t)?nt(e)?`${e}${t}`:rt(e)?`${e.slice(0,7)}${t}`:e:e,Y=(e,t)=>typeof e==`string`&&e.trim().length>0?e:t,at=e=>{let t=e.colors.syntax.base,n=e.colors.syntax.tokens??{},r=(e,t)=>Y(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}}]},ot=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=Y(a.diffAddedBackground,r.successBackground),s=Y(a.diffRemovedBackground,r.errorBackground);return{"editor.background":t.background,"editor.foreground":t.foreground,"editor.hoverHighlightBackground":Y(n.hover,t.subtle),"editor.lineHighlightBackground":t.muted,"editor.selectionBackground":n.selection,"editor.selectionHighlightBackground":n.selection,"editor.findMatchBackground":i.type,"editor.findMatchHighlightBackground":it(i.type,`cc`),"editor.findRangeHighlightBackground":t.muted,"editor.inactiveSelectionBackground":t.elevated,"editor.lineHighlightBorder":t.elevated,"editor.rangeHighlightBackground":Y(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":Y(a.lineNumberActive,t.foreground),"editorLineNumber.foreground":Y(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":Y(a.diffAdded,r.success),"merge.incomingHeaderBackground":r.info,"merge.incomingContentBackground":Y(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":Y(a.diffRemoved,r.error),"terminal.ansiGreen":Y(a.diffAdded,r.success),"terminal.ansiYellow":r.warning,"terminal.ansiBlue":Y(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":Y(e.colors.primary.foreground,t.background),"badge.foreground":Y(e.colors.primary.foreground,t.background),"activityBarBadge.foreground":Y(e.colors.primary.foreground,t.background)}};function st(e){return{name:e.metadata.name,type:e.metadata.variant,colors:ot(e),tokenColors:at(e)}}var ct=e=>/^#[0-9a-fA-F]{8}$/.test(e),X=e=>ct(e)?e.slice(0,7):e;function lt(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,ut=(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 lt({...e,name:t,fg:a,bg:i,settings:o},t)},dt=e=>st(e),$=e=>{let t=Z.get(e.metadata.id);if(t)return t;let n=ut(dt(e),e.metadata.id);return Z.set(e.metadata.id,n),n},ft=e=>{let t=e.metadata.id;if(Q.has(t))return;let n=$(e);_(t,async()=>n),Q.add(t)};export{Se as C,xe as S,D as _,G as a,ae as b,Pe as c,Ee as d,O as f,ie as g,he as h,tt as i,Be as l,se as m,$ as n,Xe as o,ce as p,et as r,L as s,ft as t,P as u,fe as v,_e as w,le as x,de as y};
|
|
@@ -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-C7zcAKyC.js";import{t as p}from"./utils-CJdWZupK.js";import{n as m}from"./Icon-BAf2hhrw.js";var h=[{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 g(e){if(!e||e===`build`)return h[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 h[1+Math.abs(t)%(h.length-1)]}var _=5,v=Math.ceil(_/2);function y(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 b(e){let t=Array.from({length:_},()=>Array.from({length:_},()=>!1));if(!e)return t;let n=y(e);for(let e=0;e<_;e++)for(let r=0;r<v;r++){let i=(n&1)==1;n>>>=1,t[e][r]=i,t[e][4-r]=i}return t}var x=d(),S=e(u(),1),C=c(),w=0;function T(e,t){return e&&S.isValidElement(t)?{render:t}:{children:t}}function E(e){let t=(0,x.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,C.jsx)(n,{...r}),t[2]=r,t[3]=i),i}function D(e){let t=(0,x.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=T(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,C.jsx)(r,{"data-slot":`dialog-trigger`,...a,...s}),t[7]=a,t[8]=s,t[9]=c):c=t[9],c}function O(e){let t=(0,x.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,C.jsx)(o,{...n}),t[2]=n,t[3]=r),r}var k=S.forwardRef((e,n)=>{let r=(0,x.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],S.useEffect(I,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,C.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});k.displayName=`DialogOverlay`;function A(e){let t=(0,x.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(),h;t[7]===s?h=t[8]:(h=p(`rounded-none`,s),t[7]=s,t[8]=h);let g;t[9]===h?g=t[10]:(g=(0,C.jsx)(k,{className:h}),t[9]=h,t[10]=g);let _=o??`items-center p-4`,v;t[11]===_?v=t[12]:(v=p(`fixed inset-0 z-50 flex justify-center pointer-events-none`,_),t[11]=_,t[12]=v);let y;t[13]===r?y=t[14]:(y=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]=y);let b;t[15]!==u||t[16]!==d?(b=u&&(0,C.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,C.jsx)(m,{name:`close`}),(0,C.jsx)(`span`,{className:`sr-only`,children:d(`dialog.common.actions.close`)})]}),t[15]=u,t[16]=d,t[17]=b):b=t[17];let S;t[18]!==n||t[19]!==c||t[20]!==y||t[21]!==b?(S=(0,C.jsxs)(a,{"data-slot":`dialog-content`,"data-state-slot":`dialog`,className:y,...c,children:[n,b]}),t[18]=n,t[19]=c,t[20]=y,t[21]=b,t[22]=S):S=t[22];let w;t[23]!==v||t[24]!==S?(w=(0,C.jsx)(`div`,{className:v,children:S}),t[23]=v,t[24]=S,t[25]=w):w=t[25];let T;return t[26]!==g||t[27]!==w?(T=(0,C.jsxs)(O,{children:[g,w]}),t[26]=g,t[27]=w,t[28]=T):T=t[28],T}function j(e){let t=(0,x.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,C.jsx)(`div`,{"data-slot":`dialog-header`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function M(e){let t=(0,x.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,C.jsx)(`div`,{"data-slot":`dialog-footer`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function N(e){let t=(0,x.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,C.jsx)(l,{"data-slot":`dialog-title`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function P(e){let t=(0,x.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,C.jsx)(s,{"data-slot":`dialog-description`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function F(){w=Math.max(0,w-1),w===0&&document.documentElement.classList.remove(`oc-dialog-open`)}function I(){return w+=1,document.documentElement.classList.add(`oc-dialog-open`),F}export{j as a,b as c,M as i,g as l,A as n,N as o,P as r,D as s,E 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-ulFAVx1H.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-C7zcAKyC.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-CBHZdTh6.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-DGNLIAdE.js";import{C as re,M as ie,O as k,P as A,S as j,_ as M,a as ae,b as oe,g as se,h as ce,i as N,j as le,k as ue,n as P,o as F,p as I,v as de,x as fe,y as L}from"./projectMeta-CGWgdtzY.js";import{t as R}from"./input-Ca2tUhgN.js";import{i as z,n as pe,t as B}from"./tooltip-GC3dg3gO.js";import{o as me}from"./OverlayScrollbar-BR0ifid5.js";import{n as V}from"./useRuntimeAPIs-DSLXJybW.js";import{E as he,T as ge,a as H,b as U,c as _e,g as W,k as ve,l as G,m as K,o as q,p as J,r as ye,x as Y}from"./insertionBoundaries-DXyrsxRu.js";import{n as be,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 I(l):void 0,m=u?await G(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 _e(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)(ue,{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}=k(),ne=t(Ue),ie=t(We),[A,M]=X.useState(!1),[ae,oe]=X.useState(``),[N,le]=X.useState(null),ue=X.useRef(null),P=X.useRef(null),F=u===1,I=u===void 0||r.length<u||F,L;if(n[0]!==r){L=new Map;for(let e of r){let t=`${e.providerID}:${e.modelID}`;L.set(t,(L.get(t)||0)+1)}n[0]=r,n[1]=L}else L=n[1];let R=L,z;n[2]===r?z=n[3]:(z=e=>r.filter(t=>t.providerID===e.providerID&&t.modelID===e.modelID).findIndex(t=>t.instanceId===e.instanceId)+1,n[2]=r,n[3]=z);let pe=z,B,me;n[4]!==y||n[5]!==A?(B=()=>{if(!A||!P.current)return;let e=P.current.getBoundingClientRect();if(y===`bottom`){let t=(window.visualViewport?.height??document.documentElement.clientHeight??window.innerHeight)-e.bottom-16-112;le(Math.max(160,Math.min(320,t)));return}let t=P.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;le(Math.max(150,Math.min(300,r)))},me=[y,A],n[4]=y,n[5]=A,n[6]=B,n[7]=me):(B=n[6],me=n[7]),X.useEffect(B,me);let V,he;n[8]!==I||n[9]!==A?(V=()=>{!I&&A&&(M(!1),oe(``))},he=[I,A],n[8]=I,n[9]=A,n[10]=V,n[11]=he):(V=n[10],he=n[11]),X.useEffect(V,he);let ge,H;n[12]===A?(ge=n[13],H=n[14]):(ge=()=>{if(!A)return;let e=e=>{ue.current&&!ue.current.contains(e.target)&&(M(!1),oe(``))};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},H=[A],n[12]=A,n[13]=ge,n[14]=H),X.useEffect(ge,H);let U;n[15]!==F||n[16]!==i||n[17]!==o||n[18]!==r.length?(U=e=>{let t={providerID:e.providerID,modelID:e.modelID,displayName:_(e.model,e.modelID)||e.modelID,instanceId:Ie()};F&&r.length>0&&o?o(0,t):i(t),F&&(M(!1),oe(``))},n[15]=F,n[16]=i,n[17]=o,n[18]=r.length,n[19]=U):U=n[19];let _e=U,W;n[20]===b?W=n[21]:(W=b(`multirun.modelMultiSelect.search.placeholder`),n[20]=b,n[21]=W);let ve;n[22]===b?ve=n[23]:(ve=b(`multirun.modelMultiSelect.search.noResults`),n[22]=b,n[23]=ve);let G;n[24]===b?G=n[25]:(G=b(`multirun.modelMultiSelect.sections.favorites`),n[24]=b,n[25]=G);let K;n[26]===b?K=n[27]:(K=b(`multirun.modelMultiSelect.sections.recent`),n[26]=b,n[27]=K);let q;n[28]===b?q=n[29]:(q=b(`multirun.modelMultiSelect.keyboard.hint`),n[28]=b,n[29]=q);let J;n[30]===b?J=n[31]:(J=b(`settings.agents.modelSelector.actions.favorite`),n[30]=b,n[31]=J);let ye;n[32]===b?ye=n[33]:(ye=b(`settings.agents.modelSelector.actions.unfavorite`),n[32]=b,n[33]=ye);let Y;n[34]===b?Y=n[35]:(Y=b(`chat.modelControls.provider`),n[34]=b,n[35]=Y);let be;n[36]===b?be=n[37]:(be=b(`chat.modelControls.capabilities`),n[36]=b,n[37]=be);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]!==W||n[55]!==ve||n[56]!==G||n[57]!==K||n[58]!==q||n[59]!==J||n[60]!==ye||n[61]!==Y||n[62]!==be||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:W,noResults:ve,favorites:G,recent:K,keyboardHint:q,favorite:J,unfavorite:ye,provider:Y,capabilities:be,capabilityToolCalling:xe,capabilityReasoning:Se,modalityImage:Z,modalityVideo:Q,modalityAudio:we,costPerMillion:Te,costInput:Ee,costOutput:De},n[54]=W,n[55]=ve,n[56]=G,n[57]=K,n[58]=q,n[59]=J,n[60]=ye,n[61]=Y,n[62]=be,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=!I,Ne;n[76]===A?Ne=n[77]:(Ne=()=>{M(!A)},n[76]=A,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:P,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]!==N||n[90]!==I||n[91]!==m||n[92]!==y||n[93]!==E||n[94]!==S||n[95]!==_e||n[96]!==ne||n[97]!==T||n[98]!==A||n[99]!==ke||n[100]!==R||n[101]!==ie||n[102]!==x||n[103]!==D||n[104]!==ae||n[105]!==C?(qe=A?(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:ae,onSearchQueryChange:oe,onSelect:_e,labels:ke,selectionCount:e=>R.get(`${e.providerID}:${e.modelID}`)||0,disabled:!I,maxHeightClassName:`flex-1`,maxHeightStyle:{maxHeight:N?`${N}px`:`300px`},stickyHeaders:!0,tooltipsEnabled:A,isFavorite:e=>T(e.providerID,e.modelID),onToggleFavorite:e=>C(e.providerID,e.modelID),onEscape:()=>{M(!1),oe(``)}})}):null,n[89]=N,n[90]=I,n[91]=m,n[92]=y,n[93]=E,n[94]=S,n[95]=_e,n[96]=ne,n[97]=T,n[98]=A,n[99]=ke,n[100]=R,n[101]=ie,n[102]=x,n[103]=D,n[104]=ae,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:ue,children:[Ke,qe]}),n[107]=Ae,n[108]=Ke,n[109]=qe,n[110]=Je):Je=n[110];let Ye;n[111]!==pe||n[112]!==R||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=R.get(n)||1,i=pe(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)(ce,{value:u,onValueChange:n=>{if(!o)return;let r=n===`__default__`?void 0:n;o(t,{...e,variant:r})},children:[(0,$.jsxs)(fe,{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)(j,{placeholder:b(`multirun.modelMultiSelect.variant.placeholder`),children:e=>e===`__default__`?b(`multirun.modelMultiSelect.variant.default`):e})]}),(0,$.jsxs)(se,{fitContent:!0,children:[(0,$.jsx)(de,{value:`__default__`,className:`pr-2 [&>span:first-child]:hidden`,children:b(`multirun.modelMultiSelect.variant.default`)}),c.map(Ge)]})]})]},e.instanceId)})}),n[111]=pe,n[112]=R,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)(de,{value:e,className:`pr-2 [&>span:first-child]:hidden`,children:e},e)}function Ke(e){let t=(0,Ce.c)(30),{git:n}=V(),r=J(e),i=Y(e),a=W(e),o=K(e),s=U(Ze),c=U(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 I(e).catch(()=>null):null;if(a)return;let i=localStorage.getItem(H),{sourceBranch:o,shouldClearSavedSourceBranch:s}=q({branches:d,savedSourceBranch:i,rootBranch:t});if(s&&localStorage.removeItem(H),a||r&&d.includes(r))return;o&&n(o)}catch{}})(),()=>{a=!0}},[d,e,i,l,n,t]),(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(ce,{value:t,onValueChange:n,disabled:i||!u||l,children:[(0,$.jsx)(fe,{id:a,size:`lg`,className:r??`w-fit typography-meta text-foreground`,children:(0,$.jsx)(j,{placeholder:o(l?`multiRun.branchSelector.status.loadingBranches`:`multiRun.branchSelector.placeholder.selectSourceBranch`)})}),(0,$.jsx)(se,{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)(M,{children:[(0,$.jsx)(L,{className:`font-semibold text-foreground`,children:o(`multiRun.branchSelector.groups.localBranches`)}),s.map(e=>(0,$.jsx)(de,{value:e,className:`whitespace-normal break-all`,children:e},e))]}),s.length>0&&c.length>0&&(0,$.jsx)(oe,{}),c.length>0&&(0,$.jsxs)(M,{children:[(0,$.jsx)(L,{className:`font-semibold text-foreground`,children:o(`multiRun.branchSelector.groups.remoteBranches`)}),c.map(e=>(0,$.jsx)(de,{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)(j,{placeholder:C}),t[19]=C,t[20]=T);let E;t[21]!==o||t[22]!==S||t[23]!==T?(E=(0,$.jsx)(fe,{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)(M,{children:g.map(it)}),t[25]=g,t[26]=D);let O;t[27]!==s||t[28]!==D?(O=(0,$.jsx)(se,{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)(ce,{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)(de,{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)(z,{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)(B,{children:[r,(0,$.jsx)(pe,{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?N[e.icon]:null,r=e.color?P[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)(ae,{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,k]=X.useState(!0),M=X.useRef(null),ae=s(e=>e.currentDirectory??null),oe=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},[]),N=h(e=>e.activeProjectId),ue=h(e=>e.setActiveProjectIdOnly),P=h(e=>e.projects),[F,I]=X.useState(()=>N??null);X.useEffect(()=>{if(N){I(N);return}!F&&P.length>0&&I(P[0].id)},[N,P,F]);let L=X.useMemo(()=>F?P.find(e=>e.id===F)??null:null,[P,F]),V=L?.path??ae,he=u(e=>{I(e),e!==N&&ue(e)}),ge=X.useMemo(()=>{if(L?.path)return{id:L.id,path:L.path};let e=ae??oe;return e?{id:`path:${e}`,path:e}:null},[L,ae,oe]),[H]=X.useState(()=>typeof window<`u`&&n()),U=X.useMemo(()=>typeof navigator>`u`?!1:/Macintosh|Mac OS X/.test(navigator.userAgent||``),[]),_e=me(),W=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},[]),ve=X.useMemo(()=>H&&U||_e?`pl-[5.5rem]`:`pl-3`,[H,U,_e]),G=X.useMemo(()=>!H||!U||W===null?``:W>=26?`h-12`:W<=15?`h-14`:``,[H,U,W]),K=u(async e=>{e.target.closest(`button, a, input, select, textarea`)||e.button===0&&H&&await d()}),q=u(e=>{r&&e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),r())}),J=!!r;X.useEffect(()=>{if(J)return window.addEventListener(`keydown`,q,!0),()=>window.removeEventListener(`keydown`,q,!0)},[J]);let[ye,Y]=X.useState(``),{isLoading:Ce,isGitRepository:Z}=Ke(V),Q=X.useRef(!1),we=Z===!0,Te=we&&ie;X.useEffect(()=>{if(Z===!1){Q.current=!0,k(!1);return}Z===!0&&Q.current&&(Q.current=!1,k(!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(!ge)return;let e=!1;return re(!0),(async()=>{try{let t=await m(ge);e||T(t)}catch{}finally{e||re(!1)}})(),()=>{e=!0}},[ge]);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})),M.current&&(M.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{F&&F!==N&&ue(F);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?ye: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&&V&&!Ce&&(Z===!1||!Te||ye)),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:K,className:ee(`relative flex h-12 shrink-0 items-center justify-center border-b app-region-drag select-none`,ve,G),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)(B,{children:[(0,$.jsx)(z,{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)(pe,{children:(0,$.jsx)(`p`,{children:a(`multirun.launcher.actions.closeEsc`)})})]})})]}),(0,$.jsx)(le,{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`)}),P.length>0?(0,$.jsxs)(ce,{value:F??void 0,onValueChange:he,children:[(0,$.jsx)(fe,{id:`multirun-project`,size:`lg`,className:`w-fit max-w-full`,children:L?(0,$.jsx)(j,{children:lt(L)}):(0,$.jsx)(j,{placeholder:a(`multirun.launcher.project.placeholder`)})}),(0,$.jsx)(se,{fitContent:!0,children:P.map(e=>(0,$.jsx)(de,{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)(R,{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:V,value:ye,onChange:Y,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)(A,{checked:ie,onChange:k,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)(be,{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)(R,{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:M,type:`file`,multiple:!0,className:`hidden`,onChange:Me,accept:`*/*`}),(0,$.jsxs)(B,{children:[(0,$.jsx)(z,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,onClick:()=>M.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)(pe,{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),A;t[13]!==n.id||t[14]!==a?(A=e=>{a(n.id,{prompt:e})},t[13]=n.id,t[14]=a,t[15]=A):A=t[15];let j=u(A),M;t[16]!==n.prompt||t[17]!==j||t[18]!==k?(M=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=ye(t,i===-1?r:i,r,`@${a}`);j(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]=j,t[18]=k,t[19]=M):M=t[19];let ae=u(M),oe;t[20]!==n.prompt||t[21]!==j||t[22]!==k?(oe=e=>{let t=n.prompt,r=S.current?.selectionStart??t.length,i=t.substring(0,r).lastIndexOf(`@`),a=ye(t,i===-1?r:i,r,`@${e}`);j(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]=j,t[22]=k,t[23]=oe):oe=t[23];let se=u(oe),ce;t[24]!==j||t[25]!==k?(ce=e=>{let t=`/${e.name} `;j(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]=j,t[25]=k,t[26]=ce):ce=t[26];let N=u(ce),le;t[27]!==n.prompt||t[28]!==j||t[29]!==k?(le=(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;j(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]=j,t[29]=k,t[30]=le):le=t[30];let ue=u(le),P;t[31]!==m||t[32]!==c||t[33]!==v?(P=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]=P):P=t[34];let I=u(P),de=r+1,fe;t[35]!==s||t[36]!==de?(fe=s(`multirun.launcher.groups.groupLabel`,{index:de}),t[35]=s,t[36]=de,t[37]=fe):fe=t[37];let L;t[38]===fe?L=t[39]:(L=(0,$.jsx)(`span`,{className:`typography-meta font-medium text-foreground`,children:fe}),t[38]=fe,t[39]=L);let R;t[40]!==i||t[41]!==n.id||t[42]!==o||t[43]!==s?(R=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]=R):R=t[44];let z;t[45]!==L||t[46]!==R?(z=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[L,R]}),t[45]=L,t[46]=R,t[47]=z):z=t[47];let pe;t[48]===s?pe=t[49]:(pe=s(`multirun.launcher.groups.prompt.label`),t[48]=s,t[49]=pe);let B;t[50]===pe?B=t[51]:(B=(0,$.jsx)(ct,{required:!0,children:pe}),t[50]=pe,t[51]=B);let me=n.prompt,V;t[52]!==j||t[53]!==k?(V=e=>{let t=e.target.value;j(t);let n=e.target.selectionStart??t.length;k(t,n)},t[52]=j,t[53]=k,t[54]=V):V=t[54];let H;t[55]===s?H=t[56]:(H=s(`multirun.launcher.groups.prompt.placeholder`),t[55]=s,t[56]=H);let U;t[57]!==n.prompt||t[58]!==I||t[59]!==V||t[60]!==H?(U=(0,$.jsx)(F,{ref:S,value:me,onChange:V,onKeyDown:I,placeholder:H,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]=I,t[59]=V,t[60]=H,t[61]=U):U=t[61];let _e;t[62]!==g||t[63]!==N||t[64]!==m?(_e=m?(0,$.jsx)(he,{ref:w,searchQuery:g,onCommandSelect:N,onClose:()=>h(!1),style:{left:0,top:`auto`,bottom:`calc(100% + 6px)`,marginBottom:0,maxWidth:`100%`}}):null,t[62]=g,t[63]=N,t[64]=m,t[65]=_e):_e=t[65];let W;t[66]!==se||t[67]!==ae||t[68]!==d||t[69]!==c?(W=c?(0,$.jsx)(ve,{ref:C,searchQuery:d,onFileSelect:ae,onAgentSelect:se,onClose:()=>l(!1),style:{left:0,top:`auto`,bottom:`calc(100% + 6px)`,marginBottom:0,maxWidth:`100%`}}):null,t[66]=se,t[67]=ae,t[68]=d,t[69]=c,t[70]=W):W=t[70];let G;t[71]!==ue||t[72]!==v||t[73]!==b?(G=v?(0,$.jsx)(ge,{ref:T,searchQuery:b,onSnippetSelect:ue,onClose:()=>y(!1),style:{left:0,top:`auto`,bottom:`calc(100% + 6px)`,marginBottom:0,maxWidth:`100%`}}):null,t[71]=ue,t[72]=v,t[73]=b,t[74]=G):G=t[74];let K;t[75]!==U||t[76]!==_e||t[77]!==W||t[78]!==G?(K=(0,$.jsxs)(`div`,{className:`relative`,children:[U,_e,W,G]}),t[75]=U,t[76]=_e,t[77]=W,t[78]=G,t[79]=K):K=t[79];let q;t[80]!==B||t[81]!==K?(q=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[B,K]}),t[80]=B,t[81]=K,t[82]=q):q=t[82];let J;t[83]===s?J=t[84]:(J=s(`multirun.launcher.models.info`,{max:ot}),t[83]=s,t[84]=J);let Y;t[85]===J?Y=t[86]:(Y=(0,$.jsx)(st,{children:J}),t[85]=J,t[86]=Y);let be;t[87]===s?be=t[88]:(be=s(`multirun.launcher.models.label`),t[87]=s,t[88]=be);let xe;t[89]!==Y||t[90]!==be?(xe=(0,$.jsx)(ct,{required:!0,info:Y,children:be}),t[89]=Y,t[90]=be,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]!==z||t[101]!==q||t[102]!==Z?(Q=(0,$.jsxs)(`div`,{className:`rounded-lg border border-border p-3 space-y-3`,children:[z,q,Z]}),t[100]=z,t[101]=q,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,t)=>{if(t.length>=e.length)return null;let n=0,r=Math.min(e.length,t.length);for(;n<r&&e[n]===t[n];)n+=1;let i=0;for(;i<e.length-n&&i<t.length-n&&e[e.length-1-i]===t[t.length-1-i];)i+=1;let a=e.length-i;return t.length-i!==n||a<=n?null:{start:n,end:a}},Fe=(e,t,n)=>{if(e===t||n.length===0)return null;let r=[...n],i=Pe(e,t);if(i){let t=Ke(e,r,{key:`Backspace`,selectionStart:i.start,selectionEnd:i.end});if(t)return t}let a=Ne(r,e,t);return a.length===0?null:{text:t,caret:t.length,removedFilenames:a}},Ie=e=>e.replaceAll(`[${ee}`,`[`),Le=/\.(?:png|jpe?g|gif|webp|svg|avif|bmp|heic|heif|tiff?)$/i,Re=e=>{let t=e.trim();return t.startsWith(`/`)||/^[A-Za-z]:[\\/]/.test(t)||t.startsWith(`\\\\`)},ze=(e,t)=>{let n=e;for(let e of t){let t=e.filename.trim(),r=e.path.trim();if(!t||!r||t===r||Re(t)||!Le.test(t)&&!Le.test(r))continue;let i=`[${r}]`;n=n.split(v(t)).join(i).split(`[${t}]`).join(i)}return n},Be=(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},Ve=e=>e.mime===`text/plain`&&typeof e.filename==`string`&&/:\d+(?:-\d+)?$/.test(e.filename),He=`application/x-directory`,Ue=e=>typeof e==`string`&&e.trim().toLowerCase()===`application/x-directory`,We=e=>typeof e==`string`&&/[/\\]$/.test(e.trim()),Ge=(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}},Ke=(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?Ge(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://`,qe=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}`},Je=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},Ye=async e=>[...new Uint8Array(await crypto.subtle.digest(`SHA-256`,await e.arrayBuffer()))].map(e=>e.toString(16).padStart(2,`0`)).join(``),Xe=e=>typeof e==`object`&&!!e&&!Array.isArray(e),Ze=async e=>{let t;try{t=await e.json()}catch{throw new x(e.status,`unavailable`)}if(!Xe(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:qe(t.path),mime:n,size:r,sha256:i}},Qe=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}`},$e=(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}},et=e=>e.startsWith(`data:`)||e.startsWith(`blob:`),tt=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 Ye(n),i=Qe(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 Ze(a);if(o.size!==n.size)throw new x(a.status,`unavailable`);return{...o,mime:t}},nt=500,rt=()=>{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}},it=()=>rt(),C=(e,t)=>{if(!rt())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>nt&&window.__OPENCHAMBER_STARTUP_TRACE__.splice(0,window.__OPENCHAMBER_STARTUP_TRACE__.length-nt)};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 at=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}},ot=3,st=3e4,ct=32e3,lt=36e5,ut=6e5,dt=new Set([429,502,503,504]),w=new Map;function ft(){let e=Date.now();for(let[t,n]of w)n.consecutiveErrors===0&&e-n.lastErrorAt>lt&&w.delete(t)}typeof setInterval<`u`&&setInterval(ft,ut).unref?.();function pt(e){let t=w.get(e);return t||(t={consecutiveErrors:0,lastErrorAt:0,circuitOpen:!1,circuitOpenAt:0,circuitCooldownMs:st},w.set(e,t)),t}function mt(e){if(!e)return;let t=w.get(e);t&&(t.consecutiveErrors=0,t.lastErrorAt=0)}function ht(e,t){if(!e)return;let n=pt(e);n.consecutiveErrors+=1,n.lastErrorAt=Date.now(),gt(t)&&n.consecutiveErrors>=ot&&(n.circuitOpen=!0,n.circuitOpenAt=Date.now(),console.warn(`[provider-tracker] Circuit opened for ${e} after ${n.consecutiveErrors} consecutive errors`))}function gt(e){return e!==void 0&&dt.has(e)}function _t(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,ct*4),!1):!0:!1}function vt(e){if(!(!e||!_t(e)))throw Error(`Provider ${e} is temporarily unavailable after repeated errors. Please retry shortly.`)}var yt=`/api`,bt=1e4,xt=4e3,St=3e3,Ct=1e3,wt=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 Tt=/^[a-zA-Z][a-zA-Z\d+\-.]*:\/\//,Et=e=>{let t=typeof e==`string`&&e.trim().length>0?e.trim():`/api`;if(Tt.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}},Dt=()=>{try{return i().api(`/api`)}catch{return null}},Ot=()=>{try{return i().api(`/`)}catch{return null}},kt=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)}},At=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}),jt=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),Mt=e=>{let t=[];for(let n of e){if(!jt(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=Je(r).trim();i&&t.push({filename:e,path:i})}return t},Nt=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=>ze(e,Mt([...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,`/`),Pt=400,Ft=()=>{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=yt){let t=Dt()||e;this.baseUrl=Et(t),this.client=O({baseUrl:this.baseUrl})}getBaseUrl(){return this.baseUrl}reconnectToRuntimeBaseUrl(){let e=Et(Dt()||yt);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=$e(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(et(n)){let e=$e(n,t.mime);if(!e)throw Error(`Failed to materialize attachment bytes for ${t.filename??`file`}`);n=(await tt({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 Nt(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),vt(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 ht(e.providerID),t}if(i.ok)return mt(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,ht(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:Et(Ot()||`/`)}).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()+bt}),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=kt(wt),r=At(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=kt(xt),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?St:Ct)}),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=Ft();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=Ft();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()+Pt}),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()+Pt}),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}}},It=3e4,Lt=40,Rt=60,zt=(e,t,n,r,i,a)=>{let o=e.trim(),s=t.trim().toLowerCase();return JSON.stringify([o,s,n,r,i,a])},Bt=(e,t)=>{try{let n=JSON.parse(e);return Array.isArray(n)&&n[0]===t}catch{return!1}},Vt=ie()(ae((e,t)=>({cache:{},cacheKeys:[],inFlight:{},async searchFiles(n,r,i=Rt,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=zt(o,s,i,c,l,u),f=Date.now(),p=t().cache[d];if(p&&f-p.timestamp<It)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>Lt;){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=>!Bt(e,n)||(delete t[e],!1)),i=Object.entries(e.inFlight).filter(([e])=>!Bt(e,n));return{cache:t,cacheKeys:r,inFlight:Object.fromEntries(i)}})}}),{name:`file-search-store`})),Ht=()=>{if(typeof window>`u`)return!1;try{return window.localStorage.getItem(`openchamber_stream_debug`)===`1`}catch{return!1}},Ut=`openchamber_stream_perf`,j=()=>{if(typeof window>`u`)return!1;try{return window.localStorage.getItem(Ut)===`1`}catch{return!1}},Wt=()=>typeof performance<`u`&&typeof performance.now==`function`?performance.now():Date.now(),Gt=()=>{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},Kt=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),qt=(e,t)=>{let n=Gt();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()},Jt=e=>{if(!(typeof window>`u`))try{if(e){window.localStorage.setItem(Ut,`1`),window.__openchamberStreamPerfState={counters:new Map,startedAt:Date.now(),lastUpdatedAt:Date.now()};return}window.localStorage.removeItem(Ut),delete window.__openchamberStreamPerfState,delete window.__openchamberVsCodeStreamPerfState}catch{}},Yt=()=>{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()}))},Xt=()=>{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:Kt(e.counters)}},Zt=()=>{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:Kt(e.counters)}},Qt=(e,t=1)=>{qt(e,t)},$t=(e,t)=>{qt(e,t)},en=(e,t)=>{if(!j())return t();let n=Wt();try{return t()}finally{qt(e,Wt()-n)}},M=null,tn=0,N=s(),nn=f(`lastDirectory`,{storage:N}),rn=typeof nn==`string`&&nn.length>0,P=e=>{try{Vt.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},an=(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(an(e,t)),on=()=>{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},sn=()=>{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},cn=()=>{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},ln=()=>{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=on();if(t&&!d())return M=t,t}return cn()||`/`},un=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},dn=e=>(M=e,typeof window<`u`&&p(`homeDirectory`,e,{storage:N}),_({homeDirectory:e}),e),fn=async()=>{let e=e=>{let t=un(e);return t?dn(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=ln();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})()||ln(),R=(()=>{let e=sn();return e&&!d()?I(e,L):L})();R&&A.setDirectory(R);var pn=!!(L&&L!==`/`),z=ie()(ae((e,t)=>({currentDirectory:R,directoryHistory:[R],historyIndex:0,homeDirectory:L,hasPersistedDirectory:rn,isHomeReady:pn,isSwitchingDirectory:!1,setDirectory:(n,r)=>{let i=I(n,M||t().homeDirectory||f(`homeDirectory`,{storage:N}));Ht(),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||ln())||e===`/`)return;let r=e.endsWith(`/`)?e.slice(0,-1):e,i=r.lastIndexOf(`/`);n(i===-1?M||ln():i===0?`/`:r.substring(0,i))},goHome:async()=>{let e=M||t().homeDirectory||await fn();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`&&(fn().then(e=>{z.getState().synchronizeHomeDirectory(e)}),n(e=>{M=null;let t=++tn;if(c(e)){let e=on(),t=sn(),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())}fn().then(e=>{t===tn&&z.getState().synchronizeHomeDirectory(e)})}));var mn=(e,n)=>{let r=o();return r?r.openWebSocket(l(e),n):t(n?new WebSocket(e,n):new WebSocket(e))},B=`/api/git`,hn=1200,gn=5e3,_n=2,vn=5e3,yn=`${B}/worktrees/queue-activation`,bn=`message_queue_activation_pending`,xn=`worktree_lifecycle_busy`,Sn=`worktree_activation_stale`,Cn=5e3,wn=3e4,Tn=[0,500,1e3,2e3,4e3,8e3,14e3],V=new Map,H=new Map,En=new Map,U=new Map,W=new Map,G=new Map,K=new Map,Dn=new Map,q=new Map,On=new Map,kn=new Set,J=0,An=[],jn=()=>J<_n?(J+=1,Promise.resolve()):new Promise(e=>{An.push(e)}),Mn=()=>{let e=An.shift();if(e){e();return}J=Math.max(0,J-1)},Y=async e=>{await jn();try{return await e()}finally{Mn()}},Nn=Symbol.for(`openchamber.git.discoveryGated`),Pn=e=>(Object.defineProperty(e,Nn,{value:!0,configurable:!0}),e),Fn=e=>typeof e==`function`&&e[Nn]===!0,X=e=>e.trim(),In=(e,t)=>t===`light`?`${X(e)}::light`:X(e),Ln=e=>En.get(X(e))??0,Z=e=>{let t=X(e);En.set(t,Ln(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)},Rn=e=>On.get(X(e))??0,Q=e=>{let t=X(e);t&&(On.set(t,Rn(e)+1),Dn.delete(t),q.delete(t))};function $(e,t,n){let r={...n};return t&&(r.directory=t),i().api(e,r)}var zn=(e,t,n)=>{let r=X(e);if(!r)return;let i=Date.now()+vn;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 Bn(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;zn(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([Vn(e),Un(e).then(e=>e.root).catch(()=>e)]);zn(e,t,t?r:null),n.set(e,{isGitRepository:t,primaryRoot:t?r:null})}catch{zn(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 Vn(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()+gn}),r})();W.set(t,a);try{return await a}finally{W.get(t)===a&&W.delete(t)}}async function Hn(e,t){let n=t?.mode,r=In(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=Ln(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 Ln(e)===t&&V.set(r,{value:a,expiresAt:Date.now()+hn}),a})();H.set(r,s);try{return await s}finally{H.get(r)===s&&H.delete(r)}}async function Un(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()+vn}),i});K.set(t,a);try{return await a}finally{K.get(t)===a&&K.delete(t)}}async function Wn(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 Gn(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 Kn(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 qn(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 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 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 Xn(e,t){await Zn(e,[t])}async function Zn(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 Qn(e,t,n){await tr(e,t,n,`stage`)}async function $n(e,t,n){await tr(e,t,n,`unstage`)}async function er(e,t,n){await tr(e,t,n,`discard`)}async function tr(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 nr(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 rr(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 ir(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 ar(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 or(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 sr(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 cr(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 lr(e){let t=X(e),n=Date.now(),r=Dn.get(t);if(r&&r.expiresAt>n)return r.value;let i=q.get(t);if(i)return i;let a=Rn(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===Rn(e)&&Dn.set(t,{value:r,expiresAt:Date.now()+vn}),r});q.set(t,o);try{return await o}finally{q.get(t)===o&&q.delete(t)}}Pn(lr);async function ur(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 dr(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 fr(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 pr=e=>typeof e==`string`&&e.length>0,mr=e=>{if(!e||typeof e!=`object`)return null;let t=e;if(!pr(t.name)||!pr(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},hr=(e,t,n)=>{if(e!==503||!t||typeof t!=`object`)return null;let r=t;if(r.code!==bn)return null;let i=mr(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!==yn)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},gr=(e,t,n,r)=>`${e}\u0000${t}\u0000${n}\u0000${r}`,_r=e=>new Promise(t=>{setTimeout(t,e)}),vr=async e=>{if(e.status===409){let t=await e.json().catch(()=>null);return t?.code===xn||t?.code===Sn}return e.status===503&&(await e.json().catch(()=>null))?.code===bn},yr=e=>e===400||e===401||e===403||e===501,br=(e,t)=>{let n=r(),i=u(),a=gr(n,i,e,t);if(kn.has(a))return;kn.add(a);let o=()=>r()===n&&u()===i;(async()=>{let n=Date.now(),r=0;for(;Date.now()-n<wn;){if(!o())return;let i=Tn[Math.min(r,Tn.length-1)]??0;if(i>0){let e=wn-(Date.now()-n);if(e<=0||(await _r(Math.min(i,e)),!o()))return}let a=new AbortController,s=setTimeout(()=>a.abort(),Cn);try{let n=await h($(yn,void 0),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({projectDirectory:e,directory:t}),signal:a.signal});if(n.ok||yr(n.status))return;if(await vr(n)){r+=1;continue}return}catch{r+=1}finally{clearTimeout(s)}}})().catch(()=>{}).finally(()=>{kn.delete(a)})};async function xr(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=mr(r);if(t)return Q(e),t;if(r&&typeof r==`object`)return Q(e),r;throw Error(`Failed to create worktree`)}let i=hr(n.status,r,e);if(i)return Q(e),br(e,i.path),i;let a=r&&typeof r==`object`?r:{error:n.statusText};throw Error(a.error||`Failed to create worktree`)}async function Sr(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 Cr(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 wr(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 Tr(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 Er(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 Dr(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 Or(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 kr(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 Ar=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()},jr=(e,t)=>Ar(e,`stash/apply`,t),Mr=(e,t)=>Ar(e,`stash/pop`,t),Nr=(e,t)=>Ar(e,`stash/drop`,t);async function Pr(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 Fr(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 Ir(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 Lr(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 Rr(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 zr(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 Br(){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 Vr(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 Hr(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 Ur(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 Wr(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 Gr(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 Kr(){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 qr(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 Jr(){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 Yr(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 Xr(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 Zr(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 Qr(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 $r(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 ei(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 ti(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 ni(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 ri(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 ii(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 ai(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 oi(e,t){return await kr(e,{message:t?.message}),{success:!0}}async function si(e){return await Mr(e,{ref:`stash@{0}`}),{success:!0}}async function ci(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 li(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 ui(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 di=()=>typeof window>`u`?!1:window.Capacitor?.isNativePlatform?.()===!0||window.location.protocol===`capacitor:`,fi=()=>{if(typeof window>`u`||!di()||pi()!==`ios`)return!1;let e=navigator.userAgent||``,t=navigator.maxTouchPoints??0;return/iPad/i.test(e)||/Macintosh|MacIntel/i.test(e)&&t>1},pi=()=>{if(typeof window<`u`){let e=window.Capacitor?.getPlatform?.();if(e===`ios`||e===`android`)return e}return d()?`vscode`:m()?`desktop`:`web`};export{Xr as $,ci as A,en as At,Yr as B,Ne as Bt,Jr as C,z as Ct,cr as D,Jt as Dt,sr as E,Yt as Et,Br as F,at as Ft,Q as G,Fe as Gt,Tr as H,Ve as Ht,Lr as I,it as It,Dr as J,ye as Jt,Fn as K,Ke as Kt,Hn as L,He as Lt,rr as M,Vt as Mt,Gn as N,A as Nt,zr as O,Ht as Ot,Kn as P,C as Pt,fr as Q,dr as R,je as Rt,ar as S,mn as St,Nr as T,Zt as Tt,wr as U,Ue as Ut,Er as V,Be as Vt,Gr as W,We as Wt,Qr as X,xe as Xt,lr as Y,ve as Yt,Mr as Z,Vr as _,$n as _t,Zr as a,ti as at,Ur as b,li as bt,Vn as c,qr as ct,ei as d,Qn as dt,or as et,ai as f,oi as ft,Cr as g,Zn as gt,Fr as h,Xn as ht,ri as i,Wn as it,Wr as j,$t as jt,Rr as k,Qt as kt,Pr as l,Jn as lt,Or as m,si as mt,di as n,ni as nt,jr as o,qn as ot,ii as p,kr as pt,nr as q,Ie as qt,fi as r,Un as rt,ui as s,er as st,pi as t,Ir as tt,$r as u,Yn as ut,xr as v,Hr as vt,Bn as w,Xt as wt,Sr as x,Y as xt,ir as y,ur as yt,Kr as z,Me as zt};
|