@jingyi0605/codingns 0.5.0 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/public/assets/AdaptiveButlerPage-SffCV4Vb.js +3 -0
- package/dist/public/assets/App-WOLwMld_.js +30 -0
- package/dist/public/assets/{BootstrapPage-Vu5oEJ8z.js → BootstrapPage--zExdgfM.js} +1 -1
- package/dist/public/assets/{ConversationPage-Cjpg6g0J.js → ConversationPage-D9pzRmOg.js} +2 -2
- package/dist/public/assets/{DesktopDetachPreviewPage-BgeEqbc5.js → DesktopDetachPreviewPage-DvI9CIKi.js} +1 -1
- package/dist/public/assets/{DesktopWindowPage-1WelvxdH.js → DesktopWindowPage-D8FpOSLE.js} +1 -1
- package/dist/public/assets/FileContextPanel-C8T7oqRN.js +1 -0
- package/dist/public/assets/GitSidebar-Bze7DNnc.js +6 -0
- package/dist/public/assets/{MobileCreateSessionSheet-DLq5qPkx.js → MobileCreateSessionSheet-CXSKMnYn.js} +1 -1
- package/dist/public/assets/MobileSheet-Gzc14EpR.js +1 -0
- package/dist/public/assets/{MobileTopHeaderFrame-DArgZI7L.js → MobileTopHeaderFrame-BWorAJ1C.js} +1 -1
- package/dist/public/assets/{MobileWorkspaceSwitcherHeader-0ywJKfBQ.js → MobileWorkspaceSwitcherHeader-DOr4pTUq.js} +1 -1
- package/dist/public/assets/{ServerSettingsModal-izoYMx9U.js → ServerSettingsModal-BYB0GvTl.js} +1 -1
- package/dist/public/assets/{SessionIndexPage-C5aG8FIv.js → SessionIndexPage-CR3IARXX.js} +1 -1
- package/dist/public/assets/SettingsPage-B_BQtnwE.js +1 -0
- package/dist/public/assets/TerminalManagerPanel-PQ-EM64j.js +1 -0
- package/dist/public/assets/{TerminalPage-CtKXIU0h.js → TerminalPage-CvnHXBhw.js} +12 -12
- package/dist/public/assets/{TerminalRuntimeFallbackModal-CRhOQOsT.js → TerminalRuntimeFallbackModal-D7Aq186N.js} +1 -1
- package/dist/public/assets/{ToolFilesPage-DcYPsS-e.js → ToolFilesPage-Qzkc6K2I.js} +1 -1
- package/dist/public/assets/{ToolGitPage-CsPl89ty.js → ToolGitPage-BdNDN-cV.js} +1 -1
- package/dist/public/assets/{ToolProcessesPage-D0dvR8xK.js → ToolProcessesPage-EXJ9DHWI.js} +1 -1
- package/dist/public/assets/{ToolsHomePage-4fP-KRiv.js → ToolsHomePage-CjF3CWzR.js} +1 -1
- package/dist/public/assets/{WorkbenchLandingPage-kvlfyxRo.js → WorkbenchLandingPage-DZPk4SmX.js} +1 -1
- package/dist/public/assets/WorkbenchLayout-rwQib5In.js +3 -0
- package/dist/public/assets/{WorkbenchModal-Ctob14VR.js → WorkbenchModal-B09hC9b5.js} +1 -1
- package/dist/public/assets/WorkbenchShellRoute-Cerk5uK7.js +1 -0
- package/dist/public/assets/WorkbenchShellRoute-DsW4mBTX.css +1 -0
- package/dist/public/assets/{WorkspaceDebugDetailPage-Com5kEXJ.js → WorkspaceDebugDetailPage-Bcq8s-Ma.js} +1 -1
- package/dist/public/assets/WorkspaceDetailPage-DNAa8pKr.js +1 -0
- package/dist/public/assets/WorkspaceHomePage-BoiLuACV.js +1 -0
- package/dist/public/assets/client-runtime-manager-CRQ-F5d2.js +1 -0
- package/dist/public/assets/{default-session-permission-mode-CcGwR4Kk.js → default-session-permission-mode-D0wZ9Jek.js} +1 -1
- package/dist/public/assets/{file-tree-icon-UFVoVzhM.js → file-tree-icon-Dp_xhVfD.js} +14 -14
- package/dist/public/assets/index-C2G8Gmf1.js +42 -0
- package/dist/public/assets/{index-_52jxu4a.css → index-CpPTUeA3.css} +1 -1
- package/dist/public/assets/{preferences-service-KIYeE2gk.js → preferences-service-gOt2ZjKZ.js} +1 -1
- package/dist/public/assets/{session-runtime-machine-0KNSSPp5.js → session-runtime-machine-Dq3pW-UF.js} +8 -8
- package/dist/public/assets/{terminal-runtime-meta-AWXJpN4r.js → terminal-runtime-meta-BMT-rSEe.js} +1 -1
- package/dist/public/assets/{useRegisteredDebugTemplates-DBDRdptr.js → useRegisteredDebugTemplates-zMcEOGca.js} +1 -1
- package/dist/public/index.html +2 -2
- package/dist/server/modules/client/client-controller.js +1 -1
- package/dist/server/modules/client/client-controller.js.map +1 -1
- package/dist/server/modules/client/client-service.d.ts +16 -2
- package/dist/server/modules/client/client-service.js +21 -3
- package/dist/server/modules/client/client-service.js.map +1 -1
- package/dist/server/modules/relay-tunnel/relay-tunnel-service.d.ts +2 -1
- package/dist/server/modules/relay-tunnel/relay-tunnel-service.js +203 -8
- package/dist/server/modules/relay-tunnel/relay-tunnel-service.js.map +1 -1
- package/dist/server/modules/workbench/snapshot-revision.d.ts +4 -0
- package/dist/server/modules/workbench/snapshot-revision.js +13 -0
- package/dist/server/modules/workbench/snapshot-revision.js.map +1 -0
- package/dist/server/modules/workbench/workbench-service.d.ts +1 -0
- package/dist/server/modules/workbench/workbench-service.js +3 -2
- package/dist/server/modules/workbench/workbench-service.js.map +1 -1
- package/dist/server/modules/workbench/workspace-panel-snapshot-service.d.ts +6 -1
- package/dist/server/modules/workbench/workspace-panel-snapshot-service.js +10 -8
- package/dist/server/modules/workbench/workspace-panel-snapshot-service.js.map +1 -1
- package/dist/server/server/create-server.js +1 -1
- package/dist/server/server/create-server.js.map +1 -1
- package/dist/server/types/domain.d.ts +9 -0
- package/dist/server/ws/workbench-ws-hub.js +135 -33
- package/dist/server/ws/workbench-ws-hub.js.map +1 -1
- package/package.json +1 -1
- package/dist/public/assets/AdaptiveButlerPage-R-XZw7pd.js +0 -3
- package/dist/public/assets/App-DkvE5EyM.js +0 -30
- package/dist/public/assets/FileContextPanel-D_ghXJuW.js +0 -1
- package/dist/public/assets/GitSidebar-D9f9Jxwr.js +0 -6
- package/dist/public/assets/MobileSheet-DLg-gX1t.js +0 -1
- package/dist/public/assets/SettingsPage-HJIC-P-4.js +0 -1
- package/dist/public/assets/TerminalManagerPanel-DpyUTo9k.js +0 -1
- package/dist/public/assets/WorkbenchLayout-ByFw4eeu.js +0 -3
- package/dist/public/assets/WorkbenchShellRoute-BUITtdAg.css +0 -1
- package/dist/public/assets/WorkbenchShellRoute-Kw7JEZI3.js +0 -1
- package/dist/public/assets/WorkspaceDetailPage-D0Lrx4Uz.js +0 -1
- package/dist/public/assets/WorkspaceHomePage-wR8d3aP9.js +0 -1
- package/dist/public/assets/index-Byp9hJ0c.js +0 -42
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/window-BWqRixxq.js","assets/event-DvH9tcej.js","assets/ServerSettingsModal-izoYMx9U.js","assets/index-Byp9hJ0c.js","assets/index-_52jxu4a.css","assets/WorkbenchModal-Ctob14VR.js","assets/BootstrapPage-Vu5oEJ8z.js","assets/DesktopDetachPreviewPage-BgeEqbc5.js","assets/DesktopWindowPage-1WelvxdH.js","assets/MobileSheet-DLg-gX1t.js","assets/FileContextPanel-D_ghXJuW.js","assets/WorkbenchLayout-ByFw4eeu.js","assets/file-tree-icon-UFVoVzhM.js","assets/GitSidebar-D9f9Jxwr.js","assets/default-session-permission-mode-CcGwR4Kk.js","assets/TerminalManagerPanel-DpyUTo9k.js","assets/terminal-runtime-meta-AWXJpN4r.js","assets/TerminalRuntimeFallbackModal-CRhOQOsT.js","assets/TerminalPage-CtKXIU0h.js","assets/MobileWorkspaceSwitcherHeader-0ywJKfBQ.js","assets/MobileTopHeaderFrame-DArgZI7L.js","assets/TerminalPage-6GBZ9nXN.css","assets/WorkbenchShellRoute-Kw7JEZI3.js","assets/WorkbenchShellRoute-BUITtdAg.css","assets/WorkbenchLandingPage-kvlfyxRo.js","assets/WorkspaceHomePage-wR8d3aP9.js","assets/butler-records-events-DgWCG364.js","assets/MobileCreateSessionSheet-DLq5qPkx.js","assets/WorkspaceDetailPage-D0Lrx4Uz.js","assets/useRegisteredDebugTemplates-DBDRdptr.js","assets/WorkspaceDebugDetailPage-Com5kEXJ.js","assets/SessionIndexPage-C5aG8FIv.js","assets/styles-CSUx5LGe.js","assets/styles-BWPBZvze.css","assets/ConversationPage-Cjpg6g0J.js","assets/session-runtime-machine-0KNSSPp5.js","assets/ToolsHomePage-4fP-KRiv.js","assets/ToolFilesPage-DcYPsS-e.js","assets/ToolGitPage-CsPl89ty.js","assets/ToolProcessesPage-D0dvR8xK.js","assets/AdaptiveButlerPage-R-XZw7pd.js","assets/AdaptiveButlerPage-B153lk5H.css","assets/SettingsPage-HJIC-P-4.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
var Un=Object.defineProperty;var On=(e,t,r)=>t in e?Un(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var he=(e,t,r)=>On(e,typeof t!="symbol"?t+"":t,r);import{u as Je,j as g,t as it,a as Gt,g as An,r as kn,b as f,R as Fn,c as lt,_ as J,d as Vn,e as ce,f as Rt,h as zt,i as _t,n as Wr,k as $r,l as zn,m as St,o as Bn,p as Hn,s as Wn,q as $n,v as Kr,w as Kn,x as Yn,y as Gn,A as Jn,I as Xn}from"./index-Byp9hJ0c.js";function qn(e,t){for(var r=0;r<t.length;r++){const n=t[r];if(typeof n!="string"&&!Array.isArray(n)){for(const a in n)if(a!=="default"&&!(a in e)){const i=Object.getOwnPropertyDescriptor(n,a);i&&Object.defineProperty(e,a,i.get?i:{enumerable:!0,get:()=>n[a]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}const Qn=[{id:"zh-CN",labelKey:"locale.zhCN"},{id:"en-US",labelKey:"locale.enUS"}];function Zn({variant:e="default",className:t}){const r=Je(a=>a.profile.language);function n(a){a!==r&&Gt({language:a}).catch(()=>{})}return g.jsxs("label",{className:`language-switcher language-switcher-${e}${t?` ${t}`:""}`,children:[g.jsx("span",{className:"language-switcher-label",children:it("common.language")}),g.jsx("div",{className:"language-switcher-options",role:"group","aria-label":it("common.language"),children:Qn.map(a=>g.jsx("button",{type:"button",className:`language-switcher-option${r===a.id?" active":""}`,"aria-pressed":r===a.id,onClick:()=>n(a.id),children:it(a.labelKey)},a.id))})]})}var Yr=kn();const ea=An(Yr),ta=qn({__proto__:null,default:ea},[Yr]);/**
|
|
3
|
-
* @remix-run/router v1.23.2
|
|
4
|
-
*
|
|
5
|
-
* Copyright (c) Remix Software Inc.
|
|
6
|
-
*
|
|
7
|
-
* This source code is licensed under the MIT license found in the
|
|
8
|
-
* LICENSE.md file in the root directory of this source tree.
|
|
9
|
-
*
|
|
10
|
-
* @license MIT
|
|
11
|
-
*/function Y(){return Y=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},Y.apply(this,arguments)}var ee;(function(e){e.Pop="POP",e.Push="PUSH",e.Replace="REPLACE"})(ee||(ee={}));const vr="popstate";function ra(e){e===void 0&&(e={});function t(n,a){let{pathname:i,search:o,hash:l}=n.location;return ot("",{pathname:i,search:o,hash:l},a.state&&a.state.usr||null,a.state&&a.state.key||"default")}function r(n,a){return typeof a=="string"?a:ct(a)}return aa(t,r,null,e)}function U(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function Be(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function na(){return Math.random().toString(36).substr(2,8)}function gr(e,t){return{usr:e.state,key:e.key,idx:t}}function ot(e,t,r,n){return r===void 0&&(r=null),Y({pathname:typeof e=="string"?e:e.pathname,search:"",hash:""},typeof t=="string"?Me(t):t,{state:r,key:t&&t.key||n||na()})}function ct(e){let{pathname:t="/",search:r="",hash:n=""}=e;return r&&r!=="?"&&(t+=r.charAt(0)==="?"?r:"?"+r),n&&n!=="#"&&(t+=n.charAt(0)==="#"?n:"#"+n),t}function Me(e){let t={};if(e){let r=e.indexOf("#");r>=0&&(t.hash=e.substr(r),e=e.substr(0,r));let n=e.indexOf("?");n>=0&&(t.search=e.substr(n),e=e.substr(0,n)),e&&(t.pathname=e)}return t}function aa(e,t,r,n){n===void 0&&(n={});let{window:a=document.defaultView,v5Compat:i=!1}=n,o=a.history,l=ee.Pop,c=null,d=m();d==null&&(d=0,o.replaceState(Y({},o.state,{idx:d}),""));function m(){return(o.state||{idx:null}).idx}function p(){l=ee.Pop;let D=m(),k=D==null?null:D-d;d=D,c&&c({action:l,location:S.location,delta:k})}function b(D,k){l=ee.Push;let L=ot(S.location,D,k);d=m()+1;let K=gr(L,d),te=S.createHref(L);try{o.pushState(K,"",te)}catch($){if($ instanceof DOMException&&$.name==="DataCloneError")throw $;a.location.assign(te)}i&&c&&c({action:l,location:S.location,delta:1})}function w(D,k){l=ee.Replace;let L=ot(S.location,D,k);d=m();let K=gr(L,d),te=S.createHref(L);o.replaceState(K,"",te),i&&c&&c({action:l,location:S.location,delta:0})}function P(D){let k=a.location.origin!=="null"?a.location.origin:a.location.href,L=typeof D=="string"?D:ct(D);return L=L.replace(/ $/,"%20"),U(k,"No window.location.(origin|href) available to create URL for href: "+L),new URL(L,k)}let S={get action(){return l},get location(){return e(a,o)},listen(D){if(c)throw new Error("A history only accepts one active listener");return a.addEventListener(vr,p),c=D,()=>{a.removeEventListener(vr,p),c=null}},createHref(D){return t(a,D)},createURL:P,encodeLocation(D){let k=P(D);return{pathname:k.pathname,search:k.search,hash:k.hash}},push:b,replace:w,go(D){return o.go(D)}};return S}var B;(function(e){e.data="data",e.deferred="deferred",e.redirect="redirect",e.error="error"})(B||(B={}));const ia=new Set(["lazy","caseSensitive","path","id","index","children"]);function oa(e){return e.index===!0}function Ct(e,t,r,n){return r===void 0&&(r=[]),n===void 0&&(n={}),e.map((a,i)=>{let o=[...r,String(i)],l=typeof a.id=="string"?a.id:o.join("-");if(U(a.index!==!0||!a.children,"Cannot specify children on an index route"),U(!n[l],'Found a route id collision on id "'+l+`". Route id's must be globally unique within Data Router usages`),oa(a)){let c=Y({},a,t(a),{id:l});return n[l]=c,c}else{let c=Y({},a,t(a),{id:l,children:void 0});return n[l]=c,a.children&&(c.children=Ct(a.children,t,o,n)),c}})}function Fe(e,t,r){return r===void 0&&(r="/"),Tt(e,t,r,!1)}function Tt(e,t,r,n){let a=typeof t=="string"?Me(t):t,i=ut(a.pathname||"/",r);if(i==null)return null;let o=Gr(e);la(o);let l=null;for(let c=0;l==null&&c<o.length;++c){let d=ba(i);l=ga(o[c],d,n)}return l}function sa(e,t){let{route:r,pathname:n,params:a}=e;return{id:r.id,pathname:n,params:a,data:t[r.id],handle:r.handle}}function Gr(e,t,r,n){t===void 0&&(t=[]),r===void 0&&(r=[]),n===void 0&&(n="");let a=(i,o,l)=>{let c={relativePath:l===void 0?i.path||"":l,caseSensitive:i.caseSensitive===!0,childrenIndex:o,route:i};c.relativePath.startsWith("/")&&(U(c.relativePath.startsWith(n),'Absolute route path "'+c.relativePath+'" nested under path '+('"'+n+'" is not valid. An absolute child route path ')+"must start with the combined path of all its parent routes."),c.relativePath=c.relativePath.slice(n.length));let d=Ne([n,c.relativePath]),m=r.concat(c);i.children&&i.children.length>0&&(U(i.index!==!0,"Index routes must not have child routes. Please remove "+('all child routes from route path "'+d+'".')),Gr(i.children,t,m,d)),!(i.path==null&&!i.index)&&t.push({path:d,score:pa(d,i.index),routesMeta:m})};return e.forEach((i,o)=>{var l;if(i.path===""||!((l=i.path)!=null&&l.includes("?")))a(i,o);else for(let c of Jr(i.path))a(i,o,c)}),t}function Jr(e){let t=e.split("/");if(t.length===0)return[];let[r,...n]=t,a=r.endsWith("?"),i=r.replace(/\?$/,"");if(n.length===0)return a?[i,""]:[i];let o=Jr(n.join("/")),l=[];return l.push(...o.map(c=>c===""?i:[i,c].join("/"))),a&&l.push(...o),l.map(c=>e.startsWith("/")&&c===""?"/":c)}function la(e){e.sort((t,r)=>t.score!==r.score?r.score-t.score:va(t.routesMeta.map(n=>n.childrenIndex),r.routesMeta.map(n=>n.childrenIndex)))}const ca=/^:[\w-]+$/,ua=3,da=2,fa=1,ha=10,ma=-2,yr=e=>e==="*";function pa(e,t){let r=e.split("/"),n=r.length;return r.some(yr)&&(n+=ma),t&&(n+=da),r.filter(a=>!yr(a)).reduce((a,i)=>a+(ca.test(i)?ua:i===""?fa:ha),n)}function va(e,t){return e.length===t.length&&e.slice(0,-1).every((n,a)=>n===t[a])?e[e.length-1]-t[t.length-1]:0}function ga(e,t,r){r===void 0&&(r=!1);let{routesMeta:n}=e,a={},i="/",o=[];for(let l=0;l<n.length;++l){let c=n[l],d=l===n.length-1,m=i==="/"?t:t.slice(i.length)||"/",p=br({path:c.relativePath,caseSensitive:c.caseSensitive,end:d},m),b=c.route;if(!p&&d&&r&&!n[n.length-1].route.index&&(p=br({path:c.relativePath,caseSensitive:c.caseSensitive,end:!1},m)),!p)return null;Object.assign(a,p.params),o.push({params:a,pathname:Ne([i,p.pathname]),pathnameBase:Ea(Ne([i,p.pathnameBase])),route:b}),p.pathnameBase!=="/"&&(i=Ne([i,p.pathnameBase]))}return o}function br(e,t){typeof e=="string"&&(e={path:e,caseSensitive:!1,end:!0});let[r,n]=ya(e.path,e.caseSensitive,e.end),a=t.match(r);if(!a)return null;let i=a[0],o=i.replace(/(.)\/+$/,"$1"),l=a.slice(1);return{params:n.reduce((d,m,p)=>{let{paramName:b,isOptional:w}=m;if(b==="*"){let S=l[p]||"";o=i.slice(0,i.length-S.length).replace(/(.)\/+$/,"$1")}const P=l[p];return w&&!P?d[b]=void 0:d[b]=(P||"").replace(/%2F/g,"/"),d},{}),pathname:i,pathnameBase:o,pattern:e}}function ya(e,t,r){t===void 0&&(t=!1),r===void 0&&(r=!0),Be(e==="*"||!e.endsWith("*")||e.endsWith("/*"),'Route path "'+e+'" will be treated as if it were '+('"'+e.replace(/\*$/,"/*")+'" because the `*` character must ')+"always follow a `/` in the pattern. To get rid of this warning, "+('please change the route path to "'+e.replace(/\*$/,"/*")+'".'));let n=[],a="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(o,l,c)=>(n.push({paramName:l,isOptional:c!=null}),c?"/?([^\\/]+)?":"/([^\\/]+)"));return e.endsWith("*")?(n.push({paramName:"*"}),a+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):r?a+="\\/*$":e!==""&&e!=="/"&&(a+="(?:(?=\\/|$))"),[new RegExp(a,t?void 0:"i"),n]}function ba(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return Be(!1,'The URL path "'+e+'" could not be decoded because it is is a malformed URL segment. This is probably due to a bad percent '+("encoding ("+t+").")),e}}function ut(e,t){if(t==="/")return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let r=t.endsWith("/")?t.length-1:t.length,n=e.charAt(r);return n&&n!=="/"?null:e.slice(r)||"/"}const wa=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,xa=e=>wa.test(e);function Sa(e,t){t===void 0&&(t="/");let{pathname:r,search:n="",hash:a=""}=typeof e=="string"?Me(e):e,i;if(r)if(xa(r))i=r;else{if(r.includes("//")){let o=r;r=r.replace(/\/\/+/g,"/"),Be(!1,"Pathnames cannot have embedded double slashes - normalizing "+(o+" -> "+r))}r.startsWith("/")?i=wr(r.substring(1),"/"):i=wr(r,t)}else i=t;return{pathname:i,search:Ra(n),hash:Ta(a)}}function wr(e,t){let r=t.replace(/\/+$/,"").split("/");return e.split("/").forEach(a=>{a===".."?r.length>1&&r.pop():a!=="."&&r.push(a)}),r.length>1?r.join("/"):"/"}function At(e,t,r,n){return"Cannot include a '"+e+"' character in a manually specified "+("`to."+t+"` field ["+JSON.stringify(n)+"]. Please separate it out to the ")+("`to."+r+"` field. Alternatively you may provide the full path as ")+'a string in <Link to="..."> and the router will parse it for you.'}function Xr(e){return e.filter((t,r)=>r===0||t.route.path&&t.route.path.length>0)}function Jt(e,t){let r=Xr(e);return t?r.map((n,a)=>a===r.length-1?n.pathname:n.pathnameBase):r.map(n=>n.pathnameBase)}function Xt(e,t,r,n){n===void 0&&(n=!1);let a;typeof e=="string"?a=Me(e):(a=Y({},e),U(!a.pathname||!a.pathname.includes("?"),At("?","pathname","search",a)),U(!a.pathname||!a.pathname.includes("#"),At("#","pathname","hash",a)),U(!a.search||!a.search.includes("#"),At("#","search","hash",a)));let i=e===""||a.pathname==="",o=i?"/":a.pathname,l;if(o==null)l=r;else{let p=t.length-1;if(!n&&o.startsWith("..")){let b=o.split("/");for(;b[0]==="..";)b.shift(),p-=1;a.pathname=b.join("/")}l=p>=0?t[p]:"/"}let c=Sa(a,l),d=o&&o!=="/"&&o.endsWith("/"),m=(i||o===".")&&r.endsWith("/");return!c.pathname.endsWith("/")&&(d||m)&&(c.pathname+="/"),c}const Ne=e=>e.join("/").replace(/\/\/+/g,"/"),Ea=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),Ra=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,Ta=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e;class Dt{constructor(t,r,n,a){a===void 0&&(a=!1),this.status=t,this.statusText=r||"",this.internal=a,n instanceof Error?(this.data=n.toString(),this.error=n):this.data=n}}function st(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}const qr=["post","put","patch","delete"],Pa=new Set(qr),_a=["get",...qr],Ca=new Set(_a),Da=new Set([301,302,303,307,308]),La=new Set([307,308]),kt={state:"idle",location:void 0,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0},ja={state:"idle",data:void 0,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0},tt={state:"unblocked",proceed:void 0,reset:void 0,location:void 0},qt=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Na=e=>({hasErrorBoundary:!!e.hasErrorBoundary}),Qr="remix-router-transitions";function Ma(e){const t=e.window?e.window:typeof window<"u"?window:void 0,r=typeof t<"u"&&typeof t.document<"u"&&typeof t.document.createElement<"u",n=!r;U(e.routes.length>0,"You must provide a non-empty routes array to createRouter");let a;if(e.mapRouteProperties)a=e.mapRouteProperties;else if(e.detectErrorBoundary){let s=e.detectErrorBoundary;a=u=>({hasErrorBoundary:s(u)})}else a=Na;let i={},o=Ct(e.routes,a,void 0,i),l,c=e.basename||"/",d=e.dataStrategy||Aa,m=e.patchRoutesOnNavigation,p=Y({v7_fetcherPersist:!1,v7_normalizeFormMethod:!1,v7_partialHydration:!1,v7_prependBasename:!1,v7_relativeSplatPath:!1,v7_skipActionErrorRevalidation:!1},e.future),b=null,w=new Set,P=null,S=null,D=null,k=e.hydrationData!=null,L=Fe(o,e.history.location,c),K=!1,te=null;if(L==null&&!m){let s=le(404,{pathname:e.history.location.pathname}),{matches:u,route:h}=jr(o);L=u,te={[h.id]:s}}L&&!e.hydrationData&&yt(L,o,e.history.location.pathname).active&&(L=null);let $;if(L)if(L.some(s=>s.route.lazy))$=!1;else if(!L.some(s=>s.route.loader))$=!0;else if(p.v7_partialHydration){let s=e.hydrationData?e.hydrationData.loaderData:null,u=e.hydrationData?e.hydrationData.errors:null;if(u){let h=L.findIndex(y=>u[y.route.id]!==void 0);$=L.slice(0,h+1).every(y=>!Ht(y.route,s,u))}else $=L.every(h=>!Ht(h.route,s,u))}else $=e.hydrationData!=null;else if($=!1,L=[],p.v7_partialHydration){let s=yt(null,o,e.history.location.pathname);s.active&&s.matches&&(K=!0,L=s.matches)}let pe,v={historyAction:e.history.action,location:e.history.location,matches:L,initialized:$,navigation:kt,restoreScrollPosition:e.hydrationData!=null?!1:null,preventScrollReset:!1,revalidation:"idle",loaderData:e.hydrationData&&e.hydrationData.loaderData||{},actionData:e.hydrationData&&e.hydrationData.actionData||null,errors:e.hydrationData&&e.hydrationData.errors||te,fetchers:new Map,blockers:new Map},N=ee.Pop,F=!1,I,re=!1,G=new Map,oe=null,ne=!1,se=!1,He=[],We=new Set,Q=new Map,Te=0,Pe=-1,we=new Map,ue=new Set,_e=new Map,Ie=new Map,de=new Set,xe=new Map,ge=new Map,Ue;function mt(){if(b=e.history.listen(s=>{let{action:u,location:h,delta:y}=s;if(Ue){Ue(),Ue=void 0;return}Be(ge.size===0||y!=null,"You are trying to use a blocker on a POP navigation to a location that was not created by @remix-run/router. This will fail silently in production. This can happen if you are navigating outside the router via `window.history.pushState`/`window.location.hash` instead of using router navigation APIs. This can also happen if you are using createHashRouter and the user manually changes the URL.");let x=fr({currentLocation:v.location,nextLocation:h,historyAction:u});if(x&&y!=null){let C=new Promise(j=>{Ue=j});e.history.go(y*-1),gt(x,{state:"blocked",location:h,proceed(){gt(x,{state:"proceeding",proceed:void 0,reset:void 0,location:h}),C.then(()=>e.history.go(y))},reset(){let j=new Map(v.blockers);j.set(x,tt),H({blockers:j})}});return}return Oe(u,h)}),r){qa(t,G);let s=()=>Qa(t,G);t.addEventListener("pagehide",s),oe=()=>t.removeEventListener("pagehide",s)}return v.initialized||Oe(ee.Pop,v.location,{initialHydration:!0}),pe}function V(){b&&b(),oe&&oe(),w.clear(),I&&I.abort(),v.fetchers.forEach((s,u)=>vt(u)),v.blockers.forEach((s,u)=>dr(u))}function fe(s){return w.add(s),()=>w.delete(s)}function H(s,u){u===void 0&&(u={}),v=Y({},v,s);let h=[],y=[];p.v7_fetcherPersist&&v.fetchers.forEach((x,C)=>{x.state==="idle"&&(de.has(C)?y.push(C):h.push(C))}),de.forEach(x=>{!v.fetchers.has(x)&&!Q.has(x)&&y.push(x)}),[...w].forEach(x=>x(v,{deletedFetchers:y,viewTransitionOpts:u.viewTransitionOpts,flushSync:u.flushSync===!0})),p.v7_fetcherPersist?(h.forEach(x=>v.fetchers.delete(x)),y.forEach(x=>vt(x))):y.forEach(x=>de.delete(x))}function ye(s,u,h){var y,x;let{flushSync:C}=h===void 0?{}:h,j=v.actionData!=null&&v.navigation.formMethod!=null&&ve(v.navigation.formMethod)&&v.navigation.state==="loading"&&((y=s.state)==null?void 0:y._isRedirect)!==!0,R;u.actionData?Object.keys(u.actionData).length>0?R=u.actionData:R=null:j?R=v.actionData:R=null;let T=u.loaderData?Dr(v.loaderData,u.loaderData,u.matches||[],u.errors):v.loaderData,E=v.blockers;E.size>0&&(E=new Map(E),E.forEach((O,ie)=>E.set(ie,tt)));let _=F===!0||v.navigation.formMethod!=null&&ve(v.navigation.formMethod)&&((x=s.state)==null?void 0:x._isRedirect)!==!0;l&&(o=l,l=void 0),ne||N===ee.Pop||(N===ee.Push?e.history.push(s,s.state):N===ee.Replace&&e.history.replace(s,s.state));let M;if(N===ee.Pop){let O=G.get(v.location.pathname);O&&O.has(s.pathname)?M={currentLocation:v.location,nextLocation:s}:G.has(s.pathname)&&(M={currentLocation:s,nextLocation:v.location})}else if(re){let O=G.get(v.location.pathname);O?O.add(s.pathname):(O=new Set([s.pathname]),G.set(v.location.pathname,O)),M={currentLocation:v.location,nextLocation:s}}H(Y({},u,{actionData:R,loaderData:T,historyAction:N,location:s,initialized:!0,navigation:kt,revalidation:"idle",restoreScrollPosition:mr(s,u.matches||v.matches),preventScrollReset:_,blockers:E}),{viewTransitionOpts:M,flushSync:C===!0}),N=ee.Pop,F=!1,re=!1,ne=!1,se=!1,He=[]}async function pt(s,u){if(typeof s=="number"){e.history.go(s);return}let h=Bt(v.location,v.matches,c,p.v7_prependBasename,s,p.v7_relativeSplatPath,u==null?void 0:u.fromRouteId,u==null?void 0:u.relative),{path:y,submission:x,error:C}=xr(p.v7_normalizeFormMethod,!1,h,u),j=v.location,R=ot(v.location,y,u&&u.state);R=Y({},R,e.history.encodeLocation(R));let T=u&&u.replace!=null?u.replace:void 0,E=ee.Push;T===!0?E=ee.Replace:T===!1||x!=null&&ve(x.formMethod)&&x.formAction===v.location.pathname+v.location.search&&(E=ee.Replace);let _=u&&"preventScrollReset"in u?u.preventScrollReset===!0:void 0,M=(u&&u.flushSync)===!0,O=fr({currentLocation:j,nextLocation:R,historyAction:E});if(O){gt(O,{state:"blocked",location:R,proceed(){gt(O,{state:"proceeding",proceed:void 0,reset:void 0,location:R}),pt(s,u)},reset(){let ie=new Map(v.blockers);ie.set(O,tt),H({blockers:ie})}});return}return await Oe(E,R,{submission:x,pendingError:C,preventScrollReset:_,replace:u&&u.replace,enableViewTransition:u&&u.viewTransition,flushSync:M})}function xn(){if(Mt(),H({revalidation:"loading"}),v.navigation.state!=="submitting"){if(v.navigation.state==="idle"){Oe(v.historyAction,v.location,{startUninterruptedRevalidation:!0});return}Oe(N||v.historyAction,v.navigation.location,{overrideNavigation:v.navigation,enableViewTransition:re===!0})}}async function Oe(s,u,h){I&&I.abort(),I=null,N=s,ne=(h&&h.startUninterruptedRevalidation)===!0,jn(v.location,v.matches),F=(h&&h.preventScrollReset)===!0,re=(h&&h.enableViewTransition)===!0;let y=l||o,x=h&&h.overrideNavigation,C=h!=null&&h.initialHydration&&v.matches&&v.matches.length>0&&!K?v.matches:Fe(y,u,c),j=(h&&h.flushSync)===!0;if(C&&v.initialized&&!se&&Ha(v.location,u)&&!(h&&h.submission&&ve(h.submission.formMethod))){ye(u,{matches:C},{flushSync:j});return}let R=yt(C,y,u.pathname);if(R.active&&R.matches&&(C=R.matches),!C){let{error:W,notFoundMatches:z,route:X}=It(u.pathname);ye(u,{matches:z,loaderData:{},errors:{[X.id]:W}},{flushSync:j});return}I=new AbortController;let T=Ge(e.history,u,I.signal,h&&h.submission),E;if(h&&h.pendingError)E=[Ve(C).route.id,{type:B.error,error:h.pendingError}];else if(h&&h.submission&&ve(h.submission.formMethod)){let W=await Sn(T,u,h.submission,C,R.active,{replace:h.replace,flushSync:j});if(W.shortCircuited)return;if(W.pendingActionResult){let[z,X]=W.pendingActionResult;if(me(X)&&st(X.error)&&X.error.status===404){I=null,ye(u,{matches:W.matches,loaderData:{},errors:{[z]:X.error}});return}}C=W.matches||C,E=W.pendingActionResult,x=Ft(u,h.submission),j=!1,R.active=!1,T=Ge(e.history,T.url,T.signal)}let{shortCircuited:_,matches:M,loaderData:O,errors:ie}=await En(T,u,C,R.active,x,h&&h.submission,h&&h.fetcherSubmission,h&&h.replace,h&&h.initialHydration===!0,j,E);_||(I=null,ye(u,Y({matches:M||C},Lr(E),{loaderData:O,errors:ie})))}async function Sn(s,u,h,y,x,C){C===void 0&&(C={}),Mt();let j=Ja(u,h);if(H({navigation:j},{flushSync:C.flushSync===!0}),x){let E=await bt(y,u.pathname,s.signal);if(E.type==="aborted")return{shortCircuited:!0};if(E.type==="error"){let _=Ve(E.partialMatches).route.id;return{matches:E.partialMatches,pendingActionResult:[_,{type:B.error,error:E.error}]}}else if(E.matches)y=E.matches;else{let{notFoundMatches:_,error:M,route:O}=It(u.pathname);return{matches:_,pendingActionResult:[O.id,{type:B.error,error:M}]}}}let R,T=at(y,u);if(!T.route.action&&!T.route.lazy)R={type:B.error,error:le(405,{method:s.method,pathname:u.pathname,routeId:T.route.id})};else if(R=(await qe("action",v,s,[T],y,null))[T.route.id],s.signal.aborted)return{shortCircuited:!0};if(ze(R)){let E;return C&&C.replace!=null?E=C.replace:E=Pr(R.response.headers.get("Location"),new URL(s.url),c,e.history)===v.location.pathname+v.location.search,await Ae(s,R,!0,{submission:h,replace:E}),{shortCircuited:!0}}if(je(R))throw le(400,{type:"defer-action"});if(me(R)){let E=Ve(y,T.route.id);return(C&&C.replace)!==!0&&(N=ee.Push),{matches:y,pendingActionResult:[E.route.id,R]}}return{matches:y,pendingActionResult:[T.route.id,R]}}async function En(s,u,h,y,x,C,j,R,T,E,_){let M=x||Ft(u,C),O=C||j||Mr(M),ie=!ne&&(!p.v7_partialHydration||!T);if(y){if(ie){let q=ir(_);H(Y({navigation:M},q!==void 0?{actionData:q}:{}),{flushSync:E})}let A=await bt(h,u.pathname,s.signal);if(A.type==="aborted")return{shortCircuited:!0};if(A.type==="error"){let q=Ve(A.partialMatches).route.id;return{matches:A.partialMatches,loaderData:{},errors:{[q]:A.error}}}else if(A.matches)h=A.matches;else{let{error:q,notFoundMatches:Ke,route:et}=It(u.pathname);return{matches:Ke,loaderData:{},errors:{[et.id]:q}}}}let W=l||o,[z,X]=Er(e.history,v,h,O,u,p.v7_partialHydration&&T===!0,p.v7_skipActionErrorRevalidation,se,He,We,de,_e,ue,W,c,_);if(Ut(A=>!(h&&h.some(q=>q.route.id===A))||z&&z.some(q=>q.route.id===A)),Pe=++Te,z.length===0&&X.length===0){let A=cr();return ye(u,Y({matches:h,loaderData:{},errors:_&&me(_[1])?{[_[0]]:_[1].error}:null},Lr(_),A?{fetchers:new Map(v.fetchers)}:{}),{flushSync:E}),{shortCircuited:!0}}if(ie){let A={};if(!y){A.navigation=M;let q=ir(_);q!==void 0&&(A.actionData=q)}X.length>0&&(A.fetchers=Rn(X)),H(A,{flushSync:E})}X.forEach(A=>{De(A.key),A.controller&&Q.set(A.key,A.controller)});let $e=()=>X.forEach(A=>De(A.key));I&&I.signal.addEventListener("abort",$e);let{loaderResults:Qe,fetcherResults:Ee}=await or(v,h,z,X,s);if(s.signal.aborted)return{shortCircuited:!0};I&&I.signal.removeEventListener("abort",$e),X.forEach(A=>Q.delete(A.key));let be=Et(Qe);if(be)return await Ae(s,be.result,!0,{replace:R}),{shortCircuited:!0};if(be=Et(Ee),be)return ue.add(be.key),await Ae(s,be.result,!0,{replace:R}),{shortCircuited:!0};let{loaderData:Ot,errors:Ze}=Cr(v,h,Qe,_,X,Ee,xe);xe.forEach((A,q)=>{A.subscribe(Ke=>{(Ke||A.done)&&xe.delete(q)})}),p.v7_partialHydration&&T&&v.errors&&(Ze=Y({},v.errors,Ze));let ke=cr(),wt=ur(Pe),xt=ke||wt||X.length>0;return Y({matches:h,loaderData:Ot,errors:Ze},xt?{fetchers:new Map(v.fetchers)}:{})}function ir(s){if(s&&!me(s[1]))return{[s[0]]:s[1].data};if(v.actionData)return Object.keys(v.actionData).length===0?null:v.actionData}function Rn(s){return s.forEach(u=>{let h=v.fetchers.get(u.key),y=rt(void 0,h?h.data:void 0);v.fetchers.set(u.key,y)}),new Map(v.fetchers)}function Tn(s,u,h,y){if(n)throw new Error("router.fetch() was called during the server render, but it shouldn't be. You are likely calling a useFetcher() method in the body of your component. Try moving it to a useEffect or a callback.");De(s);let x=(y&&y.flushSync)===!0,C=l||o,j=Bt(v.location,v.matches,c,p.v7_prependBasename,h,p.v7_relativeSplatPath,u,y==null?void 0:y.relative),R=Fe(C,j,c),T=yt(R,C,j);if(T.active&&T.matches&&(R=T.matches),!R){Se(s,u,le(404,{pathname:j}),{flushSync:x});return}let{path:E,submission:_,error:M}=xr(p.v7_normalizeFormMethod,!0,j,y);if(M){Se(s,u,M,{flushSync:x});return}let O=at(R,E),ie=(y&&y.preventScrollReset)===!0;if(_&&ve(_.formMethod)){Pn(s,u,E,O,R,T.active,x,ie,_);return}_e.set(s,{routeId:u,path:E}),_n(s,u,E,O,R,T.active,x,ie,_)}async function Pn(s,u,h,y,x,C,j,R,T){Mt(),_e.delete(s);function E(Z){if(!Z.route.action&&!Z.route.lazy){let Ye=le(405,{method:T.formMethod,pathname:h,routeId:u});return Se(s,u,Ye,{flushSync:j}),!0}return!1}if(!C&&E(y))return;let _=v.fetchers.get(s);Ce(s,Xa(T,_),{flushSync:j});let M=new AbortController,O=Ge(e.history,h,M.signal,T);if(C){let Z=await bt(x,new URL(O.url).pathname,O.signal,s);if(Z.type==="aborted")return;if(Z.type==="error"){Se(s,u,Z.error,{flushSync:j});return}else if(Z.matches){if(x=Z.matches,y=at(x,h),E(y))return}else{Se(s,u,le(404,{pathname:h}),{flushSync:j});return}}Q.set(s,M);let ie=Te,z=(await qe("action",v,O,[y],x,s))[y.route.id];if(O.signal.aborted){Q.get(s)===M&&Q.delete(s);return}if(p.v7_fetcherPersist&&de.has(s)){if(ze(z)||me(z)){Ce(s,Le(void 0));return}}else{if(ze(z))if(Q.delete(s),Pe>ie){Ce(s,Le(void 0));return}else return ue.add(s),Ce(s,rt(T)),Ae(O,z,!1,{fetcherSubmission:T,preventScrollReset:R});if(me(z)){Se(s,u,z.error);return}}if(je(z))throw le(400,{type:"defer-action"});let X=v.navigation.location||v.location,$e=Ge(e.history,X,M.signal),Qe=l||o,Ee=v.navigation.state!=="idle"?Fe(Qe,v.navigation.location,c):v.matches;U(Ee,"Didn't find any matches after fetcher action");let be=++Te;we.set(s,be);let Ot=rt(T,z.data);v.fetchers.set(s,Ot);let[Ze,ke]=Er(e.history,v,Ee,T,X,!1,p.v7_skipActionErrorRevalidation,se,He,We,de,_e,ue,Qe,c,[y.route.id,z]);ke.filter(Z=>Z.key!==s).forEach(Z=>{let Ye=Z.key,pr=v.fetchers.get(Ye),In=rt(void 0,pr?pr.data:void 0);v.fetchers.set(Ye,In),De(Ye),Z.controller&&Q.set(Ye,Z.controller)}),H({fetchers:new Map(v.fetchers)});let wt=()=>ke.forEach(Z=>De(Z.key));M.signal.addEventListener("abort",wt);let{loaderResults:xt,fetcherResults:A}=await or(v,Ee,Ze,ke,$e);if(M.signal.aborted)return;M.signal.removeEventListener("abort",wt),we.delete(s),Q.delete(s),ke.forEach(Z=>Q.delete(Z.key));let q=Et(xt);if(q)return Ae($e,q.result,!1,{preventScrollReset:R});if(q=Et(A),q)return ue.add(q.key),Ae($e,q.result,!1,{preventScrollReset:R});let{loaderData:Ke,errors:et}=Cr(v,Ee,xt,void 0,ke,A,xe);if(v.fetchers.has(s)){let Z=Le(z.data);v.fetchers.set(s,Z)}ur(be),v.navigation.state==="loading"&&be>Pe?(U(N,"Expected pending action"),I&&I.abort(),ye(v.navigation.location,{matches:Ee,loaderData:Ke,errors:et,fetchers:new Map(v.fetchers)})):(H({errors:et,loaderData:Dr(v.loaderData,Ke,Ee,et),fetchers:new Map(v.fetchers)}),se=!1)}async function _n(s,u,h,y,x,C,j,R,T){let E=v.fetchers.get(s);Ce(s,rt(T,E?E.data:void 0),{flushSync:j});let _=new AbortController,M=Ge(e.history,h,_.signal);if(C){let z=await bt(x,new URL(M.url).pathname,M.signal,s);if(z.type==="aborted")return;if(z.type==="error"){Se(s,u,z.error,{flushSync:j});return}else if(z.matches)x=z.matches,y=at(x,h);else{Se(s,u,le(404,{pathname:h}),{flushSync:j});return}}Q.set(s,_);let O=Te,W=(await qe("loader",v,M,[y],x,s))[y.route.id];if(je(W)&&(W=await Qt(W,M.signal,!0)||W),Q.get(s)===_&&Q.delete(s),!M.signal.aborted){if(de.has(s)){Ce(s,Le(void 0));return}if(ze(W))if(Pe>O){Ce(s,Le(void 0));return}else{ue.add(s),await Ae(M,W,!1,{preventScrollReset:R});return}if(me(W)){Se(s,u,W.error);return}U(!je(W),"Unhandled fetcher deferred data"),Ce(s,Le(W.data))}}async function Ae(s,u,h,y){let{submission:x,fetcherSubmission:C,preventScrollReset:j,replace:R}=y===void 0?{}:y;u.response.headers.has("X-Remix-Revalidate")&&(se=!0);let T=u.response.headers.get("Location");U(T,"Expected a Location header on the redirect Response"),T=Pr(T,new URL(s.url),c,e.history);let E=ot(v.location,T,{_isRedirect:!0});if(r){let z=!1;if(u.response.headers.has("X-Remix-Reload-Document"))z=!0;else if(qt.test(T)){const X=e.history.createURL(T);z=X.origin!==t.location.origin||ut(X.pathname,c)==null}if(z){R?t.location.replace(T):t.location.assign(T);return}}I=null;let _=R===!0||u.response.headers.has("X-Remix-Replace")?ee.Replace:ee.Push,{formMethod:M,formAction:O,formEncType:ie}=v.navigation;!x&&!C&&M&&O&&ie&&(x=Mr(v.navigation));let W=x||C;if(La.has(u.response.status)&&W&&ve(W.formMethod))await Oe(_,E,{submission:Y({},W,{formAction:T}),preventScrollReset:j||F,enableViewTransition:h?re:void 0});else{let z=Ft(E,x);await Oe(_,E,{overrideNavigation:z,fetcherSubmission:C,preventScrollReset:j||F,enableViewTransition:h?re:void 0})}}async function qe(s,u,h,y,x,C){let j,R={};try{j=await ka(d,s,u,h,y,x,C,i,a)}catch(T){return y.forEach(E=>{R[E.route.id]={type:B.error,error:T}}),R}for(let[T,E]of Object.entries(j))if(Wa(E)){let _=E.result;R[T]={type:B.redirect,response:za(_,h,T,x,c,p.v7_relativeSplatPath)}}else R[T]=await Va(E);return R}async function or(s,u,h,y,x){let C=s.matches,j=qe("loader",s,x,h,u,null),R=Promise.all(y.map(async _=>{if(_.matches&&_.match&&_.controller){let O=(await qe("loader",s,Ge(e.history,_.path,_.controller.signal),[_.match],_.matches,_.key))[_.match.route.id];return{[_.key]:O}}else return Promise.resolve({[_.key]:{type:B.error,error:le(404,{pathname:_.path})}})})),T=await j,E=(await R).reduce((_,M)=>Object.assign(_,M),{});return await Promise.all([Ya(u,T,x.signal,C,s.loaderData),Ga(u,E,y)]),{loaderResults:T,fetcherResults:E}}function Mt(){se=!0,He.push(...Ut()),_e.forEach((s,u)=>{Q.has(u)&&We.add(u),De(u)})}function Ce(s,u,h){h===void 0&&(h={}),v.fetchers.set(s,u),H({fetchers:new Map(v.fetchers)},{flushSync:(h&&h.flushSync)===!0})}function Se(s,u,h,y){y===void 0&&(y={});let x=Ve(v.matches,u);vt(s),H({errors:{[x.route.id]:h},fetchers:new Map(v.fetchers)},{flushSync:(y&&y.flushSync)===!0})}function sr(s){return Ie.set(s,(Ie.get(s)||0)+1),de.has(s)&&de.delete(s),v.fetchers.get(s)||ja}function vt(s){let u=v.fetchers.get(s);Q.has(s)&&!(u&&u.state==="loading"&&we.has(s))&&De(s),_e.delete(s),we.delete(s),ue.delete(s),p.v7_fetcherPersist&&de.delete(s),We.delete(s),v.fetchers.delete(s)}function Cn(s){let u=(Ie.get(s)||0)-1;u<=0?(Ie.delete(s),de.add(s),p.v7_fetcherPersist||vt(s)):Ie.set(s,u),H({fetchers:new Map(v.fetchers)})}function De(s){let u=Q.get(s);u&&(u.abort(),Q.delete(s))}function lr(s){for(let u of s){let h=sr(u),y=Le(h.data);v.fetchers.set(u,y)}}function cr(){let s=[],u=!1;for(let h of ue){let y=v.fetchers.get(h);U(y,"Expected fetcher: "+h),y.state==="loading"&&(ue.delete(h),s.push(h),u=!0)}return lr(s),u}function ur(s){let u=[];for(let[h,y]of we)if(y<s){let x=v.fetchers.get(h);U(x,"Expected fetcher: "+h),x.state==="loading"&&(De(h),we.delete(h),u.push(h))}return lr(u),u.length>0}function Dn(s,u){let h=v.blockers.get(s)||tt;return ge.get(s)!==u&&ge.set(s,u),h}function dr(s){v.blockers.delete(s),ge.delete(s)}function gt(s,u){let h=v.blockers.get(s)||tt;U(h.state==="unblocked"&&u.state==="blocked"||h.state==="blocked"&&u.state==="blocked"||h.state==="blocked"&&u.state==="proceeding"||h.state==="blocked"&&u.state==="unblocked"||h.state==="proceeding"&&u.state==="unblocked","Invalid blocker state transition: "+h.state+" -> "+u.state);let y=new Map(v.blockers);y.set(s,u),H({blockers:y})}function fr(s){let{currentLocation:u,nextLocation:h,historyAction:y}=s;if(ge.size===0)return;ge.size>1&&Be(!1,"A router only supports one blocker at a time");let x=Array.from(ge.entries()),[C,j]=x[x.length-1],R=v.blockers.get(C);if(!(R&&R.state==="proceeding")&&j({currentLocation:u,nextLocation:h,historyAction:y}))return C}function It(s){let u=le(404,{pathname:s}),h=l||o,{matches:y,route:x}=jr(h);return Ut(),{notFoundMatches:y,route:x,error:u}}function Ut(s){let u=[];return xe.forEach((h,y)=>{(!s||s(y))&&(h.cancel(),u.push(y),xe.delete(y))}),u}function Ln(s,u,h){if(P=s,D=u,S=h||null,!k&&v.navigation===kt){k=!0;let y=mr(v.location,v.matches);y!=null&&H({restoreScrollPosition:y})}return()=>{P=null,D=null,S=null}}function hr(s,u){return S&&S(s,u.map(y=>sa(y,v.loaderData)))||s.key}function jn(s,u){if(P&&D){let h=hr(s,u);P[h]=D()}}function mr(s,u){if(P){let h=hr(s,u),y=P[h];if(typeof y=="number")return y}return null}function yt(s,u,h){if(m)if(s){if(Object.keys(s[0].params).length>0)return{active:!0,matches:Tt(u,h,c,!0)}}else return{active:!0,matches:Tt(u,h,c,!0)||[]};return{active:!1,matches:null}}async function bt(s,u,h,y){if(!m)return{type:"success",matches:s};let x=s;for(;;){let C=l==null,j=l||o,R=i;try{await m({signal:h,path:u,matches:x,fetcherKey:y,patch:(_,M)=>{h.aborted||Tr(_,M,j,R,a)}})}catch(_){return{type:"error",error:_,partialMatches:x}}finally{C&&!h.aborted&&(o=[...o])}if(h.aborted)return{type:"aborted"};let T=Fe(j,u,c);if(T)return{type:"success",matches:T};let E=Tt(j,u,c,!0);if(!E||x.length===E.length&&x.every((_,M)=>_.route.id===E[M].route.id))return{type:"success",matches:null};x=E}}function Nn(s){i={},l=Ct(s,a,void 0,i)}function Mn(s,u){let h=l==null;Tr(s,u,l||o,i,a),h&&(o=[...o],H({}))}return pe={get basename(){return c},get future(){return p},get state(){return v},get routes(){return o},get window(){return t},initialize:mt,subscribe:fe,enableScrollRestoration:Ln,navigate:pt,fetch:Tn,revalidate:xn,createHref:s=>e.history.createHref(s),encodeLocation:s=>e.history.encodeLocation(s),getFetcher:sr,deleteFetcher:Cn,dispose:V,getBlocker:Dn,deleteBlocker:dr,patchRoutes:Mn,_internalFetchControllers:Q,_internalActiveDeferreds:xe,_internalSetRoutes:Nn},pe}function Ia(e){return e!=null&&("formData"in e&&e.formData!=null||"body"in e&&e.body!==void 0)}function Bt(e,t,r,n,a,i,o,l){let c,d;if(o){c=[];for(let p of t)if(c.push(p),p.route.id===o){d=p;break}}else c=t,d=t[t.length-1];let m=Xt(a||".",Jt(c,i),ut(e.pathname,r)||e.pathname,l==="path");if(a==null&&(m.search=e.search,m.hash=e.hash),(a==null||a===""||a===".")&&d){let p=Zt(m.search);if(d.route.index&&!p)m.search=m.search?m.search.replace(/^\?/,"?index&"):"?index";else if(!d.route.index&&p){let b=new URLSearchParams(m.search),w=b.getAll("index");b.delete("index"),w.filter(S=>S).forEach(S=>b.append("index",S));let P=b.toString();m.search=P?"?"+P:""}}return n&&r!=="/"&&(m.pathname=m.pathname==="/"?r:Ne([r,m.pathname])),ct(m)}function xr(e,t,r,n){if(!n||!Ia(n))return{path:r};if(n.formMethod&&!Ka(n.formMethod))return{path:r,error:le(405,{method:n.formMethod})};let a=()=>({path:r,error:le(400,{type:"invalid-body"})}),i=n.formMethod||"get",o=e?i.toUpperCase():i.toLowerCase(),l=tn(r);if(n.body!==void 0){if(n.formEncType==="text/plain"){if(!ve(o))return a();let b=typeof n.body=="string"?n.body:n.body instanceof FormData||n.body instanceof URLSearchParams?Array.from(n.body.entries()).reduce((w,P)=>{let[S,D]=P;return""+w+S+"="+D+`
|
|
12
|
-
`},""):String(n.body);return{path:r,submission:{formMethod:o,formAction:l,formEncType:n.formEncType,formData:void 0,json:void 0,text:b}}}else if(n.formEncType==="application/json"){if(!ve(o))return a();try{let b=typeof n.body=="string"?JSON.parse(n.body):n.body;return{path:r,submission:{formMethod:o,formAction:l,formEncType:n.formEncType,formData:void 0,json:b,text:void 0}}}catch{return a()}}}U(typeof FormData=="function","FormData is not available in this environment");let c,d;if(n.formData)c=Wt(n.formData),d=n.formData;else if(n.body instanceof FormData)c=Wt(n.body),d=n.body;else if(n.body instanceof URLSearchParams)c=n.body,d=_r(c);else if(n.body==null)c=new URLSearchParams,d=new FormData;else try{c=new URLSearchParams(n.body),d=_r(c)}catch{return a()}let m={formMethod:o,formAction:l,formEncType:n&&n.formEncType||"application/x-www-form-urlencoded",formData:d,json:void 0,text:void 0};if(ve(m.formMethod))return{path:r,submission:m};let p=Me(r);return t&&p.search&&Zt(p.search)&&c.append("index",""),p.search="?"+c,{path:ct(p),submission:m}}function Sr(e,t,r){r===void 0&&(r=!1);let n=e.findIndex(a=>a.route.id===t);return n>=0?e.slice(0,r?n+1:n):e}function Er(e,t,r,n,a,i,o,l,c,d,m,p,b,w,P,S){let D=S?me(S[1])?S[1].error:S[1].data:void 0,k=e.createURL(t.location),L=e.createURL(a),K=r;i&&t.errors?K=Sr(r,Object.keys(t.errors)[0],!0):S&&me(S[1])&&(K=Sr(r,S[0]));let te=S?S[1].statusCode:void 0,$=o&&te&&te>=400,pe=K.filter((N,F)=>{let{route:I}=N;if(I.lazy)return!0;if(I.loader==null)return!1;if(i)return Ht(I,t.loaderData,t.errors);if(Ua(t.loaderData,t.matches[F],N)||c.some(oe=>oe===N.route.id))return!0;let re=t.matches[F],G=N;return Rr(N,Y({currentUrl:k,currentParams:re.params,nextUrl:L,nextParams:G.params},n,{actionResult:D,actionStatus:te,defaultShouldRevalidate:$?!1:l||k.pathname+k.search===L.pathname+L.search||k.search!==L.search||Zr(re,G)}))}),v=[];return p.forEach((N,F)=>{if(i||!r.some(ne=>ne.route.id===N.routeId)||m.has(F))return;let I=Fe(w,N.path,P);if(!I){v.push({key:F,routeId:N.routeId,path:N.path,matches:null,match:null,controller:null});return}let re=t.fetchers.get(F),G=at(I,N.path),oe=!1;b.has(F)?oe=!1:d.has(F)?(d.delete(F),oe=!0):re&&re.state!=="idle"&&re.data===void 0?oe=l:oe=Rr(G,Y({currentUrl:k,currentParams:t.matches[t.matches.length-1].params,nextUrl:L,nextParams:r[r.length-1].params},n,{actionResult:D,actionStatus:te,defaultShouldRevalidate:$?!1:l})),oe&&v.push({key:F,routeId:N.routeId,path:N.path,matches:I,match:G,controller:new AbortController})}),[pe,v]}function Ht(e,t,r){if(e.lazy)return!0;if(!e.loader)return!1;let n=t!=null&&t[e.id]!==void 0,a=r!=null&&r[e.id]!==void 0;return!n&&a?!1:typeof e.loader=="function"&&e.loader.hydrate===!0?!0:!n&&!a}function Ua(e,t,r){let n=!t||r.route.id!==t.route.id,a=e[r.route.id]===void 0;return n||a}function Zr(e,t){let r=e.route.path;return e.pathname!==t.pathname||r!=null&&r.endsWith("*")&&e.params["*"]!==t.params["*"]}function Rr(e,t){if(e.route.shouldRevalidate){let r=e.route.shouldRevalidate(t);if(typeof r=="boolean")return r}return t.defaultShouldRevalidate}function Tr(e,t,r,n,a){var i;let o;if(e){let d=n[e];U(d,"No route found to patch children into: routeId = "+e),d.children||(d.children=[]),o=d.children}else o=r;let l=t.filter(d=>!o.some(m=>en(d,m))),c=Ct(l,a,[e||"_","patch",String(((i=o)==null?void 0:i.length)||"0")],n);o.push(...c)}function en(e,t){return"id"in e&&"id"in t&&e.id===t.id?!0:e.index===t.index&&e.path===t.path&&e.caseSensitive===t.caseSensitive?(!e.children||e.children.length===0)&&(!t.children||t.children.length===0)?!0:e.children.every((r,n)=>{var a;return(a=t.children)==null?void 0:a.some(i=>en(r,i))}):!1}async function Oa(e,t,r){if(!e.lazy)return;let n=await e.lazy();if(!e.lazy)return;let a=r[e.id];U(a,"No route found in manifest");let i={};for(let o in n){let c=a[o]!==void 0&&o!=="hasErrorBoundary";Be(!c,'Route "'+a.id+'" has a static property "'+o+'" defined but its lazy function is also returning a value for this property. '+('The lazy route property "'+o+'" will be ignored.')),!c&&!ia.has(o)&&(i[o]=n[o])}Object.assign(a,i),Object.assign(a,Y({},t(a),{lazy:void 0}))}async function Aa(e){let{matches:t}=e,r=t.filter(a=>a.shouldLoad);return(await Promise.all(r.map(a=>a.resolve()))).reduce((a,i,o)=>Object.assign(a,{[r[o].route.id]:i}),{})}async function ka(e,t,r,n,a,i,o,l,c,d){let m=i.map(w=>w.route.lazy?Oa(w.route,c,l):void 0),p=i.map((w,P)=>{let S=m[P],D=a.some(L=>L.route.id===w.route.id);return Y({},w,{shouldLoad:D,resolve:async L=>(L&&n.method==="GET"&&(w.route.lazy||w.route.loader)&&(D=!0),D?Fa(t,n,w,S,L,d):Promise.resolve({type:B.data,result:void 0}))})}),b=await e({matches:p,request:n,params:i[0].params,fetcherKey:o,context:d});try{await Promise.all(m)}catch{}return b}async function Fa(e,t,r,n,a,i){let o,l,c=d=>{let m,p=new Promise((P,S)=>m=S);l=()=>m(),t.signal.addEventListener("abort",l);let b=P=>typeof d!="function"?Promise.reject(new Error("You cannot call the handler for a route which defines a boolean "+('"'+e+'" [routeId: '+r.route.id+"]"))):d({request:t,params:r.params,context:i},...P!==void 0?[P]:[]),w=(async()=>{try{return{type:"data",result:await(a?a(S=>b(S)):b())}}catch(P){return{type:"error",result:P}}})();return Promise.race([w,p])};try{let d=r.route[e];if(n)if(d){let m,[p]=await Promise.all([c(d).catch(b=>{m=b}),n]);if(m!==void 0)throw m;o=p}else if(await n,d=r.route[e],d)o=await c(d);else if(e==="action"){let m=new URL(t.url),p=m.pathname+m.search;throw le(405,{method:t.method,pathname:p,routeId:r.route.id})}else return{type:B.data,result:void 0};else if(d)o=await c(d);else{let m=new URL(t.url),p=m.pathname+m.search;throw le(404,{pathname:p})}U(o.result!==void 0,"You defined "+(e==="action"?"an action":"a loader")+" for route "+('"'+r.route.id+"\" but didn't return anything from your `"+e+"` ")+"function. Please return a value or `null`.")}catch(d){return{type:B.error,result:d}}finally{l&&t.signal.removeEventListener("abort",l)}return o}async function Va(e){let{result:t,type:r}=e;if(rn(t)){let p;try{let b=t.headers.get("Content-Type");b&&/\bapplication\/json\b/.test(b)?t.body==null?p=null:p=await t.json():p=await t.text()}catch(b){return{type:B.error,error:b}}return r===B.error?{type:B.error,error:new Dt(t.status,t.statusText,p),statusCode:t.status,headers:t.headers}:{type:B.data,data:p,statusCode:t.status,headers:t.headers}}if(r===B.error){if(Nr(t)){var n,a;if(t.data instanceof Error){var i,o;return{type:B.error,error:t.data,statusCode:(i=t.init)==null?void 0:i.status,headers:(o=t.init)!=null&&o.headers?new Headers(t.init.headers):void 0}}return{type:B.error,error:new Dt(((n=t.init)==null?void 0:n.status)||500,void 0,t.data),statusCode:st(t)?t.status:void 0,headers:(a=t.init)!=null&&a.headers?new Headers(t.init.headers):void 0}}return{type:B.error,error:t,statusCode:st(t)?t.status:void 0}}if($a(t)){var l,c;return{type:B.deferred,deferredData:t,statusCode:(l=t.init)==null?void 0:l.status,headers:((c=t.init)==null?void 0:c.headers)&&new Headers(t.init.headers)}}if(Nr(t)){var d,m;return{type:B.data,data:t.data,statusCode:(d=t.init)==null?void 0:d.status,headers:(m=t.init)!=null&&m.headers?new Headers(t.init.headers):void 0}}return{type:B.data,data:t}}function za(e,t,r,n,a,i){let o=e.headers.get("Location");if(U(o,"Redirects returned/thrown from loaders/actions must have a Location header"),!qt.test(o)){let l=n.slice(0,n.findIndex(c=>c.route.id===r)+1);o=Bt(new URL(t.url),l,a,!0,o,i),e.headers.set("Location",o)}return e}function Pr(e,t,r,n){let a=["about:","blob:","chrome:","chrome-untrusted:","content:","data:","devtools:","file:","filesystem:","javascript:"];if(qt.test(e)){let i=e,o=i.startsWith("//")?new URL(t.protocol+i):new URL(i);if(a.includes(o.protocol))throw new Error("Invalid redirect location");let l=ut(o.pathname,r)!=null;if(o.origin===t.origin&&l)return o.pathname+o.search+o.hash}try{let i=n.createURL(e);if(a.includes(i.protocol))throw new Error("Invalid redirect location")}catch{}return e}function Ge(e,t,r,n){let a=e.createURL(tn(t)).toString(),i={signal:r};if(n&&ve(n.formMethod)){let{formMethod:o,formEncType:l}=n;i.method=o.toUpperCase(),l==="application/json"?(i.headers=new Headers({"Content-Type":l}),i.body=JSON.stringify(n.json)):l==="text/plain"?i.body=n.text:l==="application/x-www-form-urlencoded"&&n.formData?i.body=Wt(n.formData):i.body=n.formData}return new Request(a,i)}function Wt(e){let t=new URLSearchParams;for(let[r,n]of e.entries())t.append(r,typeof n=="string"?n:n.name);return t}function _r(e){let t=new FormData;for(let[r,n]of e.entries())t.append(r,n);return t}function Ba(e,t,r,n,a){let i={},o=null,l,c=!1,d={},m=r&&me(r[1])?r[1].error:void 0;return e.forEach(p=>{if(!(p.route.id in t))return;let b=p.route.id,w=t[b];if(U(!ze(w),"Cannot handle redirect results in processLoaderData"),me(w)){let P=w.error;m!==void 0&&(P=m,m=void 0),o=o||{};{let S=Ve(e,b);o[S.route.id]==null&&(o[S.route.id]=P)}i[b]=void 0,c||(c=!0,l=st(w.error)?w.error.status:500),w.headers&&(d[b]=w.headers)}else je(w)?(n.set(b,w.deferredData),i[b]=w.deferredData.data,w.statusCode!=null&&w.statusCode!==200&&!c&&(l=w.statusCode),w.headers&&(d[b]=w.headers)):(i[b]=w.data,w.statusCode&&w.statusCode!==200&&!c&&(l=w.statusCode),w.headers&&(d[b]=w.headers))}),m!==void 0&&r&&(o={[r[0]]:m},i[r[0]]=void 0),{loaderData:i,errors:o,statusCode:l||200,loaderHeaders:d}}function Cr(e,t,r,n,a,i,o){let{loaderData:l,errors:c}=Ba(t,r,n,o);return a.forEach(d=>{let{key:m,match:p,controller:b}=d,w=i[m];if(U(w,"Did not find corresponding fetcher result"),!(b&&b.signal.aborted))if(me(w)){let P=Ve(e.matches,p==null?void 0:p.route.id);c&&c[P.route.id]||(c=Y({},c,{[P.route.id]:w.error})),e.fetchers.delete(m)}else if(ze(w))U(!1,"Unhandled fetcher revalidation redirect");else if(je(w))U(!1,"Unhandled fetcher deferred data");else{let P=Le(w.data);e.fetchers.set(m,P)}}),{loaderData:l,errors:c}}function Dr(e,t,r,n){let a=Y({},t);for(let i of r){let o=i.route.id;if(t.hasOwnProperty(o)?t[o]!==void 0&&(a[o]=t[o]):e[o]!==void 0&&i.route.loader&&(a[o]=e[o]),n&&n.hasOwnProperty(o))break}return a}function Lr(e){return e?me(e[1])?{actionData:{}}:{actionData:{[e[0]]:e[1].data}}:{}}function Ve(e,t){return(t?e.slice(0,e.findIndex(n=>n.route.id===t)+1):[...e]).reverse().find(n=>n.route.hasErrorBoundary===!0)||e[0]}function jr(e){let t=e.length===1?e[0]:e.find(r=>r.index||!r.path||r.path==="/")||{id:"__shim-error-route__"};return{matches:[{params:{},pathname:"",pathnameBase:"",route:t}],route:t}}function le(e,t){let{pathname:r,routeId:n,method:a,type:i,message:o}=t===void 0?{}:t,l="Unknown Server Error",c="Unknown @remix-run/router error";return e===400?(l="Bad Request",a&&r&&n?c="You made a "+a+' request to "'+r+'" but '+('did not provide a `loader` for route "'+n+'", ')+"so there is no way to handle the request.":i==="defer-action"?c="defer() is not supported in actions":i==="invalid-body"&&(c="Unable to encode submission body")):e===403?(l="Forbidden",c='Route "'+n+'" does not match URL "'+r+'"'):e===404?(l="Not Found",c='No route matches URL "'+r+'"'):e===405&&(l="Method Not Allowed",a&&r&&n?c="You made a "+a.toUpperCase()+' request to "'+r+'" but '+('did not provide an `action` for route "'+n+'", ')+"so there is no way to handle the request.":a&&(c='Invalid request method "'+a.toUpperCase()+'"')),new Dt(e||500,l,new Error(c),!0)}function Et(e){let t=Object.entries(e);for(let r=t.length-1;r>=0;r--){let[n,a]=t[r];if(ze(a))return{key:n,result:a}}}function tn(e){let t=typeof e=="string"?Me(e):e;return ct(Y({},t,{hash:""}))}function Ha(e,t){return e.pathname!==t.pathname||e.search!==t.search?!1:e.hash===""?t.hash!=="":e.hash===t.hash?!0:t.hash!==""}function Wa(e){return rn(e.result)&&Da.has(e.result.status)}function je(e){return e.type===B.deferred}function me(e){return e.type===B.error}function ze(e){return(e&&e.type)===B.redirect}function Nr(e){return typeof e=="object"&&e!=null&&"type"in e&&"data"in e&&"init"in e&&e.type==="DataWithResponseInit"}function $a(e){let t=e;return t&&typeof t=="object"&&typeof t.data=="object"&&typeof t.subscribe=="function"&&typeof t.cancel=="function"&&typeof t.resolveData=="function"}function rn(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.headers=="object"&&typeof e.body<"u"}function Ka(e){return Ca.has(e.toLowerCase())}function ve(e){return Pa.has(e.toLowerCase())}async function Ya(e,t,r,n,a){let i=Object.entries(t);for(let o=0;o<i.length;o++){let[l,c]=i[o],d=e.find(b=>(b==null?void 0:b.route.id)===l);if(!d)continue;let m=n.find(b=>b.route.id===d.route.id),p=m!=null&&!Zr(m,d)&&(a&&a[d.route.id])!==void 0;je(c)&&p&&await Qt(c,r,!1).then(b=>{b&&(t[l]=b)})}}async function Ga(e,t,r){for(let n=0;n<r.length;n++){let{key:a,routeId:i,controller:o}=r[n],l=t[a];e.find(d=>(d==null?void 0:d.route.id)===i)&&je(l)&&(U(o,"Expected an AbortController for revalidating fetcher deferred result"),await Qt(l,o.signal,!0).then(d=>{d&&(t[a]=d)}))}}async function Qt(e,t,r){if(r===void 0&&(r=!1),!await e.deferredData.resolveData(t)){if(r)try{return{type:B.data,data:e.deferredData.unwrappedData}}catch(a){return{type:B.error,error:a}}return{type:B.data,data:e.deferredData.data}}}function Zt(e){return new URLSearchParams(e).getAll("index").some(t=>t==="")}function at(e,t){let r=typeof t=="string"?Me(t).search:t.search;if(e[e.length-1].route.index&&Zt(r||""))return e[e.length-1];let n=Xr(e);return n[n.length-1]}function Mr(e){let{formMethod:t,formAction:r,formEncType:n,text:a,formData:i,json:o}=e;if(!(!t||!r||!n)){if(a!=null)return{formMethod:t,formAction:r,formEncType:n,formData:void 0,json:void 0,text:a};if(i!=null)return{formMethod:t,formAction:r,formEncType:n,formData:i,json:void 0,text:void 0};if(o!==void 0)return{formMethod:t,formAction:r,formEncType:n,formData:void 0,json:o,text:void 0}}}function Ft(e,t){return t?{state:"loading",location:e,formMethod:t.formMethod,formAction:t.formAction,formEncType:t.formEncType,formData:t.formData,json:t.json,text:t.text}:{state:"loading",location:e,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0}}function Ja(e,t){return{state:"submitting",location:e,formMethod:t.formMethod,formAction:t.formAction,formEncType:t.formEncType,formData:t.formData,json:t.json,text:t.text}}function rt(e,t){return e?{state:"loading",formMethod:e.formMethod,formAction:e.formAction,formEncType:e.formEncType,formData:e.formData,json:e.json,text:e.text,data:t}:{state:"loading",formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0,data:t}}function Xa(e,t){return{state:"submitting",formMethod:e.formMethod,formAction:e.formAction,formEncType:e.formEncType,formData:e.formData,json:e.json,text:e.text,data:t?t.data:void 0}}function Le(e){return{state:"idle",formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0,data:e}}function qa(e,t){try{let r=e.sessionStorage.getItem(Qr);if(r){let n=JSON.parse(r);for(let[a,i]of Object.entries(n||{}))i&&Array.isArray(i)&&t.set(a,new Set(i||[]))}}catch{}}function Qa(e,t){if(t.size>0){let r={};for(let[n,a]of t)r[n]=[...a];try{e.sessionStorage.setItem(Qr,JSON.stringify(r))}catch(n){Be(!1,"Failed to save applied view transitions in sessionStorage ("+n+").")}}}/**
|
|
13
|
-
* React Router v6.30.3
|
|
14
|
-
*
|
|
15
|
-
* Copyright (c) Remix Software Inc.
|
|
16
|
-
*
|
|
17
|
-
* This source code is licensed under the MIT license found in the
|
|
18
|
-
* LICENSE.md file in the root directory of this source tree.
|
|
19
|
-
*
|
|
20
|
-
* @license MIT
|
|
21
|
-
*/function Lt(){return Lt=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},Lt.apply(this,arguments)}const Nt=f.createContext(null),nn=f.createContext(null),dt=f.createContext(null),er=f.createContext(null),Re=f.createContext({outlet:null,matches:[],isDataRoute:!1}),an=f.createContext(null);function ft(){return f.useContext(er)!=null}function ht(){return ft()||U(!1),f.useContext(er).location}function on(e){f.useContext(dt).static||f.useLayoutEffect(e)}function tr(){let{isDataRoute:e}=f.useContext(Re);return e?fi():Za()}function Za(){ft()||U(!1);let e=f.useContext(Nt),{basename:t,future:r,navigator:n}=f.useContext(dt),{matches:a}=f.useContext(Re),{pathname:i}=ht(),o=JSON.stringify(Jt(a,r.v7_relativeSplatPath)),l=f.useRef(!1);return on(()=>{l.current=!0}),f.useCallback(function(d,m){if(m===void 0&&(m={}),!l.current)return;if(typeof d=="number"){n.go(d);return}let p=Xt(d,JSON.parse(o),i,m.relative==="path");e==null&&t!=="/"&&(p.pathname=p.pathname==="/"?t:Ne([t,p.pathname])),(m.replace?n.replace:n.push)(p,m.state,m)},[t,n,o,i,e])}const ei=f.createContext(null);function ti(e){let t=f.useContext(Re).outlet;return t&&f.createElement(ei.Provider,{value:e},t)}function Ho(){let{matches:e}=f.useContext(Re),t=e[e.length-1];return t?t.params:{}}function ri(e,t,r,n){ft()||U(!1);let{navigator:a}=f.useContext(dt),{matches:i}=f.useContext(Re),o=i[i.length-1],l=o?o.params:{};o&&o.pathname;let c=o?o.pathnameBase:"/";o&&o.route;let d=ht(),m;m=d;let p=m.pathname||"/",b=p;if(c!=="/"){let S=c.replace(/^\//,"").split("/");b="/"+p.replace(/^\//,"").split("/").slice(S.length).join("/")}let w=Fe(e,{pathname:b});return si(w&&w.map(S=>Object.assign({},S,{params:Object.assign({},l,S.params),pathname:Ne([c,a.encodeLocation?a.encodeLocation(S.pathname).pathname:S.pathname]),pathnameBase:S.pathnameBase==="/"?c:Ne([c,a.encodeLocation?a.encodeLocation(S.pathnameBase).pathname:S.pathnameBase])})),i,r,n)}function ni(){let e=di(),t=st(e)?e.status+" "+e.statusText:e instanceof Error?e.message:JSON.stringify(e),r=e instanceof Error?e.stack:null,a={padding:"0.5rem",backgroundColor:"rgba(200,200,200, 0.5)"};return f.createElement(f.Fragment,null,f.createElement("h2",null,"Unexpected Application Error!"),f.createElement("h3",{style:{fontStyle:"italic"}},t),r?f.createElement("pre",{style:a},r):null,null)}const ai=f.createElement(ni,null);class ii extends f.Component{constructor(t){super(t),this.state={location:t.location,revalidation:t.revalidation,error:t.error}}static getDerivedStateFromError(t){return{error:t}}static getDerivedStateFromProps(t,r){return r.location!==t.location||r.revalidation!=="idle"&&t.revalidation==="idle"?{error:t.error,location:t.location,revalidation:t.revalidation}:{error:t.error!==void 0?t.error:r.error,location:r.location,revalidation:t.revalidation||r.revalidation}}componentDidCatch(t,r){console.error("React Router caught the following error during render",t,r)}render(){return this.state.error!==void 0?f.createElement(Re.Provider,{value:this.props.routeContext},f.createElement(an.Provider,{value:this.state.error,children:this.props.component})):this.props.children}}function oi(e){let{routeContext:t,match:r,children:n}=e,a=f.useContext(Nt);return a&&a.static&&a.staticContext&&(r.route.errorElement||r.route.ErrorBoundary)&&(a.staticContext._deepestRenderedBoundaryId=r.route.id),f.createElement(Re.Provider,{value:t},n)}function si(e,t,r,n){var a;if(t===void 0&&(t=[]),r===void 0&&(r=null),n===void 0&&(n=null),e==null){var i;if(!r)return null;if(r.errors)e=r.matches;else if((i=n)!=null&&i.v7_partialHydration&&t.length===0&&!r.initialized&&r.matches.length>0)e=r.matches;else return null}let o=e,l=(a=r)==null?void 0:a.errors;if(l!=null){let m=o.findIndex(p=>p.route.id&&(l==null?void 0:l[p.route.id])!==void 0);m>=0||U(!1),o=o.slice(0,Math.min(o.length,m+1))}let c=!1,d=-1;if(r&&n&&n.v7_partialHydration)for(let m=0;m<o.length;m++){let p=o[m];if((p.route.HydrateFallback||p.route.hydrateFallbackElement)&&(d=m),p.route.id){let{loaderData:b,errors:w}=r,P=p.route.loader&&b[p.route.id]===void 0&&(!w||w[p.route.id]===void 0);if(p.route.lazy||P){c=!0,d>=0?o=o.slice(0,d+1):o=[o[0]];break}}}return o.reduceRight((m,p,b)=>{let w,P=!1,S=null,D=null;r&&(w=l&&p.route.id?l[p.route.id]:void 0,S=p.route.errorElement||ai,c&&(d<0&&b===0?(hi("route-fallback"),P=!0,D=null):d===b&&(P=!0,D=p.route.hydrateFallbackElement||null)));let k=t.concat(o.slice(0,b+1)),L=()=>{let K;return w?K=S:P?K=D:p.route.Component?K=f.createElement(p.route.Component,null):p.route.element?K=p.route.element:K=m,f.createElement(oi,{match:p,routeContext:{outlet:m,matches:k,isDataRoute:r!=null},children:K})};return r&&(p.route.ErrorBoundary||p.route.errorElement||b===0)?f.createElement(ii,{location:r.location,revalidation:r.revalidation,component:S,error:w,children:L(),routeContext:{outlet:null,matches:k,isDataRoute:!0}}):L()},null)}var sn=(function(e){return e.UseBlocker="useBlocker",e.UseRevalidator="useRevalidator",e.UseNavigateStable="useNavigate",e})(sn||{}),ln=(function(e){return e.UseBlocker="useBlocker",e.UseLoaderData="useLoaderData",e.UseActionData="useActionData",e.UseRouteError="useRouteError",e.UseNavigation="useNavigation",e.UseRouteLoaderData="useRouteLoaderData",e.UseMatches="useMatches",e.UseRevalidator="useRevalidator",e.UseNavigateStable="useNavigate",e.UseRouteId="useRouteId",e})(ln||{});function li(e){let t=f.useContext(Nt);return t||U(!1),t}function ci(e){let t=f.useContext(nn);return t||U(!1),t}function ui(e){let t=f.useContext(Re);return t||U(!1),t}function cn(e){let t=ui(),r=t.matches[t.matches.length-1];return r.route.id||U(!1),r.route.id}function di(){var e;let t=f.useContext(an),r=ci(ln.UseRouteError),n=cn();return t!==void 0?t:(e=r.errors)==null?void 0:e[n]}function fi(){let{router:e}=li(sn.UseNavigateStable),t=cn(),r=f.useRef(!1);return on(()=>{r.current=!0}),f.useCallback(function(a,i){i===void 0&&(i={}),r.current&&(typeof a=="number"?e.navigate(a):e.navigate(a,Lt({fromRouteId:t},i)))},[e,t])}const Ir={};function hi(e,t,r){Ir[e]||(Ir[e]=!0)}function mi(e,t){e==null||e.v7_startTransition,(e==null?void 0:e.v7_relativeSplatPath)===void 0&&(!t||t.v7_relativeSplatPath),t&&(t.v7_fetcherPersist,t.v7_normalizeFormMethod,t.v7_partialHydration,t.v7_skipActionErrorRevalidation)}function un(e){let{to:t,replace:r,state:n,relative:a}=e;ft()||U(!1);let{future:i,static:o}=f.useContext(dt),{matches:l}=f.useContext(Re),{pathname:c}=ht(),d=tr(),m=Xt(t,Jt(l,i.v7_relativeSplatPath),c,a==="path"),p=JSON.stringify(m);return f.useEffect(()=>d(JSON.parse(p),{replace:r,state:n,relative:a}),[d,p,a,r,n]),null}function pi(e){return ti(e.context)}function vi(e){let{basename:t="/",children:r=null,location:n,navigationType:a=ee.Pop,navigator:i,static:o=!1,future:l}=e;ft()&&U(!1);let c=t.replace(/^\/*/,"/"),d=f.useMemo(()=>({basename:c,navigator:i,static:o,future:Lt({v7_relativeSplatPath:!1},l)}),[c,l,i,o]);typeof n=="string"&&(n=Me(n));let{pathname:m="/",search:p="",hash:b="",state:w=null,key:P="default"}=n,S=f.useMemo(()=>{let D=ut(m,c);return D==null?null:{location:{pathname:D,search:p,hash:b,state:w,key:P},navigationType:a}},[c,m,p,b,w,P,a]);return S==null?null:f.createElement(dt.Provider,{value:d},f.createElement(er.Provider,{children:r,value:S}))}new Promise(()=>{});function gi(e){let t={hasErrorBoundary:e.ErrorBoundary!=null||e.errorElement!=null};return e.Component&&Object.assign(t,{element:f.createElement(e.Component),Component:void 0}),e.HydrateFallback&&Object.assign(t,{hydrateFallbackElement:f.createElement(e.HydrateFallback),HydrateFallback:void 0}),e.ErrorBoundary&&Object.assign(t,{errorElement:f.createElement(e.ErrorBoundary),ErrorBoundary:void 0}),t}/**
|
|
22
|
-
* React Router DOM v6.30.3
|
|
23
|
-
*
|
|
24
|
-
* Copyright (c) Remix Software Inc.
|
|
25
|
-
*
|
|
26
|
-
* This source code is licensed under the MIT license found in the
|
|
27
|
-
* LICENSE.md file in the root directory of this source tree.
|
|
28
|
-
*
|
|
29
|
-
* @license MIT
|
|
30
|
-
*/function jt(){return jt=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},jt.apply(this,arguments)}function $t(e){return e===void 0&&(e=""),new URLSearchParams(typeof e=="string"||Array.isArray(e)||e instanceof URLSearchParams?e:Object.keys(e).reduce((t,r)=>{let n=e[r];return t.concat(Array.isArray(n)?n.map(a=>[r,a]):[[r,n]])},[]))}function yi(e,t){let r=$t(e);return t&&t.forEach((n,a)=>{r.has(a)||t.getAll(a).forEach(i=>{r.append(a,i)})}),r}const bi="6";try{window.__reactRouterVersion=bi}catch{}function wi(e,t){return Ma({basename:void 0,future:jt({},void 0,{v7_prependBasename:!0}),history:ra({window:void 0}),hydrationData:xi(),routes:e,mapRouteProperties:gi,dataStrategy:void 0,patchRoutesOnNavigation:void 0,window:void 0}).initialize()}function xi(){var e;let t=(e=window)==null?void 0:e.__staticRouterHydrationData;return t&&t.errors&&(t=jt({},t,{errors:Si(t.errors)})),t}function Si(e){if(!e)return null;let t=Object.entries(e),r={};for(let[n,a]of t)if(a&&a.__type==="RouteErrorResponse")r[n]=new Dt(a.status,a.statusText,a.data,a.internal===!0);else if(a&&a.__type==="Error"){if(a.__subType){let i=window[a.__subType];if(typeof i=="function")try{let o=new i(a.message);o.stack="",r[n]=o}catch{}}if(r[n]==null){let i=new Error(a.message);i.stack="",r[n]=i}}else r[n]=a;return r}const Ei=f.createContext({isTransitioning:!1}),Ri=f.createContext(new Map),Ti="startTransition",Ur=Fn[Ti],Pi="flushSync",Or=ta[Pi];function _i(e){Ur?Ur(e):e()}function nt(e){Or?Or(e):e()}class Ci{constructor(){this.status="pending",this.promise=new Promise((t,r)=>{this.resolve=n=>{this.status==="pending"&&(this.status="resolved",t(n))},this.reject=n=>{this.status==="pending"&&(this.status="rejected",r(n))}})}}function Di(e){let{fallbackElement:t,router:r,future:n}=e,[a,i]=f.useState(r.state),[o,l]=f.useState(),[c,d]=f.useState({isTransitioning:!1}),[m,p]=f.useState(),[b,w]=f.useState(),[P,S]=f.useState(),D=f.useRef(new Map),{v7_startTransition:k}=n||{},L=f.useCallback(N=>{k?_i(N):N()},[k]),K=f.useCallback((N,F)=>{let{deletedFetchers:I,flushSync:re,viewTransitionOpts:G}=F;N.fetchers.forEach((ne,se)=>{ne.data!==void 0&&D.current.set(se,ne.data)}),I.forEach(ne=>D.current.delete(ne));let oe=r.window==null||r.window.document==null||typeof r.window.document.startViewTransition!="function";if(!G||oe){re?nt(()=>i(N)):L(()=>i(N));return}if(re){nt(()=>{b&&(m&&m.resolve(),b.skipTransition()),d({isTransitioning:!0,flushSync:!0,currentLocation:G.currentLocation,nextLocation:G.nextLocation})});let ne=r.window.document.startViewTransition(()=>{nt(()=>i(N))});ne.finished.finally(()=>{nt(()=>{p(void 0),w(void 0),l(void 0),d({isTransitioning:!1})})}),nt(()=>w(ne));return}b?(m&&m.resolve(),b.skipTransition(),S({state:N,currentLocation:G.currentLocation,nextLocation:G.nextLocation})):(l(N),d({isTransitioning:!0,flushSync:!1,currentLocation:G.currentLocation,nextLocation:G.nextLocation}))},[r.window,b,m,D,L]);f.useLayoutEffect(()=>r.subscribe(K),[r,K]),f.useEffect(()=>{c.isTransitioning&&!c.flushSync&&p(new Ci)},[c]),f.useEffect(()=>{if(m&&o&&r.window){let N=o,F=m.promise,I=r.window.document.startViewTransition(async()=>{L(()=>i(N)),await F});I.finished.finally(()=>{p(void 0),w(void 0),l(void 0),d({isTransitioning:!1})}),w(I)}},[L,o,m,r.window]),f.useEffect(()=>{m&&o&&a.location.key===o.location.key&&m.resolve()},[m,b,a.location,o]),f.useEffect(()=>{!c.isTransitioning&&P&&(l(P.state),d({isTransitioning:!0,flushSync:!1,currentLocation:P.currentLocation,nextLocation:P.nextLocation}),S(void 0))},[c.isTransitioning,P]),f.useEffect(()=>{},[]);let te=f.useMemo(()=>({createHref:r.createHref,encodeLocation:r.encodeLocation,go:N=>r.navigate(N),push:(N,F,I)=>r.navigate(N,{state:F,preventScrollReset:I==null?void 0:I.preventScrollReset}),replace:(N,F,I)=>r.navigate(N,{replace:!0,state:F,preventScrollReset:I==null?void 0:I.preventScrollReset})}),[r]),$=r.basename||"/",pe=f.useMemo(()=>({router:r,navigator:te,static:!1,basename:$}),[r,te,$]),v=f.useMemo(()=>({v7_relativeSplatPath:r.future.v7_relativeSplatPath}),[r.future.v7_relativeSplatPath]);return f.useEffect(()=>mi(n,r.future),[n,r.future]),f.createElement(f.Fragment,null,f.createElement(Nt.Provider,{value:pe},f.createElement(nn.Provider,{value:a},f.createElement(Ri.Provider,{value:D.current},f.createElement(Ei.Provider,{value:c},f.createElement(vi,{basename:$,location:a.location,navigationType:a.historyAction,navigator:te,future:v},a.initialized||r.future.v7_partialHydration?f.createElement(Li,{routes:r.routes,future:r.future,state:a}):t))))),null)}const Li=f.memo(ji);function ji(e){let{routes:t,future:r,state:n}=e;return ri(t,void 0,n,r)}var Ar;(function(e){e.UseScrollRestoration="useScrollRestoration",e.UseSubmit="useSubmit",e.UseSubmitFetcher="useSubmitFetcher",e.UseFetcher="useFetcher",e.useViewTransitionState="useViewTransitionState"})(Ar||(Ar={}));var kr;(function(e){e.UseFetcher="useFetcher",e.UseFetchers="useFetchers",e.UseScrollRestoration="useScrollRestoration"})(kr||(kr={}));function Ni(e){let t=f.useRef($t(e)),r=f.useRef(!1),n=ht(),a=f.useMemo(()=>yi(n.search,r.current?null:t.current),[n.search]),i=tr(),o=f.useCallback((l,c)=>{const d=$t(typeof l=="function"?l(a):l);r.current=!0,i("?"+d,c)},[i,a]);return[a,o]}const Mi="desktop://window-lifecycle",Ii=new Set(["button","checkbox","color","file","hidden","image","radio","range","reset","submit"]);function Ui(e){return e instanceof HTMLInputElement?!Ii.has(e.type.toLowerCase()):!1}function Oi(e){const t=e.activeElement;if(Ui(t)||t instanceof HTMLTextAreaElement){const r=t.selectionStart??0,n=t.selectionEnd??r;return n<=r?null:t.value.slice(r,n)}return null}function Ai(e){const t=Oi(e);if(t!==null)return t;const r=e.getSelection();if(!r||r.isCollapsed)return null;const n=r.toString();return n.length>0?n:null}function ki(e,t){var a;const r=(a=e.execCommand)==null?void 0:a.bind(e);if(typeof r!="function")return!1;const n=e.createElement("textarea");n.value=t,n.setAttribute("readonly","true"),n.style.position="fixed",n.style.top="-9999px",n.style.opacity="0",e.body.append(n),n.select();try{return r("copy")}catch{return!1}finally{n.remove()}}async function Fi(e,t,r){var a,i;try{if(await r(t))return}catch{}const n=(a=e.defaultView)==null?void 0:a.navigator;if((i=n==null?void 0:n.clipboard)!=null&&i.writeText)try{await n.clipboard.writeText(t);return}catch{}ki(e,t)}function Vi(e){const{window:t,document:r,writeClipboardText:n}=e;function a(i){if(i.defaultPrevented||!i.metaKey||i.ctrlKey||i.altKey||i.key.toLowerCase()!=="c")return;const o=Ai(r);o&&(i.preventDefault(),Fi(r,o,n))}return t.addEventListener("keydown",a,!0),()=>{t.removeEventListener("keydown",a,!0)}}const dn=f.createContext(null),zi=["--desktop-macos-traffic-light-center-y","--desktop-macos-traffic-light-leading-inset","--desktop-macos-traffic-light-safe-zone-width","--desktop-macos-titlebar-height","--desktop-macos-traffic-light-button-diameter"];function Bi(e){if(typeof document>"u")return;const{documentElement:t,body:r}=document;t.dataset.runtimePlatform=e.platform,t.dataset.osFamily=e.ui.osFamily,t.dataset.windowControls=e.ui.windowControlsStyle,t.dataset.viewportClass=e.viewportClass,t.dataset.overlayTitlebar=String(e.ui.prefersOverlayTitlebar),r&&(r.dataset.runtimePlatform=e.platform,r.dataset.osFamily=e.ui.osFamily,r.dataset.windowControls=e.ui.windowControlsStyle,r.dataset.viewportClass=e.viewportClass,r.dataset.overlayTitlebar=String(e.ui.prefersOverlayTitlebar))}function Kt(){var e;if(!(typeof document>"u"))for(const t of zi)document.documentElement.style.removeProperty(t),(e=document.body)==null||e.style.removeProperty(t)}function Hi(e){if(typeof document>"u")return;if(!e){Kt();return}const t=[document.documentElement,document.body].filter(n=>!!n),r=[["--desktop-macos-traffic-light-center-y",`${e.trafficLightCenterY}px`],["--desktop-macos-traffic-light-leading-inset",`${e.trafficLightLeadingInset}px`],["--desktop-macos-traffic-light-safe-zone-width",`${e.trafficLightSafeZoneWidth}px`],["--desktop-macos-titlebar-height",`${e.titlebarHeight}px`],["--desktop-macos-traffic-light-button-diameter",`${e.trafficLightButtonDiameter}px`]];for(const n of t)for(const[a,i]of r)n.style.setProperty(a,i)}function Wi(){if(!(typeof window>"u"))return window.innerWidth}function $i({children:e}){const[t,r]=f.useState(()=>Wi()),n=f.useMemo(()=>lt({viewportWidth:t}),[t]);return f.useEffect(()=>{if(typeof window>"u")return;function a(){r(window.innerWidth)}return a(),window.addEventListener("resize",a),()=>{window.removeEventListener("resize",a)}},[]),f.useEffect(()=>{Bi(n)},[n]),f.useEffect(()=>{if(!(typeof window>"u"||typeof document>"u")&&!(!n.isDesktop||n.ui.osFamily!=="macos"||!n.bridge.supported))return Vi({window,document,writeClipboardText:async a=>(await n.bridge.writeClipboardText(a)).ok})},[n]),f.useEffect(()=>()=>{Kt()},[]),f.useEffect(()=>{let a=!1,i=null;return!n.isDesktop||!n.bridge.supported?()=>{a=!0}:(J(()=>import("./event-DvH9tcej.js").then(o=>o.c),[]).then(async({listen:o})=>{const l=await o(Mi,c=>{const d=c.payload,m=d==null?void 0:d.descriptor;m!=null&&m.windowId&&(n.windows.registerDescriptor(m),d.isOpen?n.windows.markWindowOpen(m.windowId):n.windows.markWindowClosed(m.windowId))});if(a){l();return}i=l}).catch(()=>{}),()=>{a=!0,i==null||i()})},[n]),f.useEffect(()=>{let a=!1,i=null;async function o(){var c,d;const l=await n.bridge.getRuntimeInfo();a||Hi(l.ok?(d=(c=l.value)==null?void 0:c.windowChrome)==null?void 0:d.macosTitlebar:null)}return!n.isDesktop||n.ui.osFamily!=="macos"||!n.ui.prefersOverlayTitlebar?(Kt(),()=>{a=!0}):(o(),J(()=>import("./window-BWqRixxq.js").then(l=>l.w),__vite__mapDeps([0,1])).then(async({getCurrentWindow:l})=>{const c=await l().onScaleChanged(()=>{o()});if(a){c();return}i=c}).catch(()=>{}),()=>{a=!0,i==null||i()})},[n]),g.jsx(dn.Provider,{value:n,children:e})}function rr(){return f.useContext(dn)??lt()}const Wo=[{id:"light",labelKey:"theme.light",color:"#f6f4ef"},{id:"dark",labelKey:"theme.dark",color:"#1b1b1b"},{id:"sky-blue",labelKey:"theme.skyBlue",color:"#00f0ff"},{id:"eye-green",labelKey:"theme.eyeGreen",color:"#16a34a"}];function $o(e){return it(e.labelKey)}function Ki(){return typeof window>"u"||typeof window.matchMedia!="function"?"light":window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function fn(e,t){return t?Ki():e}function Yi(){const{theme:e,autoTheme:t}=Vn.getState().profile;return fn(e,t)}function Gi(e){Gt({theme:e,autoTheme:!1}).catch(()=>{})}function Ji(e){Gt({autoTheme:e}).catch(()=>{})}function hn(e){typeof window>"u"||document.documentElement.setAttribute("data-theme",e)}function Xi(){const e=Je(n=>n.profile.theme),t=Je(n=>n.profile.autoTheme);return{theme:fn(e,t),selectedTheme:e,autoTheme:t,setTheme:Gi,setAutoTheme:Ji}}function qi(){hn(Yi())}function Qi({children:e}){const t=Je(n=>n.profile.theme),r=Je(n=>n.profile.autoTheme);return f.useEffect(()=>{qi()},[t,r]),f.useEffect(()=>{if(!r||typeof window>"u"||typeof window.matchMedia!="function")return;const n=window.matchMedia("(prefers-color-scheme: dark)"),a=()=>{hn(n.matches?"dark":"light")};return a(),typeof n.addEventListener=="function"?(n.addEventListener("change",a),()=>n.removeEventListener("change",a)):(n.addListener(a),()=>n.removeListener(a))},[r]),g.jsx(g.Fragment,{children:e})}const Zi={showToast:()=>"",dismissToast:()=>{}},mn=f.createContext(Zi);function eo(){return`toast-${Math.random().toString(36).slice(2,10)}`}function to({toast:e,onDismiss:t}){const{id:r,title:n,description:a,tone:i,durationMs:o,action:l}=e;return f.useEffect(()=>{if(o===null)return;const c=window.setTimeout(()=>{t(r)},o);return()=>{window.clearTimeout(c)}},[o,r,t,n,a,i]),g.jsxs("article",{className:"toast-card","data-tone":i,role:i==="error"?"alert":"status",children:[g.jsxs("div",{className:"toast-body",children:[g.jsx("strong",{className:"toast-title",children:n}),a?g.jsx("p",{className:"toast-description",children:a}):null]}),g.jsxs("div",{className:"toast-actions",children:[l?g.jsx("button",{className:"toast-action",type:"button",onClick:()=>{l.onClick(),t(r)},children:l.label}):null,g.jsx("button",{className:"toast-dismiss",type:"button","aria-label":"关闭通知",onClick:()=>t(r),children:"×"})]})]})}function ro({children:e}){const[t,r]=f.useState([]),n=f.useCallback(o=>{r(l=>l.filter(c=>c.id!==o))},[]),a=f.useCallback(o=>{const l=o.id??eo(),c={id:l,title:o.title,description:o.description,tone:o.tone??"info",durationMs:o.durationMs===void 0?4200:o.durationMs,action:o.action};return r(d=>{const m=d.findIndex(b=>b.id===l);if(m===-1)return[...d,c];const p=[...d];return p[m]=c,p}),l},[]),i=f.useMemo(()=>({showToast:a,dismissToast:n}),[n,a]);return g.jsxs(mn.Provider,{value:i,children:[e,g.jsx("div",{className:"toast-viewport","aria-live":"polite","aria-atomic":"false",children:t.map(o=>g.jsx(to,{toast:o,onDismiss:n},o.id))})]})}function Ko(){return f.useContext(mn)}const Pt="0.5.0",pn=f.createContext(Pt);function no({children:e}){const t=rr(),[r,n]=f.useState(Pt);return f.useEffect(()=>{let a=!1;return t.isDesktop?(t.bridge.getRuntimeInfo().then(i=>{var l,c;if(a)return;const o=i.ok?(c=(l=i.value)==null?void 0:l.version)==null?void 0:c.trim():"";n(o||Pt)}),()=>{a=!0}):(n(Pt),()=>{a=!0})},[t]),g.jsx(pn.Provider,{value:r,children:e})}function ao(){return f.useContext(pn)}const Fr={latestState:null,lastNotifiedVersion:null,pendingRestartVersion:null};class io{constructor(){he(this,"state",Fr);he(this,"listeners",new Set);he(this,"subscribe",t=>(this.listeners.add(t),()=>{this.listeners.delete(t)}));he(this,"getState",()=>this.state)}recordState(t){const r=Vt(this.state.pendingRestartVersion),n=Vt(t.currentVersion);this.state={latestState:t,lastNotifiedVersion:t.hasUpdate?this.state.lastNotifiedVersion:null,pendingRestartVersion:r&&r===n?null:this.state.pendingRestartVersion},this.emit()}markVersionNotified(t){this.state.lastNotifiedVersion!==t&&(this.state={...this.state,lastNotifiedVersion:t},this.emit())}markRestartPending(t){const r=Vt(t);!r||this.state.pendingRestartVersion===r||(this.state={...this.state,pendingRestartVersion:r},this.emit())}reset(){this.state=Fr,this.emit()}emit(){for(const t of this.listeners)t()}}const Xe=new io;function Vt(e){const t=e==null?void 0:e.trim();return t||null}function oo(e){return f.useSyncExternalStore(Xe.subscribe,()=>e(Xe.getState()))}function so(){return Xe.getState()}function lo(e){Xe.recordState(e)}function co(e){Xe.markVersionNotified(e)}function uo(e){Xe.markRestartPending(e)}async function fo(){const e=lt(),t=ce.getState(),r=await e.bridge.checkForUpdate(t.releaseChannel);if(!r.ok||!r.value)throw new Error(r.detail??"更新检查失败。");return r.value}async function ho(e={}){const t=e.notify??"never",r=await fo();return lo(r),await mo(r,t),r}async function Yo(){const e=lt(),t=ce.getState();return e.bridge.installUpdate(t.releaseChannel)}function Go(e){uo(e)}async function Jo(){var e;if(typeof window>"u"||typeof((e=window.__TAURI_INTERNALS__)==null?void 0:e.invoke)!="function")throw new Error("当前运行环境不支持桌面应用重启。");try{await window.__TAURI_INTERNALS__.invoke("restart_application")}catch(t){throw new Error(t instanceof Error?t.message:"重启应用失败。")}}async function mo(e,t){var i,o,l;if(!e.hasUpdate||t==="never")return;const r=((o=(i=e.manifest)==null?void 0:i.version)==null?void 0:o.trim())||e.currentVersion.trim();if(!r)return;const n=so().lastNotifiedVersion;if(t==="always"||n!==r)try{(await lt().bridge.showNotification(it("settings.releaseUpdateReady"),((l=e.manifest)==null?void 0:l.version)??e.currentVersion)).ok&&co(r)}catch{}}const po=3600*1e3;function vo(){const e=Rt(a=>a.platform),t=Rt(a=>a.autoCheckUpdate),r=Rt(a=>a.releaseChannel),n=oo(a=>a.pendingRestartVersion);return f.useEffect(()=>{if(e!=="desktop"||!t||n)return;async function a(){try{await ho({notify:"if-new"})}catch{}}a();const i=window.setInterval(()=>{a()},po);return()=>{window.clearInterval(i)}},[t,n,e,r]),null}class go{constructor(){he(this,"state",{epoch:0,activeHostId:zt(ce.getState()),connectionSignature:zr(ce.getState())});he(this,"listeners",new Set);he(this,"subscribe",t=>(this.listeners.add(t),()=>{this.listeners.delete(t)}));he(this,"getState",()=>this.state);ce.subscribe(()=>{const t=ce.getState(),r=zt(t),n=zr(t);r===this.state.activeHostId&&n===this.state.connectionSignature||(this.state={epoch:this.state.epoch+1,activeHostId:r,connectionSignature:n},this.emit())})}emit(){for(const t of this.listeners)t()}}const Vr=new go;function yo(){return f.useSyncExternalStore(Vr.subscribe,()=>{const e=Vr.getState();return`${e.activeHostId??"anonymous"}:${e.epoch}`})}function zr(e){const t=_t(e);return t?JSON.stringify({id:t.id,baseUrl:t.baseUrl,relayTunnel:t.relayTunnel}):"no-host"}const vn="codingns.server.base-url.history",nr=6,gn="__custom__";function yn(){return typeof window<"u"&&typeof window.localStorage<"u"}function bn(){return typeof window>"u"||!window.location.origin?null:window.location.origin}function ar(e){if(!e)return null;try{return Wr(e)}catch{return null}}function wn(){if(!yn())return[];const e=window.localStorage.getItem(vn);if(!e)return[];try{const t=JSON.parse(e);return Array.isArray(t)?t.map(r=>typeof r=="string"?ar(r):null).filter(r=>!!r):[]}catch{return[]}}function bo(e){const t=new Set,r=[];for(const n of e)!n||t.has(n)||(t.add(n),r.push(n));return r}function wo(e){const t=new Set,r=[];for(const n of e)!n||t.has(n.value)||(t.add(n.value),r.push(n));return r}function xo(e,t){const r=wn();return bo([e,...t,...r,ar(bn())]).slice(0,nr)}function So(e){const t=_t(e),r=wn().map(l=>({value:l,source:"history"})),n=ar(bn()),a=e.hosts.map(l=>({value:l.baseUrl,source:"saved"})),i=zn(e).map(l=>({value:l.baseUrl,source:"discovered"})),o=t?{value:t.baseUrl,source:$r(t)?"discovered":"saved"}:null;return wo([o,...a,...i,...r,n?{value:n,source:"origin"}:null]).slice(0,nr)}function Eo(e){yn()&&window.localStorage.setItem(vn,JSON.stringify(e.slice(0,nr)))}class Ro{constructor(){he(this,"state",this.createState(ce.getState()));he(this,"listeners",new Set);he(this,"subscribe",t=>(this.listeners.add(t),()=>{this.listeners.delete(t)}));he(this,"getState",()=>this.state);ce.subscribe(()=>{const t=this.createState(ce.getState());t.baseUrl===this.state.baseUrl&&t.options.length===this.state.options.length&&t.options.every((r,n)=>r===this.state.options[n])&&t.presetOptions.length===this.state.presetOptions.length&&t.presetOptions.every((r,n)=>{const a=this.state.presetOptions[n];return(a==null?void 0:a.value)===r.value&&(a==null?void 0:a.source)===r.source})||(this.state=t,this.emit())})}setBaseUrl(t){const r=ce.getState(),n=_t(r);if(!n)return!1;const a=Wr(t),i=a!==n.baseUrl;if($r(n))return ce.updateRuntime({discoveredHosts:r.discoveredHosts.map(l=>l.id===n.id?{...l,baseUrl:a,name:new URL(a).host,updatedAt:new Date().toISOString()}:l)}),this.state=this.createState(ce.getState()),this.emit(),i;const o=r.hosts.map(l=>l.id===n.id?{...l,baseUrl:a,name:new URL(a).host,updatedAt:new Date().toISOString()}:l);return this.state=this.createState({...r,hosts:o}),this.emit(),ce.update({hosts:o}),i}reset(){this.state=this.createState(ce.getState()),this.emit()}createState(t){const r=_t(t),n=(r==null?void 0:r.baseUrl)??"",a=So(t),i=xo(n,a.map(o=>o.value));return Eo(i),{baseUrl:n,options:i,presetOptions:a}}emit(){for(const t of this.listeners)t()}}const Yt=new Ro;function To(e){return f.useSyncExternalStore(Yt.subscribe,()=>e(Yt.getState()))}function Xo(e,t){return t.includes(e)?e:gn}function qo(){return gn}const Po={login(e,t){return St.login(e,t)},bootstrap(e,t,r){return St.bootstrap(e,t,r)},refresh(){return St.refresh()},logout(){St.clear()}},_o=f.lazy(async()=>({default:(await J(()=>import("./ServerSettingsModal-izoYMx9U.js"),__vite__mapDeps([2,3,4,5]))).ServerSettingsModal})),Br="width=device-width, initial-scale=1.0, viewport-fit=cover",Co="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover";function Do(){const e=f.useRef(null);return f.useEffect(()=>{const t=e.current;if(!t)return;const r=t.getContext("2d");if(!r)return;let n;const a=()=>{o(),l()};let i=[];const o=()=>{t.width=window.innerWidth,t.height=window.innerHeight},l=()=>{i=[];const d=Math.min(50,Math.floor(t.width*t.height/25e3));for(let m=0;m<d;m++)i.push({x:Math.random()*t.width,y:Math.random()*t.height,vx:(Math.random()-.5)*.5,vy:(Math.random()-.5)*.5,size:Math.random()*2+1,opacity:Math.random()*.5+.2})},c=()=>{r.clearRect(0,0,t.width,t.height),i.forEach((d,m)=>{d.x+=d.vx,d.y+=d.vy,d.x<0&&(d.x=t.width),d.x>t.width&&(d.x=0),d.y<0&&(d.y=t.height),d.y>t.height&&(d.y=0),r.beginPath(),r.arc(d.x,d.y,d.size,0,Math.PI*2),r.fillStyle=`rgba(10, 132, 255, ${d.opacity})`,r.fill(),i.slice(m+1).forEach(p=>{const b=d.x-p.x,w=d.y-p.y,P=Math.sqrt(b*b+w*w);P<150&&(r.beginPath(),r.moveTo(d.x,d.y),r.lineTo(p.x,p.y),r.strokeStyle=`rgba(10, 132, 255, ${.1*(1-P/150)})`,r.stroke())})}),n=requestAnimationFrame(c)};return o(),l(),c(),window.addEventListener("resize",a),()=>{window.removeEventListener("resize",a),cancelAnimationFrame(n)}},[]),g.jsx("canvas",{ref:e,className:"particle-canvas"})}function Lo({text:e}){return g.jsx("span",{className:"glitch-text","data-text":e,children:e})}function jo({text:e}){const[t,r]=f.useState(""),[n,a]=f.useState(!0);return f.useEffect(()=>{let i=0,o=null;const l=setInterval(()=>{i<=e.length?(r(e.slice(0,i)),i++):(clearInterval(l),o=window.setTimeout(()=>a(!1),1e3))},50);return()=>{clearInterval(l),o!==null&&window.clearTimeout(o)}},[e]),g.jsxs("span",{className:"typewriter-text",children:[t,n&&g.jsx("span",{className:"typewriter-cursor",children:"_"})]})}function No(e){const t=e==null?void 0:e.captcha;if(typeof t!="object"||t===null)return null;const r=t.captchaId,n=t.imageDataUrl;return typeof r!="string"||typeof n!="string"?null:{captchaId:r,imageDataUrl:n}}function Mo(){const e=tr(),t=Bn(),[r]=Ni(),n=rr(),a=ao(),i=Rt(V=>zt(V)),o=Hn(n.platform),l=f.useMemo(()=>Wn(n),[n]),c=f.useMemo(()=>l?$n(i):{credentials:null,legacyServerBaseUrl:null},[i,l]),d=c.credentials,m=c.legacyServerBaseUrl,[p,b]=f.useState(()=>(d==null?void 0:d.username)??"admin"),[w,P]=f.useState(()=>(d==null?void 0:d.password)??""),[S,D]=f.useState(null),[k,L]=f.useState(""),[K,te]=f.useState(()=>!!d),$=To(V=>V.baseUrl),[pe,v]=f.useState($),[N,F]=f.useState(null),[I,re]=f.useState(!1),[G,oe]=f.useState(!1),[ne,se]=f.useState(null),[He,We]=f.useState(!1),Q=Kr(V=>V.session),Te=f.useMemo(()=>r.get("returnTo")??"/",[r]),{theme:Pe}=Xi(),we=f.useRef(!1),ue=n.isNativeMobile,_e=f.useMemo(()=>Pe==="light"?"light":"dark",[Pe]);f.useEffect(()=>{b((d==null?void 0:d.username)??"admin"),P((d==null?void 0:d.password)??""),D(null),L(""),te(!!d)},[d]),f.useEffect(()=>{if(typeof document>"u")return;const V=document.querySelector('meta[name="viewport"]');if(!(V instanceof HTMLMetaElement))return;const fe=V.getAttribute("content")??Br;return ue?V.setAttribute("content",Co):V.setAttribute("content",Br),()=>{V.setAttribute("content",fe)}},[ue]),f.useEffect(()=>{we.current||(we.current=!0,!(!l||!m||m===$)&&(Yt.setBaseUrl(m),v(m)))},[$,l,m]),f.useEffect(()=>{if(Q){e(Te,{replace:!0});return}if(!pe)return;let V=!1;const fe=window.setTimeout(()=>{J(async()=>{const{probeHost:H}=await import("./index-Byp9hJ0c.js").then(ye=>ye.Q);return{probeHost:H}},__vite__mapDeps([3,4])).then(({probeHost:H})=>H(pe)).then(H=>{V||(H.demoMode&&(We(!0),Kn()&&F(t("auth.demoSessionExpired"))),H.reachable&&!H.initialized&&e("/bootstrap",{replace:!0}))}).catch(()=>{V||F(t("auth.authUnavailable"))})},0);return()=>{V=!0,window.clearTimeout(fe)}},[Q,e,pe,Te,t]);async function Ie(V){V.preventDefault(),re(!0),F(null),v($),l&&!K&&i&&Yn(i);try{const fe=S?{username:p,password:w,captchaId:S.captchaId,captchaCode:k}:{username:p,password:w};await Po.login(fe,$),D(null),L("");const{userPreferenceStore:H}=await J(async()=>{const{userPreferenceStore:ye}=await import("./index-Byp9hJ0c.js").then(pt=>pt.P);return{userPreferenceStore:ye}},__vite__mapDeps([3,4]));await H.refreshForAuthenticatedUser(),l&&K&&i&&Gn({hostId:i,username:p,password:w}),e(Te,{replace:!0})}catch(fe){if(fe instanceof Jn){if(fe.errorCode==="BOOTSTRAP_REQUIRED"){e("/bootstrap",{replace:!0});return}const H=No(fe.data);H?(D(H),L("")):fe.errorCode==="INVALID_CREDENTIALS"&&(D(null),L("")),F(fe.message)}else F(t("auth.authUnavailable"))}finally{re(!1)}}function de(V){b(V),S&&(D(null),L(""))}function xe(V){v(V),F(null)}const ge="login-username",Ue="login-password",mt="login-captcha";return g.jsxs("main",{className:"cyber-login-page","data-theme":_e,"data-native-mobile":ue?"true":"false",children:[g.jsxs("div",{className:"cyber-bg",children:[g.jsx("div",{className:"cyber-grid"}),g.jsx("div",{className:"cyber-glow cyber-glow-1"}),g.jsx("div",{className:"cyber-glow cyber-glow-2"}),g.jsx(Do,{})]}),g.jsx("div",{className:"scanlines"}),g.jsxs("div",{className:"cyber-login-container",children:[g.jsx("div",{className:"cyber-login-toolbar",children:g.jsx(Zn,{variant:"compact"})}),g.jsxs("div",{className:"cyber-login-content",children:[g.jsxs("div",{className:"cyber-brand",children:[g.jsx("div",{className:"cyber-logo",children:g.jsx("img",{src:"/logo.png",alt:"CodingNS",className:"cyber-logo-svg"})}),g.jsx("h1",{className:"cyber-brand-title",children:g.jsx(Lo,{text:"CodingNS"})}),g.jsx("p",{className:"cyber-brand-subtitle",children:g.jsx(jo,{text:t("auth.loginSubtitle")})})]}),g.jsxs("div",{className:"cyber-card",children:[g.jsx("div",{className:"cyber-corner corner-tl"}),g.jsx("div",{className:"cyber-corner corner-tr"}),g.jsx("div",{className:"cyber-corner corner-bl"}),g.jsx("div",{className:"cyber-corner corner-br"}),g.jsxs("div",{className:"cyber-card-header",children:[g.jsx("div",{className:"cyber-line"}),g.jsx("span",{className:"cyber-card-label",children:t("auth.loginTitle").toUpperCase()}),g.jsx("div",{className:"cyber-line"})]}),He?g.jsxs("div",{className:"cyber-demo-banner",children:[g.jsx("span",{className:"cyber-demo-icon",children:"⚠"}),g.jsx("span",{children:t("auth.demoBanner")})]}):null,g.jsxs("form",{className:"cyber-form",onSubmit:Ie,children:[g.jsxs("div",{className:`cyber-field ${ne==="username"?"focused":""}`,children:[g.jsx("div",{className:"cyber-field-border",children:g.jsx("div",{className:"cyber-field-border-glow"})}),g.jsxs("label",{className:"cyber-field-label",htmlFor:ge,children:[g.jsx("span",{className:"cyber-field-icon",children:"❯"}),t("auth.username")]}),g.jsx("input",{id:ge,"aria-label":t("auth.username"),className:"cyber-input",value:p,onChange:V=>de(V.target.value),onFocus:()=>se("username"),onBlur:()=>se(null),autoComplete:"username"})]}),g.jsxs("div",{className:`cyber-field ${ne==="password"?"focused":""}`,children:[g.jsx("div",{className:"cyber-field-border",children:g.jsx("div",{className:"cyber-field-border-glow"})}),g.jsxs("label",{className:"cyber-field-label",htmlFor:Ue,children:[g.jsx("span",{className:"cyber-field-icon",children:"⚷"}),t("auth.password")]}),g.jsx("input",{id:Ue,"aria-label":t("auth.password"),className:"cyber-input",type:"password",value:w,onChange:V=>P(V.target.value),onFocus:()=>se("password"),onBlur:()=>se(null),autoComplete:"current-password"})]}),S?g.jsxs("div",{className:"cyber-captcha-panel",children:[g.jsx("img",{alt:t("auth.captchaImageAlt"),className:"cyber-captcha-image",draggable:!1,src:S.imageDataUrl}),g.jsx("p",{className:"cyber-captcha-hint",children:t("auth.captchaHint")}),g.jsxs("div",{className:`cyber-field ${ne==="captcha"?"focused":""}`,children:[g.jsx("div",{className:"cyber-field-border",children:g.jsx("div",{className:"cyber-field-border-glow"})}),g.jsxs("label",{className:"cyber-field-label",htmlFor:mt,children:[g.jsx("span",{className:"cyber-field-icon",children:"#"}),t("auth.captcha")]}),g.jsx("input",{id:mt,"aria-label":t("auth.captcha"),className:"cyber-input",placeholder:t("auth.captchaPlaceholder"),value:k,onChange:V=>L(V.target.value),onFocus:()=>se("captcha"),onBlur:()=>se(null),autoComplete:"one-time-code"})]})]}):null,l?g.jsxs("label",{className:"cyber-remember-toggle",children:[g.jsx("input",{"aria-label":t("auth.rememberPassword"),type:"checkbox",checked:K,onChange:V=>te(V.target.checked)}),g.jsx("span",{children:t("auth.rememberPassword")})]}):null,N?g.jsxs("div",{className:"cyber-status","data-tone":"error",children:[g.jsx("span",{className:"cyber-status-icon",children:"⚠"}),g.jsx("span",{children:N})]}):null,g.jsxs("button",{className:`cyber-submit ${I?"loading":""}`,type:"submit",disabled:I,children:[g.jsx("span",{className:"cyber-submit-glow"}),g.jsx("span",{className:"cyber-submit-border"}),g.jsx("span",{className:"cyber-submit-text",children:I?g.jsxs(g.Fragment,{children:[g.jsx("span",{className:"cyber-spinner"}),t("common.loading")]}):g.jsxs(g.Fragment,{children:[g.jsx("span",{className:"cyber-submit-icon",children:"➤"}),t("auth.submitLogin")]})})]})]}),o?g.jsxs("div",{className:"cyber-footer",children:[g.jsxs("div",{className:"cyber-divider",children:[g.jsx("span",{className:"cyber-divider-line"}),g.jsx("span",{className:"cyber-divider-text",children:"//"}),g.jsx("span",{className:"cyber-divider-line"})]}),g.jsxs("button",{className:"cyber-server-btn",onClick:()=>oe(!0),type:"button",children:[g.jsx("span",{className:"cyber-server-icon",children:"⚙"}),g.jsx("span",{className:"cyber-server-text",children:t("auth.serverSettings")}),g.jsx("span",{className:"cyber-server-current",children:$})]})]}):null]})]}),g.jsxs("div",{className:"cyber-version",children:[g.jsxs("span",{className:"cyber-version-text",children:["v",a]}),g.jsx("span",{className:"cyber-version-divider",children:"|"}),g.jsx("span",{className:"cyber-version-text",children:"SYSTEM READY"})]})]}),o&&G?g.jsx(f.Suspense,{fallback:null,children:g.jsx(_o,{isOpen:G,onClose:()=>oe(!1),onSave:xe})}):null]})}function Io({isDesktop:e,viewportClass:t}){return e||t==="expanded"?"desktop":"mobile"}function Uo({runtimeKey:e,children:t}){return g.jsx("div",{children:t},e)}function Oo(){const e=yo();return g.jsx(Uo,{runtimeKey:e,children:g.jsx(pi,{})})}function Ao(){const e=Kr(r=>r.session),t=ht();if(!e){const r=`${t.pathname}${t.search}`;return g.jsx(un,{to:`/login?returnTo=${encodeURIComponent(r)}`,replace:!0})}return g.jsx(Oo,{})}function Hr(){const e=rr(),t=Io(e);return g.jsx(un,{to:t==="mobile"?"/workspaces":"/landing",replace:!0})}function ae(e,t){return async()=>({Component:(await e())[t]})}const ko=[{path:"/bootstrap",lazy:ae(()=>J(()=>import("./BootstrapPage-Vu5oEJ8z.js"),__vite__mapDeps([6,3,4])),"BootstrapPage")},{path:"/login",element:g.jsx(Mo,{})},{path:"/desktop-window-preview",lazy:ae(()=>J(()=>import("./DesktopDetachPreviewPage-BgeEqbc5.js"),__vite__mapDeps([7,3,4])),"DesktopDetachPreviewPage")},{path:"/",element:g.jsx(Ao,{}),children:[{path:"desktop-window/:windowId",lazy:ae(()=>J(()=>import("./DesktopWindowPage-1WelvxdH.js"),__vite__mapDeps([8,3,4,9,10,11,0,1,5,12,13,14,15,16,17,18,19,20,21])),"DesktopWindowPage")},{lazy:ae(()=>J(()=>import("./WorkbenchShellRoute-Kw7JEZI3.js"),__vite__mapDeps([22,3,4,11,9,0,1,5,23])),"WorkbenchShellRoute"),children:[{index:!0,element:g.jsx(Hr,{})},{path:"landing",lazy:ae(()=>J(()=>import("./WorkbenchLandingPage-kvlfyxRo.js"),__vite__mapDeps([24,3,4,11,9,0,1,5])),"WorkbenchLandingPage")},{path:"workspaces",lazy:ae(()=>J(()=>import("./WorkspaceHomePage-wR8d3aP9.js"),__vite__mapDeps([25,3,4,11,9,0,1,5,26,19,20,27])),"WorkspaceHomePage")},{path:"workspaces/:workspaceId",lazy:ae(()=>J(()=>import("./WorkspaceDetailPage-D0Lrx4Uz.js"),__vite__mapDeps([28,3,4,11,9,0,1,5,29,16,19,20,27])),"WorkspaceDetailPage")},{path:"workspaces/:workspaceId/debug",lazy:ae(()=>J(()=>import("./WorkspaceDebugDetailPage-Com5kEXJ.js"),__vite__mapDeps([30,3,4,29,9,16,11,0,1,5])),"WorkspaceDebugDetailPage")},{path:"workspaces/:workspaceId/sessions",lazy:ae(()=>J(()=>import("./SessionIndexPage-C5aG8FIv.js"),__vite__mapDeps([31,3,4,9,11,0,1,5,19,20,27,32,33])),"SessionIndexPage")},{path:"workspaces/:workspaceId/sessions/:sessionId",lazy:ae(()=>J(()=>import("./ConversationPage-Cjpg6g0J.js"),__vite__mapDeps([34,3,4,5,9,14,11,0,1,35,12,10,13,15,16,17,19,20,32,33])),"ConversationPage")},{path:"workspaces/:workspaceId/tools",lazy:ae(()=>J(()=>import("./ToolsHomePage-4fP-KRiv.js"),__vite__mapDeps([36,3,4,11,9,0,1,5])),"ToolsHomePage")},{path:"workspaces/:workspaceId/tools/files",lazy:ae(()=>J(()=>import("./ToolFilesPage-DcYPsS-e.js"),__vite__mapDeps([37,3,4,11,9,0,1,5])),"ToolFilesPage")},{path:"workspaces/:workspaceId/tools/git",lazy:ae(()=>J(()=>import("./ToolGitPage-CsPl89ty.js"),__vite__mapDeps([38,3,4,11,9,0,1,5])),"ToolGitPage")},{path:"workspaces/:workspaceId/tools/processes",lazy:ae(()=>J(()=>import("./ToolProcessesPage-D0dvR8xK.js"),__vite__mapDeps([39,3,4,11,9,0,1,5])),"ToolProcessesPage")},{path:"workspaces/:workspaceId/terminals",lazy:ae(()=>J(()=>import("./TerminalPage-CtKXIU0h.js"),__vite__mapDeps([18,3,4,9,11,0,1,5,19,20,16,17,21])),"TerminalPage")},{path:"workspaces/:workspaceId/butler",lazy:ae(()=>J(()=>import("./AdaptiveButlerPage-R-XZw7pd.js"),__vite__mapDeps([40,3,4,11,9,0,1,5,35,12,10,26,14,19,20,41])),"AdaptiveButlerPage")},{path:"settings",lazy:ae(()=>J(()=>import("./SettingsPage-HJIC-P-4.js"),__vite__mapDeps([42,3,4,9,5,20])),"SettingsPage")},{path:"settings/:section",lazy:ae(()=>J(()=>import("./SettingsPage-HJIC-P-4.js"),__vite__mapDeps([42,3,4,9,5,20])),"SettingsPage")},{path:"*",element:g.jsx(Hr,{})}]}]}];function Fo(){return wi(ko)}function Vo(){const e=Je(r=>r.profile.language),t=f.useMemo(()=>Fo(),[]);return g.jsx($i,{children:g.jsx(no,{children:g.jsx(Xn,{language:e,children:g.jsx(Qi,{children:g.jsxs(ro,{children:[g.jsx(vo,{}),g.jsx(Di,{router:t})]})})})})})}const Qo=Object.freeze(Object.defineProperty({__proto__:null,App:Vo},Symbol.toStringTag,{value:"Module"}));export{Qo as A,Zn as L,un as N,pi as O,Wo as T,To as a,Po as b,Ho as c,rr as d,Ko as e,Yr as f,ht as g,oo as h,Xi as i,ho as j,Yo as k,Go as l,br as m,Jo as n,ao as o,$o as p,Xo as q,Io as r,qo as s,Yt as t,tr as u};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{b as u,j as i,t as o,A as An}from"./index-Byp9hJ0c.js";import{e as Bn,d as ci,f as ui}from"./App-DkvE5EyM.js";import{ac as fi,u as di}from"./MobileSheet-DLg-gX1t.js";import{au as hi,r as Vt,w as vt,av as pi,u as mi,X as we,aw as bi,ax as Wt,ay as ft,az as vi,aA as xi,aB as yi}from"./WorkbenchLayout-ByFw4eeu.js";import{W as gi}from"./WorkbenchModal-Ctob14VR.js";import{a as jt,b as St,F as Ci}from"./file-tree-icon-UFVoVzhM.js";import"./window-BWqRixxq.js";import"./event-DvH9tcej.js";const Pi=new Set([".ds_store","thumbs.db","ehthumbs.db","desktop.ini",".spotlight-v100",".trashes",".fseventsd","__macosx","$recycle.bin","system volume information",".apdisk",".appledouble",".temporaryitems"]),ji=["._"];function $t(t){return t.split(/[/\\]/).filter(Boolean).pop()??t}function Si(t){const n=t.trim().toLowerCase();return n?Pi.has(n)||ji.some(a=>n.startsWith(a)):!1}function Gt(t,n,a){return a?[...t]:t.filter(r=>!Si(n(r)))}function xt(t,n){return Gt(t,a=>a.name,n)}function wi(t,n){return n?t:Object.entries(t).reduce((a,[r,h])=>(a[r]=xt(h,!1),a),{})}async function Ot(t,n){const[a,r]=await Promise.all([hi(n),fi(t)]);return Ni(a.changes,r.items)}function Ni(t,n){const a=new Set(n.map(r=>gt(r.path)));return t.filter(r=>a.has(gt(r.path))||r.oldPath!==null&&a.has(gt(r.oldPath)))}function Di(t){const n=Sn("","");for(const a of t){const r=gt(a.path),h=r.split("/").filter(Boolean);let d=n;h.forEach((m,y)=>{const C=h.slice(0,y+1).join("/");if(y===h.length-1){d.children.set(`file:${C}`,{kind:"file",name:m,path:r,change:a});return}const T=`directory:${C}`,k=d.children.get(T);if(k&&k.kind==="directory"){d=k;return}const V=Sn(m,C);d.children.set(T,V),d=V})}return $n(Wn([...n.children.values()]))}function Ln(t,n){const a=t.oldPath?`${t.oldPath} -> ${t.path}`:t.path;return Xt(t)?`${a} ${n}`:a}function Xt(t){return t.status==="D"||t.stagedStatus==="D"||t.worktreeStatus==="D"}function yt(t){return t.split("/").filter(Boolean).pop()??t}function gt(t){return t.replace(/\\/g,"/").replace(/^\.\//,"").trim()}function Sn(t,n){return{kind:"directory",name:t,path:n,children:new Map}}function Wn(t){return[...t].sort((n,a)=>n.kind!==a.kind?n.kind==="directory"?-1:1:n.name.localeCompare(a.name,"zh-CN")).map(n=>n.kind==="directory"?{kind:"directory",name:n.name,path:n.path,children:Wn([...n.children.values()])}:n)}function $n(t){return t.map(n=>{var m;if(n.kind!=="directory")return n;const a=$n(n.children);let r=n.name,h=n.path,d=a;for(;d.length===1&&((m=d[0])==null?void 0:m.kind)==="directory";){const y=d[0];r=`${r}/${y.name}`,h=y.path,d=y.children}return{kind:"directory",name:r,path:h,children:d}})}const Ei=450,ki=60*1e3,wn=20,Nn=16;function Mi({sessionId:t,workspaceId:n,showSystemFiles:a,selectedPath:r,refreshVersion:h,onCountChange:d,onSelectFile:m,onOpenFile:y}){const[C,T]=u.useState("tree"),[k,V]=u.useState([]),[oe,L]=u.useState(!0),[re,ce]=u.useState(!1),[W,et]=u.useState([]),D=u.useRef(null),{showToast:pe}=Bn();u.useEffect(()=>{const b=Vt(dt(n,t),ki);T("tree"),V(b??[]),L(b===null),ce(!1),et([]),D.current=null},[t,n]),u.useEffect(()=>{let b=!1;async function v(){L(!0);try{const j=await Ot(t,n);b||(V(j),vt(dt(n,t),j))}catch(j){b||pe({title:Ht(j,o("conversation.filePanelSessionLoadFailed")),tone:"error"})}finally{b||L(!1)}}return v(),()=>{b=!0}},[h,t,pe,n]);async function Nt(){L(!0);try{const b=await Ot(t,n);V(b),vt(dt(n,t),b)}catch(b){pe({title:Ht(b,o("conversation.filePanelSessionLoadFailed")),tone:"error"})}finally{L(!1)}}async function me(){if(Ne.length!==0){ce(!0);try{await pi(n,Ne.map(v=>v.path));const b=await Ot(t,n);V(b),vt(dt(n,t),b),pe({title:o("conversation.filePanelSessionStageSuccess"),tone:"success"})}catch(b){pe({title:Ht(b,o("git.stageFailed")),tone:"error"})}finally{ce(!1)}}}function w(b){et(v=>v.includes(b)?v.filter(j=>j!==b):[...v,b])}function B(b){const v=Date.now(),j=D.current;return D.current={filePath:b,timestamp:v},(j==null?void 0:j.filePath)===b&&v-j.timestamp<=Ei}async function $(b,v){if(v&&B(b)){await y(b),D.current=null;return}v||(D.current=null),await m(b)}const N=u.useMemo(()=>Gt(k,b=>yt(b.path),a),[k,a]),Ne=N.filter(b=>!b.staged),O=Di(N),De=new Set(W);return u.useEffect(()=>{d==null||d(N.length)},[d,N.length]),i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"file-panel-session-toolbar",children:[i.jsxs("div",{className:"file-panel-view-modes",role:"tablist","aria-label":o("conversation.filePanelSessionViewLabel"),children:[i.jsx("button",{className:C==="tree"?"file-panel-view-button active":"file-panel-view-button",type:"button",role:"tab","aria-selected":C==="tree",onClick:()=>T("tree"),children:o("conversation.filePanelSessionTreeView")}),i.jsx("button",{className:C==="list"?"file-panel-view-button active":"file-panel-view-button",type:"button",role:"tab","aria-selected":C==="list",onClick:()=>T("list"),children:o("conversation.filePanelSessionListView")})]}),i.jsxs("div",{className:"file-panel-session-actions",children:[i.jsx("button",{className:"secondary-button",type:"button",onClick:()=>void Nt(),disabled:oe||re,children:o("conversation.filePanelRefresh")}),i.jsx("button",{className:"primary-button",type:"button",onClick:()=>void me(),disabled:re||Ne.length===0,children:o("conversation.filePanelSessionStageAll")})]})]}),i.jsxs("div",{className:"file-panel-session-summary",children:[i.jsx("span",{children:`${o("conversation.filePanelSessionSummary")} ${N.length}`}),i.jsx("span",{children:`${o("conversation.filePanelSessionUnstagedSummary")} ${Ne.length}`})]}),i.jsx("div",{className:"file-tree",children:oe?i.jsx("p",{className:"file-tree-status status-text",children:o("conversation.filePanelSessionLoading")}):N.length===0?i.jsx("p",{className:"file-tree-status status-text",children:o("conversation.filePanelSessionEmpty")}):C==="tree"?On({nodes:O,depth:0,collapsedPathSet:De,selectedPath:r,onToggleTreePath:w,onFileClick:$}):_i({items:N,selectedPath:r,onFileClick:$})})]})}function On({nodes:t,depth:n,collapsedPathSet:a,selectedPath:r,onToggleTreePath:h,onFileClick:d}){return t.map(m=>{if(m.kind==="directory"){const y=!a.has(m.path);return i.jsxs("div",{className:"file-tree-node",children:[i.jsxs("button",{className:"file-tree-item",type:"button","data-kind":"directory","aria-expanded":y,style:{paddingInlineStart:`${wn+n*Nn}px`},onClick:()=>h(m.path),children:[i.jsx("span",{className:"file-tree-chevron","aria-hidden":"true",children:y?"v":">"}),i.jsx("span",{className:"file-tree-label",children:m.name})]}),y?i.jsx("div",{className:"file-tree-children",children:On({nodes:m.children,depth:n+1,collapsedPathSet:a,selectedPath:r,onToggleTreePath:h,onFileClick:d})}):null]},`session-directory:${m.path}`)}return i.jsx("div",{className:"file-tree-node",children:i.jsxs("button",{className:"file-tree-item is-session-change",type:"button","data-active":r===m.change.path,"data-kind":"file",style:{paddingInlineStart:`${wn+n*Nn}px`},onClick:()=>void d(m.change.path,!Xt(m.change)),children:[i.jsx("span",{className:"file-tree-chevron is-hidden","aria-hidden":"true",children:">"}),i.jsx("span",{className:"git-tree-file-icon","data-kind":St(m.name),"aria-hidden":"true",children:jt(m.name)}),i.jsxs("span",{className:"file-tree-label",children:[i.jsx("span",{className:"file-tree-name",children:m.name}),i.jsx("span",{className:"file-tree-path",children:Ln(m.change,o("conversation.filePanelSessionDeleted"))})]}),i.jsxs("span",{className:"file-session-item-meta",children:[i.jsx("span",{className:"file-session-badge","data-status":m.change.status,children:m.change.status}),i.jsx("span",{className:"file-session-badge subtle",children:m.change.staged?o("git.stagedLabel"):o("git.workingTreeLabel")})]})]})},`session-file:${m.path}`)})}function _i({items:t,selectedPath:n,onFileClick:a}){return t.map(r=>i.jsx("div",{className:"file-session-list-item",children:i.jsxs("button",{className:"file-session-list-button",type:"button","data-active":n===r.path,onClick:()=>void a(r.path,!Xt(r)),children:[i.jsx("span",{className:"git-tree-file-icon","data-kind":St(yt(r.path)),"aria-hidden":"true",children:jt(yt(r.path))}),i.jsxs("span",{className:"file-tree-label",children:[i.jsx("span",{className:"file-tree-name",children:yt(r.path)}),i.jsx("span",{className:"file-tree-path",children:Ln(r,o("conversation.filePanelSessionDeleted"))})]}),i.jsxs("span",{className:"file-session-item-meta",children:[i.jsx("span",{className:"file-session-badge","data-status":r.status,children:r.status}),i.jsx("span",{className:"file-session-badge subtle",children:r.staged?o("git.stagedLabel"):o("git.workingTreeLabel")})]})]})},`session-list:${r.path}`))}function dt(t,n){return`file-panel.session-changes.${t}.${n}`}function Ht(t,n){return t instanceof An?t.message:typeof t=="object"&&t&&"message"in t?String(t.message??n):n}const g="",Ti=450,Z=8,ht=4,Ri=176,Fi=120,Ai=300*1e3,Bi=60*1e3,Dn=1600,Li=20,Wi=16;function wa({className:t,sessionId:n,workspaceId:a,hideHeading:r=!1,hideTabs:h=!1,externalRevealRequest:d=null,externalWindowMode:m=!1,workbenchShellOverrides:y}){var Cn,Pn;const C=mi(),{navigationGroups:T,subscribeFileTree:k,requestFileTreeRefresh:V,addFileTreeSnapshotListener:oe,subscribeGitSnapshot:L,requestGitRefresh:re,addGitSnapshotListener:ce}={...C,...y},[W,et]=u.useState({}),[D,pe]=u.useState([]),[Nt,me]=u.useState([]),[w,B]=u.useState(g),[$,N]=u.useState([]),[Ne,O]=u.useState(null),[De,b]=u.useState(!1),[v,j]=u.useState(!1),[E,tt]=u.useState(!1),[Le,We]=u.useState(!1),[Q,$e]=u.useState(""),[Dt,I]=u.useState(null),[nt,it]=u.useState(!1),[at,st]=u.useState(null),[H,Oe]=u.useState("workspace"),[Yt,lt]=u.useState(0),[Zt,Et]=u.useState(0),[He,ue]=u.useState(!1),[ze,z]=u.useState(!1),[ee,K]=u.useState(null),[fe,Ee]=u.useState(null),[R,ke]=u.useState(null),[F,Jt]=u.useState(null),[Qt,It]=u.useState([]),[G,kt]=u.useState(!1),[Gn,be]=u.useState(null),te=u.useRef({}),M=u.useRef([]),X=u.useRef(g),Ue=u.useRef(!1),Ve=u.useRef(null),en=u.useRef(null),tn=u.useRef(null),Mt=u.useRef(null),nn=u.useRef(null),an=u.useRef(null),ve=u.useRef(0),ne=u.useRef(new Map),{showToast:P}=Bn(),Ke=ci(),q=di(e=>e.showSystemFiles),Ge=!!(n!=null&&n.trim()),sn=r&&Ke.isMobile;u.useEffect(()=>{we("file_panel.props",{sessionId:n,workspaceId:a,externalWindowMode:m})},[m,n,a]),u.useEffect(()=>{X.current=w},[w]);function xe(e){et(s=>{const l=typeof e=="function"?e(s):e;return te.current=l,l})}function Me(e){pe(s=>{const l=typeof e=="function"?e(s):e;return M.current=l,l})}u.useEffect(()=>{var f,p;if(Ft(),!a){Ft(),Ue.current=!1,te.current={},M.current=[],X.current=g,xe({}),Me([]),me([]),B(g),We(!1),$e(""),I(null),it(!1),b(!1),kt(!1),be(null),N([]),O(null),K(null),Ee(null),ke(null);return}Ue.current=!0;const e=Vt(Tn(a),Ai);we("file_panel.workspace_snapshot",{workspaceId:a,cached:!!e,cachedRootItems:((p=(f=e==null?void 0:e.treeCache)==null?void 0:f[g])==null?void 0:p.length)??0,cachedDirectoryCount:Object.keys((e==null?void 0:e.treeCache)??{}).length});const s=ea((e==null?void 0:e.activeDirectoryPath)??g,(e==null?void 0:e.treeCache)??{}),l=_n((e==null?void 0:e.expandedDirectories)??[],s),c=bt((e==null?void 0:e.treeCache)??{},s,l);te.current=c,M.current=l,X.current=s,xe(c),Me(l),me([]),B(s),b(!1),j(!1),We(!1),$e(""),I(null),it(!1),queueMicrotask(()=>{Ue.current=!1})},[a]),u.useEffect(()=>{if(!d||d.workspaceId!==a)return;const e=()=>{if(an.current===d.requestId)return;an.current=d.requestId,Oe("workspace"),(d.openViewer?Fe(d.filePath):he(d.filePath)).catch(l=>{P({title:J(l,o("conversation.filePanelOpenFailed")),tone:"error"})})};if(Ue.current){queueMicrotask(e);return}e()},[d,Fe,he,P,a]),u.useEffect(()=>{if(a)return oe(e=>{e.workspaceId===a&&(xe(s=>({...s,[e.path]:e.items})),e.path===g&&b(!1),me(s=>s.filter(l=>l!==e.path)),Yn(e.path,e.items))})},[oe,a]),u.useEffect(()=>()=>{Ft()},[]),u.useEffect(()=>{a&&k(a,Ut(M.current,X.current))},[w,D,k,a]),u.useEffect(()=>{N([]),O(null),st(null),be(null),lt(0),ue(!1),z(!1),K(null),Ee(null),ke(null),Ve.current=null,ve.current+=1},[n]),u.useEffect(()=>{!Ge&&H==="session"&&Oe("workspace")},[H,Ge]),u.useEffect(()=>{h&&H!=="workspace"&&Oe("workspace")},[H,h]),u.useEffect(()=>{if(!He&&!ze&&!ee)return;function e(l){var x,S,ae;if(!(l.target instanceof Node))return;const c=((x=en.current)==null?void 0:x.contains(l.target))??!1,f=((S=tn.current)==null?void 0:S.contains(l.target))??!1,p=((ae=Mt.current)==null?void 0:ae.contains(l.target))??!1;!c&&!f&&!p&&(ue(!1),z(!1),K(null),Ee(null))}function s(l){l.key==="Escape"&&(ue(!1),z(!1),K(null),Ee(null))}return document.addEventListener("pointerdown",e),document.addEventListener("keydown",s),()=>{document.removeEventListener("pointerdown",e),document.removeEventListener("keydown",s)}},[He,ze,ee]),u.useLayoutEffect(()=>{if(!ee||typeof window>"u"){Ee(null);return}const e=ee;function s(){const c=Mt.current;if(!c)return;const f=c.getBoundingClientRect();Ee(Gi({x:e.positionX,y:e.positionY},{width:f.width||Ri,height:f.height||c.scrollHeight||0},{width:window.innerWidth,height:window.innerHeight}))}s();const l=window.requestAnimationFrame(s);return window.addEventListener("resize",s),window.addEventListener("scroll",s,!0),()=>{window.cancelAnimationFrame(l),window.removeEventListener("resize",s),window.removeEventListener("scroll",s,!0)}},[ee]),u.useEffect(()=>{if(!a)return;const e=_n(D,w),s=bt(W,w,e);vt(Tn(a),{treeCache:s,expandedDirectories:e,activeDirectoryPath:w})},[w,D,W,a]),u.useEffect(()=>{if(Ue.current)return;const e=bt(W,w,D);na(W,e)||xe(e)},[w,D,W]),u.useEffect(()=>{let e=!1;const s=(a==null?void 0:a.trim())??null;async function l(f){if(!s)return;const p=xt(te.current[g]??[],q),x=(f==null?void 0:f.silent)!==!0&&p.length===0;x&&b(!0),we("file_panel.load_root_tree.start",{sessionId:n,workspaceId:s,silent:(f==null?void 0:f.silent)===!0,cachedRootItems:p.length});try{const S=await Rt(g,{force:!0});e||(we("file_panel.load_root_tree.end",{sessionId:n,workspaceId:s,itemCount:S.length}),xe(ae=>({...bt(ae,X.current,M.current),[g]:S})))}catch(S){!e&&!Rn(S)&&P({title:J(S,o("conversation.filePanelLoadFailed")),tone:"error"})}finally{!e&&x&&b(!1)}}if(xt(te.current[g]??[],q).length>0){const f=window.setTimeout(()=>{s&&(k(s,Ut(M.current,X.current)),l({silent:!0}))},1500);return()=>{e=!0,window.clearTimeout(f)}}return l(),()=>{e=!0}},[n,q,P,a]),u.useEffect(()=>{if(!a||!n){Et(0);return}const e=Vt(ia(a,n),Bi);we("file_panel.session_change_count.snapshot",{sessionId:n,workspaceId:a,cached:e!==null,cachedCount:e}),Et(e??0)},[n,Yt,a]),u.useEffect(()=>{if(!a){It([]);return}const e=a.trim();L(e),re(e)},[a,L,re]),u.useEffect(()=>{if(!a)return;const e=a.trim();return ce(s=>{var l;s.workspaceId===e&&It(((l=s.status)==null?void 0:l.changes)??[])})},[ce,a]);const ot=u.useMemo(()=>Gt(Qt,e=>$t(e.path),q),[Qt,q]),A=u.useMemo(()=>{const e=new Map,s=new Set;for(const l of ot){const c=l.path.replace(/\\/g,"/"),f=l.worktreeStatus??l.stagedStatus??l.status;e.set(c,f);const p=c.split("/");for(let x=1;x<p.length;x++)s.add(p.slice(0,x).join("/"))}return{statusByPath:e,changedDirs:s}},[ot]),ye=u.useMemo(()=>wi(W,q),[q,W]),ge=u.useMemo(()=>Dt===null?null:xt(Dt,q),[Dt,q]),_e=ye[g]??[],Ce=Le&&ge!==null,rt=u.useMemo(()=>G?Kt(_e,ye,A.statusByPath,A.changedDirs):_e,[A.changedDirs,A.statusByPath,_e,G,ye]),Xn=u.useMemo(()=>Ce?(ge??[]).map(e=>U(e.path,e.kind)):Hn(rt,ye,D,G,A.statusByPath,A.changedDirs),[D,A.changedDirs,A.statusByPath,Ce,G,ge,ye,rt]),Te=((Cn=T.find(e=>e.workspace.id===a))==null?void 0:Cn.workspace)??null,_=Mn($),_t=(_==null?void 0:_.path)??null,de=(_==null?void 0:_.kind)==="file"?_.path:null,ct=u.useMemo(()=>new Set($.map(e=>e.path)),[$]),Xe=u.useMemo(()=>mt($),[$]),Tt=!!(Te!=null&&Te.path&&$.length===1&&_t),ln=$.length===1&&(_==null?void 0:_.kind)==="file",on=Xe.length>0,Pe=Xe.length>0,qe=!!(F!=null&&F.items.length&&a),rn=!!((de?le(de):w)&&D.length);async function cn(e,s=!1){if(!a)return[];if(!s){const l=te.current[e];if(l)return l}e===g?b(!0):me(l=>Pt(l,e));try{const l=await Rt(e,{force:s});return xe(c=>({...c,[e]:l})),l}catch(l){throw Rn(l)||P({title:J(l,o("conversation.filePanelLoadFailed")),tone:"error"}),l}finally{e===g?b(!1):me(l=>l.filter(c=>c!==e))}}async function je(e){if(!a)return;const s=(e==null?void 0:e.activeDirectoryPath)??X.current,l=(e==null?void 0:e.expandedDirectories)??M.current,c=ta(te.current,s,l);we("file_panel.refresh_tree_cache.start",{sessionId:n,workspaceId:a,targetDirectories:c});const p=(await Promise.all(c.map(async x=>{const S=await Rt(x,{force:!0});return[x,S]}))).reduce((x,[S,ae])=>(x[S]=ae,x),{});we("file_panel.refresh_tree_cache.end",{sessionId:n,workspaceId:a,targetDirectories:c,directoryCount:Object.keys(p).length}),xe(p)}async function Rt(e,s){if(!a)return[];if(!(s!=null&&s.force)){const c=te.current[e];if(c)return c}const l=Ut(Pt(M.current,e),e||X.current);return k(a,l),V(a,[e]),qn(e,Dn,{allowCached:(s==null?void 0:s.force)!==!0})}function qn(e,s=Dn,l){const c=te.current[e];return(l==null?void 0:l.allowCached)!==!1&&c?Promise.resolve(c):new Promise((f,p)=>{const x=window.setTimeout(()=>{Zn(e,x),p(new Error(`FILE_TREE_SNAPSHOT_TIMEOUT:${e}`))},s),S=ne.current.get(e)??[];ne.current.set(e,[...S,{resolve:f,reject:p,timerId:x}])})}function Yn(e,s){const l=ne.current.get(e)??[];l.length!==0&&(ne.current.delete(e),l.forEach(c=>{window.clearTimeout(c.timerId),c.resolve(s)}))}function Zn(e,s){const c=(ne.current.get(e)??[]).filter(f=>f.timerId!==s);if(c.length===0){ne.current.delete(e);return}ne.current.set(e,c)}function Ft(){for(const[e,s]of ne.current.entries())s.forEach(l=>{window.clearTimeout(l.timerId),l.reject(new Error(`FILE_TREE_ABORTED:${e}`))});ne.current.clear()}function Ye(e){N([e]),O(e.path)}function Ze(e){B(e.kind==="directory"?e.path:le(e.path))}function Jn(e){const s=Hi(Xn,Ne,e);N(s),O(e.path),Ze(e)}function Qn(e){const s=Oi($,e),l=Mn(s);N(s),O(e.path),l&&Ze(l)}function un(e){Ye(e),Ze(e)}function Re(e,s){if(s!=null&&s.shiftKey){Jn(e);return}if(pt(s)){Qn(e);return}un(e)}async function ut(e,s=!1){const l=Ie(e,s);if(!l.length){B(g);return}Me(c=>Vn(c,l)),B(l[l.length-1]??g);for(const c of l)try{await cn(c)}catch{return}}async function he(e){const s=U(e,"file");Ye(s),Ze(s),await ut(e)}async function Fe(e){st(e),be(null),Ve.current=null,ve.current+=1,he(e);const s=ve.current,l=e.replace(/\\/g,"/"),c=A.statusByPath.get(l);if(a&&c&&c!=="?"&&c!=="D")try{const f=await bi(a,e,!1);ve.current===s&&be(f.content||null)}catch{ve.current===s&&be(null)}}function fn(e){const s=Date.now(),l=Ve.current;return Ve.current={filePath:e,timestamp:s},(l==null?void 0:l.filePath)===e&&s-l.timestamp<=Ti}function Se(){Ve.current=null}async function In(e,s){const l=U(e,"file");if(s!=null&&s.shiftKey||pt(s)){Se(),Re(l,s);return}if(fn(e)){await Fe(e);return}Re(l,s),await ut(e)}function dn(){We(!1),$e(""),I(null),Se()}async function ei(e,s){const l=U(e.path,e.kind);if(s!=null&&s.shiftKey||pt(s)){Se(),Re(l,s);return}if(e.kind==="directory"){dn(),Re(l,s),await hn(e.path);return}if(fn(e.path)){dn(),await Fe(e.path);return}await he(e.path)}async function hn(e){if(Ye(U(e,"directory")),B(e),!M.current.includes(e))try{await cn(e),Me(s=>Pt(s,e))}catch{}}async function pn(e){if(Ye(U(e,"directory")),B(e),M.current.includes(e)){mn(e);return}await hn(e)}function mn(e){Me(s=>s.filter(l=>l!==e&&!l.startsWith(`${e}/`))),B(le(e)),N([]),O(null)}async function bn(){if(!a)return;const e=a;try{if(re(e),await je(),de&&await ut(de),Ce&&Q.trim()){const s=await ft(e,Q.trim());I(s.items)}}catch(s){P({title:J(s,o("conversation.filePanelLoadFailed")),tone:"error"})}}async function ti(e){if(e==null||e.preventDefault(),!a||!Q.trim()){I(null);return}it(!0);try{const s=await ft(a,Q.trim());I(s.items)}catch(s){P({title:J(s,o("conversation.filePanelSearchFailed")),tone:"error"})}finally{it(!1)}}function vn(){if(Le){We(!1),$e(""),I(null);return}We(!0)}function Y(e){z(!1),e()}function xn(){var e;(e=nn.current)==null||e.click()}async function ni(e){var p;const s=((p=e.target.files)==null?void 0:p[0])??null;if(e.target.value="",!s||!a)return;const l=$i(s.name);if(!l){P({title:o("conversation.filePanelUploadFailed"),tone:"error"});return}const c=En(w,_),f=kn(c,l);tt(!0);try{const x=await Yi(s);await vi({workspaceId:a,path:f,contentBase64:x}),await je(),await he(f),P({title:o("conversation.filePanelUploadSuccess",{name:l}),tone:"success"})}catch(x){P({title:J(x,o("conversation.filePanelUploadFailed")),tone:"error"})}finally{tt(!1)}}async function At(e=de){if(!(!a||!e)){tt(!0);try{const s=await xi(a,e),l=Zi(s.contentBase64);Ji(s.fileName,new Blob([l],{type:"application/octet-stream"})),P({title:o("conversation.filePanelDownloadSuccess",{name:s.fileName}),tone:"success"})}catch(s){P({title:J(s,o("conversation.filePanelDownloadFailed")),tone:"error"})}finally{tt(!1)}}}function yn(){const e=de?le(de):w;!e||!M.current.includes(e)||mn(e)}async function Ae(e,s=En(w,_)){if(!a)return;const l=s,c=l?`${l}/`:"",f=window.prompt(e==="create_file"?o("conversation.filePanelCreateFilePrompt"):o("conversation.filePanelCreateDirectoryPrompt"),c);if(!(f!=null&&f.trim()))return;const p=f.trim();j(!0);try{await Wt({workspaceId:a,opType:e,dstPath:p,content:e==="create_file"?"":void 0}),await je(),e==="create_directory"?(await ut(p,!0),Ye(U(p,"directory")),B(p)):await he(p)}catch(x){P({title:J(x,o("conversation.filePanelMutateFailed")),tone:"error"})}finally{j(!1)}}function ie(e,s=Xe){var c;if(s.length===0)return;const l=mt(s);Jt({mode:e,items:l}),N(l),O(((c=l[l.length-1])==null?void 0:c.path)??null),P({title:e==="copy"?o("conversation.filePanelCopySelectionSuccess",{count:l.length}):o("conversation.filePanelCutSelectionSuccess",{count:l.length}),tone:"success"}),K(null)}async function Je(e=Vi(_,w)){if(!a||!F||!F.items.length)return;const s=e??g,l=F.items.map(c=>({source:c,destinationPath:kn(s,$t(c.path)||c.path)}));j(!0);try{for(const p of l)F.mode==="cut"&&Ct(p.source.path)===Ct(p.destinationPath)||await Wt({workspaceId:a,opType:F.mode==="copy"?"copy":"move",srcPath:p.source.path,dstPath:p.destinationPath});const c=l.map(p=>U(p.destinationPath,p.source.kind)),f=c[c.length-1]??null;if(F.mode==="cut"&&Jt(null),N(c),O((f==null?void 0:f.path)??null),f&&Ze(f),Se(),await je({activeDirectoryPath:(f==null?void 0:f.kind)==="directory"?f.path:f?le(f.path):X.current,expandedDirectories:M.current}),Ce&&Q.trim()){const p=await ft(a,Q.trim());I(p.items)}lt(p=>p+1),P({title:o("conversation.filePanelPasteSuccess",{count:c.length}),tone:"success"}),K(null)}catch(c){await je().catch(()=>{}),P({title:J(c,o("conversation.filePanelPasteFailed")),tone:"error"})}finally{j(!1)}}function Bt(e=Xe){!e.length||v||(ke(mt(e)),K(null))}async function ii(){var s,l;if(!a||!(R!=null&&R.length))return;const e=mt(R);j(!0);try{for(const p of e)await Wt({workspaceId:a,opType:"delete",srcPath:p.path});const c=Ki(w,e),f=M.current.filter(p=>!e.some(x=>x.kind==="directory"&&wt(x.path,p)));if(at&&e.some(p=>wt(p.path,at))&&(ve.current+=1,st(null),be(null)),ke(null),N([]),O(null),X.current=c,M.current=f,B(c),Me(f),Se(),await je({activeDirectoryPath:c,expandedDirectories:f}),Ce&&Q.trim()){const p=await ft(a,Q.trim());I(p.items)}lt(p=>p+1),P({title:e.length===1?o("conversation.filePanelDeleteSuccess",{name:$t(((s=e[0])==null?void 0:s.path)??"")||((l=e[0])==null?void 0:l.path)||""}):o("conversation.filePanelDeleteSelectionSuccess",{count:e.length}),tone:"success"})}catch(c){P({title:J(c,o("conversation.filePanelMutateFailed")),tone:"error"})}finally{j(!1)}}async function Be(e,s=_){const l=(Te==null?void 0:Te.path)??"",c=(s==null?void 0:s.path)??null;if(c===null||!l){ue(!1);return}try{const f=qi(l),p=e==="absolute"?Xi(l,c,f):Ct(c,f);await Qi(p,Ke),P({title:e==="absolute"?o("conversation.filePanelCopyAbsolutePathSuccess"):o("conversation.filePanelCopyRelativePathSuccess"),tone:"success"})}catch(f){P({title:f instanceof Error?f.message:o("conversation.filePanelCopyPathFailed"),tone:"error"})}finally{ue(!1),K(null)}}function ai(e,s,l){return[{id:`open-${e.path}`,label:e.kind==="directory"?D.includes(e.path)?o("conversation.filePanelCollapseDirectory"):o("conversation.filePanelExpandDirectory"):o("conversation.filePanelOpenFile"),onSelect:()=>{if(e.kind==="directory"){pn(e.path);return}Fe(e.path)}},{id:`download-${e.path}`,label:o("conversation.filePanelDownload"),disabled:e.kind!=="file"||E,onSelect:()=>{At(e.kind==="file"?e.path:null)}},{id:`create-file-${e.path}`,label:o("conversation.filePanelNewFile"),disabled:!a||v||E,onSelect:()=>{Ae("create_file",l)}},{id:`create-directory-${e.path}`,label:o("conversation.filePanelNewDirectory"),disabled:!a||v||E,onSelect:()=>{Ae("create_directory",l)}},{id:`copy-${e.path}`,label:o("conversation.filePanelCopy"),disabled:s.length===0,onSelect:()=>ie("copy",s)},{id:`cut-${e.path}`,label:o("conversation.filePanelCut"),disabled:s.length===0,onSelect:()=>ie("cut",s)},{id:`paste-${e.path}`,label:o("conversation.filePanelPaste"),disabled:!qe,onSelect:()=>{Je(l)}},{id:`copy-relative-${e.path}`,label:o("conversation.filePanelCopyRelativePath"),onSelect:()=>{Be("relative",e)}},{id:`copy-absolute-${e.path}`,label:o("conversation.filePanelCopyAbsolutePath"),onSelect:()=>{Be("absolute",e)}},{id:`delete-${e.path}`,label:o("conversation.filePanelDelete"),disabled:s.length===0||v||E,onSelect:()=>Bt(s)}]}async function gn(e,s){if(Ke.isMobile)return;e.preventDefault();const l=U(s.path,s.kind),c=ct.has(l.path)?Xe:[l],f=l.kind==="directory"?l.path:le(l.path);ct.has(l.path)||un(l);const p=ai(l,c,f);if(Ke.isDesktop){await yi(p);return}Ke.isWeb&&(ue(!1),z(!1),K({positionX:e.clientX,positionY:e.clientY,items:p}))}u.useEffect(()=>{if(H!=="workspace")return;function e(s){if(!zi(s)||s.altKey||s.shiftKey||Ui(s.target))return;const l=s.key.toLowerCase();if(l==="c"&&Pe){s.preventDefault(),ie("copy");return}if(l==="x"&&Pe){s.preventDefault(),ie("cut");return}l==="v"&&qe&&(s.preventDefault(),Je())}return document.addEventListener("keydown",e),()=>{document.removeEventListener("keydown",e)}},[H,Pe,qe,ie,Je]);function Lt(e,s){return i.jsx(i.Fragment,{children:e.map(l=>{const c=U(l.path,l.kind),f=l.kind==="directory",p=f&&D.includes(l.path),x=f&&Nt.includes(l.path),S=ye[l.path]??[],ae=G?Kt(S,ye,A.statusByPath,A.changedDirs):S,li=ct.has(l.path),oi=_t===l.path,Qe=A.statusByPath.get(l.path.replace(/\\/g,"/")),jn=f&&A.changedDirs.has(l.path.replace(/\\/g,"/")),ri=(F==null?void 0:F.mode)==="cut"&&F.items.some(se=>se.path===l.path);return i.jsxs("div",{className:"file-tree-node",children:[i.jsxs("button",{className:"file-tree-item",type:"button","data-active":oi,"data-selected":li,"data-cut-pending":ri||void 0,"data-kind":l.kind,"aria-expanded":f?p:void 0,style:{paddingInlineStart:`${Li+s*Wi}px`},onClick:se=>{if(f){if(se.shiftKey||pt(se)){Se(),Re(c,se);return}Se(),Re(c,se),pn(l.path);return}In(l.path,se)},onContextMenu:se=>{gn(se,l)},children:[i.jsx("span",{className:`file-tree-chevron${f?"":" is-hidden"}`,"aria-hidden":"true",children:p?"v":">"}),f?null:i.jsx("span",{className:"git-tree-file-icon","data-kind":St(l.name),"aria-hidden":"true",children:jt(l.name)}),i.jsx("span",{className:"file-tree-label","data-status":Qe??void 0,"data-has-changes":jn||void 0,children:l.name}),!f&&Qe?i.jsx("span",{className:"git-status-badge","data-status":Qe,"aria-label":Qe,children:Qe}):null,f&&jn?i.jsx("span",{className:"file-tree-dir-badge","aria-hidden":"true"}):null,x?i.jsx("span",{className:"file-tree-meta",children:o("common.loading")}):null]}),f&&p?i.jsx("div",{className:"file-tree-children",children:x&&!S.length?i.jsx("p",{className:"file-tree-empty",children:o("common.loading")}):ae.length?Lt(ae,s+1):i.jsx("p",{className:"file-tree-empty",children:o("conversation.filePanelEmptyDirectory")})}):null]},`${l.kind}-${l.path}`)})})}function si(e){return i.jsx(i.Fragment,{children:e.map(s=>{const l=s.kind==="directory",c=ct.has(s.path),f=_t===s.path;return i.jsx("div",{className:"file-tree-node",children:i.jsxs("button",{className:"file-tree-item is-search-result",type:"button","data-active":f,"data-selected":c,"data-kind":s.kind,onClick:p=>{ei(s,p)},onContextMenu:p=>{gn(p,s)},children:[i.jsx("span",{className:"file-tree-chevron is-hidden","aria-hidden":"true",children:">"}),l?null:i.jsx("span",{className:"git-tree-file-icon","data-kind":St(s.name),"aria-hidden":"true",children:jt(s.name)}),i.jsxs("span",{className:"file-tree-label",children:[i.jsx("span",{className:"file-tree-name",children:s.name}),i.jsx("span",{className:"file-tree-path",children:s.path})]})]})},`search-${s.kind}-${s.path}`)})})}return i.jsx("section",{className:["conversation-panel","surface-card","file-panel",t].filter(Boolean).join(" "),"data-testid":"file-context-panel",children:a?i.jsxs(i.Fragment,{children:[i.jsx(Ci,{workspaceId:a,filePath:at,open:at!==null,onClose:()=>{ve.current+=1,st(null),be(null)},onSaved:async e=>{await je(),await he(e),lt(s=>s+1)},diffContent:Gn}),r?null:i.jsx("div",{className:"file-panel-heading-row",children:i.jsx("h2",{className:"file-panel-heading",children:o("conversation.filePanelTitle")})}),h?null:i.jsxs("div",{className:"file-panel-tabs",role:"tablist","aria-label":o("conversation.filePanelTitle"),children:[i.jsx("button",{className:H==="workspace"?"file-panel-tab active":"file-panel-tab",type:"button",role:"tab","aria-selected":H==="workspace",onClick:()=>Oe("workspace"),children:o("conversation.filePanelWorkspaceTab")}),i.jsxs("button",{className:H==="session"?"file-panel-tab active":"file-panel-tab",type:"button",role:"tab","aria-selected":H==="session",onClick:()=>{Ge&&Oe("session")},disabled:!Ge,children:[o("conversation.filePanelSessionTab"),i.jsx("span",{className:"file-panel-tab-badge","aria-label":`${o("conversation.filePanelSessionTab")} ${Zt}`,children:Zt})]})]}),H==="workspace"?i.jsxs(i.Fragment,{children:[i.jsx("input",{ref:nn,"data-testid":"file-panel-upload-input",type:"file",hidden:!0,onChange:e=>void ni(e)}),sn?i.jsx("div",{className:"file-panel-toolbar file-panel-toolbar-mobile","aria-label":o("conversation.filePanelTitle"),children:i.jsxs("div",{className:"file-mobile-action-shell",ref:tn,children:[i.jsxs("button",{className:"secondary-button file-mobile-action-trigger",type:"button","aria-label":o("conversation.filePanelActionsMenu"),"aria-haspopup":"menu","aria-expanded":ze,"data-active":ze,onClick:()=>{ue(!1),z(e=>!e)},children:[i.jsx("span",{children:o("conversation.filePanelActionsMenu")}),i.jsx(ma,{})]}),ze?i.jsxs("div",{className:"file-mobile-action-menu",role:"menu","aria-label":o("conversation.filePanelActionsMenu"),children:[i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>Y(()=>ie("copy")),disabled:!Pe,children:o("conversation.filePanelCopy")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>Y(()=>ie("cut")),disabled:!Pe,children:o("conversation.filePanelCut")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>Y(()=>Je()),disabled:!qe||v||E,children:o("conversation.filePanelPaste")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>{z(!1),vn()},children:Le?o("conversation.filePanelHideSearch"):o("conversation.filePanelShowSearch")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>{z(!1),kt(e=>!e)},disabled:ot.length===0,children:G?o("conversation.filePanelShowAll"):o("conversation.filePanelFilterChanges")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>Y(bn),disabled:De||v||nt,children:o("conversation.filePanelRefresh")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>{z(!1),yn()},disabled:!rn,children:o("conversation.filePanelCollapseCurrent")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>{z(!1),xn()},disabled:v||E,children:o("conversation.filePanelUpload")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>Y(At),disabled:!ln||E,children:o("conversation.filePanelDownload")}),i.jsx("button",{className:"file-mobile-action-menu-item danger",type:"button",role:"menuitem",onClick:()=>Y(Bt),disabled:!on||v||E,children:o("conversation.filePanelDelete")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>Y(()=>Ae("create_file")),disabled:v||E,children:o("conversation.filePanelNewFile")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>Y(()=>Ae("create_directory")),disabled:v||E,children:o("conversation.filePanelNewDirectory")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>Y(()=>Be("absolute")),disabled:!Tt,children:o("conversation.filePanelCopyAbsolutePath")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>Y(()=>Be("relative")),disabled:!Tt,children:o("conversation.filePanelCopyRelativePath")})]}):null]})}):i.jsxs("div",{className:"file-panel-toolbar","aria-label":o("conversation.filePanelTitle"),children:[i.jsx("button",{className:"file-toolbar-button",type:"button",title:o("conversation.filePanelCopy"),"aria-label":o("conversation.filePanelCopy"),onClick:()=>ie("copy"),disabled:!Pe,children:i.jsx(oa,{})}),i.jsx("button",{className:"file-toolbar-button",type:"button",title:o("conversation.filePanelCut"),"aria-label":o("conversation.filePanelCut"),onClick:()=>ie("cut"),disabled:!Pe,children:i.jsx(ra,{})}),i.jsx("button",{className:"file-toolbar-button",type:"button",title:o("conversation.filePanelPaste"),"aria-label":o("conversation.filePanelPaste"),onClick:()=>void Je(),disabled:!qe||v||E,children:i.jsx(ca,{})}),i.jsxs("div",{className:"file-toolbar-menu-shell",ref:en,children:[i.jsx("button",{className:"file-toolbar-button",type:"button",title:o("conversation.filePanelCopyPath"),"aria-label":o("conversation.filePanelCopyPath"),"aria-haspopup":"menu","aria-expanded":He,"data-active":He,onClick:()=>{z(!1),ue(e=>!e)},disabled:!Tt,children:i.jsx(la,{})}),He?i.jsxs("div",{className:"file-toolbar-menu",role:"menu",children:[i.jsx("button",{className:"file-toolbar-menu-item",type:"button",role:"menuitem",onClick:()=>void Be("absolute"),children:o("conversation.filePanelCopyAbsolutePath")}),i.jsx("button",{className:"file-toolbar-menu-item",type:"button",role:"menuitem",onClick:()=>void Be("relative"),children:o("conversation.filePanelCopyRelativePath")})]}):null]}),i.jsx("button",{className:"file-toolbar-button",type:"button",title:o("conversation.filePanelCollapseCurrent"),"aria-label":o("conversation.filePanelCollapseCurrent"),onClick:yn,disabled:!rn,children:i.jsx(aa,{})}),i.jsx("button",{className:"file-toolbar-button",type:"button",title:o("conversation.filePanelRefresh"),"aria-label":o("conversation.filePanelRefresh"),onClick:()=>void bn(),disabled:De||v||nt,children:i.jsx(sa,{})}),i.jsx("button",{className:"file-toolbar-button",type:"button",title:o("conversation.filePanelSearchButton"),"aria-label":o("conversation.filePanelSearchButton"),"data-active":Le,onClick:vn,disabled:De,children:i.jsx(Fn,{})}),ot.length>0?i.jsx("button",{className:"file-toolbar-button",type:"button",title:G?o("conversation.filePanelShowAll"):o("conversation.filePanelFilterChanges"),"aria-label":G?o("conversation.filePanelShowAll"):o("conversation.filePanelFilterChanges"),"data-active":G,onClick:()=>kt(e=>!e),children:i.jsx(ba,{})}):null,i.jsx("button",{className:"file-toolbar-button",type:"button",title:o("conversation.filePanelUpload"),"aria-label":o("conversation.filePanelUpload"),onClick:xn,disabled:v||E,children:i.jsx(fa,{})}),i.jsx("button",{className:"file-toolbar-button",type:"button",title:o("conversation.filePanelDownload"),"aria-label":o("conversation.filePanelDownload"),onClick:()=>void At(),disabled:!ln||E,children:i.jsx(da,{})}),i.jsx("button",{className:"file-toolbar-button danger",type:"button",title:o("conversation.filePanelDelete"),"aria-label":o("conversation.filePanelDelete"),onClick:()=>Bt(),disabled:!on||v||E,children:i.jsx(ha,{})}),i.jsx("button",{className:"file-toolbar-button",type:"button",title:o("conversation.filePanelNewFile"),"aria-label":o("conversation.filePanelNewFile"),onClick:()=>void Ae("create_file"),disabled:v||E,children:i.jsx(ua,{})}),i.jsx("button",{className:"file-toolbar-button",type:"button",title:o("conversation.filePanelNewDirectory"),"aria-label":o("conversation.filePanelNewDirectory"),onClick:()=>void Ae("create_directory"),disabled:v||E,children:i.jsx(pa,{})})]}),ee&&typeof document<"u"?ui.createPortal(i.jsx("div",{className:"file-web-context-menu",ref:Mt,role:"menu","aria-label":o("conversation.filePanelActionsMenu"),style:{left:`${(fe==null?void 0:fe.left)??Math.max(8,ee.positionX)}px`,top:`${(fe==null?void 0:fe.top)??Math.max(8,ee.positionY)}px`,maxHeight:fe?`${fe.maxHeight}px`:void 0},children:ee.items.map(e=>i.jsx("button",{className:["file-web-context-menu-item",e.label===o("conversation.filePanelDelete")?"danger":""].filter(Boolean).join(" "),type:"button",role:"menuitem",disabled:e.disabled,onClick:()=>{K(null),e.onSelect()},children:e.label},e.id))}),document.body):null,Le?i.jsxs("form",{className:"file-toolbar-search",onSubmit:e=>void ti(e),children:[i.jsx("input",{value:Q,onChange:e=>$e(e.target.value),placeholder:o("conversation.filePanelSearchPlaceholder")}),sn?i.jsx("button",{className:"secondary-button file-mobile-search-submit",type:"submit","aria-label":o("conversation.filePanelSearchButton"),disabled:nt,children:o("conversation.filePanelSearchButton")}):i.jsx("button",{className:"file-toolbar-button",type:"submit",title:o("conversation.filePanelSearchButton"),"aria-label":o("conversation.filePanelSearchButton"),disabled:nt,children:i.jsx(Fn,{})})]}):null,i.jsx("div",{className:"file-tree","data-search-mode":Ce,children:De&&_e.length===0?i.jsx("p",{className:"file-tree-status status-text",children:o("common.loading")}):Ce?ge!=null&&ge.length?si(ge):i.jsx("p",{className:"file-tree-status status-text",children:o("conversation.filePanelSearchEmpty")}):G?rt.length?Lt(rt,0):i.jsx("p",{className:"file-tree-status status-text",children:o("conversation.filePanelNoChanges")}):_e.length?Lt(_e,0):i.jsx("p",{className:"file-tree-status status-text",children:o("conversation.filePanelEmptyDirectory")})}),i.jsxs(gi,{open:R!==null,title:o("conversation.filePanelDeleteConfirmTitle"),description:o("conversation.filePanelDeleteConfirmDescription"),onClose:()=>{v||ke(null)},children:[i.jsx("p",{className:"workbench-section-empty",children:R!=null&&R.length?R.length===1?((Pn=R[0])==null?void 0:Pn.kind)==="directory"?o("conversation.filePanelDeleteDirectoryConfirm",{path:R[0].path}):o("conversation.filePanelDeleteFileConfirm",{path:R[0].path}):o("conversation.filePanelDeleteSelectionConfirm",{count:R.length}):""}),i.jsxs("div",{className:"workbench-modal-actions",children:[i.jsx("button",{type:"button",className:"secondary-button",disabled:v,onClick:()=>ke(null),children:o("common.cancel")}),i.jsx("button",{type:"button",className:"secondary-button workbench-danger-button",disabled:v,onClick:()=>{ii()},children:v?o("conversation.filePanelDeleting"):o("conversation.filePanelDelete")})]})]})]}):Ge&&n?i.jsx(Mi,{sessionId:n,workspaceId:a,showSystemFiles:q,selectedPath:de,refreshVersion:Yt,onCountChange:Et,onSelectFile:he,onOpenFile:Fe}):i.jsx("section",{className:"file-panel-section",children:i.jsx("p",{className:"status-text",children:o("conversation.filePanelSessionNoSession")})})]}):i.jsx("section",{className:"file-panel-section",children:i.jsx("p",{className:"status-text",children:o("conversation.filePanelNoWorkspace")})})})}function le(t){return t.includes("/")?t.split("/").slice(0,-1).join("/"):g}function Ie(t,n=!1){const a=t.split("/").filter(Boolean),r=n?a.length:a.length-1,h=[];for(let d=0;d<r;d+=1)h.push(a.slice(0,d+1).join("/"));return h}function En(t,n){return t||((n==null?void 0:n.kind)==="directory"?n.path:n!=null&&n.path?le(n.path):g)}function kn(t,n){return t?`${t}/${n}`:n}function $i(t){var n;return((n=t.split(/[/\\]/).pop())==null?void 0:n.trim())??""}function U(t,n){return{path:t,kind:n}}function Mn(t){return t[t.length-1]??null}function Oi(t,n){return t.findIndex(r=>r.path===n.path)>=0?t.filter(r=>r.path!==n.path):[...t,n]}function Hi(t,n,a){const r=t.findIndex(y=>y.path===a.path);if(r<0)return[a];const h=n?t.findIndex(y=>y.path===n):r;if(h<0)return[a];const d=Math.min(h,r),m=Math.max(h,r);return t.slice(d,m+1)}function pt(t){return!!(t!=null&&t.ctrlKey||t!=null&&t.metaKey)}function zi(t){return t.ctrlKey||t.metaKey}function Ui(t){if(!(t instanceof HTMLElement))return!1;const n=t.tagName.toLowerCase();return n==="input"||n==="textarea"||n==="select"||t.isContentEditable}function mt(t){const n=[...new Map(t.map(r=>[r.path,r])).values()].sort((r,h)=>r.path.localeCompare(h.path)),a=[];for(const r of n)a.some(h=>h.kind==="directory"&&wt(h.path,r.path))||a.push(r);return a}function Vi(t,n){return(t==null?void 0:t.kind)==="directory"?t.path:t!=null&&t.path?le(t.path):n}function Ki(t,n){let a=t;for(;a&&n.some(r=>r.kind==="directory"&&wt(r.path,a));)a=le(a);return a}function Hn(t,n,a,r,h,d){const m=[];for(const y of t){if(m.push(U(y.path,y.kind)),y.kind!=="directory"||!a.includes(y.path))continue;const C=n[y.path]??[],T=r?Kt(C,n,h,d):C;m.push(...Hn(T,n,a,r,h,d))}return m}function Gi(t,n,a){const r=Math.max(0,a.width),h=Math.max(0,a.height),d=Math.max(0,h-Z*2),m=Math.max(0,r-Z*2),y=Math.min(Math.max(n.width,0),m),C=Math.max(0,h-t.y-ht-Z),T=Math.max(0,t.y-ht-Z),k=C<n.height&&T>C,oe=zt(Math.max(k?T:C,Fi),0,d),L=Math.min(Math.max(n.height,0),oe),re=k?t.y-ht-L:t.y+ht,ce=Math.max(Z,h-Z-L),W=Math.max(Z,r-Z-y);return{top:zt(re,Z,ce),left:zt(t.x,Z,W),maxHeight:Math.max(0,oe)}}function zt(t,n,a){return!Number.isFinite(t)||a<n?n:Math.min(Math.max(t,n),a)}function Ct(t,n="posix"){return t?zn(t,n):"."}function Xi(t,n,a){const r=zn(t,a),h=Ct(n,a).replace(/^\.[/\\]?/,"");if(!h)return r;const d=Un(a),m=h.replace(/^[/\\]+/,"");return m?r.endsWith("/")||r.endsWith("\\")?`${r}${m}`:`${r}${d}${m}`:r}function qi(t){return/^[a-zA-Z]:[\\/]/.test(t)||t.includes("\\")?"windows":"posix"}function zn(t,n){return t&&(Un(n)==="\\"?t.replace(/\//g,"\\"):t.replace(/\\/g,"/"))}function Un(t){return t==="windows"?"\\":"/"}function wt(t,n){return n===t||n.startsWith(`${t}/`)}async function Yi(t){const n=await t.arrayBuffer(),a=new Uint8Array(n),r=32768;let h="";for(let d=0;d<a.length;d+=r){const m=a.subarray(d,d+r);h+=String.fromCharCode(...m)}return btoa(h)}function Zi(t){const n=atob(t),a=new Uint8Array(n.length);for(let r=0;r<n.length;r+=1)a[r]=n.charCodeAt(r);return a.buffer.slice(a.byteOffset,a.byteOffset+a.byteLength)}function Ji(t,n){if(typeof document>"u")throw new Error(o("conversation.filePanelDownloadFailed"));const a=window.URL.createObjectURL(n),r=document.createElement("a");r.href=a,r.download=t,document.body.append(r),r.click(),r.remove(),window.URL.revokeObjectURL(a)}async function Qi(t,n){var a;if(!(n.isDesktop&&(await n.bridge.writeClipboardText(t)).ok)){if(typeof navigator<"u"&&((a=navigator.clipboard)!=null&&a.writeText))try{await navigator.clipboard.writeText(t);return}catch{}if(!Ii(t))throw new Error(o("conversation.filePanelCopyPathFailed"))}}function Ii(t){if(typeof document>"u"||typeof document.execCommand!="function")return!1;const n=document.createElement("textarea");n.value=t,n.setAttribute("readonly","true"),n.style.position="fixed",n.style.top="-9999px",n.style.left="-9999px",n.style.opacity="0",document.body.appendChild(n),n.focus(),n.select();try{return document.execCommand("copy")}catch{return!1}finally{document.body.removeChild(n)}}function ea(t,n){return t&&Ie(t,!0).every(h=>h in n)?t:g}function _n(t,n){if(!n)return[];const a=Ie(n,!0);return t.filter(r=>a.includes(r))}function bt(t,n,a){const r=qt(n,a);return Object.entries(t).reduce((h,[d,m])=>(r.has(d)&&(h[d]=m),h),{})}function ta(t,n,a){const h=[...qt(n,a)].filter(d=>d===g||d in t);return h.length?h:[g]}function qt(t,n){const a=new Set([g]),r=Vn(n,Ie(t,!0));for(const h of r){a.add(h);for(const d of Ie(h,!0))a.add(d)}return a}function na(t,n){const a=Object.keys(t),r=Object.keys(n);return a.length!==r.length?!1:a.every(h=>t[h]===n[h])}function Pt(t,n){return t.includes(n)?t:[...t,n]}function Vn(t,n){return n.reduce((a,r)=>Pt(a,r),t)}function Tn(t){return`file-panel.workspace-tree.${t}`}function ia(t,n){return`file-panel.session-change-count.${t}.${n}`}function Ut(t,n){return[...qt(n,t)]}function J(t,n){return t instanceof An?t.message:n}function Rn(t){return t instanceof Error&&(t.message.startsWith("FILE_TREE_SNAPSHOT_TIMEOUT:")||t.message.startsWith("FILE_TREE_ABORTED:"))}function aa(){return i.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:i.jsx("path",{d:"M2.5 4.5h11v2h-11zM2.5 7.5h7v2h-7zM2.5 10.5h4v2h-4z",fill:"currentColor"})})}function sa(){return i.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:i.jsx("path",{d:"M12.8 5.2A5.5 5.5 0 1 0 13.5 8h-1.8A3.7 3.7 0 1 1 10.6 5l-1.4 1.4h4V2l-1.4 1.4z",fill:"currentColor"})})}function Fn(){return i.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:i.jsx("path",{d:"M11.2 10.1l3 3-1.1 1.1-3-3a5 5 0 1 1 1.1-1.1zM6.8 10.3a3.5 3.5 0 1 0 0-7 3.5 3.5 0 0 0 0 7z",fill:"currentColor"})})}function la(){return i.jsxs("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:[i.jsx("path",{d:"M3.5 4.3h5.2v1.4H4.9v5.4H3.5zm3.8-2.1h5.2v9.5H7.3z",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),i.jsx("path",{d:"M5.7 10.8h4.5",fill:"none",stroke:"currentColor",strokeWidth:"1.2"})]})}function oa(){return i.jsxs("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:[i.jsx("path",{d:"M5 2.5h7.5v9H5z",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),i.jsx("path",{d:"M3.5 5H2.4V13.5H10V12.4",fill:"none",stroke:"currentColor",strokeWidth:"1.2"})]})}function ra(){return i.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:i.jsx("path",{d:"M4.2 4.2a1.4 1.4 0 1 1 0 2.8 1.4 1.4 0 0 1 0-2.8zm0 5.4a1.4 1.4 0 1 1 0 2.8 1.4 1.4 0 0 1 0-2.8zm1-3.2 6.6 5.6M5.2 9.6l6.6-5.6",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round"})})}function ca(){return i.jsxs("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:[i.jsx("path",{d:"M4 3.5h8v10H4zM6 2.2h4v2H6z",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),i.jsx("path",{d:"M6 7.2h4M6 9.6h4",fill:"none",stroke:"currentColor",strokeWidth:"1.2"})]})}function ua(){return i.jsxs("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:[i.jsx("path",{d:"M4 1.5h5l3 3v10H4z",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),i.jsx("path",{d:"M9 1.5v3h3",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),i.jsx("path",{d:"M8 6.5v5M5.5 9h5",fill:"none",stroke:"currentColor",strokeWidth:"1.2"})]})}function fa(){return i.jsxs("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:[i.jsx("path",{d:"M3 11.5v2h10v-2",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),i.jsx("path",{d:"M8 2.5v8",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),i.jsx("path",{d:"m5.5 5 2.5-2.5L10.5 5",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"})]})}function da(){return i.jsxs("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:[i.jsx("path",{d:"M3 11.5v2h10v-2",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),i.jsx("path",{d:"M8 2.5v8",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),i.jsx("path",{d:"m5.5 8.5 2.5 2.5 2.5-2.5",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"})]})}function ha(){return i.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:i.jsx("path",{d:"M3.5 4.5h9M6.2 2.5h3.6l.6 1.4H13v1.2H3V3.9h2.6zM5.2 5.7v6.1m2.8-6.1v6.1m2.8-6.1v6.1M4.4 13.5h7.2",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"})})}function pa(){return i.jsxs("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:[i.jsx("path",{d:"M1.8 4.5h4l1.2 1.3h7.2v6.7H1.8z",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),i.jsx("path",{d:"M8.5 7.2v4M6.5 9.2h4",fill:"none",stroke:"currentColor",strokeWidth:"1.2"})]})}function ma(){return i.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:i.jsx("path",{d:"m4 6 4 4 4-4",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round"})})}function ba(){return i.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:i.jsx("path",{d:"M1.5 2h13l-5 6v5l-3 1.5V8z",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinejoin:"round"})})}function Kt(t,n,a,r){const h=[];for(const d of t){const m=d.path.replace(/\\/g,"/");d.kind==="file"?a.has(m)&&h.push(d):Kn(m,n,a,r)&&h.push(d)}return h}function Kn(t,n,a,r,h){const d=h??new Set;if(d.has(t))return!1;d.add(t);const m=n[t];if(!m)return r.has(t);for(const y of m){const C=y.path.replace(/\\/g,"/");if(y.kind==="file"){if(a.has(C))return!0}else if(Kn(C,n,a,r,d))return!0}return!1}export{wa as FileContextPanel};
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import{b as l,t as n,j as e,A as _n}from"./index-Byp9hJ0c.js";import{u as ji,d as Ci,e as Ni,f as fn}from"./App-DkvE5EyM.js";import{u as vi,X as Qe,r as pn,w as Si,aC as Ti,au as Mi,aD as xn,aE as Ei,aF as bn,aG as Hi,aw as wi,aH as Ai,av as Pi,aI as Ri,aJ as Li,aB as Di,aK as yn,b as _i,aL as Fi,aM as Oi}from"./WorkbenchLayout-ByFw4eeu.js";import{g as ki}from"./default-session-permission-mode-CcGwR4Kk.js";import{S as Gi,q as $i,t as Bi,e as Ui}from"./MobileSheet-DLg-gX1t.js";import{F as Wi,a as Rt,b as Lt}from"./file-tree-icon-UFVoVzhM.js";import{W as De}from"./WorkbenchModal-Ctob14VR.js";import"./window-BWqRixxq.js";import"./event-DvH9tcej.js";const Tt=56,jn=28,Mt=72,et=8,Cn=960,Nn=60*1e3,vn=20,Sn=9,Tn=9,Et=68,_=12,tt=8,Dt=260,Vi=120,Ht=6e4,nt={authMode:"none",username:"",password:"",token:"",rememberOnHost:!1};function gs({className:a,workspaceId:i,panelActive:u=!0,externalWindowMode:h=!1,workbenchShellOverrides:d}){const C=ji(),b=Ci(),j=vi(),{subscribeGitSnapshot:y,requestGitRefresh:N,addGitSnapshotListener:M,requestNavigationRefresh:S,selectWorkspace:T,upsertNavigationSession:f}={...j,...d},[r,m]=l.useState(null),[g,E]=l.useState([]),[p,P]=l.useState(0),[H,ue]=l.useState(null),[de,st]=l.useState(!1),[G,Fe]=l.useState(null),[te,I]=l.useState(null),[me,he]=l.useState(""),[at,U]=l.useState(!1),[v,R]=l.useState(!1),[Vn,Gt]=l.useState([]),[J,$t]=l.useState(!0),[Q,W]=l.useState(!1),[F,In]=l.useState(()=>typeof window<"u"?window.innerWidth<=Cn:!1),[rt,$]=l.useState([]),[ge,V]=l.useState(null),[fe,ne]=l.useState("unstaged"),[pe,z]=l.useState(null),[ie,K]=l.useState(null),[zn,ot]=l.useState(!1),[Kn,lt]=l.useState(null),[Xn,Oe]=l.useState(!1),[Bt,ke]=l.useState(null),[L,xe]=l.useState(null),[Ut,be]=l.useState(null),[qn,ye]=l.useState(!1),[je,se]=l.useState(null),[ee,ct]=l.useState(!1),[Yn,Ce]=l.useState(!1),[Zn,Wt]=l.useState([]),[ss,Vt]=l.useState(!1),[Ge,ut]=l.useState(new Set),[Jn,Ne]=l.useState(new Map),[$e,It]=l.useState(null),[Qn,ve]=l.useState(!1),[A,X]=l.useState(nt),[zt,Be]=l.useState("generic"),[Kt,Ue]=l.useState(null),[O,dt]=l.useState(null),[k,mt]=l.useState(null),[Xt,qt]=l.useState(Tt),[ht,gt]=l.useState(!1),[Yt,Se]=l.useState(null),[ei,Te]=l.useState(null),Zt=l.useRef(null),Jt=l.useRef(null),Qt=l.useRef(null),en=l.useRef(null),tn=l.useRef(null),nn=l.useRef(null),ft=l.useRef(null),Me=l.useRef(new Map),We=l.useRef(new Map),Ee=l.useRef(0),sn=l.useRef(u),{showToast:w}=Ni(),an=b.isDesktop&&!F;l.useEffect(()=>{Qe("git_sidebar.props",{workspaceId:i,externalWindowMode:h})},[h,i]),l.useEffect(()=>{Gt([]),$t(!0),P(0),ue(null),st(!1),I(null),he(""),W(!1),$([]),V(null),ne("unstaged"),z(null),K(null),ot(!1),lt(null),Oe(!1),ke(null),xe(null),be(null),ye(!1),se(null),ct(!1),Ce(!1),Wt([]),ut(new Set),Ne(new Map),It(null),ve(!1),X(nt),Be("generic"),Ue(null),dt(null),mt(null),gt(!1),qt(Tt),Se(null),Te(null),We.current.clear(),Me.current.clear()},[i]),l.useEffect(()=>{function t(){In(window.innerWidth<=Cn)}return t(),window.addEventListener("resize",t),()=>{window.removeEventListener("resize",t)}},[]),l.useEffect(()=>{if(!ht)return;const t=document.body.style.cursor,s=document.body.style.userSelect;document.body.style.cursor="row-resize",document.body.style.userSelect="none";function o(x){un(x.clientY)}function c(){gt(!1)}return window.addEventListener("pointermove",o),window.addEventListener("pointerup",c),()=>{document.body.style.cursor=t,document.body.style.userSelect=s,window.removeEventListener("pointermove",o),window.removeEventListener("pointerup",c)}},[ht]),l.useEffect(()=>{var o,c;if(!(i!=null&&i.trim())){m(null),E([]),P(0),ue(null),Fe(null),U(!1);return}const t=i.trim(),s=pn(At(t),Nn);if(Qe("git_sidebar.snapshot",{workspaceId:t,cached:!!s,cachedHistoryCount:((o=s==null?void 0:s.history)==null?void 0:o.length)??0,cachedChangedCount:((c=s==null?void 0:s.status)==null?void 0:c.changes.length)??0}),s){pt(s),U(!1);return}m(null),E([]),P(0),ue(null),Fe(null),U(!0)},[i]),l.useEffect(()=>{if(i!=null&&i.trim())return M(t=>{var s,o,c;t.workspaceId===i.trim()&&(Qe("git_sidebar.snapshot_received",{workspaceId:t.workspaceId,changedCount:((s=t.status)==null?void 0:s.changes.length)??0,historyCount:t.history.length,branchCount:(((o=t.branches)==null?void 0:o.local.length)??0)+(((c=t.branches)==null?void 0:c.remote.length)??0)}),pt(t),U(!1))})},[M,i]),l.useEffect(()=>{if(!(i!=null&&i.trim()))return;const t=i.trim(),s=pn(At(t),Nn)!==null;if(y(t),s){N(t);return}q()},[N,y,i]),l.useEffect(()=>{const t=sn.current;sn.current=u,i!=null&&i.trim()&&!t&&u&&N(i.trim())},[u,N,i]),l.useEffect(()=>{i&&Si(At(i),{status:r,history:g,historyTotalCount:p,historyNextCursor:H,branches:G})},[G,g,H,p,r,i]),l.useEffect(()=>{if(!r||!te)return;r.changes.find(s=>s.path===te)||I(null)},[te,r]),l.useEffect(()=>{Yi(en.current)},[me]),l.useEffect(()=>{F||($([]),V(null),z(null),Ue(null))},[F]),l.useEffect(()=>{if(!r){$([]);return}const t=new Set(r.changes.map(s=>s.path));$(s=>s.filter(o=>t.has(o)))},[r]);function ti(){const t=Qt.current;if(!t)return;t.querySelectorAll(".git-tree-shell").forEach(o=>{o.scrollTop=0})}function pt(t){m(t.status),E(Array.isArray(t.history)?t.history:[]),P(typeof t.historyTotalCount=="number"?t.historyTotalCount:0),ue(typeof t.historyNextCursor=="string"?t.historyNextCursor:null),Fe(t.branches??null)}function q(t){i!=null&&i.trim()&&(U(!0),Qe("git_sidebar.refresh_requested",{workspaceId:i.trim(),resetTreeScroll:!1}),N(i.trim()))}async function xt(t){if(!(i!=null&&i.trim()))return;const s=i.trim();U(!0);try{const[o,c,x]=await Promise.all([Mi(s),xn(s,vn,null),Ei(s)]);pt({status:o,history:c.items,historyTotalCount:c.totalCount,historyNextCursor:c.nextCursor,branches:x}),N(s),t!=null&&t.resetTreeScroll&&requestAnimationFrame(()=>{ti()})}catch(o){w({title:D(o,n("git.panelLoadFailed")),tone:"error"})}finally{U(!1)}}async function Ve(){if(!(!i||!H||de)){st(!0);try{const t=await xn(i,vn,H);E(s=>{const o=new Set(s.map(x=>x.commitHash)),c=t.items.filter(x=>!o.has(x.commitHash));return[...s,...c]}),P(t.totalCount),ue(t.nextCursor)}catch(t){w({title:D(t,n("git.panelLoadFailed")),tone:"error"})}finally{st(!1)}}}function ni(t){if(!J||de||!H)return;const s=t.currentTarget;s.scrollHeight-s.scrollTop-s.clientHeight<=40&&Ve()}async function ii(){if(i){R(!0);try{const t=await Ti(i,"ai");he(t.validation.normalizedDraft.subject||t.draft.subject)}catch(t){w({title:D(t,n("git.draftFailed")),tone:"error"})}finally{R(!1)}}}async function Ie(t,s){if(i&&t.length){R(!0);try{const o=s?await Ai(i,t):await Pi(i,t);m(o),I(t[t.length-1]??null),$(c=>c.filter(x=>!t.includes(x))),V(null),q()}catch(o){U(!1),w({title:D(o,n("git.stageFailed")),tone:"error"})}finally{R(!1)}}}async function bt(t){if(i&&t.length){R(!0);try{const s=await Li(i,t);m(s),t.includes(te??"")&&I(null),$(o=>o.filter(c=>!t.includes(c))),V(null),q()}catch(s){U(!1),w({title:D(s,n("git.discardFailed")),tone:"error"})}finally{R(!1)}}}async function si(){if(!(!i||!me.trim())){R(!0);try{await Hi(i,Xi(me)),w({title:n("git.commitSuccess"),tone:"success"}),he(""),I(null),q()}catch(t){w({title:D(t,n("git.commitFailed")),tone:"error"})}finally{R(!1)}}}function ze(t){X(Qi($e)),ve(!0),ai(t)}async function ai(t){const s=i==null?void 0:i.trim();if(!s){Be("generic");return}try{const o=await bn(s);if((i==null?void 0:i.trim())!==s)return;Be(ts(o,t))}catch{if((i==null?void 0:i.trim())!==s)return;Be("generic")}}function ri(){const t=es(A),s=zt==="github"?n("git.remoteAuthGithubPatPlaceholder"):n("shell.clonePasswordPlaceholder");if(A.authMode==="basic"){if(!A.username.trim()){w({title:n("shell.cloneUsernamePlaceholder"),tone:"error"});return}if(!A.password){w({title:s,tone:"error"});return}}if(A.authMode==="token"&&!A.token){w({title:n("shell.cloneTokenPlaceholder"),tone:"error"});return}It(t),ve(!1),w({title:t?n("git.remoteAuthSaved"):n("git.remoteAuthCleared"),description:t&&A.rememberOnHost?n("git.remoteAuthRememberHint"):void 0,tone:"success"})}async function rn(){if(i){Vt(!0);try{const t=await bn(i);if(t.length===0){w({title:n("git.noRemotes"),tone:"error"});return}if(t.length===1){on([t[0].name]);return}Wt(t),ut(new Set),Ne(new Map),Ce(!0)}catch(t){w({title:D(t,n("git.remoteFailed")),tone:"error"})}finally{Vt(!1)}}}async function on(t){if(!i||t.length===0)return;R(!0),Ne(new Map);const s=new Map;let o=!1;try{for(const c of t)try{const x=await yn(i,"push",c,$e,A.rememberOnHost);s.set(c,{ok:!0,summary:x.summary})}catch(x){if(o=!0,s.set(c,{ok:!1,summary:D(x,n("git.remoteFailed"))}),Ne(new Map(s)),Ln(x)){ze(c);return}}Ne(s),q(),o||(w({title:n("git.pushAllSuccess",{count:String(t.length)}),tone:"success"}),Ce(!1))}finally{R(!1)}}async function yt(t){if(i){if(t==="push"){W(!1),rn();return}R(!0);try{const s=await yn(i,t,void 0,$e,A.rememberOnHost);w({title:s.summary,tone:"success"}),W(!1),q()}catch(s){if(Ln(s)){ze();return}w({title:D(s,n("git.remoteFailed")),tone:"error"})}finally{R(!1)}}}async function ae(){if(i){R(!0);try{const t=await Ri(i);he(t.commitSubject??""),w({title:t.summary||n("git.undoLastCommitSuccess"),tone:"success"}),W(!1),q()}catch(t){w({title:D(t,n("git.undoLastCommitFailed")),tone:"error"})}finally{R(!1)}}}async function oi(t){if(i){R(!0);try{const s=await Fi(i,t,!1);Fe(s),W(!1),q()}catch(s){w({title:D(s,n("git.branchFailed")),tone:"error"})}finally{R(!1)}}}async function jt(t){const s=i==null?void 0:i.trim();if(!s)throw new Error(n("git.panelLoadFailed"));const o=We.current.get(t);if(o)return o;const c=await Oi(s,t);return We.current.set(t,c),c}async function He(t){K(null),z(null),lt(t),ke(null);const s=We.current.get(t)??null;if(xe(s),Oe(!s),s)return;const o=Ee.current+1;Ee.current=o;try{const c=await jt(t);if(Ee.current!==o)return;xe(c)}catch(c){if(Ee.current!==o)return;ke(D(c,n("git.commitDetailLoadFailed"))),xe(null)}finally{Ee.current===o&&Oe(!1)}}function li(){lt(null),Oe(!1),ke(null),xe(null)}async function we(t){try{const s=await jt(t);await B(s.versionLabel,n("git.copyCommitVersionSuccess"))}catch(s){w({title:D(s,n("git.commitDetailLoadFailed")),tone:"error"})}}function Ae(t){K(null),z(null),be(t),se(null),ye(!0)}function ci(t){var o;const s=((o=g[0])==null?void 0:o.commitHash)===t.commitHash&&t.commitKind==="local";return[{id:`view-changes:${t.commitHash}`,label:n("git.viewCommitChanges"),onSelect:()=>void He(t.commitHash)},{id:`copy-hash:${t.commitHash}`,label:n("git.copyCommitHash"),onSelect:()=>void B(t.commitHash,n("git.copyCommitHashSuccess"))},{id:`copy-message:${t.commitHash}`,label:n("git.copyCommitMessage"),onSelect:()=>void B(ce(t),n("git.copyCommitMessageSuccess"))},{id:`copy-version:${t.commitHash}`,label:n("git.copyCommitVersion"),onSelect:()=>void we(t.commitHash)},{id:`explain:${t.commitHash}`,label:n("git.explainCommitAction"),onSelect:()=>Ae(t.commitHash)},...s?[{id:`undo:${t.commitHash}`,label:n("git.undoLastCommit"),disabled:v,onSelect:()=>void ae()}]:[]]}async function ln(t){K(null),z(null),await Di(ci(t))}async function ui(){var t,s;if(!(!i||!Ut||!je||ee)){ct(!0);try{const o=await jt(Ut),c=await $i({workspaceId:i,provider:je,content:qi(o),clientRequestId:((s=(t=globalThis.crypto)==null?void 0:t.randomUUID)==null?void 0:s.call(t))??`git-explain-${Date.now()}-${Math.random().toString(16).slice(2)}`,permissionMode:ki()}),x=c.session??await Bi(c.sessionId);f(x),S(),T(x.workspaceId),C(_i(x.workspaceId,x.sessionId)),ye(!1),be(null),se(null),w({title:n("git.explainCommitStarted"),tone:"success"})}catch(o){w({title:D(o,n("git.explainCommitFailed")),tone:"error"})}finally{ct(!1)}}}function Ke(t){Gt(s=>s.includes(t)?s.filter(o=>o!==t):[...s,t])}const di=450;function cn(t){const s=Date.now(),o=Zt.current;return Zt.current={filePath:t,timestamp:s},(o==null?void 0:o.filePath)===t&&s-o.timestamp<=di}async function Xe(t,s){if(s.binary){w({title:n("git.binaryDiff"),tone:"info"});return}if(s.status==="A"||s.status==="?")Te(null),Se(t);else if(i)try{const o=await wi(i,t,s.staged);Te(o.content),Se(t)}catch{Te(null),Se(t)}}function qe(t){I(t),V(null),$(s=>s.includes(t)?s.filter(o=>o!==t):[...s,t])}function un(t){const s=Jt.current;if(!s||!Number.isFinite(t))return;const o=s.getBoundingClientRect(),c=o.height-et;if(!Number.isFinite(o.top)||!Number.isFinite(o.height)||c<=0)return;const x=(t-o.top-et/2)/c*100;if(!Number.isFinite(x))return;const Le=Math.max(jn,Math.min(Mt,Math.round(x)));qt(Le)}function mi(t){t.preventDefault(),un(t.clientY),gt(!0)}const Pe=(r==null?void 0:r.changes)??[],Y=Pe.filter(t=>_t(t,"staged")),re=Pe.filter(t=>_t(t,"unstaged")),dn=Pn(Y,"staged"),mn=Pn(re,"unstaged"),Ye=new Set(Vn),Ze=new Set(rt),oe=Rn(rt,Pe,"staged"),le=Rn(rt,Pe,"unstaged"),Ct=Pe.length===0&&((r==null?void 0:r.snapshot.ahead)??0)>0,hi=Y.length>0&&me.trim().length>0,Je=(G==null?void 0:G.currentBranch)??(r==null?void 0:r.snapshot.branch)??n("common.unknown"),Nt=$e!==null,Re=zt==="github",gi=Re?n("git.remoteAuthDescriptionGithub"):n("git.remoteAuthDescription"),fi=Re?n("git.remoteAuthGithubPatLabel"):n("shell.clonePasswordLabel"),pi=Re?n("git.remoteAuthGithubPatPlaceholder"):n("shell.clonePasswordPlaceholder"),xi=Re?n("git.remoteAuthGithubUsernamePlaceholder"):n("shell.cloneUsernamePlaceholder"),vt=Number.isFinite(Xt)?Xt:Tt,bi=J?`minmax(120px, ${vt}fr) ${et}px minmax(140px, ${100-vt}fr)`:`minmax(120px, 1fr) ${et}px auto`;l.useEffect(()=>{ge==="staged"&&oe.length===0&&V(null),ge==="unstaged"&&le.length===0&&V(null)},[ge,oe.length,le.length]),l.useEffect(()=>{if(!F)return;const t=re.length>0?"unstaged":Y.length>0?"staged":"history";ne(s=>s==="unstaged"&&re.length>0||s==="staged"&&Y.length>0?s:t)},[F,Y.length,re.length]),l.useEffect(()=>{pe&&(g.some(t=>t.commitHash===pe)||z(null))},[g,pe]),l.useEffect(()=>{ie&&(g.some(t=>t.commitHash===ie)||K(null))},[ie,g]),l.useEffect(()=>{F&&fe!=="history"&&Q&&W(!1)},[F,Q,fe]),l.useLayoutEffect(()=>{if(F||!Q){dt(null);return}function t(){const o=tn.current,c=nn.current;!o||!c||typeof window>"u"||dt(Dn(o.getBoundingClientRect(),{width:c.getBoundingClientRect().width||Dt,height:c.getBoundingClientRect().height||c.scrollHeight||0},{width:window.innerWidth,height:window.innerHeight}))}t();const s=window.requestAnimationFrame(t);return window.addEventListener("resize",t),window.addEventListener("scroll",t,!0),()=>{window.cancelAnimationFrame(s),window.removeEventListener("resize",t),window.removeEventListener("scroll",t,!0)}},[v,G==null?void 0:G.local.length,Je,F,Q,Nt]);const Z=pe??ie;l.useLayoutEffect(()=>{if(!Z){mt(null);return}const t=Z;function s(){const c=Me.current.get(t)??null,x=ft.current;!c||!x||typeof window>"u"||mt(Dn(c.getBoundingClientRect(),{width:x.getBoundingClientRect().width||Dt,height:x.getBoundingClientRect().height||x.scrollHeight||0},{width:window.innerWidth,height:window.innerHeight}))}s();const o=window.requestAnimationFrame(s);return window.addEventListener("resize",s),window.addEventListener("scroll",s,!0),()=>{window.cancelAnimationFrame(o),window.removeEventListener("resize",s),window.removeEventListener("scroll",s,!0)}},[Z,g.length]),l.useEffect(()=>{if(!Z||typeof document>"u")return;const t=Z;function s(o){const c=o.target;if(!(c instanceof Node))return;const x=Me.current.get(t)??null,Le=ft.current;x!=null&&x.contains(c)||Le!=null&&Le.contains(c)||(z(null),K(null))}return document.addEventListener("pointerdown",s),()=>{document.removeEventListener("pointerdown",s)}},[Z]);async function B(t,s){var o;try{if(typeof navigator>"u"||!((o=navigator.clipboard)!=null&&o.writeText))throw new Error("clipboard unavailable");await navigator.clipboard.writeText(t),w({title:s,tone:"success"})}catch{w({title:n("common.copyContentFailed"),tone:"error"})}}async function hn(t,s){typeof window<"u"&&!window.confirm(n("git.discardConfirm",{path:s}))||await bt(t)}function gn(t){const s=(t==null?void 0:t.desktopFloating)===!0&&!F,o=s?{top:(O==null?void 0:O.top)??_,left:(O==null?void 0:O.left)??_,maxHeight:O==null?void 0:O.maxHeight,transformOrigin:(O==null?void 0:O.transformOrigin)??"top right"}:void 0,c=e.jsxs("div",{ref:s?nn:void 0,className:"git-operations-menu","data-floating":s?"true":"false",style:o,children:[e.jsxs("div",{className:"git-menu-section",children:[e.jsx("span",{className:"git-menu-caption",children:n("git.currentBranch")}),e.jsx("strong",{className:"git-menu-branch",children:Je})]}),e.jsxs("div",{className:"git-menu-section",children:[e.jsx("span",{className:"git-menu-caption",children:n("git.remoteAuthStatusLabel")}),e.jsxs("div",{className:"git-menu-branch-list",children:[e.jsx("strong",{className:"git-menu-branch",children:Nt?n("git.remoteAuthConfigured"):n("git.remoteAuthNotConfigured")}),e.jsx("button",{className:"git-menu-item",type:"button",disabled:v,onClick:()=>ze(),children:e.jsx("span",{children:n("git.remoteAuthAction")})})]})]}),e.jsxs("div",{className:"git-menu-section",children:[e.jsx("span",{className:"git-menu-caption",children:n("git.branchTitle")}),e.jsx("div",{className:"git-menu-branch-list",children:G==null?void 0:G.local.map(x=>e.jsx("button",{className:"git-menu-item",type:"button",disabled:v||x.current,onClick:()=>void oi(x.name),children:e.jsx("span",{children:x.current?`${n("git.switchBranch")} ${x.name}`:`${n("git.switchBranchTo")} ${x.name}`})},x.name))})]}),e.jsxs("div",{className:"git-menu-section",children:[e.jsx("button",{className:"git-menu-item",type:"button",disabled:v,onClick:()=>{W(!1),ot(!0)},children:e.jsx("span",{children:n("git.viewAllVersions")})}),e.jsx("button",{className:"git-menu-item",type:"button",disabled:v,onClick:()=>void yt("fetch"),children:e.jsx("span",{children:n("git.fetch")})}),e.jsx("button",{className:"git-menu-item",type:"button",disabled:v,onClick:()=>void yt("pull"),children:e.jsx("span",{children:n("git.pull")})}),e.jsx("button",{className:"git-menu-item",type:"button",disabled:v,onClick:()=>void yt("push"),children:e.jsx("span",{children:n("git.push")})}),e.jsx("button",{className:"git-menu-item",type:"button",disabled:v,onClick:()=>void ae(),children:e.jsx("span",{children:n("git.undoLastCommit")})}),e.jsx("button",{className:"git-menu-item",type:"button",disabled:v||at,onClick:()=>void xt({resetTreeScroll:!0}),children:e.jsx("span",{children:n("git.refresh")})})]})]});return s?typeof document>"u"?null:fn.createPortal(c,document.body):c}function St(t,s){if(s){Me.current.set(t,s);return}Me.current.delete(t)}function yi(){var o;if(!Z||typeof document>"u")return null;const t=g.find(c=>c.commitHash===Z);if(!t)return null;const s=((o=g[0])==null?void 0:o.commitHash)===t.commitHash&&t.commitKind==="local";return fn.createPortal(e.jsx("div",{ref:ft,className:"git-history-entry-menu","data-floating":"true",style:{top:(k==null?void 0:k.top)??_,left:(k==null?void 0:k.left)??_,maxHeight:k==null?void 0:k.maxHeight,transformOrigin:(k==null?void 0:k.transformOrigin)??"top right"},children:e.jsx(zi,{item:t,canUndo:s,actioning:v,onViewCommitChanges:c=>void He(c),onCopyCommitHash:c=>void B(c,n("git.copyCommitHashSuccess")),onCopyCommitMessage:c=>void B(ce(c),n("git.copyCommitMessageSuccess")),onCopyCommitVersion:c=>void we(c),onExplainCommitChange:c=>void Ae(c),onUndoLastCommit:()=>void ae()})}),document.body)}return e.jsxs("section",{className:["conversation-panel","surface-card","git-sidebar",a].filter(Boolean).join(" "),"data-testid":"git-sidebar",children:[e.jsxs("section",{className:"git-card git-scaffold-section",children:[e.jsxs("div",{className:"git-editor-row",children:[e.jsx("textarea",{ref:en,rows:1,value:me,onChange:t=>he($n(t.target.value)),onKeyDown:t=>{t.key==="Enter"&&t.preventDefault()},placeholder:n("git.commitSubjectPlaceholder")}),e.jsx("button",{className:"git-icon-button",type:"button","aria-label":n("git.generateDraft"),title:n("git.generateDraft"),onClick:()=>void ii(),disabled:v||at,children:e.jsx(is,{})})]}),e.jsxs("div",{className:"git-primary-actions",children:[e.jsx("button",{className:"secondary-button",type:"button",onClick:()=>void xt({resetTreeScroll:!0}),disabled:v||at||!i,children:n("git.refreshNow")}),e.jsx("button",{className:"primary-button git-primary-submit",type:"button",onClick:()=>{if(Ct){rn();return}si()},disabled:v||!Ct&&!hi,children:Ct?n("git.pushNow"):n("git.commitNow")})]})]}),F?e.jsxs("div",{className:"git-mobile-sections",children:[e.jsx(wt,{title:n("git.stagedChangesTitle"),count:Y.length,expanded:fe==="staged",onToggle:()=>ne("staged"),children:e.jsx(En,{title:n("git.stagedChangesTitle"),nodes:dn,collapsedTreePathSet:Ye,onToggleTreePath:Ke,onToggleMobileSelection:qe,selectedMobilePathSet:Ze,selectedTargets:oe,actioning:v,variant:"staged",swipeRowState:Kt,onSwipeRowChange:Ue,onStageToggle:Ie,onDiscardWithConfirm:hn,onClearSelectedTargets:()=>$(t=>t.filter(s=>!oe.includes(s))),onPreviewFile:Xe})}),e.jsx(wt,{title:n("git.changesTitle"),count:re.length,expanded:fe==="unstaged",onToggle:()=>ne("unstaged"),children:e.jsx(En,{title:n("git.changesTitle"),nodes:mn,collapsedTreePathSet:Ye,onToggleTreePath:Ke,onToggleMobileSelection:qe,selectedMobilePathSet:Ze,selectedTargets:le,actioning:v,variant:"unstaged",swipeRowState:Kt,onSwipeRowChange:Ue,onStageToggle:Ie,onDiscardWithConfirm:hn,onClearSelectedTargets:()=>$(t=>t.filter(s=>!le.includes(s))),onPreviewFile:Xe})}),e.jsxs(wt,{title:n("git.recentVersionsTitle"),count:p,expanded:fe==="history",onToggle:()=>ne("history"),trailingContent:e.jsx("span",{className:"badge",children:Je}),headerAction:e.jsx("button",{className:"git-icon-button git-mobile-section-action",type:"button","aria-label":n("git.operationMenu"),title:n("git.operationMenu"),"aria-expanded":Q,onClick:()=>{ne("history"),W(t=>!t)},disabled:v,children:e.jsx(_e,{})}),children:[Q?e.jsx("div",{className:"git-mobile-operations-shell",children:gn()}):null,e.jsx(Ii,{history:g,historyLoadingMore:de,hasMore:!!H,actioning:v,openCommitHash:pe,onMenuTriggerRef:St,onToggleMenu:t=>z(s=>s===t?null:t),onViewCommitChanges:t=>void He(t),onCopyCommitHash:t=>void B(t,n("git.copyCommitHashSuccess")),onCopyCommitMessage:t=>void B(ce(t),n("git.copyCommitMessageSuccess")),onCopyCommitVersion:t=>void we(t),onExplainCommitChange:t=>void Ae(t),onUndoLastCommit:()=>void ae(),onLoadMore:()=>void Ve()})]})]}):e.jsxs("div",{ref:Jt,className:"git-content-split",style:{gridTemplateRows:bi},children:[e.jsx("section",{className:"git-card git-tree-panel",children:e.jsxs("div",{ref:Qt,className:"git-tree-panel-body",children:[Y.length>0?e.jsx(Mn,{title:n("git.stagedChangesTitle"),count:Y.length,nodes:dn,selectedPath:te,collapsedTreePathSet:Ye,onToggleTreePath:Ke,onSelectFile:I,onPreviewFile:(t,s)=>{cn(t)&&Xe(t,s)},onToggleMobileSelection:qe,onStageToggle:Ie,onDiscard:bt,actioning:v,variant:"staged",isMobileViewport:F,selectedMobilePathSet:Ze,selectedTargets:oe,mobileActionMenuOpen:ge==="staged",onToggleMobileActionMenu:()=>V(t=>t==="staged"?null:"staged"),onClearSelectedTargets:()=>$(t=>t.filter(s=>!oe.includes(s)))}):null,e.jsx(Mn,{title:n("git.changesTitle"),count:re.length,nodes:mn,selectedPath:te,collapsedTreePathSet:Ye,onToggleTreePath:Ke,onSelectFile:I,onPreviewFile:(t,s)=>{cn(t)&&Xe(t,s)},onToggleMobileSelection:qe,onStageToggle:Ie,onDiscard:bt,actioning:v,variant:"unstaged",isMobileViewport:F,selectedMobilePathSet:Ze,selectedTargets:le,mobileActionMenuOpen:ge==="unstaged",onToggleMobileActionMenu:()=>V(t=>t==="unstaged"?null:"unstaged"),onClearSelectedTargets:()=>$(t=>t.filter(s=>!le.includes(s)))})]})}),e.jsx("button",{className:"git-panel-divider",type:"button",role:"separator","aria-label":n("git.resizePanels"),"aria-orientation":"horizontal","aria-valuemin":jn,"aria-valuemax":Mt,"aria-valuenow":J?vt:Mt,"data-dragging":ht,onPointerDown:mi,children:e.jsx("span",{className:"git-panel-divider-handle","aria-hidden":"true"})}),e.jsxs("section",{className:"git-card git-history-section",children:[e.jsxs("div",{className:"git-history-topbar",children:[e.jsxs("button",{className:"git-section-toggle",type:"button","aria-expanded":J,"aria-label":J?n("git.collapseRecentVersions"):n("git.expandRecentVersions"),onClick:()=>$t(t=>!t),children:[e.jsxs("span",{className:"git-section-toggle-main",children:[e.jsx(it,{expanded:J}),e.jsx("span",{children:n("git.recentVersionsTitle")})]}),e.jsx("span",{className:"workbench-section-counter",children:p})]}),e.jsxs("div",{className:"git-history-actions",children:[e.jsx("span",{className:"badge",children:Je}),e.jsx("button",{className:"git-icon-button",type:"button",ref:tn,"aria-label":n("git.operationMenu"),title:n("git.operationMenu"),onClick:()=>W(t=>!t),disabled:v,children:e.jsx(_e,{})}),Q?gn({desktopFloating:!0}):null]})]}),J?e.jsx(wn,{history:g,historyLoadingMore:de,hasMore:!!H,actioning:v,openCommitHash:ie,useNativeContextMenu:an,onMenuTriggerRef:St,onScroll:ni,onToggleMenu:t=>{if(an){const s=g.find(o=>o.commitHash===t);s&&ln(s);return}K(s=>s===t?null:t)},onOpenContextMenu:t=>void ln(t),onViewCommitChanges:t=>void He(t),onCopyCommitHash:t=>void B(t,n("git.copyCommitHashSuccess")),onCopyCommitMessage:t=>void B(ce(t),n("git.copyCommitMessageSuccess")),onCopyCommitVersion:t=>void we(t),onExplainCommitChange:t=>void Ae(t),onUndoLastCommit:()=>void ae(),onLoadMore:()=>void Ve()}):null]})]}),e.jsxs(De,{open:Yn,title:n("git.selectRemoteTitle"),description:n("git.selectRemoteDesc"),onClose:()=>{v||Ce(!1)},children:[e.jsxs("div",{className:"git-remote-auth-banner",children:[e.jsxs("div",{className:"git-remote-auth-banner-copy",children:[e.jsx("strong",{children:n("git.remoteAuthStatusLabel")}),e.jsx("span",{children:Nt?n("git.remoteAuthConfigured"):n("git.remoteAuthNotConfigured")})]}),e.jsx("button",{className:"secondary-button",type:"button",disabled:v,onClick:()=>ze(),children:n("git.remoteAuthAction")})]}),e.jsx("div",{className:"git-remote-select-list",children:Zn.map(t=>{const s=Ge.has(t.name),o=Jn.get(t.name);return e.jsxs("label",{className:"git-remote-item",children:[e.jsx("input",{type:"checkbox",checked:s,disabled:v,onChange:()=>{ut(c=>{const x=new Set(c);return x.has(t.name)?x.delete(t.name):x.add(t.name),x})}}),e.jsxs("span",{className:"git-remote-item-body",children:[e.jsx("span",{className:"git-remote-name",children:t.name}),e.jsx("span",{className:"git-remote-url",children:t.pushUrl}),o&&e.jsx("span",{className:`git-remote-result ${o.ok?"ok":"err"}`,children:o.summary})]})]},t.name)})}),e.jsxs("div",{className:"git-remote-actions",children:[e.jsx("button",{className:"secondary-button",type:"button",disabled:v,onClick:()=>Ce(!1),children:n("common.close")}),e.jsx("button",{className:"primary-button",type:"button",disabled:v||Ge.size===0,onClick:()=>void on(Array.from(Ge)),children:v?n("git.pushing"):n("git.pushSelected",{count:String(Ge.size)})})]})]}),e.jsxs(De,{open:Qn,title:n("git.remoteAuthTitle"),description:gi,onClose:()=>{v||ve(!1)},children:[e.jsxs("div",{className:"workbench-clone-form",children:[e.jsxs("label",{className:"workbench-modal-field",children:[e.jsx("span",{children:n("shell.cloneAuthModeLabel")}),e.jsxs("select",{value:A.authMode,disabled:v,onChange:t=>X(s=>({...s,authMode:t.target.value})),children:[e.jsx("option",{value:"none",children:n("shell.cloneAuthModeNone")}),e.jsx("option",{value:"basic",children:n("shell.cloneAuthModeBasic")}),e.jsx("option",{value:"token",children:n("shell.cloneAuthModeToken")})]})]}),A.authMode==="basic"?e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"workbench-modal-field",children:[e.jsx("span",{children:n("shell.cloneUsernameLabel")}),e.jsx("input",{type:"text",value:A.username,placeholder:xi,autoComplete:"username",onChange:t=>X(s=>({...s,username:t.target.value}))})]}),e.jsxs("label",{className:"workbench-modal-field",children:[e.jsx("span",{children:fi}),e.jsx("input",{type:"password",value:A.password,placeholder:pi,autoComplete:"current-password",onChange:t=>X(s=>({...s,password:t.target.value}))})]})]}):null,A.authMode==="token"?e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"workbench-modal-field",children:[e.jsx("span",{children:n("shell.cloneUsernameLabel")}),e.jsx("input",{type:"text",value:A.username,placeholder:n("shell.cloneTokenUsernamePlaceholder"),autoComplete:"username",onChange:t=>X(s=>({...s,username:t.target.value}))})]}),e.jsxs("label",{className:"workbench-modal-field",children:[e.jsx("span",{children:n("shell.cloneTokenLabel")}),e.jsx("input",{type:"password",value:A.token,placeholder:n("shell.cloneTokenPlaceholder"),autoComplete:"current-password",onChange:t=>X(s=>({...s,token:t.target.value}))})]})]}):null,Re?e.jsx("p",{className:"git-remote-auth-hint",children:n("git.remoteAuthGithubPatHint")}):null,A.authMode!=="none"?e.jsxs("label",{className:"settings-checkbox git-remote-auth-remember-toggle",children:[e.jsx("input",{type:"checkbox",checked:A.rememberOnHost,onChange:t=>X(s=>({...s,rememberOnHost:t.target.checked}))}),e.jsx("span",{children:n("git.remoteAuthRemember")})]}):null,e.jsx("p",{className:"git-remote-auth-hint",children:n("git.remoteAuthSessionHint")})]}),e.jsxs("div",{className:"git-remote-actions",children:[e.jsx("button",{className:"secondary-button",type:"button",disabled:v,onClick:()=>ve(!1),children:n("common.close")}),e.jsx("button",{className:"primary-button",type:"button",disabled:v,onClick:ri,children:n("git.remoteAuthSave")})]})]}),e.jsx(De,{open:zn,title:n("git.viewAllVersions"),description:n("git.viewAllVersionsDescription",{count:String(p)}),onClose:()=>ot(!1),children:e.jsx(wn,{history:g,historyLoadingMore:de,hasMore:!!H,actioning:v,openCommitHash:ie,className:"git-history-modal-list",onMenuTriggerRef:St,onToggleMenu:t=>K(s=>s===t?null:t),onViewCommitChanges:t=>void He(t),onCopyCommitHash:t=>void B(t,n("git.copyCommitHashSuccess")),onCopyCommitMessage:t=>void B(ce(t),n("git.copyCommitMessageSuccess")),onCopyCommitVersion:t=>void we(t),onExplainCommitChange:t=>void Ae(t),onUndoLastCommit:()=>void ae(),onLoadMore:()=>void Ve()})}),e.jsx(De,{open:Kn!==null,className:"git-commit-detail-modal",title:(L==null?void 0:L.subject)||n("git.commitDetailTitle"),description:L?n("git.commitDetailDescription",{hash:L.shortHash}):n("git.commitDetailLoading"),onClose:li,children:Xn?e.jsx("div",{className:"git-commit-detail-state",children:e.jsx("p",{children:n("git.commitDetailLoading")})}):Bt?e.jsx("div",{className:"git-commit-detail-state is-error",children:e.jsx("p",{children:Bt})}):L?e.jsxs("div",{className:"git-commit-detail-shell",children:[e.jsxs("div",{className:"git-commit-detail-meta-grid",children:[e.jsxs("div",{className:"git-commit-detail-meta-card",children:[e.jsx("span",{children:n("git.commitVersionLabel")}),e.jsx("strong",{children:L.versionLabel})]}),e.jsxs("div",{className:"git-commit-detail-meta-card",children:[e.jsx("span",{children:n("git.commitHashLabel")}),e.jsx("strong",{children:L.commitHash})]}),e.jsxs("div",{className:"git-commit-detail-meta-card",children:[e.jsx("span",{children:n("git.commitAuthorLabel")}),e.jsx("strong",{children:L.authorName})]}),e.jsxs("div",{className:"git-commit-detail-meta-card",children:[e.jsx("span",{children:n("git.commitTimeLabel")}),e.jsx("strong",{children:Zi(L.authoredAt)})]})]}),e.jsxs("section",{className:"git-commit-detail-section",children:[e.jsx("div",{className:"git-commit-detail-section-header",children:e.jsx("h3",{children:n("git.commitMessageLabel")})}),e.jsx("pre",{className:"git-commit-detail-message",children:ce(L)})]}),e.jsxs("section",{className:"git-commit-detail-section",children:[e.jsxs("div",{className:"git-commit-detail-section-header",children:[e.jsx("h3",{children:n("git.changedFilesTitle")}),e.jsx("span",{className:"workbench-section-counter",children:L.changedFiles.length})]}),e.jsx("div",{className:"git-commit-detail-file-list",children:L.changedFiles.map(t=>e.jsxs("div",{className:"git-commit-detail-file-item",children:[e.jsx("span",{className:"git-commit-detail-file-status","data-status":t.status,children:t.status}),e.jsxs("div",{className:"git-commit-detail-file-copy",children:[e.jsx("strong",{children:t.path}),t.oldPath?e.jsx("span",{children:n("git.renamedFromLabel",{path:t.oldPath})}):null]})]},`${t.status}:${t.oldPath??""}:${t.path}`))})]}),e.jsxs("section",{className:"git-commit-detail-section",children:[e.jsxs("div",{className:"git-commit-detail-section-header",children:[e.jsx("h3",{children:n("git.commitDiffLabel")}),L.diffTruncated?e.jsx("span",{className:"git-commit-detail-truncated",children:n("git.diffTruncated")}):null]}),e.jsx("pre",{className:"git-commit-detail-diff",children:L.diffContent||n("git.emptyDiff")})]})]}):e.jsx("div",{className:"git-commit-detail-state",children:e.jsx("p",{children:n("git.commitDetailEmpty")})})}),e.jsx(De,{open:qn,className:"git-explain-provider-modal",title:n("git.explainCommitTitle"),description:n("git.explainCommitDescription"),onClose:()=>{ee||(ye(!1),be(null),se(null))},children:e.jsxs("div",{className:"git-explain-provider-shell",children:[e.jsx(Gi,{workspaceId:i,selectedProvider:je,pendingProvider:ee?je:null,disabled:ee,onSelect:t=>se(t)}),e.jsxs("div",{className:"git-explain-provider-actions",children:[e.jsx("button",{type:"button",className:"secondary-button",disabled:ee,onClick:()=>{ye(!1),be(null),se(null)},children:n("common.cancel")}),e.jsx("button",{type:"button",className:"primary-button",disabled:!je||ee,onClick:()=>void ui(),children:ee?n("conversation.sendingState"):n("git.startExplainCommit")})]})]})}),e.jsx(Wi,{workspaceId:i,filePath:Yt,open:Yt!==null,onClose:()=>{Se(null),Te(null)},onSaved:async()=>{await xt({resetTreeScroll:!0})},diffContent:ei}),yi()]})}function Mn({title:a,count:i,nodes:u,selectedPath:h,collapsedTreePathSet:d,onToggleTreePath:C,onSelectFile:b,onPreviewFile:j,onToggleMobileSelection:y,onStageToggle:N,onDiscard:M,actioning:S,variant:T,isMobileViewport:f,selectedMobilePathSet:r,selectedTargets:m,mobileActionMenuOpen:g,onToggleMobileActionMenu:E,onClearSelectedTargets:p}){const P=kt(u),H=T==="staged"?n("git.unstageAll"):n("git.stageAll");return e.jsxs("section",{className:"git-tree-group","data-variant":T,children:[e.jsxs("div",{className:"git-section-header git-tree-group-header",children:[e.jsx("h3",{children:a}),e.jsxs("div",{className:"git-tree-group-actions",children:[e.jsx("span",{className:"workbench-section-counter",children:i}),!f&&P.length>0?e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"git-icon-button",type:"button","aria-label":H,title:H,onClick:()=>void N(P,T==="staged"),disabled:S,children:e.jsx(Ft,{staged:T==="staged"})}),T==="unstaged"?e.jsx("button",{className:"git-icon-button danger",type:"button","aria-label":n("git.discardAll"),title:n("git.discardAll"),onClick:()=>void M(P),disabled:S,children:e.jsx(Ot,{})}):null]}):null,f&&m.length>0?e.jsx("button",{className:"git-icon-button",type:"button","aria-label":n("git.operationMenu"),title:n("git.operationMenu"),onClick:E,disabled:S,children:e.jsx(_e,{})}):null]}),f&&g?e.jsxs("div",{className:"git-selection-menu",children:[e.jsxs("div",{className:"git-menu-section",children:[e.jsx("span",{className:"git-menu-caption",children:n("git.selectedFiles")}),e.jsx("strong",{className:"git-menu-branch",children:m.length})]}),e.jsxs("div",{className:"git-menu-section",children:[e.jsx("button",{className:"git-menu-item",type:"button",disabled:S,onClick:()=>void N(m,T==="staged"),children:e.jsx("span",{children:T==="staged"?n("git.unstage"):n("git.stage")})}),T==="unstaged"?e.jsx("button",{className:"git-menu-item",type:"button",disabled:S,onClick:()=>void M(m),children:e.jsx("span",{children:n("git.discard")})}):null,e.jsx("button",{className:"git-menu-item",type:"button",disabled:S,onClick:p,children:e.jsx("span",{children:n("git.clearSelection")})})]})]}):null]}),e.jsx("div",{className:"git-tree-shell",role:"tree","aria-label":a,children:u.length?On({nodes:u,depth:0,collapsedTreePathSet:d,selectedPath:h,onToggleTreePath:C,onSelectFile:b,onPreviewFile:j,onToggleMobileSelection:y,onStageToggle:N,onDiscard:M,actioning:S,variant:T,isMobileViewport:f,selectedMobilePathSet:r}):e.jsx("p",{className:"git-tree-status",children:n("git.noChanges")})})]})}function wt({title:a,count:i,expanded:u,onToggle:h,trailingContent:d,headerAction:C,children:b}){return e.jsxs("section",{className:"git-mobile-section","data-expanded":u,children:[e.jsxs("div",{className:"git-mobile-section-header",children:[e.jsxs("button",{className:"git-mobile-section-toggle",type:"button","aria-expanded":u,onClick:h,children:[e.jsxs("span",{className:"git-mobile-section-toggle-main",children:[e.jsx(it,{expanded:u}),e.jsx("h3",{children:a})]}),e.jsxs("span",{className:"git-mobile-section-toggle-meta",children:[d,e.jsx("span",{className:"workbench-section-counter",children:i})]})]}),C?e.jsx("div",{className:"git-mobile-section-header-action",children:C}):null]}),u?e.jsx("div",{className:"git-mobile-section-body",children:b}):null]})}function En({title:a,nodes:i,collapsedTreePathSet:u,onToggleTreePath:h,onToggleMobileSelection:d,selectedMobilePathSet:C,selectedTargets:b,actioning:j,variant:y,swipeRowState:N,onSwipeRowChange:M,onStageToggle:S,onDiscardWithConfirm:T,onClearSelectedTargets:f,onPreviewFile:r}){return e.jsxs("div",{className:"git-mobile-record-shell",children:[b.length>0?e.jsxs("div",{className:"git-mobile-selection-toolbar",children:[e.jsxs("span",{className:"git-mobile-selection-count",children:[n("git.selectedFiles")," ",b.length]}),e.jsxs("div",{className:"git-mobile-selection-actions",children:[e.jsx("button",{type:"button",className:"secondary-button",disabled:j,onClick:()=>void S(b,y==="staged"),children:y==="staged"?n("git.unstage"):n("git.stage")}),y==="unstaged"?e.jsx("button",{type:"button",className:"secondary-button workbench-danger-button",disabled:j,onClick:()=>void T(b,`${b.length}`),children:n("git.discard")}):null,e.jsx("button",{type:"button",className:"secondary-button",disabled:j,onClick:f,children:n("git.clearSelection")})]})]}):null,e.jsx("div",{className:"git-mobile-record-list",role:"tree","aria-label":a,children:i.length?Fn({nodes:i,depth:0,collapsedTreePathSet:u,onToggleTreePath:h,onToggleMobileSelection:d,selectedMobilePathSet:C,actioning:j,variant:y,swipeRowState:N,onSwipeRowChange:M,onStageToggle:S,onDiscardWithConfirm:T,onPreviewFile:r}):e.jsx("p",{className:"git-tree-status",children:n("git.noChanges")})})]})}function Fn({nodes:a,depth:i,collapsedTreePathSet:u,onToggleTreePath:h,onToggleMobileSelection:d,selectedMobilePathSet:C,actioning:b,variant:j,swipeRowState:y,onSwipeRowChange:N,onStageToggle:M,onDiscardWithConfirm:S,onPreviewFile:T}){return a.map(f=>{if(f.kind==="directory"){const g=!u.has(f.path),E=kt(f.children),p=`directory:${f.path}`;return e.jsxs("div",{className:"git-mobile-record-branch",children:[e.jsx(Hn,{rowKey:p,openState:(y==null?void 0:y.path)===p?y.direction:null,onOpenStateChange:P=>N(P?{path:p,direction:P}:null),trailingActions:E.length>0?[{label:j==="staged"?n("git.unstage"):n("git.stage"),tone:"accent",onPress:()=>void M(E,j==="staged")},...j==="unstaged"?[{label:n("git.discard"),tone:"danger",onPress:()=>void S(E,f.path)}]:[]]:null,children:e.jsxs("button",{className:"git-mobile-record git-mobile-record-directory",type:"button",style:{paddingInlineStart:`${Sn+i*Tn}px`},onClick:()=>h(f.path),children:[e.jsxs("span",{className:"git-mobile-record-leading",children:[e.jsx("span",{className:"git-tree-chevron","data-expanded":g,children:e.jsx(it,{expanded:g})}),e.jsx("span",{className:"git-mobile-record-title",children:f.name})]}),e.jsx("span",{className:"git-mobile-record-meta",children:E.length})]})}),g?e.jsx("div",{className:"git-mobile-record-children",role:"group",children:Fn({nodes:f.children,depth:i+1,collapsedTreePathSet:u,onToggleTreePath:h,onToggleMobileSelection:d,selectedMobilePathSet:C,actioning:b,variant:j,swipeRowState:y,onSwipeRowChange:N,onStageToggle:M,onDiscardWithConfirm:S,onPreviewFile:T})}):null]},p)}const r=`file:${f.path}`,m=C.has(f.path);return e.jsx(Hn,{rowKey:r,openState:(y==null?void 0:y.path)===r?y.direction:null,onOpenStateChange:g=>N(g?{path:r,direction:g}:null),trailingActions:[{label:n("git.preview"),tone:"neutral",onPress:()=>T(f.change.path,f.change)},{label:j==="staged"?n("git.unstage"):n("git.stage"),tone:"accent",onPress:()=>void M([f.change.path],j==="staged")},...j==="unstaged"?[{label:n("git.discard"),tone:"danger",onPress:()=>void S([f.change.path],f.path)}]:[]],children:e.jsxs("div",{className:"git-mobile-record git-mobile-record-file","data-active":m,style:{paddingInlineStart:`${Sn+i*Tn}px`},children:[e.jsx("input",{className:"git-tree-select-checkbox",type:"checkbox",checked:m,"aria-label":`${n("git.selectFile")} ${f.name}`,onChange:()=>d(f.change.path)}),e.jsxs("button",{className:"git-mobile-record-file-main",type:"button",onClick:()=>d(f.change.path),children:[e.jsx("span",{className:"git-tree-file-icon","data-kind":Lt(f.name),"aria-hidden":"true",children:Rt(f.name)}),e.jsxs("span",{className:"git-mobile-record-copy",children:[e.jsx("span",{className:"git-mobile-record-title",children:f.name}),e.jsx("span",{className:"git-mobile-record-path",children:f.path})]}),e.jsx("span",{className:"git-status-badge","data-status":f.status,children:f.status})]})]})},r)})}function Hn({rowKey:a,openState:i,onOpenStateChange:u,trailingActions:h,children:d}){const C=Ui(),b=l.useRef(null),[j,y]=l.useState(0),N=((h==null?void 0:h.length)??0)*Et;l.useEffect(()=>{i||y(0)},[i,a]);const M=j!==0?j:i==="trailing"?-N:0;function S(m){var g,E;m.button===0&&(b.current={pointerId:m.pointerId,startX:m.clientX},(E=(g=m.currentTarget).setPointerCapture)==null||E.call(g,m.pointerId))}function T(m){const g=b.current;if(!g||g.pointerId!==m.pointerId)return;const E=N>0?N+10:0,p=Math.max(-E,Math.min(0,m.clientX-g.startX));y(p)}function f(m){var E,p;const g=b.current;if(!(!g||g.pointerId!==m.pointerId)){if((p=(E=m.currentTarget).releasePointerCapture)==null||p.call(E,m.pointerId),b.current=null,j<=-44&&(h!=null&&h.length)){C.trigger("gesture"),u("trailing"),y(0);return}u(null),y(0)}}function r(m){var E,p;const g=b.current;!g||g.pointerId!==m.pointerId||((p=(E=m.currentTarget).releasePointerCapture)==null||p.call(E,m.pointerId),b.current=null,y(0))}return e.jsxs("div",{className:"git-mobile-swipe-row","data-open-state":i??"closed","data-dragging":j!==0,children:[h==null?void 0:h.map((m,g)=>e.jsx("button",{type:"button",className:"git-mobile-swipe-action trailing","data-tone":m.tone,style:{right:g*Et,width:Et},onClick:()=>{C.trigger(m.tone==="danger"?"warning":"action"),u(null),m.onPress()},children:m.label},`trailing-${g}`)),e.jsx("div",{className:"git-mobile-swipe-content",style:{transform:`translateX(${M}px)`},onPointerDown:S,onPointerMove:T,onPointerUp:f,onPointerCancel:r,children:d})]})}function Ii({history:a,historyLoadingMore:i,hasMore:u,actioning:h,openCommitHash:d,onMenuTriggerRef:C,onToggleMenu:b,onViewCommitChanges:j,onCopyCommitHash:y,onCopyCommitMessage:N,onCopyCommitVersion:M,onExplainCommitChange:S,onUndoLastCommit:T,onLoadMore:f}){return a.length?e.jsxs("div",{className:"git-mobile-history-list",children:[a.map(r=>e.jsx("article",{className:"git-mobile-history-entry","data-kind":r.commitKind,children:e.jsxs("div",{className:"git-mobile-history-entry-main",children:[e.jsx("span",{className:"git-history-marker","data-kind":r.commitKind,"aria-hidden":"true"}),e.jsxs("div",{className:"git-mobile-history-copy",children:[e.jsxs("div",{className:"git-history-title-row",children:[e.jsx("strong",{title:r.subject,children:r.subject}),e.jsx("span",{className:"git-history-kind-badge","data-kind":r.commitKind,children:Bn(r.commitKind)})]}),r.refs.length>0?e.jsx("div",{className:"git-history-ref-list",children:r.refs.map(m=>e.jsx("span",{className:"git-history-ref-pill","data-kind":m.kind,"data-remote-index":String(Un(m.remoteName)),children:m.name},`${r.commitHash}:${m.kind}:${m.name}`))}):null,e.jsxs("div",{className:"git-history-meta",children:[e.jsx("span",{className:"git-history-hash",children:r.commitHash.slice(0,8)}),e.jsx("span",{children:r.authorName}),e.jsx("time",{dateTime:r.authoredAt,children:Wn(r.authoredAt)})]})]}),e.jsx("button",{type:"button",className:"git-icon-button",ref:m=>C(r.commitHash,m),"aria-label":n("git.historyItemMenu"),onClick:()=>b(r.commitHash),children:e.jsx(_e,{})})]})},r.commitHash)),u?e.jsx("button",{type:"button",className:"secondary-button git-mobile-history-more",disabled:i,onClick:f,children:i?`${n("git.refreshNow")}...`:n("common.loadMore")}):null]}):e.jsx("p",{className:"git-tree-status",children:n("git.noHistory")})}function wn({history:a,historyLoadingMore:i,hasMore:u,actioning:h,openCommitHash:d,className:C,useNativeContextMenu:b=!1,onMenuTriggerRef:j,onScroll:y,onToggleMenu:N,onOpenContextMenu:M,onViewCommitChanges:S,onCopyCommitHash:T,onCopyCommitMessage:f,onCopyCommitVersion:r,onExplainCommitChange:m,onUndoLastCommit:g,onLoadMore:E}){return a.length?e.jsxs("div",{className:["git-history-list",C].filter(Boolean).join(" "),onScroll:y,children:[a.map(p=>{const P=d===p.commitHash;return e.jsxs("article",{className:"git-history-entry","data-kind":p.commitKind,"data-menu-open":P?"true":"false",onContextMenu:H=>{!b||!M||(H.preventDefault(),H.stopPropagation(),M(p))},children:[e.jsx("span",{className:"git-history-marker","data-kind":p.commitKind,"aria-hidden":"true"}),e.jsxs("div",{className:"git-history-body",children:[e.jsxs("div",{className:"git-history-title-row",children:[e.jsx("strong",{title:p.subject,children:p.subject}),e.jsxs("div",{className:"git-history-title-actions",children:[e.jsx("span",{className:"git-history-kind-badge","data-kind":p.commitKind,children:Bn(p.commitKind)}),b?null:e.jsx("button",{type:"button",className:"git-icon-button git-history-more",ref:H=>j(p.commitHash,H),"aria-label":n("git.historyItemMenu"),onClick:()=>{N(p.commitHash)},children:e.jsx(_e,{})})]})]}),p.refs.length>0?e.jsx("div",{className:"git-history-ref-list",children:p.refs.map(H=>e.jsx("span",{className:"git-history-ref-pill","data-kind":H.kind,"data-remote-index":String(Un(H.remoteName)),children:H.name},`${p.commitHash}:${H.kind}:${H.name}`))}):null,e.jsxs("div",{className:"git-history-meta",children:[e.jsx("span",{className:"git-history-hash",children:p.commitHash.slice(0,8)}),e.jsx("span",{children:p.authorName}),e.jsx("time",{dateTime:p.authoredAt,children:Wn(p.authoredAt)})]})]})]},p.commitHash)}),i?e.jsxs("p",{className:"git-history-loading",children:[n("git.refreshNow"),"..."]}):null,u?e.jsx("button",{type:"button",className:"secondary-button git-mobile-history-more",disabled:i,onClick:E,children:i?`${n("git.refreshNow")}...`:n("common.loadMore")}):null]}):e.jsx("p",{className:"status-text",children:n("git.noHistory")})}function zi({item:a,canUndo:i,actioning:u,onViewCommitChanges:h,onCopyCommitHash:d,onCopyCommitMessage:C,onCopyCommitVersion:b,onExplainCommitChange:j,onUndoLastCommit:y}){return e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"git-menu-item",onClick:()=>h(a.commitHash),children:e.jsx("span",{children:n("git.viewCommitChanges")})}),e.jsx("button",{type:"button",className:"git-menu-item",onClick:()=>d(a.commitHash),children:e.jsx("span",{children:n("git.copyCommitHash")})}),e.jsx("button",{type:"button",className:"git-menu-item",onClick:()=>C(a),children:e.jsx("span",{children:n("git.copyCommitMessage")})}),e.jsx("button",{type:"button",className:"git-menu-item",onClick:()=>b(a.commitHash),children:e.jsx("span",{children:n("git.copyCommitVersion")})}),e.jsx("button",{type:"button",className:"git-menu-item",onClick:()=>j(a.commitHash),children:e.jsx("span",{children:n("git.explainCommitAction")})}),i?e.jsx("button",{type:"button",className:"git-menu-item",disabled:u,onClick:y,children:e.jsx("span",{children:n("git.undoLastCommit")})}):null]})}function On({nodes:a,depth:i,collapsedTreePathSet:u,selectedPath:h,onToggleTreePath:d,onSelectFile:C,onPreviewFile:b,onToggleMobileSelection:j,onStageToggle:y,onDiscard:N,actioning:M,variant:S,isMobileViewport:T,selectedMobilePathSet:f}){return a.map(r=>{if(r.kind==="directory"){const E=!u.has(r.path),p=kt(r.children),P=`${S==="staged"?n("git.unstage"):n("git.stage")} ${r.path}`,H=`${n("git.discard")} ${r.path}`;return e.jsxs("div",{className:"git-tree-node",children:[e.jsxs("div",{className:"git-tree-row",role:"treeitem","aria-expanded":E,children:[e.jsxs("button",{className:"git-tree-trigger",type:"button",style:{paddingInlineStart:`${6+i*8}px`},onClick:()=>d(r.path),children:[e.jsx("span",{className:"git-tree-chevron","data-expanded":E,children:e.jsx(it,{expanded:E})}),e.jsx("span",{className:"git-tree-label git-tree-label-directory",children:r.name})]}),!T&&p.length>0?e.jsxs("div",{className:"git-row-actions",children:[e.jsx("button",{className:"git-icon-button",type:"button","aria-label":P,title:P,onClick:()=>void y(p,S==="staged"),disabled:M,children:e.jsx(Ft,{staged:S==="staged"})}),S==="unstaged"?e.jsx("button",{className:"git-icon-button danger",type:"button","aria-label":H,title:H,onClick:()=>void N(p),disabled:M,children:e.jsx(Ot,{})}):null]}):null]}),E?e.jsx("div",{className:"git-tree-children",role:"group",children:On({nodes:r.children,depth:i+1,collapsedTreePathSet:u,selectedPath:h,onToggleTreePath:d,onSelectFile:C,onPreviewFile:b,onToggleMobileSelection:j,onStageToggle:y,onDiscard:N,actioning:M,variant:S,isMobileViewport:T,selectedMobilePathSet:f})}):null]},`directory:${r.path}`)}const m=f.has(r.path),g=T?m:h===r.path;return T?e.jsxs("div",{className:"git-tree-row",role:"treeitem","data-active":g,"data-mobile":"true",children:[e.jsx("input",{className:"git-tree-select-checkbox",type:"checkbox",checked:m,"aria-label":`${n("git.selectFile")} ${r.name}`,onChange:()=>j(r.change.path)}),e.jsxs("button",{className:"git-tree-file-button",type:"button","data-active":g,"data-mobile":"true",style:{paddingInlineStart:`${18+i*8}px`},onClick:()=>j(r.change.path),children:[e.jsx("span",{className:"git-tree-file-icon","data-kind":Lt(r.name),"aria-hidden":"true",children:Rt(r.name)}),e.jsx("span",{className:"git-tree-label-wrap",children:e.jsx("span",{className:"git-tree-label",children:r.name})}),e.jsx("span",{className:"git-tree-file-meta",children:e.jsx("span",{className:"git-status-badge","data-status":r.status,children:r.status})})]})]},`file:${r.path}`):e.jsxs("div",{className:"git-tree-row",role:"treeitem","data-active":g,children:[e.jsxs("button",{className:"git-tree-file-button",type:"button","data-active":g,style:{paddingInlineStart:`${18+i*8}px`},onClick:()=>{C(r.change.path),b&&b(r.change.path,r.change)},children:[e.jsx("span",{className:"git-tree-file-icon","data-kind":Lt(r.name),"aria-hidden":"true",children:Rt(r.name)}),e.jsx("span",{className:"git-tree-label-wrap",children:e.jsx("span",{className:"git-tree-label",children:r.name})}),e.jsx("span",{className:"git-tree-file-meta",children:e.jsx("span",{className:"git-status-badge","data-status":r.status,children:r.status})})]}),e.jsxs("div",{className:"git-row-actions",children:[e.jsx("button",{className:"git-icon-button",type:"button","aria-label":r.variant==="staged"?n("git.unstage"):n("git.stage"),title:r.variant==="staged"?n("git.unstage"):n("git.stage"),onClick:()=>void y([r.change.path],r.variant==="staged"),disabled:M,children:e.jsx(Ft,{staged:r.variant==="staged"})}),S==="unstaged"?e.jsx("button",{className:"git-icon-button danger",type:"button","aria-label":n("git.discard"),title:n("git.discard"),onClick:()=>void N([r.change.path]),disabled:M,children:e.jsx(Ot,{})}):null]})]},`file:${r.path}`)})}function An(a,i){return{kind:"directory",name:a,path:i,children:new Map}}function Pn(a,i){const u=An("","");for(const h of a){const d=h.path.replace(/\\/g,"/"),C=d.split("/").filter(Boolean);let b=u;C.forEach((j,y)=>{const N=C.slice(0,y+1).join("/");if(y===C.length-1){b.children.set(`file:${N}`,{kind:"file",name:j,path:d,change:h,status:Ki(h,i),variant:i});return}const M=`directory:${N}`,S=b.children.get(M);if(S&&S.kind==="directory"){b=S;return}const T=An(j,N);b.children.set(M,T),b=T})}return Gn(kn([...u.children.values()]))}function kn(a){return[...a].sort((i,u)=>i.kind!==u.kind?i.kind==="directory"?-1:1:i.name.localeCompare(u.name,"zh-CN")).map(i=>i.kind==="directory"?{kind:"directory",name:i.name,path:i.path,children:kn([...i.children.values()])}:i)}function Gn(a){return a.map(i=>{var b;if(i.kind!=="directory")return i;const u=Gn(i.children);let h=i.name,d=i.path,C=u;for(;C.length===1&&((b=C[0])==null?void 0:b.kind)==="directory";){const j=C[0];h=`${h}/${j.name}`,d=j.path,C=j.children}return{kind:"directory",name:h,path:d,children:C}})}function Rn(a,i,u){const h=new Set(a);return i.filter(d=>_t(d,u)&&h.has(d.path)).map(d=>d.path)}function kt(a){const i=[],u=new Set;function h(d){if(d.kind==="file"){u.has(d.path)||(u.add(d.path),i.push(d.path));return}d.children.forEach(h)}return a.forEach(h),i}function _t(a,i){return i==="staged"?!!a.stagedStatus:!!a.worktreeStatus}function Ki(a,i){return i==="staged"?a.stagedStatus??a.status:a.worktreeStatus??a.status}function Xi(a){return{subject:$n(a).trim(),body:null,footer:null,source:"manual"}}function $n(a){return a.replace(/[\r\n]+/g," ")}function ce(a){const i=a.subject.trim(),u=a.body.trim();return u?`${i}
|
|
2
|
-
|
|
3
|
-
${u}`:i}function qi(a){const i=a.changedFiles.map(d=>`- [${d.status}] ${d.path}${d.oldPath?` (from ${d.oldPath})`:""}`).join(`
|
|
4
|
-
`),u=a.diffContent.length>Ht?a.diffContent.slice(0,Ht):a.diffContent,h=a.diffContent.length>Ht||a.diffTruncated?`
|
|
5
|
-
注意:diff 内容过长,下面已经截断,只分析可见部分,同时明确指出可能遗漏的区域。`:"";return["请你分析下面这个 Git 提交。","输出要求:","1. 先用 3 到 5 句话说明这次改动的核心目的。","2. 按文件说明关键改动点,不要泛泛而谈。","3. 指出潜在风险、边界情况和可能的回归点。","4. 如果提交信息写得差,给出一条更合适的中文提交说明。","",`版本号:${a.versionLabel}`,`Commit Hash:${a.commitHash}`,`提交标题:${a.subject}`,`提交作者:${a.authorName} <${a.authorEmail}>`,`提交时间:${a.authoredAt}`,"","变更文件:",i||"- 无",h,"","Diff:",u||"(empty diff)"].join(`
|
|
6
|
-
`)}function Yi(a){if(!a)return;a.style.height="0px";const i=Math.min(Math.max(a.scrollHeight,34),120);a.style.height=`${i}px`,a.style.overflowY=a.scrollHeight>120?"auto":"hidden"}function Bn(a){switch(a){case"local":return n("git.historyKindLocal");case"remote":return n("git.historyKindRemote");default:return n("git.historyKindShared")}}function Un(a){if(!a)return 0;let i=0;for(const u of a)i=i*33+u.charCodeAt(0)>>>0;return i%6}function Zi(a){const i=Date.parse(a);return Number.isNaN(i)?a:new Intl.DateTimeFormat("zh-CN",{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",hour12:!1}).format(i)}function D(a,i){return a instanceof _n?Ji(a)??a.message:typeof a=="object"&&a&&"message"in a?a.message:i}function At(a){return`git-sidebar.snapshot.${a}`}function Ji(a){switch(a.errorCode){case"UNAUTHORIZED":return n("git.errors.unauthorized");case"WORKSPACE_NOT_FOUND":return n("git.errors.workspaceNotFound");case"INVALID_WORKSPACE":return n("git.errors.invalidWorkspace");case"NOT_GIT_REPOSITORY":return n("git.errors.notGitRepository");case"GIT_REPO_NOT_FOUND":return n("git.errors.repoNotFound");case"PATH_OUT_OF_WORKSPACE":return n("git.errors.pathOutOfWorkspace");case"INVALID_TARGET":return n("git.errors.invalidTarget");case"NOT_STAGED":return n("git.errors.notStaged");case"EMPTY_STAGED_CHANGES":return n("git.errors.emptyStagedChanges");case"BRANCH_CONFLICT":return n("git.errors.branchConflict");case"BRANCH_NOT_FOUND":return n("git.errors.branchNotFound");case"REMOTE_NOT_FOUND":return n("git.errors.remoteNotFound");case"GIT_REMOTE_AUTH_FAILED":return n("git.errors.remoteAuthFailed");case"GIT_PUSH_FAILED":return n("git.errors.pushFailed");case"GIT_PULL_FAILED":return n("git.errors.pullFailed");case"GIT_REMOTE_FAILED":return n("git.errors.remoteFailed");case"GIT_COMMAND_TIMEOUT":return n("git.errors.commandTimeout");case"GIT_DISCARD_FAILED":return n("git.discardFailed");case"GIT_UNDO_FAILED":return n("git.undoLastCommitFailed");default:return null}}function Ln(a){return a instanceof _n&&a.errorCode==="GIT_REMOTE_AUTH_FAILED"}function Qi(a){return!a||!a.mode||a.mode==="none"?nt:a.mode==="basic"?{authMode:"basic",username:a.username??"",password:a.password??"",token:"",rememberOnHost:!1}:a.mode==="token"?{authMode:"token",username:a.username??"",password:"",token:a.token??"",rememberOnHost:!1}:nt}function es(a){return a.authMode==="none"?null:a.authMode==="basic"?{mode:"basic",username:a.username.trim(),password:a.password}:{mode:"token",username:a.username.trim()||void 0,token:a.token}}function ts(a,i){const u=a.find(d=>d.name===i)??a.find(d=>d.name==="origin")??a[0];if(!u)return"generic";const h=u.pushUrl||u.fetchUrl;return ns(h)?"github":"generic"}function ns(a){const i=(a==null?void 0:a.trim().toLowerCase())??"";return i.startsWith("https://github.com/")||i.startsWith("http://github.com/")||i.startsWith("ssh://git@github.com/")||i.startsWith("git@github.com:")}function Dn(a,i,u){const h=Math.max(0,u.width),d=Math.max(0,u.height),C=Math.max(0,d-_*2),b=Math.max(0,h-_*2),j=Math.min(Math.max(i.width||Dt,0),b),y=Math.max(0,d-a.bottom-tt-_),N=Math.max(0,a.top-tt-_),M=y<i.height&&N>y,T=Pt(Math.max(M?N:y,Vi),0,C),f=Math.min(Math.max(i.height,0),T),r=M?a.top-tt-f:a.bottom+tt,m=Math.max(_,d-_-f),g=Math.max(_,h-_-j);return{top:Pt(r,_,m),left:Pt(a.right-j,_,g),maxHeight:Math.max(0,T),transformOrigin:`${M?"bottom":"top"} right`}}function Pt(a,i,u){return!Number.isFinite(a)||u<i?i:Math.min(Math.max(a,i),u)}function it({expanded:a}){return e.jsx("svg",{className:"git-chevron-icon",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",style:{transform:a?"rotate(0deg)":"rotate(-90deg)"},"aria-hidden":"true",children:e.jsx("polyline",{points:"6 9 12 15 18 9"})})}function Ft({staged:a}){return a?e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2","aria-hidden":"true",children:e.jsx("path",{d:"M5 12h14"})}):e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2","aria-hidden":"true",children:[e.jsx("path",{d:"M12 5v14"}),e.jsx("path",{d:"M5 12h14"})]})}function Ot(){return e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2","aria-hidden":"true",children:[e.jsx("path",{d:"M10 7L6 11l4 4",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M7 11h7c3.87 0 7 3.13 7 7 0 1.9-.76 3.63-2 4.89",strokeLinecap:"round",strokeLinejoin:"round"})]})}function is(){return e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2","aria-hidden":"true",children:e.jsx("path",{d:"M12 3l1.9 5.1L19 10l-5.1 1.9L12 17l-1.9-5.1L5 10l5.1-1.9L12 3z"})})}function _e(){return e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:[e.jsx("circle",{cx:"5",cy:"12",r:"1.8"}),e.jsx("circle",{cx:"12",cy:"12",r:"1.8"}),e.jsx("circle",{cx:"19",cy:"12",r:"1.8"})]})}function Wn(a){try{return new Intl.DateTimeFormat("zh-CN",{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}).format(new Date(a))}catch{return a}}export{gs as GitSidebar,Dn as resolveGitOperationsMenuPosition};
|