pi-forge 1.3.0 → 1.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -19,7 +19,7 @@ Error generating stack: `+e.message+`
19
19
  `))t.startsWith(`:`)||t.startsWith(`data:`)&&n.push(t.slice(5).trimStart());if(n.length>0){let e=n.join(`
20
20
  `);try{let n=JSON.parse(e);await t.onEvent(n)}catch{}}r=s.indexOf(`
21
21
 
22
- `)}}}catch(e){if(e instanceof Error&&e.name===`AbortError`)return`aborted`;throw e instanceof Error?e:Error(String(e))}finally{try{o.releaseLock()}catch{}}}async function gr(e,t){let n=0;for(;;){let r;try{r=await hr(e,t)}catch(e){if(e instanceof N&&dr.has(e.status)||(n+=1,t.maxReconnects!==void 0&&t.maxReconnects>0&&n>t.maxReconnects))throw e;let r=pr(n),i=e instanceof Error?e.message:String(e);t.onReconnect?.({attempt:n,delayMs:r,reason:i});try{await mr(r,t.signal)}catch{return}continue}if(r===`aborted`)return;if(n+=1,t.maxReconnects!==void 0&&t.maxReconnects>0&&n>t.maxReconnects){t.onClose?.();return}let i=pr(n);t.onReconnect?.({attempt:n,delayMs:i,reason:`server closed stream`});try{await mr(i,t.signal)}catch{return}}}var _r=`pi-forge`,vr=`tab-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`,yr;function br(){if(yr!==void 0)return yr;if(!(typeof BroadcastChannel>`u`))return yr=new BroadcastChannel(_r),yr}function xr(e){let t=br();if(t===void 0)return;let n={from:vr,msg:e};try{t.postMessage(n)}catch{}}function Sr(e){let t=br();if(t===void 0)return()=>void 0;let n=t=>{let n=t.data;typeof n!=`object`||!n||n.from!==vr&&(typeof n.msg!=`object`||n.msg===null||e(n.msg))};return t.addEventListener(`message`,n),()=>t.removeEventListener(`message`,n)}var Cr=ft((e,t)=>({pendingBySession:{},setPending:t=>e(e=>({pendingBySession:{...e.pendingBySession,[t.sessionId]:t}})),clearPending:(n,r)=>{let i=t().pendingBySession[n];i!==void 0&&(r!==void 0&&i.requestId!==r||e(e=>({pendingBySession:{...e.pendingBySession,[n]:void 0}})))}})),wr={tasks:[],nextId:1},Tr=ft(e=>({byId:{},set:(t,n)=>e(e=>({byId:{...e.byId,[t]:n}})),clear:t=>e(e=>{let n={...e.byId};return delete n[t],{byId:n}})}));function Er(e,t){return t===void 0?wr:e.byId[t]??wr}function Dr(e){let t=0,n=0,r=0;for(let i of e.tasks)i.status===`pending`?t+=1:i.status===`in_progress`?n+=1:i.status===`completed`&&(r+=1);return{pending:t,inProgress:n,completed:r,total:t+n+r}}var Or=new Set([`running`,`terminating`,`terminate_timeout`]),kr=50,Ar=[],jr=[],Mr=ft(e=>({bySession:{},watchesBySession:{},setProcesses:(t,n)=>e(e=>({bySession:{...e.bySession,[t]:n}})),pushWatch:(t,n)=>e(e=>{let r=[...e.watchesBySession[t]??[],n];return r.length>kr&&r.splice(0,r.length-kr),{watchesBySession:{...e.watchesBySession,[t]:r}}}),clearWatches:t=>e(e=>{let n={...e.watchesBySession};return delete n[t],{watchesBySession:n}})}));function Nr(e,t){return t===void 0?Ar:e.bySession[t]??Ar}function Pr(e,t){return t===void 0?jr:e.watchesBySession[t]??jr}function Fr(e){let t=0;for(let n of e)Or.has(n.status)&&(t+=1);return t}var Ir=`pi-forge/active-session-id`,Lr=[],Rr=[],zr=[],Br=new Map,Vr=new Map,Hr=new Map,Ur=new Map;function Wr(e){for(let t of e)if(t.role===`user`&&Array.isArray(t.content))for(let e of t.content){let t=e;if(t.type===`image`&&t.__blobUrl===!0&&typeof t.data==`string`)try{URL.revokeObjectURL(t.data)}catch{}}}function Gr(e,t){for(let[n,r]of Object.entries(e.byProject))if(r.some(e=>e.sessionId===t))return n}function Kr(e,t){let n=e.messagesBySession[t];n!==void 0&&Wr(n);let r={...e.messagesBySession};delete r[t];let i={...e.streamingBySession};delete i[t];let a={...e.bannerBySession};delete a[t];let o={...e.streamingTextBySession};delete o[t];let s={...e.activeToolBySession};delete s[t];let c={...e.agentEndCountBySession};delete c[t];let l={...e.queuedBySession};delete l[t];let u={};for(let[n,r]of Object.entries(e.byProject))u[n]=r.filter(e=>e.sessionId!==t);return{messagesBySession:r,streamingBySession:i,bannerBySession:a,streamingTextBySession:o,activeToolBySession:s,agentEndCountBySession:c,queuedBySession:l,byProject:u,activeSessionId:e.activeSessionId===t?void 0:e.activeSessionId}}var qr=ft((e,t)=>({byProject:{},activeSessionId:localStorage.getItem(Ir)??void 0,messagesBySession:{},compactionsBySession:{},pendingDraftBySession:{},streamingBySession:{},bannerBySession:{},streamingTextBySession:{},activeToolBySession:{},agentEndCountBySession:{},compactionEndCountBySession:{},queuedBySession:{},pendingScrollByMessageIndex:{},error:void 0,loadingList:!1,loadSessionsForProject:async t=>{e({loadingList:!0,error:void 0});try{let{sessions:n}=await L.listSessions(t);e(e=>({byProject:{...e.byProject,[t]:n},loadingList:!1}))}catch(t){e({loadingList:!1,error:t instanceof N?t.code:t.message})}},createSession:async t=>{e({error:void 0});try{let n=await L.createSession(t),r={sessionId:n.sessionId,projectId:n.projectId,isLive:!0,workspacePath:n.workspacePath,lastActivityAt:n.lastActivityAt,createdAt:n.createdAt,messageCount:n.messageCount,firstMessage:``};return n.name!==void 0&&(r.name=n.name),e(e=>{let i=e.byProject[t]??[];return{byProject:{...e.byProject,[t]:[r,...i]},activeSessionId:n.sessionId}}),localStorage.setItem(Ir,n.sessionId),xr({type:`session_created`,projectId:t,session:r}),n}catch(t){throw e({error:t instanceof N?t.code:t.message}),t}},renameSession:async(t,n)=>{e({error:void 0});try{let r=await L.renameSession(t,n);e(e=>{let n={};for(let[i,a]of Object.entries(e.byProject))n[i]=a.map(e=>{if(e.sessionId!==t)return e;let n={...e};return r.name===void 0?delete n.name:n.name=r.name,n});return{byProject:n}}),xr({type:`session_renamed`,sessionId:t,name:r.name})}catch(t){throw e({error:t instanceof N?t.code:t.message}),t}},reloadMessages:t=>{Yr(e,t)},loadCompactions:async t=>{try{let n=await L.getCompactions(t);e(e=>({compactionsBySession:{...e.compactionsBySession,[t]:n.compactions}}))}catch{}},setPendingDraft:(t,n)=>e(e=>({pendingDraftBySession:{...e.pendingDraftBySession,[t]:n}})),consumePendingDraft:t=>e(e=>{if(e.pendingDraftBySession[t]===void 0)return{};let n={...e.pendingDraftBySession};return delete n[t],{pendingDraftBySession:n}}),requestScrollToMessage:(t,n)=>e(e=>({pendingScrollByMessageIndex:{...e.pendingScrollByMessageIndex,[t]:n}})),consumePendingScroll:n=>{let r=t().pendingScrollByMessageIndex[n];if(r!==void 0)return e(e=>{let t={...e.pendingScrollByMessageIndex};return delete t[n],{pendingScrollByMessageIndex:t}}),r},setActiveSession:t=>{t===void 0?localStorage.removeItem(Ir):localStorage.setItem(Ir,t),e({activeSessionId:t})},openStream:n=>{if(Ur.get(n)!==void 0)return;let r=new AbortController;Ur.set(n,r),t().loadCompactions(n);let i=()=>{Ur.get(n)===r&&Ur.delete(n)};gr(`/api/v1/sessions/${encodeURIComponent(n)}/stream`,{signal:r.signal,onEvent:r=>Jr(e,t,n,r),onClose:i,onReconnect:({attempt:t,delayMs:r,reason:i})=>{e(e=>({bannerBySession:{...e.bannerBySession,[n]:`Reconnecting (attempt ${t}, ${Math.round(r/1e3)}s) — ${i}`}}))}}).catch(r=>{if(r instanceof N&&r.status===404){e(e=>Kr(e,n)),t().activeSessionId===void 0&&localStorage.removeItem(Ir),i();return}let a=r instanceof N?r.code:r.message;e(e=>({bannerBySession:{...e.bannerBySession,[n]:`stream error: ${a}`}})),i()})},closeStream:e=>{let t=Ur.get(e);t!==void 0&&(t.abort(),Ur.get(e)===t&&Ur.delete(e))},sendPrompt:async(t,n,r)=>{e({error:void 0});let i=[{type:`text`,text:n}];if(r!==void 0)for(let e of r)e.type.startsWith(`image/`)?i.push({type:`image`,mimeType:e.type,data:URL.createObjectURL(e),__blobUrl:!0}):i.push({type:`file`,filename:e.name,size:e.size});let a={role:`user`,content:i,timestamp:Date.now()};e(e=>({messagesBySession:{...e.messagesBySession,[t]:[...e.messagesBySession[t]??[],a]}}));try{let e={};r!==void 0&&r.length>0&&(e.attachments=r),await L.prompt(t,n,e)}catch(n){throw Wr([a]),e(e=>{let r=e.messagesBySession[t]??[];return{messagesBySession:{...e.messagesBySession,[t]:r.filter(e=>e!==a)},error:n instanceof N?n.code:n.message,bannerBySession:{...e.bannerBySession,[t]:n instanceof N?`prompt rejected: ${n.code}${n.message===`${n.status} ${n.code}`?``:` — ${n.message}`}`:`prompt rejected: ${n.message}`}}}),n}},sendSteer:async(t,n,r)=>{e({error:void 0});try{await L.steer(t,n,r)}catch(t){throw e({error:t instanceof N?t.code:t.message}),t}},abortSession:async t=>{e({error:void 0});try{await L.abort(t)}catch(t){e({error:t instanceof N?t.code:t.message})}},disposeSession:async n=>{e({error:void 0});try{t().closeStream(n);let r=Gr(t(),n);await L.disposeSession(n),e(e=>Kr(e,n)),t().activeSessionId===void 0&&localStorage.removeItem(Ir),r!==void 0&&(xr({type:`session_deleted`,projectId:r,sessionId:n}),t().loadSessionsForProject(r))}catch(t){e({error:t instanceof N?t.code:t.message})}}}));function Jr(e,t,n,r){if(r.type===`snapshot`){e(e=>({messagesBySession:{...e.messagesBySession,[n]:r.messages??[]},streamingBySession:{...e.streamingBySession,[n]:r.isStreaming??!1},bannerBySession:{...e.bannerBySession,[n]:void 0},activeToolBySession:{...e.activeToolBySession,[n]:void 0}}));return}if(r.type===`agent_start`){let t=Vr.get(n);t!==void 0&&cancelAnimationFrame(t),Vr.delete(n),Br.delete(n),e(e=>({streamingBySession:{...e.streamingBySession,[n]:!0},streamingTextBySession:{...e.streamingTextBySession,[n]:``},bannerBySession:{...e.bannerBySession,[n]:void 0}}));return}if(r.type===`agent_end`){let t=Vr.get(n);t!==void 0&&cancelAnimationFrame(t),Vr.delete(n),Br.delete(n);let i=r.errorMessage,a=typeof i==`string`&&i.length>0?`Agent error: ${i}`:void 0;L.getMessages(n).then(({messages:t})=>{e(e=>{let r=e.messagesBySession[n];r!==void 0&&Wr(r);let i=e.bannerBySession[n],o=a??i;return{messagesBySession:{...e.messagesBySession,[n]:t},streamingBySession:{...e.streamingBySession,[n]:!1},streamingTextBySession:{...e.streamingTextBySession,[n]:``},activeToolBySession:{...e.activeToolBySession,[n]:void 0},bannerBySession:{...e.bannerBySession,[n]:o},agentEndCountBySession:{...e.agentEndCountBySession,[n]:(e.agentEndCountBySession[n]??0)+1}}})}).catch(()=>{e(e=>({streamingBySession:{...e.streamingBySession,[n]:!1},activeToolBySession:{...e.activeToolBySession,[n]:void 0},bannerBySession:{...e.bannerBySession,[n]:a??`Couldn't refresh messages after the agent finished — reload to sync`},agentEndCountBySession:{...e.agentEndCountBySession,[n]:(e.agentEndCountBySession[n]??0)+1}}))});return}if(r.type===`queue_update`){let t=r,i=Array.isArray(t.steering)?t.steering.filter(e=>typeof e==`string`):[],a=Array.isArray(t.followUp)?t.followUp.filter(e=>typeof e==`string`):[];e(e=>({queuedBySession:{...e.queuedBySession,[n]:i.length===0&&a.length===0?void 0:{steering:i,followUp:a}}}));return}if(r.type===`tool_execution_start`){let t=typeof r.toolName==`string`?r.toolName:`tool`,i=Xr(t,r.input??{}),a=i===void 0?{name:t}:{name:t,summary:i};e(e=>({activeToolBySession:{...e.activeToolBySession,[n]:a}})),Yr(e,n);return}if(r.type===`tool_execution_end`){if(e(e=>({activeToolBySession:{...e.activeToolBySession,[n]:void 0}})),Yr(e,n),r.toolName===`subagent`){let e=Gr(t(),n);e!==void 0&&t().loadSessionsForProject(e)}return}if(r.type===`message_end`||r.type===`tool_result`){Yr(e,n);return}if(r.type===`ask_user_question`){let e=typeof r.requestId==`string`?r.requestId:void 0,t=Array.isArray(r.questions)?r.questions:void 0;if(e===void 0||t===void 0)return;Cr.getState().setPending({requestId:e,sessionId:n,questions:t});return}if(r.type===`ask_user_question_cancelled`){let e=typeof r.requestId==`string`?r.requestId:void 0;Cr.getState().clearPending(n,e);return}if(r.type===`todo_update`){let e=Array.isArray(r.tasks)?r.tasks:[],t=typeof r.nextId==`number`?r.nextId:1;Tr.getState().set(n,{tasks:e,nextId:t});return}if(r.type===`process_update`){let e=Array.isArray(r.processes)?r.processes:[];Mr.getState().setProcesses(n,e);return}if(r.type===`process_watch`){let e=r.match;e!==void 0&&typeof e.processId==`string`&&typeof e.processName==`string`&&(e.source===`stdout`||e.source===`stderr`)&&typeof e.line==`string`&&typeof e.watch?.pattern==`string`&&Mr.getState().pushWatch(n,{processId:e.processId,processName:e.processName,source:e.source,line:e.line,pattern:e.watch.pattern,at:Date.now()});return}if(r.type!==`process_output`){if(r.type===`user_bash_result`){Yr(e,n);return}if(r.type===`message_update`){let t=r.assistantMessageEvent;if(typeof t==`object`&&t&&t.type===`text_delta`&&typeof t.delta==`string`){let r=t.delta;if(Br.set(n,(Br.get(n)??``)+r),!Vr.has(n)){let t=requestAnimationFrame(()=>{Vr.delete(n);let t=Br.get(n)??``;t.length!==0&&(Br.delete(n),e(e=>({streamingTextBySession:{...e.streamingTextBySession,[n]:(e.streamingTextBySession[n]??``)+t}})))});Vr.set(n,t)}}return}if(r.type===`compaction_start`){e(e=>({bannerBySession:{...e.bannerBySession,[n]:`Compacting context…`}}));return}if(r.type===`compaction_end`){let t=r.errorMessage,i=typeof t==`string`&&t.length>0?`Agent error: ${t}`:void 0;e(e=>({bannerBySession:{...e.bannerBySession,[n]:i},compactionEndCountBySession:{...e.compactionEndCountBySession,[n]:(e.compactionEndCountBySession[n]??0)+1}})),qr.getState().loadCompactions(n),Yr(e,n);return}if(r.type===`auto_retry_start`){let t=typeof r.attempt==`number`?r.attempt:`?`,i=typeof r.maxAttempts==`number`?r.maxAttempts:`?`;e(e=>({bannerBySession:{...e.bannerBySession,[n]:`Retrying (${t}/${i})…`}}));return}if(r.type===`auto_retry_end`){let t=r.success!==!1,i=r.finalError,a=!t&&typeof i==`string`&&i.length>0?`Agent error: ${i}`:void 0;e(e=>({bannerBySession:{...e.bannerBySession,[n]:a}}));return}if(r.type===`message_end`){let t=r.message;if(t?.stopReason===`error`){let r=typeof t.errorMessage==`string`?t.errorMessage:``;r.length>0&&e(e=>({bannerBySession:{...e.bannerBySession,[n]:`Agent error: ${r}`}}))}return}}}function Yr(e,t){let n=Hr.get(t)??{inflight:!1,queued:!1};if(n.inflight){n.queued=!0,Hr.set(t,n);return}n.inflight=!0,Hr.set(t,n),L.getMessages(t).then(({messages:n})=>{e(e=>({messagesBySession:{...e.messagesBySession,[t]:n}}))}).catch(()=>{}).finally(()=>{let n=Hr.get(t);n!==void 0&&(n.queued?(n.queued=!1,n.inflight=!1,Hr.set(t,n),Yr(e,t)):Hr.delete(t))})}function Xr(e,t){let n=e=>{let n=t[e];return typeof n==`string`&&n.length>0?n:void 0};switch(e){case`bash`:return n(`command`);case`read`:case`write`:case`edit`:return n(`filePath`)??n(`path`)??n(`file`);case`grep`:return n(`pattern`);case`glob`:return n(`pattern`)??n(`path`);default:for(let e of[`path`,`file`,`filePath`,`command`,`pattern`,`query`,`url`]){let t=n(e);if(t!==void 0)return t}return}}globalThis.__piForgeSessionCrossTabRegistered||(globalThis.__piForgeSessionCrossTabCleanup=Sr(e=>{if(e.type===`session_created`){let t=e.session,n=typeof t.sessionId==`string`?t.sessionId:void 0;if(n===void 0)return;let r={sessionId:n,projectId:e.projectId,isLive:t.isLive===!0,workspacePath:typeof t.workspacePath==`string`?t.workspacePath:``,lastActivityAt:typeof t.lastActivityAt==`string`?t.lastActivityAt:new Date().toISOString(),createdAt:typeof t.createdAt==`string`?t.createdAt:new Date().toISOString(),messageCount:typeof t.messageCount==`number`?t.messageCount:0,firstMessage:typeof t.firstMessage==`string`?t.firstMessage:``};typeof t.name==`string`&&(r.name=t.name),qr.setState(t=>{let i=t.byProject[e.projectId]??[];return i.some(e=>e.sessionId===n)?{}:{byProject:{...t.byProject,[e.projectId]:[r,...i]}}});return}if(e.type===`session_deleted`){if(qr.setState(t=>Kr(t,e.sessionId)),qr.getState().activeSessionId===void 0)try{localStorage.removeItem(Ir)}catch{}qr.getState().loadSessionsForProject(e.projectId);return}if(e.type===`session_renamed`){qr.setState(t=>{let n={};for(let[r,i]of Object.entries(t.byProject))n[r]=i.map(t=>{if(t.sessionId!==e.sessionId)return t;let n={...t};return e.name===void 0?delete n.name:n.name=e.name,n});return{byProject:n}});return}}),globalThis.__piForgeSessionCrossTabRegistered=!0);var Zr=/^@@ -\d+(?:,\d+)? \+(\d+)(?:,(\d+))? @@/;function Qr(e){if(e.length===0)return[];let t=0,n=0,r=new Map,i=(e,t)=>{let n=r.get(e);n!==`modified`&&(n===`added`&&t===`deletedAbove`||r.set(e,t))},a=()=>{n!==0&&(i(t,`deletedAbove`),n=0)};for(let r of e.split(`
22
+ `)}}}catch(e){if(e instanceof Error&&e.name===`AbortError`)return`aborted`;throw e instanceof Error?e:Error(String(e))}finally{try{o.releaseLock()}catch{}}}async function gr(e,t){let n=0;for(;;){let r;try{r=await hr(e,t)}catch(e){if(e instanceof N&&dr.has(e.status)||(n+=1,t.maxReconnects!==void 0&&t.maxReconnects>0&&n>t.maxReconnects))throw e;let r=pr(n),i=e instanceof Error?e.message:String(e);t.onReconnect?.({attempt:n,delayMs:r,reason:i});try{await mr(r,t.signal)}catch{return}continue}if(r===`aborted`)return;if(n+=1,t.maxReconnects!==void 0&&t.maxReconnects>0&&n>t.maxReconnects){t.onClose?.();return}let i=pr(n);t.onReconnect?.({attempt:n,delayMs:i,reason:`server closed stream`});try{await mr(i,t.signal)}catch{return}}}var _r=`pi-forge`,vr=`tab-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`,yr;function br(){if(yr!==void 0)return yr;if(!(typeof BroadcastChannel>`u`))return yr=new BroadcastChannel(_r),yr}function xr(e){let t=br();if(t===void 0)return;let n={from:vr,msg:e};try{t.postMessage(n)}catch{}}function Sr(e){let t=br();if(t===void 0)return()=>void 0;let n=t=>{let n=t.data;typeof n!=`object`||!n||n.from!==vr&&(typeof n.msg!=`object`||n.msg===null||e(n.msg))};return t.addEventListener(`message`,n),()=>t.removeEventListener(`message`,n)}var Cr=ft((e,t)=>({pendingBySession:{},setPending:t=>e(e=>({pendingBySession:{...e.pendingBySession,[t.sessionId]:t}})),clearPending:(n,r)=>{let i=t().pendingBySession[n];i!==void 0&&(r!==void 0&&i.requestId!==r||e(e=>({pendingBySession:{...e.pendingBySession,[n]:void 0}})))}})),wr={tasks:[],nextId:1},Tr=ft(e=>({byId:{},set:(t,n)=>e(e=>({byId:{...e.byId,[t]:n}})),clear:t=>e(e=>{let n={...e.byId};return delete n[t],{byId:n}})}));function Er(e,t){return t===void 0?wr:e.byId[t]??wr}function Dr(e){let t=0,n=0,r=0;for(let i of e.tasks)i.status===`pending`?t+=1:i.status===`in_progress`?n+=1:i.status===`completed`&&(r+=1);return{pending:t,inProgress:n,completed:r,total:t+n+r}}var Or=new Set([`running`,`terminating`,`terminate_timeout`]),kr=50,Ar=[],jr=[],Mr=ft(e=>({bySession:{},watchesBySession:{},setProcesses:(t,n)=>e(e=>({bySession:{...e.bySession,[t]:n}})),pushWatch:(t,n)=>e(e=>{let r=[...e.watchesBySession[t]??[],n];return r.length>kr&&r.splice(0,r.length-kr),{watchesBySession:{...e.watchesBySession,[t]:r}}}),clearWatches:t=>e(e=>{let n={...e.watchesBySession};return delete n[t],{watchesBySession:n}})}));function Nr(e,t){return t===void 0?Ar:e.bySession[t]??Ar}function Pr(e,t){return t===void 0?jr:e.watchesBySession[t]??jr}function Fr(e){let t=0;for(let n of e)Or.has(n.status)&&(t+=1);return t}var Ir=`pi-forge/active-session-id`,Lr=[],Rr=[],zr=[],Br=new Map,Vr=new Map,Hr=new Map,Ur=new Map;function Wr(e){for(let t of e)if(t.role===`user`&&Array.isArray(t.content))for(let e of t.content){let t=e;if(t.type===`image`&&t.__blobUrl===!0&&typeof t.data==`string`)try{URL.revokeObjectURL(t.data)}catch{}}}function Gr(e,t){for(let[n,r]of Object.entries(e.byProject))if(r.some(e=>e.sessionId===t))return n}function Kr(e,t){let n=e.messagesBySession[t];n!==void 0&&Wr(n);let r={...e.messagesBySession};delete r[t];let i={...e.streamingBySession};delete i[t];let a={...e.bannerBySession};delete a[t];let o={...e.streamingTextBySession};delete o[t];let s={...e.activeToolBySession};delete s[t];let c={...e.agentEndCountBySession};delete c[t];let l={...e.queuedBySession};delete l[t];let u={};for(let[n,r]of Object.entries(e.byProject))u[n]=r.filter(e=>e.sessionId!==t);return{messagesBySession:r,streamingBySession:i,bannerBySession:a,streamingTextBySession:o,activeToolBySession:s,agentEndCountBySession:c,queuedBySession:l,byProject:u,activeSessionId:e.activeSessionId===t?void 0:e.activeSessionId}}var qr=ft((e,t)=>({byProject:{},activeSessionId:localStorage.getItem(Ir)??void 0,messagesBySession:{},compactionsBySession:{},pendingDraftBySession:{},streamingBySession:{},bannerBySession:{},streamingTextBySession:{},activeToolBySession:{},agentEndCountBySession:{},compactionEndCountBySession:{},queuedBySession:{},pendingScrollByMessageIndex:{},error:void 0,loadingList:!1,loadSessionsForProject:async t=>{e({loadingList:!0,error:void 0});try{let{sessions:n}=await L.listSessions(t);e(e=>({byProject:{...e.byProject,[t]:n},loadingList:!1}))}catch(t){e({loadingList:!1,error:t instanceof N?t.code:t.message})}},createSession:async t=>{e({error:void 0});try{let n=await L.createSession(t),r={sessionId:n.sessionId,projectId:n.projectId,isLive:!0,workspacePath:n.workspacePath,lastActivityAt:n.lastActivityAt,createdAt:n.createdAt,messageCount:n.messageCount,firstMessage:``};return n.name!==void 0&&(r.name=n.name),e(e=>{let i=e.byProject[t]??[];return{byProject:{...e.byProject,[t]:[r,...i]},activeSessionId:n.sessionId}}),localStorage.setItem(Ir,n.sessionId),xr({type:`session_created`,projectId:t,session:r}),n}catch(t){throw e({error:t instanceof N?t.code:t.message}),t}},renameSession:async(t,n)=>{e({error:void 0});try{let r=await L.renameSession(t,n);e(e=>{let n={};for(let[i,a]of Object.entries(e.byProject))n[i]=a.map(e=>{if(e.sessionId!==t)return e;let n={...e};return r.name===void 0?delete n.name:n.name=r.name,n});return{byProject:n}}),xr({type:`session_renamed`,sessionId:t,name:r.name})}catch(t){throw e({error:t instanceof N?t.code:t.message}),t}},reloadMessages:t=>{Yr(e,t)},loadCompactions:async t=>{try{let n=await L.getCompactions(t);e(e=>({compactionsBySession:{...e.compactionsBySession,[t]:n.compactions}}))}catch{}},setPendingDraft:(t,n)=>e(e=>({pendingDraftBySession:{...e.pendingDraftBySession,[t]:n}})),consumePendingDraft:t=>e(e=>{if(e.pendingDraftBySession[t]===void 0)return{};let n={...e.pendingDraftBySession};return delete n[t],{pendingDraftBySession:n}}),requestScrollToMessage:(t,n)=>e(e=>({pendingScrollByMessageIndex:{...e.pendingScrollByMessageIndex,[t]:n}})),consumePendingScroll:n=>{let r=t().pendingScrollByMessageIndex[n];if(r!==void 0)return e(e=>{let t={...e.pendingScrollByMessageIndex};return delete t[n],{pendingScrollByMessageIndex:t}}),r},setActiveSession:t=>{t===void 0?localStorage.removeItem(Ir):localStorage.setItem(Ir,t),e({activeSessionId:t})},openStream:n=>{if(Ur.get(n)!==void 0)return;let r=new AbortController;Ur.set(n,r),t().loadCompactions(n);let i=()=>{Ur.get(n)===r&&Ur.delete(n)};gr(`/api/v1/sessions/${encodeURIComponent(n)}/stream`,{signal:r.signal,onEvent:r=>Jr(e,t,n,r),onClose:i,onReconnect:({attempt:t,delayMs:r,reason:i})=>{e(e=>({bannerBySession:{...e.bannerBySession,[n]:`Reconnecting (attempt ${t}, ${Math.round(r/1e3)}s) — ${i}`}}))}}).catch(r=>{if(r instanceof N&&r.status===404){e(e=>Kr(e,n)),t().activeSessionId===void 0&&localStorage.removeItem(Ir),i();return}let a=r instanceof N?r.code:r.message;e(e=>({bannerBySession:{...e.bannerBySession,[n]:`stream error: ${a}`}})),i()})},closeStream:e=>{let t=Ur.get(e);t!==void 0&&(t.abort(),Ur.get(e)===t&&Ur.delete(e))},sendPrompt:async(t,n,r)=>{e({error:void 0});let i=[{type:`text`,text:n}];if(r!==void 0)for(let e of r)e.type.startsWith(`image/`)?i.push({type:`image`,mimeType:e.type,data:URL.createObjectURL(e),__blobUrl:!0}):i.push({type:`file`,filename:e.name,size:e.size});let a={role:`user`,content:i,timestamp:Date.now()};e(e=>({messagesBySession:{...e.messagesBySession,[t]:[...e.messagesBySession[t]??[],a]}}));try{let e={};r!==void 0&&r.length>0&&(e.attachments=r),await L.prompt(t,n,e)}catch(n){throw Wr([a]),e(e=>{let r=e.messagesBySession[t]??[];return{messagesBySession:{...e.messagesBySession,[t]:r.filter(e=>e!==a)},error:n instanceof N?n.code:n.message,bannerBySession:{...e.bannerBySession,[t]:n instanceof N?`prompt rejected: ${n.code}${n.message===`${n.status} ${n.code}`?``:` — ${n.message}`}`:`prompt rejected: ${n.message}`}}}),n}},sendSteer:async(t,n,r)=>{e({error:void 0});try{await L.steer(t,n,r)}catch(t){throw e({error:t instanceof N?t.code:t.message}),t}},abortSession:async t=>{e({error:void 0});try{await L.abort(t)}catch(t){e({error:t instanceof N?t.code:t.message})}},disposeSession:async n=>{e({error:void 0});try{t().closeStream(n);let r=Gr(t(),n);await L.disposeSession(n),e(e=>Kr(e,n)),t().activeSessionId===void 0&&localStorage.removeItem(Ir),r!==void 0&&(xr({type:`session_deleted`,projectId:r,sessionId:n}),t().loadSessionsForProject(r))}catch(t){e({error:t instanceof N?t.code:t.message})}}}));function Jr(e,t,n,r){if(r.type===`snapshot`){e(e=>({messagesBySession:{...e.messagesBySession,[n]:r.messages??[]},streamingBySession:{...e.streamingBySession,[n]:r.isStreaming??!1},bannerBySession:{...e.bannerBySession,[n]:void 0},activeToolBySession:{...e.activeToolBySession,[n]:void 0}}));return}if(r.type===`agent_start`){let t=Vr.get(n);t!==void 0&&cancelAnimationFrame(t),Vr.delete(n),Br.delete(n),e(e=>({streamingBySession:{...e.streamingBySession,[n]:!0},streamingTextBySession:{...e.streamingTextBySession,[n]:``},bannerBySession:{...e.bannerBySession,[n]:void 0}}));return}if(r.type===`agent_end`){let t=Vr.get(n);t!==void 0&&cancelAnimationFrame(t),Vr.delete(n),Br.delete(n);let i=r.errorMessage,a=typeof i==`string`&&i.length>0?`Agent error: ${i}`:void 0;L.getMessages(n).then(({messages:t})=>{e(e=>{let r=e.messagesBySession[n];r!==void 0&&Wr(r);let i=e.bannerBySession[n],o=a??i;return{messagesBySession:{...e.messagesBySession,[n]:t},streamingBySession:{...e.streamingBySession,[n]:!1},streamingTextBySession:{...e.streamingTextBySession,[n]:``},activeToolBySession:{...e.activeToolBySession,[n]:void 0},bannerBySession:{...e.bannerBySession,[n]:o},agentEndCountBySession:{...e.agentEndCountBySession,[n]:(e.agentEndCountBySession[n]??0)+1}}})}).catch(()=>{e(e=>({streamingBySession:{...e.streamingBySession,[n]:!1},activeToolBySession:{...e.activeToolBySession,[n]:void 0},bannerBySession:{...e.bannerBySession,[n]:a??`Couldn't refresh messages after the agent finished — reload to sync`},agentEndCountBySession:{...e.agentEndCountBySession,[n]:(e.agentEndCountBySession[n]??0)+1}}))});return}if(r.type===`queue_update`){let t=r,i=Array.isArray(t.steering)?t.steering.filter(e=>typeof e==`string`):[],a=Array.isArray(t.followUp)?t.followUp.filter(e=>typeof e==`string`):[];e(e=>({queuedBySession:{...e.queuedBySession,[n]:i.length===0&&a.length===0?void 0:{steering:i,followUp:a}}}));return}if(r.type===`tool_execution_start`){let t=typeof r.toolName==`string`?r.toolName:`tool`,i=Xr(t,r.input??{}),a=i===void 0?{name:t}:{name:t,summary:i};e(e=>({activeToolBySession:{...e.activeToolBySession,[n]:a}})),Yr(e,n);return}if(r.type===`tool_execution_end`){e(e=>({activeToolBySession:{...e.activeToolBySession,[n]:void 0}})),Yr(e,n);return}if(r.type===`session_list_changed`){let e=typeof r.projectId==`string`?r.projectId:void 0;e!==void 0&&t().loadSessionsForProject(e);return}if(r.type===`message_end`||r.type===`tool_result`){if(Yr(e,n),r.type===`message_end`){let t=r.message;if(t?.stopReason===`error`){let r=typeof t.errorMessage==`string`?t.errorMessage:``;r.length>0&&e(e=>({bannerBySession:{...e.bannerBySession,[n]:`Agent error: ${r}`}}))}if(t?.role===`assistant`){let t=Vr.get(n);t!==void 0&&cancelAnimationFrame(t),Vr.delete(n),Br.delete(n),e(e=>({streamingTextBySession:{...e.streamingTextBySession,[n]:``}}))}}return}if(r.type===`ask_user_question`){let e=typeof r.requestId==`string`?r.requestId:void 0,t=Array.isArray(r.questions)?r.questions:void 0;if(e===void 0||t===void 0)return;Cr.getState().setPending({requestId:e,sessionId:n,questions:t});return}if(r.type===`ask_user_question_cancelled`){let e=typeof r.requestId==`string`?r.requestId:void 0;Cr.getState().clearPending(n,e);return}if(r.type===`todo_update`){let e=Array.isArray(r.tasks)?r.tasks:[],t=typeof r.nextId==`number`?r.nextId:1;Tr.getState().set(n,{tasks:e,nextId:t});return}if(r.type===`process_update`){let e=Array.isArray(r.processes)?r.processes:[];Mr.getState().setProcesses(n,e);return}if(r.type===`process_watch`){let e=r.match;e!==void 0&&typeof e.processId==`string`&&typeof e.processName==`string`&&(e.source===`stdout`||e.source===`stderr`)&&typeof e.line==`string`&&typeof e.watch?.pattern==`string`&&Mr.getState().pushWatch(n,{processId:e.processId,processName:e.processName,source:e.source,line:e.line,pattern:e.watch.pattern,at:Date.now()});return}if(r.type!==`process_output`){if(r.type===`user_bash_result`){Yr(e,n);return}if(r.type===`message_update`){let t=r.assistantMessageEvent;if(typeof t==`object`&&t&&t.type===`text_delta`&&typeof t.delta==`string`){let r=t.delta;if(Br.set(n,(Br.get(n)??``)+r),!Vr.has(n)){let t=requestAnimationFrame(()=>{Vr.delete(n);let t=Br.get(n)??``;t.length!==0&&(Br.delete(n),e(e=>({streamingTextBySession:{...e.streamingTextBySession,[n]:(e.streamingTextBySession[n]??``)+t}})))});Vr.set(n,t)}}return}if(r.type===`compaction_start`){e(e=>({bannerBySession:{...e.bannerBySession,[n]:`Compacting context…`}}));return}if(r.type===`compaction_end`){let t=r.errorMessage,i=typeof t==`string`&&t.length>0?`Agent error: ${t}`:void 0;e(e=>({bannerBySession:{...e.bannerBySession,[n]:i},compactionEndCountBySession:{...e.compactionEndCountBySession,[n]:(e.compactionEndCountBySession[n]??0)+1}})),qr.getState().loadCompactions(n),Yr(e,n);return}if(r.type===`auto_retry_start`){let t=typeof r.attempt==`number`?r.attempt:`?`,i=typeof r.maxAttempts==`number`?r.maxAttempts:`?`;e(e=>({bannerBySession:{...e.bannerBySession,[n]:`Retrying (${t}/${i})…`}}));return}if(r.type===`auto_retry_end`){let t=r.success!==!1,i=r.finalError,a=!t&&typeof i==`string`&&i.length>0?`Agent error: ${i}`:void 0;e(e=>({bannerBySession:{...e.bannerBySession,[n]:a}}));return}}}function Yr(e,t){let n=Hr.get(t)??{inflight:!1,queued:!1};if(n.inflight){n.queued=!0,Hr.set(t,n);return}n.inflight=!0,Hr.set(t,n),L.getMessages(t).then(({messages:n})=>{e(e=>({messagesBySession:{...e.messagesBySession,[t]:n}}))}).catch(()=>{}).finally(()=>{let n=Hr.get(t);n!==void 0&&(n.queued?(n.queued=!1,n.inflight=!1,Hr.set(t,n),Yr(e,t)):Hr.delete(t))})}function Xr(e,t){let n=e=>{let n=t[e];return typeof n==`string`&&n.length>0?n:void 0};switch(e){case`bash`:return n(`command`);case`read`:case`write`:case`edit`:return n(`filePath`)??n(`path`)??n(`file`);case`grep`:return n(`pattern`);case`glob`:return n(`pattern`)??n(`path`);default:for(let e of[`path`,`file`,`filePath`,`command`,`pattern`,`query`,`url`]){let t=n(e);if(t!==void 0)return t}return}}globalThis.__piForgeSessionCrossTabRegistered||(globalThis.__piForgeSessionCrossTabCleanup=Sr(e=>{if(e.type===`session_created`){let t=e.session,n=typeof t.sessionId==`string`?t.sessionId:void 0;if(n===void 0)return;let r={sessionId:n,projectId:e.projectId,isLive:t.isLive===!0,workspacePath:typeof t.workspacePath==`string`?t.workspacePath:``,lastActivityAt:typeof t.lastActivityAt==`string`?t.lastActivityAt:new Date().toISOString(),createdAt:typeof t.createdAt==`string`?t.createdAt:new Date().toISOString(),messageCount:typeof t.messageCount==`number`?t.messageCount:0,firstMessage:typeof t.firstMessage==`string`?t.firstMessage:``};typeof t.name==`string`&&(r.name=t.name),qr.setState(t=>{let i=t.byProject[e.projectId]??[];return i.some(e=>e.sessionId===n)?{}:{byProject:{...t.byProject,[e.projectId]:[r,...i]}}});return}if(e.type===`session_deleted`){if(qr.setState(t=>Kr(t,e.sessionId)),qr.getState().activeSessionId===void 0)try{localStorage.removeItem(Ir)}catch{}qr.getState().loadSessionsForProject(e.projectId);return}if(e.type===`session_renamed`){qr.setState(t=>{let n={};for(let[r,i]of Object.entries(t.byProject))n[r]=i.map(t=>{if(t.sessionId!==e.sessionId)return t;let n={...t};return e.name===void 0?delete n.name:n.name=e.name,n});return{byProject:n}});return}}),globalThis.__piForgeSessionCrossTabRegistered=!0);var Zr=/^@@ -\d+(?:,\d+)? \+(\d+)(?:,(\d+))? @@/;function Qr(e){if(e.length===0)return[];let t=0,n=0,r=new Map,i=(e,t)=>{let n=r.get(e);n!==`modified`&&(n===`added`&&t===`deletedAbove`||r.set(e,t))},a=()=>{n!==0&&(i(t,`deletedAbove`),n=0)};for(let r of e.split(`
23
23
  `)){if(r.startsWith(`@@`)){a();let e=Zr.exec(r);if(e===null)continue;t=Number.parseInt(e[1]??`0`,10),n=0;continue}if(r.startsWith(`\\`)||t===0)continue;let e=r.charAt(0);e===` `?(a(),t+=1):e===`-`?n+=1:e===`+`&&(n>0?(i(t,`modified`),--n):i(t,`added`),t+=1)}return a(),Array.from(r.entries()).map(([e,t])=>({line:e,kind:t})).sort((e,t)=>e.line-t.line)}var $r=`forge.editor.tabs.v1:`;function ei(e){try{let t=sessionStorage.getItem($r+e);if(t===null)return{paths:[],activePath:null};let n=JSON.parse(t);if(typeof n!=`object`||!n)return{paths:[],activePath:null};let r=n,i=Array.isArray(r.paths)?r.paths.filter(e=>typeof e==`string`):[],a=typeof r.activePath==`string`?r.activePath:null;return{paths:i,activePath:i.includes(a??``)?a:i[0]??null}}catch{return{paths:[],activePath:null}}}function ti(e,t,n){try{sessionStorage.setItem($r+e,JSON.stringify({paths:t,activePath:n??null}))}catch{}}var ni;function ri(e,t){e!==void 0&&ti(e,t.openFiles.map(e=>e.path),t.activePath)}var ii=ft((e,t)=>({treeByProject:{},treeLoading:{},openFiles:[],activePath:void 0,error:void 0,externallyChanged:{},gitDiffByPath:{},loadGitDiff:async(t,n)=>{try{let r=Qr((await L.gitDiffFile(t,n,!1)).diff);e(e=>({gitDiffByPath:{...e.gitDiffByPath,[n]:r}}))}catch{e(e=>{if(!(n in e.gitDiffByPath))return{};let t={...e.gitDiffByPath};return delete t[n],{gitDiffByPath:t}})}},loadTree:async t=>{e(e=>({treeLoading:{...e.treeLoading,[t]:!0},error:void 0}));try{let n=await L.filesTree(t);e(e=>({treeByProject:{...e.treeByProject,[t]:n},treeLoading:{...e.treeLoading,[t]:!1}}))}catch(n){e(e=>({treeLoading:{...e.treeLoading,[t]:!1},error:n instanceof N?n.code:n.message}))}},restoreTabs:async n=>{if(ni===n&&t().openFiles.length>0)return;ni!==n&&e({openFiles:[],activePath:void 0,externallyChanged:{},gitDiffByPath:{}}),ni=n;let r=ei(n);if(r.paths.length!==0){for(let e of r.paths)try{await t().openFile(n,e)}catch{}r.activePath!==null&&t().setActiveFile(r.activePath)}},openFile:async(n,r,i)=>{if(ni=n,t().openFiles.find(e=>e.path===r)!==void 0){e(i===void 0?e=>(ri(ni,{openFiles:e.openFiles,activePath:r}),{activePath:r}):e=>{let t={openFiles:e.openFiles.map(e=>e.path===r?{...e,pendingNav:i}:e),activePath:r};return ri(ni,t),t});return}e({error:void 0});try{let a=await L.filesRead(n,r),o={tabId:ai(),path:r,saved:a.content,draft:a.content,dirty:!1,language:a.language,binary:a.binary,saving:!1,savedAt:void 0,saveError:void 0,loadingError:a.binary?`Binary file — open externally to edit.`:void 0};i!==void 0&&(o.pendingNav=i),e(e=>{let t={openFiles:[...e.openFiles,o],activePath:r};return ri(ni,t),t}),t().loadGitDiff(n,r)}catch(t){e({error:t instanceof N?t.code:t.message})}},closeFile:t=>{e(e=>{let n=e.openFiles.findIndex(e=>e.path===t);if(n===-1)return{};let r=e.openFiles.slice(0,n).concat(e.openFiles.slice(n+1)),i=e.activePath===t?(r[n]??r[n-1]??r[0])?.path:e.activePath,a={...e.externallyChanged};delete a[t];let o={...e.gitDiffByPath};delete o[t];let s={openFiles:r,activePath:i,externallyChanged:a,gitDiffByPath:o};return ri(ni,s),s})},closeAllFiles:()=>{e(()=>{let e={openFiles:[],activePath:void 0,externallyChanged:{},gitDiffByPath:{}};return ri(ni,e),e})},setActiveFile:t=>e(e=>(ri(ni,{openFiles:e.openFiles,activePath:t}),{activePath:t})),consumePendingNav:t=>{e(e=>({openFiles:e.openFiles.map(e=>{if(e.path!==t||e.pendingNav===void 0)return e;let n={...e};return delete n.pendingNav,n})}))},updateDraft:(t,n)=>{e(e=>({openFiles:e.openFiles.map(e=>e.path===t?{...e,draft:n,dirty:n!==e.saved}:e)}))},saveFile:async(n,r)=>{let i=t().openFiles.find(e=>e.path===r);if(!(i===void 0||i.binary)){e(e=>({openFiles:e.openFiles.map(e=>e.path===r?{...e,saving:!0,saveError:void 0}:e),error:void 0}));try{await L.filesWrite(n,r,i.draft),e(e=>({openFiles:e.openFiles.map(e=>e.path===r?{...e,saving:!1,saved:e.draft,dirty:!1,savedAt:Date.now(),saveError:void 0}:e),externallyChanged:oi(e.externallyChanged,r)})),t().loadGitDiff(n,r)}catch(t){let n=t instanceof N?t.code:t.message;throw e(e=>({openFiles:e.openFiles.map(e=>e.path===r?{...e,saving:!1,saveError:n}:e),error:n})),t}}},reloadFile:async(n,r)=>{e({error:void 0});try{let i=await L.filesRead(n,r);e(e=>({openFiles:e.openFiles.map(e=>e.path===r?{...e,saved:i.content,draft:i.content,dirty:!1,language:i.language,binary:i.binary,loadingError:i.binary?`Binary file — open externally to edit.`:void 0}:e),externallyChanged:oi(e.externallyChanged,r)})),t().loadGitDiff(n,r)}catch(t){e({error:t instanceof N?t.code:t.message})}},refreshOpenFiles:async n=>{let r=t().openFiles.map(e=>({path:e.path,saved:e.saved,dirty:e.dirty}));if(r.length===0)return;let i=await Promise.allSettled(r.map(e=>L.filesRead(n,e.path)));e(e=>{let t=e.openFiles,n=e.externallyChanged;for(let e=0;e<r.length;e++){let a=i[e],o=r[e];if(a===void 0||o===void 0||a.status!==`fulfilled`)continue;let s=a.value;s.content===o.saved&&!o.dirty||s.content!==o.saved&&(o.dirty?n={...n,[o.path]:!0}:(t=t.map(e=>e.path===o.path?{...e,saved:s.content,draft:s.content,dirty:!1,language:s.language,binary:s.binary,loadingError:s.binary?`Binary file — open externally to edit.`:void 0}:e),n=oi(n,o.path)))}return{openFiles:t,externallyChanged:n}}),await Promise.allSettled(r.map(e=>t().loadGitDiff(n,e.path)))},markExternallyChanged:t=>{e(e=>({externallyChanged:{...e.externallyChanged,[t]:!0}}))},dismissExternallyChanged:t=>{e(e=>({externallyChanged:oi(e.externallyChanged,t)}))},createFile:async(n,r,i)=>{e({error:void 0});try{let e=`${r}/${i}`;return await L.filesWrite(n,e,``),await t().loadTree(n),e}catch(t){throw e({error:t instanceof N?t.code:t.message}),t}},createFolder:async(n,r,i)=>{e({error:void 0});try{await L.filesMkdir(n,r,i),await t().loadTree(n)}catch(t){throw e({error:t instanceof N?t.code:t.message}),t}},renameEntry:async(n,r,i)=>{e({error:void 0});try{let{path:a}=await L.filesRename(n,r,i);return e(e=>({openFiles:e.openFiles.map(e=>e.path===r?{...e,path:a}:e),activePath:e.activePath===r?a:e.activePath})),await t().loadTree(n),a}catch(t){throw e({error:t instanceof N?t.code:t.message}),t}},moveEntry:async(n,r,i)=>{e({error:void 0});try{let{path:a}=await L.filesMove(n,r,i);return e(e=>({openFiles:e.openFiles.map(e=>{if(e.path===r)return{...e,path:a};let t=`${r}/`;return e.path.startsWith(t)?{...e,path:`${a}/${e.path.slice(t.length)}`}:e}),activePath:e.activePath===r?a:e.activePath!==void 0&&e.activePath.startsWith(`${r}/`)?`${a}/${e.activePath.slice(r.length+1)}`:e.activePath})),await t().loadTree(n),a}catch(t){throw e({error:t instanceof N?t.code:t.message}),t}},deleteEntry:async(n,r,i)=>{e({error:void 0});try{await L.filesDelete(n,r,i?.recursive===!0?{recursive:!0}:void 0),t().openFiles.find(e=>e.path===r)!==void 0&&t().closeFile(r),await t().loadTree(n)}catch(t){throw e({error:t instanceof N?t.code:t.message}),t}},uploadFiles:async(n,r,i,a)=>{e({error:void 0});try{let e=await L.uploadFiles(n,r,i,{...a?.overwrite===void 0?{}:{overwrite:a.overwrite},...a?.onHashProgress===void 0?{}:{onHashProgress:a.onHashProgress}});return await t().loadTree(n),e.files}catch(t){throw e({error:t instanceof N?t.code:t.message}),t}}}));function ai(){return typeof crypto<`u`&&typeof crypto.randomUUID==`function`?crypto.randomUUID():`tab-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}function oi(e,t){if(e[t]===void 0)return e;let n={...e};return delete n[t],n}var si=ft(e=>({loaded:!1,minimal:!1,workspaceRoot:``,version:``,passwordAuthEnabled:!0,orchestrationEnabled:!1,error:void 0,load:async()=>{try{let t=await L.uiConfig();e({loaded:!0,minimal:t.minimal,workspaceRoot:t.workspaceRoot,version:t.version,passwordAuthEnabled:t.passwordAuthEnabled,orchestrationEnabled:t.orchestrationEnabled,error:void 0})}catch(t){let n=t instanceof N?t.code:t.message;typeof console<`u`&&console.warn(`[ui-config] load failed:`,n),e({loaded:!0,error:n})}}})),ci=ft((e,t)=>({loaded:!1,actions:[],error:void 0,load:async()=>{try{let{actions:t}=await L.listQuickActions();e({loaded:!0,actions:t,error:void 0})}catch(t){let n=t instanceof N?t.code:t.message;typeof console<`u`&&console.warn(`[quick-actions] load failed:`,n),e({error:n})}},create:async n=>{let r=await L.createQuickAction(n);return e({actions:[...t().actions,r]}),r},update:async(n,r)=>{let i=await L.updateQuickAction(n,r);return e({actions:t().actions.map(e=>e.id===n?i:e)}),i},remove:async n=>{await L.deleteQuickAction(n),e({actions:t().actions.filter(e=>e.id!==n)})}})),li=ft((e,t)=>({runs:[],addRun:n=>e({runs:[...t().runs,n]}),updateRun:(n,r)=>e({runs:t().runs.map(e=>e.runId===n?{...e,...r}:e)}),removeRun:n=>e({runs:t().runs.filter(e=>e.runId!==n)}),runsForSession:e=>t().runs.filter(t=>t.sessionId===e)})),ui=o((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),di=o(((e,t)=>{t.exports=ui()})),R=di();function fi(){let[e,t]=(0,v.useState)(``),n=ir(e=>e.login),r=ir(e=>e.loginPending),i=ir(e=>e.loginError);return(0,R.jsx)(`main`,{className:`flex min-h-screen items-center justify-center px-4`,children:(0,R.jsxs)(`form`,{onSubmit:t=>{t.preventDefault(),e.length!==0&&n(e)},className:`w-full max-w-sm space-y-4 rounded-lg border border-neutral-800 bg-neutral-900 p-6 shadow-lg`,children:[(0,R.jsxs)(`header`,{className:`space-y-1`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(`img`,{src:`/icons/icon.svg`,alt:``,className:`h-6 w-6`,"aria-hidden":`true`}),(0,R.jsx)(`h1`,{className:`text-xl font-semibold tracking-tight`,children:`pi-forge`})]}),(0,R.jsx)(`p`,{className:`text-sm text-neutral-400`,children:`Enter the pi-forge password to continue.`})]}),(0,R.jsxs)(`label`,{className:`block space-y-1.5`,children:[(0,R.jsx)(`span`,{className:`text-sm font-medium text-neutral-300`,children:`Password`}),(0,R.jsx)(`input`,{type:`password`,value:e,onChange:e=>t(e.target.value),autoFocus:!0,autoComplete:`current-password`,className:`w-full rounded-md border border-neutral-700 bg-neutral-950 px-3 py-2 text-sm outline-none focus:border-neutral-500`})]}),i!==void 0&&(0,R.jsx)(`p`,{role:`alert`,className:`text-sm text-red-400`,children:i===`invalid_password`?`Incorrect password.`:`Login failed: ${i}`}),(0,R.jsx)(`button`,{type:`submit`,disabled:r||e.length===0,className:`w-full rounded-md bg-neutral-100 px-3 py-2 text-sm font-medium text-neutral-900 transition hover:bg-white disabled:cursor-not-allowed disabled:opacity-50`,children:r?`Signing in…`:`Sign in`})]})})}var pi=8;function mi(){let[e,t]=(0,v.useState)(``),[n,r]=(0,v.useState)(``),[i,a]=(0,v.useState)(``),[o,s]=(0,v.useState)(void 0),c=ir(e=>e.changePassword),l=ir(e=>e.changePasswordPending),u=ir(e=>e.changePasswordError),d=ir(e=>e.logout),f=t=>{if(t.preventDefault(),s(void 0),n.length<pi){s(`new password must be at least ${pi} characters`);return}if(n!==i){s(`new password and confirmation do not match`);return}if(n===e){s(`new password must differ from the current one`);return}c(e,n)},p=o??hi(u);return(0,R.jsx)(`main`,{className:`flex min-h-screen items-center justify-center px-4`,children:(0,R.jsxs)(`form`,{onSubmit:f,className:`w-full max-w-sm space-y-4 rounded-lg border border-neutral-800 bg-neutral-900 p-6 shadow-lg`,children:[(0,R.jsxs)(`header`,{className:`space-y-1`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(`img`,{src:`/icons/icon.svg`,alt:``,className:`h-6 w-6`,"aria-hidden":`true`}),(0,R.jsx)(`h1`,{className:`text-xl font-semibold tracking-tight`,children:`Set a new password`})]}),(0,R.jsx)(`p`,{className:`text-sm text-neutral-400`,children:`You signed in with the deployment-supplied initial password. Pick a new one before continuing — it will be stored as a hash on the pi-forge data volume.`})]}),(0,R.jsxs)(`label`,{className:`block space-y-1.5`,children:[(0,R.jsx)(`span`,{className:`text-sm font-medium text-neutral-300`,children:`Current password`}),(0,R.jsx)(`input`,{type:`password`,value:e,onChange:e=>t(e.target.value),autoFocus:!0,autoComplete:`current-password`,className:`w-full rounded-md border border-neutral-700 bg-neutral-950 px-3 py-2 text-sm outline-none focus:border-neutral-500`})]}),(0,R.jsxs)(`label`,{className:`block space-y-1.5`,children:[(0,R.jsx)(`span`,{className:`text-sm font-medium text-neutral-300`,children:`New password`}),(0,R.jsx)(`input`,{type:`password`,value:n,onChange:e=>r(e.target.value),autoComplete:`new-password`,minLength:pi,className:`w-full rounded-md border border-neutral-700 bg-neutral-950 px-3 py-2 text-sm outline-none focus:border-neutral-500`})]}),(0,R.jsxs)(`label`,{className:`block space-y-1.5`,children:[(0,R.jsx)(`span`,{className:`text-sm font-medium text-neutral-300`,children:`Confirm new password`}),(0,R.jsx)(`input`,{type:`password`,value:i,onChange:e=>a(e.target.value),autoComplete:`new-password`,minLength:pi,className:`w-full rounded-md border border-neutral-700 bg-neutral-950 px-3 py-2 text-sm outline-none focus:border-neutral-500`})]}),p!==void 0&&(0,R.jsx)(`p`,{role:`alert`,className:`text-sm text-red-400 light:text-red-700`,children:p}),(0,R.jsx)(`button`,{type:`submit`,disabled:l||e.length===0||n.length===0,className:`w-full rounded-md bg-neutral-100 px-3 py-2 text-sm font-medium text-neutral-900 transition hover:bg-white disabled:cursor-not-allowed disabled:opacity-50`,children:l?`Saving…`:`Set new password`}),(0,R.jsx)(`button`,{type:`button`,onClick:d,className:`w-full rounded-md border border-neutral-700 px-3 py-2 text-xs text-neutral-400 hover:border-neutral-500 hover:text-neutral-200`,children:`Sign out`})]})})}function hi(e){if(e!==void 0)switch(e){case`invalid_password`:return`Current password is incorrect.`;case`password_unchanged`:return`New password must differ from the current one.`;case`ui_password_not_configured`:return`Password auth is not configured on this server.`;case`auth_required`:return`Session expired — sign in again.`;default:return`Could not change password: ${e}`}}var gi=`pi-forge/install-prompt-dismissed`;function _i(){return typeof window>`u`?!1:window.navigator.standalone===!0?!0:window.matchMedia?.(`(display-mode: standalone)`).matches??!1}function vi(){return typeof navigator>`u`?!1:/iphone|ipad|ipod/i.test(navigator.userAgent)}function yi(){let e=ot(),[t,n]=(0,v.useState)(void 0),[r,i]=(0,v.useState)(()=>typeof localStorage>`u`?!1:localStorage.getItem(gi)===`true`),[a,o]=(0,v.useState)(!1);(0,v.useEffect)(()=>{if(typeof window>`u`||_i()||r)return;let t=e=>{e.preventDefault(),n(e)};if(window.addEventListener(`beforeinstallprompt`,t),vi()&&e){let e=window.setTimeout(()=>o(!0),1500);return()=>{window.clearTimeout(e),window.removeEventListener(`beforeinstallprompt`,t)}}return()=>window.removeEventListener(`beforeinstallprompt`,t)},[e,r]);let s=()=>{i(!0),n(void 0),o(!1);try{localStorage.setItem(gi,`true`)}catch{}},c=async()=>{if(t===void 0)return;await t.prompt();let e=await t.userChoice;n(void 0),e.outcome===`accepted`&&s()};return!e||r||_i()||t===void 0&&!a?null:(0,R.jsx)(`div`,{className:`border-b border-neutral-800 bg-neutral-900 px-3 py-2 text-sm text-neutral-200`,children:(0,R.jsxs)(`div`,{className:`mx-auto flex max-w-3xl items-center gap-2`,children:[(0,R.jsx)(`div`,{className:`min-w-0 flex-1`,children:t===void 0?(0,R.jsxs)(`span`,{className:`inline-flex flex-wrap items-center gap-1`,children:[`Install: tap `,(0,R.jsx)(Je,{size:14,className:`inline shrink-0 text-neutral-400`}),` Share, then `,(0,R.jsx)(`span`,{className:`font-medium`,children:`Add to Home Screen`}),`.`]}):(0,R.jsx)(`span`,{children:`Install pi-forge as an app for a fullscreen experience.`})}),t!==void 0&&(0,R.jsx)(`button`,{type:`button`,onClick:()=>void c(),className:`shrink-0 rounded-md bg-neutral-100 px-3 py-1.5 text-xs font-medium text-neutral-900 hover:bg-neutral-200`,children:`Install`}),(0,R.jsx)(`button`,{type:`button`,onClick:s,"aria-label":`Dismiss install prompt`,className:`inline-flex min-h-9 min-w-9 shrink-0 items-center justify-center rounded text-neutral-500 hover:bg-neutral-800 hover:text-neutral-200`,children:(0,R.jsx)(rt,{size:16})})]})})}function bi({onClose:e,required:t=!1}){let n=lr(e=>e.create),r=si(e=>e.minimal),i=si(e=>e.workspaceRoot),a=lr(e=>e.load),o=lr(e=>e.setActive),[s,c]=(0,v.useState)(`create`),[l,u]=(0,v.useState)(`name`),[d,f]=(0,v.useState)(``),[p,m]=(0,v.useState)(!1),[h,g]=(0,v.useState)(),[_,y]=(0,v.useState)(),[b,x]=(0,v.useState)(null),[S,C]=(0,v.useState)([]),[w,T]=(0,v.useState)(!1),[E,D]=(0,v.useState)(``),[O,k]=(0,v.useState)(!1);(0,v.useEffect)(()=>{if(s!==`create`||l!==`browse`)return;let e=!1;return T(!0),g(void 0),L.browse(_).then(t=>{e||(y(t.path),x(t.parentPath),C(t.entries))}).catch(t=>{e||g(t instanceof N?t.code:t.message)}).finally(()=>{e||T(!1)}),()=>{e=!0}},[s,l,_]);let ee=async()=>{let t=d.trim();if(t.length!==0){if(!r){u(`browse`);return}if(i.length===0){g(`workspace_not_loaded`);return}m(!0),g(void 0);try{let{path:r}=await L.mkdir(i,t);await n(t,r),e()}catch(e){g(e instanceof N?e.code:e.message),m(!1)}}},A=async t=>{if(!p){if(i.length>0&&t===i){g(`workspace_root_not_allowed`);return}m(!0),g(void 0);try{await n(d.trim(),t),e()}catch(e){g(e instanceof N?e.code:e.message),m(!1)}}},te=()=>{b!==null&&y(b)},ne=async()=>{if(!(!_||E.trim().length===0)){g(void 0);try{let{path:e}=await L.mkdir(_,E.trim());D(``),k(!1),await A(e)}catch(e){g(e instanceof N?e.code:e.message)}}};return(0,R.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60 px-4`,children:(0,R.jsxs)(`div`,{className:`w-full max-w-lg rounded-lg border border-neutral-800 bg-neutral-900 p-6 shadow-xl`,children:[(0,R.jsxs)(`header`,{className:`mb-4 flex items-center justify-between`,children:[(0,R.jsx)(`h2`,{className:`text-lg font-semibold tracking-tight`,children:s===`clone`?`Clone repository`:l===`name`?`New project`:`Pick a folder for "${d.trim()}"`}),!t&&(0,R.jsx)(`button`,{onClick:e,className:`rounded-md px-2 py-1 text-sm text-neutral-400 hover:bg-neutral-800`,children:`Cancel`})]}),l===`name`&&(0,R.jsxs)(`div`,{className:`mb-3 flex gap-1 border-b border-neutral-800`,children:[(0,R.jsx)(xi,{active:s===`create`,onClick:()=>c(`create`),children:`Create / pick folder`}),(0,R.jsx)(xi,{active:s===`clone`,onClick:()=>c(`clone`),children:`Clone repository`})]}),l===`name`&&s===`create`&&(0,R.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),ee()},className:`space-y-4`,children:[(0,R.jsxs)(`label`,{className:`block space-y-1.5`,children:[(0,R.jsx)(`span`,{className:`text-sm font-medium text-neutral-300`,children:`Project name`}),(0,R.jsx)(`input`,{value:d,onChange:e=>f(e.target.value),autoFocus:!0,className:`w-full rounded-md border border-neutral-700 bg-neutral-950 px-3 py-2 text-sm outline-none focus:border-neutral-500`}),r&&i.length>0&&(0,R.jsxs)(`span`,{className:`block font-mono text-[11px] text-neutral-500`,children:[`Will create `,i,`/`,d.trim().length>0?d.trim():`<name>`]})]}),h!==void 0&&(0,R.jsxs)(`p`,{className:`text-xs text-red-400 light:text-red-700`,children:[`Error: `,h]}),(0,R.jsx)(`button`,{type:`submit`,disabled:d.trim().length===0||p,className:`w-full rounded-md bg-neutral-100 px-3 py-2 text-sm font-medium text-neutral-900 disabled:opacity-50`,children:r?p?`Creating…`:`Create project`:`Next: pick folder`})]}),l===`name`&&s===`clone`&&(0,R.jsx)(Si,{initialName:d,workspaceRoot:i,onProjectCreated:async t=>{await a(),o(t),e()},onCancel:e}),s===`create`&&l===`browse`&&(0,R.jsxs)(`div`,{className:`space-y-3`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-neutral-400`,children:[(0,R.jsx)(`button`,{onClick:te,disabled:b===null,className:`rounded-md border border-neutral-700 px-2 py-1 hover:bg-neutral-800 disabled:cursor-not-allowed disabled:opacity-40`,title:b===null?`At workspace root`:`Up one folder`,children:`↑ up`}),(0,R.jsx)(`code`,{className:`truncate font-mono text-neutral-300`,children:_??`(loading)`})]}),(0,R.jsxs)(`div`,{className:`max-h-64 overflow-y-auto rounded-md border border-neutral-800 bg-neutral-950`,children:[w&&(0,R.jsx)(`div`,{className:`px-3 py-2 text-sm text-neutral-400`,children:`Loading…`}),!w&&S.length===0&&(0,R.jsx)(`div`,{className:`px-3 py-2 text-sm text-neutral-400`,children:`(empty)`}),!w&&S.map(e=>(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-b border-neutral-800 px-3 py-2 text-sm last:border-b-0`,children:[(0,R.jsxs)(`button`,{onClick:()=>y(e.path),className:`flex flex-1 items-center gap-2 text-left text-neutral-200 hover:text-white`,children:[(0,R.jsx)(`span`,{children:`📁`}),(0,R.jsx)(`span`,{className:`truncate`,children:e.name}),e.isGitRepo&&(0,R.jsx)(`span`,{className:`rounded-sm bg-neutral-800 px-1.5 py-0.5 text-[10px] uppercase tracking-wider text-neutral-300`,children:`git`})]}),(0,R.jsx)(`button`,{onClick:()=>void A(e.path),disabled:p,className:`rounded-md border border-neutral-700 px-2 py-1 text-xs text-neutral-200 hover:bg-neutral-800 disabled:opacity-50`,children:`Select`})]},e.path))]}),O?(0,R.jsxs)(`div`,{className:`flex gap-2`,children:[(0,R.jsx)(`input`,{value:E,onChange:e=>D(e.target.value),placeholder:`folder name`,className:`flex-1 rounded-md border border-neutral-700 bg-neutral-950 px-3 py-2 text-sm`,autoFocus:!0}),(0,R.jsx)(`button`,{onClick:()=>void ne(),className:`rounded-md bg-neutral-100 px-3 py-2 text-sm font-medium text-neutral-900`,children:`Create + select`}),(0,R.jsx)(`button`,{onClick:()=>{k(!1),D(``)},className:`rounded-md border border-neutral-700 px-3 py-2 text-sm text-neutral-300`,children:`Cancel`})]}):(0,R.jsxs)(`div`,{className:`flex justify-between gap-2`,children:[(0,R.jsx)(`button`,{onClick:()=>u(`name`),className:`rounded-md border border-neutral-700 px-3 py-2 text-sm text-neutral-300`,children:`← Back`}),(0,R.jsxs)(`div`,{className:`flex gap-2`,children:[(0,R.jsx)(`button`,{onClick:()=>k(!0),className:`rounded-md border border-neutral-700 px-3 py-2 text-sm text-neutral-300`,children:`+ New folder`}),(0,R.jsx)(`button`,{onClick:()=>_&&void A(_),disabled:!_||p||i.length>0&&_===i,className:`rounded-md bg-neutral-100 px-3 py-2 text-sm font-medium text-neutral-900 disabled:opacity-50`,title:i.length>0&&_===i?`Pick a sub-folder — the workspace root itself can't be a project.`:`Use this folder as the project root`,children:`Select this folder`})]})]})]}),h!==void 0&&(0,R.jsx)(`p`,{className:`mt-3 text-sm text-red-400 light:text-red-700`,children:h===`path_not_allowed`?`That folder is outside the workspace root.`:h===`workspace_root_not_allowed`?`Pick a sub-folder — the workspace root itself can't be a project.`:h===`not_a_directory`?`That path is not a directory.`:h===`already_exists`?`A folder with that name already exists.`:h===`duplicate_path`?`Another project already points at that folder.`:h===`network_error`?`Couldn't reach the server.`:`Error: ${h}`})]})})}function xi({active:e,onClick:t,children:n}){return(0,R.jsx)(`button`,{onClick:t,className:`-mb-px border-b-2 px-3 py-2 text-sm transition-colors ${e?`border-neutral-200 text-neutral-100`:`border-transparent text-neutral-400 hover:text-neutral-200`}`,children:n})}function Si({initialName:e,workspaceRoot:t,onProjectCreated:n,onCancel:r}){let[i,a]=(0,v.useState)(``),[o,s]=(0,v.useState)(``),[c,l]=(0,v.useState)(``),[u,d]=(0,v.useState)(``),[f,p]=(0,v.useState)(e),[m,h]=(0,v.useState)(!1),[g,_]=(0,v.useState)(!1),[y,b]=(0,v.useState)(!1),[x,S]=(0,v.useState)(!1),[C,w]=(0,v.useState)(),[T,E]=(0,v.useState)(),[D,O]=(0,v.useState)(null),[k,ee]=(0,v.useState)([]),[A,te]=(0,v.useState)(!1),ne=(0,v.useRef)(void 0);(0,v.useEffect)(()=>{if(!g)try{let e=new URL(i).pathname.split(`/`).filter(e=>e.length>0),t=(e[e.length-1]??``).replace(/\.git$/i,``);t.length>0&&d(t)}catch{}},[i,g]),(0,v.useEffect)(()=>{y||e.trim().length>0||u.length>0&&p(u)},[u,e,y]);let re=async e=>{if(e.preventDefault(),x)return;if(i.trim().length===0){w(`url_required`);return}if(u.trim().length===0){w(`folder_required`);return}if(f.trim().length===0){w(`name_required`);return}if(t.length===0){w(`workspace_not_loaded`);return}S(!0),w(void 0),E(`starting…`),O(null),ee([]);let r=new AbortController;ne.current=r;try{let e={url:i.trim(),parentPath:t,folderName:u.trim(),projectName:f.trim()};o.trim().length>0&&(e.branch=o.trim()),c.length>0&&(e.token=c),m&&(e.insecureTls=!0);let a=await L.cloneProject(e,r.signal),s,l=!1,d=``;for await(let e of rr(a))switch(e.type){case`started`:E(`starting clone`),ee(t=>[...t,`→ cloning ${e.cloneUrlForDisplay}`]);break;case`progress`:E(e.phase),O(e.percent);break;case`stderr`:ee(t=>{let n=[...t,e.line];return n.length>200?n.slice(n.length-200):n});break;case`done`:E(`clone complete, creating project…`),O(100);break;case`project_created`:s=e.project.id;break;case`error`:l=!0,d=e.message;break}if(s!==void 0){await n(s);return}w(l?d:`clone_ended_without_project`)}catch(e){e instanceof Error&&e.name===`AbortError`?w(`cancelled`):w(e instanceof N?`${e.code}: ${e.message??``}`:e.message)}finally{S(!1),ne.current=void 0}};return(0,R.jsxs)(`form`,{onSubmit:e=>{re(e)},className:`space-y-3`,children:[(0,R.jsxs)(`label`,{className:`block space-y-1`,children:[(0,R.jsx)(`span`,{className:`text-sm font-medium text-neutral-300`,children:`Repository URL`}),(0,R.jsx)(`input`,{value:i,onChange:e=>a(e.target.value),placeholder:`https://github.com/owner/repo.git`,disabled:x,autoFocus:!0,className:`w-full rounded-md border border-neutral-700 bg-neutral-950 px-3 py-2 font-mono text-xs outline-none focus:border-neutral-500 disabled:opacity-60`})]}),(0,R.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,R.jsxs)(`label`,{className:`block space-y-1`,children:[(0,R.jsx)(`span`,{className:`text-sm font-medium text-neutral-300`,children:`Branch (optional)`}),(0,R.jsx)(`input`,{value:o,onChange:e=>s(e.target.value),placeholder:`default branch`,disabled:x,className:`w-full rounded-md border border-neutral-700 bg-neutral-950 px-3 py-2 font-mono text-xs outline-none focus:border-neutral-500 disabled:opacity-60`})]}),(0,R.jsxs)(`label`,{className:`block space-y-1`,children:[(0,R.jsx)(`span`,{className:`text-sm font-medium text-neutral-300`,children:`Folder name`}),(0,R.jsx)(`input`,{value:u,onChange:e=>{d(e.target.value),_(!0)},placeholder:`auto from URL`,disabled:x,className:`w-full rounded-md border border-neutral-700 bg-neutral-950 px-3 py-2 font-mono text-xs outline-none focus:border-neutral-500 disabled:opacity-60`})]})]}),(0,R.jsxs)(`label`,{className:`block space-y-1`,children:[(0,R.jsx)(`span`,{className:`text-sm font-medium text-neutral-300`,children:`Project name`}),(0,R.jsx)(`input`,{value:f,onChange:e=>{p(e.target.value),b(!0)},placeholder:`auto from folder`,disabled:x,className:`w-full rounded-md border border-neutral-700 bg-neutral-950 px-3 py-2 text-sm outline-none focus:border-neutral-500 disabled:opacity-60`}),t.length>0&&u.length>0&&(0,R.jsxs)(`span`,{className:`block font-mono text-[11px] text-neutral-500`,children:[`Will clone into `,t,`/`,u]})]}),(0,R.jsxs)(`label`,{className:`block space-y-1`,children:[(0,R.jsx)(`span`,{className:`text-sm font-medium text-neutral-300`,children:`Access token (optional, for private repos)`}),(0,R.jsx)(`input`,{type:`password`,value:c,onChange:e=>l(e.target.value),placeholder:`ghp_... / glpat_... / etc.`,disabled:x,className:`w-full rounded-md border border-neutral-700 bg-neutral-950 px-3 py-2 font-mono text-xs outline-none focus:border-neutral-500 disabled:opacity-60`}),(0,R.jsxs)(`span`,{className:`block text-[11px] text-neutral-500`,children:[`Sent over HTTPS, embedded as `,(0,R.jsx)(`code`,{children:`x-access-token:<token>`}),` in the clone URL, and stripped from `,(0,R.jsx)(`code`,{children:`.git/config`}),` after success.`]})]}),(0,R.jsxs)(`label`,{className:`flex items-start gap-2 rounded border border-amber-900/40 bg-amber-950/30 px-2 py-1.5 text-xs light:border-amber-300 light:bg-amber-50`,children:[(0,R.jsx)(`input`,{type:`checkbox`,checked:m,onChange:e=>h(e.target.checked),disabled:x,className:`mt-0.5`}),(0,R.jsxs)(`span`,{children:[(0,R.jsx)(`span`,{className:`text-amber-200 light:text-amber-800`,children:`Allow self-signed / invalid TLS certificate`}),(0,R.jsx)(`br`,{}),(0,R.jsxs)(`span`,{className:`text-[11px] text-amber-300/70 light:text-amber-700/80`,children:[`⚠ Disables MITM protection for this clone. Use only for internal Git hosts with known self-signed certs (corporate GHE, on-prem GitLab with a private CA). The server logs`,` `,(0,R.jsx)(`code`,{children:`git-clone-insecure-tls`}),` to stderr on every use.`]})]})]}),(x||T!==void 0)&&(0,R.jsxs)(`div`,{className:`space-y-1 rounded-md border border-neutral-800 bg-neutral-950 p-2`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between text-xs`,children:[(0,R.jsx)(`span`,{className:`text-neutral-300`,children:T??`starting…`}),(0,R.jsx)(`span`,{className:`font-mono text-neutral-500`,children:D===null?``:`${D}%`})]}),D!==null&&(0,R.jsx)(`div`,{className:`h-1 w-full overflow-hidden rounded bg-neutral-800`,children:(0,R.jsx)(`div`,{className:`h-full bg-emerald-500 transition-all`,style:{width:`${Math.max(2,Math.min(100,D))}%`}})}),k.length>0&&(0,R.jsxs)(`details`,{open:A,onToggle:e=>te(e.target.open),className:`pt-1`,children:[(0,R.jsxs)(`summary`,{className:`cursor-pointer text-[10px] uppercase tracking-wider text-neutral-500 hover:text-neutral-300`,children:[`Raw output (`,k.length,`)`]}),(0,R.jsx)(`pre`,{className:`mt-1 max-h-32 overflow-auto whitespace-pre-wrap break-words font-mono text-[10px] leading-snug text-neutral-400`,children:k.join(`
24
24
  `)})]})]}),C!==void 0&&(0,R.jsxs)(`p`,{className:`text-xs text-red-400 light:text-red-700`,children:[`Error: `,C]}),(0,R.jsxs)(`div`,{className:`flex justify-end gap-2 pt-1`,children:[(0,R.jsx)(`button`,{type:`button`,onClick:()=>{ne.current===void 0?r():ne.current.abort()},className:`rounded-md border border-neutral-700 px-3 py-2 text-sm text-neutral-300`,children:x?`Cancel clone`:`Cancel`}),(0,R.jsx)(`button`,{type:`submit`,disabled:x||i.trim().length===0||f.trim().length===0||t.length===0,className:`rounded-md bg-neutral-100 px-3 py-2 text-sm font-medium text-neutral-900 disabled:opacity-50`,children:x?`Cloning…`:`Clone + create project`})]})]})}function Ci({open:e,onClose:t,title:n,children:r,width:i=`max-w-sm`,initialFocusRef:a}){let o=(0,v.useRef)(null),s=(0,v.useId)(),c=(0,v.useRef)(t),l=(0,v.useRef)(a);return(0,v.useEffect)(()=>{c.current=t}),(0,v.useEffect)(()=>{l.current=a}),(0,v.useEffect)(()=>{if(!e)return;let t=document.activeElement,n=o.current,r=e=>{if(e.key===`Escape`){e.preventDefault(),c.current();return}if(e.key===`Tab`&&o.current!==null){let t=o.current.querySelectorAll(`a[href], button:not([disabled]), input:not([disabled]), textarea:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"])`);if(t.length===0)return;let n=t[0],r=t[t.length-1];e.shiftKey&&document.activeElement===n?(e.preventDefault(),r.focus()):!e.shiftKey&&document.activeElement===r&&(e.preventDefault(),n.focus())}};document.addEventListener(`keydown`,r);let i=window.setTimeout(()=>{let e=l.current?.current;if(e!=null){e.focus();return}(o.current?.querySelector(`a[href], button:not([disabled]), input:not([disabled]), textarea:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"])`))?.focus()},0);return()=>{document.removeEventListener(`keydown`,r),window.clearTimeout(i),t!==null&&document.contains(t)&&n!==null&&n.contains(document.activeElement)&&t.focus()}},[e]),e?(0,R.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60 p-4`,onClick:t,role:`dialog`,"aria-modal":`true`,"aria-labelledby":s,children:(0,R.jsxs)(`div`,{ref:o,className:`w-full ${i} rounded-lg border border-neutral-800 bg-neutral-900 shadow-xl`,onClick:e=>e.stopPropagation(),children:[(0,R.jsxs)(`header`,{className:`flex items-center justify-between border-b border-neutral-800 px-4 py-2`,children:[(0,R.jsx)(`h2`,{id:s,className:`text-sm font-medium text-neutral-100`,children:n}),(0,R.jsx)(`button`,{onClick:t,className:`rounded p-2 text-neutral-500 hover:bg-neutral-800 hover:text-neutral-200`,title:`Close (Esc)`,"aria-label":`Close`,children:(0,R.jsx)(rt,{size:20})})]}),r]})}):null}function wi({open:e,onClose:t,onSubmit:n,title:r,label:i,initialValue:a=``,placeholder:o,primaryLabel:s=`OK`}){let[c,l]=(0,v.useState)(a),u=(0,v.useRef)(null);(0,v.useEffect)(()=>{e&&l(a)},[e,a]);let d=c.trim(),f=()=>{d.length!==0&&n(d)};return(0,R.jsx)(Ci,{open:e,onClose:t,title:r,initialFocusRef:u,children:(0,R.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),f()},className:`flex flex-col gap-3 px-4 py-3`,children:[(0,R.jsxs)(`label`,{className:`block space-y-1.5`,children:[(0,R.jsx)(`span`,{className:`text-xs text-neutral-300`,children:i}),(0,R.jsx)(`input`,{ref:u,type:`text`,value:c,onChange:e=>l(e.target.value),placeholder:o,className:`w-full rounded-md border border-neutral-700 bg-neutral-950 px-3 py-1.5 text-sm text-neutral-100 outline-none focus:border-neutral-500`})]}),(0,R.jsxs)(`footer`,{className:`flex justify-end gap-2 pt-1`,children:[(0,R.jsx)(`button`,{type:`button`,onClick:t,className:`rounded-md border border-neutral-700 px-3 py-1 text-xs text-neutral-200 hover:bg-neutral-800`,children:`Cancel`}),(0,R.jsx)(`button`,{type:`submit`,disabled:d.length===0,className:`rounded-md bg-neutral-100 px-3 py-1 text-xs font-medium text-neutral-900 hover:bg-white disabled:cursor-not-allowed disabled:opacity-40`,children:s})]})]})})}function Ti({open:e,onClose:t,onConfirm:n,title:r,message:i,primaryLabel:a=`Confirm`,tone:o=`default`}){return(0,R.jsx)(Ci,{open:e,onClose:t,title:r,children:(0,R.jsxs)(`div`,{className:`flex flex-col gap-3 px-4 py-3`,children:[(0,R.jsx)(`p`,{className:`text-xs text-neutral-300`,children:i}),(0,R.jsxs)(`footer`,{className:`flex justify-end gap-2 pt-1`,children:[(0,R.jsx)(`button`,{type:`button`,onClick:t,className:`rounded-md border border-neutral-700 px-3 py-1 text-xs text-neutral-200 hover:bg-neutral-800`,children:`Cancel`}),(0,R.jsx)(`button`,{type:`button`,onClick:n,className:o===`danger`?`rounded-md bg-red-700 px-3 py-1 text-xs font-medium text-red-50 hover:bg-red-600`:`rounded-md bg-neutral-100 px-3 py-1 text-xs font-medium text-neutral-900 hover:bg-white`,children:a})]})]})})}function Ei({projectId:e}){let t=qr(t=>t.byProject[e]??Lr),n=qr(e=>e.activeSessionId),r=qr(e=>e.loadSessionsForProject),i=qr(e=>e.setActiveSession),a=qr(e=>e.disposeSession),o=qr(e=>e.renameSession),s=lr(e=>e.setActive),c=lr(e=>e.activeProjectId),l=t=>{c!==e&&s(e),i(t)},[u,d]=(0,v.useState)(void 0),[f,p]=(0,v.useState)(``),[m,h]=(0,v.useState)(void 0),[g,_]=(0,v.useState)(void 0);(0,v.useEffect)(()=>{if(g===void 0)return;let e=()=>_(void 0),t=window.setTimeout(e,Di),n=t=>{let n=t.target;n instanceof Element&&n.closest(`[data-armed-delete="${g}"]`)===null&&e()},r=t=>{t.key===`Escape`&&e()};return document.addEventListener(`pointerdown`,n),document.addEventListener(`keydown`,r),()=>{window.clearTimeout(t),document.removeEventListener(`pointerdown`,n),document.removeEventListener(`keydown`,r)}},[g]);let y=e=>{if(g===e){_(void 0),a(e);return}_(e)},[b,x]=(0,v.useState)(new Set),S=()=>x(new Set),C=e=>{x(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[w,T]=(0,v.useState)(new Map),E=(e,t)=>{T(n=>{let r=new Map(n);return r.set(e,!t),r})},{topLevel:D,childrenByParent:O}=(0,v.useMemo)(()=>{let n=new Map,r=new Set(t.filter(e=>e.parentSessionId===void 0).map(e=>e.sessionId));for(let e of t){if(e.parentSessionId===void 0||!r.has(e.parentSessionId))continue;let t=n.get(e.parentSessionId);t===void 0?n.set(e.parentSessionId,[e]):t.push(e)}let i=t.filter(e=>e.parentSessionId===void 0||!r.has(e.parentSessionId));return t.some(e=>e.parentSessionId!==void 0)&&console.info(`[subagent] SessionList grouping`,{projectId:e,sessionCount:t.length,topLevelCount:i.length,childCount:Array.from(n.values()).reduce((e,t)=>e+t.length,0),topLevelIds:Array.from(r),parentIdsOnChildren:t.filter(e=>e.parentSessionId!==void 0).map(e=>e.parentSessionId),bucketed:Array.from(n.keys())}),{topLevel:i,childrenByParent:n}},[t,e]),k=async()=>{if(m===void 0)return;let e=m.sessionIds;h(void 0);for(let t of e)try{await a(t)}catch{}S()};(0,v.useEffect)(()=>{r(e)},[e,r]);let ee=(e,t)=>{d(e),p(t)},A=()=>{d(void 0),p(``)},te=async e=>{let t=f.trim();A();try{await o(e,t)}catch{}},ne=(e,t)=>{e.key===`Enter`?(e.preventDefault(),te(t)):e.key===`Escape`&&(e.preventDefault(),A())};return(0,R.jsxs)(`div`,{className:`ml-6 mt-1 space-y-0.5`,children:[t.length===0&&(0,R.jsx)(`p`,{className:`px-2 py-1 text-xs italic text-neutral-600`,children:`No sessions yet.`}),b.size>0&&(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-2 rounded bg-neutral-900/60 px-2 py-1 text-[11px] text-neutral-300`,children:[(0,R.jsxs)(`span`,{children:[b.size,` selected`]}),(0,R.jsxs)(`div`,{className:`flex gap-1`,children:[(0,R.jsx)(`button`,{onClick:()=>h({sessionIds:Array.from(b)}),className:`rounded border border-red-700/50 px-1.5 py-0.5 text-red-300 hover:bg-red-900/20 light:border-red-400 light:text-red-700 light:hover:bg-red-50`,children:`Delete`}),(0,R.jsx)(`button`,{onClick:S,className:`rounded border border-neutral-700 px-1.5 py-0.5 text-neutral-300 hover:border-neutral-500`,children:`Clear`})]})]}),D.flatMap(e=>{let t=O.get(e.sessionId)??[],r=w.get(e.sessionId)===!0,i=[(0,R.jsx)(Oi,{session:e,isActive:e.sessionId===n,isSelected:b.has(e.sessionId),isRenaming:u===e.sessionId,renameDraft:f,childCount:t.length,isExpanded:r,isChild:!1,onSelect:l,onToggleSelect:C,onStartRename:ee,onChangeRename:p,onRenameKeyDown:ne,onCommitRename:e=>void te(e),onToggleExpanded:E,isArmedForDelete:g===e.sessionId,onDeleteClick:y},e.sessionId)];if(r)for(let e of t)i.push((0,R.jsx)(Oi,{session:e,isActive:e.sessionId===n,isSelected:b.has(e.sessionId),isRenaming:u===e.sessionId,renameDraft:f,childCount:0,isExpanded:!1,isChild:!0,onSelect:l,onToggleSelect:C,onStartRename:ee,onChangeRename:p,onRenameKeyDown:ne,onCommitRename:e=>void te(e),onToggleExpanded:E,isArmedForDelete:g===e.sessionId,onDeleteClick:y},e.sessionId));return i}),(0,R.jsx)(Ti,{open:m!==void 0,onClose:()=>h(void 0),onConfirm:()=>void k(),title:`Delete ${m?.sessionIds.length??0} session${(m?.sessionIds.length??0)===1?``:`s`}`,message:`Delete the ${m?.sessionIds.length??0} selected session${(m?.sessionIds.length??0)===1?``:`s`}? Live sessions are killed and on-disk JSONLs are removed. Cannot be undone.`,primaryLabel:`Delete all`,tone:`danger`})]})}var Di=3e3;function Oi(e){let{session:t,isActive:n,isSelected:r,isRenaming:i,renameDraft:a,childCount:o,isExpanded:s,isChild:c,onSelect:l,onToggleSelect:u,onStartRename:d,onChangeRename:f,onRenameKeyDown:p,onCommitRename:m,onToggleExpanded:h,isArmedForDelete:g,onDeleteClick:_}=e,v=t.name??(t.firstMessage.length>0?t.firstMessage.slice(0,40):`session ${t.sessionId.slice(0,6)}`);return(0,R.jsxs)(`div`,{className:`group flex items-center gap-1 rounded border-l-2 ${c?`ml-4`:``} px-2 py-0.5 text-xs ${r?`border-blue-400 bg-blue-500/15 text-neutral-100 hover:bg-blue-500/25`:n?`border-transparent bg-neutral-800 text-neutral-100`:`border-transparent text-neutral-400 hover:bg-neutral-900 hover:text-neutral-200`}`,children:[o>0?(0,R.jsx)(`button`,{onClick:()=>h(t.sessionId,s),className:`inline-flex h-4 w-4 shrink-0 items-center justify-center text-neutral-500 hover:text-neutral-200`,title:`${o} sub-agent session${o===1?``:`s`}`,"aria-label":s?`Collapse sub-agents`:`Expand sub-agents`,children:s?(0,R.jsx)(ue,{size:12}):(0,R.jsx)(fe,{size:12})}):(0,R.jsx)(`span`,{className:`inline-block h-4 w-4 shrink-0`,"aria-hidden":`true`}),i?(0,R.jsx)(`input`,{autoFocus:!0,value:a,onChange:e=>f(e.target.value),onKeyDown:e=>p(e,t.sessionId),onBlur:()=>m(t.sessionId),placeholder:v,maxLength:200,className:`flex-1 rounded border border-neutral-700 bg-neutral-950 px-1.5 py-0.5 text-xs text-neutral-100 outline-none focus:border-neutral-500`}):(0,R.jsxs)(`button`,{onClick:e=>{if(e.metaKey||e.ctrlKey){u(t.sessionId);return}l(t.sessionId)},onDoubleClick:()=>d(t.sessionId,t.name??``),className:`flex-1 truncate text-left`,title:`${t.sessionId} — double-click to rename, Cmd/Ctrl+click to select for bulk delete`,children:[t.isLive&&(0,R.jsx)(`span`,{className:`mr-1 text-emerald-500 light:text-emerald-700`,children:`●`}),c&&(0,R.jsx)(`span`,{className:`mr-1 text-purple-400 light:text-purple-700`,title:`sub-agent`,children:`↳`}),v]}),!i&&(0,R.jsx)(`button`,{"data-armed-delete":g?t.sessionId:void 0,onClick:e=>{e.stopPropagation(),_(t.sessionId)},className:g?`inline-flex h-6 items-center rounded border border-red-500 px-1.5 text-[11px] font-medium uppercase leading-none tracking-wide text-red-300 hover:bg-red-500/10 light:border-red-600 light:text-red-700 light:hover:bg-red-100`:`inline-flex h-6 w-6 items-center justify-center rounded text-neutral-500 hover:text-red-400 light:hover:text-red-700`,title:g?`Click again to delete (Esc to cancel)`:t.isLive?`Delete session — also kills the live shell`:`Delete session JSONL from disk`,"aria-label":g?`Confirm delete`:`Delete session`,children:g?`Confirm`:(0,R.jsx)(rt,{size:16})})]})}function ki({className:e=``}={}){let t=lr(e=>e.projects),n=lr(e=>e.activeProjectId),r=lr(e=>e.collapsed),i=lr(e=>e.setActive),a=lr(e=>e.toggleCollapsed),o=lr(e=>e.remove),s=lr(e=>e.rename),c=qr(e=>e.byProject),l=qr(e=>e.createSession),u=qr(e=>e.disposeSession),d=async e=>{n!==e&&i(e);try{await l(e)}catch{}},[f,p]=(0,v.useState)(!1),[m,h]=(0,v.useState)(),[g,_]=(0,v.useState)(``),[y,b]=(0,v.useState)(void 0),x=(e,t)=>{let n=c[e]??[],r=n.filter(e=>e.isLive).length,i=n.filter(e=>!e.isLive).length;b({id:e,name:t,liveCount:r,onDiskCount:i,acknowledged:!1,submitting:!1})},S=async()=>{if(y===void 0)return;let{id:e}=y;b({...y,submitting:!0});let t=(c[e]??[]).filter(e=>e.isLive).map(e=>e.sessionId);t.length>0&&await Promise.all(t.map(e=>u(e).catch(()=>void 0))),b(void 0),o(e)},C=async e=>{let t=g.trim();if(t.length===0){h(void 0);return}try{await s(e,t)}finally{h(void 0),_(``)}};return(0,R.jsxs)(`aside`,{className:`flex h-full w-64 flex-col border-r border-neutral-800 bg-neutral-950 ${e}`,style:{paddingTop:`env(safe-area-inset-top)`,paddingBottom:`env(safe-area-inset-bottom)`},children:[(0,R.jsxs)(`header`,{className:`flex items-center justify-between border-b border-neutral-800 px-3 py-2`,children:[(0,R.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wider text-neutral-400`,children:`Projects`}),(0,R.jsx)(`button`,{onClick:()=>p(!0),className:`rounded-md border border-neutral-700 px-2 py-0.5 text-xs text-neutral-200 hover:bg-neutral-800`,children:`+ New`})]}),(0,R.jsxs)(`div`,{className:`flex-1 overflow-y-auto py-1`,children:[t.length===0&&(0,R.jsx)(`p`,{className:`px-3 py-4 text-sm text-neutral-500`,children:`No projects yet.`}),t.map(e=>{let t=e.id===n,o=r[e.id]??!1;return(0,R.jsxs)(`div`,{className:`mt-1 px-1`,children:[(0,R.jsxs)(`div`,{className:`group flex items-center gap-1 rounded-md px-2 py-1 text-sm ${t?`bg-neutral-800 text-neutral-100`:`text-neutral-300 hover:bg-neutral-900`}`,children:[(0,R.jsx)(`button`,{onClick:()=>a(e.id),className:`flex items-center text-neutral-500 hover:text-neutral-300`,title:o?`Expand`:`Collapse`,children:o?(0,R.jsx)(fe,{size:16}):(0,R.jsx)(ue,{size:16})}),m===e.id?(0,R.jsx)(`input`,{value:g,onChange:e=>_(e.target.value),onBlur:()=>void C(e.id),onKeyDown:t=>{t.key===`Enter`&&C(e.id),t.key===`Escape`&&h(void 0)},autoFocus:!0,className:`flex-1 rounded border border-neutral-700 bg-neutral-950 px-1 py-0.5 text-sm`}):(0,R.jsxs)(`button`,{onClick:()=>i(e.id),onDoubleClick:()=>{h(e.id),_(e.name)},className:`flex min-w-0 flex-1 flex-col items-start text-left leading-tight`,title:e.path,children:[(0,R.jsx)(`span`,{className:`w-full truncate`,children:e.name}),(0,R.jsx)(`span`,{className:`w-full truncate font-mono text-[10px] text-neutral-500`,children:Ai(e.path)})]}),(0,R.jsx)(`button`,{onClick:()=>void d(e.id),className:`inline-flex p-1 text-neutral-500 hover:text-neutral-200`,title:`New session in this project`,children:(0,R.jsx)(Ve,{size:16})}),(0,R.jsx)(`button`,{onClick:()=>x(e.id,e.name),className:`inline-flex items-center p-1 text-neutral-500 hover:text-red-400`,title:`Delete project (blocked while live sessions exist)`,children:(0,R.jsx)(rt,{size:16})})]}),!o&&(0,R.jsx)(Ei,{projectId:e.id})]},e.id)})]}),f&&(0,R.jsx)(bi,{onClose:()=>p(!1)}),(0,R.jsx)(Ci,{open:y!==void 0,onClose:()=>b(void 0),title:y===void 0?`Delete project`:`Delete project "${y.name}"`,children:y!==void 0&&(()=>{let e=y.liveCount+y.onDiskCount,t=e>0,n=!y.submitting&&(!t||y.acknowledged);return(0,R.jsxs)(`div`,{className:`flex flex-col gap-3 px-4 py-3`,children:[(0,R.jsxs)(`p`,{className:`text-xs text-neutral-300`,children:[`Remove "`,y.name,`" from pi-forge.`]}),(0,R.jsxs)(`ul`,{className:`ml-4 list-disc space-y-0.5 text-[11px] text-neutral-400`,children:[(0,R.jsxs)(`li`,{children:[`Project record + the project's session directory (`,(0,R.jsxs)(`code`,{className:`font-mono text-[10px] text-neutral-400`,children:[`.pi/sessions/`,y.id,`/`]}),`) will be deleted.`]}),y.liveCount>0&&(0,R.jsxs)(`li`,{children:[y.liveCount,` live session`,y.liveCount===1?``:`s`,` will be disposed first.`]}),(0,R.jsxs)(`li`,{children:[`The project's workspace folder on disk is `,(0,R.jsx)(`strong`,{children:`not`}),` touched.`]})]}),t&&(0,R.jsxs)(`label`,{className:`flex items-start gap-2 rounded border border-red-900/40 bg-red-950/30 px-2 py-1.5 text-xs text-red-200 light:border-red-300 light:bg-red-50 light:text-red-800`,children:[(0,R.jsx)(`input`,{type:`checkbox`,checked:y.acknowledged,onChange:e=>b(t=>t===void 0?t:{...t,acknowledged:e.target.checked}),className:`mt-0.5 h-3 w-3`}),(0,R.jsxs)(`span`,{children:[`Yes, I understand this will delete `,e,` session`,e===1?``:`s`,y.liveCount>0&&y.onDiskCount>0?` (${y.liveCount} live, ${y.onDiskCount} on disk)`:y.liveCount>0?` (${y.liveCount} live)`:``,`. This can't be undone.`]})]}),(0,R.jsxs)(`footer`,{className:`flex justify-end gap-2 pt-1`,children:[(0,R.jsx)(`button`,{type:`button`,onClick:()=>b(void 0),disabled:y.submitting,className:`rounded-md border border-neutral-700 px-3 py-1 text-xs text-neutral-200 hover:bg-neutral-800 disabled:opacity-50`,children:`Cancel`}),(0,R.jsx)(`button`,{type:`button`,onClick:()=>void S(),disabled:!n,className:`rounded-md bg-red-700 px-3 py-1 text-xs font-medium text-red-50 hover:bg-red-600 disabled:opacity-50 disabled:hover:bg-red-700`,children:y.submitting?`Deleting…`:`Delete`})]})]})})()})]})}function Ai(e){let t=e.split(/[/\\]/).filter(e=>e.length>0);return t[t.length-1]??e}function ji(e){var t,n,r=``;if(typeof e==`string`||typeof e==`number`)r+=e;else if(typeof e==`object`)if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(n=ji(e[t]))&&(r&&(r+=` `),r+=n)}else for(n in e)e[n]&&(r&&(r+=` `),r+=n);return r}function Mi(){for(var e,t,n=0,r=``,i=arguments.length;n<i;n++)(e=arguments[n])&&(t=ji(e))&&(r&&(r+=` `),r+=t);return r}var Ni=Object.create,Pi=Object.defineProperty,Fi=Object.defineProperties,Ii=Object.getOwnPropertyDescriptor,Li=Object.getOwnPropertyDescriptors,Ri=Object.getOwnPropertyNames,zi=Object.getOwnPropertySymbols,Bi=Object.getPrototypeOf,Vi=Object.prototype.hasOwnProperty,Hi=Object.prototype.propertyIsEnumerable,Ui=(e,t,n)=>t in e?Pi(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Wi=(e,t)=>{for(var n in t||={})Vi.call(t,n)&&Ui(e,n,t[n]);if(zi)for(var n of zi(t))Hi.call(t,n)&&Ui(e,n,t[n]);return e},Gi=(e,t)=>Fi(e,Li(t)),Ki=(e,t)=>{var n={};for(var r in e)Vi.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&zi)for(var r of zi(e))t.indexOf(r)<0&&Hi.call(e,r)&&(n[r]=e[r]);return n},qi=(e,t)=>function(){return t||(0,e[Ri(e)[0]])((t={exports:{}}).exports,t),t.exports},Ji=(e,t)=>{for(var n in t)Pi(e,n,{get:t[n],enumerable:!0})},Yi=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let i of Ri(t))!Vi.call(e,i)&&i!==n&&Pi(e,i,{get:()=>t[i],enumerable:!(r=Ii(t,i))||r.enumerable});return e},z=((e,t,n)=>(n=e==null?{}:Ni(Bi(e)),Yi(t||!e||!e.__esModule?Pi(n,`default`,{value:e,enumerable:!0}):n,e)))(qi({"../../node_modules/.pnpm/prismjs@1.29.0_patch_hash=vrxx3pzkik6jpmgpayxfjunetu/node_modules/prismjs/prism.js"(e,t){var n=function(){var e=/(?:^|\s)lang(?:uage)?-([\w-]+)(?=\s|$)/i,t=0,n={},r={util:{encode:function e(t){return t instanceof i?new i(t.type,e(t.content),t.alias):Array.isArray(t)?t.map(e):t.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/\u00a0/g,` `)},type:function(e){return Object.prototype.toString.call(e).slice(8,-1)},objId:function(e){return e.__id||Object.defineProperty(e,"__id",{value:++t}),e.__id},clone:function e(t,n){n||={};var i,a;switch(r.util.type(t)){case`Object`:if(a=r.util.objId(t),n[a])return n[a];for(var o in i={},n[a]=i,t)t.hasOwnProperty(o)&&(i[o]=e(t[o],n));return i;case`Array`:return a=r.util.objId(t),n[a]?n[a]:(i=[],n[a]=i,t.forEach(function(t,r){i[r]=e(t,n)}),i);default:return t}},getLanguage:function(t){for(;t;){var n=e.exec(t.className);if(n)return n[1].toLowerCase();t=t.parentElement}return`none`},setLanguage:function(t,n){t.className=t.className.replace(RegExp(e,`gi`),``),t.classList.add(`language-`+n)},isActive:function(e,t,n){for(var r=`no-`+t;e;){var i=e.classList;if(i.contains(t))return!0;if(i.contains(r))return!1;e=e.parentElement}return!!n}},languages:{plain:n,plaintext:n,text:n,txt:n,extend:function(e,t){var n=r.util.clone(r.languages[e]);for(var i in t)n[i]=t[i];return n},insertBefore:function(e,t,n,i){i||=r.languages;var a=i[e],o={};for(var s in a)if(a.hasOwnProperty(s)){if(s==t)for(var c in n)n.hasOwnProperty(c)&&(o[c]=n[c]);n.hasOwnProperty(s)||(o[s]=a[s])}var l=i[e];return i[e]=o,r.languages.DFS(r.languages,function(t,n){n===l&&t!=e&&(this[t]=o)}),o},DFS:function e(t,n,i,a){a||={};var o=r.util.objId;for(var s in t)if(t.hasOwnProperty(s)){n.call(t,s,t[s],i||s);var c=t[s],l=r.util.type(c);l===`Object`&&!a[o(c)]?(a[o(c)]=!0,e(c,n,null,a)):l===`Array`&&!a[o(c)]&&(a[o(c)]=!0,e(c,n,s,a))}}},plugins:{},highlight:function(e,t,n){var a={code:e,grammar:t,language:n};if(r.hooks.run(`before-tokenize`,a),!a.grammar)throw Error(`The language "`+a.language+`" has no grammar.`);return a.tokens=r.tokenize(a.code,a.grammar),r.hooks.run(`after-tokenize`,a),i.stringify(r.util.encode(a.tokens),a.language)},tokenize:function(e,t){var n=t.rest;if(n){for(var r in n)t[r]=n[r];delete t.rest}var i=new s;return c(i,i.head,e),o(e,i,t,i.head,0),u(i)},hooks:{all:{},add:function(e,t){var n=r.hooks.all;n[e]=n[e]||[],n[e].push(t)},run:function(e,t){var n=r.hooks.all[e];if(!(!n||!n.length))for(var i=0,a;a=n[i++];)a(t)}},Token:i};function i(e,t,n,r){this.type=e,this.content=t,this.alias=n,this.length=(r||``).length|0}i.stringify=function e(t,n){if(typeof t==`string`)return t;if(Array.isArray(t)){var i=``;return t.forEach(function(t){i+=e(t,n)}),i}var a={type:t.type,content:e(t.content,n),tag:`span`,classes:[`token`,t.type],attributes:{},language:n},o=t.alias;o&&(Array.isArray(o)?Array.prototype.push.apply(a.classes,o):a.classes.push(o)),r.hooks.run(`wrap`,a);var s=``;for(var c in a.attributes)s+=` `+c+`="`+(a.attributes[c]||``).replace(/"/g,`&quot;`)+`"`;return`<`+a.tag+` class="`+a.classes.join(` `)+`"`+s+`>`+a.content+`</`+a.tag+`>`};function a(e,t,n,r){e.lastIndex=t;var i=e.exec(n);if(i&&r&&i[1]){var a=i[1].length;i.index+=a,i[0]=i[0].slice(a)}return i}function o(e,t,n,s,u,d){for(var f in n)if(!(!n.hasOwnProperty(f)||!n[f])){var p=n[f];p=Array.isArray(p)?p:[p];for(var m=0;m<p.length;++m){if(d&&d.cause==f+`,`+m)return;var h=p[m],g=h.inside,_=!!h.lookbehind,v=!!h.greedy,y=h.alias;if(v&&!h.pattern.global){var b=h.pattern.toString().match(/[imsuy]*$/)[0];h.pattern=RegExp(h.pattern.source,b+`g`)}for(var x=h.pattern||h,S=s.next,C=u;S!==t.tail&&!(d&&C>=d.reach);C+=S.value.length,S=S.next){var w=S.value;if(t.length>e.length)return;if(!(w instanceof i)){var T=1,E;if(v){if(E=a(x,C,e,_),!E||E.index>=e.length)break;var D=E.index,O=E.index+E[0].length,k=C;for(k+=S.value.length;D>=k;)S=S.next,k+=S.value.length;if(k-=S.value.length,C=k,S.value instanceof i)continue;for(var ee=S;ee!==t.tail&&(k<O||typeof ee.value==`string`);ee=ee.next)T++,k+=ee.value.length;T--,w=e.slice(C,k),E.index-=C}else if(E=a(x,0,w,_),!E)continue;var D=E.index,A=E[0],te=w.slice(0,D),ne=w.slice(D+A.length),re=C+w.length;d&&re>d.reach&&(d.reach=re);var ie=S.prev;te&&(ie=c(t,ie,te),C+=te.length),l(t,ie,T);var j=new i(f,g?r.tokenize(A,g):A,y,A);if(S=c(t,ie,j),ne&&c(t,S,ne),T>1){var ae={cause:f+`,`+m,reach:re};o(e,t,n,S.prev,C,ae),d&&ae.reach>d.reach&&(d.reach=ae.reach)}}}}}}function s(){var e={value:null,prev:null,next:null},t={value:null,prev:e,next:null};e.next=t,this.head=e,this.tail=t,this.length=0}function c(e,t,n){var r=t.next,i={value:n,prev:t,next:r};return t.next=i,r.prev=i,e.length++,i}function l(e,t,n){for(var r=t.next,i=0;i<n&&r!==e.tail;i++)r=r.next;t.next=r,r.prev=t,e.length-=i}function u(e){for(var t=[],n=e.head.next;n!==e.tail;)t.push(n.value),n=n.next;return t}return r}();t.exports=n,n.default=n}})());z.languages.markup={comment:{pattern:/<!--(?:(?!<!--)[\s\S])*?-->/,greedy:!0},prolog:{pattern:/<\?[\s\S]+?\?>/,greedy:!0},doctype:{pattern:/<!DOCTYPE(?:[^>"'[\]]|"[^"]*"|'[^']*')+(?:\[(?:[^<"'\]]|"[^"]*"|'[^']*'|<(?!!--)|<!--(?:[^-]|-(?!->))*-->)*\]\s*)?>/i,greedy:!0,inside:{"internal-subset":{pattern:/(^[^\[]*\[)[\s\S]+(?=\]>$)/,lookbehind:!0,greedy:!0,inside:null},string:{pattern:/"[^"]*"|'[^']*'/,greedy:!0},punctuation:/^<!|>$|[[\]]/,"doctype-tag":/^DOCTYPE/i,name:/[^\s<>'"]+/}},cdata:{pattern:/<!\[CDATA\[[\s\S]*?\]\]>/i,greedy:!0},tag:{pattern:/<\/?(?!\d)[^\s>\/=$<%]+(?:\s(?:\s*[^\s>\/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s/>])))+)?\s*\/?>/,greedy:!0,inside:{tag:{pattern:/^<\/?[^\s>\/]+/,inside:{punctuation:/^<\/?/,namespace:/^[^\s>\/:]+:/}},"special-attr":[],"attr-value":{pattern:/=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+)/,inside:{punctuation:[{pattern:/^=/,alias:`attr-equals`},{pattern:/^(\s*)["']|["']$/,lookbehind:!0}]}},punctuation:/\/?>/,"attr-name":{pattern:/[^\s>\/]+/,inside:{namespace:/^[^\s>\/:]+:/}}}},entity:[{pattern:/&[\da-z]{1,8};/i,alias:`named-entity`},/&#x?[\da-f]{1,8};/i]},z.languages.markup.tag.inside[`attr-value`].inside.entity=z.languages.markup.entity,z.languages.markup.doctype.inside[`internal-subset`].inside=z.languages.markup,z.hooks.add(`wrap`,function(e){e.type===`entity`&&(e.attributes.title=e.content.replace(/&amp;/,`&`))}),Object.defineProperty(z.languages.markup.tag,"addInlined",{value:function(e,t){var n={},n=(n[`language-`+t]={pattern:/(^<!\[CDATA\[)[\s\S]+?(?=\]\]>$)/i,lookbehind:!0,inside:z.languages[t]},n.cdata=/^<!\[CDATA\[|\]\]>$/i,{"included-cdata":{pattern:/<!\[CDATA\[[\s\S]*?\]\]>/i,inside:n}}),t=(n[`language-`+t]={pattern:/[\s\S]+/,inside:z.languages[t]},{});t[e]={pattern:RegExp(`(<__[^>]*>)(?:<!\\[CDATA\\[(?:[^\\]]|\\](?!\\]>))*\\]\\]>|(?!<!\\[CDATA\\[)[\\s\\S])*?(?=<\\/__>)`.replace(/__/g,function(){return e}),`i`),lookbehind:!0,greedy:!0,inside:n},z.languages.insertBefore(`markup`,`cdata`,t)}}),Object.defineProperty(z.languages.markup.tag,"addAttribute",{value:function(e,t){z.languages.markup.tag.inside[`special-attr`].push({pattern:RegExp(`(^|["'\\s])(?:`+e+`)\\s*=\\s*(?:"[^"]*"|'[^']*'|[^\\s'">=]+(?=[\\s>]))`,`i`),lookbehind:!0,inside:{"attr-name":/^[^\s=]+/,"attr-value":{pattern:/=[\s\S]+/,inside:{value:{pattern:/(^=\s*(["']|(?!["'])))\S[\s\S]*(?=\2$)/,lookbehind:!0,alias:[t,`language-`+t],inside:z.languages[t]},punctuation:[{pattern:/^=/,alias:`attr-equals`},/"|'/]}}}})}}),z.languages.html=z.languages.markup,z.languages.mathml=z.languages.markup,z.languages.svg=z.languages.markup,z.languages.xml=z.languages.extend(`markup`,{}),z.languages.ssml=z.languages.xml,z.languages.atom=z.languages.xml,z.languages.rss=z.languages.xml,function(e){var t={pattern:/\\[\\(){}[\]^$+*?|.]/,alias:`escape`},n=/\\(?:x[\da-fA-F]{2}|u[\da-fA-F]{4}|u\{[\da-fA-F]+\}|0[0-7]{0,2}|[123][0-7]{2}|c[a-zA-Z]|.)/,r=`(?:[^\\\\-]|`+n.source+`)`,r=RegExp(r+`-`+r),i={pattern:/(<|')[^<>']+(?=[>']$)/,lookbehind:!0,alias:`variable`};e.languages.regex={"char-class":{pattern:/((?:^|[^\\])(?:\\\\)*)\[(?:[^\\\]]|\\[\s\S])*\]/,lookbehind:!0,inside:{"char-class-negation":{pattern:/(^\[)\^/,lookbehind:!0,alias:`operator`},"char-class-punctuation":{pattern:/^\[|\]$/,alias:`punctuation`},range:{pattern:r,inside:{escape:n,"range-punctuation":{pattern:/-/,alias:`operator`}}},"special-escape":t,"char-set":{pattern:/\\[wsd]|\\p\{[^{}]+\}/i,alias:`class-name`},escape:n}},"special-escape":t,"char-set":{pattern:/\.|\\[wsd]|\\p\{[^{}]+\}/i,alias:`class-name`},backreference:[{pattern:/\\(?![123][0-7]{2})[1-9]/,alias:`keyword`},{pattern:/\\k<[^<>']+>/,alias:`keyword`,inside:{"group-name":i}}],anchor:{pattern:/[$^]|\\[ABbGZz]/,alias:`function`},escape:n,group:[{pattern:/\((?:\?(?:<[^<>']+>|'[^<>']+'|[>:]|<?[=!]|[idmnsuxU]+(?:-[idmnsuxU]+)?:?))?/,alias:`punctuation`,inside:{"group-name":i}},{pattern:/\)/,alias:`punctuation`}],quantifier:{pattern:/(?:[+*?]|\{\d+(?:,\d*)?\})[?+]?/,alias:`number`},alternation:{pattern:/\|/,alias:`keyword`}}}(z),z.languages.clike={comment:[{pattern:/(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/,lookbehind:!0,greedy:!0},{pattern:/(^|[^\\:])\/\/.*/,lookbehind:!0,greedy:!0}],string:{pattern:/(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,greedy:!0},"class-name":{pattern:/(\b(?:class|extends|implements|instanceof|interface|new|trait)\s+|\bcatch\s+\()[\w.\\]+/i,lookbehind:!0,inside:{punctuation:/[.\\]/}},keyword:/\b(?:break|catch|continue|do|else|finally|for|function|if|in|instanceof|new|null|return|throw|try|while)\b/,boolean:/\b(?:false|true)\b/,function:/\b\w+(?=\()/,number:/\b0x[\da-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?/i,operator:/[<>]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/,punctuation:/[{}[\];(),.:]/},z.languages.javascript=z.languages.extend(`clike`,{"class-name":[z.languages.clike[`class-name`],{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$A-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\.(?:constructor|prototype))/,lookbehind:!0}],keyword:[{pattern:/((?:^|\})\s*)catch\b/,lookbehind:!0},{pattern:/(^|[^.]|\.\.\.\s*)\b(?:as|assert(?=\s*\{)|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally(?=\s*(?:\{|$))|for|from(?=\s*(?:['"]|$))|function|(?:get|set)(?=\s*(?:[#\[$\w\xA0-\uFFFF]|$))|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/,lookbehind:!0}],function:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,number:{pattern:RegExp(`(^|[^\\w$])(?:NaN|Infinity|0[bB][01]+(?:_[01]+)*n?|0[oO][0-7]+(?:_[0-7]+)*n?|0[xX][\\dA-Fa-f]+(?:_[\\dA-Fa-f]+)*n?|\\d+(?:_\\d+)*n|(?:\\d+(?:_\\d+)*(?:\\.(?:\\d+(?:_\\d+)*)?)?|\\.\\d+(?:_\\d+)*)(?:[Ee][+-]?\\d+(?:_\\d+)*)?)(?![\\w$])`),lookbehind:!0},operator:/--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/}),z.languages.javascript[`class-name`][0].pattern=/(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/,z.languages.insertBefore(`javascript`,`keyword`,{regex:{pattern:RegExp(`((?:^|[^$\\w\\xA0-\\uFFFF."'\\])\\s]|\\b(?:return|yield))\\s*)\\/(?:(?:\\[(?:[^\\]\\\\\\r\\n]|\\\\.)*\\]|\\\\.|[^/\\\\\\[\\r\\n])+\\/[dgimyus]{0,7}|(?:\\[(?:[^[\\]\\\\\\r\\n]|\\\\.|\\[(?:[^[\\]\\\\\\r\\n]|\\\\.|\\[(?:[^[\\]\\\\\\r\\n]|\\\\.)*\\])*\\])*\\]|\\\\.|[^/\\\\\\[\\r\\n])+\\/[dgimyus]{0,7}v[dgimyus]{0,7})(?=(?:\\s|\\/\\*(?:[^*]|\\*(?!\\/))*\\*\\/)*(?:$|[\\r\\n,.;:})\\]]|\\/\\/))`),lookbehind:!0,greedy:!0,inside:{"regex-source":{pattern:/^(\/)[\s\S]+(?=\/[a-z]*$)/,lookbehind:!0,alias:`language-regex`,inside:z.languages.regex},"regex-delimiter":/^\/|\/$/,"regex-flags":/^[a-z]+$/}},"function-variable":{pattern:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)\s*=>))/,alias:`function`},parameter:[{pattern:/(function(?:\s+(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)?\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\))/,lookbehind:!0,inside:z.languages.javascript},{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i,lookbehind:!0,inside:z.languages.javascript},{pattern:/(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/,lookbehind:!0,inside:z.languages.javascript},{pattern:/((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*)\(\s*|\]\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*\{)/,lookbehind:!0,inside:z.languages.javascript}],constant:/\b[A-Z](?:[A-Z_]|\dx?)*\b/}),z.languages.insertBefore(`javascript`,`string`,{hashbang:{pattern:/^#!.*/,greedy:!0,alias:`comment`},"template-string":{pattern:/`(?:\\[\s\S]|\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}|(?!\$\{)[^\\`])*`/,greedy:!0,inside:{"template-punctuation":{pattern:/^`|`$/,alias:`string`},interpolation:{pattern:/((?:^|[^\\])(?:\\{2})*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}/,lookbehind:!0,inside:{"interpolation-punctuation":{pattern:/^\$\{|\}$/,alias:`punctuation`},rest:z.languages.javascript}},string:/[\s\S]+/}},"string-property":{pattern:/((?:^|[,{])[ \t]*)(["'])(?:\\(?:\r\n|[\s\S])|(?!\2)[^\\\r\n])*\2(?=\s*:)/m,lookbehind:!0,greedy:!0,alias:`property`}}),z.languages.insertBefore(`javascript`,`operator`,{"literal-property":{pattern:/((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m,lookbehind:!0,alias:`property`}}),z.languages.markup&&(z.languages.markup.tag.addInlined(`script`,`javascript`),z.languages.markup.tag.addAttribute(`on(?:abort|blur|change|click|composition(?:end|start|update)|dblclick|error|focus(?:in|out)?|key(?:down|up)|load|mouse(?:down|enter|leave|move|out|over|up)|reset|resize|scroll|select|slotchange|submit|unload|wheel)`,`javascript`)),z.languages.js=z.languages.javascript,z.languages.actionscript=z.languages.extend(`javascript`,{keyword:/\b(?:as|break|case|catch|class|const|default|delete|do|dynamic|each|else|extends|final|finally|for|function|get|if|implements|import|in|include|instanceof|interface|internal|is|namespace|native|new|null|override|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|use|var|void|while|with)\b/,operator:/\+\+|--|(?:[+\-*\/%^]|&&?|\|\|?|<<?|>>?>?|[!=]=?)=?|[~?@]/}),z.languages.actionscript[`class-name`].alias=`function`,delete z.languages.actionscript.parameter,delete z.languages.actionscript[`literal-property`],z.languages.markup&&z.languages.insertBefore(`actionscript`,`string`,{xml:{pattern:/(^|[^.])<\/?\w+(?:\s+[^\s>\/=]+=("|')(?:\\[\s\S]|(?!\2)[^\\])*\2)*\s*\/?>/,lookbehind:!0,inside:z.languages.markup}}),function(e){var t=/#(?!\{).+/,n={pattern:/#\{[^}]+\}/,alias:`variable`};e.languages.coffeescript=e.languages.extend(`javascript`,{comment:t,string:[{pattern:/'(?:\\[\s\S]|[^\\'])*'/,greedy:!0},{pattern:/"(?:\\[\s\S]|[^\\"])*"/,greedy:!0,inside:{interpolation:n}}],keyword:/\b(?:and|break|by|catch|class|continue|debugger|delete|do|each|else|extend|extends|false|finally|for|if|in|instanceof|is|isnt|let|loop|namespace|new|no|not|null|of|off|on|or|own|return|super|switch|then|this|throw|true|try|typeof|undefined|unless|until|when|while|window|with|yes|yield)\b/,"class-member":{pattern:/@(?!\d)\w+/,alias:`variable`}}),e.languages.insertBefore(`coffeescript`,`comment`,{"multiline-comment":{pattern:/###[\s\S]+?###/,alias:`comment`},"block-regex":{pattern:/\/{3}[\s\S]*?\/{3}/,alias:`regex`,inside:{comment:t,interpolation:n}}}),e.languages.insertBefore(`coffeescript`,`string`,{"inline-javascript":{pattern:/`(?:\\[\s\S]|[^\\`])*`/,inside:{delimiter:{pattern:/^`|`$/,alias:`punctuation`},script:{pattern:/[\s\S]+/,alias:`language-javascript`,inside:e.languages.javascript}}},"multiline-string":[{pattern:/'''[\s\S]*?'''/,greedy:!0,alias:`string`},{pattern:/"""[\s\S]*?"""/,greedy:!0,alias:`string`,inside:{interpolation:n}}]}),e.languages.insertBefore(`coffeescript`,`keyword`,{property:/(?!\d)\w+(?=\s*:(?!:))/}),delete e.languages.coffeescript[`template-string`],e.languages.coffee=e.languages.coffeescript}(z),function(e){var t=e.languages.javadoclike={parameter:{pattern:/(^[\t ]*(?:\/{3}|\*|\/\*\*)\s*@(?:arg|arguments|param)\s+)\w+/m,lookbehind:!0},keyword:{pattern:/(^[\t ]*(?:\/{3}|\*|\/\*\*)\s*|\{)@[a-z][a-zA-Z-]+\b/m,lookbehind:!0},punctuation:/[{}]/};Object.defineProperty(t,"addSupport",{value:function(t,n){(t=typeof t==`string`?[t]:t).forEach(function(t){var r=function(e){e.inside||={},e.inside.rest=n},i=`doc-comment`;if(a=e.languages[t]){var a,o=a[i];if((o||=(a=e.languages.insertBefore(t,`comment`,{"doc-comment":{pattern:/(^|[^\\])\/\*\*[^/][\s\S]*?(?:\*\/|$)/,lookbehind:!0,alias:`comment`}}))[i])instanceof RegExp&&(o=a[i]={pattern:o}),Array.isArray(o))for(var s=0,c=o.length;s<c;s++)o[s]instanceof RegExp&&(o[s]={pattern:o[s]}),r(o[s]);else r(o)}})}}),t.addSupport([`java`,`javascript`,`php`],t)}(z),function(e){var t=/(?:"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"|'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n])*')/,t=(e.languages.css={comment:/\/\*[\s\S]*?\*\//,atrule:{pattern:RegExp(`@[\\w-](?:[^;{\\s"']|\\s+(?!\\s)|`+t.source+`)*?(?:;|(?=\\s*\\{))`),inside:{rule:/^@[\w-]+/,"selector-function-argument":{pattern:/(\bselector\s*\(\s*(?![\s)]))(?:[^()\s]|\s+(?![\s)])|\((?:[^()]|\([^()]*\))*\))+(?=\s*\))/,lookbehind:!0,alias:`selector`},keyword:{pattern:/(^|[^\w-])(?:and|not|only|or)(?![\w-])/,lookbehind:!0}}},url:{pattern:RegExp(`\\burl\\((?:`+t.source+`|(?:[^\\\\\\r\\n()"']|\\\\[\\s\\S])*)\\)`,`i`),greedy:!0,inside:{function:/^url/i,punctuation:/^\(|\)$/,string:{pattern:RegExp(`^`+t.source+`$`),alias:`url`}}},selector:{pattern:RegExp(`(^|[{}\\s])[^{}\\s](?:[^{};"'\\s]|\\s+(?![\\s{])|`+t.source+`)*(?=\\s*\\{)`),lookbehind:!0},string:{pattern:t,greedy:!0},property:{pattern:/(^|[^-\w\xA0-\uFFFF])(?!\s)[-_a-z\xA0-\uFFFF](?:(?!\s)[-\w\xA0-\uFFFF])*(?=\s*:)/i,lookbehind:!0},important:/!important\b/i,function:{pattern:/(^|[^-a-z0-9])[-a-z0-9]+(?=\()/i,lookbehind:!0},punctuation:/[(){};:,]/},e.languages.css.atrule.inside.rest=e.languages.css,e.languages.markup);t&&(t.tag.addInlined(`style`,`css`),t.tag.addAttribute(`style`,`css`))}(z),function(e){var t=/("|')(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,t=(e.languages.css.selector={pattern:e.languages.css.selector.pattern,lookbehind:!0,inside:t={"pseudo-element":/:(?:after|before|first-letter|first-line|selection)|::[-\w]+/,"pseudo-class":/:[-\w]+/,class:/\.[-\w]+/,id:/#[-\w]+/,attribute:{pattern:RegExp(`\\[(?:[^[\\]"']|`+t.source+`)*\\]`),greedy:!0,inside:{punctuation:/^\[|\]$/,"case-sensitivity":{pattern:/(\s)[si]$/i,lookbehind:!0,alias:`keyword`},namespace:{pattern:/^(\s*)(?:(?!\s)[-*\w\xA0-\uFFFF])*\|(?!=)/,lookbehind:!0,inside:{punctuation:/\|$/}},"attr-name":{pattern:/^(\s*)(?:(?!\s)[-\w\xA0-\uFFFF])+/,lookbehind:!0},"attr-value":[t,{pattern:/(=\s*)(?:(?!\s)[-\w\xA0-\uFFFF])+(?=\s*$)/,lookbehind:!0}],operator:/[|~*^$]?=/}},"n-th":[{pattern:/(\(\s*)[+-]?\d*[\dn](?:\s*[+-]\s*\d+)?(?=\s*\))/,lookbehind:!0,inside:{number:/[\dn]+/,operator:/[+-]/}},{pattern:/(\(\s*)(?:even|odd)(?=\s*\))/i,lookbehind:!0}],combinator:/>|\+|~|\|\|/,punctuation:/[(),]/}},e.languages.css.atrule.inside[`selector-function-argument`].inside=t,e.languages.insertBefore(`css`,`property`,{variable:{pattern:/(^|[^-\w\xA0-\uFFFF])--(?!\s)[-_a-z\xA0-\uFFFF](?:(?!\s)[-\w\xA0-\uFFFF])*/i,lookbehind:!0}}),{pattern:/(\b\d+)(?:%|[a-z]+(?![\w-]))/,lookbehind:!0}),n={pattern:/(^|[^\w.-])-?(?:\d+(?:\.\d+)?|\.\d+)/,lookbehind:!0};e.languages.insertBefore(`css`,`function`,{operator:{pattern:/(\s)[+\-*\/](?=\s)/,lookbehind:!0},hexcode:{pattern:/\B#[\da-f]{3,8}\b/i,alias:`color`},color:[{pattern:/(^|[^\w-])(?:AliceBlue|AntiqueWhite|Aqua|Aquamarine|Azure|Beige|Bisque|Black|BlanchedAlmond|Blue|BlueViolet|Brown|BurlyWood|CadetBlue|Chartreuse|Chocolate|Coral|CornflowerBlue|Cornsilk|Crimson|Cyan|DarkBlue|DarkCyan|DarkGoldenRod|DarkGr[ae]y|DarkGreen|DarkKhaki|DarkMagenta|DarkOliveGreen|DarkOrange|DarkOrchid|DarkRed|DarkSalmon|DarkSeaGreen|DarkSlateBlue|DarkSlateGr[ae]y|DarkTurquoise|DarkViolet|DeepPink|DeepSkyBlue|DimGr[ae]y|DodgerBlue|FireBrick|FloralWhite|ForestGreen|Fuchsia|Gainsboro|GhostWhite|Gold|GoldenRod|Gr[ae]y|Green|GreenYellow|HoneyDew|HotPink|IndianRed|Indigo|Ivory|Khaki|Lavender|LavenderBlush|LawnGreen|LemonChiffon|LightBlue|LightCoral|LightCyan|LightGoldenRodYellow|LightGr[ae]y|LightGreen|LightPink|LightSalmon|LightSeaGreen|LightSkyBlue|LightSlateGr[ae]y|LightSteelBlue|LightYellow|Lime|LimeGreen|Linen|Magenta|Maroon|MediumAquaMarine|MediumBlue|MediumOrchid|MediumPurple|MediumSeaGreen|MediumSlateBlue|MediumSpringGreen|MediumTurquoise|MediumVioletRed|MidnightBlue|MintCream|MistyRose|Moccasin|NavajoWhite|Navy|OldLace|Olive|OliveDrab|Orange|OrangeRed|Orchid|PaleGoldenRod|PaleGreen|PaleTurquoise|PaleVioletRed|PapayaWhip|PeachPuff|Peru|Pink|Plum|PowderBlue|Purple|RebeccaPurple|Red|RosyBrown|RoyalBlue|SaddleBrown|Salmon|SandyBrown|SeaGreen|SeaShell|Sienna|Silver|SkyBlue|SlateBlue|SlateGr[ae]y|Snow|SpringGreen|SteelBlue|Tan|Teal|Thistle|Tomato|Transparent|Turquoise|Violet|Wheat|White|WhiteSmoke|Yellow|YellowGreen)(?![\w-])/i,lookbehind:!0},{pattern:/\b(?:hsl|rgb)\(\s*\d{1,3}\s*,\s*\d{1,3}%?\s*,\s*\d{1,3}%?\s*\)\B|\b(?:hsl|rgb)a\(\s*\d{1,3}\s*,\s*\d{1,3}%?\s*,\s*\d{1,3}%?\s*,\s*(?:0|0?\.\d+|1)\s*\)\B/i,inside:{unit:t,number:n,function:/[\w-]+(?=\()/,punctuation:/[(),]/}}],entity:/\\[\da-f]{1,8}/i,unit:t,number:n})}(z),function(e){var t=/[*&][^\s[\]{},]+/,n=/!(?:<[\w\-%#;/?:@&=+$,.!~*'()[\]]+>|(?:[a-zA-Z\d-]*!)?[\w\-%#;/?:@&=+$.~*'()]+)?/,r=`(?:`+n.source+`(?:[ ]+`+t.source+`)?|`+t.source+`(?:[ ]+`+n.source+`)?)`,i=`(?:[^\\s\\x00-\\x08\\x0e-\\x1f!"#%&'*,\\-:>?@[\\]\`{|}\\x7f-\\x84\\x86-\\x9f\\ud800-\\udfff\\ufffe\\uffff]|[?:-]<PLAIN>)(?:[ \\t]*(?:(?![#:])<PLAIN>|:<PLAIN>))*`.replace(/<PLAIN>/g,function(){return`[^\\s\\x00-\\x08\\x0e-\\x1f,[\\]{}\\x7f-\\x84\\x86-\\x9f\\ud800-\\udfff\\ufffe\\uffff]`}),a=`"(?:[^"\\\\\\r\\n]|\\\\.)*"|'(?:[^'\\\\\\r\\n]|\\\\.)*'`;function o(e,t){t=(t||``).replace(/m/g,``)+`m`;var n=`([:\\-,[{]\\s*(?:\\s<<prop>>[ \\t]+)?)(?:<<value>>)(?=[ \\t]*(?:$|,|\\]|\\}|(?:[\\r\\n]\\s*)?#))`.replace(/<<prop>>/g,function(){return r}).replace(/<<value>>/g,function(){return e});return RegExp(n,t)}e.languages.yaml={scalar:{pattern:RegExp(`([\\-:]\\s*(?:\\s<<prop>>[ \\t]+)?[|>])[ \\t]*(?:((?:\\r?\\n|\\r)[ \\t]+)\\S[^\\r\\n]*(?:\\2[^\\r\\n]+)*)`.replace(/<<prop>>/g,function(){return r})),lookbehind:!0,alias:`string`},comment:/#.*/,key:{pattern:RegExp(`((?:^|[:\\-,[{\\r\\n?])[ \\t]*(?:<<prop>>[ \\t]+)?)<<key>>(?=\\s*:\\s)`.replace(/<<prop>>/g,function(){return r}).replace(/<<key>>/g,function(){return`(?:`+i+`|`+a+`)`})),lookbehind:!0,greedy:!0,alias:`atrule`},directive:{pattern:/(^[ \t]*)%.+/m,lookbehind:!0,alias:`important`},datetime:{pattern:o(`\\d{4}-\\d\\d?-\\d\\d?(?:[tT]|[ \\t]+)\\d\\d?:\\d{2}:\\d{2}(?:\\.\\d*)?(?:[ \\t]*(?:Z|[-+]\\d\\d?(?::\\d{2})?))?|\\d{4}-\\d{2}-\\d{2}|\\d\\d?:\\d{2}(?::\\d{2}(?:\\.\\d*)?)?`),lookbehind:!0,alias:`number`},boolean:{pattern:o(`false|true`,`i`),lookbehind:!0,alias:`important`},null:{pattern:o(`null|~`,`i`),lookbehind:!0,alias:`important`},string:{pattern:o(a),lookbehind:!0,greedy:!0},number:{pattern:o(`[+-]?(?:0x[\\da-f]+|0o[0-7]+|(?:\\d+(?:\\.\\d*)?|\\.\\d+)(?:e[+-]?\\d+)?|\\.inf|\\.nan)`,`i`),lookbehind:!0},tag:n,important:t,punctuation:/---|[:[\]{}\-,|>?]|\.\.\./},e.languages.yml=e.languages.yaml}(z),function(e){var t=`(?:\\\\.|[^\\\\\\n\\r]|(?:\\n|\\r\\n?)(?![\\r\\n]))`;function n(e){return e=e.replace(/<inner>/g,function(){return t}),RegExp(`((?:^|[^\\\\])(?:\\\\{2})*)(?:`+e+`)`)}var r="(?:\\\\.|``(?:[^`\\r\\n]|`(?!`))+``|`[^`\\r\\n]+`|[^\\\\|\\r\\n`])+",i=`\\|?__(?:\\|__)+\\|?(?:(?:\\n|\\r\\n?)|(?![\\s\\S]))`.replace(/__/g,function(){return r}),a=`\\|?[ \\t]*:?-{3,}:?[ \\t]*(?:\\|[ \\t]*:?-{3,}:?[ \\t]*)+\\|?(?:\\n|\\r\\n?)`,o=(e.languages.markdown=e.languages.extend(`markup`,{}),e.languages.insertBefore(`markdown`,`prolog`,{"front-matter-block":{pattern:/(^(?:\s*[\r\n])?)---(?!.)[\s\S]*?[\r\n]---(?!.)/,lookbehind:!0,greedy:!0,inside:{punctuation:/^---|---$/,"front-matter":{pattern:/\S+(?:\s+\S+)*/,alias:[`yaml`,`language-yaml`],inside:e.languages.yaml}}},blockquote:{pattern:/^>(?:[\t ]*>)*/m,alias:`punctuation`},table:{pattern:RegExp(`^`+i+a+`(?:`+i+`)*`,`m`),inside:{"table-data-rows":{pattern:RegExp(`^(`+i+a+`)(?:`+i+`)*$`),lookbehind:!0,inside:{"table-data":{pattern:RegExp(r),inside:e.languages.markdown},punctuation:/\|/}},"table-line":{pattern:RegExp(`^(`+i+`)`+a+`$`),lookbehind:!0,inside:{punctuation:/\||:?-{3,}:?/}},"table-header-row":{pattern:RegExp(`^`+i+`$`),inside:{"table-header":{pattern:RegExp(r),alias:`important`,inside:e.languages.markdown},punctuation:/\|/}}}},code:[{pattern:/((?:^|\n)[ \t]*\n|(?:^|\r\n?)[ \t]*\r\n?)(?: {4}|\t).+(?:(?:\n|\r\n?)(?: {4}|\t).+)*/,lookbehind:!0,alias:`keyword`},{pattern:/^```[\s\S]*?^```$/m,greedy:!0,inside:{"code-block":{pattern:/^(```.*(?:\n|\r\n?))[\s\S]+?(?=(?:\n|\r\n?)^```$)/m,lookbehind:!0},"code-language":{pattern:/^(```).+/,lookbehind:!0},punctuation:/```/}}],title:[{pattern:/\S.*(?:\n|\r\n?)(?:==+|--+)(?=[ \t]*$)/m,alias:`important`,inside:{punctuation:/==+$|--+$/}},{pattern:/(^\s*)#.+/m,lookbehind:!0,alias:`important`,inside:{punctuation:/^#+|#+$/}}],hr:{pattern:/(^\s*)([*-])(?:[\t ]*\2){2,}(?=\s*$)/m,lookbehind:!0,alias:`punctuation`},list:{pattern:/(^\s*)(?:[*+-]|\d+\.)(?=[\t ].)/m,lookbehind:!0,alias:`punctuation`},"url-reference":{pattern:/!?\[[^\]]+\]:[\t ]+(?:\S+|<(?:\\.|[^>\\])+>)(?:[\t ]+(?:"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\((?:\\.|[^)\\])*\)))?/,inside:{variable:{pattern:/^(!?\[)[^\]]+/,lookbehind:!0},string:/(?:"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\((?:\\.|[^)\\])*\))$/,punctuation:/^[\[\]!:]|[<>]/},alias:`url`},bold:{pattern:n(`\\b__(?:(?!_)<inner>|_(?:(?!_)<inner>)+_)+__\\b|\\*\\*(?:(?!\\*)<inner>|\\*(?:(?!\\*)<inner>)+\\*)+\\*\\*`),lookbehind:!0,greedy:!0,inside:{content:{pattern:/(^..)[\s\S]+(?=..$)/,lookbehind:!0,inside:{}},punctuation:/\*\*|__/}},italic:{pattern:n(`\\b_(?:(?!_)<inner>|__(?:(?!_)<inner>)+__)+_\\b|\\*(?:(?!\\*)<inner>|\\*\\*(?:(?!\\*)<inner>)+\\*\\*)+\\*`),lookbehind:!0,greedy:!0,inside:{content:{pattern:/(^.)[\s\S]+(?=.$)/,lookbehind:!0,inside:{}},punctuation:/[*_]/}},strike:{pattern:n(`(~~?)(?:(?!~)<inner>)+\\2`),lookbehind:!0,greedy:!0,inside:{content:{pattern:/(^~~?)[\s\S]+(?=\1$)/,lookbehind:!0,inside:{}},punctuation:/~~?/}},"code-snippet":{pattern:/(^|[^\\`])(?:``[^`\r\n]+(?:`[^`\r\n]+)*``(?!`)|`[^`\r\n]+`(?!`))/,lookbehind:!0,greedy:!0,alias:[`code`,`keyword`]},url:{pattern:n(`!?\\[(?:(?!\\])<inner>)+\\](?:\\([^\\s)]+(?:[\\t ]+"(?:\\\\.|[^"\\\\])*")?\\)|[ \\t]?\\[(?:(?!\\])<inner>)+\\])`),lookbehind:!0,greedy:!0,inside:{operator:/^!/,content:{pattern:/(^\[)[^\]]+(?=\])/,lookbehind:!0,inside:{}},variable:{pattern:/(^\][ \t]?\[)[^\]]+(?=\]$)/,lookbehind:!0},url:{pattern:/(^\]\()[^\s)]+/,lookbehind:!0},string:{pattern:/(^[ \t]+)"(?:\\.|[^"\\])*"(?=\)$)/,lookbehind:!0}}}}),[`url`,`bold`,`italic`,`strike`].forEach(function(t){[`url`,`bold`,`italic`,`strike`,`code-snippet`].forEach(function(n){t!==n&&(e.languages.markdown[t].inside.content.inside[n]=e.languages.markdown[n])})}),e.hooks.add(`after-tokenize`,function(e){e.language!==`markdown`&&e.language!==`md`||function e(t){if(t&&typeof t!=`string`)for(var n=0,r=t.length;n<r;n++){var i,a=t[n];a.type===`code`?(i=a.content[1],a=a.content[3],i&&a&&i.type===`code-language`&&a.type===`code-block`&&typeof i.content==`string`&&(i=i.content.replace(/\b#/g,`sharp`).replace(/\b\+\+/g,`pp`),i=`language-`+(i=(/[a-z][\w-]*/i.exec(i)||[``])[0].toLowerCase()),a.alias?typeof a.alias==`string`?a.alias=[a.alias,i]:a.alias.push(i):a.alias=[i])):e(a.content)}}(e.tokens)}),e.hooks.add(`wrap`,function(t){if(t.type===`code-block`){for(var n=``,r=0,i=t.classes.length;r<i;r++){var a=t.classes[r],a=/language-(.+)/.exec(a);if(a){n=a[1];break}}var l,u=e.languages[n];u?t.content=e.highlight(function(e){return e=e.replace(o,``),e=e.replace(/&(\w{1,8}|#x?[\da-f]{1,8});/gi,function(e,t){var n;return(t=t.toLowerCase())[0]===`#`?(n=t[1]===`x`?parseInt(t.slice(2),16):Number(t.slice(1)),c(n)):s[t]||e})}(t.content),u,n):n&&n!==`none`&&e.plugins.autoloader&&(l=`md-`+new Date().valueOf()+`-`+Math.floor(0x2386f26fc10000*Math.random()),t.attributes.id=l,e.plugins.autoloader.loadLanguages(n,function(){var t=document.getElementById(l);t&&(t.innerHTML=e.highlight(t.textContent,e.languages[n],n))}))}}),RegExp(e.languages.markup.tag.pattern.source,`gi`)),s={amp:`&`,lt:`<`,gt:`>`,quot:`"`},c=String.fromCodePoint||String.fromCharCode;e.languages.md=e.languages.markdown}(z),z.languages.graphql={comment:/#.*/,description:{pattern:/(?:"""(?:[^"]|(?!""")")*"""|"(?:\\.|[^\\"\r\n])*")(?=\s*[a-z_])/i,greedy:!0,alias:`string`,inside:{"language-markdown":{pattern:/(^"(?:"")?)(?!\1)[\s\S]+(?=\1$)/,lookbehind:!0,inside:z.languages.markdown}}},string:{pattern:/"""(?:[^"]|(?!""")")*"""|"(?:\\.|[^\\"\r\n])*"/,greedy:!0},number:/(?:\B-|\b)\d+(?:\.\d+)?(?:e[+-]?\d+)?\b/i,boolean:/\b(?:false|true)\b/,variable:/\$[a-z_]\w*/i,directive:{pattern:/@[a-z_]\w*/i,alias:`function`},"attr-name":{pattern:/\b[a-z_]\w*(?=\s*(?:\((?:[^()"]|"(?:\\.|[^\\"\r\n])*")*\))?:)/i,greedy:!0},"atom-input":{pattern:/\b[A-Z]\w*Input\b/,alias:`class-name`},scalar:/\b(?:Boolean|Float|ID|Int|String)\b/,constant:/\b[A-Z][A-Z_\d]*\b/,"class-name":{pattern:/(\b(?:enum|implements|interface|on|scalar|type|union)\s+|&\s*|:\s*|\[)[A-Z_]\w*/,lookbehind:!0},fragment:{pattern:/(\bfragment\s+|\.{3}\s*(?!on\b))[a-zA-Z_]\w*/,lookbehind:!0,alias:`function`},"definition-mutation":{pattern:/(\bmutation\s+)[a-zA-Z_]\w*/,lookbehind:!0,alias:`function`},"definition-query":{pattern:/(\bquery\s+)[a-zA-Z_]\w*/,lookbehind:!0,alias:`function`},keyword:/\b(?:directive|enum|extend|fragment|implements|input|interface|mutation|on|query|repeatable|scalar|schema|subscription|type|union)\b/,operator:/[!=|&]|\.{3}/,"property-query":/\w+(?=\s*\()/,object:/\w+(?=\s*\{)/,punctuation:/[!(){}\[\]:=,]/,property:/\w+/},z.hooks.add(`after-tokenize`,function(e){if(e.language===`graphql`)for(var t=e.tokens.filter(function(e){return typeof e!=`string`&&e.type!==`comment`&&e.type!==`scalar`}),n=0;n<t.length;){var r=t[n++];if(r.type===`keyword`&&r.content===`mutation`){var i=[];if(d([`definition-mutation`,`punctuation`])&&u(1).content===`(`){n+=2;var a=f(/^\($/,/^\)$/);if(a===-1)continue;for(;n<a;n++){var o=u(0);o.type===`variable`&&(p(o,`variable-input`),i.push(o.content))}n=a+1}if(d([`punctuation`,`property-query`])&&u(0).content===`{`&&(n++,p(u(0),`property-mutation`),0<i.length)){var s=f(/^\{$/,/^\}$/);if(s!==-1)for(var c=n;c<s;c++){var l=t[c];l.type===`variable`&&0<=i.indexOf(l.content)&&p(l,`variable-input`)}}}}function u(e){return t[n+e]}function d(e,t){t||=0;for(var n=0;n<e.length;n++){var r=u(n+t);if(!r||r.type!==e[n])return}return 1}function f(e,r){for(var i=1,a=n;a<t.length;a++){var o=t[a],s=o.content;if(o.type===`punctuation`&&typeof s==`string`){if(e.test(s))i++;else if(r.test(s)&&--i===0)return a}}return-1}function p(e,t){var n=e.alias;n?Array.isArray(n)||(e.alias=n=[n]):e.alias=n=[],n.push(t)}}),z.languages.sql={comment:{pattern:/(^|[^\\])(?:\/\*[\s\S]*?\*\/|(?:--|\/\/|#).*)/,lookbehind:!0},variable:[{pattern:/@(["'`])(?:\\[\s\S]|(?!\1)[^\\])+\1/,greedy:!0},/@[\w.$]+/],string:{pattern:/(^|[^@\\])("|')(?:\\[\s\S]|(?!\2)[^\\]|\2\2)*\2/,greedy:!0,lookbehind:!0},identifier:{pattern:/(^|[^@\\])`(?:\\[\s\S]|[^`\\]|``)*`/,greedy:!0,lookbehind:!0,inside:{punctuation:/^`|`$/}},function:/\b(?:AVG|COUNT|FIRST|FORMAT|LAST|LCASE|LEN|MAX|MID|MIN|MOD|NOW|ROUND|SUM|UCASE)(?=\s*\()/i,keyword:/\b(?:ACTION|ADD|AFTER|ALGORITHM|ALL|ALTER|ANALYZE|ANY|APPLY|AS|ASC|AUTHORIZATION|AUTO_INCREMENT|BACKUP|BDB|BEGIN|BERKELEYDB|BIGINT|BINARY|BIT|BLOB|BOOL|BOOLEAN|BREAK|BROWSE|BTREE|BULK|BY|CALL|CASCADED?|CASE|CHAIN|CHAR(?:ACTER|SET)?|CHECK(?:POINT)?|CLOSE|CLUSTERED|COALESCE|COLLATE|COLUMNS?|COMMENT|COMMIT(?:TED)?|COMPUTE|CONNECT|CONSISTENT|CONSTRAINT|CONTAINS(?:TABLE)?|CONTINUE|CONVERT|CREATE|CROSS|CURRENT(?:_DATE|_TIME|_TIMESTAMP|_USER)?|CURSOR|CYCLE|DATA(?:BASES?)?|DATE(?:TIME)?|DAY|DBCC|DEALLOCATE|DEC|DECIMAL|DECLARE|DEFAULT|DEFINER|DELAYED|DELETE|DELIMITERS?|DENY|DESC|DESCRIBE|DETERMINISTIC|DISABLE|DISCARD|DISK|DISTINCT|DISTINCTROW|DISTRIBUTED|DO|DOUBLE|DROP|DUMMY|DUMP(?:FILE)?|DUPLICATE|ELSE(?:IF)?|ENABLE|ENCLOSED|END|ENGINE|ENUM|ERRLVL|ERRORS|ESCAPED?|EXCEPT|EXEC(?:UTE)?|EXISTS|EXIT|EXPLAIN|EXTENDED|FETCH|FIELDS|FILE|FILLFACTOR|FIRST|FIXED|FLOAT|FOLLOWING|FOR(?: EACH ROW)?|FORCE|FOREIGN|FREETEXT(?:TABLE)?|FROM|FULL|FUNCTION|GEOMETRY(?:COLLECTION)?|GLOBAL|GOTO|GRANT|GROUP|HANDLER|HASH|HAVING|HOLDLOCK|HOUR|IDENTITY(?:COL|_INSERT)?|IF|IGNORE|IMPORT|INDEX|INFILE|INNER|INNODB|INOUT|INSERT|INT|INTEGER|INTERSECT|INTERVAL|INTO|INVOKER|ISOLATION|ITERATE|JOIN|KEYS?|KILL|LANGUAGE|LAST|LEAVE|LEFT|LEVEL|LIMIT|LINENO|LINES|LINESTRING|LOAD|LOCAL|LOCK|LONG(?:BLOB|TEXT)|LOOP|MATCH(?:ED)?|MEDIUM(?:BLOB|INT|TEXT)|MERGE|MIDDLEINT|MINUTE|MODE|MODIFIES|MODIFY|MONTH|MULTI(?:LINESTRING|POINT|POLYGON)|NATIONAL|NATURAL|NCHAR|NEXT|NO|NONCLUSTERED|NULLIF|NUMERIC|OFF?|OFFSETS?|ON|OPEN(?:DATASOURCE|QUERY|ROWSET)?|OPTIMIZE|OPTION(?:ALLY)?|ORDER|OUT(?:ER|FILE)?|OVER|PARTIAL|PARTITION|PERCENT|PIVOT|PLAN|POINT|POLYGON|PRECEDING|PRECISION|PREPARE|PREV|PRIMARY|PRINT|PRIVILEGES|PROC(?:EDURE)?|PUBLIC|PURGE|QUICK|RAISERROR|READS?|REAL|RECONFIGURE|REFERENCES|RELEASE|RENAME|REPEAT(?:ABLE)?|REPLACE|REPLICATION|REQUIRE|RESIGNAL|RESTORE|RESTRICT|RETURN(?:ING|S)?|REVOKE|RIGHT|ROLLBACK|ROUTINE|ROW(?:COUNT|GUIDCOL|S)?|RTREE|RULE|SAVE(?:POINT)?|SCHEMA|SECOND|SELECT|SERIAL(?:IZABLE)?|SESSION(?:_USER)?|SET(?:USER)?|SHARE|SHOW|SHUTDOWN|SIMPLE|SMALLINT|SNAPSHOT|SOME|SONAME|SQL|START(?:ING)?|STATISTICS|STATUS|STRIPED|SYSTEM_USER|TABLES?|TABLESPACE|TEMP(?:ORARY|TABLE)?|TERMINATED|TEXT(?:SIZE)?|THEN|TIME(?:STAMP)?|TINY(?:BLOB|INT|TEXT)|TOP?|TRAN(?:SACTIONS?)?|TRIGGER|TRUNCATE|TSEQUAL|TYPES?|UNBOUNDED|UNCOMMITTED|UNDEFINED|UNION|UNIQUE|UNLOCK|UNPIVOT|UNSIGNED|UPDATE(?:TEXT)?|USAGE|USE|USER|USING|VALUES?|VAR(?:BINARY|CHAR|CHARACTER|YING)|VIEW|WAITFOR|WARNINGS|WHEN|WHERE|WHILE|WITH(?: ROLLUP|IN)?|WORK|WRITE(?:TEXT)?|YEAR)\b/i,boolean:/\b(?:FALSE|NULL|TRUE)\b/i,number:/\b0x[\da-f]+\b|\b\d+(?:\.\d*)?|\B\.\d+\b/i,operator:/[-+*\/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?|\b(?:AND|BETWEEN|DIV|ILIKE|IN|IS|LIKE|NOT|OR|REGEXP|RLIKE|SOUNDS LIKE|XOR)\b/i,punctuation:/[;[\]()`,.]/},function(e){var t=e.languages.javascript[`template-string`],n=t.pattern.source,r=t.inside.interpolation,i=r.inside[`interpolation-punctuation`],a=r.pattern.source;function o(t,r){if(e.languages[t])return{pattern:RegExp(`((?:`+r+`)\\s*)`+n),lookbehind:!0,greedy:!0,inside:{"template-punctuation":{pattern:/^`|`$/,alias:`string`},"embedded-code":{pattern:/[\s\S]+/,alias:t}}}}function s(t,n,r){return t={code:t,grammar:n,language:r},e.hooks.run(`before-tokenize`,t),t.tokens=e.tokenize(t.code,t.grammar),e.hooks.run(`after-tokenize`,t),t.tokens}function c(t,n,o){var c=e.tokenize(t,{interpolation:{pattern:RegExp(a),lookbehind:!0}}),l=0,u={},c=s(c.map(function(e){if(typeof e==`string`)return e;for(var n,r,e=e.content;t.indexOf((r=l++,n=`___`+o.toUpperCase()+`_`+r+`___`))!==-1;);return u[n]=e,n}).join(``),n,o),d=Object.keys(u);return l=0,function t(n){for(var a=0;a<n.length;a++){if(l>=d.length)return;var o,c,f,p,m,h,g,_=n[a];typeof _==`string`||typeof _.content==`string`?(o=d[l],(g=(h=typeof _==`string`?_:_.content).indexOf(o))!==-1&&(++l,c=h.substring(0,g),m=u[o],f=void 0,(p={})[`interpolation-punctuation`]=i,(p=e.tokenize(m,p)).length===3&&((f=[1,1]).push.apply(f,s(p[1],e.languages.javascript,`javascript`)),p.splice.apply(p,f)),f=new e.Token(`interpolation`,p,r.alias,m),p=h.substring(g+o.length),m=[],c&&m.push(c),m.push(f),p&&(t(h=[p]),m.push.apply(m,h)),typeof _==`string`?(n.splice.apply(n,[a,1].concat(m)),a+=m.length-1):_.content=m)):(g=_.content,t(Array.isArray(g)?g:[g]))}}(c),new e.Token(o,c,`language-`+o,t)}e.languages.javascript[`template-string`]=[o(`css`,`\\b(?:styled(?:\\([^)]*\\))?(?:\\s*\\.\\s*\\w+(?:\\([^)]*\\))*)*|css(?:\\s*\\.\\s*(?:global|resolve))?|createGlobalStyle|keyframes)`),o(`html`,`\\bhtml|\\.\\s*(?:inner|outer)HTML\\s*\\+?=`),o(`svg`,`\\bsvg`),o(`markdown`,`\\b(?:markdown|md)`),o(`graphql`,`\\b(?:gql|graphql(?:\\s*\\.\\s*experimental)?)`),o(`sql`,`\\bsql`),t].filter(Boolean);var l={javascript:!0,js:!0,typescript:!0,ts:!0,jsx:!0,tsx:!0};function u(e){return typeof e==`string`?e:Array.isArray(e)?e.map(u).join(``):u(e.content)}e.hooks.add(`after-tokenize`,function(t){t.language in l&&function t(n){for(var r=0,i=n.length;r<i;r++){var a,o,s,l=n[r];typeof l!=`string`&&(a=l.content,Array.isArray(a)?l.type===`template-string`?(l=a[1],a.length===3&&typeof l!=`string`&&l.type===`embedded-code`&&(o=u(l),l=l.alias,l=Array.isArray(l)?l[0]:l,s=e.languages[l])&&(a[1]=c(o,s,l))):t(a):typeof a!=`string`&&t([a]))}}(t.tokens)})}(z),function(e){e.languages.typescript=e.languages.extend(`javascript`,{"class-name":{pattern:/(\b(?:class|extends|implements|instanceof|interface|new|type)\s+)(?!keyof\b)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?:\s*<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>)?/,lookbehind:!0,greedy:!0,inside:null},builtin:/\b(?:Array|Function|Promise|any|boolean|console|never|number|string|symbol|unknown)\b/}),e.languages.typescript.keyword.push(/\b(?:abstract|declare|is|keyof|readonly|require)\b/,/\b(?:asserts|infer|interface|module|namespace|type)\b(?=\s*(?:[{_$a-zA-Z\xA0-\uFFFF]|$))/,/\btype\b(?=\s*(?:[\{*]|$))/),delete e.languages.typescript.parameter,delete e.languages.typescript[`literal-property`];var t=e.languages.extend(`typescript`,{});delete t[`class-name`],e.languages.typescript[`class-name`].inside=t,e.languages.insertBefore(`typescript`,`function`,{decorator:{pattern:/@[$\w\xA0-\uFFFF]+/,inside:{at:{pattern:/^@/,alias:`operator`},function:/^[\s\S]+/}},"generic-function":{pattern:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>(?=\s*\()/,greedy:!0,inside:{function:/^#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*/,generic:{pattern:/<[\s\S]+/,alias:`class-name`,inside:t}}}}),e.languages.ts=e.languages.typescript}(z),function(e){var t=e.languages.javascript,n=`\\{(?:[^{}]|\\{(?:[^{}]|\\{[^{}]*\\})*\\})+\\}`,r=`(@(?:arg|argument|param|property)\\s+(?:`+n+`\\s+)?)`;e.languages.jsdoc=e.languages.extend(`javadoclike`,{parameter:{pattern:RegExp(r+`(?:(?!\\s)[$\\w\\xA0-\\uFFFF.])+(?=\\s|$)`),lookbehind:!0,inside:{punctuation:/\./}}}),e.languages.insertBefore(`jsdoc`,`keyword`,{"optional-parameter":{pattern:RegExp(r+`\\[(?:(?!\\s)[$\\w\\xA0-\\uFFFF.])+(?:=[^[\\]]+)?\\](?=\\s|$)`),lookbehind:!0,inside:{parameter:{pattern:/(^\[)[$\w\xA0-\uFFFF\.]+/,lookbehind:!0,inside:{punctuation:/\./}},code:{pattern:/(=)[\s\S]*(?=\]$)/,lookbehind:!0,inside:t,alias:`language-javascript`},punctuation:/[=[\]]/}},"class-name":[{pattern:RegExp(`(@(?:augments|class|extends|interface|memberof!?|template|this|typedef)\\s+(?:<TYPE>\\s+)?)[A-Z]\\w*(?:\\.[A-Z]\\w*)*`.replace(/<TYPE>/g,function(){return n})),lookbehind:!0,inside:{punctuation:/\./}},{pattern:RegExp(`(@[a-z]+\\s+)`+n),lookbehind:!0,inside:{string:t.string,number:t.number,boolean:t.boolean,keyword:e.languages.typescript.keyword,operator:/=>|\.\.\.|[&|?:*]/,punctuation:/[.,;=<>{}()[\]]/}}],example:{pattern:/(@example\s+(?!\s))(?:[^@\s]|\s+(?!\s))+?(?=\s*(?:\*\s*)?(?:@\w|\*\/))/,lookbehind:!0,inside:{code:{pattern:/^([\t ]*(?:\*\s*)?)\S.*$/m,lookbehind:!0,inside:t,alias:`language-javascript`}}}}),e.languages.javadoclike.addSupport(`javascript`,e.languages.jsdoc)}(z),function(e){e.languages.flow=e.languages.extend(`javascript`,{}),e.languages.insertBefore(`flow`,`keyword`,{type:[{pattern:/\b(?:[Bb]oolean|Function|[Nn]umber|[Ss]tring|[Ss]ymbol|any|mixed|null|void)\b/,alias:`class-name`}]}),e.languages.flow[`function-variable`].pattern=/(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=\s*(?:function\b|(?:\([^()]*\)(?:\s*:\s*\w+)?|(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)\s*=>))/i,delete e.languages.flow.parameter,e.languages.insertBefore(`flow`,`operator`,{"flow-punctuation":{pattern:/\{\||\|\}/,alias:`punctuation`}}),Array.isArray(e.languages.flow.keyword)||(e.languages.flow.keyword=[e.languages.flow.keyword]),e.languages.flow.keyword.unshift({pattern:/(^|[^$]\b)(?:Class|declare|opaque|type)\b(?!\$)/,lookbehind:!0},{pattern:/(^|[^$]\B)\$(?:Diff|Enum|Exact|Keys|ObjMap|PropertyType|Record|Shape|Subtype|Supertype|await)\b(?!\$)/,lookbehind:!0})}(z),z.languages.n4js=z.languages.extend(`javascript`,{keyword:/\b(?:Array|any|boolean|break|case|catch|class|const|constructor|continue|debugger|declare|default|delete|do|else|enum|export|extends|false|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|module|new|null|number|package|private|protected|public|return|set|static|string|super|switch|this|throw|true|try|typeof|var|void|while|with|yield)\b/}),z.languages.insertBefore(`n4js`,`constant`,{annotation:{pattern:/@+\w+/,alias:`operator`}}),z.languages.n4jsd=z.languages.n4js,function(e){function t(e,t){return RegExp(e.replace(/<ID>/g,function(){return`(?!\\s)[_$a-zA-Z\\xA0-\\uFFFF](?:(?!\\s)[$\\w\\xA0-\\uFFFF])*`}),t)}e.languages.insertBefore(`javascript`,`function-variable`,{"method-variable":{pattern:RegExp(`(\\.\\s*)`+e.languages.javascript[`function-variable`].pattern.source),lookbehind:!0,alias:[`function-variable`,`method`,`function`,`property-access`]}}),e.languages.insertBefore(`javascript`,`function`,{method:{pattern:RegExp(`(\\.\\s*)`+e.languages.javascript.function.source),lookbehind:!0,alias:[`function`,`property-access`]}}),e.languages.insertBefore(`javascript`,`constant`,{"known-class-name":[{pattern:/\b(?:(?:Float(?:32|64)|(?:Int|Uint)(?:8|16|32)|Uint8Clamped)?Array|ArrayBuffer|BigInt|Boolean|DataView|Date|Error|Function|Intl|JSON|(?:Weak)?(?:Map|Set)|Math|Number|Object|Promise|Proxy|Reflect|RegExp|String|Symbol|WebAssembly)\b/,alias:`class-name`},{pattern:/\b(?:[A-Z]\w*)Error\b/,alias:`class-name`}]}),e.languages.insertBefore(`javascript`,`keyword`,{imports:{pattern:t(`(\\bimport\\b\\s*)(?:<ID>(?:\\s*,\\s*(?:\\*\\s*as\\s+<ID>|\\{[^{}]*\\}))?|\\*\\s*as\\s+<ID>|\\{[^{}]*\\})(?=\\s*\\bfrom\\b)`),lookbehind:!0,inside:e.languages.javascript},exports:{pattern:t(`(\\bexport\\b\\s*)(?:\\*(?:\\s*as\\s+<ID>)?(?=\\s*\\bfrom\\b)|\\{[^{}]*\\})`),lookbehind:!0,inside:e.languages.javascript}}),e.languages.javascript.keyword.unshift({pattern:/\b(?:as|default|export|from|import)\b/,alias:`module`},{pattern:/\b(?:await|break|catch|continue|do|else|finally|for|if|return|switch|throw|try|while|yield)\b/,alias:`control-flow`},{pattern:/\bnull\b/,alias:[`null`,`nil`]},{pattern:/\bundefined\b/,alias:`nil`}),e.languages.insertBefore(`javascript`,`operator`,{spread:{pattern:/\.{3}/,alias:`operator`},arrow:{pattern:/=>/,alias:`operator`}}),e.languages.insertBefore(`javascript`,`punctuation`,{"property-access":{pattern:t(`(\\.\\s*)#?<ID>`),lookbehind:!0},"maybe-class-name":{pattern:/(^|[^$\w\xA0-\uFFFF])[A-Z][$\w\xA0-\uFFFF]+/,lookbehind:!0},dom:{pattern:/\b(?:document|(?:local|session)Storage|location|navigator|performance|window)\b/,alias:`variable`},console:{pattern:/\bconsole(?=\s*\.)/,alias:`class-name`}});for(var n=[`function`,`function-variable`,`method`,`method-variable`,`property-access`],r=0;r<n.length;r++){var i=n[r],a=e.languages.javascript[i],i=(a=e.util.type(a)===`RegExp`?e.languages.javascript[i]={pattern:a}:a).inside||{};(a.inside=i)[`maybe-class-name`]=/^[A-Z][\s\S]*/}}(z),function(e){var t=e.util.clone(e.languages.javascript),n=`(?:\\s|\\/\\/.*(?!.)|\\/\\*(?:[^*]|\\*(?!\\/))\\*\\/)`,r=`(?:\\{(?:\\{(?:\\{[^{}]*\\}|[^{}])*\\}|[^{}])*\\})`,i=`(?:\\{<S>*\\.{3}(?:[^{}]|<BRACES>)*\\})`;function a(e,t){return e=e.replace(/<S>/g,function(){return n}).replace(/<BRACES>/g,function(){return r}).replace(/<SPREAD>/g,function(){return i}),RegExp(e,t)}i=a(i).source,e.languages.jsx=e.languages.extend(`markup`,t),e.languages.jsx.tag.pattern=a(`<\\/?(?:[\\w.:-]+(?:<S>+(?:[\\w.:$-]+(?:=(?:"(?:\\\\[\\s\\S]|[^\\\\"])*"|'(?:\\\\[\\s\\S]|[^\\\\'])*'|[^\\s{'"/>=]+|<BRACES>))?|<SPREAD>))*<S>*\\/?)?>`),e.languages.jsx.tag.inside.tag.pattern=/^<\/?[^\s>\/]*/,e.languages.jsx.tag.inside[`attr-value`].pattern=/=(?!\{)(?:"(?:\\[\s\S]|[^\\"])*"|'(?:\\[\s\S]|[^\\'])*'|[^\s'">]+)/,e.languages.jsx.tag.inside.tag.inside[`class-name`]=/^[A-Z]\w*(?:\.[A-Z]\w*)*$/,e.languages.jsx.tag.inside.comment=t.comment,e.languages.insertBefore(`inside`,`attr-name`,{spread:{pattern:a(`<SPREAD>`),inside:e.languages.jsx}},e.languages.jsx.tag),e.languages.insertBefore(`inside`,`special-attr`,{script:{pattern:a(`=<BRACES>`),alias:`language-javascript`,inside:{"script-punctuation":{pattern:/^=(?=\{)/,alias:`punctuation`},rest:e.languages.jsx}}},e.languages.jsx.tag);function o(t){for(var n=[],r=0;r<t.length;r++){var i=t[r],a=!1;typeof i!=`string`&&(i.type===`tag`&&i.content[0]&&i.content[0].type===`tag`?i.content[0].content[0].content===`</`?0<n.length&&n[n.length-1].tagName===s(i.content[0].content[1])&&n.pop():i.content[i.content.length-1].content!==`/>`&&n.push({tagName:s(i.content[0].content[1]),openedBraces:0}):0<n.length&&i.type===`punctuation`&&i.content===`{`?n[n.length-1].openedBraces++:0<n.length&&0<n[n.length-1].openedBraces&&i.type===`punctuation`&&i.content===`}`?n[n.length-1].openedBraces--:a=!0),(a||typeof i==`string`)&&0<n.length&&n[n.length-1].openedBraces===0&&(a=s(i),r<t.length-1&&(typeof t[r+1]==`string`||t[r+1].type===`plain-text`)&&(a+=s(t[r+1]),t.splice(r+1,1)),0<r&&(typeof t[r-1]==`string`||t[r-1].type===`plain-text`)&&(a=s(t[r-1])+a,t.splice(r-1,1),r--),t[r]=new e.Token(`plain-text`,a,null,a)),i.content&&typeof i.content!=`string`&&o(i.content)}}var s=function(e){return e?typeof e==`string`?e:typeof e.content==`string`?e.content:e.content.map(s).join(``):``};e.hooks.add(`after-tokenize`,function(e){e.language!==`jsx`&&e.language!==`tsx`||o(e.tokens)})}(z),function(e){var t=e.util.clone(e.languages.typescript),t=(e.languages.tsx=e.languages.extend(`jsx`,t),delete e.languages.tsx.parameter,delete e.languages.tsx[`literal-property`],e.languages.tsx.tag);t.pattern=RegExp(`(^|[^\\w$]|(?=<\\/))(?:`+t.pattern.source+`)`,t.pattern.flags),t.lookbehind=!0}(z),z.languages.swift={comment:{pattern:/(^|[^\\:])(?:\/\/.*|\/\*(?:[^/*]|\/(?!\*)|\*(?!\/)|\/\*(?:[^*]|\*(?!\/))*\*\/)*\*\/)/,lookbehind:!0,greedy:!0},"string-literal":[{pattern:RegExp(`(^|[^"#])(?:"(?:\\\\(?:\\((?:[^()]|\\([^()]*\\))*\\)|\\r\\n|[^(])|[^\\\\\\r\\n"])*"|"""(?:\\\\(?:\\((?:[^()]|\\([^()]*\\))*\\)|[^(])|[^\\\\"]|"(?!""))*""")(?!["#])`),lookbehind:!0,greedy:!0,inside:{interpolation:{pattern:/(\\\()(?:[^()]|\([^()]*\))*(?=\))/,lookbehind:!0,inside:null},"interpolation-punctuation":{pattern:/^\)|\\\($/,alias:`punctuation`},punctuation:/\\(?=[\r\n])/,string:/[\s\S]+/}},{pattern:RegExp(`(^|[^"#])(#+)(?:"(?:\\\\(?:#+\\((?:[^()]|\\([^()]*\\))*\\)|\\r\\n|[^#])|[^\\\\\\r\\n])*?"|"""(?:\\\\(?:#+\\((?:[^()]|\\([^()]*\\))*\\)|[^#])|[^\\\\])*?""")\\2`),lookbehind:!0,greedy:!0,inside:{interpolation:{pattern:/(\\#+\()(?:[^()]|\([^()]*\))*(?=\))/,lookbehind:!0,inside:null},"interpolation-punctuation":{pattern:/^\)|\\#+\($/,alias:`punctuation`},string:/[\s\S]+/}}],directive:{pattern:RegExp(`#(?:(?:elseif|if)\\b(?:[ ]*(?:![ \\t]*)?(?:\\b\\w+\\b(?:[ \\t]*\\((?:[^()]|\\([^()]*\\))*\\))?|\\((?:[^()]|\\([^()]*\\))*\\))(?:[ \\t]*(?:&&|\\|\\|))?)+|(?:else|endif)\\b)`),alias:`property`,inside:{"directive-name":/^#\w+/,boolean:/\b(?:false|true)\b/,number:/\b\d+(?:\.\d+)*\b/,operator:/!|&&|\|\||[<>]=?/,punctuation:/[(),]/}},literal:{pattern:/#(?:colorLiteral|column|dsohandle|file(?:ID|Literal|Path)?|function|imageLiteral|line)\b/,alias:`constant`},"other-directive":{pattern:/#\w+\b/,alias:`property`},attribute:{pattern:/@\w+/,alias:`atrule`},"function-definition":{pattern:/(\bfunc\s+)\w+/,lookbehind:!0,alias:`function`},label:{pattern:/\b(break|continue)\s+\w+|\b[a-zA-Z_]\w*(?=\s*:\s*(?:for|repeat|while)\b)/,lookbehind:!0,alias:`important`},keyword:/\b(?:Any|Protocol|Self|Type|actor|as|assignment|associatedtype|associativity|async|await|break|case|catch|class|continue|convenience|default|defer|deinit|didSet|do|dynamic|else|enum|extension|fallthrough|fileprivate|final|for|func|get|guard|higherThan|if|import|in|indirect|infix|init|inout|internal|is|isolated|lazy|left|let|lowerThan|mutating|none|nonisolated|nonmutating|open|operator|optional|override|postfix|precedencegroup|prefix|private|protocol|public|repeat|required|rethrows|return|right|safe|self|set|some|static|struct|subscript|super|switch|throw|throws|try|typealias|unowned|unsafe|var|weak|where|while|willSet)\b/,boolean:/\b(?:false|true)\b/,nil:{pattern:/\bnil\b/,alias:`constant`},"short-argument":/\$\d+\b/,omit:{pattern:/\b_\b/,alias:`keyword`},number:/\b(?:[\d_]+(?:\.[\de_]+)?|0x[a-f0-9_]+(?:\.[a-f0-9p_]+)?|0b[01_]+|0o[0-7_]+)\b/i,"class-name":/\b[A-Z](?:[A-Z_\d]*[a-z]\w*)?\b/,function:/\b[a-z_]\w*(?=\s*\()/i,constant:/\b(?:[A-Z_]{2,}|k[A-Z][A-Za-z_]+)\b/,operator:/[-+*/%=!<>&|^~?]+|\.[.\-+*/%=!<>&|^~?]+/,punctuation:/[{}[\]();,.:\\]/},z.languages.swift[`string-literal`].forEach(function(e){e.inside.interpolation.inside=z.languages.swift}),function(e){e.languages.kotlin=e.languages.extend(`clike`,{keyword:{pattern:/(^|[^.])\b(?:abstract|actual|annotation|as|break|by|catch|class|companion|const|constructor|continue|crossinline|data|do|dynamic|else|enum|expect|external|final|finally|for|fun|get|if|import|in|infix|init|inline|inner|interface|internal|is|lateinit|noinline|null|object|open|operator|out|override|package|private|protected|public|reified|return|sealed|set|super|suspend|tailrec|this|throw|to|try|typealias|val|var|vararg|when|where|while)\b/,lookbehind:!0},function:[{pattern:/(?:`[^\r\n`]+`|\b\w+)(?=\s*\()/,greedy:!0},{pattern:/(\.)(?:`[^\r\n`]+`|\w+)(?=\s*\{)/,lookbehind:!0,greedy:!0}],number:/\b(?:0[xX][\da-fA-F]+(?:_[\da-fA-F]+)*|0[bB][01]+(?:_[01]+)*|\d+(?:_\d+)*(?:\.\d+(?:_\d+)*)?(?:[eE][+-]?\d+(?:_\d+)*)?[fFL]?)\b/,operator:/\+[+=]?|-[-=>]?|==?=?|!(?:!|==?)?|[\/*%<>]=?|[?:]:?|\.\.|&&|\|\||\b(?:and|inv|or|shl|shr|ushr|xor)\b/}),delete e.languages.kotlin[`class-name`];var t={"interpolation-punctuation":{pattern:/^\$\{?|\}$/,alias:`punctuation`},expression:{pattern:/[\s\S]+/,inside:e.languages.kotlin}};e.languages.insertBefore(`kotlin`,`string`,{"string-literal":[{pattern:/"""(?:[^$]|\$(?:(?!\{)|\{[^{}]*\}))*?"""/,alias:`multiline`,inside:{interpolation:{pattern:/\$(?:[a-z_]\w*|\{[^{}]*\})/i,inside:t},string:/[\s\S]+/}},{pattern:/"(?:[^"\\\r\n$]|\\.|\$(?:(?!\{)|\{[^{}]*\}))*"/,alias:`singleline`,inside:{interpolation:{pattern:/((?:^|[^\\])(?:\\{2})*)\$(?:[a-z_]\w*|\{[^{}]*\})/i,lookbehind:!0,inside:t},string:/[\s\S]+/}}],char:{pattern:/'(?:[^'\\\r\n]|\\(?:.|u[a-fA-F0-9]{0,4}))'/,greedy:!0}}),delete e.languages.kotlin.string,e.languages.insertBefore(`kotlin`,`keyword`,{annotation:{pattern:/\B@(?:\w+:)?(?:[A-Z]\w*|\[[^\]]+\])/,alias:`builtin`}}),e.languages.insertBefore(`kotlin`,`function`,{label:{pattern:/\b\w+@|@\w+\b/,alias:`symbol`}}),e.languages.kt=e.languages.kotlin,e.languages.kts=e.languages.kotlin}(z),z.languages.c=z.languages.extend(`clike`,{comment:{pattern:/\/\/(?:[^\r\n\\]|\\(?:\r\n?|\n|(?![\r\n])))*|\/\*[\s\S]*?(?:\*\/|$)/,greedy:!0},string:{pattern:/"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"/,greedy:!0},"class-name":{pattern:/(\b(?:enum|struct)\s+(?:__attribute__\s*\(\([\s\S]*?\)\)\s*)?)\w+|\b[a-z]\w*_t\b/,lookbehind:!0},keyword:/\b(?:_Alignas|_Alignof|_Atomic|_Bool|_Complex|_Generic|_Imaginary|_Noreturn|_Static_assert|_Thread_local|__attribute__|asm|auto|break|case|char|const|continue|default|do|double|else|enum|extern|float|for|goto|if|inline|int|long|register|return|short|signed|sizeof|static|struct|switch|typedef|typeof|union|unsigned|void|volatile|while)\b/,function:/\b[a-z_]\w*(?=\s*\()/i,number:/(?:\b0x(?:[\da-f]+(?:\.[\da-f]*)?|\.[\da-f]+)(?:p[+-]?\d+)?|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?)[ful]{0,4}/i,operator:/>>=?|<<=?|->|([-+&|:])\1|[?:~]|[-+*/%&|^!=<>]=?/}),z.languages.insertBefore(`c`,`string`,{char:{pattern:/'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n]){0,32}'/,greedy:!0}}),z.languages.insertBefore(`c`,`string`,{macro:{pattern:/(^[\t ]*)#\s*[a-z](?:[^\r\n\\/]|\/(?!\*)|\/\*(?:[^*]|\*(?!\/))*\*\/|\\(?:\r\n|[\s\S]))*/im,lookbehind:!0,greedy:!0,alias:`property`,inside:{string:[{pattern:/^(#\s*include\s*)<[^>]+>/,lookbehind:!0},z.languages.c.string],char:z.languages.c.char,comment:z.languages.c.comment,"macro-name":[{pattern:/(^#\s*define\s+)\w+\b(?!\()/i,lookbehind:!0},{pattern:/(^#\s*define\s+)\w+\b(?=\()/i,lookbehind:!0,alias:`function`}],directive:{pattern:/^(#\s*)[a-z]+/,lookbehind:!0,alias:`keyword`},"directive-hash":/^#/,punctuation:/##|\\(?=[\r\n])/,expression:{pattern:/\S[\s\S]*/,inside:z.languages.c}}}}),z.languages.insertBefore(`c`,`function`,{constant:/\b(?:EOF|NULL|SEEK_CUR|SEEK_END|SEEK_SET|__DATE__|__FILE__|__LINE__|__TIMESTAMP__|__TIME__|__func__|stderr|stdin|stdout)\b/}),delete z.languages.c.boolean,z.languages.objectivec=z.languages.extend(`c`,{string:{pattern:/@?"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"/,greedy:!0},keyword:/\b(?:asm|auto|break|case|char|const|continue|default|do|double|else|enum|extern|float|for|goto|if|in|inline|int|long|register|return|self|short|signed|sizeof|static|struct|super|switch|typedef|typeof|union|unsigned|void|volatile|while)\b|(?:@interface|@end|@implementation|@protocol|@class|@public|@protected|@private|@property|@try|@catch|@finally|@throw|@synthesize|@dynamic|@selector)\b/,operator:/-[->]?|\+\+?|!=?|<<?=?|>>?=?|==?|&&?|\|\|?|[~^%?*\/@]/}),delete z.languages.objectivec[`class-name`],z.languages.objc=z.languages.objectivec,z.languages.reason=z.languages.extend(`clike`,{string:{pattern:/"(?:\\(?:\r\n|[\s\S])|[^\\\r\n"])*"/,greedy:!0},"class-name":/\b[A-Z]\w*/,keyword:/\b(?:and|as|assert|begin|class|constraint|do|done|downto|else|end|exception|external|for|fun|function|functor|if|in|include|inherit|initializer|lazy|let|method|module|mutable|new|nonrec|object|of|open|or|private|rec|sig|struct|switch|then|to|try|type|val|virtual|when|while|with)\b/,operator:/\.{3}|:[:=]|\|>|->|=(?:==?|>)?|<=?|>=?|[|^?'#!~`]|[+\-*\/]\.?|\b(?:asr|land|lor|lsl|lsr|lxor|mod)\b/}),z.languages.insertBefore(`reason`,`class-name`,{char:{pattern:/'(?:\\x[\da-f]{2}|\\o[0-3][0-7][0-7]|\\\d{3}|\\.|[^'\\\r\n])'/,greedy:!0},constructor:/\b[A-Z]\w*\b(?!\s*\.)/,label:{pattern:/\b[a-z]\w*(?=::)/,alias:`symbol`}}),delete z.languages.reason.function,function(e){for(var t=`\\/\\*(?:[^*/]|\\*(?!\\/)|\\/(?!\\*)|<self>)*\\*\\/`,n=0;n<2;n++)t=t.replace(/<self>/g,function(){return t});t=t.replace(/<self>/g,function(){return`[^\\s\\S]`}),e.languages.rust={comment:[{pattern:RegExp(`(^|[^\\\\])`+t),lookbehind:!0,greedy:!0},{pattern:/(^|[^\\:])\/\/.*/,lookbehind:!0,greedy:!0}],string:{pattern:/b?"(?:\\[\s\S]|[^\\"])*"|b?r(#*)"(?:[^"]|"(?!\1))*"\1/,greedy:!0},char:{pattern:/b?'(?:\\(?:x[0-7][\da-fA-F]|u\{(?:[\da-fA-F]_*){1,6}\}|.)|[^\\\r\n\t'])'/,greedy:!0},attribute:{pattern:/#!?\[(?:[^\[\]"]|"(?:\\[\s\S]|[^\\"])*")*\]/,greedy:!0,alias:`attr-name`,inside:{string:null}},"closure-params":{pattern:/([=(,:]\s*|\bmove\s*)\|[^|]*\||\|[^|]*\|(?=\s*(?:\{|->))/,lookbehind:!0,greedy:!0,inside:{"closure-punctuation":{pattern:/^\||\|$/,alias:`punctuation`},rest:null}},"lifetime-annotation":{pattern:/'\w+/,alias:`symbol`},"fragment-specifier":{pattern:/(\$\w+:)[a-z]+/,lookbehind:!0,alias:`punctuation`},variable:/\$\w+/,"function-definition":{pattern:/(\bfn\s+)\w+/,lookbehind:!0,alias:`function`},"type-definition":{pattern:/(\b(?:enum|struct|trait|type|union)\s+)\w+/,lookbehind:!0,alias:`class-name`},"module-declaration":[{pattern:/(\b(?:crate|mod)\s+)[a-z][a-z_\d]*/,lookbehind:!0,alias:`namespace`},{pattern:/(\b(?:crate|self|super)\s*)::\s*[a-z][a-z_\d]*\b(?:\s*::(?:\s*[a-z][a-z_\d]*\s*::)*)?/,lookbehind:!0,alias:`namespace`,inside:{punctuation:/::/}}],keyword:[/\b(?:Self|abstract|as|async|await|become|box|break|const|continue|crate|do|dyn|else|enum|extern|final|fn|for|if|impl|in|let|loop|macro|match|mod|move|mut|override|priv|pub|ref|return|self|static|struct|super|trait|try|type|typeof|union|unsafe|unsized|use|virtual|where|while|yield)\b/,/\b(?:bool|char|f(?:32|64)|[ui](?:8|16|32|64|128|size)|str)\b/],function:/\b[a-z_]\w*(?=\s*(?:::\s*<|\())/,macro:{pattern:/\b\w+!/,alias:`property`},constant:/\b[A-Z_][A-Z_\d]+\b/,"class-name":/\b[A-Z]\w*\b/,namespace:{pattern:/(?:\b[a-z][a-z_\d]*\s*::\s*)*\b[a-z][a-z_\d]*\s*::(?!\s*<)/,inside:{punctuation:/::/}},number:/\b(?:0x[\dA-Fa-f](?:_?[\dA-Fa-f])*|0o[0-7](?:_?[0-7])*|0b[01](?:_?[01])*|(?:(?:\d(?:_?\d)*)?\.)?\d(?:_?\d)*(?:[Ee][+-]?\d+)?)(?:_?(?:f32|f64|[iu](?:8|16|32|64|size)?))?\b/,boolean:/\b(?:false|true)\b/,punctuation:/->|\.\.=|\.{1,3}|::|[{}[\];(),:]/,operator:/[-+*\/%!^]=?|=[=>]?|&[&=]?|\|[|=]?|<<?=?|>>?=?|[@?]/},e.languages.rust[`closure-params`].inside.rest=e.languages.rust,e.languages.rust.attribute.inside.string=e.languages.rust.string}(z),z.languages.go=z.languages.extend(`clike`,{string:{pattern:/(^|[^\\])"(?:\\.|[^"\\\r\n])*"|`[^`]*`/,lookbehind:!0,greedy:!0},keyword:/\b(?:break|case|chan|const|continue|default|defer|else|fallthrough|for|func|go(?:to)?|if|import|interface|map|package|range|return|select|struct|switch|type|var)\b/,boolean:/\b(?:_|false|iota|nil|true)\b/,number:[/\b0(?:b[01_]+|o[0-7_]+)i?\b/i,/\b0x(?:[a-f\d_]+(?:\.[a-f\d_]*)?|\.[a-f\d_]+)(?:p[+-]?\d+(?:_\d+)*)?i?(?!\w)/i,/(?:\b\d[\d_]*(?:\.[\d_]*)?|\B\.\d[\d_]*)(?:e[+-]?[\d_]+)?i?(?!\w)/i],operator:/[*\/%^!=]=?|\+[=+]?|-[=-]?|\|[=|]?|&(?:=|&|\^=?)?|>(?:>=?|=)?|<(?:<=?|=|-)?|:=|\.\.\./,builtin:/\b(?:append|bool|byte|cap|close|complex|complex(?:64|128)|copy|delete|error|float(?:32|64)|u?int(?:8|16|32|64)?|imag|len|make|new|panic|print(?:ln)?|real|recover|rune|string|uintptr)\b/}),z.languages.insertBefore(`go`,`string`,{char:{pattern:/'(?:\\.|[^'\\\r\n]){0,10}'/,greedy:!0}}),delete z.languages.go[`class-name`],function(e){var t=/\b(?:alignas|alignof|asm|auto|bool|break|case|catch|char|char16_t|char32_t|char8_t|class|co_await|co_return|co_yield|compl|concept|const|const_cast|consteval|constexpr|constinit|continue|decltype|default|delete|do|double|dynamic_cast|else|enum|explicit|export|extern|final|float|for|friend|goto|if|import|inline|int|int16_t|int32_t|int64_t|int8_t|long|module|mutable|namespace|new|noexcept|nullptr|operator|override|private|protected|public|register|reinterpret_cast|requires|return|short|signed|sizeof|static|static_assert|static_cast|struct|switch|template|this|thread_local|throw|try|typedef|typeid|typename|uint16_t|uint32_t|uint64_t|uint8_t|union|unsigned|using|virtual|void|volatile|wchar_t|while)\b/,n=`\\b(?!<keyword>)\\w+(?:\\s*\\.\\s*\\w+)*\\b`.replace(/<keyword>/g,function(){return t.source});e.languages.cpp=e.languages.extend(`c`,{"class-name":[{pattern:RegExp(`(\\b(?:class|concept|enum|struct|typename)\\s+)(?!<keyword>)\\w+`.replace(/<keyword>/g,function(){return t.source})),lookbehind:!0},/\b[A-Z]\w*(?=\s*::\s*\w+\s*\()/,/\b[A-Z_]\w*(?=\s*::\s*~\w+\s*\()/i,/\b\w+(?=\s*<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>\s*::\s*\w+\s*\()/],keyword:t,number:{pattern:/(?:\b0b[01']+|\b0x(?:[\da-f']+(?:\.[\da-f']*)?|\.[\da-f']+)(?:p[+-]?[\d']+)?|(?:\b[\d']+(?:\.[\d']*)?|\B\.[\d']+)(?:e[+-]?[\d']+)?)[ful]{0,4}/i,greedy:!0},operator:/>>=?|<<=?|->|--|\+\+|&&|\|\||[?:~]|<=>|[-+*/%&|^!=<>]=?|\b(?:and|and_eq|bitand|bitor|not|not_eq|or|or_eq|xor|xor_eq)\b/,boolean:/\b(?:false|true)\b/}),e.languages.insertBefore(`cpp`,`string`,{module:{pattern:RegExp(`(\\b(?:import|module)\\s+)(?:"(?:\\\\(?:\\r\\n|[\\s\\S])|[^"\\\\\\r\\n])*"|<[^<>\\r\\n]*>|`+`<mod-name>(?:\\s*:\\s*<mod-name>)?|:\\s*<mod-name>`.replace(/<mod-name>/g,function(){return n})+`)`),lookbehind:!0,greedy:!0,inside:{string:/^[<"][\s\S]+/,operator:/:/,punctuation:/\./}},"raw-string":{pattern:/R"([^()\\ ]{0,16})\([\s\S]*?\)\1"/,alias:`string`,greedy:!0}}),e.languages.insertBefore(`cpp`,`keyword`,{"generic-function":{pattern:/\b(?!operator\b)[a-z_]\w*\s*<(?:[^<>]|<[^<>]*>)*>(?=\s*\()/i,inside:{function:/^\w+/,generic:{pattern:/<[\s\S]+/,alias:`class-name`,inside:e.languages.cpp}}}}),e.languages.insertBefore(`cpp`,`operator`,{"double-colon":{pattern:/::/,alias:`punctuation`}}),e.languages.insertBefore(`cpp`,`class-name`,{"base-clause":{pattern:/(\b(?:class|struct)\s+\w+\s*:\s*)[^;{}"'\s]+(?:\s+[^;{}"'\s]+)*(?=\s*[;{])/,lookbehind:!0,greedy:!0,inside:e.languages.extend(`cpp`,{})}}),e.languages.insertBefore(`inside`,`double-colon`,{"class-name":/\b[a-z_]\w*\b(?!\s*::)/i},e.languages.cpp[`base-clause`])}(z),z.languages.python={comment:{pattern:/(^|[^\\])#.*/,lookbehind:!0,greedy:!0},"string-interpolation":{pattern:/(?:f|fr|rf)(?:("""|''')[\s\S]*?\1|("|')(?:\\.|(?!\2)[^\\\r\n])*\2)/i,greedy:!0,inside:{interpolation:{pattern:/((?:^|[^{])(?:\{\{)*)\{(?!\{)(?:[^{}]|\{(?!\{)(?:[^{}]|\{(?!\{)(?:[^{}])+\})+\})+\}/,lookbehind:!0,inside:{"format-spec":{pattern:/(:)[^:(){}]+(?=\}$)/,lookbehind:!0},"conversion-option":{pattern:/![sra](?=[:}]$)/,alias:`punctuation`},rest:null}},string:/[\s\S]+/}},"triple-quoted-string":{pattern:/(?:[rub]|br|rb)?("""|''')[\s\S]*?\1/i,greedy:!0,alias:`string`},string:{pattern:/(?:[rub]|br|rb)?("|')(?:\\.|(?!\1)[^\\\r\n])*\1/i,greedy:!0},function:{pattern:/((?:^|\s)def[ \t]+)[a-zA-Z_]\w*(?=\s*\()/g,lookbehind:!0},"class-name":{pattern:/(\bclass\s+)\w+/i,lookbehind:!0},decorator:{pattern:/(^[\t ]*)@\w+(?:\.\w+)*/m,lookbehind:!0,alias:[`annotation`,`punctuation`],inside:{punctuation:/\./}},keyword:/\b(?:_(?=\s*:)|and|as|assert|async|await|break|case|class|continue|def|del|elif|else|except|exec|finally|for|from|global|if|import|in|is|lambda|match|nonlocal|not|or|pass|print|raise|return|try|while|with|yield)\b/,builtin:/\b(?:__import__|abs|all|any|apply|ascii|basestring|bin|bool|buffer|bytearray|bytes|callable|chr|classmethod|cmp|coerce|compile|complex|delattr|dict|dir|divmod|enumerate|eval|execfile|file|filter|float|format|frozenset|getattr|globals|hasattr|hash|help|hex|id|input|int|intern|isinstance|issubclass|iter|len|list|locals|long|map|max|memoryview|min|next|object|oct|open|ord|pow|property|range|raw_input|reduce|reload|repr|reversed|round|set|setattr|slice|sorted|staticmethod|str|sum|super|tuple|type|unichr|unicode|vars|xrange|zip)\b/,boolean:/\b(?:False|None|True)\b/,number:/\b0(?:b(?:_?[01])+|o(?:_?[0-7])+|x(?:_?[a-f0-9])+)\b|(?:\b\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\B\.\d+(?:_\d+)*)(?:e[+-]?\d+(?:_\d+)*)?j?(?!\w)/i,operator:/[-+%=]=?|!=|:=|\*\*?=?|\/\/?=?|<[<=>]?|>[=>]?|[&|^~]/,punctuation:/[{}[\];(),.:]/},z.languages.python[`string-interpolation`].inside.interpolation.inside.rest=z.languages.python,z.languages.py=z.languages.python,z.languages.json={property:{pattern:/(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?=\s*:)/,lookbehind:!0,greedy:!0},string:{pattern:/(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?!\s*:)/,lookbehind:!0,greedy:!0},comment:{pattern:/\/\/.*|\/\*[\s\S]*?(?:\*\/|$)/,greedy:!0},number:/-?\b\d+(?:\.\d+)?(?:e[+-]?\d+)?\b/i,punctuation:/[{}[\],]/,operator:/:/,boolean:/\b(?:false|true)\b/,null:{pattern:/\bnull\b/,alias:`keyword`}},z.languages.webmanifest=z.languages.json;var Xi={};Ji(Xi,{dracula:()=>Zi,duotoneDark:()=>Qi,duotoneLight:()=>$i,github:()=>ea,gruvboxMaterialDark:()=>ga,gruvboxMaterialLight:()=>_a,jettwaveDark:()=>fa,jettwaveLight:()=>pa,nightOwl:()=>ta,nightOwlLight:()=>na,oceanicNext:()=>ia,okaidia:()=>aa,oneDark:()=>ma,oneLight:()=>ha,palenight:()=>oa,shadesOfPurple:()=>sa,synthwave84:()=>ca,ultramin:()=>la,vsDark:()=>ua,vsLight:()=>da});var Zi={plain:{color:`#F8F8F2`,backgroundColor:`#282A36`},styles:[{types:[`prolog`,`constant`,`builtin`],style:{color:`rgb(189, 147, 249)`}},{types:[`inserted`,`function`],style:{color:`rgb(80, 250, 123)`}},{types:[`deleted`],style:{color:`rgb(255, 85, 85)`}},{types:[`changed`],style:{color:`rgb(255, 184, 108)`}},{types:[`punctuation`,`symbol`],style:{color:`rgb(248, 248, 242)`}},{types:[`string`,`char`,`tag`,`selector`],style:{color:`rgb(255, 121, 198)`}},{types:[`keyword`,`variable`],style:{color:`rgb(189, 147, 249)`,fontStyle:`italic`}},{types:[`comment`],style:{color:`rgb(98, 114, 164)`}},{types:[`attr-name`],style:{color:`rgb(241, 250, 140)`}}]},Qi={plain:{backgroundColor:`#2a2734`,color:`#9a86fd`},styles:[{types:[`comment`,`prolog`,`doctype`,`cdata`,`punctuation`],style:{color:`#6c6783`}},{types:[`namespace`],style:{opacity:.7}},{types:[`tag`,`operator`,`number`],style:{color:`#e09142`}},{types:[`property`,`function`],style:{color:`#9a86fd`}},{types:[`tag-id`,`selector`,`atrule-id`],style:{color:`#eeebff`}},{types:[`attr-name`],style:{color:`#c4b9fe`}},{types:[`boolean`,`string`,`entity`,`url`,`attr-value`,`keyword`,`control`,`directive`,`unit`,`statement`,`regex`,`atrule`,`placeholder`,`variable`],style:{color:`#ffcc99`}},{types:[`deleted`],style:{textDecorationLine:`line-through`}},{types:[`inserted`],style:{textDecorationLine:`underline`}},{types:[`italic`],style:{fontStyle:`italic`}},{types:[`important`,`bold`],style:{fontWeight:`bold`}},{types:[`important`],style:{color:`#c4b9fe`}}]},$i={plain:{backgroundColor:`#faf8f5`,color:`#728fcb`},styles:[{types:[`comment`,`prolog`,`doctype`,`cdata`,`punctuation`],style:{color:`#b6ad9a`}},{types:[`namespace`],style:{opacity:.7}},{types:[`tag`,`operator`,`number`],style:{color:`#063289`}},{types:[`property`,`function`],style:{color:`#b29762`}},{types:[`tag-id`,`selector`,`atrule-id`],style:{color:`#2d2006`}},{types:[`attr-name`],style:{color:`#896724`}},{types:[`boolean`,`string`,`entity`,`url`,`attr-value`,`keyword`,`control`,`directive`,`unit`,`statement`,`regex`,`atrule`],style:{color:`#728fcb`}},{types:[`placeholder`,`variable`],style:{color:`#93abdc`}},{types:[`deleted`],style:{textDecorationLine:`line-through`}},{types:[`inserted`],style:{textDecorationLine:`underline`}},{types:[`italic`],style:{fontStyle:`italic`}},{types:[`important`,`bold`],style:{fontWeight:`bold`}},{types:[`important`],style:{color:`#896724`}}]},ea={plain:{color:`#393A34`,backgroundColor:`#f6f8fa`},styles:[{types:[`comment`,`prolog`,`doctype`,`cdata`],style:{color:`#999988`,fontStyle:`italic`}},{types:[`namespace`],style:{opacity:.7}},{types:[`string`,`attr-value`],style:{color:`#e3116c`}},{types:[`punctuation`,`operator`],style:{color:`#393A34`}},{types:[`entity`,`url`,`symbol`,`number`,`boolean`,`variable`,`constant`,`property`,`regex`,`inserted`],style:{color:`#36acaa`}},{types:[`atrule`,`keyword`,`attr-name`,`selector`],style:{color:`#00a4db`}},{types:[`function`,`deleted`,`tag`],style:{color:`#d73a49`}},{types:[`function-variable`],style:{color:`#6f42c1`}},{types:[`tag`,`selector`,`keyword`],style:{color:`#00009f`}}]},ta={plain:{color:`#d6deeb`,backgroundColor:`#011627`},styles:[{types:[`changed`],style:{color:`rgb(162, 191, 252)`,fontStyle:`italic`}},{types:[`deleted`],style:{color:`rgba(239, 83, 80, 0.56)`,fontStyle:`italic`}},{types:[`inserted`,`attr-name`],style:{color:`rgb(173, 219, 103)`,fontStyle:`italic`}},{types:[`comment`],style:{color:`rgb(99, 119, 119)`,fontStyle:`italic`}},{types:[`string`,`url`],style:{color:`rgb(173, 219, 103)`}},{types:[`variable`],style:{color:`rgb(214, 222, 235)`}},{types:[`number`],style:{color:`rgb(247, 140, 108)`}},{types:[`builtin`,`char`,`constant`,`function`],style:{color:`rgb(130, 170, 255)`}},{types:[`punctuation`],style:{color:`rgb(199, 146, 234)`}},{types:[`selector`,`doctype`],style:{color:`rgb(199, 146, 234)`,fontStyle:`italic`}},{types:[`class-name`],style:{color:`rgb(255, 203, 139)`}},{types:[`tag`,`operator`,`keyword`],style:{color:`rgb(127, 219, 202)`}},{types:[`boolean`],style:{color:`rgb(255, 88, 116)`}},{types:[`property`],style:{color:`rgb(128, 203, 196)`}},{types:[`namespace`],style:{color:`rgb(178, 204, 214)`}}]},na={plain:{color:`#403f53`,backgroundColor:`#FBFBFB`},styles:[{types:[`changed`],style:{color:`rgb(162, 191, 252)`,fontStyle:`italic`}},{types:[`deleted`],style:{color:`rgba(239, 83, 80, 0.56)`,fontStyle:`italic`}},{types:[`inserted`,`attr-name`],style:{color:`rgb(72, 118, 214)`,fontStyle:`italic`}},{types:[`comment`],style:{color:`rgb(152, 159, 177)`,fontStyle:`italic`}},{types:[`string`,`builtin`,`char`,`constant`,`url`],style:{color:`rgb(72, 118, 214)`}},{types:[`variable`],style:{color:`rgb(201, 103, 101)`}},{types:[`number`],style:{color:`rgb(170, 9, 130)`}},{types:[`punctuation`],style:{color:`rgb(153, 76, 195)`}},{types:[`function`,`selector`,`doctype`],style:{color:`rgb(153, 76, 195)`,fontStyle:`italic`}},{types:[`class-name`],style:{color:`rgb(17, 17, 17)`}},{types:[`tag`],style:{color:`rgb(153, 76, 195)`}},{types:[`operator`,`property`,`keyword`,`namespace`],style:{color:`rgb(12, 150, 155)`}},{types:[`boolean`],style:{color:`rgb(188, 84, 84)`}}]},ra={char:`#D8DEE9`,comment:`#999999`,keyword:`#c5a5c5`,primitive:`#5a9bcf`,string:`#8dc891`,variable:`#d7deea`,boolean:`#ff8b50`,punctuation:`#5FB3B3`,tag:`#fc929e`,function:`#79b6f2`,className:`#FAC863`,method:`#6699CC`,operator:`#fc929e`},ia={plain:{backgroundColor:`#282c34`,color:`#ffffff`},styles:[{types:[`attr-name`],style:{color:ra.keyword}},{types:[`attr-value`],style:{color:ra.string}},{types:[`comment`,`block-comment`,`prolog`,`doctype`,`cdata`,`shebang`],style:{color:ra.comment}},{types:[`property`,`number`,`function-name`,`constant`,`symbol`,`deleted`],style:{color:ra.primitive}},{types:[`boolean`],style:{color:ra.boolean}},{types:[`tag`],style:{color:ra.tag}},{types:[`string`],style:{color:ra.string}},{types:[`punctuation`],style:{color:ra.string}},{types:[`selector`,`char`,`builtin`,`inserted`],style:{color:ra.char}},{types:[`function`],style:{color:ra.function}},{types:[`operator`,`entity`,`url`,`variable`],style:{color:ra.variable}},{types:[`keyword`],style:{color:ra.keyword}},{types:[`atrule`,`class-name`],style:{color:ra.className}},{types:[`important`],style:{fontWeight:`400`}},{types:[`bold`],style:{fontWeight:`bold`}},{types:[`italic`],style:{fontStyle:`italic`}},{types:[`namespace`],style:{opacity:.7}}]},aa={plain:{color:`#f8f8f2`,backgroundColor:`#272822`},styles:[{types:[`changed`],style:{color:`rgb(162, 191, 252)`,fontStyle:`italic`}},{types:[`deleted`],style:{color:`#f92672`,fontStyle:`italic`}},{types:[`inserted`],style:{color:`rgb(173, 219, 103)`,fontStyle:`italic`}},{types:[`comment`],style:{color:`#8292a2`,fontStyle:`italic`}},{types:[`string`,`url`],style:{color:`#a6e22e`}},{types:[`variable`],style:{color:`#f8f8f2`}},{types:[`number`],style:{color:`#ae81ff`}},{types:[`builtin`,`char`,`constant`,`function`,`class-name`],style:{color:`#e6db74`}},{types:[`punctuation`],style:{color:`#f8f8f2`}},{types:[`selector`,`doctype`],style:{color:`#a6e22e`,fontStyle:`italic`}},{types:[`tag`,`operator`,`keyword`],style:{color:`#66d9ef`}},{types:[`boolean`],style:{color:`#ae81ff`}},{types:[`namespace`],style:{color:`rgb(178, 204, 214)`,opacity:.7}},{types:[`tag`,`property`],style:{color:`#f92672`}},{types:[`attr-name`],style:{color:`#a6e22e !important`}},{types:[`doctype`],style:{color:`#8292a2`}},{types:[`rule`],style:{color:`#e6db74`}}]},oa={plain:{color:`#bfc7d5`,backgroundColor:`#292d3e`},styles:[{types:[`comment`],style:{color:`rgb(105, 112, 152)`,fontStyle:`italic`}},{types:[`string`,`inserted`],style:{color:`rgb(195, 232, 141)`}},{types:[`number`],style:{color:`rgb(247, 140, 108)`}},{types:[`builtin`,`char`,`constant`,`function`],style:{color:`rgb(130, 170, 255)`}},{types:[`punctuation`,`selector`],style:{color:`rgb(199, 146, 234)`}},{types:[`variable`],style:{color:`rgb(191, 199, 213)`}},{types:[`class-name`,`attr-name`],style:{color:`rgb(255, 203, 107)`}},{types:[`tag`,`deleted`],style:{color:`rgb(255, 85, 114)`}},{types:[`operator`],style:{color:`rgb(137, 221, 255)`}},{types:[`boolean`],style:{color:`rgb(255, 88, 116)`}},{types:[`keyword`],style:{fontStyle:`italic`}},{types:[`doctype`],style:{color:`rgb(199, 146, 234)`,fontStyle:`italic`}},{types:[`namespace`],style:{color:`rgb(178, 204, 214)`}},{types:[`url`],style:{color:`rgb(221, 221, 221)`}}]},sa={plain:{color:`#9EFEFF`,backgroundColor:`#2D2A55`},styles:[{types:[`changed`],style:{color:`rgb(255, 238, 128)`}},{types:[`deleted`],style:{color:`rgba(239, 83, 80, 0.56)`}},{types:[`inserted`],style:{color:`rgb(173, 219, 103)`}},{types:[`comment`],style:{color:`rgb(179, 98, 255)`,fontStyle:`italic`}},{types:[`punctuation`],style:{color:`rgb(255, 255, 255)`}},{types:[`constant`],style:{color:`rgb(255, 98, 140)`}},{types:[`string`,`url`],style:{color:`rgb(165, 255, 144)`}},{types:[`variable`],style:{color:`rgb(255, 238, 128)`}},{types:[`number`,`boolean`],style:{color:`rgb(255, 98, 140)`}},{types:[`attr-name`],style:{color:`rgb(255, 180, 84)`}},{types:[`keyword`,`operator`,`property`,`namespace`,`tag`,`selector`,`doctype`],style:{color:`rgb(255, 157, 0)`}},{types:[`builtin`,`char`,`constant`,`function`,`class-name`],style:{color:`rgb(250, 208, 0)`}}]},ca={plain:{backgroundColor:`linear-gradient(to bottom, #2a2139 75%, #34294f)`,backgroundImage:`#34294f`,color:`#f92aad`,textShadow:`0 0 2px #100c0f, 0 0 5px #dc078e33, 0 0 10px #fff3`},styles:[{types:[`comment`,`block-comment`,`prolog`,`doctype`,`cdata`],style:{color:`#495495`,fontStyle:`italic`}},{types:[`punctuation`],style:{color:`#ccc`}},{types:[`tag`,`attr-name`,`namespace`,`number`,`unit`,`hexcode`,`deleted`],style:{color:`#e2777a`}},{types:[`property`,`selector`],style:{color:`#72f1b8`,textShadow:`0 0 2px #100c0f, 0 0 10px #257c5575, 0 0 35px #21272475`}},{types:[`function-name`],style:{color:`#6196cc`}},{types:[`boolean`,`selector-id`,`function`],style:{color:`#fdfdfd`,textShadow:`0 0 2px #001716, 0 0 3px #03edf975, 0 0 5px #03edf975, 0 0 8px #03edf975`}},{types:[`class-name`,`maybe-class-name`,`builtin`],style:{color:`#fff5f6`,textShadow:`0 0 2px #000, 0 0 10px #fc1f2c75, 0 0 5px #fc1f2c75, 0 0 25px #fc1f2c75`}},{types:[`constant`,`symbol`],style:{color:`#f92aad`,textShadow:`0 0 2px #100c0f, 0 0 5px #dc078e33, 0 0 10px #fff3`}},{types:[`important`,`atrule`,`keyword`,`selector-class`],style:{color:`#f4eee4`,textShadow:`0 0 2px #393a33, 0 0 8px #f39f0575, 0 0 2px #f39f0575`}},{types:[`string`,`char`,`attr-value`,`regex`,`variable`],style:{color:`#f87c32`}},{types:[`parameter`],style:{fontStyle:`italic`}},{types:[`entity`,`url`],style:{color:`#67cdcc`}},{types:[`operator`],style:{color:`ffffffee`}},{types:[`important`,`bold`],style:{fontWeight:`bold`}},{types:[`italic`],style:{fontStyle:`italic`}},{types:[`entity`],style:{cursor:`help`}},{types:[`inserted`],style:{color:`green`}}]},la={plain:{color:`#282a2e`,backgroundColor:`#ffffff`},styles:[{types:[`comment`],style:{color:`rgb(197, 200, 198)`}},{types:[`string`,`number`,`builtin`,`variable`],style:{color:`rgb(150, 152, 150)`}},{types:[`class-name`,`function`,`tag`,`attr-name`],style:{color:`rgb(40, 42, 46)`}}]},ua={plain:{color:`#9CDCFE`,backgroundColor:`#1E1E1E`},styles:[{types:[`prolog`],style:{color:`rgb(0, 0, 128)`}},{types:[`comment`],style:{color:`rgb(106, 153, 85)`}},{types:[`builtin`,`changed`,`keyword`,`interpolation-punctuation`],style:{color:`rgb(86, 156, 214)`}},{types:[`number`,`inserted`],style:{color:`rgb(181, 206, 168)`}},{types:[`constant`],style:{color:`rgb(100, 102, 149)`}},{types:[`attr-name`,`variable`],style:{color:`rgb(156, 220, 254)`}},{types:[`deleted`,`string`,`attr-value`,`template-punctuation`],style:{color:`rgb(206, 145, 120)`}},{types:[`selector`],style:{color:`rgb(215, 186, 125)`}},{types:[`tag`],style:{color:`rgb(78, 201, 176)`}},{types:[`tag`],languages:[`markup`],style:{color:`rgb(86, 156, 214)`}},{types:[`punctuation`,`operator`],style:{color:`rgb(212, 212, 212)`}},{types:[`punctuation`],languages:[`markup`],style:{color:`#808080`}},{types:[`function`],style:{color:`rgb(220, 220, 170)`}},{types:[`class-name`],style:{color:`rgb(78, 201, 176)`}},{types:[`char`],style:{color:`rgb(209, 105, 105)`}}]},da={plain:{color:`#000000`,backgroundColor:`#ffffff`},styles:[{types:[`comment`],style:{color:`rgb(0, 128, 0)`}},{types:[`builtin`],style:{color:`rgb(0, 112, 193)`}},{types:[`number`,`variable`,`inserted`],style:{color:`rgb(9, 134, 88)`}},{types:[`operator`],style:{color:`rgb(0, 0, 0)`}},{types:[`constant`,`char`],style:{color:`rgb(129, 31, 63)`}},{types:[`tag`],style:{color:`rgb(128, 0, 0)`}},{types:[`attr-name`],style:{color:`rgb(255, 0, 0)`}},{types:[`deleted`,`string`],style:{color:`rgb(163, 21, 21)`}},{types:[`changed`,`punctuation`],style:{color:`rgb(4, 81, 165)`}},{types:[`function`,`keyword`],style:{color:`rgb(0, 0, 255)`}},{types:[`class-name`],style:{color:`rgb(38, 127, 153)`}}]},fa={plain:{color:`#f8fafc`,backgroundColor:`#011627`},styles:[{types:[`prolog`],style:{color:`#000080`}},{types:[`comment`],style:{color:`#6A9955`}},{types:[`builtin`,`changed`,`keyword`,`interpolation-punctuation`],style:{color:`#569CD6`}},{types:[`number`,`inserted`],style:{color:`#B5CEA8`}},{types:[`constant`],style:{color:`#f8fafc`}},{types:[`attr-name`,`variable`],style:{color:`#9CDCFE`}},{types:[`deleted`,`string`,`attr-value`,`template-punctuation`],style:{color:`#cbd5e1`}},{types:[`selector`],style:{color:`#D7BA7D`}},{types:[`tag`],style:{color:`#0ea5e9`}},{types:[`tag`],languages:[`markup`],style:{color:`#0ea5e9`}},{types:[`punctuation`,`operator`],style:{color:`#D4D4D4`}},{types:[`punctuation`],languages:[`markup`],style:{color:`#808080`}},{types:[`function`],style:{color:`#7dd3fc`}},{types:[`class-name`],style:{color:`#0ea5e9`}},{types:[`char`],style:{color:`#D16969`}}]},pa={plain:{color:`#0f172a`,backgroundColor:`#f1f5f9`},styles:[{types:[`prolog`],style:{color:`#000080`}},{types:[`comment`],style:{color:`#6A9955`}},{types:[`builtin`,`changed`,`keyword`,`interpolation-punctuation`],style:{color:`#0c4a6e`}},{types:[`number`,`inserted`],style:{color:`#B5CEA8`}},{types:[`constant`],style:{color:`#0f172a`}},{types:[`attr-name`,`variable`],style:{color:`#0c4a6e`}},{types:[`deleted`,`string`,`attr-value`,`template-punctuation`],style:{color:`#64748b`}},{types:[`selector`],style:{color:`#D7BA7D`}},{types:[`tag`],style:{color:`#0ea5e9`}},{types:[`tag`],languages:[`markup`],style:{color:`#0ea5e9`}},{types:[`punctuation`,`operator`],style:{color:`#475569`}},{types:[`punctuation`],languages:[`markup`],style:{color:`#808080`}},{types:[`function`],style:{color:`#0e7490`}},{types:[`class-name`],style:{color:`#0ea5e9`}},{types:[`char`],style:{color:`#D16969`}}]},ma={plain:{backgroundColor:`hsl(220, 13%, 18%)`,color:`hsl(220, 14%, 71%)`,textShadow:`0 1px rgba(0, 0, 0, 0.3)`},styles:[{types:[`comment`,`prolog`,`cdata`],style:{color:`hsl(220, 10%, 40%)`}},{types:[`doctype`,`punctuation`,`entity`],style:{color:`hsl(220, 14%, 71%)`}},{types:[`attr-name`,`class-name`,`maybe-class-name`,`boolean`,`constant`,`number`,`atrule`],style:{color:`hsl(29, 54%, 61%)`}},{types:[`keyword`],style:{color:`hsl(286, 60%, 67%)`}},{types:[`property`,`tag`,`symbol`,`deleted`,`important`],style:{color:`hsl(355, 65%, 65%)`}},{types:[`selector`,`string`,`char`,`builtin`,`inserted`,`regex`,`attr-value`],style:{color:`hsl(95, 38%, 62%)`}},{types:[`variable`,`operator`,`function`],style:{color:`hsl(207, 82%, 66%)`}},{types:[`url`],style:{color:`hsl(187, 47%, 55%)`}},{types:[`deleted`],style:{textDecorationLine:`line-through`}},{types:[`inserted`],style:{textDecorationLine:`underline`}},{types:[`italic`],style:{fontStyle:`italic`}},{types:[`important`,`bold`],style:{fontWeight:`bold`}},{types:[`important`],style:{color:`hsl(220, 14%, 71%)`}}]},ha={plain:{backgroundColor:`hsl(230, 1%, 98%)`,color:`hsl(230, 8%, 24%)`},styles:[{types:[`comment`,`prolog`,`cdata`],style:{color:`hsl(230, 4%, 64%)`}},{types:[`doctype`,`punctuation`,`entity`],style:{color:`hsl(230, 8%, 24%)`}},{types:[`attr-name`,`class-name`,`boolean`,`constant`,`number`,`atrule`],style:{color:`hsl(35, 99%, 36%)`}},{types:[`keyword`],style:{color:`hsl(301, 63%, 40%)`}},{types:[`property`,`tag`,`symbol`,`deleted`,`important`],style:{color:`hsl(5, 74%, 59%)`}},{types:[`selector`,`string`,`char`,`builtin`,`inserted`,`regex`,`attr-value`,`punctuation`],style:{color:`hsl(119, 34%, 47%)`}},{types:[`variable`,`operator`,`function`],style:{color:`hsl(221, 87%, 60%)`}},{types:[`url`],style:{color:`hsl(198, 99%, 37%)`}},{types:[`deleted`],style:{textDecorationLine:`line-through`}},{types:[`inserted`],style:{textDecorationLine:`underline`}},{types:[`italic`],style:{fontStyle:`italic`}},{types:[`important`,`bold`],style:{fontWeight:`bold`}},{types:[`important`],style:{color:`hsl(230, 8%, 24%)`}}]},ga={plain:{color:`#ebdbb2`,backgroundColor:`#292828`},styles:[{types:[`imports`,`class-name`,`maybe-class-name`,`constant`,`doctype`,`builtin`,`function`],style:{color:`#d8a657`}},{types:[`property-access`],style:{color:`#7daea3`}},{types:[`tag`],style:{color:`#e78a4e`}},{types:[`attr-name`,`char`,`url`,`regex`],style:{color:`#a9b665`}},{types:[`attr-value`,`string`],style:{color:`#89b482`}},{types:[`comment`,`prolog`,`cdata`,`operator`,`inserted`],style:{color:`#a89984`}},{types:[`delimiter`,`boolean`,`keyword`,`selector`,`important`,`atrule`,`property`,`variable`,`deleted`],style:{color:`#ea6962`}},{types:[`entity`,`number`,`symbol`],style:{color:`#d3869b`}}]},_a={plain:{color:`#654735`,backgroundColor:`#f9f5d7`},styles:[{types:[`delimiter`,`boolean`,`keyword`,`selector`,`important`,`atrule`,`property`,`variable`,`deleted`],style:{color:`#af2528`}},{types:[`imports`,`class-name`,`maybe-class-name`,`constant`,`doctype`,`builtin`],style:{color:`#b4730e`}},{types:[`string`,`attr-value`],style:{color:`#477a5b`}},{types:[`property-access`],style:{color:`#266b79`}},{types:[`function`,`attr-name`,`char`,`url`],style:{color:`#72761e`}},{types:[`tag`],style:{color:`#b94c07`}},{types:[`comment`,`prolog`,`cdata`,`operator`,`inserted`],style:{color:`#a89984`}},{types:[`entity`,`number`,`symbol`],style:{color:`#924f79`}}]},va=e=>(0,v.useCallback)(t=>{var n=t,{className:r,style:i,line:a}=n;let o=Gi(Wi({},Ki(n,[`className`,`style`,`line`])),{className:Mi(`token-line`,r)});return typeof e==`object`&&`plain`in e&&(o.style=e.plain),typeof i==`object`&&(o.style=Wi(Wi({},o.style||{}),i)),o},[e]),ya=e=>{let t=(0,v.useCallback)(({types:t,empty:n})=>{if(e!=null)return t.length===1&&t[0]===`plain`?n==null?void 0:{display:`inline-block`}:t.length===1&&n!=null?e[t[0]]:Object.assign(n==null?{}:{display:`inline-block`},...t.map(t=>e[t]))},[e]);return(0,v.useCallback)(e=>{var n=e,{token:r,className:i,style:a}=n;let o=Gi(Wi({},Ki(n,[`token`,`className`,`style`])),{className:Mi(`token`,...r.types,i),children:r.content,style:t(r)});return a!=null&&(o.style=Wi(Wi({},o.style||{}),a)),o},[t])},ba=/\r\n|\r|\n/,xa=e=>{e.length===0?e.push({types:[`plain`],content:`
25
25
  `,empty:!0}):e.length===1&&e[0].content===``&&(e[0].content=`
@@ -342,7 +342,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
342
342
  `).map((e,t)=>(0,R.jsx)(`div`,{className:Sk(e),children:e.length===0?`\xA0`:e},t))})}function Sk(e){return e.startsWith(`+++`)||e.startsWith(`---`)?`text-neutral-500`:e.startsWith(`@@`)?`bg-neutral-900 text-cyan-400 light:text-cyan-700`:e.startsWith(`+`)?`bg-emerald-950/60 text-emerald-200 light:bg-emerald-50 light:text-emerald-800`:e.startsWith(`-`)?`bg-red-950/60 text-red-200 light:bg-red-50 light:text-red-800`:`text-neutral-400`}var Ck=`pi-forge/model/`,wk=`pi-forge/sessionTree.view`;function Tk({sessionId:e,projectId:t,onClose:n}){let r=qr(t=>t.streamingBySession[e]??!1),i=qr(e=>e.setActiveSession),a=qr(e=>e.loadSessionsForProject),o=qr(e=>e.reloadMessages),s=qr(e=>e.setPendingDraft),c=qr(t=>t.agentEndCountBySession[e]??0),[l,u]=(0,v.useState)(void 0),[d,f]=(0,v.useState)(!0),[p,m]=(0,v.useState)(void 0),[h,g]=(0,v.useState)(!1),[_,y]=(0,v.useState)(void 0),b=async()=>{f(!0),m(void 0);try{u(await L.getSessionTree(e))}catch(e){m(e instanceof N?e.code:e.message)}finally{f(!1)}};(0,v.useEffect)(()=>{b()},[e]),(0,v.useEffect)(()=>{c!==0&&b()},[c]);let x=(0,v.useMemo)(()=>l===void 0?[]:Pk(l),[l]),[S,C]=(0,v.useState)(()=>{try{return localStorage.getItem(wk)===`list`?`list`:`graph`}catch{return`graph`}}),w=e=>{C(e);try{localStorage.setItem(wk,e)}catch{}},T=e=>{if(h||l?.leafId===e)return;let t=Mk(l,e);if(r||t){y({entryId:e,abandonsBranch:t,isStreaming:r});return}E(e,{})},E=async(t,n)=>{g(!0),m(void 0);try{await L.navigateSession(e,t,n),await b(),o(e)}catch(e){m(e instanceof N?e.code:e.message)}finally{g(!1)}},D=async(r,o={})=>{if(!h){g(!0),m(void 0);try{let c=o.parentId!==void 0&&o.parentId!==null?o.parentId:r,l=await L.forkSession(e,c);try{let t=localStorage.getItem(Ck+e);t!==null&&t.length>0&&localStorage.setItem(Ck+l.sessionId,t)}catch{}o.editDraft!==void 0&&o.editDraft.length>0&&s(l.sessionId,o.editDraft),await a(t),i(l.sessionId),n()}catch(e){m(e instanceof N?e.code:e.message),g(!1)}}};return(0,R.jsxs)(`div`,{className:`fixed inset-0 z-40 flex items-center justify-center bg-black/60 px-4 py-8`,onClick:n,children:[(0,R.jsxs)(`div`,{onClick:e=>e.stopPropagation(),className:`flex h-[min(90vh,900px)] w-[min(95vw,1400px)] flex-col overflow-hidden rounded-lg border border-neutral-800 bg-neutral-950 shadow-2xl`,children:[(0,R.jsxs)(`header`,{className:`flex items-center justify-between border-b border-neutral-800 px-4 py-2.5`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(De,{size:14,className:`text-neutral-400`}),(0,R.jsx)(`h2`,{className:`text-sm font-semibold text-neutral-100`,children:`Session tree`}),h&&(0,R.jsx)(Me,{size:11,className:`animate-spin text-neutral-500`})]}),(0,R.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,R.jsxs)(`div`,{className:`mr-1 flex overflow-hidden rounded border border-neutral-700`,children:[(0,R.jsx)(`button`,{onClick:()=>w(`list`),className:`px-2 py-0.5 text-[10px] uppercase tracking-wider ${S===`list`?`bg-neutral-700 text-neutral-100`:`text-neutral-400 hover:bg-neutral-800`}`,title:`Vertical list view`,children:`List`}),(0,R.jsx)(`button`,{onClick:()=>w(`graph`),className:`px-2 py-0.5 text-[10px] uppercase tracking-wider ${S===`graph`?`bg-neutral-700 text-neutral-100`:`text-neutral-400 hover:bg-neutral-800`}`,title:`Branching graph view (turn-grouped)`,children:`Graph`})]}),(0,R.jsx)(`button`,{onClick:()=>void b(),disabled:d||h,className:`rounded p-1 text-neutral-400 hover:bg-neutral-800 hover:text-neutral-200 disabled:opacity-40`,title:`Refresh tree`,children:(0,R.jsx)(He,{size:13,className:d?`animate-spin`:``})}),(0,R.jsx)(`button`,{onClick:n,className:`rounded p-2 text-neutral-400 hover:bg-neutral-800 hover:text-neutral-200`,title:`Close (Esc)`,children:(0,R.jsx)(rt,{size:20})})]})]}),p!==void 0&&(0,R.jsx)(`div`,{className:`border-b border-red-700/40 bg-red-900/20 px-4 py-1.5 text-xs text-red-300 light:border-red-300 light:bg-red-50 light:text-red-700`,children:p}),(0,R.jsxs)(`div`,{className:`flex-1 overflow-y-auto px-2 py-2`,children:[d&&l===void 0&&(0,R.jsx)(`div`,{className:`px-4 py-6 text-center text-xs italic text-neutral-500`,children:`Loading tree…`}),!d&&x.length===0&&(0,R.jsx)(`div`,{className:`px-4 py-6 text-center text-xs italic text-neutral-500`,children:`No entries yet.`}),S===`list`?(0,R.jsx)(`ul`,{className:`space-y-0.5`,children:x.map(e=>(0,R.jsx)(jk,{node:e,disabled:h,onNavigate:()=>void T(e.id),onFork:()=>void D(e.id,{...e.type===`message`&&e.role===`user`?{editDraft:e.preview??``,parentId:e.parentId}:{}})},e.id))}):l===void 0?null:(0,R.jsx)(Wk,{tree:l,disabled:h,onNavigate:e=>T(e),onForkAfterTurn:e=>void D(e)})]}),(0,R.jsxs)(`footer`,{className:`flex items-center justify-between border-t border-neutral-800 bg-neutral-900/40 px-4 py-2 text-[10px] text-neutral-500`,children:[(0,R.jsx)(`span`,{children:`Click a row to navigate · fork icon on user messages to branch from that point`}),l!==void 0&&(0,R.jsxs)(`span`,{children:[l.entries.length,` `,l.entries.length===1?`entry`:`entries`]})]})]}),(0,R.jsx)(Ek,{state:_,onCancel:()=>y(void 0),onConfirm:e=>{if(_===void 0)return;let{entryId:t}=_;y(void 0),E(t,e)}})]})}function Ek({state:e,onCancel:t,onConfirm:n}){let[r,i]=(0,v.useState)(``),[a,o]=(0,v.useState)(!1),[s,c]=(0,v.useState)(``),l=(0,v.useRef)(null);(0,v.useEffect)(()=>{e!==void 0&&(i(``),o(!1),c(``))},[e]);let u=e!==void 0,d=e?.abandonsBranch===!0,f=()=>{let e={},t=r.trim();if(t.length>0&&(e.label=t),a){e.summarize=!0;let t=s.trim();t.length>0&&(e.customInstructions=t)}n(e)};return(0,R.jsx)(Ci,{open:u,onClose:t,title:`Navigate session leaf`,width:d?`max-w-md`:`max-w-sm`,...d?{initialFocusRef:l}:{},children:(0,R.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),f()},className:`flex flex-col gap-3 px-4 py-3 text-xs text-neutral-200`,children:[e?.isStreaming===!0&&(0,R.jsx)(`p`,{className:`rounded border border-amber-700/50 bg-amber-900/20 px-2 py-1.5 text-amber-200 light:border-amber-300 light:bg-amber-50 light:text-amber-800`,children:`The agent is currently running. Navigating will abort the in-progress turn.`}),d?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`p`,{className:`text-neutral-400`,children:`You’re leaving the current branch behind. The tip stays on the tree (you can navigate back to it any time), but you can also bookmark + summarize it before moving on.`}),(0,R.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,R.jsxs)(`span`,{className:`text-neutral-500`,children:[`Label for the abandoned branch tip`,` `,(0,R.jsx)(`span`,{className:`text-neutral-600`,children:`(optional)`})]}),(0,R.jsx)(`input`,{ref:l,type:`text`,value:r,onChange:e=>i(e.target.value),placeholder:`e.g. wrong-approach`,maxLength:200,className:`rounded border border-neutral-700 bg-neutral-950 px-2 py-1 text-neutral-100 outline-none focus:border-neutral-500`})]}),(0,R.jsxs)(`label`,{className:`flex items-start gap-2 rounded border border-neutral-800 bg-neutral-950 px-2 py-1.5`,children:[(0,R.jsx)(`input`,{type:`checkbox`,checked:a,onChange:e=>o(e.target.checked),className:`mt-0.5 h-3 w-3`}),(0,R.jsxs)(`span`,{className:`flex-1 text-neutral-300`,children:[`Have pi write a `,(0,R.jsx)(`code`,{className:`font-mono text-[11px]`,children:`branch_summary`}),` entry capturing what this branch did. Costs one extra LLM call.`]})]}),a&&(0,R.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,R.jsxs)(`span`,{className:`text-neutral-500`,children:[`Custom summarizer instructions`,` `,(0,R.jsx)(`span`,{className:`text-neutral-600`,children:`(optional)`})]}),(0,R.jsx)(`textarea`,{value:s,onChange:e=>c(e.target.value),rows:3,placeholder:`e.g. Focus on what files were changed and why`,className:`rounded border border-neutral-700 bg-neutral-950 px-2 py-1 font-mono text-[11px] text-neutral-100 outline-none focus:border-neutral-500`})]})]}):(0,R.jsx)(`p`,{className:`text-neutral-400`,children:`Confirm navigation?`}),(0,R.jsxs)(`footer`,{className:`flex justify-end gap-2 pt-1`,children:[(0,R.jsx)(`button`,{type:`button`,onClick:t,className:`rounded-md border border-neutral-700 px-3 py-1 text-xs text-neutral-200 hover:bg-neutral-800`,children:`Cancel`}),(0,R.jsx)(`button`,{type:`submit`,className:`rounded-md px-3 py-1 text-xs font-medium ${e?.isStreaming===!0?`bg-amber-600 text-amber-50 hover:bg-amber-500 light:bg-amber-500 light:text-white light:hover:bg-amber-600`:`bg-neutral-100 text-neutral-900 hover:bg-white`}`,children:e?.isStreaming===!0?`Abort & navigate`:`Navigate`})]})]})})}var Dk=4,Ok=18,kk=10,Ak=8;function jk({node:e,disabled:t,onNavigate:n,onFork:r}){let i=Math.min(e.depth,Dk)*Ok+Math.min(e.branchLevel,Ak)*kk,a=e.type===`message`&&e.role===`user`,o=!e.onActivePath,s=Lk(e);return(0,R.jsx)(`li`,{className:`group min-w-0`,style:{paddingLeft:`${i}px`},children:(0,R.jsxs)(`div`,{className:`flex min-w-0 items-start gap-1.5 rounded border px-2 py-1.5 ${e.isLeaf?`border-emerald-700/60 bg-emerald-900/10`:e.onActivePath?`border-neutral-700 bg-neutral-900/40`:`border-neutral-800/50 bg-transparent`} ${o?`opacity-60`:``}`,style:e.branchLevel>0?{boxShadow:`inset 3px 0 0 ${Ik(e.branchLevel)}`}:void 0,children:[(0,R.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5 pt-0.5`,children:[e.isLeaf?(0,R.jsx)(`span`,{className:`inline-block w-[22px]`,"aria-hidden":`true`}):(0,R.jsx)(`button`,{onClick:n,disabled:t,className:`rounded p-1 text-neutral-500 hover:bg-neutral-800 hover:text-neutral-100 disabled:opacity-40`,title:`Navigate the session leaf to this entry`,children:(0,R.jsx)(Re,{size:11})}),a?(0,R.jsx)(`button`,{onClick:r,disabled:t,className:`rounded p-1 text-neutral-500 hover:bg-neutral-800 hover:text-emerald-300 disabled:opacity-40 light:hover:text-emerald-700`,title:`Fork BEFORE this message — opens a new session with the message text loaded into the input for editing.`,children:(0,R.jsx)(De,{size:11})}):(0,R.jsx)(`span`,{className:`inline-block w-[22px]`,"aria-hidden":`true`})]}),(0,R.jsxs)(`button`,{onClick:n,disabled:t||e.isLeaf,className:`flex min-w-0 flex-1 flex-col items-start gap-0.5 text-left disabled:cursor-default`,title:e.isLeaf?`Current leaf`:`Navigate the session leaf to this entry`,children:[(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,R.jsx)(`span`,{className:`rounded px-1.5 py-0.5 text-[9px] uppercase tracking-wider ${e.role===`user`?`bg-sky-900/40 text-sky-300 light:bg-sky-100 light:text-sky-800`:e.role===`assistant`?`bg-violet-900/40 text-violet-300 light:bg-violet-100 light:text-violet-800`:e.type===`branch_summary`?`bg-amber-900/40 text-amber-300 light:bg-amber-100 light:text-amber-800`:e.type===`compaction`?`bg-fuchsia-900/40 text-fuchsia-300 light:bg-fuchsia-100 light:text-fuchsia-800`:`bg-neutral-800 text-neutral-400`}`,children:s}),e.isBranchHead&&(0,R.jsxs)(`span`,{className:`rounded px-1.5 py-0.5 text-[9px] uppercase tracking-wider`,style:{background:`${Ik(e.branchLevel)}33`,color:Ik(e.branchLevel)},title:`First entry of a divergent branch`,children:[`branch `,e.branchLevel]}),e.label!==void 0&&e.label.length>0&&(0,R.jsxs)(`span`,{className:`rounded bg-neutral-800 px-1.5 py-0.5 text-[9px] text-neutral-300`,children:[`★ `,e.label]}),e.isLeaf&&(0,R.jsx)(`span`,{className:`rounded bg-emerald-900/40 px-1.5 py-0.5 text-[9px] text-emerald-300 light:bg-emerald-100 light:text-emerald-800`,children:`leaf`}),e.siblings>1&&(0,R.jsxs)(`span`,{className:`text-[9px] text-amber-400 light:text-amber-700`,title:`${e.siblings} branches diverge from this point`,children:[`⑂ `,e.siblings]}),(0,R.jsx)(`span`,{className:`text-[9px] text-neutral-600`,children:new Date(e.timestamp).toLocaleString()})]}),e.preview!==void 0&&(0,R.jsx)(`p`,{className:`w-full truncate text-[11px] text-neutral-300`,children:e.preview})]})]})})}function Mk(e,t){if(e===void 0||e.leafId===null||e.leafId===t)return!1;let n=new Map(e.entries.map(e=>[e.id,e])),r=e.leafId;for(;r!==null;){if(r===t)return!1;r=n.get(r)?.parentId??null}return!0}function Nk(e){return e.type!==`message`||e.role===`user`?0:e.role===`tool`?2:1}function Pk(e){let t=new Map;for(let n of e.entries){let e=t.get(n.parentId);e===void 0?t.set(n.parentId,[n]):e.push(n)}for(let e of t.values())e.sort((e,t)=>e.timestamp.localeCompare(t.timestamp));let n=new Set(e.branchIds),r=[],i=(a,o)=>{let s=t.get(a);if(s===void 0)return;let c=s.length;s.forEach((t,a)=>{let s=a===0?o:o+1,l=a>0&&s>0;r.push({...t,depth:Nk(t),branchLevel:s,onActivePath:n.has(t.id),isLeaf:e.leafId===t.id,siblings:c,isBranchHead:l}),i(t.id,s)})};return i(null,0),r}var Fk=[`#f59e0b`,`#0ea5e9`,`#ec4899`,`#10b981`,`#8b5cf6`,`#f97316`];function Ik(e){return e<=0?`transparent`:Fk[(e-1)%Fk.length]}function Lk(e){return e.type===`message`?e.role??`message`:e.type===`thinking_level_change`?`thinking`:e.type===`model_change`?`model`:e.type===`compaction`?`compact`:e.type===`branch_summary`?`branch`:e.type===`label`?`label`:e.type===`session_info`?`info`:e.type===`custom`?`custom`:e.type===`custom_message`?`extension`:e.type}var Rk=220,zk=78,Bk=64,Vk=28,Hk=24;function Uk(e){let t=new Map(e.entries.map(e=>[e.id,e])),n=new Map;for(let t of e.entries){let e=n.get(t.parentId);e===void 0?n.set(t.parentId,[t]):e.push(t)}for(let e of n.values())e.sort((e,t)=>e.timestamp.localeCompare(t.timestamp));let r=new Map,i=e=>{let n=r.get(e.id);if(n!==void 0)return n;if(e.type===`message`&&e.role===`user`||e.parentId===null)return r.set(e.id,e.id),e.id;let a=t.get(e.parentId);if(a===void 0)return r.set(e.id,e.id),e.id;let o=i(a);return r.set(e.id,o),o};for(let t of e.entries)i(t);let a=new Map;for(let t of e.entries){if(r.get(t.id)!==t.id)continue;let e=t.type===`message`&&t.role===`user`;a.set(t.id,{id:t.id,parentId:null,col:0,row:0,isOnActivePath:!1,isLeafTurn:!1,hasMultipleChildren:!1,childCount:0,roleLabel:e?`user`:Lk(t),preview:t.preview??``,insideCounts:{assistant:0,tool:0,thinking:0,meta:0},isUserAnchor:e,anchorParentId:t.parentId,lastEntryId:t.id,timestamp:t.timestamp})}for(let n of e.entries){let e=r.get(n.id),i=a.get(e);if(i===void 0)continue;let o=t.get(i.lastEntryId);(o===void 0||n.timestamp.localeCompare(o.timestamp)>0)&&(i.lastEntryId=n.id),e!==n.id&&(n.type===`message`&&n.role===`assistant`?i.insideCounts.assistant+=1:n.type===`message`&&(n.role===`tool`||n.role===`toolResult`)?i.insideCounts.tool+=1:(n.type===`message`&&n.role,i.insideCounts.meta+=1))}for(let e of a.values()){if(e.anchorParentId===null)continue;let t=r.get(e.anchorParentId);t!==void 0&&t!==e.id&&(e.parentId=t)}let o=new Map;for(let e of a.values()){let t=o.get(e.parentId);t===void 0?o.set(e.parentId,[e]):t.push(e)}for(let e of o.values())e.sort((e,t)=>e.timestamp.localeCompare(t.timestamp));for(let e of a.values()){let t=o.get(e.id)??[];e.childCount=t.length,e.hasMultipleChildren=t.length>1}let s=new Set(e.branchIds),c=e.leafId===null?void 0:r.get(e.leafId);for(let e of a.values())e.isOnActivePath=s.has(e.id),e.isLeafTurn=c===e.id;let l=0,u=new Map,d=(e,t)=>{(o.get(e)??[]).forEach((e,n)=>{let r;n===0?r=t:(r=l,l+=1),e.col=r,u.set(e.id,r),d(e.id,r)})};(o.get(null)??[]).forEach((e,t)=>{t===0?(e.col=0,l=Math.max(l,1)):(e.col=l,l+=1),u.set(e.id,e.col),d(e.id,e.col)});let f=(e,t)=>{let n=t.get(e.id);if(n!==void 0)return n;if(e.parentId===null)return t.set(e.id,0),0;let r=a.get(e.parentId);if(r===void 0)return t.set(e.id,0),0;let i=f(r,t)+1;return t.set(e.id,i),i},p=new Map;for(let e of a.values())e.row=f(e,p);return[...a.values()].sort((e,t)=>e.row===t.row?e.col-t.col:e.row-t.row)}function Wk({tree:e,disabled:t,onNavigate:n,onForkAfterTurn:r}){let i=(0,v.useMemo)(()=>Uk(e),[e]),a=(0,v.useMemo)(()=>{if(i.length===0)return{width:0,height:0};let e=i.reduce((e,t)=>Math.max(e,t.col),0),t=i.reduce((e,t)=>Math.max(e,t.row),0);return{width:Hk*2+(e+1)*Rk+e*Bk,height:Hk*2+(t+1)*zk+t*Vk}},[i]);if(i.length===0)return(0,R.jsx)(`div`,{className:`px-4 py-6 text-center text-xs italic text-neutral-500`,children:`No turns to render.`});let o=e=>Hk+e*284,s=e=>Hk+e*106,c=new Map(i.map(e=>[e.id,e]));return(0,R.jsxs)(`div`,{className:`relative`,style:{width:`${a.width}px`,height:`${a.height}px`},children:[(0,R.jsx)(`svg`,{"aria-hidden":`true`,className:`pointer-events-none absolute left-0 top-0`,width:a.width,height:a.height,children:i.map(e=>{if(e.parentId===null)return null;let t=c.get(e.parentId);if(t===void 0)return null;let n=o(t.col)+Rk/2,r=s(t.row)+zk,i=o(e.col)+Rk/2,a=s(e.row),l=e.isOnActivePath&&t.isOnActivePath;return(0,R.jsx)(`path`,{d:n===i?`M ${n} ${r} L ${i} ${a}`:(()=>{let e=r+(a-r)/2,t=i>n,o=t?n+8:n-8,s=t?i-8:i+8;return[`M ${n} ${r}`,`L ${n} ${e-8}`,`Q ${n} ${e} ${o} ${e}`,`L ${s} ${e}`,`Q ${i} ${e} ${i} ${e+8}`,`L ${i} ${a}`].join(` `)})(),fill:`none`,stroke:l?`#a3a3a3`:`#404040`,strokeWidth:l?1.5:1,strokeOpacity:l?.85:.5},e.id)})}),i.map(e=>(0,R.jsx)(Gk,{turn:e,x:o(e.col),y:s(e.row),disabled:t,onNavigate:()=>n(e.lastEntryId),onForkAfterTurn:()=>r(e.lastEntryId)},e.id))]})}function Gk({turn:e,x:t,y:n,disabled:r,onNavigate:i,onForkAfterTurn:a}){let o=!e.isOnActivePath;return(0,R.jsx)(`div`,{className:`absolute overflow-hidden rounded-lg border ${e.isLeafTurn?`border-emerald-700/70 bg-emerald-900/15`:e.isOnActivePath?`border-neutral-600 bg-neutral-900`:`border-neutral-800 bg-neutral-950`} ${o?`opacity-60`:``}`,style:{left:`${t}px`,top:`${n}px`,width:`${Rk}px`,height:`${zk}px`},children:(0,R.jsxs)(`button`,{onClick:i,disabled:r||e.isLeafTurn,className:`flex h-full w-full flex-col items-stretch gap-1 px-2 py-1.5 text-left disabled:cursor-default`,title:e.isLeafTurn?`Current leaf turn`:`Navigate to this turn`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,R.jsx)(`span`,{className:`rounded px-1.5 py-0.5 text-[9px] uppercase tracking-wider ${e.roleLabel===`user`?`bg-sky-900/40 text-sky-300 light:bg-sky-100 light:text-sky-800`:e.roleLabel===`compact`?`bg-fuchsia-900/40 text-fuchsia-300 light:bg-fuchsia-100 light:text-fuchsia-800`:e.roleLabel===`branch`?`bg-amber-900/40 text-amber-300 light:bg-amber-100 light:text-amber-800`:`bg-neutral-800 text-neutral-400`}`,children:e.roleLabel}),e.isLeafTurn&&(0,R.jsx)(`span`,{className:`rounded bg-emerald-900/40 px-1.5 py-0.5 text-[9px] text-emerald-300 light:bg-emerald-100 light:text-emerald-800`,children:`leaf`}),e.hasMultipleChildren&&(0,R.jsxs)(`span`,{className:`text-[9px] text-amber-400 light:text-amber-700`,title:`${e.childCount} branches diverge from here`,children:[`⑂ `,e.childCount]}),(0,R.jsx)(`button`,{onClick:e=>{e.stopPropagation(),a()},disabled:r,className:`ml-auto rounded p-0.5 text-neutral-500 hover:bg-neutral-800 hover:text-emerald-300 disabled:opacity-40 light:hover:text-emerald-700`,title:`Fork AFTER this turn — opens a new session that includes this turn's full output, ready for the next prompt.`,children:(0,R.jsx)(De,{size:11})})]}),(0,R.jsx)(`p`,{className:`line-clamp-2 flex-1 text-[11px] text-neutral-200`,children:e.preview.length>0?e.preview:(0,R.jsx)(`em`,{className:`text-neutral-500`,children:`(no text)`})}),(0,R.jsxs)(`div`,{className:`flex items-center gap-2 text-[9px] text-neutral-500`,children:[e.insideCounts.assistant>0&&(0,R.jsxs)(`span`,{title:`Assistant messages within this turn`,children:[e.insideCounts.assistant,`a`]}),e.insideCounts.tool>0&&(0,R.jsxs)(`span`,{title:`Tool results within this turn`,children:[e.insideCounts.tool,`t`]}),e.insideCounts.thinking>0&&(0,R.jsxs)(`span`,{title:`Thinking blocks`,children:[e.insideCounts.thinking,`th`]}),e.insideCounts.meta>0&&(0,R.jsxs)(`span`,{title:`Meta entries (model_change, branch_summary, etc.)`,children:[e.insideCounts.meta,`m`]}),(0,R.jsx)(`span`,{className:`ml-auto`,children:new Date(e.timestamp).toLocaleTimeString()})]})]})})}var Kk=ft(e=>({pendingInsert:void 0,setPendingInsert:(t,n)=>e({pendingInsert:{sessionId:t,text:n}}),consumePendingInsert:()=>e({pendingInsert:void 0})}));function qk(e){return typeof e.command==`string`&&e.command.length>0}function Jk(e){return typeof e.text==`string`&&e.text.length>0}function Yk(){return typeof crypto<`u`&&typeof crypto.randomUUID==`function`?crypto.randomUUID():`run-${Date.now()}-${Math.random().toString(36).slice(2)}`}function Xk({sessionId:e,projectId:t}){let n=ci(e=>e.loaded),r=ci(e=>e.actions),i=si(e=>e.minimal),a=li(e=>e.addRun),o=li(e=>e.updateRun),s=li(e=>e.runs),c=qr(e=>e.sendPrompt),l=Kk(e=>e.setPendingInsert),[u,d]=(0,v.useState)(!1),f=(0,v.useRef)(null);(0,v.useEffect)(()=>{if(!u)return;let e=e=>{f.current!==null&&(f.current.contains(e.target)||d(!1))};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[u]);let p=r.filter(e=>!(e.enabled===!1||i&&qk(e))),m=new Map,h=0;for(let e of s)e.status===`running`&&(h+=1,m.set(e.actionId,(m.get(e.actionId)??0)+1));if(!n||p.length===0)return null;let g=n=>{let r=Yk(),i=new AbortController;a({runId:r,sessionId:e,actionId:n.id,actionName:n.name,startedAt:Date.now(),status:`running`,abort:()=>{try{i.abort()}catch{}}}),L.runQuickAction(n.id,t).then(e=>{o(r,{status:i.signal.aborted?`aborted`:`done`,result:e})}).catch(e=>{o(r,{status:`done`,error:e instanceof N?`${e.code}: ${e.message}`:e.message})})},_=t=>{let n=t.text??``;n.length!==0&&((t.mode??`send`)===`insert`?l(e,n):c(e,n))},y=e=>{d(!1),qk(e)?g(e):Jk(e)&&_(e)};return(0,R.jsxs)(`div`,{ref:f,className:`relative`,children:[(0,R.jsxs)(`button`,{type:`button`,onClick:()=>d(e=>!e),"aria-haspopup":`menu`,"aria-expanded":u,className:`flex items-center gap-1 rounded px-1.5 py-0.5 text-[10px] uppercase tracking-wider text-neutral-400 hover:bg-neutral-800 hover:text-neutral-200 light:text-neutral-600 light:hover:bg-neutral-200 light:hover:text-neutral-900`,title:`Run a saved quick action`,children:[(0,R.jsx)(it,{size:11}),`Actions`,h>0&&(0,R.jsxs)(`span`,{className:`ml-0.5 flex items-center gap-0.5 rounded bg-amber-700/40 px-1 text-[9px] normal-case text-amber-100 light:bg-amber-200 light:text-amber-900`,title:`${h} action${h===1?``:`s`} running`,children:[(0,R.jsx)(Me,{size:9,className:`animate-spin`}),h]}),(0,R.jsx)(ue,{size:11})]}),u&&(0,R.jsx)(`div`,{role:`menu`,className:`absolute left-0 top-full z-30 mt-1 min-w-[14rem] max-w-[20rem] rounded-md border border-neutral-700 bg-neutral-900 py-1 shadow-xl light:border-neutral-300 light:bg-white`,children:p.map(e=>{let t=qk(e),n=t?Xe:Ie,r=m.get(e.id)??0;return(0,R.jsxs)(`button`,{role:`menuitem`,onClick:()=>y(e),className:`flex w-full items-center gap-2 px-3 py-1.5 text-left text-xs text-neutral-200 hover:bg-neutral-800 light:text-neutral-800 light:hover:bg-neutral-100`,title:t?e.command??``:`${e.mode===`insert`?`Insert`:`Send`}: ${e.text??``}`,children:[(0,R.jsx)(n,{size:12,className:t?`text-amber-400 light:text-amber-700`:`text-sky-400 light:text-sky-700`}),(0,R.jsx)(`span`,{className:`flex-1 truncate`,children:e.name}),r>0&&(0,R.jsx)(Me,{size:11,className:`animate-spin text-amber-400 light:text-amber-700`})]},e.id)})})]})}function Zk(e){return e<1e3?`${e} ms`:`${(e/1e3).toFixed(1)} s`}function Qk({run:e}){let t=li(e=>e.removeRun),n=Kk(e=>e.setPendingInsert),[r,i]=(0,v.useState)(!1),a=e.result,o=e.status===`running`,s=e.error!==void 0,c=a?.success===!0&&!s,l=a?.exitCode??null,u=o?`border-l-amber-500 light:border-l-amber-600`:c?`border-l-emerald-500 light:border-l-emerald-600`:`border-l-red-500 light:border-l-red-600`,d=o?`running`:s?`error`:a?.timedOut===!0?`timed out`:e.status===`aborted`?`aborted`:l===0?`exit 0`:`exit ${l??`?`}`,f=()=>{if(a===void 0)return``;let t=[`Ran quick action: ${e.actionName}`,``];return a.stdout.length>0&&t.push("```",a.stdout.replace(/\s+$/,``),"```"),a.stderr.length>0&&t.push(``,`stderr:`,"```",a.stderr.replace(/\s+$/,``),"```"),a.exitCode!==null&&a.exitCode!==0&&t.push(``,`exit code: ${a.exitCode}`),t.join(`
343
343
  `)};return(0,R.jsxs)(`div`,{className:`rounded-lg border border-neutral-800 border-l-4 bg-neutral-900/40 px-3 py-2 text-xs light:border-neutral-300 light:bg-neutral-50 ${u}`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(Xe,{size:12,className:`text-neutral-500 light:text-neutral-600`}),(0,R.jsx)(`span`,{className:`font-mono text-neutral-300 light:text-neutral-800`,children:e.actionName}),(0,R.jsx)(`span`,{className:`text-neutral-500 light:text-neutral-600`,children:`·`}),o?(0,R.jsxs)(`span`,{className:`flex items-center gap-1 text-amber-400 light:text-amber-700`,children:[(0,R.jsx)(Me,{size:11,className:`animate-spin`}),d]}):c?(0,R.jsxs)(`span`,{className:`flex items-center gap-1 text-emerald-400 light:text-emerald-700`,children:[(0,R.jsx)(le,{size:11}),d]}):(0,R.jsxs)(`span`,{className:`flex items-center gap-1 text-red-400 light:text-red-700`,children:[(0,R.jsx)(rt,{size:11}),d]}),a!==void 0&&(0,R.jsxs)(`span`,{className:`text-neutral-500 light:text-neutral-600`,children:[`· `,Zk(a.durationMs)]}),a?.truncated===!0&&(0,R.jsx)(`span`,{className:`rounded bg-amber-700/40 px-1 text-[10px] text-amber-100 light:bg-amber-200 light:text-amber-900`,title:`Output exceeded the per-stream cap and was cut off`,children:`truncated`}),(0,R.jsx)(`div`,{className:`flex-1`}),o?(0,R.jsx)(`button`,{type:`button`,onClick:()=>{e.abort(),li.getState().updateRun(e.runId,{status:`aborted`})},className:`rounded px-1.5 py-0.5 text-[10px] uppercase tracking-wider text-neutral-400 hover:bg-neutral-800 hover:text-neutral-200 light:text-neutral-600 light:hover:bg-neutral-200`,title:`Stop waiting on this run (server-side abort coming later)`,children:`Stop`}):(0,R.jsxs)(R.Fragment,{children:[a!==void 0&&(a.stdout.length>0||a.stderr.length>0)&&(0,R.jsxs)(`button`,{type:`button`,onClick:()=>n(e.sessionId,f()),className:`flex items-center gap-1 rounded px-1.5 py-0.5 text-[10px] uppercase tracking-wider text-sky-400 hover:bg-neutral-800 hover:text-sky-200 light:text-sky-700 light:hover:bg-neutral-200 light:hover:text-sky-900`,title:`Insert the captured output into the composer for your next prompt`,children:[(0,R.jsx)(Fe,{size:11}),`Use as context`]}),(0,R.jsx)(`button`,{type:`button`,onClick:()=>t(e.runId),className:`rounded px-1.5 py-0.5 text-[10px] uppercase tracking-wider text-neutral-500 hover:bg-neutral-800 hover:text-neutral-200 light:text-neutral-500 light:hover:bg-neutral-200 light:hover:text-neutral-900`,title:`Dismiss`,children:`Dismiss`})]})]}),a!==void 0&&(a.stdout.length>0||a.stderr.length>0||a.exitCode!==0)||s?(0,R.jsx)(`button`,{type:`button`,onClick:()=>i(e=>!e),className:`mt-1 cursor-pointer text-[10px] uppercase tracking-wider text-neutral-500 hover:text-neutral-300 light:text-neutral-600 light:hover:text-neutral-900`,children:r?`Hide output`:`Show output`}):null,r&&(0,R.jsxs)(`div`,{className:`mt-2 space-y-2`,children:[s&&(0,R.jsx)(`pre`,{className:`overflow-auto whitespace-pre-wrap rounded bg-neutral-950 px-2 py-1 font-mono text-[11px] text-red-300 light:bg-red-50 light:text-red-800`,children:e.error}),a!==void 0&&a.stdout.length>0&&(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`div`,{className:`mb-0.5 text-[10px] uppercase tracking-wider text-neutral-500 light:text-neutral-600`,children:`stdout`}),(0,R.jsx)(`pre`,{className:`max-h-72 overflow-auto whitespace-pre-wrap rounded bg-neutral-950 px-2 py-1 font-mono text-[11px] text-neutral-200 light:bg-white light:text-neutral-800`,children:a.stdout})]}),a!==void 0&&a.stderr.length>0&&(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`div`,{className:`mb-0.5 text-[10px] uppercase tracking-wider text-neutral-500 light:text-neutral-600`,children:`stderr`}),(0,R.jsx)(`pre`,{className:`max-h-72 overflow-auto whitespace-pre-wrap rounded bg-neutral-950 px-2 py-1 font-mono text-[11px] text-red-300 light:bg-red-50 light:text-red-800`,children:a.stderr})]})]})]})}var $k=new Set([`single`,`parallel`,`chain`,`management`]);function eA(e){if(!e.endsWith(`.jsonl`))return;let t=Math.max(e.lastIndexOf(`/`),e.lastIndexOf(`\\`)),n=(t>=0?e.slice(t+1):e).slice(0,-6);if(n.length!==0)return n}function tA(e){if(typeof e!=`object`||!e)return{mode:`unknown`,results:[]};let t=e,n=$k.has(t.mode)?t.mode:`unknown`,r=typeof t.runId==`string`&&t.runId.length>0?t.runId:void 0,i=t.context===`fresh`||t.context===`fork`?t.context:void 0,a=[];if(Array.isArray(t.results))for(let e of t.results){if(typeof e!=`object`||!e)continue;let t=e,n={agent:typeof t.agent==`string`?t.agent:`agent`,task:typeof t.task==`string`?t.task:``,exitCode:typeof t.exitCode==`number`?t.exitCode:0};if(typeof t.sessionFile==`string`&&t.sessionFile.length>0){n.sessionFile=t.sessionFile;let e=eA(t.sessionFile);e!==void 0&&(n.sessionId=e)}typeof t.finalOutput==`string`&&t.finalOutput.length>0&&(n.finalOutput=t.finalOutput),a.push(n)}return{mode:n,...r===void 0?{}:{runId:r},...i===void 0?{}:{context:i},results:a}}function nA({sessionId:e,onClose:t}){let n=si(e=>e.orchestrationEnabled),[r,i]=(0,v.useState)(void 0),[a,o]=(0,v.useState)([]),[s,c]=(0,v.useState)([]),[l,u]=(0,v.useState)(!1),[d,f]=(0,v.useState)(!1),[p,m]=(0,v.useState)(!1),[h,g]=(0,v.useState)(void 0),_=async()=>{f(!0),g(void 0);try{let t=await L.getSessionLink(e);i(t),t.role===`supervisor`?(o((await L.listSupervisorWorkers(e)).workers),c((await L.listSupervisorInbox(e)).items)):(o([]),c([]))}catch(e){g(e instanceof N?e.code:e.message)}finally{f(!1)}};if((0,v.useEffect)(()=>{if(!n)return;_();let e=setInterval(()=>{_()},4e3);return()=>clearInterval(e)},[n,e]),!n)return null;let y=r?.role??`standalone`;return(0,R.jsxs)(`div`,{className:`rounded-md border border-zinc-200 dark:border-zinc-800 bg-zinc-50 dark:bg-zinc-900/50 p-3 text-sm`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2 font-medium`,children:[(0,R.jsx)(nt,{size:14}),(0,R.jsx)(`span`,{children:`Orchestration`}),(0,R.jsx)(rA,{role:y})]}),(0,R.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,R.jsx)(`button`,{type:`button`,onClick:()=>{_()},title:`Refresh`,className:`p-1 text-zinc-500 hover:text-zinc-900 dark:hover:text-zinc-100`,children:d?(0,R.jsx)(Me,{size:14,className:`animate-spin`}):(0,R.jsx)(He,{size:14})}),t!==void 0&&(0,R.jsx)(`button`,{type:`button`,onClick:t,title:`Close`,className:`p-1 text-zinc-500 hover:text-zinc-900 dark:hover:text-zinc-100`,children:(0,R.jsx)(rt,{size:14})})]})]}),h!==void 0&&(0,R.jsx)(`div`,{className:`mt-2 rounded bg-red-100 dark:bg-red-900/30 text-red-800 dark:text-red-300 px-2 py-1 text-xs`,children:h}),y===`standalone`&&(0,R.jsx)(iA,{sessionId:e,busy:p,setBusy:m,setError:g,onAfter:_}),y===`supervisor`&&r!==void 0&&(0,R.jsx)(aA,{link:r,workers:a,inbox:s,showInbox:l,setShowInbox:u,busy:p,setBusy:m,setError:g,onAfter:_}),y===`worker`&&r!==void 0&&(0,R.jsx)(cA,{link:r})]})}function rA({role:e}){return(0,R.jsx)(`span`,{className:`rounded px-1.5 py-0.5 text-xs font-medium ${e===`supervisor`?`bg-violet-100 text-violet-800 dark:bg-violet-900/40 dark:text-violet-200`:e===`worker`?`bg-sky-100 text-sky-800 dark:bg-sky-900/40 dark:text-sky-200`:`bg-zinc-200 text-zinc-700 dark:bg-zinc-800 dark:text-zinc-300`}`,children:e===`supervisor`?`Supervisor`:e===`worker`?`Worker`:`Standalone`})}function iA({sessionId:e,busy:t,setBusy:n,setError:r,onAfter:i}){let a=async()=>{n(!0),r(void 0);try{await L.enableSupervisor(e),await i()}catch(e){r(e instanceof N?e.code:e.message)}finally{n(!1)}};return(0,R.jsxs)(`div`,{className:`mt-2 space-y-2`,children:[(0,R.jsxs)(`p`,{className:`text-xs text-zinc-600 dark:text-zinc-400`,children:[`This session is standalone. Enable supervisor mode to give this session the`,` `,(0,R.jsx)(`code`,{className:`text-xs`,children:`orchestrate_*`}),` tools — letting it spawn, observe, and coordinate other worker sessions in the same project.`]}),(0,R.jsx)(`button`,{type:`button`,onClick:()=>{a()},disabled:t,className:`rounded bg-violet-600 px-2.5 py-1 text-xs font-medium text-white hover:bg-violet-500 disabled:opacity-50`,children:t?`Enabling…`:`Enable supervisor mode`}),(0,R.jsx)(`p`,{className:`text-[11px] text-zinc-500 dark:text-zinc-400`,children:`The agent's tool list refreshes immediately — no reload needed.`})]})}function aA({link:e,workers:t,inbox:n,showInbox:r,setShowInbox:i,busy:a,setBusy:o,setError:s,onAfter:c}){let l=qr(e=>e.setActiveSession),u=async()=>{if(confirm(`Disable supervisor mode? Linked workers become standalone sessions.`)){o(!0),s(void 0);try{await L.disableSupervisor(e.sessionId),await c()}catch(e){s(e instanceof N?e.code:e.message)}finally{o(!1)}}},d=async t=>{o(!0),s(void 0);try{await L.detachWorker(e.sessionId,t),await c()}catch(e){s(e instanceof N?e.code:e.message)}finally{o(!1)}},f=async t=>{if(confirm(`Kill worker ${t.slice(0,8)}? (Transcript stays on disk.)`)){o(!0),s(void 0);try{await L.killWorker(e.sessionId,t),await c()}catch(e){s(e instanceof N?e.code:e.message)}finally{o(!1)}}},p=async t=>{o(!0),s(void 0);try{await L.resumeWorker(e.sessionId,t),await c()}catch(e){s(e instanceof N?e.code:e.message)}finally{o(!1)}},m=async()=>{if(confirm(`Clear inbox history?`)){o(!0),s(void 0);try{await L.clearSupervisorInbox(e.sessionId),await c()}catch(e){s(e instanceof N?e.code:e.message)}finally{o(!1)}}},h=e.pendingInbox??0;return(0,R.jsxs)(`div`,{className:`mt-2 space-y-2`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,R.jsxs)(`div`,{className:`text-xs text-zinc-600 dark:text-zinc-400`,children:[t.length,` worker`,t.length===1?``:`s`,h>0?(0,R.jsxs)(`span`,{className:`ml-2 rounded bg-amber-200 dark:bg-amber-700/50 text-amber-900 dark:text-amber-100 px-1.5 py-0.5`,children:[h,` pending inbox`]}):null]}),(0,R.jsx)(`button`,{type:`button`,onClick:()=>{u()},disabled:a,className:`rounded text-xs text-zinc-600 dark:text-zinc-400 hover:text-red-600 dark:hover:text-red-400 disabled:opacity-50 px-1.5 py-0.5`,children:`Disable supervisor mode`})]}),t.length===0?(0,R.jsxs)(`p`,{className:`text-xs italic text-zinc-500 dark:text-zinc-400`,children:[`No workers yet. The agent can spawn one with`,` `,(0,R.jsx)(`code`,{className:`text-xs`,children:`orchestrate_spawn_worker`}),`.`]}):(0,R.jsx)(`ul`,{className:`divide-y divide-zinc-200 dark:divide-zinc-800 rounded border border-zinc-200 dark:border-zinc-800 bg-white dark:bg-zinc-950`,children:t.map(e=>(0,R.jsxs)(`li`,{className:`flex items-center gap-2 px-2 py-1.5`,children:[(0,R.jsx)(lA,{state:e.state??(e.isLive?`idle`:`cold`)}),(0,R.jsxs)(`button`,{type:`button`,onClick:()=>l(e.workerId),className:`flex-1 text-left truncate text-xs hover:underline`,title:e.workerId,children:[(0,R.jsx)(`span`,{className:`font-medium`,children:e.name??e.workerId.slice(0,8)}),e.messageCount!==void 0&&(0,R.jsxs)(`span`,{className:`ml-1 text-zinc-500`,children:[`(`,e.messageCount,` msgs)`]})]}),(0,R.jsxs)(`div`,{className:`flex items-center gap-1`,children:[!e.isLive&&(0,R.jsx)(`button`,{type:`button`,onClick:()=>{p(e.workerId)},disabled:a,className:`text-[11px] text-zinc-600 dark:text-zinc-400 hover:text-violet-700 dark:hover:text-violet-300 disabled:opacity-50 px-1 py-0.5`,children:`Resume`}),(0,R.jsx)(`button`,{type:`button`,onClick:()=>{d(e.workerId)},disabled:a,className:`text-[11px] text-zinc-600 dark:text-zinc-400 hover:text-amber-700 dark:hover:text-amber-300 disabled:opacity-50 px-1 py-0.5`,title:`Detach (worker continues as standalone)`,children:`Detach`}),(0,R.jsx)(`button`,{type:`button`,onClick:()=>{f(e.workerId)},disabled:a,className:`text-[11px] text-zinc-600 dark:text-zinc-400 hover:text-red-700 dark:hover:text-red-300 disabled:opacity-50 px-1 py-0.5`,title:`Kill (dispose live session; transcript stays on disk)`,children:`Kill`})]})]},e.workerId))}),(0,R.jsxs)(`details`,{open:r,onToggle:e=>i(e.currentTarget.open),children:[(0,R.jsxs)(`summary`,{className:`cursor-pointer text-xs text-zinc-600 dark:text-zinc-400 select-none`,children:[`Inbox history (`,n.length,`) `,h>0&&`— ${h} pending`]}),n.length===0?(0,R.jsx)(`p`,{className:`text-xs italic text-zinc-500 dark:text-zinc-400 mt-1`,children:`No inbox items.`}):(0,R.jsxs)(`div`,{className:`mt-1 space-y-1`,children:[(0,R.jsx)(`ul`,{className:`divide-y divide-zinc-200 dark:divide-zinc-800 rounded border border-zinc-200 dark:border-zinc-800 bg-white dark:bg-zinc-950 max-h-48 overflow-auto`,children:n.map(e=>(0,R.jsx)(oA,{item:e},e.id))}),(0,R.jsx)(`button`,{type:`button`,onClick:()=>{m()},disabled:a,className:`text-[11px] text-zinc-500 dark:text-zinc-400 hover:text-red-600 dark:hover:text-red-400 disabled:opacity-50`,children:`Clear inbox`})]})]})]})}function oA({item:e}){let t=sA(e.type);return(0,R.jsxs)(`li`,{className:`flex items-baseline gap-2 px-2 py-1 text-xs`,children:[(0,R.jsx)(`span`,{className:`rounded px-1 py-0.5 ${e.delivered?`bg-zinc-200 text-zinc-600 dark:bg-zinc-800 dark:text-zinc-400`:`bg-amber-200 text-amber-900 dark:bg-amber-700/40 dark:text-amber-200`}`,children:t}),(0,R.jsx)(`span`,{className:`font-mono text-zinc-500`,title:e.workerId,children:e.workerId.slice(0,8)}),(0,R.jsx)(`span`,{className:`text-zinc-500 ml-auto`,children:new Date(e.occurredAt).toLocaleTimeString()})]})}function sA(e){switch(e){case`worker.ended`:return`ended`;case`worker.ask_user`:return`asked`;case`worker.auto_retry_failed`:return`retry failed`;case`worker.process_alert`:return`process`;case`worker.deleted`:return`deleted`}}function cA({link:e}){let t=qr(e=>e.setActiveSession),n=e.supervisorId;return n===void 0?null:(0,R.jsxs)(`div`,{className:`mt-2 text-xs text-zinc-600 dark:text-zinc-400`,children:[`Owned by supervisor`,` `,(0,R.jsx)(`button`,{type:`button`,onClick:()=>t(n),className:`font-mono underline hover:text-violet-700 dark:hover:text-violet-300`,title:n,children:n.slice(0,8)}),e.spawnedFrom!==void 0&&e.spawnedFrom.mode===`summary`&&(0,R.jsx)(`span`,{className:`ml-2 italic`,children:`(handoff with context summary)`})]})}function lA({state:e}){return(0,R.jsx)(`span`,{className:`inline-block h-2 w-2 rounded-full ${e===`streaming`?`bg-emerald-500 animate-pulse`:e===`idle`?`bg-sky-500`:`bg-zinc-400`}`,title:e,"aria-label":e})}var uA=(0,v.createContext)({viewType:`unified`,setViewType:()=>void 0}),dA=`forge.chat.viewType`;function fA(){try{return localStorage.getItem(dA)===`split`?`split`:`unified`}catch{return`unified`}}function pA({sessionId:e}){let t=qr(t=>t.messagesBySession[e]??Rr),n=qr(t=>t.compactionsBySession[e]??zr),r=qr(t=>t.streamingTextBySession[e]??``),i=qr(t=>t.streamingBySession[e]??!1),a=qr(t=>t.activeToolBySession[e]),o=qr(t=>t.bannerBySession[e]),s=qr(t=>t.queuedBySession[e]),c=qr(e=>e.openStream),l=qr(e=>e.closeStream),u=qr(t=>t.pendingScrollByMessageIndex[e]),d=qr(e=>e.consumePendingScroll),f=li(e=>e.runs),p=(0,v.useMemo)(()=>f.filter(t=>t.sessionId===e),[f,e]),[m,h]=(0,v.useState)(fA),g=e=>{h(e);try{localStorage.setItem(dA,e)}catch{}},_=ur(),[y,b]=(0,v.useState)(!1),[x,S]=(0,v.useState)(!1),C=si(e=>e.orchestrationEnabled),w=ot(),[T,E]=(0,v.useState)(!1),[D,O]=(0,v.useState)(void 0),k=(0,v.useRef)(null);(0,v.useEffect)(()=>{if(!T)return;let e=e=>{k.current!==null&&(k.current.contains(e.target)||E(!1))};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[T]);let ee=async t=>{E(!1),O(void 0);try{let{blob:n,filename:r}=await L.exportSession(e,t),i=URL.createObjectURL(n),a=document.createElement(`a`);a.href=i,a.download=r,document.body.appendChild(a),a.click(),a.remove(),window.setTimeout(()=>URL.revokeObjectURL(i),1e3)}catch(e){O(e instanceof N?`${e.code} (${e.status})`:e instanceof Error?e.message:`export_failed`),window.setTimeout(()=>O(void 0),4e3)}};(0,v.useEffect)(()=>(c(e),()=>{l(e)}),[e,c,l]);let A=(0,v.useRef)(null),te=(0,v.useRef)(!0),ne=()=>{let e=A.current;e!==null&&(te.current=e.scrollHeight-e.scrollTop-e.clientHeight<=96)};(0,v.useEffect)(()=>{let e=A.current;e!==null&&te.current&&(e.scrollTop=e.scrollHeight)},[t,r,i]);let re=(0,v.useRef)(0);return(0,v.useEffect)(()=>{let e=t.reduce((e,t)=>t.role===`user`?e+1:e,0);if(e>re.current){let e=A.current;e!==null&&(e.scrollTop=e.scrollHeight),te.current=!0}re.current=e},[t]),(0,v.useEffect)(()=>{if(u===void 0||t.length<=u)return;let n=A.current;if(n===null)return;let r=n.querySelector(`[data-message-index="${u}"]`);r!==null&&(r.scrollIntoView({block:`center`,behavior:`smooth`}),te.current=!1,d(e))},[u,t.length,e,d]),(0,R.jsxs)(uA.Provider,{value:{viewType:m,setViewType:g},children:[(0,R.jsxs)(`div`,{className:`flex flex-1 flex-col overflow-hidden`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-1 border-b border-neutral-800 bg-neutral-900/30 px-3 py-1`,children:[(0,R.jsx)(`div`,{className:`flex items-center gap-1`,children:_!==void 0&&(0,R.jsx)(Xk,{sessionId:e,projectId:_.id})}),(0,R.jsxs)(`div`,{className:`flex items-center gap-1`,children:[!w&&(0,R.jsxs)(`div`,{ref:k,className:`relative`,children:[(0,R.jsxs)(`button`,{onClick:()=>E(e=>!e),"aria-haspopup":`menu`,"aria-expanded":T,className:`flex items-center gap-1 rounded px-1.5 py-0.5 text-[10px] uppercase tracking-wider text-neutral-400 hover:bg-neutral-800 hover:text-neutral-200`,title:`Export this conversation`,children:[(0,R.jsx)(ye,{size:11}),`Export`]}),T&&(0,R.jsxs)(`div`,{role:`menu`,className:`absolute right-0 top-full z-30 mt-1 min-w-[12rem] rounded-md border border-neutral-700 bg-neutral-900 py-1 shadow-xl`,children:[(0,R.jsxs)(`button`,{role:`menuitem`,onClick:()=>void ee(`markdown`),className:`block w-full px-3 py-1.5 text-left text-xs text-neutral-200 hover:bg-neutral-800`,children:[`Markdown `,(0,R.jsx)(`span`,{className:`text-neutral-500`,children:`(.md)`})]}),(0,R.jsxs)(`button`,{role:`menuitem`,onClick:()=>void ee(`jsonl`),className:`block w-full px-3 py-1.5 text-left text-xs text-neutral-200 hover:bg-neutral-800`,children:[`Raw JSONL `,(0,R.jsx)(`span`,{className:`text-neutral-500`,children:`(.jsonl)`})]})]})]}),D!==void 0&&(0,R.jsxs)(`span`,{className:`text-[10px] text-amber-400 light:text-amber-700`,role:`status`,children:[`Export failed: `,D]}),(0,R.jsxs)(`button`,{onClick:()=>b(!0),className:`flex items-center gap-1 rounded px-1.5 py-0.5 text-[10px] uppercase tracking-wider text-neutral-400 hover:bg-neutral-800 hover:text-neutral-200`,title:`Open session tree (navigate / fork from any prior point)`,children:[(0,R.jsx)(De,{size:11}),`Tree`]}),C&&(0,R.jsxs)(`button`,{onClick:()=>S(e=>!e),"aria-pressed":x,className:`flex items-center gap-1 rounded px-1.5 py-0.5 text-[10px] uppercase tracking-wider hover:bg-neutral-800 ${x?`bg-neutral-800 text-violet-300`:`text-neutral-400 hover:text-neutral-200`}`,title:`Orchestration — supervisor / worker controls`,children:[(0,R.jsx)(nt,{size:11}),`Orch`]})]})]}),x&&C&&(0,R.jsx)(`div`,{className:`border-b border-neutral-800 bg-neutral-900/40 px-3 py-2`,children:(0,R.jsx)(nA,{sessionId:e,onClose:()=>S(!1)})}),o!==void 0&&(0,R.jsx)(`div`,{className:`border-b border-amber-700/40 bg-amber-900/20 px-6 py-2 text-xs text-amber-200 light:border-amber-300 light:bg-amber-50 light:text-amber-800`,children:o}),(0,R.jsxs)(`div`,{ref:A,onScroll:ne,className:`flex-1 overflow-y-auto px-6 py-4`,children:[t.length===0&&r.length===0&&!i&&(0,R.jsx)(`p`,{className:`mt-12 text-center text-sm text-neutral-500`,children:`No messages yet. Send a prompt to get started.`}),(0,R.jsxs)(`div`,{className:`chat-message-list mx-auto max-w-3xl space-y-4`,children:[(()=>{let e=new Map,r=new Set;for(let n of t)n.role===`toolResult`&&typeof n.toolCallId==`string`&&e.set(n.toolCallId,n);for(let e of t)if(!(e.role!==`assistant`||!Array.isArray(e.content)))for(let t of e.content)t.type===`toolCall`&&typeof t.id==`string`&&r.add(t.id);let i=new Map;for(let e of n){let t=i.get(e.insertBeforeIndex)??[];t.push(e),i.set(e.insertBeforeIndex,t)}let a=t=>t.archivedMessages.map((t,n)=>(0,R.jsx)(yA,{message:t,toolResultsById:e},n)),o=[],s=e=>{let t=i.get(e);if(t!==void 0)for(let e of t)o.push((0,R.jsx)(oC,{event:e,renderArchived:()=>a(e)},`compaction-${e.id}`))},c=n.length>0?n[n.length-1]:void 0,l=c?.insertBeforeIndex??0;return t.forEach((t,n)=>{s(n),!(t.role===`toolResult`&&typeof t.toolCallId==`string`&&r.has(t.toolCallId))&&t.role!==`compactionSummary`&&(c!==void 0&&n>=1&&n<l||o.push((0,R.jsx)(`div`,{"data-message-index":n,children:(0,R.jsx)(yA,{message:t,toolResultsById:e})},n)))}),s(t.length),o})(),r.length>0&&(0,R.jsxs)(`div`,{className:`message-bubble rounded-lg border border-neutral-800 bg-neutral-900 px-4 py-3`,children:[(0,R.jsx)(`div`,{className:`mb-1 text-[10px] uppercase tracking-wider text-neutral-500`,children:`assistant (streaming)`}),(0,R.jsxs)(`div`,{className:`text-neutral-100`,children:[(0,R.jsx)(aC,{text:r}),(0,R.jsx)(`span`,{className:`ml-1 inline-block h-3 w-1.5 animate-pulse bg-neutral-300 align-text-bottom`})]})]}),i&&r.length===0&&(0,R.jsx)(hA,{tool:a}),s!==void 0&&(0,R.jsx)(mA,{queued:s}),p.map(e=>(0,R.jsx)(Qk,{run:e},e.runId))]})]})]}),y&&_!==void 0&&(0,R.jsx)(Tk,{sessionId:e,projectId:_.id,onClose:()=>b(!1)})]})}function mA({queued:e}){let t=[];for(let n of e.steering)t.push({kind:`steer`,text:n});for(let n of e.followUp)t.push({kind:`followUp`,text:n});return t.length===0?null:(0,R.jsxs)(`div`,{className:`rounded-md border border-neutral-800 bg-neutral-900/40 px-3 py-2`,children:[(0,R.jsxs)(`div`,{className:`mb-1 text-[10px] uppercase tracking-wider text-neutral-500`,children:[`queued (`,t.length,`)`]}),(0,R.jsx)(`ul`,{className:`space-y-1`,children:t.map(e=>(0,R.jsxs)(`li`,{className:`flex items-baseline gap-2 text-xs text-neutral-300`,children:[(0,R.jsx)(`span`,{className:e.kind===`steer`?`shrink-0 rounded bg-amber-900/30 px-1.5 py-0.5 text-[9px] uppercase tracking-wider text-amber-300 light:bg-amber-100 light:text-amber-800`:`shrink-0 rounded bg-neutral-800 px-1.5 py-0.5 text-[9px] uppercase tracking-wider text-neutral-400`,title:e.kind===`steer`?`Delivered at the agent's next decision point (often mid-tool)`:`Delivered after the agent goes fully idle`,children:e.kind===`steer`?`steer`:`follow-up`}),(0,R.jsx)(`span`,{className:`truncate`,children:e.text})]},`${e.kind}:${e.text}`))})]})}function hA({tool:e}){return e===void 0?(0,R.jsxs)(`div`,{className:`flex items-center gap-2 text-xs italic text-neutral-500`,"aria-live":`polite`,"aria-label":`Agent is thinking`,children:[(0,R.jsx)(`span`,{children:`Thinking`}),(0,R.jsxs)(`span`,{className:`pi-thinking-dots`,"aria-hidden":`true`,children:[(0,R.jsx)(`span`,{children:`.`}),(0,R.jsx)(`span`,{children:`.`}),(0,R.jsx)(`span`,{children:`.`})]})]}):(0,R.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-neutral-400`,children:[(0,R.jsx)(`span`,{className:`inline-block h-1.5 w-1.5 animate-pulse rounded-full bg-neutral-400`}),(0,R.jsx)(`span`,{className:`text-neutral-500`,children:`running`}),(0,R.jsx)(`code`,{className:`rounded bg-neutral-800 px-1.5 py-0.5 font-mono text-[11px] text-neutral-200`,children:e.name}),e.summary!==void 0&&(0,R.jsx)(`code`,{className:`truncate rounded bg-neutral-900 px-1.5 py-0.5 font-mono text-[11px] text-neutral-300`,title:e.summary,children:e.summary})]})}function gA({diff:e,filename:t,adds:n,dels:r}){let{viewType:i,setViewType:a}=(0,v.useContext)(uA);return(0,R.jsxs)(`details`,{className:`group rounded border border-neutral-800 bg-neutral-950 text-xs`,children:[(0,R.jsxs)(`summary`,{className:`flex cursor-pointer items-center justify-between gap-2 px-3 py-2 text-neutral-300`,children:[(0,R.jsxs)(`span`,{className:`flex min-w-0 items-baseline gap-2`,children:[(0,R.jsxs)(`span`,{className:`text-neutral-500`,children:[`edit`,t===void 0?``:` `]}),t!==void 0&&(0,R.jsx)(`span`,{className:`truncate font-mono`,children:t}),(0,R.jsxs)(`span`,{className:`ml-2 text-emerald-400 light:text-emerald-700`,children:[`+`,n]}),(0,R.jsxs)(`span`,{className:`ml-1 text-red-400 light:text-red-700`,children:[`−`,r]})]}),(0,R.jsx)(`button`,{onClick:e=>{e.preventDefault(),e.stopPropagation(),a(i===`split`?`unified`:`split`)},className:`rounded p-0.5 text-neutral-500 hover:bg-neutral-800 hover:text-neutral-200`,title:i===`split`?`Switch chat diffs to unified view`:`Switch chat diffs to side-by-side view`,children:i===`split`?(0,R.jsx)(We,{size:11}):(0,R.jsx)(_e,{size:11})})]}),(0,R.jsx)(pk,{diff:e,viewType:i})]})}function _A(e){let t=[],n=e.replace(/\n?(`{3,})(\w*)\s+file:\s+([^\n]+)\n([\s\S]*?)\n\1\n?/g,(e,n,r,i,a)=>(t.push({kind:`inline`,path:i.trim(),lang:r,content:a}),``)),r=/(^|\s)@(?:"([^"\n]+)"|([^\s]+?))(?=[?,;:!)\]]?(?:\s|$))/g,i;for(;(i=r.exec(n))!==null;){let e=(i[2]??i[3]??``).trim();e.length!==0&&(t.some(t=>t.kind===`inline`&&t.path===e)||t.push({kind:`defer`,path:e}))}return n=n.replace(/\n{3,}/g,`
344
344
 
345
- `).trim(),{stripped:n,refs:t}}function vA({ref:e}){let[t,n]=(0,v.useState)(!1),r=e.kind===`inline`;return(0,R.jsxs)(`div`,{className:`overflow-hidden rounded border bg-neutral-900 ${r?`border-neutral-700`:`border-emerald-700/60 bg-emerald-900/15`}`,children:[(0,R.jsxs)(`button`,{type:`button`,onClick:()=>r&&n(e=>!e),disabled:!r,className:`flex min-h-11 w-full items-center gap-1.5 px-2 py-1 text-left text-[11px] md:min-h-0 ${r?`text-neutral-200 hover:bg-neutral-800`:`cursor-default text-emerald-200 light:text-emerald-800`}`,title:r?`${e.path} — click to ${t?`collapse`:`expand`}`:`${e.path} — model will load this on demand using its read tool (file is larger than the inline threshold)`,children:[r?t?(0,R.jsx)(ue,{size:12}):(0,R.jsx)(fe,{size:12}):(0,R.jsx)(se,{size:12,className:`text-emerald-300/80 light:text-emerald-700`}),(0,R.jsx)(xe,{size:12,className:r?`text-neutral-400`:`text-emerald-300/80`}),(0,R.jsx)(`span`,{className:`font-mono`,children:e.path}),r&&(0,R.jsx)(`span`,{className:`text-[10px] text-neutral-500`,children:e.content.length<1024?`${e.content.length} B`:`${(e.content.length/1024).toFixed(1)} KB`}),!r&&(0,R.jsx)(`span`,{className:`text-[10px] text-emerald-300/70 light:text-emerald-700/80`,children:`on demand`})]}),r&&t&&(0,R.jsx)(`pre`,{className:`max-h-72 overflow-auto border-t border-neutral-800 bg-neutral-950 px-3 py-2 font-mono text-[11px] leading-relaxed text-neutral-300`,children:e.content})]})}function yA({message:e,toolResultsById:t}){let[n,r]=(0,v.useState)(!1);if(e.role===`user`){let{stripped:t,refs:i}=_A(FA(e)),a=Array.isArray(e.content)?e.content:[],o=[],s=[];for(let e=0;e<a.length;e++){let t=a[e];if(t.type===`image`){let n=typeof t.data==`string`?t.data:``,r=typeof t.mimeType==`string`?t.mimeType:`image/png`,i=t.__blobUrl===!0?n:`data:${r};base64,${n}`;n.length>0&&o.push({src:i,key:`img-${e}`})}else if(t.type===`file`){let n={name:typeof t.filename==`string`?t.filename:`attachment`,key:`file-${e}`};typeof t.size==`number`&&(n.size=t.size),s.push(n)}}return(0,R.jsxs)(`div`,{className:`message-bubble group rounded-lg bg-neutral-800 px-4 py-3`,"data-message-role":`user`,children:[(0,R.jsxs)(`div`,{className:`mb-1 flex items-center justify-between`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(`span`,{className:`text-[10px] uppercase tracking-wider text-neutral-400`,children:`you`}),(0,R.jsx)(PA,{ts:e.timestamp})]}),t.length>0&&(0,R.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,R.jsx)(kA,{getText:()=>t,title:`Copy message text`}),(0,R.jsx)(jA,{showRaw:n,onToggle:r})]})]}),t.length>0&&(0,R.jsx)(`div`,{className:`text-neutral-100`,children:n?(0,R.jsx)(MA,{text:t}):(0,R.jsx)(aC,{text:t,chatStyleBreaks:!0})}),i.length>0&&(0,R.jsx)(`div`,{className:`mt-2 flex flex-col gap-1`,children:i.map((e,t)=>(0,R.jsx)(vA,{ref:e},`fileref-${t}-${e.path}`))}),o.length>0&&(0,R.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:o.map(e=>(0,R.jsx)(`img`,{src:e.src,alt:``,className:`max-h-48 max-w-full rounded border border-neutral-700`},e.key))}),s.length>0&&(0,R.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:s.map(e=>(0,R.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded border border-neutral-700 bg-neutral-900 px-2 py-1 text-[11px] text-neutral-300`,title:e.name,children:[(0,R.jsx)(`span`,{className:`font-mono`,children:e.name}),e.size!==void 0&&(0,R.jsx)(`span`,{className:`text-[10px] text-neutral-500`,children:e.size<1024?`${e.size} B`:e.size<1024*1024?`${(e.size/1024).toFixed(1)} KB`:`${(e.size/(1024*1024)).toFixed(1)} MB`})]},e.key))})]})}if(e.role===`assistant`){let i=Array.isArray(e.content)?e.content:[],a=i.some(e=>e.type===`text`);return(0,R.jsxs)(`div`,{className:`message-bubble group rounded-lg border border-neutral-800 bg-neutral-900 px-4 py-3`,"data-message-role":`assistant`,children:[(0,R.jsxs)(`div`,{className:`mb-1 flex items-center justify-between`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(`span`,{className:`text-[10px] uppercase tracking-wider text-neutral-500`,children:`assistant`}),(0,R.jsx)(PA,{ts:e.timestamp})]}),a&&(0,R.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,R.jsx)(kA,{getText:()=>AA(i),title:`Copy all text from this assistant message`}),(0,R.jsx)(jA,{showRaw:n,onToggle:r})]})]}),(0,R.jsx)(`div`,{className:`space-y-2 text-sm text-neutral-100`,children:bA(i,t,n)})]})}return e.role===`toolResult`?(0,R.jsx)(wA,{message:e}):e.role===`bashExecution`||e.type===`bashExecution`||e.customType===`bashExecution`?(0,R.jsx)(OA,{message:e}):(0,R.jsxs)(`details`,{className:`rounded-lg border border-neutral-800 bg-neutral-900/40 px-3 py-2 text-xs text-neutral-400`,children:[(0,R.jsxs)(`summary`,{className:`cursor-pointer`,children:[`unknown message (`,String(e.role??e.type??`?`),`)`]}),(0,R.jsx)(`pre`,{className:`mt-2 overflow-auto whitespace-pre-wrap text-[10px] text-neutral-500`,children:JSON.stringify(e,null,2)})]})}function bA(e,t,n){let r=[],i=0;for(;i<e.length;){let a=e[i];if(a.type===`toolCall`&&a.name===`todo`){let n=i,a=[];for(;i<e.length;){let n=e[i];if(n?.type!==`toolCall`||n.name!==`todo`)break;let r=typeof n.id==`string`?n.id:void 0,o=r===void 0?void 0:t?.get(r);a.push({block:n,result:o}),i+=1}if(a.length===1){let e=a[0];r.push((0,R.jsx)(CA,{block:e.block,result:e.result},n))}else r.push((0,R.jsx)(xA,{entries:a},`todo-batch-${n}`));continue}let o={block:a,showRaw:n};t!==void 0&&(o.toolResultsById=t),r.push((0,R.jsx)(SA,{...o},i)),i+=1}return r}function xA({entries:e}){let t=[...e].reverse().find(e=>e.result!==void 0)?.result?.details??void 0,n=Array.isArray(t?.tasks)?t.tasks.length:0,r=e.filter(e=>e.result===void 0).length,i=e.some(e=>e.result?.isError===!0),a=e.map(e=>(Array.isArray(e.result?.content)?e.result.content:[]).find(e=>{let t=e;return t.type===`text`&&typeof t.text==`string`})?.text??`(no output)`);return(0,R.jsxs)(`details`,{className:`group rounded border border-neutral-800 bg-neutral-950 text-xs`,children:[(0,R.jsxs)(`summary`,{className:`flex cursor-pointer items-center justify-between gap-2 px-3 py-2 text-neutral-300`,children:[(0,R.jsxs)(`span`,{className:`flex min-w-0 items-baseline gap-2`,children:[(0,R.jsx)(`span`,{className:`text-neutral-500`,children:`→`}),(0,R.jsx)(`span`,{className:`font-mono`,children:`todo`}),(0,R.jsxs)(`span`,{className:`text-neutral-500`,children:[`×`,e.length,` `,e.length===1?`call`:`calls`]}),(0,R.jsx)(`span`,{className:`ml-2 truncate text-neutral-400`,children:n===0?`no tasks`:`${n} ${n===1?`task`:`tasks`} after batch`})]}),(0,R.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[r>0&&(0,R.jsxs)(`span`,{className:`rounded bg-neutral-800 px-1.5 py-0.5 text-[10px] uppercase tracking-wider text-neutral-400`,children:[r,` running…`]}),i&&(0,R.jsx)(`span`,{className:`rounded bg-red-900/30 px-1.5 py-0.5 text-[10px] uppercase tracking-wider text-red-300 light:bg-red-100 light:text-red-800`,children:`error`})]})]}),(0,R.jsx)(`div`,{className:`space-y-1 border-t border-neutral-800/60 px-3 py-2 font-mono text-[11px] text-neutral-400`,children:a.map((e,t)=>(0,R.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,R.jsxs)(`span`,{className:`shrink-0 text-neutral-600`,children:[`#`,t+1]}),(0,R.jsx)(`span`,{className:`whitespace-pre-wrap break-words text-neutral-300`,children:e})]},t))})]})}function SA({block:e,toolResultsById:t,showRaw:n=!1}){let r=e.type;if(r===`text`&&typeof e.text==`string`)return n?(0,R.jsx)(MA,{text:e.text}):(0,R.jsx)(aC,{text:e.text});if(r===`thinking`&&typeof e.thinking==`string`)return(0,R.jsxs)(`details`,{className:`rounded border border-neutral-800 px-2 py-1 text-xs text-neutral-400`,children:[(0,R.jsx)(`summary`,{className:`cursor-pointer`,children:`Thinking…`}),(0,R.jsx)(`pre`,{className:`mt-1 whitespace-pre-wrap break-words font-sans text-[12px]`,children:e.thinking})]});if(r===`toolCall`){let n=typeof e.id==`string`?e.id:void 0;return(0,R.jsx)(CA,{block:e,result:n===void 0?void 0:t?.get(n)})}return(0,R.jsxs)(`details`,{className:`text-xs text-neutral-500`,children:[(0,R.jsxs)(`summary`,{className:`cursor-pointer`,children:[`block (`,String(r??`?`),`)`]}),(0,R.jsx)(`pre`,{className:`mt-1 overflow-auto whitespace-pre-wrap text-[10px]`,children:JSON.stringify(e,null,2)})]})}function CA({block:e,result:t}){let n=String(e.name??`tool`),r=e.input??e.arguments??{},i=typeof r==`string`?r:JSON.stringify(r,null,2),a=t?.isError===!0,o=Array.isArray(t?.content)?t?.content:[],s=NA(r)?r:void 0,c=n===`bash`&&typeof s?.command==`string`?s.command:(n===`read`||n===`write`||n===`edit`)&&typeof s?.path==`string`?s.path:void 0,l=o.filter(e=>{let t=e;return t.type===`text`&&typeof t.text==`string`}).map(e=>e.text).join(`
345
+ `).trim(),{stripped:n,refs:t}}function vA({ref:e}){let[t,n]=(0,v.useState)(!1),r=e.kind===`inline`;return(0,R.jsxs)(`div`,{className:`overflow-hidden rounded border bg-neutral-900 ${r?`border-neutral-700`:`border-emerald-700/60 bg-emerald-900/15`}`,children:[(0,R.jsxs)(`button`,{type:`button`,onClick:()=>r&&n(e=>!e),disabled:!r,className:`flex min-h-11 w-full items-center gap-1.5 px-2 py-1 text-left text-[11px] md:min-h-0 ${r?`text-neutral-200 hover:bg-neutral-800`:`cursor-default text-emerald-200 light:text-emerald-800`}`,title:r?`${e.path} — click to ${t?`collapse`:`expand`}`:`${e.path} — model will load this on demand using its read tool (file is larger than the inline threshold)`,children:[r?t?(0,R.jsx)(ue,{size:12}):(0,R.jsx)(fe,{size:12}):(0,R.jsx)(se,{size:12,className:`text-emerald-300/80 light:text-emerald-700`}),(0,R.jsx)(xe,{size:12,className:r?`text-neutral-400`:`text-emerald-300/80`}),(0,R.jsx)(`span`,{className:`font-mono`,children:e.path}),r&&(0,R.jsx)(`span`,{className:`text-[10px] text-neutral-500`,children:e.content.length<1024?`${e.content.length} B`:`${(e.content.length/1024).toFixed(1)} KB`}),!r&&(0,R.jsx)(`span`,{className:`text-[10px] text-emerald-300/70 light:text-emerald-700/80`,children:`on demand`})]}),r&&t&&(0,R.jsx)(`pre`,{className:`max-h-72 overflow-auto border-t border-neutral-800 bg-neutral-950 px-3 py-2 font-mono text-[11px] leading-relaxed text-neutral-300`,children:e.content})]})}function yA({message:e,toolResultsById:t}){let[n,r]=(0,v.useState)(!1);if(e.role===`user`){let{stripped:t,refs:i}=_A(FA(e)),a=Array.isArray(e.content)?e.content:[],o=[],s=[];for(let e=0;e<a.length;e++){let t=a[e];if(t.type===`image`){let n=typeof t.data==`string`?t.data:``,r=typeof t.mimeType==`string`?t.mimeType:`image/png`,i=t.__blobUrl===!0?n:`data:${r};base64,${n}`;n.length>0&&o.push({src:i,key:`img-${e}`})}else if(t.type===`file`){let n={name:typeof t.filename==`string`?t.filename:`attachment`,key:`file-${e}`};typeof t.size==`number`&&(n.size=t.size),s.push(n)}}return(0,R.jsxs)(`div`,{className:`message-bubble group rounded-lg bg-neutral-800 px-4 py-3`,"data-message-role":`user`,children:[(0,R.jsxs)(`div`,{className:`mb-1 flex items-center justify-between`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(`span`,{className:`text-[10px] uppercase tracking-wider text-neutral-400`,children:`you`}),(0,R.jsx)(PA,{ts:e.timestamp})]}),t.length>0&&(0,R.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,R.jsx)(kA,{getText:()=>t,title:`Copy message text`}),(0,R.jsx)(jA,{showRaw:n,onToggle:r})]})]}),t.length>0&&(0,R.jsx)(`div`,{className:`text-neutral-100`,children:n?(0,R.jsx)(MA,{text:t}):(0,R.jsx)(aC,{text:t,chatStyleBreaks:!0})}),i.length>0&&(0,R.jsx)(`div`,{className:`mt-2 flex flex-col gap-1`,children:i.map((e,t)=>(0,R.jsx)(vA,{ref:e},`fileref-${t}-${e.path}`))}),o.length>0&&(0,R.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:o.map(e=>(0,R.jsx)(`img`,{src:e.src,alt:``,className:`max-h-48 max-w-full rounded border border-neutral-700`},e.key))}),s.length>0&&(0,R.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:s.map(e=>(0,R.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded border border-neutral-700 bg-neutral-900 px-2 py-1 text-[11px] text-neutral-300`,title:e.name,children:[(0,R.jsx)(`span`,{className:`font-mono`,children:e.name}),e.size!==void 0&&(0,R.jsx)(`span`,{className:`text-[10px] text-neutral-500`,children:e.size<1024?`${e.size} B`:e.size<1024*1024?`${(e.size/1024).toFixed(1)} KB`:`${(e.size/(1024*1024)).toFixed(1)} MB`})]},e.key))})]})}if(e.role===`assistant`){let i=Array.isArray(e.content)?e.content:[],a=i.some(e=>e.type===`text`),o=e.stopReason,s=e.errorMessage,c=o===`error`&&typeof s==`string`&&s.length>0?s:void 0;return(0,R.jsxs)(`div`,{className:`message-bubble group rounded-lg border border-neutral-800 bg-neutral-900 px-4 py-3`,"data-message-role":`assistant`,children:[(0,R.jsxs)(`div`,{className:`mb-1 flex items-center justify-between`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(`span`,{className:`text-[10px] uppercase tracking-wider text-neutral-500`,children:`assistant`}),(0,R.jsx)(PA,{ts:e.timestamp})]}),a&&(0,R.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,R.jsx)(kA,{getText:()=>AA(i),title:`Copy all text from this assistant message`}),(0,R.jsx)(jA,{showRaw:n,onToggle:r})]})]}),(0,R.jsx)(`div`,{className:`space-y-2 text-sm text-neutral-100`,children:bA(i,t,n)}),c!==void 0&&(0,R.jsxs)(`div`,{className:`mt-2 rounded border border-amber-700/40 bg-amber-900/20 px-3 py-2 text-xs text-amber-200 light:border-amber-300 light:bg-amber-50 light:text-amber-800`,role:`alert`,children:[(0,R.jsx)(`span`,{className:`font-medium`,children:`Provider error: `}),c]})]})}return e.role===`toolResult`?(0,R.jsx)(wA,{message:e}):e.role===`bashExecution`||e.type===`bashExecution`||e.customType===`bashExecution`?(0,R.jsx)(OA,{message:e}):(0,R.jsxs)(`details`,{className:`rounded-lg border border-neutral-800 bg-neutral-900/40 px-3 py-2 text-xs text-neutral-400`,children:[(0,R.jsxs)(`summary`,{className:`cursor-pointer`,children:[`unknown message (`,String(e.role??e.type??`?`),`)`]}),(0,R.jsx)(`pre`,{className:`mt-2 overflow-auto whitespace-pre-wrap text-[10px] text-neutral-500`,children:JSON.stringify(e,null,2)})]})}function bA(e,t,n){let r=[],i=0;for(;i<e.length;){let a=e[i];if(a.type===`toolCall`&&a.name===`todo`){let n=i,a=[];for(;i<e.length;){let n=e[i];if(n?.type!==`toolCall`||n.name!==`todo`)break;let r=typeof n.id==`string`?n.id:void 0,o=r===void 0?void 0:t?.get(r);a.push({block:n,result:o}),i+=1}if(a.length===1){let e=a[0];r.push((0,R.jsx)(CA,{block:e.block,result:e.result},n))}else r.push((0,R.jsx)(xA,{entries:a},`todo-batch-${n}`));continue}let o={block:a,showRaw:n};t!==void 0&&(o.toolResultsById=t),r.push((0,R.jsx)(SA,{...o},i)),i+=1}return r}function xA({entries:e}){let t=[...e].reverse().find(e=>e.result!==void 0)?.result?.details??void 0,n=Array.isArray(t?.tasks)?t.tasks.length:0,r=e.filter(e=>e.result===void 0).length,i=e.some(e=>e.result?.isError===!0),a=e.map(e=>(Array.isArray(e.result?.content)?e.result.content:[]).find(e=>{let t=e;return t.type===`text`&&typeof t.text==`string`})?.text??`(no output)`);return(0,R.jsxs)(`details`,{className:`group rounded border border-neutral-800 bg-neutral-950 text-xs`,children:[(0,R.jsxs)(`summary`,{className:`flex cursor-pointer items-center justify-between gap-2 px-3 py-2 text-neutral-300`,children:[(0,R.jsxs)(`span`,{className:`flex min-w-0 items-baseline gap-2`,children:[(0,R.jsx)(`span`,{className:`text-neutral-500`,children:`→`}),(0,R.jsx)(`span`,{className:`font-mono`,children:`todo`}),(0,R.jsxs)(`span`,{className:`text-neutral-500`,children:[`×`,e.length,` `,e.length===1?`call`:`calls`]}),(0,R.jsx)(`span`,{className:`ml-2 truncate text-neutral-400`,children:n===0?`no tasks`:`${n} ${n===1?`task`:`tasks`} after batch`})]}),(0,R.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[r>0&&(0,R.jsxs)(`span`,{className:`rounded bg-neutral-800 px-1.5 py-0.5 text-[10px] uppercase tracking-wider text-neutral-400`,children:[r,` running…`]}),i&&(0,R.jsx)(`span`,{className:`rounded bg-red-900/30 px-1.5 py-0.5 text-[10px] uppercase tracking-wider text-red-300 light:bg-red-100 light:text-red-800`,children:`error`})]})]}),(0,R.jsx)(`div`,{className:`space-y-1 border-t border-neutral-800/60 px-3 py-2 font-mono text-[11px] text-neutral-400`,children:a.map((e,t)=>(0,R.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,R.jsxs)(`span`,{className:`shrink-0 text-neutral-600`,children:[`#`,t+1]}),(0,R.jsx)(`span`,{className:`whitespace-pre-wrap break-words text-neutral-300`,children:e})]},t))})]})}function SA({block:e,toolResultsById:t,showRaw:n=!1}){let r=e.type;if(r===`text`&&typeof e.text==`string`)return n?(0,R.jsx)(MA,{text:e.text}):(0,R.jsx)(aC,{text:e.text});if(r===`thinking`&&typeof e.thinking==`string`)return(0,R.jsxs)(`details`,{className:`rounded border border-neutral-800 px-2 py-1 text-xs text-neutral-400`,children:[(0,R.jsx)(`summary`,{className:`cursor-pointer`,children:`Thinking…`}),(0,R.jsx)(`pre`,{className:`mt-1 whitespace-pre-wrap break-words font-sans text-[12px]`,children:e.thinking})]});if(r===`toolCall`){let n=typeof e.id==`string`?e.id:void 0;return(0,R.jsx)(CA,{block:e,result:n===void 0?void 0:t?.get(n)})}return(0,R.jsxs)(`details`,{className:`text-xs text-neutral-500`,children:[(0,R.jsxs)(`summary`,{className:`cursor-pointer`,children:[`block (`,String(r??`?`),`)`]}),(0,R.jsx)(`pre`,{className:`mt-1 overflow-auto whitespace-pre-wrap text-[10px]`,children:JSON.stringify(e,null,2)})]})}function CA({block:e,result:t}){let n=String(e.name??`tool`),r=e.input??e.arguments??{},i=typeof r==`string`?r:JSON.stringify(r,null,2),a=t?.isError===!0,o=Array.isArray(t?.content)?t?.content:[],s=NA(r)?r:void 0,c=n===`bash`&&typeof s?.command==`string`?s.command:(n===`read`||n===`write`||n===`edit`)&&typeof s?.path==`string`?s.path:void 0,l=o.filter(e=>{let t=e;return t.type===`text`&&typeof t.text==`string`}).map(e=>e.text).join(`
346
346
  `),u=n===`edit`&&t!==void 0?(()=>{let e=t.details?.diff;return typeof e==`string`?e:l})():void 0,d=n===`edit`&&t!==void 0?IA(t):void 0,f=u===void 0?void 0:LA(u);return n===`subagent`?(0,R.jsx)(TA,{argsText:i,input:s,result:t,isError:a,outputText:l}):(0,R.jsxs)(`div`,{className:`rounded border ${t===void 0?`border-neutral-700`:a?`border-red-700/50`:`border-neutral-800`} bg-neutral-950 text-xs`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-2 text-neutral-300`,children:[(0,R.jsxs)(`div`,{className:`min-w-0 flex-1 truncate`,children:[(0,R.jsx)(`span`,{className:`text-neutral-500`,children:`→ `}),(0,R.jsx)(`span`,{className:`font-mono`,children:n}),c!==void 0&&(0,R.jsx)(`span`,{className:`ml-2 truncate font-mono text-neutral-400`,title:c,children:c})]}),(0,R.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[t===void 0&&(0,R.jsx)(`span`,{className:`rounded bg-neutral-800 px-1.5 py-0.5 text-[10px] uppercase tracking-wider text-neutral-400`,children:`running…`}),a&&(0,R.jsx)(`span`,{className:`rounded bg-red-900/30 px-1.5 py-0.5 text-[10px] uppercase tracking-wider text-red-300 light:bg-red-100 light:text-red-800`,children:`error`})]})]}),i.length>0&&(0,R.jsxs)(`details`,{className:`border-t border-neutral-800/60`,children:[(0,R.jsx)(`summary`,{className:`cursor-pointer px-3 py-1.5 text-[11px] text-neutral-500 hover:text-neutral-300`,children:`Input`}),(0,R.jsx)(`pre`,{className:`overflow-auto px-3 pb-2 font-mono text-[11px] text-neutral-400`,children:i})]}),t!==void 0&&(0,R.jsxs)(`details`,{className:`border-t border-neutral-800/60`,children:[(0,R.jsxs)(`summary`,{className:`cursor-pointer px-3 py-1.5 text-[11px] text-neutral-500 hover:text-neutral-300`,children:[`Output`,f!==void 0&&(0,R.jsxs)(`span`,{className:`ml-2 font-mono text-[10px]`,children:[(0,R.jsxs)(`span`,{className:`text-emerald-400 light:text-emerald-700`,children:[`+`,f.adds]}),` `,(0,R.jsxs)(`span`,{className:`text-red-400 light:text-red-700`,children:[`-`,f.dels]})]}),d!==void 0&&(0,R.jsx)(`span`,{className:`ml-2 font-mono text-[10px] text-neutral-500`,children:d})]}),u!==void 0&&f!==void 0?(0,R.jsx)(`div`,{className:`px-3 pb-2`,children:(0,R.jsx)(gA,{diff:u,filename:d,adds:f.adds,dels:f.dels})}):(0,R.jsx)(`pre`,{className:`max-h-96 overflow-auto px-3 pb-2 font-mono text-[11px] text-neutral-300`,children:l.length>0?l:`(empty)`})]})]})}function wA({message:e}){let t=String(e.toolName??`tool`),n=e.isError===!0,r=(Array.isArray(e.content)?e.content:[]).filter(e=>{let t=e;return t.type===`text`&&typeof t.text==`string`}).map(e=>e.text).join(`
347
347
  `);if(t===`edit`){let t=e.details,n=typeof t?.diff==`string`?t.diff:r,i=IA(e),{adds:a,dels:o}=LA(n);return(0,R.jsx)(gA,{diff:n,filename:i,adds:a,dels:o})}if(t===`read`){let t=IA(e);return(0,R.jsxs)(`details`,{className:`rounded border border-neutral-800 bg-neutral-950 text-xs`,children:[(0,R.jsxs)(`summary`,{className:`cursor-pointer px-3 py-2 text-neutral-300`,children:[(0,R.jsxs)(`span`,{className:`text-neutral-500`,children:[`read`,t===void 0?``:` `]}),t!==void 0&&(0,R.jsx)(`span`,{className:`font-mono`,children:t})]}),(0,R.jsx)(`pre`,{className:`overflow-auto px-3 pb-2 font-mono text-[11px] text-neutral-400`,children:r})]})}if(t===`bash`){let t=RA(e);return(0,R.jsxs)(`div`,{className:`rounded border ${n?`border-red-700/40`:`border-neutral-800`} bg-neutral-950 text-xs`,children:[(0,R.jsxs)(`div`,{className:`px-3 py-2 text-neutral-400`,children:[(0,R.jsxs)(`span`,{className:`text-neutral-500`,children:[`bash`,t===void 0?` output`:` → `]}),t!==void 0&&(0,R.jsx)(`span`,{className:`font-mono`,children:t})]}),(0,R.jsx)(`pre`,{className:`max-h-64 overflow-auto px-3 pb-2 font-mono text-[11px] text-neutral-300`,children:r})]})}if(t===`write`){let t=IA(e);return(0,R.jsxs)(`details`,{className:`rounded border border-neutral-800 bg-neutral-950 text-xs`,children:[(0,R.jsxs)(`summary`,{className:`cursor-pointer px-3 py-2 text-neutral-300`,children:[(0,R.jsxs)(`span`,{className:`text-neutral-500`,children:[`write`,t===void 0?``:` `]}),t!==void 0&&(0,R.jsx)(`span`,{className:`font-mono`,children:t}),(0,R.jsxs)(`span`,{className:`ml-2 text-neutral-500`,children:[`(`,r.split(`
348
348
  `).length,` lines)`]})]}),(0,R.jsx)(`pre`,{className:`overflow-auto px-3 pb-2 font-mono text-[11px] text-neutral-400`,children:r})]})}return t===`subagent`?(0,R.jsx)(EA,{message:e,argsText:``,outputText:r,isError:n}):(0,R.jsxs)(`details`,{className:`rounded border ${n?`border-red-700/40 light:border-red-300`:`border-neutral-800`} bg-neutral-950 text-xs`,children:[(0,R.jsxs)(`summary`,{className:`cursor-pointer px-3 py-2 text-neutral-300`,children:[(0,R.jsx)(`span`,{className:`text-neutral-500`,children:t}),n&&(0,R.jsx)(`span`,{className:`ml-2 text-red-400 light:text-red-700`,children:`error`})]}),(0,R.jsx)(`pre`,{className:`overflow-auto px-3 pb-2 font-mono text-[11px] text-neutral-400`,children:r})]})}function TA({argsText:e,input:t,result:n,isError:r,outputText:i}){if(n!==void 0)return(0,R.jsx)(EA,{message:n,argsText:e,outputText:i,isError:r});let a;if(t!==void 0){let e=typeof t.agent==`string`?t.agent:void 0,n=typeof t.task==`string`?t.task:void 0,r=typeof t.action==`string`?t.action:void 0,i=Array.isArray(t.tasks)?t.tasks.length:void 0,o=Array.isArray(t.chain)?t.chain.length:void 0;r===void 0?i===void 0?o===void 0?e!==void 0&&n!==void 0?a=`${e} — ${n}`:e!==void 0&&(a=e):a=`${o}-step chain`:a=`${i} parallel task${i===1?``:`s`}`:a=`action: ${r}`}return(0,R.jsx)(`div`,{className:`overflow-hidden rounded border border-l-2 border-sky-700/50 border-l-sky-400 bg-sky-950/15 text-xs light:border-sky-300 light:border-l-sky-600 light:bg-sky-50`,children:(0,R.jsx)(`div`,{className:`flex items-center justify-between gap-2 px-2.5 py-1.5`,children:(0,R.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,R.jsx)(nt,{size:11,className:`shrink-0 text-sky-300 light:text-sky-700`}),(0,R.jsx)(`span`,{className:`truncate font-medium text-sky-100 light:text-sky-900`,children:`Sub-agent running…`}),a!==void 0&&(0,R.jsx)(`span`,{className:`ml-1 truncate font-mono text-[11px] text-sky-200/70 light:text-sky-800/80`,title:a,children:a})]})})})}function EA({message:e,argsText:t,outputText:n,isError:r}){let i=qr(e=>e.setActiveSession),a=lr(e=>e.setActive),o=qr(e=>e.byProject),s=(0,v.useMemo)(()=>{let e=new Map;for(let t of Object.values(o))for(let n of t)typeof n.path==`string`&&n.path.length>0&&e.set(n.path,{sessionId:n.sessionId,projectId:n.projectId});return e},[o]),c=e=>{if(e===void 0){console.warn(`[subagent] Open clicked but result has no sessionFile`);return}let t=s.get(e);if(console.info(`[subagent] Open clicked`,{sessionFile:e,match:t}),t===void 0){console.warn(`[subagent] Open: sessionFile not found in any project's session list`,e);return}a(t.projectId),i(t.sessionId)},l=tA(e.details),u=l.mode===`management`,d=l.results.length,f=d===1?`Sub-agent: ${l.results[0].agent}`:d>1?`${d} sub-agents (${l.mode})`:u?`Sub-agent management`:`Sub-agent`;return(0,R.jsxs)(`div`,{className:`overflow-hidden rounded border border-l-2 ${r?`border-red-700/50 border-l-red-400 bg-red-950/15 light:border-red-300 light:border-l-red-600 light:bg-red-50`:`border-sky-700/50 border-l-sky-400 bg-sky-950/15 light:border-sky-300 light:border-l-sky-600 light:bg-sky-50`} text-xs`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-2.5 py-1.5`,children:[(0,R.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,R.jsx)(nt,{size:11,className:`shrink-0 text-sky-300 light:text-sky-700`}),(0,R.jsx)(`span`,{className:`truncate font-medium text-sky-100 light:text-sky-900`,children:f}),l.context!==void 0&&(0,R.jsx)(`span`,{className:`shrink-0 rounded bg-sky-900/40 px-1 py-0.5 text-[9px] font-medium uppercase tracking-wider text-sky-200 light:bg-sky-100 light:text-sky-800`,title:l.context===`fork`?`Forked from parent context`:`Fresh context`,children:l.context}),r&&(0,R.jsx)(`span`,{className:`shrink-0 rounded bg-red-900/40 px-1 py-0.5 text-[9px] font-medium uppercase tracking-wider text-red-200 light:bg-red-100 light:text-red-800`,children:`error`})]}),l.results.length===1&&l.results[0].sessionFile!==void 0&&(0,R.jsxs)(`button`,{onClick:()=>c(l.results[0].sessionFile),className:`inline-flex min-h-11 shrink-0 items-center gap-1 rounded border border-sky-700/60 px-2 py-1 text-[12px] font-medium text-sky-200 hover:border-sky-500 hover:bg-sky-900/30 hover:text-sky-100 light:border-sky-400 light:text-sky-800 light:hover:border-sky-600 light:hover:bg-sky-100 light:hover:text-sky-900 md:min-h-0 md:px-1.5 md:py-0.5 md:text-[10px]`,title:`Open sub-agent session — ${l.results[0].sessionFile}`,children:[(0,R.jsx)(be,{size:12}),`Open`]})]}),d>1&&(0,R.jsx)(`div`,{className:`space-y-1.5 border-t border-sky-900/30 px-2.5 py-2`,children:l.results.map((e,t)=>(0,R.jsx)(DA,{result:e,onOpenFile:c},e.sessionFile??`${t}-${e.agent}`))}),t.length>0&&(0,R.jsxs)(`details`,{className:`border-t border-sky-900/30`,children:[(0,R.jsx)(`summary`,{className:`cursor-pointer px-2.5 py-1 text-[11px] text-neutral-500 hover:text-neutral-300`,children:`Input`}),(0,R.jsx)(`pre`,{className:`overflow-auto px-2.5 pb-2 font-mono text-[11px] text-neutral-400`,children:t})]}),n.length>0&&(0,R.jsxs)(`details`,{open:r,className:`border-t border-sky-900/30`,children:[(0,R.jsx)(`summary`,{className:`cursor-pointer px-2.5 py-1 text-[11px] text-neutral-500 hover:text-neutral-300`,children:`Output`}),(0,R.jsx)(`pre`,{className:`overflow-auto px-2.5 pb-2 font-mono text-[11px] text-neutral-300 whitespace-pre-wrap`,children:n})]})]})}function DA({result:e,onOpenFile:t}){let n=e.exitCode!==0;return(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-2 rounded border ${n?`border-red-700/40 light:border-red-300`:`border-sky-900/40 light:border-sky-300`} bg-neutral-950/60 px-2 py-1.5`,children:[(0,R.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,R.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,R.jsx)(`span`,{className:`font-mono text-[11px] font-medium text-sky-200 light:text-sky-800`,children:e.agent}),n&&(0,R.jsxs)(`span`,{className:`text-[10px] font-medium text-red-400 light:text-red-700`,children:[`exit `,e.exitCode]})]}),e.task.length>0&&(0,R.jsx)(`div`,{className:`mt-0.5 truncate text-[11px] text-neutral-400`,title:e.task,children:e.task})]}),e.sessionFile!==void 0&&(0,R.jsxs)(`button`,{onClick:()=>t(e.sessionFile),className:`inline-flex shrink-0 items-center gap-1 rounded border border-sky-700/60 px-1.5 py-0.5 text-[10px] font-medium text-sky-200 hover:border-sky-500 hover:bg-sky-900/30 hover:text-sky-100 light:border-sky-400 light:text-sky-800 light:hover:border-sky-600 light:hover:bg-sky-100 light:hover:text-sky-900`,title:e.sessionFile,children:[(0,R.jsx)(be,{size:10}),`Open`]})]})}function OA({message:e}){let t=String(e.command??``),n=String(e.output??``),r=typeof e.exitCode==`number`?e.exitCode:void 0,i=e.truncated===!0,a=e.cancelled===!0,o=e.excludeFromContext===!0;return(0,R.jsxs)(`div`,{className:`rounded border border-neutral-800 bg-neutral-950 text-xs`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-3 py-2 text-neutral-400`,children:[(0,R.jsxs)(`div`,{className:`min-w-0 flex-1 truncate`,children:[(0,R.jsx)(`span`,{className:`text-neutral-500`,children:`$ `}),(0,R.jsx)(`span`,{className:`font-mono text-neutral-200`,children:t})]}),(0,R.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[o&&(0,R.jsx)(`span`,{className:`rounded bg-neutral-800 px-1.5 py-0.5 text-[10px] uppercase tracking-wider text-neutral-400`,title:`!! prefix — kept out of LLM context on the next turn`,children:`local-only`}),a&&(0,R.jsx)(`span`,{className:`rounded bg-amber-900/40 px-1.5 py-0.5 text-[10px] uppercase tracking-wider text-amber-300 light:bg-amber-100 light:text-amber-800`,children:`timed out`}),i&&!a&&(0,R.jsx)(`span`,{className:`rounded bg-amber-900/40 px-1.5 py-0.5 text-[10px] uppercase tracking-wider text-amber-300 light:bg-amber-100 light:text-amber-800`,children:`truncated`}),r!==void 0&&(0,R.jsxs)(`span`,{className:`rounded px-1.5 py-0.5 text-[10px] font-mono ${r===0?`bg-emerald-900/30 text-emerald-300 light:bg-emerald-100 light:text-emerald-800`:`bg-red-900/30 text-red-300 light:bg-red-100 light:text-red-800`}`,title:r===0?`exit 0`:`exit ${String(r)}`,children:[`exit `,r]})]})]}),n.length>0&&(0,R.jsx)(`pre`,{className:`max-h-64 overflow-auto px-3 pb-2 font-mono text-[11px] text-neutral-300`,children:n})]})}function kA({getText:e,title:t}){let[n,r]=(0,v.useState)(!1),i=()=>{let t=e();if(t.length===0)return;let n=navigator.clipboard?.writeText?.bind(navigator.clipboard);n===void 0?a(t):n(t).then(()=>{r(!0),window.setTimeout(()=>r(!1),1200)}).catch(()=>a(t))},a=e=>{try{let t=document.createElement(`textarea`);t.value=e,t.style.position=`fixed`,t.style.opacity=`0`,document.body.appendChild(t),t.select(),document.execCommand(`copy`),document.body.removeChild(t),r(!0),window.setTimeout(()=>r(!1),1200)}catch{}};return(0,R.jsx)(`button`,{type:`button`,onClick:i,className:`inline-flex min-h-11 min-w-11 items-center justify-center rounded px-1.5 py-0.5 text-neutral-500 hover:bg-neutral-700/40 hover:text-neutral-300 md:min-h-0 md:min-w-0`,title:t,"aria-label":t,children:n?(0,R.jsx)(le,{size:14}):(0,R.jsx)(ve,{size:14})})}function AA(e){let t=[];for(let n of e)n.type===`text`&&typeof n.text==`string`&&t.push(n.text);return t.join(`
@@ -362,7 +362,7 @@ X-Custom: value`,disabled:n,className:`w-full rounded border border-neutral-700
362
362
  `),env:Object.entries(t.env??{}).map(([e,t])=>({key:e,value:t})),cwd:t.cwd??``}))},ne=()=>{_(void 0),h(qj())},re=async()=>{if(m===void 0)return;if(m.name.trim().length===0){e(`Name is required.`);return}if(m.kind===`remote`&&m.url.trim().length===0){e(`URL is required for remote servers.`);return}if(m.kind===`stdio`&&m.command.trim().length===0){e(`Command is required for stdio servers.`);return}let t={enabled:m.enabled};if(m.kind===`remote`){t.url=m.url,t.transport=m.transport;let e={};for(let t of m.headers)t.key.trim().length!==0&&(e[t.key]=t.value);Object.keys(e).length>0&&(t.headers=e)}else{t.command=m.command;let e=Jj(m.argsText);e.length>0&&(t.args=e);let n={};for(let e of m.env)e.key.trim().length!==0&&(n[e.key]=e.value);Object.keys(n).length>0&&(t.env=n),m.cwd.trim().length>0&&(t.cwd=m.cwd)}b(!0);try{await l(m.name,t),e(void 0),h(void 0),_(void 0)}catch(t){e(`Failed to save server: ${Cj(t)}`)}finally{b(!1)}},ie=async t=>{if(window.confirm(`Remove MCP server '${t}' from the global registry?`)){b(!0);try{await u(t),e(void 0)}catch(t){e(`Failed to remove server: ${Cj(t)}`)}finally{b(!1)}}},j=async(n,r)=>{S(n);try{await d(n,r===`project`?t?.id:void 0),e(void 0),k()}catch(t){e(`Probe failed for '${n}': ${Cj(t)}`)}finally{S(void 0)}},ae=async(t,n)=>{b(!0);try{await L.setToolEnabled(`mcp`,t,n,`global`),await k()}catch(t){e(`Toggle failed: ${Cj(t)}`)}finally{b(!1)}},M=async(t,n,r)=>{b(!0);try{r===void 0?await L.clearToolProjectOverride(`mcp`,n,t):await L.setToolEnabled(`mcp`,n,r===`enabled`,`project`,t),await k()}catch(t){e(`Override write failed: ${Cj(t)}`)}finally{b(!1)}},oe=e=>{O(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})};if(r===void 0)return(0,R.jsx)(`p`,{className:`text-xs italic text-neutral-500`,children:`Loading MCP config…`});let se=r.enabled,ce=a.filter(e=>e.scope===`global`),le=a.filter(e=>e.scope===`project`);return(0,R.jsxs)(`div`,{className:`space-y-4`,children:[(0,R.jsxs)(`p`,{className:`text-xs text-neutral-500`,children:[`MCP servers extend the agent with custom tools. Servers configured here are loaded by every new session. Project-scoped servers in `,(0,R.jsx)(`code`,{className:`font-mono`,children:`.mcp.json`}),` at the project root are also loaded for sessions in that project (project entries override globals on name collision).`]}),(0,R.jsxs)(`div`,{className:`flex items-center justify-between rounded border border-neutral-800 bg-neutral-900/40 p-3`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`div`,{className:`text-sm font-medium text-neutral-100`,children:`MCP tools`}),(0,R.jsx)(`div`,{className:`text-[11px] text-neutral-500`,children:`Master switch. When off, no MCP tools reach the agent regardless of per-server state.`})]}),(0,R.jsx)(`button`,{onClick:()=>void ee(!se),disabled:y,className:`rounded border px-3 py-1 text-xs ${se?`border-emerald-700/50 bg-emerald-900/20 text-emerald-300 light:border-emerald-300 light:bg-emerald-50 light:text-emerald-800`:`border-neutral-700 text-neutral-300 hover:border-neutral-500`}`,children:se?`Enabled`:`Disabled`})]}),t!==void 0&&(0,R.jsx)(Qj,{projectName:t.name,trusted:o?.trusted===!0,gatedCount:a.filter(e=>e.scope===`project`&&e.state===`trust_required`).length,busy:y,onGrant:async()=>{b(!0);try{await f(t.id),e(void 0)}catch(t){e(`Failed to grant trust: ${Cj(t)}`)}finally{b(!1)}},onRevoke:async()=>{if(window.confirm(`Revoke stdio MCP trust for "${t.name}"? This disconnects every running project-scoped MCP server.`)){b(!0);try{await p(t.id),e(void 0)}catch(t){e(`Failed to revoke trust: ${Cj(t)}`)}finally{b(!1)}}}}),(0,R.jsx)(Xj,{title:`Global servers`,emptyHint:`No global MCP servers configured. Click 'Add server' to add one.`,servers:ce.map(e=>({status:e,config:i[e.name]})),editable:!0,editingName:g??null,probingName:x??null,toolsByServer:C,expandedServers:D,allOverrides:T,projects:n,busy:y,onToggleExpanded:oe,onToggleToolGlobal:(e,t)=>void ae(e,t),onSetProjectToolOverride:(e,t,n)=>void M(e,t,n),onToggle:(e,t)=>void A(e,t),onProbe:e=>void j(e,`global`),onEdit:te,onRemove:e=>void ie(e)}),t!==void 0&&(0,R.jsx)(Xj,{title:`Project servers (${t.name})`,emptyHint:(0,R.jsxs)(R.Fragment,{children:[`No project servers. Add a `,(0,R.jsx)(`code`,{className:`font-mono`,children:`.mcp.json`}),` file at the project root to define some — supports both`,` `,(0,R.jsx)(`code`,{className:`font-mono`,children:`{ servers: {...} }`}),` and the standard`,` `,(0,R.jsx)(`code`,{className:`font-mono`,children:`{ mcpServers: {...} }`}),` shape.`]}),servers:le.map(e=>({status:e,config:void 0})),editable:!1,probingName:x??null,toolsByServer:C,expandedServers:D,allOverrides:T,projects:n,busy:y,onToggleExpanded:oe,onToggleToolGlobal:(e,t)=>void ae(e,t),onSetProjectToolOverride:(e,t,n)=>void M(e,t,n),onProbe:e=>void j(e,`project`)}),m===void 0?(0,R.jsx)(`button`,{onClick:ne,className:`rounded-md border border-neutral-700 px-3 py-1 text-xs text-neutral-200 hover:border-neutral-500`,children:`+ Add server`}):(0,R.jsx)($j,{draft:m,isEditing:g!==void 0,busy:y,onChange:h,onSave:()=>void re(),onCancel:()=>{h(void 0),_(void 0)}})]})}function Xj(e){return(0,R.jsxs)(`section`,{className:`space-y-2`,children:[(0,R.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wider text-neutral-400`,children:e.title}),e.servers.length===0?(0,R.jsx)(`p`,{className:`text-[11px] italic text-neutral-500`,children:e.emptyHint}):(0,R.jsx)(`div`,{className:`space-y-2`,children:e.servers.map(t=>{let n=t.status,r=e.editingName===n.name,i=e.probingName===n.name,a=`${n.scope}:${n.name}`,o=e.toolsByServer.get(a)??[],s=e.expandedServers.has(a),c=o.length>0;return(0,R.jsxs)(`div`,{className:`rounded border ${r?`border-neutral-500 bg-neutral-900`:`border-neutral-800 bg-neutral-900/40`}`,children:[(0,R.jsxs)(`div`,{className:`p-3`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,R.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,R.jsx)(`button`,{type:`button`,onClick:()=>c&&e.onToggleExpanded(a),disabled:!c,className:`flex h-5 w-5 items-center justify-center rounded text-neutral-300 hover:bg-neutral-800 hover:text-neutral-100 disabled:opacity-30`,title:c?s?`Hide tools`:`Show tools`:`No tools to show (server not connected or empty)`,children:s?(0,R.jsx)(ue,{size:16}):(0,R.jsx)(fe,{size:16})}),(0,R.jsx)(Zj,{state:n.state}),(0,R.jsx)(`span`,{className:`font-mono text-sm text-neutral-100`,children:n.name}),(0,R.jsx)(`span`,{className:`rounded bg-neutral-800 px-1.5 py-0.5 text-[10px] uppercase tracking-wider text-neutral-400`,children:n.transport??`auto`}),(0,R.jsxs)(`span`,{className:`text-[11px] text-neutral-500`,children:[n.toolCount,` tools`]})]}),(0,R.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1 text-xs`,children:[e.editable&&e.onToggle!==void 0&&(0,R.jsx)(`button`,{onClick:()=>e.onToggle?.(n.name,!n.enabled),className:`rounded border px-2 py-0.5 ${n.enabled?`border-emerald-700/50 bg-emerald-900/20 text-emerald-300 light:border-emerald-300 light:bg-emerald-50 light:text-emerald-800`:`border-neutral-700 text-neutral-400 hover:border-neutral-500`}`,children:n.enabled?`Enabled`:`Disabled`}),(0,R.jsx)(`button`,{onClick:()=>e.onProbe(n.name),disabled:i,className:`rounded border border-neutral-700 px-2 py-0.5 text-neutral-300 hover:border-neutral-500 disabled:opacity-50`,title:`Reconnect and refresh tool list`,children:i?`Probing…`:`Probe`}),e.editable&&e.onEdit!==void 0&&(0,R.jsx)(`button`,{onClick:()=>e.onEdit?.(n.name),className:`rounded border border-neutral-700 px-2 py-0.5 text-neutral-300 hover:border-neutral-500`,children:`Edit`}),e.editable&&e.onRemove!==void 0&&(0,R.jsx)(`button`,{onClick:()=>e.onRemove?.(n.name),className:`rounded border border-red-700/50 px-2 py-0.5 text-red-300 hover:bg-red-900/20`,children:`Remove`})]})]}),n.kind===`stdio`?(0,R.jsxs)(`div`,{className:`mt-1 truncate font-mono text-[11px] text-neutral-500`,title:`${n.command??``} ${(n.args??[]).join(` `)}`.trim(),children:[n.command,` `,(n.args??[]).join(` `)]}):(0,R.jsx)(`div`,{className:`mt-1 truncate text-[11px] text-neutral-500`,title:n.url??``,children:n.url}),n.lastError!==void 0&&(0,R.jsx)(`div`,{className:`mt-1 truncate text-[11px] text-red-300 light:text-red-700`,title:n.lastError,children:n.lastError})]}),s&&c&&(0,R.jsxs)(`div`,{className:`space-y-2 border-t border-neutral-800 bg-neutral-950/40 px-3 py-2`,children:[(0,R.jsx)(`div`,{className:`text-[10px] uppercase tracking-wider text-neutral-500`,children:`Tools`}),(0,R.jsx)(`div`,{className:`space-y-2`,children:o.map(t=>(0,R.jsx)(zj,{family:`mcp`,name:t.shortName,fqn:t.name,description:t.description,globalEnabled:t.globalEnabled,projects:e.projects,allOverrides:e.allOverrides,busy:e.busy,onToggleGlobal:n=>e.onToggleToolGlobal(t.name,n),onSetProjectOverride:(n,r)=>e.onSetProjectToolOverride(n,t.name,r)},`mcp:${t.name}`))})]})]},a)})})]})}function Zj({state:e}){return(0,R.jsx)(`span`,{className:`h-2 w-2 rounded-full ${e===`connected`?`bg-emerald-500`:e===`connecting`?`bg-amber-400 animate-pulse`:e===`error`?`bg-red-500`:e===`disabled`?`bg-neutral-700`:`bg-neutral-500`}`,title:e})}function Qj(e){return e.trusted?(0,R.jsxs)(`div`,{className:`flex items-center justify-between rounded border border-neutral-800 bg-neutral-900/40 px-3 py-1.5 text-[11px] text-neutral-500`,children:[(0,R.jsxs)(`span`,{children:[`Stdio MCP trust granted for`,` `,(0,R.jsx)(`strong`,{className:`text-neutral-300`,children:e.projectName}),`. Project-local stdio MCP servers from `,(0,R.jsx)(`code`,{className:`font-mono`,children:`.mcp.json`}),` will spawn on session create.`]}),(0,R.jsx)(`button`,{onClick:()=>void e.onRevoke(),disabled:e.busy,className:`rounded border border-neutral-700 px-2 py-0.5 text-[10px] text-neutral-400 hover:border-neutral-500 hover:text-neutral-200 disabled:opacity-50`,title:`Disconnects every running project-scoped MCP server`,children:`Revoke`})]}):e.gatedCount===0?null:(0,R.jsxs)(`div`,{className:`rounded border border-amber-700/40 bg-amber-900/20 p-3 text-xs text-amber-200 light:border-amber-300 light:bg-amber-50 light:text-amber-800`,children:[(0,R.jsxs)(`div`,{className:`mb-2 font-medium`,children:[`This project wants to spawn `,e.gatedCount,` stdio MCP server`,e.gatedCount===1?``:`s`,`.`]}),(0,R.jsxs)(`p`,{className:`text-[11px] leading-relaxed`,children:[(0,R.jsx)(`strong`,{children:e.projectName}),`'s `,(0,R.jsx)(`code`,{className:`font-mono`,children:`.mcp.json`}),` declares MCP server`,e.gatedCount===1?``:`s`,` that pi-forge would launch as local subprocess`,e.gatedCount===1?``:`es`,`. Stdio MCP runs arbitrary commands on this machine with whatever env you've passed through — only trust projects whose`,` `,(0,R.jsx)(`code`,{className:`font-mono`,children:`.mcp.json`}),` you've reviewed and approve of. Remote (URL) entries in this project are unaffected by this gate.`]}),(0,R.jsx)(`div`,{className:`mt-2 flex gap-2`,children:(0,R.jsx)(`button`,{onClick:()=>void e.onGrant(),disabled:e.busy,className:`rounded bg-amber-200 px-3 py-1 text-[11px] font-medium text-amber-900 hover:bg-amber-100 disabled:opacity-50 light:bg-amber-600 light:text-amber-50 light:hover:bg-amber-700`,children:e.busy?`Granting…`:`Trust this project`})})]})}function $j(e){let{draft:t,busy:n}=e,r=(n,r)=>{e.onChange({...t,[n]:r})};return(0,R.jsxs)(`div`,{className:`rounded border border-neutral-700 bg-neutral-900 p-3`,children:[(0,R.jsx)(`h4`,{className:`mb-2 text-xs font-semibold uppercase tracking-wider text-neutral-400`,children:e.isEditing?`Edit '${t.name}'`:`Add MCP server`}),(0,R.jsxs)(`div`,{className:`mb-3 flex items-center gap-3 rounded border border-neutral-800 bg-neutral-950 p-2 text-[11px]`,children:[(0,R.jsx)(`span`,{className:`text-neutral-500`,children:`Type`}),(0,R.jsxs)(`label`,{className:`flex items-center gap-1.5 ${e.isEditing?`cursor-not-allowed opacity-60`:`cursor-pointer`}`,children:[(0,R.jsx)(`input`,{type:`radio`,name:`mcp-kind`,checked:t.kind===`remote`,disabled:e.isEditing,onChange:()=>r(`kind`,`remote`)}),(0,R.jsx)(`span`,{children:`Remote URL`})]}),(0,R.jsxs)(`label`,{className:`flex items-center gap-1.5 ${e.isEditing?`cursor-not-allowed opacity-60`:`cursor-pointer`}`,children:[(0,R.jsx)(`input`,{type:`radio`,name:`mcp-kind`,checked:t.kind===`stdio`,disabled:e.isEditing,onChange:()=>r(`kind`,`stdio`)}),(0,R.jsx)(`span`,{children:`Local subprocess (stdio)`})]}),e.isEditing&&(0,R.jsx)(`span`,{className:`text-[10px] italic text-neutral-600`,children:`Locked while editing — delete and re-add to change type.`})]}),(0,R.jsxs)(`div`,{className:`grid grid-cols-[80px_1fr] items-center gap-2 text-xs`,children:[(0,R.jsx)(`label`,{className:`text-neutral-500`,children:`Name`}),(0,R.jsx)(`input`,{value:t.name,onChange:e=>r(`name`,e.target.value),disabled:e.isEditing,placeholder:`my-server`,className:`rounded border border-neutral-700 bg-neutral-950 px-2 py-1 text-neutral-100 outline-none focus:border-neutral-500 disabled:opacity-50`}),t.kind===`remote`?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`label`,{className:`text-neutral-500`,children:`URL`}),(0,R.jsx)(`input`,{value:t.url,onChange:e=>r(`url`,e.target.value),placeholder:`https://mcp.example.com/sse`,className:`rounded border border-neutral-700 bg-neutral-950 px-2 py-1 text-neutral-100 outline-none focus:border-neutral-500`}),(0,R.jsx)(`label`,{className:`text-neutral-500`,children:`Transport`}),(0,R.jsxs)(`select`,{value:t.transport,onChange:e=>r(`transport`,e.target.value),className:`rounded border border-neutral-700 bg-neutral-950 px-2 py-1 text-neutral-100 outline-none focus:border-neutral-500`,children:[(0,R.jsx)(`option`,{value:`auto`,children:`auto (StreamableHTTP, fall back to SSE)`}),(0,R.jsx)(`option`,{value:`streamable-http`,children:`streamable-http`}),(0,R.jsx)(`option`,{value:`sse`,children:`sse`})]})]}):(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`label`,{className:`text-neutral-500`,children:`Command`}),(0,R.jsx)(`input`,{value:t.command,onChange:e=>r(`command`,e.target.value),placeholder:`npx (or absolute path to a binary)`,className:`rounded border border-neutral-700 bg-neutral-950 px-2 py-1 font-mono text-neutral-100 outline-none focus:border-neutral-500`}),(0,R.jsx)(`label`,{className:`self-start pt-1 text-neutral-500`,children:`Args`}),(0,R.jsx)(`textarea`,{value:t.argsText,onChange:e=>r(`argsText`,e.target.value),placeholder:`-y
363
363
  @modelcontextprotocol/server-everything`,rows:3,spellCheck:!1,className:`rounded border border-neutral-700 bg-neutral-950 px-2 py-1 font-mono text-[11px] text-neutral-100 outline-none focus:border-neutral-500`}),(0,R.jsx)(`label`,{className:`text-neutral-500`,children:`cwd`}),(0,R.jsx)(`input`,{value:t.cwd,onChange:e=>r(`cwd`,e.target.value),placeholder:`(blank ↦ default: project path for project servers)`,className:`rounded border border-neutral-700 bg-neutral-950 px-2 py-1 font-mono text-neutral-100 outline-none focus:border-neutral-500`})]}),(0,R.jsx)(`label`,{className:`text-neutral-500`,children:`Enabled`}),(0,R.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(`input`,{type:`checkbox`,checked:t.enabled,onChange:e=>r(`enabled`,e.target.checked)}),(0,R.jsx)(`span`,{className:`text-[11px] text-neutral-500`,children:`Disabled servers don't connect or contribute tools.`})]})]}),t.kind===`remote`?(0,R.jsx)(eM,{label:`Headers`,emptyHint:"No headers. Add `Authorization: Bearer …` here for auth.",keyPlaceholder:`Authorization`,valuePlaceholder:`Bearer …`,rows:t.headers,onChange:e=>r(`headers`,e)}):(0,R.jsx)(eM,{label:`Env`,emptyHint:`No env. Add API keys / config your subprocess needs (PATH / HOME / locale are inherited automatically).`,keyPlaceholder:`GITHUB_TOKEN`,valuePlaceholder:`ghp_…`,rows:t.env,onChange:e=>r(`env`,e)}),(0,R.jsxs)(`div`,{className:`mt-3 flex justify-end gap-2`,children:[(0,R.jsx)(`button`,{onClick:e.onCancel,className:`rounded border border-neutral-700 px-3 py-1 text-xs text-neutral-300 hover:border-neutral-500`,children:`Cancel`}),(0,R.jsx)(`button`,{onClick:e.onSave,disabled:n,className:`rounded bg-neutral-100 px-3 py-1 text-xs font-medium text-neutral-900 disabled:opacity-50`,children:n?`Saving…`:`Save`})]})]})}function eM(e){let{rows:t}=e;return(0,R.jsxs)(`div`,{className:`mt-3`,children:[(0,R.jsxs)(`div`,{className:`mb-1 flex items-center justify-between`,children:[(0,R.jsx)(`h5`,{className:`text-[11px] font-semibold uppercase tracking-wider text-neutral-500`,children:e.label}),(0,R.jsxs)(`button`,{onClick:()=>e.onChange([...t,{key:``,value:``}]),className:`rounded border border-neutral-700 px-2 py-0.5 text-[11px] text-neutral-300 hover:border-neutral-500`,children:[`+ `,e.label.replace(/s$/,``)]})]}),t.length===0&&(0,R.jsx)(`p`,{className:`text-[11px] italic text-neutral-600`,children:e.emptyHint}),t.map((n,r)=>(0,R.jsxs)(`div`,{className:`mb-1 grid grid-cols-[1fr_2fr_auto] gap-1`,children:[(0,R.jsx)(`input`,{value:n.key,onChange:i=>{let a=[...t];a[r]={...n,key:i.target.value},e.onChange(a)},placeholder:e.keyPlaceholder,className:`rounded border border-neutral-700 bg-neutral-950 px-2 py-1 text-[11px] font-mono text-neutral-100 outline-none focus:border-neutral-500`}),(0,R.jsx)(`input`,{value:n.value===Kj?``:n.value,onChange:i=>{let a=[...t];a[r]={...n,value:i.target.value},e.onChange(a)},placeholder:n.value===Kj?`leave blank to keep stored value`:e.valuePlaceholder,type:`password`,className:`rounded border border-neutral-700 bg-neutral-950 px-2 py-1 text-[11px] font-mono text-neutral-100 outline-none focus:border-neutral-500`}),(0,R.jsx)(`button`,{onClick:()=>e.onChange(t.filter((e,t)=>t!==r)),className:`rounded border border-neutral-700 px-2 text-[11px] text-neutral-400 hover:text-red-300 light:hover:text-red-700`,title:`Remove ${e.label.toLowerCase()}`,children:`×`})]},r)),t.some(e=>e.value===Kj)&&(0,R.jsx)(`p`,{className:`mt-1 text-[10px] italic text-neutral-500`,children:`Values with the redaction sentinel keep their stored value when you save.`})]})}var tM=8;function nM(){let e=si(e=>e.version),t=si(e=>e.loaded),n=si(e=>e.passwordAuthEnabled);return(0,R.jsxs)(`div`,{className:`space-y-6 text-sm text-neutral-300`,children:[(0,R.jsxs)(`header`,{className:`space-y-1`,children:[(0,R.jsx)(`h2`,{className:`text-base font-semibold text-neutral-100`,children:`pi-forge`}),(0,R.jsxs)(`p`,{className:`text-xs text-neutral-500`,children:[`Browser interface for the`,` `,(0,R.jsx)(`a`,{href:`https://github.com/badlogic/pi-mono`,target:`_blank`,rel:`noopener noreferrer`,className:`text-blue-400 underline hover:text-blue-300 light:text-blue-700 light:hover:text-blue-900`,children:`pi coding agent`}),`.`]})]}),(0,R.jsxs)(`section`,{className:`space-y-2`,children:[(0,R.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wider text-neutral-500`,children:`Version`}),(0,R.jsx)(`p`,{className:`font-mono text-sm`,children:t?e.length>0?e:(0,R.jsx)(`span`,{className:`text-neutral-500`,children:`unknown`}):(0,R.jsx)(`span`,{className:`text-neutral-500`,children:`loading…`})})]}),(0,R.jsxs)(`section`,{className:`space-y-2`,children:[(0,R.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wider text-neutral-500`,children:`Links`}),(0,R.jsxs)(`ul`,{className:`space-y-1 text-xs`,children:[(0,R.jsx)(`li`,{children:(0,R.jsx)(`a`,{href:`https://github.com/Devin-Marks/pi-forge`,target:`_blank`,rel:`noopener noreferrer`,className:`text-blue-400 underline hover:text-blue-300 light:text-blue-700 light:hover:text-blue-900`,children:`github.com/Devin-Marks/pi-forge`})}),(0,R.jsx)(`li`,{children:(0,R.jsx)(`a`,{href:`https://github.com/Devin-Marks/pi-forge/blob/main/CHANGELOG.md`,target:`_blank`,rel:`noopener noreferrer`,className:`text-blue-400 underline hover:text-blue-300 light:text-blue-700 light:hover:text-blue-900`,children:`Changelog`})}),(0,R.jsx)(`li`,{children:(0,R.jsx)(`a`,{href:`https://github.com/Devin-Marks/pi-forge/blob/main/SECURITY.md`,target:`_blank`,rel:`noopener noreferrer`,className:`text-blue-400 underline hover:text-blue-300 light:text-blue-700 light:hover:text-blue-900`,children:`Security`})})]})]}),n&&(0,R.jsx)(rM,{})]})}function rM(){let e=ir(e=>e.changePassword),t=ir(e=>e.changePasswordPending),n=ir(e=>e.changePasswordError),[r,i]=(0,v.useState)(``),[a,o]=(0,v.useState)(``),[s,c]=(0,v.useState)(``),[l,u]=(0,v.useState)(void 0),[d,f]=(0,v.useState)(!1),p=(0,v.useRef)(!1);(0,v.useEffect)(()=>{if(p.current&&!t&&n===void 0){i(``),o(``),c(``),f(!0);let e=window.setTimeout(()=>f(!1),2500);return()=>window.clearTimeout(e)}p.current=t},[t,n]);let m=t=>{if(t.preventDefault(),u(void 0),f(!1),a.length<tM){u(`New password must be at least ${tM} characters.`);return}if(a!==s){u(`New password and confirmation do not match.`);return}if(a===r){u(`New password must differ from the current one.`);return}e(r,a)},h=l??iM(n);return(0,R.jsxs)(`section`,{className:`space-y-2 border-t border-neutral-800 pt-5`,children:[(0,R.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wider text-neutral-500`,children:`Change password`}),(0,R.jsx)(`p`,{className:`text-xs text-neutral-500`,children:`Updates the scrypt hash on disk; existing browser sessions stay signed in.`}),(0,R.jsxs)(`form`,{onSubmit:m,className:`space-y-2`,children:[(0,R.jsxs)(`label`,{className:`block space-y-1`,children:[(0,R.jsx)(`span`,{className:`text-xs text-neutral-400`,children:`Current password`}),(0,R.jsx)(`input`,{type:`password`,value:r,onChange:e=>i(e.target.value),autoComplete:`current-password`,className:`w-full rounded-md border border-neutral-700 bg-neutral-950 px-3 py-1.5 text-sm outline-none focus:border-neutral-500`})]}),(0,R.jsxs)(`label`,{className:`block space-y-1`,children:[(0,R.jsx)(`span`,{className:`text-xs text-neutral-400`,children:`New password`}),(0,R.jsx)(`input`,{type:`password`,value:a,onChange:e=>o(e.target.value),autoComplete:`new-password`,minLength:tM,className:`w-full rounded-md border border-neutral-700 bg-neutral-950 px-3 py-1.5 text-sm outline-none focus:border-neutral-500`})]}),(0,R.jsxs)(`label`,{className:`block space-y-1`,children:[(0,R.jsx)(`span`,{className:`text-xs text-neutral-400`,children:`Confirm new password`}),(0,R.jsx)(`input`,{type:`password`,value:s,onChange:e=>c(e.target.value),autoComplete:`new-password`,minLength:tM,className:`w-full rounded-md border border-neutral-700 bg-neutral-950 px-3 py-1.5 text-sm outline-none focus:border-neutral-500`})]}),h!==void 0&&(0,R.jsx)(`p`,{role:`alert`,className:`text-xs text-red-400`,children:h}),d&&(0,R.jsx)(`p`,{role:`status`,className:`text-xs text-emerald-400 light:text-emerald-700`,children:`Password updated.`}),(0,R.jsx)(`button`,{type:`submit`,disabled:t||r.length===0||a.length===0,className:`rounded-md bg-neutral-100 px-3 py-1.5 text-xs font-medium text-neutral-900 transition hover:bg-white disabled:cursor-not-allowed disabled:opacity-50`,children:t?`Saving…`:`Update password`})]})]})}function iM(e){if(e!==void 0)switch(e){case`invalid_password`:return`Current password is incorrect.`;case`password_unchanged`:return`New password must differ from the current one.`;case`ui_password_not_configured`:return`Password auth is not configured on this server.`;case`auth_required`:return`Session expired — sign in again.`;default:return`Could not change password: ${e}`}}function aM({sessionId:e}){let t=Cr(t=>t.pendingBySession[e]);return t===void 0?null:(0,R.jsx)(oM,{pending:t},t.requestId)}function oM({pending:e}){let t=Cr(e=>e.clearPending),[n,r]=(0,v.useState)(0),[i,a]=(0,v.useState)(!1),[o,s]=(0,v.useState)(void 0),[c,l]=(0,v.useState)(()=>e.questions.map(()=>null)),u=e.questions[n];if(u===void 0)return null;let d=e=>{l(t=>{let r=t.slice();return r[n]={...r[n]??{},...e},r})},f=c[n],p=()=>u.multiSelect===!0?f?.multiLabels!==void 0&&f.multiLabels.length>0:f?.selectedLabel!==void 0||f?.customText!==void 0&&f.customText.trim().length>0,m=()=>{let t=[];for(let n=0;n<e.questions.length;n+=1){let r=e.questions[n],i=c[n];if(i!=null){if(r.multiSelect===!0){t.push({questionIndex:n,question:r.question,kind:`multi`,answer:null,...i.multiLabels===void 0?{}:{selected:i.multiLabels}});continue}if(i.selectedLabel!==void 0){let e=r.options.find(e=>e.label===i.selectedLabel);t.push({questionIndex:n,question:r.question,kind:`option`,answer:i.selectedLabel,...e?.preview===void 0?{}:{preview:e.preview}});continue}if(i.customText!==void 0&&i.customText.trim().length>0){t.push({questionIndex:n,question:r.question,kind:`custom`,answer:i.customText.trim()});continue}}}return t},h=async()=>{if(p()){if(n<e.questions.length-1){r(n+1);return}a(!0),s(void 0);try{await L.submitAskUserQuestionAnswer(e.sessionId,{requestId:e.requestId,answers:m()}),t(e.sessionId,e.requestId)}catch(e){s(e instanceof N?`${e.code}: ${e.message}`:e.message),a(!1)}}},g=async()=>{a(!0),s(void 0);try{let r={questionIndex:n,question:u.question,kind:`chat`,answer:`Chat about this`};await L.submitAskUserQuestionAnswer(e.sessionId,{requestId:e.requestId,answers:[r],cancelled:!0}),t(e.sessionId,e.requestId)}catch(e){s(e instanceof N?`${e.code}: ${e.message}`:e.message),a(!1)}};return(0,R.jsx)(`div`,{className:`flex max-h-[60vh] shrink-0 flex-col overflow-hidden border-t border-amber-700/50 bg-neutral-900/40 light:border-amber-400 light:bg-amber-50/60`,children:(0,R.jsxs)(`div`,{className:`flex flex-col overflow-hidden`,children:[(0,R.jsxs)(`header`,{className:`flex items-center gap-2 border-b border-neutral-800 px-4 py-2 light:border-neutral-200`,children:[(0,R.jsx)(`span`,{className:`text-[10px] font-semibold uppercase tracking-wider text-amber-400 light:text-amber-700`,children:`Agent question`}),e.questions.length>1&&(0,R.jsx)(`div`,{className:`ml-2 flex items-center gap-1 text-[10px] uppercase tracking-wider text-neutral-500`,children:e.questions.map((e,t)=>(0,R.jsx)(`span`,{className:`rounded px-1.5 py-0.5 ${t===n?`bg-amber-900/40 text-amber-200 light:bg-amber-100 light:text-amber-900`:c[t]===null?`text-neutral-500`:`bg-neutral-800 text-neutral-300 light:bg-neutral-200 light:text-neutral-700`}`,title:e.question,children:e.header},t))}),(0,R.jsx)(`div`,{className:`flex-1`}),(0,R.jsxs)(`span`,{className:`text-[10px] uppercase tracking-wider text-neutral-500`,children:[n+1,` of `,e.questions.length]})]}),o!==void 0&&(0,R.jsx)(`div`,{className:`border-b border-red-700/40 bg-red-900/20 px-4 py-2 text-xs text-red-300 light:border-red-300 light:bg-red-50 light:text-red-800`,children:o}),(0,R.jsx)(`div`,{className:`flex-1 overflow-y-auto px-4 py-3`,children:(0,R.jsx)(sM,{question:u,draft:f??null,onChange:e=>d(e)})}),(0,R.jsxs)(`footer`,{className:`flex items-center gap-2 border-t border-neutral-800 px-4 py-2 light:border-neutral-200`,children:[(0,R.jsxs)(`button`,{type:`button`,onClick:()=>void g(),disabled:i,className:`flex items-center gap-1 rounded border border-neutral-700 px-3 py-1 text-xs text-neutral-300 hover:border-neutral-500 disabled:opacity-50 light:border-neutral-400 light:text-neutral-700`,title:`Abandon the structured questionnaire and reply in free-form chat`,children:[(0,R.jsx)(Pe,{size:12}),`Chat about this`]}),(0,R.jsx)(`div`,{className:`flex-1`}),n>0&&(0,R.jsxs)(`button`,{type:`button`,onClick:()=>r(n-1),disabled:i,className:`flex items-center gap-1 rounded border border-neutral-700 px-3 py-1 text-xs text-neutral-300 hover:border-neutral-500 disabled:opacity-50 light:border-neutral-400 light:text-neutral-700`,children:[(0,R.jsx)(de,{size:12}),`Back`]}),(0,R.jsxs)(`button`,{type:`button`,onClick:()=>void h(),disabled:i||!p(),className:`flex items-center gap-1 rounded bg-emerald-700 px-3 py-1 text-xs text-white hover:bg-emerald-600 disabled:opacity-50`,children:[i?(0,R.jsx)(Me,{size:12,className:`animate-spin`}):null,n<e.questions.length-1?(0,R.jsxs)(R.Fragment,{children:[`Next `,(0,R.jsx)(fe,{size:12})]}):i?`Submitting…`:`Submit`]})]})]})})}function sM({question:e,draft:t,onChange:n}){let r=(0,v.useMemo)(()=>e.options.some(e=>typeof e.preview==`string`&&e.preview.length>0),[e.options]),i=e.multiSelect===!0,a=!i&&!r,[o,s]=(0,v.useState)(void 0),c=e.options.find(e=>e.label===o);return(0,v.useEffect)(()=>{r&&o===void 0&&e.options[0]!==void 0&&s(e.options[0].label)},[r,o,e.options]),(0,R.jsxs)(`div`,{className:`space-y-3`,children:[(0,R.jsx)(`h2`,{className:`text-base font-medium text-neutral-100 light:text-neutral-900`,children:e.question}),r&&!i?(0,R.jsxs)(`div`,{className:`grid grid-cols-3 gap-3`,children:[(0,R.jsx)(`div`,{className:`col-span-1 space-y-1`,children:e.options.map(e=>(0,R.jsxs)(`button`,{type:`button`,onClick:()=>{n({selectedLabel:e.label}),s(e.label)},onMouseEnter:()=>s(e.label),className:`w-full rounded border px-2 py-1.5 text-left text-xs ${t?.selectedLabel===e.label?`border-emerald-600 bg-emerald-900/30 text-emerald-100 light:bg-emerald-50 light:text-emerald-900`:o===e.label?`border-neutral-600 bg-neutral-900 text-neutral-100 light:border-neutral-400 light:bg-neutral-100 light:text-neutral-900`:`border-neutral-800 bg-neutral-900/40 text-neutral-300 hover:border-neutral-600 light:border-neutral-300 light:bg-neutral-50 light:text-neutral-700`}`,children:[(0,R.jsx)(`div`,{className:`font-medium`,children:e.label}),(0,R.jsx)(`div`,{className:`mt-0.5 text-[11px] text-neutral-400 light:text-neutral-600`,children:e.description})]},e.label))}),(0,R.jsx)(`div`,{className:`col-span-2 overflow-auto rounded border border-neutral-800 bg-neutral-950 p-3 light:border-neutral-300 light:bg-neutral-50`,children:c?.preview!==void 0&&c.preview.length>0?(0,R.jsx)(`pre`,{className:`whitespace-pre-wrap font-mono text-[11px] text-neutral-200 light:text-neutral-800`,children:c.preview}):(0,R.jsx)(`p`,{className:`text-xs italic text-neutral-500 light:text-neutral-600`,children:`No preview for this option.`})})]}):i?(0,R.jsx)(`div`,{className:`space-y-1`,children:e.options.map(e=>{let r=(t?.multiLabels??[]).includes(e.label);return(0,R.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 rounded border px-2 py-1.5 text-xs ${r?`border-emerald-600 bg-emerald-900/30 light:bg-emerald-50`:`border-neutral-800 bg-neutral-900/40 hover:border-neutral-600 light:border-neutral-300 light:bg-neutral-50`}`,children:[(0,R.jsx)(`input`,{type:`checkbox`,checked:r,onChange:()=>{let i=new Set(t?.multiLabels??[]);r?i.delete(e.label):i.add(e.label),n({multiLabels:Array.from(i)})},className:`mt-1`}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`div`,{className:`font-medium text-neutral-100 light:text-neutral-900`,children:e.label}),(0,R.jsx)(`div`,{className:`mt-0.5 text-[11px] text-neutral-400 light:text-neutral-600`,children:e.description})]})]},e.label)})}):(0,R.jsxs)(`div`,{className:`space-y-1`,children:[e.options.map(e=>(0,R.jsxs)(`button`,{type:`button`,onClick:()=>n({selectedLabel:e.label,customText:void 0}),className:`w-full rounded border px-2 py-1.5 text-left text-xs ${t?.selectedLabel===e.label?`border-emerald-600 bg-emerald-900/30 light:bg-emerald-50`:`border-neutral-800 bg-neutral-900/40 hover:border-neutral-600 light:border-neutral-300 light:bg-neutral-50`}`,children:[(0,R.jsx)(`div`,{className:`font-medium text-neutral-100 light:text-neutral-900`,children:e.label}),(0,R.jsx)(`div`,{className:`mt-0.5 text-[11px] text-neutral-400 light:text-neutral-600`,children:e.description})]},e.label)),a&&(0,R.jsxs)(`div`,{className:`pt-2`,children:[(0,R.jsx)(`label`,{className:`mb-1 block text-[10px] uppercase tracking-wider text-neutral-500 light:text-neutral-600`,children:`Type something`}),(0,R.jsx)(`textarea`,{value:t?.customText??``,onChange:e=>n({customText:e.target.value,selectedLabel:void 0}),rows:2,placeholder:`Or type your own answer…`,className:`w-full rounded border border-neutral-700 bg-neutral-950 px-2 py-1 text-xs text-neutral-100 light:border-neutral-300 light:bg-white light:text-neutral-900`})]})]})]})}function cM({sessionId:e,onClose:t}){let n=Tr(t=>Er(t,e)),r=Tr(e=>e.set),[i,a]=(0,v.useState)(void 0);(0,v.useEffect)(()=>{let t=!1;return L.listTodos(e).then(n=>{if(t)return;let i=Tr.getState().byId[e];(i===void 0||i.tasks.length===0)&&r(e,{tasks:n.tasks,nextId:n.nextId})}).catch(e=>{t||a(e instanceof N?e.code:e.message)}),()=>{t=!0}},[e,r]);let o=(0,v.useMemo)(()=>Dr(n),[n]),s=(0,v.useMemo)(()=>lM(n.tasks),[n.tasks]);return(0,R.jsxs)(`div`,{className:`flex h-full flex-col overflow-hidden bg-neutral-950 text-neutral-200 light:bg-white light:text-neutral-900`,children:[(0,R.jsxs)(`header`,{className:`flex items-center gap-2 border-b border-neutral-800 px-3 py-1.5 text-xs light:border-neutral-200`,children:[(0,R.jsx)(`span`,{className:`font-semibold uppercase tracking-wider text-neutral-400 light:text-neutral-600`,children:`Todos`}),(0,R.jsxs)(`span`,{className:`text-neutral-500 light:text-neutral-600`,children:[o.completed,`/`,o.total,o.inProgress>0?` · ${o.inProgress} in progress`:``]}),(0,R.jsx)(`div`,{className:`flex-1`}),(0,R.jsx)(`button`,{type:`button`,onClick:t,className:`rounded p-0.5 text-neutral-500 hover:bg-neutral-800 hover:text-neutral-200 light:hover:bg-neutral-200 light:hover:text-neutral-900`,title:`Hide todo panel`,children:(0,R.jsx)(rt,{size:12})})]}),i!==void 0&&n.tasks.length===0&&(0,R.jsxs)(`div`,{className:`border-b border-red-700/40 bg-red-900/20 px-3 py-1.5 text-[11px] text-red-300 light:border-red-300 light:bg-red-50 light:text-red-800`,children:[`Failed to load todos: `,i]}),(0,R.jsx)(`div`,{className:`flex-1 overflow-y-auto px-2 py-2`,children:o.total===0?(0,R.jsx)(`p`,{className:`px-1 text-[11px] italic text-neutral-500 light:text-neutral-600`,children:`No todos yet. The agent will add tasks here when it's planning multi-step work.`}):(0,R.jsxs)(`div`,{className:`space-y-2`,children:[s.in_progress.length>0&&(0,R.jsx)(uM,{label:`In Progress`,tasks:s.in_progress}),s.pending.length>0&&(0,R.jsx)(uM,{label:`Pending`,tasks:s.pending}),s.completed.length>0&&(0,R.jsx)(uM,{label:`Completed`,tasks:s.completed})]})})]})}function lM(e){let t={pending:[],in_progress:[],completed:[],deleted:[]};for(let n of e)t[n.status].push(n);return t}function uM({label:e,tasks:t}){return(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`div`,{className:`mb-1 px-1 text-[10px] uppercase tracking-wider text-neutral-500 light:text-neutral-600`,children:e}),(0,R.jsx)(`div`,{className:`space-y-0.5`,children:t.map(e=>(0,R.jsx)(dM,{task:e},e.id))})]})}function dM({task:e}){let[t,n]=(0,v.useState)(!1),r=e.description!==void 0||e.activeForm!==void 0||e.blockedBy!==void 0&&e.blockedBy.length>0||e.owner!==void 0;return(0,R.jsxs)(`div`,{className:`rounded border border-transparent px-1 py-0.5 text-xs hover:border-neutral-800 light:hover:border-neutral-300`,children:[(0,R.jsxs)(`button`,{type:`button`,onClick:()=>r&&n(e=>!e),className:`flex w-full items-start gap-1.5 text-left ${r?`cursor-pointer`:`cursor-default`}`,children:[r&&(0,R.jsx)(fe,{size:11,className:`mt-0.5 shrink-0 text-neutral-500 transition-transform light:text-neutral-600 ${t?`rotate-90`:``}`}),!r&&(0,R.jsx)(`span`,{className:`inline-block w-[11px] shrink-0`}),(0,R.jsx)(fM,{status:e.status,activeForm:e.activeForm}),(0,R.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,R.jsx)(`span`,{className:`${e.status===`completed`?`text-neutral-500 line-through light:text-neutral-500`:e.status===`in_progress`?`text-neutral-100 light:text-neutral-900`:`text-neutral-300 light:text-neutral-700`}`,children:e.subject}),e.status===`in_progress`&&e.activeForm!==void 0&&(0,R.jsx)(`span`,{className:`ml-1 text-[10px] italic text-amber-400 light:text-amber-700`,children:e.activeForm})]}),(0,R.jsxs)(`span`,{className:`shrink-0 text-[10px] text-neutral-500 light:text-neutral-600`,children:[`#`,e.id]})]}),t&&r&&(0,R.jsxs)(`div`,{className:`mt-1 space-y-0.5 pl-[34px] text-[11px] text-neutral-400 light:text-neutral-600`,children:[e.description!==void 0&&(0,R.jsx)(`div`,{children:e.description}),e.blockedBy!==void 0&&e.blockedBy.length>0&&(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`span`,{className:`text-neutral-500 light:text-neutral-600`,children:`blocked by:`}),` `,e.blockedBy.map(e=>`#${e}`).join(`, `)]}),e.owner!==void 0&&(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`span`,{className:`text-neutral-500 light:text-neutral-600`,children:`owner:`}),` `,e.owner]})]})]})}function fM({status:e,activeForm:t}){return e===`in_progress`?(0,R.jsx)(Me,{size:11,className:`mt-0.5 shrink-0 animate-spin text-amber-400 light:text-amber-700`,"aria-label":t??`in progress`}):e===`completed`?(0,R.jsx)(le,{size:11,className:`mt-0.5 shrink-0 text-emerald-400 light:text-emerald-700`,"aria-label":`completed`}):e===`deleted`?(0,R.jsx)(rt,{size:11,className:`mt-0.5 shrink-0 text-neutral-500 light:text-neutral-500`,"aria-label":`deleted`}):(0,R.jsx)(he,{size:11,className:`mt-0.5 shrink-0 text-neutral-500 light:text-neutral-500`,"aria-label":`pending`})}function pM({sessionId:e}){let t=Mr(t=>Nr(t,e)),n=Mr(t=>Pr(t,e)),r=Mr(e=>e.setProcesses),i=Mr(e=>e.clearWatches),[a,o]=(0,v.useState)(void 0),[s,c]=(0,v.useState)(!1);(0,v.useEffect)(()=>{let t=!1;return L.listProcesses(e).then(n=>{if(t)return;let i=Mr.getState().bySession[e];(i===void 0||i.length===0)&&r(e,n.processes)}).catch(e=>{t||o(e instanceof N?e.code:e.message)}),()=>{t=!0}},[e,r]);let l=(0,v.useMemo)(()=>mM(t),[t]),u=Fr(t),d=t.length-u,f=async()=>{c(!0),o(void 0);try{await L.clearProcesses(e)}catch(e){o(e instanceof N?e.code:e.message)}finally{c(!1)}};return(0,R.jsxs)(`div`,{className:`flex h-full flex-col overflow-hidden bg-neutral-950 text-neutral-200 light:bg-white light:text-neutral-900`,children:[(0,R.jsxs)(`header`,{className:`flex items-center gap-2 border-b border-neutral-800 px-3 py-1.5 text-xs light:border-neutral-200`,children:[(0,R.jsx)(`span`,{className:`font-semibold uppercase tracking-wider text-neutral-400 light:text-neutral-600`,children:`Processes`}),(0,R.jsxs)(`span`,{className:`text-neutral-500 light:text-neutral-600`,children:[u,` running · `,d,` finished`]}),(0,R.jsx)(`div`,{className:`flex-1`}),d>0&&(0,R.jsxs)(`button`,{type:`button`,onClick:()=>void f(),disabled:s,className:`flex items-center gap-1 rounded border border-neutral-700 px-1.5 py-0.5 text-[10px] text-neutral-400 hover:border-neutral-500 hover:text-neutral-200 disabled:opacity-50 light:border-neutral-400 light:text-neutral-600`,title:`Drop all FINISHED processes from the list (running ones stay)`,children:[(0,R.jsx)(Qe,{size:10}),`Clear finished`]})]}),a!==void 0&&(0,R.jsx)(`div`,{className:`border-b border-red-700/40 bg-red-900/20 px-3 py-1.5 text-[11px] text-red-300 light:border-red-300 light:bg-red-50 light:text-red-800`,children:a}),n.length>0&&(0,R.jsxs)(`div`,{className:`flex items-start gap-2 border-b border-amber-700/40 bg-amber-900/20 px-3 py-1.5 text-[11px] text-amber-200 light:border-amber-300 light:bg-amber-50 light:text-amber-800`,children:[(0,R.jsx)(ce,{size:11,className:`mt-0.5 shrink-0`}),(0,R.jsxs)(`div`,{className:`flex-1 space-y-0.5`,children:[n.slice(-3).map((e,t)=>(0,R.jsxs)(`div`,{className:`truncate font-mono`,children:[(0,R.jsxs)(`span`,{className:`text-neutral-500 light:text-neutral-600`,children:[`[`,e.processName,`]`]}),` `,e.line]},`${e.processId}-${t}`)),n.length>3&&(0,R.jsxs)(`div`,{className:`text-neutral-500 light:text-neutral-600`,children:[`+`,n.length-3,` more watch match(es)`]})]}),(0,R.jsx)(`button`,{type:`button`,onClick:()=>i(e),className:`rounded p-0.5 text-amber-300 hover:text-amber-100 light:text-amber-700 light:hover:text-amber-900`,title:`Clear watch alerts`,children:(0,R.jsx)(Ue,{size:11})})]}),(0,R.jsx)(`div`,{className:`flex-1 overflow-y-auto px-2 py-2`,children:t.length===0?(0,R.jsx)(`p`,{className:`px-1 text-[11px] italic text-neutral-500 light:text-neutral-600`,children:`No background processes yet. The agent will add them here when it starts dev servers, test watchers, builds, etc.`}):(0,R.jsxs)(`div`,{className:`space-y-2`,children:[l.live.length>0&&(0,R.jsx)(hM,{label:`Running`,items:l.live,sessionId:e}),l.finished.length>0&&(0,R.jsx)(hM,{label:`Finished`,items:l.finished,sessionId:e})]})}),(0,R.jsx)(`footer`,{className:`border-t border-neutral-800 px-3 py-1 text-[10px] italic text-neutral-500 light:border-neutral-200 light:text-neutral-600`,children:`In-memory only — processes don't survive a server restart.`})]})}function mM(e){let t=[],n=[];for(let r of e)Or.has(r.status)?t.push(r):n.push(r);return{live:t,finished:n}}function hM({label:e,items:t,sessionId:n}){return(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`div`,{className:`mb-1 px-1 text-[10px] uppercase tracking-wider text-neutral-500 light:text-neutral-600`,children:e}),(0,R.jsx)(`div`,{className:`space-y-1`,children:t.map(e=>(0,R.jsx)(gM,{process:e,sessionId:n},e.id))})]})}function gM({process:e,sessionId:t}){let[n,r]=(0,v.useState)(!1),[i,a]=(0,v.useState)(void 0),[o,s]=(0,v.useState)(!1),[c,l]=(0,v.useState)(void 0),u=Or.has(e.status);(0,v.useEffect)(()=>{if(!n)return;let r=!1;return L.getProcessOutput(t,e.id,80).then(e=>{r||a(e)}).catch(()=>{}),()=>{r=!0}},[n,t,e.id,e.endTime,e.status]);let d=Mr(e=>e.setProcesses),f=async()=>{s(!0),l(void 0);try{let n=await L.killProcess(t,e.id);n.ok||l(n.reason??`kill failed`),setTimeout(()=>{L.listProcesses(t).then(e=>d(t,e.processes)).catch(()=>void 0)},800)}catch(e){l(e instanceof N?e.code:e.message)}finally{s(!1)}},p=yM(e.startTime,e.endTime);return(0,R.jsxs)(`div`,{className:`rounded border px-1.5 py-1 text-xs ${_M(e.status)} ${u?`bg-neutral-900/40 light:bg-neutral-50`:`bg-neutral-900/20 light:bg-neutral-50/60`}`,children:[(0,R.jsxs)(`button`,{type:`button`,onClick:()=>r(e=>!e),className:`flex w-full items-start gap-1.5 text-left`,children:[(0,R.jsx)(fe,{size:11,className:`mt-0.5 shrink-0 text-neutral-500 transition-transform light:text-neutral-600 ${n?`rotate-90`:``}`}),(0,R.jsx)(vM,{status:e.status,success:e.success}),(0,R.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,R.jsxs)(`div`,{className:`flex items-baseline gap-1.5`,children:[(0,R.jsx)(`span`,{className:`truncate font-medium text-neutral-100 light:text-neutral-900`,children:e.name}),(0,R.jsx)(`span`,{className:`shrink-0 text-[10px] text-neutral-500 light:text-neutral-600`,children:e.id})]}),(0,R.jsx)(`div`,{className:`truncate font-mono text-[10px] text-neutral-500 light:text-neutral-600`,children:e.command})]}),(0,R.jsx)(`span`,{className:`shrink-0 text-[10px] text-neutral-500 light:text-neutral-600`,children:p})]}),n&&(0,R.jsxs)(`div`,{className:`mt-1 space-y-1 pl-[24px]`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2 text-[10px] text-neutral-500 light:text-neutral-600`,children:[(0,R.jsxs)(`span`,{children:[`PID `,e.pid]}),e.exitCode!==null&&(0,R.jsxs)(`span`,{children:[`exit `,e.exitCode]}),(0,R.jsx)(`div`,{className:`flex-1`}),u&&(0,R.jsxs)(`button`,{type:`button`,onClick:()=>void f(),disabled:o,className:`flex items-center gap-1 rounded border border-red-700/40 px-1.5 py-0.5 text-[10px] text-red-300 hover:bg-red-900/40 disabled:opacity-50 light:border-red-400 light:text-red-700 light:hover:bg-red-100`,children:[(0,R.jsx)(me,{size:10}),`Kill`]})]}),c!==void 0&&(0,R.jsx)(`div`,{className:`text-[10px] text-red-300 light:text-red-700`,children:c}),i!==void 0&&i.stdout.length>0&&(0,R.jsxs)(`details`,{className:`rounded bg-neutral-950 light:bg-white`,children:[(0,R.jsx)(`summary`,{className:`cursor-pointer px-1 py-0.5 text-[10px] uppercase tracking-wider text-neutral-500 hover:text-neutral-300 light:text-neutral-600 light:hover:text-neutral-900`,children:`stdout (tail)`}),(0,R.jsx)(`pre`,{className:`max-h-48 overflow-auto whitespace-pre-wrap px-1.5 py-1 font-mono text-[10px] text-neutral-300 light:text-neutral-800`,children:i.stdout.join(`
364
364
  `)})]}),i!==void 0&&i.stderr.length>0&&(0,R.jsxs)(`details`,{className:`rounded bg-neutral-950 light:bg-white`,children:[(0,R.jsx)(`summary`,{className:`cursor-pointer px-1 py-0.5 text-[10px] uppercase tracking-wider text-neutral-500 hover:text-neutral-300 light:text-neutral-600 light:hover:text-neutral-900`,children:`stderr (tail)`}),(0,R.jsx)(`pre`,{className:`max-h-48 overflow-auto whitespace-pre-wrap px-1.5 py-1 font-mono text-[10px] text-red-300 light:text-red-700`,children:i.stderr.join(`
365
- `)})]}),(0,R.jsxs)(`div`,{className:`flex gap-2 text-[10px]`,children:[(0,R.jsx)(xM,{sessionId:t,processId:e.id,stream:`stdout`}),(0,R.jsx)(xM,{sessionId:t,processId:e.id,stream:`stderr`})]})]})]})}function _M(e){return e===`running`||e===`terminating`?`border-neutral-700 light:border-neutral-300`:e===`terminate_timeout`?`border-amber-700/50 light:border-amber-400`:e===`killed`?`border-amber-700/40 light:border-amber-400`:`border-neutral-800 light:border-neutral-200`}function vM({status:e,success:t}){return e===`running`?(0,R.jsx)(Me,{size:11,className:`mt-0.5 shrink-0 animate-spin text-emerald-400 light:text-emerald-700`,"aria-label":`running`}):e===`terminating`||e===`terminate_timeout`?(0,R.jsx)(it,{size:11,className:`mt-0.5 shrink-0 text-amber-400 light:text-amber-700`,"aria-label":`terminating`}):e===`killed`?(0,R.jsx)($e,{size:11,className:`mt-0.5 shrink-0 text-amber-400 light:text-amber-700`,"aria-label":`killed`}):t===!0?(0,R.jsx)(pe,{size:11,className:`mt-0.5 shrink-0 text-emerald-400 light:text-emerald-700`,"aria-label":`exited 0`}):(0,R.jsx)(me,{size:11,className:`mt-0.5 shrink-0 text-red-400 light:text-red-700`,"aria-label":`exited non-zero`})}function yM(e,t){let n=(t??Date.now())-e;if(n<1e3)return`${n}ms`;let r=n/1e3;if(r<60)return`${r.toFixed(1)}s`;let i=r/60;return i<60?`${i.toFixed(1)}m`:`${(i/60).toFixed(1)}h`}function bM(e){return e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`).replace(/'/g,`&#39;`)}function xM({sessionId:e,processId:t,stream:n}){let[r,i]=(0,v.useState)(!1),[a,o]=(0,v.useState)(void 0);return(0,R.jsx)(`button`,{type:`button`,onClick:()=>{let r=window.open(`about:blank`,`_blank`);if(r===null){o(`popup blocked — allow popups for this site`);return}i(!0),o(void 0),(async()=>{try{let i=L.processLogFileUrl(e,t,n),a=Bt(),s={};a!==void 0&&(s.Authorization=`Bearer ${a.token}`);let c=await fetch(i,{headers:s});if(!c.ok){r.close(),o(`${c.status} ${c.statusText}`);return}let l=await c.text(),u=`<!doctype html><html><head><meta charset="utf-8"><title>${bM(`${n} — ${t}`)}</title><meta name="color-scheme" content="dark light"><style>html,body{margin:0;padding:0;background:#0a0a0a;color:#e5e5e5;font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;font-size:13px;line-height:1.5;tab-size:4}@media (prefers-color-scheme: light){html,body{background:#fafafa;color:#171717}}pre{margin:0;padding:1rem;white-space:pre-wrap;word-break:break-word}</style></head><body><pre>${bM(l)}</pre></body></html>`,d=new Blob([u],{type:`text/html;charset=utf-8`}),f=URL.createObjectURL(d);r.location.href=f,setTimeout(()=>URL.revokeObjectURL(f),6e4)}catch(e){r.close(),o(e instanceof Error?e.message:String(e))}finally{i(!1)}})()},disabled:r,className:`text-sky-400 hover:underline disabled:opacity-50 light:text-sky-700`,title:a,children:r?`loading…`:a===void 0?`full ${n} log`:`${n}: ${a}`})}function SM(){let e=ur(),t=ii(t=>e===void 0?void 0:t.treeByProject[e.id]),n=ii(t=>e===void 0?!1:t.treeLoading[e.id]??!1),r=ii(e=>e.error),i=ii(e=>e.loadTree),a=ii(e=>e.openFile),o=ii(e=>e.createFile),s=ii(e=>e.createFolder),c=ii(e=>e.renameEntry),l=ii(e=>e.moveEntry),u=ii(e=>e.deleteEntry),[d,f]=(0,v.useState)({"":!0}),[p,m]=(0,v.useState)(void 0),[h,g]=(0,v.useState)(``),[_,y]=(0,v.useState)(void 0),[b,x]=(0,v.useState)(void 0),[S,C]=(0,v.useState)(void 0),w=(0,v.useRef)(null),T=(0,v.useRef)(void 0),E=ii(e=>e.uploadFiles),[D,O]=(0,v.useState)(void 0),k=zA(e=>e.requestChatInsert),[ee,A]=(0,v.useState)(new Set);if((0,v.useEffect)(()=>{e!==void 0&&i(e.id)},[e?.id,i]),e===void 0)return(0,R.jsx)(`div`,{className:`p-4 text-xs italic text-neutral-500`,children:`Select a project to browse its files.`});let te=async(t,n,r)=>{x(void 0);try{if(t===`file`){let t=await o(e.id,n,r);await a(e.id,t)}else await s(e.id,n,r)}catch{}},ne=(e,t,n)=>{f(e=>({...e,[t]:!0})),x({kind:`create`,entryKind:n,parentAbsPath:e})},re=(e,t)=>{m(e),g(t)},ie=async t=>{let n=h.trim();if(m(void 0),g(``),n.length!==0)try{await c(e.id,t,n)}catch{}},j=()=>A(new Set),ae=e=>{A(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},M=(e,t,n)=>{x({kind:`delete`,absPath:e,name:t,isDir:n,recursive:!1})},oe=async()=>{if(b?.kind!==`delete`)return;let{absPath:t,name:n,isDir:r,recursive:i}=b;x(void 0);try{await u(e.id,t,i?{recursive:!0}:void 0)}catch(e){if(e instanceof N&&e.code===`directory_not_empty`){x({kind:`delete`,absPath:t,name:n,isDir:r,recursive:!0});return}}},se=async()=>{if(b?.kind!==`deleteMany`)return;let{paths:t}=b;x(void 0);for(let n of t)try{await u(e.id,n,{recursive:!0})}catch{}j()},ce=async t=>{if(t.type===`directory`){f(e=>({...e,[t.path]:!e[t.path]}));return}await a(e.id,EM(e.path,t.path))},le=(e,t)=>{e.preventDefault(),e.stopPropagation(),O({x:e.clientX,y:e.clientY,kind:t.isDir?`folder`:`file`,absPath:t.absPath,name:t.name,relPath:t.relPath})},ue=t=>{t.preventDefault(),O({x:t.clientX,y:t.clientY,kind:`empty`,absPath:e.path,name:``,relPath:``})},de=t=>{let n=t;t.startsWith(`${e.path}/`)&&(n=t.slice(e.path.length+1)),k(/\s/.test(n)?`@"${n}"`:`@${n}`),O(void 0)},fe=async(t,n)=>{if(t.preventDefault(),t.stopPropagation(),y(void 0),t.dataTransfer.files.length>0){await pe(n,Array.from(t.dataTransfer.files));return}let r=t.dataTransfer.getData(`application/x-pi-path`);if(r.length===0)return;let i=r.split(`/`).pop()??``;if(i.length===0)return;let a=`${n}/${i}`;if(a!==r&&!(n===r||n.startsWith(`${r}/`)))try{await l(e.id,r,a)}catch{}},pe=async(t,n)=>{if(n.length===0)return;let r=n.reduce((e,t)=>e+t.size,0);C(`Hashing ${n.length} file${n.length===1?``:`s`} (${jM(r)})…`);try{let r=await E(e.id,t,n,{onHashProgress:(e,t)=>{C(e<t?`Hashing ${jM(e)} / ${jM(t)} (${Math.floor(e/t*100)}%)…`:`Uploading ${n.length} file${n.length===1?``:`s`} (${jM(t)})…`)}});C(`Uploaded ${r.length} file${r.length===1?``:`s`}.`),window.setTimeout(()=>C(void 0),2500)}catch{C(void 0)}},me=e=>{T.current=e,w.current?.click()},he=async t=>{C(`Preparing download…`);try{let{blob:n,filename:r}=await L.filesDownload(e.id,t),i=URL.createObjectURL(n),a=document.createElement(`a`);a.href=i,a.download=r,document.body.appendChild(a),a.click(),a.remove(),window.setTimeout(()=>URL.revokeObjectURL(i),1e3),C(void 0)}catch(e){C(void 0),ii.setState({error:e instanceof Error?e.message:`download_failed`})}},ge=async t=>{let n=t.target.files,r=n===null?[]:Array.from(n),i=T.current??e.path;t.target.value=``,T.current=void 0,r.length!==0&&await pe(i,r)};return(0,R.jsxs)(`div`,{className:`flex h-full flex-col text-xs text-neutral-300`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between border-b border-neutral-800 px-3 py-2`,children:[(0,R.jsx)(`span`,{className:`truncate font-medium text-neutral-200`,title:e.path,children:e.name}),(0,R.jsxs)(`div`,{className:`flex gap-1`,children:[(0,R.jsx)(`button`,{onClick:()=>x({kind:`create`,entryKind:`file`,parentAbsPath:e.path}),className:`rounded p-1 text-neutral-400 hover:bg-neutral-800 hover:text-neutral-200`,title:`New file`,children:(0,R.jsx)(Ce,{size:14})}),(0,R.jsx)(`button`,{onClick:()=>x({kind:`create`,entryKind:`folder`,parentAbsPath:e.path}),className:`rounded p-1 text-neutral-400 hover:bg-neutral-800 hover:text-neutral-200`,title:`New folder`,children:(0,R.jsx)(Te,{size:14})}),(0,R.jsx)(`button`,{onClick:()=>me(e.path),className:`rounded p-1 text-neutral-400 hover:bg-neutral-800 hover:text-neutral-200`,title:`Upload files into project root (drag-and-drop also works on any folder)`,children:(0,R.jsx)(tt,{size:14})}),(0,R.jsx)(`button`,{onClick:()=>void he(void 0),className:`rounded p-1 text-neutral-400 hover:bg-neutral-800 hover:text-neutral-200`,title:`Download project as .tar.gz (skips node_modules, .git, dist, etc.)`,children:(0,R.jsx)(ye,{size:14})}),(0,R.jsx)(`button`,{onClick:()=>void i(e.id),className:`rounded p-1 text-neutral-400 hover:bg-neutral-800 hover:text-neutral-200`,title:`Refresh`,children:(0,R.jsx)(He,{size:14,className:n?`animate-spin`:``})})]})]}),(0,R.jsx)(`input`,{ref:w,type:`file`,multiple:!0,className:`hidden`,onChange:e=>void ge(e)}),S!==void 0&&(0,R.jsxs)(`div`,{className:`flex items-center gap-1.5 border-b border-emerald-700/40 bg-emerald-900/20 px-3 py-1.5 text-[11px] text-emerald-200 light:border-emerald-300 light:bg-emerald-50 light:text-emerald-800`,children:[!S.startsWith(`Uploaded`)&&(0,R.jsx)(Me,{size:11,className:`animate-spin`}),(0,R.jsx)(`span`,{children:S})]}),r!==void 0&&(0,R.jsx)(`div`,{className:`border-b border-red-700/40 bg-red-900/20 px-3 py-1.5 text-[11px] text-red-300 light:border-red-300 light:bg-red-50 light:text-red-700`,children:r}),ee.size>0&&(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-b border-neutral-800 bg-neutral-900/60 px-3 py-1.5 text-[11px] text-neutral-300`,children:[(0,R.jsxs)(`span`,{children:[ee.size,` selected`,(0,R.jsx)(`span`,{className:`ml-2 text-neutral-500`,children:`(Cmd/Ctrl+click rows to add or remove)`})]}),(0,R.jsxs)(`div`,{className:`flex gap-1`,children:[(0,R.jsx)(`button`,{onClick:()=>x({kind:`deleteMany`,paths:Array.from(ee)}),className:`rounded border border-red-700/50 px-2 py-0.5 text-red-300 hover:bg-red-900/20 light:border-red-400 light:text-red-700 light:hover:bg-red-50`,children:`Delete selected`}),(0,R.jsx)(`button`,{onClick:j,className:`rounded border border-neutral-700 px-2 py-0.5 text-neutral-300 hover:border-neutral-500`,children:`Clear`})]})]}),(0,R.jsxs)(`div`,{className:`flex-1 overflow-y-auto py-1`,onContextMenu:ue,onDragOver:e=>{(e.dataTransfer.types.includes(`application/x-pi-path`)||e.dataTransfer.types.includes(`Files`))&&(e.preventDefault(),e.dataTransfer.dropEffect=e.dataTransfer.types.includes(`Files`)?`copy`:`move`)},onDrop:t=>void fe(t,e.path),children:[t===void 0&&!n&&(0,R.jsx)(`p`,{className:`px-3 py-2 italic text-neutral-500`,children:`Tree not loaded.`}),t!==void 0&&(0,R.jsx)(TM,{node:t,depth:0,projectPath:e.path,expanded:d,onToggle:e=>f(t=>({...t,[e]:!t[e]})),onOpen:e=>void ce(e),renaming:p,renameDraft:h,onRenameDraftChange:g,onRenameCommit:e=>void ie(e),onRenameStart:re,onDelete:(e,t,n)=>M(e,t,n),onCreate:(e,t,n)=>ne(e,t,n),onUpload:e=>me(e),onDownload:e=>void he(e),dropTarget:_,onDropTargetChange:y,onDrop:(e,t)=>void fe(e,t),onContextMenu:le,selectedPaths:ee,onToggleSelect:ae})]}),(0,R.jsx)(wi,{open:b?.kind===`create`,onClose:()=>x(void 0),onSubmit:e=>{b?.kind===`create`&&te(b.entryKind,b.parentAbsPath,e)},title:OM(b,e.path),label:kM(b,e.path),placeholder:AM(b),primaryLabel:`Create`}),(0,R.jsx)(Ti,{open:b?.kind===`delete`,onClose:()=>x(void 0),onConfirm:()=>void oe(),title:b?.kind===`delete`?b.recursive?`"${b.name}" is not empty`:b.isDir?`Delete directory`:`Delete file`:``,message:b?.kind===`delete`?b.recursive?`"${b.name}" contains files. Delete the directory and ALL its contents? This cannot be undone.`:`Delete ${b.isDir?`directory`:`file`} "${b.name}"? This cannot be undone.`:``,primaryLabel:b?.kind===`delete`&&b.recursive?`Delete contents`:`Delete`,tone:`danger`}),(0,R.jsx)(Ti,{open:b?.kind===`deleteMany`,onClose:()=>x(void 0),onConfirm:()=>void se(),title:b?.kind===`deleteMany`?`Delete ${b.paths.length} item${b.paths.length===1?``:`s`}`:``,message:b?.kind===`deleteMany`?`Delete the ${b.paths.length} selected file${b.paths.length===1?``:`s`} / folder${b.paths.length===1?``:`s`}? Folders are deleted recursively. This cannot be undone.`:``,primaryLabel:`Delete all`,tone:`danger`}),D!==void 0&&(0,R.jsx)(CM,{x:D.x,y:D.y,kind:D.kind,onClose:()=>O(void 0),onAddAsContext:()=>de(D.absPath),...D.kind!==`empty`&&{onRename:()=>re(D.absPath,D.name),onDelete:()=>M(D.absPath,D.name,D.kind===`folder`),onDownload:()=>void he(D.absPath)},...D.kind!==`file`&&{onAddFile:()=>ne(D.absPath,D.relPath,`file`),onAddFolder:()=>ne(D.absPath,D.relPath,`folder`)}})]})}function CM(e){let t=(0,v.useRef)(e.onClose);t.current=e.onClose,(0,v.useEffect)(()=>{let e=e=>{e.key===`Escape`&&t.current()},n=()=>t.current();window.addEventListener(`keydown`,e);let r=setTimeout(()=>window.addEventListener(`mousedown`,n),0);return()=>{window.removeEventListener(`keydown`,e),window.removeEventListener(`mousedown`,n),clearTimeout(r)}},[]);let n=t=>{if(t!==void 0)return()=>{t(),e.onClose()}},r=e.kind===`empty`?void 0:n(e.onAddAsContext),i=n(e.onRename),a=n(e.onDelete),o=n(e.onDownload),s=n(e.onAddFile),c=n(e.onAddFolder);return(0,R.jsxs)(`div`,{className:`fixed z-50 min-w-[200px] overflow-hidden rounded-md border border-neutral-700 bg-neutral-900 shadow-lg`,style:{left:e.x,top:e.y},onMouseDown:e=>e.stopPropagation(),children:[r!==void 0&&(0,R.jsx)(wM,{onClick:r,icon:(0,R.jsx)(se,{size:12}),label:`Add as @ context`,title:e.kind===`folder`?`Append @<path>/ to the chat input so the model can ls / grep this folder`:`Append @<path> to the chat input so the file's content is sent with the next prompt`}),s!==void 0&&(0,R.jsx)(wM,{onClick:s,icon:(0,R.jsx)(Ce,{size:12}),label:`Add file`,title:e.kind===`folder`?`Create a new file inside this folder`:`Create a new file at the project root`}),c!==void 0&&(0,R.jsx)(wM,{onClick:c,icon:(0,R.jsx)(Te,{size:12}),label:`Add folder`,title:e.kind===`folder`?`Create a new subfolder inside this folder`:`Create a new folder at the project root`}),i!==void 0&&(0,R.jsx)(wM,{onClick:i,icon:(0,R.jsx)(Be,{size:12}),label:`Rename`,title:`Rename this file or folder`}),o!==void 0&&(0,R.jsx)(wM,{onClick:o,icon:(0,R.jsx)(ye,{size:12}),label:`Download`,title:e.kind===`folder`?`Download folder as .tar.gz`:`Download this file`}),a!==void 0&&(0,R.jsx)(wM,{onClick:a,icon:(0,R.jsx)(Qe,{size:12}),label:`Delete`,title:`Delete this file or folder`,tone:`danger`})]})}function wM(e){let t=e.tone===`danger`;return(0,R.jsxs)(`button`,{type:`button`,onClick:e.onClick,title:e.title,className:`flex w-full items-center gap-2 px-3 py-1.5 text-left text-xs ${t?`text-red-300 hover:bg-red-900/30 hover:text-red-100 light:text-red-700 light:hover:bg-red-100 light:hover:text-red-900`:`text-neutral-200 hover:bg-neutral-800`}`,children:[e.icon,e.label]})}function TM(e){let{node:t,depth:n,projectPath:r}=e;if(n===0&&t.type===`directory`)return(0,R.jsx)(`ul`,{children:t.children?.map(t=>(0,R.jsx)(TM,{...e,node:t,depth:1},t.path))});let i=EM(r,t.path),a=t.type===`directory`,o=a&&(e.expanded[t.path]??!1),s=e.renaming===i,c=a&&e.dropTarget===i;return(0,R.jsxs)(`li`,{children:[(0,R.jsxs)(`div`,{className:`group flex items-center gap-1 border-l-2 py-0.5 pr-2 ${e.selectedPaths.has(i)?`border-blue-400 bg-blue-500/15 hover:bg-blue-500/25`:`border-transparent hover:bg-neutral-900`} ${c?`bg-emerald-900/30 ring-1 ring-emerald-700/50`:``}`,style:{paddingLeft:`${n*12+6}px`},onContextMenu:s?void 0:n=>e.onContextMenu(n,{absPath:i,isDir:a,name:t.name,relPath:t.path}),draggable:!s,onDragStart:e=>{e.dataTransfer.setData(`application/x-pi-path`,i),e.dataTransfer.effectAllowed=`move`},onDragOver:a?t=>{let n=t.dataTransfer.types.includes(`Files`),r=t.dataTransfer.types.includes(`application/x-pi-path`);!n&&!r||(t.preventDefault(),t.stopPropagation(),t.dataTransfer.dropEffect=n?`copy`:`move`,e.dropTarget!==i&&e.onDropTargetChange(i))}:void 0,onDragLeave:a?()=>{e.dropTarget===i&&e.onDropTargetChange(void 0)}:void 0,onDrop:a?t=>{t.stopPropagation(),e.onDrop(t,i)}:void 0,children:[(0,R.jsxs)(`button`,{onClick:n=>{if(n.metaKey||n.ctrlKey){e.onToggleSelect(i);return}e.onOpen(t)},className:`flex flex-1 items-center gap-1 truncate text-left`,title:i,children:[a?o?(0,R.jsx)(ue,{size:12,className:`text-neutral-500`}):(0,R.jsx)(fe,{size:12,className:`text-neutral-500`}):(0,R.jsx)(`span`,{className:`inline-block w-3`}),s?(0,R.jsx)(`input`,{autoFocus:!0,value:e.renameDraft,onChange:t=>e.onRenameDraftChange(t.target.value),onKeyDown:t=>{(t.key===`Enter`||t.key===`Escape`)&&(t.preventDefault(),e.onRenameCommit(i))},onBlur:()=>e.onRenameCommit(i),onClick:e=>e.stopPropagation(),className:`flex-1 rounded border border-neutral-700 bg-neutral-950 px-1 text-[11px] text-neutral-100 outline-none focus:border-neutral-500`}):(0,R.jsx)(`span`,{className:`truncate ${a?`text-neutral-200`:`text-neutral-300`}`,children:t.name}),t.truncated===!0&&(0,R.jsx)(`span`,{className:`ml-1 text-[10px] text-neutral-600`,children:`…`})]}),!s&&(0,R.jsxs)(`div`,{className:`hidden items-center gap-0.5 group-hover:flex`,children:[a&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`button`,{onClick:n=>{n.stopPropagation(),e.onCreate(i,t.path,`file`)},className:`rounded p-0.5 text-neutral-500 hover:bg-neutral-800 hover:text-neutral-200`,title:`New file in this folder`,children:(0,R.jsx)(Ce,{size:11})}),(0,R.jsx)(`button`,{onClick:n=>{n.stopPropagation(),e.onCreate(i,t.path,`folder`)},className:`rounded p-0.5 text-neutral-500 hover:bg-neutral-800 hover:text-neutral-200`,title:`New subfolder in this folder`,children:(0,R.jsx)(Te,{size:11})}),(0,R.jsx)(`button`,{onClick:t=>{t.stopPropagation(),e.onUpload(i)},className:`rounded p-0.5 text-neutral-500 hover:bg-neutral-800 hover:text-neutral-200`,title:`Upload into this folder`,children:(0,R.jsx)(tt,{size:11})})]}),(0,R.jsx)(`button`,{onClick:t=>{t.stopPropagation(),e.onDownload(i)},className:`rounded p-0.5 text-neutral-500 hover:bg-neutral-800 hover:text-neutral-200`,title:a?`Download folder as .tar.gz`:`Download file`,children:(0,R.jsx)(ye,{size:11})}),(0,R.jsx)(`button`,{onClick:n=>{n.stopPropagation(),e.onRenameStart(i,t.name)},className:`rounded p-0.5 text-neutral-500 hover:bg-neutral-800 hover:text-neutral-200`,title:`Rename`,children:(0,R.jsx)(Be,{size:11})}),(0,R.jsx)(`button`,{onClick:n=>{n.stopPropagation(),e.onDelete(i,t.name,a)},className:`rounded p-0.5 text-neutral-500 hover:bg-red-900/30 hover:text-red-300 light:hover:bg-red-100 light:hover:text-red-700`,title:`Delete`,children:(0,R.jsx)(Qe,{size:11})})]})]}),a&&o&&t.children!==void 0&&(0,R.jsx)(`ul`,{children:t.children.map(t=>(0,R.jsx)(TM,{...e,node:t,depth:n+1},t.path))})]})}function EM(e,t){return t===``?e:`${e}/${t.replaceAll(`\\`,`/`)}`}function DM(e,t){if(e!==t)return e.startsWith(`${t}/`)?e.slice(t.length+1):e}function OM(e,t){if(e?.kind!==`create`)return``;let n=DM(e.parentAbsPath,t),r=e.entryKind===`folder`?`folder`:`file`;return n===void 0?`New ${r}`:`New ${r} in ${n}/`}function kM(e,t){if(e?.kind!==`create`)return``;let n=DM(e.parentAbsPath,t),r=e.entryKind===`folder`?`Folder name`:`File name`;return n===void 0?`${r} (relative to project root)`:`${r} (in ${n}/)`}function AM(e){return e?.kind===`create`?e.entryKind===`folder`?`utils`:`index.ts`:``}function jM(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:e<1024*1024*1024?`${(e/(1024*1024)).toFixed(1)} MB`:`${(e/(1024*1024*1024)).toFixed(2)} GB`}var MM=`forge.editor.wrap.`,NM=[];function PM(e){let t=Math.max(e.lastIndexOf(`/`),e.lastIndexOf(`\\`)),n=t===-1?e:e.slice(t+1),r=n.lastIndexOf(`.`);return r<=0?``:n.slice(r+1).toLowerCase()}function FM(e){try{let t=localStorage.getItem(MM+e);if(t===`0`)return!1;if(t===`1`)return!0}catch{}return!0}function IM(e,t){try{localStorage.setItem(MM+e,t?`1`:`0`)}catch{}}var LM=(0,v.lazy)(()=>C(()=>import(`./CodeMirrorEditor-BuLFJjB1.js`).then(e=>({default:e.CodeMirrorEditor})),[]));function RM(){let e=ur(),t=ii(e=>e.openFiles),n=ii(e=>e.activePath),r=ii(e=>e.setActiveFile),i=ii(e=>e.closeFile),a=ii(e=>e.closeAllFiles),o=ii(e=>e.updateDraft),s=ii(e=>e.saveFile),c=ii(e=>e.reloadFile),l=ii(e=>e.externallyChanged),u=ii(e=>e.gitDiffByPath),d=t.find(e=>e.path===n),f=d===void 0?``:PM(d.path),[p,m]=(0,v.useState)(()=>FM(f));(0,v.useEffect)(()=>{m(FM(f))},[f]);let h=(0,v.useCallback)(()=>{m(e=>{let t=!e;return IM(f,t),t})},[f]);return(0,R.jsxs)(`div`,{className:`flex h-full flex-col bg-neutral-950 text-sm text-neutral-200`,children:[(0,R.jsx)(BM,{files:t,activePath:n,externallyChanged:l,onActivate:r,onClose:i,onCloseAll:a}),d===void 0?(0,R.jsx)(`div`,{className:`flex flex-1 items-center justify-center text-xs italic text-neutral-500`,children:`No file open. Click a file in the tree to start editing.`}):(0,R.jsxs)(R.Fragment,{children:[l[d.path]===!0&&(0,R.jsx)(VM,{path:d.path,onReload:()=>{e!==void 0&&c(e.id,d.path)},onDiscard:()=>ii.getState().dismissExternallyChanged(d.path)}),d.binary?(0,R.jsx)(`div`,{className:`flex flex-1 items-center justify-center px-6 text-center text-sm text-neutral-500`,children:d.loadingError??`Binary file.`}):(0,R.jsx)(v.Suspense,{fallback:(0,R.jsx)(zM,{}),children:(0,R.jsx)(LM,{file:d,wrap:p,diffChanges:u[d.path]??NM,onChange:e=>o(d.path,e),onSaveShortcut:()=>{e!==void 0&&s(e.id,d.path)},onConsumePendingNav:e=>ii.getState().consumePendingNav(e)},d.tabId)}),(0,R.jsx)(HM,{file:d,wrap:p,onToggleWrap:h,onSave:()=>{e!==void 0&&s(e.id,d.path)}})]})]})}function zM(){return(0,R.jsx)(`div`,{className:`flex flex-1 items-center justify-center text-xs italic text-neutral-500`,children:`Loading editor…`})}function BM({files:e,activePath:t,externallyChanged:n,onActivate:r,onClose:i,onCloseAll:a}){if(e.length===0)return null;let o=e.filter(e=>e.dirty).length;return(0,R.jsxs)(`div`,{className:`flex border-b border-neutral-800 bg-neutral-900/40`,children:[(0,R.jsx)(`button`,{onClick:()=>{o>0&&!window.confirm(`Close ${e.length} tab${e.length===1?``:`s`}? ${o} ha${o===1?`s`:`ve`} unsaved changes that will be lost.`)||a()},className:`flex shrink-0 items-center justify-center border-r border-neutral-800 px-2 py-1.5 text-neutral-500 hover:bg-neutral-800 hover:text-neutral-200`,title:`Close all ${e.length} tab${e.length===1?``:`s`}`,children:(0,R.jsx)(Ye,{size:14})}),(0,R.jsx)(`div`,{className:`flex flex-1 overflow-x-auto`,children:e.map(e=>{let a=e.path.split(`/`).pop()??e.path,o=e.path===t,s=n[e.path]===!0;return(0,R.jsxs)(`div`,{className:`group flex items-center gap-1 border-r border-neutral-800 px-3 py-1.5 text-xs ${o?`bg-neutral-950 text-neutral-100`:`text-neutral-400 hover:bg-neutral-900 hover:text-neutral-200`} ${s?`bg-amber-900/30 text-amber-200 light:bg-amber-100 light:text-amber-800`:``}`,title:s?`${e.path}\n\nExternal change while you have unsaved edits — open the tab to review.`:e.path,children:[(0,R.jsxs)(`button`,{onClick:()=>r(e.path),className:`truncate`,children:[s?(0,R.jsx)($e,{size:11,className:`mr-1 inline text-amber-400 light:text-amber-700`}):e.dirty?(0,R.jsx)(`span`,{className:`mr-1.5 inline-block h-2.5 w-2.5 rounded-full bg-amber-400 align-middle`,"aria-label":`Unsaved changes`,title:`Unsaved changes`}):null,a]}),(0,R.jsx)(`button`,{onClick:()=>i(e.path),className:`rounded p-1 text-neutral-600 hover:bg-neutral-800 hover:text-neutral-200`,title:`Close (any unsaved changes are lost)`,children:(0,R.jsx)(rt,{size:16})})]},e.tabId)})})]})}function VM({path:e,onReload:t,onDiscard:n}){return(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-amber-700/40 bg-amber-900/20 px-4 py-1.5 text-xs text-amber-200 light:border-amber-300 light:bg-amber-50 light:text-amber-800`,children:[(0,R.jsxs)(`span`,{children:[`File changed externally — local edits in this tab are stale. Reload from disk?`,(0,R.jsx)(`span`,{className:`ml-2 font-mono text-[10px] text-amber-400/70 light:text-amber-700/80`,children:e})]}),(0,R.jsxs)(`div`,{className:`flex gap-1`,children:[(0,R.jsx)(`button`,{onClick:t,className:`rounded border border-amber-700/50 px-2 py-0.5 hover:bg-amber-900/30 light:border-amber-400 light:hover:bg-amber-100`,children:`Reload`}),(0,R.jsx)(`button`,{onClick:n,className:`rounded border border-neutral-700 px-2 py-0.5 text-neutral-300 hover:border-neutral-500`,children:`Keep mine`})]})]})}function HM({file:e,wrap:t,onToggleWrap:n,onSave:r}){let i=e.dirty,a=e.saving,o=e.savedAt,s=e.saveError,c,l=`text-neutral-500`;s===void 0?a?c=`Saving…`:i?(c=`Unsaved changes`,l=`text-amber-400 light:text-amber-700`):o===void 0?c=`Up to date`:(c=`Saved ${new Date(o).toLocaleTimeString()}`,l=`text-emerald-500 light:text-emerald-700`):(c=`Save failed (${s}) — Cmd/Ctrl+S or Save to retry`,l=`text-rose-400 light:text-rose-700`);let u=(i||s!==void 0)&&!a&&!e.binary;return(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-t border-neutral-800 bg-neutral-900/40 px-3 py-1 text-[11px]`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(`span`,{className:`font-mono text-neutral-500`,children:e.language}),(0,R.jsxs)(`button`,{onClick:n,className:`flex items-center gap-1 rounded px-1 py-0.5 text-[10px] hover:bg-neutral-800 ${t?`text-neutral-300`:`text-neutral-500`}`,title:t?`Wrap on (click to switch to horizontal scroll, persisted per file extension)`:`Wrap off (click to enable wrap, persisted per file extension)`,children:[(0,R.jsx)(Ze,{size:11}),t?`wrap`:`no wrap`]})]}),(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(`span`,{className:l,children:c}),(0,R.jsxs)(`button`,{onClick:r,disabled:!u,className:`flex items-center gap-1 rounded border border-neutral-700 px-1.5 py-0.5 text-[10px] text-neutral-200 hover:border-neutral-500 disabled:cursor-not-allowed disabled:border-neutral-800 disabled:text-neutral-600`,title:`Save (Cmd/Ctrl+S)`,children:[(0,R.jsx)(Ge,{size:11}),`Save`]})]})]})}var UM=o(((e,t)=>{(function(n,r){if(typeof e==`object`&&typeof t==`object`)t.exports=r();else if(typeof define==`function`&&define.amd)define([],r);else{var i=r();for(var a in i)(typeof e==`object`?e:n)[a]=i[a]}})(globalThis,(()=>(()=>{var e={4567:function(e,t,n){var r=this&&this.__decorate||function(e,t,n,r){var i,a=arguments.length,o=a<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o},i=this&&this.__param||function(e,t){return function(n,r){t(n,r,e)}};Object.defineProperty(t,"__esModule",{value:!0}),t.AccessibilityManager=void 0;let a=n(9042),o=n(9924),s=n(844),c=n(4725),l=n(2585),u=n(3656),d=t.AccessibilityManager=class extends s.Disposable{constructor(e,t,n,r){super(),this._terminal=e,this._coreBrowserService=n,this._renderService=r,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce=``,this._accessibilityContainer=this._coreBrowserService.mainDocument.createElement(`div`),this._accessibilityContainer.classList.add(`xterm-accessibility`),this._rowContainer=this._coreBrowserService.mainDocument.createElement(`div`),this._rowContainer.setAttribute(`role`,`list`),this._rowContainer.classList.add(`xterm-accessibility-tree`),this._rowElements=[];for(let e=0;e<this._terminal.rows;e++)this._rowElements[e]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[e]);if(this._topBoundaryFocusListener=e=>this._handleBoundaryFocus(e,0),this._bottomBoundaryFocusListener=e=>this._handleBoundaryFocus(e,1),this._rowElements[0].addEventListener(`focus`,this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener(`focus`,this._bottomBoundaryFocusListener),this._refreshRowsDimensions(),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=this._coreBrowserService.mainDocument.createElement(`div`),this._liveRegion.classList.add(`live-region`),this._liveRegion.setAttribute(`aria-live`,`assertive`),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this.register(new o.TimeBasedDebouncer(this._renderRows.bind(this))),!this._terminal.element)throw Error(`Cannot enable accessibility before Terminal.open`);this._terminal.element.insertAdjacentElement(`afterbegin`,this._accessibilityContainer),this.register(this._terminal.onResize((e=>this._handleResize(e.rows)))),this.register(this._terminal.onRender((e=>this._refreshRows(e.start,e.end)))),this.register(this._terminal.onScroll((()=>this._refreshRows()))),this.register(this._terminal.onA11yChar((e=>this._handleChar(e)))),this.register(this._terminal.onLineFeed((()=>this._handleChar(`
365
+ `)})]}),(0,R.jsxs)(`div`,{className:`flex gap-2 text-[10px]`,children:[(0,R.jsx)(xM,{sessionId:t,processId:e.id,stream:`stdout`}),(0,R.jsx)(xM,{sessionId:t,processId:e.id,stream:`stderr`})]})]})]})}function _M(e){return e===`running`||e===`terminating`?`border-neutral-700 light:border-neutral-300`:e===`terminate_timeout`?`border-amber-700/50 light:border-amber-400`:e===`killed`?`border-amber-700/40 light:border-amber-400`:`border-neutral-800 light:border-neutral-200`}function vM({status:e,success:t}){return e===`running`?(0,R.jsx)(Me,{size:11,className:`mt-0.5 shrink-0 animate-spin text-emerald-400 light:text-emerald-700`,"aria-label":`running`}):e===`terminating`||e===`terminate_timeout`?(0,R.jsx)(it,{size:11,className:`mt-0.5 shrink-0 text-amber-400 light:text-amber-700`,"aria-label":`terminating`}):e===`killed`?(0,R.jsx)($e,{size:11,className:`mt-0.5 shrink-0 text-amber-400 light:text-amber-700`,"aria-label":`killed`}):t===!0?(0,R.jsx)(pe,{size:11,className:`mt-0.5 shrink-0 text-emerald-400 light:text-emerald-700`,"aria-label":`exited 0`}):(0,R.jsx)(me,{size:11,className:`mt-0.5 shrink-0 text-red-400 light:text-red-700`,"aria-label":`exited non-zero`})}function yM(e,t){let n=(t??Date.now())-e;if(n<1e3)return`${n}ms`;let r=n/1e3;if(r<60)return`${r.toFixed(1)}s`;let i=r/60;return i<60?`${i.toFixed(1)}m`:`${(i/60).toFixed(1)}h`}function bM(e){return e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`).replace(/'/g,`&#39;`)}function xM({sessionId:e,processId:t,stream:n}){let[r,i]=(0,v.useState)(!1),[a,o]=(0,v.useState)(void 0);return(0,R.jsx)(`button`,{type:`button`,onClick:()=>{let r=window.open(`about:blank`,`_blank`);if(r===null){o(`popup blocked — allow popups for this site`);return}i(!0),o(void 0),(async()=>{try{let i=L.processLogFileUrl(e,t,n),a=Bt(),s={};a!==void 0&&(s.Authorization=`Bearer ${a.token}`);let c=await fetch(i,{headers:s});if(!c.ok){r.close(),o(`${c.status} ${c.statusText}`);return}let l=await c.text(),u=`<!doctype html><html><head><meta charset="utf-8"><title>${bM(`${n} — ${t}`)}</title><meta name="color-scheme" content="dark light"><style>html,body{margin:0;padding:0;background:#0a0a0a;color:#e5e5e5;font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;font-size:13px;line-height:1.5;tab-size:4}@media (prefers-color-scheme: light){html,body{background:#fafafa;color:#171717}}pre{margin:0;padding:1rem;white-space:pre-wrap;word-break:break-word}</style></head><body><pre>${bM(l)}</pre></body></html>`,d=new Blob([u],{type:`text/html;charset=utf-8`}),f=URL.createObjectURL(d);r.location.href=f,setTimeout(()=>URL.revokeObjectURL(f),6e4)}catch(e){r.close(),o(e instanceof Error?e.message:String(e))}finally{i(!1)}})()},disabled:r,className:`text-sky-400 hover:underline disabled:opacity-50 light:text-sky-700`,title:a,children:r?`loading…`:a===void 0?`full ${n} log`:`${n}: ${a}`})}function SM(){let e=ur(),t=ii(t=>e===void 0?void 0:t.treeByProject[e.id]),n=ii(t=>e===void 0?!1:t.treeLoading[e.id]??!1),r=ii(e=>e.error),i=ii(e=>e.loadTree),a=ii(e=>e.openFile),o=ii(e=>e.createFile),s=ii(e=>e.createFolder),c=ii(e=>e.renameEntry),l=ii(e=>e.moveEntry),u=ii(e=>e.deleteEntry),[d,f]=(0,v.useState)({"":!0}),[p,m]=(0,v.useState)(void 0),[h,g]=(0,v.useState)(``),[_,y]=(0,v.useState)(void 0),[b,x]=(0,v.useState)(void 0),[S,C]=(0,v.useState)(void 0),w=(0,v.useRef)(null),T=(0,v.useRef)(void 0),E=ii(e=>e.uploadFiles),[D,O]=(0,v.useState)(void 0),k=zA(e=>e.requestChatInsert),[ee,A]=(0,v.useState)(new Set);if((0,v.useEffect)(()=>{e!==void 0&&i(e.id)},[e?.id,i]),e===void 0)return(0,R.jsx)(`div`,{className:`p-4 text-xs italic text-neutral-500`,children:`Select a project to browse its files.`});let te=async(t,n,r)=>{x(void 0);try{if(t===`file`){let t=await o(e.id,n,r);await a(e.id,t)}else await s(e.id,n,r)}catch{}},ne=(e,t,n)=>{f(e=>({...e,[t]:!0})),x({kind:`create`,entryKind:n,parentAbsPath:e})},re=(e,t)=>{m(e),g(t)},ie=async t=>{let n=h.trim();if(m(void 0),g(``),n.length!==0)try{await c(e.id,t,n)}catch{}},j=()=>A(new Set),ae=e=>{A(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},M=(e,t,n)=>{x({kind:`delete`,absPath:e,name:t,isDir:n,recursive:!1})},oe=async()=>{if(b?.kind!==`delete`)return;let{absPath:t,name:n,isDir:r,recursive:i}=b;x(void 0);try{await u(e.id,t,i?{recursive:!0}:void 0)}catch(e){if(e instanceof N&&e.code===`directory_not_empty`){x({kind:`delete`,absPath:t,name:n,isDir:r,recursive:!0});return}}},se=async()=>{if(b?.kind!==`deleteMany`)return;let{paths:t}=b;x(void 0);for(let n of t)try{await u(e.id,n,{recursive:!0})}catch{}j()},ce=async t=>{if(t.type===`directory`){f(e=>({...e,[t.path]:!e[t.path]}));return}await a(e.id,EM(e.path,t.path))},le=(e,t)=>{e.preventDefault(),e.stopPropagation(),O({x:e.clientX,y:e.clientY,kind:t.isDir?`folder`:`file`,absPath:t.absPath,name:t.name,relPath:t.relPath})},ue=t=>{t.preventDefault(),O({x:t.clientX,y:t.clientY,kind:`empty`,absPath:e.path,name:``,relPath:``})},de=t=>{let n=t;t.startsWith(`${e.path}/`)&&(n=t.slice(e.path.length+1)),k(/\s/.test(n)?`@"${n}"`:`@${n}`),O(void 0)},fe=async(t,n)=>{if(t.preventDefault(),t.stopPropagation(),y(void 0),t.dataTransfer.files.length>0){await pe(n,Array.from(t.dataTransfer.files));return}let r=t.dataTransfer.getData(`application/x-pi-path`);if(r.length===0)return;let i=r.split(`/`).pop()??``;if(i.length===0)return;let a=`${n}/${i}`;if(a!==r&&!(n===r||n.startsWith(`${r}/`)))try{await l(e.id,r,a)}catch{}},pe=async(t,n)=>{if(n.length===0)return;let r=n.reduce((e,t)=>e+t.size,0);C(`Hashing ${n.length} file${n.length===1?``:`s`} (${jM(r)})…`);try{let r=await E(e.id,t,n,{onHashProgress:(e,t)=>{C(e<t?`Hashing ${jM(e)} / ${jM(t)} (${Math.floor(e/t*100)}%)…`:`Uploading ${n.length} file${n.length===1?``:`s`} (${jM(t)})…`)}});C(`Uploaded ${r.length} file${r.length===1?``:`s`}.`),window.setTimeout(()=>C(void 0),2500)}catch{C(void 0)}},me=e=>{T.current=e,w.current?.click()},he=async t=>{C(`Preparing download…`);try{let{blob:n,filename:r}=await L.filesDownload(e.id,t),i=URL.createObjectURL(n),a=document.createElement(`a`);a.href=i,a.download=r,document.body.appendChild(a),a.click(),a.remove(),window.setTimeout(()=>URL.revokeObjectURL(i),1e3),C(void 0)}catch(e){C(void 0),ii.setState({error:e instanceof Error?e.message:`download_failed`})}},ge=async t=>{let n=t.target.files,r=n===null?[]:Array.from(n),i=T.current??e.path;t.target.value=``,T.current=void 0,r.length!==0&&await pe(i,r)};return(0,R.jsxs)(`div`,{className:`flex h-full flex-col text-xs text-neutral-300`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between border-b border-neutral-800 px-3 py-2`,children:[(0,R.jsx)(`span`,{className:`truncate font-medium text-neutral-200`,title:e.path,children:e.name}),(0,R.jsxs)(`div`,{className:`flex gap-1`,children:[(0,R.jsx)(`button`,{onClick:()=>x({kind:`create`,entryKind:`file`,parentAbsPath:e.path}),className:`rounded p-1 text-neutral-400 hover:bg-neutral-800 hover:text-neutral-200`,title:`New file`,children:(0,R.jsx)(Ce,{size:14})}),(0,R.jsx)(`button`,{onClick:()=>x({kind:`create`,entryKind:`folder`,parentAbsPath:e.path}),className:`rounded p-1 text-neutral-400 hover:bg-neutral-800 hover:text-neutral-200`,title:`New folder`,children:(0,R.jsx)(Te,{size:14})}),(0,R.jsx)(`button`,{onClick:()=>me(e.path),className:`rounded p-1 text-neutral-400 hover:bg-neutral-800 hover:text-neutral-200`,title:`Upload files into project root (drag-and-drop also works on any folder)`,children:(0,R.jsx)(tt,{size:14})}),(0,R.jsx)(`button`,{onClick:()=>void he(void 0),className:`rounded p-1 text-neutral-400 hover:bg-neutral-800 hover:text-neutral-200`,title:`Download project as .tar.gz (skips node_modules, .git, dist, etc.)`,children:(0,R.jsx)(ye,{size:14})}),(0,R.jsx)(`button`,{onClick:()=>void i(e.id),className:`rounded p-1 text-neutral-400 hover:bg-neutral-800 hover:text-neutral-200`,title:`Refresh`,children:(0,R.jsx)(He,{size:14,className:n?`animate-spin`:``})})]})]}),(0,R.jsx)(`input`,{ref:w,type:`file`,multiple:!0,className:`hidden`,onChange:e=>void ge(e)}),S!==void 0&&(0,R.jsxs)(`div`,{className:`flex items-center gap-1.5 border-b border-emerald-700/40 bg-emerald-900/20 px-3 py-1.5 text-[11px] text-emerald-200 light:border-emerald-300 light:bg-emerald-50 light:text-emerald-800`,children:[!S.startsWith(`Uploaded`)&&(0,R.jsx)(Me,{size:11,className:`animate-spin`}),(0,R.jsx)(`span`,{children:S})]}),r!==void 0&&(0,R.jsx)(`div`,{className:`border-b border-red-700/40 bg-red-900/20 px-3 py-1.5 text-[11px] text-red-300 light:border-red-300 light:bg-red-50 light:text-red-700`,children:r}),ee.size>0&&(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-b border-neutral-800 bg-neutral-900/60 px-3 py-1.5 text-[11px] text-neutral-300`,children:[(0,R.jsxs)(`span`,{children:[ee.size,` selected`,(0,R.jsx)(`span`,{className:`ml-2 text-neutral-500`,children:`(Cmd/Ctrl+click rows to add or remove)`})]}),(0,R.jsxs)(`div`,{className:`flex gap-1`,children:[(0,R.jsx)(`button`,{onClick:()=>x({kind:`deleteMany`,paths:Array.from(ee)}),className:`rounded border border-red-700/50 px-2 py-0.5 text-red-300 hover:bg-red-900/20 light:border-red-400 light:text-red-700 light:hover:bg-red-50`,children:`Delete selected`}),(0,R.jsx)(`button`,{onClick:j,className:`rounded border border-neutral-700 px-2 py-0.5 text-neutral-300 hover:border-neutral-500`,children:`Clear`})]})]}),(0,R.jsxs)(`div`,{className:`flex-1 overflow-y-auto py-1`,onContextMenu:ue,onDragOver:e=>{(e.dataTransfer.types.includes(`application/x-pi-path`)||e.dataTransfer.types.includes(`Files`))&&(e.preventDefault(),e.dataTransfer.dropEffect=e.dataTransfer.types.includes(`Files`)?`copy`:`move`)},onDrop:t=>void fe(t,e.path),children:[t===void 0&&!n&&(0,R.jsx)(`p`,{className:`px-3 py-2 italic text-neutral-500`,children:`Tree not loaded.`}),t!==void 0&&(0,R.jsx)(TM,{node:t,depth:0,projectPath:e.path,expanded:d,onToggle:e=>f(t=>({...t,[e]:!t[e]})),onOpen:e=>void ce(e),renaming:p,renameDraft:h,onRenameDraftChange:g,onRenameCommit:e=>void ie(e),onRenameStart:re,onDelete:(e,t,n)=>M(e,t,n),onCreate:(e,t,n)=>ne(e,t,n),onUpload:e=>me(e),onDownload:e=>void he(e),dropTarget:_,onDropTargetChange:y,onDrop:(e,t)=>void fe(e,t),onContextMenu:le,selectedPaths:ee,onToggleSelect:ae})]}),(0,R.jsx)(wi,{open:b?.kind===`create`,onClose:()=>x(void 0),onSubmit:e=>{b?.kind===`create`&&te(b.entryKind,b.parentAbsPath,e)},title:OM(b,e.path),label:kM(b,e.path),placeholder:AM(b),primaryLabel:`Create`}),(0,R.jsx)(Ti,{open:b?.kind===`delete`,onClose:()=>x(void 0),onConfirm:()=>void oe(),title:b?.kind===`delete`?b.recursive?`"${b.name}" is not empty`:b.isDir?`Delete directory`:`Delete file`:``,message:b?.kind===`delete`?b.recursive?`"${b.name}" contains files. Delete the directory and ALL its contents? This cannot be undone.`:`Delete ${b.isDir?`directory`:`file`} "${b.name}"? This cannot be undone.`:``,primaryLabel:b?.kind===`delete`&&b.recursive?`Delete contents`:`Delete`,tone:`danger`}),(0,R.jsx)(Ti,{open:b?.kind===`deleteMany`,onClose:()=>x(void 0),onConfirm:()=>void se(),title:b?.kind===`deleteMany`?`Delete ${b.paths.length} item${b.paths.length===1?``:`s`}`:``,message:b?.kind===`deleteMany`?`Delete the ${b.paths.length} selected file${b.paths.length===1?``:`s`} / folder${b.paths.length===1?``:`s`}? Folders are deleted recursively. This cannot be undone.`:``,primaryLabel:`Delete all`,tone:`danger`}),D!==void 0&&(0,R.jsx)(CM,{x:D.x,y:D.y,kind:D.kind,onClose:()=>O(void 0),onAddAsContext:()=>de(D.absPath),...D.kind!==`empty`&&{onRename:()=>re(D.absPath,D.name),onDelete:()=>M(D.absPath,D.name,D.kind===`folder`),onDownload:()=>void he(D.absPath)},...D.kind!==`file`&&{onAddFile:()=>ne(D.absPath,D.relPath,`file`),onAddFolder:()=>ne(D.absPath,D.relPath,`folder`)}})]})}function CM(e){let t=(0,v.useRef)(e.onClose);t.current=e.onClose,(0,v.useEffect)(()=>{let e=e=>{e.key===`Escape`&&t.current()},n=()=>t.current();window.addEventListener(`keydown`,e);let r=setTimeout(()=>window.addEventListener(`mousedown`,n),0);return()=>{window.removeEventListener(`keydown`,e),window.removeEventListener(`mousedown`,n),clearTimeout(r)}},[]);let n=t=>{if(t!==void 0)return()=>{t(),e.onClose()}},r=e.kind===`empty`?void 0:n(e.onAddAsContext),i=n(e.onRename),a=n(e.onDelete),o=n(e.onDownload),s=n(e.onAddFile),c=n(e.onAddFolder);return(0,R.jsxs)(`div`,{className:`fixed z-50 min-w-[200px] overflow-hidden rounded-md border border-neutral-700 bg-neutral-900 shadow-lg`,style:{left:e.x,top:e.y},onMouseDown:e=>e.stopPropagation(),children:[r!==void 0&&(0,R.jsx)(wM,{onClick:r,icon:(0,R.jsx)(se,{size:12}),label:`Add as @ context`,title:e.kind===`folder`?`Append @<path>/ to the chat input so the model can ls / grep this folder`:`Append @<path> to the chat input so the file's content is sent with the next prompt`}),s!==void 0&&(0,R.jsx)(wM,{onClick:s,icon:(0,R.jsx)(Ce,{size:12}),label:`Add file`,title:e.kind===`folder`?`Create a new file inside this folder`:`Create a new file at the project root`}),c!==void 0&&(0,R.jsx)(wM,{onClick:c,icon:(0,R.jsx)(Te,{size:12}),label:`Add folder`,title:e.kind===`folder`?`Create a new subfolder inside this folder`:`Create a new folder at the project root`}),i!==void 0&&(0,R.jsx)(wM,{onClick:i,icon:(0,R.jsx)(Be,{size:12}),label:`Rename`,title:`Rename this file or folder`}),o!==void 0&&(0,R.jsx)(wM,{onClick:o,icon:(0,R.jsx)(ye,{size:12}),label:`Download`,title:e.kind===`folder`?`Download folder as .tar.gz`:`Download this file`}),a!==void 0&&(0,R.jsx)(wM,{onClick:a,icon:(0,R.jsx)(Qe,{size:12}),label:`Delete`,title:`Delete this file or folder`,tone:`danger`})]})}function wM(e){let t=e.tone===`danger`;return(0,R.jsxs)(`button`,{type:`button`,onClick:e.onClick,title:e.title,className:`flex w-full items-center gap-2 px-3 py-1.5 text-left text-xs ${t?`text-red-300 hover:bg-red-900/30 hover:text-red-100 light:text-red-700 light:hover:bg-red-100 light:hover:text-red-900`:`text-neutral-200 hover:bg-neutral-800`}`,children:[e.icon,e.label]})}function TM(e){let{node:t,depth:n,projectPath:r}=e;if(n===0&&t.type===`directory`)return(0,R.jsx)(`ul`,{children:t.children?.map(t=>(0,R.jsx)(TM,{...e,node:t,depth:1},t.path))});let i=EM(r,t.path),a=t.type===`directory`,o=a&&(e.expanded[t.path]??!1),s=e.renaming===i,c=a&&e.dropTarget===i;return(0,R.jsxs)(`li`,{children:[(0,R.jsxs)(`div`,{className:`group flex items-center gap-1 border-l-2 py-0.5 pr-2 ${e.selectedPaths.has(i)?`border-blue-400 bg-blue-500/15 hover:bg-blue-500/25`:`border-transparent hover:bg-neutral-900`} ${c?`bg-emerald-900/30 ring-1 ring-emerald-700/50`:``}`,style:{paddingLeft:`${n*12+6}px`},onContextMenu:s?void 0:n=>e.onContextMenu(n,{absPath:i,isDir:a,name:t.name,relPath:t.path}),draggable:!s,onDragStart:e=>{e.dataTransfer.setData(`application/x-pi-path`,i),e.dataTransfer.effectAllowed=`move`},onDragOver:a?t=>{let n=t.dataTransfer.types.includes(`Files`),r=t.dataTransfer.types.includes(`application/x-pi-path`);!n&&!r||(t.preventDefault(),t.stopPropagation(),t.dataTransfer.dropEffect=n?`copy`:`move`,e.dropTarget!==i&&e.onDropTargetChange(i))}:void 0,onDragLeave:a?()=>{e.dropTarget===i&&e.onDropTargetChange(void 0)}:void 0,onDrop:a?t=>{t.stopPropagation(),e.onDrop(t,i)}:void 0,children:[(0,R.jsxs)(`button`,{onClick:n=>{if(n.metaKey||n.ctrlKey){e.onToggleSelect(i);return}e.onOpen(t)},className:`flex flex-1 items-center gap-1 truncate text-left`,title:i,children:[a?o?(0,R.jsx)(ue,{size:12,className:`text-neutral-500`}):(0,R.jsx)(fe,{size:12,className:`text-neutral-500`}):(0,R.jsx)(`span`,{className:`inline-block w-3`}),s?(0,R.jsx)(`input`,{autoFocus:!0,value:e.renameDraft,onChange:t=>e.onRenameDraftChange(t.target.value),onKeyDown:t=>{(t.key===`Enter`||t.key===`Escape`)&&(t.preventDefault(),e.onRenameCommit(i))},onBlur:()=>e.onRenameCommit(i),onClick:e=>e.stopPropagation(),className:`flex-1 rounded border border-neutral-700 bg-neutral-950 px-1 text-[11px] text-neutral-100 outline-none focus:border-neutral-500`}):(0,R.jsx)(`span`,{className:`truncate ${a?`text-neutral-200`:`text-neutral-300`}`,children:t.name}),t.truncated===!0&&(0,R.jsx)(`span`,{className:`ml-1 text-[10px] text-neutral-600`,children:`…`})]}),!s&&(0,R.jsxs)(`div`,{className:`hidden items-center gap-0.5 group-hover:flex`,children:[a&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`button`,{onClick:n=>{n.stopPropagation(),e.onCreate(i,t.path,`file`)},className:`rounded p-0.5 text-neutral-500 hover:bg-neutral-800 hover:text-neutral-200`,title:`New file in this folder`,children:(0,R.jsx)(Ce,{size:11})}),(0,R.jsx)(`button`,{onClick:n=>{n.stopPropagation(),e.onCreate(i,t.path,`folder`)},className:`rounded p-0.5 text-neutral-500 hover:bg-neutral-800 hover:text-neutral-200`,title:`New subfolder in this folder`,children:(0,R.jsx)(Te,{size:11})}),(0,R.jsx)(`button`,{onClick:t=>{t.stopPropagation(),e.onUpload(i)},className:`rounded p-0.5 text-neutral-500 hover:bg-neutral-800 hover:text-neutral-200`,title:`Upload into this folder`,children:(0,R.jsx)(tt,{size:11})})]}),(0,R.jsx)(`button`,{onClick:t=>{t.stopPropagation(),e.onDownload(i)},className:`rounded p-0.5 text-neutral-500 hover:bg-neutral-800 hover:text-neutral-200`,title:a?`Download folder as .tar.gz`:`Download file`,children:(0,R.jsx)(ye,{size:11})}),(0,R.jsx)(`button`,{onClick:n=>{n.stopPropagation(),e.onRenameStart(i,t.name)},className:`rounded p-0.5 text-neutral-500 hover:bg-neutral-800 hover:text-neutral-200`,title:`Rename`,children:(0,R.jsx)(Be,{size:11})}),(0,R.jsx)(`button`,{onClick:n=>{n.stopPropagation(),e.onDelete(i,t.name,a)},className:`rounded p-0.5 text-neutral-500 hover:bg-red-900/30 hover:text-red-300 light:hover:bg-red-100 light:hover:text-red-700`,title:`Delete`,children:(0,R.jsx)(Qe,{size:11})})]})]}),a&&o&&t.children!==void 0&&(0,R.jsx)(`ul`,{children:t.children.map(t=>(0,R.jsx)(TM,{...e,node:t,depth:n+1},t.path))})]})}function EM(e,t){return t===``?e:`${e}/${t.replaceAll(`\\`,`/`)}`}function DM(e,t){if(e!==t)return e.startsWith(`${t}/`)?e.slice(t.length+1):e}function OM(e,t){if(e?.kind!==`create`)return``;let n=DM(e.parentAbsPath,t),r=e.entryKind===`folder`?`folder`:`file`;return n===void 0?`New ${r}`:`New ${r} in ${n}/`}function kM(e,t){if(e?.kind!==`create`)return``;let n=DM(e.parentAbsPath,t),r=e.entryKind===`folder`?`Folder name`:`File name`;return n===void 0?`${r} (relative to project root)`:`${r} (in ${n}/)`}function AM(e){return e?.kind===`create`?e.entryKind===`folder`?`utils`:`index.ts`:``}function jM(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:e<1024*1024*1024?`${(e/(1024*1024)).toFixed(1)} MB`:`${(e/(1024*1024*1024)).toFixed(2)} GB`}var MM=`forge.editor.wrap.`,NM=[];function PM(e){let t=Math.max(e.lastIndexOf(`/`),e.lastIndexOf(`\\`)),n=t===-1?e:e.slice(t+1),r=n.lastIndexOf(`.`);return r<=0?``:n.slice(r+1).toLowerCase()}function FM(e){try{let t=localStorage.getItem(MM+e);if(t===`0`)return!1;if(t===`1`)return!0}catch{}return!0}function IM(e,t){try{localStorage.setItem(MM+e,t?`1`:`0`)}catch{}}var LM=(0,v.lazy)(()=>C(()=>import(`./CodeMirrorEditor-DOSPzCPa.js`).then(e=>({default:e.CodeMirrorEditor})),[]));function RM(){let e=ur(),t=ii(e=>e.openFiles),n=ii(e=>e.activePath),r=ii(e=>e.setActiveFile),i=ii(e=>e.closeFile),a=ii(e=>e.closeAllFiles),o=ii(e=>e.updateDraft),s=ii(e=>e.saveFile),c=ii(e=>e.reloadFile),l=ii(e=>e.externallyChanged),u=ii(e=>e.gitDiffByPath),d=t.find(e=>e.path===n),f=d===void 0?``:PM(d.path),[p,m]=(0,v.useState)(()=>FM(f));(0,v.useEffect)(()=>{m(FM(f))},[f]);let h=(0,v.useCallback)(()=>{m(e=>{let t=!e;return IM(f,t),t})},[f]);return(0,R.jsxs)(`div`,{className:`flex h-full flex-col bg-neutral-950 text-sm text-neutral-200`,children:[(0,R.jsx)(BM,{files:t,activePath:n,externallyChanged:l,onActivate:r,onClose:i,onCloseAll:a}),d===void 0?(0,R.jsx)(`div`,{className:`flex flex-1 items-center justify-center text-xs italic text-neutral-500`,children:`No file open. Click a file in the tree to start editing.`}):(0,R.jsxs)(R.Fragment,{children:[l[d.path]===!0&&(0,R.jsx)(VM,{path:d.path,onReload:()=>{e!==void 0&&c(e.id,d.path)},onDiscard:()=>ii.getState().dismissExternallyChanged(d.path)}),d.binary?(0,R.jsx)(`div`,{className:`flex flex-1 items-center justify-center px-6 text-center text-sm text-neutral-500`,children:d.loadingError??`Binary file.`}):(0,R.jsx)(v.Suspense,{fallback:(0,R.jsx)(zM,{}),children:(0,R.jsx)(LM,{file:d,wrap:p,diffChanges:u[d.path]??NM,onChange:e=>o(d.path,e),onSaveShortcut:()=>{e!==void 0&&s(e.id,d.path)},onConsumePendingNav:e=>ii.getState().consumePendingNav(e)},d.tabId)}),(0,R.jsx)(HM,{file:d,wrap:p,onToggleWrap:h,onSave:()=>{e!==void 0&&s(e.id,d.path)}})]})]})}function zM(){return(0,R.jsx)(`div`,{className:`flex flex-1 items-center justify-center text-xs italic text-neutral-500`,children:`Loading editor…`})}function BM({files:e,activePath:t,externallyChanged:n,onActivate:r,onClose:i,onCloseAll:a}){if(e.length===0)return null;let o=e.filter(e=>e.dirty).length;return(0,R.jsxs)(`div`,{className:`flex border-b border-neutral-800 bg-neutral-900/40`,children:[(0,R.jsx)(`button`,{onClick:()=>{o>0&&!window.confirm(`Close ${e.length} tab${e.length===1?``:`s`}? ${o} ha${o===1?`s`:`ve`} unsaved changes that will be lost.`)||a()},className:`flex shrink-0 items-center justify-center border-r border-neutral-800 px-2 py-1.5 text-neutral-500 hover:bg-neutral-800 hover:text-neutral-200`,title:`Close all ${e.length} tab${e.length===1?``:`s`}`,children:(0,R.jsx)(Ye,{size:14})}),(0,R.jsx)(`div`,{className:`flex flex-1 overflow-x-auto`,children:e.map(e=>{let a=e.path.split(`/`).pop()??e.path,o=e.path===t,s=n[e.path]===!0;return(0,R.jsxs)(`div`,{className:`group flex items-center gap-1 border-r border-neutral-800 px-3 py-1.5 text-xs ${o?`bg-neutral-950 text-neutral-100`:`text-neutral-400 hover:bg-neutral-900 hover:text-neutral-200`} ${s?`bg-amber-900/30 text-amber-200 light:bg-amber-100 light:text-amber-800`:``}`,title:s?`${e.path}\n\nExternal change while you have unsaved edits — open the tab to review.`:e.path,children:[(0,R.jsxs)(`button`,{onClick:()=>r(e.path),className:`truncate`,children:[s?(0,R.jsx)($e,{size:11,className:`mr-1 inline text-amber-400 light:text-amber-700`}):e.dirty?(0,R.jsx)(`span`,{className:`mr-1.5 inline-block h-2.5 w-2.5 rounded-full bg-amber-400 align-middle`,"aria-label":`Unsaved changes`,title:`Unsaved changes`}):null,a]}),(0,R.jsx)(`button`,{onClick:()=>i(e.path),className:`rounded p-1 text-neutral-600 hover:bg-neutral-800 hover:text-neutral-200`,title:`Close (any unsaved changes are lost)`,children:(0,R.jsx)(rt,{size:16})})]},e.tabId)})})]})}function VM({path:e,onReload:t,onDiscard:n}){return(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-amber-700/40 bg-amber-900/20 px-4 py-1.5 text-xs text-amber-200 light:border-amber-300 light:bg-amber-50 light:text-amber-800`,children:[(0,R.jsxs)(`span`,{children:[`File changed externally — local edits in this tab are stale. Reload from disk?`,(0,R.jsx)(`span`,{className:`ml-2 font-mono text-[10px] text-amber-400/70 light:text-amber-700/80`,children:e})]}),(0,R.jsxs)(`div`,{className:`flex gap-1`,children:[(0,R.jsx)(`button`,{onClick:t,className:`rounded border border-amber-700/50 px-2 py-0.5 hover:bg-amber-900/30 light:border-amber-400 light:hover:bg-amber-100`,children:`Reload`}),(0,R.jsx)(`button`,{onClick:n,className:`rounded border border-neutral-700 px-2 py-0.5 text-neutral-300 hover:border-neutral-500`,children:`Keep mine`})]})]})}function HM({file:e,wrap:t,onToggleWrap:n,onSave:r}){let i=e.dirty,a=e.saving,o=e.savedAt,s=e.saveError,c,l=`text-neutral-500`;s===void 0?a?c=`Saving…`:i?(c=`Unsaved changes`,l=`text-amber-400 light:text-amber-700`):o===void 0?c=`Up to date`:(c=`Saved ${new Date(o).toLocaleTimeString()}`,l=`text-emerald-500 light:text-emerald-700`):(c=`Save failed (${s}) — Cmd/Ctrl+S or Save to retry`,l=`text-rose-400 light:text-rose-700`);let u=(i||s!==void 0)&&!a&&!e.binary;return(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-t border-neutral-800 bg-neutral-900/40 px-3 py-1 text-[11px]`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(`span`,{className:`font-mono text-neutral-500`,children:e.language}),(0,R.jsxs)(`button`,{onClick:n,className:`flex items-center gap-1 rounded px-1 py-0.5 text-[10px] hover:bg-neutral-800 ${t?`text-neutral-300`:`text-neutral-500`}`,title:t?`Wrap on (click to switch to horizontal scroll, persisted per file extension)`:`Wrap off (click to enable wrap, persisted per file extension)`,children:[(0,R.jsx)(Ze,{size:11}),t?`wrap`:`no wrap`]})]}),(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(`span`,{className:l,children:c}),(0,R.jsxs)(`button`,{onClick:r,disabled:!u,className:`flex items-center gap-1 rounded border border-neutral-700 px-1.5 py-0.5 text-[10px] text-neutral-200 hover:border-neutral-500 disabled:cursor-not-allowed disabled:border-neutral-800 disabled:text-neutral-600`,title:`Save (Cmd/Ctrl+S)`,children:[(0,R.jsx)(Ge,{size:11}),`Save`]})]})]})}var UM=o(((e,t)=>{(function(n,r){if(typeof e==`object`&&typeof t==`object`)t.exports=r();else if(typeof define==`function`&&define.amd)define([],r);else{var i=r();for(var a in i)(typeof e==`object`?e:n)[a]=i[a]}})(globalThis,(()=>(()=>{var e={4567:function(e,t,n){var r=this&&this.__decorate||function(e,t,n,r){var i,a=arguments.length,o=a<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o},i=this&&this.__param||function(e,t){return function(n,r){t(n,r,e)}};Object.defineProperty(t,"__esModule",{value:!0}),t.AccessibilityManager=void 0;let a=n(9042),o=n(9924),s=n(844),c=n(4725),l=n(2585),u=n(3656),d=t.AccessibilityManager=class extends s.Disposable{constructor(e,t,n,r){super(),this._terminal=e,this._coreBrowserService=n,this._renderService=r,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce=``,this._accessibilityContainer=this._coreBrowserService.mainDocument.createElement(`div`),this._accessibilityContainer.classList.add(`xterm-accessibility`),this._rowContainer=this._coreBrowserService.mainDocument.createElement(`div`),this._rowContainer.setAttribute(`role`,`list`),this._rowContainer.classList.add(`xterm-accessibility-tree`),this._rowElements=[];for(let e=0;e<this._terminal.rows;e++)this._rowElements[e]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[e]);if(this._topBoundaryFocusListener=e=>this._handleBoundaryFocus(e,0),this._bottomBoundaryFocusListener=e=>this._handleBoundaryFocus(e,1),this._rowElements[0].addEventListener(`focus`,this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener(`focus`,this._bottomBoundaryFocusListener),this._refreshRowsDimensions(),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=this._coreBrowserService.mainDocument.createElement(`div`),this._liveRegion.classList.add(`live-region`),this._liveRegion.setAttribute(`aria-live`,`assertive`),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this.register(new o.TimeBasedDebouncer(this._renderRows.bind(this))),!this._terminal.element)throw Error(`Cannot enable accessibility before Terminal.open`);this._terminal.element.insertAdjacentElement(`afterbegin`,this._accessibilityContainer),this.register(this._terminal.onResize((e=>this._handleResize(e.rows)))),this.register(this._terminal.onRender((e=>this._refreshRows(e.start,e.end)))),this.register(this._terminal.onScroll((()=>this._refreshRows()))),this.register(this._terminal.onA11yChar((e=>this._handleChar(e)))),this.register(this._terminal.onLineFeed((()=>this._handleChar(`
366
366
  `)))),this.register(this._terminal.onA11yTab((e=>this._handleTab(e)))),this.register(this._terminal.onKey((e=>this._handleKey(e.key)))),this.register(this._terminal.onBlur((()=>this._clearLiveRegion()))),this.register(this._renderService.onDimensionsChange((()=>this._refreshRowsDimensions()))),this.register((0,u.addDisposableDomListener)(document,`selectionchange`,(()=>this._handleSelectionChange()))),this.register(this._coreBrowserService.onDprChange((()=>this._refreshRowsDimensions()))),this._refreshRows(),this.register((0,s.toDisposable)((()=>{this._accessibilityContainer.remove(),this._rowElements.length=0})))}_handleTab(e){for(let t=0;t<e;t++)this._handleChar(` `)}_handleChar(e){this._liveRegionLineCount<21&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
367
367
  `&&(this._liveRegionLineCount++,this._liveRegionLineCount===21&&(this._liveRegion.textContent+=a.tooMuchOutput)))}_clearLiveRegion(){this._liveRegion.textContent=``,this._liveRegionLineCount=0}_handleKey(e){this._clearLiveRegion(),/\p{Control}/u.test(e)||this._charsToConsume.push(e)}_refreshRows(e,t){this._liveRegionDebouncer.refresh(e,t,this._terminal.rows)}_renderRows(e,t){let n=this._terminal.buffer,r=n.lines.length.toString();for(let i=e;i<=t;i++){let e=n.lines.get(n.ydisp+i),t=[],a=e?.translateToString(!0,void 0,void 0,t)||``,o=(n.ydisp+i+1).toString(),s=this._rowElements[i];s&&(a.length===0?(s.innerText=`\xA0`,this._rowColumns.set(s,[0,1])):(s.textContent=a,this._rowColumns.set(s,t)),s.setAttribute(`aria-posinset`,o),s.setAttribute(`aria-setsize`,r))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce=``)}_handleBoundaryFocus(e,t){let n=e.target,r=this._rowElements[t===0?1:this._rowElements.length-2];if(n.getAttribute(`aria-posinset`)===(t===0?`1`:`${this._terminal.buffer.lines.length}`)||e.relatedTarget!==r)return;let i,a;if(t===0?(i=n,a=this._rowElements.pop(),this._rowContainer.removeChild(a)):(i=this._rowElements.shift(),a=n,this._rowContainer.removeChild(i)),i.removeEventListener(`focus`,this._topBoundaryFocusListener),a.removeEventListener(`focus`,this._bottomBoundaryFocusListener),t===0){let e=this._createAccessibilityTreeNode();this._rowElements.unshift(e),this._rowContainer.insertAdjacentElement(`afterbegin`,e)}else{let e=this._createAccessibilityTreeNode();this._rowElements.push(e),this._rowContainer.appendChild(e)}this._rowElements[0].addEventListener(`focus`,this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener(`focus`,this._bottomBoundaryFocusListener),this._terminal.scrollLines(t===0?-1:1),this._rowElements[t===0?1:this._rowElements.length-2].focus(),e.preventDefault(),e.stopImmediatePropagation()}_handleSelectionChange(){if(this._rowElements.length===0)return;let e=document.getSelection();if(!e)return;if(e.isCollapsed)return void(this._rowContainer.contains(e.anchorNode)&&this._terminal.clearSelection());if(!e.anchorNode||!e.focusNode)return void console.error(`anchorNode and/or focusNode are null`);let t={node:e.anchorNode,offset:e.anchorOffset},n={node:e.focusNode,offset:e.focusOffset};if((t.node.compareDocumentPosition(n.node)&Node.DOCUMENT_POSITION_PRECEDING||t.node===n.node&&t.offset>n.offset)&&([t,n]=[n,t]),t.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(t={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(t.node))return;let r=this._rowElements.slice(-1)[0];if(n.node.compareDocumentPosition(r)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(n={node:r,offset:r.textContent?.length??0}),!this._rowContainer.contains(n.node))return;let i=({node:e,offset:t})=>{let n=e instanceof Text?e.parentNode:e,r=parseInt(n?.getAttribute(`aria-posinset`),10)-1;if(isNaN(r))return console.warn(`row is invalid. Race condition?`),null;let i=this._rowColumns.get(n);if(!i)return console.warn(`columns is null. Race condition?`),null;let a=t<i.length?i[t]:i.slice(-1)[0]+1;return a>=this._terminal.cols&&(++r,a=0),{row:r,column:a}},a=i(t),o=i(n);if(a&&o){if(a.row>o.row||a.row===o.row&&a.column>=o.column)throw Error(`invalid range`);this._terminal.select(a.column,a.row,(o.row-a.row)*this._terminal.cols-a.column+o.column)}}_handleResize(e){this._rowElements[this._rowElements.length-1].removeEventListener(`focus`,this._bottomBoundaryFocusListener);for(let e=this._rowContainer.children.length;e<this._terminal.rows;e++)this._rowElements[e]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[e]);for(;this._rowElements.length>e;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener(`focus`,this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){let e=this._coreBrowserService.mainDocument.createElement(`div`);return e.setAttribute(`role`,`listitem`),e.tabIndex=-1,this._refreshRowDimensions(e),e}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){this._accessibilityContainer.style.width=`${this._renderService.dimensions.css.canvas.width}px`,this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let e=0;e<this._terminal.rows;e++)this._refreshRowDimensions(this._rowElements[e])}}_refreshRowDimensions(e){e.style.height=`${this._renderService.dimensions.css.cell.height}px`}};t.AccessibilityManager=d=r([i(1,l.IInstantiationService),i(2,c.ICoreBrowserService),i(3,c.IRenderService)],d)},3614:(e,t)=>{function n(e){return e.replace(/\r?\n/g,`\r`)}function r(e,t){return t?`\x1B[200~`+e+`\x1B[201~`:e}function i(e,t,i,a){e=r(e=n(e),i.decPrivateModes.bracketedPasteMode&&!0!==a.rawOptions.ignoreBracketedPasteMode),i.triggerDataEvent(e,!0),t.value=``}function a(e,t,n){let r=n.getBoundingClientRect(),i=e.clientX-r.left-10,a=e.clientY-r.top-10;t.style.width=`20px`,t.style.height=`20px`,t.style.left=`${i}px`,t.style.top=`${a}px`,t.style.zIndex=`1000`,t.focus()}Object.defineProperty(t,"__esModule",{value:!0}),t.rightClickHandler=t.moveTextAreaUnderMouseCursor=t.paste=t.handlePasteEvent=t.copyHandler=t.bracketTextForPaste=t.prepareTextForTerminal=void 0,t.prepareTextForTerminal=n,t.bracketTextForPaste=r,t.copyHandler=function(e,t){e.clipboardData&&e.clipboardData.setData(`text/plain`,t.selectionText),e.preventDefault()},t.handlePasteEvent=function(e,t,n,r){e.stopPropagation(),e.clipboardData&&i(e.clipboardData.getData(`text/plain`),t,n,r)},t.paste=i,t.moveTextAreaUnderMouseCursor=a,t.rightClickHandler=function(e,t,n,r,i){a(e,t,n),i&&r.rightClickSelect(e),t.value=r.selectionText,t.select()}},7239:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ColorContrastCache=void 0;let r=n(1505);t.ColorContrastCache=class{constructor(){this._color=new r.TwoKeyMap,this._css=new r.TwoKeyMap}setCss(e,t,n){this._css.set(e,t,n)}getCss(e,t){return this._css.get(e,t)}setColor(e,t,n){this._color.set(e,t,n)}getColor(e,t){return this._color.get(e,t)}clear(){this._color.clear(),this._css.clear()}}},3656:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.addDisposableDomListener=void 0,t.addDisposableDomListener=function(e,t,n,r){e.addEventListener(t,n,r);let i=!1;return{dispose:()=>{i||(i=!0,e.removeEventListener(t,n,r))}}}},3551:function(e,t,n){var r=this&&this.__decorate||function(e,t,n,r){var i,a=arguments.length,o=a<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o},i=this&&this.__param||function(e,t){return function(n,r){t(n,r,e)}};Object.defineProperty(t,"__esModule",{value:!0}),t.Linkifier=void 0;let a=n(3656),o=n(8460),s=n(844),c=n(2585),l=n(4725),u=t.Linkifier=class extends s.Disposable{get currentLink(){return this._currentLink}constructor(e,t,n,r,i){super(),this._element=e,this._mouseService=t,this._renderService=n,this._bufferService=r,this._linkProviderService=i,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this.register(new o.EventEmitter),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this.register(new o.EventEmitter),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this.register((0,s.getDisposeArrayDisposable)(this._linkCacheDisposables)),this.register((0,s.toDisposable)((()=>{this._lastMouseEvent=void 0,this._activeProviderReplies?.clear()}))),this.register(this._bufferService.onResize((()=>{this._clearCurrentLink(),this._wasResized=!0}))),this.register((0,a.addDisposableDomListener)(this._element,`mouseleave`,(()=>{this._isMouseOut=!0,this._clearCurrentLink()}))),this.register((0,a.addDisposableDomListener)(this._element,`mousemove`,this._handleMouseMove.bind(this))),this.register((0,a.addDisposableDomListener)(this._element,`mousedown`,this._handleMouseDown.bind(this))),this.register((0,a.addDisposableDomListener)(this._element,`mouseup`,this._handleMouseUp.bind(this)))}_handleMouseMove(e){this._lastMouseEvent=e;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);if(!t)return;this._isMouseOut=!1;let n=e.composedPath();for(let e=0;e<n.length;e++){let t=n[e];if(t.classList.contains(`xterm`))break;if(t.classList.contains(`xterm-hover`))return}this._lastBufferCell&&t.x===this._lastBufferCell.x&&t.y===this._lastBufferCell.y||(this._handleHover(t),this._lastBufferCell=t)}_handleHover(e){if(this._activeLine!==e.y||this._wasResized)return this._clearCurrentLink(),this._askForLink(e,!1),void(this._wasResized=!1);this._currentLink&&this._linkAtPosition(this._currentLink.link,e)||(this._clearCurrentLink(),this._askForLink(e,!0))}_askForLink(e,t){this._activeProviderReplies&&t||(this._activeProviderReplies?.forEach((e=>{e?.forEach((e=>{e.link.dispose&&e.link.dispose()}))})),this._activeProviderReplies=new Map,this._activeLine=e.y);let n=!1;for(let[r,i]of this._linkProviderService.linkProviders.entries())t?this._activeProviderReplies?.get(r)&&(n=this._checkLinkProviderResult(r,e,n)):i.provideLinks(e.y,(t=>{if(this._isMouseOut)return;let i=t?.map((e=>({link:e})));this._activeProviderReplies?.set(r,i),n=this._checkLinkProviderResult(r,e,n),this._activeProviderReplies?.size===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)}))}_removeIntersectingLinks(e,t){let n=new Set;for(let r=0;r<t.size;r++){let i=t.get(r);if(i)for(let t=0;t<i.length;t++){let r=i[t],a=r.link.range.start.y<e?0:r.link.range.start.x,o=r.link.range.end.y>e?this._bufferService.cols:r.link.range.end.x;for(let e=a;e<=o;e++){if(n.has(e)){i.splice(t--,1);break}n.add(e)}}}}_checkLinkProviderResult(e,t,n){if(!this._activeProviderReplies)return n;let r=this._activeProviderReplies.get(e),i=!1;for(let t=0;t<e;t++)this._activeProviderReplies.has(t)&&!this._activeProviderReplies.get(t)||(i=!0);if(!i&&r){let e=r.find((e=>this._linkAtPosition(e.link,t)));e&&(n=!0,this._handleNewLink(e))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!n)for(let e=0;e<this._activeProviderReplies.size;e++){let r=this._activeProviderReplies.get(e)?.find((e=>this._linkAtPosition(e.link,t)));if(r){n=!0,this._handleNewLink(r);break}}return n}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink===this._currentLink&&this._linkAtPosition(this._currentLink.link,t)&&this._currentLink.link.activate(e,this._currentLink.link.text)}_clearCurrentLink(e,t){this._currentLink&&this._lastMouseEvent&&(!e||!t||this._currentLink.link.range.start.y>=e&&this._currentLink.link.range.end.y<=t)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,(0,s.disposeArray)(this._linkCacheDisposables))}_handleNewLink(e){if(!this._lastMouseEvent)return;let t=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);t&&this._linkAtPosition(e.link,t)&&(this._currentLink=e,this._currentLink.state={decorations:{underline:e.link.decorations===void 0||e.link.decorations.underline,pointerCursor:e.link.decorations===void 0||e.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,e.link,this._lastMouseEvent),e.link.decorations={},Object.defineProperties(e.link.decorations,{pointerCursor:{get:()=>this._currentLink?.state?.decorations.pointerCursor,set:e=>{this._currentLink?.state&&this._currentLink.state.decorations.pointerCursor!==e&&(this._currentLink.state.decorations.pointerCursor=e,this._currentLink.state.isHovered&&this._element.classList.toggle(`xterm-cursor-pointer`,e))}},underline:{get:()=>this._currentLink?.state?.decorations.underline,set:t=>{this._currentLink?.state&&this._currentLink?.state?.decorations.underline!==t&&(this._currentLink.state.decorations.underline=t,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,t))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange((e=>{if(!this._currentLink)return;let t=e.start===0?0:e.start+1+this._bufferService.buffer.ydisp,n=this._bufferService.buffer.ydisp+1+e.end;if(this._currentLink.link.range.start.y>=t&&this._currentLink.link.range.end.y<=n&&(this._clearCurrentLink(t,n),this._lastMouseEvent)){let e=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);e&&this._askForLink(e,!1)}}))))}_linkHover(e,t,n){this._currentLink?.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!0),this._currentLink.state.decorations.pointerCursor&&e.classList.add(`xterm-cursor-pointer`)),t.hover&&t.hover(n,t.text)}_fireUnderlineEvent(e,t){let n=e.range,r=this._bufferService.buffer.ydisp,i=this._createLinkUnderlineEvent(n.start.x-1,n.start.y-r-1,n.end.x,n.end.y-r-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(i)}_linkLeave(e,t,n){this._currentLink?.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!1),this._currentLink.state.decorations.pointerCursor&&e.classList.remove(`xterm-cursor-pointer`)),t.leave&&t.leave(n,t.text)}_linkAtPosition(e,t){let n=e.range.start.y*this._bufferService.cols+e.range.start.x,r=e.range.end.y*this._bufferService.cols+e.range.end.x,i=t.y*this._bufferService.cols+t.x;return n<=i&&i<=r}_positionFromMouseEvent(e,t,n){let r=n.getCoords(e,t,this._bufferService.cols,this._bufferService.rows);if(r)return{x:r[0],y:r[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,t,n,r,i){return{x1:e,y1:t,x2:n,y2:r,cols:this._bufferService.cols,fg:i}}};t.Linkifier=u=r([i(1,l.IMouseService),i(2,l.IRenderService),i(3,c.IBufferService),i(4,l.ILinkProviderService)],u)},9042:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.tooMuchOutput=t.promptLabel=void 0,t.promptLabel=`Terminal input`,t.tooMuchOutput=`Too much output to announce, navigate to rows manually to read`},3730:function(e,t,n){var r=this&&this.__decorate||function(e,t,n,r){var i,a=arguments.length,o=a<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o},i=this&&this.__param||function(e,t){return function(n,r){t(n,r,e)}};Object.defineProperty(t,"__esModule",{value:!0}),t.OscLinkProvider=void 0;let a=n(511),o=n(2585),s=t.OscLinkProvider=class{constructor(e,t,n){this._bufferService=e,this._optionsService=t,this._oscLinkService=n}provideLinks(e,t){let n=this._bufferService.buffer.lines.get(e-1);if(!n)return void t(void 0);let r=[],i=this._optionsService.rawOptions.linkHandler,o=new a.CellData,s=n.getTrimmedLength(),l=-1,u=-1,d=!1;for(let t=0;t<s;t++)if(u!==-1||n.hasContent(t)){if(n.loadCell(t,o),o.hasExtendedAttrs()&&o.extended.urlId){if(u===-1){u=t,l=o.extended.urlId;continue}d=o.extended.urlId!==l}else u!==-1&&(d=!0);if(d||u!==-1&&t===s-1){let n=this._oscLinkService.getLinkData(l)?.uri;if(n){let a={start:{x:u+1,y:e},end:{x:t+(d||t!==s-1?0:1),y:e}},o=!1;if(!i?.allowNonHttpProtocols)try{let e=new URL(n);[`http:`,`https:`].includes(e.protocol)||(o=!0)}catch{o=!0}o||r.push({text:n,range:a,activate:(e,t)=>i?i.activate(e,t,a):c(0,t),hover:(e,t)=>i?.hover?.(e,t,a),leave:(e,t)=>i?.leave?.(e,t,a)})}d=!1,o.hasExtendedAttrs()&&o.extended.urlId?(u=t,l=o.extended.urlId):(u=-1,l=-1)}}t(r)}};function c(e,t){if(confirm(`Do you want to navigate to ${t}?\n\nWARNING: This link could potentially be dangerous`)){let e=window.open();if(e){try{e.opener=null}catch{}e.location.href=t}else console.warn(`Opening link blocked as opener could not be cleared`)}}t.OscLinkProvider=s=r([i(0,o.IBufferService),i(1,o.IOptionsService),i(2,o.IOscLinkService)],s)},6193:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.RenderDebouncer=void 0,t.RenderDebouncer=class{constructor(e,t){this._renderCallback=e,this._coreBrowserService=t,this._refreshCallbacks=[]}dispose(){this._animationFrame&&=(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),void 0)}addRefreshCallback(e){return this._refreshCallbacks.push(e),this._animationFrame||=this._coreBrowserService.window.requestAnimationFrame((()=>this._innerRefresh())),this._animationFrame}refresh(e,t,n){this._rowCount=n,e=e===void 0?0:e,t=t===void 0?this._rowCount-1:t,this._rowStart=this._rowStart===void 0?e:Math.min(this._rowStart,e),this._rowEnd=this._rowEnd===void 0?t:Math.max(this._rowEnd,t),this._animationFrame||=this._coreBrowserService.window.requestAnimationFrame((()=>this._innerRefresh()))}_innerRefresh(){if(this._animationFrame=void 0,this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return void this._runRefreshCallbacks();let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(let e of this._refreshCallbacks)e(0);this._refreshCallbacks=[]}}},3236:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Terminal=void 0;let r=n(3614),i=n(3656),a=n(3551),o=n(9042),s=n(3730),c=n(1680),l=n(3107),u=n(5744),d=n(2950),f=n(1296),p=n(428),m=n(4269),h=n(5114),g=n(8934),_=n(3230),v=n(9312),y=n(4725),b=n(6731),x=n(8055),S=n(8969),C=n(8460),w=n(844),T=n(6114),E=n(8437),D=n(2584),O=n(7399),k=n(5941),ee=n(9074),A=n(2585),te=n(5435),ne=n(4567),re=n(779);class ie extends S.CoreTerminal{get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}constructor(e={}){super(e),this.browser=T,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this.register(new w.MutableDisposable),this._onCursorMove=this.register(new C.EventEmitter),this.onCursorMove=this._onCursorMove.event,this._onKey=this.register(new C.EventEmitter),this.onKey=this._onKey.event,this._onRender=this.register(new C.EventEmitter),this.onRender=this._onRender.event,this._onSelectionChange=this.register(new C.EventEmitter),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this.register(new C.EventEmitter),this.onTitleChange=this._onTitleChange.event,this._onBell=this.register(new C.EventEmitter),this.onBell=this._onBell.event,this._onFocus=this.register(new C.EventEmitter),this._onBlur=this.register(new C.EventEmitter),this._onA11yCharEmitter=this.register(new C.EventEmitter),this._onA11yTabEmitter=this.register(new C.EventEmitter),this._onWillOpen=this.register(new C.EventEmitter),this._setup(),this._decorationService=this._instantiationService.createInstance(ee.DecorationService),this._instantiationService.setService(A.IDecorationService,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(re.LinkProviderService),this._instantiationService.setService(y.ILinkProviderService,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(s.OscLinkProvider)),this.register(this._inputHandler.onRequestBell((()=>this._onBell.fire()))),this.register(this._inputHandler.onRequestRefreshRows(((e,t)=>this.refresh(e,t)))),this.register(this._inputHandler.onRequestSendFocus((()=>this._reportFocus()))),this.register(this._inputHandler.onRequestReset((()=>this.reset()))),this.register(this._inputHandler.onRequestWindowsOptionsReport((e=>this._reportWindowsOptions(e)))),this.register(this._inputHandler.onColor((e=>this._handleColorEvent(e)))),this.register((0,C.forwardEvent)(this._inputHandler.onCursorMove,this._onCursorMove)),this.register((0,C.forwardEvent)(this._inputHandler.onTitleChange,this._onTitleChange)),this.register((0,C.forwardEvent)(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this.register((0,C.forwardEvent)(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this.register(this._bufferService.onResize((e=>this._afterResize(e.cols,e.rows)))),this.register((0,w.toDisposable)((()=>{this._customKeyEventHandler=void 0,this.element?.parentNode?.removeChild(this.element)})))}_handleColorEvent(e){if(this._themeService)for(let t of e){let e,n=``;switch(t.index){case 256:e=`foreground`,n=`10`;break;case 257:e=`background`,n=`11`;break;case 258:e=`cursor`,n=`12`;break;default:e=`ansi`,n=`4;`+t.index}switch(t.type){case 0:let r=x.color.toColorRGB(e===`ansi`?this._themeService.colors.ansi[t.index]:this._themeService.colors[e]);this.coreService.triggerDataEvent(`${D.C0.ESC}]${n};${(0,k.toRgbString)(r)}${D.C1_ESCAPED.ST}`);break;case 1:if(e===`ansi`)this._themeService.modifyColors((e=>e.ansi[t.index]=x.channels.toColor(...t.color)));else{let n=e;this._themeService.modifyColors((e=>e[n]=x.channels.toColor(...t.color)))}break;case 2:this._themeService.restoreColor(t.index)}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(e){e?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(ne.AccessibilityManager,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(D.C0.ESC+`[I`),this.element.classList.add(`focus`),this._showCursor(),this._onFocus.fire()}blur(){return this.textarea?.blur()}_handleTextAreaBlur(){this.textarea.value=``,this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(D.C0.ESC+`[O`),this.element.classList.remove(`focus`),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let e=this.buffer.ybase+this.buffer.y,t=this.buffer.lines.get(e);if(!t)return;let n=Math.min(this.buffer.x,this.cols-1),r=this._renderService.dimensions.css.cell.height,i=t.getWidth(n),a=this._renderService.dimensions.css.cell.width*i,o=this.buffer.y*this._renderService.dimensions.css.cell.height,s=n*this._renderService.dimensions.css.cell.width;this.textarea.style.left=s+`px`,this.textarea.style.top=o+`px`,this.textarea.style.width=a+`px`,this.textarea.style.height=r+`px`,this.textarea.style.lineHeight=r+`px`,this.textarea.style.zIndex=`-5`}_initGlobal(){this._bindKeys(),this.register((0,i.addDisposableDomListener)(this.element,`copy`,(e=>{this.hasSelection()&&(0,r.copyHandler)(e,this._selectionService)})));let e=e=>(0,r.handlePasteEvent)(e,this.textarea,this.coreService,this.optionsService);this.register((0,i.addDisposableDomListener)(this.textarea,`paste`,e)),this.register((0,i.addDisposableDomListener)(this.element,`paste`,e)),T.isFirefox?this.register((0,i.addDisposableDomListener)(this.element,`mousedown`,(e=>{e.button===2&&(0,r.rightClickHandler)(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)}))):this.register((0,i.addDisposableDomListener)(this.element,`contextmenu`,(e=>{(0,r.rightClickHandler)(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)}))),T.isLinux&&this.register((0,i.addDisposableDomListener)(this.element,`auxclick`,(e=>{e.button===1&&(0,r.moveTextAreaUnderMouseCursor)(e,this.textarea,this.screenElement)})))}_bindKeys(){this.register((0,i.addDisposableDomListener)(this.textarea,`keyup`,(e=>this._keyUp(e)),!0)),this.register((0,i.addDisposableDomListener)(this.textarea,`keydown`,(e=>this._keyDown(e)),!0)),this.register((0,i.addDisposableDomListener)(this.textarea,`keypress`,(e=>this._keyPress(e)),!0)),this.register((0,i.addDisposableDomListener)(this.textarea,`compositionstart`,(()=>this._compositionHelper.compositionstart()))),this.register((0,i.addDisposableDomListener)(this.textarea,`compositionupdate`,(e=>this._compositionHelper.compositionupdate(e)))),this.register((0,i.addDisposableDomListener)(this.textarea,`compositionend`,(()=>this._compositionHelper.compositionend()))),this.register((0,i.addDisposableDomListener)(this.textarea,`input`,(e=>this._inputEvent(e)),!0)),this.register(this.onRender((()=>this._compositionHelper.updateCompositionElements())))}open(e){if(!e)throw Error(`Terminal requires a parent element.`);if(e.isConnected||this._logService.debug(`Terminal.open was called on an element that was not attached to the DOM`),this.element?.ownerDocument.defaultView&&this._coreBrowserService)return void(this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView));this._document=e.ownerDocument,this.options.documentOverride&&this.options.documentOverride instanceof Document&&(this._document=this.optionsService.rawOptions.documentOverride),this.element=this._document.createElement(`div`),this.element.dir=`ltr`,this.element.classList.add(`terminal`),this.element.classList.add(`xterm`),e.appendChild(this.element);let t=this._document.createDocumentFragment();this._viewportElement=this._document.createElement(`div`),this._viewportElement.classList.add(`xterm-viewport`),t.appendChild(this._viewportElement),this._viewportScrollArea=this._document.createElement(`div`),this._viewportScrollArea.classList.add(`xterm-scroll-area`),this._viewportElement.appendChild(this._viewportScrollArea),this.screenElement=this._document.createElement(`div`),this.screenElement.classList.add(`xterm-screen`),this.register((0,i.addDisposableDomListener)(this.screenElement,`mousemove`,(e=>this.updateCursorStyle(e)))),this._helperContainer=this._document.createElement(`div`),this._helperContainer.classList.add(`xterm-helpers`),this.screenElement.appendChild(this._helperContainer),t.appendChild(this.screenElement),this.textarea=this._document.createElement(`textarea`),this.textarea.classList.add(`xterm-helper-textarea`),this.textarea.setAttribute(`aria-label`,o.promptLabel),T.isChromeOS||this.textarea.setAttribute(`aria-multiline`,`false`),this.textarea.setAttribute(`autocorrect`,`off`),this.textarea.setAttribute(`autocapitalize`,`off`),this.textarea.setAttribute(`spellcheck`,`false`),this.textarea.tabIndex=0,this._coreBrowserService=this.register(this._instantiationService.createInstance(h.CoreBrowserService,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<`u`?window.document:null)),this._instantiationService.setService(y.ICoreBrowserService,this._coreBrowserService),this.register((0,i.addDisposableDomListener)(this.textarea,`focus`,(e=>this._handleTextAreaFocus(e)))),this.register((0,i.addDisposableDomListener)(this.textarea,`blur`,(()=>this._handleTextAreaBlur()))),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(p.CharSizeService,this._document,this._helperContainer),this._instantiationService.setService(y.ICharSizeService,this._charSizeService),this._themeService=this._instantiationService.createInstance(b.ThemeService),this._instantiationService.setService(y.IThemeService,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(m.CharacterJoinerService),this._instantiationService.setService(y.ICharacterJoinerService,this._characterJoinerService),this._renderService=this.register(this._instantiationService.createInstance(_.RenderService,this.rows,this.screenElement)),this._instantiationService.setService(y.IRenderService,this._renderService),this.register(this._renderService.onRenderedViewportChange((e=>this._onRender.fire(e)))),this.onResize((e=>this._renderService.resize(e.cols,e.rows))),this._compositionView=this._document.createElement(`div`),this._compositionView.classList.add(`composition-view`),this._compositionHelper=this._instantiationService.createInstance(d.CompositionHelper,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(g.MouseService),this._instantiationService.setService(y.IMouseService,this._mouseService),this.linkifier=this.register(this._instantiationService.createInstance(a.Linkifier,this.screenElement)),this.element.appendChild(t);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this.viewport=this._instantiationService.createInstance(c.Viewport,this._viewportElement,this._viewportScrollArea),this.viewport.onRequestScrollLines((e=>this.scrollLines(e.amount,e.suppressScrollEvent,1))),this.register(this._inputHandler.onRequestSyncScrollBar((()=>this.viewport.syncScrollArea()))),this.register(this.viewport),this.register(this.onCursorMove((()=>{this._renderService.handleCursorMove(),this._syncTextArea()}))),this.register(this.onResize((()=>this._renderService.handleResize(this.cols,this.rows)))),this.register(this.onBlur((()=>this._renderService.handleBlur()))),this.register(this.onFocus((()=>this._renderService.handleFocus()))),this.register(this._renderService.onDimensionsChange((()=>this.viewport.syncScrollArea()))),this._selectionService=this.register(this._instantiationService.createInstance(v.SelectionService,this.element,this.screenElement,this.linkifier)),this._instantiationService.setService(y.ISelectionService,this._selectionService),this.register(this._selectionService.onRequestScrollLines((e=>this.scrollLines(e.amount,e.suppressScrollEvent)))),this.register(this._selectionService.onSelectionChange((()=>this._onSelectionChange.fire()))),this.register(this._selectionService.onRequestRedraw((e=>this._renderService.handleSelectionChanged(e.start,e.end,e.columnSelectMode)))),this.register(this._selectionService.onLinuxMouseSelection((e=>{this.textarea.value=e,this.textarea.focus(),this.textarea.select()}))),this.register(this._onScroll.event((e=>{this.viewport.syncScrollArea(),this._selectionService.refresh()}))),this.register((0,i.addDisposableDomListener)(this._viewportElement,`scroll`,(()=>this._selectionService.refresh()))),this.register(this._instantiationService.createInstance(l.BufferDecorationRenderer,this.screenElement)),this.register((0,i.addDisposableDomListener)(this.element,`mousedown`,(e=>this._selectionService.handleMouseDown(e)))),this.coreMouseService.areMouseEventsActive?(this._selectionService.disable(),this.element.classList.add(`enable-mouse-events`)):this._selectionService.enable(),this.options.screenReaderMode&&(this._accessibilityManager.value=this._instantiationService.createInstance(ne.AccessibilityManager,this)),this.register(this.optionsService.onSpecificOptionChange(`screenReaderMode`,(e=>this._handleScreenReaderModeOptionChange(e)))),this.options.overviewRulerWidth&&(this._overviewRulerRenderer=this.register(this._instantiationService.createInstance(u.OverviewRulerRenderer,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange(`overviewRulerWidth`,(e=>{!this._overviewRulerRenderer&&e&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this.register(this._instantiationService.createInstance(u.OverviewRulerRenderer,this._viewportElement,this.screenElement)))})),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(f.DomRenderer,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function n(t){let n=e._mouseService.getMouseReportCoords(t,e.screenElement);if(!n)return!1;let r,i;switch(t.overrideType||t.type){case`mousemove`:i=32,t.buttons===void 0?(r=3,t.button!==void 0&&(r=t.button<3?t.button:3)):r=1&t.buttons?0:4&t.buttons?1:2&t.buttons?2:3;break;case`mouseup`:i=0,r=t.button<3?t.button:3;break;case`mousedown`:i=1,r=t.button<3?t.button:3;break;case`wheel`:if(e._customWheelEventHandler&&!1===e._customWheelEventHandler(t)||e.viewport.getLinesScrolled(t)===0)return!1;i=t.deltaY<0?0:1,r=4;break;default:return!1}return!(i===void 0||r===void 0||r>4)&&e.coreMouseService.triggerMouseEvent({col:n.col,row:n.row,x:n.x,y:n.y,button:r,action:i,ctrl:t.ctrlKey,alt:t.altKey,shift:t.shiftKey})}let r={mouseup:null,wheel:null,mousedrag:null,mousemove:null},a={mouseup:e=>(n(e),e.buttons||(this._document.removeEventListener(`mouseup`,r.mouseup),r.mousedrag&&this._document.removeEventListener(`mousemove`,r.mousedrag)),this.cancel(e)),wheel:e=>(n(e),this.cancel(e,!0)),mousedrag:e=>{e.buttons&&n(e)},mousemove:e=>{e.buttons||n(e)}};this.register(this.coreMouseService.onProtocolChange((e=>{e?(this.optionsService.rawOptions.logLevel===`debug`&&this._logService.debug(`Binding to mouse events:`,this.coreMouseService.explainEvents(e)),this.element.classList.add(`enable-mouse-events`),this._selectionService.disable()):(this._logService.debug(`Unbinding from mouse events.`),this.element.classList.remove(`enable-mouse-events`),this._selectionService.enable()),8&e?r.mousemove||=(t.addEventListener(`mousemove`,a.mousemove),a.mousemove):(t.removeEventListener(`mousemove`,r.mousemove),r.mousemove=null),16&e?r.wheel||=(t.addEventListener(`wheel`,a.wheel,{passive:!1}),a.wheel):(t.removeEventListener(`wheel`,r.wheel),r.wheel=null),2&e?r.mouseup||=a.mouseup:(this._document.removeEventListener(`mouseup`,r.mouseup),r.mouseup=null),4&e?r.mousedrag||=a.mousedrag:(this._document.removeEventListener(`mousemove`,r.mousedrag),r.mousedrag=null)}))),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this.register((0,i.addDisposableDomListener)(t,`mousedown`,(e=>{if(e.preventDefault(),this.focus(),this.coreMouseService.areMouseEventsActive&&!this._selectionService.shouldForceSelection(e))return n(e),r.mouseup&&this._document.addEventListener(`mouseup`,r.mouseup),r.mousedrag&&this._document.addEventListener(`mousemove`,r.mousedrag),this.cancel(e)}))),this.register((0,i.addDisposableDomListener)(t,`wheel`,(e=>{if(!r.wheel){if(this._customWheelEventHandler&&!1===this._customWheelEventHandler(e))return!1;if(!this.buffer.hasScrollback){let t=this.viewport.getLinesScrolled(e);if(t===0)return;let n=D.C0.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?`O`:`[`)+(e.deltaY<0?`A`:`B`),r=``;for(let e=0;e<Math.abs(t);e++)r+=n;return this.coreService.triggerDataEvent(r,!0),this.cancel(e,!0)}return this.viewport.handleWheel(e)?this.cancel(e):void 0}}),{passive:!1})),this.register((0,i.addDisposableDomListener)(t,`touchstart`,(e=>{if(!this.coreMouseService.areMouseEventsActive)return this.viewport.handleTouchStart(e),this.cancel(e)}),{passive:!0})),this.register((0,i.addDisposableDomListener)(t,`touchmove`,(e=>{if(!this.coreMouseService.areMouseEventsActive)return this.viewport.handleTouchMove(e)?void 0:this.cancel(e)}),{passive:!1}))}refresh(e,t){this._renderService?.refreshRows(e,t)}updateCursorStyle(e){this._selectionService?.shouldColumnSelect(e)?this.element.classList.add(`column-select`):this.element.classList.remove(`column-select`)}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines(e,t,n=0){n===1?(super.scrollLines(e,t,n),this.refresh(0,this.rows-1)):this.viewport?.scrollLines(e)}paste(e){(0,r.paste)(e,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(e){this._customKeyEventHandler=e}attachCustomWheelEventHandler(e){this._customWheelEventHandler=e}registerLinkProvider(e){return this._linkProviderService.registerLinkProvider(e)}registerCharacterJoiner(e){if(!this._characterJoinerService)throw Error(`Terminal must be opened first`);let t=this._characterJoinerService.register(e);return this.refresh(0,this.rows-1),t}deregisterCharacterJoiner(e){if(!this._characterJoinerService)throw Error(`Terminal must be opened first`);this._characterJoinerService.deregister(e)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(e){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+e)}registerDecoration(e){return this._decorationService.registerDecoration(e)}hasSelection(){return!!this._selectionService&&this._selectionService.hasSelection}select(e,t,n){this._selectionService.setSelection(e,t,n)}getSelection(){return this._selectionService?this._selectionService.selectionText:``}getSelectionPosition(){if(this._selectionService&&this._selectionService.hasSelection)return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){this._selectionService?.clearSelection()}selectAll(){this._selectionService?.selectAll()}selectLines(e,t){this._selectionService?.selectLines(e,t)}_keyDown(e){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&!1===this._customKeyEventHandler(e))return!1;let t=this.browser.isMac&&this.options.macOptionIsMeta&&e.altKey;if(!t&&!this._compositionHelper.keydown(e))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(),!1;t||e.key!==`Dead`&&e.key!==`AltGraph`||(this._unprocessedDeadKey=!0);let n=(0,O.evaluateKeyboardEvent)(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),n.type===3||n.type===2){let t=this.rows-1;return this.scrollLines(n.type===2?-t:t),this.cancel(e,!0)}return n.type===1&&this.selectAll(),!!this._isThirdLevelShift(this.browser,e)||(n.cancel&&this.cancel(e,!0),!n.key||!!(e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.key.length===1&&e.key.charCodeAt(0)>=65&&e.key.charCodeAt(0)<=90)||(this._unprocessedDeadKey?(this._unprocessedDeadKey=!1,!0):(n.key!==D.C0.ETX&&n.key!==D.C0.CR||(this.textarea.value=``),this._onKey.fire({key:n.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(n.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey?this.cancel(e,!0):void(this._keyDownHandled=!0))))}_isThirdLevelShift(e,t){let n=e.isMac&&!this.options.macOptionIsMeta&&t.altKey&&!t.ctrlKey&&!t.metaKey||e.isWindows&&t.altKey&&t.ctrlKey&&!t.metaKey||e.isWindows&&t.getModifierState(`AltGraph`);return t.type===`keypress`?n:n&&(!t.keyCode||t.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,this._customKeyEventHandler&&!1===this._customKeyEventHandler(e)||(function(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}(e)||this.focus(),this.updateCursorStyle(e),this._keyPressHandled=!1)}_keyPress(e){let t;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&!1===this._customKeyEventHandler(e))return!1;if(this.cancel(e),e.charCode)t=e.charCode;else if(e.which===null||e.which===void 0)t=e.keyCode;else{if(e.which===0||e.charCode===0)return!1;t=e.which}return!(!t||(e.altKey||e.ctrlKey||e.metaKey)&&!this._isThirdLevelShift(this.browser,e)||(t=String.fromCharCode(t),this._onKey.fire({key:t,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(t,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,0))}_inputEvent(e){if(e.data&&e.inputType===`insertText`&&(!e.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;let t=e.data;return this.coreService.triggerDataEvent(t,!0),this.cancel(e),!0}return!1}resize(e,t){e!==this.cols||t!==this.rows?super.resize(e,t):this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure()}_afterResize(e,t){this._charSizeService?.measure(),this.viewport?.syncScrollArea(!0)}clear(){if(this.buffer.ybase!==0||this.buffer.y!==0){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let e=1;e<this.rows;e++)this.buffer.lines.push(this.buffer.getBlankLine(E.DEFAULT_ATTR_DATA));this._onScroll.fire({position:this.buffer.ydisp,source:0}),this.viewport?.reset(),this.refresh(0,this.rows-1)}}reset(){this.options.rows=this.rows,this.options.cols=this.cols;let e=this._customKeyEventHandler;this._setup(),super.reset(),this._selectionService?.reset(),this._decorationService.reset(),this.viewport?.reset(),this._customKeyEventHandler=e,this.refresh(0,this.rows-1)}clearTextureAtlas(){this._renderService?.clearTextureAtlas()}_reportFocus(){this.element?.classList.contains(`focus`)?this.coreService.triggerDataEvent(D.C0.ESC+`[I`):this.coreService.triggerDataEvent(D.C0.ESC+`[O`)}_reportWindowsOptions(e){if(this._renderService)switch(e){case te.WindowsOptionsReportType.GET_WIN_SIZE_PIXELS:let e=this._renderService.dimensions.css.canvas.width.toFixed(0),t=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${D.C0.ESC}[4;${t};${e}t`);break;case te.WindowsOptionsReportType.GET_CELL_SIZE_PIXELS:let n=this._renderService.dimensions.css.cell.width.toFixed(0),r=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${D.C0.ESC}[6;${r};${n}t`)}}cancel(e,t){if(this.options.cancelEvents||t)return e.preventDefault(),e.stopPropagation(),!1}}t.Terminal=ie},9924:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.TimeBasedDebouncer=void 0,t.TimeBasedDebouncer=class{constructor(e,t=1e3){this._renderCallback=e,this._debounceThresholdMS=t,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(e,t,n){this._rowCount=n,e=e===void 0?0:e,t=t===void 0?this._rowCount-1:t,this._rowStart=this._rowStart===void 0?e:Math.min(this._rowStart,e),this._rowEnd=this._rowEnd===void 0?t:Math.max(this._rowEnd,t);let r=Date.now();if(r-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=r,this._innerRefresh();else if(!this._additionalRefreshRequested){let e=r-this._lastRefreshMs,t=this._debounceThresholdMS-e;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout((()=>{this._lastRefreshMs=Date.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0}),t)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t)}}},1680:function(e,t,n){var r=this&&this.__decorate||function(e,t,n,r){var i,a=arguments.length,o=a<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o},i=this&&this.__param||function(e,t){return function(n,r){t(n,r,e)}};Object.defineProperty(t,"__esModule",{value:!0}),t.Viewport=void 0;let a=n(3656),o=n(4725),s=n(8460),c=n(844),l=n(2585),u=t.Viewport=class extends c.Disposable{constructor(e,t,n,r,i,o,c,l){super(),this._viewportElement=e,this._scrollArea=t,this._bufferService=n,this._optionsService=r,this._charSizeService=i,this._renderService=o,this._coreBrowserService=c,this.scrollBarWidth=0,this._currentRowHeight=0,this._currentDeviceCellHeight=0,this._lastRecordedBufferLength=0,this._lastRecordedViewportHeight=0,this._lastRecordedBufferHeight=0,this._lastTouchY=0,this._lastScrollTop=0,this._wheelPartialScroll=0,this._refreshAnimationFrame=null,this._ignoreNextScrollEvent=!1,this._smoothScrollState={startTime:0,origin:-1,target:-1},this._onRequestScrollLines=this.register(new s.EventEmitter),this.onRequestScrollLines=this._onRequestScrollLines.event,this.scrollBarWidth=this._viewportElement.offsetWidth-this._scrollArea.offsetWidth||15,this.register((0,a.addDisposableDomListener)(this._viewportElement,`scroll`,this._handleScroll.bind(this))),this._activeBuffer=this._bufferService.buffer,this.register(this._bufferService.buffers.onBufferActivate((e=>this._activeBuffer=e.activeBuffer))),this._renderDimensions=this._renderService.dimensions,this.register(this._renderService.onDimensionsChange((e=>this._renderDimensions=e))),this._handleThemeChange(l.colors),this.register(l.onChangeColors((e=>this._handleThemeChange(e)))),this.register(this._optionsService.onSpecificOptionChange(`scrollback`,(()=>this.syncScrollArea()))),setTimeout((()=>this.syncScrollArea()))}_handleThemeChange(e){this._viewportElement.style.backgroundColor=e.background.css}reset(){this._currentRowHeight=0,this._currentDeviceCellHeight=0,this._lastRecordedBufferLength=0,this._lastRecordedViewportHeight=0,this._lastRecordedBufferHeight=0,this._lastTouchY=0,this._lastScrollTop=0,this._coreBrowserService.window.requestAnimationFrame((()=>this.syncScrollArea()))}_refresh(e){if(e)return this._innerRefresh(),void(this._refreshAnimationFrame!==null&&this._coreBrowserService.window.cancelAnimationFrame(this._refreshAnimationFrame));this._refreshAnimationFrame===null&&(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>this._innerRefresh())))}_innerRefresh(){if(this._charSizeService.height>0){this._currentRowHeight=this._renderDimensions.device.cell.height/this._coreBrowserService.dpr,this._currentDeviceCellHeight=this._renderDimensions.device.cell.height,this._lastRecordedViewportHeight=this._viewportElement.offsetHeight;let e=Math.round(this._currentRowHeight*this._lastRecordedBufferLength)+(this._lastRecordedViewportHeight-this._renderDimensions.css.canvas.height);this._lastRecordedBufferHeight!==e&&(this._lastRecordedBufferHeight=e,this._scrollArea.style.height=this._lastRecordedBufferHeight+`px`)}let e=this._bufferService.buffer.ydisp*this._currentRowHeight;this._viewportElement.scrollTop!==e&&(this._ignoreNextScrollEvent=!0,this._viewportElement.scrollTop=e),this._refreshAnimationFrame=null}syncScrollArea(e=!1){if(this._lastRecordedBufferLength!==this._bufferService.buffer.lines.length)return this._lastRecordedBufferLength=this._bufferService.buffer.lines.length,void this._refresh(e);this._lastRecordedViewportHeight===this._renderService.dimensions.css.canvas.height&&this._lastScrollTop===this._activeBuffer.ydisp*this._currentRowHeight&&this._renderDimensions.device.cell.height===this._currentDeviceCellHeight||this._refresh(e)}_handleScroll(e){if(this._lastScrollTop=this._viewportElement.scrollTop,!this._viewportElement.offsetParent)return;if(this._ignoreNextScrollEvent)return this._ignoreNextScrollEvent=!1,void this._onRequestScrollLines.fire({amount:0,suppressScrollEvent:!0});let t=Math.round(this._lastScrollTop/this._currentRowHeight)-this._bufferService.buffer.ydisp;this._onRequestScrollLines.fire({amount:t,suppressScrollEvent:!0})}_smoothScroll(){if(this._isDisposed||this._smoothScrollState.origin===-1||this._smoothScrollState.target===-1)return;let e=this._smoothScrollPercent();this._viewportElement.scrollTop=this._smoothScrollState.origin+Math.round(e*(this._smoothScrollState.target-this._smoothScrollState.origin)),e<1?this._coreBrowserService.window.requestAnimationFrame((()=>this._smoothScroll())):this._clearSmoothScrollState()}_smoothScrollPercent(){return this._optionsService.rawOptions.smoothScrollDuration&&this._smoothScrollState.startTime?Math.max(Math.min((Date.now()-this._smoothScrollState.startTime)/this._optionsService.rawOptions.smoothScrollDuration,1),0):1}_clearSmoothScrollState(){this._smoothScrollState.startTime=0,this._smoothScrollState.origin=-1,this._smoothScrollState.target=-1}_bubbleScroll(e,t){let n=this._viewportElement.scrollTop+this._lastRecordedViewportHeight;return!(t<0&&this._viewportElement.scrollTop!==0||t>0&&n<this._lastRecordedBufferHeight)||(e.cancelable&&e.preventDefault(),!1)}handleWheel(e){let t=this._getPixelsScrolled(e);return t!==0&&(this._optionsService.rawOptions.smoothScrollDuration?(this._smoothScrollState.startTime=Date.now(),this._smoothScrollPercent()<1?(this._smoothScrollState.origin=this._viewportElement.scrollTop,this._smoothScrollState.target===-1?this._smoothScrollState.target=this._viewportElement.scrollTop+t:this._smoothScrollState.target+=t,this._smoothScrollState.target=Math.max(Math.min(this._smoothScrollState.target,this._viewportElement.scrollHeight),0),this._smoothScroll()):this._clearSmoothScrollState()):this._viewportElement.scrollTop+=t,this._bubbleScroll(e,t))}scrollLines(e){if(e!==0)if(this._optionsService.rawOptions.smoothScrollDuration){let t=e*this._currentRowHeight;this._smoothScrollState.startTime=Date.now(),this._smoothScrollPercent()<1?(this._smoothScrollState.origin=this._viewportElement.scrollTop,this._smoothScrollState.target=this._smoothScrollState.origin+t,this._smoothScrollState.target=Math.max(Math.min(this._smoothScrollState.target,this._viewportElement.scrollHeight),0),this._smoothScroll()):this._clearSmoothScrollState()}else this._onRequestScrollLines.fire({amount:e,suppressScrollEvent:!1})}_getPixelsScrolled(e){if(e.deltaY===0||e.shiftKey)return 0;let t=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_LINE?t*=this._currentRowHeight:e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(t*=this._currentRowHeight*this._bufferService.rows),t}getBufferElements(e,t){let n,r=``,i=[],a=t??this._bufferService.buffer.lines.length,o=this._bufferService.buffer.lines;for(let t=e;t<a;t++){let e=o.get(t);if(!e)continue;let a=o.get(t+1)?.isWrapped;if(r+=e.translateToString(!a),!a||t===o.length-1){let e=document.createElement(`div`);e.textContent=r,i.push(e),r.length>0&&(n=e),r=``}}return{bufferElements:i,cursorElement:n}}getLinesScrolled(e){if(e.deltaY===0||e.shiftKey)return 0;let t=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(t/=this._currentRowHeight+0,this._wheelPartialScroll+=t,t=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(t*=this._bufferService.rows),t}_applyScrollModifier(e,t){let n=this._optionsService.rawOptions.fastScrollModifier;return n===`alt`&&t.altKey||n===`ctrl`&&t.ctrlKey||n===`shift`&&t.shiftKey?e*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:e*this._optionsService.rawOptions.scrollSensitivity}handleTouchStart(e){this._lastTouchY=e.touches[0].pageY}handleTouchMove(e){let t=this._lastTouchY-e.touches[0].pageY;return this._lastTouchY=e.touches[0].pageY,t!==0&&(this._viewportElement.scrollTop+=t,this._bubbleScroll(e,t))}};t.Viewport=u=r([i(2,l.IBufferService),i(3,l.IOptionsService),i(4,o.ICharSizeService),i(5,o.IRenderService),i(6,o.ICoreBrowserService),i(7,o.IThemeService)],u)},3107:function(e,t,n){var r=this&&this.__decorate||function(e,t,n,r){var i,a=arguments.length,o=a<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o},i=this&&this.__param||function(e,t){return function(n,r){t(n,r,e)}};Object.defineProperty(t,"__esModule",{value:!0}),t.BufferDecorationRenderer=void 0;let a=n(4725),o=n(844),s=n(2585),c=t.BufferDecorationRenderer=class extends o.Disposable{constructor(e,t,n,r,i){super(),this._screenElement=e,this._bufferService=t,this._coreBrowserService=n,this._decorationService=r,this._renderService=i,this._decorationElements=new Map,this._altBufferIsActive=!1,this._dimensionsChanged=!1,this._container=document.createElement(`div`),this._container.classList.add(`xterm-decoration-container`),this._screenElement.appendChild(this._container),this.register(this._renderService.onRenderedViewportChange((()=>this._doRefreshDecorations()))),this.register(this._renderService.onDimensionsChange((()=>{this._dimensionsChanged=!0,this._queueRefresh()}))),this.register(this._coreBrowserService.onDprChange((()=>this._queueRefresh()))),this.register(this._bufferService.buffers.onBufferActivate((()=>{this._altBufferIsActive=this._bufferService.buffer===this._bufferService.buffers.alt}))),this.register(this._decorationService.onDecorationRegistered((()=>this._queueRefresh()))),this.register(this._decorationService.onDecorationRemoved((e=>this._removeDecoration(e)))),this.register((0,o.toDisposable)((()=>{this._container.remove(),this._decorationElements.clear()})))}_queueRefresh(){this._animationFrame===void 0&&(this._animationFrame=this._renderService.addRefreshCallback((()=>{this._doRefreshDecorations(),this._animationFrame=void 0})))}_doRefreshDecorations(){for(let e of this._decorationService.decorations)this._renderDecoration(e);this._dimensionsChanged=!1}_renderDecoration(e){this._refreshStyle(e),this._dimensionsChanged&&this._refreshXPosition(e)}_createElement(e){let t=this._coreBrowserService.mainDocument.createElement(`div`);t.classList.add(`xterm-decoration`),t.classList.toggle(`xterm-decoration-top-layer`,e?.options?.layer===`top`),t.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,t.style.height=(e.options.height||1)*this._renderService.dimensions.css.cell.height+`px`,t.style.top=(e.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height+`px`,t.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;let n=e.options.x??0;return n&&n>this._bufferService.cols&&(t.style.display=`none`),this._refreshXPosition(e,t),t}_refreshStyle(e){let t=e.marker.line-this._bufferService.buffers.active.ydisp;if(t<0||t>=this._bufferService.rows)e.element&&(e.element.style.display=`none`,e.onRenderEmitter.fire(e.element));else{let n=this._decorationElements.get(e);n||(n=this._createElement(e),e.element=n,this._decorationElements.set(e,n),this._container.appendChild(n),e.onDispose((()=>{this._decorationElements.delete(e),n.remove()}))),n.style.top=t*this._renderService.dimensions.css.cell.height+`px`,n.style.display=this._altBufferIsActive?`none`:`block`,e.onRenderEmitter.fire(n)}}_refreshXPosition(e,t=e.element){if(!t)return;let n=e.options.x??0;(e.options.anchor||`left`)===`right`?t.style.right=n?n*this._renderService.dimensions.css.cell.width+`px`:``:t.style.left=n?n*this._renderService.dimensions.css.cell.width+`px`:``}_removeDecoration(e){this._decorationElements.get(e)?.remove(),this._decorationElements.delete(e),e.dispose()}};t.BufferDecorationRenderer=c=r([i(1,s.IBufferService),i(2,a.ICoreBrowserService),i(3,s.IDecorationService),i(4,a.IRenderService)],c)},5871:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ColorZoneStore=void 0,t.ColorZoneStore=class{constructor(){this._zones=[],this._zonePool=[],this._zonePoolIndex=0,this._linePadding={full:0,left:0,center:0,right:0}}get zones(){return this._zonePool.length=Math.min(this._zonePool.length,this._zones.length),this._zones}clear(){this._zones.length=0,this._zonePoolIndex=0}addDecoration(e){if(e.options.overviewRulerOptions){for(let t of this._zones)if(t.color===e.options.overviewRulerOptions.color&&t.position===e.options.overviewRulerOptions.position){if(this._lineIntersectsZone(t,e.marker.line))return;if(this._lineAdjacentToZone(t,e.marker.line,e.options.overviewRulerOptions.position))return void this._addLineToZone(t,e.marker.line)}if(this._zonePoolIndex<this._zonePool.length)return this._zonePool[this._zonePoolIndex].color=e.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=e.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=e.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=e.marker.line,void this._zones.push(this._zonePool[this._zonePoolIndex++]);this._zones.push({color:e.options.overviewRulerOptions.color,position:e.options.overviewRulerOptions.position,startBufferLine:e.marker.line,endBufferLine:e.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(e){this._linePadding=e}_lineIntersectsZone(e,t){return t>=e.startBufferLine&&t<=e.endBufferLine}_lineAdjacentToZone(e,t,n){return t>=e.startBufferLine-this._linePadding[n||`full`]&&t<=e.endBufferLine+this._linePadding[n||`full`]}_addLineToZone(e,t){e.startBufferLine=Math.min(e.startBufferLine,t),e.endBufferLine=Math.max(e.endBufferLine,t)}}},5744:function(e,t,n){var r=this&&this.__decorate||function(e,t,n,r){var i,a=arguments.length,o=a<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o},i=this&&this.__param||function(e,t){return function(n,r){t(n,r,e)}};Object.defineProperty(t,"__esModule",{value:!0}),t.OverviewRulerRenderer=void 0;let a=n(5871),o=n(4725),s=n(844),c=n(2585),l={full:0,left:0,center:0,right:0},u={full:0,left:0,center:0,right:0},d={full:0,left:0,center:0,right:0},f=t.OverviewRulerRenderer=class extends s.Disposable{get _width(){return this._optionsService.options.overviewRulerWidth||0}constructor(e,t,n,r,i,o,c){super(),this._viewportElement=e,this._screenElement=t,this._bufferService=n,this._decorationService=r,this._renderService=i,this._optionsService=o,this._coreBrowserService=c,this._colorZoneStore=new a.ColorZoneStore,this._shouldUpdateDimensions=!0,this._shouldUpdateAnchor=!0,this._lastKnownBufferLength=0,this._canvas=this._coreBrowserService.mainDocument.createElement(`canvas`),this._canvas.classList.add(`xterm-decoration-overview-ruler`),this._refreshCanvasDimensions(),this._viewportElement.parentElement?.insertBefore(this._canvas,this._viewportElement);let l=this._canvas.getContext(`2d`);if(!l)throw Error(`Ctx cannot be null`);this._ctx=l,this._registerDecorationListeners(),this._registerBufferChangeListeners(),this._registerDimensionChangeListeners(),this.register((0,s.toDisposable)((()=>{this._canvas?.remove()})))}_registerDecorationListeners(){this.register(this._decorationService.onDecorationRegistered((()=>this._queueRefresh(void 0,!0)))),this.register(this._decorationService.onDecorationRemoved((()=>this._queueRefresh(void 0,!0))))}_registerBufferChangeListeners(){this.register(this._renderService.onRenderedViewportChange((()=>this._queueRefresh()))),this.register(this._bufferService.buffers.onBufferActivate((()=>{this._canvas.style.display=this._bufferService.buffer===this._bufferService.buffers.alt?`none`:`block`}))),this.register(this._bufferService.onScroll((()=>{this._lastKnownBufferLength!==this._bufferService.buffers.normal.lines.length&&(this._refreshDrawHeightConstants(),this._refreshColorZonePadding())})))}_registerDimensionChangeListeners(){this.register(this._renderService.onRender((()=>{this._containerHeight&&this._containerHeight===this._screenElement.clientHeight||(this._queueRefresh(!0),this._containerHeight=this._screenElement.clientHeight)}))),this.register(this._optionsService.onSpecificOptionChange(`overviewRulerWidth`,(()=>this._queueRefresh(!0)))),this.register(this._coreBrowserService.onDprChange((()=>this._queueRefresh(!0)))),this._queueRefresh(!0)}_refreshDrawConstants(){let e=Math.floor(this._canvas.width/3),t=Math.ceil(this._canvas.width/3);u.full=this._canvas.width,u.left=e,u.center=t,u.right=e,this._refreshDrawHeightConstants(),d.full=0,d.left=0,d.center=u.left,d.right=u.left+u.center}_refreshDrawHeightConstants(){l.full=Math.round(2*this._coreBrowserService.dpr);let e=this._canvas.height/this._bufferService.buffer.lines.length,t=Math.round(Math.max(Math.min(e,12),6)*this._coreBrowserService.dpr);l.left=t,l.center=t,l.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*l.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*l.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*l.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*l.right)}),this._lastKnownBufferLength=this._bufferService.buffers.normal.lines.length}_refreshCanvasDimensions(){this._canvas.style.width=`${this._width}px`,this._canvas.width=Math.round(this._width*this._coreBrowserService.dpr),this._canvas.style.height=`${this._screenElement.clientHeight}px`,this._canvas.height=Math.round(this._screenElement.clientHeight*this._coreBrowserService.dpr),this._refreshDrawConstants(),this._refreshColorZonePadding()}_refreshDecorations(){this._shouldUpdateDimensions&&this._refreshCanvasDimensions(),this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height),this._colorZoneStore.clear();for(let e of this._decorationService.decorations)this._colorZoneStore.addDecoration(e);this._ctx.lineWidth=1;let e=this._colorZoneStore.zones;for(let t of e)t.position!==`full`&&this._renderColorZone(t);for(let t of e)t.position===`full`&&this._renderColorZone(t);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderColorZone(e){this._ctx.fillStyle=e.color,this._ctx.fillRect(d[e.position||`full`],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-l[e.position||`full`]/2),u[e.position||`full`],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+l[e.position||`full`]))}_queueRefresh(e,t){this._shouldUpdateDimensions=e||this._shouldUpdateDimensions,this._shouldUpdateAnchor=t||this._shouldUpdateAnchor,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>{this._refreshDecorations(),this._animationFrame=void 0})))}};t.OverviewRulerRenderer=f=r([i(2,c.IBufferService),i(3,c.IDecorationService),i(4,o.IRenderService),i(5,c.IOptionsService),i(6,o.ICoreBrowserService)],f)},2950:function(e,t,n){var r=this&&this.__decorate||function(e,t,n,r){var i,a=arguments.length,o=a<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o},i=this&&this.__param||function(e,t){return function(n,r){t(n,r,e)}};Object.defineProperty(t,"__esModule",{value:!0}),t.CompositionHelper=void 0;let a=n(4725),o=n(2585),s=n(2584),c=t.CompositionHelper=class{get isComposing(){return this._isComposing}constructor(e,t,n,r,i,a){this._textarea=e,this._compositionView=t,this._bufferService=n,this._optionsService=r,this._coreService=i,this._renderService=a,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=``}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent=``,this._dataAlreadySent=``,this._compositionView.classList.add(`active`)}compositionupdate(e){this._compositionView.textContent=e.data,this.updateCompositionElements(),setTimeout((()=>{this._compositionPosition.end=this._textarea.value.length}),0)}compositionend(){this._finalizeComposition(!0)}keydown(e){if(this._isComposing||this._isSendingComposition){if(e.keyCode===229||e.keyCode===16||e.keyCode===17||e.keyCode===18)return!1;this._finalizeComposition(!1)}return e.keyCode!==229||(this._handleAnyTextareaChanges(),!1)}_finalizeComposition(e){if(this._compositionView.classList.remove(`active`),this._isComposing=!1,e){let e={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout((()=>{if(this._isSendingComposition){let t;this._isSendingComposition=!1,e.start+=this._dataAlreadySent.length,t=this._isComposing?this._textarea.value.substring(e.start,e.end):this._textarea.value.substring(e.start),t.length>0&&this._coreService.triggerDataEvent(t,!0)}}),0)}else{this._isSendingComposition=!1;let e=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(e,!0)}}_handleAnyTextareaChanges(){let e=this._textarea.value;setTimeout((()=>{if(!this._isComposing){let t=this._textarea.value,n=t.replace(e,``);this._dataAlreadySent=n,t.length>e.length?this._coreService.triggerDataEvent(n,!0):t.length<e.length?this._coreService.triggerDataEvent(`${s.C0.DEL}`,!0):t.length===e.length&&t!==e&&this._coreService.triggerDataEvent(t,!0)}}),0)}updateCompositionElements(e){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){let e=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),t=this._renderService.dimensions.css.cell.height,n=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,r=e*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=r+`px`,this._compositionView.style.top=n+`px`,this._compositionView.style.height=t+`px`,this._compositionView.style.lineHeight=t+`px`,this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+`px`;let i=this._compositionView.getBoundingClientRect();this._textarea.style.left=r+`px`,this._textarea.style.top=n+`px`,this._textarea.style.width=Math.max(i.width,1)+`px`,this._textarea.style.height=Math.max(i.height,1)+`px`,this._textarea.style.lineHeight=i.height+`px`}e||setTimeout((()=>this.updateCompositionElements(!0)),0)}}};t.CompositionHelper=c=r([i(2,o.IBufferService),i(3,o.IOptionsService),i(4,o.ICoreService),i(5,a.IRenderService)],c)},9806:(e,t)=>{function n(e,t,n){let r=n.getBoundingClientRect(),i=e.getComputedStyle(n),a=parseInt(i.getPropertyValue(`padding-left`)),o=parseInt(i.getPropertyValue(`padding-top`));return[t.clientX-r.left-a,t.clientY-r.top-o]}Object.defineProperty(t,"__esModule",{value:!0}),t.getCoords=t.getCoordsRelativeToElement=void 0,t.getCoordsRelativeToElement=n,t.getCoords=function(e,t,r,i,a,o,s,c,l){if(!o)return;let u=n(e,t,r);return u?(u[0]=Math.ceil((u[0]+(l?s/2:0))/s),u[1]=Math.ceil(u[1]/c),u[0]=Math.min(Math.max(u[0],1),i+ +!!l),u[1]=Math.min(Math.max(u[1],1),a),u):void 0}},9504:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.moveToCellSequence=void 0;let r=n(2584);function i(e,t,n,r){let i=e-a(e,n),s=t-a(t,n);return l(Math.abs(i-s)-function(e,t,n){let r=0,i=e-a(e,n),s=t-a(t,n);for(let a=0;a<Math.abs(i-s);a++){let s=o(e,t)===`A`?-1:1;n.buffer.lines.get(i+s*a)?.isWrapped&&r++}return r}(e,t,n),c(o(e,t),r))}function a(e,t){let n=0,r=t.buffer.lines.get(e),i=r?.isWrapped;for(;i&&e>=0&&e<t.rows;)n++,r=t.buffer.lines.get(--e),i=r?.isWrapped;return n}function o(e,t){return e>t?`A`:`B`}function s(e,t,n,r,i,a){let o=e,s=t,c=``;for(;o!==n||s!==r;)o+=i?1:-1,i&&o>a.cols-1?(c+=a.buffer.translateBufferLineToString(s,!1,e,o),o=0,e=0,s++):!i&&o<0&&(c+=a.buffer.translateBufferLineToString(s,!1,0,e+1),o=a.cols-1,e=o,s--);return c+a.buffer.translateBufferLineToString(s,!1,e,o)}function c(e,t){let n=t?`O`:`[`;return r.C0.ESC+n+e}function l(e,t){e=Math.floor(e);let n=``;for(let r=0;r<e;r++)n+=t;return n}t.moveToCellSequence=function(e,t,n,r){let o=n.buffer.x,u=n.buffer.y;if(!n.buffer.hasScrollback)return function(e,t,n,r,o,u){return i(t,r,o,u).length===0?``:l(s(e,t,e,t-a(t,o),!1,o).length,c(`D`,u))}(o,u,0,t,n,r)+i(u,t,n,r)+function(e,t,n,r,o,u){let d;d=i(t,r,o,u).length>0?r-a(r,o):t;let f=r,p=function(e,t,n,r,o,s){let c;return c=i(n,r,o,s).length>0?r-a(r,o):t,e<n&&c<=r||e>=n&&c<r?`C`:`D`}(e,t,n,r,o,u);return l(s(e,d,n,f,p===`C`,o).length,c(p,u))}(o,u,e,t,n,r);let d;if(u===t)return d=o>e?`D`:`C`,l(Math.abs(o-e),c(d,r));d=u>t?`D`:`C`;let f=Math.abs(u-t);return l(function(e,t){return t.cols-e}(u>t?e:o,n)+(f-1)*n.cols+1+((u>t?o:e)-1),c(d,r))}},1296:function(e,t,n){var r=this&&this.__decorate||function(e,t,n,r){var i,a=arguments.length,o=a<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o},i=this&&this.__param||function(e,t){return function(n,r){t(n,r,e)}};Object.defineProperty(t,"__esModule",{value:!0}),t.DomRenderer=void 0;let a=n(3787),o=n(2550),s=n(2223),c=n(6171),l=n(6052),u=n(4725),d=n(8055),f=n(8460),p=n(844),m=n(2585),h=`xterm-dom-renderer-owner-`,g=`xterm-rows`,_=`xterm-fg-`,v=`xterm-bg-`,y=`xterm-focus`,b=`xterm-selection`,x=1,S=t.DomRenderer=class extends p.Disposable{constructor(e,t,n,r,i,s,u,d,m,_,v,y,S){super(),this._terminal=e,this._document=t,this._element=n,this._screenElement=r,this._viewportElement=i,this._helperContainer=s,this._linkifier2=u,this._charSizeService=m,this._optionsService=_,this._bufferService=v,this._coreBrowserService=y,this._themeService=S,this._terminalClass=x++,this._rowElements=[],this._selectionRenderModel=(0,l.createSelectionRenderModel)(),this.onRequestRedraw=this.register(new f.EventEmitter).event,this._rowContainer=this._document.createElement(`div`),this._rowContainer.classList.add(g),this._rowContainer.style.lineHeight=`normal`,this._rowContainer.setAttribute(`aria-hidden`,`true`),this._refreshRowElements(this._bufferService.cols,this._bufferService.rows),this._selectionContainer=this._document.createElement(`div`),this._selectionContainer.classList.add(b),this._selectionContainer.setAttribute(`aria-hidden`,`true`),this.dimensions=(0,c.createRenderDimensions)(),this._updateDimensions(),this.register(this._optionsService.onOptionChange((()=>this._handleOptionsChanged()))),this.register(this._themeService.onChangeColors((e=>this._injectCss(e)))),this._injectCss(this._themeService.colors),this._rowFactory=d.createInstance(a.DomRendererRowFactory,document),this._element.classList.add(h+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this.register(this._linkifier2.onShowLinkUnderline((e=>this._handleLinkHover(e)))),this.register(this._linkifier2.onHideLinkUnderline((e=>this._handleLinkLeave(e)))),this.register((0,p.toDisposable)((()=>{this._element.classList.remove(h+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()}))),this._widthCache=new o.WidthCache(this._document,this._helperContainer),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){let e=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*e,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*e),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.left=0,this.dimensions.device.char.top=0,this.dimensions.device.canvas.width=this.dimensions.device.cell.width*this._bufferService.cols,this.dimensions.device.canvas.height=this.dimensions.device.cell.height*this._bufferService.rows,this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/e),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/e),this.dimensions.css.cell.width=this.dimensions.css.canvas.width/this._bufferService.cols,this.dimensions.css.cell.height=this.dimensions.css.canvas.height/this._bufferService.rows;for(let e of this._rowElements)e.style.width=`${this.dimensions.css.canvas.width}px`,e.style.height=`${this.dimensions.css.cell.height}px`,e.style.lineHeight=`${this.dimensions.css.cell.height}px`,e.style.overflow=`hidden`;this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement(`style`),this._screenElement.appendChild(this._dimensionsStyleElement));let t=`${this._terminalSelector} .${g} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=t,this._selectionContainer.style.height=this._viewportElement.style.height,this._screenElement.style.width=`${this.dimensions.css.canvas.width}px`,this._screenElement.style.height=`${this.dimensions.css.canvas.height}px`}_injectCss(e){this._themeStyleElement||(this._themeStyleElement=this._document.createElement(`style`),this._screenElement.appendChild(this._themeStyleElement));let t=`${this._terminalSelector} .${g} { color: ${e.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;t+=`${this._terminalSelector} .${g} .xterm-dim { color: ${d.color.multiplyOpacity(e.foreground,.5).css};}`,t+=`${this._terminalSelector} span:not(.xterm-bold) { font-weight: ${this._optionsService.rawOptions.fontWeight};}${this._terminalSelector} span.xterm-bold { font-weight: ${this._optionsService.rawOptions.fontWeightBold};}${this._terminalSelector} span.xterm-italic { font-style: italic;}`;let n=`blink_underline_${this._terminalClass}`,r=`blink_bar_${this._terminalClass}`,i=`blink_block_${this._terminalClass}`;t+=`@keyframes ${n} { 50% { border-bottom-style: hidden; }}`,t+=`@keyframes ${r} { 50% { box-shadow: none; }}`,t+=`@keyframes ${i} { 0% { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css}; } 50% { background-color: inherit; color: ${e.cursor.css}; }}`,t+=`${this._terminalSelector} .${g}.${y} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${n} 1s step-end infinite;}${this._terminalSelector} .${g}.${y} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${r} 1s step-end infinite;}${this._terminalSelector} .${g}.${y} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${i} 1s step-end infinite;}${this._terminalSelector} .${g} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${g} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${g} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${g} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${g} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${b} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${b} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${b} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[n,r]of e.ansi.entries())t+=`${this._terminalSelector} .${_}${n} { color: ${r.css}; }${this._terminalSelector} .${_}${n}.xterm-dim { color: ${d.color.multiplyOpacity(r,.5).css}; }${this._terminalSelector} .${v}${n} { background-color: ${r.css}; }`;t+=`${this._terminalSelector} .${_}${s.INVERTED_DEFAULT_COLOR} { color: ${d.color.opaque(e.background).css}; }${this._terminalSelector} .${_}${s.INVERTED_DEFAULT_COLOR}.xterm-dim { color: ${d.color.multiplyOpacity(d.color.opaque(e.background),.5).css}; }${this._terminalSelector} .${v}${s.INVERTED_DEFAULT_COLOR} { background-color: ${e.foreground.css}; }`,this._themeStyleElement.textContent=t}_setDefaultSpacing(){let e=this.dimensions.css.cell.width-this._widthCache.get(`W`,!1,!1);this._rowContainer.style.letterSpacing=`${e}px`,this._rowFactory.defaultSpacing=e}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(e,t){for(let e=this._rowElements.length;e<=t;e++){let e=this._document.createElement(`div`);this._rowContainer.appendChild(e),this._rowElements.push(e)}for(;this._rowElements.length>t;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(e,t){this._refreshRowElements(e,t),this._updateDimensions(),this.handleSelectionChanged(this._selectionRenderModel.selectionStart,this._selectionRenderModel.selectionEnd,this._selectionRenderModel.columnSelectMode)}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(y),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(y),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,t,n){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,t,n),this.renderRows(0,this._bufferService.rows-1),!e||!t)return;this._selectionRenderModel.update(this._terminal,e,t,n);let r=this._selectionRenderModel.viewportStartRow,i=this._selectionRenderModel.viewportEndRow,a=this._selectionRenderModel.viewportCappedStartRow,o=this._selectionRenderModel.viewportCappedEndRow;if(a>=this._bufferService.rows||o<0)return;let s=this._document.createDocumentFragment();if(n){let n=e[0]>t[0];s.appendChild(this._createSelectionElement(a,n?t[0]:e[0],n?e[0]:t[0],o-a+1))}else{let n=r===a?e[0]:0,c=a===i?t[0]:this._bufferService.cols;s.appendChild(this._createSelectionElement(a,n,c));let l=o-a-1;if(s.appendChild(this._createSelectionElement(a+1,0,this._bufferService.cols,l)),a!==o){let e=i===o?t[0]:this._bufferService.cols;s.appendChild(this._createSelectionElement(o,0,e))}}this._selectionContainer.appendChild(s)}_createSelectionElement(e,t,n,r=1){let i=this._document.createElement(`div`),a=t*this.dimensions.css.cell.width,o=this.dimensions.css.cell.width*(n-t);return a+o>this.dimensions.css.canvas.width&&(o=this.dimensions.css.canvas.width-a),i.style.height=r*this.dimensions.css.cell.height+`px`,i.style.top=e*this.dimensions.css.cell.height+`px`,i.style.left=`${a}px`,i.style.width=`${o}px`,i}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(let e of this._rowElements)e.replaceChildren()}renderRows(e,t){let n=this._bufferService.buffer,r=n.ybase+n.y,i=Math.min(n.x,this._bufferService.cols-1),a=this._optionsService.rawOptions.cursorBlink,o=this._optionsService.rawOptions.cursorStyle,s=this._optionsService.rawOptions.cursorInactiveStyle;for(let c=e;c<=t;c++){let e=c+n.ydisp,t=this._rowElements[c],l=n.lines.get(e);if(!t||!l)break;t.replaceChildren(...this._rowFactory.createRow(l,e,e===r,o,s,i,a,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${h}${this._terminalClass}`}_handleLinkHover(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!0)}_handleLinkLeave(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!1)}_setCellUnderline(e,t,n,r,i,a){n<0&&(e=0),r<0&&(t=0);let o=this._bufferService.rows-1;n=Math.max(Math.min(n,o),0),r=Math.max(Math.min(r,o),0),i=Math.min(i,this._bufferService.cols);let s=this._bufferService.buffer,c=s.ybase+s.y,l=Math.min(s.x,i-1),u=this._optionsService.rawOptions.cursorBlink,d=this._optionsService.rawOptions.cursorStyle,f=this._optionsService.rawOptions.cursorInactiveStyle;for(let o=n;o<=r;++o){let p=o+s.ydisp,m=this._rowElements[o],h=s.lines.get(p);if(!m||!h)break;m.replaceChildren(...this._rowFactory.createRow(h,p,p===c,d,f,l,u,this.dimensions.css.cell.width,this._widthCache,a?o===n?e:0:-1,a?(o===r?t:i)-1:-1))}}};t.DomRenderer=S=r([i(7,m.IInstantiationService),i(8,u.ICharSizeService),i(9,m.IOptionsService),i(10,m.IBufferService),i(11,u.ICoreBrowserService),i(12,u.IThemeService)],S)},3787:function(e,t,n){var r=this&&this.__decorate||function(e,t,n,r){var i,a=arguments.length,o=a<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o},i=this&&this.__param||function(e,t){return function(n,r){t(n,r,e)}};Object.defineProperty(t,"__esModule",{value:!0}),t.DomRendererRowFactory=void 0;let a=n(2223),o=n(643),s=n(511),c=n(2585),l=n(8055),u=n(4725),d=n(4269),f=n(6171),p=n(3734),m=t.DomRendererRowFactory=class{constructor(e,t,n,r,i,a,o){this._document=e,this._characterJoinerService=t,this._optionsService=n,this._coreBrowserService=r,this._coreService=i,this._decorationService=a,this._themeService=o,this._workCell=new s.CellData,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(e,t,n){this._selectionStart=e,this._selectionEnd=t,this._columnSelectMode=n}createRow(e,t,n,r,i,s,c,u,f,m,g){let _=[],v=this._characterJoinerService.getJoinedCharacters(t),y=this._themeService.colors,b,x=e.getNoBgTrimmedLength();n&&x<s+1&&(x=s+1);let S=0,C=``,w=0,T=0,E=0,D=!1,O=0,k=!1,ee=0,A=[],te=m!==-1&&g!==-1;for(let ne=0;ne<x;ne++){e.loadCell(ne,this._workCell);let x=this._workCell.getWidth();if(x===0)continue;let re=!1,ie=ne,j=this._workCell;if(v.length>0&&ne===v[0][0]){re=!0;let t=v.shift();j=new d.JoinedCellData(this._workCell,e.translateToString(!0,t[0],t[1]),t[1]-t[0]),ie=t[1]-1,x=j.getWidth()}let ae=this._isCellInSelection(ne,t),M=n&&ne===s,oe=te&&ne>=m&&ne<=g,se=!1;this._decorationService.forEachDecorationAtCell(ne,t,void 0,(e=>{se=!0}));let ce=j.getChars()||o.WHITESPACE_CELL_CHAR;if(ce===` `&&(j.isUnderline()||j.isOverline())&&(ce=`\xA0`),ee=x*u-f.get(ce,j.isBold(),j.isItalic()),b){if(S&&(ae&&k||!ae&&!k&&j.bg===w)&&(ae&&k&&y.selectionForeground||j.fg===T)&&j.extended.ext===E&&oe===D&&ee===O&&!M&&!re&&!se){j.isInvisible()?C+=o.WHITESPACE_CELL_CHAR:C+=ce,S++;continue}S&&(b.textContent=C),b=this._document.createElement(`span`),S=0,C=``}else b=this._document.createElement(`span`);if(w=j.bg,T=j.fg,E=j.extended.ext,D=oe,O=ee,k=ae,re&&s>=ne&&s<=ie&&(s=ne),!this._coreService.isCursorHidden&&M&&this._coreService.isCursorInitialized){if(A.push(`xterm-cursor`),this._coreBrowserService.isFocused)c&&A.push(`xterm-cursor-blink`),A.push(r===`bar`?`xterm-cursor-bar`:r===`underline`?`xterm-cursor-underline`:`xterm-cursor-block`);else if(i)switch(i){case`outline`:A.push(`xterm-cursor-outline`);break;case`block`:A.push(`xterm-cursor-block`);break;case`bar`:A.push(`xterm-cursor-bar`);break;case`underline`:A.push(`xterm-cursor-underline`)}}if(j.isBold()&&A.push(`xterm-bold`),j.isItalic()&&A.push(`xterm-italic`),j.isDim()&&A.push(`xterm-dim`),C=j.isInvisible()?o.WHITESPACE_CELL_CHAR:j.getChars()||o.WHITESPACE_CELL_CHAR,j.isUnderline()&&(A.push(`xterm-underline-${j.extended.underlineStyle}`),C===` `&&(C=`\xA0`),!j.isUnderlineColorDefault()))if(j.isUnderlineColorRGB())b.style.textDecorationColor=`rgb(${p.AttributeData.toColorRGB(j.getUnderlineColor()).join(`,`)})`;else{let e=j.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&j.isBold()&&e<8&&(e+=8),b.style.textDecorationColor=y.ansi[e].css}j.isOverline()&&(A.push(`xterm-overline`),C===` `&&(C=`\xA0`)),j.isStrikethrough()&&A.push(`xterm-strikethrough`),oe&&(b.style.textDecoration=`underline`);let le=j.getFgColor(),ue=j.getFgColorMode(),de=j.getBgColor(),fe=j.getBgColorMode(),pe=!!j.isInverse();if(pe){let e=le;le=de,de=e;let t=ue;ue=fe,fe=t}let me,he,ge,_e=!1;switch(this._decorationService.forEachDecorationAtCell(ne,t,void 0,(e=>{e.options.layer!==`top`&&_e||(e.backgroundColorRGB&&(fe=50331648,de=e.backgroundColorRGB.rgba>>8&16777215,me=e.backgroundColorRGB),e.foregroundColorRGB&&(ue=50331648,le=e.foregroundColorRGB.rgba>>8&16777215,he=e.foregroundColorRGB),_e=e.options.layer===`top`)})),!_e&&ae&&(me=this._coreBrowserService.isFocused?y.selectionBackgroundOpaque:y.selectionInactiveBackgroundOpaque,de=me.rgba>>8&16777215,fe=50331648,_e=!0,y.selectionForeground&&(ue=50331648,le=y.selectionForeground.rgba>>8&16777215,he=y.selectionForeground)),_e&&A.push(`xterm-decoration-top`),fe){case 16777216:case 33554432:ge=y.ansi[de],A.push(`xterm-bg-${de}`);break;case 50331648:ge=l.channels.toColor(de>>16,de>>8&255,255&de),this._addStyle(b,`background-color:#${h((de>>>0).toString(16),`0`,6)}`);break;default:pe?(ge=y.foreground,A.push(`xterm-bg-${a.INVERTED_DEFAULT_COLOR}`)):ge=y.background}switch(me||j.isDim()&&(me=l.color.multiplyOpacity(ge,.5)),ue){case 16777216:case 33554432:j.isBold()&&le<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(le+=8),this._applyMinimumContrast(b,ge,y.ansi[le],j,me,void 0)||A.push(`xterm-fg-${le}`);break;case 50331648:let e=l.channels.toColor(le>>16&255,le>>8&255,255&le);this._applyMinimumContrast(b,ge,e,j,me,he)||this._addStyle(b,`color:#${h(le.toString(16),`0`,6)}`);break;default:this._applyMinimumContrast(b,ge,y.foreground,j,me,he)||pe&&A.push(`xterm-fg-${a.INVERTED_DEFAULT_COLOR}`)}A.length&&=(b.className=A.join(` `),0),M||re||se?b.textContent=C:S++,ee!==this.defaultSpacing&&(b.style.letterSpacing=`${ee}px`),_.push(b),ne=ie}return b&&S&&(b.textContent=C),_}_applyMinimumContrast(e,t,n,r,i,a){if(this._optionsService.rawOptions.minimumContrastRatio===1||(0,f.treatGlyphAsBackgroundColor)(r.getCode()))return!1;let o=this._getContrastCache(r),s;if(i||a||(s=o.getColor(t.rgba,n.rgba)),s===void 0){let e=this._optionsService.rawOptions.minimumContrastRatio/(r.isDim()?2:1);s=l.color.ensureContrastRatio(i||t,a||n,e),o.setColor((i||t).rgba,(a||n).rgba,s??null)}return!!s&&(this._addStyle(e,`color:${s.css}`),!0)}_getContrastCache(e){return e.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(e,t){e.setAttribute(`style`,`${e.getAttribute(`style`)||``}${t};`)}_isCellInSelection(e,t){let n=this._selectionStart,r=this._selectionEnd;return!(!n||!r)&&(this._columnSelectMode?n[0]<=r[0]?e>=n[0]&&t>=n[1]&&e<r[0]&&t<=r[1]:e<n[0]&&t>=n[1]&&e>=r[0]&&t<=r[1]:t>n[1]&&t<r[1]||n[1]===r[1]&&t===n[1]&&e>=n[0]&&e<r[0]||n[1]<r[1]&&t===r[1]&&e<r[0]||n[1]<r[1]&&t===n[1]&&e>=n[0])}};function h(e,t,n){for(;e.length<n;)e=t+e;return e}t.DomRendererRowFactory=m=r([i(1,u.ICharacterJoinerService),i(2,c.IOptionsService),i(3,u.ICoreBrowserService),i(4,c.ICoreService),i(5,c.IDecorationService),i(6,u.IThemeService)],m)},2550:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.WidthCache=void 0,t.WidthCache=class{constructor(e,t){this._flat=new Float32Array(256),this._font=``,this._fontSize=0,this._weight=`normal`,this._weightBold=`bold`,this._measureElements=[],this._container=e.createElement(`div`),this._container.classList.add(`xterm-width-cache-measure-container`),this._container.setAttribute(`aria-hidden`,`true`),this._container.style.whiteSpace=`pre`,this._container.style.fontKerning=`none`;let n=e.createElement(`span`);n.classList.add(`xterm-char-measure-element`);let r=e.createElement(`span`);r.classList.add(`xterm-char-measure-element`),r.style.fontWeight=`bold`;let i=e.createElement(`span`);i.classList.add(`xterm-char-measure-element`),i.style.fontStyle=`italic`;let a=e.createElement(`span`);a.classList.add(`xterm-char-measure-element`),a.style.fontWeight=`bold`,a.style.fontStyle=`italic`,this._measureElements=[n,r,i,a],this._container.appendChild(n),this._container.appendChild(r),this._container.appendChild(i),this._container.appendChild(a),t.appendChild(this._container),this.clear()}dispose(){this._container.remove(),this._measureElements.length=0,this._holey=void 0}clear(){this._flat.fill(-9999),this._holey=new Map}setFont(e,t,n,r){e===this._font&&t===this._fontSize&&n===this._weight&&r===this._weightBold||(this._font=e,this._fontSize=t,this._weight=n,this._weightBold=r,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${n}`,this._measureElements[1].style.fontWeight=`${r}`,this._measureElements[2].style.fontWeight=`${n}`,this._measureElements[3].style.fontWeight=`${r}`,this.clear())}get(e,t,n){let r=0;if(!t&&!n&&e.length===1&&(r=e.charCodeAt(0))<256){if(this._flat[r]!==-9999)return this._flat[r];let t=this._measure(e,0);return t>0&&(this._flat[r]=t),t}let i=e;t&&(i+=`B`),n&&(i+=`I`);let a=this._holey.get(i);if(a===void 0){let r=0;t&&(r|=1),n&&(r|=2),a=this._measure(e,r),a>0&&this._holey.set(i,a)}return a}_measure(e,t){let n=this._measureElements[t];return n.textContent=e.repeat(32),n.offsetWidth/32}}},2223:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.TEXT_BASELINE=t.DIM_OPACITY=t.INVERTED_DEFAULT_COLOR=void 0;let r=n(6114);t.INVERTED_DEFAULT_COLOR=257,t.DIM_OPACITY=.5,t.TEXT_BASELINE=r.isFirefox||r.isLegacyEdge?`bottom`:`ideographic`},6171:(e,t)=>{function n(e){return 57508<=e&&e<=57558}function r(e){return e>=128512&&e<=128591||e>=127744&&e<=128511||e>=128640&&e<=128767||e>=9728&&e<=9983||e>=9984&&e<=10175||e>=65024&&e<=65039||e>=129280&&e<=129535||e>=127462&&e<=127487}Object.defineProperty(t,"__esModule",{value:!0}),t.computeNextVariantOffset=t.createRenderDimensions=t.treatGlyphAsBackgroundColor=t.allowRescaling=t.isEmoji=t.isRestrictedPowerlineGlyph=t.isPowerlineGlyph=t.throwIfFalsy=void 0,t.throwIfFalsy=function(e){if(!e)throw Error(`value must not be falsy`);return e},t.isPowerlineGlyph=n,t.isRestrictedPowerlineGlyph=function(e){return 57520<=e&&e<=57527},t.isEmoji=r,t.allowRescaling=function(e,t,i,a){return t===1&&i>Math.ceil(1.5*a)&&e!==void 0&&e>255&&!r(e)&&!n(e)&&!function(e){return 57344<=e&&e<=63743}(e)},t.treatGlyphAsBackgroundColor=function(e){return n(e)||function(e){return 9472<=e&&e<=9631}(e)},t.createRenderDimensions=function(){return{css:{canvas:{width:0,height:0},cell:{width:0,height:0}},device:{canvas:{width:0,height:0},cell:{width:0,height:0},char:{width:0,height:0,left:0,top:0}}}},t.computeNextVariantOffset=function(e,t,n=0){return(e-(2*Math.round(t)-n))%(2*Math.round(t))}},6052:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.createSelectionRenderModel=void 0;class n{constructor(){this.clear()}clear(){this.hasSelection=!1,this.columnSelectMode=!1,this.viewportStartRow=0,this.viewportEndRow=0,this.viewportCappedStartRow=0,this.viewportCappedEndRow=0,this.startCol=0,this.endCol=0,this.selectionStart=void 0,this.selectionEnd=void 0}update(e,t,n,r=!1){if(this.selectionStart=t,this.selectionEnd=n,!t||!n||t[0]===n[0]&&t[1]===n[1])return void this.clear();let i=e.buffers.active.ydisp,a=t[1]-i,o=n[1]-i,s=Math.max(a,0),c=Math.min(o,e.rows-1);s>=e.rows||c<0?this.clear():(this.hasSelection=!0,this.columnSelectMode=r,this.viewportStartRow=a,this.viewportEndRow=o,this.viewportCappedStartRow=s,this.viewportCappedEndRow=c,this.startCol=t[0],this.endCol=n[0])}isCellSelected(e,t,n){return!!this.hasSelection&&(n-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?t>=this.startCol&&n>=this.viewportCappedStartRow&&t<this.endCol&&n<=this.viewportCappedEndRow:t<this.startCol&&n>=this.viewportCappedStartRow&&t>=this.endCol&&n<=this.viewportCappedEndRow:n>this.viewportStartRow&&n<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&n===this.viewportStartRow&&t>=this.startCol&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&n===this.viewportEndRow&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&n===this.viewportStartRow&&t>=this.startCol)}}t.createSelectionRenderModel=function(){return new n}},456:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.SelectionModel=void 0,t.SelectionModel=class{constructor(e){this._bufferService=e,this.isSelectAllActive=!1,this.selectionStartLength=0}clearSelection(){this.selectionStart=void 0,this.selectionEnd=void 0,this.isSelectAllActive=!1,this.selectionStartLength=0}get finalSelectionStart(){return this.isSelectAllActive?[0,0]:this.selectionEnd&&this.selectionStart&&this.areSelectionValuesReversed()?this.selectionEnd:this.selectionStart}get finalSelectionEnd(){if(this.isSelectAllActive)return[this._bufferService.cols,this._bufferService.buffer.ybase+this._bufferService.rows-1];if(this.selectionStart){if(!this.selectionEnd||this.areSelectionValuesReversed()){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?e%this._bufferService.cols==0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)-1]:[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[e,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[Math.max(e,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){let e=this.selectionStart,t=this.selectionEnd;return!(!e||!t)&&(e[1]>t[1]||e[1]===t[1]&&e[0]>t[0])}handleTrim(e){return this.selectionStart&&(this.selectionStart[1]-=e),this.selectionEnd&&(this.selectionEnd[1]-=e),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}}},428:function(e,t,n){var r=this&&this.__decorate||function(e,t,n,r){var i,a=arguments.length,o=a<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o},i=this&&this.__param||function(e,t){return function(n,r){t(n,r,e)}};Object.defineProperty(t,"__esModule",{value:!0}),t.CharSizeService=void 0;let a=n(2585),o=n(8460),s=n(844),c=t.CharSizeService=class extends s.Disposable{get hasValidSize(){return this.width>0&&this.height>0}constructor(e,t,n){super(),this._optionsService=n,this.width=0,this.height=0,this._onCharSizeChange=this.register(new o.EventEmitter),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this.register(new d(this._optionsService))}catch{this._measureStrategy=this.register(new u(e,t,this._optionsService))}this.register(this._optionsService.onMultipleOptionChange([`fontFamily`,`fontSize`],(()=>this.measure())))}measure(){let e=this._measureStrategy.measure();e.width===this.width&&e.height===this.height||(this.width=e.width,this.height=e.height,this._onCharSizeChange.fire())}};t.CharSizeService=c=r([i(2,a.IOptionsService)],c);class l extends s.Disposable{constructor(){super(...arguments),this._result={width:0,height:0}}_validateAndSet(e,t){e!==void 0&&e>0&&t!==void 0&&t>0&&(this._result.width=e,this._result.height=t)}}class u extends l{constructor(e,t,n){super(),this._document=e,this._parentElement=t,this._optionsService=n,this._measureElement=this._document.createElement(`span`),this._measureElement.classList.add(`xterm-char-measure-element`),this._measureElement.textContent=`W`.repeat(32),this._measureElement.setAttribute(`aria-hidden`,`true`),this._measureElement.style.whiteSpace=`pre`,this._measureElement.style.fontKerning=`none`,this._parentElement.appendChild(this._measureElement)}measure(){return this._measureElement.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._measureElement.style.fontSize=`${this._optionsService.rawOptions.fontSize}px`,this._validateAndSet(Number(this._measureElement.offsetWidth)/32,Number(this._measureElement.offsetHeight)),this._result}}class d extends l{constructor(e){super(),this._optionsService=e,this._canvas=new OffscreenCanvas(100,100),this._ctx=this._canvas.getContext(`2d`);let t=this._ctx.measureText(`W`);if(!(`width`in t&&`fontBoundingBoxAscent`in t&&`fontBoundingBoxDescent`in t))throw Error(`Required font metrics not supported`)}measure(){this._ctx.font=`${this._optionsService.rawOptions.fontSize}px ${this._optionsService.rawOptions.fontFamily}`;let e=this._ctx.measureText(`W`);return this._validateAndSet(e.width,e.fontBoundingBoxAscent+e.fontBoundingBoxDescent),this._result}}},4269:function(e,t,n){var r=this&&this.__decorate||function(e,t,n,r){var i,a=arguments.length,o=a<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o},i=this&&this.__param||function(e,t){return function(n,r){t(n,r,e)}};Object.defineProperty(t,"__esModule",{value:!0}),t.CharacterJoinerService=t.JoinedCellData=void 0;let a=n(3734),o=n(643),s=n(511),c=n(2585);class l extends a.AttributeData{constructor(e,t,n){super(),this.content=0,this.combinedData=``,this.fg=e.fg,this.bg=e.bg,this.combinedData=t,this._width=n}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(e){throw Error(`not implemented`)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}}t.JoinedCellData=l;let u=t.CharacterJoinerService=class e{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new s.CellData}register(e){let t={id:this._nextCharacterJoinerId++,handler:e};return this._characterJoiners.push(t),t.id}deregister(e){for(let t=0;t<this._characterJoiners.length;t++)if(this._characterJoiners[t].id===e)return this._characterJoiners.splice(t,1),!0;return!1}getJoinedCharacters(e){if(this._characterJoiners.length===0)return[];let t=this._bufferService.buffer.lines.get(e);if(!t||t.length===0)return[];let n=[],r=t.translateToString(!0),i=0,a=0,s=0,c=t.getFg(0),l=t.getBg(0);for(let e=0;e<t.getTrimmedLength();e++)if(t.loadCell(e,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==c||this._workCell.bg!==l){if(e-i>1){let e=this._getJoinedRanges(r,s,a,t,i);for(let t=0;t<e.length;t++)n.push(e[t])}i=e,s=a,c=this._workCell.fg,l=this._workCell.bg}a+=this._workCell.getChars().length||o.WHITESPACE_CELL_CHAR.length}if(this._bufferService.cols-i>1){let e=this._getJoinedRanges(r,s,a,t,i);for(let t=0;t<e.length;t++)n.push(e[t])}return n}_getJoinedRanges(t,n,r,i,a){let o=t.substring(n,r),s=[];try{s=this._characterJoiners[0].handler(o)}catch(e){console.error(e)}for(let t=1;t<this._characterJoiners.length;t++)try{let n=this._characterJoiners[t].handler(o);for(let t=0;t<n.length;t++)e._mergeRanges(s,n[t])}catch(e){console.error(e)}return this._stringRangesToCellRanges(s,i,a),s}_stringRangesToCellRanges(e,t,n){let r=0,i=!1,a=0,s=e[r];if(s){for(let c=n;c<this._bufferService.cols;c++){let n=t.getWidth(c),l=t.getString(c).length||o.WHITESPACE_CELL_CHAR.length;if(n!==0){if(!i&&s[0]<=a&&(s[0]=c,i=!0),s[1]<=a){if(s[1]=c,s=e[++r],!s)break;s[0]<=a?(s[0]=c,i=!0):i=!1}a+=l}}s&&(s[1]=this._bufferService.cols)}}static _mergeRanges(e,t){let n=!1;for(let r=0;r<e.length;r++){let i=e[r];if(n){if(t[1]<=i[0])return e[r-1][1]=t[1],e;if(t[1]<=i[1])return e[r-1][1]=Math.max(t[1],i[1]),e.splice(r,1),e;e.splice(r,1),r--}else{if(t[1]<=i[0])return e.splice(r,0,t),e;if(t[1]<=i[1])return i[0]=Math.min(t[0],i[0]),e;t[0]<i[1]&&(i[0]=Math.min(t[0],i[0]),n=!0)}}return n?e[e.length-1][1]=t[1]:e.push(t),e}};t.CharacterJoinerService=u=r([i(0,c.IBufferService)],u)},5114:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.CoreBrowserService=void 0;let r=n(844),i=n(8460),a=n(3656);class o extends r.Disposable{constructor(e,t,n){super(),this._textarea=e,this._window=t,this.mainDocument=n,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=new s(this._window),this._onDprChange=this.register(new i.EventEmitter),this.onDprChange=this._onDprChange.event,this._onWindowChange=this.register(new i.EventEmitter),this.onWindowChange=this._onWindowChange.event,this.register(this.onWindowChange((e=>this._screenDprMonitor.setWindow(e)))),this.register((0,i.forwardEvent)(this._screenDprMonitor.onDprChange,this._onDprChange)),this._textarea.addEventListener(`focus`,(()=>this._isFocused=!0)),this._textarea.addEventListener(`blur`,(()=>this._isFocused=!1))}get window(){return this._window}set window(e){this._window!==e&&(this._window=e,this._onWindowChange.fire(this._window))}get dpr(){return this.window.devicePixelRatio}get isFocused(){return this._cachedIsFocused===void 0&&(this._cachedIsFocused=this._isFocused&&this._textarea.ownerDocument.hasFocus(),queueMicrotask((()=>this._cachedIsFocused=void 0))),this._cachedIsFocused}}t.CoreBrowserService=o;class s extends r.Disposable{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this.register(new r.MutableDisposable),this._onDprChange=this.register(new i.EventEmitter),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this.register((0,r.toDisposable)((()=>this.clearListener())))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=(0,a.addDisposableDomListener)(this._parentWindow,`resize`,(()=>this._setDprAndFireIfDiffers()))}_setDprAndFireIfDiffers(){this._parentWindow.devicePixelRatio!==this._currentDevicePixelRatio&&this._onDprChange.fire(this._parentWindow.devicePixelRatio),this._updateDpr()}_updateDpr(){this._outerListener&&(this._resolutionMediaMatchList?.removeListener(this._outerListener),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._resolutionMediaMatchList=this._parentWindow.matchMedia(`screen and (resolution: ${this._parentWindow.devicePixelRatio}dppx)`),this._resolutionMediaMatchList.addListener(this._outerListener))}clearListener(){this._resolutionMediaMatchList&&this._outerListener&&(this._resolutionMediaMatchList.removeListener(this._outerListener),this._resolutionMediaMatchList=void 0,this._outerListener=void 0)}}},779:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.LinkProviderService=void 0;let r=n(844);class i extends r.Disposable{constructor(){super(),this.linkProviders=[],this.register((0,r.toDisposable)((()=>this.linkProviders.length=0)))}registerLinkProvider(e){return this.linkProviders.push(e),{dispose:()=>{let t=this.linkProviders.indexOf(e);t!==-1&&this.linkProviders.splice(t,1)}}}}t.LinkProviderService=i},8934:function(e,t,n){var r=this&&this.__decorate||function(e,t,n,r){var i,a=arguments.length,o=a<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o},i=this&&this.__param||function(e,t){return function(n,r){t(n,r,e)}};Object.defineProperty(t,"__esModule",{value:!0}),t.MouseService=void 0;let a=n(4725),o=n(9806),s=t.MouseService=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,n,r,i){return(0,o.getCoords)(window,e,t,n,r,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,i)}getMouseReportCoords(e,t){let n=(0,o.getCoordsRelativeToElement)(window,e,t);if(this._charSizeService.hasValidSize)return n[0]=Math.min(Math.max(n[0],0),this._renderService.dimensions.css.canvas.width-1),n[1]=Math.min(Math.max(n[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(n[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(n[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(n[0]),y:Math.floor(n[1])}}};t.MouseService=s=r([i(0,a.IRenderService),i(1,a.ICharSizeService)],s)},3230:function(e,t,n){var r=this&&this.__decorate||function(e,t,n,r){var i,a=arguments.length,o=a<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o},i=this&&this.__param||function(e,t){return function(n,r){t(n,r,e)}};Object.defineProperty(t,"__esModule",{value:!0}),t.RenderService=void 0;let a=n(6193),o=n(4725),s=n(8460),c=n(844),l=n(7226),u=n(2585),d=t.RenderService=class extends c.Disposable{get dimensions(){return this._renderer.value.dimensions}constructor(e,t,n,r,i,o,u,d){super(),this._rowCount=e,this._charSizeService=r,this._renderer=this.register(new c.MutableDisposable),this._pausedResizeTask=new l.DebouncedIdleTask,this._observerDisposable=this.register(new c.MutableDisposable),this._isPaused=!1,this._needsFullRefresh=!1,this._isNextRenderRedrawOnly=!0,this._needsSelectionRefresh=!1,this._canvasWidth=0,this._canvasHeight=0,this._selectionState={start:void 0,end:void 0,columnSelectMode:!1},this._onDimensionsChange=this.register(new s.EventEmitter),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this.register(new s.EventEmitter),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this.register(new s.EventEmitter),this.onRender=this._onRender.event,this._onRefreshRequest=this.register(new s.EventEmitter),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new a.RenderDebouncer(((e,t)=>this._renderRows(e,t)),u),this.register(this._renderDebouncer),this.register(u.onDprChange((()=>this.handleDevicePixelRatioChange()))),this.register(o.onResize((()=>this._fullRefresh()))),this.register(o.buffers.onBufferActivate((()=>this._renderer.value?.clear()))),this.register(n.onOptionChange((()=>this._handleOptionsChanged()))),this.register(this._charSizeService.onCharSizeChange((()=>this.handleCharSizeChanged()))),this.register(i.onDecorationRegistered((()=>this._fullRefresh()))),this.register(i.onDecorationRemoved((()=>this._fullRefresh()))),this.register(n.onMultipleOptionChange([`customGlyphs`,`drawBoldTextInBrightColors`,`letterSpacing`,`lineHeight`,`fontFamily`,`fontSize`,`fontWeight`,`fontWeightBold`,`minimumContrastRatio`,`rescaleOverlappingGlyphs`],(()=>{this.clear(),this.handleResize(o.cols,o.rows),this._fullRefresh()}))),this.register(n.onMultipleOptionChange([`cursorBlink`,`cursorStyle`],(()=>this.refreshRows(o.buffer.y,o.buffer.y,!0)))),this.register(d.onChangeColors((()=>this._fullRefresh()))),this._registerIntersectionObserver(u.window,t),this.register(u.onWindowChange((e=>this._registerIntersectionObserver(e,t))))}_registerIntersectionObserver(e,t){if(`IntersectionObserver`in e){let n=new e.IntersectionObserver((e=>this._handleIntersectionChange(e[e.length-1])),{threshold:0});n.observe(t),this._observerDisposable.value=(0,c.toDisposable)((()=>n.disconnect()))}}_handleIntersectionChange(e){this._isPaused=e.isIntersecting===void 0?e.intersectionRatio===0:!e.isIntersecting,this._isPaused||this._charSizeService.hasValidSize||this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(e,t,n=!1){this._isPaused?this._needsFullRefresh=!0:(n||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(e,t,this._rowCount))}_renderRows(e,t){this._renderer.value&&(e=Math.min(e,this._rowCount-1),t=Math.min(t,this._rowCount-1),this._renderer.value.renderRows(e,t),this._needsSelectionRefresh&&=(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:e,end:t}),this._onRender.fire({start:e,end:t}),this._isNextRenderRedrawOnly=!0)}resize(e,t){this._rowCount=t,this._fireOnCanvasResize()}_handleOptionsChanged(){this._renderer.value&&(this.refreshRows(0,this._rowCount-1),this._fireOnCanvasResize())}_fireOnCanvasResize(){this._renderer.value&&(this._renderer.value.dimensions.css.canvas.width===this._canvasWidth&&this._renderer.value.dimensions.css.canvas.height===this._canvasHeight||this._onDimensionsChange.fire(this._renderer.value.dimensions))}hasRenderer(){return!!this._renderer.value}setRenderer(e){this._renderer.value=e,this._renderer.value&&(this._renderer.value.onRequestRedraw((e=>this.refreshRows(e.start,e.end,!0))),this._needsSelectionRefresh=!0,this._fullRefresh())}addRefreshCallback(e){return this._renderDebouncer.addRefreshCallback(e)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){this._renderer.value&&(this._renderer.value.clearTextureAtlas?.(),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(e,t){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set((()=>this._renderer.value?.handleResize(e,t))):this._renderer.value.handleResize(e,t),this._fullRefresh())}handleCharSizeChanged(){this._renderer.value?.handleCharSizeChanged()}handleBlur(){this._renderer.value?.handleBlur()}handleFocus(){this._renderer.value?.handleFocus()}handleSelectionChanged(e,t,n){this._selectionState.start=e,this._selectionState.end=t,this._selectionState.columnSelectMode=n,this._renderer.value?.handleSelectionChanged(e,t,n)}handleCursorMove(){this._renderer.value?.handleCursorMove()}clear(){this._renderer.value?.clear()}};t.RenderService=d=r([i(2,u.IOptionsService),i(3,o.ICharSizeService),i(4,u.IDecorationService),i(5,u.IBufferService),i(6,o.ICoreBrowserService),i(7,o.IThemeService)],d)},9312:function(e,t,n){var r=this&&this.__decorate||function(e,t,n,r){var i,a=arguments.length,o=a<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o},i=this&&this.__param||function(e,t){return function(n,r){t(n,r,e)}};Object.defineProperty(t,"__esModule",{value:!0}),t.SelectionService=void 0;let a=n(9806),o=n(9504),s=n(456),c=n(4725),l=n(8460),u=n(844),d=n(6114),f=n(4841),p=n(511),m=n(2585),h=RegExp(`\xA0`,`g`),g=t.SelectionService=class extends u.Disposable{constructor(e,t,n,r,i,a,o,c,d){super(),this._element=e,this._screenElement=t,this._linkifier=n,this._bufferService=r,this._coreService=i,this._mouseService=a,this._optionsService=o,this._renderService=c,this._coreBrowserService=d,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new p.CellData,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this.register(new l.EventEmitter),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this.register(new l.EventEmitter),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this.register(new l.EventEmitter),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this.register(new l.EventEmitter),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=e=>this._handleMouseMove(e),this._mouseUpListener=e=>this._handleMouseUp(e),this._coreService.onUserInput((()=>{this.hasSelection&&this.clearSelection()})),this._trimListener=this._bufferService.buffer.lines.onTrim((e=>this._handleTrim(e))),this.register(this._bufferService.buffers.onBufferActivate((e=>this._handleBufferActivate(e)))),this.enable(),this._model=new s.SelectionModel(this._bufferService),this._activeSelectionMode=0,this.register((0,u.toDisposable)((()=>{this._removeMouseDownListeners()})))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;return!(!e||!t||e[0]===t[0]&&e[1]===t[1])}get selectionText(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;if(!e||!t)return``;let n=this._bufferService.buffer,r=[];if(this._activeSelectionMode===3){if(e[0]===t[0])return``;let i=e[0]<t[0]?e[0]:t[0],a=e[0]<t[0]?t[0]:e[0];for(let o=e[1];o<=t[1];o++){let e=n.translateBufferLineToString(o,!0,i,a);r.push(e)}}else{let i=e[1]===t[1]?t[0]:void 0;r.push(n.translateBufferLineToString(e[1],!0,e[0],i));for(let i=e[1]+1;i<=t[1]-1;i++){let e=n.lines.get(i),t=n.translateBufferLineToString(i,!0);e?.isWrapped?r[r.length-1]+=t:r.push(t)}if(e[1]!==t[1]){let e=n.lines.get(t[1]),i=n.translateBufferLineToString(t[1],!0,0,t[0]);e&&e.isWrapped?r[r.length-1]+=i:r.push(i)}}return r.map((e=>e.replace(h,` `))).join(d.isWindows?`\r
368
368
  `:`
@@ -372,4 +372,4 @@ X-Custom: value`,disabled:n,className:`w-full rounded border border-neutral-700
372
372
  `).pop()??`Fetched`:`Fetched`)}catch(e){l((e instanceof N,e.message))}finally{s(!1)}},Je=async()=>{s(!0),l(void 0),d(void 0);try{let t={};ye!==void 0&&(t.remote=ye);let n=xe.trim();n.length>0&&(t.branch=n);let{output:i}=await L.gitPull(e.id,t);d(i.trim().length>0?i.trim().split(`
373
373
  `).pop()??`Pulled`:`Pulled`),r()}catch(e){l((e instanceof N,e.message))}finally{s(!1)}},Ye=async()=>{s(!0),l(void 0),d(void 0);try{let t={};ye!==void 0&&(t.remote=ye);let n=xe.trim();n.length>0&&(t.branch=n),Ce&&(t.setUpstream=!0);let{output:r}=await L.gitPush(e.id,t);d(r.trim().length>0?r.trim().split(`
374
374
  `).pop()??`Pushed`:`Pushed`),Ce&&we(!1)}catch(e){l((e instanceof N,e.message))}finally{s(!1)}};return(0,R.jsxs)(`div`,{className:`flex h-full flex-col text-xs text-neutral-300`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between border-b border-neutral-800 px-3 py-2`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2 font-medium text-neutral-200`,children:[(0,R.jsx)(De,{size:13}),t?.branch??`—`,t!==void 0&&t.files.length>0&&(0,R.jsx)(`span`,{className:`rounded bg-neutral-800 px-1.5 py-0.5 text-[10px] text-neutral-400`,children:t.files.length})]}),(0,R.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,R.jsx)(`button`,{onClick:()=>je(ke===`split`?`unified`:`split`),className:`rounded p-1 text-neutral-400 hover:bg-neutral-800 hover:text-neutral-200`,title:ke===`split`?`Switch git diffs to unified view`:`Switch git diffs to side-by-side view`,children:ke===`split`?(0,R.jsx)(We,{size:13}):(0,R.jsx)(_e,{size:13})}),(0,R.jsx)(`button`,{onClick:()=>void r(),className:`rounded p-1 text-neutral-400 hover:bg-neutral-800 hover:text-neutral-200`,title:`Refresh`,children:(0,R.jsx)(He,{size:13,className:o?`animate-spin`:``})})]})]}),(n!==void 0||c!==void 0)&&(0,R.jsx)(`div`,{className:`border-b border-red-700/40 bg-red-900/20 px-3 py-1.5 text-[11px] text-red-300 light:border-red-300 light:bg-red-50 light:text-red-700`,children:c??n}),u!==void 0&&(0,R.jsx)(`div`,{className:`border-b border-emerald-700/40 bg-emerald-900/20 px-3 py-1.5 text-[11px] text-emerald-300 light:border-emerald-300 light:bg-emerald-50 light:text-emerald-800`,children:u}),(0,R.jsxs)(`div`,{className:`flex-1 overflow-y-auto`,children:[t===void 0&&(0,R.jsx)(`p`,{className:`px-3 py-3 italic text-neutral-500`,children:`Loading…`}),t?.files.length===0&&(0,R.jsx)(`p`,{className:`px-3 py-3 italic text-neutral-500`,children:`Working tree clean.`}),Me.length>0&&(0,R.jsx)(TN,{label:`Staged`,files:Me,actionLabel:`Unstage all`,onGroupAction:()=>void Re(Me.map(e=>e.path)),onFileAction:e=>void Re([e.path]),fileActionLabel:`Unstage`,onRevert:e=>void Le([e.path]),onClickFile:e=>void Fe(e,!0),openDiffs:me,staged:!0,diffViewType:ke,onHunkAction:(e,t)=>void ze(e,t,`unstage`),pendingHunkPath:ge}),Ne.length>0&&(0,R.jsx)(TN,{label:`Unstaged`,files:Ne,actionLabel:`Stage all`,onGroupAction:()=>void Ie(Ne.map(e=>e.path)),onFileAction:e=>void Ie([e.path]),fileActionLabel:`Stage`,onRevert:e=>void Le([e.path]),onClickFile:e=>void Fe(e,!1),openDiffs:me,staged:!1,diffViewType:ke,onHunkAction:(e,t)=>void ze(e,t,`stage`),pendingHunkPath:ge}),Pe.length>0&&(0,R.jsx)(TN,{label:`Untracked`,files:Pe,actionLabel:`Stage all`,onGroupAction:()=>void Ie(Pe.map(e=>e.path)),onFileAction:e=>void Ie([e.path]),fileActionLabel:`Stage`,onRevert:void 0,onClickFile:e=>void Fe(e,!1),openDiffs:me,staged:!1,diffViewType:ke}),(0,R.jsxs)(`div`,{className:`border-t border-neutral-800/60 px-3 py-3`,children:[(0,R.jsxs)(`div`,{className:`mb-1 flex items-center gap-1 text-[10px] uppercase tracking-wider text-neutral-500`,children:[(0,R.jsx)(Oe,{size:10}),` Commit`]}),(0,R.jsx)(`textarea`,{value:i,onChange:e=>a(e.target.value),placeholder:`Commit message…`,rows:3,className:`w-full resize-none rounded border border-neutral-700 bg-neutral-950 px-2 py-1 text-xs text-neutral-100 outline-none focus:border-neutral-500`}),(0,R.jsxs)(`div`,{className:`mt-1 flex items-center justify-between gap-2`,children:[(0,R.jsxs)(`span`,{className:`text-[10px] text-neutral-500`,children:[Me.length,` staged`]}),(0,R.jsx)(`button`,{onClick:()=>void Ue(),disabled:o||Me.length===0||i.trim().length===0,className:`rounded bg-neutral-100 px-3 py-1 text-xs font-medium text-neutral-900 disabled:cursor-not-allowed disabled:opacity-50`,children:`Commit`})]})]}),(0,R.jsxs)(`div`,{className:`border-t border-neutral-800/60 px-3 py-3`,children:[(0,R.jsxs)(`div`,{className:`mb-1 flex items-center justify-between gap-1 text-[10px] uppercase tracking-wider text-neutral-500`,children:[(0,R.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,R.jsx)(tt,{size:10}),` Push`]}),(0,R.jsx)(`button`,{onClick:()=>{Ee(e=>!e),!Te&&m===void 0&&L.gitBranches(e.id).then(e=>h(e.branches)).catch(()=>void 0),!Te&&g===void 0&&L.gitRemotes(e.id).then(e=>_(e.remotes)).catch(()=>void 0)},className:`rounded px-1 py-0.5 text-[10px] normal-case text-neutral-400 hover:bg-neutral-900 hover:text-neutral-200`,children:Te?`Hide options`:`Options`})]}),Te&&(0,R.jsxs)(`div`,{className:`mb-2 space-y-1.5 rounded border border-neutral-800 bg-neutral-900/40 p-2`,children:[(0,R.jsxs)(`label`,{className:`flex items-center gap-2 text-[11px]`,children:[(0,R.jsx)(`span`,{className:`w-16 shrink-0 text-neutral-400`,children:`Remote`}),Ge.length>0?(0,R.jsxs)(`select`,{value:ye??``,onChange:e=>be(e.target.value===``?void 0:e.target.value),className:`flex-1 rounded border border-neutral-700 bg-neutral-950 px-1 py-0.5 text-[11px] text-neutral-100 outline-none focus:border-neutral-500`,children:[(0,R.jsx)(`option`,{value:``,children:`configured upstream`}),Ge.map(e=>(0,R.jsx)(`option`,{value:e,children:e},e))]}):(0,R.jsx)(`input`,{type:`text`,value:ye??``,onChange:e=>be(e.target.value.length===0?void 0:e.target.value),placeholder:`origin`,className:`flex-1 rounded border border-neutral-700 bg-neutral-950 px-1 py-0.5 text-[11px] text-neutral-100 outline-none focus:border-neutral-500`})]}),(0,R.jsxs)(`label`,{className:`flex items-center gap-2 text-[11px]`,children:[(0,R.jsx)(`span`,{className:`w-16 shrink-0 text-neutral-400`,children:`Branch`}),Ke.length>0?(0,R.jsxs)(`select`,{value:xe,onChange:e=>Se(e.target.value),className:`flex-1 rounded border border-neutral-700 bg-neutral-950 px-1 py-0.5 text-[11px] text-neutral-100 outline-none focus:border-neutral-500`,children:[(0,R.jsx)(`option`,{value:``,children:t?.branch??`current branch`}),Ke.map(e=>(0,R.jsx)(`option`,{value:e,children:e},e))]}):(0,R.jsx)(`input`,{type:`text`,value:xe,onChange:e=>Se(e.target.value),placeholder:t?.branch??`current`,className:`flex-1 rounded border border-neutral-700 bg-neutral-950 px-1 py-0.5 text-[11px] text-neutral-100 outline-none focus:border-neutral-500`})]}),(0,R.jsxs)(`label`,{className:`flex items-center gap-2 text-[11px] text-neutral-300`,children:[(0,R.jsx)(`input`,{type:`checkbox`,checked:Ce,onChange:e=>we(e.target.checked),className:`h-3 w-3`}),(0,R.jsx)(`span`,{children:`Set upstream (first push of a new branch)`})]})]}),(0,R.jsxs)(`div`,{className:`flex gap-1`,children:[(0,R.jsx)(`button`,{onClick:()=>void qe(),disabled:o,className:`flex-1 rounded border border-neutral-700 px-3 py-1 text-xs text-neutral-200 hover:border-neutral-500 disabled:opacity-50`,title:ye===void 0?`git fetch (configured upstream)`:`git fetch ${ye}`,children:`Fetch`}),(0,R.jsx)(`button`,{onClick:()=>void Je(),disabled:o,className:`flex-1 rounded border border-neutral-700 px-3 py-1 text-xs text-neutral-200 hover:border-neutral-500 disabled:opacity-50`,title:`git pull — conflicts surface in the error banner; resolve via the integrated terminal`,children:`Pull`}),(0,R.jsx)(`button`,{onClick:()=>void Ye(),disabled:o,className:`flex-1 rounded border border-neutral-700 px-3 py-1 text-xs text-neutral-200 hover:border-neutral-500 disabled:opacity-50`,title:ye===void 0&&xe.trim().length===0?`git push (configured upstream)`:`git push ${ye??`(upstream)`}${xe.trim().length>0?` ${xe.trim()}`:``}`,children:`Push`})]})]}),(0,R.jsxs)(`div`,{className:`border-t border-neutral-800/60`,children:[(0,R.jsxs)(`button`,{onClick:()=>b(e=>!e),className:`flex w-full items-center justify-between px-3 py-2 text-left text-[10px] uppercase tracking-wider text-neutral-400 hover:bg-neutral-900`,children:[(0,R.jsx)(`span`,{children:`Log`}),(0,R.jsx)(`span`,{children:y?`−`:`+`})]}),y&&(0,R.jsx)(`div`,{className:`px-3 pb-3 text-[11px]`,children:f===void 0?(0,R.jsx)(`p`,{className:`italic text-neutral-500`,children:`Loading…`}):f.length===0?(0,R.jsx)(`p`,{className:`italic text-neutral-500`,children:`No commits yet.`}):(0,R.jsx)(kN,{commits:f})})]}),(0,R.jsxs)(`div`,{className:`border-t border-neutral-800/60`,children:[(0,R.jsxs)(`button`,{onClick:()=>S(e=>!e),className:`flex w-full items-center justify-between px-3 py-2 text-left text-[10px] uppercase tracking-wider text-neutral-400 hover:bg-neutral-900`,children:[(0,R.jsx)(`span`,{children:`Branches`}),(0,R.jsx)(`span`,{children:x?`−`:`+`})]}),x&&(0,R.jsx)(`div`,{className:`px-3 pb-3 text-[11px]`,children:m===void 0?(0,R.jsx)(`p`,{className:`italic text-neutral-500`,children:`Loading…`}):(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`ul`,{className:`space-y-0.5`,children:m.map(e=>{let t=T===e.name;return(0,R.jsxs)(`li`,{className:`group flex items-center gap-1 rounded px-1 py-0.5 font-mono hover:bg-neutral-900 ${e.current?`text-emerald-400 light:text-emerald-700`:`text-neutral-300`}`,children:[(0,R.jsx)(`span`,{className:`w-3 shrink-0`,children:e.current?(0,R.jsx)(le,{size:10}):null}),(0,R.jsx)(`span`,{className:`flex-1 truncate`,title:e.name,children:e.name}),e.remote&&(0,R.jsx)(`span`,{className:`ml-1 text-[10px] text-neutral-600`,children:`remote`}),!e.current&&(0,R.jsxs)(`div`,{className:`hidden gap-0.5 group-hover:flex`,children:[(0,R.jsx)(`button`,{onClick:()=>void de(e.name),disabled:t,className:`rounded px-1 py-0.5 text-[10px] text-neutral-400 hover:bg-neutral-800 hover:text-neutral-100 disabled:opacity-40`,title:e.remote?`Checkout (creates a tracking branch from ${e.name})`:`Checkout ${e.name}`,children:`checkout`}),!e.remote&&(0,R.jsx)(`button`,{onClick:()=>O({kind:`delete`,name:e.name}),disabled:t,className:`rounded p-0.5 text-neutral-500 hover:bg-red-900/30 hover:text-red-300 disabled:opacity-40 light:hover:bg-red-100 light:hover:text-red-700`,title:`Delete branch`,children:(0,R.jsx)(Qe,{size:10})})]})]},e.name)})}),(0,R.jsxs)(`button`,{onClick:()=>O({kind:`create`}),className:`mt-2 flex items-center gap-1 rounded px-1 py-0.5 text-[11px] text-neutral-400 hover:bg-neutral-900 hover:text-neutral-100`,children:[(0,R.jsx)(Ve,{size:10}),` New branch`]})]})})]}),(0,R.jsxs)(`div`,{className:`border-t border-neutral-800/60`,children:[(0,R.jsxs)(`button`,{onClick:()=>w(e=>!e),className:`flex w-full items-center justify-between px-3 py-2 text-left text-[10px] uppercase tracking-wider text-neutral-400 hover:bg-neutral-900`,children:[(0,R.jsx)(`span`,{children:`Remotes`}),(0,R.jsx)(`span`,{children:C?`−`:`+`})]}),C&&(0,R.jsx)(`div`,{className:`px-3 pb-3 text-[11px]`,children:g===void 0?(0,R.jsx)(`p`,{className:`italic text-neutral-500`,children:`Loading…`}):(0,R.jsxs)(R.Fragment,{children:[g.length===0?(0,R.jsx)(`p`,{className:`italic text-neutral-500`,children:`No remotes configured.`}):(0,R.jsx)(`ul`,{className:`space-y-1`,children:g.map(e=>{let t=e.fetchUrl!==e.pushUrl,n=k===e.name;return(0,R.jsxs)(`li`,{className:`group flex flex-col gap-0.5`,children:[(0,R.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,R.jsx)(`span`,{className:`font-mono text-neutral-200`,children:e.name}),t&&(0,R.jsx)(`span`,{className:`rounded bg-amber-900/30 px-1 py-0.5 text-[9px] uppercase tracking-wider text-amber-300 light:bg-amber-100 light:text-amber-800`,children:`fetch ≠ push`}),(0,R.jsx)(`button`,{onClick:()=>M(e.name),disabled:n,className:`ml-auto hidden rounded p-0.5 text-neutral-500 hover:bg-red-900/30 hover:text-red-300 disabled:opacity-40 group-hover:inline-flex light:hover:bg-red-100 light:hover:text-red-700`,title:`Remove remote "${e.name}"`,children:(0,R.jsx)(Qe,{size:10})})]}),(0,R.jsx)(`span`,{className:`break-all font-mono text-[10px] text-neutral-500`,title:e.fetchUrl,children:e.fetchUrl}),t&&(0,R.jsxs)(`span`,{className:`break-all font-mono text-[10px] text-neutral-500`,title:`push → ${e.pushUrl}`,children:[`push → `,e.pushUrl]})]},e.name)})}),(0,R.jsxs)(`button`,{onClick:()=>{re(``),j(``),te(!0)},className:`mt-2 flex items-center gap-1 rounded px-1 py-0.5 text-[11px] text-neutral-400 hover:bg-neutral-900 hover:text-neutral-100`,children:[(0,R.jsx)(Ve,{size:10}),` Add remote`]})]})})]})]}),(0,R.jsx)(wi,{open:D?.kind===`create`,onClose:()=>O(void 0),onSubmit:e=>void fe(e),title:`New branch`,label:`Branch name`,placeholder:`feature/my-change`,primaryLabel:`Create + checkout`}),(0,R.jsx)(Ti,{open:D?.kind===`delete`,onClose:()=>O(void 0),onConfirm:()=>void pe(!1),title:`Delete branch`,message:D?.kind===`delete`?`Delete branch "${D.name}"? Refused if not merged into HEAD; force-delete from the terminal if you really mean it.`:``,primaryLabel:`Delete`,tone:`danger`}),(0,R.jsx)(Ci,{open:A,onClose:()=>te(!1),title:`Add remote`,children:(0,R.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),se()},className:`flex flex-col gap-3 px-4 py-3`,children:[(0,R.jsxs)(`label`,{className:`block space-y-1.5`,children:[(0,R.jsx)(`span`,{className:`text-xs text-neutral-300`,children:`Name`}),(0,R.jsx)(`input`,{type:`text`,value:ne,onChange:e=>re(e.target.value),placeholder:`origin`,autoFocus:!0,className:`w-full rounded-md border border-neutral-700 bg-neutral-950 px-3 py-1.5 font-mono text-sm text-neutral-100 outline-none focus:border-neutral-500`})]}),(0,R.jsxs)(`label`,{className:`block space-y-1.5`,children:[(0,R.jsx)(`span`,{className:`text-xs text-neutral-300`,children:`URL`}),(0,R.jsx)(`input`,{type:`text`,value:ie,onChange:e=>j(e.target.value),placeholder:`git@github.com:user/repo.git`,className:`w-full rounded-md border border-neutral-700 bg-neutral-950 px-3 py-1.5 font-mono text-sm text-neutral-100 outline-none focus:border-neutral-500`})]}),(0,R.jsxs)(`footer`,{className:`flex justify-end gap-2 pt-1`,children:[(0,R.jsx)(`button`,{type:`button`,onClick:()=>te(!1),className:`rounded-md border border-neutral-700 px-3 py-1 text-xs text-neutral-200 hover:bg-neutral-800`,children:`Cancel`}),(0,R.jsx)(`button`,{type:`submit`,disabled:ne.trim().length===0||ie.trim().length===0,className:`rounded-md bg-neutral-100 px-3 py-1 text-xs font-medium text-neutral-900 hover:bg-white disabled:cursor-not-allowed disabled:opacity-40`,children:`Add`})]})]})}),(0,R.jsx)(Ti,{open:ae!==void 0,onClose:()=>M(void 0),onConfirm:()=>void ce(),title:`Remove remote`,message:ae===void 0?``:`Remove remote "${ae}"? The local repo loses its reference to this URL; existing commits aren't affected.`,primaryLabel:`Remove`,tone:`danger`})]})}var wN=3e3;function TN(e){let[t,n]=(0,v.useState)(void 0),r=(0,v.useRef)(void 0),i=()=>{r.current!==void 0&&(window.clearTimeout(r.current),r.current=void 0),n(void 0)};(0,v.useEffect)(()=>()=>{r.current!==void 0&&window.clearTimeout(r.current)},[]);let a=a=>{if(e.onRevert!==void 0){if(t===a.path){i(),e.onRevert(a);return}r.current!==void 0&&window.clearTimeout(r.current),n(a.path),r.current=window.setTimeout(()=>{n(void 0),r.current=void 0},wN)}};return(0,R.jsxs)(`div`,{className:`border-t border-neutral-800/60`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-1.5`,children:[(0,R.jsxs)(`span`,{className:`text-[10px] uppercase tracking-wider text-neutral-500`,children:[e.label,` (`,e.files.length,`)`]}),(0,R.jsx)(`button`,{onClick:e.onGroupAction,className:`text-[10px] text-neutral-400 hover:text-neutral-200`,children:e.actionLabel})]}),(0,R.jsx)(`ul`,{children:e.files.map(n=>{let r=`${n.path}|${e.staged?`staged`:`unstaged`}`,i=e.openDiffs[r],o=t===n.path;return(0,R.jsxs)(`li`,{className:`border-t border-neutral-900`,children:[(0,R.jsxs)(`div`,{className:`group flex items-center gap-2 px-3 py-1 hover:bg-neutral-900`,children:[(0,R.jsx)(`span`,{className:`inline-block w-5 shrink-0 text-center font-mono text-[10px] text-neutral-500`,title:`porcelain code: ${n.code}`,children:EN(n.kind)}),(0,R.jsx)(`button`,{onClick:()=>e.onClickFile(n),className:`flex-1 truncate text-left font-mono`,title:n.path,children:n.path}),e.onRevert!==void 0&&(0,R.jsxs)(`button`,{onClick:()=>a(n),className:o?`inline-flex items-center gap-1 rounded bg-red-900/40 px-1 py-0.5 text-[10px] text-red-200 light:bg-red-100 light:text-red-800`:`hidden items-center gap-1 text-[10px] text-neutral-500 hover:text-red-300 group-hover:inline-flex light:hover:text-red-700`,title:o?`Click again to discard local changes (this cannot be undone)`:`Revert: discard local changes for this file`,children:[(0,R.jsx)(et,{size:10}),o?`Confirm?`:`Revert`]}),(0,R.jsxs)(`button`,{onClick:()=>e.onFileAction(n),className:`ml-3 hidden items-center gap-1 text-[10px] text-neutral-500 hover:text-neutral-200 group-hover:inline-flex`,children:[e.fileActionLabel===`Stage`?(0,R.jsx)(Ve,{size:10}):e.fileActionLabel===`Unstage`?(0,R.jsx)(Le,{size:10}):null,e.fileActionLabel]})]}),i!==void 0&&(0,R.jsx)(`div`,{className:`border-t border-neutral-900 bg-neutral-950`,children:i===`loading`?(0,R.jsx)(`p`,{className:`px-3 py-2 italic text-neutral-500`,children:`Loading…`}):i===`error`?(0,R.jsx)(`p`,{className:`px-3 py-2 text-red-400 light:text-red-700`,children:`Failed to load diff.`}):i.length===0?(0,R.jsx)(`p`,{className:`px-3 py-2 italic text-neutral-500`,children:`(no diff — file is binary or unchanged)`}):(0,R.jsx)(pk,{diff:i,viewType:e.diffViewType,onHunkAction:e.onHunkAction===void 0?void 0:t=>e.onHunkAction?.(n,t),hunkActionLabel:e.staged?`Unstage hunk`:`Stage hunk`,hunkActionDisabled:e.pendingHunkPath===n.path})})]},n.path)})})]})}function EN(e){switch(e){case`modified`:return`M`;case`added`:return`A`;case`deleted`:return`D`;case`renamed`:return`R`;case`copied`:return`C`;case`untracked`:return`?`;case`ignored`:return`!`;case`conflicted`:return`U`;default:return`·`}}var DN=14,ON=36;function kN({commits:e}){let t=bN(e),n=Math.max(1,...t.map(e=>e.width));return(0,R.jsx)(`ul`,{className:`space-y-0`,children:e.map((e,r)=>{let i=t[r];return i===void 0?null:(0,R.jsxs)(`li`,{className:`group flex items-stretch`,children:[(0,R.jsx)(AN,{layout:i,isLast:r===t.length-1,maxLanes:n}),(0,R.jsxs)(`div`,{className:`flex flex-col justify-center gap-0.5 pl-2`,style:{minHeight:ON},children:[(0,R.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,R.jsx)(`span`,{className:`font-mono text-neutral-500`,children:e.hash.slice(0,7)}),e.refs.map((e,t)=>(0,R.jsx)(jN,{ref_:e},`${t}-${e}`)),(0,R.jsx)(`span`,{className:`truncate text-neutral-200`,title:e.message,children:e.message})]}),(0,R.jsxs)(`span`,{className:`font-mono text-[10px] text-neutral-600`,children:[e.author,` · `,new Date(e.date).toLocaleString()]})]})]},e.hash)})})}function AN({layout:e,isLast:t,maxLanes:n}){let r=n*DN,i=ON,a=e.lane*DN+DN/2,o=i/2,s=[];for(let t of e.through){let e=t*DN+DN/2;s.push({x1:e,y1:0,x2:e,y2:i,color:SN(t)})}for(let t of e.incomingLanes){let e=t*DN+DN/2;s.push({x1:e,y1:0,x2:a,y2:o,color:SN(t)})}if(!t)for(let t of e.outgoingLanes){let e=t.lane*DN+DN/2;s.push({x1:a,y1:o,x2:e,y2:i,color:SN(t.lane)})}if(t&&e.outgoingLanes.length>0)for(let t of e.outgoingLanes){let e=t.lane*DN+DN/2;s.push({x1:a,y1:o,x2:e,y2:24,color:SN(t.lane)})}return(0,R.jsxs)(`svg`,{width:r,height:i,viewBox:`0 0 ${r} ${i}`,className:`shrink-0`,"aria-hidden":!0,children:[s.map((e,t)=>(0,R.jsx)(`line`,{x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,stroke:e.color,strokeWidth:1.5,strokeLinecap:`round`},t)),(0,R.jsx)(`circle`,{cx:a,cy:o,r:3.5,fill:SN(e.lane)})]})}function jN({ref_:e}){let t=e.startsWith(`HEAD ->`)||e===`HEAD`,n=e.startsWith(`tag:`),r=t?e.replace(/^HEAD ->\s*/,``):n?e.replace(/^tag:\s*/,``):e;return(0,R.jsx)(`span`,{className:`shrink-0 rounded px-1.5 py-0 text-[9px] uppercase tracking-wider ${t?`bg-emerald-900/40 text-emerald-300 light:bg-emerald-100 light:text-emerald-800`:n?`bg-amber-900/40 text-amber-300 light:bg-amber-100 light:text-amber-800`:e.includes(`/`)?`bg-neutral-800 text-neutral-500`:`bg-neutral-800 text-neutral-300`}`,children:n?`▼ ${r}`:r})}var MN=250,NN=2,PN=200;function FN(){let e=ur(),t=ii(e=>e.openFile),[n,r]=(0,v.useState)(``),[i,a]=(0,v.useState)(!1),[o,s]=(0,v.useState)(!1),[c,l]=(0,v.useState)(!1),[u,d]=(0,v.useState)(``),[f,p]=(0,v.useState)(``),[m,h]=(0,v.useState)(!1),[g,_]=(0,v.useState)(void 0),[y,b]=(0,v.useState)(!1),[x,S]=(0,v.useState)(void 0),C=(0,v.useRef)(void 0),w=(0,v.useCallback)(async t=>{if(e===void 0)return;if(t.length<NN){_(void 0),S(void 0);return}C.current?.abort();let n=new AbortController;C.current=n,b(!0),S(void 0);try{let r={query:t,regex:i,caseSensitive:o,includeGitignored:c,limit:PN,...u.length>0?{include:u}:{},...f.length>0?{exclude:f}:{}},a=await L.searchFiles(e.id,r,n.signal);if(n.signal.aborted)return;_(a)}catch(e){if(n.signal.aborted||e instanceof Error&&e.name===`AbortError`)return;e instanceof N&&e.code===`invalid_response_body`?S(`server returned an unexpected response`):e instanceof Error?S(e.message):S(`search failed`),_(void 0)}finally{n.signal.aborted||b(!1)}},[e,i,o,c,u,f]);(0,v.useEffect)(()=>{let e=window.setTimeout(()=>void w(n),MN);return()=>window.clearTimeout(e)},[n,w]),(0,v.useEffect)(()=>()=>{C.current?.abort()},[]);let T=(0,v.useMemo)(()=>LN(g?.matches??[]),[g]);return e===void 0?(0,R.jsx)(`div`,{className:`p-4 text-xs italic text-neutral-500`,children:`Select a project to search its files.`}):(0,R.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,R.jsxs)(`div`,{className:`border-b border-neutral-800 bg-neutral-900/40 p-2`,children:[(0,R.jsxs)(`div`,{className:`relative`,children:[(0,R.jsx)(Ke,{size:12,className:`pointer-events-none absolute left-2 top-1/2 -translate-y-1/2 text-neutral-500`}),(0,R.jsx)(`input`,{type:`text`,value:n,onChange:e=>r(e.target.value),placeholder:i?`Regex…`:`Search project…`,className:`w-full rounded border border-neutral-700 bg-neutral-900 py-1.5 pl-7 pr-2 text-xs text-neutral-100 placeholder:text-neutral-500 focus:border-neutral-500 focus:outline-none`,autoFocus:!0})]}),(0,R.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1`,children:[(0,R.jsx)(RN,{label:`Regex`,active:i,onClick:()=>a(e=>!e)}),(0,R.jsx)(RN,{label:`Aa`,title:`Case sensitive`,active:o,onClick:()=>s(e=>!e)}),(0,R.jsx)(RN,{label:`+ignored`,title:`Include files that .gitignore would normally skip`,active:c,onClick:()=>l(e=>!e)}),(0,R.jsxs)(`button`,{onClick:()=>h(e=>!e),className:`ml-auto flex items-center gap-1 rounded border border-neutral-700 px-1.5 py-0.5 text-[10px] text-neutral-400 hover:border-neutral-500`,children:[m?(0,R.jsx)(ue,{size:10}):(0,R.jsx)(fe,{size:10}),`Globs`]})]}),m&&(0,R.jsxs)(`div`,{className:`mt-2 grid grid-cols-1 gap-1.5`,children:[(0,R.jsx)(`input`,{type:`text`,value:u,onChange:e=>d(e.target.value),placeholder:`include glob — e.g. **/*.ts`,className:`rounded border border-neutral-700 bg-neutral-900 px-2 py-1 text-[11px] text-neutral-200 placeholder:text-neutral-500 focus:border-neutral-500 focus:outline-none`}),(0,R.jsx)(`input`,{type:`text`,value:f,onChange:e=>p(e.target.value),placeholder:`exclude glob — e.g. **/dist/**`,className:`rounded border border-neutral-700 bg-neutral-900 px-2 py-1 text-[11px] text-neutral-200 placeholder:text-neutral-500 focus:border-neutral-500 focus:outline-none`})]})]}),(0,R.jsxs)(`div`,{className:`flex-1 overflow-auto`,children:[(0,R.jsx)(zN,{query:n,loading:y,error:x,results:g,totalFiles:T.length}),(0,R.jsx)(`ul`,{className:`divide-y divide-neutral-900`,children:T.map(([n,r])=>(0,R.jsx)(BN,{path:n,matches:r,onPick:r=>void t(e.id,IN(e.path,n),{line:r.line,column:r.column})},n))})]})]})}function IN(e,t){return t.startsWith(`/`)?t:`${e}${e.endsWith(`/`)?``:`/`}${t}`}function LN(e){let t=new Map;for(let n of e){let e=t.get(n.path);e===void 0?t.set(n.path,[n]):e.push(n)}return Array.from(t.entries())}function RN({label:e,title:t,active:n,onClick:r}){return(0,R.jsx)(`button`,{onClick:r,title:t,className:`rounded border px-1.5 py-0.5 text-[10px] ${n?`border-neutral-500 bg-neutral-800 text-neutral-100`:`border-neutral-700 text-neutral-400 hover:border-neutral-500`}`,children:e})}function zN({query:e,loading:t,error:n,results:r,totalFiles:i}){return e.length===0?(0,R.jsxs)(`div`,{className:`flex flex-col items-center gap-2 px-4 py-8 text-center text-xs text-neutral-500`,children:[(0,R.jsx)(we,{size:20,className:`text-neutral-700`}),(0,R.jsx)(`p`,{children:`Type to search across project files.`}),(0,R.jsxs)(`p`,{className:`text-[10px] text-neutral-600`,children:[`Min `,NN,` chars · Click a result to jump to that line.`]})]}):e.length<NN?(0,R.jsxs)(`div`,{className:`px-4 py-3 text-xs italic text-neutral-500`,children:[`Keep typing — at least `,NN,` characters.`]}):t&&r===void 0?(0,R.jsxs)(`div`,{className:`flex items-center gap-2 px-4 py-3 text-xs text-neutral-400`,children:[(0,R.jsx)(Me,{size:12,className:`animate-spin`}),` Searching…`]}):n===void 0?r===void 0?null:r.matches.length===0?(0,R.jsx)(`div`,{className:`px-4 py-3 text-xs italic text-neutral-500`,children:`No matches.`}):(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-b border-neutral-800 bg-neutral-950/60 px-3 py-1.5 text-[10px]`,children:[(0,R.jsxs)(`span`,{className:`text-neutral-400`,children:[r.matches.length,` match`,r.matches.length===1?``:`es`,` in `,i,` `,`file`,i===1?``:`s`,r.truncated&&(0,R.jsxs)(`span`,{className:`ml-1 text-amber-400 light:text-amber-700`,children:[`· truncated at `,PN]})]}),r.engine===`node`&&(0,R.jsx)(`span`,{className:`rounded bg-amber-900/40 px-1.5 py-0.5 text-[9px] uppercase tracking-wider text-amber-300 light:bg-amber-100 light:text-amber-800`,title:`ripgrep was not found on this host — using the slower in-process fallback`,children:`fallback`})]}):(0,R.jsx)(`div`,{className:`px-4 py-3 text-xs text-rose-400 light:text-rose-700`,children:n})}function BN({path:e,matches:t,onPick:n}){let[r,i]=(0,v.useState)(!0);return(0,R.jsxs)(`li`,{className:`bg-neutral-950`,children:[(0,R.jsxs)(`button`,{onClick:()=>i(e=>!e),className:`flex w-full items-center gap-1 truncate px-2 py-1 text-left text-[11px] text-neutral-300 hover:bg-neutral-900`,title:e,children:[r?(0,R.jsx)(ue,{size:11}):(0,R.jsx)(fe,{size:11}),(0,R.jsx)(`span`,{className:`truncate font-mono`,children:e}),(0,R.jsx)(`span`,{className:`ml-auto text-[10px] text-neutral-500`,children:t.length})]}),r&&(0,R.jsx)(`ul`,{children:t.map((t,r)=>(0,R.jsx)(`li`,{children:(0,R.jsxs)(`button`,{onClick:()=>n(t),className:`flex w-full gap-2 px-2 py-0.5 text-left font-mono text-[11px] text-neutral-400 hover:bg-neutral-900 hover:text-neutral-100`,title:`${e}:${t.line}:${t.column}`,children:[(0,R.jsx)(`span`,{className:`w-10 shrink-0 text-right text-neutral-600`,children:t.line}),(0,R.jsx)(`span`,{className:`truncate`,children:VN(t.lineSnippet,t.column,t.length)})]})},`${t.line}:${t.column}:${r}`))})]})}function VN(e,t,n){let r=Math.max(0,Math.min(e.length,t-1)),i=Math.max(r,Math.min(e.length,r+n)),a=e.length-e.trimStart().length,o=Math.min(a,r),s=e.slice(o,r),c=e.slice(r,i),l=e.slice(i);return n===0||c.length===0?(0,R.jsx)(`span`,{children:e.slice(o)}):(0,R.jsxs)(`span`,{children:[(0,R.jsx)(`span`,{children:s}),(0,R.jsx)(`span`,{className:`bg-amber-700/30 text-amber-100 light:bg-amber-200 light:text-amber-900`,children:c}),(0,R.jsx)(`span`,{children:l})]})}var HN=3;function UN(){let e=qr(e=>e.activeSessionId),t=qr(t=>e===void 0?0:t.agentEndCountBySession[e]??0),n=qr(t=>e===void 0?0:t.compactionEndCountBySession[e]??0),r=qr(t=>e===void 0?!1:t.streamingBySession[e]??!1),i=qr(t=>e===void 0?``:t.streamingTextBySession[e]??``),[a,o]=(0,v.useState)(void 0),[s,c]=(0,v.useState)(!1),[l,u]=(0,v.useState)(void 0),[d,f]=(0,v.useState)(!1),[p,m]=(0,v.useState)(!1),[h,g]=(0,v.useState)(``),[_,y]=(0,v.useState)(void 0),b=(0,v.useRef)(void 0),x=async()=>{if(e===void 0){o(void 0);return}b.current?.abort();let t=new AbortController;b.current=t,c(!0),u(void 0);try{let n=await L.getSessionContext(e,t.signal);if(t.signal.aborted)return;o(n)}catch(e){if(t.signal.aborted||e instanceof Error&&e.name===`AbortError`)return;e instanceof N&&e.status===404?(o(void 0),u(void 0)):u(e instanceof N?e.code:e.message)}finally{t.signal.aborted||c(!1)}};return(0,v.useEffect)(()=>{x()},[e,t,n]),(0,v.useEffect)(()=>()=>{b.current?.abort()},[]),e===void 0?(0,R.jsx)(`div`,{className:`flex h-full items-center justify-center px-4 py-6 text-center text-xs italic text-neutral-500`,children:`Select a session to inspect its context.`}):(0,R.jsxs)(`div`,{className:`flex h-full flex-col bg-neutral-950 text-xs text-neutral-200`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between border-b border-neutral-800 bg-neutral-900/40 px-3 py-1.5`,children:[(0,R.jsx)(`span`,{className:`text-[10px] uppercase tracking-wider text-neutral-400`,children:`Context inspector`}),(0,R.jsxs)(`div`,{className:`flex items-center gap-1`,children:[s&&(0,R.jsx)(Me,{size:11,className:`animate-spin text-neutral-500`}),(0,R.jsx)(`button`,{onClick:()=>void x(),disabled:s,className:`rounded p-1 text-neutral-500 hover:bg-neutral-800 hover:text-neutral-200 disabled:opacity-40`,title:`Refresh`,children:(0,R.jsx)(He,{size:11,className:s?`animate-spin`:``})})]})]}),l!==void 0&&(0,R.jsx)(`div`,{className:`border-b border-red-700/40 bg-red-900/20 px-3 py-1.5 text-[11px] text-red-300 light:border-red-300 light:bg-red-50 light:text-red-700`,children:l}),(0,R.jsx)(`div`,{className:`flex-1 overflow-y-auto`,children:a===void 0?(0,R.jsx)(`div`,{className:`px-4 py-6 text-center text-xs italic text-neutral-500`,children:s?`Loading…`:`No data — try refresh.`}):(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(WN,{data:a,turnsExpanded:d,onToggleTurns:()=>f(e=>!e)}),(0,R.jsx)(YN,{messages:a.messages,showThinking:p,onToggleThinking:()=>m(e=>!e),onViewRaw:(e,t)=>y({index:e,payload:t}),search:h,onSearchChange:g,...r&&i.length>0?{streamingTail:{content:i}}:{}})]})}),_!==void 0&&(0,R.jsx)(ZN,{title:`Message ${_.index} — raw AgentMessage JSON`,payload:_.payload,onClose:()=>y(void 0)})]})}function WN({data:e,turnsExpanded:t,onToggleTurns:n}){let r=e.contextUsage,i=(0,v.useMemo)(()=>qN(e.messages,r.tokens),[e.messages,r.tokens]),a=(0,v.useMemo)(()=>tP(e.messages,e.turns),[e.messages,e.turns]),o=r.tokens??i.total,s=r.contextWindow>0?Math.min(1,o/r.contextWindow):0;return(0,R.jsxs)(`div`,{className:`space-y-2 border-b border-neutral-800 px-3 py-2`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsxs)(`div`,{className:`mb-1 flex items-center justify-between text-[10px] text-neutral-400`,children:[(0,R.jsxs)(`span`,{children:[`Context window (`,r.tokens===void 0?`estimate`:`current`,`)`]}),(0,R.jsxs)(`span`,{children:[iP(o),` /`,` `,r.contextWindow>0?iP(r.contextWindow):`unknown`,r.contextWindow>0&&(0,R.jsxs)(`span`,{className:`ml-1 text-neutral-600`,children:[`(`,(s*100).toFixed(1),`%)`]})]})]}),(0,R.jsx)(`div`,{className:`h-1.5 w-full overflow-hidden rounded bg-neutral-800`,children:(0,R.jsx)(`div`,{className:`h-full ${s>.9?`bg-red-500`:s>.7?`bg-amber-500`:`bg-emerald-500`}`,style:{width:`${Math.max(2,Math.min(100,s*100))}%`}})})]}),(0,R.jsx)(KN,{breakdown:i,contextWindow:r.contextWindow}),(0,R.jsxs)(`div`,{className:`space-y-0.5 border-t border-neutral-800 pt-1.5`,children:[e.turns.length>0&&(()=>{let t=e.turns[e.turns.length-1],n=a.get(t.index)??0;return(0,R.jsxs)(`div`,{className:`flex items-center justify-between text-[11px]`,children:[(0,R.jsx)(`span`,{className:`text-neutral-500`,children:`Last turn`}),(0,R.jsxs)(`span`,{className:`font-mono text-neutral-300`,title:`New = user message + tool results since the prior assistant turn (estimate). Out = assistant output tokens. Cost = that turn's billed cost.`,children:[`~`,iP(n),` new · `,iP(t.outputTokens),` out ·`,` `,aP(t.cost)]})]})})(),(0,R.jsxs)(`div`,{className:`flex items-center justify-between text-[11px]`,children:[(0,R.jsx)(`span`,{className:`text-neutral-500`,title:"Sum of `usage.input` per turn — NEW non-cached input the LLM saw across the session. Excludes cached portions (tracked separately below).",children:`Input (lifetime)`}),(0,R.jsx)(`span`,{className:`font-mono text-neutral-400`,children:iP(e.totalInputTokens)})]}),(0,R.jsxs)(`div`,{className:`flex items-center justify-between text-[11px]`,children:[(0,R.jsx)(`span`,{className:`text-neutral-500`,title:"Sum of `usage.cacheRead` per turn — prior context served from the prompt cache. Counted ONCE PER API CALL: every turn re-reads the same cached content and re-pays the (discounted) read fee, so this number grows ~quadratically with conversation length. Billed at ~10% of input rate on most providers.",children:`Cache served (lifetime)`}),(0,R.jsx)(`span`,{className:`font-mono text-neutral-400`,children:iP(e.totalCacheReadTokens)})]}),(0,R.jsxs)(`div`,{className:`flex items-center justify-between text-[11px]`,children:[(0,R.jsx)(`span`,{className:`text-neutral-500`,title:"Sum of `usage.cacheWrite` per turn — portions cached for reuse on subsequent turns. Billed at ~125% of input rate; small premium up front for big savings on the cache-served line.",children:`Cache written (lifetime)`}),(0,R.jsx)(`span`,{className:`font-mono text-neutral-400`,children:iP(e.totalCacheWriteTokens)})]}),(0,R.jsxs)(`div`,{className:`flex items-center justify-between text-[11px]`,children:[(0,R.jsx)(`span`,{className:`text-neutral-500`,title:"Sum of `usage.output` per turn — assistant tokens generated.",children:`Output (lifetime)`}),(0,R.jsx)(`span`,{className:`font-mono text-neutral-400`,children:iP(e.totalOutputTokens)})]}),(0,R.jsxs)(`div`,{className:`flex items-center justify-between text-[11px] font-medium`,children:[(0,R.jsx)(`span`,{className:`text-neutral-300`,children:`Total cost`}),(0,R.jsx)(`span`,{className:`font-mono text-emerald-400 light:text-emerald-700`,children:aP(e.totalCost)})]})]}),e.turns.length>0&&(0,R.jsxs)(`div`,{children:[(0,R.jsxs)(`button`,{onClick:n,className:`flex items-center gap-1 text-[10px] uppercase tracking-wider text-neutral-400 hover:text-neutral-200`,children:[t?(0,R.jsx)(ue,{size:10}):(0,R.jsx)(fe,{size:10}),`Per-turn (`,e.turns.length,`)`]}),t&&(0,R.jsx)(JN,{turns:e.turns,newDeltas:a})]})]})}var GN=[{key:`systemAndTools`,label:`System + tools`,color:`#64748b`},{key:`userPrompts`,label:`User prompts`,color:`#0ea5e9`},{key:`assistantText`,label:`Assistant text`,color:`#a78bfa`},{key:`thinking`,label:`Thinking`,color:`#71717a`},{key:`toolCalls`,label:`Tool calls`,color:`#f59e0b`},{key:`toolResults`,label:`Tool results`,color:`#10b981`},{key:`images`,label:`Images`,color:`#ec4899`}];function KN({breakdown:e,contextWindow:t}){let n=e.total;return n===0?null:(0,R.jsxs)(`div`,{children:[(0,R.jsxs)(`div`,{className:`mb-1 flex items-center justify-between text-[10px] text-neutral-400`,children:[(0,R.jsx)(`span`,{children:`What’s in the context`}),(0,R.jsxs)(`span`,{className:`text-neutral-600`,title:`Sum of category estimates (~chars/3)`,children:[`~`,iP(n),` tok`,t>0&&(0,R.jsxs)(`span`,{className:`ml-1`,children:[`(`,(n/t*100).toFixed(1),`%)`]})]})]}),(0,R.jsx)(`div`,{className:`flex h-1.5 w-full overflow-hidden rounded bg-neutral-800`,children:GN.map(t=>{let r=e[t.key];if(r===0)return null;let i=r/n*100;return(0,R.jsx)(`div`,{style:{width:`${i}%`,background:t.color},title:`${t.label}: ${iP(r)} tok (${i.toFixed(1)}%)`},t.key)})}),(0,R.jsx)(`ul`,{className:`mt-1 grid grid-cols-2 gap-x-3 gap-y-0.5 text-[10px]`,children:GN.map(t=>{let r=e[t.key];if(r===0)return null;let i=r/n*100;return(0,R.jsxs)(`li`,{className:`flex items-center gap-1.5`,children:[(0,R.jsx)(`span`,{className:`inline-block h-2 w-2 rounded-sm`,style:{background:t.color},"aria-hidden":`true`}),(0,R.jsx)(`span`,{className:`flex-1 truncate text-neutral-400`,children:t.label}),(0,R.jsx)(`span`,{className:`font-mono text-neutral-300`,children:iP(r)}),(0,R.jsxs)(`span`,{className:`w-10 text-right text-neutral-600`,children:[i.toFixed(0),`%`]})]},t.key)})})]})}function qN(e,t){let n=0,r=0,i=0,a=0,o=0,s=0;for(let t of e){let e=typeof t.role==`string`?t.role:``,c=t.content;if(e===`user`){if(typeof c==`string`)n+=c.length;else if(Array.isArray(c))for(let e of c){let t=e;t.type===`text`&&typeof t.text==`string`?n+=t.text.length:t.type===`image`&&(s+=1)}}else if(e===`assistant`&&Array.isArray(c))for(let e of c){let t=e;if(t.type===`text`&&typeof t.text==`string`)r+=t.text.length;else if(t.type===`thinking`&&typeof t.thinking==`string`)i+=t.thinking.length;else if(t.type===`toolCall`)try{a+=JSON.stringify(t.arguments??{}).length}catch{a+=String(t.arguments??``).length}}else if(e===`toolResult`){if(typeof c==`string`)o+=c.length;else if(Array.isArray(c))for(let e of c){let t=e;t.type===`text`&&typeof t.text==`string`?o+=t.text.length:t.type===`image`&&(s+=1)}}}let c=e=>Math.ceil(e/HN),l=c(n),u=c(r),d=c(i),f=c(a),p=c(o),m=s*1500,h=l+u+d+f+p+m,g=t!==void 0&&t>h?t-h:0;return{systemAndTools:g,userPrompts:l,assistantText:u,thinking:d,toolCalls:f,toolResults:p,images:m,total:h+g}}function JN({turns:e,newDeltas:t}){return(0,R.jsx)(`div`,{className:`mt-1 overflow-x-auto`,children:(0,R.jsxs)(`table`,{className:`w-full font-mono text-[10px]`,children:[(0,R.jsx)(`thead`,{className:`text-neutral-500`,children:(0,R.jsxs)(`tr`,{children:[(0,R.jsx)(`th`,{className:`pr-2 text-left font-normal`,children:`#`}),(0,R.jsx)(`th`,{className:`pr-2 text-left font-normal`,children:`Model`}),(0,R.jsx)(`th`,{className:`pr-2 text-right font-normal`,title:`Estimated new tokens this turn — user message + tool results since the prior assistant turn (~chars/3 estimate). Distinct from Prompt.`,children:`New`}),(0,R.jsx)(`th`,{className:`pr-2 text-right font-normal`,title:`Full prompt sent to the LLM = usage.input + cacheRead + cacheWrite. Includes ALL re-sent prior context — this grows monotonically with conversation length, which is normal LLM behavior.`,children:`Prompt`}),(0,R.jsx)(`th`,{className:`pr-2 text-right font-normal`,title:`Assistant output tokens this turn`,children:`Out`}),(0,R.jsx)(`th`,{className:`text-right font-normal`,title:`Cost billed for this turn`,children:`Cost`})]})}),(0,R.jsx)(`tbody`,{className:`text-neutral-300`,children:e.map((e,n)=>{let r=e.inputTokens+e.cacheReadTokens+e.cacheWriteTokens,i=t.get(e.index)??0;return(0,R.jsxs)(`tr`,{className:`border-t border-neutral-800/60`,children:[(0,R.jsx)(`td`,{className:`pr-2 text-neutral-600`,children:n+1}),(0,R.jsx)(`td`,{className:`max-w-[140px] truncate pr-2`,title:`${e.provider}/${e.model}`,children:e.model}),(0,R.jsxs)(`td`,{className:`pr-2 text-right text-neutral-200`,title:`New content (estimate)`,children:[`~`,iP(i)]}),(0,R.jsx)(`td`,{className:`pr-2 text-right`,title:`input ${iP(e.inputTokens)} + cR ${iP(e.cacheReadTokens)} + cW ${iP(e.cacheWriteTokens)}`,children:iP(r)}),(0,R.jsx)(`td`,{className:`pr-2 text-right`,children:iP(e.outputTokens)}),(0,R.jsx)(`td`,{className:`text-right text-emerald-400 light:text-emerald-700`,children:aP(e.cost)})]},`${e.index}-${e.timestamp}`)})})]})})}function YN({messages:e,showThinking:t,onToggleThinking:n,onViewRaw:r,search:i,onSearchChange:a,streamingTail:o}){let s=i.trim().toLowerCase(),c=(0,v.useMemo)(()=>s.length===0?e.map((e,t)=>({msg:e,originalIndex:t})):e.map((e,t)=>({msg:e,originalIndex:t})).filter(({msg:e})=>(typeof e.role==`string`?e.role.toLowerCase():``).includes(s)?!0:$N(e,!0).toLowerCase().includes(s)),[e,s]);return(0,R.jsxs)(`div`,{className:`px-2 py-2`,children:[(0,R.jsxs)(`div`,{className:`mb-1 flex items-center justify-between gap-2 px-1`,children:[(0,R.jsxs)(`span`,{className:`shrink-0 text-[10px] uppercase tracking-wider text-neutral-400`,children:[`Messages (`,s.length>0?`${c.length}/${e.length}`:e.length,`)`]}),(0,R.jsxs)(`label`,{className:`flex items-center gap-1 text-[10px] text-neutral-500 hover:text-neutral-300`,children:[(0,R.jsx)(`input`,{type:`checkbox`,checked:t,onChange:n,className:`h-3 w-3`}),`Show thinking blocks`]})]}),e.length>=10&&(0,R.jsxs)(`div`,{className:`relative mb-1 px-1`,children:[(0,R.jsx)(Ke,{size:11,className:`pointer-events-none absolute left-2.5 top-1/2 -translate-y-1/2 text-neutral-500`}),(0,R.jsx)(`input`,{type:`text`,value:i,onChange:e=>a(e.target.value),placeholder:`Find in messages…`,className:`w-full rounded border border-neutral-800 bg-neutral-950 py-1 pl-6 pr-2 text-[11px] text-neutral-200 placeholder:text-neutral-600 focus:border-neutral-600 focus:outline-none`})]}),(0,R.jsxs)(`ul`,{className:`space-y-1`,children:[c.map(({msg:e,originalIndex:n})=>(0,R.jsx)(XN,{index:n,message:e,showThinking:t,onViewRaw:()=>r(n,e)},n)),o!==void 0&&s.length===0&&(0,R.jsx)(`li`,{className:`rounded border border-violet-700/40 bg-violet-900/10 light:border-violet-300 light:bg-violet-50`,children:(0,R.jsxs)(`div`,{className:`flex items-start gap-2 px-2 py-1.5`,children:[(0,R.jsx)(Me,{size:11,className:`mt-0.5 shrink-0 animate-spin text-violet-300 light:text-violet-700`}),(0,R.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,R.jsx)(`div`,{className:`flex items-center gap-1.5`,children:(0,R.jsx)(`span`,{className:`rounded bg-violet-900/40 px-1.5 py-0.5 text-[9px] uppercase tracking-wider text-violet-300 light:bg-violet-100 light:text-violet-800`,children:`assistant (streaming)`})}),(0,R.jsx)(`p`,{className:`line-clamp-2 text-[11px] text-neutral-300`,children:o.content})]})]})})]})]})}function XN({index:e,message:t,showThinking:n,onViewRaw:r}){let[i,a]=(0,v.useState)(!1),o=typeof t.role==`string`?t.role:`unknown`,s=o===`compactionSummary`,c=(0,v.useMemo)(()=>$N(t,n),[t,n]),l=eP(t),u=typeof t.timestamp==`number`?t.timestamp:0;return(0,R.jsxs)(`li`,{className:`rounded border border-neutral-800/70 bg-neutral-900/30`,children:[(0,R.jsxs)(`button`,{onClick:()=>a(e=>!e),className:`flex w-full items-start gap-2 px-2 py-1.5 text-left hover:bg-neutral-900/60`,children:[(0,R.jsx)(`span`,{className:`pt-0.5 text-neutral-600`,children:i?(0,R.jsx)(ue,{size:11}):(0,R.jsx)(fe,{size:11})}),(0,R.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,R.jsx)(`span`,{className:`rounded px-1.5 py-0.5 text-[9px] uppercase tracking-wider ${QN(o)}`,children:o}),s&&(0,R.jsx)(`span`,{className:`rounded bg-fuchsia-900/40 px-1.5 py-0.5 text-[9px] text-fuchsia-300 light:bg-fuchsia-100 light:text-fuchsia-800`,children:`compacted`}),(0,R.jsxs)(`span`,{className:`text-[10px] text-neutral-600`,children:[`~`,iP(l),` tok`]}),u>0&&(0,R.jsx)(`span`,{className:`text-[10px] text-neutral-600`,children:new Date(u).toLocaleTimeString()})]}),!i&&c.length>0&&(0,R.jsx)(`p`,{className:`line-clamp-2 text-[11px] text-neutral-400`,children:c})]}),(0,R.jsx)(`button`,{onClick:e=>{e.stopPropagation(),r()},className:`rounded p-1 text-neutral-500 hover:bg-neutral-800 hover:text-neutral-100`,title:`View raw AgentMessage JSON`,children:(0,R.jsx)(ge,{size:11})})]}),i&&(0,R.jsx)(`div`,{className:`space-y-1 border-t border-neutral-800/70 px-3 py-2`,children:nP(t,n,e)})]})}function ZN({title:e,payload:t,onClose:n}){let r=(0,v.useMemo)(()=>{try{return JSON.stringify(t,null,2)}catch{return String(t)}},[t]);return(0,v.useEffect)(()=>{let e=e=>{e.key===`Escape`&&n()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[n]),(0,R.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/70 px-4 py-8`,onClick:n,children:(0,R.jsxs)(`div`,{onClick:e=>e.stopPropagation(),className:`flex h-full max-h-[720px] w-full max-w-4xl flex-col overflow-hidden rounded-lg border border-neutral-800 bg-neutral-950 shadow-2xl`,children:[(0,R.jsxs)(`header`,{className:`flex items-center justify-between border-b border-neutral-800 px-3 py-2`,children:[(0,R.jsx)(`span`,{className:`text-xs text-neutral-200`,children:e}),(0,R.jsx)(`button`,{onClick:n,className:`rounded p-2 text-neutral-400 hover:bg-neutral-800 hover:text-neutral-200`,title:`Close (Esc)`,children:(0,R.jsx)(rt,{size:20})})]}),(0,R.jsx)(Da,{code:r,language:`json`,theme:Xi.vsDark,children:({style:e,tokens:t,getLineProps:n,getTokenProps:r})=>(0,R.jsx)(`pre`,{className:`flex-1 overflow-auto whitespace-pre p-3 font-mono text-[11px]`,style:{...e,background:`transparent`},children:t.map((e,t)=>(0,R.jsx)(`div`,{...n({line:e}),children:e.map((e,t)=>(0,R.jsx)(`span`,{...r({token:e})},t))},t))})})]})})}function QN(e){return e===`user`?`bg-sky-900/40 text-sky-300 light:bg-sky-100 light:text-sky-800`:e===`assistant`?`bg-violet-900/40 text-violet-300 light:bg-violet-100 light:text-violet-800`:e===`tool`||e===`toolResult`?`bg-amber-900/40 text-amber-300 light:bg-amber-100 light:text-amber-800`:e===`compactionSummary`?`bg-fuchsia-900/40 text-fuchsia-300 light:bg-fuchsia-100 light:text-fuchsia-800`:`bg-neutral-800 text-neutral-400`}function $N(e,t){let n=e.content;if(typeof n==`string`)return n.slice(0,200);if(!Array.isArray(n))return``;let r=[];for(let e of n){let n=e;n.type===`thinking`&&!t||(n.type===`text`&&typeof n.text==`string`?r.push(n.text):n.type===`thinking`&&typeof n.thinking==`string`?r.push(`[thinking] ${n.thinking}`):n.type===`toolCall`&&typeof n.name==`string`&&r.push(`[tool: ${n.name}]`))}return r.join(` `).slice(0,200)}function eP(e){let t=e.usage;if(t!==void 0&&typeof t.totalTokens==`number`)return t.totalTokens;let n=e.content;if(typeof n==`string`)return Math.ceil(n.length/HN);if(!Array.isArray(n))return 0;let r=0,i=0;for(let e of n){let t=e;typeof t.text==`string`&&(r+=t.text.length),t.type===`image`&&(i+=1)}return Math.ceil(r/HN)+i*1500}function tP(e,t){let n=new Map,r=-1;for(let i of t){let t=0;for(let n=r+1;n<i.index;n++){let r=e[n];if(r===void 0)continue;let i=typeof r.role==`string`?r.role:``;i!==`user`&&i!==`toolResult`||(t+=eP(r))}n.set(i.index,t),r=i.index}return n}function nP(e,t,n){let r=typeof e.role==`string`?e.role:`unknown`,i=e.content;return r===`toolResult`?(0,R.jsxs)(`div`,{children:[(0,R.jsxs)(`p`,{className:`mb-1 text-[10px] text-neutral-500`,children:[`tool: `,(0,R.jsx)(`span`,{className:`font-mono`,children:String(e.toolName??`unknown`)}),` `,e.isError===!0&&(0,R.jsx)(`span`,{className:`text-red-400 light:text-red-700`,children:`(error)`})]}),(0,R.jsx)(`pre`,{className:`max-h-64 overflow-auto whitespace-pre-wrap break-words rounded bg-neutral-950 p-2 font-mono text-[10px] text-neutral-300`,children:rP(i)})]}):Array.isArray(i)?(0,R.jsx)(R.Fragment,{children:i.map((e,r)=>{let i=e;if(i.type===`thinking`&&!t)return null;if(i.type===`text`||i.type===`thinking`){let e=i.type===`thinking`?i.thinking:i.text;return(0,R.jsx)(`pre`,{className:`whitespace-pre-wrap break-words font-sans text-[11px] ${i.type===`thinking`?`italic text-neutral-500`:`text-neutral-200`}`,children:String(e??``)},`${n}-${r}`)}return i.type===`toolCall`?(0,R.jsxs)(`div`,{className:`rounded border border-neutral-800 p-2`,children:[(0,R.jsxs)(`p`,{className:`mb-1 text-[10px] text-neutral-500`,children:[`tool call: `,(0,R.jsx)(`span`,{className:`font-mono`,children:String(i.name??`unknown`)})]}),(0,R.jsx)(`pre`,{className:`max-h-48 overflow-auto whitespace-pre-wrap break-words font-mono text-[10px] text-neutral-300`,children:rP(i.arguments)})]},`${n}-${r}`):i.type===`image`?(0,R.jsx)(`p`,{className:`text-[11px] italic text-neutral-500`,children:`[image attachment]`},`${n}-${r}`):(0,R.jsx)(`pre`,{className:`whitespace-pre-wrap break-words font-mono text-[10px] text-neutral-500`,children:rP(i)},`${n}-${r}`)})}):typeof i==`string`?(0,R.jsx)(`pre`,{className:`whitespace-pre-wrap break-words font-sans text-[11px] text-neutral-200`,children:i}):(0,R.jsx)(`pre`,{className:`whitespace-pre-wrap break-words font-mono text-[10px] text-neutral-500`,children:rP(e)})}function rP(e){try{return JSON.stringify(e,null,2)}catch{return String(e)}}function iP(e){return e<1e3?String(e):e<1e6?`${(e/1e3).toFixed(+(e<1e4))}k`:`${(e/1e6).toFixed(2)}M`}function aP(e){return e===0?`$0`:e<.01?`$${e.toFixed(4)}`:e<1?`$${e.toFixed(3)}`:`$${e.toFixed(2)}`}function oP({getStartSize:e,onResize:t,direction:n,minSize:r,maxSize:i,orientation:a=`vertical`}){let o=(0,v.useRef)(null),s=a===`horizontal`,c=s?`row-resize`:`col-resize`;(0,v.useEffect)(()=>{let e=()=>{o.current!==null&&(o.current=null,document.body.style.removeProperty(`cursor`),document.body.style.removeProperty(`user-select`))},t=t=>{t.key===`Escape`&&e()};return window.addEventListener(`keydown`,t),window.addEventListener(`blur`,e),()=>{e(),window.removeEventListener(`keydown`,t),window.removeEventListener(`blur`,e)}},[]);let l=t=>{t.preventDefault(),t.currentTarget.setPointerCapture(t.pointerId),o.current={start:s?t.clientY:t.clientX,startSize:e()},document.body.style.cursor=c,document.body.style.userSelect=`none`},u=e=>{if(o.current===null)return;let a=(s?e.clientY:e.clientX)-o.current.start,c=o.current.startSize+a*n;t(Math.min(Math.max(c,r),i))},d=e=>{o.current!==null&&(e.currentTarget.releasePointerCapture(e.pointerId),o.current=null,document.body.style.removeProperty(`cursor`),document.body.style.removeProperty(`user-select`))},f=s?`h-1 w-full cursor-row-resize`:`w-1 h-full cursor-col-resize`,p=s?`absolute inset-x-0 -top-1 -bottom-1`:`absolute inset-y-0 -left-1 -right-1`;return(0,R.jsx)(`div`,{onPointerDown:l,onPointerMove:u,onPointerUp:d,onPointerCancel:d,className:`group relative shrink-0 bg-neutral-800 hover:bg-neutral-600 active:bg-neutral-500 ${f}`,role:`separator`,"aria-orientation":s?`horizontal`:`vertical`,children:(0,R.jsx)(`div`,{className:p})})}var sP=`pi-forge/files-width`,cP=`pi-forge/editor-width`,lP=`pi-forge/terminal-height`,uP=`pi-forge/todo-panel-height`,dP=280,fP=480,pP=280,mP=200,hP=200,gP=320,_P=320,vP=140,yP=100;function bP(e,t){let n=localStorage.getItem(e);if(n===null)return t;let r=Number.parseInt(n,10);return Number.isFinite(r)&&r>0?r:t}function xP(){let e=ir(e=>e.ready),t=ir(e=>e.isAuthenticated),n=ir(e=>e.mustChangePassword),r=ir(e=>e.bootstrap),i=ir(e=>e.logout),a=lr(e=>e.projects),o=lr(e=>!e.loading),s=lr(e=>e.load),c=ur(),l=lr(e=>e.activeProjectId),u=qr(e=>e.activeSessionId),d=ot(),[f,p]=(0,v.useState)(!1),[m,h]=(0,v.useState)(!1),[g,_]=(0,v.useState)(()=>localStorage.getItem(`pi-forge/files-open`)===`true`),y=e=>{_(e),localStorage.setItem(`pi-forge/files-open`,e?`true`:`false`)},[b,x]=(0,v.useState)(()=>{let e=localStorage.getItem(`pi-forge/right-tab`);return e===`files`||e===`search`||e===`changes`||e===`git`||e===`context`||e===`processes`?e:`files`}),S=e=>{x(e),localStorage.setItem(`pi-forge/right-tab`,e)},[C,w]=(0,v.useState)(()=>localStorage.getItem(`pi-forge/terminal-open`)===`true`),T=e=>{w(e),localStorage.setItem(`pi-forge/terminal-open`,e?`true`:`false`)},[E,D]=(0,v.useState)(()=>localStorage.getItem(`pi-forge/chat-open`)!==`false`),O=e=>{D(e),localStorage.setItem(`pi-forge/chat-open`,e?`true`:`false`)},[k,ee]=(0,v.useState)(()=>localStorage.getItem(`pi-forge/editor-open`)!==`false`),A=e=>{ee(e),localStorage.setItem(`pi-forge/editor-open`,e?`true`:`false`)},[te,ne]=(0,v.useState)(!1),[re,ie]=(0,v.useState)(()=>bP(lP,pP)),j=(0,v.useRef)(re);(0,v.useEffect)(()=>{j.current=re,localStorage.setItem(lP,String(re))},[re]);let[ae,M]=(0,v.useState)(()=>bP(uP,mP)),oe=(0,v.useRef)(ae);(0,v.useEffect)(()=>{oe.current=ae,localStorage.setItem(uP,String(ae))},[ae]);let se=zA(e=>e.todoPanelOpen);(0,v.useEffect)(()=>{se&&!g&&!d&&y(!0)},[se]);let ce=zA(e=>e.openProcessesTabSeq);(0,v.useEffect)(()=>{ce!==0&&(!g&&!d&&y(!0),S(`processes`))},[ce]);let[le,ue]=(0,v.useState)(()=>bP(sP,dP)),[de,fe]=(0,v.useState)(()=>bP(cP,fP)),pe=(0,v.useRef)(le),me=(0,v.useRef)(de);(0,v.useEffect)(()=>{pe.current=le,localStorage.setItem(sP,String(le))},[le]),(0,v.useEffect)(()=>{me.current=de,localStorage.setItem(cP,String(de))},[de]);let he=ii(e=>e.openFiles.length),ge=k&&he>0,_e=yN(c?.id).status?.files.length??0,ve=Fr(Mr(e=>Nr(e,u))),ye=qr(e=>u===void 0?0:e.agentEndCountBySession[u]??0),be=qr(e=>u===void 0?!1:e.streamingBySession[u]??!1),Se=ii(e=>e.loadTree),Ce=ii(e=>e.restoreTabs),we=ii(e=>e.refreshOpenFiles);(0,v.useEffect)(()=>{c===void 0||be||(Se(c.id),we(c.id))},[c?.id,be,ye]),(0,v.useEffect)(()=>{c!==void 0&&Ce(c.id)},[c?.id]),(0,v.useEffect)(()=>{if(!m)return;let e=e=>{e.key===`Escape`&&h(!1)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[m]);let Te=(0,v.useRef)(!0);(0,v.useEffect)(()=>{if(Te.current){Te.current=!1;return}f&&p(!1)},[l,u]),(0,v.useEffect)(()=>{if(!f)return;let e=e=>{e.key===`Escape`&&p(!1)};window.addEventListener(`keydown`,e);let t=document.body.style.overflow;return document.body.style.overflow=`hidden`,()=>{window.removeEventListener(`keydown`,e),document.body.style.overflow=t}},[f]),(0,v.useEffect)(()=>{!d&&f&&p(!1)},[d,f]);let De=zA(e=>e.settingsRequest),Oe=zA(e=>e.clearSettingsRequest),[ke,Ae]=(0,v.useState)(void 0);(0,v.useEffect)(()=>{De!==void 0&&(h(!0),De.tab!==void 0&&Ae(De.tab),Oe())},[De,Oe]),(0,v.useEffect)(()=>{r()},[r]);let je=si(e=>e.load),Me=si(e=>e.minimal);(0,v.useEffect)(()=>{je()},[je]),(0,v.useEffect)(()=>{t&&!n&&s()},[t,n,s]);let Pe=ci(e=>e.load);(0,v.useEffect)(()=>{t&&!n&&Pe()},[t,n,Pe]);let Fe=pj(e=>e.startPolling),Le=pj(e=>e.stopPolling);return(0,v.useEffect)(()=>{t&&!n?Fe():Le()},[t,n,Fe,Le]),e?t?n?(0,R.jsx)(mi,{}):(0,R.jsxs)(`div`,{className:`flex h-screen flex-col bg-neutral-950 text-neutral-100`,children:[(0,R.jsxs)(`header`,{className:`flex items-center justify-between border-b border-neutral-800 px-4 py-2`,style:{paddingTop:`max(0.5rem, env(safe-area-inset-top))`},children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,R.jsx)(`button`,{type:`button`,onClick:()=>p(e=>!e),"aria-label":f?`Close project sidebar`:`Open project sidebar`,"aria-expanded":f,className:`-ml-1 inline-flex min-h-11 min-w-11 items-center justify-center rounded-md text-neutral-300 hover:bg-neutral-800 md:hidden`,children:(0,R.jsx)(Ne,{size:20})}),(0,R.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,R.jsx)(`img`,{src:`/icons/icon.svg`,alt:``,className:`h-8 w-8`,"aria-hidden":`true`}),(0,R.jsx)(`span`,{className:`text-sm font-semibold tracking-tight`,children:`pi-forge`})]})]}),(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsxs)(`div`,{className:`hidden md:contents`,children:[(0,R.jsxs)(`button`,{onClick:()=>O(!E),className:`flex items-center gap-1 rounded-md border px-2 py-1 text-xs ${E?`border-neutral-500 bg-neutral-800 text-neutral-100`:`border-neutral-700 text-neutral-300 hover:border-neutral-500`}`,title:`Toggle the chat pane`,children:[(0,R.jsx)(Ie,{size:13}),`Chat`]}),(0,R.jsxs)(`button`,{onClick:()=>A(!k),className:`flex items-center gap-1 rounded-md border px-2 py-1 text-xs ${k?`border-neutral-500 bg-neutral-800 text-neutral-100`:`border-neutral-700 text-neutral-300 hover:border-neutral-500`}`,title:`Toggle the editor pane (open tabs persist across reloads)`,children:[(0,R.jsx)(xe,{size:13}),`Editor`]}),(0,R.jsxs)(`button`,{onClick:()=>y(!g),className:`flex items-center gap-1 rounded-md border px-2 py-1 text-xs ${g?`border-neutral-500 bg-neutral-800 text-neutral-100`:`border-neutral-700 text-neutral-300 hover:border-neutral-500`}`,title:`Toggle the file browser tree`,children:[(0,R.jsx)(Ee,{size:13}),`Files`]}),!Me&&(0,R.jsxs)(`button`,{onClick:()=>T(!C),className:`flex items-center gap-1 rounded-md border px-2 py-1 text-xs ${C?`border-neutral-500 bg-neutral-800 text-neutral-100`:`border-neutral-700 text-neutral-300 hover:border-neutral-500`}`,title:`Toggle the integrated terminal`,children:[(0,R.jsx)(Xe,{size:13}),`Terminal`]})]}),(0,R.jsx)(`div`,{className:`hidden md:block`,children:(0,R.jsx)(pN,{})}),(0,R.jsx)(mN,{}),(0,R.jsx)(`button`,{onClick:()=>h(!0),className:`rounded-md border border-neutral-700 px-2 py-1 text-xs text-neutral-300 hover:border-neutral-500`,title:`Settings (providers, agent defaults, MCP, skills)`,children:`Settings`}),(0,R.jsx)(`button`,{onClick:i,className:`rounded-md border border-neutral-700 px-2 py-1 text-xs text-neutral-300 hover:border-neutral-500`,children:`Sign out`})]})]}),(0,R.jsx)(yi,{}),m&&(0,R.jsx)(Sj,{onClose:()=>{h(!1),Ae(void 0)},...ke===void 0?{}:{initialTab:ke}}),(0,R.jsxs)(`div`,{className:`flex flex-1 flex-col overflow-hidden`,children:[(0,R.jsxs)(`div`,{className:`flex flex-1 overflow-hidden`,children:[f&&(0,R.jsx)(`div`,{className:`fixed inset-0 z-30 bg-black/50 md:hidden`,onClick:()=>p(!1),"aria-hidden":!0}),d&&!f&&(0,R.jsx)(`div`,{className:`fixed inset-y-0 left-0 z-20 w-5 md:hidden`,"aria-hidden":!0,onPointerDown:e=>{let t=e.clientX,n=!1,r=e=>{n||e.clientX-t>50&&(p(!0),n=!0,i())},i=()=>{window.removeEventListener(`pointermove`,r),window.removeEventListener(`pointerup`,i),window.removeEventListener(`pointercancel`,i)};window.addEventListener(`pointermove`,r),window.addEventListener(`pointerup`,i),window.addEventListener(`pointercancel`,i)}}),(0,R.jsx)(ki,{className:`fixed inset-y-0 left-0 z-40 shadow-2xl transition-transform duration-200 ease-out md:static md:inset-auto md:z-auto md:shadow-none md:transition-none `+(f?`max-md:translate-x-0`:`max-md:-translate-x-full`)}),(0,R.jsxs)(`main`,{className:`flex flex-1 overflow-hidden`,children:[E&&(0,R.jsx)(`div`,{className:`flex flex-1 flex-col overflow-hidden`,children:o&&a.length===0?te?(0,R.jsx)(`div`,{className:`flex flex-1 items-center justify-center px-6 text-center`,children:(0,R.jsxs)(`div`,{className:`space-y-3 text-sm text-neutral-400`,children:[(0,R.jsx)(`p`,{children:`No projects yet.`}),(0,R.jsx)(`button`,{onClick:()=>ne(!1),className:`rounded-md bg-neutral-100 px-3 py-1.5 text-sm font-medium text-neutral-900 hover:bg-white`,children:`+ New project`})]})}):(0,R.jsx)(`div`,{className:`flex flex-1 items-center justify-center`,children:(0,R.jsx)(bi,{onClose:()=>ne(!0)})}):u===void 0?c?(0,R.jsx)(`div`,{className:`flex flex-1 items-center justify-center px-6 text-center`,children:(0,R.jsxs)(`div`,{className:`space-y-3 text-sm text-neutral-400`,children:[(0,R.jsx)(`h2`,{className:`text-xl font-semibold text-neutral-100`,children:c.name}),(0,R.jsx)(`p`,{className:`font-mono text-xs`,children:c.path}),(0,R.jsx)(`p`,{children:`Pick a session from the sidebar — or start a new one here.`}),(0,R.jsx)(`button`,{onClick:()=>{qr.getState().createSession(c.id)},className:`rounded-md bg-neutral-100 px-3 py-1.5 text-sm font-medium text-neutral-900 hover:bg-white`,children:`+ New session`})]})}):(0,R.jsx)(`div`,{className:`flex flex-1 items-center justify-center`,children:(0,R.jsx)(`p`,{className:`text-sm text-neutral-400`,children:`Select a project from the sidebar.`})}):(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(pA,{sessionId:u}),!Me&&(0,R.jsx)(lj,{sessionId:u,alreadyOnChangesTab:g&&b===`changes`,onOpen:()=>{g||y(!0),S(`changes`)}}),(0,R.jsx)(aM,{sessionId:u}),(0,R.jsx)(aj,{sessionId:u})]})}),!d&&ge&&(E?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(oP,{getStartSize:()=>me.current,onResize:e=>fe(e),direction:-1,minSize:gP,maxSize:Math.max(gP,window.innerWidth-(g?le:0)-_P-240)}),(0,R.jsx)(`div`,{className:`flex shrink-0 flex-col border-l border-neutral-800`,style:{width:`${de}px`},children:(0,R.jsx)(RM,{})})]}):(0,R.jsx)(`div`,{className:`flex flex-1 flex-col overflow-hidden`,children:(0,R.jsx)(RM,{})})),!d&&g&&(()=>{let e=!E&&!ge,t=(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`div`,{className:`flex border-b border-neutral-800 bg-neutral-900/40`,children:(Me?[`files`,`search`,`processes`,`context`]:[`files`,`search`,`changes`,`git`,`processes`,`context`]).map(e=>(0,R.jsxs)(`button`,{onClick:()=>S(e),className:`flex items-center gap-1 px-3 py-1.5 text-[11px] uppercase tracking-wider ${b===e?`border-b border-neutral-100 text-neutral-100`:`text-neutral-500 hover:text-neutral-300`}`,children:[e===`files`?`Files`:e===`search`?`Search`:e===`changes`?`Last turn`:e===`git`?`Git`:e===`processes`?`Processes`:`Context`,e===`git`&&_e>0&&(0,R.jsx)(`span`,{className:`rounded bg-amber-900/40 px-1 py-0.5 text-[9px] text-amber-300 light:bg-amber-100 light:text-amber-800`,children:_e}),e===`processes`&&ve>0&&(0,R.jsx)(`span`,{className:`rounded bg-emerald-900/40 px-1 py-0.5 text-[9px] text-emerald-300 light:bg-emerald-100 light:text-emerald-800`,children:ve})]},e))}),(0,R.jsxs)(`div`,{className:`flex flex-1 flex-col overflow-hidden`,children:[(0,R.jsx)(`div`,{className:`flex-1 overflow-hidden`,children:b===`files`?(0,R.jsx)(SM,{}):b===`search`?(0,R.jsx)(FN,{}):!Me&&b===`changes`?(0,R.jsx)(_N,{}):!Me&&b===`git`?(0,R.jsx)(CN,{}):b===`context`?(0,R.jsx)(UN,{}):b===`processes`&&u!==void 0?(0,R.jsx)(pM,{sessionId:u}):(0,R.jsx)(SM,{})}),se&&u!==void 0&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(oP,{orientation:`horizontal`,getStartSize:()=>oe.current,onResize:e=>M(e),direction:-1,minSize:yP,maxSize:Math.max(yP,window.innerHeight*.7)}),(0,R.jsx)(`div`,{className:`shrink-0 overflow-hidden border-t border-neutral-800 light:border-neutral-200`,style:{height:`${ae}px`},children:(0,R.jsx)(cM,{sessionId:u,onClose:()=>zA.getState().setTodoPanelOpen(!1)})})]})]})]});return e?(0,R.jsx)(`div`,{className:`flex flex-1 flex-col overflow-hidden`,children:t}):(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(oP,{getStartSize:()=>pe.current,onResize:e=>ue(e),direction:-1,minSize:hP,maxSize:Math.max(hP,window.innerWidth-_P-240-(ge?gP:0))}),(0,R.jsx)(`div`,{className:`flex shrink-0 flex-col border-l border-neutral-800`,style:{width:`${le}px`},children:t})]})})()]})]}),!d&&!Me&&C&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(oP,{orientation:`horizontal`,getStartSize:()=>j.current,onResize:e=>ie(e),direction:-1,minSize:vP,maxSize:Math.max(vP,Math.floor(window.innerHeight*.7))}),(0,R.jsx)(`div`,{className:`shrink-0 border-t border-neutral-800`,style:{height:`${re}px`},children:(0,R.jsx)(lN,{})})]})]})]}):(0,R.jsx)(fi,{}):(0,R.jsx)(`main`,{className:`flex min-h-screen items-center justify-center text-sm text-neutral-400`,children:`Loading…`})}$S(),O({immediate:!0});var SP=class extends v.Component{state={error:null};static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){console.error(`[pi-forge] root render error`,e,t)}render(){return this.state.error===null?this.props.children:(0,R.jsxs)(`main`,{style:{padding:`2rem`,fontFamily:`monospace`,color:`#fca5a5`,background:`#0a0a0a`,minHeight:`100vh`,whiteSpace:`pre-wrap`,overflow:`auto`},children:[(0,R.jsx)(`h1`,{style:{color:`#fff`,marginBottom:`1rem`},children:`pi-forge: render crash`}),(0,R.jsx)(`p`,{style:{color:`#d4d4d4`,marginBottom:`1rem`},children:this.state.error.message}),(0,R.jsx)(`pre`,{style:{fontSize:`11px`,color:`#a3a3a3`},children:this.state.error.stack??`(no stack)`}),(0,R.jsx)(`p`,{style:{marginTop:`2rem`,color:`#71717a`,fontSize:`12px`},children:`Tip: open the browser console for more detail. Try clearing localStorage (devtools → Application → Local Storage → Clear) and refreshing if the error mentions stale state.`})]})}};window.addEventListener(`error`,e=>{console.error(`[pi-forge] uncaught error`,e.error)}),window.addEventListener(`unhandledrejection`,e=>{console.error(`[pi-forge] unhandled rejection`,e.reason)});var CP=document.getElementById(`root`);if(!CP)throw Error(`#root element missing in index.html`);(0,y.createRoot)(CP).render((0,R.jsx)(v.StrictMode,{children:(0,R.jsx)(SP,{children:(0,R.jsx)(xP,{})})}));export{l as a,d as i,eC as n,di as r,tC as t};
375
- //# sourceMappingURL=index-GubcPYw6.js.map
375
+ //# sourceMappingURL=index-D8rNSBxI.js.map