@shawnstack/quickforge 1.6.9 → 1.6.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +452 -452
- package/dist/assets/AgentProfilesPage-CvoB0OId.js +1 -0
- package/dist/assets/ChatPanelHost-Cyi1yi_P.js +244 -0
- package/dist/assets/{PluginsPage-C5OClNdT.js → PluginsPage-B_4nlPca.js} +1 -1
- package/dist/assets/{ScheduledTasksPage-yT10oaaM.js → ScheduledTasksPage-Zbsuo8o6.js} +2 -2
- package/dist/assets/{SettingsWorkspacePage-DuXwIeLd.js → SettingsWorkspacePage-BtgkwIKN.js} +358 -293
- package/dist/assets/{SharedConversationPage-ClpUSa0F.js → SharedConversationPage-B5FS3eSl.js} +1 -1
- package/dist/assets/TerminalDock-CiJCmyqg.js +2 -0
- package/dist/assets/WorkspaceInspector-C9HyQIvF.js +13 -0
- package/dist/assets/index-BFKildY3.js +63 -0
- package/dist/assets/index-CsKSKUn-.css +3 -0
- package/dist/assets/{mcp-servers-dialog-DC2Zfojn.js → mcp-servers-dialog-BPk4a4nW.js} +2 -2
- package/dist/assets/{skills-dialog-Mnj8fZwq.js → skills-dialog-DcxeFWSt.js} +1 -1
- package/dist/index.html +4 -4
- package/package.json +1 -1
- package/server/agent-manager.mjs +45 -3
- package/server/approval-store.mjs +4 -0
- package/server/global-memory.mjs +168 -0
- package/server/index.mjs +7 -0
- package/server/project-config.mjs +3 -0
- package/server/routes/backup.mjs +135 -48
- package/server/routes/memory.mjs +26 -0
- package/server/routes/tools.mjs +5 -3
- package/server/routes/workspace.mjs +56 -0
- package/server/system-prompt.mjs +22 -0
- package/server/tools/definitions.mjs +14 -0
- package/server/tools/index.mjs +6 -0
- package/server/utils/platform.mjs +4 -4
- package/dist/assets/AgentProfilesPage-5eqU0Cjk.js +0 -1
- package/dist/assets/ChatPanelHost-BNFeNRy-.js +0 -244
- package/dist/assets/TerminalDock-BmL-FeKv.js +0 -2
- package/dist/assets/WorkspaceInspector-yH23pXpj.js +0 -13
- package/dist/assets/index-Qof73j0o.css +0 -3
- package/dist/assets/index-_ut7awrd.js +0 -63
package/dist/assets/{SharedConversationPage-ClpUSa0F.js → SharedConversationPage-B5FS3eSl.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-DWdDZTNf.js";import{Vt as t,ht as n,i as r}from"./icons-C7j5jdKo.js";import{n as i}from"./react-vendor-VqdnQHHS.js";import{S as a,b as o,d as s,f as c,p as l,u}from"./pi-web-ui-DoRGtREc.js";import{U as d}from"./pi-ai-Cr3rpCXT.js";import{t as f}from"./logger-B65Akg8A.js";import{B as p,G as m,J as h,U as g,W as _,Y as v,Z as y,c as b,ct as x,l as S,lt as C,ot as w,pt as T,q as E,s as D,x as O}from"./index-_ut7awrd.js";import{ChatPanelHost as k}from"./ChatPanelHost-BNFeNRy-.js";var A=e(t(),1),j=`quickforgeClientMessageId`;function M(e){let t=e?.metadata;return t&&typeof t==`object`&&!Array.isArray(t)?t:void 0}function N(e){let t=M(e)?.[j];return typeof t==`string`&&t?t:void 0}function P(){return`qfcm_${typeof crypto<`u`&&typeof crypto.randomUUID==`function`?crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`}`}function F(e){let t=N(e);if(t)return{message:e,clientMessageId:t};let n=P();return{message:{...e,metadata:{...M(e),[j]:n}},clientMessageId:n}}function I(e){return typeof e==`string`?e:Array.isArray(e)?e.filter(e=>e&&typeof e==`object`&&e.type===`text`).map(e=>e.text).filter(e=>typeof e==`string`).join(``):``}function L(e,t){if(!e||!t||e.role!==t.role)return!1;let n=N(e),r=N(t);return n&&r?n===r:I(e.content)===I(t.content)}async function R(e,t){let n=await fetch(e,{...t,cache:`no-store`,headers:{...t?.body?{"content-type":`application/json`}:void 0,...t?.headers}}),r=await n.json().catch(()=>null);if(!n.ok)throw Error(r?.error||`Request failed: ${n.status}`);return r}var z=class e{state;streamFn=d;getApiKey;sessionId;shareId;permission;listeners=new Set;eventSource=null;disposed=!1;reconnectTimer=null;reconnectDelay=1e3;baseUrl=``;syncingThinkingLevel=!1;planMode=!1;onPlanModeConsumed;constructor(e,t){this.shareId=e,this.sessionId=t.sessionId||t.id||e,this.permission=t.permission??`read`;let n={systemPrompt:t.systemPrompt??``,model:t.model??{provider:`shared`,id:`shared`},thinkingLevel:t.thinkingLevel??`off`,messages:t.messages?.slice()??[],tools:t.tools??[],isStreaming:!!t.isStreaming,streamingMessage:void 0,pendingToolCalls:new Set,errorMessage:t.errorMessage,contextCompaction:t.contextCompaction??null,contextUsage:t.contextUsage??null};this.state=new Proxy(n,{set:(e,t,n)=>{let r=e[t];return e[t]=n,t===`thinkingLevel`&&!this.syncingThinkingLevel&&n!==r&&this.updateThinkingLevel(n).catch(e=>{f.error(`Failed to update shared thinking level:`,e)}),!0}}),this.connectEvents()}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}setNextPromptCapabilities(){}setPlanMode(e,t){this.planMode=e,this.onPlanModeConsumed=e?t:void 0}async prompt(e){if(this.disposed||this.permission!==`operate`)return;let{message:t,clientMessageId:n}=F(this.normalizeInput(e)),r=this.planMode?{type:`plan`}:void 0;if(this.planMode){this.planMode=!1;let e=this.onPlanModeConsumed;this.onPlanModeConsumed=void 0,e?.()}this.state.messages=[...this.state.messages,t],this.emit({type:`message_start`,message:t}),this.state.isStreaming||(this.state.isStreaming=!0,this.state.errorMessage=void 0,this.emit({type:`agent_start`}));try{await R(`/api/shared/${encodeURIComponent(this.shareId)}/message`,{method:`POST`,body:JSON.stringify({message:t,clientMessageId:n,command:r})})}catch(e){let t=e instanceof Error?e.message:String(e);throw this.state.errorMessage=t,this.state.isStreaming=!1,this.emit({type:`error`,error:t}),this.emit({type:`agent_end`,messages:this.state.messages}),e}}async updateModel(e){if(!(this.disposed||this.permission!==`operate`)){this.state.model=e;try{let t=await R(`/api/shared/${encodeURIComponent(this.shareId)}/model`,{method:`POST`,body:JSON.stringify({model:e})});t.model&&(this.state.model=t.model)}catch(e){let t=e instanceof Error?e.message:String(e);throw this.state.errorMessage=t,this.emit({type:`error`,error:t}),e}}}async updateThinkingLevel(e){if(!(this.disposed||this.permission!==`operate`)){!this.syncingThinkingLevel&&this.state.thinkingLevel!==e&&(this.state.thinkingLevel=e);try{let t=await R(`/api/shared/${encodeURIComponent(this.shareId)}/thinking-level`,{method:`POST`,body:JSON.stringify({thinkingLevel:e})});t.thinkingLevel&&(this.state.thinkingLevel=t.thinkingLevel)}catch(e){let t=e instanceof Error?e.message:String(e);throw this.state.errorMessage=t,this.emit({type:`error`,error:t}),e}}}abort(){this.permission===`operate`&&fetch(`/api/shared/${encodeURIComponent(this.shareId)}/abort`,{method:`POST`}).catch(e=>{f.error(`Failed to abort shared conversation:`,e)})}steer(){}followUp(){}reset(){this.state.messages=[],this.state.errorMessage=void 0,this.state.isStreaming=!1,this.state.streamingMessage=void 0,this.state.pendingToolCalls=new Set}async rollback(e){if(this.permission!==`operate`)return;let t=await R(`/api/shared/${encodeURIComponent(this.shareId)}/rollback`,{method:`POST`,body:JSON.stringify({messageIndex:e})});return this.applyState(t.session),this.emit({type:`messages_replaced`,messages:this.state.messages}),t}dispose(){this.disposed=!0,this.reconnectTimer&&clearTimeout(this.reconnectTimer),this.reconnectTimer=null,this.eventSource?.close(),this.eventSource=null,this.listeners.clear()}static async loadState(e){return R(`/api/shared/${encodeURIComponent(e)}/session`)}static async create(t){return new e(t,await e.loadState(t))}normalizeInput(e){return typeof e==`string`?{role:`user`,content:e,timestamp:Date.now()}:Array.isArray(e)?[...e].reverse().find(e=>e.role===`user`||e.role===`user-with-attachments`)??e[e.length-1]:e}connectEvents(){this.disposed||(this.eventSource?.close(),this.baseUrl=``,this.openEventSource())}openEventSource(){if(this.disposed)return;let e=`${this.baseUrl}/api/shared/${encodeURIComponent(this.shareId)}/events`;this.eventSource=new EventSource(e,{withCredentials:!0}),this.eventSource.onopen=()=>{this.reconnectDelay=1e3};let t=[`state`,`agent_start`,`agent_end`,`message_start`,`message_end`,`turn_start`,`turn_end`,`message_update`,`tool_execution_start`,`tool_execution_update`,`tool_execution_end`,`error`,`title_updated`,`messages_replaced`,`auto_compact_completed`],n=e=>t=>{try{let n=JSON.parse(t.data);this.handleEvent(e?{type:e,...n}:n)}catch{}};this.eventSource.onmessage=n();for(let e of t)this.eventSource.addEventListener(e,n(e));this.eventSource.onerror=()=>{this.eventSource?.close(),this.eventSource=null,this.scheduleReconnect()}}scheduleReconnect(){this.disposed||this.reconnectTimer||(this.reconnectTimer=setTimeout(()=>{this.reconnectTimer=null,this.reconnectDelay=Math.min(this.reconnectDelay*2,3e4),this.openEventSource()},this.reconnectDelay))}handleEvent(e){if(e.type){switch(e.type){case`state`:this.applyState(e);break;case`agent_start`:this.state.isStreaming=!0,this.state.errorMessage=void 0;break;case`agent_end`:this.state.isStreaming=!1,this.state.streamingMessage=void 0;break;case`message_start`:if(e.message){let t=this.state.messages.findIndex(t=>L(t,e.message));if(t>=0){let n=this.state.messages.slice();n[t]=e.message,this.state.messages=n}else this.state.messages=[...this.state.messages,e.message];this.state.contextUsage=null}break;case`message_update`:e.message&&(this.state.streamingMessage=e.message);break;case`message_end`:e.message&&(this.state.messages=h(this.state.messages,e.message)),this.state.contextUsage=`contextUsage`in e?e.contextUsage:null,this.state.streamingMessage=void 0;break;case`messages_replaced`:e.messages&&(this.state.messages=e.messages,this.state.streamingMessage=void 0),`contextCompaction`in e&&(this.state.contextCompaction=e.contextCompaction),`contextUsage`in e&&(this.state.contextUsage=e.contextUsage);break;case`auto_compact_completed`:`contextCompaction`in e&&(this.state.contextCompaction=e.contextCompaction),`contextUsage`in e&&(this.state.contextUsage=e.contextUsage);break;case`tool_execution_start`:{let t=e;t.toolCallId&&(this.state.messages=v(this.state.messages,E(t),!0),this.state.pendingToolCalls=new Set([...this.state.pendingToolCalls,t.toolCallId]));break}case`tool_execution_update`:{let t=e;this.state.messages=v(this.state.messages,t,!0),t.toolCallId&&(this.state.pendingToolCalls=new Set([...this.state.pendingToolCalls,t.toolCallId]));break}case`tool_execution_end`:{let t=e;if(this.state.messages=v(this.state.messages,t,!1),t.toolCallId){let e=new Set(this.state.pendingToolCalls);e.delete(t.toolCallId),this.state.pendingToolCalls=e}break}case`error`:this.state.errorMessage=typeof e.error==`string`?e.error:`Unknown error`,this.state.isStreaming=!1;break}this.emit(e)}}applyState(e){this.sessionId=e.sessionId||e.id||this.sessionId,e.messages&&(this.state.messages=e.messages,this.state.contextUsage=e.contextUsage===void 0?null:e.contextUsage),e.systemPrompt!==void 0&&(this.state.systemPrompt=e.systemPrompt),e.model&&(this.state.model=e.model),e.thinkingLevel&&(this.syncingThinkingLevel=!0,this.state.thinkingLevel=e.thinkingLevel,this.syncingThinkingLevel=!1),e.tools&&(this.state.tools=e.tools),e.isStreaming!==void 0&&(this.state.isStreaming=!!e.isStreaming),e.errorMessage!==void 0&&(this.state.errorMessage=e.errorMessage),e.contextCompaction!==void 0&&(this.state.contextCompaction=e.contextCompaction),e.contextUsage!==void 0&&(this.state.contextUsage=e.contextUsage)}emit(e){for(let t of this.listeners)try{t(e)}catch{}}},B=i();function V(e){return{id:`shared-${e.provider}`,name:e.provider,type:e.api,baseUrl:e.baseUrl??``,models:[e]}}async function H(e,t){try{let t=await b(e);if(t.providers?.length)return t.providers}catch{}return t?[V(t)]:[]}function U(e,t){let n=t.model??{provider:`shared`,id:`shared`};return new z(e,{...t,model:n,thinkingLevel:t.thinkingLevel??y(n)})}function W(e,t){let n={settings:new u,providerKeys:new c,sessions:new s,customProviders:new l},r=new w(``,{blockedStores:[`sessions`,`provider-keys`],fakeProviderKeys:t?[t.provider]:void 0,storeOverrides:t?{"custom-providers":{keys:async()=>(await H(e,t)).map(e=>e.name),get:async n=>(await H(e,t)).find(e=>e.name===n)??null,has:async n=>(await H(e,t)).some(e=>e.name===n)}}:void 0});n.settings.setBackend(r),n.providerKeys.setBackend(r),n.sessions.setBackend(r),n.customProviders.setBackend(r),a(new o(n.settings,n.providerKeys,n.sessions,n.customProviders,r))}function G({shareId:e}){let[t,i]=(0,A.useState)(``),[a,o]=(0,A.useState)(null),[s,c]=(0,A.useState)(`read`),[l,u]=(0,A.useState)(`QuickForge 分享对话`),[d,h]=(0,A.useState)(),[v,y]=(0,A.useState)(!1),[b,w]=(0,A.useState)(),E=(0,A.useRef)(!1),j=s===`operate`,M=!!a,N=!!a?.state.tools?.length;(0,A.useEffect)(()=>{W(e,a?.state.model)},[a?.state.model,e]),(0,A.useEffect)(()=>()=>a?.dispose(),[a]);let P=(0,A.useCallback)(async(n=t.trim())=>{h(void 0),y(!0);try{let t=await S(e,n);c(t.permission),u(t.title||t.share.titleSnapshot||`QuickForge 分享对话`);let r=await z.loadState(e);W(e,r.model),o(U(e,r))}catch(e){h(e instanceof Error?e.message:`Failed to unlock shared conversation`)}finally{y(!1)}},[t,e]);(0,A.useEffect)(()=>{if(M||v||E.current)return;E.current=!0;let t=window.setTimeout(()=>{(async()=>{try{(await D(e)).share.hasPassword||await P(``)}catch(e){h(e instanceof Error?e.message:`Failed to load shared conversation`)}})()},0);return()=>window.clearTimeout(t)},[v,e,P,M]);let F=(0,A.useCallback)(async e=>{await g(e)},[]),I=(0,A.useCallback)(async()=>{if(!(!a||a.permission!==`operate`))try{let t=(await H(e,a.state.model)).flatMap(e=>e.models??[]);if(!t.length)return;O(a.state.model,t,t=>{!t.reasoning&&a.state.thinkingLevel!==`off`&&a.updateThinkingLevel(`off`).catch(e=>{f.error(`Failed to update shared thinking level:`,e)}),W(e,t),a.updateModel(t).catch(e=>{h(e instanceof Error?e.message:`Failed to update model`)})},void 0,{thinkingLevel:a.state.thinkingLevel,onThinkingLevelSelect:e=>{a.updateThinkingLevel(e).catch(e=>{f.error(`Failed to update shared thinking level:`,e),h(e instanceof Error?e.message:`Failed to update thinking level`)})}})}catch(e){h(e instanceof Error?e.message:`Failed to load models`)}},[a,e]),L=(0,A.useCallback)(e=>{w(t=>t?.id===e?void 0:t)},[]),R=(0,A.useCallback)(async e=>{if(!a||a.permission!==`operate`)return;if(h(void 0),a.state.isStreaming){p(T(`generationStillRunning`));return}let t=m(a.state.messages,e),n=t>=0?a.state.messages[t]:void 0;if(!n){p(T(`noConversationTurnToRollback`));return}try{await a.rollback(e),w({id:Date.now(),sessionId:a.sessionId,text:_(n),attachments:n.role===`user-with-attachments`?n.attachments:void 0})}catch(e){h(e instanceof Error?e.message:`Failed to roll back`)}},[a]);return M?(0,B.jsxs)(`div`,{className:`flex h-screen min-h-0 flex-col bg-background text-foreground`,children:[(0,B.jsx)(`header`,{className:C(`shrink-0 border-b px-4 py-3`,j?`border-red-300 bg-red-50 text-red-950`:`border-border bg-background`),children:(0,B.jsxs)(`div`,{className:`mx-auto flex max-w-4xl items-start gap-3`,children:[(0,B.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,B.jsx)(`div`,{className:`truncate text-sm font-semibold`,children:l}),(0,B.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-x-2 gap-y-1 text-xs`,children:[(0,B.jsxs)(`span`,{className:C(`inline-flex items-center gap-1 rounded-full px-2 py-0.5 font-medium`,j?`bg-red-100 text-red-700`:`bg-muted text-muted-foreground`),children:[j?(0,B.jsx)(r,{className:`size-3.5`}):null,j?`高危可操作`:`只读分享`]}),(0,B.jsx)(`span`,{className:C(j?`text-red-800`:`text-muted-foreground`),children:j?`正在操作分享者的原始对话`:`只能查看,不能发送或修改`})]}),j?null:(0,B.jsx)(`div`,{className:`mt-1 text-xs leading-5 text-muted-foreground`,children:`界面与正常对话保持一致`})]}),(0,B.jsxs)(x,{variant:`ghost`,size:`sm`,className:C(`shrink-0`,j?`text-red-700 hover:bg-red-100 hover:text-red-800`:void 0),onClick:()=>void g(window.location.href),"aria-label":j?`复制高危分享链接`:`复制分享链接`,title:j?`复制高危分享链接`:`复制分享链接`,children:[(0,B.jsx)(n,{className:`size-4`}),(0,B.jsx)(`span`,{className:`hidden sm:inline`,children:j?`复制高危链接`:`复制链接`})]})]})}),d?(0,B.jsx)(`div`,{className:`mx-auto w-full max-w-4xl px-4 py-2 text-sm text-destructive`,children:d}):null,(0,B.jsx)(k,{agent:a,revision:0,agentAccessMode:N?`full-access`:`default`,workspaceToolsEnabled:N,onModelSelect:I,onAccessModeChange:()=>void 0,onRollbackFromMessage:R,onRetryFromMessage:()=>void 0,onCopyAnswer:F,onForkFromMessage:()=>void 0,onApproveToolCall:()=>void 0,onRejectToolCall:()=>void 0,disableFork:!0,rollbackConfirmTitle:T(`sharedRollbackConfirmTitle`),rollbackConfirmDescription:T(`sharedRollbackConfirm`),readOnly:!j,restoredDraft:b,onRestoredDraftConsumed:L,bypassClientApiKeyCheck:!0})]}):(0,B.jsx)(`div`,{className:`flex min-h-screen items-center justify-center bg-background p-6 text-foreground`,children:(0,B.jsxs)(`div`,{className:`w-full max-w-md rounded-2xl border border-border bg-background p-6 shadow-quickforge`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2 text-base font-semibold`,children:[(0,B.jsx)(r,{className:`size-5 text-amber-500`}),`QuickForge 局域网对话分享`]}),(0,B.jsx)(`p`,{className:`mt-2 text-sm text-muted-foreground`,children:`如果分享者设置了密码,请输入密码。未设置密码的链接会自动打开。`}),(0,B.jsx)(`input`,{type:`password`,value:t,onChange:e=>i(e.target.value),onKeyDown:e=>{e.key===`Enter`&&P()},className:`mt-5 h-10 w-full rounded-md border border-input bg-background px-3 text-sm outline-none focus:border-primary`,placeholder:`密码`,autoFocus:!0}),d?(0,B.jsx)(`div`,{className:`mt-3 rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:d}):null,(0,B.jsx)(x,{className:`mt-5 w-full`,onClick:()=>void P(),disabled:v||!t.trim(),children:v?T(`loading`):`用密码打开分享对话`})]})})}export{G as SharedConversationPage};
|
|
1
|
+
import{i as e}from"./rolldown-runtime-DWdDZTNf.js";import{Vt as t,ht as n,i as r}from"./icons-C7j5jdKo.js";import{n as i}from"./react-vendor-VqdnQHHS.js";import{S as a,b as o,d as s,f as c,p as l,u}from"./pi-web-ui-DoRGtREc.js";import{U as d}from"./pi-ai-Cr3rpCXT.js";import{t as f}from"./logger-B65Akg8A.js";import{G as p,J as m,K as h,Q as g,S as _,V as v,W as y,X as b,Y as x,c as S,dt as C,ht as w,l as T,s as E,st as D,ut as O}from"./index-BFKildY3.js";import{ChatPanelHost as k}from"./ChatPanelHost-Cyi1yi_P.js";var A=e(t(),1),j=`quickforgeClientMessageId`;function M(e){let t=e?.metadata;return t&&typeof t==`object`&&!Array.isArray(t)?t:void 0}function N(e){let t=M(e)?.[j];return typeof t==`string`&&t?t:void 0}function P(){return`qfcm_${typeof crypto<`u`&&typeof crypto.randomUUID==`function`?crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`}`}function F(e){let t=N(e);if(t)return{message:e,clientMessageId:t};let n=P();return{message:{...e,metadata:{...M(e),[j]:n}},clientMessageId:n}}function I(e){return typeof e==`string`?e:Array.isArray(e)?e.filter(e=>e&&typeof e==`object`&&e.type===`text`).map(e=>e.text).filter(e=>typeof e==`string`).join(``):``}function L(e,t){if(!e||!t||e.role!==t.role)return!1;let n=N(e),r=N(t);return n&&r?n===r:I(e.content)===I(t.content)}async function R(e,t){let n=await fetch(e,{...t,cache:`no-store`,headers:{...t?.body?{"content-type":`application/json`}:void 0,...t?.headers}}),r=await n.json().catch(()=>null);if(!n.ok)throw Error(r?.error||`Request failed: ${n.status}`);return r}var z=class e{state;streamFn=d;getApiKey;sessionId;shareId;permission;listeners=new Set;eventSource=null;disposed=!1;reconnectTimer=null;reconnectDelay=1e3;baseUrl=``;syncingThinkingLevel=!1;planMode=!1;onPlanModeConsumed;constructor(e,t){this.shareId=e,this.sessionId=t.sessionId||t.id||e,this.permission=t.permission??`read`;let n={systemPrompt:t.systemPrompt??``,model:t.model??{provider:`shared`,id:`shared`},thinkingLevel:t.thinkingLevel??`off`,messages:t.messages?.slice()??[],tools:t.tools??[],isStreaming:!!t.isStreaming,streamingMessage:void 0,pendingToolCalls:new Set,errorMessage:t.errorMessage,contextCompaction:t.contextCompaction??null,contextUsage:t.contextUsage??null};this.state=new Proxy(n,{set:(e,t,n)=>{let r=e[t];return e[t]=n,t===`thinkingLevel`&&!this.syncingThinkingLevel&&n!==r&&this.updateThinkingLevel(n).catch(e=>{f.error(`Failed to update shared thinking level:`,e)}),!0}}),this.connectEvents()}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}setNextPromptCapabilities(){}setPlanMode(e,t){this.planMode=e,this.onPlanModeConsumed=e?t:void 0}async prompt(e){if(this.disposed||this.permission!==`operate`)return;let{message:t,clientMessageId:n}=F(this.normalizeInput(e)),r=this.planMode?{type:`plan`}:void 0;if(this.planMode){this.planMode=!1;let e=this.onPlanModeConsumed;this.onPlanModeConsumed=void 0,e?.()}this.state.messages=[...this.state.messages,t],this.emit({type:`message_start`,message:t}),this.state.isStreaming||(this.state.isStreaming=!0,this.state.errorMessage=void 0,this.emit({type:`agent_start`}));try{await R(`/api/shared/${encodeURIComponent(this.shareId)}/message`,{method:`POST`,body:JSON.stringify({message:t,clientMessageId:n,command:r})})}catch(e){let t=e instanceof Error?e.message:String(e);throw this.state.errorMessage=t,this.state.isStreaming=!1,this.emit({type:`error`,error:t}),this.emit({type:`agent_end`,messages:this.state.messages}),e}}async updateModel(e){if(!(this.disposed||this.permission!==`operate`)){this.state.model=e;try{let t=await R(`/api/shared/${encodeURIComponent(this.shareId)}/model`,{method:`POST`,body:JSON.stringify({model:e})});t.model&&(this.state.model=t.model)}catch(e){let t=e instanceof Error?e.message:String(e);throw this.state.errorMessage=t,this.emit({type:`error`,error:t}),e}}}async updateThinkingLevel(e){if(!(this.disposed||this.permission!==`operate`)){!this.syncingThinkingLevel&&this.state.thinkingLevel!==e&&(this.state.thinkingLevel=e);try{let t=await R(`/api/shared/${encodeURIComponent(this.shareId)}/thinking-level`,{method:`POST`,body:JSON.stringify({thinkingLevel:e})});t.thinkingLevel&&(this.state.thinkingLevel=t.thinkingLevel)}catch(e){let t=e instanceof Error?e.message:String(e);throw this.state.errorMessage=t,this.emit({type:`error`,error:t}),e}}}abort(){this.permission===`operate`&&fetch(`/api/shared/${encodeURIComponent(this.shareId)}/abort`,{method:`POST`}).catch(e=>{f.error(`Failed to abort shared conversation:`,e)})}steer(){}followUp(){}reset(){this.state.messages=[],this.state.errorMessage=void 0,this.state.isStreaming=!1,this.state.streamingMessage=void 0,this.state.pendingToolCalls=new Set}async rollback(e){if(this.permission!==`operate`)return;let t=await R(`/api/shared/${encodeURIComponent(this.shareId)}/rollback`,{method:`POST`,body:JSON.stringify({messageIndex:e})});return this.applyState(t.session),this.emit({type:`messages_replaced`,messages:this.state.messages}),t}dispose(){this.disposed=!0,this.reconnectTimer&&clearTimeout(this.reconnectTimer),this.reconnectTimer=null,this.eventSource?.close(),this.eventSource=null,this.listeners.clear()}static async loadState(e){return R(`/api/shared/${encodeURIComponent(e)}/session`)}static async create(t){return new e(t,await e.loadState(t))}normalizeInput(e){return typeof e==`string`?{role:`user`,content:e,timestamp:Date.now()}:Array.isArray(e)?[...e].reverse().find(e=>e.role===`user`||e.role===`user-with-attachments`)??e[e.length-1]:e}connectEvents(){this.disposed||(this.eventSource?.close(),this.baseUrl=``,this.openEventSource())}openEventSource(){if(this.disposed)return;let e=`${this.baseUrl}/api/shared/${encodeURIComponent(this.shareId)}/events`;this.eventSource=new EventSource(e,{withCredentials:!0}),this.eventSource.onopen=()=>{this.reconnectDelay=1e3};let t=[`state`,`agent_start`,`agent_end`,`message_start`,`message_end`,`turn_start`,`turn_end`,`message_update`,`tool_execution_start`,`tool_execution_update`,`tool_execution_end`,`error`,`title_updated`,`messages_replaced`,`auto_compact_completed`],n=e=>t=>{try{let n=JSON.parse(t.data);this.handleEvent(e?{type:e,...n}:n)}catch{}};this.eventSource.onmessage=n();for(let e of t)this.eventSource.addEventListener(e,n(e));this.eventSource.onerror=()=>{this.eventSource?.close(),this.eventSource=null,this.scheduleReconnect()}}scheduleReconnect(){this.disposed||this.reconnectTimer||(this.reconnectTimer=setTimeout(()=>{this.reconnectTimer=null,this.reconnectDelay=Math.min(this.reconnectDelay*2,3e4),this.openEventSource()},this.reconnectDelay))}handleEvent(e){if(e.type){switch(e.type){case`state`:this.applyState(e);break;case`agent_start`:this.state.isStreaming=!0,this.state.errorMessage=void 0;break;case`agent_end`:this.state.isStreaming=!1,this.state.streamingMessage=void 0;break;case`message_start`:if(e.message){let t=this.state.messages.findIndex(t=>L(t,e.message));if(t>=0){let n=this.state.messages.slice();n[t]=e.message,this.state.messages=n}else this.state.messages=[...this.state.messages,e.message];this.state.contextUsage=null}break;case`message_update`:e.message&&(this.state.streamingMessage=e.message);break;case`message_end`:e.message&&(this.state.messages=x(this.state.messages,e.message)),this.state.contextUsage=`contextUsage`in e?e.contextUsage:null,this.state.streamingMessage=void 0;break;case`messages_replaced`:e.messages&&(this.state.messages=e.messages,this.state.streamingMessage=void 0),`contextCompaction`in e&&(this.state.contextCompaction=e.contextCompaction),`contextUsage`in e&&(this.state.contextUsage=e.contextUsage);break;case`auto_compact_completed`:`contextCompaction`in e&&(this.state.contextCompaction=e.contextCompaction),`contextUsage`in e&&(this.state.contextUsage=e.contextUsage);break;case`tool_execution_start`:{let t=e;t.toolCallId&&(this.state.messages=b(this.state.messages,m(t),!0),this.state.pendingToolCalls=new Set([...this.state.pendingToolCalls,t.toolCallId]));break}case`tool_execution_update`:{let t=e;this.state.messages=b(this.state.messages,t,!0),t.toolCallId&&(this.state.pendingToolCalls=new Set([...this.state.pendingToolCalls,t.toolCallId]));break}case`tool_execution_end`:{let t=e;if(this.state.messages=b(this.state.messages,t,!1),t.toolCallId){let e=new Set(this.state.pendingToolCalls);e.delete(t.toolCallId),this.state.pendingToolCalls=e}break}case`error`:this.state.errorMessage=typeof e.error==`string`?e.error:`Unknown error`,this.state.isStreaming=!1;break}this.emit(e)}}applyState(e){this.sessionId=e.sessionId||e.id||this.sessionId,e.messages&&(this.state.messages=e.messages,this.state.contextUsage=e.contextUsage===void 0?null:e.contextUsage),e.systemPrompt!==void 0&&(this.state.systemPrompt=e.systemPrompt),e.model&&(this.state.model=e.model),e.thinkingLevel&&(this.syncingThinkingLevel=!0,this.state.thinkingLevel=e.thinkingLevel,this.syncingThinkingLevel=!1),e.tools&&(this.state.tools=e.tools),e.isStreaming!==void 0&&(this.state.isStreaming=!!e.isStreaming),e.errorMessage!==void 0&&(this.state.errorMessage=e.errorMessage),e.contextCompaction!==void 0&&(this.state.contextCompaction=e.contextCompaction),e.contextUsage!==void 0&&(this.state.contextUsage=e.contextUsage)}emit(e){for(let t of this.listeners)try{t(e)}catch{}}},B=i();function V(e){return{id:`shared-${e.provider}`,name:e.provider,type:e.api,baseUrl:e.baseUrl??``,models:[e]}}async function H(e,t){try{let t=await S(e);if(t.providers?.length)return t.providers}catch{}return t?[V(t)]:[]}function U(e,t){let n=t.model??{provider:`shared`,id:`shared`};return new z(e,{...t,model:n,thinkingLevel:t.thinkingLevel??g(n)})}function W(e,t){let n={settings:new u,providerKeys:new c,sessions:new s,customProviders:new l},r=new D(``,{blockedStores:[`sessions`,`provider-keys`],fakeProviderKeys:t?[t.provider]:void 0,storeOverrides:t?{"custom-providers":{keys:async()=>(await H(e,t)).map(e=>e.name),get:async n=>(await H(e,t)).find(e=>e.name===n)??null,has:async n=>(await H(e,t)).some(e=>e.name===n)}}:void 0});n.settings.setBackend(r),n.providerKeys.setBackend(r),n.sessions.setBackend(r),n.customProviders.setBackend(r),a(new o(n.settings,n.providerKeys,n.sessions,n.customProviders,r))}function G({shareId:e}){let[t,i]=(0,A.useState)(``),[a,o]=(0,A.useState)(null),[s,c]=(0,A.useState)(`read`),[l,u]=(0,A.useState)(`QuickForge 分享对话`),[d,m]=(0,A.useState)(),[g,b]=(0,A.useState)(!1),[x,S]=(0,A.useState)(),D=(0,A.useRef)(!1),j=s===`operate`,M=!!a,N=!!a?.state.tools?.length;(0,A.useEffect)(()=>{W(e,a?.state.model)},[a?.state.model,e]),(0,A.useEffect)(()=>()=>a?.dispose(),[a]);let P=(0,A.useCallback)(async(n=t.trim())=>{m(void 0),b(!0);try{let t=await T(e,n);c(t.permission),u(t.title||t.share.titleSnapshot||`QuickForge 分享对话`);let r=await z.loadState(e);W(e,r.model),o(U(e,r))}catch(e){m(e instanceof Error?e.message:`Failed to unlock shared conversation`)}finally{b(!1)}},[t,e]);(0,A.useEffect)(()=>{if(M||g||D.current)return;D.current=!0;let t=window.setTimeout(()=>{(async()=>{try{(await E(e)).share.hasPassword||await P(``)}catch(e){m(e instanceof Error?e.message:`Failed to load shared conversation`)}})()},0);return()=>window.clearTimeout(t)},[g,e,P,M]);let F=(0,A.useCallback)(async e=>{await y(e)},[]),I=(0,A.useCallback)(async()=>{if(!(!a||a.permission!==`operate`))try{let t=(await H(e,a.state.model)).flatMap(e=>e.models??[]);if(!t.length)return;_(a.state.model,t,t=>{!t.reasoning&&a.state.thinkingLevel!==`off`&&a.updateThinkingLevel(`off`).catch(e=>{f.error(`Failed to update shared thinking level:`,e)}),W(e,t),a.updateModel(t).catch(e=>{m(e instanceof Error?e.message:`Failed to update model`)})},void 0,{thinkingLevel:a.state.thinkingLevel,onThinkingLevelSelect:e=>{a.updateThinkingLevel(e).catch(e=>{f.error(`Failed to update shared thinking level:`,e),m(e instanceof Error?e.message:`Failed to update thinking level`)})}})}catch(e){m(e instanceof Error?e.message:`Failed to load models`)}},[a,e]),L=(0,A.useCallback)(e=>{S(t=>t?.id===e?void 0:t)},[]),R=(0,A.useCallback)(async e=>{if(!a||a.permission!==`operate`)return;if(m(void 0),a.state.isStreaming){v(w(`generationStillRunning`));return}let t=h(a.state.messages,e),n=t>=0?a.state.messages[t]:void 0;if(!n){v(w(`noConversationTurnToRollback`));return}try{await a.rollback(e),S({id:Date.now(),sessionId:a.sessionId,text:p(n),attachments:n.role===`user-with-attachments`?n.attachments:void 0})}catch(e){m(e instanceof Error?e.message:`Failed to roll back`)}},[a]);return M?(0,B.jsxs)(`div`,{className:`flex h-screen min-h-0 flex-col bg-background text-foreground`,children:[(0,B.jsx)(`header`,{className:C(`shrink-0 border-b px-4 py-3`,j?`border-red-300 bg-red-50 text-red-950`:`border-border bg-background`),children:(0,B.jsxs)(`div`,{className:`mx-auto flex max-w-4xl items-start gap-3`,children:[(0,B.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,B.jsx)(`div`,{className:`truncate text-sm font-semibold`,children:l}),(0,B.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-x-2 gap-y-1 text-xs`,children:[(0,B.jsxs)(`span`,{className:C(`inline-flex items-center gap-1 rounded-full px-2 py-0.5 font-medium`,j?`bg-red-100 text-red-700`:`bg-muted text-muted-foreground`),children:[j?(0,B.jsx)(r,{className:`size-3.5`}):null,j?`高危可操作`:`只读分享`]}),(0,B.jsx)(`span`,{className:C(j?`text-red-800`:`text-muted-foreground`),children:j?`正在操作分享者的原始对话`:`只能查看,不能发送或修改`})]}),j?null:(0,B.jsx)(`div`,{className:`mt-1 text-xs leading-5 text-muted-foreground`,children:`界面与正常对话保持一致`})]}),(0,B.jsxs)(O,{variant:`ghost`,size:`sm`,className:C(`shrink-0`,j?`text-red-700 hover:bg-red-100 hover:text-red-800`:void 0),onClick:()=>void y(window.location.href),"aria-label":j?`复制高危分享链接`:`复制分享链接`,title:j?`复制高危分享链接`:`复制分享链接`,children:[(0,B.jsx)(n,{className:`size-4`}),(0,B.jsx)(`span`,{className:`hidden sm:inline`,children:j?`复制高危链接`:`复制链接`})]})]})}),d?(0,B.jsx)(`div`,{className:`mx-auto w-full max-w-4xl px-4 py-2 text-sm text-destructive`,children:d}):null,(0,B.jsx)(k,{agent:a,revision:0,agentAccessMode:N?`full-access`:`default`,workspaceToolsEnabled:N,onModelSelect:I,onAccessModeChange:()=>void 0,onRollbackFromMessage:R,onRetryFromMessage:()=>void 0,onCopyAnswer:F,onForkFromMessage:()=>void 0,onApproveToolCall:()=>void 0,onRejectToolCall:()=>void 0,disableFork:!0,rollbackConfirmTitle:w(`sharedRollbackConfirmTitle`),rollbackConfirmDescription:w(`sharedRollbackConfirm`),readOnly:!j,restoredDraft:x,onRestoredDraftConsumed:L,bypassClientApiKeyCheck:!0})]}):(0,B.jsx)(`div`,{className:`flex min-h-screen items-center justify-center bg-background p-6 text-foreground`,children:(0,B.jsxs)(`div`,{className:`w-full max-w-md rounded-2xl border border-border bg-background p-6 shadow-quickforge`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2 text-base font-semibold`,children:[(0,B.jsx)(r,{className:`size-5 text-amber-500`}),`QuickForge 局域网对话分享`]}),(0,B.jsx)(`p`,{className:`mt-2 text-sm text-muted-foreground`,children:`如果分享者设置了密码,请输入密码。未设置密码的链接会自动打开。`}),(0,B.jsx)(`input`,{type:`password`,value:t,onChange:e=>i(e.target.value),onKeyDown:e=>{e.key===`Enter`&&P()},className:`mt-5 h-10 w-full rounded-md border border-input bg-background px-3 text-sm outline-none focus:border-primary`,placeholder:`密码`,autoFocus:!0}),d?(0,B.jsx)(`div`,{className:`mt-3 rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:d}):null,(0,B.jsx)(O,{className:`mt-5 w-full`,onClick:()=>void P(),disabled:g||!t.trim(),children:g?w(`loading`):`用密码打开分享对话`})]})})}export{G as SharedConversationPage};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{i as e}from"./rolldown-runtime-DWdDZTNf.js";import{At as t,B as n,C as r,N as i,R as a,Vt as o,c as s,n as c}from"./icons-C7j5jdKo.js";import{n as l}from"./react-vendor-VqdnQHHS.js";import{E as u,P as d,dt as f,ht as p,j as m,ut as h}from"./index-BFKildY3.js";import{n as ee,t as g}from"./xterm-CGiQzDiR.js";var _=e(o(),1);async function v(e,t){let n=await fetch(e,{cache:`no-store`,...t}),r=await n.json().catch(()=>null);if(!n.ok)throw Error(r?.error||`Request failed: ${n.status}`);return r}function y(){return v(`/api/terminal/capabilities`)}function b(e){return v(`/api/terminal/sessions${e?`?projectId=${encodeURIComponent(e)}`:``}`)}function x(e){return v(`/api/terminal/sessions`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(e)})}function S(e){return v(`/api/terminal/sessions/${encodeURIComponent(e)}`,{method:`DELETE`})}function C(e,t){return v(`/api/terminal/sessions/${encodeURIComponent(e)}/input`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({data:t})})}function w(){return``}function te(){let e=w();if(e){let t=new URL(e);return t.protocol=t.protocol===`https:`?`wss:`:`ws:`,t.toString().replace(/\/$/,``)}return`${location.protocol===`https:`?`wss:`:`ws:`}//${location.host}`}function T(){let[e,t]=(0,_.useState)(()=>u());return(0,_.useEffect)(()=>{if(typeof document>`u`)return;let e=document.documentElement,n=()=>t(u());n();let r=new MutationObserver(n);return r.observe(e,{attributes:!0,attributeFilter:[`class`]}),()=>r.disconnect()},[]),e}var E=l(),D={light:{background:`#ffffff`,foreground:`#1f2937`,cursor:`#1f2937`,selectionBackground:`#dbeafe`},dark:{background:`#171717`,foreground:`#e5e7eb`,cursor:`#e5e7eb`,selectionBackground:`#3f3f46`}};function ne({session:e,active:t,height:n,onReady:r,onExited:i,onConnectionError:a}){let o=T(),s=D[o],c=(0,_.useRef)(null),l=(0,_.useRef)(null),u=(0,_.useRef)(null),f=(0,_.useRef)(null),h=(0,_.useRef)(null),v=(0,_.useRef)(null);return(0,_.useEffect)(()=>{let t=c.current;if(!t)return;let n=!1,o=!1,_=!1,y=!1,b=t=>{n||_||y||(y=!0,a(e.id,t))},x=d(),S=new ee({cursorBlink:!0,convertEol:!1,fontFamily:getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||`ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace`,fontSize:x.fontSize,lineHeight:x.lineHeight,scrollback:5e3,theme:s}),C=new g;S.loadAddon(C),S.open(t),S.writeln(`\x1b[2mConnected to ${e.cwd}\x1b[0m`),l.current=S,u.current=C;let w=()=>{if(t.isConnected)try{C.fit();let{cols:e,rows:t}=S,n=f.current;n?.readyState===WebSocket.OPEN&&n.send(JSON.stringify({type:`resize`,cols:e,rows:t}))}catch{}},T=new WebSocket(`${te()}/api/terminal/sessions/${encodeURIComponent(e.id)}/ws`);f.current=T,T.addEventListener(`open`,()=>{o=!0,y=!1,a(e.id,void 0),h.current=S.onData(e=>{T.readyState===WebSocket.OPEN&&T.send(JSON.stringify({type:`input`,data:e}))}),window.setTimeout(w,0)}),T.addEventListener(`message`,t=>{try{let n=JSON.parse(String(t.data));n.type===`ready`?r(e.id):n.type===`output`?S.write(n.data):n.type===`exit`?(_=!0,S.writeln(``),S.writeln(`\x1b[33m[process exited with code ${n.exitCode??`unknown`}]\x1b[0m`),i(e.id)):n.type===`error`&&S.writeln(`\x1b[31m${n.message}\x1b[0m`)}catch{}}),T.addEventListener(`error`,()=>{b(p(o?`terminalConnectionClosedUnexpectedly`:`terminalConnectionFailed`))}),T.addEventListener(`close`,e=>{h.current?.dispose(),h.current=null,!(n||_)&&(!e.wasClean||e.code!==1e3)&&b(p(o?`terminalConnectionClosedUnexpectedly`:`terminalConnectionFailed`))});let E=new ResizeObserver(()=>w());E.observe(t),v.current=E;let D=()=>{let e=d();S.options.fontSize=e.fontSize,S.options.lineHeight=e.lineHeight,window.setTimeout(w,0)};return window.addEventListener(m,D),window.setTimeout(w,50),()=>{n=!0,window.removeEventListener(m,D),E.disconnect(),v.current=null,h.current?.dispose(),h.current=null,T.close(),f.current=null,S.dispose(),l.current=null,u.current=null}},[o,a,i,r,e.cwd,e.id,s]),(0,_.useEffect)(()=>{if(!t)return;let e=u.current,n=l.current;window.setTimeout(()=>{try{e?.fit(),n?.focus()}catch{}},0)},[t,n]),(0,E.jsx)(`div`,{className:t?`h-full min-h-0 w-full pl-2 md:pl-3`:`hidden`,"aria-hidden":!t,children:(0,E.jsx)(`div`,{ref:c,className:`h-full min-h-0 w-full`})})}var re=180,ie=.7,ae=320;function O(e,t){let n=t?t.name:`Terminal`,r=new Set(e.map(e=>e.name));if(n!==`Terminal`&&!r.has(n))return n;let i=1;for(;r.has(`${n} ${i}`);)i+=1;return`${n} ${i}`}function k(e,t){let n=e?.terminalShellProfiles||[],r=t||e?.defaultTerminalShellProfileId||``;return n.find(e=>e.id===r)||n[0]}function A({project:e,onCollapse:o,pendingCommand:l,onPendingCommandHandled:u,variant:d=`dock`,singleSession:m=!1,panelInstanceId:ee,panelSessionId:g,onPanelSessionReady:v}){let[w,te]=(0,_.useState)(null),[T,D]=(0,_.useState)([]),[A,j]=(0,_.useState)(),[M,oe]=(0,_.useState)(ae),[N,se]=(0,_.useState)(!0),[P,ce]=(0,_.useState)(!1),[le,F]=(0,_.useState)(),[ue,I]=(0,_.useState)({}),[L,R]=(0,_.useState)(!1),[z,de]=(0,_.useState)(!1),B=(0,_.useRef)(!1),V=(0,_.useRef)(!1),H=(0,_.useRef)(new Set),fe=(0,_.useRef)(l),U=(0,_.useRef)(new Set),W=(0,_.useRef)(new Set),G=(0,_.useRef)(new Map),K=(0,_.useRef)(!0),pe=(0,_.useRef)(v),[me,he]=(0,_.useState)(()=>new Set),ge=(0,_.useRef)(null),_e=(0,_.useRef)(null),q=e?.id,J=d===`panel`&&!!ee,Y=(0,_.useMemo)(()=>T.find(e=>e.id===A)??T[0],[A,T]);(0,_.useEffect)(()=>{fe.current=l},[l]),(0,_.useEffect)(()=>{pe.current=v},[v]),(0,_.useEffect)(()=>()=>{K.current=!1},[]);let ve=(0,_.useCallback)(async()=>{let e=await b(q);return D(e.sessions),j(t=>t&&e.sessions.some(e=>e.id===t)?t:e.sessions[0]?.id),e.sessions},[q]),ye=(0,_.useCallback)(async(e,t)=>{if(B.current)return;let n=k(w,t);B.current=!0,ce(!0),F(void 0),I({});try{let t=await x({projectId:q,name:O(e,n),cols:120,rows:30,shellProfileId:n?.id,shellProfileName:n?.name});D(e=>[...e,t]),j(t.id)}catch(e){F(e instanceof Error?e.message:p(`terminalCreateFailed`))}finally{B.current=!1,ce(!1)}},[w,q]);(0,_.useEffect)(()=>{let e=!1;return(async()=>{se(!0),F(void 0);try{let[t,n]=await Promise.all([y(),b(q)]);if(e)return;if(te(t),t.enabled&&J&&g&&n.sessions.some(e=>e.id===g)){V.current=!0,D(n.sessions),j(g);return}if(t.enabled&&J&&!V.current){V.current=!0;let r=k(t);try{let t=await x({projectId:q,name:O(n.sessions,r),cols:120,rows:30,shellProfileId:r?.id,shellProfileName:r?.name});if(e){S(t.id).catch(()=>{});return}D([...n.sessions,t]),j(t.id),pe.current?.(t.id);return}catch(t){e||F(t instanceof Error?t.message:p(`terminalCreateFailed`))}}if(D(n.sessions),j(n.sessions[0]?.id),t.enabled&&n.sessions.length===0&&!fe.current){let n=k(t);x({projectId:q,name:O([],n),cols:120,rows:30,shellProfileId:n?.id,shellProfileName:n?.name}).then(t=>{if(e){S(t.id).catch(()=>{});return}D([t]),j(t.id)}).catch(t=>{e||F(t instanceof Error?t.message:p(`terminalCreateFailed`))})}}catch(t){e||F(t instanceof Error?t.message:p(`terminalUnavailable`))}finally{e||se(!1)}})(),()=>{e=!0}},[J,g,q]),(0,_.useEffect)(()=>{if(!L)return;let e=e=>{_e.current?.contains(e.target)||R(!1)},t=e=>{e.key===`Escape`&&R(!1)};return document.addEventListener(`pointerdown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`pointerdown`,e),document.removeEventListener(`keydown`,t)}},[L]),(0,_.useEffect)(()=>{if(!z)return;let e=e=>{e.key===`Escape`&&de(!1)};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[z]),(0,_.useEffect)(()=>{if(!l||H.current.has(l.id)||G.current.has(l.id)||U.current.has(l.id)||N||P||!w)return;if(!w.enabled){H.current.add(l.id),window.setTimeout(()=>{F(w.reason||p(`terminalUnavailable`)),u?.(l.id)},0);return}let e=Y&&!Y.exited?Y:T.find(e=>!e.exited);if(e){G.current.set(l.id,e.id),window.setTimeout(()=>{K.current&&j(e.id)},0);return}U.current.add(l.id),window.setTimeout(()=>{K.current&&F(void 0)},0);let t=k(w);x({projectId:q,name:O(T,t),cols:120,rows:30,shellProfileId:t?.id,shellProfileName:t?.name}).then(e=>{if(!K.current){S(e.id).catch(()=>{});return}G.current.set(l.id,e.id),D(t=>t.some(t=>t.id===e.id)?t:[...t,e]),j(e.id)}).catch(e=>{K.current&&(F(e instanceof Error?e.message:p(`terminalCommandExecuteFailed`)),H.current.add(l.id),u?.(l.id))}).finally(()=>{U.current.delete(l.id)})},[Y,w,P,N,u,l,q,T]),(0,_.useEffect)(()=>{if(!l||H.current.has(l.id)||W.current.has(l.id))return;let e=G.current.get(l.id),t=e?T.find(t=>t.id===e):Y&&!Y.exited?Y:T.find(e=>!e.exited);!t||t.exited||!me.has(t.id)||(W.current.add(l.id),window.setTimeout(()=>{K.current&&(j(t.id),F(void 0))},0),(async()=>{try{if(l.execute){let e=l.command.split(`
|
|
2
|
+
`),n=e.flatMap((t,n)=>n<e.length-1?[t,`\r`]:[t]);n.push(`\r`),await C(t.id,n.join(``))}else await C(t.id,l.command)}catch(e){K.current&&F(e instanceof Error?e.message:p(`terminalCommandExecuteFailed`))}finally{H.current.add(l.id),W.current.delete(l.id),G.current.delete(l.id),K.current&&u?.(l.id)}})())},[Y,u,l,me,T]);let be=async e=>{F(void 0),I(t=>{if(!t[e])return t;let n={...t};return delete n[e],n});let t=T.filter(t=>t.id!==e);D(t),A===e&&j(t[0]?.id);try{await S(e)}catch(e){F(e instanceof Error?e.message:p(`terminalCloseFailed`)),ve().catch(()=>{})}},xe=(0,_.useCallback)(e=>{D(t=>t.map(t=>t.id===e?{...t,exited:!0}:t)),he(t=>{if(!t.has(e))return t;let n=new Set(t);return n.delete(e),n})},[]),Se=(0,_.useCallback)(e=>{he(t=>{if(t.has(e))return t;let n=new Set(t);return n.add(e),n})},[]),Ce=(0,_.useCallback)((e,t)=>{I(n=>{if(!t){if(!n[e])return n;let t={...n};return delete t[e],t}return n[e]===t?n:{...n,[e]:t}})},[]),we=e=>{ge.current={startY:e.clientY,startHeight:M},e.currentTarget.setPointerCapture(e.pointerId)},Te=e=>{let t=ge.current;if(!t)return;let n=Math.max(re,Math.floor(window.innerHeight*ie));oe(Math.min(n,Math.max(re,t.startHeight+t.startY-e.clientY)))},Ee=e=>{ge.current=null;try{e.currentTarget.releasePointerCapture(e.pointerId)}catch{}},X=w?.terminalShellProfiles||[],De=w?.defaultTerminalShellProfileId||``,Oe=X.find(e=>e.id===De)||X[0],ke=!!(w&&T.length>=w.maxSessions),Ae=P||ke,je=Y?ue[Y.id]:void 0,Me=J&&Y?[Y]:T,Z=le??je,Q=d===`panel`,$=Q&&m,Ne=Q?void 0:z?Z?`calc(100% - 4.25rem)`:`calc(100% - 2.25rem)`:Z?M-72:M-45;return(0,E.jsxs)(`div`,{className:f(Q?`flex min-h-0 flex-1 flex-col bg-background`:`shrink-0 border-t border-border bg-background`,z&&`quickforge-terminal-fullscreen z-40 flex flex-col border-t-0`),style:z||Q?void 0:{height:M},children:[!z&&!Q?(0,E.jsx)(`div`,{className:`h-1 cursor-row-resize bg-transparent hover:bg-border`,onPointerDown:we,onPointerMove:Te,onPointerUp:Ee,onPointerCancel:Ee}):null,(0,E.jsxs)(`div`,{className:`flex h-9 items-center gap-1 border-b border-border px-2`,children:[(0,E.jsx)(s,{className:`size-4 shrink-0 text-muted-foreground/60`}),(0,E.jsx)(`div`,{className:`flex min-w-0 flex-1 items-center gap-1 overflow-x-auto`,children:Me.map(e=>{let t=f(`flex max-w-44 shrink-0 items-center gap-1 rounded-md px-2 py-1 text-xs text-muted-foreground/72`,Y?.id===e.id&&`bg-muted/28 text-foreground/90`);return $?(0,E.jsxs)(`div`,{className:t,title:`${e.name} — ${e.cwd}`,children:[(0,E.jsx)(`span`,{className:f(`size-1.5 rounded-full`,e.exited?`bg-muted-foreground/40`:`bg-emerald-500/80`)}),(0,E.jsx)(`span`,{className:`truncate`,children:e.name})]},e.id):(0,E.jsxs)(`button`,{type:`button`,className:f(t,`hover:bg-muted/20 hover:text-foreground/85`),onClick:()=>j(e.id),title:`${e.name} — ${e.cwd}`,children:[(0,E.jsx)(`span`,{className:f(`size-1.5 rounded-full`,e.exited?`bg-muted-foreground/40`:`bg-emerald-500/80`)}),(0,E.jsx)(`span`,{className:`truncate`,children:e.name}),(0,E.jsx)(`span`,{role:`button`,tabIndex:0,className:`ml-1 rounded-sm p-0.5 opacity-60 hover:bg-background hover:opacity-100`,onClick:t=>{t.stopPropagation(),be(e.id)},onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),t.stopPropagation(),be(e.id))},"aria-label":p(`terminalCloseSession`,{name:e.name}),children:(0,E.jsx)(c,{className:`size-3`})})]},e.id)})}),$?null:(0,E.jsxs)(`div`,{className:`relative shrink-0`,ref:_e,children:[(0,E.jsxs)(`div`,{className:`flex items-center overflow-hidden rounded-md border border-border bg-background`,children:[(0,E.jsx)(`button`,{type:`button`,className:`inline-flex h-7 w-7 items-center justify-center text-foreground/85 transition-colors hover:bg-muted/20 disabled:pointer-events-none disabled:opacity-50`,onClick:()=>void ye(T),disabled:Ae,title:Oe?p(`terminalNewWithProfile`,{name:Oe.name}):p(`terminalNew`),"aria-label":p(`terminalNew`),children:P?(0,E.jsx)(n,{className:`size-3.5 animate-spin`}):(0,E.jsx)(r,{className:`size-3.5`})}),X.length>0?(0,E.jsx)(`button`,{type:`button`,className:`inline-flex h-7 w-7 items-center justify-center border-l border-border text-muted-foreground/72 transition-colors hover:bg-muted/20 hover:text-foreground/85 disabled:pointer-events-none disabled:opacity-50`,onClick:()=>R(e=>!e),disabled:Ae,title:p(`terminalSelectShell`),"aria-label":p(`terminalSelectShell`),"aria-expanded":L,children:(0,E.jsx)(t,{className:`size-3.5`})}):null]}),L?(0,E.jsxs)(`div`,{className:f(`absolute right-0 z-30 w-64 overflow-hidden rounded-lg border border-border bg-background p-1.5 shadow-[0_16px_38px_-22px_rgb(15_23_42_/_0.65)]`,Q?`top-9`:`bottom-9`),children:[(0,E.jsx)(`div`,{className:`px-2 pb-1.5 pt-1 text-[11px] font-medium uppercase tracking-wide text-muted-foreground/60`,children:p(`terminalNewWith`)}),X.map(e=>(0,E.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-xs text-muted-foreground/80 hover:bg-muted/20 hover:text-foreground/90`,onClick:()=>{R(!1),ye(T,e.id)},children:[(0,E.jsx)(`span`,{className:`inline-flex size-5 shrink-0 items-center justify-center rounded bg-muted/20 text-[10px] text-muted-foreground/70`,children:e.name.slice(0,1).toUpperCase()}),(0,E.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,E.jsx)(`span`,{className:`block truncate font-medium`,children:e.name}),(0,E.jsx)(`span`,{className:`block truncate font-mono text-[11px] text-muted-foreground/55`,children:e.command})]})]},e.id))]}):null]}),$?null:(0,E.jsx)(h,{variant:`ghost`,size:`icon`,className:`size-7`,onClick:()=>de(e=>!e),title:p(z?`terminalExitFullscreen`:`terminalFullscreen`),"aria-label":p(z?`terminalExitFullscreen`:`terminalFullscreen`),children:z?(0,E.jsx)(i,{className:`size-3.5`}):(0,E.jsx)(a,{className:`size-3.5`})}),(0,E.jsx)(h,{variant:`ghost`,size:`icon`,className:f(`size-7`,Q&&`hidden`),onClick:o,title:p(`terminalCollapse`),"aria-label":p(`terminalCollapse`),children:(0,E.jsx)(t,{className:`size-3.5`})})]}),Z?(0,E.jsx)(`div`,{className:`border-b border-border px-3 py-1.5 text-xs text-destructive`,children:Z}):null,(0,E.jsx)(`div`,{className:f(`min-h-0 bg-background`,Q&&`flex-1`),style:Ne===void 0?void 0:{height:Ne},children:N?(0,E.jsxs)(`div`,{className:`flex h-full items-center justify-center gap-2 text-xs text-muted-foreground/60`,children:[(0,E.jsx)(n,{className:`size-4 animate-spin`}),` `,p(`terminalStarting`)]}):w&&!w.enabled?(0,E.jsx)(`div`,{className:`flex h-full items-center justify-center px-4 text-center text-xs text-muted-foreground/60`,children:w.reason||p(`terminalUnavailable`)}):T.length===0?(0,E.jsx)(`div`,{className:`flex h-full items-center justify-center text-xs text-muted-foreground/60`,children:p(`terminalNoSessions`)}):T.map(e=>(0,E.jsx)(ne,{session:e,active:e.id===Y?.id,height:z?window.innerHeight-36:Q?0:M,onReady:Se,onExited:xe,onConnectionError:Ce},e.id))})]})}export{A as TerminalDock,T as t};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import{i as e}from"./rolldown-runtime-DWdDZTNf.js";import{$ as t,At as n,B as r,C as i,Et as a,It as o,K as s,M as c,N as l,Ot as u,P as d,Q as f,R as p,Rt as m,U as h,Vt as g,W as _,Y as v,Z as ee,_ as y,_t as b,at as x,b as te,c as S,ct as C,et as ne,ft as re,gt as ie,ht as ae,jt as oe,lt as w,mt as se,n as ce,nt as le,o as ue,ot as T,pt as de,q as E,rt as fe,st as D,tt as pe,ut as me,v as he,x as ge}from"./icons-C7j5jdKo.js";import{n as _e}from"./react-vendor-VqdnQHHS.js";import{H as ve,N as ye,V as be,_ as xe,a as Se,b as Ce,d as we,dt as O,f as Te,g as Ee,h as De,ht as k,i as Oe,j as ke,lt as Ae,m as je,n as A,o as Me,p as Ne,r as j,t as M,u as Pe,ut as N,v as Fe,y as Ie}from"./index-BFKildY3.js";import{n as Le,r as Re,t as P}from"./mermaid-renderer-BmbSAmpG.js";import{TerminalDock as ze,t as Be}from"./TerminalDock-CiJCmyqg.js";import{n as F,t as Ve}from"./monaco-CdOyGlWD.js";var I=e(g(),1),L=_e();function He(e){let t=e.trim();if(!t.startsWith(`/api/workspace/preview/`))return!1;try{let e=new URL(t,window.location.origin);return e.origin===window.location.origin&&e.pathname.startsWith(`/api/workspace/preview/`)}catch{return!1}}function Ue(e){let t=e.trim().replace(/\\/g,`/`);return t.startsWith(`/`)||/^[a-zA-Z]:\//.test(t)}function We(e,t){let n=e.trim();if(!t||!He(n))return n;try{let e=new URL(n,window.location.origin),r=`/api/workspace/preview/${encodeURIComponent(t)}/`;return e.pathname.startsWith(r)?e.pathname.slice(r.length).split(`/`).map(e=>decodeURIComponent(e)).join(`/`):n}catch{return n}}function Ge(e,t){let n=e.trim();if(!n)return{url:``,displayUrl:``,error:``};if(He(n)){let e=new URL(n,window.location.origin);return{url:`${e.pathname}${e.search}${e.hash}`,displayUrl:We(n,t),error:``}}if(t&&Ue(n))return{url:Me(t,n),displayUrl:n,error:``};let r=/^https?:\/\//i.test(n)?n:`http://${n}`;try{let e=new URL(r);return e.protocol!==`http:`&&e.protocol!==`https:`?{url:``,displayUrl:n,error:k(`invalidPreviewUrl`)}:{url:e.toString(),displayUrl:e.toString(),error:``}}catch{return{url:``,displayUrl:n,error:k(`invalidPreviewUrl`)}}}function Ke({url:e,onUrlChange:t,projectId:n}){let r=(0,I.useMemo)(()=>Ge(e,n),[n,e]),[a,o]=(0,I.useState)({sourceUrl:e,value:r.displayUrl}),[s,l]=(0,I.useState)(``),[u,d]=(0,I.useState)(0),[f,p]=(0,I.useState)(!1),[h,g]=(0,I.useState)(100),v=(0,I.useRef)(null),ee=(0,I.useRef)(null),y=r.url,b=y.startsWith(`/api/workspace/preview/`)?`allow-scripts allow-same-origin allow-forms`:`allow-scripts allow-same-origin allow-forms allow-popups allow-downloads allow-modals allow-pointer-lock`,x=a.sourceUrl===e?a.value:r.displayUrl;(0,I.useEffect)(()=>{if(!f)return;function e(e){v.current?.contains(e.target)||p(!1)}return document.addEventListener(`pointerdown`,e),()=>document.removeEventListener(`pointerdown`,e)},[f]);function te(){try{ee.current?.contentWindow?.history.back()}catch{}}function S(e=x){let r=Ge(e,n);if(r.error){l(r.error);return}l(``),o({sourceUrl:r.displayUrl,value:r.displayUrl}),t(r.displayUrl),r.url&&d(e=>e+1)}function C(){y&&d(e=>e+1)}function ne(){y&&window.open(y,`_blank`,`noopener,noreferrer`)}return(0,L.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,L.jsxs)(`div`,{className:`flex shrink-0 flex-col gap-2 border-b border-border p-3`,children:[(0,L.jsxs)(`form`,{className:`flex items-center gap-2`,onSubmit:e=>{e.preventDefault(),S()},children:[(0,L.jsx)(N,{type:`button`,variant:`ghost`,size:`icon`,onClick:te,disabled:!y,"aria-label":k(`back`),title:k(`back`),children:(0,L.jsx)(m,{className:`size-4`})}),(0,L.jsx)(N,{type:`button`,variant:`ghost`,size:`icon`,onClick:C,disabled:!y,"aria-label":k(`refreshPreview`),title:k(`refreshPreview`),children:(0,L.jsx)(ge,{className:`size-4`})}),(0,L.jsxs)(`label`,{className:`mx-auto flex h-9 min-w-0 max-w-xl flex-1 items-center rounded-full border border-[color-mix(in_oklab,var(--border)_42%,transparent)] bg-muted/30 px-3 text-sm text-muted-foreground/65 focus-within:bg-background focus-within:text-foreground/85`,children:[(0,L.jsx)(`span`,{className:`sr-only`,children:k(`previewUrl`)}),(0,L.jsx)(`input`,{value:x,onChange:t=>{o({sourceUrl:e,value:t.target.value}),s&&l(``)},placeholder:k(`previewUrlPlaceholder`),className:`min-w-0 flex-1 bg-transparent text-center text-sm text-foreground/85 outline-none placeholder:text-muted-foreground/55`})]}),(0,L.jsx)(N,{type:`button`,variant:`ghost`,size:`icon`,onClick:ne,disabled:!y,"aria-label":k(`openInBrowser`),title:k(`openInBrowser`),children:(0,L.jsx)(me,{className:`size-4`})}),(0,L.jsxs)(`div`,{ref:v,className:`relative shrink-0`,children:[(0,L.jsx)(N,{type:`button`,variant:`ghost`,size:`icon`,onClick:()=>p(e=>!e),"aria-label":k(`more`),title:k(`more`),"aria-haspopup":`menu`,"aria-expanded":f,children:(0,L.jsx)(re,{className:`size-4`})}),f?(0,L.jsxs)(`div`,{className:`absolute right-0 top-10 z-30 w-48 rounded-2xl border border-[color-mix(in_oklab,var(--border)_34%,transparent)] bg-popover p-2 shadow-quickforge`,role:`menu`,children:[(0,L.jsx)(`div`,{className:`px-2 py-1.5 text-xs font-medium text-muted-foreground`,children:k(`zoom`)}),(0,L.jsxs)(`div`,{className:`flex items-center justify-between gap-2 rounded-xl px-1 py-1.5`,children:[(0,L.jsx)(N,{type:`button`,variant:`ghost`,size:`icon`,className:`size-8`,onClick:()=>g(e=>Math.max(50,e-10)),"aria-label":k(`zoomOut`),title:k(`zoomOut`),children:(0,L.jsx)(c,{className:`size-4`})}),(0,L.jsxs)(`button`,{type:`button`,className:`min-w-14 rounded-lg px-2 py-1 text-sm font-medium text-foreground/85 hover:bg-muted/50`,onClick:()=>g(100),title:k(`resetZoom`),children:[h,`%`]}),(0,L.jsx)(N,{type:`button`,variant:`ghost`,size:`icon`,className:`size-8`,onClick:()=>g(e=>Math.min(200,e+10)),"aria-label":k(`zoomIn`),title:k(`zoomIn`),children:(0,L.jsx)(i,{className:`size-4`})})]})]}):null]})]}),s?(0,L.jsx)(`div`,{className:`text-xs text-destructive`,children:s}):null]}),(0,L.jsx)(`div`,{className:`min-h-0 flex-1 bg-muted/10`,children:y?(0,L.jsx)(`div`,{className:`h-full w-full overflow-auto bg-background`,children:(0,L.jsx)(`iframe`,{ref:ee,title:k(`webPreview`),src:y,sandbox:b,className:`origin-top-left border-0 bg-background`,style:{width:`${1e4/h}%`,height:`${1e4/h}%`,transform:`scale(${h/100})`}},`${y}:${u}`)}):(0,L.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center px-8 text-center`,children:[(0,L.jsx)(_,{className:`size-20 stroke-[1.55] text-muted-foreground/75`}),(0,L.jsx)(`div`,{className:`mt-8 text-xl font-semibold tracking-tight text-foreground/88`,children:k(`noPreviewUrlTitle`)}),(0,L.jsx)(`div`,{className:`mt-4 max-w-xs text-base leading-6 text-muted-foreground/82`,children:k(`noPreviewUrlDescription`)})]})})]})}function qe({source:e}){let[t,n]=(0,I.useState)({source:e,value:`preview`}),[r,i]=(0,I.useState)({source:``,dataUrl:``,error:!1});(0,I.useEffect)(()=>{let t=!1;return Re(e).then(n=>{t||i({source:e,dataUrl:P(n),error:!1})}).catch(()=>{t||i({source:e,dataUrl:``,error:!0})}),()=>{t=!0}},[e]);let a=r.source===e?r:{source:e,dataUrl:``,error:!1},o=t.source===e?t.value:`preview`,s=r.source!==e,c=o===`source`||a.error;return(0,L.jsxs)(`figure`,{className:`my-5 overflow-hidden rounded-xl border border-border bg-muted/20`,children:[(0,L.jsxs)(`figcaption`,{className:`flex min-h-9 items-center justify-between gap-3 border-b border-border px-3 py-1.5`,children:[(0,L.jsx)(`span`,{className:`font-mono text-[11px] text-muted-foreground/65`,children:`mermaid`}),(0,L.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md bg-background/70 p-0.5`,children:[(0,L.jsx)(`button`,{type:`button`,className:`rounded px-2 py-1 text-[11px] text-muted-foreground transition-colors hover:text-foreground disabled:cursor-not-allowed disabled:opacity-40`,disabled:!a.dataUrl,"aria-pressed":!c,onClick:()=>n({source:e,value:`preview`}),children:k(`svgPreviewMode`)}),(0,L.jsx)(`button`,{type:`button`,className:`rounded px-2 py-1 text-[11px] text-muted-foreground transition-colors hover:text-foreground`,"aria-pressed":c,onClick:()=>n({source:e,value:`source`}),children:k(`svgSourceMode`)})]})]}),s?(0,L.jsx)(`div`,{className:`flex min-h-28 items-center justify-center px-4 py-8 text-xs text-muted-foreground/70`,role:`status`,children:k(`mermaidRendering`)}):c?(0,L.jsxs)(L.Fragment,{children:[a.error?(0,L.jsx)(`p`,{className:`px-4 pt-3 text-xs text-muted-foreground`,children:k(`mermaidRenderFailed`)}):null,(0,L.jsx)(`pre`,{className:`overflow-auto p-4 text-[12px] leading-5`,children:(0,L.jsx)(`code`,{children:e})})]}):(0,L.jsx)(`div`,{className:`flex min-h-28 justify-center overflow-auto bg-background/45 p-4`,children:(0,L.jsx)(`img`,{className:`h-auto max-w-full object-contain`,src:a.dataUrl,alt:k(`mermaidPreviewLabel`)})})]})}function Je(){let[e,t]=(0,I.useState)(()=>ye());return(0,I.useEffect)(()=>{if(typeof window>`u`)return;let e=()=>t(ye());return window.addEventListener(ke,e),()=>window.removeEventListener(ke,e)},[]),e}function Ye({path:e,content:t,language:n}){let r=Be(),i=Je();return(0,L.jsx)(Ve,{value:t,language:n,theme:r===`dark`?`vs-dark`:`vs`,options:{readOnly:!0,contextmenu:!1,automaticLayout:!0,minimap:{enabled:!1},fontFamily:getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||`ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace`,fontSize:i.fontSize,lineHeight:i.lineHeight,lineNumbers:`on`,scrollBeyondLastLine:!1,wordWrap:`off`,renderLineHighlight:`line`,folding:!1,glyphMargin:!1,scrollbar:{horizontal:`visible`,horizontalScrollbarSize:10,verticalScrollbarSize:8}}},e)}function Xe(e){let t=e.trim();if(t&&!/^(javascript|data|vbscript):/i.test(t)&&/^(https?:|mailto:|#|\/|\.\.?\/)/i.test(t))return t}function R(e,t){let n=[],r=/`([^`]+)`|\[([^\]]+)\]\(([^)\s]+)(?:\s+"[^"]*")?\)|\*\*([^*]+)\*\*|__([^_]+)__|\*([^*\n]+)\*|_([^_\n]+)_/g,i=0,a=0,o;for(;o=r.exec(e);){o.index>i&&n.push(e.slice(i,o.index));let s=`${t}-inline-${a++}`;if(o[1])n.push((0,L.jsx)(`code`,{className:`rounded bg-muted/35 px-1 py-0.5 font-mono text-[0.85em] text-foreground/90`,children:o[1]},s));else if(o[2]&&o[3]){let e=Xe(o[3]);n.push(e?(0,L.jsx)(`a`,{className:`text-primary underline-offset-4 hover:underline`,href:e,target:e.startsWith(`http`)?`_blank`:void 0,rel:`noreferrer`,children:o[2]},s):`[${o[2]}](${o[3]})`)}else o[4]||o[5]?n.push((0,L.jsx)(`strong`,{className:`font-semibold text-foreground/95`,children:o[4]||o[5]},s)):(o[6]||o[7])&&n.push((0,L.jsx)(`em`,{className:`italic`,children:o[6]||o[7]},s));i=r.lastIndex}return i<e.length&&n.push(e.slice(i)),n.length?n:[e]}function Ze(e,t){return e.split(`
|
|
2
|
+
`).flatMap((e,n)=>{let r=R(e,`${t}-line-${n}`);return n===0?r:[(0,L.jsx)(`br`,{},`${t}-br-${n}`),...r]})}function z(e){return/^\s*(```|~~~)/.test(e)}function Qe(e){return/^\s*\|?\s*:?-{3,}:?\s*(\|\s*:?-{3,}:?\s*)+\|?\s*$/.test(e)}function $e(e,t){return!!(e[t]?.includes(`|`)&&e[t+1]&&Qe(e[t+1]))}function et(e,t){let n=e[t]??``;return z(n)||$e(e,t)||/^\s{0,3}#{1,6}\s+/.test(n)||/^\s{0,3}([-*_])(?:\s*\1){2,}\s*$/.test(n)||/^\s{0,3}>\s?/.test(n)||/^\s{0,3}[-*+]\s+/.test(n)||/^\s{0,3}\d+[.)]\s+/.test(n)}function B(e){return e.trim().replace(/^\|/,``).replace(/\|$/,``).split(`|`).map(e=>e.trim())}function tt(e){let t=e.replace(/\r\n?/g,`
|
|
3
|
+
`).split(`
|
|
4
|
+
`),n=[],r=0,i=0;for(;r<t.length;){let e=t[r],a=`markdown-block-${i++}`;if(!e.trim()){r+=1;continue}if(z(e)){let i=e.match(/^\s*(```|~~~)\s*([^`]*)$/),o=i?.[1]??"```",s=i?.[2]?.trim(),c=[];for(r+=1;r<t.length&&!t[r].trimStart().startsWith(o);)c.push(t[r]),r+=1;r<t.length&&(r+=1);let l=c.join(`
|
|
5
|
+
`);Le(s)?n.push((0,L.jsx)(qe,{source:l},a)):n.push((0,L.jsxs)(`figure`,{className:`my-5 overflow-hidden rounded-xl border border-border bg-muted/20`,children:[s?(0,L.jsx)(`figcaption`,{className:`border-b border-border px-3 py-1.5 font-mono text-[11px] text-muted-foreground/65`,children:s}):null,(0,L.jsx)(`pre`,{className:`overflow-auto p-4 text-[12px] leading-5`,children:(0,L.jsx)(`code`,{children:l})})]},a));continue}let o=e.match(/^\s{0,3}(#{1,6})\s+(.+?)\s*#*\s*$/);if(o){let e=o[1].length,t=o[2],i=[`mt-8 mb-3 border-border text-foreground/95`,e===1?`border-b pb-3 text-3xl font-semibold tracking-tight`:``,e===2?`border-b pb-2 text-2xl font-semibold tracking-tight`:``,e===3?`text-xl font-semibold`:``,e===4?`text-lg font-semibold`:``,e>=5?`text-base font-semibold`:``].filter(Boolean).join(` `),s=R(t,`${a}-heading`);e===1?n.push((0,L.jsx)(`h1`,{className:i,children:s},a)):e===2?n.push((0,L.jsx)(`h2`,{className:i,children:s},a)):e===3?n.push((0,L.jsx)(`h3`,{className:i,children:s},a)):e===4?n.push((0,L.jsx)(`h4`,{className:i,children:s},a)):e===5?n.push((0,L.jsx)(`h5`,{className:i,children:s},a)):n.push((0,L.jsx)(`h6`,{className:i,children:s},a)),r+=1;continue}if(/^\s{0,3}([-*_])(?:\s*\1){2,}\s*$/.test(e)){n.push((0,L.jsx)(`hr`,{className:`my-6 border-border`},a)),r+=1;continue}if($e(t,r)){let e=B(t[r]);r+=2;let i=[];for(;r<t.length&&t[r].includes(`|`)&&t[r].trim();)i.push(B(t[r])),r+=1;n.push((0,L.jsx)(`div`,{className:`my-5 overflow-auto rounded-xl border border-border`,children:(0,L.jsxs)(`table`,{className:`w-full border-collapse text-left text-sm`,children:[(0,L.jsx)(`thead`,{className:`bg-muted/25 text-foreground/90`,children:(0,L.jsx)(`tr`,{children:e.map((e,t)=>(0,L.jsx)(`th`,{className:`border-b border-border px-3 py-2 font-semibold`,children:R(e,`${a}-th-${t}`)},`${a}-th-${t}`))})}),(0,L.jsx)(`tbody`,{children:i.map((t,n)=>(0,L.jsx)(`tr`,{className:`border-t border-border/70`,children:e.map((e,r)=>(0,L.jsx)(`td`,{className:`px-3 py-2 align-top text-foreground/85`,children:R(t[r]??``,`${a}-td-${n}-${r}`)},`${a}-td-${n}-${r}`))},`${a}-row-${n}`))})]})},a));continue}if(/^\s{0,3}>\s?/.test(e)){let e=[];for(;r<t.length&&/^\s{0,3}>\s?/.test(t[r]);)e.push(t[r].replace(/^\s{0,3}>\s?/,``)),r+=1;n.push((0,L.jsx)(`blockquote`,{className:`my-4 border-l-2 border-border pl-4 text-muted-foreground/85`,children:Ze(e.join(`
|
|
6
|
+
`),`${a}-quote`)},a));continue}if(/^\s{0,3}[-*+]\s+/.test(e)){let e=[];for(;r<t.length&&/^\s{0,3}[-*+]\s+/.test(t[r]);)e.push(t[r].replace(/^\s{0,3}[-*+]\s+/,``)),r+=1;n.push((0,L.jsx)(`ul`,{className:`my-4 list-disc space-y-1 pl-6`,children:e.map((e,t)=>(0,L.jsx)(`li`,{children:R(e,`${a}-li-${t}`)},`${a}-li-${t}`))},a));continue}if(/^\s{0,3}\d+[.)]\s+/.test(e)){let e=[];for(;r<t.length&&/^\s{0,3}\d+[.)]\s+/.test(t[r]);)e.push(t[r].replace(/^\s{0,3}\d+[.)]\s+/,``)),r+=1;n.push((0,L.jsx)(`ol`,{className:`my-4 list-decimal space-y-1 pl-6`,children:e.map((e,t)=>(0,L.jsx)(`li`,{children:R(e,`${a}-li-${t}`)},`${a}-li-${t}`))},a));continue}let s=[];for(;r<t.length&&t[r].trim()&&!et(t,r);)s.push(t[r].trim()),r+=1;n.push((0,L.jsx)(`p`,{className:`my-4 text-foreground/86`,children:R(s.join(` `),`${a}-p`)},a))}return n}function nt({path:e,content:t,language:n,mode:r}){let i=(0,I.useMemo)(()=>tt(t),[t]);return(0,L.jsx)(`div`,{className:`flex h-full min-h-0 flex-col bg-background`,children:(0,L.jsx)(`div`,{className:`min-h-0 flex-1`,children:r===`source`?(0,L.jsx)(Ye,{path:e,content:t,language:n}):(0,L.jsx)(`div`,{className:`h-full overflow-auto bg-background`,children:(0,L.jsx)(`article`,{className:`quickforge-markdown-reader mx-auto max-w-3xl px-8 py-7 text-sm leading-7 text-foreground/88`,children:i.length?i:(0,L.jsx)(`p`,{className:`text-muted-foreground/70`,children:`This Markdown file is empty.`})})})})})}function rt({path:e,oldContent:t,newContent:n,language:r,status:i}){let a=Be(),o=Je();return(0,L.jsx)(F,{original:t,modified:n,language:r,theme:a===`dark`?`vs-dark`:`vs`,options:{readOnly:!0,contextmenu:!1,automaticLayout:!0,renderSideBySide:!0,minimap:{enabled:!1},fontFamily:getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||`ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace`,fontSize:o.fontSize,lineHeight:o.lineHeight,scrollBeyondLastLine:!1,ignoreTrimWhitespace:!1,folding:!1,glyphMargin:!1,scrollbar:{verticalScrollbarSize:8,horizontalScrollbarSize:8}}},`${i}:${e}`)}function V(e,t){let n=e.replace(/\r\n?/g,`
|
|
7
|
+
`).split(`
|
|
8
|
+
`),r=t.replace(/\r\n?/g,`
|
|
9
|
+
`).split(`
|
|
10
|
+
`),i=n.length,a=r.length;if(i*a>4e6)return;let o=Array(a+1).fill(0),s=Array(a+1).fill(0);for(let e=1;e<=i;e++){let t=n[e-1];for(let e=1;e<=a;e++)s[e]=t===r[e-1]?o[e-1]+1:Math.max(o[e],s[e-1]);let i=o;o=s,s=i}let c=o[a];return{added:a-c,removed:i-c}}var it=3,at=5e7;function ot(e){let t=e.replace(/\r\n/g,`
|
|
11
|
+
`).replace(/\r/g,`
|
|
12
|
+
`).split(`
|
|
13
|
+
`);return t.length>1&&t[t.length-1]===``&&t.pop(),t}function st(e,t){let n=ot(e),r=ot(t);if(n.length*r.length>at)return;let i=Array.from({length:n.length+1},()=>new Uint32Array(r.length+1));for(let e=n.length-1;e>=0;--e)for(let t=r.length-1;t>=0;--t)i[e][t]=n[e]===r[t]?i[e+1][t+1]+1:Math.max(i[e+1][t],i[e][t+1]);let a=[],o=0,s=0,c=1,l=1;for(;o<n.length||s<r.length;){if(o<n.length&&s<r.length&&n[o]===r[s]){a.push({kind:`context`,oldLine:c,newLine:l,text:n[o]}),o+=1,s+=1,c+=1,l+=1;continue}if(s<r.length&&(o>=n.length||i[o][s+1]>=i[o+1][s])){a.push({kind:`add`,newLine:l,text:r[s]}),s+=1,l+=1;continue}o<n.length&&(a.push({kind:`delete`,oldLine:c,text:n[o]}),o+=1,c+=1)}return a}function H(e){let t=e.map(e=>e.kind!==`context`);e.forEach((n,r)=>{if(n.kind===`context`)return;let i=Math.max(0,r-it),a=Math.min(e.length-1,r+it);for(let e=i;e<=a;e+=1)t[e]=!0});let n=[],r=0,i=0;for(;r<e.length;){if(t[r]||e[r].kind!==`context`){n.push(e[r]),r+=1;continue}let a=r;for(;r<e.length&&!t[r]&&e[r].kind===`context`;)r+=1;let o=e.slice(a,r);n.push({kind:`collapsed`,id:`collapsed-${i++}-${a}`,count:o.length,rows:o})}return n}function ct(e){return e===`add`?`bg-emerald-500/12 text-foreground`:e===`delete`?`bg-red-500/12 text-foreground`:`bg-background text-foreground/90`}function U(e){return e===`add`?`+`:e===`delete`?`-`:` `}function W({row:e}){let t=e.kind===`delete`?e.oldLine:e.newLine??e.oldLine;return(0,L.jsxs)(`div`,{className:O(`grid w-max min-w-full grid-cols-[3rem_auto] text-[13px] leading-6`,ct(e.kind)),children:[(0,L.jsx)(`span`,{className:O(`select-none pr-3 text-right font-mono`,e.kind===`delete`&&`text-red-600 dark:text-red-500`,e.kind===`add`&&`text-emerald-600 dark:text-emerald-500`,e.kind===`context`&&`text-muted-foreground/62`),children:t??``}),(0,L.jsxs)(`code`,{className:`whitespace-pre pr-4 font-mono`,children:[(0,L.jsx)(`span`,{className:O(`mr-3 select-none`,e.kind===`add`&&`text-emerald-600 dark:text-emerald-500`,e.kind===`delete`&&`text-red-600 dark:text-red-500`),children:U(e.kind)}),e.text||` `]})]})}function lt(e,t,n){let r=new Set(e[t]??[]);return r.has(n)?r.delete(n):r.add(n),{...e,[t]:[...r]}}function ut({diff:e,loading:t,error:r}){let[i,a]=(0,I.useState)({}),o=e?`${e.path}\u0000${e.oldContent.length}\u0000${e.newContent.length}`:``,s=(0,I.useMemo)(()=>new Set(i[o]??[]),[o,i]),c=(0,I.useMemo)(()=>{if(!e)return;let t=st(e.oldContent,e.newContent);return t?H(t):void 0},[e]);return t?(0,L.jsx)(`div`,{className:`border-t border-[color-mix(in_oklab,var(--border)_34%,transparent)] bg-background px-3 py-4 text-sm text-muted-foreground/70`,children:k(`workspaceLoadingDiff`)}):r?(0,L.jsx)(`div`,{className:`border-t border-[color-mix(in_oklab,var(--border)_34%,transparent)] bg-background px-3 py-4 text-sm text-destructive`,children:r}):e?c?c.length===0?(0,L.jsx)(`div`,{className:`border-t border-[color-mix(in_oklab,var(--border)_34%,transparent)] bg-background px-3 py-4 text-sm text-muted-foreground/70`,children:k(`workspaceNoDiffPreview`)}):(0,L.jsx)(`div`,{className:`min-w-0 max-w-full overflow-hidden rounded-b-xl border-t border-[color-mix(in_oklab,var(--border)_34%,transparent)] bg-background`,children:(0,L.jsx)(`div`,{className:`max-h-[28rem] min-w-0 overflow-auto pb-1`,children:(0,L.jsx)(`div`,{className:`w-max min-w-full py-2`,children:c.map(e=>{if(e.kind!==`collapsed`)return(0,L.jsx)(W,{row:e},`${e.kind}:${e.oldLine??``}:${e.newLine??``}:${e.text}`);let t=s.has(e.id);return(0,L.jsxs)(`div`,{children:[(0,L.jsxs)(`div`,{className:`grid w-full min-w-0 grid-cols-[3rem_minmax(0,1fr)] gap-1 py-1 pr-4`,children:[(0,L.jsx)(`button`,{type:`button`,className:`flex h-12 items-center justify-center rounded-lg bg-muted/60 text-muted-foreground/75 transition-colors hover:bg-muted/78 hover:text-foreground/80`,onClick:()=>{a(t=>lt(t,o,e.id))},"aria-expanded":t,title:k(`workspaceUnmodifiedLines`,{count:e.count}),children:(0,L.jsx)(n,{className:O(`size-4 transition-transform`,t&&`rotate-180`)})}),(0,L.jsx)(`button`,{type:`button`,className:`flex h-12 items-center rounded-lg bg-muted/60 px-4 text-left text-base font-medium text-muted-foreground/80 transition-colors hover:bg-muted/78 hover:text-foreground/80`,onClick:()=>{a(t=>lt(t,o,e.id))},"aria-expanded":t,children:k(`workspaceUnmodifiedLines`,{count:e.count})})]}),t?e.rows.map(t=>(0,L.jsx)(W,{row:t},`hidden:${e.id}:${t.oldLine}:${t.newLine}`)):null]},e.id)})})})}):(0,L.jsx)(`div`,{className:`border-t border-[color-mix(in_oklab,var(--border)_34%,transparent)] bg-background px-3 py-4 text-sm text-muted-foreground/70`,children:k(`workspaceDiffTooLarge`)}):(0,L.jsx)(`div`,{className:`border-t border-[color-mix(in_oklab,var(--border)_34%,transparent)] bg-background px-3 py-4 text-sm text-muted-foreground/70`,children:k(`workspaceNoDiffPreview`)})}var dt={ts:`typescript`,tsx:`typescript`,js:`javascript`,jsx:`javascript`,mjs:`javascript`,cjs:`javascript`,json:`json`,jsonc:`json`,css:`css`,scss:`scss`,less:`less`,html:`html`,htm:`html`,md:`markdown`,markdown:`markdown`,py:`python`,rb:`ruby`,go:`go`,rs:`rust`,java:`java`,c:`c`,h:`c`,cpp:`cpp`,cc:`cpp`,cxx:`cpp`,hpp:`cpp`,cs:`csharp`,php:`php`,swift:`swift`,kt:`kotlin`,kts:`kotlin`,sh:`shell`,bash:`shell`,zsh:`shell`,ps1:`powershell`,yml:`yaml`,yaml:`yaml`,xml:`xml`,sql:`sql`,dockerfile:`dockerfile`,toml:`toml`,ini:`ini`,env:`ini`};function ft(e){let t=e.split(`/`).pop()?.toLowerCase()??``;return t===`dockerfile`||t.endsWith(`.dockerfile`)?`dockerfile`:dt[t.includes(`.`)?t.split(`.`).pop()??``:t]??`plaintext`}function pt(e){return e.slice(e.lastIndexOf(`/`)+1)}function G(e){let t=e.lastIndexOf(`.`);return t>0?e.slice(t+1):``}var mt={typescript:{Icon:T,className:`text-sky-500 dark:text-sky-400`},javascript:{Icon:T,className:`text-amber-500 dark:text-amber-400`},python:{Icon:T,className:`text-blue-600 dark:text-blue-400`},go:{Icon:T,className:`text-cyan-600 dark:text-cyan-400`},rust:{Icon:T,className:`text-orange-600 dark:text-orange-400`},java:{Icon:T,className:`text-red-500 dark:text-red-400`},c:{Icon:T,className:`text-blue-500 dark:text-blue-400`},cpp:{Icon:T,className:`text-indigo-500 dark:text-indigo-400`},csharp:{Icon:T,className:`text-violet-500 dark:text-violet-400`},php:{Icon:T,className:`text-indigo-500 dark:text-indigo-400`},ruby:{Icon:T,className:`text-rose-500 dark:text-rose-400`},swift:{Icon:T,className:`text-orange-500 dark:text-orange-400`},kotlin:{Icon:T,className:`text-violet-500 dark:text-violet-400`},shell:{Icon:T,className:`text-green-600 dark:text-green-400`},powershell:{Icon:T,className:`text-blue-600 dark:text-blue-400`},json:{Icon:D,className:`text-amber-600 dark:text-amber-400`},css:{Icon:h,className:`text-sky-500 dark:text-sky-400`},scss:{Icon:h,className:`text-pink-500 dark:text-pink-400`},less:{Icon:h,className:`text-sky-500 dark:text-sky-400`},html:{Icon:de,className:`text-orange-500 dark:text-orange-400`},markdown:{Icon:ne,className:`text-slate-500 dark:text-slate-400`},yaml:{Icon:x,className:`text-slate-500 dark:text-slate-400`},toml:{Icon:x,className:`text-slate-500 dark:text-slate-400`},ini:{Icon:x,className:`text-slate-500 dark:text-slate-400`},xml:{Icon:T,className:`text-slate-500 dark:text-slate-400`},sql:{Icon:se,className:`text-indigo-500 dark:text-indigo-400`},dockerfile:{Icon:ie,className:`text-sky-600 dark:text-sky-400`},plaintext:{Icon:ne,className:`text-slate-500 dark:text-slate-400`}},K=new Set([`png`,`jpg`,`jpeg`,`gif`,`svg`,`ico`,`webp`,`bmp`,`avif`]),q=new Set([`zip`,`tar`,`gz`,`tgz`,`rar`,`7z`,`bz2`,`xz`]),J=new Set([`csv`,`tsv`,`xls`,`xlsx`]);function ht(e){if(e===`readme`||e.startsWith(`readme.`))return{Icon:o,className:`text-sky-500 dark:text-sky-400`};if(e===`license`||e.startsWith(`license.`)||e===`licence`||e.startsWith(`licence.`)||e===`copying`||e.startsWith(`copying.`))return{Icon:he,className:`text-slate-500 dark:text-slate-400`};if(e===`makefile`||e.startsWith(`makefile.`))return{Icon:ue,className:`text-slate-500 dark:text-slate-400`};if(e.startsWith(`docker-compose`))return{Icon:ie,className:`text-sky-600 dark:text-sky-400`};if(e===`.gitignore`||e===`.gitattributes`||e===`.gitmodules`)return{Icon:he,className:`text-orange-500 dark:text-orange-400`};if(e===`.env`||e.startsWith(`.env.`))return{Icon:x,className:`text-slate-500 dark:text-slate-400`};if(e.endsWith(`.lock`)||e.endsWith(`-lock.json`)||e.endsWith(`-lock.yaml`))return{Icon:le,className:`text-slate-500 dark:text-slate-400`}}function gt(e){let n=pt(e).toLowerCase(),r=ht(n);if(r)return r;let i=G(n);return K.has(i)?{Icon:fe,className:`text-purple-500 dark:text-purple-400`}:q.has(i)?{Icon:C,className:`text-slate-500 dark:text-slate-400`}:J.has(i)?{Icon:pe,className:`text-green-600 dark:text-green-400`}:mt[ft(e)]||{Icon:t,className:`text-slate-500 dark:text-slate-400`}}function Y(e,t){let n=e.toLowerCase();return n===`.git`||n===`.svn`||n===`.hg`?{Icon:f,className:`text-orange-500 dark:text-orange-400`}:{Icon:t?ee:v,className:`text-slate-500 dark:text-slate-400`}}function _t({path:e,className:t=`size-3.5`}){let{Icon:n,className:r}=gt(e);return(0,L.jsx)(n,{className:`${r} ${t}`})}function vt({name:e,open:t,className:n=`size-3.5`}){let{Icon:r,className:i}=Y(e,t);return(0,L.jsx)(r,{className:`${i} ${n}`})}function yt(e){return k(e===`added`?`workspaceStatusAdded`:e===`deleted`?`workspaceStatusDeleted`:e===`renamed`?`workspaceStatusRenamed`:e===`untracked`?`workspaceStatusUntracked`:e===`conflicted`?`workspaceStatusConflict`:`workspaceStatusModified`)}function bt(e){let t=e.replace(/\\/g,`/`);return t.split(`/`).filter(Boolean).pop()||t||`—`}function X(e,t,n){return e?.action===t&&(n?e.path===n:!e.path)}function xt(e){return!!(e.unstaged||e.status===`untracked`||e.conflict||!e.staged)}function St({files:e,selectedPath:t,expandedDiff:n,expandedLoading:a,expandedError:o,onSelectFile:s,onRestoreFile:l,onStageFile:u,onUnstageFile:d,onOpenFile:f,onRestoreAll:p,onStageAll:m,onUnstageAll:h,showUnstageAll:g=!1,pendingAction:_,emptyMessage:v=k(`workspaceNoWorkingTreeChanges`)}){let ee=e.filter(xt),y=e.filter(e=>e.staged),b=X(_,`restore`),x=X(_,`stage`),S=X(_,`unstage`),C=!!_;return(0,L.jsxs)(`div`,{className:`relative flex min-h-0 min-w-0 flex-1 flex-col bg-background`,children:[(0,L.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-auto px-2 pb-20 pt-1`,children:e.length===0?(0,L.jsx)(`div`,{className:`px-3 py-4 text-xs text-muted-foreground/70`,children:v}):(0,L.jsx)(`div`,{className:`min-w-0 divide-y divide-[color-mix(in_oklab,var(--border)_28%,transparent)]`,children:e.map(e=>{let p=t===e.path,m=bt(e.path),h=X(_,`restore`,e.path),v=X(_,`stage`,e.path),ee=X(_,`unstage`,e.path),y=e.status===`deleted`,b=g,x=C||(b?!d||!e.staged:!u||!xt(e)),S=C||!l,ne=C||!f||y,re=e.oldPath?`${e.oldPath} → ${e.path}`:e.path;return(0,L.jsxs)(`div`,{className:O(`group min-w-0 overflow-hidden`,p&&`rounded-xl bg-muted/30`),children:[(0,L.jsxs)(`div`,{className:O(`grid min-h-[40px] grid-cols-[minmax(0,1fr)_auto] items-center gap-2 rounded-xl transition-colors`,p?`bg-muted/40`:`hover:bg-muted/24`),children:[(0,L.jsxs)(`button`,{type:`button`,className:`grid min-w-0 grid-cols-[24px_minmax(0,1fr)_auto] items-center gap-3 px-3 py-2 text-left text-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,onClick:()=>s(e.path),title:`${yt(e.status)} · ${re}`,"aria-expanded":p,children:[(0,L.jsx)(_t,{path:e.path,className:`size-[15px] shrink-0`}),(0,L.jsx)(`span`,{className:`min-w-0 truncate font-medium leading-[18px] text-foreground/90`,children:m}),typeof e.additions==`number`&&typeof e.deletions==`number`?(0,L.jsxs)(`span`,{className:`min-w-[64px] shrink-0 whitespace-nowrap text-right font-mono text-sm font-medium leading-[18px]`,children:[(0,L.jsxs)(`span`,{className:`text-emerald-600 dark:text-emerald-500`,children:[`+`,e.additions]}),(0,L.jsxs)(`span`,{className:`ml-1.5 text-red-600 dark:text-red-500`,children:[`-`,e.deletions]})]}):(0,L.jsx)(`span`,{className:`min-w-[64px]`})]}),(0,L.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1 pr-2 text-muted-foreground/55 opacity-80 transition-opacity group-hover:opacity-100`,children:[(0,L.jsx)(`button`,{type:`button`,className:`inline-flex size-[26px] items-center justify-center rounded-full transition-colors hover:bg-destructive/10 hover:text-destructive disabled:cursor-not-allowed disabled:opacity-40`,onClick:()=>l?.(e),disabled:S,"aria-label":k(`workspaceRestoreFile`),title:k(`workspaceRestoreFile`),children:h?(0,L.jsx)(r,{className:`size-3.5 animate-spin`}):(0,L.jsx)(te,{className:`size-4`})}),(0,L.jsx)(`button`,{type:`button`,className:O(`inline-flex size-[26px] items-center justify-center rounded-full transition-colors disabled:cursor-not-allowed disabled:opacity-40`,b?`hover:bg-amber-500/10 hover:text-amber-600 dark:hover:text-amber-500`:`hover:bg-emerald-500/10 hover:text-emerald-600 dark:hover:text-emerald-500`),onClick:()=>b?d?.(e):u?.(e),disabled:x,"aria-label":k(b?`workspaceUnstageFile`:`workspaceStageFile`),title:k(b?`workspaceUnstageFile`:`workspaceStageFile`),children:v||ee?(0,L.jsx)(r,{className:`size-3.5 animate-spin`}):b?(0,L.jsx)(c,{className:`size-4`}):(0,L.jsx)(i,{className:`size-4`})}),(0,L.jsx)(`button`,{type:`button`,className:`inline-flex size-[26px] items-center justify-center rounded-full transition-colors hover:bg-muted/35 hover:text-foreground/85 disabled:cursor-not-allowed disabled:opacity-40`,onClick:()=>f?.(e),disabled:ne,"aria-label":k(`workspaceOpenFileInNewTab`),title:k(y?`workspaceCannotOpenDeletedFile`:`workspaceOpenFileInNewTab`),children:(0,L.jsx)(me,{className:`size-4`})})]})]}),p?(0,L.jsx)(ut,{diff:n,loading:a,error:o}):null]},`${e.status}:${e.oldPath??``}:${e.path}`)})})}),(0,L.jsx)(`div`,{className:`pointer-events-none absolute inset-x-0 bottom-4 z-20 flex justify-center px-2`,children:(0,L.jsxs)(`div`,{className:`pointer-events-auto inline-flex max-w-full items-center gap-1 rounded-full border border-[color-mix(in_oklab,var(--border)_34%,transparent)] bg-background/95 p-1 shadow-quickforge`,children:[(0,L.jsxs)(`button`,{type:`button`,className:`inline-flex h-8 min-w-0 items-center gap-2 rounded-full px-3 text-sm font-medium text-muted-foreground/78 transition-colors hover:bg-destructive/10 hover:text-destructive disabled:cursor-not-allowed disabled:opacity-40`,onClick:p,disabled:!p||e.length===0||C,"aria-label":k(`workspaceRestoreAll`),title:k(`workspaceRestoreAll`),children:[b?(0,L.jsx)(r,{className:`size-3.5 animate-spin`}):(0,L.jsx)(te,{className:`size-3.5`}),(0,L.jsx)(`span`,{className:`truncate`,children:k(`workspaceRestoreAll`)})]}),(0,L.jsxs)(`button`,{type:`button`,className:O(`inline-flex h-8 min-w-0 items-center gap-2 rounded-full px-3 text-sm font-medium text-muted-foreground/78 transition-colors disabled:cursor-not-allowed disabled:opacity-40`,g?`hover:bg-amber-500/10 hover:text-amber-600 dark:hover:text-amber-500`:`hover:bg-emerald-500/10 hover:text-emerald-600 dark:hover:text-emerald-500`),onClick:g?h:m,disabled:g?!h||y.length===0||C:!m||ee.length===0||C,"aria-label":k(g?`workspaceUnstageAll`:`workspaceStageAll`),title:k(g?`workspaceUnstageAll`:`workspaceStageAll`),children:[x||S?(0,L.jsx)(r,{className:`size-3.5 animate-spin`}):g?(0,L.jsx)(c,{className:`size-3.5`}):(0,L.jsx)(i,{className:`size-3.5`}),(0,L.jsx)(`span`,{className:`truncate`,children:k(g?`workspaceUnstageAll`:`workspaceStageAll`)})]})]})})]})}function Ct(e){return e?e.status===`added`?`A`:e.status===`deleted`?`D`:e.status===`renamed`?`R`:e.status===`untracked`?`U`:`M`:``}function wt({projectId:e,path:t}){let[n,r]=(0,I.useState)(!1);return n?(0,L.jsx)(_t,{path:t,className:`size-3.5 shrink-0`}):(0,L.jsx)(`img`,{src:Me(e,t),alt:``,"aria-hidden":!0,loading:`lazy`,decoding:`async`,onError:()=>r(!0),className:`size-3.5 shrink-0 rounded-[3px] object-cover ring-1 ring-black/5 dark:ring-white/10`})}function Tt({node:e,depth:t,selectedPath:n,gitStatuses:r,onSelectFile:i,onPreviewFile:a,projectId:o}){let[s,c]=(0,I.useState)(t<1),l=e.type===`directory`,d=n===e.path,f=Ct(r[e.path]),p=(l?void 0:A(e.path))===`image`,m=!!o&&p,h=!!a&&(p||Oe(e.path));function g(){a?.(e.path)}return(0,L.jsxs)(`div`,{children:[(0,L.jsxs)(`button`,{type:`button`,className:`group flex h-7 w-full items-center gap-1.5 rounded-md px-2 text-left text-xs transition-colors ${d?`bg-muted/28 text-foreground/90`:`text-muted-foreground/72 hover:bg-muted/20 hover:text-foreground/85`}`,style:{paddingLeft:`${.5+t*.75}rem`},onClick:()=>{l?c(e=>!e):p&&a?g():i(e.path)},title:e.path,children:[l?(0,L.jsx)(u,{className:`size-3 shrink-0 transition-transform ${s?`rotate-90`:``}`}):(0,L.jsx)(`span`,{className:`w-3 shrink-0`}),l?(0,L.jsx)(vt,{name:e.name,open:s,className:`size-3.5 shrink-0`}):m?(0,L.jsx)(wt,{projectId:o,path:e.path}):(0,L.jsx)(_t,{path:e.path,className:`size-3.5 shrink-0`}),(0,L.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name}),f?(0,L.jsx)(`span`,{className:`shrink-0 font-mono text-[0.68rem] text-emerald-600 dark:text-emerald-500`,children:f}):null,h?(0,L.jsx)(`span`,{role:`button`,tabIndex:0,"aria-label":k(`openPreview`),title:k(`openPreview`),className:`-mr-1 shrink-0 rounded p-0.5 text-muted-foreground/60 opacity-0 transition-opacity hover:bg-muted/40 hover:text-foreground/85 focus-visible:opacity-100 focus-visible:text-foreground/85 focus-visible:outline-none group-hover:opacity-100`,onClick:e=>{e.stopPropagation(),g()},onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),e.stopPropagation(),g())},children:(0,L.jsx)(w,{className:`size-3.5`})}):null]}),l&&s?(0,L.jsx)(`div`,{children:(e.children??[]).map(e=>(0,L.jsx)(Tt,{node:e,depth:t+1,selectedPath:n,gitStatuses:r,onSelectFile:i,onPreviewFile:a,projectId:o},e.path))}):null]})}function Et({tree:e,selectedPath:t,gitStatuses:n={},onSelectFile:r,onPreviewFile:i,projectId:a}){return e.length===0?(0,L.jsx)(`div`,{className:`px-2 py-3 text-xs text-muted-foreground/70`,children:k(`workspaceNoFilesToDisplay`)}):(0,L.jsx)(`div`,{className:`space-y-0.5`,children:e.map(e=>(0,L.jsx)(Tt,{node:e,depth:0,selectedPath:t,gitStatuses:n,onSelectFile:r,onPreviewFile:i,projectId:a},e.path))})}function Dt(e,t,n){return!!(e&&t&&e.projectId===t&&e.id!==n)}var Z=`quickforge:workspace-inspector-tabs:v1:`;function Ot(e){return`${Z}${e}`}function kt(e,t){return e===`browser`?`browser`:`${e}:${t}`}function At(e){return e===`files`||e===`review`||e===`terminal`||e===`browser`||e===`reader`}function jt(){try{return globalThis.localStorage}catch{return}}function Mt(e){if(!Array.isArray(e))return[];let t=new Set,n=[];for(let r of e){if(!r||typeof r!=`object`||Array.isArray(r))continue;let e=r;if(!(typeof e.id!=`string`||!e.id||!At(e.kind))){if(e.kind===`review`){if(t.has(e.kind))continue;t.add(e.kind)}if(e.kind===`reader`){let t=e.reader;if(!t||t.mode!==`file`||typeof t.path!=`string`||!t.path)continue;let r=kt(t.mode,t.path);n.push({id:e.id,kind:e.kind,readerTabs:[{id:r,mode:t.mode,path:t.path,loading:!0}],activeReaderTabId:r});continue}n.push({id:e.id,kind:e.kind,...e.kind===`browser`&&typeof e.url==`string`?{url:e.url}:{},...e.kind===`review`?{reviewView:e.reviewView===`review`?`review`:`changes`}:{},...e.kind===`terminal`&&typeof e.terminalSessionId==`string`?{terminalSessionId:e.terminalSessionId}:{},...e.kind===`files`||e.kind===`review`?{readerTabs:[],activeReaderTabId:void 0}:{}})}}return n}function Nt(e,t=jt()){if(!t)return{tabs:[]};try{let n=t.getItem(Ot(e));if(!n)return{tabs:[]};let r=JSON.parse(n),i=Mt(r?.tabs),a=typeof r?.activePanelTabId==`string`&&i.some(e=>e.id===r.activePanelTabId)?r.activePanelTabId:i[0]?.id;return a?{tabs:i,activePanelTabId:a}:{tabs:i}}catch{return{tabs:[]}}}function Pt(e,t){let n=e.flatMap(e=>{if(e.kind===`reader`){let t=e.readerTabs?.find(t=>t.id===e.activeReaderTabId)??e.readerTabs?.[0];return!t||t.mode!==`file`?[]:[{id:e.id,kind:e.kind,reader:{mode:t.mode,path:t.path}}]}return[{id:e.id,kind:e.kind,...e.kind===`browser`?{url:e.url||``}:{},...e.kind===`review`?{reviewView:e.reviewView||`changes`}:{},...e.kind===`terminal`&&e.terminalSessionId?{terminalSessionId:e.terminalSessionId}:{}}]});return{tabs:n,activePanelTabId:t&&n.some(e=>e.id===t)?t:n[0]?.id}}function Ft(e,t,n,r=jt()){if(!r)return!1;try{return r.setItem(Ot(e),JSON.stringify(Pt(t,n))),!0}catch{return!1}}function It(e){return e.reduce((e,t)=>{let n=t.id.match(/-(\d+)$/);if(!n)return e;let r=Number(n[1]);return Number.isFinite(r)?Math.max(e,r):e},0)+1}function Lt(){let e,t=0;return{token:n=>(n!==e&&(e=n,t+=1),{projectId:n,epoch:t}),isCurrent:n=>n.projectId===e&&n.epoch===t,invalidate:()=>(t+=1,t)}}function Rt(){if(typeof window>`u`)return 0;let e=window.getComputedStyle(document.body).getPropertyValue(`--quickforge-desktop-titlebar-height`).trim();if(!e)return 0;let t=Number.parseFloat(e);return Number.isFinite(t)?t:0}function zt(e,t){return e===`browser`?`browser`:`${e}:${t}`}var Bt=[{kind:`files`,label:k(`rightPanelFiles`),description:k(`rightPanelFilesDesc`),icon:v},{kind:`review`,label:k(`rightPanelReview`),description:k(`rightPanelReviewDesc`),icon:E},{kind:`terminal`,label:k(`rightPanelTerminal`),description:k(`rightPanelTerminalDesc`),icon:S},{kind:`browser`,label:k(`rightPanelBrowser`),description:k(`rightPanelBrowserDesc`),icon:_}],Vt=[{value:`unstaged`,label:k(`workspaceReviewFilterUnstaged`)},{value:`staged`,label:k(`workspaceReviewFilterStaged`)},{value:`all`,label:k(`workspaceReviewFilterAllBranches`)},{value:`last`,label:k(`workspaceReviewFilterLastRun`)}],Ht=Object.fromEntries(Bt.map(e=>[e.kind,e]));function Ut(e){return e===`review`?`changes`:e}function Wt(e){let t=e.trim();if(!t)return`about:blank`;if(/^[a-zA-Z]:[\\/]/.test(t))return M(t);try{let e=new URL(t);return e.protocol===`about:`?t:e.protocol===`file:`?M(decodeURIComponent(e.pathname)):e.host||t}catch{return M(t)}}function Gt(e,t){if(e.kind===`terminal`)return t||k(`rightPanelTerminal`);if(e.kind===`browser`)return Wt(e.url||``);if(e.kind===`reader`){let t=e.readerTabs?.find(t=>t.id===e.activeReaderTabId)??e.readerTabs?.[0];return t?M(t.path):k(`rightPanelFiles`)}return Ht[e.kind].label}function Kt(e,t){return e.kind===`browser`?e.url||t:e.kind===`reader`&&(e.readerTabs?.find(t=>t.id===e.activeReaderTabId)??e.readerTabs?.[0])?.path||t}var qt=340,Q=380,Jt=640,Yt=`quickforge_workspaceInspectorWidth_v2`,Xt=140,Zt=200,Qt=400;function $t(){if(typeof window>`u`)return Q;try{let e=window.localStorage.getItem(Yt);if(!e)return Q;let t=Number(e);return Number.isFinite(t)?Math.min(Jt,Math.max(qt,t)):Q}catch{return Q}}function en(e,t){let n=t.trim().toLowerCase();return n?e.flatMap(e=>{let t=e.children?en(e.children,n):void 0;return!(e.name.toLowerCase().includes(n)||e.path.toLowerCase().includes(n))&&(!t||t.length===0)?[]:[{...e,...t?{children:t}:{}}]}):e}function tn(e,t){let n=e?.trim();if(!n)return``;let r=n.replace(/\\/g,`/`).replace(/^\.\/+/g,``),i=t?.trim().replace(/\\/g,`/`).replace(/\/+$/g,``);return i&&r.startsWith(`${i}/`)&&(r=r.slice(i.length+1)),r.replace(/^\/+/,``)}function nn(e,t){let n=new Set;for(let r of e){let e=tn(r.path,t),i=tn(r.outputFile,t);e&&n.add(e),i&&n.add(i)}return n}function rn(e){return k(e===`staged`?`workspaceNoStagedChanges`:e===`last`?`workspaceNoLastRunChanges`:`workspaceNoWorkingTreeChanges`)}function an(e){return e?e.language===`markdown`||/\.(md|markdown)$/i.test(e.path):!1}function on(e,t=!1){return k(t?`readerFileMarkdownPrompt`:`readerFilePrompt`,{path:e})}function sn(e){return k(`readerDiffPrompt`,{path:e})}function $(e){return`Diff for ${e.oldPath?`${e.oldPath} -> ${e.path}`:e.path}\n\n--- OLD\n${e.oldContent}\n\n--- NEW\n${e.newContent}`}function cn({mode:e,file:t,diff:n,loading:r,error:i,onClose:a,onDraftRequest:o}){let[s,c]=(0,I.useState)(),[l,u]=(0,I.useState)(`preview`);async function f(e,t){t&&(await navigator.clipboard.writeText(t),c(e),window.setTimeout(()=>c(void 0),1200))}let p=e===`file`?t?.path:n?.path,m=e===`file`&&an(t),h=e===`file`?t?.content:n?$(n):void 0,g=e===`file`&&t?on(t.path,m):e===`diff`&&n?sn(n.path):void 0,_=(0,I.useMemo)(()=>e===`diff`&&n?V(n.oldContent,n.newContent):void 0,[e,n]);return(0,L.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,L.jsxs)(`div`,{className:`flex h-11 shrink-0 items-center gap-2 border-b border-border px-3`,children:[m?(0,L.jsx)(`div`,{className:`inline-flex rounded-full bg-muted/25 p-1 text-xs`,children:[`preview`,`source`].map(e=>(0,L.jsx)(`button`,{type:`button`,className:e===l?`rounded-full bg-background px-3 py-1 font-medium text-foreground/90 shadow-[0_8px_20px_-16px_rgb(15_23_42_/_0.42)]`:`rounded-full px-3 py-1 text-muted-foreground/70 hover:text-foreground/85`,onClick:()=>u(e),children:k(e===`preview`?`markdownPreview`:`markdownSource`)},e))}):null,_?(0,L.jsxs)(`span`,{className:`shrink-0 font-mono text-[11px] font-medium`,children:[(0,L.jsxs)(`span`,{className:`text-emerald-600 dark:text-emerald-400`,children:[`+`,_.added]}),(0,L.jsxs)(`span`,{className:`ml-1.5 text-red-600 dark:text-red-400`,children:[`-`,_.removed]})]}):null,(0,L.jsx)(`div`,{className:`flex-1`}),(0,L.jsx)(N,{variant:`ghost`,size:`icon`,className:`size-7`,onClick:()=>void f(`path`,p),disabled:!p,"aria-label":k(`copyPath`),title:k(`copyPath`),children:s===`path`?(0,L.jsx)(oe,{className:`size-3.5`}):(0,L.jsx)(ae,{className:`size-3.5`})}),(0,L.jsx)(N,{variant:`ghost`,size:`icon`,className:`size-7`,onClick:()=>void f(`content`,h),disabled:!h,"aria-label":k(`copyContent`),title:k(e===`file`?`copyContent`:`copyDiffContent`),children:s===`content`?(0,L.jsx)(oe,{className:`size-3.5`}):(0,L.jsx)(ae,{className:`size-3.5`})}),(0,L.jsx)(N,{variant:`ghost`,size:`icon`,className:`size-7`,onClick:()=>g&&o?.(g),disabled:!g||!o,"aria-label":k(`askAiAboutThis`),title:k(`askAiAboutThis`),children:(0,L.jsx)(d,{className:`size-3.5`})}),(0,L.jsx)(N,{variant:`ghost`,size:`icon`,className:`size-7`,onClick:a,"aria-label":k(`close`),title:k(`close`),children:(0,L.jsx)(ce,{className:`size-3.5`})})]}),(0,L.jsxs)(`div`,{className:`min-h-0 flex-1 bg-background`,children:[r?(0,L.jsx)(`div`,{className:`p-4 text-sm text-muted-foreground/70`,children:k(`openingReader`)}):null,!r&&i?(0,L.jsx)(`div`,{className:`p-4 text-sm text-destructive`,children:i}):null,!r&&!i&&e===`file`&&t?m?(0,L.jsx)(nt,{path:t.path,content:t.content,language:t.language,mode:l},t.path):(0,L.jsx)(Ye,{path:t.path,content:t.content,language:t.language}):null,!r&&!i&&e===`diff`&&n?(0,L.jsx)(rt,{path:n.path,oldContent:n.oldContent,newContent:n.newContent,language:n.language,status:n.status}):null]})]})}function ln({project:e,artifacts:t,changesCount:r,changedPaths:i,isGitRepository:a,gitBranch:o,onSelectFile:s,onSelectDiff:c,onPreviewFile:l}){let[u,d]=(0,I.useState)(!1),[f,p]=(0,I.useState)(()=>new Set),m=Se(t),h=t.filter(e=>e.command);function g(e){p(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}return(0,L.jsxs)(`div`,{className:`space-y-3 p-2`,children:[(0,L.jsxs)(`div`,{className:`rounded-lg border border-border bg-background px-3 py-3`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-semibold text-foreground/90`,children:[(0,L.jsx)(b,{className:`size-3.5 text-emerald-600 dark:text-emerald-500`}),k(`workspaceCurrentArtifacts`)]}),t.length===0?(0,L.jsx)(`div`,{className:`mt-2 text-xs leading-5 text-muted-foreground/70`,children:k(`workspaceNoArtifacts`)}):(0,L.jsxs)(`div`,{className:`mt-3 space-y-3`,children:[m.length?(0,L.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,L.jsxs)(`div`,{className:`text-[11px] font-medium uppercase tracking-wide text-muted-foreground/60`,children:[k(`workspaceFiles`),` `,m.length]}),m.slice(0,8).map(e=>{let t=e.path,n=j(t),r=i.has(t),a=typeof e.addedLines==`number`||typeof e.removedLines==`number`;return(0,L.jsxs)(`div`,{className:`group flex min-w-0 items-center gap-2 rounded-md px-2 py-1.5 text-xs text-foreground/85 transition-colors hover:bg-muted/20`,children:[(0,L.jsx)(`button`,{type:`button`,className:`min-w-0 flex-1 truncate text-left font-medium`,onClick:()=>n?l(t):r?c(t):s(t),title:t,children:e.title||M(t)}),a?(0,L.jsxs)(`span`,{className:`shrink-0 font-mono text-[10px] font-medium`,children:[(0,L.jsxs)(`span`,{className:`text-emerald-600 dark:text-emerald-400`,children:[`+`,e.addedLines??0]}),(0,L.jsxs)(`span`,{className:`ml-1 text-red-600 dark:text-red-400`,children:[`-`,e.removedLines??0]})]}):null,(0,L.jsx)(`span`,{className:`shrink-0 rounded-full bg-muted/30 px-1.5 py-0.5 text-[10px] font-medium text-muted-foreground/70`,children:e.kind}),n?(0,L.jsx)(`button`,{type:`button`,className:`shrink-0 inline-flex size-5 items-center justify-center text-blue-600 opacity-0 transition-opacity hover:bg-blue-500/10 hover:text-blue-700 group-hover:opacity-100 dark:text-blue-400`,onClick:()=>l(t),"aria-label":k(`previewArtifact`),title:k(`previewArtifact`),children:(0,L.jsx)(w,{className:`size-3.5`})}):null,(0,L.jsx)(`button`,{type:`button`,className:`shrink-0 rounded-md px-1.5 py-0.5 text-[10px] font-medium text-muted-foreground/70 opacity-0 transition-opacity hover:bg-muted/25 group-hover:opacity-100`,onClick:()=>r?c(t):s(t),children:k(r?`workspaceViewDiff`:`artifactPreviewViewSource`)})]},e.id)}),m.length>8?(0,L.jsxs)(`div`,{className:`px-2 text-[11px] text-muted-foreground/60`,children:[`+`,m.length-8]}):null]}):null,h.length?(0,L.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,L.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 rounded-md px-1 py-1 text-left text-[11px] font-medium uppercase tracking-wide text-muted-foreground/60 transition-colors hover:bg-muted/15 hover:text-foreground/75`,onClick:()=>d(e=>!e),"aria-expanded":u,children:[(0,L.jsx)(n,{className:O(`size-3.5 transition-transform`,u?``:`-rotate-90`)}),(0,L.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,children:[k(`workspaceCommands`),` `,h.length]})]}),u?(0,L.jsx)(`div`,{className:`space-y-1`,children:h.map((e,t)=>{let r=f.has(e.id);return(0,L.jsxs)(`div`,{className:`rounded-md bg-muted/15 text-[11px] text-muted-foreground/80`,children:[(0,L.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 px-2 py-1.5 text-left transition-colors hover:bg-muted/20`,onClick:()=>g(e.id),"aria-expanded":r,children:[(0,L.jsx)(n,{className:O(`size-3 shrink-0 transition-transform`,r?``:`-rotate-90`)}),(0,L.jsxs)(`span`,{className:`shrink-0 font-medium text-muted-foreground/65`,children:[`#`,t+1]}),(0,L.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono`,children:e.command})]}),r?(0,L.jsxs)(`div`,{className:`space-y-1 px-2 pb-2 pt-1.5`,children:[(0,L.jsx)(`pre`,{className:`whitespace-pre-wrap break-words font-mono text-[11px] leading-5 text-foreground/80`,children:e.command}),e.outputFile?(0,L.jsxs)(`div`,{className:`text-[10px] text-muted-foreground/65`,children:[k(`workspaceCommandOutput`),`: `,(0,L.jsx)(`span`,{className:`font-mono`,children:e.outputFile})]}):null]}):null]},e.id)})}):null]}):null]})]}),(0,L.jsxs)(`div`,{className:`rounded-lg border border-border bg-muted/10 px-3 py-3`,children:[(0,L.jsx)(`div`,{className:`text-xs font-medium text-foreground/85`,children:e?.name??k(`noProjectSelected`)}),(0,L.jsx)(`div`,{className:`mt-1 text-[11px] text-muted-foreground/65`,children:a?`${k(`workspaceCurrentBranch`)}: ${o||k(`unknown`)} · ${r} ${k(`workspaceChangeCount`)}`:k(`workspaceNotGitRepository`)})]})]})}function un({project:e,open:t,onOpenChange:r,onOpenCommitPush:o,onOpenProjectInExplorer:c,onOpenProjectInVSCode:u,onOpenProjectInIDEA:d,onPreviewArtifact:f,onDraftRequest:m,request:h,onRequestHandled:g,artifacts:_=[],pendingTerminalCommand:v,onPendingTerminalCommandHandled:ee}){let[x,te]=(0,I.useState)([]),[S,C]=(0,I.useState)([]),[ne,re]=(0,I.useState)(),[ie,ae]=(0,I.useState)(!1),[w,se]=(0,I.useState)(!1),[le,ue]=(0,I.useState)(),[T,de]=(0,I.useState)(``),[E,fe]=(0,I.useState)(`unstaged`),[D,pe]=(0,I.useState)(),[me,he]=(0,I.useState)(),[_e,ye]=(0,I.useState)(!1),[Se,Oe]=(0,I.useState)(),ke=(0,I.useRef)(void 0);ke.current||=e?.id?Nt(e.id):{tabs:[]};let[A,Me]=(0,I.useState)(()=>ke.current?.tabs??[]),[j,M]=(0,I.useState)(()=>ke.current?.activePanelTabId),[Le,Re]=(0,I.useState)(!1),[P,Be]=(0,I.useState)(!1),[F,Ve]=(0,I.useState)(!1),[He,Ue]=(0,I.useState)(),[We,Ge]=(0,I.useState)(Zt),[qe,Je]=(0,I.useState)(!1),[Ye,Xe]=(0,I.useState)(t),[R,Ze]=(0,I.useState)(!1),[z,Qe]=(0,I.useState)($t),[$e,et]=(0,I.useState)(!1),[B,tt]=(0,I.useState)(!1),[nt,rt]=(0,I.useState)(!1),V=(0,I.useRef)(null),it=(0,I.useRef)(null),at=(0,I.useRef)(null),ot=(0,I.useRef)(null),st=(0,I.useRef)(null),H=(0,I.useRef)(null),ct=(0,I.useRef)(null),U=(0,I.useRef)(null),W=(0,I.useRef)(null),lt=(0,I.useRef)(null),ut=(0,I.useRef)(It(ke.current?.tabs??[])),dt=(0,I.useRef)(void 0),ft=(0,I.useRef)(void 0),pt=(0,I.useRef)(void 0),G=(0,I.useRef)(Lt()),mt=(0,I.useRef)(new Set),K=(0,I.useRef)(0);(0,I.useEffect)(()=>{let e=G.current;return()=>{e.invalidate()}},[]);let q=e?.id;q&&G.current.token(q);let J=(0,I.useMemo)(()=>A.find(e=>e.id===j),[j,A]),ht=J?.activeReaderTabId,gt=(0,I.useMemo)(()=>J?.readerTabs||[],[J?.readerTabs]),Y=(0,I.useMemo)(()=>gt.find(e=>e.id===ht),[ht,gt]),_t=!!(Y&&Y.mode!==`browser`&&(J?.kind===`reader`||J?.kind===`files`||J?.kind===`review`&&Y.mode===`diff`)),vt=J?.kind===`review`?J.reviewView===`review`?`overview`:`changes`:`files`,yt=(0,I.useMemo)(()=>{let e={};for(let t of S)e[t.path]=t;return e},[S]),bt=(0,I.useMemo)(()=>{let e=new Set;for(let t of S)e.add(t.path),t.oldPath&&e.add(t.oldPath);return e},[S]),X=(0,I.useMemo)(()=>en(x,T),[T,x]),xt=(0,I.useMemo)(()=>nn(_,e?.path),[_,e?.path]),Ct=(0,I.useMemo)(()=>E===`staged`?S.filter(e=>e.staged):E===`all`?S:E===`last`?S.filter(e=>xt.has(e.path)||(e.oldPath?xt.has(e.oldPath):!1)):S.filter(e=>e.unstaged||e.status===`untracked`||e.conflict||e.status===`conflicted`),[S,xt,E]),wt=D?Ct.find(e=>e.path===D):void 0;function Tt(e){C(e.files),re(e.branch),ae(e.isGitRepository)}async function Z(e,t,n,r){Ue({action:e,path:t});try{Tt(await n())}catch(e){await be(e instanceof Error?e.message:r)}finally{Ue(void 0)}}async function Ot(e){q&&await Z(`stage`,e.path,()=>Fe(q,e.path),k(`workspaceStageFailed`))}async function kt(){q&&await Z(`stage`,void 0,()=>xe(q),k(`workspaceStageFailed`))}async function At(e){q&&await Z(`unstage`,e.path,()=>Ce(q,e.path),k(`workspaceUnstageFailed`))}async function jt(){q&&await Z(`unstage`,void 0,()=>Ie(q),k(`workspaceUnstageFailed`))}async function Mt(e){q&&await ve({title:k(`workspaceRestoreConfirmTitle`),description:k(`workspaceRestoreFileConfirm`,{path:e.path}),confirmLabel:k(`workspaceRestoreFile`),cancelLabel:k(`cancel`),variant:`destructive`})&&await Z(`restore`,e.path,()=>Ee(q,e.path),k(`workspaceRestoreFailed`))}async function Pt(){q&&await ve({title:k(`workspaceRestoreConfirmTitle`),description:k(`workspaceRestoreAllConfirm`),confirmLabel:k(`workspaceRestoreAll`),cancelLabel:k(`cancel`),variant:`destructive`})&&await Z(`restore`,void 0,()=>De(q),k(`workspaceRestoreFailed`))}function Wt(e){e.status!==`deleted`&&mn(e.path)}async function Q(t){if(e){if(!wt){t===`explorer`?c?.(e):t===`idea`?d?.(e):u?.(e);return}if(q)try{await je(q,wt.path,t)}catch(e){let n=k(t===`explorer`?`openInExplorerFailed`:t===`idea`?`openInIDEAFailed`:`openInVSCodeFailed`);await be(e instanceof Error?e.message:n)}}}(0,I.useEffect)(()=>{!D||Ct.some(e=>e.path===D)||(pe(void 0),he(void 0),Oe(void 0),ye(!1))},[D,Ct]),(0,I.useEffect)(()=>{if(t){let e=!1;return queueMicrotask(()=>{e||(Xe(!0),window.requestAnimationFrame(()=>{e||Ze(!0)}))}),()=>{e=!0}}let e=!1;queueMicrotask(()=>{e||Ze(!1)});let n=window.setTimeout(()=>Xe(!1),180);return()=>{e=!0,window.clearTimeout(n)}},[t]),(0,I.useEffect)(()=>{if(!Le&&!P&&!F)return;let e=e=>{let t=e.target;Le&&!it.current?.contains(t)&&Re(!1),P&&!at.current?.contains(t)&&Be(!1),F&&!ot.current?.contains(t)&&Ve(!1)},t=e=>{e.key===`Escape`&&(Re(!1),Be(!1),Ve(!1))};return document.addEventListener(`pointerdown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`pointerdown`,e),document.removeEventListener(`keydown`,t)}},[Le,F,P]),(0,I.useEffect)(()=>{!t||!Dt(h,q,pt.current)||(pt.current=h.id,h.kind===`review`?dt.current?.(`review`,h.view):h.kind===`reader`?ft.current?.(h.path):h.kind===`browser`?dt.current?.(`browser`,`browser`,{url:h.url}):dt.current?.(h.kind,Ut(h.kind)),g?.(h.id))},[g,t,q,h]),(0,I.useEffect)(()=>{try{window.localStorage.setItem(Yt,String(z))}catch{}},[z]);let tn=(0,I.useCallback)(()=>{Qe(e=>e<Jt?Jt:e)},[]);(0,I.useEffect)(()=>{!R||B||(J?.kind===`browser`||J?.kind===`terminal`||ht)&&tn()},[J?.kind,ht,R,B,tn]);let an=(0,I.useCallback)(async e=>{if(q){se(!0),ue(void 0);try{let[t,n]=await Promise.all([Ne(q),we(q)]);if(e?.())return;te(t.tree),C(n.files),re(n.branch),ae(n.isGitRepository)}catch(t){e?.()||ue(t instanceof Error?t.message:k(`workspaceLoadFailed`))}finally{e?.()||se(!1)}}},[q]);(0,I.useEffect)(()=>{let e=!1;if(!(!q||!t))return queueMicrotask(()=>{e||an(()=>e)}),()=>{e=!0}},[an,t,q]),(0,I.useEffect)(()=>{q&&Ft(q,A,j)},[j,A,q]),(0,I.useEffect)(()=>{!j||A.some(e=>e.id===j)||M(A[0]?.id)},[j,A]),(0,I.useEffect)(()=>{if(!q)return;let e=A.flatMap(e=>e.kind===`reader`?(e.readerTabs||[]).filter(e=>e.loading&&e.mode===`file`).map(t=>({panelTabId:e.id,reader:t})):[]);for(let{panelTabId:t,reader:n}of e){let e=`${q}:${n.id}`;if(mt.current.has(e))continue;mt.current.add(e);let r=G.current.token(q);Te(q,n.path).then(e=>({file:e})).then(e=>{G.current.isCurrent(r)&&$(t,t=>({...t,readerTabs:(t.readerTabs||[]).map(t=>t.id===n.id?{...t,...e,loading:!1,error:void 0}:t)}))}).catch(e=>{G.current.isCurrent(r)&&$(t,t=>({...t,readerTabs:(t.readerTabs||[]).map(t=>t.id===n.id?{...t,loading:!1,error:e instanceof Error?e.message:k(`workspaceOpenFileFailed`)}:t)}))}).finally(()=>{mt.current.delete(e)})}},[A,q]);function on(e,t){let n=`${e}-${ut.current++}`;return e===`browser`?{id:n,kind:e,url:t?.url||``}:e===`reader`?{id:n,kind:e,readerTabs:t?.readerTab?[t.readerTab]:[],activeReaderTabId:t?.readerTab?.id}:e===`files`||e===`review`?{id:n,kind:e,...e===`review`?{reviewView:t?.reviewView||`changes`}:{},readerTabs:t?.readerTab?[t.readerTab]:[],activeReaderTabId:t?.readerTab?.id}:{id:n,kind:e}}function sn(e){return on(`reader`,{readerTab:e})}function $(e,t){Me(n=>n.map(n=>n.id===e?t(n):n))}function un(e,t=Ut(e),n){let r=e===`review`?A.find(e=>e.kind===`review`):void 0,i=r||on(e,{...n,...e===`review`?{reviewView:t===`review`?`review`:`changes`}:{}});return r||Me(e=>[...e,i]),r?.kind===`review`&&$(r.id,e=>({...e,reviewView:t===`review`?`review`:`changes`})),M(i.id),Re(!1),i}dt.current=un;function dn(e){M(e.id)}function fn(e){Me(t=>{let n=t.findIndex(t=>t.id===e),i=t.filter(t=>t.id!==e);return i.length===0?(M(void 0),r(!1),i):(j===e&&M((i[n]??i[n-1])?.id),i)})}function pn(e){if(f&&q){f(q,e);return}mn(e)}async function mn(e){if(!q)return;let t=G.current.token(q),n=zt(`file`,e),r=A.find(e=>e.kind===`reader`&&e.readerTabs?.some(e=>e.id===n));if(r){M(r.id),$(r.id,e=>({...e,activeReaderTabId:n}));return}let i=sn({id:n,mode:`file`,path:e,loading:!0});Me(e=>[...e,i]),M(i.id);try{let r=await Te(q,e);if(!G.current.isCurrent(t))return;$(i.id,e=>({...e,readerTabs:(e.readerTabs||[]).map(e=>e.id===n?{...e,file:r,loading:!1,error:void 0}:e)}))}catch(e){if(!G.current.isCurrent(t))return;$(i.id,t=>({...t,readerTabs:(t.readerTabs||[]).map(t=>t.id===n?{...t,loading:!1,error:e instanceof Error?e.message:k(`workspaceOpenFileFailed`)}:t)}))}}ft.current=mn;async function hn(e,t){if(!q)return;let n=G.current.token(q),r=A.find(e=>e.kind===`review`)||un(`review`,t?`changes`:`review`);M(r.id),t&&r.kind===`review`&&$(r.id,e=>({...e,reviewView:`changes`}));let i=zt(`diff`,e);if(r.readerTabs?.some(e=>e.id===i)){$(r.id,e=>({...e,activeReaderTabId:i}));return}let a={id:i,mode:`diff`,path:e,loading:!0};$(r.id,e=>({...e,readerTabs:[...e.readerTabs||[],a],activeReaderTabId:i}));try{let t=await Pe(q,e);if(!G.current.isCurrent(n))return;$(r.id,e=>({...e,readerTabs:(e.readerTabs||[]).map(e=>e.id===i?{...e,diff:t,loading:!1,error:void 0}:e)}))}catch(e){if(!G.current.isCurrent(n))return;$(r.id,t=>({...t,readerTabs:(t.readerTabs||[]).map(t=>t.id===i?{...t,loading:!1,error:e instanceof Error?e.message:k(`workspaceOpenDiffFailed`)}:t)}))}}async function gn(e){if(!q)return;let t=G.current.token(q);if(D===e){K.current+=1,pe(void 0),he(void 0),Oe(void 0),ye(!1);return}let n=K.current+1;K.current=n,pe(e),he(void 0),Oe(void 0),ye(!0);try{let r=await Pe(q,e);if(K.current!==n||!G.current.isCurrent(t))return;he(r)}catch(e){if(K.current!==n||!G.current.isCurrent(t))return;Oe(e instanceof Error?e.message:k(`workspaceOpenDiffFailed`))}finally{K.current===n&&G.current.isCurrent(t)&&ye(!1)}}function _n(e){J&&$(J.id,t=>{let n=t.readerTabs||[],r=n.findIndex(t=>t.id===e),i=n.filter(t=>t.id!==e),a=t.activeReaderTabId===e?(i[r]??i[r-1])?.id:t.activeReaderTabId;return{...t,readerTabs:i,activeReaderTabId:a}})}async function vn(e){await hn(e,!1)}function yn(e){ct.current={startX:e.clientX,startWidth:z,currentWidth:z},lt.current={cursor:document.body.style.cursor,userSelect:document.body.style.userSelect},document.body.style.cursor=`col-resize`,document.body.style.userSelect=`none`,et(!0),e.preventDefault();try{e.currentTarget.setPointerCapture(e.pointerId)}catch{}}function bn(e){let t=ct.current,n=V.current;!t||!n||(t.currentWidth=Math.min(Jt,Math.max(qt,t.startWidth+t.startX-e.clientX)),U.current===null&&(U.current=window.requestAnimationFrame(()=>{U.current=null;let e=ct.current;!e||!V.current||(V.current.style.width=`${e.currentWidth}px`)})))}function xn(e){let t=ct.current?.currentWidth;ct.current=null,U.current!==null&&(window.cancelAnimationFrame(U.current),U.current=null),typeof t==`number`&&(V.current&&(V.current.style.width=`${t}px`),Qe(t));let n=lt.current;n&&(document.body.style.cursor=n.cursor,document.body.style.userSelect=n.userSelect,lt.current=null),et(!1);try{e.currentTarget.releasePointerCapture(e.pointerId)}catch{}}function Sn(e){st.current={startX:e.clientX,startWidth:We,currentWidth:We},document.body.style.cursor=`col-resize`,document.body.style.userSelect=`none`,Je(!0),e.preventDefault();try{e.currentTarget.setPointerCapture(e.pointerId)}catch{}}function Cn(e){let t=st.current;t&&(t.currentWidth=Math.min(Qt,Math.max(Xt,t.startWidth+e.clientX-t.startX)),H.current===null&&(H.current=window.requestAnimationFrame(()=>{H.current=null;let e=st.current;e&&Ge(e.currentWidth)})))}function wn(e){let t=st.current?.currentWidth;st.current=null,H.current!==null&&(window.cancelAnimationFrame(H.current),H.current=null),typeof t==`number`&&Ge(t),document.body.style.cursor=``,document.body.style.userSelect=``,Je(!1);try{e.currentTarget.releasePointerCapture(e.pointerId)}catch{}}let Tn=(0,I.useCallback)(()=>{let e=V.current;if(!e){tt(e=>!e);return}W.current?.cancel();let t=e.getBoundingClientRect(),n=window.innerWidth,r=Rt(),i=window.innerHeight-r,a=`${r}px`,o=`${i}px`,s=`cubic-bezier(0.22, 1, 0.36, 1)`;if(rt(!0),!B){window.requestAnimationFrame(()=>{let e=V.current;if(!e)return;Object.assign(e.style,{position:`fixed`,left:`${t.left}px`,top:`${t.top}px`,right:`auto`,bottom:`auto`,width:`${t.width}px`,height:`${t.height}px`,minWidth:`0px`,maxWidth:`none`,zIndex:`40`});let r=e.animate([{left:`${t.left}px`,top:`${t.top}px`,width:`${t.width}px`,height:`${t.height}px`},{left:`0px`,top:a,width:`${n}px`,height:o}],{duration:240,easing:s,fill:`forwards`});W.current=r,r.onfinish=()=>{W.current=null,tt(!0),window.requestAnimationFrame(()=>{r.cancel(),e.removeAttribute(`style`),window.requestAnimationFrame(()=>rt(!1))})},r.oncancel=()=>{W.current=null,rt(!1)}});return}window.requestAnimationFrame(()=>{let e=V.current;if(!e)return;Object.assign(e.style,{position:`fixed`,left:`0px`,top:a,right:`auto`,bottom:`auto`,width:`${t.width}px`,height:o,zIndex:`40`});let r=n-z,i=e.animate([{left:`0px`,top:a,width:`${t.width}px`,height:o},{left:`${r}px`,top:a,width:`${z}px`,height:o}],{duration:240,easing:s,fill:`forwards`});W.current=i,i.onfinish=()=>{W.current=null,tt(!1),window.requestAnimationFrame(()=>{i.cancel(),e.style.position=``,e.style.left=``,e.style.top=``,e.style.right=``,e.style.bottom=``,e.style.height=``,e.style.zIndex=``,e.style.width=`${z}px`,e.style.minWidth=`${qt}px`,e.style.maxWidth=`${Jt}px`,window.requestAnimationFrame(()=>rt(!1))})},i.oncancel=()=>{W.current=null,rt(!1)}})},[B,z]);return(0,I.useEffect)(()=>{if(!B)return;let e=e=>{e.key===`Escape`&&tt(!1)};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[B]),(0,I.useEffect)(()=>()=>{U.current!==null&&window.cancelAnimationFrame(U.current),H.current!==null&&window.cancelAnimationFrame(H.current),W.current?.cancel(),V.current&&V.current.removeAttribute(`style`);let e=lt.current;e&&(document.body.style.cursor=e.cursor,document.body.style.userSelect=e.userSelect)},[]),Ye?(0,L.jsx)(L.Fragment,{children:(0,L.jsxs)(`aside`,{ref:V,className:O(`relative hidden shrink-0 overflow-hidden flex-col bg-background transition-[width,min-width,max-width,opacity,transform] duration-200 ease-out will-change-[width,opacity,transform] lg:flex`,R?`translate-x-0 opacity-100`:`w-0 min-w-0 max-w-0 translate-x-4 opacity-0`,$e?`transition-none`:``,B?`quickforge-workspace-inspector-fullscreen z-40 rounded-none border-l-0`:`lg:rounded-l-2xl`),style:R?B?void 0:{width:z,minWidth:qt,maxWidth:Jt}:void 0,children:[R&&!B?(0,L.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-valuemin":qt,"aria-valuemax":Jt,"aria-valuenow":z,className:O(`group absolute inset-y-0 -left-2 z-20 flex w-4 cursor-col-resize items-center justify-center bg-transparent transition-colors hover:bg-border/40`,$e?`bg-border/45`:``),onPointerDown:yn,onPointerMove:bn,onPointerUp:xn,onPointerCancel:xn,children:(0,L.jsx)(`div`,{className:O(`flex h-10 w-3 items-center justify-center rounded-full border border-border bg-background text-muted-foreground/60 opacity-0 shadow-sm transition-opacity`,$e?`opacity-100`:`group-hover:opacity-100`),children:(0,L.jsx)(a,{className:`size-3`})})}):null,(0,L.jsxs)(`div`,{className:O(`flex h-14 shrink-0 items-center gap-2 border-b-[0.5px] border-[color-mix(in_oklab,var(--border)_34%,transparent)] bg-background px-3 pr-20 transition-opacity duration-150`,nt?`opacity-0`:`opacity-100`),children:[A.length>0?(0,L.jsxs)(`div`,{ref:at,className:`relative shrink-0`,children:[(0,L.jsx)(`button`,{type:`button`,className:`flex size-9 items-center justify-center rounded-2xl bg-transparent text-muted-foreground/85 transition-colors hover:bg-muted/45 hover:text-foreground/90`,onClick:()=>Be(e=>!e),"aria-label":k(`rightPanelOpenTabsTitle`),title:k(`rightPanelOpenTabsTitle`),"aria-haspopup":`menu`,"aria-expanded":P,children:(0,L.jsx)(n,{className:O(`size-4 transition-transform`,P&&`rotate-180`)})}),P?(0,L.jsx)(`div`,{className:`absolute left-0 top-12 z-40 w-72 max-w-[calc(100vw-2rem)] rounded-2xl border border-[color-mix(in_oklab,var(--border)_34%,transparent)] bg-popover p-2 shadow-quickforge`,role:`menu`,children:A.map(t=>{let n=(t.kind===`reader`?void 0:Ht[t.kind])?.icon??b,r=t.id===j,i=Gt(t,e?.name),a=Kt(t,i);return(0,L.jsxs)(`div`,{className:O(`group flex h-10 w-full items-center gap-2 rounded-xl px-2 transition-colors`,r?`bg-muted/55 text-foreground`:`text-foreground/86 hover:bg-muted/34 hover:text-foreground`),role:`none`,children:[(0,L.jsxs)(`button`,{type:`button`,className:`flex min-w-0 flex-1 items-center gap-2 text-left text-sm font-medium`,onClick:()=>{dn(t),Be(!1)},role:`menuitem`,title:a,children:[(0,L.jsx)(n,{className:`size-4 shrink-0 text-muted-foreground/80`}),(0,L.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:i})]}),(0,L.jsx)(`button`,{type:`button`,className:`inline-flex size-7 shrink-0 items-center justify-center rounded-full text-muted-foreground/70 opacity-70 transition-colors hover:bg-destructive/10 hover:text-destructive group-hover:opacity-100`,onClick:e=>{e.stopPropagation(),fn(t.id)},"aria-label":k(`close`),children:(0,L.jsx)(ce,{className:`size-3.5`})})]},t.id)})}):null]}):null,(0,L.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-1 overflow-hidden`,children:[A.map((t,n)=>{let r=(t.kind===`reader`?void 0:Ht[t.kind])?.icon??b,i=t.id===j,a=Gt(t,e?.name),o=Kt(t,a);return(0,L.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[n>0?(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`mx-0.5 h-3.5 w-px bg-[color-mix(in_oklab,var(--muted-foreground)_18%,transparent)]`}):null,(0,L.jsxs)(`button`,{type:`button`,className:O(`group flex h-10 max-w-40 items-center gap-2 rounded-2xl px-3 text-[13px] font-medium transition-colors`,i?`bg-[color-mix(in_oklab,var(--muted)_86%,transparent)] text-foreground/82 hover:bg-[color-mix(in_oklab,var(--muted)_86%,transparent)]`:`text-muted-foreground/45 hover:bg-[color-mix(in_oklab,var(--muted)_72%,transparent)] hover:text-muted-foreground/72`),onClick:()=>dn(t),title:o,children:[(0,L.jsx)(r,{className:O(`size-4 shrink-0`,i?`text-foreground/74`:`text-muted-foreground/45 group-hover:text-muted-foreground/72`)}),(0,L.jsx)(`span`,{className:`min-w-0 truncate`,children:a}),(0,L.jsx)(`span`,{role:`button`,tabIndex:0,className:O(`ml-0.5 inline-flex size-5 shrink-0 items-center justify-center rounded-full opacity-0 transition-all hover:bg-black hover:text-white group-hover:opacity-100`,i&&`opacity-100`),onClick:e=>{e.stopPropagation(),fn(t.id)},onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),e.stopPropagation(),fn(t.id))},"aria-label":k(`close`),children:(0,L.jsx)(ce,{className:`size-3.5`})})]})]},t.id)}),A.length===0?(0,L.jsx)(`div`,{className:`min-w-0 flex-1`}):null]}),A.length>0?(0,L.jsxs)(`div`,{ref:it,className:`relative shrink-0`,children:[(0,L.jsx)(`button`,{type:`button`,className:`flex size-9 items-center justify-center rounded-2xl bg-transparent text-muted-foreground/85 transition-colors hover:bg-muted/45 hover:text-foreground/90`,onClick:()=>Re(e=>!e),"aria-label":k(`rightPanelAddTab`),title:k(`rightPanelAddTab`),"aria-haspopup":`menu`,"aria-expanded":Le,children:(0,L.jsx)(i,{className:`size-4 stroke-[1.9]`})}),Le?(0,L.jsx)(`div`,{className:`absolute right-0 top-12 z-40 w-64 rounded-2xl border border-[color-mix(in_oklab,var(--border)_34%,transparent)] bg-popover p-2 shadow-quickforge`,role:`menu`,children:Bt.map(e=>{let t=e.icon;return(0,L.jsxs)(`button`,{type:`button`,className:O(`flex w-full items-center gap-3 rounded-xl px-3 py-2.5 text-left text-[15px] font-medium transition-colors`,e.kind===J?.kind?`bg-muted/55 text-foreground`:`text-foreground/86 hover:bg-muted/34 hover:text-foreground`),onClick:()=>un(e.kind,Ut(e.kind)),role:`menuitem`,children:[(0,L.jsx)(t,{className:`size-4 shrink-0 text-muted-foreground/80`}),(0,L.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.label})]},e.kind)})}):null]}):null,(0,L.jsx)(N,{variant:`ghost`,size:`icon`,className:`shrink-0`,onClick:Tn,"aria-label":k(B?`workspaceExitFullscreen`:`workspaceFullscreen`),title:k(B?`workspaceExitFullscreen`:`workspaceFullscreen`),children:B?(0,L.jsx)(l,{className:`size-4`}):(0,L.jsx)(p,{className:`size-4`})})]}),(0,L.jsx)(`div`,{className:O(`flex min-h-0 flex-1 transition-opacity duration-150`,nt?`opacity-0`:`opacity-100`),children:e?.id?J?J.kind===`browser`?(0,L.jsx)(Ke,{url:J.url||``,onUrlChange:e=>{$(J.id,t=>({...t,url:e}))},projectId:e.id}):J.kind===`terminal`?(0,L.jsx)(ze,{project:e,pendingCommand:v,onPendingCommandHandled:ee,onCollapse:()=>fn(J.id),variant:`panel`,singleSession:!0,panelInstanceId:J.id,panelSessionId:J.terminalSessionId,onPanelSessionReady:e=>$(J.id,t=>({...t,terminalSessionId:e}))},J.id):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`div`,{className:O(`flex min-h-0 min-w-0 flex-col bg-muted/20`,_t?`shrink-0 border-r-[0.5px] border-[color-mix(in_oklab,var(--border)_34%,transparent)]`:`flex-1`),style:_t?{width:We,minWidth:Xt,maxWidth:Qt}:void 0,children:le?(0,L.jsx)(`div`,{className:`p-4 text-sm text-destructive`,children:le}):(0,L.jsxs)(`div`,{className:O(`min-h-0 min-w-0 flex-1 p-2`,vt===`changes`?`flex flex-col overflow-hidden`:`overflow-auto`),children:[w?(0,L.jsx)(`div`,{className:`px-2 py-3 text-xs text-muted-foreground/70`,children:k(`workspaceLoading`)}):null,!w&&vt===`overview`?(0,L.jsx)(ln,{project:e,artifacts:_,changesCount:S.length,changedPaths:bt,isGitRepository:ie,gitBranch:ne,onSelectFile:mn,onSelectDiff:vn,onPreviewFile:pn}):null,!w&&vt===`files`?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`label`,{className:`mb-2 flex items-center gap-2 rounded-md border-[0.5px] border-[color-mix(in_oklab,var(--border)_34%,transparent)] bg-background px-2 py-1.5 text-xs text-muted-foreground/65 focus-within:text-foreground/85`,children:[(0,L.jsx)(y,{className:`size-3.5 shrink-0`}),(0,L.jsx)(`input`,{value:T,onChange:e=>de(e.target.value),placeholder:k(`workspaceFilterFiles`),className:`min-w-0 flex-1 bg-transparent text-xs text-foreground/85 outline-none placeholder:text-muted-foreground/50`})]}),(0,L.jsx)(Et,{tree:X,selectedPath:Y?.mode===`file`?Y.path:void 0,gitStatuses:yt,onSelectFile:mn,onPreviewFile:pn,projectId:q})]}):null,!w&&vt===`changes`?ie?(0,L.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[(0,L.jsxs)(`div`,{className:`flex min-w-0 shrink-0 flex-wrap items-center justify-between gap-x-2 gap-y-1.5 pb-2`,children:[(0,L.jsxs)(`div`,{ref:ot,className:`relative min-w-24 flex-1`,children:[(0,L.jsxs)(`button`,{type:`button`,className:`inline-flex h-8 w-full min-w-0 max-w-full items-center gap-2 rounded-xl border border-[color-mix(in_oklab,var(--border)_45%,transparent)] bg-background px-3 text-sm font-medium text-foreground/86 transition-colors hover:border-border/60 hover:bg-muted/30 hover:text-foreground`,onClick:()=>Ve(e=>!e),"aria-haspopup":`menu`,"aria-expanded":F,title:k(`workspaceReviewFilter`),children:[(0,L.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-left`,children:Vt.find(e=>e.value===E)?.label}),(0,L.jsx)(n,{className:O(`size-3.5 shrink-0 text-muted-foreground/70 transition-transform`,F&&`rotate-180`)})]}),F?(0,L.jsx)(`div`,{className:`absolute left-0 top-10 z-40 w-48 rounded-2xl border border-[color-mix(in_oklab,var(--border)_34%,transparent)] bg-popover p-1.5 shadow-quickforge`,role:`menu`,"aria-label":k(`workspaceReviewFilter`),children:Vt.map(e=>{let t=e.value===E;return(0,L.jsxs)(`button`,{type:`button`,className:O(`flex h-9 w-full items-center gap-2 rounded-xl px-2.5 text-left text-sm font-medium transition-colors`,t?`bg-muted/55 text-foreground`:`text-foreground/82 hover:bg-muted/34 hover:text-foreground`),onClick:()=>{fe(e.value),Ve(!1)},role:`menuitemradio`,"aria-checked":t,children:[(0,L.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.label}),t?(0,L.jsx)(oe,{className:`size-3.5 shrink-0 text-muted-foreground/80`}):null]},e.value)})}):null]}),(0,L.jsxs)(`div`,{className:`ml-auto flex shrink-0 items-center gap-1`,children:[(0,L.jsx)(`button`,{type:`button`,className:`inline-flex size-8 shrink-0 items-center justify-center rounded-xl text-muted-foreground/72 transition-colors hover:bg-muted/30 hover:text-foreground/85 disabled:cursor-not-allowed disabled:opacity-60`,onClick:()=>void an(),disabled:w,"aria-label":k(`refreshWorkspace`),title:k(`refreshWorkspace`),children:(0,L.jsx)(ge,{className:O(`size-3.5`,w&&`animate-spin`)})}),(0,L.jsx)(Ae,{project:e,disabledTargets:wt?.status===`deleted`?{vscode:!0,idea:!0}:void 0,targetDisabledLabel:k(`workspaceCannotOpenDeletedFile`),onOpenInExplorer:()=>{Q(`explorer`)},onOpenInVSCode:()=>{Q(`vscode`)},onOpenInIDEA:()=>{Q(`idea`)}}),o?(0,L.jsx)(`button`,{type:`button`,className:`inline-flex size-8 shrink-0 items-center justify-center rounded-xl text-muted-foreground/72 transition-colors hover:bg-muted/30 hover:text-foreground/85`,onClick:o,"aria-label":k(`gitToolsCommitOrPush`),title:k(`gitToolsCommitOrPush`),children:(0,L.jsx)(s,{className:`size-3.5`})}):null]})]}),(0,L.jsx)(St,{files:Ct,selectedPath:D,expandedDiff:me,expandedLoading:_e,expandedError:Se,onSelectFile:gn,onRestoreFile:Mt,onStageFile:Ot,onUnstageFile:At,onOpenFile:Wt,onRestoreAll:Pt,onStageAll:kt,onUnstageAll:jt,showUnstageAll:E===`staged`,pendingAction:He,emptyMessage:rn(E)})]}):(0,L.jsx)(`div`,{className:`px-2 py-3 text-xs text-muted-foreground/70`,children:k(`workspaceNotGitRepository`)}):null]})}),_t?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-valuemin":Xt,"aria-valuemax":Qt,"aria-valuenow":We,className:O(`group relative z-10 w-1.5 shrink-0 cursor-col-resize bg-transparent transition-colors`,qe?`bg-primary/30`:`hover:bg-[color-mix(in_oklab,var(--border)_52%,transparent)]`),onPointerDown:Sn,onPointerMove:Cn,onPointerUp:wn,onPointerCancel:wn}),(0,L.jsx)(`div`,{className:`flex min-w-0 flex-1 flex-col bg-background`,children:Y?(0,L.jsx)(cn,{mode:Y.mode,file:Y.file,diff:Y.diff,loading:Y.loading,error:Y.error,onClose:()=>J.kind===`reader`?fn(J.id):_n(Y.id),onDraftRequest:m}):null})]}):null]}):(0,L.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center px-5`,children:(0,L.jsxs)(`div`,{className:`w-full max-w-[26rem] space-y-4`,children:[(0,L.jsxs)(`div`,{className:`text-center font-sans`,children:[(0,L.jsx)(`div`,{className:`text-lg font-semibold leading-tight tracking-[-0.01em] text-foreground/90`,children:k(`rightPanelOpenTabsTitle`)}),(0,L.jsx)(`div`,{className:`mt-2 text-sm leading-5 text-muted-foreground/70`,children:k(`rightPanelOpenTabsDescription`)})]}),(0,L.jsx)(`div`,{className:`space-y-2`,children:Bt.map(e=>{let t=e.icon;return(0,L.jsxs)(`button`,{type:`button`,className:`flex w-full cursor-pointer items-center gap-3 rounded-xl border border-[color-mix(in_oklab,var(--border)_34%,transparent)] bg-muted/60 px-4 py-3 text-left transition-colors hover:bg-muted/72 active:bg-muted/82`,onClick:()=>un(e.kind,Ut(e.kind)),children:[(0,L.jsx)(t,{className:`size-4 shrink-0 text-muted-foreground/78`}),(0,L.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,L.jsx)(`div`,{className:`text-sm font-medium text-foreground/90`,children:e.label}),(0,L.jsx)(`div`,{className:`mt-0.5 text-xs leading-4 text-muted-foreground/60`,children:e.description})]})]},e.kind)})})]})}):(0,L.jsx)(`div`,{className:`p-4 text-sm text-muted-foreground/70`,children:k(`workspaceSelectProject`)})})]})}):null}export{un as WorkspaceInspector};
|