@jingyi0605/codingns 0.7.1 → 0.7.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/public/assets/{AdaptiveButlerPage-Cd8nPdO0.js → AdaptiveButlerPage-CgBX49t-.js} +3 -3
- package/dist/public/assets/{App-CyxK-Nos.js → App-tXOqoHNl.js} +3 -3
- package/dist/public/assets/{BootstrapPage-DEwPKWR8.js → BootstrapPage-DoRMz87R.js} +1 -1
- package/dist/public/assets/ConversationPage-DXR6Hp4O.js +9 -0
- package/dist/public/assets/{DesktopDetachPreviewPage-DDOWolgB.js → DesktopDetachPreviewPage-Cyk-ZYCk.js} +1 -1
- package/dist/public/assets/{DesktopWindowPage-CtS9D8FD.js → DesktopWindowPage-DNVNK3hs.js} +1 -1
- package/dist/public/assets/{FileContextPanel-CNOjhsi5.js → FileContextPanel-xGTYDclT.js} +1 -1
- package/dist/public/assets/{GitSidebar-DpC4UhFy.js → GitSidebar-Cr3Z9OUI.js} +1 -1
- package/dist/public/assets/{MobileCreateSessionSheet-DE4pTyXj.js → MobileCreateSessionSheet-DMW0V6GJ.js} +1 -1
- package/dist/public/assets/{MobileTopHeaderFrame-D_ZbS0qi.js → MobileTopHeaderFrame-CkdnZ_MU.js} +1 -1
- package/dist/public/assets/{MobileWorkspaceSwitcherHeader-Dc12IAXc.js → MobileWorkspaceSwitcherHeader-KIbqBYJN.js} +1 -1
- package/dist/public/assets/{RelayConnectEntryPage-D8kyZfdm.js → RelayConnectEntryPage-DIRBH3hw.js} +1 -1
- package/dist/public/assets/{ServerSettingsModal-8eRu6VXr.js → ServerSettingsModal-C-9RxdWP.js} +1 -1
- package/dist/public/assets/{SessionIndexPage-DIi0JWKP.js → SessionIndexPage-bRlIydRA.js} +1 -1
- package/dist/public/assets/{SettingsPage-OQq3kp32.js → SettingsPage-CMEt4ua9.js} +1 -1
- package/dist/public/assets/{TerminalManagerPanel-BEMzisSy.js → TerminalManagerPanel-2bi9wVhT.js} +1 -1
- package/dist/public/assets/{TerminalPage-CXLQfwjU.js → TerminalPage-DayZz2Tf.js} +1 -1
- package/dist/public/assets/{TerminalRuntimeFallbackModal-BY_VUAbq.js → TerminalRuntimeFallbackModal-DgwYcp-Y.js} +1 -1
- package/dist/public/assets/{ToolFilesPage-CYx3DgHg.js → ToolFilesPage-YvnP_FXW.js} +1 -1
- package/dist/public/assets/{ToolGitPage-fgQcvF6v.js → ToolGitPage-GMcQKtV9.js} +1 -1
- package/dist/public/assets/{ToolProcessesPage-BL6yDDPV.js → ToolProcessesPage-DFIQ7BCd.js} +1 -1
- package/dist/public/assets/{ToolsHomePage-B1n2OeVw.js → ToolsHomePage-CSilFzXR.js} +1 -1
- package/dist/public/assets/{WorkbenchLandingPage-Cu9yAWYo.js → WorkbenchLandingPage-1VtToSz9.js} +1 -1
- package/dist/public/assets/WorkbenchLayout-DScHaza9.js +244 -0
- package/dist/public/assets/{WorkbenchModal-Bpb_G1-U.js → WorkbenchModal-BWXYSXmC.js} +1 -1
- package/dist/public/assets/WorkbenchShellRoute-DN6LdrqC.js +1 -0
- package/dist/public/assets/{WorkspaceDebugDetailPage-CZwT99iQ.js → WorkspaceDebugDetailPage-Ux8_Q7la.js} +1 -1
- package/dist/public/assets/{WorkspaceDetailPage-DCM-olfU.js → WorkspaceDetailPage-B402p99m.js} +1 -1
- package/dist/public/assets/{WorkspaceHomePage-CsIIqIma.js → WorkspaceHomePage-D2pob6HI.js} +1 -1
- package/dist/public/assets/{client-runtime-manager-CMK7kLp8.js → client-runtime-manager-C5D76ewj.js} +1 -1
- package/dist/public/assets/{file-tree-icon-Bv-apgA1.js → file-tree-icon-lfU9Ag77.js} +1 -1
- package/dist/public/assets/index-CFYXCsyx.css +1 -0
- package/dist/public/assets/{index-O3gOb1E0.js → index-NGxWr8Ix.js} +3 -3
- package/dist/public/assets/{login-direct-candidate-resolver-Bn4I5JHh.js → login-direct-candidate-resolver-wXSaB0i7.js} +1 -1
- package/dist/public/assets/{model-switch-api-ZGnyVir7.js → model-switch-api-CPtou49j.js} +1 -1
- package/dist/public/assets/{preferences-service-scuqVhuA.js → preferences-service-CdaK7zA8.js} +1 -1
- package/dist/public/assets/{realtime-client-TRootbbB.js → realtime-client-BjQazYsK.js} +1 -1
- package/dist/public/assets/{relay-entry-eyCjVFMA.js → relay-entry-BwE5nw0l.js} +1 -1
- package/dist/public/assets/{terminal-runtime-meta-BGcnzxqn.js → terminal-runtime-meta-C-Lbyx2i.js} +1 -1
- package/dist/public/assets/{useRegisteredDebugTemplates-BdgPIDVM.js → useRegisteredDebugTemplates-BM7-c-gx.js} +1 -1
- package/dist/public/index.html +2 -2
- package/dist/server/config/env.js +36 -29
- package/dist/server/config/env.js.map +1 -1
- package/dist/server/modules/sessions/session-history-service.d.ts +3 -1
- package/dist/server/modules/sessions/session-history-service.js +55 -2
- package/dist/server/modules/sessions/session-history-service.js.map +1 -1
- package/dist/server/modules/sessions/session-provider-error-mapper.js +2 -2
- package/dist/server/modules/sessions/session-provider-error-mapper.js.map +1 -1
- package/dist/server/server/release-manifest-sync.d.ts +7 -0
- package/dist/server/server/release-manifest-sync.js +96 -0
- package/dist/server/server/release-manifest-sync.js.map +1 -0
- package/dist/server/server/start-host.js +2 -0
- package/dist/server/server/start-host.js.map +1 -1
- package/dist/server/ws/ws-server.js +1 -1
- package/dist/server/ws/ws-server.js.map +1 -1
- package/node_modules/@codingns/session-sync-core/package.json +1 -1
- package/package.json +3 -2
- package/scripts/postinstall.mjs +167 -22
- package/dist/public/assets/ConversationPage-CxWtRhfz.js +0 -6
- package/dist/public/assets/WorkbenchLayout-D6hGXWGE.js +0 -244
- package/dist/public/assets/WorkbenchShellRoute-BCjcGWhl.js +0 -1
- package/dist/public/assets/index-CkkzIvxs.css +0 -1
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/FileContextPanel-xGTYDclT.js","assets/index-NGxWr8Ix.js","assets/index-CFYXCsyx.css","assets/App-tXOqoHNl.js","assets/App-CcDXqFl1.css","assets/model-switch-api-CPtou49j.js","assets/WorkbenchModal-BWXYSXmC.js","assets/file-tree-icon-lfU9Ag77.js","assets/window-BVUB8gMK.js","assets/event-DvH9tcej.js","assets/relay-entry-BwE5nw0l.js","assets/GitSidebar-Cr3Z9OUI.js","assets/TerminalManagerPanel-2bi9wVhT.js","assets/terminal-runtime-meta-C-Lbyx2i.js","assets/TerminalRuntimeFallbackModal-DgwYcp-Y.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
var uk=Object.defineProperty;var dk=(e,t,n)=>t in e?uk(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Xe=(e,t,n)=>dk(e,typeof t!="symbol"?t+"":t,n);import{C as ye,t as l,b as f,j as i,e as On,m as Ji,H as Jc,J as cf,F as hk,K as pk,w as Qc,A as Zc,g as uf,D as fk,p as Ha,L as mk,M as gk,N as df,i as hf,O as mc,f as eu,h as gc,P as bk,l as pf,y as kk,n as yk,z as xk,d as wk,_ as tu}from"./index-NGxWr8Ix.js";import{m as at,e as kn,h as Ua,u as lo,f as Fn,g as ur,i as vk,j as Sk,O as td}from"./App-tXOqoHNl.js";import{e as nu,f as Ys,i as ru,j as fn,k as _o,V as ff,A as Ck,a2 as Nk,a3 as jk,H as mf,l as Tk,m as Ik,a4 as gf,a5 as Ek,M as Mk,a6 as Rk,a7 as Ak,n as Pk,t as Lk,q as _k,s as bf,h as Hs,a as bc,v as Dk,o as Bk,p as su,a8 as Ok,a9 as Wk,aa as Fk,u as Do,g as $k,ab as zk,ac as Hk,ad as Uk,ae as kf,af as qk,ag as yf,ah as Gk,ai as Vk,aj as xf,K as Kk,S as Yk,R as nd,r as Xk,ak as Jk}from"./model-switch-api-CPtou49j.js";import{t as Xs,P as wa,g as wf}from"./window-BVUB8gMK.js";import{R as Qk,_ as rd,a as sd,C as vf,i as Le}from"./event-DvH9tcej.js";import{W as Et,M as Zk,D as iu}from"./WorkbenchModal-BWXYSXmC.js";import{r as ey,b as ty}from"./relay-entry-BwE5nw0l.js";const Js=new Map,Sf=48;function fs(){return typeof window<"u"&&typeof window.sessionStorage<"u"}function id(e,t){return!Number.isFinite(e)||Date.now()-e>t}function ny(e){return!e||typeof e!="object"||!("savedAt"in e)||!("value"in e)?!1:Number.isFinite(e.savedAt)}function Cf(e){try{const t=JSON.parse(e);return ny(t)?t:null}catch{return null}}function ry(){if(!fs())return[];try{return Array.from({length:window.sessionStorage.length},(e,t)=>window.sessionStorage.key(t)).filter(e=>typeof e=="string"&&e.length>0)}catch{return[]}}function Nf(){if(!fs())return[];const e=[];for(const t of ry()){let n=null;try{n=window.sessionStorage.getItem(t)}catch{continue}if(!n)continue;const r=Cf(n);r&&e.push({key:t,savedAt:r.savedAt})}return e.sort((t,n)=>t.savedAt-n.savedAt)}function Qi(e){if(fs())try{window.sessionStorage.removeItem(e)}catch{}}function Bo(e){const t=new Set((e==null?void 0:e.preserveKeys)??[]),n=(e==null?void 0:e.maxCount)??Sf,r=Nf().filter(o=>!t.has(o.key)),s=Math.max(0,t.size+r.length-n);for(let o=0;o<s;o+=1){const a=r[o];if(!a)break;Qi(a.key)}}function sy(e){return e instanceof DOMException&&(e.name==="QuotaExceededError"||e.name==="NS_ERROR_DOM_QUOTA_REACHED"||e.code===22||e.code===1014)}function Cl(e,t){if(!fs())return"failed";try{return window.sessionStorage.setItem(e,t),"success"}catch(n){return sy(n)?"quota_exceeded":"failed"}}function iy(e,t){const n=Cl(e,t);if(n==="success"){Bo({preserveKeys:[e]});return}if(n==="quota_exceeded"){if(Qi(e),Bo({maxCount:Math.max(0,Sf-1)}),Cl(e,t)==="success"){Bo({preserveKeys:[e]});return}for(const r of Nf())if(r.key!==e&&(Qi(r.key),Cl(e,t)==="success")){Bo({preserveKeys:[e]});return}}}function va(e,t){const n=Js.get(e);if(n){if(!id(n.savedAt,t))return n.value;Js.delete(e)}if(!fs())return null;let r=null;try{r=window.sessionStorage.getItem(e)}catch{return null}if(!r)return null;const s=Cf(r);return!s||id(s.savedAt,t)?(Qi(e),Js.delete(e),null):(Js.set(e,s),s.value)}function qi(e,t){const n={savedAt:Date.now(),value:t};if(Js.set(e,n),!!fs())try{iy(e,JSON.stringify(n))}catch{}}function YA(e){Js.delete(e),fs()&&Qi(e)}const oy="codingns.debug.perf",ay="codingns.debug.sessionMessageDedup",ly="codingns.debug.timelineScroll",cy="codingns.debug.conversationTimeline";function uy(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(oy)==="1"}catch{return!1}}function Wt(e,t){if(!uy()||typeof performance>"u")return;const n=Math.round(performance.now());if(t&&Object.keys(t).length>0){console.info(`[perf-ui] ${e} ${n}ms`,t);return}console.info(`[perf-ui] ${e} ${n}ms`)}function dy(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(ay)==="1"}catch{return!1}}function Dr(e,t){if(!dy()||typeof performance>"u")return;const n=Math.round(performance.now()),r={scope:e,timestampMs:n,...t??{}};try{const s=window,o=s.__CODINGNS_SESSION_MESSAGE_DEDUP_DEBUG__??[];o.push(r),o.length>300&&o.splice(0,o.length-300),s.__CODINGNS_SESSION_MESSAGE_DEDUP_DEBUG__=o}catch{}if(t&&Object.keys(t).length>0){console.info(`[session-dedup] ${e} ${n}ms`,t);return}console.info(`[session-dedup] ${e} ${n}ms`)}function hy(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(cy)==="1"}catch{return!1}}function py(e,t){if(!hy()||typeof performance>"u")return;const n=Math.round(performance.now()),r={scope:e,timestampMs:n,...t??{}};try{const s=window;s.__CODINGNS_CONVERSATION_TIMELINE_DEBUG_CLEARED__!==!0&&(s.__CODINGNS_OPENCODE_ORDER_DEBUG__=[],s.__CODINGNS_SESSION_MESSAGE_DEDUP_DEBUG__=[],s.__CODINGNS_TIMELINE_SCROLL_DEBUG__=[],s.__CODINGNS_CONVERSATION_TIMELINE_DEBUG__=[],s.__CODINGNS_CONVERSATION_TIMELINE_DEBUG_CLEARED__=!0);const o=s.__CODINGNS_CONVERSATION_TIMELINE_DEBUG__??[];o.push(r),o.length>400&&o.splice(0,o.length-400),s.__CODINGNS_CONVERSATION_TIMELINE_DEBUG__=o}catch{}if(t&&Object.keys(t).length>0){console.info(`[conversation-timeline] ${e} ${n}ms`,t);return}console.info(`[conversation-timeline] ${e} ${n}ms`)}function kc(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(ly)==="1"}catch{return!1}}function fy(e,t){if(!kc()||typeof performance>"u")return;const n=Math.round(performance.now()),r={scope:e,timestampMs:n,...t??{}};try{const s=window,o=s.__CODINGNS_TIMELINE_SCROLL_DEBUG__??[];o.push(r),o.length>300&&o.splice(0,o.length-300),s.__CODINGNS_TIMELINE_SCROLL_DEBUG__=o}catch{}if(t&&Object.keys(t).length>0){console.info(`[timeline-scroll] ${e} ${n}ms`,t);return}console.info(`[timeline-scroll] ${e} ${n}ms`)}function XA(e,t,n,r){return ye.request("/api/files/content",{method:"PUT",body:JSON.stringify({workspaceId:e,path:t,content:n,expectedVersion:r??void 0})})}function JA(e){return ye.request("/api/files/ops",{method:"POST",body:JSON.stringify(e)})}function QA(e){return ye.request("/api/files/upload",{method:"POST",body:JSON.stringify(e)})}function ZA(e,t){const n=new URLSearchParams({workspaceId:e,path:t});return ye.request(`/api/files/download?${n.toString()}`)}function my(e,t,n=1,r=20){const s=new URLSearchParams({workspaceId:e,keyword:t,page:String(n),pageSize:String(r)});return ye.request(`/api/files/search?${s.toString()}`)}function eP(e,t){const n=new URLSearchParams({workspaceId:e,path:t});return ye.request(`/api/files/preview?${n.toString()}`)}function gy(e,t){const n=new URLSearchParams({workspaceId:e,path:t});return ye.request(`/api/files/preview-link?${n.toString()}`)}function tP(e){return ye.request(`/api/git/status?workspaceId=${encodeURIComponent(e)}`)}function nP(e){return ye.request("/api/git/init",{method:"POST",body:JSON.stringify({workspaceId:e})})}function rP(e,t,n){const r=new URLSearchParams({workspaceId:e,path:t,staged:String(n)});return ye.request(`/api/git/diff?${r.toString()}`)}function sP(e,t){return ye.request("/api/git/stage",{method:"POST",body:JSON.stringify({workspaceId:e,targets:t})})}function iP(e,t){return ye.request("/api/git/unstage",{method:"POST",body:JSON.stringify({workspaceId:e,targets:t})})}function oP(e,t){return ye.request("/api/git/discard",{method:"POST",body:JSON.stringify({workspaceId:e,targets:t})})}function aP(e,t){return ye.request("/api/git/commit/draft",{method:"POST",body:JSON.stringify({workspaceId:e,mode:t})})}function lP(e,t){return ye.request("/api/git/commit",{method:"POST",body:JSON.stringify({workspaceId:e,draft:t})})}function cP(e){return ye.request("/api/git/commit/undo",{method:"POST",body:JSON.stringify({workspaceId:e})})}function uP(e,t=5,n=null){const r=new URLSearchParams({workspaceId:e,limit:String(t)});return n&&r.set("cursor",n),ye.request(`/api/git/history?${r.toString()}`)}function dP(e,t){const n=new URLSearchParams({workspaceId:e,commitHash:t});return ye.request(`/api/git/commit-detail?${n.toString()}`)}function by(e){return ye.request(`/api/git/branches?workspaceId=${encodeURIComponent(e)}`)}function ky(e){return ye.request(`/api/git/tags?workspaceId=${encodeURIComponent(e)}`)}function hP(e,t,n){return ye.request("/api/git/branches/switch",{method:"POST",body:JSON.stringify({workspaceId:e,branchName:t,create:n})})}function pP(e,t,n,r,s){return ye.request("/api/git/remote/sync",{method:"POST",body:JSON.stringify({workspaceId:e,action:t,...n?{remote:n}:{},...r?{auth:r}:{},...s?{remember:s}:{}})})}function fP(e){return ye.request(`/api/git/remotes?workspaceId=${encodeURIComponent(e)}`)}var fa,ma;function jf(e){var t;if("items"in e)e.items=(t=e.items)===null||t===void 0?void 0:t.map(n=>"rid"in n?n:jf(n));else if("action"in e&&e.action){const n=new vf;return n.onmessage=e.action,delete e.action,{...e,handler:n}}return e}async function ai(e,t){const n=new vf;if(t&&typeof t=="object"&&("action"in t&&t.action&&(n.onmessage=t.action,delete t.action),"item"in t&&t.item&&typeof t.item=="object"&&"About"in t.item&&t.item.About&&typeof t.item.About=="object"&&"icon"in t.item.About&&t.item.About.icon&&(t.item.About.icon=Xs(t.item.About.icon)),"icon"in t&&t.icon&&(t.icon=Xs(t.icon)),"items"in t&&t.items)){let r=function(s){var o;return"rid"in s?[s.rid,s.kind]:("item"in s&&typeof s.item=="object"&&(!((o=s.item.About)===null||o===void 0)&&o.icon)&&(s.item.About.icon=Xs(s.item.About.icon)),"icon"in s&&s.icon&&(s.icon=Xs(s.icon)),"items"in s&&s.items&&(s.items=s.items.map(r)),jf(s))};t.items=t.items.map(r)}return Le("plugin:menu|new",{kind:e,options:t,handler:n})}class li extends Qk{get id(){return rd(this,fa,"f")}get kind(){return rd(this,ma,"f")}constructor(t,n,r){super(t),fa.set(this,void 0),ma.set(this,void 0),sd(this,fa,n),sd(this,ma,r)}}fa=new WeakMap,ma=new WeakMap;class ou extends li{constructor(t,n){super(t,n,"MenuItem")}static async new(t){return ai("MenuItem",t).then(([n,r])=>new ou(n,r))}async text(){return Le("plugin:menu|text",{rid:this.rid,kind:this.kind})}async setText(t){return Le("plugin:menu|set_text",{rid:this.rid,kind:this.kind,text:t})}async isEnabled(){return Le("plugin:menu|is_enabled",{rid:this.rid,kind:this.kind})}async setEnabled(t){return Le("plugin:menu|set_enabled",{rid:this.rid,kind:this.kind,enabled:t})}async setAccelerator(t){return Le("plugin:menu|set_accelerator",{rid:this.rid,kind:this.kind,accelerator:t})}}class au extends li{constructor(t,n){super(t,n,"Check")}static async new(t){return ai("Check",t).then(([n,r])=>new au(n,r))}async text(){return Le("plugin:menu|text",{rid:this.rid,kind:this.kind})}async setText(t){return Le("plugin:menu|set_text",{rid:this.rid,kind:this.kind,text:t})}async isEnabled(){return Le("plugin:menu|is_enabled",{rid:this.rid,kind:this.kind})}async setEnabled(t){return Le("plugin:menu|set_enabled",{rid:this.rid,kind:this.kind,enabled:t})}async setAccelerator(t){return Le("plugin:menu|set_accelerator",{rid:this.rid,kind:this.kind,accelerator:t})}async isChecked(){return Le("plugin:menu|is_checked",{rid:this.rid})}async setChecked(t){return Le("plugin:menu|set_checked",{rid:this.rid,checked:t})}}var od;(function(e){e.Add="Add",e.Advanced="Advanced",e.Bluetooth="Bluetooth",e.Bookmarks="Bookmarks",e.Caution="Caution",e.ColorPanel="ColorPanel",e.ColumnView="ColumnView",e.Computer="Computer",e.EnterFullScreen="EnterFullScreen",e.Everyone="Everyone",e.ExitFullScreen="ExitFullScreen",e.FlowView="FlowView",e.Folder="Folder",e.FolderBurnable="FolderBurnable",e.FolderSmart="FolderSmart",e.FollowLinkFreestanding="FollowLinkFreestanding",e.FontPanel="FontPanel",e.GoLeft="GoLeft",e.GoRight="GoRight",e.Home="Home",e.IChatTheater="IChatTheater",e.IconView="IconView",e.Info="Info",e.InvalidDataFreestanding="InvalidDataFreestanding",e.LeftFacingTriangle="LeftFacingTriangle",e.ListView="ListView",e.LockLocked="LockLocked",e.LockUnlocked="LockUnlocked",e.MenuMixedState="MenuMixedState",e.MenuOnState="MenuOnState",e.MobileMe="MobileMe",e.MultipleDocuments="MultipleDocuments",e.Network="Network",e.Path="Path",e.PreferencesGeneral="PreferencesGeneral",e.QuickLook="QuickLook",e.RefreshFreestanding="RefreshFreestanding",e.Refresh="Refresh",e.Remove="Remove",e.RevealFreestanding="RevealFreestanding",e.RightFacingTriangle="RightFacingTriangle",e.Share="Share",e.Slideshow="Slideshow",e.SmartBadge="SmartBadge",e.StatusAvailable="StatusAvailable",e.StatusNone="StatusNone",e.StatusPartiallyAvailable="StatusPartiallyAvailable",e.StatusUnavailable="StatusUnavailable",e.StopProgressFreestanding="StopProgressFreestanding",e.StopProgress="StopProgress",e.TrashEmpty="TrashEmpty",e.TrashFull="TrashFull",e.User="User",e.UserAccounts="UserAccounts",e.UserGroup="UserGroup",e.UserGuest="UserGuest"})(od||(od={}));class lu extends li{constructor(t,n){super(t,n,"Icon")}static async new(t){return ai("Icon",t).then(([n,r])=>new lu(n,r))}async text(){return Le("plugin:menu|text",{rid:this.rid,kind:this.kind})}async setText(t){return Le("plugin:menu|set_text",{rid:this.rid,kind:this.kind,text:t})}async isEnabled(){return Le("plugin:menu|is_enabled",{rid:this.rid,kind:this.kind})}async setEnabled(t){return Le("plugin:menu|set_enabled",{rid:this.rid,kind:this.kind,enabled:t})}async setAccelerator(t){return Le("plugin:menu|set_accelerator",{rid:this.rid,kind:this.kind,accelerator:t})}async setIcon(t){return Le("plugin:menu|set_icon",{rid:this.rid,kind:this.kind,icon:Xs(t)})}}class cu extends li{constructor(t,n){super(t,n,"Predefined")}static async new(t){return ai("Predefined",t).then(([n,r])=>new cu(n,r))}async text(){return Le("plugin:menu|text",{rid:this.rid,kind:this.kind})}async setText(t){return Le("plugin:menu|set_text",{rid:this.rid,kind:this.kind,text:t})}}function ti([e,t,n]){switch(n){case"Submenu":return new qa(e,t);case"Predefined":return new cu(e,t);case"Check":return new au(e,t);case"Icon":return new lu(e,t);case"MenuItem":default:return new ou(e,t)}}class qa extends li{constructor(t,n){super(t,n,"Submenu")}static async new(t){return ai("Submenu",t).then(([n,r])=>new qa(n,r))}async text(){return Le("plugin:menu|text",{rid:this.rid,kind:this.kind})}async setText(t){return Le("plugin:menu|set_text",{rid:this.rid,kind:this.kind,text:t})}async isEnabled(){return Le("plugin:menu|is_enabled",{rid:this.rid,kind:this.kind})}async setEnabled(t){return Le("plugin:menu|set_enabled",{rid:this.rid,kind:this.kind,enabled:t})}async append(t){return Le("plugin:menu|append",{rid:this.rid,kind:this.kind,items:(Array.isArray(t)?t:[t]).map(n=>"rid"in n?[n.rid,n.kind]:n)})}async prepend(t){return Le("plugin:menu|prepend",{rid:this.rid,kind:this.kind,items:(Array.isArray(t)?t:[t]).map(n=>"rid"in n?[n.rid,n.kind]:n)})}async insert(t,n){return Le("plugin:menu|insert",{rid:this.rid,kind:this.kind,items:(Array.isArray(t)?t:[t]).map(r=>"rid"in r?[r.rid,r.kind]:r),position:n})}async remove(t){return Le("plugin:menu|remove",{rid:this.rid,kind:this.kind,item:[t.rid,t.kind]})}async removeAt(t){return Le("plugin:menu|remove_at",{rid:this.rid,kind:this.kind,position:t}).then(ti)}async items(){return Le("plugin:menu|items",{rid:this.rid,kind:this.kind}).then(t=>t.map(ti))}async get(t){return Le("plugin:menu|get",{rid:this.rid,kind:this.kind,id:t}).then(n=>n?ti(n):null)}async popup(t,n){var r;return Le("plugin:menu|popup",{rid:this.rid,kind:this.kind,window:(r=n==null?void 0:n.label)!==null&&r!==void 0?r:null,at:t instanceof wa?t:t?new wa(t):null})}async setAsWindowsMenuForNSApp(){return Le("plugin:menu|set_as_windows_menu_for_nsapp",{rid:this.rid})}async setAsHelpMenuForNSApp(){return Le("plugin:menu|set_as_help_menu_for_nsapp",{rid:this.rid})}async setIcon(t){return Le("plugin:menu|set_icon",{rid:this.rid,kind:this.kind,icon:Xs(t)})}}class Qs extends li{constructor(t,n){super(t,n,"Menu")}static async new(t){return ai("Menu",t).then(([n,r])=>new Qs(n,r))}static async default(){return Le("plugin:menu|create_default").then(([t,n])=>new Qs(t,n))}async append(t){return Le("plugin:menu|append",{rid:this.rid,kind:this.kind,items:(Array.isArray(t)?t:[t]).map(n=>"rid"in n?[n.rid,n.kind]:n)})}async prepend(t){return Le("plugin:menu|prepend",{rid:this.rid,kind:this.kind,items:(Array.isArray(t)?t:[t]).map(n=>"rid"in n?[n.rid,n.kind]:n)})}async insert(t,n){return Le("plugin:menu|insert",{rid:this.rid,kind:this.kind,items:(Array.isArray(t)?t:[t]).map(r=>"rid"in r?[r.rid,r.kind]:r),position:n})}async remove(t){return Le("plugin:menu|remove",{rid:this.rid,kind:this.kind,item:[t.rid,t.kind]})}async removeAt(t){return Le("plugin:menu|remove_at",{rid:this.rid,kind:this.kind,position:t}).then(ti)}async items(){return Le("plugin:menu|items",{rid:this.rid,kind:this.kind}).then(t=>t.map(ti))}async get(t){return Le("plugin:menu|get",{rid:this.rid,kind:this.kind,id:t}).then(n=>n?ti(n):null)}async popup(t,n){var r;return Le("plugin:menu|popup",{rid:this.rid,kind:this.kind,window:(r=n==null?void 0:n.label)!==null&&r!==void 0?r:null,at:t instanceof wa?t:t?new wa(t):null})}async setAsAppMenu(){return Le("plugin:menu|set_as_app_menu",{rid:this.rid}).then(t=>t?new Qs(t[0],t[1]):null)}async setAsWindowMenu(t){var n;return Le("plugin:menu|set_as_window_menu",{rid:this.rid,window:(n=t==null?void 0:t.label)!==null&&n!==void 0?n:null}).then(r=>r?new Qs(r[0],r[1]):null)}}async function yy(e){if(e.length===0)return;await(await Qs.new({items:await Promise.all(e.map(n=>Tf(n)))})).popup(void 0,wf())}async function Tf(e){return"items"in e?qa.new({id:e.id,text:e.label,enabled:!e.disabled,items:await Promise.all(e.items.map(t=>Tf(t)))}):{id:e.id,text:e.label,enabled:!e.disabled,accelerator:e.accelerator,action:()=>{e.onSelect()}}}const ad={"parallel-group-1":{accent:"#0ea5e9",soft:"rgba(14, 165, 233, 0.16)",surface:"rgba(14, 165, 233, 0.08)"},"parallel-group-2":{accent:"#10b981",soft:"rgba(16, 185, 129, 0.16)",surface:"rgba(16, 185, 129, 0.08)"},"parallel-group-3":{accent:"#f59e0b",soft:"rgba(245, 158, 11, 0.16)",surface:"rgba(245, 158, 11, 0.08)"},"parallel-group-4":{accent:"#ec4899",soft:"rgba(236, 72, 153, 0.16)",surface:"rgba(236, 72, 153, 0.08)"},"parallel-group-5":{accent:"#8b5cf6",soft:"rgba(139, 92, 246, 0.16)",surface:"rgba(139, 92, 246, 0.08)"},"parallel-group-6":{accent:"#f97316",soft:"rgba(249, 115, 22, 0.16)",surface:"rgba(249, 115, 22, 0.08)"}},xy=2600,If="workbench.parallel.pane.palette";let Us=null;const ld=["#34C759","#22C55E","#14B8A6","#06B6D4","#0EA5E9","#3B82F6","#6366F1","#8B5CF6","#A855F7","#D946EF","#EC4899","#F43F5E","#EF4444","#F97316","#F59E0B","#EAB308","#84CC16","#10B981"];function wy(e="create"){return e==="append"?{totalDurationMs:1200,sidebarCollapseDurationMs:0,paneEnterDelayMs:0,paneEnterDurationMs:1e3,gridRevealDelayMs:0,gridRevealDurationMs:920,shellExpandDurationMs:0,paneStaggerMs:80}:{totalDurationMs:2e3,sidebarCollapseDurationMs:720,paneEnterDelayMs:520,paneEnterDurationMs:1480,gridRevealDelayMs:420,gridRevealDurationMs:1360,shellExpandDurationMs:720,paneStaggerMs:96}}function Ef(e){var n,r;const t=(n=e.displayParentSessionId)==null?void 0:n.trim();return t||((r=e.parentSessionId)==null?void 0:r.trim())||null}function vy(e){var r;const t=(r=e==null?void 0:e.colorToken)==null?void 0:r.trim();if(!t)return;const n=ad[t]??ad["parallel-group-1"];return{"--parallel-group-accent":n.accent,"--parallel-group-soft":n.soft,"--parallel-group-surface":n.surface}}function mP(e){const t=Sa(e.overrideColor)??Sy(e.groupId,e.ordinal);return{"--parallel-group-accent":t,"--parallel-group-soft":cd(t,.08),"--parallel-group-surface":cd(t,.03)}}function gP(e){if(typeof window>"u")return null;const t=e.trim();if(!t)return null;const n=Mf();return Sa(n[t]??null)}function bP(e,t){if(typeof window>"u")return Sa(t);const n=e.trim();if(!n)return null;const r=Mf(),s=Sa(t);return s?r[n]=s:delete r[n],window.localStorage.setItem(If,JSON.stringify(r)),s}function Sy(e,t){const n=ld.length,r=Math.abs(Ey(e))%n;return ld[(r+t*5)%n]}function kP(e){return e?e.role==="anchor"?l("shell.parallelGroupAnchorBadge"):l("shell.parallelGroupMemberBadge"):null}function Cy(e){return e?l("shell.parallelGroupBadge",{count:e.memberCount}):null}function yP(e){var n;return((n=e==null?void 0:e.branchName)==null?void 0:n.trim())||null}function xP(e){var n,r,s;return((r=(n=e==null?void 0:e.parallelGroup)==null?void 0:n.groupId)==null?void 0:r.trim())?((s=e==null?void 0:e.sessionIsolatedWorkspace)==null?void 0:s.lifecycleStatus)!=="promoted":!1}function Ny(e,t){return t&&(t.lifecycleStatus==="active"||t.lifecycleStatus==="removing")?t.sourceWorkspaceId:e.workspaceId}function jy(e,t){return t&&(t.lifecycleStatus==="active"||t.lifecycleStatus==="promoted")?t.workspaceId:e.workspaceId}function Ty(e,t="create"){Us={groupId:e,createdAt:Date.now(),...wy(t)}}function Iy(e){return!Us||Us.groupId!==e?null:Date.now()-Us.createdAt>xy?(Us=null,null):Us}function Mf(){if(typeof window>"u")return{};const e=window.localStorage.getItem(If);if(!e)return{};try{const t=JSON.parse(e);return!t||typeof t!="object"?{}:t}catch{return{}}}function Ey(e){let t=0;for(const n of e)t=t*31+n.charCodeAt(0)|0;return t}function Sa(e){const t=(e==null?void 0:e.trim().toUpperCase())??"";return/^#[0-9A-F]{6}$/.test(t)?t:null}function cd(e,t){const n=Math.max(0,Math.min(t,1)),r=Number.parseInt(e.slice(1,3),16),s=Number.parseInt(e.slice(3,5),16),o=Number.parseInt(e.slice(5,7),16);return`rgba(${r}, ${s}, ${o}, ${n})`}function uu(e,t){const n=new Map(e.map(o=>[t.getId(o),o])),r=new Map,s=[];for(const o of e){const a=My(o,n,t);if(!a){s.push(o);continue}const c=r.get(a)??[];r.set(a,[...c,o])}return[...s].sort(t.compare).map(o=>Pf(o,0,r,t,new Set))}function ci(e){return Array.isArray(e==null?void 0:e.children)?e.children:[]}function Rf(e){return e.flatMap(t=>[t.item,...Rf(ci(t))])}function os(e){return e.flatMap(t=>[t,...os(ci(t))])}function du(e,t){return e.some(n=>t(n.item)||du(ci(n),t))}function Af(e,t,n){return e?n(e.item)===t?!0:ci(e).some(r=>Af(r,t,n)):!1}function qs(e,t,n){for(const r of e){const s=n(r.item);if(s===t)return[];const o=qs(ci(r),t,n);if(Af(r,t,n)&&o.length>=0)return[s,...o]}return[]}function Pf(e,t,n,r,s){const o=r.getId(e),a=new Set(s);a.add(o);const c=[...n.get(o)??[]].filter(u=>!a.has(r.getId(u))).sort(r.compare).map(u=>Pf(u,t+1,n,r,a));return{item:e,depth:t,children:c}}function My(e,t,n){const r=ud(n.getParentId(e));if(!r)return null;const s=t.get(r);if(!s)return null;const o=new Set([n.getId(e)]);let a=s;for(;a;){const c=n.getId(a);if(o.has(c))return null;o.add(c);const u=ud(n.getParentId(a));if(!u||(a=t.get(u),!a))return r}return r}function ud(e){const t=e==null?void 0:e.trim();return t||null}function en(){return"/workspaces"}function rr(e){return`/workspaces/${encodeURIComponent(e)}`}function Lf(e){return`${rr(e)}/debug`}function ii(e){return`${rr(e)}/sessions`}function Bn(e,t){return`${ii(e)}/${encodeURIComponent(t)}`}function _f(e,t){const n=`${rr(e)}/tools`;if(!t)return n;const r=new URLSearchParams({tab:t});return`${n}?${r.toString()}`}function Df(e){return`${rr(e)}/tools/files`}function Bf(e){return`${rr(e)}/tools/git`}function Of(e){return`${rr(e)}/tools/processes`}function as(e){return`${rr(e)}/terminals`}function ds(e,t){const n=`${rr(e)}/butler`;if(!t)return n;const r=new URLSearchParams({tab:t});return`${n}?${r.toString()}`}function Ry(e){return $f(e.flatMap(t=>[...t.sessions.map(n=>({session:n,workspace:t.workspace})),...Ff(t.childWorktrees??[])])).sort((t,n)=>(n.session.lastMessageAt??n.session.updatedAt).localeCompare(t.session.lastMessageAt??t.session.updatedAt))}function wP(e,t){return uu($f(e),{getId:n=>n.session.sessionId,getParentId:n=>Ay(n.session,t),compare:Ly})}function Ay(e,t){var n;return(t==null?void 0:t.mode)==="mobile"?((n=e.parentSessionId)==null?void 0:n.trim())||null:Ef(e)}function Wf(e,t){const n=Py(),r=new URLSearchParams({provider:t});return`${Bn(e,n)}?${r.toString()}`}function Py(){const e=globalThis.crypto;return e&&typeof e.randomUUID=="function"?`draft-${e.randomUUID()}`:`draft-${Date.now()}-${Math.random().toString(16).slice(2)}`}function Ly(e,t){return(t.session.lastMessageAt??t.session.updatedAt).localeCompare(e.session.lastMessageAt??e.session.updatedAt)}function Ff(e){return e.flatMap(t=>[...t.sessions.map(n=>({session:n,workspace:t.workspace})),...Ff(t.children)])}function $f(e){const t=[],n=new Set;for(const r of e){const s=r.session.sessionId.trim();!s||n.has(s)||(n.add(s),t.push(r))}return t}const _y="mobile.tools.last-primary-tool";function zf(){if(typeof window>"u")return"files";try{return window.localStorage.getItem(_y)==="git"?"git":"files"}catch{return"files"}}function hu(e){var r;const t=[{pattern:"/workspaces/:workspaceId/tools/processes",routeKind:"processes"},{pattern:"/workspaces/:workspaceId/tools/files",routeKind:"files"},{pattern:"/workspaces/:workspaceId/tools/git",routeKind:"git"},{pattern:"/workspaces/:workspaceId/tools",routeKind:"home"}];for(const s of t){const o=at(s.pattern,e),a=((r=o==null?void 0:o.params.workspaceId)==null?void 0:r.trim())??null;if(a)return{workspaceId:a,routeKind:s.routeKind,legacy:!1}}const n=[{pattern:"/tools/processes",routeKind:"processes"},{pattern:"/tools/files",routeKind:"files"},{pattern:"/tools/git",routeKind:"git"},{pattern:"/tools",routeKind:"home"}];for(const s of n)if(at(s.pattern,e))return{workspaceId:null,routeKind:s.routeKind,legacy:!0};return null}function Dy(e,t){const n=hu(e);if((n==null?void 0:n.routeKind)==="git")return"git";if((n==null?void 0:n.routeKind)==="files")return"files";const r=new URLSearchParams(t).get("tab");return r==="git"?"git":r==="files"?"files":zf()}function pu(e,t){const n=hu(e);return(n==null?void 0:n.routeKind)==="processes"&&n.workspaceId?as(n.workspaceId):n!=null&&n.workspaceId?_f(n.workspaceId,Dy(e,t)):n!=null&&n.legacy?zf()==="git"?"/tools?tab=git":"/tools?tab=files":null}function fu({activeEntry:e,presentation:t,pathname:n,search:r,moreButtonLabel:s}){if(t==="conversation-focus"||e!=="butler")return null;const o=hu(n);return o?o.routeKind==="processes"?{title:l("shell.terminalManagerEntry"),showBackButton:!0,showMoreButton:!1,moreButtonLabel:s}:(o.routeKind==="home"||o.routeKind==="files"||o.routeKind==="git",null):null}const Hf=f.createContext({composerPortalTarget:null});function mu({composerPortalTarget:e,children:t}){return i.jsx(Hf.Provider,{value:{composerPortalTarget:e},children:t})}function vP(){return f.useContext(Hf)}function gu(e,t,n){const[r,s]=f.useState(void 0);return f.useEffect(()=>{const o=e.current,a=t.current;if(!n||!o||!a){s(void 0),o&&o.style.removeProperty("--mobile-conversation-tabbar-height");return}const c=o,u=a;function d(){if(!e.current||!u.isConnected)return;const h=`${Math.round(u.getBoundingClientRect().height)}px`;c.style.setProperty("--mobile-conversation-tabbar-height",h),s(h)}d();const p=typeof ResizeObserver<"u"?new ResizeObserver(d):null;return p==null||p.observe(u),window.addEventListener("resize",d),()=>{p==null||p.disconnect(),window.removeEventListener("resize",d),c.style.removeProperty("--mobile-conversation-tabbar-height")}},[n,e,t]),r}const By=3e3,Oo=10,dd=84,hd=.36;function bu({enabled:e,rootRef:t,suspended:n=!1,resetKey:r}){const s=f.useRef(null),o=f.useRef(null),a=f.useRef("visible"),c=f.useRef(1),[u,d]=f.useState("visible"),[p,h]=f.useState(1);f.useEffect(()=>{a.current=u},[u]),f.useEffect(()=>{c.current=p},[p]);function m(){ns(s),s.current=window.setTimeout(()=>{g()},By)}function g(){d("hidden"),h(0)}function y(){d("visible"),h(1),m()}f.useEffect(()=>{if(ns(s),!e){ns(s),d("visible"),h(1);return}if(n){d("hidden"),h(0);return}return y(),()=>{ns(s)}},[e,r,n]),f.useEffect(()=>()=>{ns(s)},[]),f.useEffect(()=>{if(!e||n){o.current=null;return}const C=t.current;if(!C)return;function x(U){if(U.touches.length!==1){o.current=null;return}const L=U.touches[0],E=md(U.target);if(!L||!E){o.current=null;return}o.current={surface:E,startX:L.clientX,startY:L.clientY,pointerType:"touch",initialState:a.current==="visible"?"visible":"hidden",touchId:L.identifier,dragging:!1,latestProgress:c.current},a.current==="visible"&&ns(s)}function A(U){const L=o.current;if(!L||L.pointerType!=="touch")return;const E=Nl(U.touches,L.touchId);if(!E)return;const $=E.clientX-L.startX,B=E.clientY-L.startY;if(L.surface==="conversation"){if(Math.abs(B)<=Oo||Math.abs(B)<=Math.abs($))return;o.current=null,L.initialState==="visible"&&g();return}const re=L.initialState==="hidden"?-B:B;re<=Oo&&!L.dragging||(bd(U),L.dragging=!0,L.latestProgress=pd(L.initialState,re),d("dragging"),h(L.latestProgress))}function j(U){const L=o.current;if(!(!L||L.pointerType!=="touch"||!Nl(U.changedTouches,L.touchId))){if(o.current=null,!L.dragging){L.initialState==="visible"&&m();return}fd(L.initialState,L.latestProgress,y,d,h)}}function G(U){const L=o.current;if(!(!L||L.pointerType!=="touch"||!Nl(U.changedTouches,L.touchId))){if(o.current=null,!L.dragging){L.initialState==="visible"&&m();return}if(L.initialState==="visible"){y();return}d("hidden"),h(0)}}function P(U){if(U.pointerType!=="touch")return;const L=md(U.target);if(!L){o.current=null;return}if(o.current={surface:L,startX:U.clientX,startY:U.clientY,pointerType:"pointer",initialState:a.current==="visible"?"visible":"hidden",pointerId:U.pointerId,captureTarget:U.target instanceof Element?U.target:null,dragging:!1,latestProgress:c.current},U.target instanceof Element)try{U.target.setPointerCapture(U.pointerId)}catch{}a.current==="visible"&&ns(s)}function T(U){const L=o.current;if(!L||L.pointerType!=="pointer")return;const E=U.clientX-L.startX,$=U.clientY-L.startY;if(L.surface==="conversation"){if(Math.abs($)<=Oo||Math.abs($)<=Math.abs(E))return;o.current=null,L.initialState==="visible"&&g();return}const B=L.initialState==="hidden"?-$:$;B<=Oo&&!L.dragging||(bd(U),L.dragging=!0,L.latestProgress=pd(L.initialState,B),d("dragging"),h(L.latestProgress))}function K(U){const L=o.current;if(!(!L||L.pointerType!=="pointer"||L.pointerId!==U.pointerId)){if(o.current=null,Oy(L),!L.dragging){L.initialState==="visible"&&m();return}fd(L.initialState,L.latestProgress,y,d,h)}}return C.addEventListener("touchstart",x,{passive:!0}),C.addEventListener("pointerdown",P,{passive:!0}),window.addEventListener("touchmove",A,{passive:!1}),window.addEventListener("touchend",j),window.addEventListener("touchcancel",G),window.addEventListener("pointermove",T,{passive:!1}),window.addEventListener("pointerup",K),window.addEventListener("pointercancel",K),()=>{C.removeEventListener("touchstart",x),C.removeEventListener("pointerdown",P),window.removeEventListener("touchmove",A),window.removeEventListener("touchend",j),window.removeEventListener("touchcancel",G),window.removeEventListener("pointermove",T),window.removeEventListener("pointerup",K),window.removeEventListener("pointercancel",K)}},[e,t,n]);const S=e&&!n?p:e?0:1;return{state:n&&e?"hidden":u,progress:S,isOpen:S>.01}}function ns(e){e.current!==null&&(window.clearTimeout(e.current),e.current=null)}function pd(e,t){return gd(e==="hidden"?t/dd:1-t/dd,0,1)}function fd(e,t,n,r,s){if(e==="hidden"){if(t>=hd){n();return}r("hidden"),s(0);return}if(t<=1-hd){r("hidden"),s(0);return}n()}function Oy(e){if(!(e.pointerType!=="pointer"||typeof e.pointerId!="number"||!(e.captureTarget instanceof Element)))try{e.captureTarget.hasPointerCapture(e.pointerId)&&e.captureTarget.releasePointerCapture(e.pointerId)}catch{}}function Nl(e,t){if(typeof t!="number")return e[0]??null;for(let n=0;n<e.length;n+=1){const r=e[n];if((r==null?void 0:r.identifier)===t)return r}return null}function md(e){return e instanceof Element?e.closest(".composer-panel")?"composer":e.closest(".message-list, .message-timeline, .mobile-conversation-main, .conversation-page-shell, .mobile-butler-main-stage, .mobile-butler-chat-body, .mobile-butler-page-shell")?"conversation":null:null}function gd(e,t,n){return Math.min(Math.max(e,t),n)}function bd(e){e.cancelable&&e.preventDefault()}function co({viewportClass:e,activeEntry:t,hasNavigationPanel:n,hasAuxiliaryPanel:r,preferCompactLayout:s=!1}){return s||e==="compact"?"compact":e==="expanded"&&n&&r?"expanded":t==="butler"&&r?"medium-auxiliary":n?"medium-navigation":r?"medium-auxiliary":"compact"}function Ga(e){return!e.isNativeMobile||e.viewportClass==="expanded"||typeof window>"u"?!1:window.innerHeight>window.innerWidth}function Uf(e){return e==="medium-navigation"||e==="expanded"}function qf(e){return e==="medium-auxiliary"||e==="expanded"}function ku({viewportClass:e,activeEntry:t,hasNavigationPanel:n,hasAuxiliaryPanel:r,preferCompactLayout:s=!1,children:o,navigationPanel:a,auxiliaryPanel:c}){const u=co({viewportClass:e,activeEntry:t,hasNavigationPanel:n,hasAuxiliaryPanel:r,preferCompactLayout:s}),d=Uf(u)&&a,p=qf(u)&&c;return i.jsxs("div",{className:"mobile-adaptive-pane-layout","data-pane-layout":u,children:[d?i.jsx("aside",{className:"workbench-nav surface-card mobile-adaptive-pane-panel mobile-adaptive-pane-panel-navigation",children:a}):null,i.jsx("div",{className:"mobile-adaptive-pane-main",children:o}),p?i.jsx("aside",{className:"workbench-auxiliary surface-card mobile-adaptive-pane-panel mobile-adaptive-pane-panel-auxiliary",children:c}):null]})}function Wy({activeEntry:e,presentation:t="default",children:n,navigationPanel:r,auxiliaryPanel:s,onNavigateWorkspaces:o,onNavigateTerminals:a,onNavigateSessions:c,onNavigateButler:u,onNavigateToolProcesses:d,onNavigateSettings:p}){const h=kn(),m=nu(),g=Ua(),y=lo(),S=f.useRef(null),C=f.useRef(null),[x,A]=f.useState(null),j=t==="conversation-focus",G=Ga({isNativeMobile:h.isNativeMobile,viewportClass:h.viewportClass}),P=bu({enabled:j,rootRef:S,resetKey:`${g.pathname}${g.search}`}),T=co({viewportClass:h.viewportClass,activeEntry:e,hasNavigationPanel:!!r,hasAuxiliaryPanel:!!s,preferCompactLayout:G}),K=fu({activeEntry:e,presentation:t,pathname:g.pathname,search:g.search,moreButtonLabel:l("shell.androidMoreAction")}),U=[{key:"workspaces",label:l("shell.mobileWorkspacesEntry"),icon:i.jsx(zy,{}),onClick:o},{key:"sessions",label:l("shell.mobileSessionsEntry"),icon:i.jsx(Hy,{}),onClick:c},{key:"terminals",label:l("shell.mobileButlerEntry"),icon:i.jsx(qy,{}),onClick:u},{key:"butler",label:l("shell.mobileTerminalsEntry"),icon:i.jsx(Uy,{}),onClick:a},{key:"settings",label:l("shell.mobileSettingsEntry"),icon:i.jsx(Gy,{}),onClick:p}],L=j?{"--mobile-conversation-tabbar-progress":P.progress.toFixed(4)}:void 0;gu(S,C,j);function E(){const B=pu(g.pathname,g.search);if(!B){a();return}y(B,{replace:!0})}const $=i.jsx("nav",{ref:C,className:"android-workbench-bottom-nav","aria-label":l("shell.title"),children:U.map(B=>i.jsxs("button",{type:"button",className:"android-workbench-bottom-nav-item","data-active":B.key===e,"aria-current":B.key===e?"page":void 0,onClick:()=>{B.key!==e&&m.trigger("selection"),B.onClick()},children:[i.jsx("span",{className:"android-workbench-bottom-nav-icon","aria-hidden":"true",children:B.icon}),i.jsx("span",{className:"android-workbench-bottom-nav-label",children:B.label})]},B.key))});return i.jsx(mu,{composerPortalTarget:j?x:null,children:i.jsxs("div",{ref:S,className:"android-workbench-shell","data-active-entry":e,"data-mobile-presentation":t,"data-pane-layout":T,"data-tabbar-open":j?P.isOpen:!0,"data-conversation-tabbar-state":j?P.state:"default",style:L,children:[K?i.jsxs("header",{className:"android-workbench-topbar","data-header-kind":"tools",children:[i.jsxs("div",{className:"android-workbench-topbar-leading",children:[K.showBackButton?i.jsx("button",{type:"button",className:"android-workbench-icon-button","aria-label":l("common.back"),onClick:E,children:i.jsx(Fy,{})}):null,i.jsx("div",{className:"android-workbench-topbar-copy",children:i.jsx("h1",{children:K.title})})]}),i.jsx("div",{className:"android-workbench-topbar-actions",children:K.showMoreButton?i.jsx("button",{type:"button",className:"android-workbench-icon-button","aria-label":K.moreButtonLabel,onClick:d,children:i.jsx($y,{})}):null})]}):null,i.jsx("div",{className:"android-workbench-content",children:i.jsx(ku,{viewportClass:h.viewportClass,activeEntry:e,hasNavigationPanel:!!r,hasAuxiliaryPanel:!!s,preferCompactLayout:G,navigationPanel:r,auxiliaryPanel:s,children:n})}),j?i.jsxs("div",{className:"mobile-conversation-bottom-layer",children:[i.jsx("div",{ref:A,className:"mobile-conversation-bottom-layer-composer-slot"}),i.jsx("div",{className:"mobile-conversation-bottom-layer-tabbar-shell",children:$})]}):$]})})}function Fy(){return i.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[i.jsx("path",{d:"m15 18-6-6 6-6"}),i.jsx("path",{d:"M21 12H9"})]})}function $y(){return i.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:[i.jsx("circle",{cx:"12",cy:"5",r:"1.8"}),i.jsx("circle",{cx:"12",cy:"12",r:"1.8"}),i.jsx("circle",{cx:"12",cy:"19",r:"1.8"})]})}function zy(){return i.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[i.jsx("path",{d:"M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7z"}),i.jsx("path",{d:"M8 13h8"})]})}function Hy(){return i.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:i.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H8l-5 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}function Uy(){return i.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[i.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2.5"}),i.jsx("path",{d:"m7.5 9 3 3-3 3"}),i.jsx("path",{d:"M12.5 15H17"})]})}function qy(){return i.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[i.jsx("rect",{x:"5",y:"7",width:"14",height:"10",rx:"3"}),i.jsx("path",{d:"M9 7V5a3 3 0 0 1 6 0v2"}),i.jsx("circle",{cx:"10",cy:"12",r:"1",fill:"currentColor",stroke:"none"}),i.jsx("circle",{cx:"14",cy:"12",r:"1",fill:"currentColor",stroke:"none"}),i.jsx("path",{d:"M10 15c.6.5 1.2.8 2 .8s1.4-.3 2-.8"})]})}function Gy(){return i.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[i.jsx("circle",{cx:"12",cy:"12",r:"3"}),i.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09a1.65 1.65 0 0 0-1-1.51 1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06A1.65 1.65 0 0 0 4.6 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09a1.65 1.65 0 0 0 1.51-1 1.65 1.65 0 0 0-.33-1.82L4.21 7.1a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06A1.65 1.65 0 0 0 8.92 4a1.65 1.65 0 0 0 1-1.51V2.4a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9c0 .66.39 1.25 1 1.51h.09a2 2 0 0 1 0 4h-.09c-.61.26-1 .85-1 1.49z"})]})}const Vy=120,Oi={viewportHeight:null,keyboardInset:0,keyboardOpen:!1};function yc(e){return typeof e=="number"&&Number.isFinite(e)&&e>0}function Ky(e){if(!(e instanceof HTMLElement))return!1;if(e.isContentEditable||e.closest("[contenteditable='true']"))return!0;if(e instanceof HTMLTextAreaElement)return!e.readOnly&&!e.disabled;if(e instanceof HTMLInputElement){if(e.readOnly||e.disabled)return!1;const t=(e.type||"text").toLowerCase();return!["button","checkbox","color","file","hidden","image","radio","range","reset","submit"].includes(t)}return!1}function Yy(){var t;if(typeof window>"u")return 0;const e=[window.innerHeight,typeof document<"u"?(t=document.documentElement)==null?void 0:t.clientHeight:0].filter(yc);return e.length>0?Math.max(...e):0}function kd(){if(typeof window>"u")return Oi;const e=window.visualViewport,t=Yy(),n=(e==null?void 0:e.height)??t,r=yc(n)?Math.round(n):null,s=yc(e==null?void 0:e.offsetTop)?(e==null?void 0:e.offsetTop)??0:0,o=r===null?0:Math.max(0,Math.round(t-r-s));return{viewportHeight:r,keyboardInset:o,keyboardOpen:Ky(typeof document<"u"?document.activeElement:null)&&o>=Vy}}function jl(e,t){if(typeof document>"u")return;[document.documentElement,document.body].filter(r=>r instanceof HTMLElement).forEach(r=>{if(!e){delete r.dataset.mobileKeyboardOpen,delete r.dataset.mobileViewportBound,r.style.removeProperty("--mobile-shell-viewport-height"),r.style.removeProperty("--mobile-shell-keyboard-inset");return}r.dataset.mobileKeyboardOpen=String(t.keyboardOpen),r.dataset.mobileViewportBound="true",t.viewportHeight===null?r.style.removeProperty("--mobile-shell-viewport-height"):r.style.setProperty("--mobile-shell-viewport-height",`${t.viewportHeight}px`),r.style.setProperty("--mobile-shell-keyboard-inset",`${t.keyboardInset}px`)})}function Xy(e){const[t,n]=f.useState(()=>e?kd():Oi),r=f.useRef(null);return f.useEffect(()=>{if(!e){n(Oi),jl(!1,Oi);return}function s(){n(kd())}function o(){r.current!==null&&window.clearTimeout(r.current),r.current=window.setTimeout(()=>{r.current=null,s()},0)}s();const a=window.visualViewport;return window.addEventListener("resize",s),window.addEventListener("orientationchange",s),a==null||a.addEventListener("resize",s),a==null||a.addEventListener("scroll",s),document.addEventListener("focusin",s),document.addEventListener("focusout",o),()=>{r.current!==null&&(window.clearTimeout(r.current),r.current=null),window.removeEventListener("resize",s),window.removeEventListener("orientationchange",s),a==null||a.removeEventListener("resize",s),a==null||a.removeEventListener("scroll",s),document.removeEventListener("focusin",s),document.removeEventListener("focusout",o),jl(!1,Oi)}},[e]),f.useEffect(()=>{jl(e,t)},[e,t]),t}function Jy({activeEntry:e,presentation:t="default",children:n,navigationPanel:r,auxiliaryPanel:s,onNavigateWorkspaces:o,onNavigateTerminals:a,onNavigateSessions:c,onNavigateButler:u,onNavigateToolProcesses:d,onNavigateSettings:p}){const h=kn(),m=nu(),g=Ua(),y=lo(),S=f.useRef(null),C=f.useRef(null),[x,A]=f.useState(null),j=t==="conversation-focus",G=Ga({isNativeMobile:h.isNativeMobile,viewportClass:h.viewportClass}),P=bu({enabled:j,rootRef:S,resetKey:`${g.pathname}${g.search}`}),T=co({viewportClass:h.viewportClass,activeEntry:e,hasNavigationPanel:!!r,hasAuxiliaryPanel:!!s,preferCompactLayout:G}),K=fu({activeEntry:e,presentation:t,pathname:g.pathname,search:g.search,moreButtonLabel:l("shell.iosMoreAction")}),U=[{key:"workspaces",label:l("shell.mobileWorkspacesEntry"),icon:i.jsx(ex,{}),onClick:o},{key:"sessions",label:l("shell.mobileSessionsEntry"),icon:i.jsx(tx,{}),onClick:c},{key:"terminals",label:l("shell.mobileButlerEntry"),icon:i.jsx(rx,{}),onClick:u},{key:"butler",label:l("shell.mobileTerminalsEntry"),icon:i.jsx(nx,{}),onClick:a},{key:"settings",label:l("shell.mobileSettingsEntry"),icon:i.jsx(sx,{}),onClick:p}],L=j?{"--mobile-conversation-tabbar-progress":P.progress.toFixed(4)}:void 0;gu(S,C,j);function E(){const B=pu(g.pathname,g.search);if(!B){a();return}y(B,{replace:!0})}const $=i.jsx("nav",{ref:C,className:"ios-workbench-tabbar","aria-label":l("shell.title"),children:U.map(B=>i.jsxs("button",{type:"button",className:"ios-workbench-tabbar-item","data-active":B.key===e,"aria-current":B.key===e?"page":void 0,onClick:()=>{B.key!==e&&m.trigger("selection"),B.onClick()},children:[i.jsx("span",{className:"ios-workbench-tabbar-icon","aria-hidden":"true",children:B.icon}),i.jsx("span",{className:"ios-workbench-tabbar-label",children:B.label})]},B.key))});return i.jsx(mu,{composerPortalTarget:j?x:null,children:i.jsxs("div",{ref:S,className:"ios-workbench-shell","data-active-entry":e,"data-mobile-presentation":t,"data-pane-layout":T,"data-tabbar-open":j?P.isOpen:!0,"data-conversation-tabbar-state":j?P.state:"default",style:L,children:[K?i.jsxs("header",{className:"ios-workbench-nav","data-header-kind":"tools",children:[i.jsx("div",{className:"ios-workbench-nav-leading",children:K.showBackButton?i.jsxs("button",{type:"button",className:"ios-workbench-back-button","aria-label":l("common.back"),onClick:E,children:[i.jsx(Qy,{}),i.jsx("span",{children:l("common.back")})]}):null}),i.jsx("div",{className:"ios-workbench-nav-copy",children:i.jsx("h1",{children:K.title})}),i.jsx("div",{className:"ios-workbench-nav-actions",children:K.showMoreButton?i.jsx("button",{type:"button",className:"ios-workbench-icon-button","aria-label":K.moreButtonLabel,onClick:d,children:i.jsx(Zy,{})}):null})]}):null,i.jsx("div",{className:"ios-workbench-content",children:i.jsx(ku,{viewportClass:h.viewportClass,activeEntry:e,hasNavigationPanel:!!r,hasAuxiliaryPanel:!!s,preferCompactLayout:G,navigationPanel:r,auxiliaryPanel:s,children:n})}),j?i.jsxs("div",{className:"mobile-conversation-bottom-layer",children:[i.jsx("div",{ref:A,className:"mobile-conversation-bottom-layer-composer-slot"}),i.jsx("div",{className:"mobile-conversation-bottom-layer-tabbar-shell",children:$})]}):$]})})}function Qy(){return i.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.85",children:i.jsx("path",{d:"m15 18-6-6 6-6"})})}function Zy(){return i.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:[i.jsx("circle",{cx:"12",cy:"5",r:"1.8"}),i.jsx("circle",{cx:"12",cy:"12",r:"1.8"}),i.jsx("circle",{cx:"12",cy:"19",r:"1.8"})]})}function ex(){return i.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.85",children:[i.jsx("path",{d:"M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7z"}),i.jsx("path",{d:"M8 13h8"})]})}function tx(){return i.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.85",children:i.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H8l-5 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}function nx(){return i.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.85",children:[i.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2.5"}),i.jsx("path",{d:"m7.5 9 3 3-3 3"}),i.jsx("path",{d:"M12.5 15H17"})]})}function rx(){return i.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.85",children:[i.jsx("rect",{x:"5",y:"7",width:"14",height:"10",rx:"3"}),i.jsx("path",{d:"M9 7V5a3 3 0 0 1 6 0v2"}),i.jsx("circle",{cx:"10",cy:"12",r:".95",fill:"currentColor",stroke:"none"}),i.jsx("circle",{cx:"14",cy:"12",r:".95",fill:"currentColor",stroke:"none"}),i.jsx("path",{d:"M10 15c.6.5 1.2.8 2 .8s1.4-.3 2-.8"})]})}function sx(){return i.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",children:[i.jsx("circle",{cx:"12",cy:"12",r:"3"}),i.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09a1.65 1.65 0 0 0-1-1.51 1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06A1.65 1.65 0 0 0 4.6 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09a1.65 1.65 0 0 0 1.51-1 1.65 1.65 0 0 0-.33-1.82L4.21 7.1a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06A1.65 1.65 0 0 0 8.92 4a1.65 1.65 0 0 0 1-1.51V2.4a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9c0 .66.39 1.25 1 1.51h.09a2 2 0 0 1 0 4h-.09c-.61.26-1 .85-1 1.49z"})]})}function ix(e){const t=kn();return t.platform==="ios"?i.jsx(Jy,{...e}):t.platform==="android"?i.jsx(Wy,{...e}):i.jsx(ox,{...e})}function ox({activeEntry:e,presentation:t="default",children:n,navigationPanel:r,auxiliaryPanel:s,onNavigateWorkspaces:o,onNavigateTerminals:a,onNavigateSessions:c,onNavigateButler:u,onNavigateToolProcesses:d,onNavigateSettings:p}){const h=kn(),m=nu(),g=Ua(),y=lo(),S=f.useRef(null),C=f.useRef(null),[x,A]=f.useState(null),j=Xy(h.platform==="web"),G=h.platform==="web"&&j.keyboardOpen,P=t==="conversation-focus",T=Ga({isNativeMobile:h.isNativeMobile,viewportClass:h.viewportClass}),K=bu({enabled:P,rootRef:S,suspended:G,resetKey:`${g.pathname}${g.search}`}),U=co({viewportClass:h.viewportClass,activeEntry:e,hasNavigationPanel:!!r,hasAuxiliaryPanel:!!s,preferCompactLayout:T}),L=fu({activeEntry:e,presentation:t,pathname:g.pathname,search:g.search,moreButtonLabel:l("shell.iosMoreAction")}),E=[{key:"workspaces",label:l("shell.mobileWorkspacesEntry"),icon:i.jsx(cx,{}),onClick:o},{key:"sessions",label:l("shell.mobileSessionsEntry"),icon:i.jsx(ux,{}),onClick:c},{key:"terminals",label:l("shell.mobileButlerEntry"),icon:i.jsx(hx,{}),onClick:u},{key:"butler",label:l("shell.mobileTerminalsEntry"),icon:i.jsx(dx,{}),onClick:a},{key:"settings",label:l("shell.mobileSettingsEntry"),icon:i.jsx(px,{}),onClick:p}],$=P?{"--mobile-conversation-tabbar-progress":K.progress.toFixed(4)}:void 0;gu(S,C,P);function B(){const X=pu(g.pathname,g.search);if(!X){a();return}y(X,{replace:!0})}const re=i.jsx("nav",{ref:C,className:"mobile-workbench-tabbar","aria-label":l("shell.title"),hidden:G,children:E.map(X=>i.jsxs("button",{type:"button",className:"mobile-workbench-tabbar-item","data-active":X.key===e,"aria-current":X.key===e?"page":void 0,onClick:()=>{X.key!==e&&m.trigger("selection"),X.onClick()},children:[i.jsx("span",{className:"mobile-workbench-tabbar-icon","aria-hidden":"true",children:X.icon}),i.jsx("span",{className:"mobile-workbench-tabbar-label",children:X.label})]},X.key))});return i.jsx(mu,{composerPortalTarget:P?x:null,children:i.jsxs("div",{ref:S,className:"mobile-workbench-shell","data-active-entry":e,"data-mobile-presentation":t,"data-mobile-runtime":h.platform,"data-mobile-keyboard-open":G,"data-pane-layout":U,"data-tabbar-open":G?!1:P?K.isOpen:!0,"data-conversation-tabbar-state":P?K.state:"default",style:$,children:[L?i.jsxs("header",{className:"mobile-workbench-header","data-header-kind":"tools",children:[i.jsxs("div",{className:"mobile-workbench-header-leading",children:[L.showBackButton?i.jsx("button",{type:"button",className:"mobile-workbench-header-button","aria-label":l("common.back"),onClick:B,children:i.jsx(ax,{})}):null,i.jsx("div",{className:"mobile-workbench-header-copy",children:i.jsx("h1",{children:L.title})})]}),i.jsx("div",{className:"mobile-workbench-header-actions",children:L.showMoreButton?i.jsx("button",{type:"button",className:"mobile-workbench-header-button mobile-tools-more-button","aria-label":L.moreButtonLabel,onClick:d,children:i.jsx(lx,{})}):null})]}):null,i.jsx("div",{className:"mobile-workbench-content",children:i.jsx(ku,{viewportClass:h.viewportClass,activeEntry:e,hasNavigationPanel:!!r,hasAuxiliaryPanel:!!s,preferCompactLayout:T,navigationPanel:r,auxiliaryPanel:s,children:n})}),P?i.jsxs("div",{className:"mobile-conversation-bottom-layer",children:[i.jsx("div",{ref:A,className:"mobile-conversation-bottom-layer-composer-slot"}),i.jsx("div",{className:"mobile-conversation-bottom-layer-tabbar-shell",children:re})]}):re]})})}function ax(){return i.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:[i.jsx("path",{d:"m15 18-6-6 6-6"}),i.jsx("path",{d:"M21 12H9"})]})}function lx(){return i.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:[i.jsx("circle",{cx:"12",cy:"5",r:"1.8"}),i.jsx("circle",{cx:"12",cy:"12",r:"1.8"}),i.jsx("circle",{cx:"12",cy:"19",r:"1.8"})]})}function cx(){return i.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:[i.jsx("path",{d:"M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7z"}),i.jsx("path",{d:"M8 13h8"})]})}function ux(){return i.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:i.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H8l-5 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}function dx(){return i.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:[i.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2.5"}),i.jsx("path",{d:"m7.5 9 3 3-3 3"}),i.jsx("path",{d:"M12.5 15H17"})]})}function hx(){return i.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:[i.jsx("rect",{x:"5",y:"7",width:"14",height:"10",rx:"3"}),i.jsx("path",{d:"M9 7V5a3 3 0 0 1 6 0v2"}),i.jsx("circle",{cx:"10",cy:"12",r:"1",fill:"currentColor",stroke:"none"}),i.jsx("circle",{cx:"14",cy:"12",r:"1",fill:"currentColor",stroke:"none"}),i.jsx("path",{d:"M10 15c.6.5 1.2.8 2 .8s1.4-.3 2-.8"})]})}function px(){return i.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[i.jsx("circle",{cx:"12",cy:"12",r:"3"}),i.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09a1.65 1.65 0 0 0-1-1.51 1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06A1.65 1.65 0 0 0 4.6 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09a1.65 1.65 0 0 0 1.51-1 1.65 1.65 0 0 0-.33-1.82L4.21 7.1a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06A1.65 1.65 0 0 0 8.92 4a1.65 1.65 0 0 0 1-1.51V2.4a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9c0 .66.39 1.25 1 1.51h.09a2 2 0 0 1 0 4h-.09c-.61.26-1 .85-1 1.49z"})]})}class fx{constructor(t){Xe(this,"maxAttempts");Xe(this,"baseDelayMs");Xe(this,"reconnectAttempts",0);Xe(this,"reconnectTimer",null);Xe(this,"disposed",!1);this.options=t,this.maxAttempts=t.maxAttempts??4,this.baseDelayMs=t.baseDelayMs??300}start(){this.options.onReconnect(!1)}markConnected(){this.reconnectAttempts=0,this.options.onStateChange("connected")}markTransientFailure(){this.disposed||this.reconnectAttempts>0||this.options.onStateChange("reconnecting")}markDisconnected(){if(this.disposed)return;if(!On.getState().autoReconnect){this.options.onStateChange("reconnect_failed");return}if(this.reconnectAttempts+=1,this.reconnectAttempts>this.maxAttempts){this.options.onStateChange("reconnect_failed");return}this.options.onStateChange("reconnecting");const t=this.baseDelayMs*this.reconnectAttempts;this.reconnectTimer=window.setTimeout(()=>{this.options.onReconnect(!0)},t)}reconnectNow(){this.reconnectAttempts=0,this.reconnectTimer!==null&&(window.clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this.options.onReconnect(!0)}close(){this.disposed=!0,this.reconnectTimer!==null&&(window.clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this.options.onStateChange("closed")}}class mx{constructor(t){Xe(this,"socket",null);Xe(this,"disposed",!1);Xe(this,"authRecoveryInFlight",!1);Xe(this,"pendingRefresh",!1);Xe(this,"workbenchKnownRevision");Xe(this,"lastWorkbenchSnapshot",null);Xe(this,"fileTreeSubscription",null);Xe(this,"gitSubscription",null);Xe(this,"terminalManagerSubscription",null);Xe(this,"workspaceManagementSubscription",null);Xe(this,"pendingFileTreeRefresh",null);Xe(this,"pendingGitRefresh",null);Xe(this,"pendingTerminalManagerRefresh",null);Xe(this,"pendingWorkspaceManagementRefresh",null);Xe(this,"fileTreeRevisionByPath",new Map);Xe(this,"gitRevisionByWorkspaceId",new Map);Xe(this,"terminalManagerRevisionByWorkspaceId",new Map);Xe(this,"workspaceManagementRevisionByWorkspaceId",new Map);Xe(this,"fileTreeListeners",new Set);Xe(this,"gitListeners",new Set);Xe(this,"terminalManagerListeners",new Set);Xe(this,"workspaceManagementListeners",new Set);Xe(this,"workbenchSubscribeStartedAtMs",null);Xe(this,"workbenchRefreshStartedAtMs",null);Xe(this,"connectionManager");this.options=t,this.workbenchKnownRevision=null,this.connectionManager=new fx({onReconnect:n=>{this.connect(n)},onStateChange:t.onConnectionChange})}start(){this.connectionManager.start()}requestRefresh(){const t=this.socket;if(!yd(t)){this.pendingRefresh=!0;return}this.workbenchRefreshStartedAtMs=performance.now(),t.send(JSON.stringify({type:"workbench.refresh",knownRevision:this.workbenchKnownRevision??void 0})),Wt("workbench.refresh.sent",{knownRevision:this.workbenchKnownRevision}),this.pendingRefresh=!1}setWorkbenchKnownRevision(t){this.workbenchKnownRevision=Tn(t)}primeWorkbenchSnapshot(t){if(!t||!Array.isArray(t.items)){this.lastWorkbenchSnapshot=null,this.workbenchKnownRevision=null;return}this.lastWorkbenchSnapshot=t,this.workbenchKnownRevision=Tn(t.revision)??null}subscribeFileTree(t,n,r){this.fileTreeSubscription={workspaceId:t,paths:xd(n),knownRevisionByPath:Tl(r==null?void 0:r.knownRevisionByPath)},this.sendWhenReady({type:"fileTree.subscribe",workspaceId:t,paths:this.fileTreeSubscription.paths,knownRevisions:Il(t,this.fileTreeSubscription.paths,this.fileTreeSubscription.knownRevisionByPath,this.fileTreeRevisionByPath)})}requestFileTreeRefresh(t,n,r){const s=xd(n),o={type:"fileTree.refresh",workspaceId:t,paths:s,knownRevisions:Il(t,s,Tl(r==null?void 0:r.knownRevisionByPath),this.fileTreeRevisionByPath)};this.sendWhenReady(o)?this.pendingFileTreeRefresh=null:this.pendingFileTreeRefresh={workspaceId:t,paths:s,knownRevisionByPath:Tl(r==null?void 0:r.knownRevisionByPath)}}subscribeGit(t,n){this.gitSubscription={workspaceId:t,knownRevision:Tn(n==null?void 0:n.knownRevision)},this.sendWhenReady({type:"git.subscribe",workspaceId:t,knownRevision:this.gitSubscription.knownRevision??this.gitRevisionByWorkspaceId.get(t)})}requestGitRefresh(t,n){const r={type:"git.refresh",workspaceId:t,knownRevision:Tn(n==null?void 0:n.knownRevision)??this.gitRevisionByWorkspaceId.get(t)};this.sendWhenReady(r)?this.pendingGitRefresh=null:this.pendingGitRefresh={workspaceId:t,knownRevision:Tn(n==null?void 0:n.knownRevision)}}subscribeTerminalManager(t,n){this.terminalManagerSubscription={workspaceId:t,knownRevision:Tn(n==null?void 0:n.knownRevision)},this.sendWhenReady({type:"terminalManager.subscribe",workspaceId:t,knownRevision:this.terminalManagerSubscription.knownRevision??this.terminalManagerRevisionByWorkspaceId.get(t)})}requestTerminalManagerRefresh(t,n){const r={type:"terminalManager.refresh",workspaceId:t,knownRevision:Tn(n==null?void 0:n.knownRevision)??this.terminalManagerRevisionByWorkspaceId.get(t)};this.sendWhenReady(r)?this.pendingTerminalManagerRefresh=null:this.pendingTerminalManagerRefresh={workspaceId:t,knownRevision:Tn(n==null?void 0:n.knownRevision)}}subscribeWorkspaceManagement(t,n){this.workspaceManagementSubscription={workspaceId:t,knownRevision:Tn(n==null?void 0:n.knownRevision)},this.sendWhenReady({type:"workspaceManagement.subscribe",workspaceId:t,knownRevision:this.workspaceManagementSubscription.knownRevision??this.workspaceManagementRevisionByWorkspaceId.get(t)})}requestWorkspaceManagementRefresh(t,n){const r={type:"workspaceManagement.refresh",workspaceId:t,knownRevision:Tn(n==null?void 0:n.knownRevision)??this.workspaceManagementRevisionByWorkspaceId.get(t)};this.sendWhenReady(r)?this.pendingWorkspaceManagementRefresh=null:this.pendingWorkspaceManagementRefresh={workspaceId:t,knownRevision:Tn(n==null?void 0:n.knownRevision)}}addFileTreeSnapshotListener(t){return this.fileTreeListeners.add(t),()=>{this.fileTreeListeners.delete(t)}}addGitSnapshotListener(t){return this.gitListeners.add(t),()=>{this.gitListeners.delete(t)}}addTerminalManagerSnapshotListener(t){return this.terminalManagerListeners.add(t),()=>{this.terminalManagerListeners.delete(t)}}addWorkspaceManagementSnapshotListener(t){return this.workspaceManagementListeners.add(t),()=>{this.workspaceManagementListeners.delete(t)}}close(){var t;this.disposed=!0,this.connectionManager.close(),(t=this.socket)==null||t.close(),this.socket=null}connect(t){var u;if(this.disposed)return;t&&this.socket&&(this.socket.close(),this.socket=null);const n=(u=Ji.getState().session)==null?void 0:u.accessToken;if(!n){this.options.onUnauthorized();return}const r=Jc(),s=cf(r),o=s.baseUrl,a=`${hk("/ws",o)}?access_token=${encodeURIComponent(n)}`,c=s.transport.createWebSocket({path:"/ws",baseUrl:o,url:a});this.socket=c,c.addEventListener("open",()=>{this.workbenchSubscribeStartedAtMs=performance.now(),c.send(JSON.stringify({type:"workbench.subscribe",knownRevision:this.workbenchKnownRevision??void 0})),Wt("workbench.subscribe.sent",{knownRevision:this.workbenchKnownRevision,baseUrl:o}),this.pendingRefresh&&this.requestRefresh(),this.fileTreeSubscription&&c.send(JSON.stringify({type:"fileTree.subscribe",workspaceId:this.fileTreeSubscription.workspaceId,paths:this.fileTreeSubscription.paths,knownRevisions:Il(this.fileTreeSubscription.workspaceId,this.fileTreeSubscription.paths,this.fileTreeSubscription.knownRevisionByPath,this.fileTreeRevisionByPath)})),this.pendingFileTreeRefresh&&this.requestFileTreeRefresh(this.pendingFileTreeRefresh.workspaceId,this.pendingFileTreeRefresh.paths,{knownRevisionByPath:this.pendingFileTreeRefresh.knownRevisionByPath}),this.gitSubscription&&c.send(JSON.stringify({type:"git.subscribe",workspaceId:this.gitSubscription.workspaceId,knownRevision:this.gitSubscription.knownRevision??this.gitRevisionByWorkspaceId.get(this.gitSubscription.workspaceId)})),this.pendingGitRefresh&&this.requestGitRefresh(this.pendingGitRefresh.workspaceId,{knownRevision:this.pendingGitRefresh.knownRevision}),this.terminalManagerSubscription&&c.send(JSON.stringify({type:"terminalManager.subscribe",workspaceId:this.terminalManagerSubscription.workspaceId,knownRevision:this.terminalManagerSubscription.knownRevision??this.terminalManagerRevisionByWorkspaceId.get(this.terminalManagerSubscription.workspaceId)})),this.pendingTerminalManagerRefresh&&this.requestTerminalManagerRefresh(this.pendingTerminalManagerRefresh.workspaceId,{knownRevision:this.pendingTerminalManagerRefresh.knownRevision}),this.workspaceManagementSubscription&&c.send(JSON.stringify({type:"workspaceManagement.subscribe",workspaceId:this.workspaceManagementSubscription.workspaceId,knownRevision:this.workspaceManagementSubscription.knownRevision??this.workspaceManagementRevisionByWorkspaceId.get(this.workspaceManagementSubscription.workspaceId)})),this.pendingWorkspaceManagementRefresh&&this.requestWorkspaceManagementRefresh(this.pendingWorkspaceManagementRefresh.workspaceId,{knownRevision:this.pendingWorkspaceManagementRefresh.knownRevision})}),c.addEventListener("message",d=>{var h,m,g,y,S,C,x,A,j,G;if(!(d instanceof MessageEvent)||typeof d.data!="string")return;const p=JSON.parse(d.data);if(p.type==="system.connected"){this.connectionManager.markConnected();return}if(p.type==="session.error"){p.error_code==="UNAUTHORIZED"&&this.handleUnauthorized();return}if(p.type==="workbench.snapshot"&&(Wt("workbench.snapshot.received",{unchanged:p.unchanged,revision:p.revision,workspaceCount:((h=p.snapshot)==null?void 0:h.items.length)??0,sessionCount:p.snapshot?kx(p.snapshot):0,subscribeDurationMs:Wo(this.workbenchSubscribeStartedAtMs),refreshDurationMs:Wo(this.workbenchRefreshStartedAtMs)}),this.workbenchRefreshStartedAtMs=null),p.type==="workbench.delta"){Wt("workbench.delta.received",{baseRevision:p.baseRevision,revision:p.revision,changedWorkspaceCount:p.changedItems.length,removedWorkspaceCount:p.removedWorkspaceIds.length,subscribeDurationMs:Wo(this.workbenchSubscribeStartedAtMs),refreshDurationMs:Wo(this.workbenchRefreshStartedAtMs)}),this.workbenchRefreshStartedAtMs=null;const P=bx(this.lastWorkbenchSnapshot,p);if(!P){Wt("workbench.delta.mismatch",{currentRevision:((m=this.lastWorkbenchSnapshot)==null?void 0:m.revision)??null,baseRevision:p.baseRevision,revision:p.revision}),this.workbenchKnownRevision=null,this.lastWorkbenchSnapshot=null,this.connectionManager.reconnectNow();return}this.lastWorkbenchSnapshot=P,this.workbenchKnownRevision=p.revision,this.options.onSnapshot(P);return}if(p.type==="fileTree.snapshot"){const P=p.snapshot;if(P)P.revision=p.revision,this.fileTreeRevisionByPath.set(xc(P.workspaceId,P.path),p.revision);else if(p.unchanged&&this.fileTreeSubscription)for(const T of this.fileTreeSubscription.paths)this.fileTreeRevisionByPath.set(xc(this.fileTreeSubscription.workspaceId,T),p.revision);if(!P)return;(y=(g=this.options).onFileTreeSnapshot)==null||y.call(g,P),this.fileTreeListeners.forEach(T=>T(P));return}if(p.type==="git.snapshot"){const P=p.snapshot;if(P?(P.revision=p.revision,this.gitRevisionByWorkspaceId.set(P.workspaceId,p.revision)):p.unchanged&&this.gitSubscription&&this.gitRevisionByWorkspaceId.set(this.gitSubscription.workspaceId,p.revision),!P)return;(C=(S=this.options).onGitSnapshot)==null||C.call(S,P),this.gitListeners.forEach(T=>T(P));return}if(p.type==="terminalManager.snapshot"){const P=p.snapshot;if(P?(P.revision=p.revision,this.terminalManagerRevisionByWorkspaceId.set(P.workspaceId,p.revision)):p.unchanged&&this.terminalManagerSubscription&&this.terminalManagerRevisionByWorkspaceId.set(this.terminalManagerSubscription.workspaceId,p.revision),!P)return;(A=(x=this.options).onTerminalManagerSnapshot)==null||A.call(x,P),this.terminalManagerListeners.forEach(T=>T(P));return}if(p.type==="workspaceManagement.snapshot"){const P=p.snapshot;if(P?(P.revision=p.revision,this.workspaceManagementRevisionByWorkspaceId.set(P.workspaceId,p.revision)):p.unchanged&&this.workspaceManagementSubscription&&this.workspaceManagementRevisionByWorkspaceId.set(this.workspaceManagementSubscription.workspaceId,p.revision),!P)return;(G=(j=this.options).onWorkspaceManagementSnapshot)==null||G.call(j,P),this.workspaceManagementListeners.forEach(T=>T(P));return}p.type==="workbench.snapshot"&&p.snapshot&&gx(p.snapshot)?(p.snapshot.revision=p.revision,this.lastWorkbenchSnapshot=p.snapshot,this.workbenchKnownRevision=p.revision,this.options.onSnapshot(p.snapshot)):p.type==="workbench.snapshot"&&p.unchanged&&(this.workbenchKnownRevision=p.revision,this.lastWorkbenchSnapshot&&(this.lastWorkbenchSnapshot={...this.lastWorkbenchSnapshot,revision:p.revision}))}),c.addEventListener("close",()=>{this.disposed||this.socket!==c||this.connectionManager.markDisconnected()}),c.addEventListener("error",()=>{this.disposed||this.socket!==c||this.connectionManager.markTransientFailure()})}handleUnauthorized(){if(this.authRecoveryInFlight||this.disposed)return;this.authRecoveryInFlight=!0;const t=this.socket;this.socket=null,t==null||t.close(),Ji.refresh().then(n=>{if(this.authRecoveryInFlight=!1,!this.disposed){if(n.status==="refreshed"){this.connectionManager.reconnectNow();return}if(n.status==="deferred"){this.connectionManager.markDisconnected();return}this.options.onUnauthorized()}})}sendWhenReady(t){const n=this.socket;return yd(n)?(n.send(JSON.stringify(t)),!0):!1}}function yd(e){return e!==null&&e.readyState===1}function gx(e){return typeof e!="object"||e===null?!1:Array.isArray(e.items)}function xd(e){const t=new Set;for(const n of e??[""])t.add(n.trim().replace(/\\/g,"/").replace(/^\/+|\/+$/g,""));return[...t]}function Tn(e){return typeof e=="string"&&e.trim().length>0?e.trim():null}function bx(e,t){if(!e||e.revision!==t.baseRevision)return null;const n=new Map(e.items.map(s=>[s.workspace.id,s]));for(const s of t.removedWorkspaceIds)n.delete(s);for(const s of t.changedItems)n.set(s.workspace.id,s);const r=[];for(const s of t.orderedWorkspaceIds){const o=n.get(s);if(!o)return null;r.push(o)}return{revision:t.revision,items:r}}function Tl(e){return e?Object.fromEntries(Object.entries(e).map(([t,n])=>[t.trim().replace(/\\/g,"/").replace(/^\/+|\/+$/g,""),Tn(n)]).filter(t=>t[1]!==null)):{}}function Il(e,t,n,r){const s=t.map(o=>{const a=o.trim().replace(/\\/g,"/").replace(/^\/+|\/+$/g,"");return[a,n[a]??r.get(xc(e,a))??null]}).filter(o=>!!o[1]);if(s.length!==0)return Object.fromEntries(s)}function xc(e,t){return`${e}::${t}`}function kx(e){return e.items.reduce((t,n)=>t+n.sessions.length+Gf(n.childWorktrees??[]),0)}function Gf(e){return e.reduce((t,n)=>{if(typeof n!="object"||n===null)return t;const r=n,s=Array.isArray(r.sessions)?r.sessions.length:0,o=Array.isArray(r.children)?Gf(r.children):0;return t+s+o},0)}function Wo(e){return e===null||typeof performance>"u"?null:Math.round(performance.now()-e)}const wd=6,yx=["button","a","input","textarea","select","summary","[role='button']","[role='link']","[role='tab']","[role='menuitem']","[contenteditable='true']","[data-window-drag='ignore']"].join(", ");function xx(e){return e instanceof HTMLElement?!e.closest(yx):!0}function wc(e,t,n){return e.isDesktop&&e.ui.osFamily==="macos"&&t===0&&xx(n)}function Vf(e){return e.isDesktop&&e.ui.osFamily==="macos"&&e.ui.prefersOverlayTitlebar}function Kf(e){return Vf(e)?"":void 0}function wx(e){if(!wc(e.platform,e.button,e.target)||typeof window>"u")return;const t=e.clientX,n=e.clientY;let r=!0;const s=()=>{r&&(r=!1,window.removeEventListener("mousemove",o),window.removeEventListener("mouseup",a),window.removeEventListener("blur",c))},o=u=>{Math.abs(u.clientX-t)<wd&&Math.abs(u.clientY-n)<wd||(s(),vx())},a=()=>{s()},c=()=>{s()};window.addEventListener("mousemove",o),window.addEventListener("mouseup",a),window.addEventListener("blur",c)}async function vx(){typeof window>"u"||typeof window.__TAURI_INTERNALS__>"u"||await wf().startDragging()}const Ca=.78,Sx=1;function Cx(){return typeof window<"u"&&typeof window.__TAURI_INTERNALS__<"u"}function Yf(e,t,n,r){const s=Math.hypot(n-e,r-t),o=Math.min(1,s/120);return Ca+(Sx-Ca)*o}function Lr(e){return Math.round(Number.isFinite(e)?e:0)}function Nx(e){if(!Cx())return null;const t=Lr(e.x),n=Lr(e.y);let r=!1,s=Promise.resolve();const o=(c,u)=>(s=s.then(async()=>{await window.__TAURI_INTERNALS__.invoke(c,u)}).catch(()=>{}),s),a=async()=>{r||(r=!0,await o("close_detach_preview"))};return o("show_detach_preview",{title:e.title,x:t,y:n,scale:Ca}),{updatePosition(c,u){if(r)return;const d=Lr(c),p=Lr(u);o("update_detach_preview_position",{x:d,y:p,scale:Yf(t,n,d,p)})},complete(){return a()},cancel(){return a()}}}function jx(e){if(typeof document>"u")return null;const t=Lr(e.x),n=Lr(e.y),r=document.createElement("div");r.className="desktop-window-detach-animation",r.setAttribute("aria-hidden","true"),r.dataset.state="preview",r.style.left=`${t}px`,r.style.top=`${n}px`,r.style.setProperty("--detach-preview-scale",Ca.toFixed(3));const s=document.createElement("div");s.className="desktop-window-detach-animation-bar";const o=document.createElement("strong");o.className="desktop-window-detach-animation-title",o.textContent=e.title;const a=document.createElement("div");a.className="desktop-window-detach-animation-body",s.append(o),r.append(s,a),document.body.append(r);let c=!1;const u=()=>{c||(c=!0,r.remove())};return{updatePosition(d,p){if(c)return;const h=Lr(d),m=Lr(p),g=Yf(t,n,h,m);r.style.left=`${h}px`,r.style.top=`${m}px`,r.style.setProperty("--detach-preview-scale",g.toFixed(3))},async complete(){u()},async cancel(){u()}}}function vd(e){return Nx(e)??jx(e)}const Tx={files:{kind:"files",label:"文件",defaultFocusOwner:"file-context-panel"},git:{kind:"git",label:"Git",defaultFocusOwner:"git-sidebar"},processes:{kind:"processes",label:"调试",defaultFocusOwner:"terminal-manager-panel"},terminals:{kind:"terminals",label:"终端",defaultFocusOwner:"terminal-page"}};function Ix(e){return{...e,bounds:{...e.bounds}}}function Ex(e,t,n){t&&(e.windows.registerDescriptor(t),n?e.windows.markWindowOpen(t.windowId):e.windows.markWindowClosed(t.windowId))}function Mx(e){return Tx[e]}function Xf(e,t){return`${e}-${t}`}async function Va(e,t,n){const r=n.workspaceId.trim(),s=Mx(t);if(!e.isDesktop||!e.bridge.supported)return{ok:!1,errorCode:"PLATFORM_NOT_SUPPORTED",detail:"当前运行环境不支持桌面外部窗口。"};if(!r)return{ok:!1,errorCode:"WINDOW_WORKSPACE_REQUIRED",detail:`${s.label}外部窗口必须绑定工作区。`};const o=Xf(t,r),a=e.windows.getDescriptor(o),c=a?Ix(a):null,u=e.windows.isWindowOpen(o),d=pk({windowId:o,kind:t,workspaceId:r,workspaceName:n.workspaceName??(c==null?void 0:c.workspaceName)??null,sessionId:n.sessionId??(c==null?void 0:c.sessionId)??null,mode:"external",bounds:c==null?void 0:c.bounds,focusOwner:n.focusOwner??s.defaultFocusOwner});e.windows.registerDescriptor(d);const p=await e.bridge.createWindow(d);return p.ok?(e.windows.markWindowOpen(o),{ok:!0,value:d}):(c?Ex(e,c,u):e.windows.removeWindow(o),{ok:!1,errorCode:p.errorCode,detail:p.detail})}function SP(e){return Xf("terminals",e)}function Rx(e,t){return Va(e,"files",t)}function Ax(e,t){return Va(e,"git",t)}function Px(e,t){return Va(e,"processes",t)}function CP(e,t){return Va(e,"terminals",t)}async function Sd(){return await ye.request("/api/skills/overview")}async function Lx(e){await ye.request("/api/skills",{method:"POST",body:JSON.stringify(e)})}async function _x(e){await ye.request("/api/skills/import",{method:"POST",body:JSON.stringify(e)})}async function Dx(e){await ye.request("/api/skills/sync",{method:"POST",body:JSON.stringify(e)})}async function Bx(){return await ye.request("/api/opencli/catalog")}async function Cd(){return await ye.request("/api/opencli/check",{method:"POST"})}async function Ox(e){return await ye.request("/api/opencli/config",{method:"POST",body:JSON.stringify(e)})}const El="all",Ml="status";function Wx({toolbarMode:e="internal",onToolbarStateChange:t}={}){var Fe,Ue,_e,qe;const n=Qc(W=>{var Y;return((Y=W.session)==null?void 0:Y.accessToken)??null}),[r,s]=f.useState(null),[o,a]=f.useState(!1),[c,u]=f.useState(!1),[d,p]=f.useState(!1),[h,m]=f.useState(!1),[g,y]=f.useState([]),[S,C]=f.useState(null),[x,A]=f.useState(null),[j,G]=f.useState(El),[P,T]=f.useState(null),[K,U]=f.useState(!1),[L,E]=f.useState(""),[$,B]=f.useState(Ml);f.useEffect(()=>{let W=!0;if(!n){s(null),m(!1),y([]),A(null),C(null),a(!1),G(El),T(null),U(!1),E(""),B(Ml);return}return(async()=>{a(!0),A(null),C(null);try{const se=await Cd();if(!W)return;N(se)}catch(se){if(!W)return;const Ce=$o(se);try{const ve=await Bx();if(!W)return;N(ve),A(Ce)}catch(ve){if(!W)return;A($o(ve))}}finally{W&&a(!1)}})(),()=>{W=!1}},[n]);const re=f.useMemo(()=>new Set(g),[g]),X=f.useMemo(()=>zx((r==null?void 0:r.entries)??[]),[r==null?void 0:r.entries]),F=f.useMemo(()=>Gx(),[]);f.useEffect(()=>{X.some(W=>W.id===j)||G(El)},[j,X]);const q=f.useMemo(()=>((r==null?void 0:r.siteGroups)??[]).filter(W=>W.commands.some(Y=>Nd(Y,j,re))),[j,r==null?void 0:r.siteGroups,re]),D=f.useMemo(()=>P?q.find(W=>W.site===P)??null:null,[P,q]);f.useEffect(()=>{P&&!D&&T(null)},[P,D]),f.useEffect(()=>{E(""),B(Ml)},[P]);const V=f.useMemo(()=>{if(!D)return[];const W=L.trim().toLowerCase();return D.commands.filter(Y=>Nd(Y,j,re)&&Ux(Y,W)).sort((Y,se)=>qx(Y,se,{sortId:$,selectedCommandIdSet:re}))},[j,D,L,$,re]),te=!!(r&&(r.provider.enabled!==h||r.entries.some(W=>W.enabled!==re.has(W.commandId)))),v=f.useMemo(()=>({draftEnabled:h,enableDisabled:o||c||d,refreshDisabled:!n||o||c||d,detailDisabled:!r||o,saveDisabled:!n||o||c||d||!r||!te,refreshing:c,saving:d,onEnabledChange:de,onRefresh:()=>{je()},onShowDetails:()=>U(!0),onSave:()=>{Te()}}),[n,r,g,h,te,o,c,d]);f.useEffect(()=>{t==null||t(v)},[t,v]),f.useEffect(()=>()=>{t==null||t(null)},[t]);async function je(){if(n){u(!0),A(null),C(null);try{const W=await Cd();N(W),C(ew(W.refreshState,W.runtimeAvailability))}catch(W){A($o(W))}finally{u(!1)}}}async function Te(){if(n){p(!0),A(null),C(null);try{const W=await Ox({enabled:h,enabledCommandIds:g});N(W),C(tw(W))}catch(W){A($o(W))}finally{p(!1)}}}function N(W){s(W),m(W.provider.enabled),y(W.entries.filter(Y=>Y.enabled).map(Y=>Y.commandId).sort((Y,se)=>Y.localeCompare(se))),A(null)}function de(W){m(W)}function Ie(W,Y){const se=W.commands.map(Ce=>Ce.commandId);y(Ce=>{const ve=new Set(Ce);for(const fe of se)Y?ve.add(fe):ve.delete(fe);return[...ve].sort((fe,ht)=>fe.localeCompare(ht))})}function he(W,Y){y(se=>{const Ce=new Set(se);return Y?Ce.add(W):Ce.delete(W),[...Ce].sort((ve,fe)=>ve.localeCompare(fe))})}const le=(r==null?void 0:r.summary)??{catalogCount:0,browserDependentCount:0,installState:"not_installed"};return i.jsxs("section",{className:"settings-opencli-panel settings-skill-section",children:[e==="internal"?i.jsx(Fx,{state:v,className:"settings-opencli-inline-toolbar"}):null,i.jsxs("div",{className:"settings-skill-summary-grid",children:[i.jsx(Fo,{label:l("settings.opencliSummaryInstallState"),value:Id(le.installState)}),i.jsx(Fo,{label:l("settings.opencliSummaryCatalogCount"),value:String(le.catalogCount)}),i.jsx(Fo,{label:l("settings.opencliSummaryEnabledCount"),value:String(g.length)}),i.jsx(Fo,{label:l("settings.opencliSummaryBrowserCount"),value:String(le.browserDependentCount)})]}),S?i.jsx("p",{className:"settings-release-status",children:S}):null,x?i.jsx("p",{className:"settings-release-status",children:x}):null,o?i.jsx("div",{className:"settings-skill-empty",children:l("settings.opencliLoading")}):r!=null&&r.siteGroups.length?i.jsxs("section",{className:"settings-opencli-catalog-section settings-skill-section",children:[i.jsx("div",{className:"settings-model-tabs settings-opencli-filter-tabs",role:"tablist","aria-label":l("settings.opencliFilterTabsLabel"),children:X.map(W=>{const Y=j===W.id;return i.jsx("button",{type:"button",role:"tab",className:"settings-model-tab","aria-selected":Y,"data-active":Y?"true":"false",onClick:()=>G(W.id),children:W.label},W.id)})}),q.length>0?i.jsx("div",{className:"settings-opencli-site-grid",children:q.map(W=>{const Y=Hx(W,re),se=Vx(W.commands),Ce=Td(W,{maxDescriptions:2}),ve=Td(W),fe=Qf(W.site),ht=P===W.site;return i.jsxs("div",{className:"settings-opencli-site-card","data-selected":ht?"true":"false",children:[i.jsxs("div",{className:"settings-opencli-site-card-head",children:[i.jsx("div",{className:"settings-opencli-site-card-visual",style:fe.style,children:i.jsx("span",{children:fe.label})}),i.jsxs("div",{className:"settings-opencli-site-card-body",children:[i.jsxs("div",{className:"settings-opencli-site-card-topline",children:[i.jsx("strong",{className:"settings-skill-entry-title",children:W.site}),i.jsxs("div",{className:"settings-opencli-site-card-actions",children:[i.jsx("button",{className:"ghost-button settings-opencli-site-detail-button",type:"button",onClick:()=>T(W.site),children:l("settings.opencliSiteViewAction")}),i.jsxs("label",{className:"settings-opencli-checkbox settings-opencli-site-toggle",children:[i.jsx("input",{"aria-label":l("settings.opencliSiteToggleLabel",{site:W.site}),type:"checkbox",checked:Y.allSelected,disabled:c||d,ref:Ke=>{Ke&&(Ke.indeterminate=Y.partialSelected)},onChange:Ke=>Ie(W,Ke.target.checked)}),i.jsx("span",{children:l("settings.opencliSiteEnableAction")})]})]})]}),i.jsx("p",{className:"settings-opencli-site-card-description",title:ve,children:Ce})]})]}),i.jsx("div",{className:"settings-opencli-site-card-summary",children:i.jsx("div",{className:"settings-opencli-site-card-tag-rows",children:i.jsx("div",{className:"settings-skill-tags settings-opencli-site-card-tag-row settings-opencli-site-card-type-row",children:(se.length>0?se:["unknown"]).slice(0,2).map(Ke=>i.jsx("span",{className:"settings-skill-tag settings-opencli-strategy-tag","data-strategy":tm(Ke),children:Zf(Ke)},`${W.site}:${Ke}`))})})})]},W.site)})}):i.jsx("div",{className:"settings-skill-empty",children:l("settings.opencliFilteredEmpty")})]}):i.jsx("div",{className:"settings-skill-empty",children:nw(r)}),i.jsx(Et,{open:K,title:l("settings.opencliDetailTitle"),className:"settings-opencli-detail-modal",onClose:()=>U(!1),children:r?i.jsxs(i.Fragment,{children:[i.jsx(Ys,{heading:l("settings.opencliDetailStatusHeading"),actions:i.jsxs("div",{className:"settings-opencli-detail-tags",children:[i.jsx(_o,{children:Id(r.provider.installState)}),i.jsx(_o,{children:Xx(r.provider.healthState)}),i.jsx(_o,{children:Qx(((Fe=r.activeRuntimeProfile)==null?void 0:Fe.status)??null)})]}),children:i.jsxs(ru,{compact:!0,className:"settings-opencli-detail-list",children:[i.jsx(fn,{label:l("settings.opencliEnabledStateLabel"),trailing:i.jsx("span",{className:"settings-opencli-detail-value",children:h?l("settings.opencliEnabledStateOn"):l("settings.opencliEnabledStateOff")})}),i.jsx(fn,{label:l("settings.opencliSummaryCatalogCount"),trailing:i.jsx("span",{className:"settings-opencli-detail-value",children:String(le.catalogCount)})}),i.jsx(fn,{label:l("settings.opencliSummaryEnabledCount"),trailing:i.jsx("span",{className:"settings-opencli-detail-value",children:String(g.length)})}),i.jsx(fn,{label:l("settings.opencliSummaryBrowserCount"),trailing:i.jsx("span",{className:"settings-opencli-detail-value",children:String(le.browserDependentCount)})}),i.jsx(fn,{label:l("settings.opencliVersionLabel"),trailing:i.jsx("span",{className:"settings-opencli-detail-value",children:r.provider.version??"-"})}),i.jsx(fn,{label:l("settings.opencliCatalogSourceLabel"),trailing:i.jsx("span",{className:"settings-opencli-detail-value",children:Jx(r.effectiveCatalogSource??null)})}),i.jsx(fn,{label:l("settings.opencliLastCheckedLabel"),trailing:i.jsx("span",{className:"settings-opencli-detail-value",children:Ed(r.provider.lastCheckedAt)})}),i.jsx(fn,{label:l("settings.opencliCatalogRefreshedLabel"),trailing:i.jsx("span",{className:"settings-opencli-detail-value",children:Ed(r.provider.catalogRefreshedAt)})}),i.jsx(fn,{label:l("settings.opencliInstallPathLabel"),description:r.provider.installPath??"-"}),i.jsx(fn,{label:l("settings.opencliDetailRuntimeIdLabel"),description:r.provider.activeRuntimeId??"-"}),i.jsx(fn,{label:l("settings.opencliDetailRuntimeRootLabel"),description:((Ue=r.activeRuntimeProfile)==null?void 0:Ue.runtimeRootPath)??"-"})]})}),r.provider.lastErrorDetail||(_e=r.activeRuntimeProfile)!=null&&_e.lastErrorDetail?i.jsx(Ys,{tone:"danger",heading:l("settings.opencliDetailErrorHeading"),children:i.jsxs("div",{className:"settings-opencli-detail-errors",children:[r.provider.lastErrorDetail?i.jsx("p",{className:"settings-skill-entry-meta",children:r.provider.lastErrorDetail}):null,(qe=r.activeRuntimeProfile)!=null&&qe.lastErrorDetail?i.jsx("p",{className:"settings-skill-entry-meta",children:r.activeRuntimeProfile.lastErrorDetail}):null]})}):null]}):null}),i.jsx(Et,{open:D!==null,title:D?l("settings.opencliSiteDetailTitle",{site:D.site}):l("settings.opencliCommandModalFallbackTitle"),description:D?l("settings.opencliSiteDetailDescription",{count:V.length,total:D.totalCount}):void 0,className:"settings-opencli-command-modal",onClose:()=>T(null),children:D?i.jsxs("section",{className:"settings-skill-section",children:[i.jsx(Ys,{heading:l("settings.opencliSiteDescriptionHeading"),children:i.jsx("div",{className:"settings-opencli-site-detail-copy",children:Jf(D.commands).map(W=>i.jsx("p",{className:"settings-opencli-site-detail-description",children:W},W))})}),i.jsx(Ys,{heading:l("settings.opencliCommandSearchLabel"),actions:i.jsx(_o,{children:l("settings.opencliCommandResultCount",{count:V.length})}),children:i.jsxs("div",{className:"settings-opencli-command-tools",children:[i.jsxs("label",{className:"settings-opencli-command-search",htmlFor:"opencli-command-search",children:[i.jsx("span",{className:"settings-opencli-command-search-label",children:l("settings.opencliCommandSearchLabel")}),i.jsx("input",{id:"opencli-command-search",className:"settings-text-input",type:"search",value:L,placeholder:l("settings.opencliCommandSearchPlaceholder"),onChange:W=>E(W.target.value)})]}),i.jsxs("div",{className:"settings-opencli-command-sort",children:[i.jsx("span",{className:"settings-opencli-command-search-label",children:l("settings.opencliCommandSortLabel")}),i.jsx("div",{className:"settings-opencli-command-sort-tabs",role:"tablist","aria-label":l("settings.opencliCommandSortLabel"),children:F.map(W=>{const Y=$===W.id;return i.jsx("button",{type:"button",role:"tab",className:"settings-model-tab settings-opencli-command-sort-button","aria-selected":Y,"data-active":Y?"true":"false",onClick:()=>B(W.id),children:W.label},W.id)})})]})]})}),V.length>0?i.jsx("div",{className:"settings-opencli-command-grid",children:V.map(W=>i.jsx($x,{command:W,checked:re.has(W.commandId),disabled:c||d,onToggle:he},W.commandId))}):i.jsx(ff,{compact:!0,title:l("settings.opencliCommandModalEmpty")})]}):null})]})}function Fx({state:e,className:t}){return i.jsxs("div",{className:`settings-opencli-toolbar${t?` ${t}`:""}`,children:[i.jsxs("label",{className:"settings-opencli-checkbox settings-opencli-toolbar-toggle",children:[i.jsx("input",{"aria-label":l("settings.opencliProviderToggleLabel"),type:"checkbox",checked:e.draftEnabled,disabled:e.enableDisabled,onChange:n=>e.onEnabledChange(n.target.checked)}),i.jsx("span",{children:l("settings.opencliEnableAction")})]}),i.jsx("button",{className:"secondary-button",type:"button",disabled:e.refreshDisabled,onClick:e.onRefresh,children:e.refreshing?l("common.loading"):l("settings.opencliRefreshAction")}),i.jsx("button",{className:"secondary-button",type:"button",disabled:e.detailDisabled,onClick:e.onShowDetails,children:l("settings.opencliDetailAction")}),i.jsx("button",{className:"primary-button",type:"button",disabled:e.saveDisabled,onClick:e.onSave,children:e.saving?l("common.loading"):l("settings.opencliSaveAction")})]})}function $x({command:e,checked:t,disabled:n,onToggle:r}){const s=Qf(e.commandId);return i.jsxs("div",{className:"settings-opencli-command-card",children:[i.jsxs("div",{className:"settings-opencli-command-card-head",children:[i.jsx("div",{className:"settings-opencli-command-badge",style:s.style,children:i.jsx("span",{children:e.name.slice(0,1).toUpperCase()})}),i.jsxs("div",{className:"settings-opencli-command-card-main",children:[i.jsxs("label",{className:"settings-opencli-checkbox",children:[i.jsx("input",{"aria-label":l("settings.opencliCommandToggleLabel",{commandId:e.commandId}),type:"checkbox",checked:t,disabled:n,onChange:o=>r(e.commandId,o.target.checked)}),i.jsx("span",{children:e.commandId})]}),i.jsx("p",{className:"settings-skill-entry-meta",children:e.description||l("settings.opencliCommandDescriptionEmpty")})]})]}),i.jsxs("div",{className:"settings-skill-tags",children:[i.jsx("span",{className:"settings-skill-tag settings-opencli-strategy-tag","data-strategy":tm(e.strategy),children:Zx(e.strategy)}),e.browser?i.jsx("span",{className:"settings-skill-tag","data-status":"failed",children:l("settings.opencliBrowserTag")}):i.jsx("span",{className:"settings-skill-tag","data-status":"synced",children:l("settings.opencliHttpTag")})]})]})}function Fo({label:e,value:t}){return i.jsxs("div",{className:"settings-skill-summary-card",children:[i.jsx("span",{children:e}),i.jsx("strong",{children:t})]})}function zx(e){const t=Array.from(new Set(e.map(n=>n.strategy.trim()).filter(n=>n.length>0&&n!=="unknown"))).sort((n,r)=>n.localeCompare(r));return[{id:"all",label:l("settings.opencliFilterAll")},{id:"enabled",label:l("settings.opencliFilterEnabled")},{id:"browser",label:l("settings.opencliFilterBrowser")},{id:"direct",label:l("settings.opencliFilterDirect")},...t.map(n=>({id:`strategy:${n}`,label:l("settings.opencliFilterStrategy",{strategy:Zf(n)})}))]}function Nd(e,t,n){switch(t){case"all":return!0;case"enabled":return n.has(e.commandId);case"browser":return e.browser;case"direct":return!e.browser;default:return t.startsWith("strategy:")?e.strategy===t.slice(9):!0}}function Hx(e,t){const n=e.commands.filter(r=>t.has(r.commandId)).length;return{selectedCount:n,allSelected:n>0&&n===e.commands.length,partialSelected:n>0&&n<e.commands.length}}function Ux(e,t){return t?[e.commandId,e.name,e.description,e.strategy].join(`
|
|
3
|
+
`).toLowerCase().includes(t):!0}function qx(e,t,n){const r=jd(e,n)-jd(t,n);if(r!==0)return r;const s=e.name.localeCompare(t.name);return s!==0?s:e.commandId.localeCompare(t.commandId)}function jd(e,t){const n=t.selectedCommandIdSet.has(e.commandId)?0:1,r=e.browser?1:0;switch(t.sortId){case"browser":return(e.browser?0:2)+n;case"name":return 0;case"status":default:return n*2+r}}function Gx(){return[{id:"status",label:l("settings.opencliCommandSortStatus")},{id:"browser",label:l("settings.opencliCommandSortBrowser")},{id:"name",label:l("settings.opencliCommandSortName")}]}function Jf(e){return Array.from(new Set(e.map(t=>t.description.trim()).filter(t=>t.length>0)))}function Td(e,t={}){const n=Jf(e.commands);if(n.length===0)return l("settings.opencliSiteDescriptionEmpty");const r=t.maxDescriptions??n.length;return n.slice(0,r).join(" · ")}function Vx(e){return Array.from(new Set(e.map(t=>t.strategy.trim()).filter(t=>t.length>0&&t!=="unknown"))).sort((t,n)=>t.localeCompare(n))}function Qf(e){const t=rw[e.toLowerCase()];if(t)return{label:t.label,style:{background:t.background}};const n=Md[Math.abs(Yx(e))%Md.length];return{label:Kx(e),style:{background:`linear-gradient(135deg, ${n[0]} 0%, ${n[1]} 100%)`}}}function Kx(e){const t=e.split(/[^a-z0-9]+/i).map(r=>r.trim()).filter(r=>r.length>0);if(t.length>=2)return`${t[0][0]??""}${t[1][0]??""}`.toUpperCase();const n=t[0]??e;return n.slice(0,Math.min(2,n.length)).toUpperCase()}function Yx(e){let t=0;for(const n of e)t=(t<<5)-t+n.charCodeAt(0),t|=0;return t}function $o(e){return e instanceof Zc?e.message||l("settings.opencliLoadFailed"):e instanceof Error?e.message:l("settings.opencliLoadFailed")}function Id(e){switch(e){case"installed":return l("settings.opencliInstallInstalled");case"broken":return l("settings.opencliInstallBroken");default:return l("settings.opencliInstallMissing")}}function Xx(e){switch(e){case"ready":return l("settings.opencliHealthReady");case"bridge_missing":return l("settings.opencliHealthBridgeMissing");case"binary_ready":return l("settings.opencliHealthBinaryReady");case"runtime_build_failed":return l("settings.opencliHealthRuntimeBuildFailed");default:return l("settings.opencliHealthUnknown")}}function Jx(e){switch(e){case"manifest":return l("settings.opencliCatalogSourceManifest");case"cli_list":return l("settings.opencliCatalogSourceCliList");case"local_manifest":return l("settings.opencliCatalogSourceLocalManifest");case"cache":return l("settings.opencliCatalogSourceCache");default:return"-"}}function Qx(e){switch(e){case"ready":return l("settings.opencliRuntimeReady");case"failed":return l("settings.opencliRuntimeFailed");case"pending":return l("settings.opencliRuntimePending");case"stale":return l("settings.opencliRuntimeStale");default:return l("settings.opencliRuntimeIdle")}}function Zx(e){return l("settings.opencliStrategyLabel",{strategy:em(e)})}function Zf(e){return l("settings.opencliStrategyShortLabel",{strategy:em(e)})}function em(e){switch(nm(e)){case"cookie":return l("settings.opencliStrategyCookie");case"header":return l("settings.opencliStrategyHeader");case"intercept":return l("settings.opencliStrategyIntercept");case"local":return l("settings.opencliStrategyLocal");case"public":return l("settings.opencliStrategyPublic");case"ui":return l("settings.opencliStrategyUi");default:return l("settings.opencliStrategyUnknown")}}function tm(e){return nm(e)}function nm(e){const t=e.trim().toLowerCase();return t.length>0?t:"unknown"}function ew(e,t){return e==="cache_retained"?l("settings.opencliRefreshCacheRetained"):e==="unavailable"?l("settings.opencliRefreshUnavailable"):t==="ready"?l("settings.opencliRefreshReady"):l("settings.opencliRefreshDone")}function tw(e){return e.runtimeAvailability==="ready"?l("settings.opencliSaveReady"):e.provider.enabled?l("settings.opencliSaveEnabled"):l("settings.opencliSaveDisabled")}function nw(e){return e?e.provider.installState!=="installed"?l("settings.opencliEmptyNotInstalled"):l("settings.opencliEmpty"):l("settings.opencliEmpty")}function Ed(e){if(!e)return"-";const t=Date.parse(e);return Number.isNaN(t)?e:new Date(t).toLocaleString()}const Md=[["#2563eb","#0ea5e9"],["#0f766e","#14b8a6"],["#7c3aed","#6366f1"],["#ea580c","#f59e0b"],["#be123c","#f43f5e"],["#1d4ed8","#38bdf8"]],rw={github:{label:"GH",background:"linear-gradient(135deg, #111827 0%, #374151 100%)"},hackernews:{label:"HN",background:"linear-gradient(135deg, #f97316 0%, #fb923c 100%)"},twitter:{label:"TW",background:"linear-gradient(135deg, #2563eb 0%, #38bdf8 100%)"},x:{label:"X",background:"linear-gradient(135deg, #111827 0%, #6b7280 100%)"},reddit:{label:"RD",background:"linear-gradient(135deg, #f97316 0%, #ef4444 100%)"}},sw=[{id:"skills"},{id:"opencli"}];function iw({triggerClassName:e="secondary-button",triggerLabel:t,triggerLeading:n}){const r=Qc(I=>{var z;return((z=I.session)==null?void 0:z.accessToken)??null}),s=f.useRef(null),[o,a]=f.useState(null),[c,u]=f.useState(!1),[d,p]=f.useState(null),[h,m]=f.useState(null),[g,y]=f.useState(null),[S,C]=f.useState(!1),[x,A]=f.useState(!1),[j,G]=f.useState(null),[P,T]=f.useState("file"),[K,U]=f.useState("workspace"),[L,E]=f.useState(""),[$,B]=f.useState(()=>Ri("workspace")),[re,X]=f.useState("skills"),[F,q]=f.useState(null),D=f.useId(),te=Ck(S&&!!r).items??[],v=f.useMemo(()=>pw(te),[te]);f.useEffect(()=>{let I=!0;if(!S)return;if(!r){a(null),m(null),y(null),u(!1);return}return(async()=>{u(!0);try{const ie=await Sd();if(!I)return;a(ie),m(null)}catch(ie){if(!I)return;m(_s(ie))}finally{I&&u(!1)}})(),()=>{I=!1}},[r,S]);async function je(){const I=await Sd();a(I),m(null)}async function Te(){if(r){p("refresh"),m(null),y(null);try{await je(),y(l("settings.skillRefreshSuccess"))}catch(I){m(_s(I))}finally{p(null)}}}async function N(I){if(r){p(Rd(I)),m(null),y(null);try{await _x({targetCli:I.targetCli,directoryPath:I.directoryPath,expectedContentHash:I.contentHash}),await je(),y(l("settings.skillImportSuccess",{name:I.name,target:gn(I.targetCli)}))}catch(z){m(_s(z))}finally{p(null)}}}async function de(I){if(!r)return;const z=I.bindings.filter(ie=>ie.enabled).map(ie=>ie.targetCli).filter(ie=>Vt(ie,v));if(z.length===0){m(ww(I.bindings));return}p(Ad(I.skill.id)),m(null),y(null);try{await Dx({skillId:I.skill.id,targetCli:z}),await je(),y(l("settings.skillSyncSuccess",{name:I.skill.name}))}catch(ie){m(_s(ie))}finally{p(null)}}async function Ie(I){var ie;const z=((ie=I.target.files)==null?void 0:ie[0])??null;if(I.target.value="",!!z){m(null),y(null);try{const ue=await Iw(z),we=im(z.name,ue);G(we),B(Ri(K,v))}catch(ue){m(_s(ue))}}}async function he(){const I=Pd({sourceMode:P,fileDraft:j,pastedMarkdown:L});if(!r)return;if(!I){m(P==="paste"?l("settings.skillPasteEmpty"):l("settings.skillUploadEmpty"));return}const z=I.directoryName;if(!z){m(l("settings.skillUploadDirectoryInvalid"));return}const ie=Na(K).filter(ue=>$[ue]).filter(ue=>Vt(ue,v)).map(ue=>ue);if(ie.length===0){m(vw(K,v));return}p("upload"),m(null),y(null);try{await Lx({markdownContent:I.rawContent,scope:K,fileName:I.fileName,directoryName:z,targetCli:ie}),await je(),y(l("settings.skillUploadSuccess",{name:z})),W(K),A(!1)}catch(ue){m(_s(ue))}finally{p(null)}}function le(I){U(I),B(Ri(I,v))}function Fe(I){T(I),G(null),E(""),B(Ri(K,v)),m(null)}function Ue(I){Vt(I,v)&&B(z=>({...z,[I]:!z[I]}))}function _e(){A(!0),m(null),W(K)}function qe(){A(!1),m(null),W(K)}function W(I){G(null),E(""),T("file"),B(Ri(I,v))}const Y=(o==null?void 0:o.summary)??{managedSkillCount:0,managedEntryCount:0},se=Nw((o==null?void 0:o.assistantRuntimeSkills)??[],(o==null?void 0:o.conflictedEntries)??[],(o==null?void 0:o.diagnostics)??[]),Ce=((o==null?void 0:o.conflictedEntries)??[]).filter(I=>!sm(I,(o==null?void 0:o.diagnostics)??[])),ve=((o==null?void 0:o.diagnostics)??[]).filter(I=>!uo(I)),fe=Pd({sourceMode:P,fileDraft:j,pastedMarkdown:L}),ht=t??l("settings.skillManageAction"),Ke=re==="skills",st=re==="opencli";return i.jsxs(i.Fragment,{children:[i.jsxs("button",{className:e,type:"button","data-open":S?"true":"false","aria-haspopup":"dialog","aria-expanded":S,onClick:()=>{X("skills"),C(!0)},children:[n,i.jsx("span",{children:ht})]}),i.jsxs(Et,{open:S,title:l("settings.skillConfigModalTitle"),hideHeader:!0,className:"settings-skill-modal",onClose:()=>{X("skills"),C(!1)},children:[i.jsxs("div",{className:"settings-skill-modal-topbar",children:[i.jsxs("div",{className:"settings-skill-modal-topbar-main",children:[i.jsx("div",{className:"settings-model-tabs settings-skill-tabs",role:"tablist","aria-label":l("settings.skillConfigTabsLabel"),children:sw.map(I=>{const z=re===I.id,ie=`${D}-${I.id}-tab`,ue=`${D}-${I.id}-panel`;return i.jsx("button",{id:ie,type:"button",role:"tab",className:"settings-model-tab","aria-selected":z,"aria-controls":ue,"data-active":z?"true":"false",onClick:()=>X(I.id),children:Rw(I.id)},I.id)})}),Ke?i.jsxs("div",{className:"settings-skill-modal-actions settings-skill-page-toolbar",children:[i.jsx("button",{className:"secondary-button",type:"button",disabled:!r||c||d!==null,onClick:_e,children:l("settings.skillCreateAction")}),i.jsx("button",{className:"secondary-button",type:"button",disabled:!r||c||d!==null,onClick:()=>{Te()},children:d==="refresh"?l("common.loading"):l("settings.skillRefresh")})]}):null,st&&F?i.jsxs("div",{className:"settings-skill-modal-actions settings-skill-page-toolbar settings-opencli-toolbar",children:[i.jsxs("label",{className:"settings-opencli-checkbox settings-opencli-toolbar-toggle",children:[i.jsx("input",{"aria-label":l("settings.opencliProviderToggleLabel"),type:"checkbox",checked:F.draftEnabled,disabled:F.enableDisabled,onChange:I=>F.onEnabledChange(I.target.checked)}),i.jsx("span",{children:l("settings.opencliEnableAction")})]}),i.jsx("button",{className:"secondary-button",type:"button",disabled:F.refreshDisabled,onClick:F.onRefresh,children:F.refreshing?l("common.loading"):l("settings.opencliRefreshAction")}),i.jsx("button",{className:"secondary-button",type:"button",disabled:F.detailDisabled,onClick:F.onShowDetails,children:l("settings.opencliDetailAction")}),i.jsx("button",{className:"primary-button",type:"button",disabled:F.saveDisabled,onClick:F.onSave,children:F.saving?l("common.loading"):l("settings.opencliSaveAction")})]}):null]}),i.jsx(Zk,{onClick:()=>{X("skills"),C(!1)}})]}),Ke?i.jsxs("div",{id:`${D}-skills-panel`,role:"tabpanel","aria-labelledby":`${D}-skills-tab`,className:"settings-skill-panel",children:[i.jsxs("section",{className:"settings-skill-summary-block",children:[i.jsxs("div",{className:"settings-skill-summary-grid",children:[i.jsx(zo,{label:l("settings.skillSummaryManagedSkills"),value:String(Y.managedSkillCount)}),i.jsx(zo,{label:l("settings.skillSummaryManagedEntries"),value:String(Y.managedEntryCount)}),i.jsx(zo,{label:l("settings.skillSummaryConflictedEntries"),value:String(Ce.length)}),i.jsx(zo,{label:l("settings.skillSummaryDiagnostics"),value:String(ve.length)})]}),i.jsx("div",{className:"settings-release-meta",children:i.jsxs("span",{children:[l("settings.skillScannedAt"),": ",c?l("common.loading"):Cw(o==null?void 0:o.scannedAt)]})}),g?i.jsx("p",{className:"settings-release-status",children:g}):null,h?i.jsx("p",{className:"settings-release-status",children:h}):null]}),i.jsx(Mi,{title:l("settings.skillManagedListTitle"),emptyText:l("settings.skillManagedEmpty"),items:(o==null?void 0:o.managedSkills)??[],renderItem:I=>{const z=Ad(I.skill.id);return i.jsxs("div",{className:"settings-skill-entry",children:[i.jsxs("div",{className:"settings-skill-entry-main",children:[i.jsx("strong",{className:"settings-skill-entry-title",children:I.skill.name}),i.jsx("p",{className:"settings-skill-entry-meta",children:kw(I.bindings)}),i.jsx("div",{className:"settings-skill-tags",children:I.bindings.map(ie=>i.jsx("span",{className:"settings-skill-tag","data-status":gw(ie,v),children:bw(ie,v)},`${I.skill.id}-${ie.targetCli}`))})]}),i.jsx("div",{className:"settings-skill-entry-actions",children:i.jsx("button",{className:"secondary-button",type:"button",disabled:c||d!==null||!mw(I.bindings,v),onClick:()=>{de(I)},children:d===z?l("common.loading"):l("settings.skillSyncAction")})})]},I.skill.id)}}),i.jsx(Mi,{title:l("settings.skillUnmanagedListTitle"),emptyText:l("settings.skillUnmanagedEmpty"),items:(o==null?void 0:o.unmanagedEntries)??[],renderItem:I=>{const z=Rd(I);return i.jsxs("div",{className:"settings-skill-entry",children:[i.jsxs("div",{className:"settings-skill-entry-main",children:[i.jsx("strong",{className:"settings-skill-entry-title",children:I.name}),i.jsx("p",{className:"settings-skill-entry-meta",children:yw(I,v)}),Vt(I.targetCli,v)?null:i.jsx("div",{className:"settings-skill-tags",children:i.jsx("span",{className:"settings-skill-tag","data-status":"failed",children:l("settings.skillTargetDisabledTag")})})]}),i.jsx("div",{className:"settings-skill-entry-actions",children:i.jsx("button",{className:"secondary-button",type:"button",disabled:c||d!==null||!Vt(I.targetCli,v),onClick:()=>{N(I)},children:d===z?l("common.loading"):l("settings.skillImportAction")})})]},`${I.targetCli}:${I.directoryPath}`)}}),i.jsx(Mi,{title:l("settings.skillAssistantRuntimeListTitle"),description:l("settings.skillAssistantRuntimeListDescription"),emptyText:l("settings.skillAssistantRuntimeEmpty"),items:se,renderItem:I=>i.jsx("div",{className:"settings-skill-entry",children:i.jsxs("div",{className:"settings-skill-entry-main",children:[i.jsx("strong",{className:"settings-skill-entry-title",children:I.name}),i.jsx("p",{className:"settings-skill-entry-meta",children:l("settings.skillAssistantRuntimeItemDescription")}),i.jsxs("p",{className:"settings-skill-entry-meta",children:[l("settings.skillAssistantRuntimeUsedBy"),": ",rm(I.usedByTargetCli)]}),i.jsxs("div",{className:"settings-skill-tags",children:[i.jsx("span",{className:"settings-skill-tag","data-status":"assistant-runtime",children:l("settings.skillTagAssistantOnly")}),I.usedByTargetCli.map(z=>i.jsx("span",{className:"settings-skill-tag","data-status":Vt(z,v)?"synced":"failed",children:Vt(z,v)?gn(z):`${gn(z)} · ${l("settings.skillTargetDisabledTag")}`},`${I.directoryName}:${z}`))]})]})},`${I.directoryName}:${I.sourcePath}`)}),i.jsx(Mi,{title:l("settings.skillConflictedListTitle"),emptyText:l("settings.skillConflictedEmpty"),items:Ce,renderItem:I=>{const z=jw(I,(o==null?void 0:o.diagnostics)??[]);return i.jsx("div",{className:"settings-skill-entry",children:i.jsxs("div",{className:"settings-skill-entry-main",children:[i.jsx("strong",{className:"settings-skill-entry-title",children:I.name}),i.jsx("p",{className:"settings-skill-entry-meta",children:xw(I,v)}),z.length>0?i.jsx("div",{className:"settings-skill-tags",children:z.map(ie=>i.jsx("span",{className:"settings-skill-tag","data-status":ie.status,children:ie.label},ie.key))}):null]})},`${I.targetCli}:${I.directoryPath}`)}}),i.jsx(Mi,{title:l("settings.skillDiagnosticsTitle"),emptyText:l("settings.skillDiagnosticsEmpty"),items:ve,renderItem:I=>{const z=Tw(I),ie=Sw(I);return i.jsx("div",{className:"settings-skill-entry",children:i.jsxs("div",{className:"settings-skill-entry-main",children:[i.jsx("strong",{className:"settings-skill-entry-title",children:ie.title}),i.jsx("p",{className:"settings-skill-entry-meta",children:ie.detail}),z.length>0?i.jsx("div",{className:"settings-skill-tags",children:z.map(ue=>i.jsx("span",{className:"settings-skill-tag","data-status":ue.status,children:ue.label},ue.key))}):null]})},`${I.targetCli}:${I.code}:${I.directoryPath??I.rootDir}`)}})]}):i.jsx("div",{id:`${D}-opencli-panel`,role:"tabpanel","aria-labelledby":`${D}-opencli-tab`,className:"settings-skill-panel",children:i.jsx(Wx,{toolbarMode:"external",onToolbarStateChange:q})})]}),i.jsx(Et,{open:x,title:l("settings.skillCreateModalTitle"),description:l("settings.skillCreateModalDescription"),className:"settings-skill-create-modal",onClose:qe,children:i.jsxs("section",{className:"settings-skill-section",children:[i.jsx("h3",{className:"settings-skill-section-title",children:l("settings.skillUploadSectionTitle")}),i.jsx("p",{className:"settings-skill-section-description",children:l("settings.skillUploadSectionDescription")}),i.jsxs("div",{className:"settings-skill-create-panel",children:[i.jsx("input",{ref:s,type:"file",accept:".md,text/markdown,text/plain",className:"settings-skill-upload-input",onChange:I=>{Ie(I)}}),i.jsx("div",{className:"settings-model-tabs",role:"tablist","aria-label":l("settings.skillCreateSourceTabsLabel"),children:cw.map(I=>{const z=P===I;return i.jsx("button",{type:"button",role:"tab",className:"settings-model-tab","aria-selected":z,"data-active":z?"true":"false",onClick:()=>Fe(I),children:dw(I)},I)})}),i.jsx("div",{className:"settings-skill-upload-targets",role:"radiogroup","aria-label":l("settings.skillUploadScopeLabel"),children:lw.map(I=>i.jsxs("label",{className:"settings-skill-upload-target","data-selected":K===I?"true":"false",children:[i.jsx("input",{type:"radio",name:"skill-upload-scope",checked:K===I,onChange:()=>le(I)}),i.jsx("span",{children:uw(I)})]},I))}),P==="file"?i.jsx("div",{className:"settings-skill-create-toolbar",children:i.jsx("button",{className:"secondary-button",type:"button",disabled:c||d!==null,onClick:()=>{var I;(I=s.current)==null||I.click()},children:l("settings.skillUploadPickAction")})}):i.jsxs("label",{className:"settings-skill-upload-field",children:[i.jsx("span",{children:l("settings.skillPasteLabel")}),i.jsx("textarea",{className:"settings-skill-create-textarea",value:L,onChange:I=>E(I.target.value),placeholder:l("settings.skillPastePlaceholder")})]}),fe?i.jsx("div",{className:"settings-skill-entry",children:i.jsxs("div",{className:"settings-skill-entry-main",children:[i.jsx("strong",{className:"settings-skill-entry-title",children:fe.previewTitle}),i.jsxs("p",{className:"settings-skill-entry-meta",children:[l("settings.skillUploadPickedFile"),": ",fe.fileName]})]})}):i.jsx("div",{className:"settings-skill-empty",children:P==="paste"?l("settings.skillPasteEmpty"):l("settings.skillUploadEmpty")}),i.jsxs("div",{className:"settings-skill-upload-field",children:[i.jsx("span",{children:l("settings.skillUploadTargetsLabel")}),i.jsx("div",{className:"settings-skill-upload-targets",children:Na(K).map(I=>i.jsxs("label",{className:"settings-skill-upload-target","data-selected":$[I]?"true":"false",children:[i.jsx("input",{type:"checkbox",checked:$[I],disabled:!Vt(I,v),onChange:()=>Ue(I)}),i.jsx("span",{children:Vt(I,v)?gn(I):`${gn(I)} · ${l("settings.skillTargetDisabledTag")}`})]},I))})]}),fe!=null&&fe.notes.length?i.jsx("div",{className:"settings-skill-tags",children:fe.notes.map((I,z)=>i.jsx("span",{className:"settings-skill-tag","data-status":"pending",children:I},`${fe.fileName}:${z}`))}):null,h?i.jsx("p",{className:"settings-release-status",children:h}):null,i.jsx("div",{className:"settings-skill-create-actions",children:i.jsx("button",{className:"primary-button",type:"button",disabled:c||d!==null,onClick:()=>{he()},children:d==="upload"?l("common.loading"):l("settings.skillCreateSubmitAction")})})]})]})})]})}function Mi({title:e,description:t,emptyText:n,items:r,renderItem:s}){return i.jsxs("section",{className:"settings-skill-section",children:[i.jsx("h3",{className:"settings-skill-section-title",children:e}),t?i.jsx("p",{className:"settings-skill-section-description",children:t}):null,r.length>0?i.jsx("div",{className:"settings-skill-entry-list",children:r.map(o=>s(o))}):i.jsx("div",{className:"settings-skill-empty",children:n})]})}function zo({label:e,value:t}){return i.jsxs("div",{className:"settings-skill-summary-card",children:[i.jsx("span",{children:e}),i.jsx("strong",{children:t})]})}function Rd(e){return`import:${e.targetCli}:${e.directoryPath}`}function Ad(e){return`sync:${e}`}const ow=["codex","claude-code","gemini","opencode"],aw=["codex","claude-code"],lw=["workspace","assistant"],cw=["file","paste"];function _s(e){return e instanceof Zc?e.message||l("settings.skillLoadFailed"):e instanceof Error?e.message:l("settings.skillLoadFailed")}function gn(e){switch(e){case"claude-code":return l("settings.skillTargetClaudeCode");case"gemini":return l("settings.skillTargetGemini");case"opencode":return l("settings.skillTargetOpenCode");default:return l("settings.skillTargetCodex")}}function uw(e){return e==="assistant"?l("settings.skillUploadScopeAssistant"):l("settings.skillUploadScopeWorkspace")}function dw(e){return e==="paste"?l("settings.skillCreateSourcePaste"):l("settings.skillCreateSourceFile")}function Ri(e,t={}){const r=Na(e).filter(s=>Vt(s,t))[0]??null;return{codex:r==="codex","claude-code":r==="claude-code",gemini:r==="gemini",opencode:r==="opencode"}}function Na(e){return e==="assistant"?aw:ow}function Pd({sourceMode:e,fileDraft:t,pastedMarkdown:n}){return e==="file"?t:n.trim()?im(Ew(n),n):null}function hw(e){switch(e){case"conflicted":return l("settings.skillBindingConflicted");case"failed":return l("settings.skillBindingFailed");case"pending":return l("settings.skillBindingPending");default:return l("settings.skillBindingSynced")}}function pw(e){const t={};for(const n of e){const r=fw(n.provider);r&&(t[r]=n)}return t}function fw(e){switch(e){case"claude-code":return"claude-code";case"codex":return"codex";case"gemini":return"gemini";case"opencode":return"opencode";default:return null}}function Vt(e,t){var n;return((n=t[e])==null?void 0:n.enabled)!==!1}function mw(e,t){return e.some(n=>n.enabled&&Vt(n.targetCli,t))}function gw(e,t){return Vt(e.targetCli,t)?e.syncStatus:"failed"}function bw(e,t){return Vt(e.targetCli,t)?`${gn(e.targetCli)} · ${hw(e.syncStatus)}`:`${gn(e.targetCli)} · ${l("settings.skillTargetDisabledTag")}`}function rm(e){return e.map(gn).join(" / ")}function kw(e){const t=e.filter(n=>n.enabled);return t.length===0?l("settings.skillManagedItemNoTarget"):l("settings.skillManagedItemDescription",{targets:rm(t.map(n=>n.targetCli))})}function yw(e,t){return Vt(e.targetCli,t)?l("settings.skillUnmanagedItemDescription",{target:gn(e.targetCli)}):l("settings.skillUnmanagedItemDisabledDescription",{target:gn(e.targetCli)})}function xw(e,t){return Vt(e.targetCli,t)?l("settings.skillConflictedItemDescription",{target:gn(e.targetCli)}):l("settings.skillConflictedItemDisabledDescription",{target:gn(e.targetCli)})}function ww(e,t){return e.some(r=>r.enabled)?l("settings.skillSyncTargetDisabled"):l("settings.skillSyncTargetMissing")}function vw(e,t){return Na(e).some(r=>Vt(r,t))?l("settings.skillUploadTargetRequired"):l("settings.skillUploadTargetDisabled")}function Sw(e){const t=gn(e.targetCli);switch(e.code){case"SKILL_TARGET_ROOT_MISSING":return{title:l("settings.skillDiagnosticTargetMissingTitle",{target:t}),detail:l("settings.skillDiagnosticTargetMissingDetail",{target:t})};case"SKILL_TARGET_ROOT_INVALID":case"SKILL_TARGET_STAT_FAILED":case"SKILL_TARGET_READ_FAILED":return{title:l("settings.skillDiagnosticReadFailedTitle",{target:t}),detail:l("settings.skillDiagnosticReadFailedDetail",{target:t})};case"SKILL_TARGET_SKILL_MISSING":return{title:l("settings.skillDiagnosticSyncMissingTitle",{target:t}),detail:l("settings.skillDiagnosticSyncMissingDetail",{target:t})};default:return{title:l("settings.skillDiagnosticGenericTitle",{target:t}),detail:l("settings.skillDiagnosticGenericDetail",{target:t})}}}function Cw(e){if(!e)return"-";const t=Date.parse(e);return Number.isNaN(t)?e:new Date(t).toLocaleString()}function Nw(e,t,n){if(e.length>0)return e.map(s=>({name:s.name,directoryName:s.directoryName,sourcePath:s.sourcePath,usedByTargetCli:s.usedByTargetCli}));const r=new Map;for(const s of t)sm(s,n)&&r.set(Ld(s.targetCli,s.directoryPath),{name:s.name,directoryName:s.directoryName,sourcePath:s.directoryPath,usedByTargetCli:[s.targetCli]});for(const s of n){if(!uo(s))continue;const o=s.directoryPath??s.rootDir,a=Ld(s.targetCli,o);r.has(a)||r.set(a,{name:s.directoryName??"codingns-assistant",directoryName:s.directoryName??"codingns-assistant",sourcePath:o,usedByTargetCli:[s.targetCli]})}return[...r.values()]}function Ld(e,t){return`${e}:${t}`}function sm(e,t){return t.some(n=>uo(n)&&n.targetCli===e.targetCli&&n.directoryPath===e.directoryPath&&n.directoryName===e.directoryName)}function uo(e){return e.code==="SKILL_RESERVED_FOR_ASSISTANT_RUNTIME"}function jw(e,t){return t.find(r=>uo(r)&&r.targetCli===e.targetCli&&r.directoryName===e.directoryName&&r.directoryPath===e.directoryPath)?[{key:`assistant-runtime:${e.targetCli}:${e.directoryPath}`,label:l("settings.skillTagAssistantOnly"),status:"assistant-runtime"}]:[]}function Tw(e){return uo(e)?[{key:`assistant-runtime:${e.targetCli}:${e.directoryPath??e.rootDir}`,label:l("settings.skillTagAssistantOnly"),status:"assistant-runtime"}]:[]}function im(e,t){const n=[],r=t.replace(/^\uFEFF/,"").replace(/\r\n?/g,`
|
|
4
|
+
`).trim();if(!r)throw new Error(l("settings.skillUploadContentEmpty"));r!==t.trim()&&n.push(l("settings.skillUploadNormalizedNote"));const s=om(r),o=vc(e)??vc(s)??"";return o||n.push(l("settings.skillUploadDirectoryRequiredNote")),s||n.push(l("settings.skillUploadHeadingNote")),{fileName:e,rawContent:r,directoryName:o,previewTitle:s||Mw(o||"skill"),notes:n}}async function Iw(e){if(typeof e.text=="function")return await e.text();if(typeof FileReader>"u")throw new Error(l("settings.skillUploadReadFailed"));return await new Promise((t,n)=>{const r=new FileReader;r.onerror=()=>{n(r.error??new Error(l("settings.skillUploadReadFailed")))},r.onload=()=>{if(typeof r.result=="string"){t(r.result);return}n(new Error(l("settings.skillUploadReadFailed")))},r.readAsText(e)})}function vc(e){const r=(e.replace(/\\/g,"/").split("/").pop()??e).replace(/\.[A-Za-z0-9]+$/,"").trim().replace(/\s+/g,"-").replace(/[^A-Za-z0-9._-]+/g,"-").replace(/-+/g,"-").replace(/^[-._]+|[-._]+$/g,"").toLowerCase();return r.length>0?r:null}function Ew(e){const t=vc(om(e));return t?`${t}.md`:"pasted-skill.md"}function om(e){var t,n;return((n=(t=e.match(/^#\s+(.+)$/m))==null?void 0:t[1])==null?void 0:n.trim())??""}function Mw(e){return e.split(/[._-]+/).filter(Boolean).map(n=>n.charAt(0).toUpperCase()+n.slice(1)).join(" ")||e}function Rw(e){switch(e){case"opencli":return l("settings.skillConfigTabOpenCli");default:return l("settings.skillConfigTabSkills")}}function Aw(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const Pw=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Lw=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,_w={};function _d(e,t){return(_w.jsx?Lw:Pw).test(e)}const Dw=/[ \t\n\f\r]/g;function Bw(e){return typeof e=="object"?e.type==="text"?Dd(e.value):!1:Dd(e)}function Dd(e){return e.replace(Dw,"")===""}class ho{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}ho.prototype.normal={};ho.prototype.property={};ho.prototype.space=void 0;function am(e,t){const n={},r={};for(const s of e)Object.assign(n,s.property),Object.assign(r,s.normal);return new ho(n,r,t)}function Sc(e){return e.toLowerCase()}class cn{constructor(t,n){this.attribute=n,this.property=t}}cn.prototype.attribute="";cn.prototype.booleanish=!1;cn.prototype.boolean=!1;cn.prototype.commaOrSpaceSeparated=!1;cn.prototype.commaSeparated=!1;cn.prototype.defined=!1;cn.prototype.mustUseProperty=!1;cn.prototype.number=!1;cn.prototype.overloadedBoolean=!1;cn.prototype.property="";cn.prototype.spaceSeparated=!1;cn.prototype.space=void 0;let Ow=0;const Oe=ms(),Rt=ms(),Cc=ms(),oe=ms(),bt=ms(),ni=ms(),pn=ms();function ms(){return 2**++Ow}const Nc=Object.freeze(Object.defineProperty({__proto__:null,boolean:Oe,booleanish:Rt,commaOrSpaceSeparated:pn,commaSeparated:ni,number:oe,overloadedBoolean:Cc,spaceSeparated:bt},Symbol.toStringTag,{value:"Module"})),Rl=Object.keys(Nc);class yu extends cn{constructor(t,n,r,s){let o=-1;if(super(t,n),Bd(this,"space",s),typeof r=="number")for(;++o<Rl.length;){const a=Rl[o];Bd(this,Rl[o],(r&Nc[a])===Nc[a])}}}yu.prototype.defined=!0;function Bd(e,t,n){n&&(e[t]=n)}function ui(e){const t={},n={};for(const[r,s]of Object.entries(e.properties)){const o=new yu(r,e.transform(e.attributes||{},r),s,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(o.mustUseProperty=!0),t[r]=o,n[Sc(r)]=r,n[Sc(o.attribute)]=r}return new ho(t,n,e.space)}const lm=ui({properties:{ariaActiveDescendant:null,ariaAtomic:Rt,ariaAutoComplete:null,ariaBusy:Rt,ariaChecked:Rt,ariaColCount:oe,ariaColIndex:oe,ariaColSpan:oe,ariaControls:bt,ariaCurrent:null,ariaDescribedBy:bt,ariaDetails:null,ariaDisabled:Rt,ariaDropEffect:bt,ariaErrorMessage:null,ariaExpanded:Rt,ariaFlowTo:bt,ariaGrabbed:Rt,ariaHasPopup:null,ariaHidden:Rt,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:bt,ariaLevel:oe,ariaLive:null,ariaModal:Rt,ariaMultiLine:Rt,ariaMultiSelectable:Rt,ariaOrientation:null,ariaOwns:bt,ariaPlaceholder:null,ariaPosInSet:oe,ariaPressed:Rt,ariaReadOnly:Rt,ariaRelevant:null,ariaRequired:Rt,ariaRoleDescription:bt,ariaRowCount:oe,ariaRowIndex:oe,ariaRowSpan:oe,ariaSelected:Rt,ariaSetSize:oe,ariaSort:null,ariaValueMax:oe,ariaValueMin:oe,ariaValueNow:oe,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function cm(e,t){return t in e?e[t]:t}function um(e,t){return cm(e,t.toLowerCase())}const Ww=ui({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:ni,acceptCharset:bt,accessKey:bt,action:null,allow:null,allowFullScreen:Oe,allowPaymentRequest:Oe,allowUserMedia:Oe,alt:null,as:null,async:Oe,autoCapitalize:null,autoComplete:bt,autoFocus:Oe,autoPlay:Oe,blocking:bt,capture:null,charSet:null,checked:Oe,cite:null,className:bt,cols:oe,colSpan:null,content:null,contentEditable:Rt,controls:Oe,controlsList:bt,coords:oe|ni,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Oe,defer:Oe,dir:null,dirName:null,disabled:Oe,download:Cc,draggable:Rt,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Oe,formTarget:null,headers:bt,height:oe,hidden:Cc,high:oe,href:null,hrefLang:null,htmlFor:bt,httpEquiv:bt,id:null,imageSizes:null,imageSrcSet:null,inert:Oe,inputMode:null,integrity:null,is:null,isMap:Oe,itemId:null,itemProp:bt,itemRef:bt,itemScope:Oe,itemType:bt,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:Oe,low:oe,manifest:null,max:null,maxLength:oe,media:null,method:null,min:null,minLength:oe,multiple:Oe,muted:Oe,name:null,nonce:null,noModule:Oe,noValidate:Oe,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:Oe,optimum:oe,pattern:null,ping:bt,placeholder:null,playsInline:Oe,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Oe,referrerPolicy:null,rel:bt,required:Oe,reversed:Oe,rows:oe,rowSpan:oe,sandbox:bt,scope:null,scoped:Oe,seamless:Oe,selected:Oe,shadowRootClonable:Oe,shadowRootDelegatesFocus:Oe,shadowRootMode:null,shape:null,size:oe,sizes:null,slot:null,span:oe,spellCheck:Rt,src:null,srcDoc:null,srcLang:null,srcSet:null,start:oe,step:null,style:null,tabIndex:oe,target:null,title:null,translate:null,type:null,typeMustMatch:Oe,useMap:null,value:Rt,width:oe,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:bt,axis:null,background:null,bgColor:null,border:oe,borderColor:null,bottomMargin:oe,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:Oe,declare:Oe,event:null,face:null,frame:null,frameBorder:null,hSpace:oe,leftMargin:oe,link:null,longDesc:null,lowSrc:null,marginHeight:oe,marginWidth:oe,noResize:Oe,noHref:Oe,noShade:Oe,noWrap:Oe,object:null,profile:null,prompt:null,rev:null,rightMargin:oe,rules:null,scheme:null,scrolling:Rt,standby:null,summary:null,text:null,topMargin:oe,valueType:null,version:null,vAlign:null,vLink:null,vSpace:oe,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:Oe,disableRemotePlayback:Oe,prefix:null,property:null,results:oe,security:null,unselectable:null},space:"html",transform:um}),Fw=ui({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:pn,accentHeight:oe,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:oe,amplitude:oe,arabicForm:null,ascent:oe,attributeName:null,attributeType:null,azimuth:oe,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:oe,by:null,calcMode:null,capHeight:oe,className:bt,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:oe,diffuseConstant:oe,direction:null,display:null,dur:null,divisor:oe,dominantBaseline:null,download:Oe,dx:null,dy:null,edgeMode:null,editable:null,elevation:oe,enableBackground:null,end:null,event:null,exponent:oe,externalResourcesRequired:null,fill:null,fillOpacity:oe,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:ni,g2:ni,glyphName:ni,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:oe,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:oe,horizOriginX:oe,horizOriginY:oe,id:null,ideographic:oe,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:oe,k:oe,k1:oe,k2:oe,k3:oe,k4:oe,kernelMatrix:pn,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:oe,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:oe,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:oe,overlineThickness:oe,paintOrder:null,panose1:null,path:null,pathLength:oe,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:bt,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:oe,pointsAtY:oe,pointsAtZ:oe,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:pn,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:pn,rev:pn,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:pn,requiredFeatures:pn,requiredFonts:pn,requiredFormats:pn,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:oe,specularExponent:oe,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:oe,strikethroughThickness:oe,string:null,stroke:null,strokeDashArray:pn,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:oe,strokeOpacity:oe,strokeWidth:null,style:null,surfaceScale:oe,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:pn,tabIndex:oe,tableValues:null,target:null,targetX:oe,targetY:oe,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:pn,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:oe,underlineThickness:oe,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:oe,values:null,vAlphabetic:oe,vMathematical:oe,vectorEffect:null,vHanging:oe,vIdeographic:oe,version:null,vertAdvY:oe,vertOriginX:oe,vertOriginY:oe,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:oe,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:cm}),dm=ui({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}}),hm=ui({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:um}),pm=ui({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),$w={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},zw=/[A-Z]/g,Od=/-[a-z]/g,Hw=/^data[-\w.:]+$/i;function Uw(e,t){const n=Sc(t);let r=t,s=cn;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&Hw.test(t)){if(t.charAt(4)==="-"){const o=t.slice(5).replace(Od,Gw);r="data"+o.charAt(0).toUpperCase()+o.slice(1)}else{const o=t.slice(4);if(!Od.test(o)){let a=o.replace(zw,qw);a.charAt(0)!=="-"&&(a="-"+a),t="data"+a}}s=yu}return new s(r,t)}function qw(e){return"-"+e.toLowerCase()}function Gw(e){return e.charAt(1).toUpperCase()}const Vw=am([lm,Ww,dm,hm,pm],"html"),xu=am([lm,Fw,dm,hm,pm],"svg");function Kw(e){return e.join(" ").trim()}var Ds={},Al,Wd;function Yw(){if(Wd)return Al;Wd=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,n=/^\s*/,r=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,s=/^:\s*/,o=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,a=/^[;\s]*/,c=/^\s+|\s+$/g,u=`
|
|
5
|
+
`,d="/",p="*",h="",m="comment",g="declaration";function y(C,x){if(typeof C!="string")throw new TypeError("First argument must be a string");if(!C)return[];x=x||{};var A=1,j=1;function G(X){var F=X.match(t);F&&(A+=F.length);var q=X.lastIndexOf(u);j=~q?X.length-q:j+X.length}function P(){var X={line:A,column:j};return function(F){return F.position=new T(X),L(),F}}function T(X){this.start=X,this.end={line:A,column:j},this.source=x.source}T.prototype.content=C;function K(X){var F=new Error(x.source+":"+A+":"+j+": "+X);if(F.reason=X,F.filename=x.source,F.line=A,F.column=j,F.source=C,!x.silent)throw F}function U(X){var F=X.exec(C);if(F){var q=F[0];return G(q),C=C.slice(q.length),F}}function L(){U(n)}function E(X){var F;for(X=X||[];F=$();)F!==!1&&X.push(F);return X}function $(){var X=P();if(!(d!=C.charAt(0)||p!=C.charAt(1))){for(var F=2;h!=C.charAt(F)&&(p!=C.charAt(F)||d!=C.charAt(F+1));)++F;if(F+=2,h===C.charAt(F-1))return K("End of comment missing");var q=C.slice(2,F-2);return j+=2,G(q),C=C.slice(F),j+=2,X({type:m,comment:q})}}function B(){var X=P(),F=U(r);if(F){if($(),!U(s))return K("property missing ':'");var q=U(o),D=X({type:g,property:S(F[0].replace(e,h)),value:q?S(q[0].replace(e,h)):h});return U(a),D}}function re(){var X=[];E(X);for(var F;F=B();)F!==!1&&(X.push(F),E(X));return X}return L(),re()}function S(C){return C?C.replace(c,h):h}return Al=y,Al}var Fd;function Xw(){if(Fd)return Ds;Fd=1;var e=Ds&&Ds.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(Ds,"__esModule",{value:!0}),Ds.default=n;const t=e(Yw());function n(r,s){let o=null;if(!r||typeof r!="string")return o;const a=(0,t.default)(r),c=typeof s=="function";return a.forEach(u=>{if(u.type!=="declaration")return;const{property:d,value:p}=u;c?s(d,p,u):p&&(o=o||{},o[d]=p)}),o}return Ds}var Ai={},$d;function Jw(){if($d)return Ai;$d=1,Object.defineProperty(Ai,"__esModule",{value:!0}),Ai.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,t=/-([a-z])/g,n=/^[^-]+$/,r=/^-(webkit|moz|ms|o|khtml)-/,s=/^-(ms)-/,o=function(d){return!d||n.test(d)||e.test(d)},a=function(d,p){return p.toUpperCase()},c=function(d,p){return"".concat(p,"-")},u=function(d,p){return p===void 0&&(p={}),o(d)?d:(d=d.toLowerCase(),p.reactCompat?d=d.replace(s,c):d=d.replace(r,c),d.replace(t,a))};return Ai.camelCase=u,Ai}var Pi,zd;function Qw(){if(zd)return Pi;zd=1;var e=Pi&&Pi.__importDefault||function(s){return s&&s.__esModule?s:{default:s}},t=e(Xw()),n=Jw();function r(s,o){var a={};return!s||typeof s!="string"||(0,t.default)(s,function(c,u){c&&u&&(a[(0,n.camelCase)(c,o)]=u)}),a}return r.default=r,Pi=r,Pi}var Zw=Qw();const ev=uf(Zw),fm=mm("end"),wu=mm("start");function mm(e){return t;function t(n){const r=n&&n.position&&n.position[e]||{};if(typeof r.line=="number"&&r.line>0&&typeof r.column=="number"&&r.column>0)return{line:r.line,column:r.column,offset:typeof r.offset=="number"&&r.offset>-1?r.offset:void 0}}}function tv(e){const t=wu(e),n=fm(e);if(t&&n)return{start:t,end:n}}function Gi(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?Hd(e.position):"start"in e||"end"in e?Hd(e):"line"in e||"column"in e?jc(e):""}function jc(e){return Ud(e&&e.line)+":"+Ud(e&&e.column)}function Hd(e){return jc(e&&e.start)+"-"+jc(e&&e.end)}function Ud(e){return e&&typeof e=="number"?e:1}class Yt extends Error{constructor(t,n,r){super(),typeof n=="string"&&(r=n,n=void 0);let s="",o={},a=!1;if(n&&("line"in n&&"column"in n?o={place:n}:"start"in n&&"end"in n?o={place:n}:"type"in n?o={ancestors:[n],place:n.position}:o={...n}),typeof t=="string"?s=t:!o.cause&&t&&(a=!0,s=t.message,o.cause=t),!o.ruleId&&!o.source&&typeof r=="string"){const u=r.indexOf(":");u===-1?o.ruleId=r:(o.source=r.slice(0,u),o.ruleId=r.slice(u+1))}if(!o.place&&o.ancestors&&o.ancestors){const u=o.ancestors[o.ancestors.length-1];u&&(o.place=u.position)}const c=o.place&&"start"in o.place?o.place.start:o.place;this.ancestors=o.ancestors||void 0,this.cause=o.cause||void 0,this.column=c?c.column:void 0,this.fatal=void 0,this.file="",this.message=s,this.line=c?c.line:void 0,this.name=Gi(o.place)||"1:1",this.place=o.place||void 0,this.reason=this.message,this.ruleId=o.ruleId||void 0,this.source=o.source||void 0,this.stack=a&&o.cause&&typeof o.cause.stack=="string"?o.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}Yt.prototype.file="";Yt.prototype.name="";Yt.prototype.reason="";Yt.prototype.message="";Yt.prototype.stack="";Yt.prototype.column=void 0;Yt.prototype.line=void 0;Yt.prototype.ancestors=void 0;Yt.prototype.cause=void 0;Yt.prototype.fatal=void 0;Yt.prototype.place=void 0;Yt.prototype.ruleId=void 0;Yt.prototype.source=void 0;const vu={}.hasOwnProperty,nv=new Map,rv=/[A-Z]/g,sv=new Set(["table","tbody","thead","tfoot","tr"]),iv=new Set(["td","th"]),gm="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function ov(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const n=t.filePath||void 0;let r;if(t.development){if(typeof t.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");r=fv(n,t.jsxDEV)}else{if(typeof t.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof t.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");r=pv(n,t.jsx,t.jsxs)}const s={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space==="svg"?xu:Vw,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},o=bm(s,e,void 0);return o&&typeof o!="string"?o:s.create(e,s.Fragment,{children:o||void 0},void 0)}function bm(e,t,n){if(t.type==="element")return av(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return lv(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return uv(e,t,n);if(t.type==="mdxjsEsm")return cv(e,t);if(t.type==="root")return dv(e,t,n);if(t.type==="text")return hv(e,t)}function av(e,t,n){const r=e.schema;let s=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(s=xu,e.schema=s),e.ancestors.push(t);const o=ym(e,t.tagName,!1),a=mv(e,t);let c=Cu(e,t);return sv.has(t.tagName)&&(c=c.filter(function(u){return typeof u=="string"?!Bw(u):!0})),km(e,a,o,t),Su(a,c),e.ancestors.pop(),e.schema=r,e.create(t,o,a,n)}function lv(e,t){if(t.data&&t.data.estree&&e.evaluater){const r=t.data.estree.body[0];return r.type,e.evaluater.evaluateExpression(r.expression)}Zi(e,t.position)}function cv(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);Zi(e,t.position)}function uv(e,t,n){const r=e.schema;let s=r;t.name==="svg"&&r.space==="html"&&(s=xu,e.schema=s),e.ancestors.push(t);const o=t.name===null?e.Fragment:ym(e,t.name,!0),a=gv(e,t),c=Cu(e,t);return km(e,a,o,t),Su(a,c),e.ancestors.pop(),e.schema=r,e.create(t,o,a,n)}function dv(e,t,n){const r={};return Su(r,Cu(e,t)),e.create(t,e.Fragment,r,n)}function hv(e,t){return t.value}function km(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function Su(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function pv(e,t,n){return r;function r(s,o,a,c){const d=Array.isArray(a.children)?n:t;return c?d(o,a,c):d(o,a)}}function fv(e,t){return n;function n(r,s,o,a){const c=Array.isArray(o.children),u=wu(r);return t(s,o,a,c,{columnNumber:u?u.column-1:void 0,fileName:e,lineNumber:u?u.line:void 0},void 0)}}function mv(e,t){const n={};let r,s;for(s in t.properties)if(s!=="children"&&vu.call(t.properties,s)){const o=bv(e,s,t.properties[s]);if(o){const[a,c]=o;e.tableCellAlignToStyle&&a==="align"&&typeof c=="string"&&iv.has(t.tagName)?r=c:n[a]=c}}if(r){const o=n.style||(n.style={});o[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=r}return n}function gv(e,t){const n={};for(const r of t.attributes)if(r.type==="mdxJsxExpressionAttribute")if(r.data&&r.data.estree&&e.evaluater){const o=r.data.estree.body[0];o.type;const a=o.expression;a.type;const c=a.properties[0];c.type,Object.assign(n,e.evaluater.evaluateExpression(c.argument))}else Zi(e,t.position);else{const s=r.name;let o;if(r.value&&typeof r.value=="object")if(r.value.data&&r.value.data.estree&&e.evaluater){const c=r.value.data.estree.body[0];c.type,o=e.evaluater.evaluateExpression(c.expression)}else Zi(e,t.position);else o=r.value===null?!0:r.value;n[s]=o}return n}function Cu(e,t){const n=[];let r=-1;const s=e.passKeys?new Map:nv;for(;++r<t.children.length;){const o=t.children[r];let a;if(e.passKeys){const u=o.type==="element"?o.tagName:o.type==="mdxJsxFlowElement"||o.type==="mdxJsxTextElement"?o.name:void 0;if(u){const d=s.get(u)||0;a=u+"-"+d,s.set(u,d+1)}}const c=bm(e,o,a);c!==void 0&&n.push(c)}return n}function bv(e,t,n){const r=Uw(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?Aw(n):Kw(n)),r.property==="style"){let s=typeof n=="object"?n:kv(e,String(n));return e.stylePropertyNameCase==="css"&&(s=yv(s)),["style",s]}return[e.elementAttributeNameCase==="react"&&r.space?$w[r.property]||r.property:r.attribute,n]}}function kv(e,t){try{return ev(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const r=n,s=new Yt("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:r,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw s.file=e.filePath||void 0,s.url=gm+"#cannot-parse-style-attribute",s}}function ym(e,t,n){let r;if(!n)r={type:"Literal",value:t};else if(t.includes(".")){const s=t.split(".");let o=-1,a;for(;++o<s.length;){const c=_d(s[o])?{type:"Identifier",name:s[o]}:{type:"Literal",value:s[o]};a=a?{type:"MemberExpression",object:a,property:c,computed:!!(o&&c.type==="Literal"),optional:!1}:c}r=a}else r=_d(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){const s=r.value;return vu.call(e.components,s)?e.components[s]:s}if(e.evaluater)return e.evaluater.evaluateExpression(r);Zi(e)}function Zi(e,t){const n=new Yt("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw n.file=e.filePath||void 0,n.url=gm+"#cannot-handle-mdx-estrees-without-createevaluater",n}function yv(e){const t={};let n;for(n in e)vu.call(e,n)&&(t[xv(n)]=e[n]);return t}function xv(e){let t=e.replace(rv,wv);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function wv(e){return"-"+e.toLowerCase()}const Pl={action:["form"],cite:["blockquote","del","ins","q"],data:["object"],formAction:["button","input"],href:["a","area","base","link"],icon:["menuitem"],itemId:null,manifest:["html"],ping:["a","area"],poster:["video"],src:["audio","embed","iframe","img","input","script","source","track","video"]},vv={};function Nu(e,t){const n=vv,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,s=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return xm(e,r,s)}function xm(e,t,n){if(Sv(e)){if("value"in e)return e.type==="html"&&!n?"":e.value;if(t&&"alt"in e&&e.alt)return e.alt;if("children"in e)return qd(e.children,t,n)}return Array.isArray(e)?qd(e,t,n):""}function qd(e,t,n){const r=[];let s=-1;for(;++s<e.length;)r[s]=xm(e[s],t,n);return r.join("")}function Sv(e){return!!(e&&typeof e=="object")}const Gd=document.createElement("i");function ju(e){const t="&"+e+";";Gd.innerHTML=t;const n=Gd.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function bn(e,t,n,r){const s=e.length;let o=0,a;if(t<0?t=-t>s?0:s+t:t=t>s?s:t,n=n>0?n:0,r.length<1e4)a=Array.from(r),a.unshift(t,n),e.splice(...a);else for(n&&e.splice(t,n);o<r.length;)a=r.slice(o,o+1e4),a.unshift(t,0),e.splice(...a),o+=1e4,t+=1e4}function In(e,t){return e.length>0?(bn(e,e.length,0,t),e):t}const Vd={}.hasOwnProperty;function wm(e){const t={};let n=-1;for(;++n<e.length;)Cv(t,e[n]);return t}function Cv(e,t){let n;for(n in t){const s=(Vd.call(e,n)?e[n]:void 0)||(e[n]={}),o=t[n];let a;if(o)for(a in o){Vd.call(s,a)||(s[a]=[]);const c=o[a];Nv(s[a],Array.isArray(c)?c:c?[c]:[])}}}function Nv(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);bn(e,0,0,r)}function vm(e,t){const n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)===65535||(n&65535)===65534||n>1114111?"�":String.fromCodePoint(n)}function Wn(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const tn=Or(/[A-Za-z]/),Kt=Or(/[\dA-Za-z]/),jv=Or(/[#-'*+\--9=?A-Z^-~]/);function ja(e){return e!==null&&(e<32||e===127)}const Tc=Or(/\d/),Tv=Or(/[\dA-Fa-f]/),Iv=Or(/[!-/:-@[-`{-~]/);function Ee(e){return e!==null&&e<-2}function dt(e){return e!==null&&(e<0||e===32)}function ze(e){return e===-2||e===-1||e===32}const Ka=Or(new RegExp("\\p{P}|\\p{S}","u")),hs=Or(/\s/);function Or(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function di(e){const t=[];let n=-1,r=0,s=0;for(;++n<e.length;){const o=e.charCodeAt(n);let a="";if(o===37&&Kt(e.charCodeAt(n+1))&&Kt(e.charCodeAt(n+2)))s=2;else if(o<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(o))||(a=String.fromCharCode(o));else if(o>55295&&o<57344){const c=e.charCodeAt(n+1);o<56320&&c>56319&&c<57344?(a=String.fromCharCode(o,c),s=1):a="�"}else a=String.fromCharCode(o);a&&(t.push(e.slice(r,n),encodeURIComponent(a)),r=n+s+1,a=""),s&&(n+=s,s=0)}return t.join("")+e.slice(r)}function Je(e,t,n,r){const s=r?r-1:Number.POSITIVE_INFINITY;let o=0;return a;function a(u){return ze(u)?(e.enter(n),c(u)):t(u)}function c(u){return ze(u)&&o++<s?(e.consume(u),c):(e.exit(n),t(u))}}const Ev={tokenize:Mv};function Mv(e){const t=e.attempt(this.parser.constructs.contentInitial,r,s);let n;return t;function r(c){if(c===null){e.consume(c);return}return e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),Je(e,t,"linePrefix")}function s(c){return e.enter("paragraph"),o(c)}function o(c){const u=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=u),n=u,a(c)}function a(c){if(c===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(c);return}return Ee(c)?(e.consume(c),e.exit("chunkText"),o):(e.consume(c),a)}}const Rv={tokenize:Av},Kd={tokenize:Pv};function Av(e){const t=this,n=[];let r=0,s,o,a;return c;function c(j){if(r<n.length){const G=n[r];return t.containerState=G[1],e.attempt(G[0].continuation,u,d)(j)}return d(j)}function u(j){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,s&&A();const G=t.events.length;let P=G,T;for(;P--;)if(t.events[P][0]==="exit"&&t.events[P][1].type==="chunkFlow"){T=t.events[P][1].end;break}x(r);let K=G;for(;K<t.events.length;)t.events[K][1].end={...T},K++;return bn(t.events,P+1,0,t.events.slice(G)),t.events.length=K,d(j)}return c(j)}function d(j){if(r===n.length){if(!s)return m(j);if(s.currentConstruct&&s.currentConstruct.concrete)return y(j);t.interrupt=!!(s.currentConstruct&&!s._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(Kd,p,h)(j)}function p(j){return s&&A(),x(r),m(j)}function h(j){return t.parser.lazy[t.now().line]=r!==n.length,a=t.now().offset,y(j)}function m(j){return t.containerState={},e.attempt(Kd,g,y)(j)}function g(j){return r++,n.push([t.currentConstruct,t.containerState]),m(j)}function y(j){if(j===null){s&&A(),x(0),e.consume(j);return}return s=s||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:s,contentType:"flow",previous:o}),S(j)}function S(j){if(j===null){C(e.exit("chunkFlow"),!0),x(0),e.consume(j);return}return Ee(j)?(e.consume(j),C(e.exit("chunkFlow")),r=0,t.interrupt=void 0,c):(e.consume(j),S)}function C(j,G){const P=t.sliceStream(j);if(G&&P.push(null),j.previous=o,o&&(o.next=j),o=j,s.defineSkip(j.start),s.write(P),t.parser.lazy[j.start.line]){let T=s.events.length;for(;T--;)if(s.events[T][1].start.offset<a&&(!s.events[T][1].end||s.events[T][1].end.offset>a))return;const K=t.events.length;let U=K,L,E;for(;U--;)if(t.events[U][0]==="exit"&&t.events[U][1].type==="chunkFlow"){if(L){E=t.events[U][1].end;break}L=!0}for(x(r),T=K;T<t.events.length;)t.events[T][1].end={...E},T++;bn(t.events,U+1,0,t.events.slice(K)),t.events.length=T}}function x(j){let G=n.length;for(;G-- >j;){const P=n[G];t.containerState=P[1],P[0].exit.call(t,e)}n.length=j}function A(){s.write([null]),o=void 0,s=void 0,t.containerState._closeFlow=void 0}}function Pv(e,t,n){return Je(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function oi(e){if(e===null||dt(e)||hs(e))return 1;if(Ka(e))return 2}function Ya(e,t,n){const r=[];let s=-1;for(;++s<e.length;){const o=e[s].resolveAll;o&&!r.includes(o)&&(t=o(t,n),r.push(o))}return t}const Ic={name:"attention",resolveAll:Lv,tokenize:_v};function Lv(e,t){let n=-1,r,s,o,a,c,u,d,p;for(;++n<e.length;)if(e[n][0]==="enter"&&e[n][1].type==="attentionSequence"&&e[n][1]._close){for(r=n;r--;)if(e[r][0]==="exit"&&e[r][1].type==="attentionSequence"&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;u=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const h={...e[r][1].end},m={...e[n][1].start};Yd(h,-u),Yd(m,u),a={type:u>1?"strongSequence":"emphasisSequence",start:h,end:{...e[r][1].end}},c={type:u>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:m},o={type:u>1?"strongText":"emphasisText",start:{...e[r][1].end},end:{...e[n][1].start}},s={type:u>1?"strong":"emphasis",start:{...a.start},end:{...c.end}},e[r][1].end={...a.start},e[n][1].start={...c.end},d=[],e[r][1].end.offset-e[r][1].start.offset&&(d=In(d,[["enter",e[r][1],t],["exit",e[r][1],t]])),d=In(d,[["enter",s,t],["enter",a,t],["exit",a,t],["enter",o,t]]),d=In(d,Ya(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),d=In(d,[["exit",o,t],["enter",c,t],["exit",c,t],["exit",s,t]]),e[n][1].end.offset-e[n][1].start.offset?(p=2,d=In(d,[["enter",e[n][1],t],["exit",e[n][1],t]])):p=0,bn(e,r-1,n-r+3,d),n=r+d.length-p-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}function _v(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,s=oi(r);let o;return a;function a(u){return o=u,e.enter("attentionSequence"),c(u)}function c(u){if(u===o)return e.consume(u),c;const d=e.exit("attentionSequence"),p=oi(u),h=!p||p===2&&s||n.includes(u),m=!s||s===2&&p||n.includes(r);return d._open=!!(o===42?h:h&&(s||!m)),d._close=!!(o===42?m:m&&(p||!h)),t(u)}}function Yd(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const Dv={name:"autolink",tokenize:Bv};function Bv(e,t,n){let r=0;return s;function s(g){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(g),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),o}function o(g){return tn(g)?(e.consume(g),a):g===64?n(g):d(g)}function a(g){return g===43||g===45||g===46||Kt(g)?(r=1,c(g)):d(g)}function c(g){return g===58?(e.consume(g),r=0,u):(g===43||g===45||g===46||Kt(g))&&r++<32?(e.consume(g),c):(r=0,d(g))}function u(g){return g===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(g),e.exit("autolinkMarker"),e.exit("autolink"),t):g===null||g===32||g===60||ja(g)?n(g):(e.consume(g),u)}function d(g){return g===64?(e.consume(g),p):jv(g)?(e.consume(g),d):n(g)}function p(g){return Kt(g)?h(g):n(g)}function h(g){return g===46?(e.consume(g),r=0,p):g===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(g),e.exit("autolinkMarker"),e.exit("autolink"),t):m(g)}function m(g){if((g===45||Kt(g))&&r++<63){const y=g===45?m:h;return e.consume(g),y}return n(g)}}const po={partial:!0,tokenize:Ov};function Ov(e,t,n){return r;function r(o){return ze(o)?Je(e,s,"linePrefix")(o):s(o)}function s(o){return o===null||Ee(o)?t(o):n(o)}}const Sm={continuation:{tokenize:Fv},exit:$v,name:"blockQuote",tokenize:Wv};function Wv(e,t,n){const r=this;return s;function s(a){if(a===62){const c=r.containerState;return c.open||(e.enter("blockQuote",{_container:!0}),c.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(a),e.exit("blockQuoteMarker"),o}return n(a)}function o(a){return ze(a)?(e.enter("blockQuotePrefixWhitespace"),e.consume(a),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(a))}}function Fv(e,t,n){const r=this;return s;function s(a){return ze(a)?Je(e,o,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a):o(a)}function o(a){return e.attempt(Sm,t,n)(a)}}function $v(e){e.exit("blockQuote")}const Cm={name:"characterEscape",tokenize:zv};function zv(e,t,n){return r;function r(o){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(o),e.exit("escapeMarker"),s}function s(o){return Iv(o)?(e.enter("characterEscapeValue"),e.consume(o),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(o)}}const Nm={name:"characterReference",tokenize:Hv};function Hv(e,t,n){const r=this;let s=0,o,a;return c;function c(h){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(h),e.exit("characterReferenceMarker"),u}function u(h){return h===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(h),e.exit("characterReferenceMarkerNumeric"),d):(e.enter("characterReferenceValue"),o=31,a=Kt,p(h))}function d(h){return h===88||h===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(h),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),o=6,a=Tv,p):(e.enter("characterReferenceValue"),o=7,a=Tc,p(h))}function p(h){if(h===59&&s){const m=e.exit("characterReferenceValue");return a===Kt&&!ju(r.sliceSerialize(m))?n(h):(e.enter("characterReferenceMarker"),e.consume(h),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return a(h)&&s++<o?(e.consume(h),p):n(h)}}const Xd={partial:!0,tokenize:qv},Jd={concrete:!0,name:"codeFenced",tokenize:Uv};function Uv(e,t,n){const r=this,s={partial:!0,tokenize:P};let o=0,a=0,c;return u;function u(T){return d(T)}function d(T){const K=r.events[r.events.length-1];return o=K&&K[1].type==="linePrefix"?K[2].sliceSerialize(K[1],!0).length:0,c=T,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),p(T)}function p(T){return T===c?(a++,e.consume(T),p):a<3?n(T):(e.exit("codeFencedFenceSequence"),ze(T)?Je(e,h,"whitespace")(T):h(T))}function h(T){return T===null||Ee(T)?(e.exit("codeFencedFence"),r.interrupt?t(T):e.check(Xd,S,G)(T)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),m(T))}function m(T){return T===null||Ee(T)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),h(T)):ze(T)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),Je(e,g,"whitespace")(T)):T===96&&T===c?n(T):(e.consume(T),m)}function g(T){return T===null||Ee(T)?h(T):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),y(T))}function y(T){return T===null||Ee(T)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),h(T)):T===96&&T===c?n(T):(e.consume(T),y)}function S(T){return e.attempt(s,G,C)(T)}function C(T){return e.enter("lineEnding"),e.consume(T),e.exit("lineEnding"),x}function x(T){return o>0&&ze(T)?Je(e,A,"linePrefix",o+1)(T):A(T)}function A(T){return T===null||Ee(T)?e.check(Xd,S,G)(T):(e.enter("codeFlowValue"),j(T))}function j(T){return T===null||Ee(T)?(e.exit("codeFlowValue"),A(T)):(e.consume(T),j)}function G(T){return e.exit("codeFenced"),t(T)}function P(T,K,U){let L=0;return E;function E(F){return T.enter("lineEnding"),T.consume(F),T.exit("lineEnding"),$}function $(F){return T.enter("codeFencedFence"),ze(F)?Je(T,B,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(F):B(F)}function B(F){return F===c?(T.enter("codeFencedFenceSequence"),re(F)):U(F)}function re(F){return F===c?(L++,T.consume(F),re):L>=a?(T.exit("codeFencedFenceSequence"),ze(F)?Je(T,X,"whitespace")(F):X(F)):U(F)}function X(F){return F===null||Ee(F)?(T.exit("codeFencedFence"),K(F)):U(F)}}}function qv(e,t,n){const r=this;return s;function s(a){return a===null?n(a):(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),o)}function o(a){return r.parser.lazy[r.now().line]?n(a):t(a)}}const Ll={name:"codeIndented",tokenize:Vv},Gv={partial:!0,tokenize:Kv};function Vv(e,t,n){const r=this;return s;function s(d){return e.enter("codeIndented"),Je(e,o,"linePrefix",5)(d)}function o(d){const p=r.events[r.events.length-1];return p&&p[1].type==="linePrefix"&&p[2].sliceSerialize(p[1],!0).length>=4?a(d):n(d)}function a(d){return d===null?u(d):Ee(d)?e.attempt(Gv,a,u)(d):(e.enter("codeFlowValue"),c(d))}function c(d){return d===null||Ee(d)?(e.exit("codeFlowValue"),a(d)):(e.consume(d),c)}function u(d){return e.exit("codeIndented"),t(d)}}function Kv(e,t,n){const r=this;return s;function s(a){return r.parser.lazy[r.now().line]?n(a):Ee(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),s):Je(e,o,"linePrefix",5)(a)}function o(a){const c=r.events[r.events.length-1];return c&&c[1].type==="linePrefix"&&c[2].sliceSerialize(c[1],!0).length>=4?t(a):Ee(a)?s(a):n(a)}}const Yv={name:"codeText",previous:Jv,resolve:Xv,tokenize:Qv};function Xv(e){let t=e.length-4,n=3,r,s;if((e[n][1].type==="lineEnding"||e[n][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(r=n;++r<t;)if(e[r][1].type==="codeTextData"){e[n][1].type="codeTextPadding",e[t][1].type="codeTextPadding",n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)s===void 0?r!==t&&e[r][1].type!=="lineEnding"&&(s=r):(r===t||e[r][1].type==="lineEnding")&&(e[s][1].type="codeTextData",r!==s+2&&(e[s][1].end=e[r-1][1].end,e.splice(s+2,r-s-2),t-=r-s-2,r=s+2),s=void 0);return e}function Jv(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function Qv(e,t,n){let r=0,s,o;return a;function a(h){return e.enter("codeText"),e.enter("codeTextSequence"),c(h)}function c(h){return h===96?(e.consume(h),r++,c):(e.exit("codeTextSequence"),u(h))}function u(h){return h===null?n(h):h===32?(e.enter("space"),e.consume(h),e.exit("space"),u):h===96?(o=e.enter("codeTextSequence"),s=0,p(h)):Ee(h)?(e.enter("lineEnding"),e.consume(h),e.exit("lineEnding"),u):(e.enter("codeTextData"),d(h))}function d(h){return h===null||h===32||h===96||Ee(h)?(e.exit("codeTextData"),u(h)):(e.consume(h),d)}function p(h){return h===96?(e.consume(h),s++,p):s===r?(e.exit("codeTextSequence"),e.exit("codeText"),t(h)):(o.type="codeTextData",d(h))}}class Zv{constructor(t){this.left=t?[...t]:[],this.right=[]}get(t){if(t<0||t>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+t+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return t<this.left.length?this.left[t]:this.right[this.right.length-t+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(t,n){const r=n??Number.POSITIVE_INFINITY;return r<this.left.length?this.left.slice(t,r):t>this.left.length?this.right.slice(this.right.length-r+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-r+this.left.length).reverse())}splice(t,n,r){const s=n||0;this.setCursor(Math.trunc(t));const o=this.right.splice(this.right.length-s,Number.POSITIVE_INFINITY);return r&&Li(this.left,r),o.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),Li(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),Li(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t<this.left.length){const n=this.left.splice(t,Number.POSITIVE_INFINITY);Li(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);Li(this.left,n.reverse())}}}function Li(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function jm(e){const t={};let n=-1,r,s,o,a,c,u,d;const p=new Zv(e);for(;++n<p.length;){for(;n in t;)n=t[n];if(r=p.get(n),n&&r[1].type==="chunkFlow"&&p.get(n-1)[1].type==="listItemPrefix"&&(u=r[1]._tokenizer.events,o=0,o<u.length&&u[o][1].type==="lineEndingBlank"&&(o+=2),o<u.length&&u[o][1].type==="content"))for(;++o<u.length&&u[o][1].type!=="content";)u[o][1].type==="chunkText"&&(u[o][1]._isInFirstContentOfListItem=!0,o++);if(r[0]==="enter")r[1].contentType&&(Object.assign(t,eS(p,n)),n=t[n],d=!0);else if(r[1]._container){for(o=n,s=void 0;o--;)if(a=p.get(o),a[1].type==="lineEnding"||a[1].type==="lineEndingBlank")a[0]==="enter"&&(s&&(p.get(s)[1].type="lineEndingBlank"),a[1].type="lineEnding",s=o);else if(!(a[1].type==="linePrefix"||a[1].type==="listItemIndent"))break;s&&(r[1].end={...p.get(s)[1].start},c=p.slice(s,n),c.unshift(r),p.splice(s,n-s+1,c))}}return bn(e,0,Number.POSITIVE_INFINITY,p.slice(0)),!d}function eS(e,t){const n=e.get(t)[1],r=e.get(t)[2];let s=t-1;const o=[];let a=n._tokenizer;a||(a=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(a._contentTypeTextTrailing=!0));const c=a.events,u=[],d={};let p,h,m=-1,g=n,y=0,S=0;const C=[S];for(;g;){for(;e.get(++s)[1]!==g;);o.push(s),g._tokenizer||(p=r.sliceStream(g),g.next||p.push(null),h&&a.defineSkip(g.start),g._isInFirstContentOfListItem&&(a._gfmTasklistFirstContentOfListItem=!0),a.write(p),g._isInFirstContentOfListItem&&(a._gfmTasklistFirstContentOfListItem=void 0)),h=g,g=g.next}for(g=n;++m<c.length;)c[m][0]==="exit"&&c[m-1][0]==="enter"&&c[m][1].type===c[m-1][1].type&&c[m][1].start.line!==c[m][1].end.line&&(S=m+1,C.push(S),g._tokenizer=void 0,g.previous=void 0,g=g.next);for(a.events=[],g?(g._tokenizer=void 0,g.previous=void 0):C.pop(),m=C.length;m--;){const x=c.slice(C[m],C[m+1]),A=o.pop();u.push([A,A+x.length-1]),e.splice(A,2,x)}for(u.reverse(),m=-1;++m<u.length;)d[y+u[m][0]]=y+u[m][1],y+=u[m][1]-u[m][0]-1;return d}const tS={resolve:rS,tokenize:sS},nS={partial:!0,tokenize:iS};function rS(e){return jm(e),e}function sS(e,t){let n;return r;function r(c){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),s(c)}function s(c){return c===null?o(c):Ee(c)?e.check(nS,a,o)(c):(e.consume(c),s)}function o(c){return e.exit("chunkContent"),e.exit("content"),t(c)}function a(c){return e.consume(c),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,s}}function iS(e,t,n){const r=this;return s;function s(a){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),Je(e,o,"linePrefix")}function o(a){if(a===null||Ee(a))return n(a);const c=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&c&&c[1].type==="linePrefix"&&c[2].sliceSerialize(c[1],!0).length>=4?t(a):e.interrupt(r.parser.constructs.flow,n,t)(a)}}function Tm(e,t,n,r,s,o,a,c,u){const d=u||Number.POSITIVE_INFINITY;let p=0;return h;function h(x){return x===60?(e.enter(r),e.enter(s),e.enter(o),e.consume(x),e.exit(o),m):x===null||x===32||x===41||ja(x)?n(x):(e.enter(r),e.enter(a),e.enter(c),e.enter("chunkString",{contentType:"string"}),S(x))}function m(x){return x===62?(e.enter(o),e.consume(x),e.exit(o),e.exit(s),e.exit(r),t):(e.enter(c),e.enter("chunkString",{contentType:"string"}),g(x))}function g(x){return x===62?(e.exit("chunkString"),e.exit(c),m(x)):x===null||x===60||Ee(x)?n(x):(e.consume(x),x===92?y:g)}function y(x){return x===60||x===62||x===92?(e.consume(x),g):g(x)}function S(x){return!p&&(x===null||x===41||dt(x))?(e.exit("chunkString"),e.exit(c),e.exit(a),e.exit(r),t(x)):p<d&&x===40?(e.consume(x),p++,S):x===41?(e.consume(x),p--,S):x===null||x===32||x===40||ja(x)?n(x):(e.consume(x),x===92?C:S)}function C(x){return x===40||x===41||x===92?(e.consume(x),S):S(x)}}function Im(e,t,n,r,s,o){const a=this;let c=0,u;return d;function d(g){return e.enter(r),e.enter(s),e.consume(g),e.exit(s),e.enter(o),p}function p(g){return c>999||g===null||g===91||g===93&&!u||g===94&&!c&&"_hiddenFootnoteSupport"in a.parser.constructs?n(g):g===93?(e.exit(o),e.enter(s),e.consume(g),e.exit(s),e.exit(r),t):Ee(g)?(e.enter("lineEnding"),e.consume(g),e.exit("lineEnding"),p):(e.enter("chunkString",{contentType:"string"}),h(g))}function h(g){return g===null||g===91||g===93||Ee(g)||c++>999?(e.exit("chunkString"),p(g)):(e.consume(g),u||(u=!ze(g)),g===92?m:h)}function m(g){return g===91||g===92||g===93?(e.consume(g),c++,h):h(g)}}function Em(e,t,n,r,s,o){let a;return c;function c(m){return m===34||m===39||m===40?(e.enter(r),e.enter(s),e.consume(m),e.exit(s),a=m===40?41:m,u):n(m)}function u(m){return m===a?(e.enter(s),e.consume(m),e.exit(s),e.exit(r),t):(e.enter(o),d(m))}function d(m){return m===a?(e.exit(o),u(a)):m===null?n(m):Ee(m)?(e.enter("lineEnding"),e.consume(m),e.exit("lineEnding"),Je(e,d,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),p(m))}function p(m){return m===a||m===null||Ee(m)?(e.exit("chunkString"),d(m)):(e.consume(m),m===92?h:p)}function h(m){return m===a||m===92?(e.consume(m),p):p(m)}}function Vi(e,t){let n;return r;function r(s){return Ee(s)?(e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),n=!0,r):ze(s)?Je(e,r,n?"linePrefix":"lineSuffix")(s):t(s)}}const oS={name:"definition",tokenize:lS},aS={partial:!0,tokenize:cS};function lS(e,t,n){const r=this;let s;return o;function o(g){return e.enter("definition"),a(g)}function a(g){return Im.call(r,e,c,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(g)}function c(g){return s=Wn(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),g===58?(e.enter("definitionMarker"),e.consume(g),e.exit("definitionMarker"),u):n(g)}function u(g){return dt(g)?Vi(e,d)(g):d(g)}function d(g){return Tm(e,p,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(g)}function p(g){return e.attempt(aS,h,h)(g)}function h(g){return ze(g)?Je(e,m,"whitespace")(g):m(g)}function m(g){return g===null||Ee(g)?(e.exit("definition"),r.parser.defined.push(s),t(g)):n(g)}}function cS(e,t,n){return r;function r(c){return dt(c)?Vi(e,s)(c):n(c)}function s(c){return Em(e,o,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(c)}function o(c){return ze(c)?Je(e,a,"whitespace")(c):a(c)}function a(c){return c===null||Ee(c)?t(c):n(c)}}const uS={name:"hardBreakEscape",tokenize:dS};function dS(e,t,n){return r;function r(o){return e.enter("hardBreakEscape"),e.consume(o),s}function s(o){return Ee(o)?(e.exit("hardBreakEscape"),t(o)):n(o)}}const hS={name:"headingAtx",resolve:pS,tokenize:fS};function pS(e,t){let n=e.length-2,r=3,s,o;return e[r][1].type==="whitespace"&&(r+=2),n-2>r&&e[n][1].type==="whitespace"&&(n-=2),e[n][1].type==="atxHeadingSequence"&&(r===n-1||n-4>r&&e[n-2][1].type==="whitespace")&&(n-=r+1===n?2:4),n>r&&(s={type:"atxHeadingText",start:e[r][1].start,end:e[n][1].end},o={type:"chunkText",start:e[r][1].start,end:e[n][1].end,contentType:"text"},bn(e,r,n-r+1,[["enter",s,t],["enter",o,t],["exit",o,t],["exit",s,t]])),e}function fS(e,t,n){let r=0;return s;function s(p){return e.enter("atxHeading"),o(p)}function o(p){return e.enter("atxHeadingSequence"),a(p)}function a(p){return p===35&&r++<6?(e.consume(p),a):p===null||dt(p)?(e.exit("atxHeadingSequence"),c(p)):n(p)}function c(p){return p===35?(e.enter("atxHeadingSequence"),u(p)):p===null||Ee(p)?(e.exit("atxHeading"),t(p)):ze(p)?Je(e,c,"whitespace")(p):(e.enter("atxHeadingText"),d(p))}function u(p){return p===35?(e.consume(p),u):(e.exit("atxHeadingSequence"),c(p))}function d(p){return p===null||p===35||dt(p)?(e.exit("atxHeadingText"),c(p)):(e.consume(p),d)}}const mS=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],Qd=["pre","script","style","textarea"],gS={concrete:!0,name:"htmlFlow",resolveTo:yS,tokenize:xS},bS={partial:!0,tokenize:vS},kS={partial:!0,tokenize:wS};function yS(e){let t=e.length;for(;t--&&!(e[t][0]==="enter"&&e[t][1].type==="htmlFlow"););return t>1&&e[t-2][1].type==="linePrefix"&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function xS(e,t,n){const r=this;let s,o,a,c,u;return d;function d(N){return p(N)}function p(N){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(N),h}function h(N){return N===33?(e.consume(N),m):N===47?(e.consume(N),o=!0,S):N===63?(e.consume(N),s=3,r.interrupt?t:v):tn(N)?(e.consume(N),a=String.fromCharCode(N),C):n(N)}function m(N){return N===45?(e.consume(N),s=2,g):N===91?(e.consume(N),s=5,c=0,y):tn(N)?(e.consume(N),s=4,r.interrupt?t:v):n(N)}function g(N){return N===45?(e.consume(N),r.interrupt?t:v):n(N)}function y(N){const de="CDATA[";return N===de.charCodeAt(c++)?(e.consume(N),c===de.length?r.interrupt?t:B:y):n(N)}function S(N){return tn(N)?(e.consume(N),a=String.fromCharCode(N),C):n(N)}function C(N){if(N===null||N===47||N===62||dt(N)){const de=N===47,Ie=a.toLowerCase();return!de&&!o&&Qd.includes(Ie)?(s=1,r.interrupt?t(N):B(N)):mS.includes(a.toLowerCase())?(s=6,de?(e.consume(N),x):r.interrupt?t(N):B(N)):(s=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(N):o?A(N):j(N))}return N===45||Kt(N)?(e.consume(N),a+=String.fromCharCode(N),C):n(N)}function x(N){return N===62?(e.consume(N),r.interrupt?t:B):n(N)}function A(N){return ze(N)?(e.consume(N),A):E(N)}function j(N){return N===47?(e.consume(N),E):N===58||N===95||tn(N)?(e.consume(N),G):ze(N)?(e.consume(N),j):E(N)}function G(N){return N===45||N===46||N===58||N===95||Kt(N)?(e.consume(N),G):P(N)}function P(N){return N===61?(e.consume(N),T):ze(N)?(e.consume(N),P):j(N)}function T(N){return N===null||N===60||N===61||N===62||N===96?n(N):N===34||N===39?(e.consume(N),u=N,K):ze(N)?(e.consume(N),T):U(N)}function K(N){return N===u?(e.consume(N),u=null,L):N===null||Ee(N)?n(N):(e.consume(N),K)}function U(N){return N===null||N===34||N===39||N===47||N===60||N===61||N===62||N===96||dt(N)?P(N):(e.consume(N),U)}function L(N){return N===47||N===62||ze(N)?j(N):n(N)}function E(N){return N===62?(e.consume(N),$):n(N)}function $(N){return N===null||Ee(N)?B(N):ze(N)?(e.consume(N),$):n(N)}function B(N){return N===45&&s===2?(e.consume(N),q):N===60&&s===1?(e.consume(N),D):N===62&&s===4?(e.consume(N),je):N===63&&s===3?(e.consume(N),v):N===93&&s===5?(e.consume(N),te):Ee(N)&&(s===6||s===7)?(e.exit("htmlFlowData"),e.check(bS,Te,re)(N)):N===null||Ee(N)?(e.exit("htmlFlowData"),re(N)):(e.consume(N),B)}function re(N){return e.check(kS,X,Te)(N)}function X(N){return e.enter("lineEnding"),e.consume(N),e.exit("lineEnding"),F}function F(N){return N===null||Ee(N)?re(N):(e.enter("htmlFlowData"),B(N))}function q(N){return N===45?(e.consume(N),v):B(N)}function D(N){return N===47?(e.consume(N),a="",V):B(N)}function V(N){if(N===62){const de=a.toLowerCase();return Qd.includes(de)?(e.consume(N),je):B(N)}return tn(N)&&a.length<8?(e.consume(N),a+=String.fromCharCode(N),V):B(N)}function te(N){return N===93?(e.consume(N),v):B(N)}function v(N){return N===62?(e.consume(N),je):N===45&&s===2?(e.consume(N),v):B(N)}function je(N){return N===null||Ee(N)?(e.exit("htmlFlowData"),Te(N)):(e.consume(N),je)}function Te(N){return e.exit("htmlFlow"),t(N)}}function wS(e,t,n){const r=this;return s;function s(a){return Ee(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),o):n(a)}function o(a){return r.parser.lazy[r.now().line]?n(a):t(a)}}function vS(e,t,n){return r;function r(s){return e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),e.attempt(po,t,n)}}const SS={name:"htmlText",tokenize:CS};function CS(e,t,n){const r=this;let s,o,a;return c;function c(v){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(v),u}function u(v){return v===33?(e.consume(v),d):v===47?(e.consume(v),P):v===63?(e.consume(v),j):tn(v)?(e.consume(v),U):n(v)}function d(v){return v===45?(e.consume(v),p):v===91?(e.consume(v),o=0,y):tn(v)?(e.consume(v),A):n(v)}function p(v){return v===45?(e.consume(v),g):n(v)}function h(v){return v===null?n(v):v===45?(e.consume(v),m):Ee(v)?(a=h,D(v)):(e.consume(v),h)}function m(v){return v===45?(e.consume(v),g):h(v)}function g(v){return v===62?q(v):v===45?m(v):h(v)}function y(v){const je="CDATA[";return v===je.charCodeAt(o++)?(e.consume(v),o===je.length?S:y):n(v)}function S(v){return v===null?n(v):v===93?(e.consume(v),C):Ee(v)?(a=S,D(v)):(e.consume(v),S)}function C(v){return v===93?(e.consume(v),x):S(v)}function x(v){return v===62?q(v):v===93?(e.consume(v),x):S(v)}function A(v){return v===null||v===62?q(v):Ee(v)?(a=A,D(v)):(e.consume(v),A)}function j(v){return v===null?n(v):v===63?(e.consume(v),G):Ee(v)?(a=j,D(v)):(e.consume(v),j)}function G(v){return v===62?q(v):j(v)}function P(v){return tn(v)?(e.consume(v),T):n(v)}function T(v){return v===45||Kt(v)?(e.consume(v),T):K(v)}function K(v){return Ee(v)?(a=K,D(v)):ze(v)?(e.consume(v),K):q(v)}function U(v){return v===45||Kt(v)?(e.consume(v),U):v===47||v===62||dt(v)?L(v):n(v)}function L(v){return v===47?(e.consume(v),q):v===58||v===95||tn(v)?(e.consume(v),E):Ee(v)?(a=L,D(v)):ze(v)?(e.consume(v),L):q(v)}function E(v){return v===45||v===46||v===58||v===95||Kt(v)?(e.consume(v),E):$(v)}function $(v){return v===61?(e.consume(v),B):Ee(v)?(a=$,D(v)):ze(v)?(e.consume(v),$):L(v)}function B(v){return v===null||v===60||v===61||v===62||v===96?n(v):v===34||v===39?(e.consume(v),s=v,re):Ee(v)?(a=B,D(v)):ze(v)?(e.consume(v),B):(e.consume(v),X)}function re(v){return v===s?(e.consume(v),s=void 0,F):v===null?n(v):Ee(v)?(a=re,D(v)):(e.consume(v),re)}function X(v){return v===null||v===34||v===39||v===60||v===61||v===96?n(v):v===47||v===62||dt(v)?L(v):(e.consume(v),X)}function F(v){return v===47||v===62||dt(v)?L(v):n(v)}function q(v){return v===62?(e.consume(v),e.exit("htmlTextData"),e.exit("htmlText"),t):n(v)}function D(v){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(v),e.exit("lineEnding"),V}function V(v){return ze(v)?Je(e,te,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(v):te(v)}function te(v){return e.enter("htmlTextData"),a(v)}}const Tu={name:"labelEnd",resolveAll:IS,resolveTo:ES,tokenize:MS},NS={tokenize:RS},jS={tokenize:AS},TS={tokenize:PS};function IS(e){let t=-1;const n=[];for(;++t<e.length;){const r=e[t][1];if(n.push(e[t]),r.type==="labelImage"||r.type==="labelLink"||r.type==="labelEnd"){const s=r.type==="labelImage"?4:2;r.type="data",t+=s}}return e.length!==n.length&&bn(e,0,e.length,n),e}function ES(e,t){let n=e.length,r=0,s,o,a,c;for(;n--;)if(s=e[n][1],o){if(s.type==="link"||s.type==="labelLink"&&s._inactive)break;e[n][0]==="enter"&&s.type==="labelLink"&&(s._inactive=!0)}else if(a){if(e[n][0]==="enter"&&(s.type==="labelImage"||s.type==="labelLink")&&!s._balanced&&(o=n,s.type!=="labelLink")){r=2;break}}else s.type==="labelEnd"&&(a=n);const u={type:e[o][1].type==="labelLink"?"link":"image",start:{...e[o][1].start},end:{...e[e.length-1][1].end}},d={type:"label",start:{...e[o][1].start},end:{...e[a][1].end}},p={type:"labelText",start:{...e[o+r+2][1].end},end:{...e[a-2][1].start}};return c=[["enter",u,t],["enter",d,t]],c=In(c,e.slice(o+1,o+r+3)),c=In(c,[["enter",p,t]]),c=In(c,Ya(t.parser.constructs.insideSpan.null,e.slice(o+r+4,a-3),t)),c=In(c,[["exit",p,t],e[a-2],e[a-1],["exit",d,t]]),c=In(c,e.slice(a+1)),c=In(c,[["exit",u,t]]),bn(e,o,e.length,c),e}function MS(e,t,n){const r=this;let s=r.events.length,o,a;for(;s--;)if((r.events[s][1].type==="labelImage"||r.events[s][1].type==="labelLink")&&!r.events[s][1]._balanced){o=r.events[s][1];break}return c;function c(m){return o?o._inactive?h(m):(a=r.parser.defined.includes(Wn(r.sliceSerialize({start:o.end,end:r.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(m),e.exit("labelMarker"),e.exit("labelEnd"),u):n(m)}function u(m){return m===40?e.attempt(NS,p,a?p:h)(m):m===91?e.attempt(jS,p,a?d:h)(m):a?p(m):h(m)}function d(m){return e.attempt(TS,p,h)(m)}function p(m){return t(m)}function h(m){return o._balanced=!0,n(m)}}function RS(e,t,n){return r;function r(h){return e.enter("resource"),e.enter("resourceMarker"),e.consume(h),e.exit("resourceMarker"),s}function s(h){return dt(h)?Vi(e,o)(h):o(h)}function o(h){return h===41?p(h):Tm(e,a,c,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(h)}function a(h){return dt(h)?Vi(e,u)(h):p(h)}function c(h){return n(h)}function u(h){return h===34||h===39||h===40?Em(e,d,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(h):p(h)}function d(h){return dt(h)?Vi(e,p)(h):p(h)}function p(h){return h===41?(e.enter("resourceMarker"),e.consume(h),e.exit("resourceMarker"),e.exit("resource"),t):n(h)}}function AS(e,t,n){const r=this;return s;function s(c){return Im.call(r,e,o,a,"reference","referenceMarker","referenceString")(c)}function o(c){return r.parser.defined.includes(Wn(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(c):n(c)}function a(c){return n(c)}}function PS(e,t,n){return r;function r(o){return e.enter("reference"),e.enter("referenceMarker"),e.consume(o),e.exit("referenceMarker"),s}function s(o){return o===93?(e.enter("referenceMarker"),e.consume(o),e.exit("referenceMarker"),e.exit("reference"),t):n(o)}}const LS={name:"labelStartImage",resolveAll:Tu.resolveAll,tokenize:_S};function _S(e,t,n){const r=this;return s;function s(c){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(c),e.exit("labelImageMarker"),o}function o(c){return c===91?(e.enter("labelMarker"),e.consume(c),e.exit("labelMarker"),e.exit("labelImage"),a):n(c)}function a(c){return c===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(c):t(c)}}const DS={name:"labelStartLink",resolveAll:Tu.resolveAll,tokenize:BS};function BS(e,t,n){const r=this;return s;function s(a){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(a),e.exit("labelMarker"),e.exit("labelLink"),o}function o(a){return a===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(a):t(a)}}const _l={name:"lineEnding",tokenize:OS};function OS(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),Je(e,t,"linePrefix")}}const ga={name:"thematicBreak",tokenize:WS};function WS(e,t,n){let r=0,s;return o;function o(d){return e.enter("thematicBreak"),a(d)}function a(d){return s=d,c(d)}function c(d){return d===s?(e.enter("thematicBreakSequence"),u(d)):r>=3&&(d===null||Ee(d))?(e.exit("thematicBreak"),t(d)):n(d)}function u(d){return d===s?(e.consume(d),r++,u):(e.exit("thematicBreakSequence"),ze(d)?Je(e,c,"whitespace")(d):c(d))}}const an={continuation:{tokenize:HS},exit:qS,name:"list",tokenize:zS},FS={partial:!0,tokenize:GS},$S={partial:!0,tokenize:US};function zS(e,t,n){const r=this,s=r.events[r.events.length-1];let o=s&&s[1].type==="linePrefix"?s[2].sliceSerialize(s[1],!0).length:0,a=0;return c;function c(g){const y=r.containerState.type||(g===42||g===43||g===45?"listUnordered":"listOrdered");if(y==="listUnordered"?!r.containerState.marker||g===r.containerState.marker:Tc(g)){if(r.containerState.type||(r.containerState.type=y,e.enter(y,{_container:!0})),y==="listUnordered")return e.enter("listItemPrefix"),g===42||g===45?e.check(ga,n,d)(g):d(g);if(!r.interrupt||g===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),u(g)}return n(g)}function u(g){return Tc(g)&&++a<10?(e.consume(g),u):(!r.interrupt||a<2)&&(r.containerState.marker?g===r.containerState.marker:g===41||g===46)?(e.exit("listItemValue"),d(g)):n(g)}function d(g){return e.enter("listItemMarker"),e.consume(g),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||g,e.check(po,r.interrupt?n:p,e.attempt(FS,m,h))}function p(g){return r.containerState.initialBlankLine=!0,o++,m(g)}function h(g){return ze(g)?(e.enter("listItemPrefixWhitespace"),e.consume(g),e.exit("listItemPrefixWhitespace"),m):n(g)}function m(g){return r.containerState.size=o+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(g)}}function HS(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(po,s,o);function s(c){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,Je(e,t,"listItemIndent",r.containerState.size+1)(c)}function o(c){return r.containerState.furtherBlankLines||!ze(c)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,a(c)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt($S,t,a)(c))}function a(c){return r.containerState._closeFlow=!0,r.interrupt=void 0,Je(e,e.attempt(an,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(c)}}function US(e,t,n){const r=this;return Je(e,s,"listItemIndent",r.containerState.size+1);function s(o){const a=r.events[r.events.length-1];return a&&a[1].type==="listItemIndent"&&a[2].sliceSerialize(a[1],!0).length===r.containerState.size?t(o):n(o)}}function qS(e){e.exit(this.containerState.type)}function GS(e,t,n){const r=this;return Je(e,s,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function s(o){const a=r.events[r.events.length-1];return!ze(o)&&a&&a[1].type==="listItemPrefixWhitespace"?t(o):n(o)}}const Zd={name:"setextUnderline",resolveTo:VS,tokenize:KS};function VS(e,t){let n=e.length,r,s,o;for(;n--;)if(e[n][0]==="enter"){if(e[n][1].type==="content"){r=n;break}e[n][1].type==="paragraph"&&(s=n)}else e[n][1].type==="content"&&e.splice(n,1),!o&&e[n][1].type==="definition"&&(o=n);const a={type:"setextHeading",start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[s][1].type="setextHeadingText",o?(e.splice(s,0,["enter",a,t]),e.splice(o+1,0,["exit",e[r][1],t]),e[r][1].end={...e[o][1].end}):e[r][1]=a,e.push(["exit",a,t]),e}function KS(e,t,n){const r=this;let s;return o;function o(d){let p=r.events.length,h;for(;p--;)if(r.events[p][1].type!=="lineEnding"&&r.events[p][1].type!=="linePrefix"&&r.events[p][1].type!=="content"){h=r.events[p][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||h)?(e.enter("setextHeadingLine"),s=d,a(d)):n(d)}function a(d){return e.enter("setextHeadingLineSequence"),c(d)}function c(d){return d===s?(e.consume(d),c):(e.exit("setextHeadingLineSequence"),ze(d)?Je(e,u,"lineSuffix")(d):u(d))}function u(d){return d===null||Ee(d)?(e.exit("setextHeadingLine"),t(d)):n(d)}}const YS={tokenize:XS};function XS(e){const t=this,n=e.attempt(po,r,e.attempt(this.parser.constructs.flowInitial,s,Je(e,e.attempt(this.parser.constructs.flow,s,e.attempt(tS,s)),"linePrefix")));return n;function r(o){if(o===null){e.consume(o);return}return e.enter("lineEndingBlank"),e.consume(o),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}function s(o){if(o===null){e.consume(o);return}return e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),t.currentConstruct=void 0,n}}const JS={resolveAll:Rm()},QS=Mm("string"),ZS=Mm("text");function Mm(e){return{resolveAll:Rm(e==="text"?eC:void 0),tokenize:t};function t(n){const r=this,s=this.parser.constructs[e],o=n.attempt(s,a,c);return a;function a(p){return d(p)?o(p):c(p)}function c(p){if(p===null){n.consume(p);return}return n.enter("data"),n.consume(p),u}function u(p){return d(p)?(n.exit("data"),o(p)):(n.consume(p),u)}function d(p){if(p===null)return!0;const h=s[p];let m=-1;if(h)for(;++m<h.length;){const g=h[m];if(!g.previous||g.previous.call(r,r.previous))return!0}return!1}}}function Rm(e){return t;function t(n,r){let s=-1,o;for(;++s<=n.length;)o===void 0?n[s]&&n[s][1].type==="data"&&(o=s,s++):(!n[s]||n[s][1].type!=="data")&&(s!==o+2&&(n[o][1].end=n[s-1][1].end,n.splice(o+2,s-o-2),s=o+2),o=void 0);return e?e(n,r):n}}function eC(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type==="lineEnding")&&e[n-1][1].type==="data"){const r=e[n-1][1],s=t.sliceStream(r);let o=s.length,a=-1,c=0,u;for(;o--;){const d=s[o];if(typeof d=="string"){for(a=d.length;d.charCodeAt(a-1)===32;)c++,a--;if(a)break;a=-1}else if(d===-2)u=!0,c++;else if(d!==-1){o++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(c=0),c){const d={type:n===e.length||u||c<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:o?a:r.start._bufferIndex+a,_index:r.start._index+o,line:r.end.line,column:r.end.column-c,offset:r.end.offset-c},end:{...r.end}};r.end={...d.start},r.start.offset===r.end.offset?Object.assign(r,d):(e.splice(n,0,["enter",d,t],["exit",d,t]),n+=2)}n++}return e}const tC={42:an,43:an,45:an,48:an,49:an,50:an,51:an,52:an,53:an,54:an,55:an,56:an,57:an,62:Sm},nC={91:oS},rC={[-2]:Ll,[-1]:Ll,32:Ll},sC={35:hS,42:ga,45:[Zd,ga],60:gS,61:Zd,95:ga,96:Jd,126:Jd},iC={38:Nm,92:Cm},oC={[-5]:_l,[-4]:_l,[-3]:_l,33:LS,38:Nm,42:Ic,60:[Dv,SS],91:DS,92:[uS,Cm],93:Tu,95:Ic,96:Yv},aC={null:[Ic,JS]},lC={null:[42,95]},cC={null:[]},uC=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:lC,contentInitial:nC,disable:cC,document:tC,flow:sC,flowInitial:rC,insideSpan:aC,string:iC,text:oC},Symbol.toStringTag,{value:"Module"}));function dC(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const s={},o=[];let a=[],c=[];const u={attempt:K(P),check:K(T),consume:A,enter:j,exit:G,interrupt:K(T,{interrupt:!0})},d={code:null,containerState:{},defineSkip:S,events:[],now:y,parser:e,previous:null,sliceSerialize:m,sliceStream:g,write:h};let p=t.tokenize.call(d,u);return t.resolveAll&&o.push(t),d;function h($){return a=In(a,$),C(),a[a.length-1]!==null?[]:(U(t,0),d.events=Ya(o,d.events,d),d.events)}function m($,B){return pC(g($),B)}function g($){return hC(a,$)}function y(){const{_bufferIndex:$,_index:B,line:re,column:X,offset:F}=r;return{_bufferIndex:$,_index:B,line:re,column:X,offset:F}}function S($){s[$.line]=$.column,E()}function C(){let $;for(;r._index<a.length;){const B=a[r._index];if(typeof B=="string")for($=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===$&&r._bufferIndex<B.length;)x(B.charCodeAt(r._bufferIndex));else x(B)}}function x($){p=p($)}function A($){Ee($)?(r.line++,r.column=1,r.offset+=$===-3?2:1,E()):$!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===a[r._index].length&&(r._bufferIndex=-1,r._index++)),d.previous=$}function j($,B){const re=B||{};return re.type=$,re.start=y(),d.events.push(["enter",re,d]),c.push(re),re}function G($){const B=c.pop();return B.end=y(),d.events.push(["exit",B,d]),B}function P($,B){U($,B.from)}function T($,B){B.restore()}function K($,B){return re;function re(X,F,q){let D,V,te,v;return Array.isArray(X)?Te(X):"tokenize"in X?Te([X]):je(X);function je(he){return le;function le(Fe){const Ue=Fe!==null&&he[Fe],_e=Fe!==null&&he.null,qe=[...Array.isArray(Ue)?Ue:Ue?[Ue]:[],...Array.isArray(_e)?_e:_e?[_e]:[]];return Te(qe)(Fe)}}function Te(he){return D=he,V=0,he.length===0?q:N(he[V])}function N(he){return le;function le(Fe){return v=L(),te=he,he.partial||(d.currentConstruct=he),he.name&&d.parser.constructs.disable.null.includes(he.name)?Ie():he.tokenize.call(B?Object.assign(Object.create(d),B):d,u,de,Ie)(Fe)}}function de(he){return $(te,v),F}function Ie(he){return v.restore(),++V<D.length?N(D[V]):q}}}function U($,B){$.resolveAll&&!o.includes($)&&o.push($),$.resolve&&bn(d.events,B,d.events.length-B,$.resolve(d.events.slice(B),d)),$.resolveTo&&(d.events=$.resolveTo(d.events,d))}function L(){const $=y(),B=d.previous,re=d.currentConstruct,X=d.events.length,F=Array.from(c);return{from:X,restore:q};function q(){r=$,d.previous=B,d.currentConstruct=re,d.events.length=X,c=F,E()}}function E(){r.line in s&&r.column<2&&(r.column=s[r.line],r.offset+=s[r.line]-1)}}function hC(e,t){const n=t.start._index,r=t.start._bufferIndex,s=t.end._index,o=t.end._bufferIndex;let a;if(n===s)a=[e[n].slice(r,o)];else{if(a=e.slice(n,s),r>-1){const c=a[0];typeof c=="string"?a[0]=c.slice(r):a.shift()}o>0&&a.push(e[s].slice(0,o))}return a}function pC(e,t){let n=-1;const r=[];let s;for(;++n<e.length;){const o=e[n];let a;if(typeof o=="string")a=o;else switch(o){case-5:{a="\r";break}case-4:{a=`
|
|
6
|
+
`;break}case-3:{a=`\r
|
|
7
|
+
`;break}case-2:{a=t?" ":" ";break}case-1:{if(!t&&s)continue;a=" ";break}default:a=String.fromCharCode(o)}s=o===-2,r.push(a)}return r.join("")}function fC(e){const r={constructs:wm([uC,...(e||{}).extensions||[]]),content:s(Ev),defined:[],document:s(Rv),flow:s(YS),lazy:{},string:s(QS),text:s(ZS)};return r;function s(o){return a;function a(c){return dC(r,o,c)}}}function mC(e){for(;!jm(e););return e}const eh=/[\0\t\n\r]/g;function gC(){let e=1,t="",n=!0,r;return s;function s(o,a,c){const u=[];let d,p,h,m,g;for(o=t+(typeof o=="string"?o.toString():new TextDecoder(a||void 0).decode(o)),h=0,t="",n&&(o.charCodeAt(0)===65279&&h++,n=void 0);h<o.length;){if(eh.lastIndex=h,d=eh.exec(o),m=d&&d.index!==void 0?d.index:o.length,g=o.charCodeAt(m),!d){t=o.slice(h);break}if(g===10&&h===m&&r)u.push(-3),r=void 0;else switch(r&&(u.push(-5),r=void 0),h<m&&(u.push(o.slice(h,m)),e+=m-h),g){case 0:{u.push(65533),e++;break}case 9:{for(p=Math.ceil(e/4)*4,u.push(-2);e++<p;)u.push(-1);break}case 10:{u.push(-4),e=1;break}default:r=!0,e=1}h=m+1}return c&&(r&&u.push(-5),t&&u.push(t),u.push(null)),u}}const bC=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function kC(e){return e.replace(bC,yC)}function yC(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const s=n.charCodeAt(1),o=s===120||s===88;return vm(n.slice(o?2:1),o?16:10)}return ju(n)||e}const Am={}.hasOwnProperty;function xC(e,t,n){return t&&typeof t=="object"&&(n=t,t=void 0),wC(n)(mC(fC(n).document().write(gC()(e,t,!0))))}function wC(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:o(Ke),autolinkProtocol:L,autolinkEmail:L,atxHeading:o(Ce),blockQuote:o(_e),characterEscape:L,characterReference:L,codeFenced:o(qe),codeFencedFenceInfo:a,codeFencedFenceMeta:a,codeIndented:o(qe,a),codeText:o(W,a),codeTextData:L,data:L,codeFlowValue:L,definition:o(Y),definitionDestinationString:a,definitionLabelString:a,definitionTitleString:a,emphasis:o(se),hardBreakEscape:o(ve),hardBreakTrailing:o(ve),htmlFlow:o(fe,a),htmlFlowData:L,htmlText:o(fe,a),htmlTextData:L,image:o(ht),label:a,link:o(Ke),listItem:o(I),listItemValue:m,listOrdered:o(st,h),listUnordered:o(st),paragraph:o(z),reference:N,referenceString:a,resourceDestinationString:a,resourceTitleString:a,setextHeading:o(Ce),strong:o(ie),thematicBreak:o(we)},exit:{atxHeading:u(),atxHeadingSequence:P,autolink:u(),autolinkEmail:Ue,autolinkProtocol:Fe,blockQuote:u(),characterEscapeValue:E,characterReferenceMarkerHexadecimal:Ie,characterReferenceMarkerNumeric:Ie,characterReferenceValue:he,characterReference:le,codeFenced:u(C),codeFencedFence:S,codeFencedFenceInfo:g,codeFencedFenceMeta:y,codeFlowValue:E,codeIndented:u(x),codeText:u(F),codeTextData:E,data:E,definition:u(),definitionDestinationString:G,definitionLabelString:A,definitionTitleString:j,emphasis:u(),hardBreakEscape:u(B),hardBreakTrailing:u(B),htmlFlow:u(re),htmlFlowData:E,htmlText:u(X),htmlTextData:E,image:u(D),label:te,labelText:V,lineEnding:$,link:u(q),listItem:u(),listOrdered:u(),listUnordered:u(),paragraph:u(),referenceString:de,resourceDestinationString:v,resourceTitleString:je,resource:Te,setextHeading:u(U),setextHeadingLineSequence:K,setextHeadingText:T,strong:u(),thematicBreak:u()}};Pm(t,(e||{}).mdastExtensions||[]);const n={};return r;function r(H){let J={type:"root",children:[]};const ge={stack:[J],tokenStack:[],config:t,enter:c,exit:d,buffer:a,resume:p,data:n},xe=[];let De=-1;for(;++De<H.length;)if(H[De][1].type==="listOrdered"||H[De][1].type==="listUnordered")if(H[De][0]==="enter")xe.push(De);else{const He=xe.pop();De=s(H,He,De)}for(De=-1;++De<H.length;){const He=t[H[De][0]];Am.call(He,H[De][1].type)&&He[H[De][1].type].call(Object.assign({sliceSerialize:H[De][2].sliceSerialize},ge),H[De][1])}if(ge.tokenStack.length>0){const He=ge.tokenStack[ge.tokenStack.length-1];(He[1]||th).call(ge,void 0,He[0])}for(J.position={start:Er(H.length>0?H[0][1].start:{line:1,column:1,offset:0}),end:Er(H.length>0?H[H.length-2][1].end:{line:1,column:1,offset:0})},De=-1;++De<t.transforms.length;)J=t.transforms[De](J)||J;return J}function s(H,J,ge){let xe=J-1,De=-1,He=!1,xt,lt,Ye,nt;for(;++xe<=ge;){const Qe=H[xe];switch(Qe[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{Qe[0]==="enter"?De++:De--,nt=void 0;break}case"lineEndingBlank":{Qe[0]==="enter"&&(xt&&!nt&&!De&&!Ye&&(Ye=xe),nt=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:nt=void 0}if(!De&&Qe[0]==="enter"&&Qe[1].type==="listItemPrefix"||De===-1&&Qe[0]==="exit"&&(Qe[1].type==="listUnordered"||Qe[1].type==="listOrdered")){if(xt){let rt=xe;for(lt=void 0;rt--;){const pt=H[rt];if(pt[1].type==="lineEnding"||pt[1].type==="lineEndingBlank"){if(pt[0]==="exit")continue;lt&&(H[lt][1].type="lineEndingBlank",He=!0),pt[1].type="lineEnding",lt=rt}else if(!(pt[1].type==="linePrefix"||pt[1].type==="blockQuotePrefix"||pt[1].type==="blockQuotePrefixWhitespace"||pt[1].type==="blockQuoteMarker"||pt[1].type==="listItemIndent"))break}Ye&&(!lt||Ye<lt)&&(xt._spread=!0),xt.end=Object.assign({},lt?H[lt][1].start:Qe[1].end),H.splice(lt||xe,0,["exit",xt,Qe[2]]),xe++,ge++}if(Qe[1].type==="listItemPrefix"){const rt={type:"listItem",_spread:!1,start:Object.assign({},Qe[1].start),end:void 0};xt=rt,H.splice(xe,0,["enter",rt,Qe[2]]),xe++,ge++,Ye=void 0,nt=!0}}}return H[J][1]._spread=He,ge}function o(H,J){return ge;function ge(xe){c.call(this,H(xe),xe),J&&J.call(this,xe)}}function a(){this.stack.push({type:"fragment",children:[]})}function c(H,J,ge){this.stack[this.stack.length-1].children.push(H),this.stack.push(H),this.tokenStack.push([J,ge||void 0]),H.position={start:Er(J.start),end:void 0}}function u(H){return J;function J(ge){H&&H.call(this,ge),d.call(this,ge)}}function d(H,J){const ge=this.stack.pop(),xe=this.tokenStack.pop();if(xe)xe[0].type!==H.type&&(J?J.call(this,H,xe[0]):(xe[1]||th).call(this,H,xe[0]));else throw new Error("Cannot close `"+H.type+"` ("+Gi({start:H.start,end:H.end})+"): it’s not open");ge.position.end=Er(H.end)}function p(){return Nu(this.stack.pop())}function h(){this.data.expectingFirstListItemValue=!0}function m(H){if(this.data.expectingFirstListItemValue){const J=this.stack[this.stack.length-2];J.start=Number.parseInt(this.sliceSerialize(H),10),this.data.expectingFirstListItemValue=void 0}}function g(){const H=this.resume(),J=this.stack[this.stack.length-1];J.lang=H}function y(){const H=this.resume(),J=this.stack[this.stack.length-1];J.meta=H}function S(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function C(){const H=this.resume(),J=this.stack[this.stack.length-1];J.value=H.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function x(){const H=this.resume(),J=this.stack[this.stack.length-1];J.value=H.replace(/(\r?\n|\r)$/g,"")}function A(H){const J=this.resume(),ge=this.stack[this.stack.length-1];ge.label=J,ge.identifier=Wn(this.sliceSerialize(H)).toLowerCase()}function j(){const H=this.resume(),J=this.stack[this.stack.length-1];J.title=H}function G(){const H=this.resume(),J=this.stack[this.stack.length-1];J.url=H}function P(H){const J=this.stack[this.stack.length-1];if(!J.depth){const ge=this.sliceSerialize(H).length;J.depth=ge}}function T(){this.data.setextHeadingSlurpLineEnding=!0}function K(H){const J=this.stack[this.stack.length-1];J.depth=this.sliceSerialize(H).codePointAt(0)===61?1:2}function U(){this.data.setextHeadingSlurpLineEnding=void 0}function L(H){const ge=this.stack[this.stack.length-1].children;let xe=ge[ge.length-1];(!xe||xe.type!=="text")&&(xe=ue(),xe.position={start:Er(H.start),end:void 0},ge.push(xe)),this.stack.push(xe)}function E(H){const J=this.stack.pop();J.value+=this.sliceSerialize(H),J.position.end=Er(H.end)}function $(H){const J=this.stack[this.stack.length-1];if(this.data.atHardBreak){const ge=J.children[J.children.length-1];ge.position.end=Er(H.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(J.type)&&(L.call(this,H),E.call(this,H))}function B(){this.data.atHardBreak=!0}function re(){const H=this.resume(),J=this.stack[this.stack.length-1];J.value=H}function X(){const H=this.resume(),J=this.stack[this.stack.length-1];J.value=H}function F(){const H=this.resume(),J=this.stack[this.stack.length-1];J.value=H}function q(){const H=this.stack[this.stack.length-1];if(this.data.inReference){const J=this.data.referenceType||"shortcut";H.type+="Reference",H.referenceType=J,delete H.url,delete H.title}else delete H.identifier,delete H.label;this.data.referenceType=void 0}function D(){const H=this.stack[this.stack.length-1];if(this.data.inReference){const J=this.data.referenceType||"shortcut";H.type+="Reference",H.referenceType=J,delete H.url,delete H.title}else delete H.identifier,delete H.label;this.data.referenceType=void 0}function V(H){const J=this.sliceSerialize(H),ge=this.stack[this.stack.length-2];ge.label=kC(J),ge.identifier=Wn(J).toLowerCase()}function te(){const H=this.stack[this.stack.length-1],J=this.resume(),ge=this.stack[this.stack.length-1];if(this.data.inReference=!0,ge.type==="link"){const xe=H.children;ge.children=xe}else ge.alt=J}function v(){const H=this.resume(),J=this.stack[this.stack.length-1];J.url=H}function je(){const H=this.resume(),J=this.stack[this.stack.length-1];J.title=H}function Te(){this.data.inReference=void 0}function N(){this.data.referenceType="collapsed"}function de(H){const J=this.resume(),ge=this.stack[this.stack.length-1];ge.label=J,ge.identifier=Wn(this.sliceSerialize(H)).toLowerCase(),this.data.referenceType="full"}function Ie(H){this.data.characterReferenceType=H.type}function he(H){const J=this.sliceSerialize(H),ge=this.data.characterReferenceType;let xe;ge?(xe=vm(J,ge==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):xe=ju(J);const De=this.stack[this.stack.length-1];De.value+=xe}function le(H){const J=this.stack.pop();J.position.end=Er(H.end)}function Fe(H){E.call(this,H);const J=this.stack[this.stack.length-1];J.url=this.sliceSerialize(H)}function Ue(H){E.call(this,H);const J=this.stack[this.stack.length-1];J.url="mailto:"+this.sliceSerialize(H)}function _e(){return{type:"blockquote",children:[]}}function qe(){return{type:"code",lang:null,meta:null,value:""}}function W(){return{type:"inlineCode",value:""}}function Y(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function se(){return{type:"emphasis",children:[]}}function Ce(){return{type:"heading",depth:0,children:[]}}function ve(){return{type:"break"}}function fe(){return{type:"html",value:""}}function ht(){return{type:"image",title:null,url:"",alt:null}}function Ke(){return{type:"link",title:null,url:"",children:[]}}function st(H){return{type:"list",ordered:H.type==="listOrdered",start:null,spread:H._spread,children:[]}}function I(H){return{type:"listItem",spread:H._spread,checked:null,children:[]}}function z(){return{type:"paragraph",children:[]}}function ie(){return{type:"strong",children:[]}}function ue(){return{type:"text",value:""}}function we(){return{type:"thematicBreak"}}}function Er(e){return{line:e.line,column:e.column,offset:e.offset}}function Pm(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?Pm(e,r):vC(e,r)}}function vC(e,t){let n;for(n in t)if(Am.call(t,n))switch(n){case"canContainEols":{const r=t[n];r&&e[n].push(...r);break}case"transforms":{const r=t[n];r&&e[n].push(...r);break}case"enter":case"exit":{const r=t[n];r&&Object.assign(e[n],r);break}}}function th(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+Gi({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+Gi({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+Gi({start:t.start,end:t.end})+") is still open")}function SC(e){const t=this;t.parser=n;function n(r){return xC(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function CC(e,t){const n={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)}function NC(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
|
|
8
|
+
`}]}function jC(e,t){const n=t.value?t.value+`
|
|
9
|
+
`:"",r={},s=t.lang?t.lang.split(/\s+/):[];s.length>0&&(r.className=["language-"+s[0]]);let o={type:"element",tagName:"code",properties:r,children:[{type:"text",value:n}]};return t.meta&&(o.data={meta:t.meta}),e.patch(t,o),o=e.applyData(t,o),o={type:"element",tagName:"pre",properties:{},children:[o]},e.patch(t,o),o}function TC(e,t){const n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function IC(e,t){const n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function EC(e,t){const n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",r=String(t.identifier).toUpperCase(),s=di(r.toLowerCase()),o=e.footnoteOrder.indexOf(r);let a,c=e.footnoteCounts.get(r);c===void 0?(c=0,e.footnoteOrder.push(r),a=e.footnoteOrder.length):a=o+1,c+=1,e.footnoteCounts.set(r,c);const u={type:"element",tagName:"a",properties:{href:"#"+n+"fn-"+s,id:n+"fnref-"+s+(c>1?"-"+c:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(a)}]};e.patch(t,u);const d={type:"element",tagName:"sup",properties:{},children:[u]};return e.patch(t,d),e.applyData(t,d)}function MC(e,t){const n={type:"element",tagName:"h"+t.depth,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function RC(e,t){if(e.options.allowDangerousHtml){const n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}}function Lm(e,t){const n=t.referenceType;let r="]";if(n==="collapsed"?r+="[]":n==="full"&&(r+="["+(t.label||t.identifier)+"]"),t.type==="imageReference")return[{type:"text",value:"!["+t.alt+r}];const s=e.all(t),o=s[0];o&&o.type==="text"?o.value="["+o.value:s.unshift({type:"text",value:"["});const a=s[s.length-1];return a&&a.type==="text"?a.value+=r:s.push({type:"text",value:r}),s}function AC(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return Lm(e,t);const s={src:di(r.url||""),alt:t.alt};r.title!==null&&r.title!==void 0&&(s.title=r.title);const o={type:"element",tagName:"img",properties:s,children:[]};return e.patch(t,o),e.applyData(t,o)}function PC(e,t){const n={src:di(t.url)};t.alt!==null&&t.alt!==void 0&&(n.alt=t.alt),t.title!==null&&t.title!==void 0&&(n.title=t.title);const r={type:"element",tagName:"img",properties:n,children:[]};return e.patch(t,r),e.applyData(t,r)}function LC(e,t){const n={type:"text",value:t.value.replace(/\r?\n|\r/g," ")};e.patch(t,n);const r={type:"element",tagName:"code",properties:{},children:[n]};return e.patch(t,r),e.applyData(t,r)}function _C(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return Lm(e,t);const s={href:di(r.url||"")};r.title!==null&&r.title!==void 0&&(s.title=r.title);const o={type:"element",tagName:"a",properties:s,children:e.all(t)};return e.patch(t,o),e.applyData(t,o)}function DC(e,t){const n={href:di(t.url)};t.title!==null&&t.title!==void 0&&(n.title=t.title);const r={type:"element",tagName:"a",properties:n,children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function BC(e,t,n){const r=e.all(t),s=n?OC(n):_m(t),o={},a=[];if(typeof t.checked=="boolean"){const p=r[0];let h;p&&p.type==="element"&&p.tagName==="p"?h=p:(h={type:"element",tagName:"p",properties:{},children:[]},r.unshift(h)),h.children.length>0&&h.children.unshift({type:"text",value:" "}),h.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),o.className=["task-list-item"]}let c=-1;for(;++c<r.length;){const p=r[c];(s||c!==0||p.type!=="element"||p.tagName!=="p")&&a.push({type:"text",value:`
|
|
10
|
+
`}),p.type==="element"&&p.tagName==="p"&&!s?a.push(...p.children):a.push(p)}const u=r[r.length-1];u&&(s||u.type!=="element"||u.tagName!=="p")&&a.push({type:"text",value:`
|
|
11
|
+
`});const d={type:"element",tagName:"li",properties:o,children:a};return e.patch(t,d),e.applyData(t,d)}function OC(e){let t=!1;if(e.type==="list"){t=e.spread||!1;const n=e.children;let r=-1;for(;!t&&++r<n.length;)t=_m(n[r])}return t}function _m(e){const t=e.spread;return t??e.children.length>1}function WC(e,t){const n={},r=e.all(t);let s=-1;for(typeof t.start=="number"&&t.start!==1&&(n.start=t.start);++s<r.length;){const a=r[s];if(a.type==="element"&&a.tagName==="li"&&a.properties&&Array.isArray(a.properties.className)&&a.properties.className.includes("task-list-item")){n.className=["contains-task-list"];break}}const o={type:"element",tagName:t.ordered?"ol":"ul",properties:n,children:e.wrap(r,!0)};return e.patch(t,o),e.applyData(t,o)}function FC(e,t){const n={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function $C(e,t){const n={type:"root",children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function zC(e,t){const n={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function HC(e,t){const n=e.all(t),r=n.shift(),s=[];if(r){const a={type:"element",tagName:"thead",properties:{},children:e.wrap([r],!0)};e.patch(t.children[0],a),s.push(a)}if(n.length>0){const a={type:"element",tagName:"tbody",properties:{},children:e.wrap(n,!0)},c=wu(t.children[1]),u=fm(t.children[t.children.length-1]);c&&u&&(a.position={start:c,end:u}),s.push(a)}const o={type:"element",tagName:"table",properties:{},children:e.wrap(s,!0)};return e.patch(t,o),e.applyData(t,o)}function UC(e,t,n){const r=n?n.children:void 0,o=(r?r.indexOf(t):1)===0?"th":"td",a=n&&n.type==="table"?n.align:void 0,c=a?a.length:t.children.length;let u=-1;const d=[];for(;++u<c;){const h=t.children[u],m={},g=a?a[u]:void 0;g&&(m.align=g);let y={type:"element",tagName:o,properties:m,children:[]};h&&(y.children=e.all(h),e.patch(h,y),y=e.applyData(h,y)),d.push(y)}const p={type:"element",tagName:"tr",properties:{},children:e.wrap(d,!0)};return e.patch(t,p),e.applyData(t,p)}function qC(e,t){const n={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}const nh=9,rh=32;function GC(e){const t=String(e),n=/\r?\n|\r/g;let r=n.exec(t),s=0;const o=[];for(;r;)o.push(sh(t.slice(s,r.index),s>0,!0),r[0]),s=r.index+r[0].length,r=n.exec(t);return o.push(sh(t.slice(s),s>0,!1)),o.join("")}function sh(e,t,n){let r=0,s=e.length;if(t){let o=e.codePointAt(r);for(;o===nh||o===rh;)r++,o=e.codePointAt(r)}if(n){let o=e.codePointAt(s-1);for(;o===nh||o===rh;)s--,o=e.codePointAt(s-1)}return s>r?e.slice(r,s):""}function VC(e,t){const n={type:"text",value:GC(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function KC(e,t){const n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}const YC={blockquote:CC,break:NC,code:jC,delete:TC,emphasis:IC,footnoteReference:EC,heading:MC,html:RC,imageReference:AC,image:PC,inlineCode:LC,linkReference:_C,link:DC,listItem:BC,list:WC,paragraph:FC,root:$C,strong:zC,table:HC,tableCell:qC,tableRow:UC,text:VC,thematicBreak:KC,toml:Ho,yaml:Ho,definition:Ho,footnoteDefinition:Ho};function Ho(){}const Dm=-1,Xa=0,Ki=1,Ta=2,Iu=3,Eu=4,Mu=5,Ru=6,Bm=7,Om=8,ih=typeof self=="object"?self:globalThis,XC=(e,t)=>{const n=(s,o)=>(e.set(o,s),s),r=s=>{if(e.has(s))return e.get(s);const[o,a]=t[s];switch(o){case Xa:case Dm:return n(a,s);case Ki:{const c=n([],s);for(const u of a)c.push(r(u));return c}case Ta:{const c=n({},s);for(const[u,d]of a)c[r(u)]=r(d);return c}case Iu:return n(new Date(a),s);case Eu:{const{source:c,flags:u}=a;return n(new RegExp(c,u),s)}case Mu:{const c=n(new Map,s);for(const[u,d]of a)c.set(r(u),r(d));return c}case Ru:{const c=n(new Set,s);for(const u of a)c.add(r(u));return c}case Bm:{const{name:c,message:u}=a;return n(new ih[c](u),s)}case Om:return n(BigInt(a),s);case"BigInt":return n(Object(BigInt(a)),s);case"ArrayBuffer":return n(new Uint8Array(a).buffer,a);case"DataView":{const{buffer:c}=new Uint8Array(a);return n(new DataView(c),a)}}return n(new ih[o](a),s)};return r},oh=e=>XC(new Map,e)(0),Bs="",{toString:JC}={},{keys:QC}=Object,_i=e=>{const t=typeof e;if(t!=="object"||!e)return[Xa,t];const n=JC.call(e).slice(8,-1);switch(n){case"Array":return[Ki,Bs];case"Object":return[Ta,Bs];case"Date":return[Iu,Bs];case"RegExp":return[Eu,Bs];case"Map":return[Mu,Bs];case"Set":return[Ru,Bs];case"DataView":return[Ki,n]}return n.includes("Array")?[Ki,n]:n.includes("Error")?[Bm,n]:[Ta,n]},Uo=([e,t])=>e===Xa&&(t==="function"||t==="symbol"),ZC=(e,t,n,r)=>{const s=(a,c)=>{const u=r.push(a)-1;return n.set(c,u),u},o=a=>{if(n.has(a))return n.get(a);let[c,u]=_i(a);switch(c){case Xa:{let p=a;switch(u){case"bigint":c=Om,p=a.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+u);p=null;break;case"undefined":return s([Dm],a)}return s([c,p],a)}case Ki:{if(u){let m=a;return u==="DataView"?m=new Uint8Array(a.buffer):u==="ArrayBuffer"&&(m=new Uint8Array(a)),s([u,[...m]],a)}const p=[],h=s([c,p],a);for(const m of a)p.push(o(m));return h}case Ta:{if(u)switch(u){case"BigInt":return s([u,a.toString()],a);case"Boolean":case"Number":case"String":return s([u,a.valueOf()],a)}if(t&&"toJSON"in a)return o(a.toJSON());const p=[],h=s([c,p],a);for(const m of QC(a))(e||!Uo(_i(a[m])))&&p.push([o(m),o(a[m])]);return h}case Iu:return s([c,a.toISOString()],a);case Eu:{const{source:p,flags:h}=a;return s([c,{source:p,flags:h}],a)}case Mu:{const p=[],h=s([c,p],a);for(const[m,g]of a)(e||!(Uo(_i(m))||Uo(_i(g))))&&p.push([o(m),o(g)]);return h}case Ru:{const p=[],h=s([c,p],a);for(const m of a)(e||!Uo(_i(m)))&&p.push(o(m));return h}}const{message:d}=a;return s([c,{name:u,message:d}],a)};return o},ah=(e,{json:t,lossy:n}={})=>{const r=[];return ZC(!(t||n),!!t,new Map,r)(e),r},Ia=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?oh(ah(e,t)):structuredClone(e):(e,t)=>oh(ah(e,t));function e0(e,t){const n=[{type:"text",value:"↩"}];return t>1&&n.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(t)}]}),n}function t0(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function n0(e){const t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||e0,r=e.options.footnoteBackLabel||t0,s=e.options.footnoteLabel||"Footnotes",o=e.options.footnoteLabelTagName||"h2",a=e.options.footnoteLabelProperties||{className:["sr-only"]},c=[];let u=-1;for(;++u<e.footnoteOrder.length;){const d=e.footnoteById.get(e.footnoteOrder[u]);if(!d)continue;const p=e.all(d),h=String(d.identifier).toUpperCase(),m=di(h.toLowerCase());let g=0;const y=[],S=e.footnoteCounts.get(h);for(;S!==void 0&&++g<=S;){y.length>0&&y.push({type:"text",value:" "});let A=typeof n=="string"?n:n(u,g);typeof A=="string"&&(A={type:"text",value:A}),y.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+m+(g>1?"-"+g:""),dataFootnoteBackref:"",ariaLabel:typeof r=="string"?r:r(u,g),className:["data-footnote-backref"]},children:Array.isArray(A)?A:[A]})}const C=p[p.length-1];if(C&&C.type==="element"&&C.tagName==="p"){const A=C.children[C.children.length-1];A&&A.type==="text"?A.value+=" ":C.children.push({type:"text",value:" "}),C.children.push(...y)}else p.push(...y);const x={type:"element",tagName:"li",properties:{id:t+"fn-"+m},children:e.wrap(p,!0)};e.patch(d,x),c.push(x)}if(c.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:o,properties:{...Ia(a),id:"footnote-label"},children:[{type:"text",value:s}]},{type:"text",value:`
|
|
12
|
+
`},{type:"element",tagName:"ol",properties:{},children:e.wrap(c,!0)},{type:"text",value:`
|
|
13
|
+
`}]}}const Ja=(function(e){if(e==null)return o0;if(typeof e=="function")return Qa(e);if(typeof e=="object")return Array.isArray(e)?r0(e):s0(e);if(typeof e=="string")return i0(e);throw new Error("Expected function, string, or object as test")});function r0(e){const t=[];let n=-1;for(;++n<e.length;)t[n]=Ja(e[n]);return Qa(r);function r(...s){let o=-1;for(;++o<t.length;)if(t[o].apply(this,s))return!0;return!1}}function s0(e){const t=e;return Qa(n);function n(r){const s=r;let o;for(o in e)if(s[o]!==t[o])return!1;return!0}}function i0(e){return Qa(t);function t(n){return n&&n.type===e}}function Qa(e){return t;function t(n,r,s){return!!(a0(n)&&e.call(this,n,typeof r=="number"?r:void 0,s||void 0))}}function o0(){return!0}function a0(e){return e!==null&&typeof e=="object"&&"type"in e}const Wm=[],l0=!0,Ec=!1,c0="skip";function Fm(e,t,n,r){let s;typeof t=="function"&&typeof n!="function"?(r=n,n=t):s=t;const o=Ja(s),a=r?-1:1;c(e,void 0,[])();function c(u,d,p){const h=u&&typeof u=="object"?u:{};if(typeof h.type=="string"){const g=typeof h.tagName=="string"?h.tagName:typeof h.name=="string"?h.name:void 0;Object.defineProperty(m,"name",{value:"node ("+(u.type+(g?"<"+g+">":""))+")"})}return m;function m(){let g=Wm,y,S,C;if((!t||o(u,d,p[p.length-1]||void 0))&&(g=u0(n(u,p)),g[0]===Ec))return g;if("children"in u&&u.children){const x=u;if(x.children&&g[0]!==c0)for(S=(r?x.children.length:-1)+a,C=p.concat(x);S>-1&&S<x.children.length;){const A=x.children[S];if(y=c(A,S,C)(),y[0]===Ec)return y;S=typeof y[1]=="number"?y[1]:S+a}}return g}}}function u0(e){return Array.isArray(e)?e:typeof e=="number"?[l0,e]:e==null?Wm:[e]}function Au(e,t,n,r){let s,o,a;typeof t=="function"&&typeof n!="function"?(o=void 0,a=t,s=n):(o=t,a=n,s=r),Fm(e,o,c,s);function c(u,d){const p=d[d.length-1],h=p?p.children.indexOf(u):void 0;return a(u,h,p)}}const Mc={}.hasOwnProperty,d0={};function h0(e,t){const n=t||d0,r=new Map,s=new Map,o=new Map,a={...YC,...n.handlers},c={all:d,applyData:f0,definitionById:r,footnoteById:s,footnoteCounts:o,footnoteOrder:[],handlers:a,one:u,options:n,patch:p0,wrap:g0};return Au(e,function(p){if(p.type==="definition"||p.type==="footnoteDefinition"){const h=p.type==="definition"?r:s,m=String(p.identifier).toUpperCase();h.has(m)||h.set(m,p)}}),c;function u(p,h){const m=p.type,g=c.handlers[m];if(Mc.call(c.handlers,m)&&g)return g(c,p,h);if(c.options.passThrough&&c.options.passThrough.includes(m)){if("children"in p){const{children:S,...C}=p,x=Ia(C);return x.children=c.all(p),x}return Ia(p)}return(c.options.unknownHandler||m0)(c,p,h)}function d(p){const h=[];if("children"in p){const m=p.children;let g=-1;for(;++g<m.length;){const y=c.one(m[g],p);if(y){if(g&&m[g-1].type==="break"&&(!Array.isArray(y)&&y.type==="text"&&(y.value=lh(y.value)),!Array.isArray(y)&&y.type==="element")){const S=y.children[0];S&&S.type==="text"&&(S.value=lh(S.value))}Array.isArray(y)?h.push(...y):h.push(y)}}}return h}}function p0(e,t){e.position&&(t.position=tv(e))}function f0(e,t){let n=t;if(e&&e.data){const r=e.data.hName,s=e.data.hChildren,o=e.data.hProperties;if(typeof r=="string")if(n.type==="element")n.tagName=r;else{const a="children"in n?n.children:[n];n={type:"element",tagName:r,properties:{},children:a}}n.type==="element"&&o&&Object.assign(n.properties,Ia(o)),"children"in n&&n.children&&s!==null&&s!==void 0&&(n.children=s)}return n}function m0(e,t){const n=t.data||{},r="value"in t&&!(Mc.call(n,"hProperties")||Mc.call(n,"hChildren"))?{type:"text",value:t.value}:{type:"element",tagName:"div",properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function g0(e,t){const n=[];let r=-1;for(t&&n.push({type:"text",value:`
|
|
14
|
+
`});++r<e.length;)r&&n.push({type:"text",value:`
|
|
15
|
+
`}),n.push(e[r]);return t&&e.length>0&&n.push({type:"text",value:`
|
|
16
|
+
`}),n}function lh(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function ch(e,t){const n=h0(e,t),r=n.one(e,void 0),s=n0(n),o=Array.isArray(r)?{type:"root",children:r}:r||{type:"root",children:[]};return s&&o.children.push({type:"text",value:`
|
|
17
|
+
`},s),o}function b0(e,t){return e&&"run"in e?async function(n,r){const s=ch(n,{file:r,...t});await e.run(s,r)}:function(n,r){return ch(n,{file:r,...e||t})}}function uh(e){if(e)throw e}var Dl,dh;function k0(){if(dh)return Dl;dh=1;var e=Object.prototype.hasOwnProperty,t=Object.prototype.toString,n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,s=function(d){return typeof Array.isArray=="function"?Array.isArray(d):t.call(d)==="[object Array]"},o=function(d){if(!d||t.call(d)!=="[object Object]")return!1;var p=e.call(d,"constructor"),h=d.constructor&&d.constructor.prototype&&e.call(d.constructor.prototype,"isPrototypeOf");if(d.constructor&&!p&&!h)return!1;var m;for(m in d);return typeof m>"u"||e.call(d,m)},a=function(d,p){n&&p.name==="__proto__"?n(d,p.name,{enumerable:!0,configurable:!0,value:p.newValue,writable:!0}):d[p.name]=p.newValue},c=function(d,p){if(p==="__proto__")if(e.call(d,p)){if(r)return r(d,p).value}else return;return d[p]};return Dl=function u(){var d,p,h,m,g,y,S=arguments[0],C=1,x=arguments.length,A=!1;for(typeof S=="boolean"&&(A=S,S=arguments[1]||{},C=2),(S==null||typeof S!="object"&&typeof S!="function")&&(S={});C<x;++C)if(d=arguments[C],d!=null)for(p in d)h=c(S,p),m=c(d,p),S!==m&&(A&&m&&(o(m)||(g=s(m)))?(g?(g=!1,y=h&&s(h)?h:[]):y=h&&o(h)?h:{},a(S,{name:p,newValue:u(A,y,m)})):typeof m<"u"&&a(S,{name:p,newValue:m}));return S},Dl}var y0=k0();const Bl=uf(y0);function Rc(e){if(typeof e!="object"||e===null)return!1;const t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function x0(){const e=[],t={run:n,use:r};return t;function n(...s){let o=-1;const a=s.pop();if(typeof a!="function")throw new TypeError("Expected function as last argument, not "+a);c(null,...s);function c(u,...d){const p=e[++o];let h=-1;if(u){a(u);return}for(;++h<s.length;)(d[h]===null||d[h]===void 0)&&(d[h]=s[h]);s=d,p?w0(p,c)(...d):a(null,...d)}}function r(s){if(typeof s!="function")throw new TypeError("Expected `middelware` to be a function, not "+s);return e.push(s),t}}function w0(e,t){let n;return r;function r(...a){const c=e.length>a.length;let u;c&&a.push(s);try{u=e.apply(this,a)}catch(d){const p=d;if(c&&n)throw p;return s(p)}c||(u&&u.then&&typeof u.then=="function"?u.then(o,s):u instanceof Error?s(u):o(u))}function s(a,...c){n||(n=!0,t(a,...c))}function o(a){s(null,a)}}const er={basename:v0,dirname:S0,extname:C0,join:N0,sep:"/"};function v0(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');fo(e);let n=0,r=-1,s=e.length,o;if(t===void 0||t.length===0||t.length>e.length){for(;s--;)if(e.codePointAt(s)===47){if(o){n=s+1;break}}else r<0&&(o=!0,r=s+1);return r<0?"":e.slice(n,r)}if(t===e)return"";let a=-1,c=t.length-1;for(;s--;)if(e.codePointAt(s)===47){if(o){n=s+1;break}}else a<0&&(o=!0,a=s+1),c>-1&&(e.codePointAt(s)===t.codePointAt(c--)?c<0&&(r=s):(c=-1,r=a));return n===r?r=a:r<0&&(r=e.length),e.slice(n,r)}function S0(e){if(fo(e),e.length===0)return".";let t=-1,n=e.length,r;for(;--n;)if(e.codePointAt(n)===47){if(r){t=n;break}}else r||(r=!0);return t<0?e.codePointAt(0)===47?"/":".":t===1&&e.codePointAt(0)===47?"//":e.slice(0,t)}function C0(e){fo(e);let t=e.length,n=-1,r=0,s=-1,o=0,a;for(;t--;){const c=e.codePointAt(t);if(c===47){if(a){r=t+1;break}continue}n<0&&(a=!0,n=t+1),c===46?s<0?s=t:o!==1&&(o=1):s>-1&&(o=-1)}return s<0||n<0||o===0||o===1&&s===n-1&&s===r+1?"":e.slice(s,n)}function N0(...e){let t=-1,n;for(;++t<e.length;)fo(e[t]),e[t]&&(n=n===void 0?e[t]:n+"/"+e[t]);return n===void 0?".":j0(n)}function j0(e){fo(e);const t=e.codePointAt(0)===47;let n=T0(e,!t);return n.length===0&&!t&&(n="."),n.length>0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function T0(e,t){let n="",r=0,s=-1,o=0,a=-1,c,u;for(;++a<=e.length;){if(a<e.length)c=e.codePointAt(a);else{if(c===47)break;c=47}if(c===47){if(!(s===a-1||o===1))if(s!==a-1&&o===2){if(n.length<2||r!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(u=n.lastIndexOf("/"),u!==n.length-1){u<0?(n="",r=0):(n=n.slice(0,u),r=n.length-1-n.lastIndexOf("/")),s=a,o=0;continue}}else if(n.length>0){n="",r=0,s=a,o=0;continue}}t&&(n=n.length>0?n+"/..":"..",r=2)}else n.length>0?n+="/"+e.slice(s+1,a):n=e.slice(s+1,a),r=a-s-1;s=a,o=0}else c===46&&o>-1?o++:o=-1}return n}function fo(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const I0={cwd:E0};function E0(){return"/"}function Ac(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function M0(e){if(typeof e=="string")e=new URL(e);else if(!Ac(e)){const t=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code="ERR_INVALID_ARG_TYPE",t}if(e.protocol!=="file:"){const t=new TypeError("The URL must be of scheme file");throw t.code="ERR_INVALID_URL_SCHEME",t}return R0(e)}function R0(e){if(e.hostname!==""){const r=new TypeError('File URL host must be "localhost" or empty on darwin');throw r.code="ERR_INVALID_FILE_URL_HOST",r}const t=e.pathname;let n=-1;for(;++n<t.length;)if(t.codePointAt(n)===37&&t.codePointAt(n+1)===50){const r=t.codePointAt(n+2);if(r===70||r===102){const s=new TypeError("File URL path must not include encoded / characters");throw s.code="ERR_INVALID_FILE_URL_PATH",s}}return decodeURIComponent(t)}const Ol=["history","path","basename","stem","extname","dirname"];class $m{constructor(t){let n;t?Ac(t)?n={path:t}:typeof t=="string"||A0(t)?n={value:t}:n=t:n={},this.cwd="cwd"in n?"":I0.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;for(;++r<Ol.length;){const o=Ol[r];o in n&&n[o]!==void 0&&n[o]!==null&&(this[o]=o==="history"?[...n[o]]:n[o])}let s;for(s in n)Ol.includes(s)||(this[s]=n[s])}get basename(){return typeof this.path=="string"?er.basename(this.path):void 0}set basename(t){Fl(t,"basename"),Wl(t,"basename"),this.path=er.join(this.dirname||"",t)}get dirname(){return typeof this.path=="string"?er.dirname(this.path):void 0}set dirname(t){hh(this.basename,"dirname"),this.path=er.join(t||"",this.basename)}get extname(){return typeof this.path=="string"?er.extname(this.path):void 0}set extname(t){if(Wl(t,"extname"),hh(this.dirname,"extname"),t){if(t.codePointAt(0)!==46)throw new Error("`extname` must start with `.`");if(t.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=er.join(this.dirname,this.stem+(t||""))}get path(){return this.history[this.history.length-1]}set path(t){Ac(t)&&(t=M0(t)),Fl(t,"path"),this.path!==t&&this.history.push(t)}get stem(){return typeof this.path=="string"?er.basename(this.path,this.extname):void 0}set stem(t){Fl(t,"stem"),Wl(t,"stem"),this.path=er.join(this.dirname||"",t+(this.extname||""))}fail(t,n,r){const s=this.message(t,n,r);throw s.fatal=!0,s}info(t,n,r){const s=this.message(t,n,r);return s.fatal=void 0,s}message(t,n,r){const s=new Yt(t,n,r);return this.path&&(s.name=this.path+":"+s.name,s.file=this.path),s.fatal=!1,this.messages.push(s),s}toString(t){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(t||void 0).decode(this.value)}}function Wl(e,t){if(e&&e.includes(er.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+er.sep+"`")}function Fl(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function hh(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function A0(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const P0=(function(e){const r=this.constructor.prototype,s=r[e],o=function(){return s.apply(o,arguments)};return Object.setPrototypeOf(o,r),o}),L0={}.hasOwnProperty;class Pu extends P0{constructor(){super("copy"),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=x0()}copy(){const t=new Pu;let n=-1;for(;++n<this.attachers.length;){const r=this.attachers[n];t.use(...r)}return t.data(Bl(!0,{},this.namespace)),t}data(t,n){return typeof t=="string"?arguments.length===2?(Hl("data",this.frozen),this.namespace[t]=n,this):L0.call(this.namespace,t)&&this.namespace[t]||void 0:t?(Hl("data",this.frozen),this.namespace=t,this):this.namespace}freeze(){if(this.frozen)return this;const t=this;for(;++this.freezeIndex<this.attachers.length;){const[n,...r]=this.attachers[this.freezeIndex];if(r[0]===!1)continue;r[0]===!0&&(r[0]=void 0);const s=n.call(t,...r);typeof s=="function"&&this.transformers.use(s)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(t){this.freeze();const n=qo(t),r=this.parser||this.Parser;return $l("parse",r),r(String(n),n)}process(t,n){const r=this;return this.freeze(),$l("process",this.parser||this.Parser),zl("process",this.compiler||this.Compiler),n?s(void 0,n):new Promise(s);function s(o,a){const c=qo(t),u=r.parse(c);r.run(u,c,function(p,h,m){if(p||!h||!m)return d(p);const g=h,y=r.stringify(g,m);B0(y)?m.value=y:m.result=y,d(p,m)});function d(p,h){p||!h?a(p):o?o(h):n(void 0,h)}}}processSync(t){let n=!1,r;return this.freeze(),$l("processSync",this.parser||this.Parser),zl("processSync",this.compiler||this.Compiler),this.process(t,s),fh("processSync","process",n),r;function s(o,a){n=!0,uh(o),r=a}}run(t,n,r){ph(t),this.freeze();const s=this.transformers;return!r&&typeof n=="function"&&(r=n,n=void 0),r?o(void 0,r):new Promise(o);function o(a,c){const u=qo(n);s.run(t,u,d);function d(p,h,m){const g=h||t;p?c(p):a?a(g):r(void 0,g,m)}}}runSync(t,n){let r=!1,s;return this.run(t,n,o),fh("runSync","run",r),s;function o(a,c){uh(a),s=c,r=!0}}stringify(t,n){this.freeze();const r=qo(n),s=this.compiler||this.Compiler;return zl("stringify",s),ph(t),s(t,r)}use(t,...n){const r=this.attachers,s=this.namespace;if(Hl("use",this.frozen),t!=null)if(typeof t=="function")u(t,n);else if(typeof t=="object")Array.isArray(t)?c(t):a(t);else throw new TypeError("Expected usable value, not `"+t+"`");return this;function o(d){if(typeof d=="function")u(d,[]);else if(typeof d=="object")if(Array.isArray(d)){const[p,...h]=d;u(p,h)}else a(d);else throw new TypeError("Expected usable value, not `"+d+"`")}function a(d){if(!("plugins"in d)&&!("settings"in d))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");c(d.plugins),d.settings&&(s.settings=Bl(!0,s.settings,d.settings))}function c(d){let p=-1;if(d!=null)if(Array.isArray(d))for(;++p<d.length;){const h=d[p];o(h)}else throw new TypeError("Expected a list of plugins, not `"+d+"`")}function u(d,p){let h=-1,m=-1;for(;++h<r.length;)if(r[h][0]===d){m=h;break}if(m===-1)r.push([d,...p]);else if(p.length>0){let[g,...y]=p;const S=r[m][1];Rc(S)&&Rc(g)&&(g=Bl(!0,S,g)),r[m]=[d,g,...y]}}}}const _0=new Pu().freeze();function $l(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function zl(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function Hl(e,t){if(t)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function ph(e){if(!Rc(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function fh(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function qo(e){return D0(e)?e:new $m(e)}function D0(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function B0(e){return typeof e=="string"||O0(e)}function O0(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const W0="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",mh=[],gh={allowDangerousHtml:!0},F0=/^(https?|ircs?|mailto|xmpp)$/i,$0=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"className",id:"remove-classname"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function z0(e){const t=H0(e),n=U0(e);return q0(t.runSync(t.parse(n),n),e)}function H0(e){const t=e.rehypePlugins||mh,n=e.remarkPlugins||mh,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...gh}:gh;return _0().use(SC).use(n).use(b0,r).use(t)}function U0(e){const t=e.children||"",n=new $m;return typeof t=="string"&&(n.value=t),n}function q0(e,t){const n=t.allowedElements,r=t.allowElement,s=t.components,o=t.disallowedElements,a=t.skipHtml,c=t.unwrapDisallowed,u=t.urlTransform||G0;for(const p of $0)Object.hasOwn(t,p.from)&&(""+p.from+(p.to?"use `"+p.to+"` instead":"remove it")+W0+p.id,void 0);return Au(e,d),ov(e,{Fragment:i.Fragment,components:s,ignoreInvalidStyle:!0,jsx:i.jsx,jsxs:i.jsxs,passKeys:!0,passNode:!0});function d(p,h,m){if(p.type==="raw"&&m&&typeof h=="number")return a?m.children.splice(h,1):m.children[h]={type:"text",value:p.value},h;if(p.type==="element"){let g;for(g in Pl)if(Object.hasOwn(Pl,g)&&Object.hasOwn(p.properties,g)){const y=p.properties[g],S=Pl[g];(S===null||S.includes(p.tagName))&&(p.properties[g]=u(String(y||""),g,p))}}if(p.type==="element"){let g=n?!n.includes(p.tagName):o?o.includes(p.tagName):!1;if(!g&&r&&typeof h=="number"&&(g=!r(p,h,m)),g&&m&&typeof h=="number")return c&&p.children?m.children.splice(h,1,...p.children):m.children.splice(h,1),h}}}function G0(e){const t=e.indexOf(":"),n=e.indexOf("?"),r=e.indexOf("#"),s=e.indexOf("/");return t===-1||s!==-1&&t>s||n!==-1&&t>n||r!==-1&&t>r||F0.test(e.slice(0,t))?e:""}function bh(e,t){const n=String(e);if(typeof t!="string")throw new TypeError("Expected character");let r=0,s=n.indexOf(t);for(;s!==-1;)r++,s=n.indexOf(t,s+t.length);return r}function V0(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function K0(e,t,n){const s=Ja((n||{}).ignore||[]),o=Y0(t);let a=-1;for(;++a<o.length;)Fm(e,"text",c);function c(d,p){let h=-1,m;for(;++h<p.length;){const g=p[h],y=m?m.children:void 0;if(s(g,y?y.indexOf(g):void 0,m))return;m=g}if(m)return u(d,p)}function u(d,p){const h=p[p.length-1],m=o[a][0],g=o[a][1];let y=0;const C=h.children.indexOf(d);let x=!1,A=[];m.lastIndex=0;let j=m.exec(d.value);for(;j;){const G=j.index,P={index:j.index,input:j.input,stack:[...p,d]};let T=g(...j,P);if(typeof T=="string"&&(T=T.length>0?{type:"text",value:T}:void 0),T===!1?m.lastIndex=G+1:(y!==G&&A.push({type:"text",value:d.value.slice(y,G)}),Array.isArray(T)?A.push(...T):T&&A.push(T),y=G+j[0].length,x=!0),!m.global)break;j=m.exec(d.value)}return x?(y<d.value.length&&A.push({type:"text",value:d.value.slice(y)}),h.children.splice(C,1,...A)):A=[d],C+A.length}}function Y0(e){const t=[];if(!Array.isArray(e))throw new TypeError("Expected find and replace tuple or list of tuples");const n=!e[0]||Array.isArray(e[0])?e:[e];let r=-1;for(;++r<n.length;){const s=n[r];t.push([X0(s[0]),J0(s[1])])}return t}function X0(e){return typeof e=="string"?new RegExp(V0(e),"g"):e}function J0(e){return typeof e=="function"?e:function(){return e}}const Ul="phrasing",ql=["autolink","link","image","label"];function Q0(){return{transforms:[i1],enter:{literalAutolink:e1,literalAutolinkEmail:Gl,literalAutolinkHttp:Gl,literalAutolinkWww:Gl},exit:{literalAutolink:s1,literalAutolinkEmail:r1,literalAutolinkHttp:t1,literalAutolinkWww:n1}}}function Z0(){return{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:Ul,notInConstruct:ql},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:Ul,notInConstruct:ql},{character:":",before:"[ps]",after:"\\/",inConstruct:Ul,notInConstruct:ql}]}}function e1(e){this.enter({type:"link",title:null,url:"",children:[]},e)}function Gl(e){this.config.enter.autolinkProtocol.call(this,e)}function t1(e){this.config.exit.autolinkProtocol.call(this,e)}function n1(e){this.config.exit.data.call(this,e);const t=this.stack[this.stack.length-1];t.type,t.url="http://"+this.sliceSerialize(e)}function r1(e){this.config.exit.autolinkEmail.call(this,e)}function s1(e){this.exit(e)}function i1(e){K0(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,o1],[new RegExp("(?<=^|\\s|\\p{P}|\\p{S})([-.\\w+]+)@([-\\w]+(?:\\.[-\\w]+)+)","gu"),a1]],{ignore:["link","linkReference"]})}function o1(e,t,n,r,s){let o="";if(!zm(s)||(/^w/i.test(t)&&(n=t+n,t="",o="http://"),!l1(n)))return!1;const a=c1(n+r);if(!a[0])return!1;const c={type:"link",title:null,url:o+t+a[0],children:[{type:"text",value:t+a[0]}]};return a[1]?[c,{type:"text",value:a[1]}]:c}function a1(e,t,n,r){return!zm(r,!0)||/[-\d_]$/.test(n)?!1:{type:"link",title:null,url:"mailto:"+t+"@"+n,children:[{type:"text",value:t+"@"+n}]}}function l1(e){const t=e.split(".");return!(t.length<2||t[t.length-1]&&(/_/.test(t[t.length-1])||!/[a-zA-Z\d]/.test(t[t.length-1]))||t[t.length-2]&&(/_/.test(t[t.length-2])||!/[a-zA-Z\d]/.test(t[t.length-2])))}function c1(e){const t=/[!"&'),.:;<>?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let n=t[0],r=n.indexOf(")");const s=bh(e,"(");let o=bh(e,")");for(;r!==-1&&s>o;)e+=n.slice(0,r+1),n=n.slice(r+1),r=n.indexOf(")"),o++;return[e,n]}function zm(e,t){const n=e.input.charCodeAt(e.index-1);return(e.index===0||hs(n)||Ka(n))&&(!t||n!==47)}Hm.peek=k1;function u1(){this.buffer()}function d1(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function h1(){this.buffer()}function p1(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function f1(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Wn(this.sliceSerialize(e)).toLowerCase(),n.label=t}function m1(e){this.exit(e)}function g1(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Wn(this.sliceSerialize(e)).toLowerCase(),n.label=t}function b1(e){this.exit(e)}function k1(){return"["}function Hm(e,t,n,r){const s=n.createTracker(r);let o=s.move("[^");const a=n.enter("footnoteReference"),c=n.enter("reference");return o+=s.move(n.safe(n.associationId(e),{after:"]",before:o})),c(),a(),o+=s.move("]"),o}function y1(){return{enter:{gfmFootnoteCallString:u1,gfmFootnoteCall:d1,gfmFootnoteDefinitionLabelString:h1,gfmFootnoteDefinition:p1},exit:{gfmFootnoteCallString:f1,gfmFootnoteCall:m1,gfmFootnoteDefinitionLabelString:g1,gfmFootnoteDefinition:b1}}}function x1(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:Hm},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function n(r,s,o,a){const c=o.createTracker(a);let u=c.move("[^");const d=o.enter("footnoteDefinition"),p=o.enter("label");return u+=c.move(o.safe(o.associationId(r),{before:u,after:"]"})),p(),u+=c.move("]:"),r.children&&r.children.length>0&&(c.shift(4),u+=c.move((t?`
|
|
18
|
+
`:" ")+o.indentLines(o.containerFlow(r,c.current()),t?Um:w1))),d(),u}}function w1(e,t,n){return t===0?e:Um(e,t,n)}function Um(e,t,n){return(n?"":" ")+e}const v1=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];qm.peek=T1;function S1(){return{canContainEols:["delete"],enter:{strikethrough:N1},exit:{strikethrough:j1}}}function C1(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:v1}],handlers:{delete:qm}}}function N1(e){this.enter({type:"delete",children:[]},e)}function j1(e){this.exit(e)}function qm(e,t,n,r){const s=n.createTracker(r),o=n.enter("strikethrough");let a=s.move("~~");return a+=n.containerPhrasing(e,{...s.current(),before:a,after:"~"}),a+=s.move("~~"),o(),a}function T1(){return"~"}function I1(e){return e.length}function E1(e,t){const n=t||{},r=(n.align||[]).concat(),s=n.stringLength||I1,o=[],a=[],c=[],u=[];let d=0,p=-1;for(;++p<e.length;){const S=[],C=[];let x=-1;for(e[p].length>d&&(d=e[p].length);++x<e[p].length;){const A=M1(e[p][x]);if(n.alignDelimiters!==!1){const j=s(A);C[x]=j,(u[x]===void 0||j>u[x])&&(u[x]=j)}S.push(A)}a[p]=S,c[p]=C}let h=-1;if(typeof r=="object"&&"length"in r)for(;++h<d;)o[h]=kh(r[h]);else{const S=kh(r);for(;++h<d;)o[h]=S}h=-1;const m=[],g=[];for(;++h<d;){const S=o[h];let C="",x="";S===99?(C=":",x=":"):S===108?C=":":S===114&&(x=":");let A=n.alignDelimiters===!1?1:Math.max(1,u[h]-C.length-x.length);const j=C+"-".repeat(A)+x;n.alignDelimiters!==!1&&(A=C.length+A+x.length,A>u[h]&&(u[h]=A),g[h]=A),m[h]=j}a.splice(1,0,m),c.splice(1,0,g),p=-1;const y=[];for(;++p<a.length;){const S=a[p],C=c[p];h=-1;const x=[];for(;++h<d;){const A=S[h]||"";let j="",G="";if(n.alignDelimiters!==!1){const P=u[h]-(C[h]||0),T=o[h];T===114?j=" ".repeat(P):T===99?P%2?(j=" ".repeat(P/2+.5),G=" ".repeat(P/2-.5)):(j=" ".repeat(P/2),G=j):G=" ".repeat(P)}n.delimiterStart!==!1&&!h&&x.push("|"),n.padding!==!1&&!(n.alignDelimiters===!1&&A==="")&&(n.delimiterStart!==!1||h)&&x.push(" "),n.alignDelimiters!==!1&&x.push(j),x.push(A),n.alignDelimiters!==!1&&x.push(G),n.padding!==!1&&x.push(" "),(n.delimiterEnd!==!1||h!==d-1)&&x.push("|")}y.push(n.delimiterEnd===!1?x.join("").replace(/ +$/,""):x.join(""))}return y.join(`
|
|
19
|
+
`)}function M1(e){return e==null?"":String(e)}function kh(e){const t=typeof e=="string"?e.codePointAt(0):0;return t===67||t===99?99:t===76||t===108?108:t===82||t===114?114:0}function R1(e,t,n,r){const s=n.enter("blockquote"),o=n.createTracker(r);o.move("> "),o.shift(2);const a=n.indentLines(n.containerFlow(e,o.current()),A1);return s(),a}function A1(e,t,n){return">"+(n?"":" ")+e}function P1(e,t){return yh(e,t.inConstruct,!0)&&!yh(e,t.notInConstruct,!1)}function yh(e,t,n){if(typeof t=="string"&&(t=[t]),!t||t.length===0)return n;let r=-1;for(;++r<t.length;)if(e.includes(t[r]))return!0;return!1}function xh(e,t,n,r){let s=-1;for(;++s<n.unsafe.length;)if(n.unsafe[s].character===`
|
|
20
|
+
`&&P1(n.stack,n.unsafe[s]))return/[ \t]/.test(r.before)?"":" ";return`\\
|
|
21
|
+
`}function L1(e,t){const n=String(e);let r=n.indexOf(t),s=r,o=0,a=0;if(typeof t!="string")throw new TypeError("Expected substring");for(;r!==-1;)r===s?++o>a&&(a=o):o=1,s=r+t.length,r=n.indexOf(t,s);return a}function _1(e,t){return!!(t.options.fences===!1&&e.value&&!e.lang&&/[^ \r\n]/.test(e.value)&&!/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(e.value))}function D1(e){const t=e.options.fence||"`";if(t!=="`"&&t!=="~")throw new Error("Cannot serialize code with `"+t+"` for `options.fence`, expected `` ` `` or `~`");return t}function B1(e,t,n,r){const s=D1(n),o=e.value||"",a=s==="`"?"GraveAccent":"Tilde";if(_1(e,n)){const h=n.enter("codeIndented"),m=n.indentLines(o,O1);return h(),m}const c=n.createTracker(r),u=s.repeat(Math.max(L1(o,s)+1,3)),d=n.enter("codeFenced");let p=c.move(u);if(e.lang){const h=n.enter(`codeFencedLang${a}`);p+=c.move(n.safe(e.lang,{before:p,after:" ",encode:["`"],...c.current()})),h()}if(e.lang&&e.meta){const h=n.enter(`codeFencedMeta${a}`);p+=c.move(" "),p+=c.move(n.safe(e.meta,{before:p,after:`
|
|
22
|
+
`,encode:["`"],...c.current()})),h()}return p+=c.move(`
|
|
23
|
+
`),o&&(p+=c.move(o+`
|
|
24
|
+
`)),p+=c.move(u),d(),p}function O1(e,t,n){return(n?"":" ")+e}function Lu(e){const t=e.options.quote||'"';if(t!=='"'&&t!=="'")throw new Error("Cannot serialize title with `"+t+"` for `options.quote`, expected `\"`, or `'`");return t}function W1(e,t,n,r){const s=Lu(n),o=s==='"'?"Quote":"Apostrophe",a=n.enter("definition");let c=n.enter("label");const u=n.createTracker(r);let d=u.move("[");return d+=u.move(n.safe(n.associationId(e),{before:d,after:"]",...u.current()})),d+=u.move("]: "),c(),!e.url||/[\0- \u007F]/.test(e.url)?(c=n.enter("destinationLiteral"),d+=u.move("<"),d+=u.move(n.safe(e.url,{before:d,after:">",...u.current()})),d+=u.move(">")):(c=n.enter("destinationRaw"),d+=u.move(n.safe(e.url,{before:d,after:e.title?" ":`
|
|
25
|
+
`,...u.current()}))),c(),e.title&&(c=n.enter(`title${o}`),d+=u.move(" "+s),d+=u.move(n.safe(e.title,{before:d,after:s,...u.current()})),d+=u.move(s),c()),a(),d}function F1(e){const t=e.options.emphasis||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize emphasis with `"+t+"` for `options.emphasis`, expected `*`, or `_`");return t}function eo(e){return"&#x"+e.toString(16).toUpperCase()+";"}function Ea(e,t,n){const r=oi(e),s=oi(t);return r===void 0?s===void 0?n==="_"?{inside:!0,outside:!0}:{inside:!1,outside:!1}:s===1?{inside:!0,outside:!0}:{inside:!1,outside:!0}:r===1?s===void 0?{inside:!1,outside:!1}:s===1?{inside:!0,outside:!0}:{inside:!1,outside:!1}:s===void 0?{inside:!1,outside:!1}:s===1?{inside:!0,outside:!1}:{inside:!1,outside:!1}}Gm.peek=$1;function Gm(e,t,n,r){const s=F1(n),o=n.enter("emphasis"),a=n.createTracker(r),c=a.move(s);let u=a.move(n.containerPhrasing(e,{after:s,before:c,...a.current()}));const d=u.charCodeAt(0),p=Ea(r.before.charCodeAt(r.before.length-1),d,s);p.inside&&(u=eo(d)+u.slice(1));const h=u.charCodeAt(u.length-1),m=Ea(r.after.charCodeAt(0),h,s);m.inside&&(u=u.slice(0,-1)+eo(h));const g=a.move(s);return o(),n.attentionEncodeSurroundingInfo={after:m.outside,before:p.outside},c+u+g}function $1(e,t,n){return n.options.emphasis||"*"}function z1(e,t){let n=!1;return Au(e,function(r){if("value"in r&&/\r?\n|\r/.test(r.value)||r.type==="break")return n=!0,Ec}),!!((!e.depth||e.depth<3)&&Nu(e)&&(t.options.setext||n))}function H1(e,t,n,r){const s=Math.max(Math.min(6,e.depth||1),1),o=n.createTracker(r);if(z1(e,n)){const p=n.enter("headingSetext"),h=n.enter("phrasing"),m=n.containerPhrasing(e,{...o.current(),before:`
|
|
26
|
+
`,after:`
|
|
27
|
+
`});return h(),p(),m+`
|
|
28
|
+
`+(s===1?"=":"-").repeat(m.length-(Math.max(m.lastIndexOf("\r"),m.lastIndexOf(`
|
|
29
|
+
`))+1))}const a="#".repeat(s),c=n.enter("headingAtx"),u=n.enter("phrasing");o.move(a+" ");let d=n.containerPhrasing(e,{before:"# ",after:`
|
|
30
|
+
`,...o.current()});return/^[\t ]/.test(d)&&(d=eo(d.charCodeAt(0))+d.slice(1)),d=d?a+" "+d:a,n.options.closeAtx&&(d+=" "+a),u(),c(),d}Vm.peek=U1;function Vm(e){return e.value||""}function U1(){return"<"}Km.peek=q1;function Km(e,t,n,r){const s=Lu(n),o=s==='"'?"Quote":"Apostrophe",a=n.enter("image");let c=n.enter("label");const u=n.createTracker(r);let d=u.move("![");return d+=u.move(n.safe(e.alt,{before:d,after:"]",...u.current()})),d+=u.move("]("),c(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(c=n.enter("destinationLiteral"),d+=u.move("<"),d+=u.move(n.safe(e.url,{before:d,after:">",...u.current()})),d+=u.move(">")):(c=n.enter("destinationRaw"),d+=u.move(n.safe(e.url,{before:d,after:e.title?" ":")",...u.current()}))),c(),e.title&&(c=n.enter(`title${o}`),d+=u.move(" "+s),d+=u.move(n.safe(e.title,{before:d,after:s,...u.current()})),d+=u.move(s),c()),d+=u.move(")"),a(),d}function q1(){return"!"}Ym.peek=G1;function Ym(e,t,n,r){const s=e.referenceType,o=n.enter("imageReference");let a=n.enter("label");const c=n.createTracker(r);let u=c.move("![");const d=n.safe(e.alt,{before:u,after:"]",...c.current()});u+=c.move(d+"]["),a();const p=n.stack;n.stack=[],a=n.enter("reference");const h=n.safe(n.associationId(e),{before:u,after:"]",...c.current()});return a(),n.stack=p,o(),s==="full"||!d||d!==h?u+=c.move(h+"]"):s==="shortcut"?u=u.slice(0,-1):u+=c.move("]"),u}function G1(){return"!"}Xm.peek=V1;function Xm(e,t,n){let r=e.value||"",s="`",o=-1;for(;new RegExp("(^|[^`])"+s+"([^`]|$)").test(r);)s+="`";for(/[^ \r\n]/.test(r)&&(/^[ \r\n]/.test(r)&&/[ \r\n]$/.test(r)||/^`|`$/.test(r))&&(r=" "+r+" ");++o<n.unsafe.length;){const a=n.unsafe[o],c=n.compilePattern(a);let u;if(a.atBreak)for(;u=c.exec(r);){let d=u.index;r.charCodeAt(d)===10&&r.charCodeAt(d-1)===13&&d--,r=r.slice(0,d)+" "+r.slice(u.index+1)}}return s+r+s}function V1(){return"`"}function Jm(e,t){const n=Nu(e);return!!(!t.options.resourceLink&&e.url&&!e.title&&e.children&&e.children.length===1&&e.children[0].type==="text"&&(n===e.url||"mailto:"+n===e.url)&&/^[a-z][a-z+.-]+:/i.test(e.url)&&!/[\0- <>\u007F]/.test(e.url))}Qm.peek=K1;function Qm(e,t,n,r){const s=Lu(n),o=s==='"'?"Quote":"Apostrophe",a=n.createTracker(r);let c,u;if(Jm(e,n)){const p=n.stack;n.stack=[],c=n.enter("autolink");let h=a.move("<");return h+=a.move(n.containerPhrasing(e,{before:h,after:">",...a.current()})),h+=a.move(">"),c(),n.stack=p,h}c=n.enter("link"),u=n.enter("label");let d=a.move("[");return d+=a.move(n.containerPhrasing(e,{before:d,after:"](",...a.current()})),d+=a.move("]("),u(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(u=n.enter("destinationLiteral"),d+=a.move("<"),d+=a.move(n.safe(e.url,{before:d,after:">",...a.current()})),d+=a.move(">")):(u=n.enter("destinationRaw"),d+=a.move(n.safe(e.url,{before:d,after:e.title?" ":")",...a.current()}))),u(),e.title&&(u=n.enter(`title${o}`),d+=a.move(" "+s),d+=a.move(n.safe(e.title,{before:d,after:s,...a.current()})),d+=a.move(s),u()),d+=a.move(")"),c(),d}function K1(e,t,n){return Jm(e,n)?"<":"["}Zm.peek=Y1;function Zm(e,t,n,r){const s=e.referenceType,o=n.enter("linkReference");let a=n.enter("label");const c=n.createTracker(r);let u=c.move("[");const d=n.containerPhrasing(e,{before:u,after:"]",...c.current()});u+=c.move(d+"]["),a();const p=n.stack;n.stack=[],a=n.enter("reference");const h=n.safe(n.associationId(e),{before:u,after:"]",...c.current()});return a(),n.stack=p,o(),s==="full"||!d||d!==h?u+=c.move(h+"]"):s==="shortcut"?u=u.slice(0,-1):u+=c.move("]"),u}function Y1(){return"["}function _u(e){const t=e.options.bullet||"*";if(t!=="*"&&t!=="+"&&t!=="-")throw new Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function X1(e){const t=_u(e),n=e.options.bulletOther;if(!n)return t==="*"?"-":"*";if(n!=="*"&&n!=="+"&&n!=="-")throw new Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw new Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}function J1(e){const t=e.options.bulletOrdered||".";if(t!=="."&&t!==")")throw new Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function eg(e){const t=e.options.rule||"*";if(t!=="*"&&t!=="-"&&t!=="_")throw new Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function Q1(e,t,n,r){const s=n.enter("list"),o=n.bulletCurrent;let a=e.ordered?J1(n):_u(n);const c=e.ordered?a==="."?")":".":X1(n);let u=t&&n.bulletLastUsed?a===n.bulletLastUsed:!1;if(!e.ordered){const p=e.children?e.children[0]:void 0;if((a==="*"||a==="-")&&p&&(!p.children||!p.children[0])&&n.stack[n.stack.length-1]==="list"&&n.stack[n.stack.length-2]==="listItem"&&n.stack[n.stack.length-3]==="list"&&n.stack[n.stack.length-4]==="listItem"&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(u=!0),eg(n)===a&&p){let h=-1;for(;++h<e.children.length;){const m=e.children[h];if(m&&m.type==="listItem"&&m.children&&m.children[0]&&m.children[0].type==="thematicBreak"){u=!0;break}}}}u&&(a=c),n.bulletCurrent=a;const d=n.containerFlow(e,r);return n.bulletLastUsed=a,n.bulletCurrent=o,s(),d}function Z1(e){const t=e.options.listItemIndent||"one";if(t!=="tab"&&t!=="one"&&t!=="mixed")throw new Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}function eN(e,t,n,r){const s=Z1(n);let o=n.bulletCurrent||_u(n);t&&t.type==="list"&&t.ordered&&(o=(typeof t.start=="number"&&t.start>-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+o);let a=o.length+1;(s==="tab"||s==="mixed"&&(t&&t.type==="list"&&t.spread||e.spread))&&(a=Math.ceil(a/4)*4);const c=n.createTracker(r);c.move(o+" ".repeat(a-o.length)),c.shift(a);const u=n.enter("listItem"),d=n.indentLines(n.containerFlow(e,c.current()),p);return u(),d;function p(h,m,g){return m?(g?"":" ".repeat(a))+h:(g?o:o+" ".repeat(a-o.length))+h}}function tN(e,t,n,r){const s=n.enter("paragraph"),o=n.enter("phrasing"),a=n.containerPhrasing(e,r);return o(),s(),a}const nN=Ja(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function rN(e,t,n,r){return(e.children.some(function(a){return nN(a)})?n.containerPhrasing:n.containerFlow).call(n,e,r)}function sN(e){const t=e.options.strong||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}tg.peek=iN;function tg(e,t,n,r){const s=sN(n),o=n.enter("strong"),a=n.createTracker(r),c=a.move(s+s);let u=a.move(n.containerPhrasing(e,{after:s,before:c,...a.current()}));const d=u.charCodeAt(0),p=Ea(r.before.charCodeAt(r.before.length-1),d,s);p.inside&&(u=eo(d)+u.slice(1));const h=u.charCodeAt(u.length-1),m=Ea(r.after.charCodeAt(0),h,s);m.inside&&(u=u.slice(0,-1)+eo(h));const g=a.move(s+s);return o(),n.attentionEncodeSurroundingInfo={after:m.outside,before:p.outside},c+u+g}function iN(e,t,n){return n.options.strong||"*"}function oN(e,t,n,r){return n.safe(e.value,r)}function aN(e){const t=e.options.ruleRepetition||3;if(t<3)throw new Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}function lN(e,t,n){const r=(eg(n)+(n.options.ruleSpaces?" ":"")).repeat(aN(n));return n.options.ruleSpaces?r.slice(0,-1):r}const ng={blockquote:R1,break:xh,code:B1,definition:W1,emphasis:Gm,hardBreak:xh,heading:H1,html:Vm,image:Km,imageReference:Ym,inlineCode:Xm,link:Qm,linkReference:Zm,list:Q1,listItem:eN,paragraph:tN,root:rN,strong:tg,text:oN,thematicBreak:lN};function cN(){return{enter:{table:uN,tableData:wh,tableHeader:wh,tableRow:hN},exit:{codeText:pN,table:dN,tableData:Vl,tableHeader:Vl,tableRow:Vl}}}function uN(e){const t=e._align;this.enter({type:"table",align:t.map(function(n){return n==="none"?null:n}),children:[]},e),this.data.inTable=!0}function dN(e){this.exit(e),this.data.inTable=void 0}function hN(e){this.enter({type:"tableRow",children:[]},e)}function Vl(e){this.exit(e)}function wh(e){this.enter({type:"tableCell",children:[]},e)}function pN(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,fN));const n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function fN(e,t){return t==="|"?t:e}function mN(e){const t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,s=t.stringLength,o=n?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:`
|
|
31
|
+
`,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:m,table:a,tableCell:u,tableRow:c}};function a(g,y,S,C){return d(p(g,S,C),g.align)}function c(g,y,S,C){const x=h(g,S,C),A=d([x]);return A.slice(0,A.indexOf(`
|
|
32
|
+
`))}function u(g,y,S,C){const x=S.enter("tableCell"),A=S.enter("phrasing"),j=S.containerPhrasing(g,{...C,before:o,after:o});return A(),x(),j}function d(g,y){return E1(g,{align:y,alignDelimiters:r,padding:n,stringLength:s})}function p(g,y,S){const C=g.children;let x=-1;const A=[],j=y.enter("table");for(;++x<C.length;)A[x]=h(C[x],y,S);return j(),A}function h(g,y,S){const C=g.children;let x=-1;const A=[],j=y.enter("tableRow");for(;++x<C.length;)A[x]=u(C[x],g,y,S);return j(),A}function m(g,y,S){let C=ng.inlineCode(g,y,S);return S.stack.includes("tableCell")&&(C=C.replace(/\|/g,"\\$&")),C}}function gN(){return{exit:{taskListCheckValueChecked:vh,taskListCheckValueUnchecked:vh,paragraph:kN}}}function bN(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:yN}}}function vh(e){const t=this.stack[this.stack.length-2];t.type,t.checked=e.type==="taskListCheckValueChecked"}function kN(e){const t=this.stack[this.stack.length-2];if(t&&t.type==="listItem"&&typeof t.checked=="boolean"){const n=this.stack[this.stack.length-1];n.type;const r=n.children[0];if(r&&r.type==="text"){const s=t.children;let o=-1,a;for(;++o<s.length;){const c=s[o];if(c.type==="paragraph"){a=c;break}}a===n&&(r.value=r.value.slice(1),r.value.length===0?n.children.shift():n.position&&r.position&&typeof r.position.start.offset=="number"&&(r.position.start.column++,r.position.start.offset++,n.position.start=Object.assign({},r.position.start)))}}this.exit(e)}function yN(e,t,n,r){const s=e.children[0],o=typeof e.checked=="boolean"&&s&&s.type==="paragraph",a="["+(e.checked?"x":" ")+"] ",c=n.createTracker(r);o&&c.move(a);let u=ng.listItem(e,t,n,{...r,...c.current()});return o&&(u=u.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,d)),u;function d(p){return p+a}}function xN(){return[Q0(),y1(),S1(),cN(),gN()]}function wN(e){return{extensions:[Z0(),x1(e),C1(),mN(e),bN()]}}const vN={tokenize:IN,partial:!0},rg={tokenize:EN,partial:!0},sg={tokenize:MN,partial:!0},ig={tokenize:RN,partial:!0},SN={tokenize:AN,partial:!0},og={name:"wwwAutolink",tokenize:jN,previous:lg},ag={name:"protocolAutolink",tokenize:TN,previous:cg},hr={name:"emailAutolink",tokenize:NN,previous:ug},sr={};function CN(){return{text:sr}}let rs=48;for(;rs<123;)sr[rs]=hr,rs++,rs===58?rs=65:rs===91&&(rs=97);sr[43]=hr;sr[45]=hr;sr[46]=hr;sr[95]=hr;sr[72]=[hr,ag];sr[104]=[hr,ag];sr[87]=[hr,og];sr[119]=[hr,og];function NN(e,t,n){const r=this;let s,o;return a;function a(h){return!Pc(h)||!ug.call(r,r.previous)||Du(r.events)?n(h):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),c(h))}function c(h){return Pc(h)?(e.consume(h),c):h===64?(e.consume(h),u):n(h)}function u(h){return h===46?e.check(SN,p,d)(h):h===45||h===95||Kt(h)?(o=!0,e.consume(h),u):p(h)}function d(h){return e.consume(h),s=!0,u}function p(h){return o&&s&&tn(r.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(h)):n(h)}}function jN(e,t,n){const r=this;return s;function s(a){return a!==87&&a!==119||!lg.call(r,r.previous)||Du(r.events)?n(a):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(vN,e.attempt(rg,e.attempt(sg,o),n),n)(a))}function o(a){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(a)}}function TN(e,t,n){const r=this;let s="",o=!1;return a;function a(h){return(h===72||h===104)&&cg.call(r,r.previous)&&!Du(r.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),s+=String.fromCodePoint(h),e.consume(h),c):n(h)}function c(h){if(tn(h)&&s.length<5)return s+=String.fromCodePoint(h),e.consume(h),c;if(h===58){const m=s.toLowerCase();if(m==="http"||m==="https")return e.consume(h),u}return n(h)}function u(h){return h===47?(e.consume(h),o?d:(o=!0,u)):n(h)}function d(h){return h===null||ja(h)||dt(h)||hs(h)||Ka(h)?n(h):e.attempt(rg,e.attempt(sg,p),n)(h)}function p(h){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(h)}}function IN(e,t,n){let r=0;return s;function s(a){return(a===87||a===119)&&r<3?(r++,e.consume(a),s):a===46&&r===3?(e.consume(a),o):n(a)}function o(a){return a===null?n(a):t(a)}}function EN(e,t,n){let r,s,o;return a;function a(d){return d===46||d===95?e.check(ig,u,c)(d):d===null||dt(d)||hs(d)||d!==45&&Ka(d)?u(d):(o=!0,e.consume(d),a)}function c(d){return d===95?r=!0:(s=r,r=void 0),e.consume(d),a}function u(d){return s||r||!o?n(d):t(d)}}function MN(e,t){let n=0,r=0;return s;function s(a){return a===40?(n++,e.consume(a),s):a===41&&r<n?o(a):a===33||a===34||a===38||a===39||a===41||a===42||a===44||a===46||a===58||a===59||a===60||a===63||a===93||a===95||a===126?e.check(ig,t,o)(a):a===null||dt(a)||hs(a)?t(a):(e.consume(a),s)}function o(a){return a===41&&r++,e.consume(a),s}}function RN(e,t,n){return r;function r(c){return c===33||c===34||c===39||c===41||c===42||c===44||c===46||c===58||c===59||c===63||c===95||c===126?(e.consume(c),r):c===38?(e.consume(c),o):c===93?(e.consume(c),s):c===60||c===null||dt(c)||hs(c)?t(c):n(c)}function s(c){return c===null||c===40||c===91||dt(c)||hs(c)?t(c):r(c)}function o(c){return tn(c)?a(c):n(c)}function a(c){return c===59?(e.consume(c),r):tn(c)?(e.consume(c),a):n(c)}}function AN(e,t,n){return r;function r(o){return e.consume(o),s}function s(o){return Kt(o)?n(o):t(o)}}function lg(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||dt(e)}function cg(e){return!tn(e)}function ug(e){return!(e===47||Pc(e))}function Pc(e){return e===43||e===45||e===46||e===95||Kt(e)}function Du(e){let t=e.length,n=!1;for(;t--;){const r=e[t][1];if((r.type==="labelLink"||r.type==="labelImage")&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}const PN={tokenize:$N,partial:!0};function LN(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:ON,continuation:{tokenize:WN},exit:FN}},text:{91:{name:"gfmFootnoteCall",tokenize:BN},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:_N,resolveTo:DN}}}}function _N(e,t,n){const r=this;let s=r.events.length;const o=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let a;for(;s--;){const u=r.events[s][1];if(u.type==="labelImage"){a=u;break}if(u.type==="gfmFootnoteCall"||u.type==="labelLink"||u.type==="label"||u.type==="image"||u.type==="link")break}return c;function c(u){if(!a||!a._balanced)return n(u);const d=Wn(r.sliceSerialize({start:a.end,end:r.now()}));return d.codePointAt(0)!==94||!o.includes(d.slice(1))?n(u):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(u),e.exit("gfmFootnoteCallLabelMarker"),t(u))}}function DN(e,t){let n=e.length;for(;n--;)if(e[n][1].type==="labelImage"&&e[n][0]==="enter"){e[n][1];break}e[n+1][1].type="data",e[n+3][1].type="gfmFootnoteCallLabelMarker";const r={type:"gfmFootnoteCall",start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},s={type:"gfmFootnoteCallMarker",start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};s.end.column++,s.end.offset++,s.end._bufferIndex++;const o={type:"gfmFootnoteCallString",start:Object.assign({},s.end),end:Object.assign({},e[e.length-1][1].start)},a={type:"chunkString",contentType:"string",start:Object.assign({},o.start),end:Object.assign({},o.end)},c=[e[n+1],e[n+2],["enter",r,t],e[n+3],e[n+4],["enter",s,t],["exit",s,t],["enter",o,t],["enter",a,t],["exit",a,t],["exit",o,t],e[e.length-2],e[e.length-1],["exit",r,t]];return e.splice(n,e.length-n+1,...c),e}function BN(e,t,n){const r=this,s=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let o=0,a;return c;function c(h){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(h),e.exit("gfmFootnoteCallLabelMarker"),u}function u(h){return h!==94?n(h):(e.enter("gfmFootnoteCallMarker"),e.consume(h),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",d)}function d(h){if(o>999||h===93&&!a||h===null||h===91||dt(h))return n(h);if(h===93){e.exit("chunkString");const m=e.exit("gfmFootnoteCallString");return s.includes(Wn(r.sliceSerialize(m)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(h),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(h)}return dt(h)||(a=!0),o++,e.consume(h),h===92?p:d}function p(h){return h===91||h===92||h===93?(e.consume(h),o++,d):d(h)}}function ON(e,t,n){const r=this,s=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let o,a=0,c;return u;function u(y){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(y),e.exit("gfmFootnoteDefinitionLabelMarker"),d}function d(y){return y===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(y),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",p):n(y)}function p(y){if(a>999||y===93&&!c||y===null||y===91||dt(y))return n(y);if(y===93){e.exit("chunkString");const S=e.exit("gfmFootnoteDefinitionLabelString");return o=Wn(r.sliceSerialize(S)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(y),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),m}return dt(y)||(c=!0),a++,e.consume(y),y===92?h:p}function h(y){return y===91||y===92||y===93?(e.consume(y),a++,p):p(y)}function m(y){return y===58?(e.enter("definitionMarker"),e.consume(y),e.exit("definitionMarker"),s.includes(o)||s.push(o),Je(e,g,"gfmFootnoteDefinitionWhitespace")):n(y)}function g(y){return t(y)}}function WN(e,t,n){return e.check(po,t,e.attempt(PN,t,n))}function FN(e){e.exit("gfmFootnoteDefinition")}function $N(e,t,n){const r=this;return Je(e,s,"gfmFootnoteDefinitionIndent",5);function s(o){const a=r.events[r.events.length-1];return a&&a[1].type==="gfmFootnoteDefinitionIndent"&&a[2].sliceSerialize(a[1],!0).length===4?t(o):n(o)}}function zN(e){let n=(e||{}).singleTilde;const r={name:"strikethrough",tokenize:o,resolveAll:s};return n==null&&(n=!0),{text:{126:r},insideSpan:{null:[r]},attentionMarkers:{null:[126]}};function s(a,c){let u=-1;for(;++u<a.length;)if(a[u][0]==="enter"&&a[u][1].type==="strikethroughSequenceTemporary"&&a[u][1]._close){let d=u;for(;d--;)if(a[d][0]==="exit"&&a[d][1].type==="strikethroughSequenceTemporary"&&a[d][1]._open&&a[u][1].end.offset-a[u][1].start.offset===a[d][1].end.offset-a[d][1].start.offset){a[u][1].type="strikethroughSequence",a[d][1].type="strikethroughSequence";const p={type:"strikethrough",start:Object.assign({},a[d][1].start),end:Object.assign({},a[u][1].end)},h={type:"strikethroughText",start:Object.assign({},a[d][1].end),end:Object.assign({},a[u][1].start)},m=[["enter",p,c],["enter",a[d][1],c],["exit",a[d][1],c],["enter",h,c]],g=c.parser.constructs.insideSpan.null;g&&bn(m,m.length,0,Ya(g,a.slice(d+1,u),c)),bn(m,m.length,0,[["exit",h,c],["enter",a[u][1],c],["exit",a[u][1],c],["exit",p,c]]),bn(a,d-1,u-d+3,m),u=d+m.length-2;break}}for(u=-1;++u<a.length;)a[u][1].type==="strikethroughSequenceTemporary"&&(a[u][1].type="data");return a}function o(a,c,u){const d=this.previous,p=this.events;let h=0;return m;function m(y){return d===126&&p[p.length-1][1].type!=="characterEscape"?u(y):(a.enter("strikethroughSequenceTemporary"),g(y))}function g(y){const S=oi(d);if(y===126)return h>1?u(y):(a.consume(y),h++,g);if(h<2&&!n)return u(y);const C=a.exit("strikethroughSequenceTemporary"),x=oi(y);return C._open=!x||x===2&&!!S,C._close=!S||S===2&&!!x,c(y)}}}class HN{constructor(){this.map=[]}add(t,n,r){UN(this,t,n,r)}consume(t){if(this.map.sort(function(o,a){return o[0]-a[0]}),this.map.length===0)return;let n=this.map.length;const r=[];for(;n>0;)n-=1,r.push(t.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),t.length=this.map[n][0];r.push(t.slice()),t.length=0;let s=r.pop();for(;s;){for(const o of s)t.push(o);s=r.pop()}this.map.length=0}}function UN(e,t,n,r){let s=0;if(!(n===0&&r.length===0)){for(;s<e.map.length;){if(e.map[s][0]===t){e.map[s][1]+=n,e.map[s][2].push(...r);return}s+=1}e.map.push([t,n,r])}}function qN(e,t){let n=!1;const r=[];for(;t<e.length;){const s=e[t];if(n){if(s[0]==="enter")s[1].type==="tableContent"&&r.push(e[t+1][1].type==="tableDelimiterMarker"?"left":"none");else if(s[1].type==="tableContent"){if(e[t-1][1].type==="tableDelimiterMarker"){const o=r.length-1;r[o]=r[o]==="left"?"center":"right"}}else if(s[1].type==="tableDelimiterRow")break}else s[0]==="enter"&&s[1].type==="tableDelimiterRow"&&(n=!0);t+=1}return r}function GN(){return{flow:{null:{name:"table",tokenize:VN,resolveAll:KN}}}}function VN(e,t,n){const r=this;let s=0,o=0,a;return c;function c(E){let $=r.events.length-1;for(;$>-1;){const X=r.events[$][1].type;if(X==="lineEnding"||X==="linePrefix")$--;else break}const B=$>-1?r.events[$][1].type:null,re=B==="tableHead"||B==="tableRow"?T:u;return re===T&&r.parser.lazy[r.now().line]?n(E):re(E)}function u(E){return e.enter("tableHead"),e.enter("tableRow"),d(E)}function d(E){return E===124||(a=!0,o+=1),p(E)}function p(E){return E===null?n(E):Ee(E)?o>1?(o=0,r.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(E),e.exit("lineEnding"),g):n(E):ze(E)?Je(e,p,"whitespace")(E):(o+=1,a&&(a=!1,s+=1),E===124?(e.enter("tableCellDivider"),e.consume(E),e.exit("tableCellDivider"),a=!0,p):(e.enter("data"),h(E)))}function h(E){return E===null||E===124||dt(E)?(e.exit("data"),p(E)):(e.consume(E),E===92?m:h)}function m(E){return E===92||E===124?(e.consume(E),h):h(E)}function g(E){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(E):(e.enter("tableDelimiterRow"),a=!1,ze(E)?Je(e,y,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(E):y(E))}function y(E){return E===45||E===58?C(E):E===124?(a=!0,e.enter("tableCellDivider"),e.consume(E),e.exit("tableCellDivider"),S):P(E)}function S(E){return ze(E)?Je(e,C,"whitespace")(E):C(E)}function C(E){return E===58?(o+=1,a=!0,e.enter("tableDelimiterMarker"),e.consume(E),e.exit("tableDelimiterMarker"),x):E===45?(o+=1,x(E)):E===null||Ee(E)?G(E):P(E)}function x(E){return E===45?(e.enter("tableDelimiterFiller"),A(E)):P(E)}function A(E){return E===45?(e.consume(E),A):E===58?(a=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(E),e.exit("tableDelimiterMarker"),j):(e.exit("tableDelimiterFiller"),j(E))}function j(E){return ze(E)?Je(e,G,"whitespace")(E):G(E)}function G(E){return E===124?y(E):E===null||Ee(E)?!a||s!==o?P(E):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(E)):P(E)}function P(E){return n(E)}function T(E){return e.enter("tableRow"),K(E)}function K(E){return E===124?(e.enter("tableCellDivider"),e.consume(E),e.exit("tableCellDivider"),K):E===null||Ee(E)?(e.exit("tableRow"),t(E)):ze(E)?Je(e,K,"whitespace")(E):(e.enter("data"),U(E))}function U(E){return E===null||E===124||dt(E)?(e.exit("data"),K(E)):(e.consume(E),E===92?L:U)}function L(E){return E===92||E===124?(e.consume(E),U):U(E)}}function KN(e,t){let n=-1,r=!0,s=0,o=[0,0,0,0],a=[0,0,0,0],c=!1,u=0,d,p,h;const m=new HN;for(;++n<e.length;){const g=e[n],y=g[1];g[0]==="enter"?y.type==="tableHead"?(c=!1,u!==0&&(Sh(m,t,u,d,p),p=void 0,u=0),d={type:"table",start:Object.assign({},y.start),end:Object.assign({},y.end)},m.add(n,0,[["enter",d,t]])):y.type==="tableRow"||y.type==="tableDelimiterRow"?(r=!0,h=void 0,o=[0,0,0,0],a=[0,n+1,0,0],c&&(c=!1,p={type:"tableBody",start:Object.assign({},y.start),end:Object.assign({},y.end)},m.add(n,0,[["enter",p,t]])),s=y.type==="tableDelimiterRow"?2:p?3:1):s&&(y.type==="data"||y.type==="tableDelimiterMarker"||y.type==="tableDelimiterFiller")?(r=!1,a[2]===0&&(o[1]!==0&&(a[0]=a[1],h=Go(m,t,o,s,void 0,h),o=[0,0,0,0]),a[2]=n)):y.type==="tableCellDivider"&&(r?r=!1:(o[1]!==0&&(a[0]=a[1],h=Go(m,t,o,s,void 0,h)),o=a,a=[o[1],n,0,0])):y.type==="tableHead"?(c=!0,u=n):y.type==="tableRow"||y.type==="tableDelimiterRow"?(u=n,o[1]!==0?(a[0]=a[1],h=Go(m,t,o,s,n,h)):a[1]!==0&&(h=Go(m,t,a,s,n,h)),s=0):s&&(y.type==="data"||y.type==="tableDelimiterMarker"||y.type==="tableDelimiterFiller")&&(a[3]=n)}for(u!==0&&Sh(m,t,u,d,p),m.consume(t.events),n=-1;++n<t.events.length;){const g=t.events[n];g[0]==="enter"&&g[1].type==="table"&&(g[1]._align=qN(t.events,n))}return e}function Go(e,t,n,r,s,o){const a=r===1?"tableHeader":r===2?"tableDelimiter":"tableData",c="tableContent";n[0]!==0&&(o.end=Object.assign({},Gs(t.events,n[0])),e.add(n[0],0,[["exit",o,t]]));const u=Gs(t.events,n[1]);if(o={type:a,start:Object.assign({},u),end:Object.assign({},u)},e.add(n[1],0,[["enter",o,t]]),n[2]!==0){const d=Gs(t.events,n[2]),p=Gs(t.events,n[3]),h={type:c,start:Object.assign({},d),end:Object.assign({},p)};if(e.add(n[2],0,[["enter",h,t]]),r!==2){const m=t.events[n[2]],g=t.events[n[3]];if(m[1].end=Object.assign({},g[1].end),m[1].type="chunkText",m[1].contentType="text",n[3]>n[2]+1){const y=n[2]+1,S=n[3]-n[2]-1;e.add(y,S,[])}}e.add(n[3]+1,0,[["exit",h,t]])}return s!==void 0&&(o.end=Object.assign({},Gs(t.events,s)),e.add(s,0,[["exit",o,t]]),o=void 0),o}function Sh(e,t,n,r,s){const o=[],a=Gs(t.events,n);s&&(s.end=Object.assign({},a),o.push(["exit",s,t])),r.end=Object.assign({},a),o.push(["exit",r,t]),e.add(n+1,0,o)}function Gs(e,t){const n=e[t],r=n[0]==="enter"?"start":"end";return n[1][r]}const YN={name:"tasklistCheck",tokenize:JN};function XN(){return{text:{91:YN}}}function JN(e,t,n){const r=this;return s;function s(u){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(u):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(u),e.exit("taskListCheckMarker"),o)}function o(u){return dt(u)?(e.enter("taskListCheckValueUnchecked"),e.consume(u),e.exit("taskListCheckValueUnchecked"),a):u===88||u===120?(e.enter("taskListCheckValueChecked"),e.consume(u),e.exit("taskListCheckValueChecked"),a):n(u)}function a(u){return u===93?(e.enter("taskListCheckMarker"),e.consume(u),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),c):n(u)}function c(u){return Ee(u)?t(u):ze(u)?e.check({tokenize:QN},t,n)(u):n(u)}}function QN(e,t,n){return Je(e,r,"whitespace");function r(s){return s===null?n(s):t(s)}}function ZN(e){return wm([CN(),LN(),zN(e),GN(),XN()])}const ej={};function tj(e){const t=this,n=e||ej,r=t.data(),s=r.micromarkExtensions||(r.micromarkExtensions=[]),o=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),a=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);s.push(ZN(n)),o.push(xN()),a.push(wN(n))}const nj="X-CodingNS-Assistant-Source",rj="butler-ui",Kl=new Map;async function pr(e,t={},n={}){const r=new Headers(t.headers);r.set(nj,rj);const s=sj();if(Kl.get(s)===!1){if(n.unsupportedFallback!==void 0)return Ch(n.unsupportedFallback);throw Nh()}try{const a=await ye.request(e,{...t,headers:r});return Kl.set(s,!0),a}catch(a){if(!ij(a))throw a;if(Kl.set(s,!1),n.unsupportedFallback!==void 0)return Ch(n.unsupportedFallback);throw Nh()}}function sj(){return Jc()}function Ch(e){return typeof e=="function"?e():e}function ij(e){return e instanceof Zc&&(e.status===404||e.status===405||e.status===501)}function Nh(){return new Error("当前 Host 版本不支持新版助手接口,请先升级 Host。")}function oj(){return ye.request("/api/butler/profile")}function NP(e){return ye.request("/api/butler/profile/init",{method:"POST",body:JSON.stringify(e)})}function jP(e){return ye.request("/api/butler/profile",{method:"PATCH",body:JSON.stringify(e)})}function TP(){return ye.request("/api/butler/control-session")}function IP(){return ye.request("/api/butler/control-sessions")}function EP(e){return ye.request(`/api/butler/control-sessions/${encodeURIComponent(e)}`)}function MP(e={}){var s;const t=new URLSearchParams;e.status&&t.set("status",e.status),(s=e.controlSessionId)!=null&&s.trim()&&t.set("controlSessionId",e.controlSessionId.trim()),e.limit&&e.limit>0&&t.set("limit",String(e.limit));const n=t.toString(),r=n?`/api/butler/control-timers?${n}`:"/api/butler/control-timers";return ye.request(r)}function RP(){return ye.request("/api/butler/control-session/reset",{method:"POST"})}function AP(e={}){return ye.request("/api/butler/control-session/start",{method:"POST",body:JSON.stringify(e)})}function PP(e){return ye.request("/api/butler/control-session/messages",{method:"POST",body:JSON.stringify(e)})}function LP(e={}){var s;const t=new URLSearchParams;e.status&&t.set("status",e.status),(s=e.controlSessionId)!=null&&s.trim()&&t.set("controlSessionId",e.controlSessionId.trim()),e.limit&&e.limit>0&&t.set("limit",String(e.limit));const n=t.toString(),r=n?`/api/assistant/automations?${n}`:"/api/assistant/automations";return pr(r,{},{unsupportedFallback:()=>({payload:{items:[]}})})}function _P(e={}){var s;const t=new URLSearchParams;(s=e.controlSessionId)!=null&&s.trim()&&t.set("controlSessionId",e.controlSessionId.trim()),e.limit&&e.limit>0&&t.set("limit",String(e.limit));const n=t.toString(),r=n?`/api/assistant/automations/runs/recent?${n}`:"/api/assistant/automations/runs/recent";return pr(r,{},{unsupportedFallback:()=>({payload:{items:[]}})})}function DP(e){return pr(`/api/assistant/automations/${encodeURIComponent(e)}/cancel`,{method:"POST",body:JSON.stringify({})})}function BP(e,t){return pr(`/api/assistant/automations/${encodeURIComponent(e)}`,{method:"PATCH",body:JSON.stringify(t)})}function OP(e){return pr(`/api/assistant/automations/${encodeURIComponent(e)}/skip-wait`,{method:"POST",body:JSON.stringify({})})}function WP(e={}){var s;const t=new URLSearchParams;e.status&&t.set("status",e.status),(s=e.controlSessionId)!=null&&s.trim()&&t.set("controlSessionId",e.controlSessionId.trim());const n=t.toString(),r=n?`/api/assistant/sandboxes?${n}`:"/api/assistant/sandboxes";return pr(r,{},{unsupportedFallback:()=>({payload:{items:[]}})})}function FP(e){return pr(`/api/assistant/sandboxes/${encodeURIComponent(e.sandboxId)}/promote`,{method:"POST",body:JSON.stringify({mode:e.mode,projectName:e.projectName,defaultProvider:e.defaultProvider})})}function $P(e){return pr(`/api/assistant/sandboxes/${encodeURIComponent(e)}/expire`,{method:"POST",body:JSON.stringify({})})}function zP(e){return pr(`/api/assistant/sandboxes/${encodeURIComponent(e)}`,{method:"DELETE"})}function HP(e){return ye.request(`/api/butler/control-timers/${encodeURIComponent(e)}/cancel`,{method:"POST",body:JSON.stringify({})})}function UP(){return ye.request("/api/butler/control-session/events")}function aj(){return ye.request("/api/butler/overview")}function lj(e={}){var s;const t=new URLSearchParams;(s=e.workspaceId)!=null&&s.trim()&&t.set("workspaceId",e.workspaceId.trim()),e.status&&t.set("status",e.status),e.riskLevel&&t.set("riskLevel",e.riskLevel);const n=t.toString(),r=n?`/api/butler/projects?${n}`:"/api/butler/projects";return ye.request(r)}function qP(e,t={}){const n=new URLSearchParams;t.enabled!==null&&t.enabled!==void 0&&n.set("enabled",String(t.enabled)),t.executionMode&&n.set("executionMode",t.executionMode);const r=n.toString(),s=r?`/api/butler/projects/${encodeURIComponent(e)}/patrol-plans?${r}`:`/api/butler/projects/${encodeURIComponent(e)}/patrol-plans`;return ye.request(s)}function dg(e={}){var s,o;const t=new URLSearchParams;(s=e.workspaceId)!=null&&s.trim()&&t.set("workspaceId",e.workspaceId.trim()),(o=e.projectId)!=null&&o.trim()&&t.set("projectId",e.projectId.trim()),e.status&&t.set("status",e.status),e.itemType&&t.set("itemType",e.itemType);const n=t.toString(),r=n?`/api/butler/inbox?${n}`:"/api/butler/inbox";return ye.request(r)}function cj(e){return ye.request("/api/butler/inbox",{method:"POST",body:JSON.stringify(e)})}function uj(e={}){var s,o;const t=new URLSearchParams;e.status&&t.set("status",e.status),(s=e.projectId)!=null&&s.trim()&&t.set("projectId",e.projectId.trim()),(o=e.sessionId)!=null&&o.trim()&&t.set("sessionId",e.sessionId.trim());const n=t.toString(),r=n?`/api/butler/follow-up-tasks?${n}`:"/api/butler/follow-up-tasks";return ye.request(r)}function GP(e){return ye.request("/api/butler/follow-up-tasks",{method:"POST",body:JSON.stringify(e)})}function dj(e){return ye.request(`/api/butler/follow-up-tasks/${encodeURIComponent(e)}`)}function VP(e){return ye.request(`/api/butler/follow-up-tasks/${encodeURIComponent(e)}/cancel`,{method:"POST"})}function KP(e,t){return ye.request(`/api/butler/projects/${encodeURIComponent(e)}/verifications/${encodeURIComponent(t)}/cancel`,{method:"POST"})}function jh(e,t){return ye.request(`/api/butler/inbox/${encodeURIComponent(e)}`,{method:"PATCH",body:JSON.stringify({projectId:t.projectId,itemType:t.itemType,title:t.title,content:t.content,priority:t.priority,status:t.status})})}function YP(e){return ye.request(`/api/butler/inbox/${encodeURIComponent(e)}/analyze`,{method:"POST",body:JSON.stringify({})})}function XP(e){return ye.request(`/api/butler/inbox/${encodeURIComponent(e)}/start-session`,{method:"POST",body:JSON.stringify({})})}function hj(e){return ye.request(`/api/butler/inbox/${encodeURIComponent(e)}`,{method:"DELETE"})}function pj(){return ye.request("/api/butler/notifications/archives")}function fj(e,t){return ye.request(`/api/butler/notifications/archives/${encodeURIComponent(e)}`,{method:"PATCH",body:JSON.stringify({archived:t})})}function mj(e){const t=new URLSearchParams;return t.set("sessionId",e),ye.request(`/api/butler/session-target?${t.toString()}`)}function JP(e){const t=new URLSearchParams;return t.set("sessionId",e),ye.request(`/api/butler/session-action-context?${t.toString()}`)}function QP(e){return ye.request("/api/butler/actions/start-verification",{method:"POST",body:JSON.stringify(e)})}const Ma="*** Begin Patch",Ra="*** End Patch";function Th(e){const t=e.replace(/\r\n/g,`
|
|
33
|
+
`);if(!t.includes(Ma)||!t.includes(Ra))return null;const n=t.split(`
|
|
34
|
+
`),r=[];let s=null,o=null;for(const a of n){if(a===Ma||a===Ra)continue;if(a.startsWith("*** Update File: ")){s=Yl("update",a.slice(17)),r.push(s),o=null;continue}if(a.startsWith("*** Add File: ")){s=Yl("add",a.slice(14)),r.push(s),o={oldLineNumber:0,newLineNumber:1};continue}if(a.startsWith("*** Delete File: ")){s=Yl("delete",a.slice(17)),r.push(s),o=null;continue}if(!s)continue;if(a.startsWith("*** Move to: ")){s.nextPath=a.slice(13),s.lines.push({kind:"meta",text:a,oldLineNumber:null,newLineNumber:null});continue}if(a.startsWith("@@")){o=kj(a)??{oldLineNumber:0,newLineNumber:0},s.lines.push({kind:"hunk",text:a,oldLineNumber:null,newLineNumber:null});continue}if(a==="*** End of File"){s.lines.push({kind:"meta",text:a,oldLineNumber:null,newLineNumber:null});continue}if(s.action==="add"&&a.startsWith("+")){s.additions+=1,s.statsKnown=!0,s.lines.push({kind:"add",text:a,oldLineNumber:null,newLineNumber:(o==null?void 0:o.newLineNumber)??s.additions}),o&&(o.newLineNumber+=1);continue}if(!o){s.lines.push({kind:"meta",text:a,oldLineNumber:null,newLineNumber:null});continue}if(a.startsWith("+")){s.additions+=1,s.statsKnown=!0,s.lines.push({kind:"add",text:a,oldLineNumber:null,newLineNumber:o.newLineNumber}),o.newLineNumber+=1;continue}if(a.startsWith("-")){s.deletions+=1,s.statsKnown=!0,s.lines.push({kind:"remove",text:a,oldLineNumber:o.oldLineNumber,newLineNumber:null}),o.oldLineNumber+=1;continue}if(a.startsWith(" ")||a.length===0){s.lines.push({kind:"context",text:a,oldLineNumber:o.oldLineNumber,newLineNumber:o.newLineNumber}),o.oldLineNumber+=1,o.newLineNumber+=1;continue}s.lines.push({kind:"meta",text:a,oldLineNumber:null,newLineNumber:null})}return r.length===0?null:{files:r,totalAdditions:r.reduce((a,c)=>a+c.additions,0),totalDeletions:r.reduce((a,c)=>a+c.deletions,0)}}function gj(e,t=[]){const n=e.replace(/\r\n/g,`
|
|
35
|
+
`).trim();if(!n)return null;if(n.includes(Ma)&&n.includes(Ra))return n;const r=[...new Set(t.map(s=>s.trim()).filter(s=>s.length>0))];return r.length!==1||!yj(n)?null:[Ma,`*** Update File: ${r[0]}`,n,Ra].join(`
|
|
36
|
+
`)}function bj(e){const t=xj(e);if(!t)return[];const n=t.replace(/\r\n/g,`
|
|
37
|
+
`).split(`
|
|
38
|
+
`),r=[];let s=!1;for(const o of n){const a=o.trim();if(!s){/^Success\.\s+Updated the following files:/i.test(a)&&(s=!0);continue}if(!a){if(r.length>0)break;continue}const c=a.match(/^[A-Z?]\s+(.+)$/),u=((c==null?void 0:c[1])??a).trim();if(!u)break;r.push(u)}return[...new Set(r)]}function Ih(e){return e.replace(/\\/g,"/").split("/").at(-1)||e}function Yl(e,t){return{path:t,nextPath:null,action:e,additions:0,deletions:0,statsKnown:!1,lines:[]}}function kj(e){const t=e.match(/^@@\s+-(\d+)(?:,\d+)?\s+\+(\d+)(?:,\d+)?\s+@@/);return t?{oldLineNumber:Number(t[1]),newLineNumber:Number(t[2])}:null}function yj(e){return e.startsWith("@@")||e.startsWith("*** Update File: ")||e.startsWith("*** Add File: ")||e.startsWith("*** Delete File: ")||e.includes(`
|
|
39
|
+
@@`)||e.startsWith("+")||e.startsWith("-")}function xj(e){const t=e.trim();if(!t)return"";if(!t.startsWith("{"))return t;try{const n=JSON.parse(t);if(!n||typeof n!="object"||Array.isArray(n))return t;const r=n;if(typeof r.output=="string"&&r.output.trim().length>0)return r.output;if(typeof r.result=="string"&&r.result.trim().length>0)return r.result;if(typeof r.message=="string"&&r.message.trim().length>0)return r.message}catch{return t}return t}const wj=/data:image\/([a-zA-Z0-9.+-]+);base64,([A-Za-z0-9+/=]+)/g,vj=/!\[([^\]]*)\]\((data:image\/[a-zA-Z0-9.+-]+;base64,[A-Za-z0-9+/=]+)\)/g,Sj=/<img\b[^>]*src=["'](data:image\/[a-zA-Z0-9.+-]+;base64,[A-Za-z0-9+/=]+)["'][^>]*>/gi,Cj=/<image\b([^>]*)>([\s\S]*?)<\/image>/gi,Nj=/\[\[CODINGNS_IMAGE_ATTACHMENTS\]\][\s\S]*?\[\[\/CODINGNS_IMAGE_ATTACHMENTS\]\]/g,Eh=/```question\s*([\s\S]*?)```/i;function to(e){const t=Tj(e),n=jj(t);if(n)return n;const r=Ij(t);return r||{...pg(t),structuredQuestions:null}}function jj(e){var r;const t=e.match(Eh);if(!t)return null;const n=((r=t[1])==null?void 0:r.trim())??"";if(!n)return null;try{const s=JSON.parse(n),o=hg(s);return o?{text:Bu(e.replace(Eh,"").trim()),inlineImages:[],structuredQuestions:o}:null}catch{return null}}function Tj(e){return e.replace(Nj,"")}function Ij(e){const t=e.trim();if(!Mj(t))return null;try{const n=JSON.parse(t),r=hg(n),s=Rj(r?Ej(n):n);return s.text||s.inlineImages.length>0||r?{...s,structuredQuestions:r}:null}catch{return null}}function Ej(e){const t=mo(e);if(!t||!("questions"in t))return e;const{questions:n,...r}=t;return r}function Mj(e){return e.length<2?!1:e.startsWith("[")&&e.endsWith("]")||e.startsWith("{")&&e.endsWith("}")}function Rj(e){const t=[],n=[];return ba(e,t,n),{text:Bu(t.join(`
|
|
40
|
+
|
|
41
|
+
`)),inlineImages:fg(n),structuredQuestions:null}}function hg(e){const t=mo(e);if(!t)return null;const n=Aj(t.questions);return n.length===0?null:{questions:n}}function Aj(e){return Array.isArray(e)?e.map((t,n)=>Pj(t,n)).filter(t=>t!==null):[]}function Pj(e,t){const n=mo(e);if(!n)return null;const r=tr(Ft(n.question));if(!r)return null;const s=Lj(n.options);return s.length===0?null:{id:tr(Ft(n.id))??`structured-question-${t+1}`,header:tr(Ft(n.header))??"问题",question:r,allowOther:!!(n.allowOther??n.isOther),secret:!!(n.secret??n.isSecret),options:s}}function Lj(e){return Array.isArray(e)?e.map(t=>{const n=mo(t);if(!n)return null;const r=tr(Ft(n.label));return r?{label:r,description:tr(Ft(n.description))}:null}).filter(t=>t!==null):[]}function ba(e,t,n){if(typeof e=="string"){const a=pg(e);a.text&&t.push(a.text),n.push(...a.inlineImages);return}if(e==null)return;if(Array.isArray(e)){e.forEach(a=>ba(a,t,n));return}if(typeof e!="object")return;const r=e,s=new Set,o=_j(r);o&&(n.push(o),["type","source","media_type","mime_type","mimeType","data","image_url","imageUrl","url","src","alt","name"].forEach(a=>{a in r&&s.add(a)}));for(const a of["image_url","url","src","source"]){const c=r[a];typeof c!="string"||!mg(c)||(n.push(cs(c,Ft(r.alt))),s.add(a))}for(const a of["text","message","content","output","result","summary","caption"])a in r&&(s.add(a),ba(r[a],t,n));s.size>0||Object.values(r).forEach(a=>{ba(a,t,n)})}function pg(e){const t=[];let n=e;return n=n.replace(Cj,(r,s,o)=>{const a=Wj(s,"name"),c=Oj(o);return c!=null&&c.url&&t.push(cs(c.url,c.altText||a)),""}),n=n.replace(vj,(r,s,o)=>(t.push(cs(o,s)),"")),n=n.replace(Sj,(r,s)=>(t.push(cs(s,null)),"")),n=n.replace(wj,(r,s,o)=>(t.push(cs(r,null,`image/${s}`,Aa(o))),"")),{text:Bu(n),inlineImages:fg(t),structuredQuestions:null}}function cs(e,t,n,r){const s=n??Dj(e)??"image/png";return{url:e,mimeType:s,altText:tr(t),estimatedBytes:r??Bj(e)}}function _j(e){const t=mo(e.source);if(t){const s=Ft(t.type).trim().toLowerCase(),o=Rh(t.media_type??t.mime_type??t.mimeType),a=Mh(t.data);if(s==="base64"&&o&&a)return cs(`data:${o};base64,${a}`,tr(Ft(t.alt)||Ft(t.name)||Ft(e.alt)||Ft(e.name)),o,Aa(a))}const n=Rh(e.media_type??e.mime_type??e.mimeType),r=Mh(e.data);return n&&r?cs(`data:${n};base64,${r}`,tr(Ft(e.alt)||Ft(e.name)),n,Aa(r)):null}function fg(e){const t=new Map;return e.forEach(n=>{t.has(n.url)||t.set(n.url,n)}),[...t.values()]}function Bu(e){return e.replace(/\r\n/g,`
|
|
42
|
+
`).replace(/[ \t]{2,}/g," ").replace(/[ \t]+\n/g,`
|
|
43
|
+
`).replace(/\n{3,}/g,`
|
|
44
|
+
|
|
45
|
+
`).trim()}function mg(e){return/^data:image\/[a-zA-Z0-9.+-]+;base64,[A-Za-z0-9+/=]+$/.test(e.trim())}function Dj(e){var n;const t=e.match(/^data:(image\/[a-zA-Z0-9.+-]+);base64,/i);return((n=t==null?void 0:t[1])==null?void 0:n.toLowerCase())??null}function Bj(e){const t=e.match(/^data:image\/[a-zA-Z0-9.+-]+;base64,([A-Za-z0-9+/=]+)$/i);return t?Aa(t[1]):null}function Aa(e){const t=e.trim(),n=t.endsWith("==")?2:t.endsWith("=")?1:0;return Math.max(0,Math.floor(t.length*3/4)-n)}function tr(e){const t=Ft(e).trim();return t.length>0?t:null}function Mh(e){if(typeof e!="string")return null;const t=e.replace(/\s+/g,"").trim();return/^[A-Za-z0-9+/=]+$/.test(t)?t:null}function Rh(e){if(typeof e!="string")return null;const t=e.trim().toLowerCase();return t.startsWith("image/")?t:null}function Ft(e){return typeof e=="string"?e:""}function mo(e){return!e||typeof e!="object"||Array.isArray(e)?null:e}function Oj(e){const t=e.trim();if(t.length===0)return null;try{const n=JSON.parse(t),r=Ft(n.image_url??n.imageUrl).trim(),s=tr(Ft(n.name)||Ft(n.alt));return{url:mg(r)?r:null,altText:s}}catch{const n=t.match(/(data:image\/[a-zA-Z0-9.+-]+;base64,[A-Za-z0-9+/=]+)/i);return n?{url:n[1],altText:null}:null}}function Wj(e,t){const n=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),r=e.match(new RegExp(`${n}\\s*=\\s*(?:"([^"]*)"|'([^']*)'|\\[([^\\]]*)\\]|([^\\s>]+))`,"i"));return tr((r==null?void 0:r[1])??(r==null?void 0:r[2])??(r==null?void 0:r[3])??(r==null?void 0:r[4])??"")}const Fj=new Set(["updateplan"]),gg=new Set(["todowrite"]),Lc=new Set(["todoread"]),bg=new Set(["taskcreate","taskupdate","taskget","tasklist","taskdelete","taskremove"]);function ZP(e,t){const n=Hj(e,t);return n||Uj(e,t)}function $j(e){return e.reduce((t,n)=>(t[n.status]+=1,t),{pending:0,in_progress:0,completed:0,failed:0,cancelled:0})}function zj(e,t,n){if(!e)return null;if(_c(e.name)){const a=ri(e);if(!a||!el(a.value))return null;const c=kg(a.value,n);return!c||c.items.length===0?null:{provider:t,source:"plan",explanation:c.explanation,items:c.items,updatedAt:n}}const r=Za(e.name);if(!gg.has(r)&&!Lc.has(r)&&!bg.has(r))return null;const s=ri(e,(Lc.has(r),"prefer-output"));if(!s)return null;if(r==="taskdelete"||r==="taskremove"){const a=yg(s.value);return a.length>0?{provider:t,source:"todo",explanation:null,items:a.map((c,u)=>({id:c,title:`Task ${u+1}`,status:"cancelled",detail:c,updatedAt:n})),updatedAt:n}:null}const o=Wi(s.value,n);return o.length===0?null:{provider:t,source:_c(e.name)?"plan":"todo",explanation:null,items:o,updatedAt:n}}function Hj(e,t){let n=null;for(const r of e){const s=r.toolCall;if(!s||Za(s.name)===""||!_c(s.name))continue;const o=ri(s);if(!o||typeof o.value!="object"||o.value===null)continue;const a=kg(o.value,r.timestamp);!a||a.items.length===0||(n={provider:t,source:"plan",explanation:a.explanation,items:a.items,updatedAt:r.timestamp})}return n}function Uj(e,t){const n=new Map;let r=null;for(const o of e){const a=o.toolCall;if(!a)continue;const c=Za(a.name);if(gg.has(c)){const p=ri(a),h=p?Wi(p.value,o.timestamp):[];h.length>0&&(Xl(n,h),r=o.timestamp);continue}if(Lc.has(c)){const p=ri(a,"prefer-output"),h=p?Wi(p.value,o.timestamp):[];h.length>0&&(Xl(n,h),r=o.timestamp);continue}if(!bg.has(c))continue;const u=ri(a,"prefer-output");if(!u)continue;if(c==="tasklist"||c==="taskget"){const p=Wi(u.value,o.timestamp);p.length>0&&(Xl(n,p),r=o.timestamp);continue}if(c==="taskdelete"||c==="taskremove"){const p=yg(u.value);if(p.length>0){for(const h of p)n.delete(h);r=o.timestamp}continue}const d=Wi(u.value,o.timestamp);if(d.length!==0){for(const p of d)Gj(n,p);r=o.timestamp}}const s=Array.from(n.values()).sort((o,a)=>o.updatedAt.localeCompare(a.updatedAt)).map(o=>({...o}));return s.length===0||!r?null:{provider:t,source:"todo",explanation:null,items:s,updatedAt:r}}function _c(e){return Fj.has(Za(e))}function kg(e,t){const n=Array.isArray(e.plan)?e.plan:null;if(!n||n.length===0)return null;const r=n.map((s,o)=>xg(s,{fallbackIdPrefix:"plan",fallbackTitle:`Step ${o+1}`,fallbackStatus:"pending",updatedAt:t})).filter(s=>s!==null);return r.length===0?null:{items:r,explanation:Ct(e.explanation)}}function ri(e,t="prefer-input"){const n=t==="prefer-output"?[{text:e.output,source:"output"},{text:e.input,source:"input"}]:[{text:e.input,source:"input"},{text:e.output,source:"output"}];for(const r of n){const s=qj(r.text);if(s!==null)return{value:s,source:r.source}}return null}function qj(e){const t=(e==null?void 0:e.trim())??"";if(!t)return null;const n=Vo(t);if(n!==null)return n;const r=t.match(/```(?:json)?\s*([\s\S]+?)```/i);if(r!=null&&r[1]){const u=Vo(r[1].trim());if(u!==null)return u}const s=t.indexOf("{"),o=t.lastIndexOf("}");if(s>=0&&o>s){const u=Vo(t.slice(s,o+1));if(u!==null)return u}const a=t.indexOf("["),c=t.lastIndexOf("]");return a>=0&&c>a?Vo(t.slice(a,c+1)):null}function Vo(e){try{return JSON.parse(e)}catch{return null}}function Wi(e,t){return Yi(e).map((r,s)=>xg(r,{fallbackIdPrefix:"task",fallbackTitle:`Task ${s+1}`,fallbackStatus:"pending",updatedAt:t})).filter(r=>r!==null)}function Yi(e){if(Array.isArray(e))return e.flatMap(n=>Yi(n));if(!el(e))return[];if(Xj(e))return[e];const t=["tasks","todos","items","entries","results","data"];for(const n of t){if(!(n in e))continue;const r=Yi(e[n]);if(r.length>0)return r}return Object.values(e).flatMap(n=>Yi(n))}function yg(e){const n=Yi(e).map(s=>Dc(s)).filter(s=>s!==null);if(n.length>0)return n;if(!el(e))return[];const r=Dc(e);return r?[r]:[]}function xg(e,t){if(!el(e))return null;const n=Ct(e.step)??Ct(e.title)??Ct(e.content)??Ct(e.task)??Ct(e.text)??Ct(e.name)??Ct(e.subject)??Ct(e.description)??t.fallbackTitle,r=Dc(e)??Yj(t.fallbackIdPrefix,n),s=Kj(e,n);return{id:r,title:n,status:Vj(e.status,t.fallbackStatus),detail:s,updatedAt:t.updatedAt}}function Gj(e,t){const n=e.get(t.id);if(!n){e.set(t.id,{...t});return}e.set(t.id,{id:n.id,title:t.title||n.title,status:t.status,detail:t.detail??n.detail,updatedAt:t.updatedAt})}function Xl(e,t){e.clear();for(const n of t)e.set(n.id,{...n})}function Vj(e,t){var r;const n=(r=Ct(e))==null?void 0:r.toLowerCase().replace(/[\s-]+/g,"_");return n?["pending","todo","open","queued","not_started","created"].includes(n)?"pending":["in_progress","progress","active","doing","running","started"].includes(n)?"in_progress":["completed","complete","done","success","succeeded","finished","closed"].includes(n)?"completed":["failed","error","errored"].includes(n)?"failed":["cancelled","canceled","aborted","skipped"].includes(n)?"cancelled":t:t}function Kj(e,t){const n=[Ct(e.detail),Ct(e.details),Ct(e.description),Ct(e.reason),Ct(e.summary),Ct(e.note),Ct(e.priority)].filter(r=>r!==null);for(const r of n)if(r!==t)return r;return null}function Dc(e){return Ct(e.id)??Ct(e.taskId)??Ct(e.task_id)??Ct(e.uuid)??Ct(e.key)}function Yj(e,t){return`${e}:${t.trim().toLowerCase()}`}function Xj(e){return[e.step,e.title,e.content,e.task,e.text,e.subject,e.name,e.description].some(t=>Ct(t)!==null)}function Za(e){return e.trim().toLowerCase().replace(/[\s_.-]+/g,"")}function el(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Ct(e){if(typeof e!="string")return null;const t=e.trim();return t||null}function Jj({snapshot:e,toolName:t="",expanded:n=!1,exportMode:r=!1,className:s,children:o,onToggleExpanded:a}){const c=$j(e.items),u=n?l("conversation.taskCardRawCollapse"):l("conversation.taskCardRawExpand"),d=s?`tool-call-item task-tool-item ${s}`:"tool-call-item task-tool-item";return i.jsxs("div",{className:d,children:[i.jsxs("div",{className:"task-tool-header",children:[i.jsxs("div",{className:"task-tool-heading",children:[i.jsx("span",{className:"task-tool-badge",children:e.source==="plan"?l("conversation.taskCardPlanTitle"):l("conversation.taskCardTodoTitle")}),i.jsxs("div",{className:"task-tool-heading-main",children:[i.jsx("strong",{children:Qj(e,t)}),i.jsx("span",{className:"task-tool-summary-text",children:Zj(e.items,c)})]})]}),!r&&a?i.jsx("button",{type:"button",className:"task-tool-raw-toggle",onClick:a,children:u}):null]}),i.jsx("ol",{className:"task-tool-list",children:e.items.map(p=>i.jsxs("li",{className:"task-tool-list-item","data-status":p.status,children:[i.jsx("span",{className:"task-tool-item-indicator","data-status":p.status,"aria-hidden":"true"}),i.jsx("strong",{className:"task-tool-item-title",children:p.title}),p.detail?i.jsx("span",{className:"task-tool-item-detail",children:p.detail}):null,i.jsx("span",{className:"task-tool-item-status",children:eT(p.status)})]},p.id))}),o]})}function Qj(e,t){if(e.source==="plan")return l("conversation.taskCardPlanUpdated");const n=t.trim().toLowerCase();return n==="taskcreate"||n==="todowrite"||n==="todoread"?l("conversation.taskCardTodoUpdated"):n.startsWith("task")?l("conversation.taskCardTodoUpdated"):l("conversation.taskCardTodoUpdated")}function Zj(e,t){const n=[l("conversation.taskCardSummaryTotal",{count:e.length})];return t.in_progress>0&&n.push(l("conversation.taskCardSummaryInProgress",{count:t.in_progress})),t.pending>0&&n.push(l("conversation.taskCardSummaryPending",{count:t.pending})),t.completed>0&&n.push(l("conversation.taskCardSummaryCompleted",{count:t.completed})),t.failed>0&&n.push(l("conversation.taskCardSummaryFailed",{count:t.failed})),n.join(" / ")}function eT(e){switch(e){case"in_progress":return l("conversation.taskProgressStatusInProgress");case"completed":return l("conversation.taskProgressStatusCompleted");case"failed":return l("conversation.taskProgressStatusFailed");case"cancelled":return l("conversation.taskProgressStatusCancelled");case"pending":default:return l("conversation.taskProgressStatusPending")}}function tT(){return i.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 20 20",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round",className:"conversation-action-icon",children:[i.jsx("rect",{x:"7",y:"5",width:"9",height:"11",rx:"2.5"}),i.jsx("path",{d:"M5.5 12.5H5A2 2 0 0 1 3 10.5V5a2 2 0 0 1 2-2h5.5"})]})}function nT(){return i.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 20 20",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round",className:"conversation-action-icon",children:[i.jsx("circle",{cx:"6",cy:"5",r:"2.25"}),i.jsx("circle",{cx:"14",cy:"6",r:"2.25"}),i.jsx("circle",{cx:"14",cy:"14",r:"2.25"}),i.jsx("path",{d:"M8.4 5.7h2.2a2.7 2.7 0 0 1 2.7 2.7v1.2"}),i.jsx("path",{d:"M8.1 5.9l4.1 6.2"})]})}function eL(){return i.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 20 20",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round",className:"conversation-action-icon",children:[i.jsx("path",{d:"M10 2.8l1.6 3.4 3.8.5-2.8 2.6.7 3.9-3.3-1.8-3.3 1.8.7-3.9-2.8-2.6 3.8-.5L10 2.8z"}),i.jsx("path",{d:"M15.8 13.3l.7 1.5 1.7.2-1.2 1.1.3 1.8-1.5-.8-1.5.8.3-1.8-1.2-1.1 1.7-.2.7-1.5z"})]})}function tL(){return i.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 20 20",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round",className:"conversation-action-icon",children:[i.jsx("circle",{cx:"6",cy:"5",r:"2.2"}),i.jsx("circle",{cx:"14",cy:"5",r:"2.2"}),i.jsx("circle",{cx:"10",cy:"14",r:"2.2"}),i.jsx("path",{d:"M8.2 5h3.6"}),i.jsx("path",{d:"M10 7.2v4.6"}),i.jsx("path",{d:"M7.3 6.8l1.7 4"}),i.jsx("path",{d:"M12.7 6.8l-1.7 4"})]})}function nL(){return i.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 20 20",fill:"currentColor",className:"conversation-action-icon",children:[i.jsx("circle",{cx:"4.5",cy:"10",r:"1.5"}),i.jsx("circle",{cx:"10",cy:"10",r:"1.5"}),i.jsx("circle",{cx:"15.5",cy:"10",r:"1.5"})]})}function rL(){return i.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 20 20",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round",className:"conversation-action-icon",children:[i.jsx("path",{d:"M4.5 5.5h1.2"}),i.jsx("path",{d:"M8 5.5h7.5"}),i.jsx("path",{d:"M4.5 10h1.2"}),i.jsx("path",{d:"M8 10h7.5"}),i.jsx("path",{d:"M4.5 14.5h1.2"}),i.jsx("path",{d:"M8 14.5h7.5"}),i.jsx("path",{d:"M5.1 5.5l.5.5 1-1"}),i.jsx("circle",{cx:"5.1",cy:"10",r:".8",fill:"currentColor",stroke:"none"}),i.jsx("path",{d:"M5.1 14.5l.5.5 1-1"})]})}const wg="codingns.user-app.conversation-scroll",Os=1,rT=200,sT=1e7;function vg(){return typeof window<"u"&&typeof window.localStorage<"u"}function Sg(e){return e.trim()}function Cg(e){return!Number.isFinite(e)||e<=0?0:Math.min(Math.round(e),sT)}function Ng(e){return!e||typeof e!="object"?null:{scrollTop:Cg(e.scrollTop),stickToBottom:e.stickToBottom===!0,lastMessageSignature:typeof e.lastMessageSignature=="string"?e.lastMessageSignature:null,updatedAt:Number.isFinite(e.updatedAt)?e.updatedAt:0}}function jg(){if(!vg())return{schemaVersion:Os,bySessionId:{}};const e=window.localStorage.getItem(wg);if(!e)return{schemaVersion:Os,bySessionId:{}};try{const t=JSON.parse(e);if(!t||typeof t!="object"||t.schemaVersion!==Os||!t.bySessionId||typeof t.bySessionId!="object"||Array.isArray(t.bySessionId))return{schemaVersion:Os,bySessionId:{}};const n=Object.fromEntries(Object.entries(t.bySessionId).map(([r,s])=>{const o=Ng(s);return o?[r,o]:null}).filter(r=>!!r));return{schemaVersion:Os,bySessionId:n}}catch{return{schemaVersion:Os,bySessionId:{}}}}function iT(e){if(vg())try{window.localStorage.setItem(wg,JSON.stringify(e))}catch{}}function Ko(e){const t=Sg(e);if(!t)return null;const n=jg().bySessionId[t],r=Ng(n);return r?{scrollTop:r.scrollTop,stickToBottom:r.stickToBottom,lastMessageSignature:r.lastMessageSignature}:null}function Ah(e,t){const n=Sg(e);if(!n)return;const r=jg();r.bySessionId[n]={scrollTop:Cg(t.scrollTop),stickToBottom:t.stickToBottom,lastMessageSignature:t.lastMessageSignature,updatedAt:Date.now()};const s=Object.entries(r.bySessionId).sort((o,a)=>a[1].updatedAt-o[1].updatedAt).slice(0,rT);r.bySessionId=Object.fromEntries(s),iT(r)}const oT=5e3;let Ws=null;function aT(){var t;if(Ws!==null)return Ws;if(typeof document>"u")return Ws=0,Ws;const e=document.createElement("div");return e.dataset.scrollbarProbe="true",e.style.position="absolute",e.style.top="-9999px",e.style.width="120px",e.style.height="120px",e.style.overflow="scroll",e.style.visibility="hidden",e.style.pointerEvents="none",(t=document.body)==null||t.appendChild(e),Ws=Math.max(0,e.offsetWidth-e.clientWidth),e.remove(),Ws}function lT(e){if(aT()>0){e.dataset.scrollbarLayout="stable";return}e.removeAttribute("data-scrollbar-layout")}function Ou(e){const t=f.useRef(null),n=e??t;return f.useEffect(()=>{const r=n.current;if(!r||typeof globalThis.window>"u")return;lT(r);let s=null;const o=()=>{s!==null&&(window.clearTimeout(s),s=null)},a=()=>{o(),r.removeAttribute("data-scrolling")},c=()=>{r.setAttribute("data-scrolling","true"),o(),s=window.setTimeout(()=>{r.removeAttribute("data-scrolling"),s=null},oT)},u=()=>{c()};return r.addEventListener("scroll",u,{passive:!0}),()=>{r.removeEventListener("scroll",u),a()}},[n]),n}function Wu(e){var t,n;return e.runningState==="failed"||!!((t=e.lastErrorCode)!=null&&t.trim())||!!((n=e.lastErrorDetail)!=null&&n.trim())}function cT(e,t,n){return`${e} is-${Tg(t,n)}`}function Tg(e,t){t==null||t.isActive;const n=hT(e);return t!=null&&t.hasSubagents?n==="error"?"error":n==="unread"?"subagent-unread":n==="running"||n==="running_inferred"?"subagent-running":"subagent":n==="running_inferred"?"running-inferred":n.replace("_","-")}function uT(e){return e.runningState==="stale"?l("conversation.runtimeStale"):e.runningState==="unknown"?l("conversation.runtimeUnknown"):null}function dT(e,t){return t.runningState==="stale"?`${e} is-stale`:t.runningState==="unknown"?`${e} is-unknown`:null}function sL(e){return e?e.activityState==="running"?!0:e.runningState==="starting"||e.runningState==="running"||e.runningState==="reconnecting":!1}function hT(e){return Wu(e)?"error":e.runningState==="stale"?"stale":e.runningState==="unknown"?"unknown":e.activityState==="running"?pT(e)?"running_inferred":"running":e.activityState==="completed_unread"?"unread":"idle"}function pT(e){return e.activityResolutionSource==="inferred_log"||e.activitySource==="inferred"}function fT(e){return Wu(e)||e.syncStatus==="error"}function mT(e){if(!fT(e))return null;const t=bT(e.lastErrorCode),n=kT(e.lastErrorDetail),r=gT(t,n,e.syncStatus);return{title:e.syncStatus==="error"&&!Wu(e)?l("conversation.syncStatusError"):l("conversation.runtimeErrorTitle"),summary:r,code:t,detail:n}}function gT(e,t,n){return t||(n==="error"?l("conversation.syncStatusError"):e?l("conversation.runtimeErrorFallbackDetail"):l("conversation.runtimeErrorFallbackDetail"))}function bT(e){const t=(e==null?void 0:e.trim())??"";return t.length>0?t:null}function kT(e){const t=(e==null?void 0:e.replace(/\s+/g," ").trim())??"";return t.length>0?t:null}function yT(e){const t=e.messages.map(s=>({type:"message",key:s.id,message:s})),n=e.runtimeThinkingPlaceholder??null,r=mT({runningState:e.sessionRunningState??null,syncStatus:e.sessionSyncStatus??null,lastErrorCode:e.sessionLastErrorCode??null,lastErrorDetail:e.sessionLastErrorDetail??null});return n&&t.push({type:"runtime_thinking",key:`runtime-thinking:${n}`,label:n}),r&&t.push({type:"session_error",key:`session-error:${r.code??"none"}:${r.summary??"none"}`,error:r}),t}function xT(e){return e.flatMap(t=>t.type==="message"?[t.message]:[])}function wT(e){for(let t=e.length-1;t>=0;t-=1){const n=e[t];if((n==null?void 0:n.type)==="runtime_thinking")return n.label}return null}function iL(e,t){const n=e.filter(o=>o.type!=="runtime_thinking");if(!t)return n;const r={type:"runtime_thinking",key:`runtime-thinking:${t}`,label:t},s=n.findIndex(o=>o.type==="session_error");return s<0?[...n,r]:[...n.slice(0,s),r,...n.slice(s)]}function vT(e){return e.replace(/(\.{3,}|…+)$/,"").trimEnd()}function ST(e){const t=e.trim();if(!t)return[];const n=/\b(?:last status:\s*\d{3}\s+[A-Za-z][A-Za-z ]*|\d{3}\s+(?:Too Many Requests|Bad Gateway|Gateway Timeout|Service Unavailable|Unauthorized|Forbidden|Not Found|Internal Server Error))\b|\brequest id:\s*[A-Za-z0-9-]+\b/gi,r=[];let s=0;for(const o of t.matchAll(n)){const a=o.index??0,c=o[0];a>s&&r.push({type:"text",text:t.slice(s,a)}),r.push({type:/^request id:/i.test(c)?"request_id":"status_code",text:c}),s=a+c.length}return s<t.length&&r.push({type:"text",text:t.slice(s)}),r.filter(o=>o.text.length>0)}function Ig(e){var r;const t=e.match(/^\s*<turn_aborted>([\s\S]*?)<\/turn_aborted>\s*$/i);if(!t)return null;const n=((r=t[1])==null?void 0:r.trim())??"";return!n||/^previous turn aborted$/i.test(n)?{detail:null}:{detail:n}}function CT(e){return e==="user"?l("conversation.turnAbortedUser"):e==="runtime"?l("conversation.turnAbortedUnexpected"):l("conversation.turnAbortedGeneric")}const NT=480,Ph=80,Lh=240,jT=120,TT=18,IT=50,ET=3500,Bc=f.createContext(!1);function Pa(e){return e.replace(/\\/g,"/")}function La(e){return/^[a-zA-Z]:\//.test(e)}function MT(e){return e.startsWith("/")||e.startsWith("//")||La(e)}function RT(e){return/^[a-zA-Z][a-zA-Z\d+.-]*:/.test(e)&&!La(e)}function _h(e){return e.replace(/\/+$/,"")}function Eg(e){const t=e.indexOf("#"),n=t>=0?e.slice(0,t):e,r=n.indexOf("?");return(r>=0?n.slice(0,r):n).replace(/:(\d+)(?::(\d+))?$/,"")}function Mg(e){const t=[];for(const n of Pa(e).split("/"))if(!(!n||n===".")){if(n===".."){if(t.length===0)return null;t.pop();continue}t.push(n)}return t.join("/")}function Fu(e){try{return decodeURIComponent(e)}catch{return e}}function Rg(e,t){const n=Fu(e).trim();if(!n||n.startsWith("#"))return null;let r=n;if(/^file:\/\//i.test(r))try{r=decodeURIComponent(new URL(r).pathname),/^\/[a-zA-Z]:\//.test(r)&&(r=r.slice(1))}catch{return null}else if(RT(r))return null;if(r=Pa(Eg(r.trim())),!r)return null;const s=_h(Pa(t.trim()));if(!s)return null;if(MT(r)){const o=_h(r),a=La(s)?s.toLowerCase():s,c=La(o)?o.toLowerCase():o;if(c===a)return null;const u=`${a}/`;return c.startsWith(u)?o.slice(s.length+1):null}return Mg(r)}function AT(e){if(e.name.trim()!=="view_image")return null;const t=tl(e.input);return(t?Pg(t,"path").trim():"")||null}function PT(e){return Pa(e).split("/").filter(Boolean).at(-1)??e}function LT(e,t){const n=AT(e);if(!n)return null;const r=t?Rg(n,t):Mg(Eg(n));return{path:r??n,displayPath:r??n,fileName:PT(n)}}function _T(e,t,n){var r;if(e&&!n&&typeof window<"u"&&((r=window.location)!=null&&r.origin))return new URL(e,window.location.origin).toString();if(e&&n)try{const s=cf(Jc()).baseUrl;return fk(e,s)}catch{return t}return t}function $u(e){return e.kind==="tool_call"||e.kind==="tool_result"}function Ag(e){return e.toolCall?e.toolCall:$u(e)?{callId:e.rawRef||e.id,name:"tool",input:e.kind==="tool_call"?e.content:"",output:e.kind==="tool_result"&&e.content?e.content:null,error:null,status:e.kind==="tool_call"?"running":"completed"}:null}function DT(e){return e==="shell_command"||e==="tool"?l("conversation.roleTool"):e}function tl(e){if(!e.trim())return null;try{const t=JSON.parse(e);return!t||typeof t!="object"||Array.isArray(t)?null:t}catch{return null}}function Pg(e,t){const n=e[t];return typeof n=="string"?n:""}function Fs(e,t){for(const n of t){const r=Pg(e,n);if(r)return r}return""}function no(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function Lt(e,t){if(!e)return null;const n=e[t];return no(n)?n:null}function Jl(e,t){if(!e)return null;const n=e[t];return Array.isArray(n)?n:null}function ot(e,t){if(!e)return null;const n=e[t];if(typeof n=="string"){const r=n.trim();return r||null}return typeof n=="number"||typeof n=="boolean"?String(n):null}function BT(e){const t=[e.output,e.input];for(const n of t){const r=Lg(n,0);if(r)return r}return null}function Lg(e,t){if(!(e!=null&&e.trim())||t>2)return null;try{return _g(JSON.parse(e),t)}catch{return null}}function _g(e,t){if(!no(e))return null;if(OT(e))return{ok:!0,capability:ot(e,"capability")??"",auditId:ot(e,"auditId")??"",timestamp:ot(e,"timestamp")??"",targetRef:{kind:ot(Lt(e,"targetRef"),"kind")??"none",id:ot(Lt(e,"targetRef"),"id")},payload:Lt(e,"payload")??{}};const n=["output","result","data","payload"];for(const r of n){const s=e[r];if(typeof s=="string"){const o=Lg(s,t+1);if(o)return o}if(no(s)){const o=_g(s,t+1);if(o)return o}}return null}function OT(e){return e.ok===!0&&typeof e.capability=="string"&&typeof e.auditId=="string"&&typeof e.timestamp=="string"&&no(e.targetRef)&&no(e.payload)}function WT(e){const t=new Map,n=new Map,r=new Map;return e.forEach(s=>{t.set(s.workspace.id,s.workspace.name),s.sessions.forEach(o=>{const a=typeof o.title=="string"&&o.title.trim()?o.title.trim():o.sessionId;n.set(o.sessionId,a),r.set(o.sessionId,s.workspace.id)})}),{workspaceNamesById:t,sessionNamesById:n,sessionWorkspaceIdsById:r}}function FT(e,t){const n=BT(e);return n?{...Bg(n.capability),rows:XT(n,t)}:null}function $T(e,t){const n=zT(e);if(!n)return null;const r=HT(n);return r?{...GT(r),rows:YT(r,t)}:null}function zT(e){const t=tl(e.input),n=t&&typeof t.command=="string"?t.command.trim():"";if(!n)return null;const r=n.indexOf("codingns assistant");return r<0?null:n.slice(r).trim()}function HT(e){const t=UT(e),n=t.findIndex((p,h)=>p==="codingns"&&t[h+1]==="assistant");if(n<0)return null;const r=t.slice(n+2);if(r.length===0||r[0]==="--help"||r[0]==="-h")return{group:null,action:null,mode:"help",options:{},positionals:[]};if(r[0]==="help")return{group:r[1]??null,action:r[2]??null,mode:"help",options:{},positionals:[]};const s=r[0]??null,o=r[1],a=o&&!o.startsWith("-")?o:null,c=r.slice(a?2:1),{options:u,positionals:d}=qT(c);return!a&&u["--help"]?{group:s,action:null,mode:"help",options:u,positionals:d}:{group:s,action:a,mode:"execute",options:u,positionals:d}}function UT(e){const t=[],n=/"([^"\\]|\\.)*"|'([^'\\]|\\.)*'|`([^`\\]|\\.)*`|\S+/g;for(const r of e.matchAll(n)){const s=r[0]??"";if(!s)continue;const o=s[0];if((o==='"'||o==="'"||o==="`")&&s[s.length-1]===o){t.push(s.slice(1,-1));continue}t.push(s)}return t}function qT(e){const t={},n=[];for(let r=0;r<e.length;r+=1){const s=e[r]??"";if(!s.startsWith("--")){n.push(s);continue}const o=e[r+1];if(!o||o.startsWith("--")){t[s]=!0;continue}t[s]=o,r+=1}return{options:t,positionals:n}}function GT(e){if(e.mode==="help")return VT(e.group,e.action);const t=KT(e.group,e.action);return t?Bg(t):{kind:zu(e.group),badge:Dg(e.group),title:l("conversation.assistantCapabilityQueryTitle"),summary:l("conversation.assistantCliSummaryCommand")}}function VT(e,t){return e?e==="sessions"?{kind:"session",badge:l("conversation.assistantCapabilityBadgeSession"),title:t?l("conversation.assistantCliHelpSessionActionTitle",{action:t}):l("conversation.assistantCliHelpSessionsTitle"),summary:l("conversation.assistantCliSummaryHelp")}:e==="timers"?{kind:"automation",badge:l("conversation.assistantCapabilityBadgeAutomation"),title:l("conversation.assistantCliHelpTimersTitle"),summary:l("conversation.assistantCliSummaryHelp")}:e==="terminals"?{kind:"terminal",badge:l("conversation.assistantCapabilityBadgeTerminal"),title:l("conversation.assistantCliHelpTerminalsTitle"),summary:l("conversation.assistantCliSummaryHelp")}:e==="workspaces"||e==="worktrees"?{kind:"workspace",badge:l("conversation.assistantCapabilityBadgeWorkspace"),title:l("conversation.assistantCliHelpWorkspacesTitle"),summary:l("conversation.assistantCliSummaryHelp")}:{kind:zu(e),badge:Dg(e),title:l("conversation.assistantCliHelpGenericTitle",{group:e}),summary:l("conversation.assistantCliSummaryHelp")}:{kind:"query",badge:l("conversation.assistantCapabilityBadgeQuery"),title:l("conversation.assistantCliHelpRootTitle"),summary:l("conversation.assistantCliSummaryHelp")}}function KT(e,t){const n=e==null?void 0:e.trim(),r=t==null?void 0:t.trim();return n?n==="capabilities"&&r==="list"?"capabilities.list":n==="projects"&&r==="list"?"projects.list":n==="projects"&&r==="get"?"projects.get":n==="sessions"&&r==="list"?"projects.sessions.list":n==="sessions"&&r==="get"?"sessions.get":n==="sessions"&&r==="messages"?"sessions.messages.list":n==="sessions"&&r==="runtime"?"sessions.runtime.get":n==="sessions"&&r==="start"?"projects.sessions.start":n==="sessions"&&r==="send"?"sessions.message.send":n==="sessions"&&r==="fork"?"sessions.fork":n==="timers"&&r==="create"?"timers.create":n==="timers"&&r==="cancel"?"timers.cancel":n==="timers"&&r==="list"?"timers.list":n==="terminals"&&r==="send"?"terminals.input.send":n==="terminals"&&r==="close"?"terminals.close":n==="terminals"&&r==="history"?"terminals.history.read":n==="terminals"&&r==="list"?"terminals.list":n==="workspaces"&&r==="list"?"workspaces.list":n==="workspaces"&&r==="clone"?"workspaces.clone":n==="workspaces"&&r==="import"?"workspaces.import":n==="workspaces"&&r==="management"?"workspaces.management.get":n==="worktrees"&&r==="tree"?"worktrees.tree":n==="worktrees"&&r==="create"?"worktrees.create":null:null}function zu(e){switch(e){case"sessions":case"projects":return"session";case"timers":return"automation";case"terminals":return"terminal";case"workspaces":case"worktrees":return"workspace";case"debug-targets":case"debug-runtimes":return"debug";default:return"query"}}function Dg(e){switch(zu(e)){case"session":return l("conversation.assistantCapabilityBadgeSession");case"automation":return l("conversation.assistantCapabilityBadgeAutomation");case"terminal":return l("conversation.assistantCapabilityBadgeTerminal");case"workspace":return l("conversation.assistantCapabilityBadgeWorkspace");case"debug":return l("conversation.assistantCapabilityBadgeDebug");case"query":default:return l("conversation.assistantCapabilityBadgeQuery")}}function YT(e,t){const n=[],r=$s(e,"--session-id")??e.positionals[0]??null,s=$s(e,"--project")??$s(e,"--project-id");return e.mode==="help"?(We(n,l("conversation.assistantCliLabelScope"),e.group??l("conversation.assistantCliScopeRoot")),We(n,l("conversation.assistantCliLabelAction"),e.action),n):(e.group==="sessions"&&We(n,l("conversation.assistantCapabilityLabelSession"),us(r,null,t)),e.group==="timers"&&(We(n,l("conversation.assistantCapabilityLabelSession"),us(r,null,t)),We(n,l("conversation.assistantCliLabelDelay"),$s(e,"--after-seconds"))),e.group==="terminals"&&We(n,l("conversation.assistantCapabilityLabelTerminal"),e.positionals[0]??null),(e.group==="workspaces"||e.group==="worktrees")&&We(n,l("conversation.assistantCapabilityLabelWorkspace"),Pr(e.positionals[0]??null,null,t)),We(n,l("conversation.assistantCliLabelProject"),s),We(n,l("conversation.assistantCliLabelMessage"),$s(e,"--message")),We(n,l("conversation.assistantCliLabelInput"),$s(e,"--input")),n.slice(0,4))}function $s(e,t){const n=e.options[t];return typeof n=="string"?n:null}function Bg(e){switch(e){case"projects.sessions.start":return{kind:"session",badge:l("conversation.assistantCapabilityBadgeSession"),title:l("conversation.assistantCapabilityProjectSessionStartTitle"),summary:l("conversation.assistantCapabilitySummarySessionStart")};case"sessions.message.send":return{kind:"session",badge:l("conversation.assistantCapabilityBadgeSession"),title:l("conversation.assistantCapabilitySessionSendTitle"),summary:l("conversation.assistantCapabilitySummarySessionSend")};case"sessions.fork":return{kind:"session",badge:l("conversation.assistantCapabilityBadgeSession"),title:l("conversation.assistantCapabilitySessionForkTitle"),summary:l("conversation.assistantCapabilitySummarySessionFork")};case"timers.create":return{kind:"automation",badge:l("conversation.assistantCapabilityBadgeAutomation"),title:l("conversation.assistantCapabilityTimerCreateTitle"),summary:l("conversation.assistantCapabilitySummaryTimerCreate")};case"timers.cancel":return{kind:"automation",badge:l("conversation.assistantCapabilityBadgeAutomation"),title:l("conversation.assistantCapabilityTimerCancelTitle"),summary:l("conversation.assistantCapabilitySummaryTimerCancel")};case"terminals.input.send":return{kind:"terminal",badge:l("conversation.assistantCapabilityBadgeTerminal"),title:l("conversation.assistantCapabilityTerminalInputTitle"),summary:l("conversation.assistantCapabilitySummaryTerminalInput")};case"terminals.close":return{kind:"terminal",badge:l("conversation.assistantCapabilityBadgeTerminal"),title:l("conversation.assistantCapabilityTerminalCloseTitle"),summary:l("conversation.assistantCapabilitySummaryTerminalClose")};case"workspaces.directory.create":return{kind:"workspace",badge:l("conversation.assistantCapabilityBadgeWorkspace"),title:l("conversation.assistantCapabilityWorkspaceDirectoryCreateTitle"),summary:l("conversation.assistantCapabilitySummaryWorkspace")};case"workspaces.import":return{kind:"workspace",badge:l("conversation.assistantCapabilityBadgeWorkspace"),title:l("conversation.assistantCapabilityWorkspaceImportTitle"),summary:l("conversation.assistantCapabilitySummaryWorkspace")};case"workspaces.clone":return{kind:"workspace",badge:l("conversation.assistantCapabilityBadgeWorkspace"),title:l("conversation.assistantCapabilityWorkspaceCloneTitle"),summary:l("conversation.assistantCapabilitySummaryWorkspace")};case"workspaces.navigation-state.update":return{kind:"workspace",badge:l("conversation.assistantCapabilityBadgeWorkspace"),title:l("conversation.assistantCapabilityWorkspaceNavigationUpdateTitle"),summary:l("conversation.assistantCapabilitySummaryWorkspace")};case"workspaces.remove":return{kind:"workspace",badge:l("conversation.assistantCapabilityBadgeWorkspace"),title:l("conversation.assistantCapabilityWorkspaceRemoveTitle"),summary:l("conversation.assistantCapabilitySummaryWorkspace")};case"worktrees.create":return{kind:"workspace",badge:l("conversation.assistantCapabilityBadgeWorkspace"),title:l("conversation.assistantCapabilityWorktreeCreateTitle"),summary:l("conversation.assistantCapabilitySummaryWorktree")};case"worktrees.merge-into-parent":return{kind:"workspace",badge:l("conversation.assistantCapabilityBadgeWorkspace"),title:l("conversation.assistantCapabilityWorktreeMergeTitle"),summary:l("conversation.assistantCapabilitySummaryWorktree")};case"worktrees.cleanup":return{kind:"workspace",badge:l("conversation.assistantCapabilityBadgeWorkspace"),title:l("conversation.assistantCapabilityWorktreeCleanupTitle"),summary:l("conversation.assistantCapabilitySummaryWorktree")};case"debug-targets.run":return{kind:"debug",badge:l("conversation.assistantCapabilityBadgeDebug"),title:l("conversation.assistantCapabilityDebugRunTitle"),summary:l("conversation.assistantCapabilitySummaryDebug")};default:return e.startsWith("sessions.")||e.startsWith("projects.")?{kind:"session",badge:l("conversation.assistantCapabilityBadgeSession"),title:l("conversation.assistantCapabilitySessionReadTitle"),summary:l("conversation.assistantCapabilitySummaryRead")}:e.startsWith("timers.")?{kind:"automation",badge:l("conversation.assistantCapabilityBadgeAutomation"),title:l("conversation.assistantCapabilityAutomationReadTitle"),summary:l("conversation.assistantCapabilitySummaryRead")}:e.startsWith("terminals.")?{kind:"terminal",badge:l("conversation.assistantCapabilityBadgeTerminal"),title:l("conversation.assistantCapabilityTerminalReadTitle"),summary:l("conversation.assistantCapabilitySummaryRead")}:e.startsWith("workspaces.")||e.startsWith("worktrees.")?{kind:"workspace",badge:l("conversation.assistantCapabilityBadgeWorkspace"),title:l("conversation.assistantCapabilityWorkspaceReadTitle"),summary:l("conversation.assistantCapabilitySummaryRead")}:e.startsWith("debug-targets.")||e.startsWith("debug-runtimes.")?{kind:"debug",badge:l("conversation.assistantCapabilityBadgeDebug"),title:l("conversation.assistantCapabilityDebugReadTitle"),summary:l("conversation.assistantCapabilitySummaryRead")}:{kind:"query",badge:l("conversation.assistantCapabilityBadgeQuery"),title:l("conversation.assistantCapabilityQueryTitle"),summary:l("conversation.assistantCapabilitySummaryRead")}}}function XT(e,t){const n=[],r=e.payload;switch(e.capability){case"projects.sessions.start":{const s=Lt(r,"session");We(n,l("conversation.assistantCapabilityLabelSession"),us(ot(s,"sessionId"),ot(s,"title"),t)),We(n,l("conversation.assistantCapabilityLabelProvider"),ot(s,"provider"));break}case"sessions.message.send":{const s=Lt(r,"result");We(n,l("conversation.assistantCapabilityLabelSession"),us(e.targetRef.id,null,t)),We(n,l("conversation.assistantCapabilityLabelWorkspace"),Og(e.targetRef.id,t)),We(n,l("conversation.assistantCapabilityLabelStatus"),l("conversation.assistantCapabilityStatusCompleted")),We(n,l("conversation.assistantCapabilityLabelDueAt"),Dh(ot(s,"acceptedAt")??e.timestamp));break}case"sessions.fork":{const s=Lt(r,"session");We(n,l("conversation.assistantCapabilityLabelSession"),us(ot(s,"sessionId"),ot(s,"title"),t)),We(n,l("conversation.assistantCapabilityLabelProvider"),ot(s,"provider"));break}case"timers.create":case"timers.cancel":{const s=Lt(r,"timer"),o=Lt(s,"controlSession"),a=Lt(o,"session");We(n,l("conversation.assistantCapabilityLabelTimer"),ot(s,"title")),We(n,l("conversation.assistantCapabilityLabelWorkspace"),Pr(ot(a,"workspaceId"),null,t)),We(n,l("conversation.assistantCapabilityLabelSession"),us(ot(s,"targetSessionId"),null,t)),We(n,l("conversation.assistantCapabilityLabelDueAt"),Dh(ot(s,"dueAt"))),We(n,l("conversation.assistantCapabilityLabelStatus"),ZT(ot(s,"status")));break}case"terminals.input.send":case"terminals.close":We(n,l("conversation.assistantCapabilityLabelTerminal"),e.targetRef.id);break;case"workspaces.directory.create":{const s=Lt(r,"result");We(n,l("conversation.assistantCapabilityLabelPath"),ot(s,"path"));break}case"workspaces.import":case"workspaces.clone":case"workspaces.remove":{const s=Lt(r,"workspace");We(n,l("conversation.assistantCapabilityLabelWorkspace"),Pr(ot(s,"id")??e.targetRef.id,ot(s,"name"),t)),We(n,l("conversation.assistantCapabilityLabelPath"),ot(s,"path"));break}case"workspaces.navigation-state.update":{const s=Lt(r,"state");We(n,l("conversation.assistantCapabilityLabelWorkspace"),Pr(ot(s,"workspaceId")??e.targetRef.id,null,t)),We(n,l("conversation.assistantCapabilityLabelStatus"),ot(s,"collapsed")==="true"?l("conversation.assistantCapabilityNavigationCollapsed"):l("conversation.assistantCapabilityNavigationExpanded"));break}case"worktrees.create":{const s=Lt(r,"result"),o=Lt(s,"workspace");We(n,l("conversation.assistantCapabilityLabelWorkspace"),Pr(ot(o,"id")??e.targetRef.id,ot(o,"name"),t)),We(n,l("conversation.assistantCapabilityLabelBranch"),ot(s,"branchName"));break}case"worktrees.merge-into-parent":case"worktrees.cleanup":{const s=Lt(r,"result");We(n,l("conversation.assistantCapabilityLabelWorkspace"),Pr(e.targetRef.id,null,t)),We(n,l("conversation.assistantCapabilityLabelStatus"),ot(s,"status"));break}case"debug-targets.run":{const s=Lt(r,"result");We(n,l("conversation.assistantCapabilityLabelDebugTarget"),e.targetRef.id),We(n,l("conversation.assistantCapabilityLabelRuntime"),ot(s,"runtimeId"));break}}return JT(n,e,t),n.slice(0,4)}function JT(e,t,n){t.targetRef.kind==="session"&&(We(e,l("conversation.assistantCapabilityLabelSession"),us(t.targetRef.id,null,n)),We(e,l("conversation.assistantCapabilityLabelWorkspace"),Og(t.targetRef.id,n))),(t.targetRef.kind==="workspace"||t.targetRef.kind==="worktree")&&We(e,l("conversation.assistantCapabilityLabelWorkspace"),Pr(t.targetRef.id,null,n)),t.targetRef.kind==="terminal"&&We(e,l("conversation.assistantCapabilityLabelTerminal"),t.targetRef.id),t.targetRef.kind==="timer"&&We(e,l("conversation.assistantCapabilityLabelTimer"),t.targetRef.id);const r=QT(t.payload);r!==null&&We(e,l("conversation.assistantCapabilityLabelCount"),String(r))}function We(e,t,n){const r=n==null?void 0:n.trim();r&&(e.some(s=>s.label===t)||e.push({label:t,value:r}))}function us(e,t,n){const r=t==null?void 0:t.trim();if(r)return r;const s=e==null?void 0:e.trim();return s?n.sessionNamesById.get(s)??s:null}function Pr(e,t,n){const r=t==null?void 0:t.trim();if(r)return r;const s=e==null?void 0:e.trim();return s?n.workspaceNamesById.get(s)??s:null}function Og(e,t){const n=e==null?void 0:e.trim();return n?Pr(t.sessionWorkspaceIdsById.get(n)??null,null,t):null}function QT(e){const t=Jl(e,"items");if(t)return t.length;const n=Lt(e,"page"),r=Jl(n,"items");if(r)return r.length;const s=Lt(e,"history"),o=Jl(s,"items");return o?o.length:null}function Dh(e){const t=e==null?void 0:e.trim();if(!t)return null;const n=Date.parse(t);return Number.isFinite(n)?new Intl.DateTimeFormat(void 0,{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}).format(new Date(n)):t}function ZT(e){switch(e){case"active":return l("conversation.assistantCapabilityStatusActive");case"completed":return l("conversation.assistantCapabilityStatusCompleted");case"cancelled":return l("conversation.assistantCapabilityStatusCancelled");case"failed":return l("conversation.assistantCapabilityStatusFailed");default:return e}}function eI({kind:e}){switch(e){case"session":return i.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8","aria-hidden":"true",children:i.jsx("path",{d:"M5 7.5A2.5 2.5 0 0 1 7.5 5h9A2.5 2.5 0 0 1 19 7.5v5A2.5 2.5 0 0 1 16.5 15H11l-4 4v-4H7.5A2.5 2.5 0 0 1 5 12.5z"})});case"automation":return i.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8","aria-hidden":"true",children:[i.jsx("circle",{cx:"12",cy:"12",r:"7.5"}),i.jsx("path",{d:"M12 8.5v4.2l2.8 1.8"})]});case"terminal":return i.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8","aria-hidden":"true",children:[i.jsx("path",{d:"m7 8 3.5 3.5L7 15"}),i.jsx("path",{d:"M13 15h4"}),i.jsx("rect",{x:"4.5",y:"5.5",width:"15",height:"13",rx:"2.5"})]});case"workspace":return i.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8","aria-hidden":"true",children:i.jsx("path",{d:"M4.5 8.5A2.5 2.5 0 0 1 7 6h3l1.5 1.5H17A2.5 2.5 0 0 1 19.5 10v6A2.5 2.5 0 0 1 17 18.5H7A2.5 2.5 0 0 1 4.5 16z"})});case"debug":return i.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8","aria-hidden":"true",children:[i.jsx("path",{d:"M9 4.5h6"}),i.jsx("path",{d:"M10 8h4a4 4 0 0 1 4 4v1a6 6 0 0 1-12 0v-1a4 4 0 0 1 4-4Z"}),i.jsx("path",{d:"M4.5 11h3M16.5 11h3M5.5 7.5l2 1.5M18.5 7.5l-2 1.5"})]});case"query":default:return i.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8","aria-hidden":"true",children:[i.jsx("circle",{cx:"11",cy:"11",r:"5.5"}),i.jsx("path",{d:"m16 16 3.5 3.5"})]})}}function tI(e){if(e.name==="apply_patch"){const c=Th(e.input);if(c)return c;const u=bj(e.output||e.error||""),d=gj(e.input,u);return d?Th(d):null}const t=e.name.trim().toLowerCase(),n=nI(t);if(!n)return null;const r=tl(e.input);if(!r)return null;const s=Fs(r,["file_path","filePath","path"]);if(!s)return null;if(n==="write"){const c=Fs(r,["content","new_content","newContent"]),u=c.length>0?c.split(/\r?\n/):[];return{files:[{path:s,nextPath:null,action:"add",additions:u.length,deletions:0,statsKnown:!0,lines:u.map((d,p)=>({kind:"add",text:`+${d}`,oldLineNumber:null,newLineNumber:p+1}))}],totalAdditions:u.length,totalDeletions:0}}if(n==="edit"){const c=Fs(r,["old_string","oldString","old_text","oldText","search","searchText"]).split(/\r?\n/),u=Fs(r,["new_string","newString","new_text","newText","replacement","replacementText","replace"]).split(/\r?\n/);return Bh(s,[{oldLines:c,newLines:u}])}const a=(Array.isArray(r.edits)?r.edits:[]).map(c=>{if(!c||typeof c!="object"||Array.isArray(c))return null;const u=c;return{oldLines:Fs(u,["old_string","oldString","old_text","oldText","search","searchText"]).split(/\r?\n/),newLines:Fs(u,["new_string","newString","new_text","newText","replacement","replacementText","replace"]).split(/\r?\n/)}}).filter(c=>!!c);return a.length>0?Bh(s,a):null}function nI(e){return e==="write"||e==="overwrite"?"write":e==="edit"?"edit":e==="multiedit"||e==="multi_edit"?"multiedit":null}function Bh(e,t){const n=[];let r=0,s=0;return t.forEach((o,a)=>{n.push({kind:"hunk",text:`@@ -1,${o.oldLines.length} +1,${o.newLines.length} @@`,oldLineNumber:null,newLineNumber:null}),o.oldLines.forEach((c,u)=>{c.length===0&&o.oldLines.length===1&&o.newLines.length>0||(s+=1,n.push({kind:"remove",text:`-${c}`,oldLineNumber:u+1,newLineNumber:null}))}),o.newLines.forEach((c,u)=>{c.length===0&&o.newLines.length===1&&o.oldLines.length>0||(r+=1,n.push({kind:"add",text:`+${c}`,oldLineNumber:null,newLineNumber:u+1}))}),a<t.length-1&&n.push({kind:"meta",text:"***",oldLineNumber:null,newLineNumber:null})}),{files:[{path:e,nextPath:null,action:"update",additions:r,deletions:s,statsKnown:!0,lines:n}],totalAdditions:r,totalDeletions:s}}function rI(e){const t=tl(e.input),n=t&&typeof t.command=="string"?t.command.trim():"";if(n)return`${l("conversation.toolPreviewCommand")}:${n}`;if(e.name==="read_thread_terminal")return l("conversation.toolPreviewTerminal");const r=e.input||e.error||e.output||l("conversation.toolResultEmpty");return r.length>60?`${r.slice(0,60)}...`:r}function Oh(e){var o;const t=e.map(a=>({message:a,tool:Ag(a)})).filter(a=>!!a.tool);if(t.length===0)return null;const n={...t[0].tool};let r=!1,s=!1;for(const{message:a,tool:c}of t)a.kind==="tool_call"&&(r=!0,!n.input&&c.input&&(n.input=c.input)),a.kind==="tool_result"&&(s=!0,n.output=c.output,n.error=c.error,n.status=c.status,!n.input&&c.input&&(n.input=c.input)),!n.name&&c.name&&(n.name=c.name);return{key:t.map(({message:a})=>a.id).join(":"),messageIds:t.map(({message:a})=>a.id),tool:n,hasRequest:r,hasResult:s,updatedAt:((o=t.at(-1))==null?void 0:o.message.timestamp)??t[0].message.timestamp}}function sI(e){const t=[];let n=[],r=null;function s(){if(n.length===0)return;const o=Oh(n);o&&t.push(o),n=[],r=null}for(const o of e){const a=Ag(o),c=(a==null?void 0:a.callId.trim())??"";if(!a||c.length===0){s();const u=Oh([o]);u&&t.push(u);continue}if(n.length===0){n=[o],r=c;continue}if(r===c){n.push(o);continue}s(),n=[o],r=c}return s(),t}function iI(e,t){const n=[],r=[];let s=0;function o(){if(r.length===0)return;const a=sI(r);if(a.length===0){const c=r[0];c&&n.push({type:"message",key:c.id,message:c}),r.length=0;return}a.forEach(c=>{n.push({type:"tool_group",key:c.key,group:c})}),r.length=0}for(const a of e){if(a.type!=="message"){o(),n.push(a);continue}const c=a.message,u=s;if(s+=1,!Fg(t,u)){if(!$u(c)){o(),n.push({type:"message",key:c.id,message:c});continue}r.push(c)}}return o(),n}function oI(e,t){var c;if(!e||e.forkSourceType!=="message"||typeof e.inheritedPrefixMessageCount!="number"||e.inheritedPrefixMessageCount<0)return{visibleItems:t,visibleMessages:t.flatMap(u=>u.type==="message"?[u.message]:[]),hiddenMessageIds:[]};const n=((c=e.createdAt)==null?void 0:c.trim())||"";if(n.length===0)return{visibleItems:t,visibleMessages:t.flatMap(u=>u.type==="message"?[u.message]:[]),hiddenMessageIds:[]};const r=Math.max(0,e.inheritedPrefixMessageCount),s=[],o=[],a=[];for(const u of t){if(u.type!=="message"){s.push(u);continue}const d=u.message;if(d.sequence<=r||d.timestamp>=n){s.push(u),o.push(d);continue}a.push(d.id)}return{visibleItems:s,visibleMessages:o,hiddenMessageIds:a}}function Wg(e){const t=oI(e.sessionSummary,e.items),n=iI(t.visibleItems,t.visibleMessages),r=hI(t.visibleMessages,e.provider),s=PI(t.visibleMessages);return{visibleMessages:t.visibleMessages,renderItems:n,leadingSystemPromptMessageIds:r,actionStateByMessageId:s,hiddenMessageIds:t.hiddenMessageIds,validationIssues:aI(t.visibleMessages,n)}}function aI(e,t){const n=[],r=t.map(u=>u.key),s=lI(r);s.length>0&&n.push(`duplicate_render_keys:${s.join(",")}`);const o=[];for(const u of t){if(u.type==="message"){o.push(u.message.id);continue}u.type==="tool_group"&&o.push(...u.group.messageIds)}const a=new Set(o);for(const u of e)Wh(e,u.id)&&!a.has(u.id)&&n.push(`missing_render_message:${u.id}`);const c=e.filter(u=>Wh(e,u.id)).map(u=>u.id);return o.join(",")!==c.join(",")&&n.push("render_order_mismatch"),n}function Wh(e,t){const n=e.findIndex(r=>r.id===t);return n<0?!1:!Fg(e,n)}function lI(e){const t=new Map;for(const n of e)t.set(n,(t.get(n)??0)+1);return Array.from(t.entries()).filter(([,n])=>n>1).map(([n])=>n)}function Fg(e,t){const n=e[t];if(!n||Ig(n.content)===null)return!1;for(let r=t-1;r>=0;r-=1){const s=e[r];if(!(!s||$u(s)))return s.role==="user"}return!1}function cI(e,t){if(!Nk(null,e))return!1;const n=t.trim();return/AGENTS\.md instructions for/i.test(n)&&/<INSTRUCTIONS>/i.test(n)&&/<\/INSTRUCTIONS>/i.test(n)}function uI(e,t){if(e!=="claude-code")return!1;const n=t.trim();return/Base directory for this skill:/i.test(n)&&/^#\s+.+/im.test(n)&&/\bARGUMENTS:/i.test(n)}function dI(e,t){if(e==="skill_context"){const r=t.split(/\r?\n/).map(s=>s.trim()).find(s=>/^#\s+/.test(s));if(r)return r.replace(/^#+\s*/,"")}const n=t.split(/\r?\n/).map(r=>r.trim()).find(Boolean);return n?n.replace(/^#+\s*/,""):l("conversation.rulesMessageTitle")}function hI(e,t){const n=new Set;if(t!=="kimi")return n;for(const r of e){if(r.role==="system"&&r.kind==="text"){n.add(r.id);continue}break}return n}function pI(e){const t=[];for(const n of e){if(n.type==="message"){t.push(n.message.id);continue}n.type==="tool_group"&&t.push(...n.group.messageIds)}return t}function fI(e,t,n){if(!e)return[];const r=new Set(n.filter(u=>u.role==="assistant").map(u=>u.id));if(r.size===0)return[];const s=new Map(e.map((u,d)=>[u,d])),o=new Map(t.map((u,d)=>[u,d])),a=new Map(n.map(u=>[u.id,u])),c=[];for(const u of r){const d=s.get(u)??null,p=o.get(u)??null;if(d===p)continue;const h=a.get(u)??null;c.push({messageId:u,fromIndex:d,toIndex:p,sequence:(h==null?void 0:h.sequence)??null,rawRef:(h==null?void 0:h.rawRef)??null,timestamp:(h==null?void 0:h.timestamp)??null})}return c.slice(0,8)}function ro(e){var t;return typeof e=="string"||typeof e=="number"?String(e):Array.isArray(e)?e.map(n=>ro(n)).join(""):e&&typeof e=="object"&&"props"in e?ro(((t=e.props)==null?void 0:t.children)??""):""}function mI(e){const t=Array.isArray(e)?e[0]:e;if(!f.isValidElement(t))return null;const n=t.props,r=typeof n.className=="string"?n.className:"",s=/language-([^\s]+)/.exec(r);return{content:ro(n.children).replace(/\n$/,""),codeClassName:r||void 0,language:(s==null?void 0:s[1])??null}}function gI(e){if(typeof document>"u"||typeof document.execCommand!="function")return!1;const t=document.createElement("textarea");t.value=e,t.setAttribute("readonly","true"),t.style.position="fixed",t.style.top="-9999px",t.style.left="-9999px",t.style.opacity="0",document.body.appendChild(t),t.focus(),t.select();try{return document.execCommand("copy")}catch{return!1}finally{document.body.removeChild(t)}}async function Hu(e,t){var n;if(!(t.isDesktop&&(await t.bridge.writeClipboardText(e)).ok)){if(typeof navigator<"u"&&((n=navigator.clipboard)!=null&&n.writeText))try{await navigator.clipboard.writeText(e);return}catch{}if(!gI(e))throw new Error(l("conversation.copyContentFailed"))}}function bI({className:e,children:t,onCopy:n,exportMode:r=!1}){const s=f.useContext(Bc),o=ro(t).trim();if(r||s||!o)return i.jsx("code",{className:e||void 0,children:t});function a(c){c.key!=="Enter"&&c.key!==" "||(c.preventDefault(),n(o))}return i.jsx("code",{className:[e,"markdown-inline-copy"].filter(Boolean).join(" "),role:"button",tabIndex:0,"aria-label":l("conversation.copyAction"),onClick:()=>n(o),onKeyDown:a,children:t})}function kI({href:e,children:t,className:n,onInteract:r,exportMode:s=!1}){if(s)return i.jsx(Bc.Provider,{value:!0,children:i.jsx("a",{href:e,className:n,children:t})});const o=ro(t).trim()||(e?Fu(e).trim():"");return i.jsx(Bc.Provider,{value:!0,children:i.jsx("a",{href:e,className:[n,"markdown-interactive-link"].filter(Boolean).join(" "),onClick:a=>{a.preventDefault(),r(e,o)},children:t})})}function $g({language:e,codeClassName:t,content:n,exportMode:r=!1}){const{showToast:s}=Fn(),o=kn(),a=(e==null?void 0:e.trim().toLowerCase())??null,c=a==="text",u=a||"code";async function d(){try{await Hu(n,o),s({title:l("conversation.copyContentSuccess"),tone:"success"})}catch(p){s({title:p instanceof Error?p.message:l("conversation.copyContentFailed"),tone:"error"})}}return i.jsxs("div",{className:`code-block${c?" text-code-block":""}`,children:[i.jsxs("div",{className:"code-header",children:[i.jsx("span",{className:"code-header-label",children:u}),r?null:i.jsx("button",{className:"code-copy-button",type:"button",onClick:()=>void d(),children:l("conversation.copyAction")})]}),i.jsx("pre",{className:t,children:i.jsx("code",{children:n})})]})}function Fi({content:e,className:t,exportMode:n=!1}){const{showToast:r}=Fn(),s=kn(),{navigationGroups:o,currentWorkspaceId:a,revealWorkspaceFile:c}=Zb(),u=f.useMemo(()=>{var h;return((h=o.find(m=>m.workspace.id===a))==null?void 0:h.workspace)??null},[a,o]);async function d(h){if(h.trim())try{await Hu(h,s),r({title:l("conversation.copyContentSuccess"),tone:"success"})}catch(m){r({title:m instanceof Error?m.message:l("conversation.copyContentFailed"),tone:"error"})}}function p(h,m){const g=h&&(u!=null&&u.path)?Rg(h,u.path):null;g&&c({workspaceId:(u==null?void 0:u.id)??a,filePath:g,openViewer:!1})||d(m||(h?Fu(h).trim():""))}return i.jsx("div",{className:t,children:i.jsx(z0,{remarkPlugins:[tj],components:{p:({node:h,...m})=>i.jsx("p",{...m}),a(h){return i.jsx(kI,{href:typeof h.href=="string"?h.href:void 0,className:typeof h.className=="string"?h.className:void 0,onInteract:p,exportMode:n,children:h.children})},pre(h){const m=mI(h.children);return m?i.jsx($g,{language:m.language,codeClassName:m.codeClassName,content:m.content,exportMode:n}):i.jsx("pre",{children:h.children})},code(h){const m=typeof h.className=="string"?h.className:"";return i.jsx(bI,{className:m||void 0,exportMode:n,onCopy:g=>{d(g)},children:h.children})}},children:e})})}function Fh(e,t){return e.kind!=="image"||!(t!=null&&t.contentBase64)||t.mimeType!==e.mimeType?null:`data:${t.mimeType};base64,${t.contentBase64}`}function yI(e){return typeof e!="number"||!Number.isFinite(e)||e<0?null:e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function Yo({sessionId:e,attachmentPayloads:t=[],attachments:n=[],inlineImages:r=[]}){return i.jsx(xI,{sessionId:e,attachments:n,attachmentPayloads:t,inlineImages:r})}function xI({sessionId:e,attachmentPayloads:t=[],attachments:n=[],inlineImages:r=[]}){const[s,o]=f.useState({}),[a,c]=f.useState(null),u=f.useMemo(()=>n.map((m,g)=>{const y=Fh(m,t==null?void 0:t[g]);if(y)return{id:m.id,kind:m.kind,fileName:m.fileName,fileSize:m.fileSize,url:y,status:"ready"};const S=s[m.id];return{id:m.id,kind:m.kind,fileName:m.fileName,fileSize:m.fileSize,url:(S==null?void 0:S.url)??null,status:(S==null?void 0:S.status)??(e?"loading":"error")}}),[t,n,s,e]),d=f.useMemo(()=>r.map((m,g)=>({id:`inline-image-${g}`,kind:"image",fileName:m.altText||`${l("conversation.imageAttachmentLabel")} ${g+1}`,fileSize:m.estimatedBytes,url:m.url,status:"ready"})),[r]),p=f.useMemo(()=>[...d,...u],[u,d]),h=p.find(m=>m.id===a)??null;return f.useEffect(()=>{if(!a)return;function m(g){g.key==="Escape"&&c(null)}return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[a]),f.useEffect(()=>{const m=n.filter((S,C)=>!Fh(S,t==null?void 0:t[C]));if(!e||m.length===0){o({});return}let g=!1;const y=[];return o(Object.fromEntries(m.map(S=>[S.id,{id:S.id,kind:S.kind,fileName:S.fileName,fileSize:S.fileSize,url:null,status:"loading"}]))),Promise.all(m.map(async S=>{try{const C=await jk(e,S.id),x=URL.createObjectURL(C);return y.push(x),{id:S.id,kind:S.kind,fileName:S.fileName,fileSize:S.fileSize,url:x,status:"ready"}}catch{return{id:S.id,kind:S.kind,fileName:S.fileName,fileSize:S.fileSize,url:null,status:"error"}}})).then(S=>{if(g){y.forEach(C=>URL.revokeObjectURL(C));return}o(Object.fromEntries(S.map(C=>[C.id,C])))}),()=>{g=!0,y.forEach(S=>URL.revokeObjectURL(S))}},[t,n,e]),p.length===0?null:i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"message-attachments",children:p.map(m=>{const g=m.kind==="image",y=m.status==="loading"?l("conversation.attachmentPreviewLoading"):m.status==="error"?l("conversation.attachmentPreviewUnavailable"):g?l("conversation.attachmentPreviewOpen"):l("conversation.attachmentDownload"),S=yI(m.fileSize),C=i.jsx("div",{className:"message-attachment-card",children:g?m.url?i.jsx("img",{className:"message-attachment-thumbnail",src:m.url,alt:m.fileName||l("conversation.attachmentPreviewAlt"),loading:"lazy"}):i.jsx("div",{className:"message-attachment-placeholder","aria-hidden":"true",children:m.status==="loading"?l("conversation.attachmentPreviewLoading"):l("conversation.attachmentPreviewUnavailable")}):i.jsxs("div",{className:"message-attachment-file-card",children:[i.jsx("div",{className:"message-attachment-file-icon","aria-hidden":"true",children:i.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[i.jsx("path",{d:"M14 2H7a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V7z"}),i.jsx("path",{d:"M14 2v5h5"}),i.jsx("path",{d:"M9 13h6"}),i.jsx("path",{d:"M9 17h6"})]})}),i.jsxs("div",{className:"message-attachment-file-meta",children:[i.jsx("strong",{title:m.fileName,children:m.fileName}),i.jsx("span",{children:S??l("conversation.fileAttachmentLabel")})]})]})});return!g&&m.url?i.jsx("a",{className:"message-attachment-button",href:m.url,download:m.fileName,"aria-label":`${m.fileName} - ${y}`,title:y,children:C},m.id):i.jsx("button",{type:"button",className:"message-attachment-button",onClick:()=>g&&m.url&&c(m.id),disabled:!m.url,"aria-label":`${m.fileName} - ${y}`,title:y,children:C},m.id)})}),i.jsx(iu,{open:!!(h!=null&&h.url),title:l("conversation.imagePreviewTitle"),description:h==null?void 0:h.fileName,size:"xwide",layout:"viewer",className:"message-image-modal",bodyClassName:"message-image-modal-body",onClose:()=>c(null),children:h!=null&&h.url?i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"message-image-modal-stage",children:i.jsx("img",{className:"message-image-modal-image",src:h.url,alt:h.fileName||l("conversation.attachmentPreviewAlt")})}),i.jsx("p",{className:"message-image-modal-hint",children:l("conversation.imagePreviewHint")})]}):null})]})}function wI(){return i.jsx("div",{className:"timeline-skeleton","aria-hidden":"true",children:Array.from({length:3},(e,t)=>i.jsxs("article",{className:`timeline-skeleton-item ${t%2===0?"assistant":"user"}`,children:[i.jsx("div",{className:"timeline-skeleton-avatar"}),i.jsxs("div",{className:"timeline-skeleton-bubble",children:[i.jsx("span",{className:"timeline-skeleton-line long"}),i.jsx("span",{className:"timeline-skeleton-line medium"}),i.jsx("span",{className:"timeline-skeleton-line short"})]})]},t))})}function vI({tool:e,preview:t,exportMode:n=!1}){const[r,s]=f.useState(null),o=r===null?null:t.files[r]??null;return f.useEffect(()=>{if(r===null)return;function a(c){c.key==="Escape"&&s(null)}return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[r]),i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"tool-call-item apply-patch-item",children:t.files.map((a,c)=>n?i.jsxs("div",{className:"apply-patch-summary-row",children:[i.jsx("span",{className:"apply-patch-summary-label",children:Ql(a.action)}),i.jsx("span",{className:"apply-patch-summary-file",title:Xo(a),children:Ih(a.nextPath??a.path)}),ec(a)]},Zl(a,c)):i.jsxs("button",{type:"button",className:"apply-patch-summary-row",onClick:()=>s(c),children:[i.jsx("span",{className:"apply-patch-summary-label",children:Ql(a.action)}),i.jsx("span",{className:"apply-patch-summary-file",title:Xo(a),children:Ih(a.nextPath??a.path)}),ec(a)]},Zl(a,c)))}),i.jsx(iu,{open:o!==null,title:l("conversation.applyPatchDialogTitle"),description:l("conversation.applyPatchDialogDescription"),size:"full",layout:"viewer",className:"apply-patch-modal",bodyClassName:"apply-patch-modal-body",onClose:()=>s(null),children:o?i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"apply-patch-modal-totals",children:NI(o)}),i.jsxs("section",{className:"apply-patch-file-panel",children:[i.jsxs("div",{className:"apply-patch-file-panel-header",children:[i.jsxs("div",{className:"apply-patch-file-panel-title",children:[i.jsx("span",{className:"apply-patch-summary-label",children:Ql(o.action)}),i.jsx("strong",{children:Xo(o)})]}),ec(o)]}),i.jsx("div",{className:"apply-patch-diff-view",children:i.jsx("div",{className:"apply-patch-diff-scroll",children:o.lines.map((a,c)=>i.jsxs("div",{className:`apply-patch-diff-line ${jI(a.kind)}`,children:[i.jsx("span",{className:"apply-patch-line-number",children:zh(a.oldLineNumber)}),i.jsx("span",{className:"apply-patch-line-number",children:zh(a.newLineNumber)}),i.jsx("span",{className:"apply-patch-line-content",children:a.text||" "})]},`${Xo(o)}:${c}`))})})]},Zl(o,r??0)),e.error?i.jsxs("section",{className:"apply-patch-error-panel",children:[i.jsx("div",{className:"tool-call-section-label",children:l("conversation.toolResultLabel")}),i.jsx("pre",{className:"tool-call-error",children:e.error})]}):null]}):null})]})}function SI({tool:e,snapshot:t,workspaceId:n,exportMode:r=!1}){const s=kn(),[o,a]=f.useState({status:"idle",url:null});return f.useEffect(()=>{if(r||!n||!t.path){a({status:"idle",url:null});return}let c=!1;return a({status:"loading",url:null}),gy(n,t.path).then(u=>{if(c)return;const d=_T(u.previewPath,u.previewUrl,s.isDesktop);a(d?{status:"ready",url:d}:{status:"error",url:null})}).catch(()=>{c||a({status:"error",url:null})}),()=>{c=!0}},[r,s.isDesktop,t.path,n]),i.jsxs("div",{className:`tool-call-item view-image-tool-item ${e.status==="completed"?"tool-result":""}`,children:[i.jsx("div",{className:"tool-call-header view-image-tool-header",children:i.jsxs("div",{className:"tool-call-info",children:[i.jsx("span",{className:"tool-call-name",children:l("conversation.toolViewImageActiveLabel")}),i.jsx("span",{className:"tool-call-input-preview",children:t.displayPath})]})}),r?null:i.jsx("div",{className:"view-image-tool-preview",children:o.status==="ready"?i.jsx("img",{src:o.url,alt:t.fileName||l("conversation.attachmentPreviewAlt")}):i.jsx("div",{className:"view-image-tool-placeholder",children:o.status==="loading"?l("conversation.attachmentPreviewLoading"):l("conversation.attachmentPreviewUnavailable")})})]})}function zg({group:e,workspaceId:t,workspacePath:n,exportMode:r=!1}){const[s,o]=f.useState(!1),{navigationGroups:a}=Zb(),{tool:c,hasRequest:u,hasResult:d}=e,p=DT(c.name),h=f.useMemo(()=>LT(c,n),[c,n]),m=f.useMemo(()=>WT(a),[a]),g=f.useMemo(()=>FT(c,m),[m,c]),y=f.useMemo(()=>$T(c,m),[m,c]),S=f.useMemo(()=>zj(c,null,e.updatedAt),[e.updatedAt,c]),C=f.useMemo(()=>tI(c),[c.input,c.name]);if(h)return i.jsx(SI,{tool:c,snapshot:h,workspaceId:t,exportMode:r});if(C)return i.jsx(vI,{tool:c,preview:C,exportMode:r});if(g)return i.jsx($h,{tool:c,snapshot:g,expanded:s,hasRequest:u,hasResult:d,exportMode:r,onToggleExpanded:()=>{o(P=>!P)}});if(y)return i.jsx($h,{tool:c,snapshot:y,expanded:s,hasRequest:u,hasResult:d,exportMode:r,onToggleExpanded:()=>{o(P=>!P)}});if(S)return i.jsx(CI,{tool:c,snapshot:S,expanded:s,hasRequest:u,hasResult:d,exportMode:r,onToggleExpanded:()=>{o(P=>!P)}});const x=rI(c),A=!!(c.input||c.output||c.error),j=A&&!r,G=i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"tool-call-info",children:[i.jsx("span",{className:"tool-call-name",children:p}),i.jsx("span",{className:"tool-call-input-preview",children:x})]}),i.jsx("div",{className:"tool-call-meta",children:j&&i.jsx("span",{className:`tool-call-toggle ${s?"expanded":""}`,children:i.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:i.jsx("polyline",{points:"6 9 12 15 18 9"})})})})]});return i.jsxs("div",{className:`tool-call-item ${d?"tool-result":""}`,children:[r?i.jsx("div",{className:"tool-call-header",children:G}):i.jsx("button",{type:"button",className:"tool-call-header",onClick:()=>A&&o(P=>!P),children:G}),s&&A&&i.jsxs("div",{className:"tool-call-output",children:[u&&c.input&&i.jsxs("div",{className:"tool-call-section",children:[i.jsx("div",{className:"tool-call-section-label",children:l("conversation.toolInputLabel")}),i.jsx("pre",{children:c.input})]}),(d||c.error||c.output)&&i.jsxs("div",{className:"tool-call-section",children:[i.jsx("div",{className:"tool-call-section-label",children:l("conversation.toolResultLabel")}),i.jsx("pre",{className:c.error?"tool-call-error":void 0,children:c.error||c.output||l("conversation.toolResultEmpty")})]})]})]})}function $h({tool:e,snapshot:t,expanded:n,hasRequest:r,hasResult:s,onToggleExpanded:o,exportMode:a=!1}){const c=n?l("conversation.assistantCapabilityRawCollapse"):l("conversation.assistantCapabilityRawExpand");return i.jsxs("div",{className:"tool-call-item assistant-capability-item","data-kind":t.kind,children:[i.jsxs("div",{className:"assistant-capability-header",children:[i.jsxs("div",{className:"assistant-capability-heading",children:[i.jsx("span",{className:"assistant-capability-icon",children:i.jsx(eI,{kind:t.kind})}),i.jsxs("div",{className:"assistant-capability-heading-main",children:[i.jsx("span",{className:"assistant-capability-badge",children:t.badge}),i.jsx("strong",{children:t.title}),i.jsx("span",{className:"assistant-capability-summary",children:t.summary})]})]}),a?null:i.jsx("button",{type:"button",className:"task-tool-raw-toggle",onClick:o,children:c})]}),t.rows.length>0?i.jsx("div",{className:"assistant-capability-list",children:t.rows.map(u=>i.jsxs("div",{className:"assistant-capability-row",children:[i.jsx("span",{className:"assistant-capability-row-label",children:u.label}),i.jsx("span",{className:"assistant-capability-row-value",children:u.value})]},u.label))}):null,!a&&n?i.jsxs("div",{className:"tool-call-output",children:[r&&e.input?i.jsxs("div",{className:"tool-call-section",children:[i.jsx("div",{className:"tool-call-section-label",children:l("conversation.toolInputLabel")}),i.jsx("pre",{children:e.input})]}):null,s||e.error||e.output?i.jsxs("div",{className:"tool-call-section",children:[i.jsx("div",{className:"tool-call-section-label",children:l("conversation.toolResultLabel")}),i.jsx("pre",{className:e.error?"tool-call-error":void 0,children:e.error||e.output||l("conversation.toolResultEmpty")})]}):null]}):null]})}function CI({tool:e,snapshot:t,expanded:n,hasRequest:r,hasResult:s,onToggleExpanded:o,exportMode:a=!1}){return i.jsx(Jj,{snapshot:t,toolName:e.name,expanded:n,exportMode:a,onToggleExpanded:a?void 0:o,children:!a&&n?i.jsxs("div",{className:"tool-call-output",children:[r&&e.input?i.jsxs("div",{className:"tool-call-section",children:[i.jsx("div",{className:"tool-call-section-label",children:l("conversation.toolInputLabel")}),i.jsx("pre",{children:e.input})]}):null,s||e.error||e.output?i.jsxs("div",{className:"tool-call-section",children:[i.jsx("div",{className:"tool-call-section-label",children:l("conversation.toolResultLabel")}),i.jsx("pre",{className:e.error?"tool-call-error":void 0,children:e.error||e.output||l("conversation.toolResultEmpty")})]}):null]}):null})}function Ql(e){return e==="add"?l("conversation.applyPatchAddedLabel"):e==="delete"?l("conversation.applyPatchDeletedLabel"):l("conversation.applyPatchEditedLabel")}function Xo(e){return e.nextPath&&e.nextPath!==e.path?`${e.path} -> ${e.nextPath}`:e.nextPath??e.path}function Zl(e,t){return`${e.path}:${e.nextPath??""}:${t}`}function ec(e){return e.statsKnown?i.jsxs("span",{className:"apply-patch-summary-stats",children:[i.jsxs("span",{className:"apply-patch-summary-added",children:["+",e.additions]}),i.jsxs("span",{className:"apply-patch-summary-removed",children:["-",e.deletions]})]}):i.jsx("span",{className:"apply-patch-summary-stats",children:i.jsx("span",{className:"apply-patch-summary-edited",children:l("conversation.applyPatchEditedStat")})})}function NI(e){return e.statsKnown?i.jsxs(i.Fragment,{children:[i.jsxs("span",{className:"apply-patch-stat-pill positive",children:[l("conversation.applyPatchAddedStat")," +",e.additions]}),i.jsxs("span",{className:"apply-patch-stat-pill negative",children:[l("conversation.applyPatchRemovedStat")," -",e.deletions]})]}):i.jsx("span",{className:"apply-patch-stat-pill neutral",children:l("conversation.applyPatchEditedStat")})}function jI(e){return e==="add"?"is-added":e==="remove"?"is-removed":e==="hunk"?"is-hunk":e==="meta"?"is-meta":"is-context"}function zh(e){return e===null||e<=0?"":String(e)}function TI(e){return new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function Hg({timestamp:e,leading:t,children:n}){return i.jsxs("div",{className:"user-message-footer",children:[i.jsx("div",{className:"user-message-footer-leading",children:t}),i.jsxs("div",{className:"user-message-footer-trailing",children:[i.jsx("time",{className:"message-time",dateTime:e,children:TI(e)}),n]})]})}function ls({text:e,canCopy:t=!0,canFork:n=!1,compact:r=!1,onFork:s}){const{showToast:o}=Fn(),a=kn(),[c,u]=f.useState(!1),[d,p]=f.useState(!1),h=e.trim().length>0,m=t&&h;async function g(){if(!(!m||c)){u(!0);try{await Hu(e,a),o({title:l("conversation.copyContentSuccess"),tone:"success"})}catch(S){o({title:S instanceof Error?S.message:l("conversation.copyContentFailed"),tone:"error"})}finally{u(!1)}}}async function y(){if(!(!s||d)){p(!0);try{await s()}finally{p(!1)}}}return!m&&!n?null:i.jsxs("div",{className:r?"message-metadata-bar compact":"message-metadata-bar",children:[m?i.jsx("button",{type:"button",className:"message-metadata-action","aria-label":l("conversation.copyAction"),title:l("conversation.copyAction"),onClick:()=>{g()},disabled:c,children:i.jsx(tT,{})}):null,n?i.jsx("button",{type:"button",className:"message-metadata-action","aria-label":d?l("conversation.forkingAction"):l("conversation.forkFromHereAction"),title:d?l("conversation.forkingAction"):l("conversation.forkFromHereAction"),onClick:()=>{y()},disabled:d,children:i.jsx(nT,{})}):null]})}function II({message:e,kind:t,tone:n,actionState:r,onRetry:s,onForkMessage:o,forceExpanded:a=!1,exportMode:c=!1}){const[u,d]=f.useState(!1),p=dI(t,e.content),h=n==="user-message",m=a||u,g=t==="system_prompt"?l("conversation.systemPromptTitle"):t==="skill_context"?l("conversation.skillContextTitle"):l("conversation.rulesMessageTitle"),y=t==="system_prompt"?l("conversation.systemPromptHint"):t==="skill_context"?l("conversation.skillContextHint"):l("conversation.rulesMessageHint"),S=m?t==="system_prompt"?l("conversation.systemPromptCollapse"):t==="skill_context"?l("conversation.skillContextCollapse"):l("conversation.rulesMessageCollapse"):t==="system_prompt"?l("conversation.systemPromptExpand"):t==="skill_context"?l("conversation.skillContextExpand"):l("conversation.rulesMessageExpand");return i.jsx("article",{className:`message-item ${n} rules-message-row`,"data-message-id":e.id,children:i.jsxs("div",{className:"message-content-wrapper",children:[i.jsxs("div",{className:"rules-message-card",children:[a?i.jsx("div",{className:"rules-message-toggle","aria-expanded":m,children:i.jsxs("div",{className:"rules-message-heading",children:[i.jsx("span",{className:"rules-message-badge",children:g}),i.jsx("span",{className:"rules-message-summary",children:p})]})}):i.jsxs("button",{type:"button",className:"rules-message-toggle","aria-expanded":m,onClick:()=>d(C=>!C),children:[i.jsxs("div",{className:"rules-message-heading",children:[i.jsx("span",{className:"rules-message-badge",children:g}),i.jsx("span",{className:"rules-message-summary",children:p})]}),i.jsx("span",{className:"rules-message-action",children:S})]}),i.jsx("p",{className:"rules-message-hint",children:y}),m&&i.jsx("div",{className:"rules-message-body",children:i.jsx(Fi,{content:e.content,className:"message-text message-content markdown-content",exportMode:c})}),h?i.jsx(Hg,{timestamp:e.timestamp,children:i.jsx(ls,{text:e.content,canCopy:r.canCopy,canFork:r.canFork&&!!(o&&e.deliveryState==="sent"),compact:!0,onFork:o?()=>o(e):null})}):i.jsx(ls,{text:e.content,canCopy:r.canCopy,canFork:r.canFork&&!!(o&&e.deliveryState==="sent"),onFork:o?()=>o(e):null})]}),e.deliveryState==="failed"&&e.clientRequestId&&i.jsx("button",{className:"retry-button",type:"button",onClick:()=>s(e.clientRequestId),children:l("conversation.resendButton")})]})})}function Ug({message:e,provider:t,interruptedSource:n=null,foldedPromptKind:r=null,actionState:s,onRetry:o,onForkMessage:a,assistantAvatar:c,exportMode:u=!1,onSubmitStructuredQuestion:d}){const p=e.role==="user",h=e.kind==="thinking",m=e.role==="assistant"&&e.kind==="text",g=t==="codex"&&e.kind==="text"?Ig(e.content):null,y=r??(cI(t,e.content)?"rules":uI(t,e.content)?"skill_context":null),S=f.useMemo(()=>to(e.content),[e.content]),C=S.text,x=S.inlineImages,A=S.structuredQuestions,[j,G]=f.useState(!1),[P,T]=f.useState(!1),[K,U]=f.useState(null),[L,E]=f.useState(null);if(y){const $=e.role==="user"?"user-message":e.role==="assistant"?"assistant-message":"system-message";return i.jsx(II,{message:e,kind:y,tone:$,actionState:s,onRetry:o,onForkMessage:a,forceExpanded:u,exportMode:u})}if(g){const $=CT(n),B=g.detail?`${$}
|
|
46
|
+
|
|
47
|
+
${g.detail}`:$;return i.jsxs("article",{className:"message-item assistant-message","data-message-id":e.id,children:[i.jsx("div",{className:"message-avatar",children:c??i.jsx(tc,{})}),i.jsxs("div",{className:"message-content-wrapper",children:[i.jsx(Fi,{content:B,className:"message-text message-content markdown-content",exportMode:u}),i.jsx(ls,{text:B,canCopy:s.canCopy,canFork:!1,onFork:null})]})]})}if(p){const $=e.origin==="butler_proxy"||RI(e.clientRequestId),B=e.origin==="butler_proxy"&&typeof e.originRef=="string"&&e.originRef.trim().length>0;async function re(){if(!B)return;const F=!j;if(G(F),!(!F||L||P)){T(!0),U(null);try{const q=await dj(e.originRef);E(q.task)}catch(q){U(q instanceof Error?q.message:l("conversation.butlerOriginDetailLoadFailed"))}finally{T(!1)}}}const X=$?B?i.jsxs("div",{className:"message-origin-detail-anchor",children:[i.jsx("button",{type:"button",className:"message-origin-badge message-origin-badge-button","aria-expanded":j,onClick:()=>{re()},children:l("conversation.butlerProxyMessageBadge")}),j?i.jsxs("div",{className:"message-origin-detail-popover",role:"dialog","aria-live":"polite",children:[i.jsx("strong",{children:l("conversation.butlerOriginDetailTitle")}),P?i.jsx("p",{children:l("conversation.butlerOriginDetailLoading")}):K?i.jsx("p",{children:K}):L?i.jsxs(i.Fragment,{children:[i.jsxs("p",{children:[l("conversation.butlerOriginDetailObjectiveLabel"),":",L.objective]}),i.jsxs("p",{children:[l("conversation.butlerOriginDetailStatusLabel"),":",AI(L.status)]}),i.jsxs("p",{children:[l("conversation.butlerOriginDetailSummaryLabel"),":",L.lastAutomationSummary||l("conversation.butlerAnalysisEmpty")]}),L.waitingReason?i.jsxs("p",{children:[l("conversation.butlerOriginDetailWaitingReasonLabel"),":",L.waitingReason]}):null]}):i.jsx("p",{children:l("conversation.butlerAnalysisEmpty")})]}):null]}):i.jsx("span",{className:"message-origin-badge",children:l("conversation.butlerProxyMessageBadge")}):null;return i.jsx("article",{className:"message-item user-message","data-message-id":e.id,children:i.jsxs("div",{className:"message-content-wrapper",children:[i.jsx(Yo,{sessionId:e.sessionId,attachments:e.attachments,attachmentPayloads:e.attachmentPayloads,inlineImages:x}),C?i.jsx(Fi,{content:C,className:"message-text message-content markdown-content",exportMode:u}):null,e.deliveryState==="failed"&&e.clientRequestId&&i.jsx("button",{className:"retry-button",type:"button",onClick:()=>o(e.clientRequestId),children:l("conversation.resendButton")}),i.jsx(Hg,{timestamp:e.timestamp,leading:X,children:i.jsx(ls,{text:C,canCopy:s.canCopy,canFork:s.canFork&&!!(a&&e.deliveryState==="sent"),compact:!0,onFork:a?()=>a(e):null})})]})})}return h?i.jsxs("article",{className:"message-item assistant-message thinking-message-row","data-message-id":e.id,children:[i.jsx("div",{className:"message-avatar",children:c??i.jsx(tc,{})}),i.jsxs("div",{className:"thinking-message-content",children:[i.jsx("div",{className:"thinking-message-label",children:l("conversation.thinkingLabel")}),i.jsx(Yo,{sessionId:e.sessionId,attachments:e.attachments,attachmentPayloads:e.attachmentPayloads,inlineImages:x}),C&&i.jsx(Fi,{content:C,className:"message-text message-content markdown-content thinking-message-text",exportMode:u}),i.jsx(ls,{text:C,canCopy:s.canCopy,canFork:s.canFork&&!!(a&&e.deliveryState==="sent"),onFork:a?()=>a(e):null})]})]}):m?i.jsxs("article",{className:"message-item assistant-message","data-message-id":e.id,children:[i.jsx("div",{className:"message-avatar",children:c??i.jsx(tc,{})}),i.jsxs("div",{className:"message-content-wrapper",children:[i.jsx(Yo,{sessionId:e.sessionId,attachments:e.attachments,attachmentPayloads:e.attachmentPayloads,inlineImages:x}),C&&i.jsx(Fi,{content:C,className:"message-text message-content markdown-content",exportMode:u}),A&&d?i.jsx(EI,{messageId:e.id,prompt:A,onSubmit:d}):null,i.jsx(ls,{text:C,canCopy:s.canCopy,canFork:s.canFork&&!!(a&&e.deliveryState==="sent"),onFork:a?()=>a(e):null})]})]}):i.jsx("article",{className:"message-item system-message","data-message-id":e.id,children:i.jsxs("div",{className:"message-content-wrapper",children:[i.jsx(Yo,{sessionId:e.sessionId,attachments:e.attachments,attachmentPayloads:e.attachmentPayloads,inlineImages:x}),C?i.jsx("div",{className:"message-text message-content",children:i.jsx($g,{language:"text",content:C,exportMode:u})}):null,i.jsx(ls,{text:C,canCopy:s.canCopy,canFork:s.canFork&&!!(a&&e.deliveryState==="sent"),onFork:a?()=>a(e):null})]})})}function EI({messageId:e,prompt:t,onSubmit:n}){const[r,s]=f.useState({}),[o,a]=f.useState(!1),c=t.questions.some(u=>{var d;return(((d=r[u.id])==null?void 0:d.filter(Boolean).length)??0)===0});return i.jsxs("section",{className:"permission-request-card permission-request-card-inline",children:[i.jsxs("header",{className:"permission-request-card-header",children:[i.jsx("div",{className:"permission-request-provider",children:i.jsxs("div",{className:"permission-request-provider-copy",children:[i.jsx("strong",{children:l("conversation.permissionRequestQuestionsLabel")}),i.jsx("span",{children:l("conversation.permissionRequestSectionDescription")})]})}),i.jsx("span",{className:"permission-request-kind",children:l("conversation.permissionRequestKindUserInput")})]}),i.jsx("div",{className:"permission-request-card-body",children:i.jsxs("div",{className:"permission-request-block",children:[i.jsx("div",{className:"permission-request-block-label",children:l("conversation.permissionRequestQuestionsLabel")}),i.jsx("div",{className:"permission-request-question-list",children:t.questions.map(u=>i.jsxs("div",{className:"permission-request-question",children:[i.jsx("div",{className:"permission-request-question-header",children:u.header}),i.jsx("p",{children:u.question}),i.jsx("div",{className:"permission-request-question-options",children:u.options.map(d=>{var h;const p=((h=r[u.id])==null?void 0:h.includes(d.label))??!1;return i.jsxs("label",{className:"permission-request-question-option",children:[i.jsx("input",{type:"radio",name:`${e}:${u.id}`,checked:p,onChange:()=>{s(m=>({...m,[u.id]:[d.label]}))}}),i.jsxs("span",{children:[i.jsx("strong",{children:d.label}),d.description?i.jsx("small",{children:d.description}):null]})]},`${u.id}:${d.label}`)})})]},`${e}:${u.id}`))})]})}),i.jsx("footer",{className:"permission-request-card-footer",children:i.jsx("button",{type:"button",className:"primary-button permission-request-action",disabled:o||c,onClick:async()=>{a(!0);try{await n({messageId:e,answers:r})}finally{a(!1)}},children:o?l("conversation.permissionRequestSubmitting"):l("common.confirm")})})]})}function qg(e){return i.jsx("div",{className:"timeline-status timeline-status-inline thinking-status-inline","data-runtime-thinking-placeholder":"true",children:i.jsxs("span",{className:"status-text thinking-status-text","aria-label":e.label,children:[i.jsx("span",{children:vT(e.label)||e.label}),i.jsx("span",{className:"thinking-status-dots","aria-hidden":"true",children:"..."})]})},e.key)}function Gg(e){return i.jsxs("article",{className:"message-item assistant-message session-runtime-error-row",children:[i.jsx("div",{className:"session-runtime-error-row__spacer","aria-hidden":"true"}),i.jsxs("section",{className:"message-content-wrapper session-runtime-error-panel",role:"status","aria-label":e.error.title,children:[i.jsxs("div",{className:"session-runtime-error-panel__header",children:[i.jsxs("div",{className:"session-runtime-error-panel__title-group",children:[i.jsx("span",{className:"session-runtime-error-panel__dot","aria-hidden":"true"}),i.jsx("strong",{children:e.error.title})]}),e.error.code?i.jsx("code",{className:"session-runtime-error-panel__code",children:e.error.code}):null]}),e.error.summary?i.jsx("p",{className:"session-runtime-error-panel__summary",children:ST(e.error.summary).map((t,n)=>t.type==="text"?i.jsx("span",{children:t.text},`${e.key}:text:${n}`):i.jsx("mark",{className:`session-runtime-error-panel__summary-token session-runtime-error-panel__summary-token--${t.type}`,children:t.text},`${e.key}:${t.type}:${n}`))}):null]})]},e.key)}function MI({sessionId:e,sessionSummary:t=null,workspaceId:n=null,workspacePath:r=null,items:s,provider:o,interruptedSource:a=null,assistantAvatar:c}){const u=f.useMemo(()=>Wg({sessionSummary:t,items:s,provider:o}),[s,o,t]),d=u.renderItems,p=u.leadingSystemPromptMessageIds;return i.jsx("section",{className:"message-timeline message-timeline-export","aria-label":l("conversation.exportPrintContainerTitle"),children:i.jsxs("div",{className:"message-list message-list-export","data-export-mode":"true",children:[d.length===0?i.jsx("div",{className:"timeline-empty",children:i.jsx("p",{className:"status-text",children:l("conversation.timelineEmpty")})}):null,d.map(h=>h.type==="tool_group"?i.jsx("article",{className:"message-item tool-message-row",children:i.jsx(zg,{group:h.group,workspaceId:n,workspacePath:r,exportMode:!0})},h.key):h.type==="runtime_thinking"?qg(h):h.type==="session_error"?Gg(h):i.jsx(Ug,{message:h.message,provider:o,foldedPromptKind:p.has(h.message.id)?"system_prompt":null,actionState:{canCopy:!1,canFork:!1},onRetry:()=>{},onForkMessage:null,interruptedSource:a,assistantAvatar:c,exportMode:!0},h.key))]})})}function tc(){return i.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[i.jsx("circle",{cx:"12",cy:"12",r:"10"}),i.jsx("path",{d:"M12 16v-4M12 8h.01"})]})}function RI(e){return typeof e=="string"&&e.startsWith("butler-follow-up:")}function AI(e){switch(e){case"waiting_user":return l("shell.butlerAutomationStatusWaitingUser");case"completed":return l("shell.butlerAutomationStatusCompleted");case"failed":return l("shell.butlerAutomationStatusFailed");case"cancelled":return l("shell.butlerAutomationStatusCancelled");case"active":default:return l("shell.butlerAutomationStatusActive")}}function oL({sessionId:e="session",sessionSummary:t=null,workspaceId:n=null,workspacePath:r=null,items:s,historyState:o,loadingOlderMessages:a=!1,hasOlderMessages:c=!1,onLoadOlderMessages:u=()=>{},onRetryMessage:d,onForkMessage:p,provider:h,interruptedSource:m=null,assistantAvatar:g,followTailUpdates:y=!1,onSubmitStructuredQuestion:S}){var $n;const{showToast:C}=Fn(),x=kn(),A=!y,j=f.useRef(null);Ou(j);const G=f.useRef(e),P=f.useRef(0),T=f.useRef(null),K=f.useRef(!0),U=f.useRef(null),L=f.useRef(null),E=f.useRef(!1),$=f.useRef(y?null:Ko(e)),B=f.useRef(y?null:(($n=Ko(e))==null?void 0:$n.lastMessageSignature)??null),re=f.useRef(y?null:Ko(e)),X=f.useRef(null),F=f.useRef(null),q=f.useRef(null),D=f.useRef(0),V=f.useRef(!1),te=f.useRef(null),v=f.useRef(null),je=f.useRef(null),[Te,N]=f.useState(!1),[de,Ie]=f.useState(!1),he=f.useRef(!1),le=f.useRef(null),Fe=x.isMobile?0:ET,Ue=f.useMemo(()=>xT(s),[s]),_e=f.useMemo(()=>wT(s),[s]),qe=f.useMemo(()=>Wg({sessionSummary:t,items:s,provider:h}),[s,h,t]),W=qe.visibleMessages,Y=qe.renderItems,se=qe.leadingSystemPromptMessageIds,Ce=qe.actionStateByMessageId,ve=o==="loading"&&Ue.length===0;function fe(_){var ce,Se,ke;if(!_)return null;try{const be=JSON.parse(_);return{type:typeof be.type=="string"?be.type:"message",key:typeof be.key=="string"?be.key:null,id:typeof be.id=="string"?be.id:null,timestamp:typeof be.timestamp=="string"?be.timestamp:null,deliveryState:typeof be.deliveryState=="string"?be.deliveryState:null,contentLength:typeof be.content=="string"?be.content.length:0,labelLength:typeof be.label=="string"?be.label.length:0,summaryLength:typeof be.summary=="string"?be.summary.length:0,messageIdCount:Array.isArray(be.messageIds)?be.messageIds.length:0,attachmentCount:Array.isArray(be.attachments)?be.attachments.length:0,toolStatus:typeof((ce=be.toolCall)==null?void 0:ce.status)=="string"?be.toolCall.status:null,hasToolOutput:typeof((Se=be.toolCall)==null?void 0:Se.output)=="string"?be.toolCall.output.length>0:!1,hasToolError:typeof((ke=be.toolCall)==null?void 0:ke.error)=="string"?be.toolCall.error.length>0:!1}}catch{return{parseError:!0,length:_.length}}}function ht(_){var ce;return{id:_.id,rawRef:_.rawRef,role:_.role,kind:_.kind,deliveryState:_.deliveryState,timestamp:_.timestamp,sequence:_.sequence,attachmentCount:((ce=_.attachments)==null?void 0:ce.length)??0,contentPreview:to(_.content).text.replace(/\r\n/g,`
|
|
48
|
+
`).trimEnd().slice(0,120)}}function Ke(_){return _.type==="message"?{type:_.type,key:_.key,message:ht(_.message)}:_.type==="runtime_thinking"?{type:_.type,key:_.key,labelPreview:_.label.slice(0,80)}:_.type==="session_error"?{type:_.type,key:_.key,code:_.error.code,summary:_.error.summary}:{type:_.type,key:_.key,callId:_.group.tool.callId,name:_.group.tool.name,hasRequest:_.group.hasRequest,hasResult:_.group.hasResult,updatedAt:_.group.updatedAt}}function st(_,ce){const Se=_.getBoundingClientRect(),ke=ce.getBoundingClientRect(),be=Math.max(ke.top,Se.top),wt=Math.min(ke.bottom,Se.bottom),zt=Math.max(0,wt-be);return{top:Math.round(ke.top),bottom:Math.round(ke.bottom),height:Math.round(ke.height),relativeTop:Math.round(ke.top-Se.top),relativeBottom:Math.round(ke.bottom-Se.top),bottomGap:Math.round(Se.bottom-ke.bottom),visibleHeight:Math.round(zt),fullyVisible:ke.top>=Se.top&&ke.bottom<=Se.bottom}}function I(_,ce){var be;const Se=ce.dataset.messageId??null,ke=Se?W.find(wt=>wt.id===Se)??null:null;return{messageId:Se,role:(ke==null?void 0:ke.role)??null,kind:(ke==null?void 0:ke.kind)??null,className:ce.className,textLength:((be=ce.textContent)==null?void 0:be.length)??0,rect:st(_,ce)}}function z(_){var be;if(!_)return null;const ce=_.getBoundingClientRect(),Se=Array.from(_.children).filter(wt=>wt instanceof HTMLElement&&wt.classList.contains("message-item")),ke=_.querySelector("[data-runtime-thinking-placeholder='true']");return{listRect:{top:Math.round(ce.top),bottom:Math.round(ce.bottom),height:Math.round(ce.height)},messageElementCount:Se.length,tailDomItems:Se.slice(-5).map(wt=>I(_,wt)),runtimeThinkingPlaceholderDom:ke?{textLength:((be=ke.textContent)==null?void 0:be.length)??0,rect:st(_,ke)}:null}}function ie(_,ce={}){const Se=W[0]??null,ke=W.at(-1)??null,be=Y.at(-1)??null,wt=$.current,zt=re.current,Ht=_?_.scrollHeight-_.clientHeight-_.scrollTop:null;return{sessionId:e,historyState:o,followTailUpdates:y,messagesLength:W.length,rawMessagesLength:Ue.length,renderItemsLength:Y.length,firstMessageId:(Se==null?void 0:Se.id)??null,firstMessageRole:(Se==null?void 0:Se.role)??null,lastMessageId:(ke==null?void 0:ke.id)??null,lastMessageRole:(ke==null?void 0:ke.role)??null,lastMessageKind:(ke==null?void 0:ke.kind)??null,lastMessageTimestamp:(ke==null?void 0:ke.timestamp)??null,runtimeThinkingPlaceholderVisible:!!_e,runtimeThinkingPlaceholderLength:(_e==null?void 0:_e.length)??0,runtimeThinkingPlaceholderPreview:(_e==null?void 0:_e.slice(0,80))??null,tailItemType:(be==null?void 0:be.type)??null,tailItemKey:(be==null?void 0:be.key)??null,tailToolCallId:be&&be.type==="tool_group"?be.group.tool.callId:null,scrollTop:(_==null?void 0:_.scrollTop)??null,scrollHeight:(_==null?void 0:_.scrollHeight)??null,clientHeight:(_==null?void 0:_.clientHeight)??null,distanceToBottom:Ht,stickToBottomRef:K.current,hasNewMessagesBelow:he.current,previousMessageCount:P.current,previousLastMessage:fe(T.current),hiddenMessageIds:qe.hiddenMessageIds,validationIssues:qe.validationIssues,tailMessages:W.slice(-5).map(ht),tailRenderItems:Y.slice(-5).map(Ke),dom:z(_),pendingRestoreState:wt===null?null:{scrollTop:wt.scrollTop,stickToBottom:wt.stickToBottom,lastMessage:fe(wt.lastMessageSignature)},currentScrollState:zt===null?null:{scrollTop:zt.scrollTop,stickToBottom:zt.stickToBottom,lastMessage:fe(zt.lastMessageSignature)},restoredTailMessage:fe(B.current),...ce}}function ue(_,ce,Se={}){kc()&&fy(_,ie(ce,Se))}function we(_){const Se=_.scrollHeight-_.clientHeight-_.scrollTop<=Ph;return{scrollTop:_.scrollTop,stickToBottom:Se,lastMessageSignature:he.current&&!Se?B.current:is(Y.at(-1)??null)}}function H(_){return re.current=we(_),re.current}function J(_){const ce=_.scrollHeight-_.clientHeight-_.scrollTop,Se=ce<=Ph;K.current=Se,Se&&he.current&&(Ye(),he.current=!1,B.current=is(Y.at(-1)??null),Ie(!1)),N(Y.length>0&&(ce>Lh||he.current)),H(_),ue("affordance.sync",_,{distanceToBottom:ce,nextStickToBottom:Se})}function ge(_=j.current){A&&(_&&H(_),re.current&&Ah(e,re.current))}function xe(_){A&&re.current&&Ah(_,re.current)}function De(){X.current!==null&&(window.clearTimeout(X.current),X.current=null)}function He(){A&&(De(),X.current=window.setTimeout(()=>{X.current=null,ge()},jT))}function xt(_,ce,Se={}){ue("jump_to_bottom.before",_,{reason:ce,...Se}),_.scrollTop=_.scrollHeight,ue("jump_to_bottom.after",_,{reason:ce,...Se})}function lt(){F.current!==null&&(window.clearTimeout(F.current),F.current=null)}function Ye(){lt(),V.current=!1,q.current=null,D.current=0,te.current=null}function nt(_,ce){const Se=Math.max(0,_.scrollHeight-_.clientHeight),ke=Math.max(0,Math.min(ce,Se));te.current=ke,_.scrollTop=ke,K.current=!1,ue("manual_restore.apply",_,{targetScrollTop:ce,maxScrollableTop:Se,nextScrollTop:ke}),N(Y.length>0&&(Se-ke>Lh||he.current))}function Qe(){lt(),V.current&&(F.current=window.setTimeout(()=>{F.current=null;const _=j.current,ce=q.current;if(!_||ce===null){Ye();return}if(nt(_,ce),Date.now()<D.current){Qe();return}Ye(),J(_)},IT))}function rt(_,ce){if(Fe<=0){nt(ce,_),Ye();return}V.current=!0,q.current=_,D.current=Date.now()+Fe,nt(ce,_),Qe()}function pt(){V.current&&(ue("manual_restore.interrupt",j.current),Ye())}function $t(_){return E.current||!c||a||o!=="ready"||_.scrollTop>NT?!1:(E.current=!0,U.current=_.scrollHeight-_.scrollTop,L.current=is(Y[0]??null),ue("older_history.prefetch",_,{pendingOlderLoadOffset:U.current,pendingOlderLoadHeadMessage:fe(L.current)}),u(),!0)}f.useEffect(()=>{o==="error"&&C({title:l("conversation.historyLoadFailed"),tone:"error"})},[o,C]),f.useLayoutEffect(()=>{var _,ce;if(G.current!==e){const Se=G.current;xe(Se),G.current=e,P.current=0,T.current=null,$.current=y?null:Ko(e),B.current=((_=$.current)==null?void 0:_.lastMessageSignature)??null,re.current=$.current,K.current=y?!0:((ce=$.current)==null?void 0:ce.stickToBottom)??!0,U.current=null,L.current=null,Ye(),he.current=!1,Ie(!1),N(!1),ue("session.switch",j.current,{previousSessionId:Se,nextSessionId:e})}},[y,A,e]),f.useLayoutEffect(()=>()=>{De(),Ye(),xe(G.current)},[A,e]),f.useLayoutEffect(()=>{const _=j.current,ce=is(Y.at(-1)??null);if(!_){P.current=Y.length,T.current=ce;return}const Se=P.current,ke=T.current,be=$.current,wt=Se===0||Y.length!==Se||ce!==ke;if(ue("messages.effect.start",_,{previousCount:Se,previousLastMessage:fe(ke),currentLastMessage:fe(ce),hasTailUpdate:wt}),be&&o==="ready"){const ir=!be.stickToBottom&&be.lastMessageSignature!==null&&ce!==null&&be.lastMessageSignature!==ce;be.stickToBottom?(Ye(),xt(_,"restore_ready_stick_to_bottom",{hasTailUpdates:ir})):(rt(be.scrollTop,_),ue("restore_ready.manual",_,{hasTailUpdates:ir,targetScrollTop:be.scrollTop})),he.current=ir,B.current=be.lastMessageSignature,Ie(ir),$.current=null,J(_),P.current=Y.length,T.current=ce,H(_);return}if(be&&o==="error"){be.stickToBottom?(Ye(),xt(_,"restore_error_stick_to_bottom")):(rt(be.scrollTop,_),ue("restore_error.manual",_,{targetScrollTop:be.scrollTop})),$.current=null,J(_),P.current=Y.length,T.current=ce,H(_);return}if(V.current){nt(_,q.current??_.scrollTop),P.current=Y.length,T.current=ce,H(_);return}const zt=is(Y[0]??null),Ht=U.current,yn=L.current,En=Ht!==null&&!a&&yn!==null&&yn!==zt&&Y.length>=Se,nn=wt&&(y||K.current);ue("messages.effect.decision",_,{currentHeadMessage:fe(zt),pendingOlderLoadOffset:Ht,pendingOlderLoadHeadMessage:fe(yn),shouldRestoreOlderLoadOffset:En,shouldFollowTailUpdate:nn,loadingOlderMessages:a}),En?(_.scrollTop=Math.max(0,_.scrollHeight-Ht),U.current=null,L.current=null):U.current!==null&&!a?(U.current=null,L.current=null,nn&&xt(_,"older_load_offset_cleared_follow_tail",{pendingOlderLoadOffset:Ht})):nn&&xt(_,"tail_update_follow"),J(_),P.current=Y.length,T.current=ce},[o,a,Y,e]),f.useEffect(()=>{if(!c){E.current=!1;return}!a&&U.current===null&&(E.current=!1)},[c,a,W.length]),f.useLayoutEffect(()=>{const _=je.current;_!==_e&&(ue("runtime_thinking.placeholder_change",j.current,{previousVisible:!!_,nextVisible:!!_e,previousLength:(_==null?void 0:_.length)??0,nextLength:(_e==null?void 0:_e.length)??0,note:"Codex 思考中占位符已经并入统一 timeline source item 列表;调试时直接看 renderItems 尾部即可。"}),je.current=_e)},[_e,e]),f.useEffect(()=>{const _=j.current;if(!kc()||!_||typeof ResizeObserver>"u")return;const ce=new ResizeObserver(()=>{ue("list.resize",_)});return ce.observe(_),()=>{ce.disconnect()}},[e,W.length]),f.useEffect(()=>{const _=pI(Y),ce=fI(le.current,_,W);(qe.hiddenMessageIds.length>0||qe.validationIssues.length>0||ce.length>0)&&py("timeline.render",{sessionId:e,hiddenMessageIds:qe.hiddenMessageIds,validationIssues:qe.validationIssues,assistantRenderMoves:ce,rawTailMessages:Ue.slice(-6).map(ht),visibleTailMessages:W.slice(-6).map(ht),renderTailItems:Y.slice(-6).map(Ke)}),le.current=_},[Ue,Y,e,qe.hiddenMessageIds,qe.validationIssues,W]);function Ge(){const _=j.current;if(_){if(V.current){const ce=te.current;ce!==null&&Math.abs(_.scrollTop-ce)<=1?te.current=null:pt()}J(_),He(),ue("scroll",_),$t(_)}}function ft(_){if(_.deltaY!==0&&pt(),_.deltaY>=0)return;const ce=j.current;ce&&$t(ce)}function Be(_){var ce;pt(),v.current=((ce=_.touches[0])==null?void 0:ce.clientY)??null}function Nt(_){var be;const ce=v.current,Se=((be=_.touches[0])==null?void 0:be.clientY)??null;if(ce===null||Se===null||Se-ce<TT)return;pt();const ke=j.current;ke&&$t(ke)}function Ze(){v.current=null}return i.jsxs("section",{className:"message-timeline",children:[o==="loading"&&i.jsx("div",{className:"timeline-status",children:i.jsx("span",{className:"status-text",children:l("conversation.historyLoading")})}),i.jsxs("div",{ref:j,className:"message-list","data-scrollbar-autohide":"true",onScroll:Ge,onPointerDown:pt,onWheel:ft,onTouchStart:Be,onTouchMove:Nt,onTouchEnd:Ze,onTouchCancel:Ze,children:[ve?i.jsx(wI,{}):null,a?i.jsx("div",{className:"timeline-status timeline-status-inline",children:i.jsx("span",{className:"status-text",children:l("conversation.historyLoadingOlder")})}):null,Y.length===0&&o==="ready"&&i.jsx("div",{className:"timeline-empty",children:i.jsx("p",{className:"status-text",children:l("conversation.timelineEmpty")})}),Y.map(_=>_.type==="tool_group"?i.jsx("article",{className:"message-item tool-message-row",children:i.jsx(zg,{group:_.group,workspaceId:n,workspacePath:r})},_.key):_.type==="runtime_thinking"?qg(_):_.type==="session_error"?Gg(_):i.jsx(Ug,{message:_.message,provider:h,foldedPromptKind:se.has(_.message.id)?"system_prompt":null,actionState:Ce.get(_.message.id)??{canCopy:_.message.role==="user",canFork:!1},onRetry:d,onForkMessage:p,interruptedSource:m,assistantAvatar:g,onSubmitStructuredQuestion:S},_.key))]}),Te?i.jsxs("button",{type:"button",className:"conversation-scroll-to-bottom-button","data-has-new":de?"true":"false","aria-label":l("conversation.scrollToBottomAction"),title:l("conversation.scrollToBottomAction"),onClick:()=>{const _=j.current;_&&(Ye(),xt(_,"scroll_button_click"),he.current=!1,B.current=is(Y.at(-1)??null),Ie(!1),J(_),ge(_))},children:[de?i.jsx("span",{className:"conversation-scroll-to-bottom-button-badge",children:"NEW"}):null,i.jsx("svg",{className:"conversation-scroll-to-bottom-button-icon",viewBox:"0 0 20 20","aria-hidden":"true",focusable:"false",children:i.jsx("path",{d:"M10 4.25a.75.75 0 0 1 .75.75v7.19l2.72-2.72a.75.75 0 1 1 1.06 1.06l-4 4a.75.75 0 0 1-1.06 0l-4-4a.75.75 0 1 1 1.06-1.06l2.72 2.72V5a.75.75 0 0 1 .75-.75Zm-4 11a.75.75 0 0 1 0-1.5h8a.75.75 0 0 1 0 1.5H6Z",fill:"currentColor"})})]}):null]})}function is(e){return e?"type"in e?e.type==="message"?is(e.message):e.type==="tool_group"?JSON.stringify({type:e.type,key:e.key,messageIds:e.group.messageIds,timestamp:e.group.updatedAt,toolCall:{status:e.group.tool.status,output:e.group.tool.output,error:e.group.tool.error}}):e.type==="runtime_thinking"?JSON.stringify({type:e.type,key:e.key,label:e.label}):JSON.stringify({type:e.type,key:e.key,summary:e.error.summary,code:e.error.code}):JSON.stringify({type:"message",id:e.id,content:e.content,attachments:e.attachments,timestamp:e.timestamp,deliveryState:e.deliveryState,toolCall:e.toolCall?{status:e.toolCall.status,output:e.toolCall.output,error:e.toolCall.error}:null}):null}function PI(e){const t=new Map;let n=0;function r(s){let o=null;for(let a=s-1;a>=n;a-=1){const c=e[a];if(!(!c||!LI(c))){o=c.id;break}}for(let a=n;a<s;a+=1){const c=e[a];if(c){if(c.role==="user"){t.set(c.id,{canCopy:!0,canFork:!1});continue}t.set(c.id,{canCopy:c.id===o,canFork:c.id===o})}}}for(let s=0;s<e.length;s+=1){const o=e[s];o&&o.role==="user"&&s>n&&(r(s),n=s)}return r(e.length),t}function LI(e){return e.role==="user"?!1:e.kind!=="tool_call"&&e.kind!=="tool_result"}function _I(e){return Uu(e)!==null}function DI(e){return e.isSubagent===!0&&!_I(e)}function Uu(e){return e.forkMethod==="reconstructed_message_fork"||e.forkMethod==="reconstructed_session_fork"?"reconstructed":e.forkMethod==="native_message_fork"||e.forkSourceType==="message"?"message":e.forkMethod==="native_session_fork"||e.forkSourceType==="session"?"session":null}function BI(e){const t=Uu(e);return t==="reconstructed"?l("shell.sessionForkReconstructed"):t==="message"?l("shell.sessionForkMessage"):t==="session"?l("shell.sessionForkSession"):null}function OI(e){return e.sessionKind==="annotation"?"annotation":null}function aL(e){return OI(e)==="annotation"?l("conversation.actionSessionBadge"):null}const Hh=120*1e3,WI=8,FI=/\[\[CODINGNS_IMAGE_ATTACHMENTS\]\][\s\S]*?\[\[\/CODINGNS_IMAGE_ATTACHMENTS\]\]/g,$I=/\[\[CODINGNS_IMAGE_ATTACHMENTS\]\][\s\S]*?\[\[\/CODINGNS_IMAGE_ATTACHMENTS\]\]/;function lL(e){return{session:(e==null?void 0:e.session)??null,capabilities:(e==null?void 0:e.capabilities)??null,runtimeHasActiveRun:(e==null?void 0:e.runtimeHasActiveRun)??null,runtimeCanInterrupt:(e==null?void 0:e.runtimeCanInterrupt)??null,contextUsage:(e==null?void 0:e.contextUsage)??null,messages:(e==null?void 0:e.messages)??[],timelineItems:(e==null?void 0:e.timelineItems)??[],permissionRequests:(e==null?void 0:e.permissionRequests)??[],queuedMessages:(e==null?void 0:e.queuedMessages)??[],historyState:"idle",loadingOlderMessages:!1,olderCursor:(e==null?void 0:e.olderCursor)??null,hasOlderMessages:(e==null?void 0:e.hasOlderMessages)??!1,connectionState:"closed",lastCursor:(e==null?void 0:e.lastCursor)??null,pagesLoaded:(e==null?void 0:e.pagesLoaded)??0,interruptSource:(e==null?void 0:e.interruptSource)??null,errorCode:null,errorDetail:null}}function Vg(e,t,n="sent",r=null){const s=t.kind??(t.role==="tool"?"tool_result":"text"),o=t.toolCall??(s==="tool_call"||s==="tool_result"?{callId:t.rawRef||t.messageId,name:"tool",input:s==="tool_call"?t.content:"",output:s==="tool_result"&&t.content?t.content:null,error:null,status:s==="tool_call"?"running":"completed"}:null);return{id:t.messageId,sessionId:e,role:t.role,kind:s,content:fE(t.provider,t.role,s,t.content),toolCall:o,attachments:t.attachments??[],attachmentPayloads:null,origin:t.origin??null,originRef:t.originRef??null,timestamp:t.timestamp,sequence:t.sequence,rawRef:t.rawRef,deliveryState:n,clientRequestId:r}}function cL(e,t,n,r=[],s=[],o=Number.MAX_SAFE_INTEGER){return{id:`pending-${n}`,sessionId:e,role:"user",kind:"text",content:t,toolCall:null,attachments:r,attachmentPayloads:s,origin:null,originRef:null,timestamp:new Date().toISOString(),sequence:o,rawRef:`pending://${n}`,deliveryState:"sending",clientRequestId:n}}function uL(e,t){return Kg([...e,t])}function dL(e,t,n){const r=new Map,s=new Set,o=[];for(const a of e)r.set(a.id,a),s.add(a.id);for(const a of n){const c=Vg(t,a);o.push(c);const u=yE(r,c,t);if(u&&u!==c.id)continue;const d=kE(r,c,t),p=d&&d!==c.id?r.get(d)??null:null;d&&d!==c.id&&r.delete(d);const h=xE(r,s,c);if(h&&h!==c.id){const S=r.get(h)??null;if(S){const C=Oc(S,c);Dr("session.messages.codex_equivalent_replace",{sessionId:t,previous:_t(S),incoming:_t(c),merged:_t(C)}),r.delete(h),r.set(a.messageId,C);continue}}const m=vE(r,c);if(m&&m!==c.id){const S=r.get(m)??null;if(S){const C=rE(S,c);Dr("session.messages.opencode_equivalent_replace",{sessionId:t,previous:_t(S),incoming:_t(c),merged:_t(C)}),r.set(m,C);continue}}const g=r.get(a.messageId)??null,y=p===null?c:nE(c,p);r.set(a.messageId,g?Oc(g,y):y)}return Kg(SE(Array.from(r.values()),o))}function hL(e,t){const n=new Map;for(const r of e)n.set(Vh(r),r);for(const r of t){const s=Vh(r),o=n.get(s)??null;if(o){Dr("session.messages.runtime_overlay_merge",{overlayKey:s,mode:"update",previous:_t(o),incoming:_t(r)}),n.set(s,sE(o,r));continue}Dr("session.messages.runtime_overlay_merge",{overlayKey:s,mode:"insert",incoming:_t(r)}),n.set(s,r)}return Yg(Array.from(n.values()))}function pL(e,t){return e.map(n=>n.clientRequestId===t?{...n,deliveryState:"failed"}:n)}function zI(e){const t=[];let n=null,r=!1;for(const s of e)if(!oE(n,s,r)){if(t.push(s),oo(s)){n=s,r=!1;continue}n&&aE(s)&&(r=!0)}return t}function HI(e){const t=[];for(const n of e){const r=t.at(-1);if(!r||!Zg(r,n)){t.push(n);continue}t[t.length-1]=eb(r,n)}return t}function UI(e){const t=[];for(const n of e){if(t.push(n),t.length<4)continue;const r=t[t.length-4],s=t[t.length-3],o=t[t.length-2],a=t[t.length-1];lE(r,s,o,a)&&t.splice(t.length-3,3,eb(s,a))}return t}function qI(e){const t=[];for(const n of e){const r=t.at(-1);if(!r||!cE(r,n)){t.push(n);continue}t[t.length-1]=dE(r,n)}return t}function GI(e){const t=[];for(const n of e){const r=t.findIndex(s=>uE(s,n));if(r===-1){t.push(n);continue}t[r]=hE(t[r],n)}return t}function Kg(e){const t=Yg(e);return GI(qI(zI(UI(HI(t)))))}function Yg(e){return[...e].sort((t,n)=>Xg(t,n))}function Xg(e,t){const n=VI(e.rawRef,t.rawRef);if(n!==null&&n!==0)return n;if(e.sequence!==t.sequence)return e.sequence-t.sequence;const r=KI(e.rawRef,t.rawRef);if(r!==0)return r;const s=e.timestamp.localeCompare(t.timestamp);if(s!==0)return s;const o=YI(e.rawRef,t.rawRef);if(o!==0)return o;const a=tE(e.role,t.role);if(a!==0)return a;const c=e.rawRef.localeCompare(t.rawRef);return c!==0?c:e.id.localeCompare(t.id)}function VI(e,t){if(!e.startsWith("codex://")||!t.startsWith("codex://"))return null;const n=so(e),r=so(t);if(!n||!r||n!==r)return null;const s=io(e),o=io(t);if(s===null||o===null)return null;if(s!==o)return s-o;const a=ps(e,"part")??0,c=ps(t,"part")??0;return a-c}function so(e){const t=e.match(/^codex:\/\/(.+?)(?:#|$)/);return(t==null?void 0:t[1])??null}function KI(e,t){const n=eE(e,t);if(n!==null&&n!==0)return n;const r=XI(e,t);if(r!==null&&r!==0)return r;const s=qh(e),o=qh(t);if(!s&&!o||!s||!o)return 0;const a=Math.max(s.length,o.length);for(let c=0;c<a;c+=1){const u=s[c],d=o[c];if(u===void 0&&d===void 0)return 0;if(u===void 0)return-1;if(d===void 0)return 1;if(u!==d)return u-d}return 0}function YI(e,t){const n=io(e),r=io(t);return n===null&&r===null?0:n===null?1:r===null?-1:n-r}function io(e){const t=e.match(/(?:^|[?#&])line=(\d+)(?:$|[&#])/);if(!t)return null;const n=Number.parseInt(t[1]??"",10);return Number.isFinite(n)?n:null}function XI(e,t){const n=Uh(e),r=Uh(t);if(!n||!r||n!==r)return null;const s=ps(e,"part"),o=ps(t,"part");return s===null||o===null?null:s-o}function Uh(e){const t=e.match(/^(.+\/message\/[^/?#]+)\/part\/[^/?#]+(?:[?#].*)?$/i);return(t==null?void 0:t[1])??null}function qh(e){const t=io(e);if(t!==null){const s=ps(e,"part");return s===null?[t]:[t,s]}const n=JI(e);if(n)return n;const r=QI(e);return r||null}function JI(e){const t=ps(e,"index");if(t===null)return null;const n=ps(e,"part");return n===null?[t]:[t,n]}function ps(e,t){const n=e.match(new RegExp(`(?:^|[?#&])${t}=(\\d+)(?:$|[&#])`));if(!n)return null;const r=Number.parseInt(n[1]??"",10);return Number.isFinite(r)?r:null}function QI(e){const t=e.match(/\/message\/(user|assistant|tool)-(\d+)\/part\/([a-z_]+)-(\d+)/i);if(!t)return null;const n=ZI(t[1]??""),r=Number.parseInt(t[2]??"",10),s=$i(t[3]??""),o=Number.parseInt(t[4]??"",10);return!Number.isFinite(r)||!Number.isFinite(o)?null:[r,n,s,o]}function ZI(e){switch(e.toLowerCase()){case"user":return 0;case"assistant":return 1;case"tool":return 2;default:return 3}}function $i(e){switch(e.toLowerCase()){case"reasoning":case"thinking":return 0;case"text":return 1;case"tool":case"tool_call":case"tool_result":return 2;default:return 3}}function eE(e,t){const n="claude-code://message/";if(!e.startsWith(n)||!t.startsWith(n))return null;let r="",s="";try{r=decodeURIComponent(e.slice(n.length)),s=decodeURIComponent(t.slice(n.length))}catch{return null}const o=r.match(/^message:(assistant|user):([^:]+):type:(thinking|text)$/i),a=s.match(/^message:(assistant|user):([^:]+):type:(thinking|text)$/i);if(o&&a){const C=o[1]??"",x=a[1]??"",A=o[2]??"",j=a[2]??"";return C!==x||A!==j?0:$i(o[3]??"")-$i(a[3]??"")}const c=r.match(/^message:(assistant|user):([^:]+):part:(\d+):type:([a-z_]+)$/i),u=s.match(/^message:(assistant|user):([^:]+):part:(\d+):type:([a-z_]+)$/i);if(!c||!u)return null;const d=c[1]??"",p=u[1]??"",h=c[2]??"",m=u[2]??"";if(d!==p||h!==m)return 0;const g=Number.parseInt(c[3]??"",10),y=Number.parseInt(u[3]??"",10);if(!Number.isFinite(g)||!Number.isFinite(y))return null;const S=g-y;return S!==0?S:$i(c[4]??"")-$i(u[4]??"")}function tE(e,t){return Gh(e)-Gh(t)}function Gh(e){switch(e){case"user":return 0;case"assistant":return 1;case"tool":return 2;case"system":default:return 3}}function nE(e,t){if(!t)return e;const n=e.attachments??[];return{...e,attachments:n.length>0?n:t.attachments??[],attachmentPayloads:t.attachmentPayloads??null}}function Oc(e,t){if(e.id!==t.id)return t;if(Jg(e,t)){const a=_a(e.toolCall,t.toolCall),c=Qg(e,t,a,Da),u=Ba(e.attachments,t.attachments),d=Oa(e,t);return{...dr(e,t),kind:(a==null?void 0:a.status)==="running"?"tool_call":"tool_result",content:c,toolCall:a,attachments:u,attachmentPayloads:e.attachmentPayloads??t.attachmentPayloads??null,rawRef:d.rawRef,timestamp:d.timestamp,sequence:d.sequence}}if(e.role!==t.role||e.kind!==t.kind)return dr(e,t);const n=_a(e.toolCall,t.toolCall),r=Da(e.content,t.content,e.timestamp,t.timestamp),s=Ba(e.attachments,t.attachments),o=Oa(e,t);return{...dr(e,t),content:r,toolCall:n,attachments:s,attachmentPayloads:e.attachmentPayloads??t.attachmentPayloads??null,rawRef:o.rawRef,timestamp:o.timestamp,sequence:o.sequence}}function rE(e,t){if(Jg(e,t)){const a=_a(e.toolCall,t.toolCall),c=Qg(e,t,a,Da),u=Ba(e.attachments,t.attachments),d=Oa(e,t);return{...dr(e,t),id:e.id,kind:(a==null?void 0:a.status)==="running"?"tool_call":"tool_result",content:c,toolCall:a,attachments:u,attachmentPayloads:e.attachmentPayloads??t.attachmentPayloads??null,rawRef:d.rawRef,timestamp:d.timestamp,sequence:d.sequence,clientRequestId:e.clientRequestId??t.clientRequestId}}if(e.role!==t.role||e.kind!==t.kind)return{...dr(e,t),id:e.id,clientRequestId:e.clientRequestId??t.clientRequestId};const n=_a(e.toolCall,t.toolCall),r=Da(e.content,t.content,e.timestamp,t.timestamp),s=Ba(e.attachments,t.attachments),o=Oa(e,t);return{...dr(e,t),id:e.id,content:r,toolCall:n,attachments:s,attachmentPayloads:e.attachmentPayloads??t.attachmentPayloads??null,rawRef:o.rawRef,timestamp:o.timestamp,sequence:o.sequence,clientRequestId:e.clientRequestId??t.clientRequestId}}function Jg(e,t){return sb(e,t)||qu(e,t)}function Qg(e,t,n,r){if((n==null?void 0:n.status)==="running"){if(t.kind==="tool_call"&&t.content)return t.content;if(e.kind==="tool_call"&&e.content)return e.content}else{if(t.kind==="tool_result"&&t.content)return t.content;if(e.kind==="tool_result"&&e.content)return e.content;if(n!=null&&n.output)return n.output}return r(e.content,t.content,e.timestamp,t.timestamp)}function sE(e,t){return{...Oc(e,{...t,id:e.id,clientRequestId:e.clientRequestId??t.clientRequestId}),id:e.id,rawRef:e.rawRef,timestamp:e.timestamp,sequence:e.sequence,clientRequestId:e.clientRequestId??t.clientRequestId}}function Vh(e){var t;if(e.role==="tool"&&(e.kind==="tool_call"||e.kind==="tool_result")){const n=((t=e.toolCall)==null?void 0:t.callId.trim())??"";if(n)return`toolCall:${n}`}if(e.role==="assistant"&&(e.kind==="text"||e.kind==="thinking")&&e.rawRef.startsWith("codex://")){const n=so(e.rawRef);if(n)return`codexAssistantStream:${n}:${e.kind}:${e.sequence}`}return e.id?`id:${e.id}`:e.rawRef?`rawRef:${e.rawRef}`:`fallback:${e.role}:${e.kind}:${e.timestamp}:${e.sequence}`}function iE(e,t,n){if(e.deliveryState!=="sent"||t.deliveryState!=="sent"||!e.rawRef.startsWith("codex://")||!t.rawRef.startsWith("codex://")||e.role!==t.role||e.kind!==t.kind||e.toolCall!==null||t.toolCall!==null||e.kind!=="text"&&e.kind!=="thinking")return!1;const r=to(e.content),s=to(t.content);return gs(e.timestamp,t.timestamp,n)&&yt(r.text)===yt(s.text)&&bE(r.inlineImages,s.inlineImages)}function oE(e,t,n){return!e||n||!oo(e)||!oo(t)?!1:gs(e.timestamp,t.timestamp,120*1e3)&&yt(e.content)===yt(t.content)}function oo(e){return e.deliveryState==="sent"&&e.rawRef.startsWith("opencode://")&&e.role==="user"&&e.kind==="text"}function Wc(e){return e.deliveryState==="sent"&&e.rawRef.startsWith("opencode://")&&e.role==="assistant"&&(e.kind==="text"||e.kind==="thinking")}function aE(e){return Wc(e)&&e.kind==="text"}function Zg(e,t){return Wc(e)&&Wc(t)&&e.kind===t.kind&&gs(e.timestamp,t.timestamp,120*1e3)&&yt(e.content)===yt(t.content)}function lE(e,t,n,r){return!e||!t||!n||!r||!oo(e)||!oo(n)?!1:Zg(t,r)&&gs(e.timestamp,n.timestamp,120*1e3)&&yt(e.content)===yt(n.content)}function eb(e,t){var a,c;const n=((a=e.attachments)==null?void 0:a.length)??0,r=((c=t.attachments)==null?void 0:c.length)??0;if(n!==r)return n>r?e:t;const s=yt(e.content).length,o=yt(t.content).length;return s!==o?s>o?e:t:dr(e,t)}function cE(e,t){return!Kh(e)||!Kh(t)?!1:e.role===t.role&&gs(e.timestamp,t.timestamp,120*1e3)&&yt(e.content)===yt(t.content)}function uE(e,t){return!Yh(e)||!Yh(t)?!1:e.role===t.role&&gs(e.timestamp,t.timestamp,120*1e3)&&yt(e.content)===yt(t.content)}function Kh(e){return e.deliveryState==="sent"&&e.rawRef.startsWith("gemini://session/")&&e.kind==="text"&&e.toolCall===null&&(e.role==="user"||e.role==="assistant")}function Yh(e){return e.deliveryState==="sent"&&e.rawRef.startsWith("kimi://session/")&&e.kind==="text"&&e.toolCall===null&&(e.role==="user"||e.role==="assistant")}function dE(e,t){var u,d;const n=((u=e.attachments)==null?void 0:u.length)??0,r=((d=t.attachments)==null?void 0:d.length)??0;if(n!==r)return n>r?e:t;const s=yt(e.content).length,o=yt(t.content).length;if(s!==o)return s>o?e:t;const a=e.rawRef.includes("#file="),c=t.rawRef.includes("#file=");return a!==c?a?e:t:dr(e,t)}function hE(e,t){var u,d;const n=((u=e.attachments)==null?void 0:u.length)??0,r=((d=t.attachments)==null?void 0:d.length)??0;if(n!==r)return n>r?e:t;const s=yt(e.content).length,o=yt(t.content).length;if(s!==o)return s>o?e:t;const a=e.rawRef.includes("/context#"),c=t.rawRef.includes("/context#");return a!==c?a?e:t:dr(e,t)}function _a(e,t){return e?t?{...pE(e,t),input:tb(e.input,t.input),output:Jh(e.output,t.output),error:Jh(e.error,t.error)}:e:t}function pE(e,t){const n=Xh(e.status),r=Xh(t.status);return r!==n?r>n?t:e:t}function Xh(e){return e==="running"?0:1}function Da(e,t,n,r){const s=yt(e),o=yt(t);if(s===o){const a=gE(e,t);return a!==null?a:e.length>=t.length?e:t}return s.length>o.length&&s.includes(o)?e:o.length>s.length&&o.includes(s)||r.localeCompare(n)>=0?t:e}function Ba(e,t){const n=(e==null?void 0:e.length)??0,r=(t==null?void 0:t.length)??0;return r!==n?r>n?t:e:t??e}function tb(e,t){return t.length>e.length?t:e}function Jh(e,t){return e===null?t:t===null?e:tb(e,t)}function dr(e,t){return t.timestamp!==e.timestamp?t.timestamp.localeCompare(e.timestamp)>=0?t:e:t.sequence!==e.sequence?t.sequence>=e.sequence?t:e:t}function Oa(e,t){return Xg(e,t)<=0?e:t}function yt(e){return mE(e).replace(/\r\n/g,`
|
|
49
|
+
`).trimEnd()}function Fc(e){return yt(e).replace(/[ \t]+\n/g,`
|
|
50
|
+
`).replace(/\n{2,}/g,`
|
|
51
|
+
`).trim()}function fE(e,t,n,r){return e!=="claude-code"&&e!=="codex"||t!=="user"&&t!=="assistant"||n!=="text"&&n!=="thinking"?r:nb(r)}function mE(e){return nb(e).replace(/\r\n/g,`
|
|
52
|
+
`).trimEnd()}function $c(e){return $I.test(e)}function nb(e){return $c(e)?e.replace(FI,"").replace(/[ \t]+\n/g,`
|
|
53
|
+
`).replace(/\n{3,}/g,`
|
|
54
|
+
|
|
55
|
+
`).trimEnd():e}function gE(e,t){const n=$c(e),r=$c(t);return n===r?null:n?t:e}function bE(e,t){return e.length===0||t.length===0?!0:e.length!==t.length?!1:e.every((n,r)=>{var s;return n.url===((s=t[r])==null?void 0:s.url)})}function kE(e,t,n){return ib(t)?rb(e,t,"optimistic",n):null}function yE(e,t,n){return nl(t)?rb(e,t,"authoritative",n):null}function xE(e,t,n){if(!Wa(n))return null;for(const[r,s]of e.entries())if(!(r===n.id||!t.has(r)||!wE(s,n)))return Dr("session.messages.codex_identity_bridge_match",{previous:_t(s),incoming:_t(n)}),r;return null}function wE(e,t){if(!CE(e,t))return!1;if(e.rawRef===t.rawRef)return!0;if(e.kind==="tool_call"||e.kind==="tool_result")return qu(e,t);const n=so(e.rawRef),r=so(t.rawRef);if(!n||!r||n!==r)return!1;const s=Math.abs(e.sequence-t.sequence);return s>1?(Dr("session.messages.codex_identity_bridge_rejected",{reason:"sequence_distance",sequenceDistance:s,previous:_t(e),incoming:_t(t)}),!1):!0}function vE(e,t){if(!Qh(t))return null;const n=Fa(t.rawRef);if(n===null)return null;const r=Br(t.timestamp);let s=null,o=Number.POSITIVE_INFINITY;for(const[a,c]of e.entries()){if(a===t.id||!Qh(c)||c.role!==t.role)continue;if(sb(c,t))return a;if(c.kind!==t.kind||Fa(c.rawRef)!==n)continue;const d=Br(c.timestamp),p=Math.abs(d-r),m=Math.abs(c.sequence-t.sequence)*6e4+p;m<o&&(s=a,o=m)}return s}function rb(e,t,n,r){const s=Br(t.timestamp),o=yt(t.content),a=Fc(t.content),c=zc(t.attachments);let u=null,d=Number.POSITIVE_INFINITY;const p=[];for(const[h,m]of e.entries()){if(!(n==="optimistic"?nl(m):ib(m)))continue;const y=yt(m.content),S=Fc(m.content),C=y===o,x=S===a;if(!C&&!x)continue;const A=Br(m.timestamp),j=Math.abs(A-s);if(j>300*1e3)continue;const G=Math.abs(m.sequence-t.sequence),P=zc(m.attachments),T=jE(P,c);if(T==="conflict"&&(C||o.length===0)){p.push(ep(m,{strictTextMatches:C,relaxedTextMatches:x,attachmentCompatibility:T,distanceMs:j,sequenceDistance:G}));continue}const K=j+G*15e3+(C?0:500)+TE(T);p.push(ep(m,{strictTextMatches:C,relaxedTextMatches:x,attachmentCompatibility:T,distanceMs:j,sequenceDistance:G})),K<d&&(u=h,d=K)}return p.length>0&&Dr("session.messages.user_match",{sessionId:r,target:n,matchedId:u,matchedScore:Number.isFinite(d)?d:null,incoming:IE(t,{relaxedContent:a,attachmentSignature:c}),candidates:p.slice(0,5)}),u}function Wa(e){return e.deliveryState==="sent"&&e.rawRef.startsWith("codex://")&&(e.role==="assistant"||e.role==="tool")}function SE(e,t){const n=t.filter(Wa);return n.length===0?e:e.map(r=>{if(!NE(r))return r;const s=Br(r.timestamp),o=n.reduce((c,u)=>Br(u.timestamp)<s?c:Math.min(c,u.sequence),Number.POSITIVE_INFINITY);if(!Number.isFinite(o)||o>=r.sequence)return r;const a={...r,sequence:o};return Dr("session.messages.synthetic_user_rebased",{syntheticMessage:_t(r),rebasedMessage:_t(a),incomingAnchors:n.slice(0,5).map(_t)}),a})}function Qh(e){return e.deliveryState==="sent"&&e.rawRef.startsWith("opencode://")&&!nl(e)&&(e.role==="user"||e.role==="assistant"||e.role==="tool")}function Zh(e){return e.deliveryState==="sent"&&e.rawRef.startsWith("opencode://")&&e.role==="tool"&&(e.kind==="tool_call"||e.kind==="tool_result")&&e.toolCall!==null}function sb(e,t){var s,o;if(!Zh(e)||!Zh(t))return!1;const n=((s=e.toolCall)==null?void 0:s.callId.trim())??"",r=((o=t.toolCall)==null?void 0:o.callId.trim())??"";return n&&r?n===r:Fa(e.rawRef)===Fa(t.rawRef)}function Fa(e){if(!e.startsWith("opencode://"))return null;const t=e.indexOf("#"),n=t>=0?e.slice(t):"",r=t>=0?e.slice(0,t):e,s=r.indexOf("?");if(s<0)return e;const o=r.slice(0,s),a=new URLSearchParams(r.slice(s+1));if(!a.has("part"))return e;a.delete("part");const c=a.toString();return`${o}${c?`?${c}`:""}${n}`}function CE(e,t){if(!Wa(e)||!Wa(t)||e.role!==t.role)return!1;const n=(e.kind==="tool_call"||e.kind==="tool_result")&&(t.kind==="tool_call"||t.kind==="tool_result");return!n&&e.kind!==t.kind?!1:n?qu(e,t):Math.abs(e.sequence-t.sequence)>WI||!gs(e.timestamp,t.timestamp,Hh)?!1:t.kind==="text"||t.kind==="thinking"?iE(e,t,Hh):!1}function qu(e,t){if(e.deliveryState!=="sent"||t.deliveryState!=="sent"||!e.rawRef.startsWith("codex://")||!t.rawRef.startsWith("codex://")||e.role!=="tool"||t.role!=="tool"||e.kind!=="tool_call"&&e.kind!=="tool_result"||t.kind!=="tool_call"&&t.kind!=="tool_result"||e.toolCall===null||t.toolCall===null)return!1;const n=e.toolCall.callId.trim(),r=t.toolCall.callId.trim();return n.length>0&&n===r}function nl(e){return e.role!=="user"||e.kind!=="text"||e.deliveryState==="failed"?!1:e.rawRef.startsWith("pending://")||e.rawRef.startsWith("synthetic://")||e.rawRef.includes("#synthetic")}function NE(e){return e.deliveryState==="sent"&&e.role==="user"&&e.kind==="text"&&e.rawRef.startsWith("synthetic://codex/")}function ib(e){return e.role==="user"&&e.kind==="text"&&!nl(e)}function Br(e){const t=Date.parse(e);return Number.isFinite(t)?t:0}function _t(e){var t;return{id:e.id,rawRef:e.rawRef,role:e.role,kind:e.kind,sequence:e.sequence,timestamp:e.timestamp,callId:((t=e.toolCall)==null?void 0:t.callId)??null,contentPreview:e.kind==="text"||e.kind==="thinking"?yt(to(e.content).text).slice(0,160):yt(e.content).slice(0,160)}}function zc(e){return(e??[]).map(t=>[t.kind,t.fileName.trim().toLowerCase(),t.mimeType.trim().toLowerCase(),String(t.fileSize)].join(":")).sort().join("|")}function jE(e,t){return!e&&!t?"same":!e||!t?"one_side_missing":e===t?"same":"conflict"}function TE(e){switch(e){case"same":return 0;case"one_side_missing":return 2500;case"conflict":default:return 12e4}}function ep(e,t){return{..._t(e),comparableContent:Fc(e.content).slice(0,160),attachmentSignature:zc(e.attachments),strictTextMatches:t.strictTextMatches,relaxedTextMatches:t.relaxedTextMatches,attachmentCompatibility:t.attachmentCompatibility,distanceMs:t.distanceMs,sequenceDistance:t.sequenceDistance}}function IE(e,t){return{..._t(e),comparableContent:t.relaxedContent.slice(0,160),attachmentSignature:t.attachmentSignature}}function fL(e){return e.reduce((n,r)=>Number.isFinite(r.sequence)&&r.sequence>n?r.sequence:n,0)+1}function gs(e,t,n){return Math.abs(Br(e)-Br(t))<=n}const EE=200;async function ME(e){const t=[],n=new Set;let r=null;for(;!(r&&n.has(r));){r&&n.add(r);const s=await mf(e,r,EE,"forward"),o=s.messages.map(a=>Vg(e,a));if(t.push(...o),!s.nextCursor||s.nextCursor===r||o.length===0)break;r=s.nextCursor}return{messages:t}}function nc(e,t,n=new Date){return`${OE(e.title||l("conversation.titleFallback"))}-${BE(n)}.${t}`}function RE(e,t,n=new Date){const s=[`# ${(e.title||l("conversation.titleFallback")).trim()||l("conversation.titleFallback")}`,"",`${l("conversation.exportMarkdownSessionIdLabel")}:\`${e.sessionId}\``,`${l("conversation.exportMarkdownProviderLabel")}:${e.provider}`,`${l("conversation.exportMarkdownWorkspaceLabel")}:\`${e.workspaceId}\``,`${l("conversation.exportMarkdownCreatedAtLabel")}:${si(e.createdAt)}`,`${l("conversation.exportMarkdownExportedAtLabel")}:${si(n.toISOString())}`,""];return t.forEach((o,a)=>{var c,u,d;s.push(`## ${a+1}. ${ob(o)}`),s.push(""),s.push(`- ${l("conversation.exportMarkdownTimeLabel")}:${si(o.timestamp)}`),s.push(`- ${l("conversation.exportMarkdownTypeLabel")}:${DE(o)}`),(((c=o.attachments)==null?void 0:c.length)??0)>0&&s.push(`- ${l("conversation.exportMarkdownAttachmentsLabel")}:${o.attachments.length}`),s.push(""),o.content.trim()&&(s.push(o.content),s.push("")),o.toolCall&&(s.push(`### ${l("conversation.exportMarkdownToolSectionTitle")}`),s.push(""),s.push(`- ${l("conversation.exportMarkdownToolNameLabel")}:${o.toolCall.name}`),s.push(`- ${l("conversation.exportMarkdownToolStatusLabel")}:${o.toolCall.status}`),s.push(""),o.toolCall.input.trim()&&(s.push(`#### ${l("conversation.exportMarkdownToolInputLabel")}`),s.push(""),s.push("```text"),s.push(o.toolCall.input),s.push("```"),s.push("")),(o.toolCall.output??"").trim()&&(s.push(`#### ${l("conversation.exportMarkdownToolOutputLabel")}`),s.push(""),s.push("```text"),s.push(o.toolCall.output??""),s.push("```"),s.push("")),(o.toolCall.error??"").trim()&&(s.push(`#### ${l("conversation.exportMarkdownToolErrorLabel")}`),s.push(""),s.push("```text"),s.push(o.toolCall.error??""),s.push("```"),s.push(""))),(((u=o.attachments)==null?void 0:u.length)??0)>0&&(s.push(`### ${l("conversation.exportMarkdownAttachmentsSectionTitle")}`),s.push(""),(d=o.attachments)==null||d.forEach(p=>{s.push(`- ${p.fileName} (${p.kind}, ${p.mimeType}, ${ab(p.fileSize)})`)}),s.push(""))}),`${s.join(`
|
|
56
|
+
`).trimEnd()}
|
|
57
|
+
`}function tp(e,t,n="text/plain;charset=utf-8"){if(typeof document>"u")throw new Error(l("conversation.exportDownloadFailed"));const r=new Blob([t],{type:n}),s=URL.createObjectURL(r),o=document.createElement("a");o.href=s,o.download=e,document.body.append(o),o.click(),o.remove(),URL.revokeObjectURL(s)}function AE(e,t,n="application/octet-stream"){if(typeof document>"u")throw new Error(l("conversation.exportDownloadFailed"));const r=new Uint8Array(t.byteLength);r.set(t);const s=new Blob([r],{type:n}),o=URL.createObjectURL(s),a=document.createElement("a");a.href=o,a.download=e,document.body.append(a),a.click(),a.remove(),URL.revokeObjectURL(o)}function PE(e,t,n=new Date){const r=(e.title||l("conversation.titleFallback")).trim()||l("conversation.titleFallback"),s=[`${l("conversation.exportMarkdownSessionIdLabel")}:${e.sessionId}`,`${l("conversation.exportMarkdownProviderLabel")}:${e.provider}`,`${l("conversation.exportMarkdownWorkspaceLabel")}:${e.workspaceId}`,`${l("conversation.exportMarkdownCreatedAtLabel")}:${si(e.createdAt)}`,`${l("conversation.exportMarkdownExportedAtLabel")}:${si(n.toISOString())}`],o=new zE;return o.renderDocumentHeader(r,s),t.forEach((a,c)=>{o.renderMessageCard(c,a)}),QE(o.finish())}function LE(e){const t=np(e.htmlAttributes,e.htmlStyle),n=np(e.bodyAttributes,e.bodyStyle);return["<!DOCTYPE html>",`<html${t}>`,"<head>",'<meta charset="utf-8" />','<meta name="viewport" content="width=device-width, initial-scale=1" />',`<title>${lb(e.title)}</title>`,`<style>${e.styleText}</style>`,"</head>",`<body${n}>`,e.bodyHtml,"</body>","</html>"].join("")}function ob(e){return`${_E(e)} · ${si(e.timestamp)}`}function _E(e){switch(e.role){case"user":return l("conversation.roleUser");case"assistant":return l("conversation.roleAssistant");case"tool":return l("conversation.roleTool");case"system":default:return l("conversation.roleSystem")}}function DE(e){return e.kind==="thinking"?l("conversation.thinkingLabel"):e.kind==="tool_call"?l("conversation.exportMarkdownToolCallType"):e.kind==="tool_result"?l("conversation.exportMarkdownToolResultType"):l("conversation.exportMarkdownTextType")}function si(e){const t=Date.parse(e);return Number.isNaN(t)?e:new Date(t).toLocaleString()}function BE(e){const t=String(e.getFullYear()),n=String(e.getMonth()+1).padStart(2,"0"),r=String(e.getDate()).padStart(2,"0"),s=String(e.getHours()).padStart(2,"0"),o=String(e.getMinutes()).padStart(2,"0"),a=String(e.getSeconds()).padStart(2,"0");return`${t}${n}${r}-${s}${o}${a}`}function ab(e){return!Number.isFinite(e)||e<0?l("conversation.exportMarkdownUnknownSize"):e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function OE(e){return e.trim().replace(/[\\/:*?"<>|]+/g,"-").replace(/\s+/g,"-")||"session"}function np(e,t){const n=Object.entries(e??{}).filter(([,r])=>r.trim().length>0);return t!=null&&t.trim()&&n.push(["style",t.trim()]),n.length===0?"":` ${n.map(([r,s])=>`${r}="${WE(s)}"`).join(" ")}`}function lb(e){return e.replaceAll("&","&").replaceAll("<","<").replaceAll(">",">")}function WE(e){return lb(e).replaceAll('"',""")}const cb=595.28,zi=841.89,rp=40,sp=40,Vs=36,ub=cb-Vs*2,FE=14,Hc=12,Jo=12,$E=72,Qo=11,Zs=9,Di=12,ip=20;class zE{constructor(){Xe(this,"pages",[[]]);Xe(this,"cursorTop",rp)}renderDocumentHeader(t,n){this.drawRichText(t,Vs,this.cursorTop,ip,[15,23,42],"sans"),this.cursorTop+=ip+8,n.forEach(r=>{this.drawRichText(r,Vs,this.cursorTop,Zs,[71,85,105],"sans"),this.cursorTop+=Rr(Zs)}),this.cursorTop+=18}renderMessageCard(t,n){const r=HE(t,n);let s=0,o=0;for(;s<r.lines.length||o===0;){this.ensureVerticalSpace($E);const a=this.pickSegmentLines(r.lines,s);a.count===0&&r.lines.length>0&&(a.lines.push(r.lines[s]),a.count=1,a.height=Rr(r.lines[s].fontSize));const c=o===0?r.header:`${r.header} · 续`,u=Jo*2+Rr(Di)+8+Math.max(a.height,0);if(this.ensureVerticalSpace(u),this.drawCardSegment(r,c,a.lines,a.height),this.cursorTop+=u+FE,s+=a.count,o+=1,r.lines.length===0)break}}finish(){return this.pages.map(t=>t.join(`
|
|
58
|
+
`))}drawCardSegment(t,n,r,s){const o=Jo*2+Rr(Di)+8+Math.max(s,0),a=this.cursorTop,c=zi-a-o;this.pushCommand(`${Zo(t.backgroundColor)} rg ${Zo(t.borderColor)} RG 1 w ${mn(Vs)} ${mn(c)} ${mn(ub)} ${mn(o)} re B`);let u=a+Jo;this.drawRichText(n,Vs+Hc,u,Di,t.headerColor,"sans"),u+=Rr(Di)+8,r.forEach(d=>{u+=d.gapBefore,this.drawRichText(d.text,Vs+Hc,u,d.fontSize,d.color,d.fontKind),u+=Rr(d.fontSize)})}pickSegmentLines(t,n){const r={lines:[],count:0,height:0},s=zi-this.cursorTop-sp-Jo*2-Rr(Di)-8;if(s<=0)return r;let o=0;for(let a=n;a<t.length;a+=1){const c=t[a],u=o+c.gapBefore+Rr(c.fontSize);if(r.count>0&&u>s)break;r.lines.push(c),r.count+=1,o=u}return r.height=o,r}ensureVerticalSpace(t){this.cursorTop+t<=zi-sp||(this.pages.push([]),this.cursorTop=rp)}drawRichText(t,n,r,s,o,a){const c=zi-r-s;let u=n;VE(t).forEach(p=>{if(p.text){if(p.fontRef==="F1"){u=this.drawPdfUnicodeRun(p.text,u,c,s,o);return}this.pushCommand(`BT /${p.fontRef} ${mn(s)} Tf ${Zo(o)} rg 1 0 0 1 ${mn(u)} ${mn(c)} Tm (${JE(p.text)}) Tj ET`),u+=YE(p.text,s,p.fontRef)}})}drawPdfUnicodeRun(t,n,r,s,o){let a=n;for(const c of Array.from(t))this.pushCommand(`BT /F1 ${mn(s)} Tf ${Zo(o)} rg 1 0 0 1 ${mn(a)} ${mn(r)} Tm <${GE(c)}> Tj ET`),a+=Gu(c,s,"F1");return a}pushCommand(t){var n;(n=this.pages[this.pages.length-1])==null||n.push(t)}}function HE(e,t){var a,c;const n=UE(t.role),r=ub-Hc*2,s=[],o=`${e+1}. ${ob(t)}`;if(t.content.trim()&&Mr(s,t.content,r,Qo,[15,23,42],0,"sans"),t.toolCall){const u=`${l("conversation.exportMarkdownToolSectionTitle")} · ${t.toolCall.name} · ${t.toolCall.status}`;Mr(s,u,r,Qo,[30,41,59],10,"sans"),t.toolCall.input.trim()&&Mr(s,`${l("conversation.exportMarkdownToolInputLabel")}:${t.toolCall.input}`,r,Zs,[71,85,105],6,"mono"),(t.toolCall.output??"").trim()&&Mr(s,`${l("conversation.exportMarkdownToolOutputLabel")}:${t.toolCall.output??""}`,r,Zs,[71,85,105],6,"mono"),(t.toolCall.error??"").trim()&&Mr(s,`${l("conversation.exportMarkdownToolErrorLabel")}:${t.toolCall.error??""}`,r,Zs,[185,28,28],6,"mono")}return(((a=t.attachments)==null?void 0:a.length)??0)>0&&(Mr(s,l("conversation.exportMarkdownAttachmentsSectionTitle"),r,Qo,[30,41,59],10,"sans"),(c=t.attachments)==null||c.forEach(u=>{Mr(s,`- ${u.fileName} (${u.kind}, ${u.mimeType}, ${ab(u.fileSize)})`,r,Zs,[71,85,105],4,"sans")})),s.length===0&&Mr(s,l("conversation.exportMarkdownTextType"),r,Qo,[100,116,139],0,"sans"),{header:o,headerColor:n.headerColor,backgroundColor:n.backgroundColor,borderColor:n.borderColor,lines:s}}function UE(e){switch(e){case"user":return{headerColor:[30,64,175],backgroundColor:[239,246,255],borderColor:[191,219,254]};case"tool":return{headerColor:[6,95,70],backgroundColor:[236,253,245],borderColor:[167,243,208]};case"system":return{headerColor:[71,85,105],backgroundColor:[248,250,252],borderColor:[226,232,240]};case"assistant":default:return{headerColor:[15,23,42],backgroundColor:[255,255,255],borderColor:[226,232,240]}}}function Mr(e,t,n,r,s,o=0,a="sans"){t.replace(/\r\n/g,`
|
|
59
|
+
`).split(`
|
|
60
|
+
`).forEach((d,p)=>{const h=qE(d,n,r);if(h.length===0){e.push({text:" ",fontSize:r,color:s,gapBefore:p===0?o:4,fontKind:a});return}h.forEach((m,g)=>{e.push({text:m,fontSize:r,color:s,gapBefore:p===0&&g===0?o:g===0?4:0,fontKind:a})})})}function qE(e,t,n,r){if(!e.trim())return[];const s=[];let o="",a=0;const c=db();for(const u of Array.from(e)){const d=Gu(u,n,c);if(o&&a+d>t){s.push(o.trimEnd()),o=u,a=d;continue}o+=u,a+=d}return o.trim().length>0&&s.push(o.trimEnd()),s}function Gu(e,t,n){if(n==="F1")return t*(XE(e)/1e3);const r=n==="F3"?600:hb[e]??556;return t*(r/1e3)}function Rr(e){return e*1.5}function Zo(e){return e.map(t=>mn(t/255)).join(" ")}function mn(e){return Number.isInteger(e)?String(e):e.toFixed(3).replace(/0+$/u,"").replace(/\.$/u,"")}function GE(e){return[254,255,...Array.from(e).flatMap(r=>{const s=r.codePointAt(0)??32;if(s<=65535)return[s];const o=s-65536,a=55296+(o>>10&1023),c=56320+(o&1023);return[a,c]}).flatMap(r=>[r>>8&255,r&255])].map(r=>r.toString(16).padStart(2,"0").toUpperCase()).join("")}function VE(e,t){if(!e)return[];const n=db();return[{text:e,fontRef:n}]}function db(e,t){return"F1"}function KE(e){const t=e.codePointAt(0)??0;return t>=32&&t<=126}function YE(e,t,n){return Array.from(e).reduce((r,s)=>r+Gu(s,t,n),0)}function XE(e){return KE(e)?hb[e]??556:e===" "?278:1e3}function JE(e){return e.replace(/\\/gu,"\\\\").replace(/\(/gu,"\\(").replace(/\)/gu,"\\)")}const hb={" ":278,"!":278,'"':355,"#":556,$:556,"%":889,"&":667,"'":191,"(":333,")":333,"*":389,"+":584,",":278,"-":333,".":278,"/":278,0:556,1:556,2:556,3:556,4:556,5:556,6:556,7:556,8:556,9:556,":":278,";":278,"<":584,"=":584,">":584,"?":556,"@":1015,A:667,B:667,C:722,D:722,E:667,F:611,G:778,H:722,I:278,J:500,K:667,L:556,M:833,N:722,O:778,P:667,Q:778,R:722,S:667,T:611,U:722,V:667,W:944,X:667,Y:667,Z:611,"[":278,"\\":278,"]":278,"^":469,_:556,"`":333,a:556,b:556,c:500,d:556,e:556,f:278,g:556,h:556,i:222,j:222,k:500,l:222,m:833,n:556,o:556,p:556,q:556,r:333,s:500,t:278,u:556,v:500,w:722,x:500,y:500,z:500,"{":334,"|":260,"}":334,"~":584};function QE(e){const t=[],n=[];t[1]="<< /Type /Catalog /Pages 2 0 R >>",t[3]="<< /Type /Font /Subtype /Type0 /BaseFont /STSong-Light /Encoding /UniGB-UCS2-H /DescendantFonts [4 0 R] >>",t[4]="<< /Type /Font /Subtype /CIDFontType0 /BaseFont /STSong-Light /CIDSystemInfo << /Registry (Adobe) /Ordering (GB1) /Supplement 4 >> /DW 1000 >>",t[5]="<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica >>",t[6]="<< /Type /Font /Subtype /Type1 /BaseFont /Courier >>";let c=7;e.forEach(y=>{const S=c,C=c+1;n.push(S),c+=2;const x=new TextEncoder().encode(y);t[C]=`<< /Length ${x.length} >>
|
|
61
|
+
stream
|
|
62
|
+
${y}
|
|
63
|
+
endstream`,t[S]=["<< /Type /Page","/Parent 2 0 R",`/MediaBox [0 0 ${mn(cb)} ${mn(zi)}]`,"/Resources << /Font << /F1 3 0 R /F2 5 0 R /F3 6 0 R >> >>",`/Contents ${C} 0 R`,">>"].join(" ")}),t[2]=`<< /Type /Pages /Kids [${n.map(y=>`${y} 0 R`).join(" ")}] /Count ${n.length} >>`;const u=t.filter(Boolean).length,d=[`%PDF-1.4
|
|
64
|
+
%----
|
|
65
|
+
`],p=[0];let h=new TextEncoder().encode(d[0]).length;for(let y=1;y<t.length;y+=1){const S=t[y];if(!S)continue;p[y]=h;const C=`${y} 0 obj
|
|
66
|
+
${S}
|
|
67
|
+
endobj
|
|
68
|
+
`;d.push(C),h+=new TextEncoder().encode(C).length}const m=h,g=["xref",`0 ${u+1}`,"0000000000 65535 f "];for(let y=1;y<p.length;y+=1){const S=p[y];typeof S=="number"&&g.push(`${String(S).padStart(10,"0")} 00000 n `)}return d.push(`${g.join(`
|
|
69
|
+
`)}
|
|
70
|
+
`),d.push(["trailer",`<< /Size ${u+1} /Root 1 0 R >>`,"startxref",String(m),"%%EOF"].join(`
|
|
71
|
+
`)),new TextEncoder().encode(d.join(""))}const op=48;function ZE(e){return typeof e=="string"?e.replace(/\s+/g," ").trim():""}function Vu(e,t){const n=ZE(e)||t,r=n.length>op?n.slice(0,op).trimEnd():n;return{fullTitle:n,displayTitle:r}}function ea(e,t){return(t??"").localeCompare(e??"")}function ap(e,t){return e.localeCompare(t,void 0,{numeric:!0,sensitivity:"base"})}function ta(e){return(e==null?void 0:e.trim())??""}function ao(e,t,n){if(n==="updatedAt"){const a=ea(e.updatedAt,t.updatedAt);if(a!==0)return a}if(n==="title"){const a=ap(ta(e.title),ta(t.title));if(a!==0)return a}else{const a=ea(e.createdAt,t.createdAt);if(a!==0)return a}const r=ea(e.updatedAt,t.updatedAt);if(r!==0)return r;const s=ea(e.createdAt,t.createdAt);if(s!==0)return s;const o=ap(ta(e.title),ta(t.title));return o!==0?o:e.sessionId.localeCompare(t.sessionId)}function go(e,t){return[...e].sort((n,r)=>ao(n,r,t))}function Ku(e,t){return Array.isArray(e)?e.map(n=>({...n,sessions:go(n.sessions,t),children:Ku(n.children,t)})):[]}const rc=5,sc=["#2563eb","#0891b2","#16a34a","#d97706","#dc2626","#64748b"];function eM(e){const t=Math.round(e.ratio*1e3)/10;return`${t.toFixed(t%1===0?0:1)}%`}function tM(e,t){const n=e.reduce((c,u)=>c+u.count,0);if(n<=0)return[];const s=e.slice(0,rc).map((c,u)=>({...c,key:c.type,ratio:c.count/n,color:sc[u]??sc[0]})),o=e.slice(rc);if(o.length===0)return s;const a=o.reduce((c,u)=>c+u.count,0);return s.push({key:"other",type:t,count:a,ratio:a/n,color:sc[rc]}),s}function nM(e){if(e.length===0)return"conic-gradient(color-mix(in srgb, var(--border-primary) 78%, transparent) 0% 100%)";let t=0;return`conic-gradient(${e.map((r,s)=>{const o=t,a=s===e.length-1?1:Math.min(1,t+r.ratio);return t=a,`${r.color} ${lp(o)} ${lp(a)}`}).join(", ")})`}function rM(e){return{"--workbench-manage-chart-background":nM(e)}}function lp(e){const t=Math.round(e*1e3)/10;return`${t.toFixed(t%1===0?0:1)}%`}const sM=8,iM=12,oM=160,cp=96;function aM(e,t,n,r={}){const s=r.gapPx??sM,o=r.viewportMarginPx??iM,a=r.defaultWidthPx??oM,c=r.estimatedHeightPx??cp,u=r.minHeightPx??cp,d=Math.max(0,n.width),p=Math.max(0,n.height),h=Math.max(0,p-o*2),m=Math.max(0,d-o*2),g=na(Math.max(t.width||a,a),0,m),y=Math.max(t.height||c,c),S=Math.max(0,d-e.x-o),C=Math.max(0,e.x-o),x=S<g&&C>S,A=Math.max(0,p-e.y-s-o),j=Math.max(0,e.y-s-o),G=A<y&&j>A,T=na(Math.max(G?j:A,u),0,h),K=Math.min(y,T),U=x?e.x-g:e.x,L=Math.max(o,d-o-g),E=G?e.y-s-K:e.y+s,$=Math.max(o,p-o-K),B=na(U,o,L),re=na(E,o,$),X=x||B<e.x?"right":"left";return{top:re,left:B,width:g,maxHeight:Math.max(0,T),transformOrigin:`${G?"bottom":"top"} ${X}`}}function na(e,t,n){return!Number.isFinite(e)||n<t?t:Math.min(Math.max(e,t),n)}const pb="workbench.navigation.snapshot",fb=1800*1e3,lM="workbench.navigation.snapshot.host.";function mb(e){return`${lM}${e}`}function cM(e=fb,t=Ha(On.getState())){if(t){const n=va(mb(t),e);if(n)return n}return va(pb,e)}function ra(e,t=Ha(On.getState())){qi(pb,e),t&&qi(mb(t),e)}function up(e,t="createdAt"){return!e||!Array.isArray(e.items)?[]:e.items.map(n=>({workspace:n.workspace,sessions:go(n.sessions,t),childWorktrees:uM(n.childWorktrees,t)}))}function uM(e,t){return Ku(e,t)}function $a(e){return{workspaceId:e.id,tone:"root",backgroundColor:e.backgroundColor??null,displayName:e.name,workspaceName:e.name,branchName:null,depth:0,rootWorkspaceId:e.id,rootDisplayName:e.name,parentWorkspaceId:null,parentDisplayName:null}}function dM(e){const t=new Map;for(const n of e)t.set(n.workspace.id,$a(n.workspace)),gb(t,n.childWorktrees??[],n.workspace,n.workspace);return Object.fromEntries(t)}function cr(e){if(e!=null&&e.backgroundColor)return{"--workspace-tone-color":e.backgroundColor}}function gb(e,t,n,r,s=r.name){var o;for(const a of t){const c=((o=a.meta.displayName)==null?void 0:o.trim())||a.workspace.name;e.set(a.workspace.id,{workspaceId:a.workspace.id,tone:"worktree",backgroundColor:a.workspace.backgroundColor??null,displayName:c,workspaceName:a.workspace.name,branchName:a.meta.branchName||null,depth:a.meta.depth,rootWorkspaceId:n.id,rootDisplayName:n.name,parentWorkspaceId:a.meta.parentWorkspaceId||r.id,parentDisplayName:s}),gb(e,a.children,n,a.workspace,c)}}class Uc extends Error{constructor(t,n){super(n),this.code=t,this.name="HostSwitchError"}}class hM{constructor(){Xe(this,"inFlight",null)}async switchHost(t){this.inFlight&&await this.inFlight;const n=this.performSwitch(t).finally(()=>{this.inFlight===n&&(this.inFlight=null)});this.inFlight=n,await n}async performSwitch(t){const n=On.getState();if(Ha(n)===t)return;const r=mk(n,t);if(!r)throw new Uc("HOST_NOT_FOUND",`找不到 HOST:${t}`);if(!(await gk(r.baseUrl)).reachable)throw new Uc("HOST_UNREACHABLE",`目标 HOST 不可达:${r.baseUrl}`);const o=df(r.id);if(o)try{await Ji.loginForHost(r,{username:o.username,password:o.password})}catch{}const a=On.getState(),c=new Date().toISOString();if(hf(r)){On.updateRuntime({discoveredHosts:a.discoveredHosts.map(u=>u.id===t?{...u,lastConnectedAt:c,updatedAt:c}:u),activeDiscoveredHostId:t});return}mc.setActiveDiscoveredHost(null),await On.update({hosts:a.hosts.map(u=>u.id===t?{...u,lastConnectedAt:c,updatedAt:c}:u),activeHostId:t})}}const pM=new hM,fM=1700;function mM({open:e,id:t,role:n="dialog",labelledBy:r,className:s,anchorRef:o,popoverRef:a,children:c,maxWidth:u=360,gap:d=10,viewportPadding:p=16}){const[h,m]=f.useState(null);if(f.useEffect(()=>{if(!e||typeof window>"u"||typeof document>"u"){m(null);return}let y=0;const S=()=>{const x=o.current;if(!x)return;const A=x.getBoundingClientRect(),j=Math.max(180,Math.min(u,window.innerWidth-p*2)),G=Math.min(Math.max(p,A.right-j),Math.max(p,window.innerWidth-p-j)),P=A.top>=Math.min(240,window.innerHeight*.42),T=Math.round(P?A.top-d:A.bottom+d);m({top:T,left:Math.round(G),width:j,placeAbove:P})},C=()=>{window.cancelAnimationFrame(y),y=window.requestAnimationFrame(S)};return S(),window.addEventListener("resize",C),window.addEventListener("scroll",C,!0),()=>{window.cancelAnimationFrame(y),window.removeEventListener("resize",C),window.removeEventListener("scroll",C,!0)}},[o,d,u,e,p]),!e||!h||typeof document>"u")return null;const g={position:"fixed",top:h.top,left:h.left,width:h.width,maxWidth:`calc(100vw - ${p*2}px)`,zIndex:fM,transform:h.placeAbove?"translateY(-100%)":void 0};return ur.createPortal(i.jsx("div",{id:t,ref:a,role:n,"aria-labelledby":r,className:s,"data-placement":h.placeAbove?"top":"bottom",style:g,children:c}),document.body)}const ic={status:"idle",latencyMs:null};function bb({collapsed:e=!1}){const[t,n]=f.useState(!1),[r,s]=f.useState(!1),[o,a]=f.useState(""),[c,u]=f.useState(""),[d,p]=f.useState(""),[h,m]=f.useState(""),[g,y]=f.useState(null),[S,C]=f.useState(null),[x,A]=f.useState(null),[j,G]=f.useState(!1),[P,T]=f.useState(!1),[K,U]=f.useState(ic),[L,E]=f.useState(null),$=f.useRef(null),B=f.useRef(null),re=f.useRef(null),X=f.useRef(null),F=eu(W=>W),q=Qc(W=>W.session),{showToast:D}=Fn(),V=gc(F),te=Ha(F),v=Tk(),je=bk(te),Te=f.useMemo(()=>dp(F.hosts,te),[te,F.hosts]),N=f.useMemo(()=>dp(pf(F),te),[te,F]),de=f.useCallback(()=>{if(typeof window>"u")return;const W=$.current;if(!W)return;const Y=W.getBoundingClientRect(),se=window.innerWidth,Ce=window.innerHeight,ve=16,fe=8,Ke=Math.min(320,Math.max(240,se-ve*2)),st=Math.min(e?Math.max(ve,Y.right+fe):Math.max(ve,Y.left),Math.max(ve,se-Ke-ve)),I=r?440:240,z=e?Y.top:Y.bottom+fe,ie=Math.min(Math.max(ve,z),Math.max(ve,Ce-I-ve));E({position:"fixed",top:ie,left:st,width:Ke,maxWidth:se-ve*2})},[e,r]);f.useEffect(()=>{if(!t){E(null),G(!1),U(ic);return}mc.refresh();function W(se){var Ce,ve,fe;se.target instanceof Node&&!((Ce=$.current)!=null&&Ce.contains(se.target))&&!((ve=B.current)!=null&&ve.contains(se.target))&&!((fe=X.current)!=null&&fe.contains(se.target))&&(n(!1),s(!1),G(!1),A(null))}function Y(se){se.key==="Escape"&&(n(!1),s(!1),G(!1),A(null))}return window.addEventListener("pointerdown",W),window.addEventListener("keydown",Y),window.addEventListener("resize",de),window.addEventListener("scroll",de,!0),de(),()=>{window.removeEventListener("pointerdown",W),window.removeEventListener("keydown",Y),window.removeEventListener("resize",de),window.removeEventListener("scroll",de,!0)}},[t,de]),f.useEffect(()=>{if(!j||!t||(v==null?void 0:v.kind)!=="relay"){U(ic);return}let W=!1;const Y=performance.now();return U({status:"probing",latencyMs:null}),ye.request("/api/client/runtime-config").then(()=>{W||U({status:"ready",latencyMs:performance.now()-Y})}).catch(()=>{W||U({status:"error",latencyMs:null})}),()=>{W=!0}},[v==null?void 0:v.kind,j,t]);async function Ie(W){if(g||S||W.id===te){n(!1);return}y(W.id);try{await pM.switchHost(W.id),n(!1),s(!1),G(!1),A(null)}catch(Y){D({title:xM(Y,W.name),tone:"error"})}finally{y(null)}}async function he(W){if(!(W.id===te||g||S)){if(x!==W.id){A(W.id);return}C(W.id);try{await On.update({hosts:F.hosts.filter(Y=>Y.id!==W.id)}),kk(W.id),Ji.clearHostSession(W.id),A(null),D({title:l("shell.hostDeleteSuccess",{name:W.name})})}catch{D({title:l("shell.hostDeleteFailed",{name:W.name}),tone:"error"})}finally{C(null)}}}async function le(){if(P)return;const W=o.trim(),Y=d.trim();if((Y.length>0||h.length>0)&&(!Y||!h)){D({title:l("shell.hostAddIncompleteCredentials"),tone:"error"});return}let Ce;try{Ce=yk(c)}catch{D({title:l("shell.hostAddInvalidUrl"),tone:"error"});return}T(!0);try{const ve=await ey(Ce),fe=On.getState(),ht=gc(fe);if(ve?fe.hosts.find(ie=>{var ue;return ie.baseUrl===Ce||!!ve.bindingId&&((ue=ie.relayTunnel)==null?void 0:ue.bindingId)===ve.bindingId}):fe.hosts.find(ie=>ie.baseUrl===Ce)){D({title:l("shell.hostAddDuplicate"),tone:"error"});return}const st=hf(ht)&&ht.baseUrl===Ce;st&&mc.setActiveDiscoveredHost(null);let I,z;if(ve){const ue=(await On.update(ty(fe,ve,{activate:st,displayName:W}))).hosts.find(we=>kM(we,Ce,ve.bindingId??null));if(!ue)throw new Error("relay entry host missing after save");I=ue.id,z=ue.name}else{const ie=new Date().toISOString(),ue={id:yM(),name:W||gM(Ce),baseUrl:Ce,kind:bM(Ce),createdAt:ie,updatedAt:ie,lastConnectedAt:null,lastUserId:null,lastUsername:null};await On.update({hosts:[...fe.hosts,ue],activeHostId:st?ue.id:fe.activeHostId}),I=ue.id,z=ue.name}Y&&h&&xk({hostId:I,username:Y,password:h}),Fe(),s(!1),A(null),D({title:l("shell.hostAddSuccess",{name:z})})}catch{D({title:l("shell.hostAddFailed"),tone:"error"})}finally{T(!1)}}function Fe(){a(""),u(""),p(""),m("")}if(!V)return null;const Ue=q!=null&&q.user.username?`${V.baseUrl} · ${q.user.username}`:V.baseUrl,_e=(v==null?void 0:v.kind)==="relay"?l("shell.hostSwitcherDetailStatusRelay"):l("shell.hostSwitcherDetailStatusDirect"),qe=v?l(Ik(v.kind)):l("common.unknown");return i.jsxs("div",{ref:$,className:"workbench-host-switcher-anchor","data-collapsed":e,children:[i.jsx("button",{type:"button",className:e?"workbench-nav-toolbar-button workbench-collapsed-button":"workbench-nav-toolbar-button","aria-label":l("shell.hostSwitcherAriaLabel"),title:Ue,"aria-expanded":t,onClick:()=>{n(W=>!W),s(!1)},children:i.jsx(SM,{})}),t&&L&&typeof document<"u"?ur.createPortal(i.jsxs("div",{ref:B,className:"workbench-host-switcher-menu",style:L,role:"menu","aria-label":l("shell.hostSwitcherTitle"),children:[i.jsx("div",{className:"workbench-host-switcher-menu-header",children:i.jsx("strong",{children:l("shell.hostSwitcherTitle")})}),i.jsxs("div",{className:"workbench-host-switcher-list",children:[i.jsx("div",{className:"workbench-host-switcher-section-label",children:l("shell.hostSwitcherSavedSection")}),Te.map(W=>{const Y=W.id===te,se=Y?(q==null?void 0:q.user.username)??W.lastUsername??W.baseUrl:W.lastUsername??W.baseUrl;return i.jsxs("div",{className:"workbench-host-switcher-item","data-active":Y,children:[i.jsxs("button",{type:"button",className:"workbench-host-switcher-item-main",disabled:g!==null||S!==null,onClick:()=>{Ie(W)},children:[i.jsxs("span",{className:"workbench-host-switcher-item-copy",children:[i.jsxs("span",{className:"workbench-host-switcher-item-title",children:[W.name,Y?i.jsx("span",{className:"workbench-host-switcher-item-badge",children:l("shell.hostSwitcherCurrentBadge")}):null]}),i.jsx("span",{className:"workbench-host-switcher-item-meta",children:se})]}),i.jsx("span",{className:"workbench-host-switcher-item-trailing",children:g===W.id?l("shell.hostSwitcherSwitching"):Y?i.jsx(pp,{}):i.jsx(hp,{})})]}),Y?i.jsx("button",{ref:re,type:"button",className:"workbench-host-switcher-item-action","aria-label":l("shell.hostSwitcherDetailAriaLabel",{name:W.name}),"aria-expanded":j,"aria-haspopup":"dialog","data-tone":"detail",onClick:()=>{G(Ce=>!Ce),A(null)},children:l("shell.hostSwitcherDetailAction")}):i.jsx("button",{type:"button",className:"workbench-host-switcher-item-action","aria-label":l("shell.hostDeleteAriaLabel",{name:W.name}),title:x===W.id?l("shell.hostDeleteConfirmAction"):l("shell.hostDeleteAction"),"data-confirming":x===W.id,disabled:g!==null||S!==null,onClick:()=>{he(W)},children:S===W.id?l("shell.hostDeleteBusy"):x===W.id?l("shell.hostDeleteConfirmAction"):i.jsx(NM,{})})]},W.id)}),N.length>0?i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"workbench-host-switcher-section-label",children:l("shell.hostSwitcherDiscoveredSection")}),N.map(W=>{const Y=W.id===te,se=df(W.id),Ce=Y?(q==null?void 0:q.user.username)??(se==null?void 0:se.username)??W.baseUrl:(se==null?void 0:se.username)??W.baseUrl;return i.jsxs("div",{className:"workbench-host-switcher-item","data-active":Y,"data-discovered":"true",children:[i.jsxs("button",{type:"button",className:"workbench-host-switcher-item-main",disabled:g!==null||S!==null,onClick:()=>{Ie(W)},children:[i.jsxs("span",{className:"workbench-host-switcher-item-copy",children:[i.jsxs("span",{className:"workbench-host-switcher-item-title",children:[W.name,i.jsx("span",{className:"workbench-host-switcher-item-badge","data-tone":"discovered",children:l("shell.hostSwitcherDiscoveredBadge")}),Y?i.jsx("span",{className:"workbench-host-switcher-item-badge",children:l("shell.hostSwitcherCurrentBadge")}):null]}),i.jsx("span",{className:"workbench-host-switcher-item-meta",children:Ce})]}),i.jsx("span",{className:"workbench-host-switcher-item-trailing",children:g===W.id?l("shell.hostSwitcherSwitching"):Y?i.jsx(pp,{}):i.jsx(hp,{})})]}),Y?i.jsx("button",{ref:re,type:"button",className:"workbench-host-switcher-item-action","aria-label":l("shell.hostSwitcherDetailAriaLabel",{name:W.name}),"aria-expanded":j,"aria-haspopup":"dialog","data-tone":"detail",onClick:()=>{G(ve=>!ve),A(null)},children:l("shell.hostSwitcherDetailAction")}):null]},W.id)})]}):null,F.localHostDiscovery.status==="refreshing"?i.jsx("div",{className:"workbench-host-switcher-state-row",children:l("shell.hostDiscoveryRefreshing")}):null,F.localHostDiscovery.status==="failed"?i.jsx("div",{className:"workbench-host-switcher-state-row","data-tone":"error",children:l("shell.hostDiscoveryFailed")}):null]}),r?i.jsxs("div",{className:"workbench-host-switcher-form",children:[i.jsxs("label",{className:"workbench-host-switcher-field",children:[i.jsx("span",{children:l("shell.hostSwitcherNameLabel")}),i.jsx("input",{value:o,disabled:P,onChange:W=>a(W.target.value),placeholder:l("shell.hostSwitcherNamePlaceholder")})]}),i.jsxs("label",{className:"workbench-host-switcher-field",children:[i.jsx("span",{children:l("shell.hostSwitcherUrlLabel")}),i.jsx("input",{value:c,disabled:P,onChange:W=>u(W.target.value),placeholder:l("shell.hostSwitcherUrlPlaceholder")})]}),i.jsxs("label",{className:"workbench-host-switcher-field",children:[i.jsx("span",{children:l("auth.username")}),i.jsx("input",{value:d,disabled:P,onChange:W=>p(W.target.value),autoComplete:"username"})]}),i.jsxs("label",{className:"workbench-host-switcher-field",children:[i.jsx("span",{children:l("auth.password")}),i.jsx("input",{type:"password",value:h,disabled:P,onChange:W=>m(W.target.value),autoComplete:"current-password"})]}),i.jsxs("div",{className:"workbench-host-switcher-form-actions",children:[i.jsx("button",{type:"button",className:"secondary-button",disabled:P,onClick:()=>{s(!1),Fe()},children:l("common.cancel")}),i.jsx("button",{type:"button",className:"primary-button",disabled:P,onClick:()=>{le()},children:P?l("common.loading"):l("shell.hostSwitcherSaveAction")})]})]}):i.jsxs("button",{type:"button",className:"workbench-host-switcher-add",onClick:()=>{s(!0),A(null)},children:[i.jsx(CM,{}),l("shell.hostSwitcherAddAction")]}),i.jsxs(mM,{open:j&&v!==null&&re.current!==null,className:"workbench-host-switcher-detail-popover",anchorRef:re,popoverRef:X,labelledBy:"workbench-host-switcher-detail-title",children:[i.jsx("div",{className:"workbench-host-switcher-detail-header",children:i.jsx("strong",{id:"workbench-host-switcher-detail-title",children:l("shell.hostSwitcherDetailTitle")})}),i.jsxs("div",{className:"workbench-host-switcher-detail-grid",children:[i.jsxs("div",{className:"workbench-host-switcher-detail-row",children:[i.jsx("span",{className:"workbench-host-switcher-detail-label",children:l("shell.hostSwitcherDetailStatusLabel")}),i.jsx("span",{className:"workbench-host-switcher-detail-value",children:_e})]}),i.jsxs("div",{className:"workbench-host-switcher-detail-row",children:[i.jsx("span",{className:"workbench-host-switcher-detail-label",children:l("shell.hostSwitcherDetailRouteLabel")}),i.jsx("span",{className:"workbench-host-switcher-detail-value",children:qe})]}),i.jsxs("div",{className:"workbench-host-switcher-detail-row",children:[i.jsx("span",{className:"workbench-host-switcher-detail-label",children:l("shell.hostSwitcherDetailAddressLabel")}),i.jsx("span",{className:"workbench-host-switcher-detail-value","data-multiline":"true",children:(v==null?void 0:v.url)??V.baseUrl})]}),(v==null?void 0:v.kind)==="relay"?i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"workbench-host-switcher-detail-row",children:[i.jsx("span",{className:"workbench-host-switcher-detail-label",children:l("shell.hostSwitcherDetailLatencyLabel")}),i.jsx("span",{className:"workbench-host-switcher-detail-value",children:wM(K)})]}),i.jsxs("div",{className:"workbench-host-switcher-detail-row",children:[i.jsx("span",{className:"workbench-host-switcher-detail-label",children:l("shell.hostSwitcherDetailTrafficLabel")}),i.jsx("span",{className:"workbench-host-switcher-detail-value",children:vM(je.totalBytes)})]})]}):null]})]})]}),document.body):null]})}function dp(e,t){return[...e].sort((n,r)=>{if(n.id===t)return-1;if(r.id===t)return 1;const s=n.lastConnectedAt??n.updatedAt??n.createdAt;return(r.lastConnectedAt??r.updatedAt??r.createdAt).localeCompare(s)})}function gM(e){try{const t=new URL(e),n=t.pathname==="/"?"":t.pathname.replace(/\/+$/,"");return`${t.host}${n}`}catch{return e}}function bM(e){try{const t=new URL(e).hostname.toLowerCase();return t==="localhost"||t==="127.0.0.1"||t==="::1"||t==="[::1]"?"local":/^10\./.test(t)||/^192\.168\./.test(t)||/^172\.(1[6-9]|2\d|3[0-1])\./.test(t)?"lan":"remote"}catch{return"custom"}}function kM(e,t,n){var r;return!!(e.baseUrl===t||n&&((r=e.relayTunnel)==null?void 0:r.bindingId)===n)}function yM(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?`host-${crypto.randomUUID()}`:`host-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`}function xM(e,t){return e instanceof Uc?e.code==="HOST_UNREACHABLE"?l("shell.hostSwitchUnreachable",{name:t}):l("shell.hostSwitchMissing"):l("shell.hostSwitchFailed")}function wM(e){return e.status==="probing"?l("shell.hostSwitcherDetailLatencyLoading"):e.status==="error"?l("shell.hostSwitcherDetailUnavailable"):e.status==="ready"?`${Math.max(1,Math.round(e.latencyMs))} ms`:l("shell.hostSwitcherDetailUnavailable")}function vM(e){return!Number.isFinite(e)||e<1024?`${Math.max(0,Math.round(e))} B`:e<1024**2?`${(e/1024).toFixed(1)} KB`:e<1024**3?`${(e/1024**2).toFixed(1)} MB`:`${(e/1024**3).toFixed(2)} GB`}function SM(){return i.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:[i.jsx("rect",{x:"4",y:"4.5",width:"16",height:"6.5",rx:"2.2",stroke:"currentColor",strokeWidth:"1.8"}),i.jsx("rect",{x:"4",y:"13",width:"16",height:"6.5",rx:"2.2",stroke:"currentColor",strokeWidth:"1.8"}),i.jsx("path",{d:"M11 7.75h5.5",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round"}),i.jsx("path",{d:"M11 16.25h5.5",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round"}),i.jsx("circle",{cx:"7.5",cy:"7.75",r:"1",fill:"currentColor",stroke:"none"}),i.jsx("circle",{cx:"7.5",cy:"16.25",r:"1",fill:"currentColor",stroke:"none"})]})}function hp(){return i.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:i.jsx("path",{d:"M6 3.5L10.5 8 6 12.5",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.6"})})}function pp(){return i.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:i.jsx("path",{d:"M3.5 8.5L6.5 11.5L12.5 5.5",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.8"})})}function CM(){return i.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:i.jsx("path",{d:"M8 3.5v9M3.5 8h9",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.6"})})}function NM(){return i.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:i.jsx("path",{d:"M3.5 4.5h9M6.5 2.75h3M5 4.5v7.25a1 1 0 0 0 1 1h4a1 1 0 0 0 1-1V4.5M6.75 6.5v4M9.25 6.5v4",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.35"})})}const sa={repositoryUrl:"",parentPath:"",directoryName:"",name:"",authMode:"none",username:"",password:"",token:""};function jM({open:e,onClose:t,onCloned:n}){const{showToast:r}=Fn(),[s,o]=f.useState(!1),[a,c]=f.useState(sa),[u,d]=f.useState(!1),[p,h]=f.useState(!1),[m,g]=f.useState(null),[y,S]=f.useState(""),[C,x]=f.useState(""),[A,j]=f.useState(null),[G,P]=f.useState([]),[T,K]=f.useState([]),U=s||p;f.useEffect(()=>{!e&&!s&&(c(sa),d(!1),g(null))},[s,e]);const L=f.useCallback(async q=>{h(!0),g(null);try{const D=await gf(q);S(D.currentPath),x(D.currentPath),j(D.parentPath),P(D.roots),K(D.items),c(V=>({...V,parentPath:D.currentPath}))}catch(D){S(""),j(null),K([]),g(D instanceof Error?D.message:l("shell.importBrowserBrowseFailed"))}finally{h(!1)}},[]);function E(){s||(d(!1),g(null),c(sa),t())}function $(){d(!0),L(a.parentPath||void 0)}function B(){s||(d(!1),g(null))}async function re(q){q.preventDefault(),await L(C)}function X(){c(q=>({...q,parentPath:y})),d(!1),g(null)}async function F(q){q.preventDefault();const D=a.repositoryUrl.trim(),V=a.parentPath.trim();if(!D){r({title:l("shell.cloneRepoRequired"),tone:"error"});return}if(!V){r({title:l("shell.clonePathRequired"),tone:"error"});return}o(!0);try{const te=await Ek({repositoryUrl:D,parentPath:V,directoryName:a.directoryName.trim()||void 0,name:a.name.trim()||void 0,auth:a.authMode==="none"?{mode:"none"}:a.authMode==="basic"?{mode:"basic",username:a.username.trim(),password:a.password}:{mode:"token",username:a.username.trim()||void 0,token:a.token}});await(n==null?void 0:n(te)),c(sa),d(!1),r({title:l("shell.cloneSuccess"),description:te.path,tone:"success"}),t()}catch(te){r({title:te instanceof Error?te.message:l("shell.cloneFailed"),tone:"error"})}finally{o(!1)}}return i.jsxs(i.Fragment,{children:[i.jsx(Et,{open:e,title:l("shell.cloneWorkspaceTitle"),description:l("shell.cloneWorkspaceHint"),onClose:E,children:i.jsxs("form",{className:"workbench-clone-form",onSubmit:q=>void F(q),children:[i.jsxs("label",{className:"workbench-modal-field",children:[i.jsx("span",{children:l("shell.cloneRepositoryLabel")}),i.jsx("input",{type:"text",value:a.repositoryUrl,placeholder:l("shell.cloneRepositoryPlaceholder"),onChange:q=>c(D=>({...D,repositoryUrl:q.target.value}))})]}),i.jsxs("label",{className:"workbench-modal-field",children:[i.jsx("span",{children:l("shell.cloneParentPathLabel")}),i.jsxs("div",{className:"workbench-modal-inline-field",children:[i.jsx("input",{type:"text",value:a.parentPath,placeholder:l("shell.cloneParentPathPlaceholder"),onChange:q=>c(D=>({...D,parentPath:q.target.value}))}),i.jsx("button",{type:"button",className:"secondary-button",disabled:s,onClick:$,children:l("shell.clonePickDirectory")})]})]}),i.jsxs("label",{className:"workbench-modal-field",children:[i.jsx("span",{children:l("shell.cloneDirectoryNameLabel")}),i.jsx("input",{type:"text",value:a.directoryName,placeholder:l("shell.cloneDirectoryNamePlaceholder"),onChange:q=>c(D=>({...D,directoryName:q.target.value}))})]}),i.jsxs("label",{className:"workbench-modal-field",children:[i.jsx("span",{children:l("shell.importNameLabel")}),i.jsx("input",{type:"text",value:a.name,placeholder:l("shell.importNamePlaceholder"),onChange:q=>c(D=>({...D,name:q.target.value}))})]}),i.jsxs("label",{className:"workbench-modal-field",children:[i.jsx("span",{children:l("shell.cloneAuthModeLabel")}),i.jsxs("select",{value:a.authMode,onChange:q=>c(D=>({...D,authMode:q.target.value})),children:[i.jsx("option",{value:"none",children:l("shell.cloneAuthModeNone")}),i.jsx("option",{value:"basic",children:l("shell.cloneAuthModeBasic")}),i.jsx("option",{value:"token",children:l("shell.cloneAuthModeToken")})]})]}),a.authMode==="basic"?i.jsxs(i.Fragment,{children:[i.jsxs("label",{className:"workbench-modal-field",children:[i.jsx("span",{children:l("shell.cloneUsernameLabel")}),i.jsx("input",{type:"text",value:a.username,placeholder:l("shell.cloneUsernamePlaceholder"),autoComplete:"username",onChange:q=>c(D=>({...D,username:q.target.value}))})]}),i.jsxs("label",{className:"workbench-modal-field",children:[i.jsx("span",{children:l("shell.clonePasswordLabel")}),i.jsx("input",{type:"password",value:a.password,placeholder:l("shell.clonePasswordPlaceholder"),autoComplete:"current-password",onChange:q=>c(D=>({...D,password:q.target.value}))})]})]}):null,a.authMode==="token"?i.jsxs(i.Fragment,{children:[i.jsxs("label",{className:"workbench-modal-field",children:[i.jsx("span",{children:l("shell.cloneUsernameLabel")}),i.jsx("input",{type:"text",value:a.username,placeholder:l("shell.cloneTokenUsernamePlaceholder"),onChange:q=>c(D=>({...D,username:q.target.value}))})]}),i.jsxs("label",{className:"workbench-modal-field",children:[i.jsx("span",{children:l("shell.cloneTokenLabel")}),i.jsx("input",{type:"password",value:a.token,placeholder:l("shell.cloneTokenPlaceholder"),onChange:q=>c(D=>({...D,token:q.target.value}))})]})]}):null,i.jsx("p",{className:"workbench-import-hint",children:l("shell.cloneHint")}),i.jsxs("div",{className:"workbench-modal-actions",children:[i.jsx("button",{type:"button",className:"secondary-button",disabled:s,onClick:E,children:l("common.cancel")}),i.jsx("button",{type:"submit",className:"primary-button",disabled:s,children:s?l("shell.cloneSubmitting"):l("shell.cloneSubmit")})]})]})}),i.jsxs(Et,{open:e&&u,title:l("shell.cloneBrowserTitle"),description:l("shell.cloneBrowserDescription"),onClose:B,children:[i.jsxs("form",{className:"workbench-directory-browser-form",onSubmit:re,children:[i.jsxs("label",{className:"workbench-modal-field",children:[i.jsx("span",{children:l("shell.importBrowserCurrentPath")}),i.jsx("input",{type:"text",value:C,placeholder:l("shell.importPathPlaceholder"),onChange:q=>x(q.target.value)})]}),i.jsxs("div",{className:"workbench-directory-browser-toolbar",children:[i.jsx("button",{type:"button",className:"secondary-button",disabled:U||!A,onClick:()=>{A&&L(A)},children:l("shell.importBrowserOpenParent")}),i.jsx("button",{type:"submit",className:"secondary-button",disabled:U,children:l("shell.importBrowserOpenPath")})]})]}),i.jsxs("section",{className:"workbench-directory-browser-panel",children:[i.jsxs("div",{className:"workbench-directory-browser-section",children:[i.jsx("span",{className:"workbench-directory-browser-section-title",children:l("shell.importBrowserRoots")}),i.jsx("div",{className:"workbench-directory-browser-root-list",children:G.map(q=>i.jsx("button",{type:"button",className:"workbench-directory-browser-chip",disabled:U,onClick:()=>{L(q.path)},children:q.name},q.path))})]}),i.jsx("div",{className:"workbench-directory-browser-current-path",children:y}),m?i.jsx("p",{className:"workbench-directory-browser-status status-text","data-tone":"error",children:m}):null,p?i.jsx("p",{className:"workbench-directory-browser-status status-text",children:l("common.loading")}):T.length>0?i.jsx("div",{className:"workbench-directory-browser-list",children:T.map(q=>i.jsxs("button",{type:"button",className:"workbench-directory-browser-item",disabled:U,onClick:()=>{L(q.path)},children:[i.jsx("span",{className:"workbench-directory-browser-item-name",children:q.name}),i.jsx("span",{className:"workbench-directory-browser-item-path",children:q.path})]},q.path))}):i.jsx("p",{className:"workbench-directory-browser-status status-text",children:l("shell.importBrowserEmpty")})]}),i.jsxs("div",{className:"workbench-modal-actions",children:[i.jsx("button",{type:"button",className:"secondary-button",disabled:s,onClick:B,children:l("common.cancel")}),i.jsx("button",{type:"button",className:"primary-button",disabled:U||!y,onClick:X,children:l("shell.cloneBrowserSubmit")})]})]})]})}const TM="butler:inbox-updated";function oc(){typeof window>"u"||window.dispatchEvent(new Event(TM))}const fp={projectId:"",itemType:"task",title:"",content:"",status:"pending"};function kb({active:e,preferredWorkspaceId:t,preferredSessionId:n,creationRequestId:r=0,initialDraft:s=null,compactComposer:o=!1,composerOpen:a=!0,onComposerOpenChange:c}){const{showToast:u}=Fn(),[d,p]=f.useState(!1),[h,m]=f.useState(!1),[g,y]=f.useState([]),[S,C]=f.useState([]),[x,A]=f.useState(null),[j,G]=f.useState(null),[P,T]=f.useState(fp),[K,U]=f.useState(!1),L=f.useMemo(()=>gp(g,t,j),[j,t,g]),E=f.useMemo(()=>K?S:S.filter(D=>D.status!=="closed"),[S,K]);f.useEffect(()=>{e&&$()},[e,n]),f.useEffect(()=>{!e||x||T(D=>{const V=kp({projects:L,currentProjectId:D.projectId,preferredProjectId:j,preferredWorkspaceId:t});return V===D.projectId?D:{...D,projectId:V}})},[e,x,j,t,L]),f.useEffect(()=>{!e||r<=0||(B(void 0,t,s,j),c==null||c(!0))},[e,r,s,c,j,t]);async function $(){p(!0);try{const[D,V,te]=await Promise.all([lj(),dg(),n?mj(n).catch(()=>null):Promise.resolve(null)]),v=(te==null?void 0:te.target.project.id)??null;G(v),y(D.items),C(V.items),x||B(D.items,t,r>0?s:null,v)}catch(D){u({title:l("shell.butlerInboxLoadFailed"),description:D instanceof Error?D.message:void 0,tone:"error"})}finally{p(!1)}}function B(D=g,V=t,te=s,v=j){var Te,N;const je=gp(D,V,v);A(null),T({...fp,projectId:kp({projects:je,preferredProjectId:v,preferredWorkspaceId:V}),title:((Te=te==null?void 0:te.title)==null?void 0:Te.trim())??"",content:((N=te==null?void 0:te.content)==null?void 0:N.trim())??""})}function re(D){A(D.id),T({projectId:D.projectId,itemType:D.itemType,title:D.title,content:D.content,status:D.status}),o&&(c==null||c(!0))}async function X(D){D.preventDefault(),m(!0);try{x?(await jh(x,{projectId:P.projectId,itemType:P.itemType,title:P.title,content:P.content,status:P.status,priority:"medium"}),u({title:l("shell.butlerInboxUpdated"),tone:"success"})):(await cj({projectId:P.projectId,itemType:P.itemType,title:P.title,content:P.content,status:P.status,priority:"medium"}),u({title:l("shell.butlerInboxCreated"),tone:"success"})),oc(),await $(),B(),o&&(c==null||c(!1))}catch(V){u({title:l("shell.butlerInboxSaveFailed"),description:V instanceof Error?V.message:void 0,tone:"error"})}finally{m(!1)}}async function F(D){m(!0);try{await hj(D),u({title:l("shell.butlerInboxDeleted"),tone:"success"}),oc(),await $(),x===D&&B()}catch(V){u({title:l("shell.butlerInboxDeleteFailed"),description:V instanceof Error?V.message:void 0,tone:"error"})}finally{m(!1)}}async function q(D,V){if(D.status!==V){m(!0);try{await jh(D.id,{status:V}),u({title:l("shell.butlerInboxUpdated"),tone:"success"}),oc(),await $(),x===D.id&&T(te=>({...te,status:V}))}catch(te){u({title:l("shell.butlerInboxSaveFailed"),description:te instanceof Error?te.message:void 0,tone:"error"})}finally{m(!1)}}}return i.jsxs("div",{className:"workspace-inbox-modal",children:[o?null:i.jsx("section",{className:"workspace-inbox-panel",children:i.jsx(mp,{selectableProjects:L,formState:P,saving:h,editingItemId:x,useMobilePicker:!1,onProjectChange:D=>{T(V=>({...V,projectId:D}))},onItemTypeChange:D=>{T(V=>({...V,itemType:D}))},onStatusChange:D=>{T(V=>({...V,status:D}))},onTitleChange:D=>{T(V=>({...V,title:D}))},onContentChange:D=>{T(V=>({...V,content:D}))},onCancel:()=>B(),onSubmit:X})}),i.jsxs("section",{className:"workspace-inbox-panel",children:[i.jsxs("header",{className:"workspace-inbox-panel-header",children:[i.jsxs("div",{children:[i.jsx("h3",{children:l("shell.butlerInboxListTitle")}),i.jsx("p",{children:l("shell.butlerInboxListDescription")})]}),i.jsxs("label",{className:"workspace-inbox-closed-toggle",children:[i.jsx("input",{type:"checkbox",checked:K,onChange:D=>U(D.target.checked)}),i.jsx("span",{children:l("shell.butlerInboxShowClosedAction")})]})]}),d?i.jsx("p",{className:"workspace-inbox-status",children:l("shell.butlerInboxLoading")}):null,!d&&E.length===0?i.jsx("p",{className:"workspace-inbox-status",children:l("shell.butlerInboxEmpty")}):null,!d&&E.length>0?i.jsx("div",{className:"workspace-inbox-list",children:E.map(D=>i.jsxs("article",{className:"workspace-inbox-item",children:[i.jsxs("div",{className:"workspace-inbox-item-header",children:[i.jsxs("div",{children:[i.jsx("strong",{children:D.title}),i.jsx("p",{children:D.projectName})]}),i.jsxs("div",{className:"workspace-inbox-item-badges",children:[i.jsx("span",{className:"workspace-inbox-badge",children:yp(D.status)}),i.jsx("span",{className:"workspace-inbox-badge",children:AM(D.itemType)})]})]}),i.jsx("p",{className:"workspace-inbox-item-content",children:D.content}),i.jsxs("div",{className:"workspace-inbox-item-footer",children:[i.jsx("span",{children:PM(D.updatedAt)}),i.jsxs("div",{className:"workspace-inbox-item-actions",children:[i.jsx("div",{className:"workspace-inbox-status-quick-actions",role:"group","aria-label":l("shell.butlerInboxQuickStatusLabel"),children:["pending","in_progress","closed"].map(V=>{const te=D.status===V;return i.jsx("button",{type:"button",className:"secondary-button","data-active":te,disabled:h,onClick:()=>{q(D,V)},children:yp(V)},`${D.id}:${V}`)})}),i.jsx("button",{type:"button",className:"secondary-button",disabled:h,onClick:()=>re(D),children:l("shell.butlerInboxEditAction")}),i.jsx("button",{type:"button",className:"secondary-button workbench-danger-button",disabled:h,onClick:()=>{F(D.id)},children:l("shell.butlerInboxDeleteAction")})]})]})]},D.id))}):null]}),o?i.jsx(Et,{open:e&&a,title:x?l("shell.butlerInboxEditingTitle"):l("shell.butlerInboxCreateTitle"),description:l("shell.butlerInboxFormDescription"),className:"workspace-inbox-modal-card workspace-inbox-composer-modal-card",onClose:()=>{c==null||c(!1),B()},children:i.jsx("div",{className:"workspace-inbox-composer-modal-body",children:i.jsx(mp,{selectableProjects:L,formState:P,saving:h,editingItemId:x,useMobilePicker:!0,onProjectChange:D=>{T(V=>({...V,projectId:D}))},onItemTypeChange:D=>{T(V=>({...V,itemType:D}))},onStatusChange:D=>{T(V=>({...V,status:D}))},onTitleChange:D=>{T(V=>({...V,title:D}))},onContentChange:D=>{T(V=>({...V,content:D}))},onCancel:()=>{c==null||c(!1),B()},onSubmit:X})})}):null]})}function mp(e){const t=e.selectableProjects.map(s=>({value:s.id,label:s.name})),n=[{value:"task",label:l("shell.butlerInboxTypeTask")},{value:"bug",label:l("shell.butlerInboxTypeBug")},{value:"feature",label:l("shell.butlerInboxTypeFeature")},{value:"change",label:l("shell.butlerInboxTypeChange")}],r=[{value:"pending",label:l("shell.butlerInboxStatusPending")},{value:"in_progress",label:l("shell.butlerInboxStatusInProgress")},{value:"closed",label:l("shell.butlerInboxStatusClosed")}];return i.jsxs(i.Fragment,{children:[i.jsxs("header",{className:"workspace-inbox-panel-header",children:[i.jsx("h3",{children:e.editingItemId?l("shell.butlerInboxEditingTitle"):l("shell.butlerInboxCreateTitle")}),i.jsx("p",{children:l("shell.butlerInboxFormDescription")})]}),e.selectableProjects.length===0?i.jsx("p",{className:"workspace-inbox-status",children:l("shell.butlerInboxProjectsEmpty")}):i.jsxs("form",{className:"workspace-inbox-form",onSubmit:e.onSubmit,children:[i.jsx("div",{className:"workspace-inbox-form-grid",children:e.useMobilePicker?i.jsxs(i.Fragment,{children:[i.jsx(ac,{label:l("shell.butlerInboxProjectLabel"),value:e.formState.projectId,options:t,disabled:e.saving,onChange:e.onProjectChange}),i.jsx(ac,{label:l("shell.butlerInboxTypeLabel"),value:e.formState.itemType,options:n,disabled:e.saving,onChange:e.onItemTypeChange}),i.jsx(ac,{label:l("shell.butlerInboxStatusLabel"),value:e.formState.status,options:r,disabled:e.saving,onChange:e.onStatusChange})]}):i.jsxs(i.Fragment,{children:[i.jsxs("label",{className:"workbench-modal-field",children:[i.jsx("span",{children:l("shell.butlerInboxProjectLabel")}),i.jsx("select",{value:e.formState.projectId,disabled:e.saving,onChange:s=>e.onProjectChange(s.target.value),children:e.selectableProjects.map(s=>i.jsx("option",{value:s.id,children:s.name},s.id))})]}),i.jsxs("label",{className:"workbench-modal-field",children:[i.jsx("span",{children:l("shell.butlerInboxTypeLabel")}),i.jsxs("select",{value:e.formState.itemType,disabled:e.saving,onChange:s=>e.onItemTypeChange(s.target.value),children:[i.jsx("option",{value:"task",children:l("shell.butlerInboxTypeTask")}),i.jsx("option",{value:"bug",children:l("shell.butlerInboxTypeBug")}),i.jsx("option",{value:"feature",children:l("shell.butlerInboxTypeFeature")}),i.jsx("option",{value:"change",children:l("shell.butlerInboxTypeChange")})]})]}),i.jsxs("label",{className:"workbench-modal-field",children:[i.jsx("span",{children:l("shell.butlerInboxStatusLabel")}),i.jsxs("select",{value:e.formState.status,disabled:e.saving,onChange:s=>e.onStatusChange(s.target.value),children:[i.jsx("option",{value:"pending",children:l("shell.butlerInboxStatusPending")}),i.jsx("option",{value:"in_progress",children:l("shell.butlerInboxStatusInProgress")}),i.jsx("option",{value:"closed",children:l("shell.butlerInboxStatusClosed")})]})]})]})}),i.jsxs("label",{className:"workbench-modal-field",children:[i.jsx("span",{children:l("shell.butlerInboxTitleLabel")}),i.jsx("input",{value:e.formState.title,placeholder:l("shell.butlerInboxTitlePlaceholder"),disabled:e.saving,onChange:s=>e.onTitleChange(s.target.value)})]}),i.jsxs("label",{className:"workbench-modal-field",children:[i.jsx("span",{children:l("shell.butlerInboxContentLabel")}),i.jsx("textarea",{rows:4,value:e.formState.content,placeholder:l("shell.butlerInboxContentPlaceholder"),disabled:e.saving,onChange:s=>e.onContentChange(s.target.value)})]}),i.jsxs("div",{className:"workbench-modal-actions",children:[i.jsx("button",{type:"button",className:"secondary-button",disabled:e.saving,onClick:e.onCancel,children:e.editingItemId?l("shell.butlerInboxCancelEditAction"):l("common.cancel")}),i.jsx("button",{type:"submit",className:"primary-button",disabled:e.saving||!e.formState.projectId,children:e.editingItemId?l("shell.butlerInboxUpdateAction"):l("shell.butlerInboxCreateAction")})]})]})]})}function ac({label:e,value:t,options:n,disabled:r,onChange:s}){const[o,a]=f.useState(!1),c=n.find(u=>u.value===t)??n[0]??null;return f.useEffect(()=>{if(!o)return;function u(d){d.key==="Escape"&&a(!1)}return window.addEventListener("keydown",u),()=>{window.removeEventListener("keydown",u)}},[o]),i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"workbench-modal-field workspace-inbox-mobile-picker",children:[i.jsx("span",{children:e}),i.jsxs("button",{type:"button",className:"workspace-inbox-mobile-picker-trigger","aria-label":e,"aria-haspopup":"dialog","aria-expanded":o,disabled:r||n.length===0,onClick:()=>a(!0),children:[i.jsx("span",{className:"workspace-inbox-mobile-picker-trigger-value",children:(c==null?void 0:c.label)??""}),i.jsx("span",{className:"workspace-inbox-mobile-picker-trigger-icon",children:i.jsx(MM,{expanded:o})})]})]}),i.jsx(IM,{open:o,title:e,options:n,selectedValue:t,onClose:()=>a(!1),onSelect:u=>{s(u),a(!1)}})]})}function IM({open:e,title:t,options:n,selectedValue:r,onClose:s,onSelect:o}){return e?i.jsx(Mk,{open:e,title:t,kind:"picker",height:"half",className:"workspace-inbox-picker-sheet",cardClassName:"workspace-inbox-picker-sheet-card",bodyClassName:"workspace-inbox-picker-sheet-body",showHandle:!0,onClose:s,children:i.jsx(ru,{className:"workspace-inbox-picker-sheet-options",role:"listbox","aria-label":t,children:n.map(a=>{const c=a.value===r;return i.jsx(fn,{as:"button",className:"workspace-inbox-picker-option",role:"option","aria-selected":c,selected:c,trailing:i.jsx("span",{className:"workspace-inbox-picker-option-indicator","aria-hidden":"true",children:c?i.jsx(RM,{}):null}),onClick:()=>o(a.value),children:i.jsxs("span",{className:"workspace-inbox-picker-option-copy",children:[i.jsx("strong",{children:a.label}),a.description?i.jsx("span",{children:a.description}):null]})},a.value)})})}):null}function mL({open:e,preferredWorkspaceId:t,preferredSessionId:n,creationRequestId:r=0,initialDraft:s=null,onClose:o,compactComposer:a=!1}){const[c,u]=f.useState(0),[d,p]=f.useState(!a);return f.useEffect(()=>{e||p(!a)},[a,e]),i.jsx(Et,{open:e,title:l("shell.butlerInboxModalTitle"),description:l("shell.butlerInboxModalDescription"),className:"workspace-inbox-modal-card",showCloseButton:!a,headerActions:a?i.jsx("button",{type:"button",className:"workspace-inbox-modal-create-button","aria-label":l("shell.butlerInboxCreateAction"),title:l("shell.butlerInboxCreateAction"),onClick:()=>{u(h=>h+1),p(!0)},children:i.jsx(EM,{})}):void 0,onClose:o,children:i.jsx(kb,{active:e,preferredWorkspaceId:t,preferredSessionId:n,creationRequestId:Math.max(r,c),initialDraft:s,compactComposer:a,composerOpen:d,onComposerOpenChange:p})})}function gp(e,t,n){return[...e].filter(r=>r.lifecycleStatus!=="archived").sort((r,s)=>{const o=bp(r,t,n),a=bp(s,t,n);return o!==a?a-o:r.name.localeCompare(s.name,"zh-Hans-CN")})}function bp(e,t,n){return n&&e.id===n?2:t&&e.workspaceId===t?1:0}function kp({projects:e,currentProjectId:t,preferredProjectId:n,preferredWorkspaceId:r}){var o;if(t&&e.some(a=>a.id===t))return t;if(n&&e.some(a=>a.id===n))return n;const s=r?e.find(a=>a.workspaceId===r):null;return(s==null?void 0:s.id)||((o=e[0])==null?void 0:o.id)||""}function EM(){return i.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8","aria-hidden":"true",children:[i.jsx("path",{d:"M12 5v14"}),i.jsx("path",{d:"M5 12h14"})]})}function MM({expanded:e}){return i.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true","data-expanded":e?"true":void 0,children:i.jsx("path",{d:"M3.5 6 8 10l4.5-4",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.6"})})}function RM(){return i.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:i.jsx("path",{d:"M3.5 8.4 6.6 11.5 12.5 5.5",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.8"})})}function AM(e){switch(e){case"bug":return l("shell.butlerInboxTypeBug");case"feature":return l("shell.butlerInboxTypeFeature");case"change":return l("shell.butlerInboxTypeChange");case"task":default:return l("shell.butlerInboxTypeTask")}}function yp(e){switch(e){case"in_progress":return l("shell.butlerInboxStatusInProgress");case"closed":return l("shell.butlerInboxStatusClosed");case"pending":default:return l("shell.butlerInboxStatusPending")}}function PM(e){return new Date(e).toLocaleString()}function LM({open:e,onClose:t,onImported:n}){const{showToast:r}=Fn(),[s,o]=f.useState(!1),[a,c]=f.useState(!1),[u,d]=f.useState(!1),[p,h]=f.useState(null),[m,g]=f.useState(""),[y,S]=f.useState(""),[C,x]=f.useState(null),[A,j]=f.useState([]),[G,P]=f.useState([]),[T,K]=f.useState(!1),[U,L]=f.useState(""),E=s||a||u,$=f.useCallback(async V=>{o(!0),h(null);try{const te=await gf(V);g(te.currentPath),S(te.currentPath),x(te.parentPath),j(te.roots),P(te.items)}catch(te){g(""),x(null),P([]),h(te instanceof Error?te.message:l("shell.importBrowserBrowseFailed"))}finally{o(!1)}},[]);f.useEffect(()=>{if(!e){K(!1),L(""),h(null);return}$(m||void 0)},[$,e]);function B(){E||(K(!1),L(""),t())}async function re(V){V.preventDefault(),await $(y)}function X(){!m||E||(L(""),K(!0))}function F(){a||(K(!1),L(""))}async function q(V){V==null||V.preventDefault();const te=U.trim();if(!(!m||!te||E)){c(!0),h(null);try{const v=await Ak({parentPath:m,directoryName:te});r({title:l("shell.importBrowserCreateDirectorySuccess"),description:v.path,tone:"success"}),K(!1),L(""),await $(v.path)}catch(v){const je=v instanceof Error?v.message:l("shell.importBrowserCreateDirectoryFailed");h(je),r({title:je,tone:"error"})}finally{c(!1)}}}async function D(){const V=m.trim();if(!(!V||E)){d(!0),h(null);try{const te=await Rk({path:V});r({title:l("shell.importSuccess"),description:te.path,tone:"success"}),t(),Promise.resolve().then(()=>n==null?void 0:n(te)).catch(v=>{r({title:v instanceof Error?v.message:l("shell.navigationLoadFailed"),tone:"error"})})}catch(te){r({title:te instanceof Error?te.message:l("shell.importFailed"),tone:"error"})}finally{d(!1)}}}return i.jsxs(i.Fragment,{children:[i.jsxs(Et,{open:e,title:l("shell.importBrowserTitle"),description:l("shell.importBrowserDescription"),onClose:B,children:[i.jsxs("form",{className:"workbench-directory-browser-form",onSubmit:re,children:[i.jsxs("label",{className:"workbench-modal-field",children:[i.jsx("span",{children:l("shell.importBrowserCurrentPath")}),i.jsx("input",{type:"text",value:y,placeholder:l("shell.importPathPlaceholder"),onChange:V=>S(V.target.value)})]}),i.jsxs("div",{className:"workbench-directory-browser-toolbar",children:[i.jsx("button",{type:"button",className:"secondary-button",disabled:E||!C,onClick:()=>{C&&$(C)},children:l("shell.importBrowserOpenParent")}),i.jsx("button",{type:"submit",className:"secondary-button",disabled:E,children:l("shell.importBrowserOpenPath")}),i.jsx("button",{type:"button",className:"secondary-button",disabled:E||!m,onClick:X,children:l("shell.importBrowserCreateDirectory")})]})]}),i.jsxs("section",{className:"workbench-directory-browser-panel",children:[i.jsxs("div",{className:"workbench-directory-browser-section",children:[i.jsx("span",{className:"workbench-directory-browser-section-title",children:l("shell.importBrowserRoots")}),i.jsx("div",{className:"workbench-directory-browser-root-list",children:A.map(V=>i.jsx("button",{type:"button",className:"workbench-directory-browser-chip",disabled:E,onClick:()=>{$(V.path)},children:V.name},V.path))})]}),i.jsx("div",{className:"workbench-directory-browser-current-path",children:m}),p?i.jsx("p",{className:"workbench-directory-browser-status status-text","data-tone":"error",children:p}):null,s?i.jsx("p",{className:"workbench-directory-browser-status status-text",children:l("common.loading")}):G.length>0?i.jsx("div",{className:"workbench-directory-browser-list",children:G.map(V=>i.jsxs("button",{type:"button",className:"workbench-directory-browser-item",disabled:E,onClick:()=>{$(V.path)},children:[i.jsx("span",{className:"workbench-directory-browser-item-name",children:V.name}),i.jsx("span",{className:"workbench-directory-browser-item-path",children:V.path})]},V.path))}):i.jsx("p",{className:"workbench-directory-browser-status status-text",children:l("shell.importBrowserEmpty")})]}),i.jsxs("div",{className:"workbench-modal-actions",children:[i.jsx("button",{type:"button",className:"secondary-button",disabled:E,onClick:B,children:l("common.cancel")}),i.jsx("button",{type:"button",className:"primary-button",disabled:E||!m,onClick:()=>{D()},children:u?l("shell.importSubmitting"):l("shell.importBrowserSubmit")})]})]}),i.jsx(Et,{open:e&&T,title:l("shell.importBrowserCreateDirectoryTitle"),description:l("shell.importBrowserCreateDirectoryDescription"),onClose:F,children:i.jsxs("form",{className:"workbench-rename-form",onSubmit:V=>void q(V),children:[i.jsx("div",{className:"workbench-directory-browser-current-path",children:m}),i.jsxs("label",{className:"workbench-modal-field",children:[i.jsx("span",{children:l("shell.importBrowserCreateDirectoryLabel")}),i.jsx("input",{type:"text",value:U,placeholder:l("shell.importBrowserCreateDirectoryPlaceholder"),autoFocus:!0,onChange:V=>L(V.target.value)})]}),i.jsxs("div",{className:"workbench-modal-actions",children:[i.jsx("button",{type:"button",className:"secondary-button",disabled:a,onClick:F,children:l("common.cancel")}),i.jsx("button",{type:"submit",className:"primary-button",disabled:a||!U.trim(),children:a?l("shell.importBrowserCreatingDirectory"):l("shell.importBrowserCreateDirectorySubmit")})]})]})})]})}function _M({onOpenSoftwareUpdate:e}){var r;const t=eu(s=>s.platform),n=vk(s=>s.latestState);return t!=="desktop"||!(n!=null&&n.hasUpdate)?null:i.jsx("button",{className:"workbench-nav-update-badge",type:"button",title:((r=n.manifest)==null?void 0:r.version)??l("settings.releaseUpdateReady"),onClick:e,children:i.jsx("span",{className:"workbench-nav-update-badge-label",children:l("settings.releaseUpdateBadge")})})}function DM(){const e=wk.getState().profile.defaultPermissionMode;return e==="default"?null:e}const Hi="provider-default",ka="__global_default__";function BM(e){switch(e){case"claude-code":case"codex":case"gemini":return e;default:return null}}function ia(e,t){const n=(t==null?void 0:t.trim())||null;return e==="cc-switch-preset"&&n?{providerConfigMode:"cc-switch-preset",providerPresetId:n}:{providerConfigMode:"global-default",providerPresetId:null}}function OM(e){const t=e!=null&&e.currentPresetName?e.currentModel?`${e.currentPresetName} · ${e.currentModel}`:e.currentPresetName:null;return[{value:ka,label:l("conversation.deploymentDefaultPreset"),summary:t},...((e==null?void 0:e.options)??[]).map(n=>({value:n.id,label:n.name,summary:n.model??n.summary??null}))]}function WM(e){return e.usesProviderDefault===!0||e.id===Hi}function FM(e){return e?e.cliAvailable===!0&&e.status!=="unavailable"&&e.options.length>1:!0}function $M({triggerId:e,ariaLabel:t,triggerLabel:n,presetOptions:r,selectedPresetValue:s,selectedPresetSummary:o,onSelectPreset:a,modelOptions:c,selectedModelValue:u,onSelectModel:d,loadingPresets:p=!1,loadingModels:h=!1,modelColumnDisabled:m=!1,showPresetColumn:g=!0,modelEmptyText:y}){const[S,C]=f.useState(!1),x=f.useRef(null),A=f.useRef(null),j=f.useRef(null),[G,P]=f.useState(null),T=f.useId(),K=f.useCallback(()=>{const U=A.current;if(!U||typeof window>"u")return;const L=U.getBoundingClientRect(),E=U.closest(".workbench-modal-card"),$=E instanceof HTMLElement?E.getBoundingClientRect():null,B=window.innerWidth,re=window.innerHeight,X=12,F=8,q=320,D=Math.min(560,Math.max(320,B-X*2)),V=Math.min(D,420),te=Math.max(Math.min(D,Math.max(V,Math.round(L.width*1.9))),Math.min(320,D)),v=Math.min(Math.max(X,L.left),Math.max(X,B-te-X)),je=$?Math.max(X,$.top+8):X,Te=$?Math.min(re-X,$.bottom-8):re-X,N=Math.max(0,L.top-je-F),de=Math.max(0,Te-L.bottom-F),Ie=$?!(de>=q||de>N+40):N>=240||N>=de;P({position:"fixed",left:v,width:te,maxWidth:D,zIndex:1905,top:Ie?void 0:L.bottom+F,bottom:Ie?re-L.top+F:void 0})},[]);return f.useEffect(()=>{if(!S)return;function U(E){var B,re;const $=E.target;!((B=x.current)!=null&&B.contains($))&&!((re=j.current)!=null&&re.contains($))&&C(!1)}function L(E){E.key==="Escape"&&C(!1)}return window.addEventListener("pointerdown",U),window.addEventListener("keydown",L),window.addEventListener("resize",K),window.addEventListener("scroll",K,!0),K(),()=>{window.removeEventListener("pointerdown",U),window.removeEventListener("keydown",L),window.removeEventListener("resize",K),window.removeEventListener("scroll",K,!0)}},[S,K]),i.jsxs("div",{ref:x,className:"composer-mac-select composer-deployment-select","data-open":S?"true":"false",children:[i.jsxs("button",{id:e,ref:A,type:"button",className:"composer-mac-select-trigger composer-deployment-select-trigger","aria-label":t,"aria-haspopup":"dialog","aria-expanded":S,"aria-controls":T,onClick:()=>C(U=>!U),children:[i.jsx("span",{className:"composer-mac-select-label composer-deployment-select-label",children:n}),i.jsx("svg",{className:"composer-mac-select-chevron",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:i.jsx("polyline",{points:"6 14 12 8 18 14"})})]}),S&&G&&typeof document<"u"?ur.createPortal(i.jsx("div",{ref:j,className:"composer-mac-select-popover composer-deployment-select-popover",style:G,role:"presentation",children:i.jsxs("div",{id:T,className:`composer-deployment-select-panel${g?"":" is-model-only"}`,role:"dialog","aria-label":t,children:[g?i.jsxs("div",{className:"composer-deployment-select-column",children:[i.jsx("div",{className:"composer-deployment-select-column-header",children:l("conversation.deploymentConfigColumn")}),i.jsxs("div",{className:"composer-deployment-select-list",role:"listbox","aria-label":l("conversation.deploymentConfigColumn"),children:[r.map(U=>{const L=U.value===s;return i.jsxs("button",{type:"button",role:"option","aria-selected":L,className:`composer-deployment-select-option ${L?"is-selected":""}`,onClick:()=>a(U.value),children:[i.jsx("span",{className:"composer-deployment-select-option-check","aria-hidden":"true",children:L?"✓":""}),i.jsxs("span",{className:"composer-deployment-select-option-copy",children:[i.jsx("span",{className:"composer-deployment-select-option-label",children:U.label}),U.summary?i.jsx("span",{className:"composer-deployment-select-option-summary",children:U.summary}):null]})]},U.value)}),p?i.jsx("div",{className:"composer-deployment-select-state",children:l("conversation.deploymentLoading")}):null]})]}):null,i.jsxs("div",{className:"composer-deployment-select-column","data-disabled":m?"true":"false",children:[i.jsx("div",{className:"composer-deployment-select-column-header",children:l("conversation.deploymentModelColumn")}),g&&o?i.jsx("div",{className:"composer-deployment-select-column-hint",children:o}):null,i.jsx("div",{className:"composer-deployment-select-list",role:"listbox","aria-label":l("conversation.deploymentModelColumn"),children:h&&m?i.jsx("div",{className:"composer-deployment-select-state",children:l("conversation.deploymentModelLoading")}):c.length>0?c.map(U=>{const L=U.value===u;return i.jsxs("button",{type:"button",role:"option","aria-selected":L,className:`composer-deployment-select-option ${L?"is-selected":""}`,disabled:m,onClick:()=>{d(U.value),C(!1)},children:[i.jsx("span",{className:"composer-deployment-select-option-check","aria-hidden":"true",children:L?"✓":""}),i.jsx("span",{className:"composer-deployment-select-option-copy",children:i.jsx("span",{className:"composer-deployment-select-option-label",children:U.label})})]},U.value)}):i.jsx("div",{className:"composer-deployment-select-state",children:y})})]})]})}),document.body):null]})}const yb=144,zM=196,HM=124,UM=72;let xp=null;function qM(e,t){if(typeof document>"u")return t.length*8;xp??(xp=document.createElement("canvas"));const n=xp.getContext("2d");if(!n)return t.length*8;const r=window.getComputedStyle(e),s=r.fontStyle||"normal",o=r.fontWeight||"600",a=r.fontSize||"13px",c=r.fontFamily||"system-ui";return n.font=`${s} ${o} ${a} ${c}`,n.measureText(t).width}function GM({labels:e,triggerWidth:t,maxWidth:n,preferredWidth:r,measureText:s}){const o=e.reduce((a,c)=>Math.max(a,Math.ceil(s(c)+UM)),0);return Math.min(n,Math.max(t,yb,r,o))}function wp({triggerId:e,ariaLabel:t,value:n,options:r,onChange:s,disabled:o=!1,compact:a=!1,className:c}){const[u,d]=f.useState(!1),p=f.useRef(null),h=f.useRef(null),m=f.useRef(null),[g,y]=f.useState(null),S=f.useId(),C=r.find(j=>j.value===n)??r[0]??null,x=f.useMemo(()=>r.map(j=>j.label),[r]),A=f.useCallback(()=>{const j=h.current;if(!j||typeof window>"u")return;const G=j.getBoundingClientRect(),P=window.innerWidth,T=window.innerHeight,K=12,U=10,L=Math.max(yb,P-K*2),E=a?HM:zM,$=GM({labels:x,triggerWidth:G.width,maxWidth:L,preferredWidth:E,measureText:q=>qM(j,q)}),B=Math.min(Math.max(K,G.left),Math.max(K,P-$-K)),re=G.top-K,X=T-G.bottom-K,F=re>=180||re>=X;y({position:"fixed",left:B,width:$,maxWidth:L,zIndex:1905,top:F?void 0:G.bottom+U,bottom:F?T-G.top+U:void 0})},[a,x]);return f.useEffect(()=>{if(!u)return;function j(P){var K,U;const T=P.target;!((K=p.current)!=null&&K.contains(T))&&!((U=m.current)!=null&&U.contains(T))&&d(!1)}function G(P){P.key==="Escape"&&d(!1)}return window.addEventListener("pointerdown",j),window.addEventListener("keydown",G),window.addEventListener("resize",A),window.addEventListener("scroll",A,!0),A(),()=>{window.removeEventListener("pointerdown",j),window.removeEventListener("keydown",G),window.removeEventListener("resize",A),window.removeEventListener("scroll",A,!0)}},[u,A]),C?i.jsxs("div",{ref:p,className:`composer-mac-select ${a?"is-compact":""}${c?` ${c}`:""}`,"data-open":u?"true":"false",children:[i.jsxs("button",{id:e,ref:h,type:"button",className:"composer-mac-select-trigger","aria-label":t,"aria-haspopup":"listbox","aria-expanded":u,"aria-controls":S,disabled:o,onClick:()=>d(j=>!j),children:[i.jsx("span",{className:"composer-mac-select-label",children:C.label}),i.jsx("svg",{className:"composer-mac-select-chevron",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:i.jsx("polyline",{points:"6 14 12 8 18 14"})})]}),u&&g&&typeof document<"u"?ur.createPortal(i.jsx("div",{ref:m,className:"composer-mac-select-popover",style:g,role:"presentation",children:i.jsx("div",{id:S,className:"composer-mac-select-list",role:"listbox","aria-label":t,children:r.map(j=>{const G=j.value===n;return i.jsxs("button",{type:"button",role:"option","aria-selected":G,className:`composer-mac-select-option ${G?"is-selected":""}`,onClick:()=>{s(j.value),d(!1)},children:[i.jsx("span",{className:"composer-mac-select-option-check","aria-hidden":"true",children:G?"✓":""}),i.jsx("span",{className:"composer-mac-select-option-label",children:j.label})]},j.value)})})}),document.body):null]}):null}const oa=["codex","claude-code","gemini"];function xb(e){return{provider:e,model:"",providerConfigMode:"global-default",providerPresetId:null,memberPrompt:"",workspaceIsolationMode:"none"}}function vp(e,t){return Array.from({length:t},()=>xb(e))}function lc(e,t){var n;return(n=e==null?void 0:e.modelOptions)!=null&&n.length?e.modelOptions:su(t).modelOptions??[]}function Sp(e,t,n){return t!=="cc-switch-preset"||!n?null:`${e}::${n}`}function Cp(e,t){return Math.max(0,e-t.length)}function VM({open:e,source:t,onClose:n,onCreated:r}){const s=f.useId(),o=(t==null?void 0:t.defaultProvider)??"codex",a=(t==null?void 0:t.kind)==="group",c=(t==null?void 0:t.kind)==="group"?Math.max(0,4-t.currentMemberCount):4,u=f.useMemo(()=>(t==null?void 0:t.kind)==="group"?Array.from({length:c},(I,z)=>z+1):[2,3,4],[c,t==null?void 0:t.kind]),d=(t==null?void 0:t.kind)==="group"?1:2,p=(t==null?void 0:t.kind)==="group"?t.sharedPrompt:"",{visibleProviders:h}=Pk(Bk,e),[m,g]=f.useState(p),[y,S]=f.useState(d),[C,x]=f.useState(()=>vp(o,d)),[A,j]=f.useState({}),[G,P]=f.useState({}),[T,K]=f.useState({}),[U,L]=f.useState({}),[E,$]=f.useState({}),[B,re]=f.useState(!1),[X,F]=f.useState(!1),[q,D]=f.useState(null),[V,te]=f.useState(null),[v,je]=f.useState({}),Te=f.useRef(!1),N=f.useRef({});f.useEffect(()=>{if(!e)return;const I=(t==null?void 0:t.defaultProvider)??"codex",z=(t==null?void 0:t.kind)==="group"?1:2;g((t==null?void 0:t.kind)==="group"?t.sharedPrompt:""),S(z),x(vp(I,z)),j({}),P({}),K({}),L({}),$({}),re(!1),F(!1),D(null),te(null),je({}),Te.current=!1,Object.keys(N.current).forEach(ie=>{delete N.current[ie]})},[e,t==null?void 0:t.defaultProvider,t==null?void 0:t.kind,t==null?void 0:t.workspaceId,(t==null?void 0:t.kind)==="session"?t.sessionId:null,(t==null?void 0:t.kind)==="group"?t.groupId:null,(t==null?void 0:t.kind)==="group"?t.sharedPrompt:null]),f.useEffect(()=>{x(I=>{var ue;if(I.length===y)return I;if(I.length>y)return I.slice(0,y);const z=I.slice(),ie=((ue=I[0])==null?void 0:ue.provider)??o;for(;z.length<y;)z.push(xb(ie));return z})},[o,y]),f.useEffect(()=>{u.length!==0&&S(I=>u.includes(I)?I:u[0]??I)},[u]),f.useEffect(()=>{if(!e||!t)return;let I=!1;return re(!0),Lk(h,t.workspaceId).then(z=>{I||j(z)}).finally(()=>{I||re(!1)}),()=>{I=!0}},[e,t==null?void 0:t.workspaceId,h]),f.useEffect(()=>{e&&(Te.current||(Te.current=!0,K(I=>({...I,...Object.fromEntries(oa.map(z=>[z,!0]))})),_k().then(I=>{const z=Object.fromEntries(I.items.map(ie=>[ie.app,ie]));P(Object.fromEntries(oa.map(ie=>[ie,z[ie]??null])))}).catch(()=>{P(Object.fromEntries(oa.map(I=>[I,null])))}).finally(()=>{K(I=>({...I,...Object.fromEntries(oa.map(z=>[z,!1]))}))})))},[e]),f.useEffect(()=>{if(!e||!t)return;const I=Array.from(new Set(C.map(z=>{const ie=ia(z.providerConfigMode,z.providerPresetId);return Sp(z.provider,ie.providerConfigMode,ie.providerPresetId)}).filter(z=>z!==null))).filter(z=>U[z]===void 0&&!N.current[z]);if(I.length!==0)for(const z of I){const[ie,ue]=z.split("::");N.current[z]=!0,$(we=>({...we,[z]:!0})),bf(ie,t.workspaceId,{providerConfigMode:"cc-switch-preset",providerPresetId:ue}).then(we=>{L(H=>({...H,[z]:we}))}).catch(()=>{L(we=>({...we,[z]:null}))}).finally(()=>{delete N.current[z],$(we=>({...we,[z]:!1}))})}},[U,C,e,t]);const de=f.useMemo(()=>h.filter(I=>{const z=A[I];return z?z.canStartSession!==!1:!1}),[A,h]);f.useEffect(()=>{if(!de.length)return;const I=de.includes(o)?o:de[0];x(z=>{let ie=!1;const ue=z.map(we=>de.includes(we.provider)?we:(ie=!0,{...we,provider:I,providerConfigMode:"global-default",providerPresetId:null,model:""}));return ie?ue:z})},[de,o]);const Ie=f.useMemo(()=>C.map((I,z)=>{var Ge;const ie=ia(I.providerConfigMode,I.providerPresetId),ue=BM(I.provider),we=ue?G[ue]??null:null,H=OM(we),J=ie.providerConfigMode==="cc-switch-preset"?ie.providerPresetId??ka:ka,ge=H.find(ft=>ft.value===J)??H[0]??null,xe=Sp(I.provider,ie.providerConfigMode,ie.providerPresetId),De=A[I.provider]??null,He=xe?U[xe]??null:null,lt=(ie.providerConfigMode==="cc-switch-preset"?He?lc(He,I.provider):[{id:Hi,name:l("conversation.modelUseCliDefault"),usesProviderDefault:!0}]:lc(De,I.provider)).map(ft=>({value:ft.id,label:WM(ft)?l("conversation.modelUseCliDefault"):ft.name})),Ye=I.model.trim()||Hi,nt=((Ge=lt.find(ft=>ft.value===Ye))==null?void 0:Ge.label)??l("conversation.modelUseCliDefault"),Qe=FM(we),rt=ue!==null,pt=xe?E[xe]===!0:!1,$t=!!(xe&&pt&&He===null);return{index:z,draft:I,supportsDeploymentPicker:rt,showPresetColumn:Qe,deploymentPresetOptions:H,selectedPresetValue:J,selectedPresetOption:ge,triggerLabel:Qe?`${(ge==null?void 0:ge.label)??l("conversation.deploymentDefaultPreset")} · ${nt}`:nt,selectedModelValue:Ye,modelOptions:lt,loadingPresets:ue?T[ue]===!0:!1,loadingModels:pt,modelColumnDisabled:$t}}),[U,G,T,E,C,A]);if(f.useEffect(()=>{e&&x(I=>{let z=!1;const ie=I.map((ue,we)=>{const H=Ie[we];if(!H)return ue;let J=ue;const ge=ia(ue.providerConfigMode,ue.providerPresetId);ge.providerConfigMode==="cc-switch-preset"&&ge.providerPresetId&&!H.loadingPresets&&!H.deploymentPresetOptions.some(He=>He.value===ge.providerPresetId)&&(J={...J,providerConfigMode:"global-default",providerPresetId:null,model:""},z=!0);const xe=new Set(H.modelOptions.map(He=>He.value)),De=J.model.trim()||Hi;return xe.has(De)||(J={...J,model:""},z=!0),J});return z?ie:I})},[Ie,e]),!e||!t)return null;const he=t,le=V?Cp(C.length,V.memberFailures):0,Fe=new Set(V?C.map((I,z)=>z).filter(I=>!(I in v)):[]),Ue=he.kind==="group"?l("shell.parallelAppendModalTitle"):l("shell.parallelCreateModalTitle"),_e=he.kind==="session"?`${he.workspaceName} · ${he.sessionTitle}`:he.workspaceName,qe=he.kind==="group"?l("shell.parallelAppendSharedPromptLabel"):l("shell.parallelCreateSharedPromptLabel"),W=he.kind==="group"?l("shell.parallelAppendCountLabel"):l("shell.parallelCreateCountLabel"),Y=he.kind==="group"?l("shell.parallelAppendSubmit"):l("shell.parallelCreateSubmit"),se=he.kind==="group"?l("shell.parallelAppendSubmitting"):l("shell.parallelCreateSubmitting"),Ce=q??(he.kind==="group"&&c===0?l("shell.parallelAppendNoRemainingSlots"):null)??(!B&&de.length===0?l("shell.parallelCreateNoAvailableProviders"):null),ve={"--parallel-member-columns":String(Math.max(1,Math.min(y,4)))};function fe(I){D(null),te(null),je(z=>{if(!(I in z))return z;const ie={...z};return delete ie[I],ie})}function ht(){D(null),te(null),je({})}function Ke(I,z){fe(I);const ie=z?"temporary_worktree":"none";x(ue=>ue.map((we,H)=>H===I?{...we,workspaceIsolationMode:ie}:we))}async function st(){const I=m.trim();if(!a&&!I){D(l("shell.parallelCreatePromptRequired"));return}if(he.kind==="group"&&c===0){D(l("shell.parallelAppendNoRemainingSlots"));return}if(!de.length){D(l("shell.parallelCreateNoAvailableProviders"));return}F(!0),D(null),te(null),je({});try{const z=DM(),ie=C.map(we=>{const H=ia(we.providerConfigMode,we.providerPresetId);return{provider:we.provider,model:we.model.trim()||null,providerConfigMode:H.providerConfigMode,providerPresetId:H.providerConfigMode==="cc-switch-preset"?H.providerPresetId:null,memberPrompt:we.memberPrompt.trim()||null,workspaceIsolationMode:we.workspaceIsolationMode}}),ue=he.kind==="group"?await Ok(he.groupId,{permissionMode:z,members:ie}):he.kind==="session"?await Wk(he.sessionId,{sharedPrompt:I,permissionMode:z,members:ie}):await Fk(he.workspaceId,{sharedPrompt:I,permissionMode:z,members:ie});if(ue.memberFailures.length>0){const we=Cp(C.length,ue.memberFailures);te(ue),je(Object.fromEntries(ue.memberFailures.map(H=>[H.ordinal,H]))),D(we>0?l("shell.parallelCreatePartialFailure",{successCount:we,failureCount:ue.memberFailures.length}):l("shell.parallelCreateAllFailed",{failureCount:ue.memberFailures.length}));return}await r(ue)}catch(z){D(z instanceof Error?z.message:l("shell.parallelGroupLoadFailed"))}finally{F(!1)}}return i.jsx(iu,{open:e,title:Ue,description:_e,size:"xwide",layout:"form",className:"parallel-create-modal",bodyClassName:"parallel-create-modal-body",dismissible:!X,onClose:n,footer:i.jsxs(Dk,{align:"between",className:"parallel-create-modal-footer",children:[i.jsx("div",{className:"parallel-create-modal-status",role:"status","aria-live":"polite",children:Ce?i.jsx("span",{className:"parallel-create-modal-error",children:Ce}):null}),i.jsxs("div",{className:"parallel-create-modal-footer-actions",children:[V&&le>0?i.jsx("button",{type:"button",className:"secondary-button",disabled:X,onClick:()=>{r(V)},children:l("shell.parallelCreateContinuePartial")}):null,i.jsx("button",{type:"button",className:"secondary-button",disabled:X,onClick:n,children:l("common.cancel")}),i.jsx("button",{type:"button",className:"primary-button",disabled:X||B||de.length===0||he.kind==="group"&&c===0,onClick:()=>{st()},children:X?se:Y})]})]}),children:i.jsxs("div",{className:"parallel-create-layout",children:[i.jsx(Ys,{className:"parallel-create-shared-section",tone:"accent",children:i.jsxs("div",{className:"parallel-create-target-row",children:[i.jsx(Hs,{className:"parallel-create-target-field",label:qe,htmlFor:`${s}-shared-prompt`,children:i.jsx("textarea",{id:`${s}-shared-prompt`,className:"parallel-create-textarea parallel-create-textarea-target",rows:2,value:m,readOnly:a,"aria-readonly":a,"data-readonly":a?"true":void 0,onChange:I=>{a||(ht(),g(I.target.value))}})}),i.jsx(Hs,{className:"parallel-create-count-field",label:W,children:i.jsx("div",{className:"parallel-create-count-group",role:"group","aria-label":W,children:u.map(I=>i.jsx("button",{type:"button",className:"parallel-create-count-button","data-active":y===I,onClick:()=>{ht(),S(I)},children:I},I))})})]})}),i.jsx(Ys,{className:"parallel-create-members-section",heading:l("shell.parallelCreateMembersTitle"),children:i.jsx("div",{className:"parallel-create-member-list",style:ve,children:Ie.map(({draft:I,index:z,supportsDeploymentPicker:ie,showPresetColumn:ue,deploymentPresetOptions:we,selectedPresetValue:H,selectedPresetOption:J,triggerLabel:ge,selectedModelValue:xe,modelOptions:De,loadingPresets:He,loadingModels:xt,modelColumnDisabled:lt})=>{var $t;const Ye=de,nt=Ye.includes(I.provider)?I.provider:"",Qe=Ye.length>0?Ye.map(Ge=>({value:Ge,label:bc(Ge,"full")})):[{value:"",label:B?l("shell.parallelCreateProvidersLoading"):l("shell.parallelCreateNoAvailableProviders")}],rt=lc(A[I.provider]??null,I.provider),pt=rt.length>0?[{value:"",label:(($t=rt.find(Ge=>Ge.usesProviderDefault===!0))==null?void 0:$t.name)??l("shell.parallelPaneModelFallback")},...rt.filter(Ge=>Ge.usesProviderDefault!==!0).map(Ge=>({value:Ge.id,label:Ge.name}))]:[{value:"",label:l("shell.parallelCreateNoModelsAvailable")}];return i.jsxs("article",{className:"parallel-create-member-card","data-state":v[z]?"error":Fe.has(z)?"success":void 0,children:[i.jsxs("header",{className:"parallel-create-member-header",children:[i.jsxs("div",{className:"parallel-create-member-title-block",children:[i.jsx("strong",{children:l("shell.parallelCreateMemberTitle",{index:z+1})}),i.jsx("span",{className:"parallel-create-member-provider",children:bc(I.provider,"full")}),i.jsxs("label",{className:"parallel-create-isolation-toggle",children:[i.jsx("input",{type:"checkbox",checked:I.workspaceIsolationMode==="temporary_worktree",onChange:Ge=>{Ke(z,Ge.target.checked)}}),i.jsx("span",{className:"parallel-create-isolation-copy",children:l("shell.parallelCreateIsolationLabel")})]})]}),v[z]?i.jsx("span",{className:"parallel-create-member-status error",children:l("shell.parallelCreateMemberFailed")}):Fe.has(z)?i.jsx("span",{className:"parallel-create-member-status success",children:l("shell.parallelCreateMemberSucceeded")}):null]}),i.jsxs("div",{className:"parallel-create-member-grid",children:[i.jsx(Hs,{label:l("shell.createSessionProviderLabel"),htmlFor:`${s}-member-${z}-provider`,children:i.jsx(wp,{triggerId:`${s}-member-${z}-provider`,className:"parallel-create-provider-select",ariaLabel:l("shell.createSessionProviderLabel"),value:nt,options:Qe,disabled:!Ye.length,onChange:Ge=>{fe(z);const ft=Ge;x(Be=>Be.map((Nt,Ze)=>Ze===z?{...Nt,provider:ft,providerConfigMode:"global-default",providerPresetId:null,model:""}:Nt))}})}),i.jsx(Hs,{label:l("shell.parallelCreateModelLabel"),htmlFor:ie?void 0:`${s}-member-${z}-model`,children:ie?i.jsx("div",{className:"parallel-create-deployment-select",children:i.jsx($M,{triggerId:`${s}-member-${z}-model`,ariaLabel:l("shell.parallelCreateModelLabel"),triggerLabel:ge,presetOptions:we,selectedPresetValue:H,selectedPresetSummary:(J==null?void 0:J.summary)??null,onSelectPreset:Ge=>{fe(z),x(ft=>ft.map((Be,Nt)=>Nt!==z?Be:Ge===ka?{...Be,providerConfigMode:"global-default",providerPresetId:null,model:""}:{...Be,providerConfigMode:"cc-switch-preset",providerPresetId:Ge,model:""}))},modelOptions:De,selectedModelValue:xe,onSelectModel:Ge=>{fe(z),x(ft=>ft.map((Be,Nt)=>Nt===z?{...Be,model:Ge===Hi?"":Ge}:Be))},loadingPresets:He,loadingModels:xt,modelColumnDisabled:lt,showPresetColumn:ue,modelEmptyText:l("conversation.deploymentModelEmpty")})}):i.jsx(wp,{triggerId:`${s}-member-${z}-model`,className:"parallel-create-provider-select",ariaLabel:l("shell.parallelCreateModelLabel"),value:I.model,options:pt,disabled:!Ye.length||rt.length===0,onChange:Ge=>{fe(z),x(ft=>ft.map((Be,Nt)=>Nt===z?{...Be,model:Ge}:Be))}})})]}),i.jsx(Hs,{label:l("shell.parallelCreateMemberPromptLabel"),htmlFor:`${s}-member-${z}-prompt`,children:i.jsx("textarea",{id:`${s}-member-${z}-prompt`,className:"parallel-create-textarea member",rows:2,value:I.memberPrompt,onChange:Ge=>{fe(z);const ft=Ge.target.value;x(Be=>Be.map((Nt,Ze)=>Ze===z?{...Nt,memberPrompt:ft}:Nt))}})}),v[z]?i.jsxs("div",{className:"parallel-create-member-error",role:"alert",children:[i.jsx("strong",{children:l("shell.parallelCreateMemberErrorTitle")}),i.jsx("p",{children:v[z].detail})]}):null]},`parallel-member-${z}`)})})})]})})}const KM=12,YM=180,Np=72;function XM(e,t){const[n,r]=f.useState(!1),[s,o]=f.useState(""),[a,c]=f.useState({}),[u,d]=f.useState({}),[p,h]=f.useState(!1),[m,g]=f.useState(null);f.useEffect(()=>{e||(r(!1),o(""),g(null))},[e]),f.useEffect(()=>{if(!e||!n)return;const C=t.filter(A=>u[A.sessionId]!==!0);if(C.length===0)return;let x=!1;return h(!0),g(null),Promise.allSettled(C.map(async A=>{const j=await mf(A.sessionId,null,KM,"backward");return{sessionId:A.sessionId,summary:JM(j.messages)}})).then(A=>{if(x)return;const j={},G={};let P=0;C.forEach(T=>{j[T.sessionId]=!0});for(const T of A){if(T.status==="fulfilled"){G[T.value.sessionId]=T.value.summary;continue}P+=1}d(T=>({...T,...j})),Object.keys(G).length>0&&c(T=>({...T,...G})),g(P>0?l("shell.archiveSearchSummaryFailed"):null)}).finally(()=>{x||h(!1)}),()=>{x=!0}},[u,e,n,t]);const y=f.useMemo(()=>{const C=cc(s);return C?t.filter(x=>cc(x.title).includes(C)?!0:cc(a[x.sessionId]??"").includes(C)):t},[s,t,a]);function S(){r(C=>{const x=!C;return x||(o(""),g(null)),x})}return{searchOpen:n,searchKeyword:s,filteredSessions:y,summaryLoading:p,summaryError:m,summaryBySessionId:a,setSearchKeyword:o,toggleSearch:S}}function JM(e){const t=[...e].sort((r,s)=>r.sequence-s.sequence).map(QM).filter(r=>r.length>0);if(t.length===0)return"";const n=t.slice(-3).join(" · ");return qc(n,YM)}function QM(e){var n,r;const t=wb(e.content);return t.length>0?qc(t,Np):(r=(n=e.toolCall)==null?void 0:n.name)!=null&&r.trim()?qc(e.toolCall.name.trim(),Np):""}function cc(e){return wb(e).toLocaleLowerCase()}function wb(e){return e.replace(/\s+/g," ").trim()}function qc(e,t){return e.length<=t?e:`${e.slice(0,Math.max(0,t-1)).trimEnd()}…`}const jp="workbench.left.width",Tp="workbench.right.width",Ip="workbench.left.collapsed",Ep="workbench.right.collapsed",aa="workbench.last.session.path",uc="workbench.workspace.selected.id",Mp="workbench.notifications.seen_at",ZM=280,eR=320,Rp=240,Ap=280,Pp=520,Lp=560,tR=200,dc=20,Bi=40,la=5,nR=3e4,rR=12,_p=60*1e3,sR=4e3,Dp=220,Bp=18,iR=6,zs="data-workbench-panel-resizing",ca="data-workbench-window-resizing",oR=180,aR="workbench:focus-composer",lR=new Set(["starting","running","reconnecting","stale","unknown"]),cR=["#34C759","#22C55E","#14B8A6","#06B6D4","#0EA5E9","#3B82F6","#6366F1","#8B5CF6","#A855F7","#D946EF","#EC4899","#F43F5E","#EF4444","#F97316","#F59E0B","#EAB308","#84CC16","#10B981"],uR=["--workbench-titlebar-live-content-shift-y","--workbench-nav-toolbar-live-shift-y","--workbench-info-tabs-live-shift-y","--workbench-auxiliary-toolbar-button-live-shift-y","--workbench-conversation-header-main-live-shift-y","--workbench-conversation-header-actions-live-shift-y","--workbench-terminal-tabbar-live-shift-y","--workbench-collapsed-controls-live-shift-y","--workbench-collapsed-left-controls-live-shift-y","--workbench-collapsed-right-controls-live-shift-y"],kt={navToolbar:{selector:".workbench-nav-toolbar",variableName:"--workbench-nav-toolbar-live-shift-y"},infoTabs:{selector:".workbench-info-tabs",variableName:"--workbench-info-tabs-live-shift-y"},auxiliaryToolbarButton:{selector:".workbench-auxiliary-header > .workbench-nav-toolbar-button",variableName:"--workbench-auxiliary-toolbar-button-live-shift-y"},conversationHeaderMain:{selector:".conversation-header-main",variableName:"--workbench-conversation-header-main-live-shift-y"},conversationHeaderActions:{selector:".conversation-header-actions",variableName:"--workbench-conversation-header-actions-live-shift-y"},terminalTabbarMain:{selector:".terminal-tabbar-main",variableName:"--workbench-terminal-tabbar-live-shift-y"},collapsedLeftControls:{selector:'.workbench-collapsed-controls.left[data-visible="true"] .workbench-nav-toolbar-button',variableName:"--workbench-collapsed-left-controls-live-shift-y"},collapsedRightControls:{selector:'.workbench-collapsed-controls.right[data-visible="true"] .workbench-nav-toolbar-button',variableName:"--workbench-collapsed-right-controls-live-shift-y"}};function vb(e,t){const n=e.getPropertyValue(t).trim();if(!n)return null;const r=Number.parseFloat(n);return Number.isFinite(r)?r:null}function dR(e){return Math.round(e*100)/100}function hR(e,t){const n=t.getBoundingClientRect();if(n.width<=0||n.height<=0)return null;const r=window.getComputedStyle(t);return r.display==="none"||r.visibility==="hidden"?null:n.top-e.top+n.height/2}function Ar(e,t){const n=e.getBoundingClientRect(),s=Array.from(e.querySelectorAll(t)).map(o=>hR(n,o)).filter(o=>o!==null);return s.length===0?null:s.reduce((o,a)=>o+a,0)/s.length}function Qn(e,t,n){const r=e.style.getPropertyValue(t).trim();if(n===null||!Number.isFinite(n)){r&&e.style.removeProperty(t);return}const s=`${dR(n)}px`;r!==s&&e.style.setProperty(t,s)}function Zn(e,t,n,r){return r===null?null:(vb(e,t)??0)+(n-r)}function Op(e){if(e)for(const t of uR)e.style.removeProperty(t)}function pR(e){return lR.has(e.runningState??"idle")||e.activityState==="running"}function fR(e,t){const n=[];for(const r of[...t].sort()){const s=e.get(r);!s||s.size===0||n.push(`${r}:${[...s].sort().join(",")}`)}return n.join("|")}function mR(e){var s,o;const t=((s=e.lastErrorCode)==null?void 0:s.trim())??"",n=((o=e.lastErrorDetail)==null?void 0:o.trim())??"",r=[t,n].filter(a=>a.length>0).join(" · ");return r?r.length<=Dp?r:`${r.slice(0,Dp-3)}...`:null}function gR(e,t,n){var o,a,c,u,d,p,h,m,g,y,S,C;const r=new Map(e.projects.map(x=>[x.id,x.workspaceId])),s=[];for(const x of n){const A=x.title.trim()||x.projectName;if(x.assistantState.lifecycleStage==="analyzed"&&!((o=x.assistantState.linkedSessionId)!=null&&o.trim())&&x.assistantState.lastAnalyzedAt){s.push({id:`todo-analysis-completed:${x.id}:${x.assistantState.lastAnalyzedAt}`,kind:"todo_analyzed",title:l("shell.globalNotificationTodoAnalyzedTitle",{title:A}),body:((a=x.assistantState.analysisSummary)==null?void 0:a.trim())||((c=x.assistantState.generatedPrompt)==null?void 0:c.trim())||x.content,routePath:ds(x.workspaceId),workspaceId:x.workspaceId,createdAt:x.assistantState.lastAnalyzedAt});continue}x.assistantState.lifecycleStage==="failed"&&s.push({id:`todo-analysis-failed:${x.id}:${x.updatedAt}`,kind:"todo_analyze_failed",title:l("shell.globalNotificationTodoAnalyzeFailedTitle",{title:A}),body:((u=x.assistantState.lastError)==null?void 0:u.trim())||x.content,routePath:ds(x.workspaceId),workspaceId:x.workspaceId,createdAt:x.updatedAt})}for(const x of t){const A=((d=x.sessionTitle)==null?void 0:d.trim())||x.projectName,j=x.updatedAt||x.lastAutomationAt||x.createdAt;if(x.status==="waiting_user"){s.push({id:`follow-up-waiting:${x.id}`,kind:"follow_up_waiting_user",title:l("shell.globalNotificationFollowUpWaitingTitle",{title:A}),body:((p=x.waitingReason)==null?void 0:p.trim())||((h=x.lastAutomationSummary)==null?void 0:h.trim())||x.objective,routePath:Bn(x.workspaceId,x.sessionId),workspaceId:x.workspaceId,createdAt:j});continue}if(x.status==="completed"){s.push({id:`follow-up-completed:${x.id}`,kind:"follow_up_completed",title:l("shell.globalNotificationFollowUpCompletedTitle",{title:A}),body:((m=x.lastAutomationSummary)==null?void 0:m.trim())||x.objective,routePath:Bn(x.workspaceId,x.sessionId),workspaceId:x.workspaceId,createdAt:j});continue}x.status==="failed"&&s.push({id:`follow-up-failed:${x.id}`,kind:"follow_up_failed",title:l("shell.globalNotificationFollowUpFailedTitle",{title:A}),body:((g=x.lastAutomationSummary)==null?void 0:g.trim())||((y=x.waitingReason)==null?void 0:y.trim())||x.objective,routePath:Bn(x.workspaceId,x.sessionId),workspaceId:x.workspaceId,createdAt:j})}for(const x of e.verifications){if(x.status!=="failed")continue;const A=x.projectId?r.get(x.projectId)??null:null,j=((S=x.targetRef)==null?void 0:S.trim())||x.verificationType;s.push({id:`verification-failed:${x.id}`,kind:"verification_failed",title:l("shell.globalNotificationVerificationFailedTitle",{title:j}),body:((C=x.summary)==null?void 0:C.trim())||l("shell.globalNotificationVerificationFailedFallback"),routePath:A?ds(A):null,workspaceId:A,createdAt:x.finishedAt||x.startedAt||x.createdAt})}return s.sort((x,A)=>{const j=Wp(x.kind)-Wp(A.kind);return j!==0?j:_r(A.createdAt)-_r(x.createdAt)}).slice(0,rR)}function Wp(e){switch(e){case"follow_up_waiting_user":return 0;case"todo_analyze_failed":return 1;case"follow_up_failed":return 2;case"verification_failed":return 3;case"todo_analyzed":return 4;case"follow_up_completed":return 5;default:return 9}}function bR(e){switch(e){case"follow_up_waiting_user":return l("shell.globalNotificationKindWaitingUser");case"todo_analyzed":return l("shell.globalNotificationKindTodoAnalyzed");case"todo_analyze_failed":return l("shell.globalNotificationKindTodoAnalyzeFailed");case"follow_up_completed":return l("shell.globalNotificationKindFollowUpCompleted");case"follow_up_failed":return l("shell.globalNotificationKindFollowUpFailed");case"verification_failed":return l("shell.globalNotificationKindVerificationFailed");default:return l("shell.globalNotificationsPanelTitle")}}function _r(e){if(!e)return 0;const t=new Date(e).getTime();return Number.isNaN(t)?0:t}function kR(e){return/^(?:[A-Za-z0-9_-]+)(?:\/[A-Za-z0-9_-]+)*$/.test(e)}function yR(e){return/^(?:[A-Za-z0-9_-]+(?:\/[A-Za-z0-9_-]+)*\/?)?$/.test(e)}function xR(e,t){const n=new Set,r=(e==null?void 0:e.currentBranch)??"",s=((e==null?void 0:e.local)??[]).slice().sort((c,u)=>Number(u.current)-Number(c.current)||c.name.localeCompare(u.name)).map(c=>({value:c.name,current:c.current,recommended:c.name===r})).filter(c=>!c.value||n.has(c.value)?!1:(n.add(c.value),!0)),o=((e==null?void 0:e.remote)??[]).map(c=>({value:c.name})).filter(c=>!c.value||n.has(c.value)?!1:(n.add(c.value),!0)),a=t.map(c=>({value:c.name})).filter(c=>!c.value||n.has(c.value)?!1:(n.add(c.value),!0));return{localBranches:s,remoteBranches:o,tags:a}}function wR(e){return e.getBoundingClientRect()}function vR(e,t){return t?_r(e.createdAt)>_r(t):!0}function SR(e){const t=new Date(e);return Number.isNaN(t.getTime())?e:new Intl.DateTimeFormat(void 0,{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}).format(t)}function Fp(e,t){var a,c;const n=["/workspaces/:workspaceId","/workspaces/:workspaceId/sessions","/workspaces/:workspaceId/sessions/:sessionId","/workspaces/:workspaceId/tools","/workspaces/:workspaceId/tools/files","/workspaces/:workspaceId/tools/git","/workspaces/:workspaceId/tools/processes","/workspaces/:workspaceId/terminals","/workspaces/:workspaceId/butler"];for(const u of n){const d=at(u,e),p=(a=d==null?void 0:d.params.workspaceId)==null?void 0:a.trim();if(p)return p}const r=Xi(e),s=(r==null?void 0:r.sessionId)??null;return!s||!ek(s)?null:((c=new URLSearchParams(t).get("workspaceId"))==null?void 0:c.trim())||null}function CR(e){return e.startsWith("/sessions")||e.startsWith("/terminals")||e.startsWith("/tools")}function hc(e){return e==="mobile"?en():"/landing"}function Xi(e){var o,a,c;const t=at("/workspaces/:workspaceId/sessions/:sessionId",e),n=(o=t==null?void 0:t.params.sessionId)==null?void 0:o.trim();if(n)return{sessionId:n,workspaceId:((a=t==null?void 0:t.params.workspaceId)==null?void 0:a.trim())??null};const r=at("/sessions/:sessionId",e),s=(c=r==null?void 0:r.params.sessionId)==null?void 0:c.trim();return s?{sessionId:s,workspaceId:null}:null}function NR(e){return!!(at("/sessions",e)||at("/workspaces/:workspaceId/sessions",e))}function $p(e){return!!Xi(e)}function jR(e){return!!(at("/tools",e)||at("/tools/files",e)||at("/tools/git",e)||at("/tools/processes",e)||at("/workspaces/:workspaceId/tools",e)||at("/workspaces/:workspaceId/tools/files",e)||at("/workspaces/:workspaceId/tools/git",e)||at("/workspaces/:workspaceId/tools/processes",e))}function ya(e){return!!(at("/terminals",e)||at("/workspaces/:workspaceId/terminals",e))}function xa(e){return!!at("/workspaces/:workspaceId/butler",e)}function TR(e,t){return at("/workspaces/:workspaceId/debug",e)?Lf(t):at("/workspaces/:workspaceId",e)?rr(t):at("/workspaces/:workspaceId/tools/files",e)||at("/tools/files",e)?Df(t):at("/workspaces/:workspaceId/tools/git",e)||at("/tools/git",e)?Bf(t):at("/workspaces/:workspaceId/tools/processes",e)||at("/tools/processes",e)?Of(t):at("/workspaces/:workspaceId/tools",e)||at("/tools",e)?_f(t):ya(e)?as(t):xa(e)?ds(t):ii(t)}function IR(e){return e.trim().replace(/\\/g,"/").replace(/^(?:\.\/)+/,"").replace(/^\/+/,"")}const ER=f.lazy(async()=>({default:(await tu(()=>import("./FileContextPanel-xGTYDclT.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10]))).FileContextPanel})),MR=f.lazy(async()=>({default:(await tu(()=>import("./GitSidebar-Cr3Z9OUI.js"),__vite__mapDeps([11,1,2,3,4,5,7,6,8,9,10]))).GitSidebar})),RR=f.lazy(async()=>({default:(await tu(()=>import("./TerminalManagerPanel-2bi9wVhT.js"),__vite__mapDeps([12,1,2,6,3,4,5,13,14,8,9,10]))).TerminalManagerPanel}));function AR(e){return!!((e==null?void 0:e.item)??(e==null?void 0:e.session))}function ln(e){return ci(e)}function PR(e){return e&&"item"in e?e.item:(e==null?void 0:e.session)??null}function Ks(e){return Array.isArray(e==null?void 0:e.visibleSessionTree)?e.visibleSessionTree.filter(AR):[]}async function Sb(e,t){const n=await bf(t,e);if(n.canStartSession===!1)throw new Error(n.limitations[0]??l("conversation.capabilityDenied"))}const Cb=f.createContext(null);function za(e){return DI(e)}function nr(e){return e.isArchived===!0}function bo(e){return Ef(e)}function Nb(e,t){return uu(e,{getId:n=>n.sessionId,getParentId:bo,compare:(n,r)=>ao(n,r,t)})}function LR(e,t){const n=_R(e);return jb(n,t)}function jb(e,t){const n=DR(e);return uu(n,{getId:r=>r.session.sessionId,getParentId:r=>bo(r.session),compare:(r,s)=>ao(r.session,s.session,t)}).map(r=>Ib(r))}function _R(e){return e.flatMap(t=>[...t.visibleSessions.map(n=>({session:n,workspace:t.workspace})),...Tb(t.childWorktrees)])}function Tb(e){return e.flatMap(t=>[...t.visibleSessions.map(n=>({session:n,workspace:t.workspace})),...Tb(t.children)])}function DR(e){const t=[],n=new Set;for(const r of e){const s=r.session.sessionId.trim();!s||n.has(s)||(n.add(s),t.push(r))}return t}function Ib(e,t=0){return{item:e.item.session,depth:t,children:e.children.map(n=>Ib(n,t+1))}}function Gc(e,t){return{...e,depth:e.depth+t,children:ln(e).map(n=>Gc(n,t))}}function zp(e){return`${e}::parallel-anchor-member`}function Hp(e){const{session:t,depth:n,children:r}=e;return{item:t,depth:n,children:[...r]}}function Vc(e,t){for(const n of e){if(n.item.sessionId===t)return n;const r=Vc(ln(n),t);if(r)return r}return null}function BR(e,t){const n=t.trim();if(!n)return null;for(const r of e){const s=Eb(r,n,null);if(s)return s}return null}function Eb(e,t,n){var s,o;const r=((o=(s=e.item.parallelGroup)==null?void 0:s.groupId)==null?void 0:o.trim())||n;if(e.item.sessionId===t)return r;for(const a of ln(e)){const c=Eb(a,t,r);if(c)return c}return null}function Mb(e){return e.filter(t=>{if(nr(t))return!1;const n=bo(t);if(!n)return!0;const r=e.find(s=>s.sessionId===n);return r&&nr(r)?!za(t):!0})}function OR(e){return e.flatMap(t=>{const n=PR(t);return n?[n,...Rf(ln(t))]:[]})}function WR(e,t,n){var m;const r=ln(e),s=os(r).sort((g,y)=>ao(g.item,y.item,n));if(!(((m=e.item.parallelGroup)==null?void 0:m.role)==="anchor"&&r.some(g=>{var y,S;return((y=g.item.parallelGroup)==null?void 0:y.groupId)===((S=e.item.parallelGroup)==null?void 0:S.groupId)}))){const g=new Set(s.slice(0,Math.max(0,t)).map(y=>y.item.sessionId));return{...e,children:Kc(r,g)}}const a=r.slice().sort((g,y)=>ao(g.item,y.item,n)),c=a.filter(g=>{var y,S;return((y=g.item.parallelGroup)==null?void 0:y.groupId)===((S=e.item.parallelGroup)==null?void 0:S.groupId)}).map(g=>g.item.sessionId),u=a.filter(g=>{var y,S;return((y=g.item.parallelGroup)==null?void 0:y.groupId)!==((S=e.item.parallelGroup)==null?void 0:S.groupId)}).map(g=>g.item.sessionId),d=[...c,...u],p=Math.max(0,t-d.length),h=new Set(d);for(const g of s){if(h.size>=d.length+p)break;h.add(g.item.sessionId)}return{...e,children:Kc(r,h)}}function Kc(e,t){return e.flatMap(n=>{const r=Kc(ln(n),t);return!t.has(n.item.sessionId)&&r.length===0?[]:[{...n,children:r}]})}function ua(e,t,n,r=-1){if(e<=0)return 0;const s=r>=0?Math.max(t,r+1):t;return Math.min(e,Math.max(n??0,s))}function Up(e,t){const n=Object.keys(e),r=Object.keys(t);return n.length!==r.length?!1:n.every(s=>e[s]===t[s])}function FR(e){const t=e.lastMessageAt??e.updatedAt;return t?new Date(t).toLocaleDateString():""}function rl(e,t="compact"){return bc(e,t)}const $R={position:"relative",zIndex:0},zR={zIndex:1};function Rb(e,t,n,r){const s=[],o=(r==null?void 0:r.trim())||t.name;n&&s.push(o);const a=FR(e);return a&&s.push(a),s.join(" · ")||o}function qp(e,t){return cT("session-state-indicator",e,t)}function HR(e,t){return Tg(e,t)}function Gp(e,t){try{const n=window.localStorage.getItem(e),r=n?Number(n):Number.NaN;return Number.isFinite(r)?r:t}catch{return t}}function Vp(e,t){try{const n=window.localStorage.getItem(e);return n===null?t:n==="true"}catch{return t}}function Kp(e){var t;try{const n=(t=window.localStorage.getItem(e))==null?void 0:t.trim();return n||null}catch{return null}}function ss(e,t){try{window.localStorage.setItem(e,t)}catch{}}function UR(e){try{window.localStorage.removeItem(e)}catch{}}function da(e,t,n){return Math.max(t,Math.min(n,e))}function ha(e){const t=Number.parseFloat(e);return Number.isFinite(t)?t:0}function qR(e){const t=window.getComputedStyle(e),n=ha(t.getPropertyValue("--desktop-macos-titlebar-height")),r=ha(t.getPropertyValue("--workbench-header-min-height")),s=ha(t.getPropertyValue("--workbench-macos-titlebar-padding-top")),o=ha(t.getPropertyValue("--workbench-macos-titlebar-padding-bottom"));return Math.max(n,r,40)+s+o+8}function Yp(e,t){const n=t.getBoundingClientRect();return e>=n.top&&e<=n.top+qR(t)}function GR(e){return e instanceof HTMLElement?e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement||!!e.closest("[contenteditable='true']"):!1}function VR(){typeof window>"u"||window.dispatchEvent(new CustomEvent(aR))}function Ab(e,t){const n=t==null?void 0:t.trim();if(!n)return null;for(const r of e){if(r.workspace.id===n)return r;const s=Ab(r.children,n);if(s)return s}return null}function Xp(e,t){const n=t==null?void 0:t.trim();if(!n)return null;for(const r of e){const s=Ab(r.childWorktrees,n);if(s)return s}return null}function Pb(e){return e.flatMap(t=>[t.workspace.id,...Pb(t.children)])}function KR(e){return new Set(e.flatMap(t=>[t.workspace.id,...Pb(t.childWorktrees)]))}function Jp(e){return!e||!Array.isArray(e.items)?[]:e.items.filter(t=>{var n;return t.collapsed===!0&&((n=t.workspace)==null?void 0:n.id)}).map(t=>t.workspace.id)}function pc(e,t){const n=new Set(t);return{items:e.map(r=>({workspace:r.workspace,sessions:r.sessions,childWorktrees:r.childWorktrees,collapsed:n.has(r.workspace.id)}))}}function Lb(e,t,n,r=new Set){return e.map(s=>{const o=s.sessions.filter(c=>!r.has(c.sessionId)),a=Mb(o);return{workspace:s.workspace,meta:s.meta,visibleSessions:a,archivedSessions:o.filter(c=>nr(c)&&!bo(c)),visibleSessionTree:Nb(a,n).filter(c=>!t.has(c.item.sessionId)&&!du(ln(c),u=>t.has(u.sessionId))),children:Lb(s.children,t,n,r)}})}function Yc(e){return e.flatMap(t=>[t.workspace.id,...Yc(t.children)])}function Ui(e){return e.flatMap(t=>[...t.visibleSessionTree,...Ui(t.children)])}function _b(e){return e.flatMap(t=>[t,..._b(t.children)])}function YR(e,t){if(!t)return null;for(const n of e){if(n.workspace.id===t)return{workspace:n.workspace,visibleSessionTree:Ks(n)};const r=Db(n.childWorktrees,t);if(r)return r}return null}function Db(e,t){for(const n of e){if(n.workspace.id===t)return{workspace:n.workspace,visibleSessionTree:n.visibleSessionTree};const r=Db(n.children,t);if(r)return r}return null}function XR(e,t){if(!t)return null;for(const n of e){if(n.workspace.id===t)return{workspace:n.workspace,archivedSessions:n.archivedSessions};const r=Bb(n.childWorktrees,t);if(r)return r}return null}function fc(e,t){if(!t)return null;for(const n of e){if(n.workspace.id===t)return n.workspace;const r=Ob(n.childWorktrees,t);if(r)return r}return null}function Bb(e,t){for(const n of e){if(n.workspace.id===t)return{workspace:n.workspace,archivedSessions:n.archivedSessions};const r=Bb(n.children,t);if(r)return r}return null}function Ob(e,t){for(const n of e){if(n.workspace.id===t)return n.workspace;const r=Ob(n.children,t);if(r)return r}return null}function Wb(e,t){for(const n of e){if(n.workspace.id===t)return[n.workspace.id];const r=Wb(n.children,t);if(r.length>0)return[n.workspace.id,...r]}return[]}function Qp(e){return e.flatMap(t=>[t.workspace.id,...Fb(t.childWorktrees)])}function Fb(e){return e.flatMap(t=>[t.workspace.id,...Fb(t.children)])}function JR(e,t=[]){if(e.tone!=="worktree")return e.rootDisplayName;if(t.length>0)return t.join(" / ");const n=[e.rootDisplayName];return e.parentDisplayName&&e.parentDisplayName!==e.rootDisplayName&&n.push(e.parentDisplayName),n.join(" / ")}function QR(e,t,n,r){if(t===n)return e;const s=e.findIndex(d=>d.workspace.id===t),o=e.findIndex(d=>d.workspace.id===n);if(s<0||o<0)return e;const a=[...e],[c]=a.splice(s,1);if(!c)return e;const u=a.findIndex(d=>d.workspace.id===n);return u<0?e:(a.splice(r==="before"?u:u+1,0,c),a.every((d,p)=>{var h;return d.workspace.id===((h=e[p])==null?void 0:h.workspace.id)})?e:a)}function ZR(e,t){if(!Array.isArray(e.items)||t.size===0)return e;let n=!1;const r=e.items.map(s=>{let o=!1;const a=s.sessions.map(u=>{const d=t.get(u.sessionId);return d===void 0||nr(u)===d?u:(n=!0,o=!0,{...u,isArchived:d})}),c=zb(s.childWorktrees??[],t,u=>{u&&(n=!0,o=!0)});return o?{...s,sessions:a,childWorktrees:c}:s});return n?{...e,items:r}:e}function eA(e,t){if(!(!Array.isArray(t.items)||e.size===0))for(const n of t.items){for(const r of n.sessions){const s=e.get(r.sessionId);s!==void 0&&nr(r)===s&&e.delete(r.sessionId)}Hb(e,n.childWorktrees??[])}}function tA(e,t,n){let r=!1;const s=e.map(o=>{if(o.workspace.id!==t.workspaceId){const{nodes:u,changed:d}=Ub(o.childWorktrees,t,n);return d?(r=!0,{...o,childWorktrees:u}):o}const a=o.sessions.findIndex(u=>u.sessionId===t.sessionId),c=a>=0?o.sessions.map((u,d)=>d===a?t:u):[t,...o.sessions];return r=!0,{...o,sessions:go(c,n)}});return r?s:e}function nA(e,t,n){let r=!1;const s=e.map(o=>{let a=!1;const c=o.sessions.map(d=>d.sessionId!==t?d:(r=!0,a=!0,{...d,lastSeenAt:d.lastSeenAt&&d.lastSeenAt>n?d.lastSeenAt:n,activityState:d.activityState==="completed_unread"?"idle":d.activityState})),u=sl(o.childWorktrees,d=>d.sessionId!==t?d:(r=!0,a=!0,{...d,lastSeenAt:d.lastSeenAt&&d.lastSeenAt>n?d.lastSeenAt:n,activityState:d.activityState==="completed_unread"?"idle":d.activityState}));return a?{...o,sessions:c,childWorktrees:u}:o});return r?s:e}function Zp(e,t,n){let r=!1;const s=e.map(o=>{let a=!1;const c=o.sessions.map(d=>d.sessionId!==t||d.isArchived===n?d:(r=!0,a=!0,{...d,isArchived:n})),u=sl(o.childWorktrees,d=>d.sessionId!==t||d.isArchived===n?d:(r=!0,a=!0,{...d,isArchived:n}));return a?{...o,sessions:c,childWorktrees:u}:o});return r?s:e}function ef(e,t,n){let r=!1;const s=e.map(o=>{let a=!1;const c=o.sessions.map(d=>d.sessionId!==t||d.isFavorite===!0===n?d:(r=!0,a=!0,{...d,isFavorite:n})),u=sl(o.childWorktrees,d=>d.sessionId!==t||d.isFavorite===!0===n?d:(r=!0,a=!0,{...d,isFavorite:n}));return a?{...o,sessions:c,childWorktrees:u}:o});return r?s:e}function rA(e,t){return e.includes(t)?e.filter(n=>n!==t):[...e,t]}function sA(e){return e?e.slice(0,8):"--"}function tf(e,t,n){return n?e.includes(t)?e:[...e,t]:e.includes(t)?e.filter(r=>r!==t):e}function $b(e,t){const n=e.filter(r=>t.has(r));return n.length===e.length?e:n}function zb(e,t,n){return e.map(r=>{let s=!1;const o=r.sessions.map(c=>{const u=t.get(c.sessionId);return u===void 0||nr(c)===u?c:(s=!0,{...c,isArchived:u})}),a=zb(r.children,t,c=>{c&&(s=!0)});return n(s),s?{...r,sessions:o,children:a}:r})}function Hb(e,t){for(const n of t){for(const r of n.sessions){const s=e.get(r.sessionId);s!==void 0&&nr(r)===s&&e.delete(r.sessionId)}Hb(e,n.children)}}function Ub(e,t,n){let r=!1;const s=e.map(o=>{if(o.workspace.id===t.workspaceId){const c=o.sessions.findIndex(d=>d.sessionId===t.sessionId),u=c>=0?o.sessions.map((d,p)=>p===c?t:d):[t,...o.sessions];return r=!0,{...o,sessions:go(u,n)}}const a=Ub(o.children,t,n);return a.changed?(r=!0,{...o,children:a.nodes}):o});return{nodes:r?s:[...e],changed:r}}function iA(e,t){return e.map(n=>({...n,sessions:go(n.sessions,t),childWorktrees:Ku(n.childWorktrees,t)}))}function sl(e,t){let n=!1;const r=e.map(s=>{let o=!1;const a=s.sessions.map(u=>{const d=t(u);return d!==u&&(o=!0,n=!0),d}),c=sl(s.children,t);return c!==s.children&&(o=!0,n=!0),o?{...s,sessions:a,children:c}:s});return n?r:[...e]}function Xc(e){return`workspace-management.summary.${e}`}function qb(e){return`git-sidebar.snapshot.${e}`}function Gb(e,t){const n=e.repoRoot??null;return{workspaceId:e.id,name:e.name,path:e.path,git:{isRepository:!!n,repoRoot:n,currentBranch:null,commitCount:null,remotes:[],error:null},codeComposition:{scannedFileCount:0,truncated:!1,items:[],error:null}}}function Vb(e,t){const n=e.git.repoRoot??t.repoRoot??null;return{...e,workspaceId:t.id,name:t.name,path:t.path,git:{...e.git,isRepository:e.git.isRepository||!!n,repoRoot:n}}}function Kb(e,t){var o,a,c,u;const n=((o=t.status)==null?void 0:o.snapshot.enabled)!==!1,r=n?((a=t.status)==null?void 0:a.snapshot.repoRoot)??e.git.repoRoot:e.git.repoRoot,s=n?((c=t.status)==null?void 0:c.snapshot.branch)??((u=t.branches)==null?void 0:u.currentBranch)??e.git.currentBranch??null:e.git.currentBranch??null;return{...e,git:{...e.git,isRepository:n&&(e.git.isRepository||!!r),repoRoot:r,currentBranch:s,error:null}}}function Yb({count:e,className:t="workbench-skeleton-lines"}){return i.jsx("div",{className:t,"aria-hidden":"true",children:Array.from({length:e},(n,r)=>i.jsx("span",{className:"skeleton-line"},r))})}function oA(){return i.jsx("div",{className:"workbench-nav-loading","aria-hidden":"true",children:Array.from({length:3},(e,t)=>i.jsxs("section",{className:"workbench-skeleton-card",children:[i.jsxs("div",{className:"workbench-skeleton-heading",children:[i.jsx("span",{className:"skeleton-line short"}),i.jsx("span",{className:"skeleton-line tiny"})]}),i.jsx("div",{className:"workbench-skeleton-list",children:Array.from({length:3},(n,r)=>i.jsxs("div",{className:"workbench-skeleton-session",children:[i.jsx("span",{className:"workbench-skeleton-dot"}),i.jsx(Yb,{count:2,className:"workbench-skeleton-lines compact"})]},r))})]},t))})}function pa(){return i.jsx("section",{className:"workbench-info-skeleton","aria-hidden":"true",children:Array.from({length:4},(e,t)=>i.jsxs("article",{className:"workbench-info-skeleton-card",children:[i.jsx("span",{className:"skeleton-line short"}),i.jsx(Yb,{count:3})]},t))})}function aA({side:e,collapsed:t}){const n=e==="left"?8.5:15.5,r=e==="left"?t?"12 9 15 12 12 15":"15 9 12 12 15 15":t?"12 9 9 12 12 15":"9 9 12 12 9 15";return i.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[i.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2"}),i.jsx("line",{x1:n,y1:"4",x2:n,y2:"20"}),i.jsx("polyline",{points:r})]})}function nf({ariaLabel:e,side:t,collapsed:n,className:r="panel-icon-button",onClick:s}){return i.jsx("button",{className:r,type:"button","aria-label":e,title:e,onClick:s,children:i.jsx(aA,{side:t,collapsed:n})})}function ei({expanded:e}){return i.jsx("svg",{className:e?"workbench-chevron":"workbench-chevron collapsed",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:i.jsx("polyline",{points:"6 9 12 15 18 9"})})}function lA(){return i.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[i.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),i.jsx("polyline",{points:"7 10 12 15 17 10"}),i.jsx("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]})}function cA(){return i.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[i.jsx("rect",{x:"4",y:"5",width:"16",height:"14",rx:"2"}),i.jsx("line",{x1:"8",y1:"10",x2:"16",y2:"10"}),i.jsx("line",{x1:"8",y1:"14",x2:"12",y2:"14"}),i.jsx("circle",{cx:"17.5",cy:"15.5",r:"2.5"})]})}function uA(){return i.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[i.jsx("path",{d:"M7.5 10.2a4.5 4.5 0 1 1 9 0v3.1c0 .8.3 1.6.9 2.2l.8.8H5.8l.8-.8c.6-.6.9-1.4.9-2.2z",strokeLinecap:"round",strokeLinejoin:"round"}),i.jsx("path",{d:"M10 18.5a2 2 0 0 0 4 0",strokeLinecap:"round"})]})}function Xb(e){return i.jsx("div",{className:"workbench-notification-anchor",children:i.jsxs("button",{type:"button",className:e.collapsed?"workbench-nav-toolbar-button workbench-collapsed-button":"workbench-nav-toolbar-button","aria-label":l("shell.globalNotificationsAction"),title:l("shell.globalNotificationsAction"),"aria-expanded":e.open,onClick:e.onToggle,children:[i.jsx(uA,{}),e.unreadCount>0?i.jsx("span",{className:"workbench-notification-badge","aria-label":l("shell.globalNotificationsUnreadAria",{count:String(e.unreadCount)}),children:e.unreadCount>99?"99+":e.unreadCount}):null]})})}function dA(e){const[t,n]=f.useState("notifications");f.useEffect(()=>{e.open&&n("notifications")},[e.open]);const r=f.useMemo(()=>e.notifications.filter(s=>e.showArchivedNotifications||!e.archivedNotificationIds.has(s.id)),[e.archivedNotificationIds,e.notifications,e.showArchivedNotifications]);return i.jsxs(Et,{open:e.open,title:l("shell.globalNotificationsPanelTitle"),description:l("shell.globalNotificationsPanelDescription"),className:"workbench-notification-modal-card workspace-inbox-modal-card",showCloseButton:!1,onClose:e.onClose,children:[i.jsxs("div",{className:"workbench-notification-tabs",role:"tablist","aria-label":l("shell.globalNotificationsPanelTitle"),children:[i.jsx("button",{type:"button",className:t==="notifications"?"workbench-notification-tab active":"workbench-notification-tab",role:"tab","aria-selected":t==="notifications",onClick:()=>n("notifications"),children:l("shell.globalNotificationsAction")}),i.jsx("button",{type:"button",className:t==="inbox"?"workbench-notification-tab active":"workbench-notification-tab",role:"tab","aria-selected":t==="inbox",onClick:()=>n("inbox"),children:l("shell.butlerInboxAction")})]}),i.jsx("div",{className:"workbench-notification-content","data-tab":t,children:t==="notifications"?i.jsxs("div",{className:"workbench-notification-pane",role:"tabpanel","aria-label":l("shell.globalNotificationsAction"),children:[i.jsx("div",{className:"workbench-notification-toolbar",children:i.jsxs("label",{className:"workbench-notification-filter",children:[i.jsx("input",{type:"checkbox",checked:e.showArchivedNotifications,onChange:s=>e.onToggleShowArchivedNotifications(s.target.checked)}),i.jsx("span",{children:l("shell.globalNotificationsShowArchived")})]})}),r.length>0?i.jsx("div",{className:"workbench-notification-list",children:r.map(s=>{const o=e.archivedNotificationIds.has(s.id);return i.jsxs("article",{className:"workbench-notification-item","data-archived":o,children:[i.jsxs("button",{type:"button",className:"workbench-notification-item-content",onClick:()=>{e.onSelectNotification(s)},children:[i.jsx("span",{className:"workbench-notification-item-kind",children:bR(s.kind)}),i.jsx("strong",{children:s.title}),i.jsx("p",{children:s.body})]}),i.jsxs("div",{className:"workbench-notification-item-side",children:[i.jsx("time",{children:SR(s.createdAt)}),i.jsx("button",{type:"button",className:"secondary-button workbench-notification-item-action-button",onClick:()=>{if(o){e.onUnarchiveNotification(s.id);return}e.onArchiveNotification(s.id)},children:o?l("shell.globalNotificationsRemoveArchiveAction"):l("shell.globalNotificationsArchiveAction")})]})]},s.id)})}):i.jsx("p",{className:"workbench-notification-empty",children:l("shell.globalNotificationsEmpty")})]}):i.jsx("div",{className:"workbench-notification-pane",role:"tabpanel","aria-label":l("shell.butlerInboxAction"),children:i.jsx(kb,{active:e.open&&t==="inbox",preferredWorkspaceId:e.preferredWorkspaceId,preferredSessionId:e.preferredSessionId})})}),i.jsx("div",{className:"workbench-modal-actions workbench-notification-footer-actions",children:i.jsx("button",{type:"button",className:"secondary-button",onClick:e.onClose,children:l("common.close")})})]})}function hA(){return i.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[i.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),i.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})}function pA(){return i.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[i.jsx("circle",{cx:"11",cy:"11",r:"7"}),i.jsx("line",{x1:"20",y1:"20",x2:"16.65",y2:"16.65"})]})}function fA(){return i.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:i.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H8l-5 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}function mA(){return i.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:[i.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2"}),i.jsx("path",{d:"M7 9l3 3-3 3"}),i.jsx("path",{d:"M13 15h4"})]})}function gA(){return i.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:[i.jsx("rect",{x:"4",y:"5",width:"16",height:"14",rx:"3"}),i.jsx("circle",{cx:"9",cy:"11",r:"1"}),i.jsx("circle",{cx:"15",cy:"11",r:"1"}),i.jsx("path",{d:"M8 15h8"}),i.jsx("path",{d:"M12 5V3"})]})}function bA(){return i.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:[i.jsx("path",{d:"M12 4.5 13.6 8l3.9.4-2.9 2.7.8 3.9L12 13.2 8.6 15l.8-3.9-2.9-2.7L10.4 8 12 4.5Z"}),i.jsx("path",{d:"m18.5 4.5.5 1.3 1.3.5-1.3.5-.5 1.3-.5-1.3-1.3-.5 1.3-.5.5-1.3Z"})]})}function Jb(){return i.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[i.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2"}),i.jsx("line",{x1:"9",y1:"4",x2:"9",y2:"20"}),i.jsx("polyline",{points:"14 9 11 12 14 15"})]})}function kA(){return i.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[i.jsx("circle",{cx:"18",cy:"6",r:"3"}),i.jsx("circle",{cx:"6",cy:"6",r:"3"}),i.jsx("circle",{cx:"18",cy:"18",r:"3"}),i.jsx("path",{d:"M6 9v6a3 3 0 0 0 3 3h3"}),i.jsx("line",{x1:"18",y1:"9",x2:"18",y2:"15"})]})}function yA(){return i.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[i.jsx("circle",{cx:"12",cy:"12",r:"3"}),i.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09a1.65 1.65 0 0 0-1-1.51 1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06A1.65 1.65 0 0 0 4.6 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09a1.65 1.65 0 0 0 1.51-1 1.65 1.65 0 0 0-.33-1.82L4.21 7.1a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06A1.65 1.65 0 0 0 8.92 4a1.65 1.65 0 0 0 1-1.51V2.4a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9c0 .66.39 1.25 1 1.51h.09a2 2 0 0 1 0 4h-.09c-.61.26-1 .85-1 1.49z"})]})}function xA(){return i.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[i.jsx("rect",{x:"4",y:"5",width:"6",height:"6",rx:"1.5"}),i.jsx("rect",{x:"14",y:"5",width:"6",height:"6",rx:"1.5"}),i.jsx("rect",{x:"4",y:"13",width:"6",height:"6",rx:"1.5"}),i.jsx("path",{d:"M14 16l2 2 4-4"})]})}function wA(){return i.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[i.jsx("rect",{x:"4",y:"6",width:"10",height:"12",rx:"2"}),i.jsx("path",{d:"M10 12h8"}),i.jsx("path",{d:"M15 8l4 4-4 4"})]})}function vA({selected:e}){return e?i.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[i.jsx("rect",{x:"4",y:"4",width:"16",height:"16",rx:"4"}),i.jsx("path",{d:"M8 12.5l2.8 2.8L16.5 9.5"})]}):i.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:i.jsx("rect",{x:"4",y:"4",width:"16",height:"16",rx:"4"})})}function Qb({active:e,className:t}){return e?i.jsx("svg",{className:t,width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",stroke:"currentColor",strokeWidth:"1.5",children:i.jsx("polygon",{points:"12 3 15 9 22 10 17 15 18 22 12 18 6 22 7 15 2 10 9 9"})}):i.jsx("svg",{className:t,width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:i.jsx("polygon",{points:"12 3 15 9 22 10 17 15 18 22 12 18 6 22 7 15 2 10 9 9"})})}function SA(){return i.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[i.jsx("path",{d:"M3 7h18"}),i.jsx("path",{d:"M5 7l1 12h12l1-12"}),i.jsx("path",{d:"M9 11h6"}),i.jsx("path",{d:"M8 4h8l1 3H7l1-3z"})]})}function CA(){return i.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[i.jsx("path",{d:"M12 20h9"}),i.jsx("path",{d:"M16.5 3.5a2.12 2.12 0 1 1 3 3L7 19l-4 1 1-4 12.5-12.5z"})]})}function NA(){return i.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[i.jsx("path",{d:"M12 4v10"}),i.jsx("path",{d:"M8.5 7.5L12 4l3.5 3.5"}),i.jsx("path",{d:"M5 14v4a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2v-4"})]})}function jA(){return i.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[i.jsx("path",{d:"M3 6h18"}),i.jsx("path",{d:"M8 6V4h8v2"}),i.jsx("path",{d:"M6 6l1 14h10l1-14"}),i.jsx("path",{d:"M10 11v5"}),i.jsx("path",{d:"M14 11v5"})]})}function TA(){return i.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[i.jsx("path",{d:"M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7z"}),i.jsx("path",{d:"M9 13h6"})]})}function IA(){return i.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",children:[i.jsx("circle",{cx:"12",cy:"12",r:"9"}),i.jsx("path",{d:"M9.7 9.4a2.5 2.5 0 1 1 4.1 2c-.8.7-1.8 1.2-1.8 2.6",strokeLinecap:"round"}),i.jsx("circle",{cx:"12",cy:"17.2",r:"1",fill:"currentColor",stroke:"none"})]})}function EA({open:e,mode:t,keyword:n,codeWorkspaceId:r,codeResults:s,codeLoading:o,codeError:a,workspaceOptions:c,sessionResults:u,onClose:d,onModeChange:p,onKeywordChange:h,onCodeWorkspaceChange:m,onCodeSearch:g,onOpenSession:y}){const S=n.trim().length>0&&r.trim().length>0;return i.jsx(Et,{open:e,title:l("shell.searchModalTitle"),description:l("shell.searchModalDescription"),onClose:d,children:i.jsxs("div",{className:"workbench-search-modal",children:[i.jsxs("div",{className:"workbench-search-mode-switch",role:"tablist","aria-label":l("shell.searchModeLabel"),children:[i.jsx("button",{type:"button",className:t==="sessions"?"workbench-search-mode-button active":"workbench-search-mode-button",role:"tab","aria-selected":t==="sessions",onClick:()=>p("sessions"),children:l("shell.searchModeSessions")}),i.jsx("button",{type:"button",className:t==="code"?"workbench-search-mode-button active":"workbench-search-mode-button",role:"tab","aria-selected":t==="code",onClick:()=>p("code"),children:l("shell.searchModeCode")})]}),t==="sessions"?i.jsxs(i.Fragment,{children:[i.jsxs("label",{className:"workbench-modal-field",children:[i.jsx("span",{children:l("shell.searchKeywordLabel")}),i.jsx("input",{type:"text",value:n,placeholder:l("shell.searchSessionPlaceholder"),autoFocus:!0,onChange:C=>h(C.target.value)})]}),i.jsx("div",{className:"workbench-search-results",children:n.trim().length===0?i.jsx("p",{className:"workbench-search-empty",children:l("shell.searchSessionHint")}):u.length>0?u.map(C=>{const x=Vu(C.session.title,l("common.unknown"));return i.jsxs("button",{type:"button",className:"workbench-search-result-item",onClick:()=>y(C.session.sessionId),children:[i.jsx("span",{className:"workbench-search-result-title",title:x.fullTitle,children:x.displayTitle}),i.jsxs("span",{className:"workbench-search-result-meta",children:[C.workspace.name," · ",rl(C.session.provider,"full")]})]},C.session.sessionId)}):i.jsx("p",{className:"workbench-search-empty",children:l("shell.searchSessionEmpty")})})]}):i.jsxs(i.Fragment,{children:[i.jsxs("label",{className:"workbench-modal-field",children:[i.jsx("span",{children:l("shell.searchWorkspaceLabel")}),i.jsx("select",{value:r,onChange:C=>m(C.target.value),children:c.map(C=>i.jsx("option",{value:C.id,children:C.name},C.id))})]}),i.jsxs("form",{className:"workbench-search-code-form",onSubmit:C=>{C.preventDefault(),g()},children:[i.jsxs("label",{className:"workbench-modal-field",children:[i.jsx("span",{children:l("shell.searchKeywordLabel")}),i.jsx("input",{type:"text",value:n,placeholder:l("shell.searchCodePlaceholder"),autoFocus:!0,onChange:C=>h(C.target.value)})]}),i.jsx("button",{type:"submit",className:"primary-button",disabled:!S||o,children:o?l("common.loading"):l("shell.searchSubmit")})]}),i.jsxs("div",{className:"workbench-search-results",children:[a?i.jsx("p",{className:"status-text","data-tone":"error",children:a}):null,!a&&n.trim().length===0?i.jsx("p",{className:"workbench-search-empty",children:l("shell.searchCodeHint")}):null,!a&&n.trim().length>0&&!o&&s.length===0?i.jsx("p",{className:"workbench-search-empty",children:l("shell.searchCodeEmpty")}):null,s.map(C=>i.jsxs("div",{className:"workbench-search-result-item static",children:[i.jsx("span",{className:"workbench-search-result-title",children:C.name}),i.jsx("span",{className:"workbench-search-result-meta",children:C.path})]},`${C.path}-${C.kind}`))]})]})]})})}const MA=`
|
|
72
|
+
html,
|
|
73
|
+
body {
|
|
74
|
+
width: 100% !important;
|
|
75
|
+
height: auto !important;
|
|
76
|
+
min-height: auto !important;
|
|
77
|
+
overflow: visible !important;
|
|
78
|
+
overflow-x: visible !important;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
body {
|
|
82
|
+
margin: 0 !important;
|
|
83
|
+
padding: 0 !important;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.session-export-document-root {
|
|
87
|
+
position: static !important;
|
|
88
|
+
inset: auto !important;
|
|
89
|
+
z-index: auto !important;
|
|
90
|
+
opacity: 1 !important;
|
|
91
|
+
pointer-events: auto !important;
|
|
92
|
+
overflow: visible !important;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.session-export-document-root,
|
|
96
|
+
.session-export-document-root * {
|
|
97
|
+
font-family: var(--font-sans, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif);
|
|
98
|
+
letter-spacing: normal !important;
|
|
99
|
+
word-spacing: normal !important;
|
|
100
|
+
text-align: left !important;
|
|
101
|
+
-webkit-text-fill-color: currentColor !important;
|
|
102
|
+
text-fill-color: currentColor !important;
|
|
103
|
+
-webkit-background-clip: border-box !important;
|
|
104
|
+
background-clip: border-box !important;
|
|
105
|
+
text-shadow: none !important;
|
|
106
|
+
mix-blend-mode: normal !important;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
.session-export-document-root .markdown-content p,
|
|
110
|
+
.session-export-document-root .markdown-content blockquote,
|
|
111
|
+
.session-export-document-root .markdown-content td {
|
|
112
|
+
display: block !important;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
.session-export-document-root .markdown-content li {
|
|
116
|
+
display: list-item !important;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
.session-export-document-root .markdown-content code,
|
|
120
|
+
.session-export-document-root .markdown-content pre,
|
|
121
|
+
.session-export-document-root .code-block pre,
|
|
122
|
+
.session-export-document-root .tool-call-section pre,
|
|
123
|
+
.session-export-document-root .tool-call-input-preview,
|
|
124
|
+
.session-export-document-root .apply-patch-line-content,
|
|
125
|
+
.session-export-document-root .apply-patch-summary-file {
|
|
126
|
+
font-family:
|
|
127
|
+
var(--font-mono, "SF Mono", "Consolas", "Cascadia Code", "Courier New", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", monospace) !important;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
.session-export-document-root .thinking-message-label,
|
|
131
|
+
.session-export-document-root .thinking-status-text {
|
|
132
|
+
background: none !important;
|
|
133
|
+
color: var(--text-secondary, #475569) !important;
|
|
134
|
+
-webkit-text-fill-color: currentColor !important;
|
|
135
|
+
animation: none !important;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
@media print {
|
|
139
|
+
body * {
|
|
140
|
+
visibility: hidden;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
.session-export-document-root,
|
|
144
|
+
.session-export-document-root * {
|
|
145
|
+
visibility: visible;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
.session-export-document-root {
|
|
149
|
+
position: static !important;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
.session-export-document-root .session-export-print-shell {
|
|
153
|
+
width: 100%;
|
|
154
|
+
max-width: none;
|
|
155
|
+
margin: 0;
|
|
156
|
+
padding: 0;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
.session-export-document-root .message-timeline-export,
|
|
160
|
+
.session-export-document-root .message-timeline-export .message-list-export {
|
|
161
|
+
overflow: visible;
|
|
162
|
+
height: auto;
|
|
163
|
+
max-height: none;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
.session-export-document-root .tool-call-header,
|
|
167
|
+
.session-export-document-root .tool-call-info,
|
|
168
|
+
.session-export-document-root .task-tool-header,
|
|
169
|
+
.session-export-document-root .task-tool-heading,
|
|
170
|
+
.session-export-document-root .task-tool-heading-main,
|
|
171
|
+
.session-export-document-root .task-tool-list-item,
|
|
172
|
+
.session-export-document-root .assistant-capability-header,
|
|
173
|
+
.session-export-document-root .assistant-capability-heading,
|
|
174
|
+
.session-export-document-root .assistant-capability-heading-main,
|
|
175
|
+
.session-export-document-root .assistant-capability-row,
|
|
176
|
+
.session-export-document-root .apply-patch-summary-row,
|
|
177
|
+
.session-export-document-root .rules-message-toggle {
|
|
178
|
+
display: flex !important;
|
|
179
|
+
flex-wrap: wrap !important;
|
|
180
|
+
align-items: flex-start !important;
|
|
181
|
+
justify-content: flex-start !important;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
.session-export-document-root .task-tool-list-item,
|
|
185
|
+
.session-export-document-root .assistant-capability-row,
|
|
186
|
+
.session-export-document-root .apply-patch-summary-row {
|
|
187
|
+
row-gap: 4px !important;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
.session-export-document-root .tool-call-input-preview,
|
|
191
|
+
.session-export-document-root .rules-message-summary,
|
|
192
|
+
.session-export-document-root .task-tool-summary-text,
|
|
193
|
+
.session-export-document-root .task-tool-item-title,
|
|
194
|
+
.session-export-document-root .task-tool-item-detail,
|
|
195
|
+
.session-export-document-root .task-tool-item-status,
|
|
196
|
+
.session-export-document-root .assistant-capability-heading-main strong,
|
|
197
|
+
.session-export-document-root .assistant-capability-summary,
|
|
198
|
+
.session-export-document-root .assistant-capability-row-label,
|
|
199
|
+
.session-export-document-root .assistant-capability-row-value,
|
|
200
|
+
.session-export-document-root .apply-patch-summary-file,
|
|
201
|
+
.session-export-document-root .apply-patch-summary-stats,
|
|
202
|
+
.session-export-document-root .session-title,
|
|
203
|
+
.session-export-document-root .message-text,
|
|
204
|
+
.session-export-document-root .markdown-content,
|
|
205
|
+
.session-export-document-root .thinking-message-text,
|
|
206
|
+
.session-export-document-root .thinking-message-text :where(p, li, blockquote, strong, em, a, span),
|
|
207
|
+
.session-export-document-root .thinking-message-label,
|
|
208
|
+
.session-export-document-root .thinking-status-text {
|
|
209
|
+
white-space: normal !important;
|
|
210
|
+
overflow: visible !important;
|
|
211
|
+
text-overflow: clip !important;
|
|
212
|
+
word-break: break-word !important;
|
|
213
|
+
overflow-wrap: anywhere !important;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
.session-export-document-root .assistant-capability-summary {
|
|
217
|
+
display: inline !important;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
.session-export-document-root .task-tool-list {
|
|
221
|
+
list-style: decimal !important;
|
|
222
|
+
padding-left: 24px !important;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
.session-export-document-root .message-timeline-export .conversation-scroll-to-bottom-button,
|
|
226
|
+
.session-export-document-root .message-timeline-export .message-metadata-bar,
|
|
227
|
+
.session-export-document-root .message-timeline-export .retry-button,
|
|
228
|
+
.session-export-document-root .message-timeline-export .code-copy-button,
|
|
229
|
+
.session-export-document-root .message-timeline-export .rules-message-action,
|
|
230
|
+
.session-export-document-root .message-timeline-export .message-origin-detail-popover {
|
|
231
|
+
display: none !important;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
.session-export-document-root .message-item,
|
|
235
|
+
.session-export-document-root .tool-message-row,
|
|
236
|
+
.session-export-document-root .rules-message-row {
|
|
237
|
+
break-inside: avoid;
|
|
238
|
+
page-break-inside: avoid;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
`;function RA({menuKey:e,session:t,workspace:n,workspaceContext:r,isActive:s,isFavorite:o,menuOpen:a,menuAnchorPoint:c,showWorkspaceName:u,depth:d=0,showActions:p=!0,exportDisabled:h=!1,hasSubagents:m=!1,subagentListExpanded:g=!1,showParallelBadge:y=!0,selectionMode:S=!1,selected:C=!1,onToggleSelect:x,onToggleSubagents:A,onOpen:j,onRename:G,onOpenContextMenu:P,onExport:T,onToggleFavorite:K,onArchive:U,onDelete:L,onCloseMenu:E}){var Ue,_e,qe,W;const $=kn(),B=su(t.provider).supportsSessionDelete===!0,re=!$.isDesktop&&!$.isMobile,X=za(t)?((Ue=t.subagentLabel)==null?void 0:Ue.trim())||l("shell.subagentBadge"):null,F=Vu(t.title,l("common.unknown")),q=uT(t),D=q?dT("session-activity-badge",t):null,V=Uu(t),te=BI(t),v=y&&((_e=t.parallelGroup)==null?void 0:_e.role)==="anchor"?Cy(t.parallelGroup):null,je=vy(t.parallelGroup),Te=f.useRef(null),[N,de]=f.useState(null),[Ie,he]=f.useState(!1);f.useEffect(()=>{a||he(!1)},[a]),f.useLayoutEffect(()=>{if($.isDesktop||!a||!c||typeof window>"u"){de(null);return}const Y=()=>{var Ce,ve;const se=aM(c,{width:((Ce=Te.current)==null?void 0:Ce.offsetWidth)??0,height:((ve=Te.current)==null?void 0:ve.offsetHeight)??0},{width:window.innerWidth,height:window.innerHeight},{estimatedHeightPx:B&&L?216:168});de({position:"fixed",top:`${Math.round(se.top)}px`,left:`${Math.round(se.left)}px`,width:`${Math.round(se.width)}px`,maxWidth:"calc(100vw - 24px)",maxHeight:`${Math.round(se.maxHeight)}px`,transformOrigin:se.transformOrigin})};return Y(),window.addEventListener("resize",Y),window.addEventListener("scroll",Y,!0),()=>{window.removeEventListener("resize",Y),window.removeEventListener("scroll",Y,!0)}},[c,a,$.isDesktop]);async function le(){await yy([{id:`rename:${t.sessionId}`,label:l("shell.renameAction"),onSelect:G},{id:`export:${t.sessionId}`,label:l("conversation.exportAction"),disabled:h,items:[{id:`export-markdown:${t.sessionId}`,label:l("conversation.exportMarkdownAction"),onSelect:()=>T("md")},{id:`export-pdf:${t.sessionId}`,label:l("conversation.exportPdfAction"),onSelect:()=>T("pdf")},{id:`export-html:${t.sessionId}`,label:l("conversation.exportHtmlAction"),onSelect:()=>T("html")}]},{id:`favorite:${t.sessionId}`,label:o?l("shell.unfavoriteAction"):l("shell.favoriteAction"),onSelect:K},{id:`archive:${t.sessionId}`,label:l("shell.archiveAction"),onSelect:U},...B&&L?[{id:`delete:${t.sessionId}`,label:l("shell.deleteSessionAction"),onSelect:L}]:[]])}const Fe=!$.isDesktop&&a&&typeof document<"u"?ur.createPortal(i.jsxs("div",{ref:Te,className:"workbench-session-menu","data-menu-key":e,role:"menu","aria-label":l("shell.sessionMoreAction"),onClick:Y=>Y.stopPropagation(),style:N??{position:"fixed",top:0,left:0,visibility:"hidden"},children:[i.jsxs("button",{type:"button",className:"workbench-session-menu-item",onClick:()=>{G(),E()},children:[i.jsx(CA,{}),i.jsx("span",{children:l("shell.renameAction")})]}),i.jsxs("button",{type:"button",className:"workbench-session-menu-item",onClick:()=>{K(),E()},children:[i.jsx(Qb,{active:o}),i.jsx("span",{children:o?l("shell.unfavoriteAction"):l("shell.favoriteAction")})]}),i.jsxs("button",{type:"button",className:"workbench-session-menu-item",onClick:()=>{U(),E()},children:[i.jsx(SA,{}),i.jsx("span",{children:l("shell.archiveAction")})]}),re?i.jsxs("div",{className:"workbench-session-submenu","data-open":Ie,children:[i.jsxs("button",{type:"button",className:"workbench-session-menu-item","aria-haspopup":"menu","aria-expanded":Ie,onClick:()=>{he(Y=>!Y)},children:[i.jsx(NA,{}),i.jsx("span",{children:l("conversation.exportAction")}),i.jsx("span",{className:"workbench-session-submenu-caret","aria-hidden":"true",children:i.jsx(ei,{expanded:Ie})})]}),Ie?i.jsxs("div",{className:"workbench-session-submenu-panel",role:"menu","aria-label":l("conversation.exportAction"),children:[i.jsx("button",{type:"button",className:"workbench-session-menu-item",role:"menuitem",disabled:h,onClick:()=>{T("md"),E()},children:i.jsx("span",{children:l("conversation.exportMarkdownAction")})}),i.jsx("button",{type:"button",className:"workbench-session-menu-item",role:"menuitem",disabled:h,onClick:()=>{T("pdf"),E()},children:i.jsx("span",{children:l("conversation.exportPdfAction")})}),i.jsx("button",{type:"button",className:"workbench-session-menu-item",role:"menuitem",disabled:h,onClick:()=>{T("html"),E()},children:i.jsx("span",{children:l("conversation.exportHtmlAction")})})]}):null]}):null,B&&L?i.jsxs("button",{type:"button",className:"workbench-session-menu-item",onClick:()=>{L(),E()},children:[i.jsx(jA,{}),i.jsx("span",{children:l("shell.deleteSessionAction")})]}):null]}),document.body):null;return i.jsxs("article",{className:"workbench-session-card","data-active":s,"data-depth":d,"data-subagent":za(t),"data-workspace-tone":r.tone,"data-worktree-depth":r.depth,"data-has-subagents":m,"data-selecting":S,"data-selected":C,"data-parallel-group":t.parallelGroup?"true":void 0,"data-parallel-role":((qe=t.parallelGroup)==null?void 0:qe.role)??void 0,"data-parallel-color-token":((W=t.parallelGroup)==null?void 0:W.colorToken)??void 0,style:{...cr(r)??{},...je??{}},onContextMenu:Y=>{if(!(S||!p||!P)){if(Y.preventDefault(),Y.stopPropagation(),$.isDesktop){le();return}P({x:Y.clientX,y:Y.clientY})}},children:[i.jsxs("div",{className:"workbench-session-main",children:[S?i.jsx("span",{className:"workbench-session-selection-indicator","data-selected":C,"aria-hidden":"true",children:i.jsx(vA,{selected:C})}):m?i.jsxs("button",{type:"button",className:"workbench-session-subagent-toggle",style:zR,"data-indicator-variant":HR(t,{hasSubagents:!0,isActive:s}),"aria-label":g?l("shell.subagentCollapse"):l("shell.subagentExpand"),title:g?l("shell.subagentCollapse"):l("shell.subagentExpand"),"aria-expanded":g,onClick:Y=>{Y.stopPropagation(),A==null||A()},children:[i.jsx("span",{className:qp(t,{hasSubagents:!0,isActive:s}),"data-activity-source":t.activitySource,"aria-hidden":"true"}),i.jsx("span",{className:"workbench-session-subagent-toggle-icon","aria-hidden":"true",children:i.jsx(ei,{expanded:g})})]}):i.jsx("span",{className:qp(t,{isActive:s}),"data-activity-source":t.activitySource,"aria-hidden":"true"}),i.jsx("button",{type:"button",className:"workbench-session-link",style:m?$R:void 0,"data-active":s,"aria-pressed":S?C:void 0,onClick:S?x:j,onKeyDown:Y=>{if(S||!p||!P||Y.key!=="ContextMenu"&&!(Y.shiftKey&&Y.key==="F10"))return;if(Y.preventDefault(),Y.stopPropagation(),$.isDesktop){le();return}const se=Y.currentTarget.getBoundingClientRect();P({x:se.right,y:se.bottom})},children:i.jsxs("div",{className:"workbench-session-link-copy",children:[i.jsxs("div",{className:"session-title-row",children:[i.jsx("span",{className:"session-title",title:F.fullTitle,children:F.displayTitle}),X?i.jsx("span",{className:"session-subagent-badge",children:X}):null,v?i.jsx("span",{className:"session-parallel-badge",children:v}):null,!v&&te&&V?i.jsx("span",{className:`session-fork-badge ${V}`,children:te}):null]}),i.jsxs("div",{className:"session-meta-row",children:[i.jsx("span",{className:"session-meta",children:Rb(t,n,u,r.displayName)}),q&&D?i.jsx("span",{className:D,children:q}):null,i.jsx("span",{className:`session-provider-badge ${t.provider}`,children:rl(t.provider)})]})]})})]}),Fe]})}async function AA(e,t=document){await sf(),await sf(),await Yu(420),await LA(t,1800),e&&await _A(e,1800)}function PA(){if(typeof document>"u")return"";const e=[];for(const t of Array.from(document.styleSheets))try{const n=t.cssRules;if(!n||n.length===0)continue;e.push(Array.from(n).map(r=>r.cssText).join(`
|
|
242
|
+
`))}catch{continue}return e.join(`
|
|
243
|
+
`)}function rf(e){const t={};for(const n of Array.from(e.attributes))n.name!=="style"&&(t[n.name]=n.value);return t}function sf(){return new Promise(e=>{window.requestAnimationFrame(()=>e())})}function Yu(e){return new Promise(t=>{window.setTimeout(t,e)})}async function LA(e,t){const n=e.fonts;!n||typeof n.ready>"u"||await Promise.race([n.ready.catch(()=>{}),Yu(t)])}async function _A(e,t){const n=Array.from(e.querySelectorAll("img"));n.length!==0&&await Promise.race([Promise.all(n.map(r=>BA(r))),Yu(t)])}function DA(){if(typeof document>"u")return{shellWidthPx:null};const e=[".conversation-timeline-shell",".conversation-main",".conversation-panel"];for(const t of e){const n=document.querySelector(t);if(!(n instanceof HTMLElement))continue;const r=n.getBoundingClientRect();if(!(!Number.isFinite(r.width)||r.width<=0))return{shellWidthPx:Math.round(r.width)}}return{shellWidthPx:null}}function BA(e){return e.complete?Promise.resolve():new Promise(t=>{const n=()=>{e.removeEventListener("load",n),e.removeEventListener("error",n),t()};e.addEventListener("load",n),e.addEventListener("error",n)})}function of({workspaceGroups:e,workspaceVisualContextMap:t,sessionDisplaySortMode:n,favoriteSessions:r,favoriteSessionIds:s,activeWorkspaceId:o,isConversationActive:a,isTerminalActive:c,isButlerActive:u,isSearchOpen:d,navigationLoading:p,navigationError:h,activeSessionId:m,onRefreshNavigation:g,onSessionUpdated:y,onNavigateConversation:S,onNavigateTerminals:C,onNavigateButler:x,onOpenSearch:A,onOpenSettings:j,onSelectWorkspace:G,onToggleWorkspaceCollapse:P,onStartWorkspaceReorder:T,onPreviewWorkspaceReorder:K,onCommitWorkspaceReorder:U,allowWorkspaceReorder:L,subscribeGitSnapshot:E,requestGitRefresh:$,subscribeWorkspaceManagementSnapshot:B,requestWorkspaceManagementRefresh:re,onToggleFavoriteSession:X,onArchiveSession:F,onUnarchiveSession:q,workspaceManagementStateById:D,setWorkspaceManagementStateById:V,unreadNotificationCount:te,notificationPanelOpen:v,onToggleNotificationPanel:je,onClose:Te,onToggleCollapse:N}){var Ii;const de=lo(),Ie=kn(),he=Kf(Ie),{showToast:le}=Fn(),Fe=Ou(),Ue=eu(k=>k),_e=((Ii=gc(Ue))==null?void 0:Ii.name)??"",qe=Ue.hosts.length+pf(Ue).length>1&&_e.length>0,[W,Y]=f.useState(!1),[se,Ce]=f.useState(!1),[ve,fe]=f.useState(!1),[ht,Ke]=f.useState([]),[st,I]=f.useState(null),[z,ie]=f.useState(null),[ue,we]=f.useState(null),[H,J]=f.useState(null),[ge,xe]=f.useState(null),[De,He]=f.useState(null),[xt,lt]=f.useState(null),[Ye,nt]=f.useState(!1),[Qe,rt]=f.useState(!1),[pt,$t]=f.useState(""),[Ge,ft]=f.useState(""),[Be,Nt]=f.useState(""),[Ze,$n]=f.useState({localBranches:[],remoteBranches:[],tags:[]}),[_,ce]=f.useState(!1),[Se,ke]=f.useState(-1),[be,wt]=f.useState(!1),[zt,Ht]=f.useState(!1),[yn,En]=f.useState(null),[nn,ir]=f.useState(null),[hi,pi]=f.useState(null),[fr,ko]=f.useState(null),[xn,Wr]=f.useState(null),[Fr,$r]=f.useState(null),[Ut,qt]=f.useState(null),[wn,yo]=f.useState(!1),[Dt,vn]=f.useState(null),[mt,zr]=f.useState(null),[mr,gr]=f.useState(null),[un,bs]=f.useState(null),[Hr,Ur]=f.useState(dc),[br,zn]=f.useState({}),[fi,ks]=f.useState({}),[il,xo]=f.useState([]),[Hn,mi]=f.useState({expandedWorkspaceIds:[],collapsedWorkspaceIds:[]}),[Xt,kr]=f.useState(null),[qr,yr]=f.useState(""),[Gr,Jt]=f.useState(null),[St,Qt]=f.useState(null),[Pt,rn]=f.useState([]),[xr,gi]=f.useState(!1),[Vr,Un]=f.useState({}),[ys,wr]=f.useState(null),qn=f.useRef(null),vr=f.useRef(null),Sr=f.useRef(null),Gn=f.useRef(null),xs=f.useRef(new Map),Kr=f.useRef(null),ws=f.useRef(null),Cr=f.useRef(null),wo=f.useMemo(()=>new Set(Hn.expandedWorkspaceIds),[Hn.expandedWorkspaceIds]),vo=f.useMemo(()=>new Set(Hn.collapsedWorkspaceIds),[Hn.collapsedWorkspaceIds]),Vn=ys!==null,Mn=L&&Ie.isDesktop&&Ie.ui.osFamily==="macos",Nr=f.useMemo(()=>LR(e,n),[e,n]),$e=f.useMemo(()=>{const k=new Map;for(const M of e){k.set(M.workspace.id,Ks(M).map(O=>Vc(Nr,O.item.sessionId)??O));for(const O of _b(M.childWorktrees)){const Z=O.visibleSessionTree.map(ne=>Vc(Nr,ne.item.sessionId)??ne).filter(ne=>ne.item.workspaceId===O.workspace.id&&ne.depth===0);k.set(O.workspace.id,Z)}}return k},[Nr,e]),ct=f.useCallback(()=>{vn(null),zr(null)},[]),ut=f.useCallback((k,M)=>{vn(k),zr(M)},[]),it=fc(e,ge)??((xt==null?void 0:xt.id)===ge?xt:null),or=Be.trim().toLowerCase(),Kn=f.useMemo(()=>[{key:"localBranches",label:l("shell.createWorktreeBaseRefLocalGroup"),items:Ze.localBranches},{key:"remoteBranches",label:l("shell.createWorktreeBaseRefRemoteGroup"),items:Ze.remoteBranches},{key:"tags",label:l("shell.createWorktreeBaseRefTagGroup"),items:Ze.tags}].map(M=>({...M,items:M.items.filter(O=>or?O.value.toLowerCase().includes(or):!0)})).filter(M=>M.items.length>0),[or,Ze]),Zt=f.useMemo(()=>Kn.flatMap(k=>k.items),[Kn]),Rn=it?`create-worktree-base-ref-listbox-${it.id}`:"create-worktree-base-ref-listbox",Gt=XR(e,fr),An=Gt?Jn(Gt.workspace):null,vs=(Gt==null?void 0:Gt.archivedSessions)??[],{searchOpen:Ss,searchKeyword:bi,filteredSessions:Bt,summaryLoading:Mt,summaryError:Pn,summaryBySessionId:Cs,setSearchKeyword:ki,toggleSearch:yi}=XM(Gt!==null,vs),Re=f.useId(),Yn=f.useMemo(()=>YR(e,St),[St,e]),Yr=f.useMemo(()=>Yn?OR(Yn.visibleSessionTree):[],[Yn]),sn=f.useMemo(()=>Yr.map(k=>k.sessionId),[Yr]),jr=f.useMemo(()=>new Set(sn),[sn]),ol=f.useMemo(()=>new Set(Pt),[Pt]),Xr=sn.length>0&&Pt.length===sn.length;f.useEffect(()=>{V(k=>{const M=Qp(e),O=new Set(M),Z={};Object.entries(k).forEach(([pe,Ve])=>{O.has(pe)&&(Z[pe]=Ve)}),M.forEach(pe=>{const Ve=fc(e,pe);if(!Ve)return;const vt=va(Xc(pe),_p),gt=va(qb(pe),_p),At=Z[pe];let Nn=Vb((At==null?void 0:At.detail)??vt??Gb(Ve),Ve);(gt!=null&>.status||gt!=null&>.branches)&&(Nn=Kb(Nn,{status:gt.status??null,branches:gt.branches??null})),Z[pe]={detail:Nn,loading:!1,error:null}});const ne=Object.keys(k),Ae=Object.keys(Z);return ne.length===Ae.length&&Ae.every(pe=>k[pe]===Z[pe])?k:Z})},[e]);const dn=f.useCallback(async k=>{await g(),await Ie.bridge.showNotification(l("shell.importSuccess"),k.path)},[g,Ie.bridge]),jt=f.useCallback(async k=>{await g(),await Ie.bridge.showNotification(l("shell.cloneSuccess"),k.path)},[g,Ie.bridge]);function Jr(k){if(ht.includes(k)){Ke(O=>O.filter(Z=>Z!==k));return}Ke(O=>[...O,k]),E(k),$(k),B(k),re(k)}async function xi(k,M){if(Vr[k])return;const O=(M==null?void 0:M.trim().toUpperCase())??null;Un(Z=>({...Z,[k]:!0}));try{await yf(k,{backgroundColor:O}),await g()}catch(Z){le({title:Z instanceof Error?Z.message:l("shell.manageWorkspaceColorSaveFailed"),tone:"error"})}finally{Un(Z=>({...Z,[k]:!1}))}}async function Ns(){if(!(!st||z)){ie(st.id);try{await Xk(st.id),Ke(k=>k.filter(M=>M!==st.id)),V(k=>{const M={...k};return delete M[st.id],M}),I(null),await g(),le({title:l("shell.manageWorkspaceRemoveSuccess"),tone:"success"})}catch(k){le({title:k instanceof Error?k.message:l("shell.manageWorkspaceRemoveFailed"),tone:"error"})}finally{ie(null)}}}f.useEffect(()=>{if(!Dt)return;function k(M){const O=M.target;O instanceof HTMLElement&&O.closest(".workbench-session-menu")||ct()}return window.addEventListener("pointerdown",k),()=>{window.removeEventListener("pointerdown",k)}},[ct,Dt]),f.useEffect(()=>{if(!St){Pt.length>0&&rn([]),Ut&&qt(null);return}if(!Yn){Qt(null),rn([]),qt(null);return}rn(k=>$b(k,jr))},[Yn,Ut,jr,St,Pt.length]),f.useEffect(()=>{St&&sn.length===0&&(Qt(null),rn([]),qt(null))},[sn.length,St]),f.useEffect(()=>{const k=new Set(Qp(e)),M=new Set(e.flatMap(O=>Yc(O.childWorktrees)));Ke(O=>O.filter(Z=>k.has(Z))),mi(O=>({expandedWorkspaceIds:O.expandedWorkspaceIds.filter(Z=>M.has(Z)),collapsedWorkspaceIds:O.collapsedWorkspaceIds.filter(Z=>M.has(Z))})),I(O=>O&&k.has(O.id)?O:null),Un(O=>Object.fromEntries(Object.entries(O).filter(([Z,ne])=>ne&&k.has(Z))))},[e]),f.useEffect(()=>{const k=r.findIndex(M=>M.session.sessionId===m);Ur(M=>{const O=ua(r.length,dc,M,k);return O===M?M:O})},[m,r]),f.useEffect(()=>{zn(k=>{const M={};for(const O of e){const Z=Ks(O),ne=Z.findIndex(Ae=>Ae.item.sessionId===m||qs([Ae],m??"",pe=>pe.sessionId).length>0);M[O.workspace.id]=ua(Z.length,Bi,k[O.workspace.id],ne);for(const Ae of Ui(O.childWorktrees)){Ae.item.sessionId===m||qs([Ae],m??"",gt=>gt.sessionId).length>0;const pe=Ae.item.workspaceId;if(M[pe]!==void 0)continue;const Ve=Ui(O.childWorktrees).filter(gt=>gt.item.workspaceId===pe&>.depth===0),vt=Ve.findIndex(gt=>gt.item.sessionId===m||qs([gt],m??"",At=>At.sessionId).length>0);M[pe]=ua(Ve.length,Bi,k[pe],vt)}}return Up(k,M)?k:M})},[m,e]),f.useEffect(()=>{ks(k=>{const M={};for(const O of e)for(const Z of[...Ks(O),...Ui(O.childWorktrees)])for(const ne of os(ln(Z))){const Ae=ln(ne);if(Ae.length===0)continue;const pe=os(Ae),Ve=pe.findIndex(vt=>vt.item.sessionId===m);M[ne.item.sessionId]=ua(pe.length,la,k[ne.item.sessionId],Ve)}return Up(k,M)?k:M})},[m,e]),f.useEffect(()=>{if(!m)return;const k=e.flatMap(M=>[...qs(Ks(M),m,O=>O.sessionId),...Ui(M.childWorktrees).flatMap(O=>qs([O],m,Z=>Z.sessionId))]);k.length!==0&&xo(M=>{const O=new Set(M);let Z=!1;for(const ne of k)O.has(ne)||(O.add(ne),Z=!0);return Z?Array.from(O):M})},[m,e]),f.useEffect(()=>{if(!o)return;const k=[];for(const M of e){const O=Wb(M.childWorktrees,o);O.length!==0&&k.push(...O)}k.length>0&&mi(M=>{const O=new Set(M.expandedWorkspaceIds);let Z=!1;for(const ne of k)O.has(ne)||(O.add(ne),Z=!0);return Z?{expandedWorkspaceIds:Array.from(O),collapsedWorkspaceIds:M.collapsedWorkspaceIds}:M})},[o,e]),f.useEffect(()=>{if(!ge){lt(null),nt(!1),rt(!1),$t(""),ft(""),Nt(""),ce(!1),ke(-1),wt(!1),$n({localBranches:[],remoteBranches:[],tags:[]}),Ht(!1),En(null);return}nt(!1),$t(""),ft(""),Nt(""),ce(!1),ke(-1),wt(!1),$n({localBranches:[],remoteBranches:[],tags:[]}),Ht(!1),En(null)},[ge]),f.useEffect(()=>{const k=it;if(!Ye||!k)return;let M=!1;const O=k.id;return Ht(!0),En(null),Promise.all([by(O),ky(O)]).then(([Z,ne])=>{M||$n(xR(Z,ne))}).catch(()=>{M||($n({localBranches:[],remoteBranches:[],tags:[]}),En(l("shell.createWorktreeBaseRefLoadFailed")))}).finally(()=>{M||Ht(!1)}),()=>{M=!0}},[it==null?void 0:it.id,Ye]),f.useLayoutEffect(()=>{if(!_||!qn.current){ir(null),pi(null);return}const k=()=>{const O=qn.current;if(!O)return;const Z=wR(O);ir({top:Z.bottom+8,left:Z.left,width:Z.width})};k();const M=O=>{var ne,Ae;const Z=O.target;Z instanceof Node&&((ne=qn.current)!=null&&ne.contains(Z)||(Ae=vr.current)!=null&&Ae.contains(Z)||(ce(!1),ke(-1)))};return window.addEventListener("resize",k),window.addEventListener("scroll",k,!0),window.addEventListener("pointerdown",M),()=>{window.removeEventListener("resize",k),window.removeEventListener("scroll",k,!0),window.removeEventListener("pointerdown",M)}},[Zt.length,_]),f.useLayoutEffect(()=>{if(!_||!vr.current){pi(null);return}const k=vr.current,M=()=>{const Z=Math.ceil(k.getBoundingClientRect().height);pi(ne=>ne===Z?ne:Z)};if(M(),typeof ResizeObserver>"u")return;const O=new ResizeObserver(()=>{M()});return O.observe(k),()=>{O.disconnect()}},[_,Kn,zt,yn]);function Qr(){Y(!0)}function al(){Ce(!0)}function Ln(k){Sn(),xe(null),He({kind:"workspace",workspaceId:k.id,workspaceName:k.name})}function Sn(){nt(!1),$t(""),ft(""),Nt(""),ce(!1),ke(-1),wt(!1)}function wi(k,M){const O=k.getBoundingClientRect();return M<=O.top+O.height/2?"before":"after"}function vi(){Gn.current!==null&&(cancelAnimationFrame(Gn.current),Gn.current=null),wr(null)}function Tr(k){const M=(k==null?void 0:k.commit)??!1,O=(k==null?void 0:k.preserveClickSuppression)??!1,Z=Kr.current,ne=ws.current;Kr.current=null,ws.current=null,ne==null||ne(),Z!=null&&Z.dragging&&(vi(),M&&U(),!O&&Cr.current===Z.workspaceId&&(Cr.current=null))}function ll(k){if(Cr.current===k){Cr.current=null;return}P(k)}function _n(k,M){if(M){xs.current.set(k,M);return}xs.current.delete(k)}function So(k,M){for(const[O,Z]of xs.current){const ne=Z.getBoundingClientRect();if(k>=ne.left&&k<=ne.right&&M>=ne.top&&M<=ne.bottom)return{workspaceId:O,element:Z}}return null}function js(k,M){var Ve;if(!Mn||k.button!==0)return;Tr();const O=k.currentTarget,Z={pointerId:k.pointerId,workspaceId:M,startX:k.clientX,startY:k.clientY,pointerTarget:O,dragging:!1};Kr.current=Z,(Ve=O.setPointerCapture)==null||Ve.call(O,k.pointerId);const ne=vt=>{Ot(vt)},Ae=vt=>{ar(vt.pointerId,{commit:!0,preserveClickSuppression:!0})},pe=vt=>{ar(vt.pointerId,{commit:!1,preserveClickSuppression:!1})};ws.current=()=>{O.removeEventListener("pointermove",ne),O.removeEventListener("pointerup",Ae),O.removeEventListener("pointercancel",pe),window.removeEventListener("pointermove",ne),window.removeEventListener("pointerup",Ae),window.removeEventListener("pointercancel",pe)},O.addEventListener("pointermove",ne),O.addEventListener("pointerup",Ae),O.addEventListener("pointercancel",pe),window.addEventListener("pointermove",ne,{passive:!1}),window.addEventListener("pointerup",Ae),window.addEventListener("pointercancel",pe)}function Ot(k){const M=Kr.current;if(!M||M.pointerId!==k.pointerId)return;if(!M.dragging){if(Math.hypot(k.clientX-M.startX,k.clientY-M.startY)<iR)return;M.dragging=!0,Cr.current=M.workspaceId,T(),wr(M.workspaceId)}k.preventDefault();const O=So(k.clientX,k.clientY);!O||O.workspaceId===M.workspaceId||K(M.workspaceId,O.workspaceId,wi(O.element,k.clientY))}function ar(k,M){var Z,ne;const O=Kr.current;!O||O.pointerId!==k||((ne=(Z=O.pointerTarget).releasePointerCapture)==null||ne.call(Z,k),Tr(M))}function Si(k){Ot(k)}function cl(k){ar(k.pointerId,{commit:!0,preserveClickSuppression:!0})}function ul(k){ar(k.pointerId,{commit:!1,preserveClickSuppression:!1})}function Co(k,M){k.dataTransfer.effectAllowed="move",k.dataTransfer.setData("text/plain",M),T(),Gn.current!==null&&cancelAnimationFrame(Gn.current),Gn.current=requestAnimationFrame(()=>{Gn.current=null,wr(M)})}function dl(k,M){const O=ys||k.dataTransfer.getData("text/plain");!O||O===M||(k.preventDefault(),k.dataTransfer.dropEffect="move",K(O,M,wi(k.currentTarget,k.clientY)))}function hl(k){k.preventDefault()}function pl(){vi(),U()}f.useEffect(()=>()=>{Tr()},[]);function fl(k){return fi[k]??la}function ml(k){return il.includes(k)}function Ts(k){return br[k]??Bi}function gl(){Ur(k=>Math.min(r.length,k+dc))}function No(k,M){zn(O=>({...O,[k]:Math.min(M,(O[k]??Bi)+Bi)}))}function lr(k){ks(M=>({...M,[k]:(M[k]??la)+la}))}function Is(k){xo(M=>M.includes(k)?M.filter(O=>O!==k):[...M,k])}function Zr(k,M){return vo.has(k)?!1:M||wo.has(k)}function jo(k,M){const O=!Zr(k,M);mi(Z=>{const ne=Z.expandedWorkspaceIds.filter(pe=>pe!==k),Ae=Z.collapsedWorkspaceIds.filter(pe=>pe!==k);return O?{expandedWorkspaceIds:[...ne,k],collapsedWorkspaceIds:Ae}:{expandedWorkspaceIds:ne,collapsedWorkspaceIds:[...Ae,k]}})}function To(k){const M=os(Nr).find(O=>O.item.sessionId===k)??null;return M?ln(M):[]}function Ci(k,M){const O=Jn(k);return i.jsxs("button",{type:"button",className:"workbench-archive-folder","data-workspace-tone":O.tone,style:cr(O),onClick:()=>ko(k.id),children:[i.jsxs("span",{className:"workbench-archive-folder-main",children:[i.jsx(TA,{}),i.jsx("span",{children:l("shell.archiveFolderLabel")})]}),i.jsx("span",{className:"workbench-section-counter",children:M.length})]})}function Es(){return i.jsxs("div",{className:"workbench-workspace-batch-toolbar",children:[i.jsx("span",{className:"workbench-workspace-batch-label",children:l("shell.batchSelectionMode")}),i.jsxs("span",{className:"workbench-workspace-batch-counter",children:[Pt.length,"/",sn.length]}),i.jsx("button",{type:"button",className:"workbench-workspace-batch-action",onClick:kl,children:Xr?l("shell.clearSelectedSessions"):l("shell.selectAllSessions")}),i.jsx("button",{type:"button",className:"workbench-workspace-batch-action primary",disabled:Pt.length===0||xr||wn,onClick:()=>{As()},children:xr?l("shell.batchArchiving"):l("shell.batchArchiveAction")}),i.jsx("button",{type:"button",className:"workbench-workspace-batch-action danger",disabled:Pt.length===0||xr||wn,onClick:Mo,children:wn?l("shell.batchDeleting"):l("shell.batchDeleteAction")}),i.jsx("button",{type:"button",className:"workbench-workspace-batch-action",onClick:Eo,children:l("common.cancel")})]})}function Ni(k,M="workbench-workspace-actions"){return i.jsxs("div",{className:M,children:[i.jsx("button",{type:"button",className:"workbench-workspace-icon-button","aria-label":l("shell.switchWorkspace"),title:l("shell.switchWorkspace"),"aria-pressed":o===k,onClick:()=>{G(k),Te==null||Te()},children:i.jsx(wA,{})}),i.jsx("button",{type:"button",className:"workbench-workspace-icon-button","aria-label":l("shell.batchSelectSessions"),title:l("shell.batchSelectSessions"),onClick:()=>bl(k),children:i.jsx(xA,{})}),i.jsx("button",{type:"button",className:"workbench-workspace-icon-button workbench-workspace-create","aria-label":l("shell.createSession"),title:l("shell.createSession"),onClick:()=>xe(k),children:i.jsx(hA,{})})]})}function Io(k){const M=$e.get(k.workspace.id)??k.visibleSessionTree,Z=new Set(Yc(k.children)).has(o??""),ne=k.workspace.id===o||Z,Ae=Vn||!Zr(k.workspace.id,ne),pe=Jn(k.workspace);return i.jsxs("section",{className:"workbench-workspace-group","data-worktree-node":"true","data-batch-active":St===k.workspace.id,"data-worktree-depth":k.meta.depth,"data-workspace-tone":"worktree",style:cr(pe),children:[i.jsxs("div",{className:"workbench-workspace-header minimal",children:[i.jsxs("button",{type:"button",className:"workbench-workspace-toggle","aria-label":Ae?l("shell.worktreeExpand"):l("shell.worktreeCollapse"),onClick:()=>jo(k.workspace.id,ne),children:[i.jsx("span",{className:"workbench-workspace-toggle-icon","aria-hidden":"true",children:i.jsx(ei,{expanded:!Ae})}),i.jsxs("span",{children:[i.jsx("strong",{children:k.meta.displayName||k.workspace.name}),i.jsx("span",{className:"session-meta",children:k.meta.branchName})]})]}),St===k.workspace.id?Es():Ni(k.workspace.id)]}),Ae?null:i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"workbench-session-list","data-workspace-tone":pe.tone,style:cr(pe),children:[M.length===0?i.jsx("p",{className:"workbench-session-empty",children:l("shell.emptyWorkspaceSessions")}):M.slice(0,Ts(k.workspace.id)).map(Ve=>es({node:Ve,workspace:k.workspace,workspaceContext:pe,menuKeyPrefix:`worktree:${k.workspace.id}`,showWorkspaceName:!1,selectionMode:St===k.workspace.id,favoriteEnabled:!0})),M.length>Ts(k.workspace.id)?i.jsx("button",{type:"button",className:"workbench-subsession-expand ghost-button",onClick:()=>No(k.workspace.id,M.length),children:l("shell.sessionExpandMore")}):null]}),k.children.length>0?i.jsx("div",{className:"workbench-session-list workbench-worktree-child-list",children:k.children.map(Ve=>Io(Ve))}):null,Ci(k.workspace,k.archivedSessions)]})]},k.workspace.id)}function es(k){var Ju,Qu,Zu,ed;const{node:M,fullNode:O=M,branchKey:Z,subagentStateKey:ne,workspace:Ae,workspaceContext:pe,menuKeyPrefix:Ve,showWorkspaceName:vt,selectionMode:gt,favoriteEnabled:At,showParallelBadge:Nn=!0,forceInactive:jn=!1,ancestorExpanded:Ir=!1,allowToggle:b=M.depth===0,ancestorHasNextSiblings:w=[],hasNextSibling:R=!1,isFirstSibling:Q=!1}=k,ee=M.item,ae=fc(e,ee.workspaceId)??Ae,Ne=Jn(ae),Me=ln(O),Pe=ne??ee.sessionId,me=ml(Pe),et=Ir&&ln(M).length>0,on=me,hn=et||on,Tt=me&&b,Dn=et?M:Tt?WR(M,fl(Pe),n):O,Ps=hn?ln(Dn):[],tk=os(Me).length,nk=os(Ps).length,rk=Tt&&nk<tk,sk=M.depth>0?[...w,R]:[...w],Ls=((Qu=(Ju=ee.parallelGroup)==null?void 0:Ju.groupId)==null?void 0:Qu.trim())||null,vl=((Zu=ee.parallelGroup)==null?void 0:Zu.role)==="anchor"&&Ls?Ps.filter(tt=>{var It;return((It=tt.item.parallelGroup)==null?void 0:It.groupId)===Ls}):[],ik=Ps.filter(tt=>{var It;return((It=tt.item.parallelGroup)==null?void 0:It.groupId)!==Ls}),ok=((ed=ee.parallelGroup)==null?void 0:ed.role)==="anchor"&&Ls?Me.filter(tt=>{var It;return((It=tt.item.parallelGroup)==null?void 0:It.groupId)===Ls}):[],ak=Me.filter(tt=>{var It;return((It=tt.item.parallelGroup)==null?void 0:It.groupId)!==Ls}),lk=vl.length>0?ik:[],Xu=vl.length>0?[Hp({session:ee,depth:M.depth+1,children:lk.map(tt=>Gc(tt,1))}),...vl].map((tt,It)=>{const Ei=It===0,ck=Hp({session:ee,depth:M.depth+1,children:ak.map(Sl=>Gc(Sl,1))});return{node:tt,fullNode:Ei?ck:ok.find(Sl=>Sl.item.sessionId===tt.item.sessionId)??tt,branchKey:Ei?zp(ee.sessionId):void 0,subagentStateKey:Ei?zp(ee.sessionId):void 0,showParallelBadge:!Ei,forceInactive:Ei}}):Ps.map(tt=>({node:tt,fullNode:Me.find(It=>It.item.sessionId===tt.item.sessionId)??tt}));return i.jsxs("div",{className:"workbench-session-tree-node",children:[i.jsxs("div",{className:"workbench-session-tree-row",style:{"--workbench-session-tree-depth":M.depth},children:[M.depth>0?i.jsxs("div",{className:"workbench-session-tree-guides","aria-hidden":"true",children:[w.map((tt,It)=>tt?i.jsx("span",{className:"workbench-session-tree-guide-column",style:{"--workbench-session-tree-level":It+1}},`${ee.sessionId}:ancestor:${It}`):null),i.jsx("span",{className:"workbench-session-tree-guide-branch","data-continue":R,"data-first":Q,style:{"--workbench-session-tree-level":M.depth},children:i.jsx("span",{className:"workbench-session-tree-guide-branch-horizontal"})})]}):null,i.jsx(RA,{menuKey:`${Ve}:${Z??ee.sessionId}`,session:ee,workspace:ae,workspaceContext:Ne,isActive:!jn&&ee.sessionId===m,isFavorite:At&&s.has(ee.sessionId),menuOpen:Dt===`${Ve}:${Z??ee.sessionId}`,showWorkspaceName:vt,depth:M.depth,showActions:At,exportDisabled:mr!==null,hasSubagents:b&&Me.length>0,subagentListExpanded:on,showParallelBadge:Nn,selectionMode:gt,selected:ol.has(ee.sessionId),onToggleSelect:()=>Ms(ee.sessionId),onToggleSubagents:()=>Is(Pe),onOpen:()=>{de(Bn(ae.id,ee.sessionId)),Te==null||Te()},onRename:()=>Ao(ee,ae),menuAnchorPoint:Dt===`${Ve}:${Z??ee.sessionId}`?mt:null,onOpenContextMenu:tt=>ut(`${Ve}:${Z??ee.sessionId}`,tt),onExport:tt=>Xn(ee,tt),onToggleFavorite:()=>Ro(ee.sessionId),onArchive:()=>Cn(ee.sessionId),onDelete:su(ee.provider).supportsSessionDelete===!0?()=>{ct(),Wr({session:ee,workspace:ae})}:void 0,onCloseMenu:ct})]}),Me.length>0&&hn?i.jsxs("div",{className:"workbench-subsession-list",children:[Xu.map((tt,It)=>es({node:tt.node,fullNode:tt.fullNode,branchKey:tt.branchKey,subagentStateKey:tt.subagentStateKey,workspace:Ae,workspaceContext:pe,menuKeyPrefix:Ve,showWorkspaceName:vt,selectionMode:gt,favoriteEnabled:At,showParallelBadge:tt.showParallelBadge,forceInactive:tt.forceInactive,allowToggle:!0,ancestorHasNextSiblings:sk,hasNextSibling:It<Xu.length-1,isFirstSibling:It===0})),rk?i.jsx("button",{type:"button",className:"workbench-subsession-expand ghost-button",onClick:()=>lr(Pe),children:l("shell.subagentExpandMore")}):null]}):null]},Z??ee.sessionId)}function bl(k){ct(),Qt(k),rn([]),qt(null)}function Eo(){Qt(null),rn([]),qt(null)}function Ms(k){rn(M=>rA(M,k))}function kl(){rn(k=>k.length===sn.length?[]:sn)}function Mo(){if(!Yn||Pt.length===0||xr||wn)return;const k=new Map(Yr.map(O=>[O.sessionId,O])),M=Pt.flatMap(O=>{const Z=k.get(O);return Z?[Z]:[]});M.length!==0&&(ct(),qt({workspace:Yn.workspace,sessions:M}))}async function yl(k,M){we(k),J(M);try{await Sb(k,M),xe(null),de(Wf(k,M)),Te==null||Te()}catch(O){le({title:O instanceof Error?O.message:l("shell.startSessionFailed"),tone:"error"})}finally{we(null),J(null)}}async function xl(k){if(k.preventDefault(),!it||Qe)return;const M=pt.trim(),O=Ge.trim(),Z=Be.trim();if(!M){le({title:l("shell.createWorktreeBranchRequired"),tone:"error"});return}if(!kR(M)){le({title:l("shell.createWorktreeBranchInvalid"),tone:"error"});return}rt(!0);try{const ne=await Jk({sourceWorkspaceId:it.id,branchName:M,displayName:O||void 0,baseRef:Z||void 0});lt(ne.workspace),G(ne.workspace.id),await g(),xe(ne.workspace.id),Sn(),le({title:l("shell.createWorktreeSucceeded",{name:ne.meta.displayName||ne.workspace.name}),tone:"success"})}catch(ne){le({title:ne instanceof Error?ne.message:l("shell.createWorktreeFailed"),tone:"error"})}finally{rt(!1)}}async function Ro(k){const M=s.has(k);ct();try{await X(k),le({title:M?l("shell.favoriteRemoved"):l("shell.favoriteAdded"),tone:"success"})}catch(O){le({title:O instanceof Error?O.message:l("shell.favoriteToggleFailed"),tone:"error"})}}async function Cn(k){ct();try{await F(k),le({title:l("shell.archiveAdded"),tone:"success"})}catch(M){le({title:M instanceof Error?M.message:l("shell.navigationLoadFailed"),tone:"error"})}}async function Xn(k,M){var O,Z;if(!mr){ct(),gr(k.sessionId);try{const ne=await ME(k.sessionId),Ae=DA();if(M==="md"){const w=nc(k,"md"),R=RE(k,ne.messages);tp(w,R,"text/markdown;charset=utf-8"),le({title:l("conversation.exportMarkdownSuccess"),tone:"success"});return}ur.flushSync(()=>{bs({session:k,items:yT({messages:ne.messages}),shellWidthPx:Ae.shellWidthPx})}),await AA(Sr.current);const pe=((O=Sr.current)==null?void 0:O.innerHTML.trim())??"";if(!pe)throw new Error(l("conversation.exportLoadFailed"));const Ve=rf(document.documentElement),vt=document.body?rf(document.body):{},gt=document.documentElement.getAttribute("style"),At=((Z=document.body)==null?void 0:Z.getAttribute("style"))??null,Nn=`${PA()}
|
|
244
|
+
${MA}`,jn=LE({title:k.title||l("conversation.titleFallback"),bodyHtml:`<div class="session-export-document-root">${pe}</div>`,styleText:Nn,htmlAttributes:Ve,bodyAttributes:vt,htmlStyle:gt,bodyStyle:At});if(M==="html"){const w=nc(k,"html");tp(w,jn,"text/html;charset=utf-8"),le({title:l("conversation.exportHtmlSuccess"),tone:"success"});return}const Ir=nc(k,"pdf"),b=PE(k,ne.messages);AE(Ir,b,"application/pdf"),le({title:l("conversation.exportPdfPreparing"),tone:"success"})}catch(ne){le({title:ne instanceof Error?ne.message:l("conversation.exportLoadFailed"),tone:"error"})}finally{ur.flushSync(()=>{bs(null)}),gr(null)}}}async function Rs(){if(!xn||Fr)return;const{session:k,workspace:M}=xn;$r(k.sessionId),ct();try{await nd(k.sessionId),rn(O=>O.filter(Z=>Z!==k.sessionId)),Wr(null),m===k.sessionId&&de(M.id?ii(M.id):en()),await g(),le({title:l("shell.deleteSessionSuccess"),tone:"success"})}catch(O){le({title:O instanceof Error?O.message:l("shell.deleteSessionFailed"),tone:"error"})}finally{$r(null)}}async function As(){if(!(Pt.length===0||xr||wn)){ct(),gi(!0);try{const k=[...Pt],M=await Promise.allSettled(k.map(async ne=>({sessionId:ne,session:await kf(ne,!0)}))),O=[];let Z=0;for(const ne of M){if(ne.status==="fulfilled"){O.push(ne.value.sessionId),y(ne.value.session);continue}Z+=1}O.length>0&&(await g(),rn(ne=>ne.filter(Ae=>!O.includes(Ae)))),Z>0?le({title:O.length>0?l("shell.batchArchivePartialFailed"):l("shell.batchArchiveFailed"),tone:"error"}):le({title:l("shell.batchArchiveSuccess"),tone:"success"})}catch(k){le({title:k instanceof Error?k.message:l("shell.batchArchiveFailed"),tone:"error"})}finally{gi(!1)}}}async function ts(){if(!Ut||wn)return;const{workspace:k,sessions:M}=Ut,O=M.map(Z=>Z.sessionId);if(O.length===0){qt(null);return}yo(!0),ct();try{const Z=await Promise.allSettled(O.map(async pe=>(await nd(pe),pe))),ne=[];let Ae=0;for(const pe of Z){if(pe.status==="fulfilled"){ne.push(pe.value);continue}Ae+=1}if(ne.length>0&&(m&&ne.includes(m)&&de(k.id?ii(k.id):en()),rn(pe=>pe.filter(Ve=>!ne.includes(Ve))),await g()),Ae>0){qt(pe=>{if(!pe)return pe;const Ve=pe.sessions.filter(vt=>!ne.includes(vt.sessionId));return Ve.length>0?{...pe,sessions:Ve}:null}),le({title:ne.length>0?l("shell.batchDeletePartialFailed"):l("shell.batchDeleteFailed"),tone:"error"});return}qt(null),le({title:l("shell.batchDeleteSuccess"),tone:"success"})}catch(Z){le({title:Z instanceof Error?Z.message:l("shell.batchDeleteFailed"),tone:"error"})}finally{yo(!1)}}async function wl(k){ct();try{await q(k),le({title:l("shell.archiveRestored"),tone:"success"})}catch(M){le({title:M instanceof Error?M.message:l("shell.navigationLoadFailed"),tone:"error"})}}function Ao(k,M){ct(),kr({session:k,workspace:M}),yr(k.title)}async function Po(k){if(k.preventDefault(),!Xt)return;const M=qr.trim();if(M){Jt(Xt.session.sessionId);try{const O=await xf(Xt.session.sessionId,M);y(O),kr(null),yr(""),le({title:l("shell.renameSuccess"),tone:"success"})}catch(O){le({title:O instanceof Error?O.message:l("shell.renameFailed"),tone:"error"})}finally{Jt(null)}}}const ji=r.slice(0,Hr),Lo=ji.length<r.length;function Jn(k){return t[k.id]??$a(k)}function Ti(k,M,O,Z,ne=[]){var w;const Ae=ht.includes(k.id),pe=D[k.id]??{detail:null,loading:!1,error:null},Ve=z===k.id,vt=Vr[k.id]===!0,gt=(w=pe.detail)!=null&&w.git.remotes.length?pe.detail.git.remotes.map(R=>`${R.name}: ${R.url}`).join(" · "):l("shell.manageWorkspaceNoRemote"),At=pe.detail?tM(pe.detail.codeComposition.items,l("shell.manageWorkspaceCodeCompositionOther")):[],Nn=At.length>0?rM(At):void 0,jn=Jn(k),Ir=JR(jn,ne),b=[...ne,jn.displayName];return i.jsxs("article",{className:"workbench-manage-item","data-workspace-tone":jn.tone,"data-worktree-node":Z,style:cr(jn),children:[i.jsxs("button",{type:"button",className:"workbench-manage-item-toggle","aria-expanded":Ae,onClick:()=>Jr(k.id),children:[i.jsxs("span",{className:"workbench-manage-item-heading",children:[i.jsx(ei,{expanded:Ae}),i.jsxs("span",{className:"workbench-manage-item-heading-copy",children:[i.jsx("strong",{children:jn.displayName}),i.jsx("span",{className:"workbench-manage-item-tree-path",children:Ir})]})]}),i.jsx("span",{className:"workbench-section-counter",children:M})]}),Ae?i.jsxs("div",{className:"workbench-manage-item-body",children:[i.jsxs("div",{className:"workbench-manage-detail-block",children:[i.jsx("span",{className:"workbench-manage-detail-label",children:l("shell.manageWorkspacePathLabel")}),i.jsx("p",{className:"workbench-manage-detail-value",children:k.path})]}),Z?i.jsxs("div",{className:"workbench-manage-detail-block",children:[i.jsxs("div",{className:"workbench-manage-detail-header",children:[i.jsx("span",{className:"workbench-manage-detail-label",children:l("shell.manageWorkspaceColorLabel")}),i.jsxs("div",{className:"workbench-manage-color-actions",children:[i.jsx("div",{className:"workbench-manage-color-palette","aria-label":l("shell.manageWorkspaceColorLabel"),children:cR.map(R=>i.jsx("button",{type:"button",className:"workbench-manage-color-swatch","aria-label":l("shell.manageWorkspaceColorSelectSwatch",{color:R}),"aria-pressed":k.backgroundColor===R,disabled:vt,"data-selected":k.backgroundColor===R,style:{backgroundColor:R},onClick:()=>{xi(k.id,R)}},R))}),i.jsx("button",{type:"button",className:"ghost-button",disabled:vt||!k.backgroundColor,onClick:()=>{xi(k.id,null)},children:l("shell.manageWorkspaceColorClearAction")})]})]}),i.jsx("p",{className:"workbench-manage-hint",children:k.backgroundColor??l("shell.manageWorkspaceColorUnset")})]}):null,pe.loading&&pe.detail===null?i.jsx("p",{className:"workbench-manage-status status-text",children:l("shell.manageWorkspaceLoading")}):null,pe.error?i.jsx("p",{className:"workbench-manage-status status-text","data-tone":"error",children:pe.error}):null,pe.detail?i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"workbench-manage-detail-block",children:i.jsxs("div",{className:"workbench-manage-detail-header",children:[i.jsx("span",{className:"workbench-manage-detail-label",children:l("shell.manageWorkspaceGitCommitCount")}),i.jsx("strong",{className:"workbench-manage-detail-accent",children:pe.detail.git.commitCount??"--"})]})}),i.jsxs("div",{className:"workbench-manage-detail-block",children:[i.jsx("span",{className:"workbench-manage-detail-label",children:l("shell.manageWorkspaceGitInfoLabel")}),pe.detail.git.isRepository?i.jsxs("div",{className:"workbench-manage-kv-list",children:[i.jsxs("div",{className:"workbench-manage-kv-item",children:[i.jsx("span",{children:l("shell.manageWorkspaceRepoRoot")}),i.jsx("span",{children:pe.detail.git.repoRoot??"--"})]}),i.jsxs("div",{className:"workbench-manage-kv-item",children:[i.jsx("span",{children:l("shell.manageWorkspaceCurrentBranch")}),i.jsx("span",{children:pe.detail.git.currentBranch??"--"})]}),i.jsxs("div",{className:"workbench-manage-kv-item",children:[i.jsx("span",{children:l("shell.manageWorkspaceRemoteLabel")}),i.jsx("span",{children:gt})]})]}):i.jsx("p",{className:"workbench-section-empty",children:pe.detail.git.error??l("shell.manageWorkspaceNotGit")})]}),i.jsxs("div",{className:"workbench-manage-detail-block",children:[i.jsx("span",{className:"workbench-manage-detail-label",children:l("shell.manageWorkspaceCodeCompositionLabel")}),At.length>0?i.jsxs("div",{className:"workbench-manage-type-chart",children:[i.jsxs("div",{className:"workbench-manage-type-chart-ring",style:Nn,"aria-hidden":"true",children:[i.jsx("strong",{className:"workbench-manage-type-chart-total",children:pe.detail.codeComposition.scannedFileCount}),i.jsx("span",{className:"workbench-manage-type-chart-caption",children:l("shell.manageWorkspaceCodeCompositionFiles")})]}),i.jsx("div",{className:"workbench-manage-type-list",children:At.map(R=>i.jsxs("div",{className:"workbench-manage-type-item",children:[i.jsxs("span",{className:"workbench-manage-type-meta",children:[i.jsx("span",{className:"workbench-manage-type-swatch",style:{backgroundColor:R.color},"aria-hidden":"true"}),i.jsx("span",{className:"workbench-manage-type-name",children:R.type})]}),i.jsxs("span",{children:[R.count," · ",eM(R)]})]},R.key))})]}):i.jsx("p",{className:"workbench-section-empty",children:pe.detail.codeComposition.error??l("shell.manageWorkspaceNoCodeComposition")}),pe.detail.codeComposition.truncated?i.jsx("p",{className:"workbench-manage-hint",children:l("shell.manageWorkspaceCodeTruncated",{count:pe.detail.codeComposition.scannedFileCount})}):null]})]}):null,i.jsxs("div",{className:"workbench-modal-actions",children:[i.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{fe(!1),de(Lf(k.id))},children:l("shell.workspaceDetailDebugOpenPageAction")}),i.jsx("button",{type:"button",className:"secondary-button workbench-danger-button",disabled:!!z,onClick:()=>I(k),children:Ve?l("shell.manageWorkspaceRemoving"):l("shell.manageWorkspaceRemoveAction")})]})]}):null,O.length>0?i.jsx("div",{className:"workbench-manage-children",children:O.map(R=>Ti(R.workspace,R.visibleSessions.length+R.archivedSessions.length,R.children,!0,b))}):null]},k.id)}return i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"workbench-nav-header","data-window-drag-handle":"workbench-nav-header","data-tauri-drag-region":he,children:i.jsxs("div",{className:"workbench-nav-toolbar","data-tauri-drag-region":he,children:[N?i.jsx("button",{type:"button",className:"workbench-nav-toolbar-button","aria-label":l("shell.hideSessionSidebar"),title:l("shell.hideSessionSidebar"),onClick:N,children:i.jsx(Jb,{})}):null,i.jsx(bb,{}),i.jsx(Xb,{unreadCount:te,open:v,onToggle:je})]})}),i.jsxs("div",{ref:Fe,className:"workbench-nav-body","data-scrollbar-autohide":"true",children:[i.jsxs("div",{className:"workbench-nav-segment",children:[i.jsxs("div",{className:"workbench-nav-segment-tabs",role:"tablist","aria-label":l("shell.centerTabsLabel"),children:[i.jsxs("div",{className:"workbench-nav-segment-pair",children:[i.jsxs("button",{type:"button",className:a?"workbench-nav-segment-button active":"workbench-nav-segment-button","data-layout":"paired",role:"tab","aria-selected":a,onClick:S,children:[i.jsx(fA,{}),i.jsx("span",{children:l("shell.conversationEntry")})]}),i.jsxs("button",{type:"button",className:u?"workbench-nav-segment-button active":"workbench-nav-segment-button","data-layout":"paired",role:"tab","aria-selected":u,onClick:x,children:[i.jsx(gA,{}),i.jsx("span",{children:l("shell.butlerEntry")})]})]}),i.jsxs("button",{type:"button",className:c?"workbench-nav-segment-button active":"workbench-nav-segment-button",role:"tab","aria-selected":c,onClick:C,children:[i.jsx(mA,{}),i.jsx("span",{children:l("shell.terminalsEntry")})]})]}),i.jsx(iw,{triggerClassName:"workbench-nav-segment-button",triggerLabel:l("shell.skillsEntry"),triggerLeading:i.jsx(bA,{})}),i.jsxs("button",{type:"button",className:"workbench-nav-segment-button","data-open":d,"aria-haspopup":"dialog","aria-expanded":d,onClick:A,children:[i.jsx(pA,{}),i.jsx("span",{children:l("shell.searchEntry")})]})]}),h?i.jsx("div",{className:"workbench-status-row",children:i.jsx("p",{className:"status-text","data-tone":"error",children:h})}):null,r.length>0?i.jsxs("section",{className:"workbench-section-block workbench-favorite-section",children:[i.jsxs("div",{className:"workbench-section-heading",children:[i.jsxs("div",{className:"workbench-section-heading-main",children:[i.jsx(Qb,{active:!0,className:"workbench-favorite-heading-icon"}),i.jsx("span",{children:l("shell.favoriteSectionTitle")})]}),i.jsx("span",{className:"workbench-section-counter",children:r.length})]}),i.jsxs("div",{className:"workbench-session-list",children:[ji.map(k=>{const M=To(k.session.sessionId);return i.jsx("div",{children:es({node:{item:k.session,depth:0,children:M},workspace:k.workspace,workspaceContext:Jn(k.workspace),menuKeyPrefix:"favorite",showWorkspaceName:!0,selectionMode:!1,favoriteEnabled:!0})},k.session.sessionId)}),Lo?i.jsx("button",{type:"button",className:"workbench-subsession-expand ghost-button",onClick:gl,children:l("shell.favoriteExpandMore")}):null]})]}):null,p&&e.length===0?i.jsx(oA,{}):null,!p&&!h&&e.length===0?i.jsx("div",{className:"workbench-empty-state minimal",children:i.jsx("p",{children:l("shell.emptyNavigationBody")})}):null,i.jsxs("section",{className:"workbench-section-block workbench-workspace-section",children:[i.jsxs("div",{className:"workbench-section-heading",children:[i.jsx("div",{className:"workbench-section-heading-main",children:i.jsx("span",{children:l("shell.workspaceSectionTitle")})}),i.jsxs("div",{className:"workbench-section-actions",children:[i.jsx("button",{type:"button",className:"workbench-workspace-icon-button","aria-label":l("shell.manageWorkspaceAction"),title:l("shell.manageWorkspaceAction"),onClick:()=>fe(!0),children:i.jsx(cA,{})}),i.jsx("button",{type:"button",className:"workbench-workspace-icon-button","aria-label":l("shell.importWorkspaceTitle"),title:l("shell.importWorkspaceTitle"),onClick:Qr,children:i.jsx(lA,{})}),i.jsx("button",{type:"button",className:"workbench-workspace-icon-button","aria-label":l("shell.cloneWorkspaceTitle"),title:l("shell.cloneWorkspaceTitle"),onClick:al,children:i.jsx(kA,{})})]})]}),e.map(k=>{const M=$e.get(k.workspace.id)??Ks(k),O=ys===k.workspace.id,Z=k.isCollapsed||Vn;return i.jsxs("section",{className:"workbench-workspace-group",ref:ne=>_n(k.workspace.id,ne),"data-workspace-group-id":k.workspace.id,"data-batch-active":St===k.workspace.id,"data-dragging":O,onDragOver:ne=>dl(ne,k.workspace.id),onDrop:hl,children:[i.jsxs("div",{className:"workbench-workspace-header minimal",children:[i.jsxs("button",{type:"button",className:"workbench-workspace-toggle","aria-label":Z?l("shell.workspaceExpand"):l("shell.workspaceCollapse"),draggable:L&&!Mn,onClick:()=>ll(k.workspace.id),onPointerDown:Mn?ne=>js(ne,k.workspace.id):void 0,onPointerMove:Mn?Si:void 0,onPointerUp:Mn?cl:void 0,onPointerCancel:Mn?ul:void 0,onDragStart:L&&!Mn?ne=>Co(ne,k.workspace.id):void 0,onDragEnd:L&&!Mn?pl:void 0,"data-reorder-enabled":L?"true":void 0,children:[i.jsx("span",{className:"workbench-workspace-toggle-icon","aria-hidden":"true",children:i.jsx(ei,{expanded:!Z})}),i.jsx("strong",{children:k.workspace.name})]}),St===k.workspace.id?Es():Ni(k.workspace.id)]}),Z?null:i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"workbench-session-list",children:[M.length===0?i.jsx("p",{className:"workbench-session-empty",children:l("shell.emptyWorkspaceSessions")}):M.slice(0,Ts(k.workspace.id)).map(ne=>es({node:ne,workspace:k.workspace,workspaceContext:Jn(k.workspace),menuKeyPrefix:`workspace:${k.workspace.id}`,showWorkspaceName:!1,selectionMode:St===k.workspace.id,favoriteEnabled:!0})),M.length>Ts(k.workspace.id)?i.jsx("button",{type:"button",className:"workbench-subsession-expand ghost-button",onClick:()=>No(k.workspace.id,M.length),children:l("shell.sessionExpandMore")}):null]}),k.childWorktrees.length>0?i.jsx("div",{className:"workbench-session-list workbench-worktree-child-list",children:k.childWorktrees.map(ne=>Io(ne))}):null,Ci(k.workspace,k.archivedSessions)]})]},k.workspace.id)})]})]}),i.jsx("div",{className:"workbench-nav-footer minimal",children:i.jsxs("div",{className:"workbench-nav-footer-actions",children:[i.jsxs("button",{className:"settings-entry-button workbench-nav-settings-button",type:"button",onClick:j,title:qe?`${l("settings.title")} · ${_e}`:l("settings.title"),children:[i.jsx(yA,{}),i.jsx("span",{className:"settings-entry-label",children:l("settings.title")}),qe?i.jsx("span",{className:"workbench-nav-settings-host-badge",title:_e,children:_e}):null]}),i.jsx(_M,{onOpenSoftwareUpdate:()=>de("/settings/software-update")})]})}),i.jsx(Et,{open:ve,title:l("shell.manageWorkspaceTitle"),className:"workbench-manage-workspaces-modal",description:l("shell.manageWorkspaceDescription"),headerActions:i.jsxs(i.Fragment,{children:[i.jsx("button",{type:"button",className:"secondary-button workbench-manage-modal-action",onClick:Qr,children:l("shell.manageWorkspaceImportAction")}),i.jsx("button",{type:"button",className:"secondary-button workbench-manage-modal-action",onClick:al,children:l("shell.manageWorkspaceCloneAction")})]}),onClose:()=>{z||fe(!1)},children:e.length>0?i.jsx("div",{className:"workbench-manage-list",children:e.map(k=>Ti(k.workspace,k.visibleSessions.length+k.archivedSessions.length,k.childWorktrees,!1))}):i.jsx("p",{className:"workbench-section-empty",children:l("shell.manageWorkspaceEmpty")})}),i.jsxs(Et,{open:xn!==null,title:l("shell.deleteSessionConfirmTitle"),description:l("shell.deleteSessionConfirmDescription"),onClose:()=>{Fr||Wr(null)},children:[i.jsx("p",{className:"workbench-section-empty",children:xn?xn.session.title:""}),i.jsxs("div",{className:"workbench-modal-actions",children:[i.jsx("button",{type:"button",className:"secondary-button",disabled:!!Fr,onClick:()=>Wr(null),children:l("common.cancel")}),i.jsx("button",{type:"button",className:"secondary-button workbench-danger-button",disabled:!!Fr,onClick:()=>{Rs()},children:Fr?l("common.loading"):l("shell.deleteSessionAction")})]})]}),i.jsxs(Et,{open:Ut!==null,title:l("shell.batchDeleteConfirmTitle"),description:l("shell.batchDeleteConfirmDescription",{count:`${(Ut==null?void 0:Ut.sessions.length)??0}`}),onClose:()=>{wn||qt(null)},children:[i.jsx("p",{className:"workbench-section-empty",children:Ut?l("shell.batchDeleteSelectionSummary",{count:`${Ut.sessions.length}`}):""}),i.jsxs("div",{className:"workbench-modal-actions",children:[i.jsx("button",{type:"button",className:"secondary-button",disabled:wn,onClick:()=>qt(null),children:l("common.cancel")}),i.jsx("button",{type:"button",className:"secondary-button workbench-danger-button",disabled:wn,onClick:()=>{ts()},children:wn?l("shell.batchDeleting"):l("shell.batchDeleteAction")})]})]}),i.jsxs(Et,{open:st!==null,title:l("shell.manageWorkspaceRemoveConfirmTitle"),description:l("shell.manageWorkspaceRemoveConfirmDescription"),onClose:()=>{z||I(null)},children:[i.jsx("p",{className:"workbench-section-empty",children:st?l("shell.manageWorkspaceRemoveConfirmTarget",{name:st.name}):""}),i.jsxs("div",{className:"workbench-modal-actions",children:[i.jsx("button",{type:"button",className:"secondary-button",disabled:!!z,onClick:()=>I(null),children:l("common.cancel")}),i.jsx("button",{type:"button",className:"secondary-button workbench-danger-button",disabled:!!z,onClick:()=>{Ns()},children:z?l("shell.manageWorkspaceRemoving"):l("shell.manageWorkspaceRemoveConfirmAction")})]})]}),i.jsx(jM,{open:se,onClose:()=>Ce(!1),onCloned:jt}),i.jsx(LM,{open:W,onClose:()=>Y(!1),onImported:dn}),i.jsx(VM,{open:De!==null,source:De,onClose:()=>He(null),onCreated:async k=>{k.members.forEach(O=>{y(O.session)}),Ty(k.group.id),await g();const M=k.members.find(O=>O.session.sessionId===k.group.anchorSessionId)??k.members[0]??null;M&&de(Bn(Ny(M.session,M.sessionIsolatedWorkspace),M.session.sessionId)),He(null),le({title:l("shell.parallelCreateSucceeded"),tone:"success"})}}),i.jsx(Et,{open:it!==null,title:l("shell.createSessionModalTitle"),className:"workbench-create-session-modal",description:it?`${l("shell.createSessionTarget")} · ${it.name}`:l("shell.createSessionModalDescription"),headerActions:i.jsxs(i.Fragment,{children:[i.jsx("button",{type:"button",className:"primary-button create-session-parallel-trigger",disabled:Qe||!!ue||!it,onClick:()=>{it&&Ln(it)},children:l("shell.parallelCreateAction")}),i.jsx("button",{type:"button",className:"primary-button create-session-worktree-trigger",disabled:Qe||!!ue,onClick:()=>nt(!0),children:l("shell.createWorktreeAction")})]}),onClose:()=>xe(null),children:i.jsxs("section",{className:"create-session-modal-section",children:[i.jsx("div",{className:"create-session-modal-section-header",children:i.jsx("strong",{children:l("shell.createSessionProviderLabel")})}),i.jsx(Yk,{disabled:!!ue||Qe,workspaceId:(it==null?void 0:it.id)??null,pendingProvider:ue===(it==null?void 0:it.id)?H??null:null,onSelect:k=>{it&&yl(it.id,k)}})]})}),i.jsx(Et,{open:it!==null&&Ye,title:l("shell.createWorktreeAction"),className:"workbench-create-worktree-modal",headerActions:i.jsx("button",{type:"button",className:be?"workbench-modal-help-button active":"workbench-modal-help-button","aria-label":l("shell.createWorktreeHelpAction"),title:l("shell.createWorktreeHelpAction"),"aria-pressed":be,onClick:()=>wt(k=>!k),children:i.jsx(IA,{})}),description:it?`${l("shell.createWorktreeSectionDescription")} ${l("shell.createSessionTarget")} · ${it.name}`:l("shell.createWorktreeSectionDescription"),onClose:Sn,children:i.jsxs("form",{className:"create-session-worktree-form",onSubmit:xl,children:[be?i.jsxs("section",{className:"create-session-worktree-help-card","aria-label":l("shell.createWorktreeHelpTitle"),children:[i.jsx("strong",{children:l("shell.createWorktreeHelpTitle")}),i.jsxs("div",{className:"create-session-worktree-help-grid",children:[i.jsxs("article",{children:[i.jsx("h3",{children:l("shell.createWorktreeHelpBranchTitle")}),i.jsx("p",{children:l("shell.createWorktreeHelpBranchBody")})]}),i.jsxs("article",{children:[i.jsx("h3",{children:l("shell.createWorktreeHelpDisplayNameTitle")}),i.jsx("p",{children:l("shell.createWorktreeHelpDisplayNameBody")})]}),i.jsxs("article",{children:[i.jsx("h3",{children:l("shell.createWorktreeHelpBaseRefTitle")}),i.jsx("p",{children:l("shell.createWorktreeHelpBaseRefBody")})]})]})]}):null,i.jsxs("label",{className:"create-session-worktree-field",children:[i.jsx("span",{children:l("shell.createWorktreeBranchLabel")}),i.jsx("input",{className:"settings-text-input",value:pt,placeholder:l("shell.createWorktreeBranchPlaceholder"),onChange:k=>{const M=k.target.value;yR(M)&&$t(M)}})]}),i.jsxs("label",{className:"create-session-worktree-field",children:[i.jsx("span",{children:l("shell.createWorktreeDisplayNameLabel")}),i.jsx("input",{className:"settings-text-input",value:Ge,placeholder:l("shell.createWorktreeDisplayNamePlaceholder"),onChange:k=>ft(k.target.value)})]}),i.jsxs("label",{className:"create-session-worktree-field",children:[i.jsx("span",{children:l("shell.createWorktreeBaseRefLabel")}),i.jsx("div",{className:"create-session-worktree-combobox",ref:qn,onBlurCapture:k=>{var O,Z;const M=k.relatedTarget;M instanceof Node&&((O=qn.current)!=null&&O.contains(M)||(Z=vr.current)!=null&&Z.contains(M))||(ce(!1),ke(-1))},children:i.jsxs("div",{className:"create-session-worktree-combobox-input-wrap",children:[i.jsx("input",{className:"settings-text-input create-session-worktree-combobox-input",role:"combobox","aria-autocomplete":"list","aria-expanded":_,"aria-controls":Rn,value:Be,placeholder:l("shell.createWorktreeBaseRefPlaceholder"),onFocus:()=>{ce(!0),ke(Zt.length>0?0:-1)},onChange:k=>{Nt(k.target.value),ce(!0),ke(Zt.length>0?0:-1)},onKeyDown:k=>{if(k.key==="ArrowDown"){if(k.preventDefault(),!_){ce(!0);return}Zt.length>0&&ke(M=>M>=Zt.length-1?0:M+1);return}if(k.key==="ArrowUp"){if(k.preventDefault(),!_){ce(!0);return}Zt.length>0&&ke(M=>M<=0?Zt.length-1:M-1);return}if(k.key==="Enter"&&_&&Se>=0){k.preventDefault();const M=Zt[Se];M&&(Nt(M.value),ce(!1),ke(-1));return}k.key==="Escape"&&ce(!1)}}),i.jsx("button",{type:"button",className:"create-session-worktree-combobox-toggle","aria-label":l("shell.createWorktreeBaseRefToggle"),"aria-expanded":_,onClick:()=>{ce(k=>!k),ke(!_&&Zt.length>0?0:-1)},children:i.jsx(ei,{expanded:_})})]})}),i.jsx("span",{className:"create-session-worktree-field-hint",children:zt?l("shell.createWorktreeBaseRefLoading"):yn||l("shell.createWorktreeBaseRefHint",{localCount:Ze.localBranches.length,remoteCount:Ze.remoteBranches.length,tagCount:Ze.tags.length})})]}),_&&nn&&typeof document<"u"?ur.createPortal(i.jsxs("div",{className:"create-session-worktree-combobox-floating-layer",children:[i.jsx("div",{className:"create-session-worktree-combobox-floating-backdrop",style:{"--create-worktree-combobox-top":`${nn.top}px`,"--create-worktree-combobox-left":`${nn.left}px`,"--create-worktree-combobox-width":`${nn.width}px`,"--create-worktree-combobox-height":`${hi??0}px`}}),i.jsx("div",{ref:vr,className:"create-session-worktree-combobox-popover floating",style:{"--create-worktree-combobox-top":`${nn.top}px`,"--create-worktree-combobox-left":`${nn.left}px`,"--create-worktree-combobox-width":`${nn.width}px`},children:zt?i.jsx("p",{className:"create-session-worktree-combobox-empty",children:l("shell.createWorktreeBaseRefLoading")}):yn?i.jsx("p",{className:"create-session-worktree-combobox-empty",children:yn}):Kn.length>0?i.jsx("div",{id:Rn,className:"create-session-worktree-combobox-list",role:"listbox",children:Kn.map(k=>i.jsxs("section",{className:"create-session-worktree-combobox-group","aria-label":k.label,children:[i.jsx("header",{className:"create-session-worktree-combobox-group-title",children:k.label}),i.jsx("div",{className:"create-session-worktree-combobox-group-options",children:k.items.map(M=>{const O=Zt.findIndex(Ae=>Ae.value===M.value),Z=Be===M.value,ne=Se===O;return i.jsxs("button",{type:"button",role:"option",className:"create-session-worktree-combobox-option","aria-selected":Z,"data-highlighted":ne,onMouseDown:Ae=>Ae.preventDefault(),onMouseEnter:()=>ke(O),onClick:()=>{Nt(M.value),ce(!1),ke(-1)},children:[i.jsx("span",{className:"create-session-worktree-combobox-option-label",children:M.value}),i.jsxs("span",{className:"create-session-worktree-combobox-option-badges",children:[M.current?i.jsx("span",{className:"create-session-worktree-combobox-badge",children:l("shell.createWorktreeBaseRefCurrentBadge")}):null,M.recommended?i.jsx("span",{className:"create-session-worktree-combobox-badge recommended",children:l("shell.createWorktreeBaseRefRecommendedBadge")}):null]})]},`${k.key}:${M.value}`)})})]},k.key))}):i.jsx("p",{className:"create-session-worktree-combobox-empty",children:l("shell.createWorktreeBaseRefEmpty")})})]}),document.body):null,i.jsxs("div",{className:"workbench-modal-actions",children:[i.jsx("button",{type:"button",className:"secondary-button",disabled:Qe,onClick:Sn,children:l("common.cancel")}),i.jsx("button",{type:"submit",className:"primary-button",disabled:Qe,children:Qe?l("shell.createWorktreeSubmitting"):l("shell.createWorktreeSubmit")})]})]})}),i.jsxs(Et,{open:Gt!==null,title:l("shell.archiveModalTitle"),description:Gt?`${Gt.workspace.name} · ${l("shell.archiveModalDescription")}`:l("shell.archiveModalDescription"),headerActions:vs.length>0?i.jsx("button",{type:"button",className:"secondary-button","aria-pressed":Ss,onClick:yi,children:l("shell.archiveSearchAction")}):void 0,onClose:()=>ko(null),children:[Ss?i.jsxs("div",{className:"workbench-archive-search-panel",children:[i.jsx(Hs,{label:l("shell.archiveSearchLabel"),htmlFor:Re,children:i.jsx("input",{id:Re,type:"text",value:bi,placeholder:l("shell.archiveSearchPlaceholder"),autoFocus:!0,onChange:k=>ki(k.target.value)})}),Mt?i.jsx("p",{className:"workbench-archive-search-status",children:l("shell.archiveSearchSummaryLoading")}):null,Pn?i.jsx("p",{className:"workbench-archive-search-status status-text","data-tone":"warning",children:Pn}):null]}):null,Gt&&Bt.length>0?i.jsx(ru,{className:"workbench-archive-list","data-workspace-tone":(An==null?void 0:An.tone)??"root",style:cr(An),children:Bt.map(k=>{var Z;const M=Vu(k.title,l("common.unknown")),O=((Z=Cs[k.sessionId])==null?void 0:Z.trim())??"";return i.jsx(fn,{className:"workbench-archive-item","data-workspace-tone":(An==null?void 0:An.tone)??"root",style:cr(An),trailing:i.jsx("button",{type:"button",className:"secondary-button",onClick:()=>wl(k.sessionId),children:l("shell.unarchiveAction")}),children:i.jsxs("div",{className:"workbench-archive-item-main",children:[i.jsx("strong",{title:M.fullTitle,children:M.displayTitle}),i.jsxs("p",{children:[Rb(k,Gt.workspace,!1)," ·"," ",rl(k.provider)]}),Ss&&O?i.jsx("p",{className:"workbench-archive-item-summary",children:O}):null]})},k.sessionId)})}):i.jsx(ff,{title:vs.length>0&&bi.trim().length>0?l("shell.archiveSearchEmpty"):l("shell.archiveEmpty"),compact:!0,className:"workbench-section-empty"})]}),i.jsx(Et,{open:Xt!==null,title:l("shell.renameModalTitle"),description:l("shell.renameModalDescription"),onClose:()=>{Gr||(kr(null),yr(""))},children:i.jsxs("form",{className:"workbench-rename-form",onSubmit:Po,children:[i.jsxs("label",{className:"workbench-modal-field",children:[i.jsx("span",{children:l("shell.renameInputLabel")}),i.jsx("input",{type:"text",value:qr,placeholder:l("shell.renameInputPlaceholder"),maxLength:120,autoFocus:!0,onChange:k=>yr(k.target.value)})]}),i.jsxs("div",{className:"workbench-modal-actions",children:[i.jsx("button",{type:"button",className:"secondary-button",disabled:!!Gr,onClick:()=>{kr(null),yr("")},children:l("common.cancel")}),i.jsx("button",{type:"submit",className:"primary-button",disabled:!qr.trim()||Gr===(Xt==null?void 0:Xt.session.sessionId),children:Gr===(Xt==null?void 0:Xt.session.sessionId)?l("shell.renamingSession"):l("common.save")})]})]})}),un?i.jsx("div",{ref:Sr,className:"session-export-print-root","aria-hidden":"true",children:i.jsxs("div",{className:"session-export-print-shell",style:un.shellWidthPx?{width:`${un.shellWidthPx}px`,maxWidth:"100%"}:void 0,children:[i.jsxs("header",{className:"session-export-print-header",children:[i.jsx("h1",{children:un.session.title||l("conversation.titleFallback")}),i.jsx("p",{children:l("conversation.exportAction")})]}),i.jsx(MI,{sessionId:un.session.sessionId,items:un.items,provider:un.session.provider})]})}):null]})}function af({panelReady:e,activeTab:t,fileRevealRequest:n,onTabChange:r,onToggleCollapse:s,currentSessionId:o,activeWorkspaceId:a,navigationGroups:c,workspaceContext:u,worktreeMeta:d,worktreeMergeState:p,onRefreshWorktreeMergePreview:h,onApplyWorktreeMerge:m,onCleanupWorktree:g}){var X;const y=a??((X=c[0])==null?void 0:X.workspace.id)??null,S=kn(),C=Kf(S),{showToast:x}=Fn(),A=Ou(),j=f.useRef(null),G=f.useRef(null),P=S.isDesktop&&S.bridge.supported,T=P&&!!a,K=P&&!!y,U=P&&!!y,L=typeof globalThis<"u"&&"PointerEvent"in globalThis,E=f.useCallback(async(F,q,D)=>{if(F==="files"){const te=await Rx(S,{workspaceId:q,sessionId:D,focusOwner:"file-context-panel"});te.ok||x({title:te.detail??l("conversation.filePanelOpenExternalFailed"),tone:"error"});return}if(F==="git"){const te=await Ax(S,{workspaceId:q,focusOwner:"git-sidebar"});te.ok||x({title:te.detail??l("git.openExternalFailed"),tone:"error"});return}const V=await Px(S,{workspaceId:q,focusOwner:"terminal-manager-panel"});V.ok||x({title:V.detail??l("terminalManager.openExternalFailed"),tone:"error"})},[S,x]),$=f.useCallback((F,q)=>{if(F.button!==0||!P)return;const D=q==="files"?a:q==="git"||q==="terminals"?y:null;if(!D)return;const V=q==="files"?o:null;j.current={tab:q,startX:F.clientX,startY:F.clientY,workspaceId:D,sessionId:V,detached:!1,preview:null};const te=N=>{var le;const de=j.current;if(!de)return;const Ie=Math.abs(N.clientX-de.startX),he=Math.abs(N.clientY-de.startY);!de.detached&&Math.max(Ie,he)<Bp||(de.detached||(de.detached=!0,G.current=de.tab,de.preview=vd({title:de.tab==="files"?l("shell.filesEntry"):de.tab==="git"?l("shell.gitEntry"):l("shell.terminalManagerEntry"),x:N.clientX,y:N.clientY})),(le=de.preview)==null||le.updatePosition(N.clientX,N.clientY))},v=N=>{var Ie;const de=(Ie=j.current)==null?void 0:Ie.preview;N&&(de==null||de.cancel()),window.removeEventListener("mousemove",te),window.removeEventListener("mouseup",je),window.removeEventListener("blur",Te),j.current=null},je=async()=>{var de;const N=j.current;v(!1),N!=null&&N.detached&&(await((de=N.preview)==null?void 0:de.complete()),await E(N.tab,N.workspaceId,N.sessionId))},Te=()=>{v(!0)};window.addEventListener("mousemove",te),window.addEventListener("mouseup",je),window.addEventListener("blur",Te)},[a,P,o,y,E]),B=f.useCallback((F,q)=>{if(F.button!==0||!P)return;const D=q==="files"?a:q==="git"||q==="terminals"?y:null;if(!D)return;const V=F.currentTarget,te=F.pointerId;V.setPointerCapture(te);const v=q==="files"?o:null;j.current={tab:q,startX:F.clientX,startY:F.clientY,workspaceId:D,sessionId:v,detached:!1,preview:null};const je=he=>{var _e;if(he.pointerId!==te)return;const le=j.current;if(!le)return;const Fe=Math.abs(he.clientX-le.startX),Ue=Math.abs(he.clientY-le.startY);!le.detached&&Math.max(Fe,Ue)<Bp||(le.detached||(le.detached=!0,G.current=le.tab,le.preview=vd({title:le.tab==="files"?l("shell.filesEntry"):le.tab==="git"?l("shell.gitEntry"):l("shell.terminalManagerEntry"),x:he.clientX,y:he.clientY})),(_e=le.preview)==null||_e.updatePosition(he.clientX,he.clientY))},Te=he=>{var Fe;const le=(Fe=j.current)==null?void 0:Fe.preview;he&&(le==null||le.cancel()),V.removeEventListener("pointermove",je),V.removeEventListener("pointerup",N),V.removeEventListener("pointercancel",de),V.removeEventListener("lostpointercapture",de),window.removeEventListener("blur",Ie),j.current=null,V.hasPointerCapture(te)&&V.releasePointerCapture(te)},N=async he=>{var Fe;if(he.pointerId!==te)return;const le=j.current;Te(!1),le!=null&&le.detached&&(await((Fe=le.preview)==null?void 0:Fe.complete()),await E(le.tab,le.workspaceId,le.sessionId))},de=he=>{he.pointerId===te&&Te(!0)},Ie=()=>{Te(!0)};V.addEventListener("pointermove",je),V.addEventListener("pointerup",N),V.addEventListener("pointercancel",de),V.addEventListener("lostpointercapture",de),window.addEventListener("blur",Ie)},[a,P,o,y,E]),re=f.useCallback(F=>{if(G.current===F){G.current=null;return}r(F)},[r]);return i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"workbench-auxiliary-header","data-workspace-tone":(u==null?void 0:u.tone)??"root",style:cr(u),"data-window-drag-handle":"workbench-auxiliary-header","data-tauri-drag-region":C,children:[s?i.jsx("button",{type:"button",className:"workbench-nav-toolbar-button","aria-label":l("shell.hideInfoSidebar"),title:l("shell.hideInfoSidebar"),onClick:s,children:i.jsx(Jb,{})}):null,i.jsxs("div",{className:"workbench-info-tabs",role:"tablist","aria-label":l("shell.infoTabsLabel"),"data-tauri-drag-region":C,children:[i.jsx("button",{className:t==="files"?"workbench-info-tab active":"workbench-info-tab",type:"button",role:"tab","aria-selected":t==="files",title:T?"拖拽标签到独立窗口":void 0,onPointerDown:F=>B(F,"files"),onMouseDown:L?void 0:F=>$(F,"files"),onClick:()=>re("files"),children:l("shell.filesEntry")}),i.jsx("button",{className:t==="git"?"workbench-info-tab active":"workbench-info-tab",type:"button",role:"tab","aria-selected":t==="git",title:K?"拖拽标签到独立窗口":void 0,onPointerDown:F=>B(F,"git"),onMouseDown:L?void 0:F=>$(F,"git"),onClick:()=>re("git"),children:l("shell.gitEntry")}),i.jsx("button",{className:t==="terminals"?"workbench-info-tab active":"workbench-info-tab",type:"button",role:"tab","aria-selected":t==="terminals",title:U?"拖拽标签到独立窗口":void 0,onPointerDown:F=>B(F,"terminals"),onMouseDown:L?void 0:F=>$(F,"terminals"),onClick:()=>re("terminals"),children:l("shell.terminalManagerEntry")})]})]}),i.jsxs("div",{ref:A,className:"workbench-auxiliary-body","data-scrollbar-autohide":"true",children:[e?null:i.jsx(pa,{}),e&&t==="git"&&d?i.jsx(OA,{meta:d,state:p,onRefresh:()=>h(d.workspaceId,!0),onApply:()=>m(d.workspaceId),onCleanup:()=>g(d)}):null,e&&t==="files"?a?i.jsx(f.Suspense,{fallback:i.jsx(pa,{}),children:i.jsx(ER,{sessionId:o,workspaceId:a,externalRevealRequest:n})}):i.jsx("section",{className:"workbench-empty-state minimal",children:i.jsx("p",{children:l("shell.filesPanelEmpty")})}):null,e&&t==="git"?y?i.jsx(f.Suspense,{fallback:i.jsx(pa,{}),children:i.jsx(MR,{workspaceId:y})}):i.jsx("section",{className:"workbench-empty-state minimal",children:i.jsx("p",{children:l("shell.gitPanelEmpty")})}):null,e&&t==="terminals"?i.jsx(f.Suspense,{fallback:i.jsx(pa,{}),children:i.jsx(RR,{currentWorkspaceId:a,navigationGroups:c})}):null]})]})}function OA({meta:e,state:t,onRefresh:n,onApply:r,onCleanup:s}){const[o,a]=f.useState(!1),c=(t==null?void 0:t.preview)??null,u=(t==null?void 0:t.loading)??!1,d=(t==null?void 0:t.applying)??!1,p=(t==null?void 0:t.cleaning)??!1,h=c!==null,m=(c==null?void 0:c.alreadyMerged)===!0,g=new Set((c==null?void 0:c.blockers.map(B=>B.code))??[]),y=g.size>0||!!(t!=null&&t.error),S=m&&!y,C=(c==null?void 0:c.canMerge)===!0&&!u&&!d&&!p&&!S,x=S&&!u&&!d&&!p&&!g.has("SOURCE_DIRTY")&&!g.has("HAS_ACTIVE_CHILDREN"),A=u||d||p?"loading":y?"blocked":S?"merged":c!=null&&c.canMerge?"ready":h?"blocked":"idle",j=(c==null?void 0:c.targetWorkspace.name)??l("common.unknown"),G=(c==null?void 0:c.sourceBranchName)??e.branchName,P=(c==null?void 0:c.targetBranchName)??e.baseRef??l("common.unknown"),T=FA({t:l,hasPreview:h,showMergedState:S,isMerged:m,canMerge:(c==null?void 0:c.canMerge)===!0,ahead:(c==null?void 0:c.ahead)??0,blockerCodeSet:g}),K=u?l("shell.worktreeMergePreviewLoading"):d?l("shell.worktreeMergeApplying"):p?l("shell.worktreeCleanupRunning"):S?l("shell.worktreeMergeAlreadyMerged"):c!=null&&c.canMerge?l("shell.worktreeMergeReady"):h?l("shell.worktreeMergeBlocked"):l("shell.worktreeMergePreviewIdle"),U=[l("shell.worktreeMergeCurrentBranch",{branch:G}),l("shell.worktreeMergeParentBranch",{branch:P}),l("shell.worktreeMergeTargetWorkspace",{name:j}),c?l("shell.worktreeMergeAheadBehind",{ahead:c.ahead,behind:c.behind}):l("shell.worktreeMergeAheadBehindPending"),c!=null&&c.mergeBaseCommit?l("shell.worktreeMergeBaseCommit",{commit:sA(c.mergeBaseCommit)}):null].filter(B=>!!B),L=`worktree-merge-panel-details-${e.workspaceId}`,E=o?l("shell.worktreeMergeCollapseDetails"):l("shell.worktreeMergeExpandDetails"),$=WA({t:l,loading:u,applying:d,cleaning:p,hasPreview:h,canMerge:(c==null?void 0:c.canMerge)===!0,showMergedState:S,blockerCodeSet:g});return f.useEffect(()=>{a(!1)},[e.workspaceId]),i.jsxs("section",{className:"worktree-merge-panel","data-state":A,children:[i.jsxs("button",{type:"button",className:"worktree-merge-panel-summary","aria-label":E,"aria-expanded":o,"aria-controls":L,onClick:()=>{a(B=>!B)},children:[i.jsx("span",{className:"worktree-merge-panel-summary-label",children:l("shell.worktreeMergePanelLabel")}),i.jsx("span",{className:"worktree-merge-panel-summary-main",children:i.jsx("span",{className:"worktree-merge-panel-summary-tags",children:$.map(B=>i.jsx("span",{className:"worktree-merge-panel-summary-tag","data-state":A,children:B},B))})}),i.jsx("span",{className:"worktree-merge-panel-summary-toggle",children:E})]}),o?i.jsxs("div",{id:L,className:"worktree-merge-panel-details",children:[i.jsx("div",{className:"worktree-merge-panel-detail-head",children:i.jsx("span",{className:"worktree-merge-panel-status","data-state":A,children:K})}),i.jsx("div",{className:"worktree-merge-panel-meta",children:U.map(B=>i.jsx("span",{children:B},B))}),h?i.jsx("div",{className:"worktree-merge-panel-checklist","aria-label":l("shell.worktreeMergeChecklistTitle"),children:T.map(B=>i.jsxs("div",{className:"worktree-merge-panel-checklist-item","data-state":B.state,children:[i.jsx("span",{className:"worktree-merge-panel-checklist-marker","aria-hidden":"true",children:B.state==="done"?"✓":B.state==="blocked"?"!":"·"}),i.jsxs("span",{className:"worktree-merge-panel-checklist-copy",children:[i.jsx("strong",{children:B.label}),B.detail?i.jsx("span",{children:B.detail}):null]})]},B.key))}):null,t!=null&&t.error?i.jsx("p",{className:"worktree-merge-panel-error status-text","data-tone":"error",children:t.error}):null,c!=null&&c.conflictPaths.length?i.jsxs("div",{className:"worktree-merge-panel-conflicts",children:[i.jsx("span",{className:"worktree-merge-panel-conflicts-label",children:l("shell.worktreeMergeConflictLabel")}),i.jsx("div",{className:"worktree-merge-panel-conflict-list",children:c.conflictPaths.map(B=>i.jsx("code",{children:B},B))})]}):null,i.jsxs("div",{className:"worktree-merge-panel-actions",children:[i.jsx("button",{type:"button",className:"secondary-button",disabled:u||d||p,onClick:n,children:h?l("shell.worktreeMergePreviewRefresh"):l("shell.worktreeMergePreviewAction")}),i.jsx("button",{type:"button",className:"primary-button",disabled:!C,onClick:r,children:d?l("shell.worktreeMergeApplying"):l("shell.worktreeMergeApplyAction")}),i.jsx("button",{type:"button",className:"secondary-button worktree-merge-panel-cleanup-button",disabled:!x,onClick:s,children:p?l("shell.worktreeCleanupRunning"):l("shell.worktreeCleanupAction")})]})]}):null]})}function WA(e){const{t,loading:n,applying:r,cleaning:s,hasPreview:o,canMerge:a,showMergedState:c,blockerCodeSet:u}=e;if(n)return[t("shell.worktreeMergeCompactChecking")];if(r)return[t("shell.worktreeMergeCompactMerging")];if(s)return[t("shell.worktreeMergeCompactCleaning")];const d=[];return u.has("SOURCE_NOT_ACTIVE")&&d.push(t("shell.worktreeMergeCompactInactive")),u.has("SOURCE_DIRTY")&&d.push(t("shell.worktreeMergeCompactDirty")),u.has("TARGET_DIRTY")&&d.push(t("shell.worktreeMergeCompactTargetDirty")),u.has("HAS_CONFLICTS")&&d.push(t("shell.worktreeMergeCompactConflict")),u.has("HAS_ACTIVE_CHILDREN")&&d.push(t("shell.worktreeMergeCompactChildren")),d.length>0?d:a?[t("shell.worktreeMergeCompactReady")]:c?[t("shell.worktreeMergeCompactMerged")]:o?u.has("NO_COMMITS_TO_MERGE")?[t("shell.worktreeMergeCompactNoCommits")]:[t("shell.worktreeMergeCompactBlocked")]:[t("shell.worktreeMergeCompactPending")]}function FA(e){const{t,hasPreview:n,showMergedState:r,isMerged:s,canMerge:o,ahead:a,blockerCodeSet:c}=e,u=c.has("SOURCE_NOT_ACTIVE"),d=c.has("SOURCE_DIRTY"),p=c.has("TARGET_DIRTY"),h=c.has("HAS_ACTIVE_CHILDREN"),m=c.has("HAS_CONFLICTS"),g=n&&!s&&(c.has("NO_COMMITS_TO_MERGE")||a<=0),y=r?{key:"merge-result",label:t("shell.worktreeMergeChecklistResultMerged"),detail:t("shell.worktreeMergeMergedHint"),state:"done"}:o?{key:"merge-result",label:t("shell.worktreeMergeChecklistResultReady"),detail:t("shell.worktreeMergeChecklistResultReadyDetail"),state:"done"}:n?{key:"merge-result",label:t("shell.worktreeMergeChecklistResultBlocked"),detail:t("shell.worktreeMergeChecklistResultBlockedDetail"),state:"blocked"}:{key:"merge-result",label:t("shell.worktreeMergeChecklistResultPending"),detail:null,state:"pending"};return[{key:"source-state",label:t("shell.worktreeMergeChecklistSourceState"),detail:n&&u?t("shell.worktreeMergeChecklistSourceStateBlocked"):null,state:n?u?"blocked":"done":"pending"},{key:"clean-source",label:t("shell.worktreeMergeChecklistSourceClean"),detail:n&&d?t("shell.worktreeMergeChecklistSourceCleanBlocked"):null,state:n?d?"blocked":"done":"pending"},{key:"clean-target",label:t("shell.worktreeMergeChecklistTargetClean"),detail:n&&p?t("shell.worktreeMergeChecklistTargetCleanBlocked"):null,state:n?p?"blocked":"done":"pending"},{key:"children",label:t("shell.worktreeMergeChecklistChildren"),detail:n&&h?t("shell.worktreeMergeChecklistChildrenBlocked"):null,state:n?h?"blocked":"done":"pending"},{key:"commits",label:t("shell.worktreeMergeChecklistCommits"),detail:g?t(s?"shell.worktreeMergeMergedDirtyHint":"shell.worktreeMergeChecklistCommitsBlocked"):null,state:g?s?"done":"blocked":n?"done":"pending"},{key:"conflicts",label:t("shell.worktreeMergeChecklistConflicts"),detail:m?t("shell.worktreeMergeChecklistConflictsBlocked"):null,state:m?"blocked":n?"done":"pending"},y]}function gL({shellMode:e="desktop"}){var Jn,Ti,Ii,k,M,O,Z,ne,Ae,pe,Ve,vt,gt,At,Nn,jn,Ir;const t=Ua(),n=lo(),r=kn(),{showToast:s}=Fn(),o=Do(b=>b.sessionDisplaySortMode),a=Do(b=>b.notificationPreferences.notifyOnPermissionRequest),c=Do(b=>b.notificationPreferences.notifyOnSessionCompleted),u=Do(b=>b.notificationPreferences.notifyOnSessionFailed),d=f.useRef(cM(fb)),p=f.useRef(0),h=f.useRef((((Ti=(Jn=d.current)==null?void 0:Jn.items)==null?void 0:Ti.length)??0)>0),m=f.useRef(new Map),g=f.useRef(!1),y=f.useRef(null),S=f.useRef(0),C=f.useRef(null),x=f.useRef(null),A=f.useRef(new Set),j=f.useRef(new Set),G=f.useRef(new Set),P=f.useRef(new Set),T=f.useRef(null),K=f.useRef(null),U=f.useRef(null),L=f.useRef(null),E=f.useRef(null),$=f.useRef(null),B=f.useRef(null),re=f.useRef(null),X=f.useRef(0),F=f.useRef(0),q=f.useRef(s),D=f.useRef(r.bridge),V=f.useRef(null),te=f.useRef(0),v=f.useRef(0),je=f.useRef(null),Te=f.useRef(null),N=f.useRef(null),de=f.useRef(!1),Ie=f.useRef(!1),he=f.useRef(!1),le=f.useRef(new Map),Fe=f.useRef(!1),Ue=f.useRef(new Map),_e=f.useRef(""),qe=f.useRef([]),W=f.useRef(o),Y=f.useRef(null),[se,Ce]=f.useState(()=>up(d.current,o)),ve=f.useRef(se),[fe,ht]=f.useState(()=>{var b,w;return(((w=(b=d.current)==null?void 0:b.items)==null?void 0:w.length)??0)===0}),[Ke,st]=f.useState(null),[I,z]=f.useState(()=>da(Gp(jp,ZM),Rp,Pp)),[ie,ue]=f.useState(()=>da(Gp(Tp,eR),Ap,Lp)),[we,H]=f.useState(()=>Vp(Ip,!1)),[J,ge]=f.useState(()=>Vp(Ep,!1)),[xe,De]=f.useState(null),[He,xt]=f.useState(null),[lt,Ye]=f.useState(()=>Jp(d.current)),[nt,Qe]=f.useState(()=>Kp(uc)),[rt,pt]=f.useState(!1),[$t,Ge]=f.useState("files"),[ft,Be]=f.useState(!1),[Nt,Ze]=f.useState(!1),[$n,_]=f.useState(null),[ce,Se]=f.useState({}),[ke,be]=f.useState(!1),[wt,zt]=f.useState("sessions"),[Ht,yn]=f.useState(""),[En,nn]=f.useState(""),[ir,hi]=f.useState(!1),[pi,fr]=f.useState(null),[ko,xn]=f.useState([]),[Wr,Fr]=f.useState(null),[$r,Ut]=f.useState({}),qt=Vf(r),wn=f.useCallback(b=>{if(qt)return;const w=V.current;w&&(!wc(r,b.button,b.target)||!Yp(b.clientY,w)||wx({platform:r,button:b.button,target:b.target,clientX:b.clientX,clientY:b.clientY}))},[r,qt]),yo=f.useCallback(b=>{if(qt)return;const w=V.current;w&&(!wc(r,b.button,b.target)||!Yp(b.clientY,w)||r.bridge.setWindowState("toggle-zoom"))},[r,qt]),[Dt,vn]=f.useState({}),[mt,zr]=f.useState(null),[mr,gr]=f.useState(!1),[un,bs]=f.useState([]),[Hr,Ur]=f.useState(()=>new Set),[br,zn]=f.useState(!1),[fi,ks]=f.useState(!1),[il,xo]=f.useState(0),[Hn,mi]=f.useState(()=>Kp(Mp)),Xt=e==="desktop"&&r.isDesktop&&r.ui.osFamily==="macos"&&r.ui.prefersOverlayTitlebar,{theme:kr}=Sk();f.useEffect(()=>{q.current=s},[s]),f.useEffect(()=>{if(typeof document>"u")return;const{documentElement:b,body:w}=document,R=document.getElementById("root");if(!Xt){b.removeAttribute("data-workbench-macos-vibrancy"),w==null||w.removeAttribute("data-workbench-macos-vibrancy");return}const Q=b.style.background,ee=(w==null?void 0:w.style.background)??"",ae=(R==null?void 0:R.style.background)??"";return b.setAttribute("data-workbench-macos-vibrancy","true"),w==null||w.setAttribute("data-workbench-macos-vibrancy","true"),b.style.background="transparent",w==null||w.style.setProperty("background","transparent"),R==null||R.style.setProperty("background","transparent"),()=>{b.removeAttribute("data-workbench-macos-vibrancy"),w==null||w.removeAttribute("data-workbench-macos-vibrancy"),b.style.background=Q,w&&(w.style.background=ee),R instanceof HTMLElement&&(R.style.background=ae)}},[Xt]),f.useEffect(()=>()=>{N.current!==null&&window.clearTimeout(N.current)},[]),f.useEffect(()=>{var ee;if(typeof document>"u")return;const{documentElement:b,body:w}=document;if(!He){b.removeAttribute(zs),w==null||w.removeAttribute(zs);return}const R=b.style.cursor,Q=(w==null?void 0:w.style.cursor)??"";return b.setAttribute(zs,He),w==null||w.setAttribute(zs,He),b.style.cursor="col-resize",w==null||w.style.setProperty("cursor","col-resize"),(ee=window.getSelection())==null||ee.removeAllRanges(),()=>{b.removeAttribute(zs),w==null||w.removeAttribute(zs),b.style.cursor=R,w&&(w.style.cursor=Q)}},[He]),f.useEffect(()=>{W.current=o,Ce(b=>iA(b,o))},[o]),f.useEffect(()=>{ve.current=se},[se]),f.useEffect(()=>{D.current=r.bridge},[r.bridge]),f.useEffect(()=>{te.current=I},[I]),f.useEffect(()=>{v.current=ie},[ie]),f.useEffect(()=>()=>{je.current!==null&&window.cancelAnimationFrame(je.current)},[]);const qr=f.useCallback(async()=>{const b=X.current+1;X.current=b;try{const w=await oj();if(b!==X.current)return;if(!w.initialized){bs([]),Ur(new Set);return}const[R,Q,ee,ae]=await Promise.all([aj(),uj(),dg(),pj()]);if(b!==X.current)return;bs(gR(R.overview,Q.items,ee.items)),Ur(new Set(ae.items.map(Ne=>Ne.notificationId)))}catch{if(b!==X.current)return;bs([]),Ur(new Set)}},[]),yr=f.useCallback(b=>{const w=b.map(R=>R.createdAt).sort((R,Q)=>_r(Q)-_r(R))[0]??null;w&&mi(R=>R&&_r(R)>=_r(w)?R:w)},[]);f.useEffect(()=>{Hn&&ss(Mp,Hn)},[Hn]),f.useEffect(()=>{qr();const b=window.setInterval(()=>{qr()},nR);return()=>{window.clearInterval(b)}},[qr]),f.useEffect(()=>{Wt("workbench.layout_mounted",{path:t.pathname,search:t.search})},[t.pathname,t.search]),f.useEffect(()=>{var b,w;Wt("workbench.cached_snapshot_loaded",{cached:!!d.current,workspaceCount:((b=d.current)==null?void 0:b.items.length)??0,sessionCount:((w=d.current)==null?void 0:w.items.reduce((R,Q)=>R+Q.sessions.length,0))??0})},[]);function Gr(b){var Q;if(!b||!Array.isArray(b.items))return;eA(m.current,b);const w=ZR(b,m.current);Wt("workbench.apply_snapshot",{workspaceCount:w.items.length,sessionCount:w.items.reduce((ee,ae)=>ee+ae.sessions.length,0),currentSessionId:((Q=Xi(t.pathname))==null?void 0:Q.sessionId)??null});const R=up(w,W.current);d.current=w,ra(w),ve.current=R,Ce(R),Ye(Jp(w)),st(null)}const Jt=f.useCallback(async()=>{const b=p.current+1;p.current=b,ht(w=>w||!h.current),Wt("workbench.refresh_navigation.start",{requestId:b,hasNavigationData:h.current});try{const w=await $k();if(b!==p.current){Wt("workbench.refresh_navigation.stale",{requestId:b});return}Gr(w)}catch(w){if(b!==p.current)return;st(w instanceof Error?w.message:l("shell.navigationLoadFailed")),q.current({title:w instanceof Error?w.message:l("shell.navigationLoadFailed"),tone:"error"})}finally{Wt("workbench.refresh_navigation.end",{requestId:b,success:b===p.current}),b===p.current&&ht(!1)}},[]),St=f.useCallback(b=>{Ce(w=>{const R=tA(w,b,W.current);return ve.current=R,R})},[]),Qt=f.useCallback(()=>{var b;(b=x.current)==null||b.requestRefresh()},[]),Pt=f.useCallback((b,w)=>{n(Bn(b,w))},[n]),rn=f.useCallback((b,w,R)=>{var Q;T.current={workspaceId:b,paths:w,knownRevisionByPath:R==null?void 0:R.knownRevisionByPath},(Q=x.current)==null||Q.subscribeFileTree(b,w,R)},[]),xr=f.useCallback((b,w,R)=>{var Q;K.current={workspaceId:b,paths:w,knownRevisionByPath:R==null?void 0:R.knownRevisionByPath},(Q=x.current)==null||Q.requestFileTreeRefresh(b,w,R)},[]),gi=f.useCallback(b=>(A.current.add(b),()=>{A.current.delete(b)}),[]),Vr=f.useCallback((b,w)=>{var R;U.current={workspaceId:b,knownRevision:w==null?void 0:w.knownRevision},(R=x.current)==null||R.subscribeGit(b,w)},[]),Un=f.useCallback((b,w)=>{var R;L.current={workspaceId:b,knownRevision:w==null?void 0:w.knownRevision},(R=x.current)==null||R.requestGitRefresh(b,w)},[]),ys=f.useCallback(b=>(j.current.add(b),()=>{j.current.delete(b)}),[]),wr=f.useCallback((b,w)=>{var R;E.current={workspaceId:b,knownRevision:w==null?void 0:w.knownRevision},(R=x.current)==null||R.subscribeWorkspaceManagement(b,w)},[]),qn=f.useCallback((b,w)=>{var R;$.current={workspaceId:b,knownRevision:w==null?void 0:w.knownRevision},Ut(Q=>{var ee;return{...Q,[b]:{detail:((ee=Q[b])==null?void 0:ee.detail)??null,loading:!0,error:null}}}),(R=x.current)==null||R.requestWorkspaceManagementRefresh(b,w)},[]),vr=f.useCallback(b=>(G.current.add(b),()=>{G.current.delete(b)}),[]),Sr=f.useCallback(async(b,w=!1)=>{const R=b.trim();if(!R)return;let Q=!0;if(vn(ee=>{const ae=ee[R];return!w&&(ae!=null&&ae.loading)?(Q=!1,ee):{...ee,[R]:{preview:(ae==null?void 0:ae.preview)??null,loading:!0,applying:(ae==null?void 0:ae.applying)??!1,cleaning:(ae==null?void 0:ae.cleaning)??!1,error:null}}}),!!Q)try{const ee=await zk(R);vn(ae=>{var Ne,Me;return{...ae,[R]:{preview:ee,loading:!1,applying:((Ne=ae[R])==null?void 0:Ne.applying)??!1,cleaning:((Me=ae[R])==null?void 0:Me.cleaning)??!1,error:null}}})}catch(ee){vn(ae=>{var Ne,Me,Pe;return{...ae,[R]:{preview:((Ne=ae[R])==null?void 0:Ne.preview)??null,loading:!1,applying:((Me=ae[R])==null?void 0:Me.applying)??!1,cleaning:((Pe=ae[R])==null?void 0:Pe.cleaning)??!1,error:ee instanceof Error?ee.message:l("shell.worktreeMergePreviewFailed")}}})}},[]),Gn=f.useCallback(async b=>{const w=b.trim();if(w){vn(R=>{var Q,ee;return{...R,[w]:{preview:((Q=R[w])==null?void 0:Q.preview)??null,loading:!1,applying:!0,cleaning:((ee=R[w])==null?void 0:ee.cleaning)??!1,error:null}}});try{const R=await Hk(w);vn(Q=>{var ee;return{...Q,[w]:{preview:R.preview,loading:!1,applying:!1,cleaning:((ee=Q[w])==null?void 0:ee.cleaning)??!1,error:null}}}),Qt(),Jt(),Sr(w,!0),Un(R.preview.targetWorkspace.id),q.current({title:R.applied?l("shell.worktreeMergeApplySuccess"):l("shell.worktreeMergeAlreadyMerged"),tone:"success"})}catch(R){vn(Q=>{var ee,ae;return{...Q,[w]:{preview:((ee=Q[w])==null?void 0:ee.preview)??null,loading:!1,applying:!1,cleaning:((ae=Q[w])==null?void 0:ae.cleaning)??!1,error:R instanceof Error?R.message:l("shell.worktreeMergeApplyFailed")}}}),q.current({title:R instanceof Error?R.message:l("shell.worktreeMergeApplyFailed"),tone:"error"})}}},[Sr,Jt,Un,Qt]),xs=f.useCallback(async b=>{var Q,ee;const w=b.workspaceId,R=mr&&((ee=(Q=Dt[w])==null?void 0:Q.preview)==null?void 0:ee.alreadyMerged)===!0;vn(ae=>{var Ne;return{...ae,[w]:{preview:((Ne=ae[w])==null?void 0:Ne.preview)??null,loading:!1,applying:!1,cleaning:!0,error:null}}});try{const ae=await Uk(w,{deleteBranch:R});if(vn(Ne=>{var Me;return{...Ne,[w]:{preview:((Me=Ne[w])==null?void 0:Me.preview)??null,loading:!1,applying:!1,cleaning:!1,error:null}}}),gr(!1),zr(Ne=>(Ne==null?void 0:Ne.workspaceId)===w?null:Ne),Qt(),await Jt(),n(rr(b.parentWorkspaceId),{replace:!0}),ae.branchDeleted){q.current({title:l("shell.worktreeCleanupDeleteBranchSuccess",{branch:ae.deletedBranchName||b.branchName}),tone:"success"});return}if(ae.branchDeleteRequested){q.current({title:l("shell.worktreeCleanupDeleteBranchPartialFailed",{branch:b.branchName}),description:ae.branchDeleteError||void 0,tone:"warning"});return}q.current({title:l("shell.worktreeCleanupSuccess"),tone:"success"})}catch(ae){vn(Ne=>{var Me;return{...Ne,[w]:{preview:((Me=Ne[w])==null?void 0:Me.preview)??null,loading:!1,applying:!1,cleaning:!1,error:ae instanceof Error?ae.message:l("shell.worktreeCleanupFailed")}}}),q.current({title:ae instanceof Error?ae.message:l("shell.worktreeCleanupFailed"),tone:"error"})}},[mr,n,Jt,Qt,Dt]),Kr=f.useCallback(b=>{gr(!1),zr(b)},[]),ws=f.useCallback((b,w)=>{var R;B.current={workspaceId:b,knownRevision:w==null?void 0:w.knownRevision},(R=x.current)==null||R.subscribeTerminalManager(b,w)},[]),Cr=f.useCallback((b,w)=>{var R;re.current={workspaceId:b,knownRevision:w==null?void 0:w.knownRevision},(R=x.current)==null||R.requestTerminalManagerRefresh(b,w)},[]),wo=f.useCallback(b=>(P.current.add(b),()=>{P.current.delete(b)}),[]),vo=f.useCallback((b,w)=>{Ce(R=>nA(R,b,w??new Date().toISOString()))},[]),Vn=f.useCallback(async(b,w)=>{m.current.set(b,w),Ce(R=>Zp(R,b,w));try{const R=await kf(b,w),Q=nr(R);Q===w?m.current.set(b,Q):m.current.delete(b),St(R),Qt(),Jt()}catch(R){throw m.current.delete(b),Ce(Q=>Zp(Q,b,!w)),R}},[Jt,Qt,St]),Mn=f.useCallback((b,w)=>{Wt("workbench.set_session_workspace",{sessionId:b,workspaceId:w}),Se(R=>{if(!w){if(!(b in R))return R;const Q={...R};return delete Q[b],Q}return R[b]===w?R:{...R,[b]:w}})},[]);f.useEffect(()=>{h.current=se.length>0},[se]),f.useEffect(()=>{Wt("workbench.navigation_state",{navigationLoading:fe,workspaceCount:se.length,sessionCount:se.reduce((b,w)=>b+w.sessions.length,0)})},[se,fe]),f.useEffect(()=>{C.current!==null&&window.clearTimeout(C.current),C.current=window.setTimeout(()=>{var me;C.current=null,!(g.current||h.current)&&(Wt("workbench.refresh_navigation.ws_fallback_triggered"),(me=x.current)==null||me.requestRefresh())},1200);const b=new mx({onConnectionChange:me=>{me==="connected"&&qk(),me==="reconnect_failed"&&!h.current&&(st(l("shell.navigationLoadFailed")),q.current({id:"workbench-navigation-connection",title:l("shell.navigationLoadFailed"),tone:"warning",durationMs:3600}))},onSnapshot:me=>{g.current=!0,Wt("workbench.ws_snapshot_received",{workspaceCount:me.items.length,sessionCount:me.items.reduce((et,on)=>et+on.sessions.length,0)}),C.current!==null&&(window.clearTimeout(C.current),C.current=null),Gr(me),ht(!1)},onFileTreeSnapshot:me=>{A.current.forEach(et=>et(me))},onGitSnapshot:me=>{qi(qb(me.workspaceId),{revision:me.revision??null,status:me.status,history:me.history,historyTotalCount:me.historyTotalCount,historyNextCursor:me.historyNextCursor,branches:me.branches}),Ut(et=>{var Dn;const on=((Dn=se.find(Ps=>Ps.workspace.id===me.workspaceId))==null?void 0:Dn.workspace)??null;if(!on)return et;const hn=et[me.workspaceId],Tt=Kb(Vb((hn==null?void 0:hn.detail)??Gb(on),on),me);return qi(Xc(me.workspaceId),Tt),{...et,[me.workspaceId]:{detail:Tt,loading:!1,error:null}}}),j.current.forEach(et=>et(me))},onWorkspaceManagementSnapshot:me=>{qi(Xc(me.workspaceId),me),Ut(et=>({...et,[me.workspaceId]:{detail:me,loading:!1,error:null}})),G.current.forEach(et=>et(me))},onTerminalManagerSnapshot:me=>{P.current.forEach(et=>et(me))},onUnauthorized:()=>{Ji.clear(),n("/login",{replace:!0})}});b.primeWorkbenchSnapshot(d.current),x.current=b;const w=T.current,R=K.current,Q=U.current,ee=L.current,ae=E.current,Ne=$.current,Me=B.current,Pe=re.current;return w&&b.subscribeFileTree(w.workspaceId,w.paths,{knownRevisionByPath:w.knownRevisionByPath}),Q&&b.subscribeGit(Q.workspaceId,{knownRevision:Q.knownRevision}),ae&&b.subscribeWorkspaceManagement(ae.workspaceId,{knownRevision:ae.knownRevision}),Me&&b.subscribeTerminalManager(Me.workspaceId,{knownRevision:Me.knownRevision}),R&&b.requestFileTreeRefresh(R.workspaceId,R.paths,{knownRevisionByPath:R.knownRevisionByPath}),ee&&b.requestGitRefresh(ee.workspaceId,{knownRevision:ee.knownRevision}),Ne&&b.requestWorkspaceManagementRefresh(Ne.workspaceId,{knownRevision:Ne.knownRevision}),Pe&&b.requestTerminalManagerRefresh(Pe.workspaceId,{knownRevision:Pe.knownRevision}),b.start(),()=>{C.current!==null&&(window.clearTimeout(C.current),C.current=null),x.current===b&&(x.current=null),b.close()}},[n]),f.useEffect(()=>{ss(jp,String(I))},[I]),f.useEffect(()=>{ss(Tp,String(ie))},[ie]),f.useEffect(()=>{ss(Ip,String(we))},[we]),f.useEffect(()=>{ss(Ep,String(J))},[J]),f.useEffect(()=>{if(!nt){UR(uc);return}ss(uc,nt)},[nt]),f.useEffect(()=>{if(rt||J)return;const b=window.setTimeout(()=>{pt(!0)},tR);return()=>{window.clearTimeout(b)}},[rt,J]);const Nr=Xi(t.pathname),$e=(Nr==null?void 0:Nr.sessionId)??null,ct=$e?ek($e):!1,ut=f.useMemo(()=>Ry(se),[se]),it=f.useMemo(()=>jb(ut,o),[ut,o]),or=f.useMemo(()=>KR(se),[se]),Kn=f.useMemo(()=>new Set(lt),[lt]),Zt=f.useMemo(()=>ut.filter(b=>b.session.isFavorite===!0).map(b=>b.session.sessionId),[ut]),Rn=f.useMemo(()=>new Set(Zt),[Zt]),Gt=f.useCallback(b=>{const w=pc(b,lt);d.current=w,ra(w),ve.current=b,Ce(b)},[lt]),An=f.useCallback(b=>{const w=!Kn.has(b),R=tf(lt,b,w),Q=pc(se,R);d.current=Q,ra(Q),Ye(R),yf(b,{collapsed:w}).catch(ee=>{const ae=tf(R,b,!w),Ne=pc(se,ae);d.current=Ne,ra(Ne),Ye(ae),q.current({title:ee instanceof Error?ee.message:l("shell.workspaceCollapseStateSaveFailed"),tone:"error"})})},[Kn,lt,se]),vs=f.useCallback(()=>{Y.current={originalGroups:ve.current}},[]),Ss=f.useCallback((b,w,R)=>{const Q=ve.current,ee=QR(Q,b,w,R);ee!==Q&&Gt(ee)},[Gt]),bi=f.useCallback(()=>{const b=Y.current;Y.current=null;const w=ve.current;b&&(b.originalGroups.length===w.length&&b.originalGroups.every((R,Q)=>{var ee;return R.workspace.id===((ee=w[Q])==null?void 0:ee.workspace.id)})||Gk({workspaceIds:w.map(R=>R.workspace.id)}).catch(R=>{Gt(b.originalGroups),q.current({title:R instanceof Error?R.message:l("shell.workspaceReorderFailed"),tone:"error"})}))},[Gt]);f.useEffect(()=>{const b=new Map;if(ut.forEach(({session:w})=>{b.set(w.sessionId,{activityState:w.activityState,completedAt:w.completedAt??null,runningState:w.runningState??null})}),!he.current){he.current=!0,le.current=b;return}ut.forEach(({session:w})=>{var Ne;if(w.sessionId===$e)return;const R=le.current.get(w.sessionId);if(!R)return;const Q=R.activityState!=="completed_unread"&&w.activityState==="completed_unread",ee=((Ne=w.title)==null?void 0:Ne.trim())||l("common.unknown");if(c&&Q){const Me=l("conversation.backgroundCompletionToastDescription",{title:ee});q.current({id:`workbench-session-completed-${w.sessionId}-${w.completedAt??"unknown"}`,title:l("conversation.backgroundCompletionToastTitle"),description:Me,tone:"success",durationMs:8e3,action:{label:l("shell.contextOpenSession"),onClick:()=>Pt(w.workspaceId,w.sessionId)}}),D.current.showNotification(l("conversation.backgroundCompletionToastTitle"),Me)}const ae=R.runningState!=="failed"&&(w.runningState??null)==="failed";if(u&&ae){const Me=mR(w)??l("conversation.runtimeFailed"),Pe=l("conversation.backgroundFailureToastDescription",{title:ee,detail:Me});q.current({id:`workbench-session-failed-${w.sessionId}-${w.updatedAt}`,title:l("conversation.backgroundFailureToastTitle"),description:Pe,tone:"error",durationMs:8e3,action:{label:l("shell.contextOpenSession"),onClick:()=>Pt(w.workspaceId,w.sessionId)}}),D.current.showNotification(l("conversation.backgroundFailureToastTitle"),Pe)}}),le.current=b},[$e,ut,c,u,Pt]),f.useEffect(()=>{qe.current=ut.map(b=>b.session).filter(b=>b.sessionId!==$e&&pR(b)).map(b=>{var w;return{sessionId:b.sessionId,workspaceId:b.workspaceId,title:((w=b.title)==null?void 0:w.trim())||l("common.unknown")}})},[$e,ut]),f.useEffect(()=>{let b=!1,w=null;const R=()=>{w=window.setTimeout(()=>{Q().finally(()=>{b||R()})},sR)},Q=async()=>{var Pe;const ee=qe.current;if(ee.length===0){Fe.current||(Fe.current=!0),_e.current="";return}const ae=new Set(ee.map(me=>me.sessionId)),Ne=await Promise.all(ee.map(async me=>{try{const et=await Kk(me.sessionId);return{session:me,items:et.items}}catch{return{session:me,items:null}}}));if(b)return;for(const me of Ne){if(!me.items)continue;const et=me.items.filter(Tt=>Tt.status==="pending"),on=new Set(et.map(Tt=>Tt.id)),hn=Ue.current.get(me.session.sessionId)??new Set;Fe.current&&et.forEach(Tt=>{if(hn.has(Tt.id)||!a)return;const Dn=l("conversation.backgroundPermissionToastDescription",{title:me.session.title,requestTitle:Tt.title});q.current({id:`workbench-permission-request-${Tt.id}`,title:l("conversation.permissionRequestToastTitle"),description:Dn,tone:"warning",durationMs:8e3,action:{label:l("shell.contextOpenSession"),onClick:()=>Pt(me.session.workspaceId,me.session.sessionId)}}),D.current.showNotification(l("conversation.permissionRequestToastTitle"),Dn)}),Ue.current.set(me.session.sessionId,on)}for(const[me,et]of Ue.current.entries())!ae.has(me)&&et.size===0&&Ue.current.delete(me);const Me=fR(Ue.current,ae);Fe.current&&Me!==_e.current&&((Pe=x.current)==null||Pe.requestRefresh()),_e.current=Me,Fe.current=!0};return Q().finally(()=>{b||R()}),()=>{b=!0,w!==null&&window.clearTimeout(w)}},[a,Pt]),f.useEffect(()=>{fe&&se.length===0||(Ye(b=>$b(b,or)),Qe(b=>b&&or.has(b)?b:null))},[or,fe]);const Bt=ut.find(b=>b.session.sessionId===$e)??null,Mt=(Bt==null?void 0:Bt.workspace.id)??($e?ce[$e]??null:null),Pn=Fp(t.pathname,t.search),Cs=Pn&&or.has(Pn)?Pn:null,ki=nt&&or.has(nt)?nt:null,yi=Mt??Cs??ki??null,Re=yi??((Ii=se[0])==null?void 0:Ii.workspace.id)??null,Yn=f.useCallback(b=>{if(b){const w=ut.find(R=>R.workspace.id===b)??null;if(w)return w}return ut[0]??null},[ut]),Yr=f.useCallback(b=>{const w=typeof window>"u"?null:window.localStorage.getItem(aa);if(!w)return null;const R=w.split("?")[0]??w,Q=Xi(R);if(!Q)return window.localStorage.removeItem(aa),null;const ee=Q.sessionId,ae=ut.find(Me=>Me.session.sessionId===ee)??null,Ne=Q.workspaceId??(ae==null?void 0:ae.workspace.id)??null;return ae&&(!b||Ne===b)?Bn(ae.workspace.id,ae.session.sessionId):(window.localStorage.removeItem(aa),null)},[ut]),sn=f.useMemo(()=>un.filter(b=>!Hr.has(b.id)),[Hr,un]),jr=f.useMemo(()=>sn.filter(b=>vR(b,Hn)).length,[sn,Hn]);f.useEffect(()=>{br&&yr(sn)},[sn,yr,br]);const ol=f.useCallback(b=>{zn(!1),b.routePath&&n(b.routePath)},[n]),Xr=f.useCallback(async(b,w)=>{const R=F.current+1;F.current=R;try{const Q=await fj(b,w);if(R!==F.current)return;Ur(ee=>{const ae=new Set(ee);return Q.item?ae.add(Q.item.notificationId):ae.delete(b),ae})}catch(Q){if(R!==F.current)return;q.current({title:l("shell.globalNotificationsArchiveFailed"),description:Q instanceof Error?Q.message:void 0,tone:"error"})}},[]);f.useEffect(()=>{Mt&&Qe(b=>b===Mt?b:Mt)},[Mt]),f.useEffect(()=>{var ae;if(fe)return;const b=((ae=se[0])==null?void 0:ae.workspace.id)??null,w=Cs??b??ki,R=$e&&!ct?Yn(w):null,Q=$e&&!ct?Yr(w):null,ee=R?Bn(R.workspace.id,R.session.sessionId):null;if(Pn&&!Cs){n(Q??ee??(b?TR(t.pathname,b):hc(e)),{replace:!0});return}if($e&&!ct&&!Mt){n(Q??ee??(b?ii(b):hc(e)),{replace:!0});return}},[$e,Yn,ct,t.pathname,n,se,fe,Yr,Pn,Mt,e,ki,Cs]),f.useEffect(()=>{Wt("workbench.current_workspace_resolved",{currentSessionId:$e,sessionWorkspaceId:Mt,routeWorkspaceId:Pn,currentWorkspaceId:Re,source:Mt?Bt?"navigation":"sessionWorkspaceMap":Pn?"route":nt?"workspaceSelection":"navigationFallback"})},[Bt,$e,Re,Pn,nt,Mt]);const dn=ya(t.pathname)?"terminals":xa(t.pathname)?"butler":"conversation",jt=e==="mobile",Jr=hc(e),xi=f.useMemo(()=>se.map(b=>{const w=Mb(b.sessions),R=new Set(b.sessions.map(Q=>Q.sessionId));return{workspace:b.workspace,visibleSessions:w,archivedSessions:b.sessions.filter(Q=>nr(Q)&&!bo(Q)),visibleSessionTree:Nb(w,o).filter(Q=>!Rn.has(Q.item.sessionId)&&!du(ln(Q),ee=>Rn.has(ee.sessionId))),childWorktrees:Lb(b.childWorktrees,Rn,o,R),isCollapsed:Kn.has(b.workspace.id)}}),[Kn,Rn,se,o]),Ns=f.useMemo(()=>dM(se),[se]),Qr=f.useMemo(()=>Xp(se,Re),[Re,se]),Ln=(Bt?jy(Bt.session,Bt.session.sessionIsolatedWorkspace):Re)??Re,Sn=f.useMemo(()=>Xp(se,Ln),[Ln,se]),wi=f.useMemo(()=>Re?(Qr==null?void 0:Qr.workspace)??se.map(b=>b.workspace).find(b=>b.id===Re)??null:null,[Re,Qr,se]),vi=f.useMemo(()=>Ln?(Sn==null?void 0:Sn.workspace)??se.map(b=>b.workspace).find(b=>b.id===Ln)??null:null,[Ln,Sn,se]),Tr=(Sn==null?void 0:Sn.meta)??null,ll=(Re?Ns[Re]??null:null)??(wi?$a(wi):null),_n=(Ln?Ns[Ln]??null:null)??(vi?$a(vi):ll),So=Tr?Dt[Tr.workspaceId]??null:null,js=f.useMemo(()=>{var w,R,Q;if(!$e)return null;const b=((Q=(R=(w=Bt==null?void 0:Bt.session)==null?void 0:w.parallelGroup)==null?void 0:R.groupId)==null?void 0:Q.trim())||null;return b||BR(it,$e)},[(M=(k=Bt==null?void 0:Bt.session)==null?void 0:k.parallelGroup)==null?void 0:M.groupId,$e,it]),Ot=dn==="conversation"&&!!js;f.useEffect(()=>{if(typeof window>"u"||!Ot||!js){De(null);return}const b=Iy(js);if(!b||b.sidebarCollapseDurationMs<=0){De(null);return}De(b);const w=Date.now()-b.createdAt,R=b.totalDurationMs-w;if(R<=0){De(null);return}const Q=window.setTimeout(()=>{De(null)},R);return()=>{window.clearTimeout(Q)}},[js,Ot]),f.useEffect(()=>{Wt("workbench.info_panel_state",{infoPanelReady:rt,rightCollapsed:J||Ot,currentWorkspaceId:Re,sessionWorkspaceId:Mt,currentSessionId:$e})},[$e,Re,rt,Ot,J,Mt]);const ar=f.useMemo(()=>ut.filter(b=>Rn.has(b.session.sessionId)&&!nr(b.session)&&!za(b.session)),[Rn,ut]),Si=t.pathname.startsWith("/settings")?"settings":xa(t.pathname)?"terminals":ya(t.pathname)?"butler":jR(t.pathname)?t.pathname.endsWith("/tools/processes")||t.pathname==="/tools/processes"?"butler":"sessions":NR(t.pathname)||$p(t.pathname)?"sessions":"workspaces",cl=jt&&(Si==="sessions"&&$p(t.pathname)||xa(t.pathname)),ul=Ga({isNativeMobile:r.isNativeMobile,viewportClass:r.viewportClass}),Co=co({viewportClass:r.viewportClass,activeEntry:Si,hasNavigationPanel:jt,hasAuxiliaryPanel:jt,preferCompactLayout:ul}),dl=jt&&Uf(Co),hl=jt&&qf(Co),pl=f.useMemo(()=>se.map(b=>b.workspace),[se]),fl=f.useMemo(()=>{const b=Ht.trim().toLowerCase();return b?ut.filter(w=>{const R=(w.session.title||"").toLowerCase(),Q=w.workspace.name.toLowerCase(),ee=rl(w.session.provider,"full").toLowerCase();return R.includes(b)||Q.includes(b)||ee.includes(b)}):[]},[ut,Ht]);f.useEffect(()=>{var w;const b=Re??((w=se[0])==null?void 0:w.workspace.id)??"";b&&nn(R=>R&&se.some(ee=>ee.workspace.id===R)?R:b)},[Re,se]),f.useEffect(()=>{$e&&!ct&&Mt&&ss(aa,`${t.pathname}${t.search}`)},[$e,ct,t.pathname,t.search,Mt]),f.useEffect(()=>{if($e&&ct){y.current=`${t.pathname}${t.search}`;return}$e&&!ct&&(y.current=null)},[$e,ct,t.pathname,t.search]),f.useEffect(()=>{jt||(Be(!1),Ze(!1))},[jt]),f.useEffect(()=>{!jt||fe||!CR(t.pathname)||yi||(Be(!1),Ze(!1),n(Jr,{replace:!0}))},[yi,jt,t.pathname,n,fe,Jr]);function ml(){if(jt){Be(!0);return}H(!1)}function Ts(){if(!Ot){if(lr(),jt){Ze(!0);return}ge(!1)}}function gl(){if(jt){Be(b=>!b);return}H(b=>!b)}function No(){if(!Ot){if(lr(),jt){Ze(b=>!b);return}ge(b=>!b)}}function lr(){pt(!0)}function Is(b){if(Qe(b),lr(),ya(t.pathname)){const w=as(b);t.pathname!==w&&n(w);return}$e&&Mt!==b&&n(Jr)}const Zr=f.useCallback(async b=>{var Q;const w=((Q=ut.find(ee=>ee.session.sessionId===b))==null?void 0:Q.session)??null,R=(w==null?void 0:w.isFavorite)!==!0;Ce(ee=>ef(ee,b,R));try{const ee=await Vk(b,R);St(ee),Qt()}catch(ee){throw Ce(ae=>ef(ae,b,!R)),ee}},[ut,Qt,St]),jo=f.useCallback((b,w)=>{Sb(b,w).then(()=>{n(Wf(b,w))}).catch(R=>{s({title:R instanceof Error?R.message:l("shell.startSessionFailed"),tone:"error"})})},[n,s]),To=f.useCallback(b=>{var Q;const w=((Q=b.workspaceId)==null?void 0:Q.trim())||Re,R=IR(b.filePath);return!w||!R?!1:(lr(),Ge("files"),jt?(Be(!1),Ze(!0)):ge(!1),Fr({requestId:S.current+1,workspaceId:w,filePath:R,openViewer:b.openViewer===!0}),S.current+=1,!0)},[Re,jt]),Ci=f.useCallback(async(b,w)=>{const R=await xf(b,w.trim());return St(R),R},[St]);function Es(b){be(!0)}function Ni(){be(!1),zt("sessions"),yn(""),fr(null),xn([]),hi(!1)}async function Io(){const b=Ht.trim();if(!b||!En.trim()){xn([]),fr(null);return}hi(!0),fr(null);try{const w=await my(En,b);xn(w.items)}catch(w){xn([]),fr(w instanceof Error?w.message:l("shell.searchCodeFailed"))}finally{hi(!1)}}function es(b,w){const R=V.current;R&&(R.style.setProperty("--workbench-left-width",`${b}px`),R.style.setProperty("--workbench-left-current-width",we?"0px":`${b}px`),R.style.setProperty("--workbench-right-width",`${w}px`),R.style.setProperty("--workbench-right-current-width",J?"0px":`${w}px`))}function bl(b={}){return{leftWidth:b.leftWidth??(we?0:te.current),rightWidth:b.rightWidth??(Cn&&!J?v.current:0),leftCollapsed:b.leftCollapsed??we,rightCollapsed:b.rightCollapsed??(!Cn||J),prefersDarkAppearance:b.prefersDarkAppearance??kr!=="light",isResizing:b.isResizing??He!==null}}function Eo(b,w){var Me;w.preventDefault(),w.stopPropagation(),(Me=window.getSelection())==null||Me.removeAllRanges();const R=w.clientX,Q=b==="left"?I:ie;xt(b);const ee=()=>{const Pe=Te.current;if(Te.current=null,Pe!==null){if(b==="left"){te.current=Pe,z(me=>me===Pe?me:Pe),es(Pe,v.current);return}v.current=Pe,ue(me=>me===Pe?me:Pe),es(te.current,Pe)}};function ae(Pe){var hn;Pe.preventDefault(),(hn=window.getSelection())==null||hn.removeAllRanges();const me=Pe.clientX-R,et=b==="left"?da(Q+me,Rp,Pp):da(Q-me,Ap,Lp),on=b==="left"?te.current:v.current;et===on&&Te.current===null||(Te.current=et,je.current===null&&(je.current=window.requestAnimationFrame(()=>{je.current=null,ee()})))}function Ne(){document.removeEventListener("mousemove",ae),document.removeEventListener("mouseup",Ne),je.current!==null&&(window.cancelAnimationFrame(je.current),je.current=null),ee(),xt(me=>me===b?null:me);const Pe=bl({isResizing:!1});Po.current=Pe,r.bridge.syncNativeSidebarLayout(Pe)}document.addEventListener("mousemove",ae,{passive:!1}),document.addEventListener("mouseup",Ne)}function Ms(){if(Mo())return;if(ut.length===0){n(Jr);return}const b=Bn(ut[0].workspace.id,ut[0].session.sessionId);n(b)}function kl(){if(!Mo(Re)){if(Re){n(ii(Re));return}n(Jr)}}function Mo(b){if($e&&Mt)return b&&Mt&&Mt!==b?!1:(n(`${t.pathname}${t.search}`),!0);if(y.current){if(b){const[R,Q=""]=y.current.split("?"),ee=Fp(R??y.current,Q?`?${Q}`:"");if(ee&&ee!==b)return!1}return n(y.current),!0}const w=Yr(b);return w?(n(w),!0):!1}f.useEffect(()=>{if(typeof window>"u")return;function b(w){if(!(w.metaKey||w.ctrlKey)){w.key==="Escape"&&(Be(!1),Ze(!1));return}if(GR(w.target))return;const Q=w.key.toLowerCase();if(!w.shiftKey&&Q==="b"){w.preventDefault(),gl();return}if(w.shiftKey&&Q==="i"){w.preventDefault(),No();return}if(!w.shiftKey&&Q===","){w.preventDefault(),n("/settings");return}if(!w.shiftKey&&Q==="1"){w.preventDefault(),Ms();return}if(!w.shiftKey&&Q==="2"){w.preventDefault(),n(Re?as(Re):en());return}if(!w.shiftKey&&Q==="k"){w.preventDefault(),VR();return}w.shiftKey&&Q==="r"&&(w.preventDefault(),Jt())}return window.addEventListener("keydown",b),()=>{window.removeEventListener("keydown",b)}},[n,Jt,jt,Ms]);const yl=f.useMemo(()=>({shellMode:e,navigationGroups:se,navigationLoading:fe,navigationError:Ke,currentWorkspaceId:Re,currentSessionId:$e,favoriteSessionIds:Zt,favoriteSessions:ar,globalNotifications:un,archivedNotificationIds:Array.from(Hr),showArchivedNotifications:fi,unreadNotificationCount:jr,refreshNavigation:Jt,requestNavigationRefresh:Qt,openNotificationPanel:()=>{zn(!0)},closeNotificationPanel:()=>{zn(!1)},setShowArchivedNotifications:ks,archiveNotification:b=>{Xr(b,!0)},unarchiveNotification:b=>{Xr(b,!1)},setAuxiliaryPanel:_,subscribeFileTree:rn,requestFileTreeRefresh:xr,addFileTreeSnapshotListener:gi,subscribeGitSnapshot:Vr,requestGitRefresh:Un,addGitSnapshotListener:ys,subscribeWorkspaceManagementSnapshot:wr,requestWorkspaceManagementRefresh:qn,addWorkspaceManagementSnapshotListener:vr,workspaceManagementStateById:$r,subscribeTerminalManagerSnapshot:ws,requestTerminalManagerRefresh:Cr,addTerminalManagerSnapshotListener:wo,selectWorkspace:Is,toggleFavoriteSession:Zr,archiveSession:b=>Vn(b,!0),unarchiveSession:b=>Vn(b,!1),renameSession:Ci,startDraftSession:jo,markNavigationSessionSeen:vo,upsertNavigationSession:St,setSessionWorkspace:Mn,revealWorkspaceFile:To}),[gi,ys,vr,wo,Vn,$e,Re,un,Zt,ar,Is,Hr,vo,Ke,se,fe,jr,xr,Un,qn,Jt,Qt,ks,_,Cr,Ci,fi,$r,e,jo,Mn,rn,Vr,wr,ws,Xr,Zr,St,To]),xl={"--workbench-left-width":`${I}px`,"--workbench-left-current-width":we?"0px":`${I}px`,"--workbench-right-width":`${ie}px`,"--workbench-right-current-width":J||Ot?"0px":`${ie}px`,"--workbench-right-sidebar-duration":xe&&!J?`${xe.sidebarCollapseDurationMs}ms`:void 0,"--workbench-right-sidebar-content-duration":xe&&!J?`${Math.max(320,xe.sidebarCollapseDurationMs-120)}ms`:void 0},Ro=dn==="butler"?$n:i.jsx(af,{panelReady:rt,activeTab:$t,fileRevealRequest:Wr,onTabChange:b=>{lr(),Ge(b)},currentSessionId:ct?null:$e,activeWorkspaceId:Ln,navigationGroups:se,workspaceContext:_n,worktreeMeta:Tr,worktreeMergeState:So,onRefreshWorktreeMergePreview:Sr,onApplyWorktreeMerge:Gn,onCleanupWorktree:xs}),Cn=Ro!==null,Xn=J||Ot,Rs=Ot&&xe!==null&&!J,As=r.isDesktop&&r.ui.osFamily==="macos"&&r.ui.prefersOverlayTitlebar;f.useEffect(()=>{if(typeof window>"u"||typeof document>"u")return;const{documentElement:b,body:w}=document,R=()=>{N.current!==null&&(window.clearTimeout(N.current),N.current=null);const ee=de.current;de.current=!1,b.removeAttribute(ca),w==null||w.removeAttribute(ca),ee&&Ie.current&&(Ie.current=!1,xo(ae=>ae+1))};if(!As){R();return}const Q=()=>{de.current=!0,b.setAttribute(ca,"true"),w==null||w.setAttribute(ca,"true"),N.current!==null&&window.clearTimeout(N.current),N.current=window.setTimeout(()=>{R()},oR)};return window.addEventListener("resize",Q),()=>{window.removeEventListener("resize",Q),R()}},[As]);const ts=f.useMemo(()=>({leftWidth:we?0:I,rightWidth:Cn&&!Xn?ie:0,leftCollapsed:we,rightCollapsed:!Cn||Xn,prefersDarkAppearance:kr!=="light",isResizing:He!==null}),[He,Xn,we,I,ie,Cn,kr]),wl=f.useDeferredValue(ts),Ao=He===null?wl:ts,Po=f.useRef(ts);f.useEffect(()=>{Po.current=ts},[ts]),f.useEffect(()=>{if(typeof window>"u")return;let b=null;const w=()=>{b=null,r.bridge.syncNativeSidebarLayout(Ao)},R=()=>{b!==null&&window.cancelAnimationFrame(b),b=window.requestAnimationFrame(w)};return Xt?(R(),()=>{b!==null&&window.cancelAnimationFrame(b)}):(r.bridge.syncNativeSidebarLayout({leftWidth:0,rightWidth:0,leftCollapsed:!0,rightCollapsed:!0,prefersDarkAppearance:!1,isResizing:!1}),()=>{b!==null&&window.cancelAnimationFrame(b)})},[Ao,r.bridge,Xt]),f.useLayoutEffect(()=>{const b=V.current;if(!b||!As||typeof window>"u"){Op(b);return}let w=null,R=null;const Q=new Set([b]),ee=()=>{Ie.current=!1;const Ne=window.getComputedStyle(b),Me=vb(Ne,"--desktop-macos-traffic-light-center-y");if(Me===null){Op(b);return}const Pe={navToolbar:Ar(b,kt.navToolbar.selector),infoTabs:Ar(b,kt.infoTabs.selector),auxiliaryToolbarButton:Ar(b,kt.auxiliaryToolbarButton.selector),conversationHeaderMain:Ar(b,kt.conversationHeaderMain.selector),conversationHeaderActions:Ar(b,kt.conversationHeaderActions.selector),terminalTabbarMain:Ar(b,kt.terminalTabbarMain.selector),collapsedLeftControls:Ar(b,kt.collapsedLeftControls.selector),collapsedRightControls:Ar(b,kt.collapsedRightControls.selector)},me=[Pe.infoTabs,Pe.conversationHeaderMain,Pe.conversationHeaderActions,Pe.terminalTabbarMain].filter(Tt=>Tt!==null),et=[Pe.collapsedLeftControls,Pe.collapsedRightControls].filter(Tt=>Tt!==null),on=et.length>0?Zn(Ne,"--workbench-collapsed-controls-live-shift-y",Me,et.reduce((Tt,Dn)=>Tt+Dn,0)/et.length):null,hn=me.length>0?Zn(Ne,"--workbench-titlebar-live-content-shift-y",Me,me.reduce((Tt,Dn)=>Tt+Dn,0)/me.length):null;Qn(b,"--workbench-titlebar-live-content-shift-y",hn),Qn(b,"--workbench-collapsed-controls-live-shift-y",on),Qn(b,kt.navToolbar.variableName,Zn(Ne,kt.navToolbar.variableName,Me,Pe.navToolbar)),Qn(b,kt.infoTabs.variableName,Zn(Ne,kt.infoTabs.variableName,Me,Pe.infoTabs)),Qn(b,kt.auxiliaryToolbarButton.variableName,Zn(Ne,kt.auxiliaryToolbarButton.variableName,Me,Pe.auxiliaryToolbarButton)),Qn(b,kt.conversationHeaderMain.variableName,Zn(Ne,kt.conversationHeaderMain.variableName,Me,Pe.conversationHeaderMain)),Qn(b,kt.conversationHeaderActions.variableName,Zn(Ne,kt.conversationHeaderActions.variableName,Me,Pe.conversationHeaderActions)),Qn(b,kt.terminalTabbarMain.variableName,Zn(Ne,kt.terminalTabbarMain.variableName,Me,Pe.terminalTabbarMain)),Qn(b,kt.collapsedLeftControls.variableName,Zn(Ne,kt.collapsedLeftControls.variableName,Me,Pe.collapsedLeftControls)),Qn(b,kt.collapsedRightControls.variableName,Zn(Ne,kt.collapsedRightControls.variableName,Me,Pe.collapsedRightControls))},ae=()=>{if(de.current){Ie.current=!0;return}w!==null&&window.cancelAnimationFrame(w),w=window.requestAnimationFrame(()=>{w=null,ee()})};if(ae(),typeof ResizeObserver<"u"){R=new ResizeObserver(()=>{ae()});for(const Ne of Object.values(kt))for(const Me of b.querySelectorAll(Ne.selector))Q.add(Me);for(const Ne of Q)R.observe(Ne)}return window.addEventListener("resize",ae),()=>{w!==null&&window.cancelAnimationFrame(w),window.removeEventListener("resize",ae),R==null||R.disconnect()}},[dn,rt,we,t.pathname,t.search,J,Cn,As,il]);const ji=jt?i.jsx(of,{workspaceGroups:xi,workspaceVisualContextMap:Ns,sessionDisplaySortMode:o,favoriteSessions:ar,favoriteSessionIds:Rn,activeWorkspaceId:Re,isConversationActive:dn==="conversation",isTerminalActive:dn==="terminals",isButlerActive:dn==="butler",isSearchOpen:ke,navigationLoading:fe,navigationError:Ke,activeSessionId:$e,onRefreshNavigation:Jt,onSessionUpdated:St,onNavigateConversation:Ms,onNavigateTerminals:()=>{Be(!1),n(Re?as(Re):en())},onNavigateButler:()=>{Be(!1),n(Re?ds(Re):en())},onOpenSearch:()=>{Be(!1),Es()},onOpenSettings:()=>{Be(!1),n("/settings")},onSelectWorkspace:Is,onToggleWorkspaceCollapse:An,onStartWorkspaceReorder:vs,onPreviewWorkspaceReorder:Ss,onCommitWorkspaceReorder:bi,allowWorkspaceReorder:!1,subscribeGitSnapshot:Vr,requestGitRefresh:Un,subscribeWorkspaceManagementSnapshot:wr,requestWorkspaceManagementRefresh:qn,onToggleFavoriteSession:Zr,onArchiveSession:b=>Vn(b,!0),onUnarchiveSession:b=>Vn(b,!1),workspaceManagementStateById:$r,setWorkspaceManagementStateById:Ut,unreadNotificationCount:jr,notificationPanelOpen:br,onToggleNotificationPanel:()=>{zn(b=>!b)},onClose:()=>Be(!1)}):null,Lo=jt&&Cn?Ro:null;return i.jsxs(Cb.Provider,{value:yl,children:[jt?i.jsx(i.Fragment,{children:i.jsx(ix,{activeEntry:Si,presentation:cl?"conversation-focus":"default",navigationPanel:ji,auxiliaryPanel:Lo,onOpenNavigation:()=>{Ze(!1),Be(!0)},onOpenSearch:()=>{Be(!1),Ze(!1),Es()},onOpenAuxiliary:()=>{Cn&&(lr(),Be(!1),Ze(!0))},onNavigateWorkspaces:()=>{Be(!1),Ze(!1),n(en())},onNavigateTerminals:()=>{Be(!1),Ze(!1),n(Re?as(Re):en())},onNavigateButler:()=>{Be(!1),Ze(!1),n(Re?ds(Re):en())},onNavigateSessions:()=>{Be(!1),Ze(!1),kl()},onNavigateToolFiles:()=>{Be(!1),Ze(!1),n(Re?Df(Re):en())},onNavigateToolGit:()=>{Be(!1),Ze(!1),n(Re?Bf(Re):en())},onNavigateToolProcesses:()=>{Be(!1),Ze(!1),n(Re?Of(Re):en())},onNavigateSettings:()=>{Be(!1),Ze(!1),n("/settings")},children:i.jsx(td,{})})}):i.jsx("div",{className:"workbench-shell",ref:V,style:xl,onMouseDownCapture:wn,onDoubleClickCapture:yo,"data-nav-loading":fe,"data-left-collapsed":we,"data-right-collapsed":Xn,"data-info-ready":rt,"data-parallel-conversation-active":Ot?"true":void 0,"data-parallel-sidebar-transition":Rs?"true":void 0,"data-runtime-platform":r.platform,"data-os-family":r.ui.osFamily,"data-overlay-titlebar":r.ui.prefersOverlayTitlebar,children:i.jsxs("div",{className:"workbench-body-shell",children:[i.jsx("aside",{className:"workbench-nav surface-card","data-collapsed":we,children:i.jsx(of,{workspaceGroups:xi,workspaceVisualContextMap:Ns,sessionDisplaySortMode:o,favoriteSessions:ar,favoriteSessionIds:Rn,activeWorkspaceId:Re,isConversationActive:dn==="conversation",isTerminalActive:dn==="terminals",isButlerActive:dn==="butler",isSearchOpen:ke,navigationLoading:fe,navigationError:Ke,activeSessionId:$e,onRefreshNavigation:Jt,onSessionUpdated:St,onNavigateConversation:Ms,onNavigateTerminals:()=>n(Re?as(Re):en()),onNavigateButler:()=>n(Re?ds(Re):en()),onOpenSearch:()=>Es(),onOpenSettings:()=>n("/settings"),onSelectWorkspace:Is,onToggleWorkspaceCollapse:An,onStartWorkspaceReorder:vs,onPreviewWorkspaceReorder:Ss,onCommitWorkspaceReorder:bi,allowWorkspaceReorder:!0,subscribeGitSnapshot:Vr,requestGitRefresh:Un,subscribeWorkspaceManagementSnapshot:wr,requestWorkspaceManagementRefresh:qn,onToggleFavoriteSession:Zr,onArchiveSession:b=>Vn(b,!0),onUnarchiveSession:b=>Vn(b,!1),workspaceManagementStateById:$r,setWorkspaceManagementStateById:Ut,unreadNotificationCount:jr,notificationPanelOpen:br,onToggleNotificationPanel:()=>{zn(b=>!b)},onToggleCollapse:()=>H(!0)})}),i.jsx("div",{className:"workbench-side-resizer","data-side":"left","data-collapsed":we,role:"separator","aria-label":l("shell.leftResizerLabel"),onMouseDown:we?void 0:b=>Eo("left",b)}),i.jsxs("div",{className:"workbench-main-shell",children:[i.jsxs("div",{className:"workbench-collapsed-rail","aria-hidden":!we&&!J,children:[i.jsxs("div",{className:"workbench-collapsed-controls left","data-visible":we,children:[i.jsx(nf,{className:"workbench-nav-toolbar-button workbench-collapsed-button",ariaLabel:l("shell.showSessionSidebar"),side:"left",collapsed:!0,onClick:ml}),i.jsx(bb,{collapsed:!0}),i.jsx(Xb,{unreadCount:jr,open:br,onToggle:()=>{zn(b=>!b)},collapsed:!0})]}),Cn&&!Ot?i.jsx("div",{className:"workbench-collapsed-controls right","data-visible":J,children:i.jsx(nf,{className:"workbench-nav-toolbar-button workbench-collapsed-button",ariaLabel:l("shell.showInfoSidebar"),side:"right",collapsed:!0,onClick:Ts})}):null]}),i.jsx(td,{})]}),Cn?i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"workbench-side-resizer","data-side":"right","data-collapsed":Xn,"data-auto-hidden":Ot?"true":void 0,role:"separator","aria-label":l("shell.rightResizerLabel"),onMouseDown:Xn?void 0:b=>Eo("right",b)}),i.jsx("aside",{className:"workbench-auxiliary surface-card","data-workspace-tone":(_n==null?void 0:_n.tone)??"root","data-worktree-depth":(_n==null?void 0:_n.depth)??0,"data-collapsed":Xn,"data-auto-hidden":Ot?"true":void 0,"data-custom-panel":dn==="butler","data-parallel-transition":Rs?"true":void 0,"aria-hidden":Xn&&!Rs,style:cr(_n),children:Ot&&!Rs?null:dn==="butler"?i.jsx("div",{className:"workbench-auxiliary-custom-panel",children:$n}):i.jsx(af,{panelReady:rt,activeTab:$t,fileRevealRequest:Wr,onTabChange:b=>{lr(),Ge(b)},onToggleCollapse:()=>ge(!0),currentSessionId:ct?null:$e,activeWorkspaceId:Ln,navigationGroups:se,workspaceContext:_n,worktreeMeta:Tr,worktreeMergeState:So,onRefreshWorktreeMergePreview:Sr,onApplyWorktreeMerge:Gn,onCleanupWorktree:Kr})})]}):null]})}),i.jsx(dA,{open:br,notifications:un,archivedNotificationIds:Hr,showArchivedNotifications:fi,onClose:()=>zn(!1),onToggleShowArchivedNotifications:ks,onArchiveNotification:b=>{Xr(b,!0)},onUnarchiveNotification:b=>{Xr(b,!1)},onSelectNotification:ol,preferredWorkspaceId:Re,preferredSessionId:ct?null:$e}),i.jsx(EA,{open:ke,mode:wt,keyword:Ht,codeWorkspaceId:En,codeResults:ko,codeLoading:ir,codeError:pi,workspaceOptions:pl,sessionResults:fl,onClose:Ni,onModeChange:b=>{zt(b),fr(null),xn([])},onKeywordChange:b=>{yn(b),wt==="code"&&!b.trim()&&(xn([]),fr(null))},onCodeWorkspaceChange:b=>nn(b),onCodeSearch:()=>{Io()},onOpenSession:b=>{Ni();const w=ut.find(R=>R.session.sessionId===b)??null;n(w?Bn(w.workspace.id,b):en())}}),i.jsxs(Et,{open:mt!==null,title:l("shell.worktreeCleanupModalTitle"),description:l("shell.worktreeCleanupModalDescription"),onClose:()=>{var b;mt&&((b=Dt[mt.workspaceId])!=null&&b.cleaning)||(gr(!1),zr(null))},children:[i.jsx("p",{className:"workbench-section-empty",children:mt?l("shell.worktreeCleanupConfirm",{name:mt.displayName||mt.branchName}):""}),mt?i.jsxs("div",{className:"worktree-cleanup-modal-options",children:[i.jsxs("label",{className:"conversation-selection-checkbox worktree-cleanup-modal-option",children:[i.jsx("input",{type:"checkbox",checked:mr,disabled:!!((O=Dt[mt.workspaceId])!=null&&O.cleaning)||((ne=(Z=Dt[mt.workspaceId])==null?void 0:Z.preview)==null?void 0:ne.alreadyMerged)!==!0,onChange:b=>gr(b.target.checked)}),i.jsx("span",{children:l("shell.worktreeCleanupDeleteBranchLabel",{branch:mt.branchName})})]}),((pe=(Ae=Dt[mt.workspaceId])==null?void 0:Ae.preview)==null?void 0:pe.alreadyMerged)!==!0?i.jsx("p",{className:"conversation-selection-hint worktree-cleanup-modal-hint",children:l("shell.worktreeCleanupDeleteBranchHint")}):null]}):null,i.jsxs("div",{className:"workbench-modal-actions",children:[i.jsx("button",{type:"button",className:"secondary-button",disabled:!!(mt&&((Ve=Dt[mt.workspaceId])!=null&&Ve.cleaning)),onClick:()=>{gr(!1),zr(null)},children:l("common.cancel")}),i.jsx("button",{type:"button",className:mr&&mt&&((gt=(vt=Dt[mt.workspaceId])==null?void 0:vt.preview)==null?void 0:gt.alreadyMerged)===!0?"secondary-button workbench-danger-button":"primary-button",disabled:!mt||!!(mt&&((At=Dt[mt.workspaceId])!=null&&At.cleaning)),onClick:()=>{mt&&xs(mt)},children:mt&&((Nn=Dt[mt.workspaceId])!=null&&Nn.cleaning)?l("shell.worktreeCleanupRunning"):mr&&mt&&((Ir=(jn=Dt[mt.workspaceId])==null?void 0:jn.preview)==null?void 0:Ir.alreadyMerged)===!0?l("shell.worktreeCleanupDeleteBranchAction"):l("shell.worktreeCleanupAction")})]})]}),jt?i.jsxs(i.Fragment,{children:[dl?null:i.jsx(lf,{isOpen:ft,side:"left",onClose:()=>Be(!1),children:ji}),hl?null:i.jsx(lf,{isOpen:Nt,side:"right",onClose:()=>Ze(!1),children:Lo})]}):null]})}function lf({isOpen:e,side:t,onClose:n,children:r,className:s,overlayClassName:o}){if(!e)return null;const a=i.jsxs(i.Fragment,{children:[i.jsx("div",{className:["mobile-nav-overlay","open",o].filter(Boolean).join(" "),onClick:n,role:"button",tabIndex:0,"aria-label":l("common.back"),onKeyDown:c=>{c.key==="Escape"&&n()}}),i.jsx("div",{className:["mobile-nav-drawer",t,"open",s].filter(Boolean).join(" "),children:r})]});return typeof document>"u"?a:ur.createPortal(a,document.body)}function Zb(){return f.useContext(Cb)??{navigationGroups:[],navigationLoading:!1,navigationError:null,shellMode:"desktop",currentWorkspaceId:null,currentSessionId:null,favoriteSessionIds:[],favoriteSessions:[],globalNotifications:[],archivedNotificationIds:[],showArchivedNotifications:!1,unreadNotificationCount:0,refreshNavigation:async()=>{},requestNavigationRefresh:()=>{},openNotificationPanel:()=>{},closeNotificationPanel:()=>{},setShowArchivedNotifications:()=>{},archiveNotification:()=>{},unarchiveNotification:()=>{},setAuxiliaryPanel:()=>{},subscribeFileTree:()=>{},requestFileTreeRefresh:()=>{},addFileTreeSnapshotListener:()=>()=>{},subscribeGitSnapshot:()=>{},requestGitRefresh:()=>{},addGitSnapshotListener:()=>()=>{},subscribeWorkspaceManagementSnapshot:()=>{},requestWorkspaceManagementRefresh:()=>{},addWorkspaceManagementSnapshotListener:()=>()=>{},workspaceManagementStateById:{},subscribeTerminalManagerSnapshot:()=>{},requestTerminalManagerRefresh:()=>{},addTerminalManagerSnapshotListener:()=>()=>{},selectWorkspace:()=>{},toggleFavoriteSession:async()=>{},archiveSession:async()=>{},unarchiveSession:async()=>{},renameSession:async()=>{throw new Error("workbench shell unavailable")},startDraftSession:()=>{},setSessionWorkspace:()=>{},upsertNavigationSession:()=>{},markNavigationSessionSeen:()=>{},revealWorkspaceFile:()=>!1}}function ek(e){return e.startsWith("draft-")}export{eL as $,eM as A,TM as B,Vu as C,uT as D,dT as E,Cy as F,kP as G,vy as H,aM as I,cT as J,dM as K,Ay as L,wP as M,os as N,ci as O,qs as P,ia as Q,Hi as R,BM as S,FM as T,OM as U,ka as V,mx as W,WM as X,$M as Y,DM as Z,JP as _,gL as a,YP as a$,VP as a0,KP as a1,QP as a2,GP as a3,nL as a4,lL as a5,cL as a6,Wt as a7,py as a8,Vg as a9,Ax as aA,Px as aB,CP as aC,Uu as aD,BI as aE,OI as aF,aL as aG,vP as aH,xP as aI,Ty as aJ,du as aK,XM as aL,tL as aM,en as aN,fx as aO,SP as aP,NP as aQ,jP as aR,AP as aS,PP as aT,RP as aU,EP as aV,TP as aW,UP as aX,IP as aY,WP as aZ,dj as a_,Dr as aa,dL as ab,pL as ac,uL as ad,hL as ae,yT as af,fL as ag,Vh as ah,to as ai,Xg as aj,iL as ak,Ry as al,Ny as am,$a as an,VM as ao,wy as ap,Iy as aq,gP as ar,mP as as,yP as at,jy as au,cr as av,ld as aw,bP as ax,oL as ay,Rx as az,va as b,XP as b0,HP as b1,DP as b2,BP as b3,OP as b4,FP as b5,$P as b6,zP as b7,mM as b8,MP as b9,iP as bA,cP as bB,oP as bC,pP as bD,fP as bE,hP as bF,dP as bG,eP as bH,XA as bI,z0 as bJ,tj as bK,Lf as bL,LP as ba,_P as bb,qP as bc,ZP as bd,$j as be,Jj as bf,rL as bg,wp as bh,cM as bi,pM as bj,Uc as bk,tP as bl,Ou as bm,sP as bn,rP as bo,JA as bp,my as bq,QA as br,ZA as bs,yy as bt,YA as bu,nP as bv,aP as bw,uP as bx,by,lP as bz,Bn as c,LM as d,jM as e,mL as f,DI as g,oj as h,sL as i,aj as j,dg as k,uj as l,up as m,ii as n,as as o,_f as p,ds as q,Kf as r,Of as s,rr as t,Zb as u,tM as v,qi as w,rM as x,Df as y,Bf as z};
|