@jetcrab/pi-desk 1.1.32 → 1.1.33

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.
Files changed (32) hide show
  1. package/package.json +1 -1
  2. package/src/client/l2_biz/project-preview/l2-project-preview.tsx +2 -2
  3. package/src/client/l2_biz/project-preview/views/l2-project-history-view.tsx +2 -2
  4. package/src/client/l2_biz/terminal/l2-terminal-workspace.tsx +1 -0
  5. package/src/client/l2_biz/workbench/l2-work-session-columns.tsx +1 -0
  6. package/src/client/l2_biz/workbench/l2-workbench-sidebar-layout.tsx +1 -0
  7. package/temp/build/pi-desk/release/.next/BUILD_ID +1 -1
  8. package/temp/build/pi-desk/release/.next/build-manifest.json +2 -2
  9. package/temp/build/pi-desk/release/.next/prerender-manifest.json +3 -3
  10. package/temp/build/pi-desk/release/.next/required-server-files.js +2 -2
  11. package/temp/build/pi-desk/release/.next/required-server-files.json +2 -2
  12. package/temp/build/pi-desk/release/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
  13. package/temp/build/pi-desk/release/.next/server/app/_global-error.html +1 -1
  14. package/temp/build/pi-desk/release/.next/server/app/_global-error.rsc +1 -1
  15. package/temp/build/pi-desk/release/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  16. package/temp/build/pi-desk/release/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  17. package/temp/build/pi-desk/release/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  18. package/temp/build/pi-desk/release/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  19. package/temp/build/pi-desk/release/.next/server/app/api/health/route.js +1 -1
  20. package/temp/build/pi-desk/release/.next/server/app/login/page_client-reference-manifest.js +1 -1
  21. package/temp/build/pi-desk/release/.next/server/app/page.js +4 -4
  22. package/temp/build/pi-desk/release/.next/server/app/page_client-reference-manifest.js +1 -1
  23. package/temp/build/pi-desk/release/.next/server/app/project-preview/page_client-reference-manifest.js +1 -1
  24. package/temp/build/pi-desk/release/.next/server/chunks/27344.js +1 -1
  25. package/temp/build/pi-desk/release/.next/server/middleware-build-manifest.js +1 -1
  26. package/temp/build/pi-desk/release/.next/server/pages/500.html +1 -1
  27. package/temp/build/pi-desk/release/.next/server/server-reference-manifest.json +1 -1
  28. package/temp/build/pi-desk/release/.next/static/chunks/{65232-f5b71cec787a30ec.js → 65232-87ad5d745e5d22f0.js} +1 -1
  29. package/temp/build/pi-desk/release/.next/static/chunks/app/{page-4f02cd8374a5ea39.js → page-eb5c2229f59dda1a.js} +4 -4
  30. package/temp/build/pi-desk/release/.next/trace-build +1 -1
  31. /package/temp/build/pi-desk/release/.next/static/{YNnS2PkK7QVGmBEX0iXCM → IDVi-aOj0xwp4DoZljk5f}/_buildManifest.js +0 -0
  32. /package/temp/build/pi-desk/release/.next/static/{YNnS2PkK7QVGmBEX0iXCM → IDVi-aOj0xwp4DoZljk5f}/_ssgManifest.js +0 -0
@@ -12,4 +12,4 @@ window.addEventListener('keydown', function (event) {
12
12
  </script>`;function r(e){return`${e}
13
13
  ${i}`}},45273:(e,t,s)=>{"use strict";s.d(t,{Fj:()=>r});let i="/project-preview";function r(e){return e?`${i}?cwd=${encodeURIComponent(e)}`:i}},46487:(e,t,s)=>{"use strict";s.d(t,{n:()=>h});var i=s(7962),r=s(57445),a=s(73028),n=s(69266),o=s(10508),l=s(8001),c=s(35907),d=s.n(c);let u={cjk:r.h,code:a.a},h=(0,n.memo)(function({content:e,label:t,savedScrollTop:s,onScroll:r}){let a=(0,n.useRef)(null),c=(0,n.useRef)(s);return(0,n.useLayoutEffect)(()=>{a.current&&(a.current.scrollTop=c.current)},[]),(0,i.jsx)("div",{ref:a,"data-testid":"markdown-preview",role:"region","aria-label":t,tabIndex:0,className:"h-full min-h-0 overflow-auto overscroll-contain bg-background outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring",onScroll:e=>r(e.currentTarget.scrollTop),children:(0,i.jsx)(o.jH,{className:`${d().document} ${l.om}`,allowedTags:l.IV,components:l.e6,remarkPlugins:l.XC,mode:"static",parseIncompleteMarkdown:!1,isAnimating:!1,controls:!1,lineNumbers:!1,plugins:u,children:e})})})},56592:(e,t,s)=>{"use strict";s.d(t,{Q:()=>h,h:()=>g});var i=s(93540),r=s(73230),a=s(7237),n=s(33550),o=s(93320),l=s(97921),c=s(82075);let d={scope:"all",caseSensitive:!1,wholeWord:!1,regex:!1};function u(e){return{...e,status:e.query.trim()?"loading":"idle",fileMatches:[],contentMatches:[],truncated:!1,error:null}}function h(e){return JSON.stringify([e.repositoryRoot,e.path,e.comparison?.baseCommit??null,e.comparison?.targetCommit??null,e.comparison?.oldPath??null])}function p(e,t){return(0,r.B)({msg:i.C["zh-CN"][e],i18n:{key:`projectFiles:${e}`,...t?{params:t}:{}}})}function m(e){return e instanceof Error?e.message:p("projectReadFailed")}async function f(e,t){if(e.type!==t.type||e.size!==t.size)return!1;let[s,i]=await Promise.all([e.arrayBuffer(),t.arrayBuffer()]),r=new Uint8Array(i);return new Uint8Array(s).every((e,t)=>e===r[t])}class g{constructor(e,t,s){this.cwd=e,this.reader=t,this.options=s,this.state={tabs:[],activePath:null,directories:new Map,expandedPaths:new Set,treeScrollTop:0,search:u({query:"",...d}),searchOpen:!1,documents:new Map,diffs:[],activeDiff:null},this.listeners=new Set,this.directoryRequests=new Map,this.compactRequests=new Map,this.documentRequests=new Map,this.closeMissing=new Set,this.restoredTabs=new Set,this.restoredEditorStates=new Map,this.restoredFileViewModes=new Map,this.restoredPreviewScrollTops=new Map,this.searchRequest=null,this.navigation=null,this.diffRequests=new Map,this.revision=0,this.disposed=!1,this.subscribe=e=>(this.listeners.add(e),()=>this.listeners.delete(e)),this.getRevision=()=>this.revision}setSearchOpen(e){this.disposed||this.state.searchOpen===e||(this.cancelSearch(),this.state.searchOpen=e,this.state.search=u({...this.searchInput(),scope:e?"all":this.state.search.scope}),this.publish())}get pendingNavigation(){let e=this.state.activePath;return e&&!this.documentRequests.has(e)?this.navigation:null}consumeNavigation(e,t){this.navigation===e&&(this.navigation=null,t||this.options.onNotice?.(p("searchLineUnavailable")),this.publish())}get canReveal(){return!!this.options.reveal}getBrowsingDocumentSettings(){let e={},t={};for(let s of this.state.tabs){let i=this.state.documents.get(s),r=i?.status==="text"?i.editorState:this.restoredEditorStates.get(s);r&&JSON.stringify(r).length<32768&&(e[s]=r);let a=i?.status==="text"?i.viewMode:this.restoredFileViewModes.get(s);a&&(t[s]=a)}return{editorStates:e,fileViewModes:t}}restoreBrowsing(e){if(this.disposed)return;for(let t of(this.state.tabs=e.tabs.slice(0,this.options.maxTabs),this.state.tabs)){this.restoredTabs.add(t);let s=e.editorStates[t];s&&this.restoredEditorStates.set(t,s);let i=e.fileViewModes[t];i&&this.restoredFileViewModes.set(t,i)}for(let t of(this.state.activePath=e.activePath&&this.state.tabs.includes(e.activePath)?e.activePath:null,this.state.expandedPaths=new Set(e.expandedPaths),this.state.treeScrollTop=e.treeScrollTop,this.state.search=u({query:e.searchQuery,...d}),this.state.tabs))this.state.documents.set(t,{status:"unloaded"});for(let t of[...e.diffs??[],...e.activeDiff?[e.activeDiff]:[]])if(!this.state.diffs.some(e=>h(e)===h(t))){if(this.options.maxTabs&&this.state.tabs.length+this.state.diffs.length>=this.options.maxTabs)break;this.state.diffs.push({...t,status:"unloaded"})}for(let t of e.expandedPaths)this.ensureDirectory(t);this.publish();let t=e.activeDiff,s=t?this.state.diffs.find(e=>h(e)===h(t)):null;s?this.openDiff(s.repositoryRoot,s.path,s.comparison):this.state.activePath&&this.ensureDocument(this.state.activePath)}async revealFile(e,t="file"){if(!this.options.reveal)throw Error(p("revealUnavailable"));await this.options.reveal(e,t)}ensureRoot(){return this.ensureDirectory("")}ensureDirectory(e,t=!1){let s=this.state.directories.get(e);if(this.disposed||!t&&s?.status==="ready")return Promise.resolve();let i=this.directoryRequests.get(e);if(i)return i.promise;let r=new AbortController,a=Promise.resolve().then(async()=>{try{if(r.signal.aborted)return;let t=await this.reader.list(e,r.signal);if(this.directoryRequests.get(e)?.controller!==r)return;this.state.directories.set(e,{status:"ready",...t})}catch(t){if(this.directoryRequests.get(e)?.controller!==r)return;this.state.directories.set(e,{status:"error",error:m(t)})}this.directoryRequests.get(e)?.controller===r&&(this.directoryRequests.delete(e),this.publish())});return this.directoryRequests.set(e,{controller:r,promise:a}),s?.status!=="ready"&&(this.state.directories.set(e,{status:"loading"}),this.publish()),a}refreshDirectories(e){for(let t of new Set(e))this.ensureDirectory(t,!0)}setExpandedPaths(e,t=!0){let s=[...this.state.expandedPaths].filter(t=>!e.has(t));for(let t of(this.state.expandedPaths=new Set(e),this.compactRequests.keys()))s.some(e=>t===e||t.startsWith(`${e}/`))&&this.compactRequests.delete(t);if(this.publish(),t)for(let t of e)this.ensureDirectory(t,!0)}cancelDirectoryExpansion(e=""){for(let t of this.compactRequests.keys())(!e||t===e||t.startsWith(`${e}/`))&&this.compactRequests.delete(t)}compactDirectory(e,t){return(0,c.rk)(e,e=>{let t=this.onlyDirectory(e);return t&&this.state.directories.has(t)?t:null},t)}async expandDirectoryChain(e,t){let s={};this.compactRequests.set(e,s);let i=e,r=16;for(;!this.disposed&&this.compactRequests.get(e)===s&&this.state.expandedPaths.has(e);){if(this.state.directories.get(i)?.status!=="ready"){if(r--<=0)break;await this.ensureDirectory(i)}if(this.compactRequests.get(e)!==s||this.disposed)return;let a=this.onlyDirectory(i);if(!a||t.has(i)||t.has(a)||r<=0&&this.state.directories.get(a)?.status!=="ready")break;this.state.expandedPaths.add(a),i=a,this.publish()}this.compactRequests.get(e)===s&&this.compactRequests.delete(e)}onlyDirectory(e){let t=this.state.directories.get(e);if(t?.status!=="ready"||t.truncated||1!==t.entries.length)return null;let s=t.entries[0];return"directory"===s.type?(0,c._J)(e,s.name):null}setTreeScrollTop(e){this.state.treeScrollTop=e}refreshTree(){for(let e of(this.compactRequests.clear(),this.directoryRequests.values()))e.controller.abort();this.directoryRequests.clear(),this.state.directories.clear(),this.cancelSearch(),this.state.search=u(this.searchInput()),this.publish(),this.ensureRoot().then(()=>{if(!this.disposed){for(let e of this.state.expandedPaths)this.ensureDirectory(e);this.state.searchOpen&&this.state.search.query.trim()&&(this.cancelSearch(),this.state.search={...this.state.search,status:"loading"},this.search(this.state.search.query))}})}setSearchQuery(e){this.disposed||this.state.search.query===e||(this.cancelSearch(),this.state.search=u({...this.searchInput(),query:e}),this.publish())}setSearchOptions(e){if(this.disposed)return;let t=this.searchInput(),s={...t,...e};(s.scope!==t.scope||s.caseSensitive!==t.caseSensitive||s.wholeWord!==t.wholeWord||s.regex!==t.regex)&&(this.cancelSearch(),this.state.search=u(s),this.publish(),this.state.searchOpen&&this.search(s.query))}searchInput(){let{query:e,scope:t,caseSensitive:s,wholeWord:i,regex:r}=this.state.search;return{query:e,scope:t,caseSensitive:s,wholeWord:i,regex:r}}async search(e){if(this.disposed||!e.trim()||this.state.search.query!==e||"ready"===this.state.search.status||this.searchRequest)return;let t=new AbortController;this.searchRequest=t;let s=this.searchInput();this.state.search=u(s),this.publish();try{let e=await this.reader.search(s,t.signal);if(this.searchRequest!==t)return;this.state.search={...s,status:"ready",...e,error:null}}catch(e){if(this.searchRequest!==t)return;this.state.search={...u(s),status:"error",error:m(e)}}this.searchRequest===t&&(this.searchRequest=null,this.publish())}openFile(e,t){var s;let i,r;if(this.disposed)return;let a=(s=this.cwd,i=e.replaceAll("\\","/"),r=`${s.replaceAll("\\","/").replace(/\/+$/,"")}/`,(/^[a-z]:\//i.test(r)||r.startsWith("//")?i.toLowerCase().startsWith(r.toLowerCase()):i.startsWith(r))?i.slice(r.length):i),n=/^[a-z]:[\\/]/i.test(this.cwd)||this.cwd.startsWith("\\\\")?this.state.tabs.find(e=>e.toLowerCase()===a.toLowerCase())??a:a;if(!this.state.tabs.includes(n)){if(!this.canOpenTab())return;this.state.tabs.push(n)}this.state.activeDiff=null,this.state.documents.has(n)||this.state.documents.set(n,{status:"unloaded"}),this.state.activePath=n,this.navigation=void 0===t?null:{line:t};let o=this.state.documents.get(n);void 0!==t&&o?.status==="text"&&(o.viewMode="source"),this.ensureDocument(n,void 0!==t),this.publish()}closeTabs(e,t){if(this.disposed)return;let s=this.state,i=[...s.tabs,...s.diffs],r=null===e?s.activeDiff:"string"==typeof e?e:s.diffs.find(t=>h(t)===h(e)),a=null==r?-1:i.indexOf(r);if(a<0&&"all"!==t)return;let n=new Set(i.filter((e,s)=>"all"===t||("current"===t?e===r:"others"===t?e!==r:"left"===t?s<a:s>a)));if(!n.size)return;let o=s.activeDiff??s.activePath;for(let e of n){if("string"!=typeof e){this.invalidateDiff(e);continue}this.documentRequests.get(e)?.abort(),this.documentRequests.delete(e),this.releaseDocument(s.documents.get(e)),s.documents.delete(e),this.restoredEditorStates.delete(e),this.restoredFileViewModes.delete(e),this.restoredPreviewScrollTops.delete(e),this.closeMissing.delete(e),this.restoredTabs.delete(e)}if(s.tabs=s.tabs.filter(e=>!n.has(e)),s.diffs=s.diffs.filter(e=>!n.has(e)),s.activePath&&n.has(s.activePath)){let e=i.filter(e=>"string"==typeof e),t=e.indexOf(s.activePath);s.activePath=e.slice(t+1).find(e=>!n.has(e))??e.slice(0,t).reverse().find(e=>!n.has(e))??null}if(null!==o&&n.has(o)){this.navigation=null;let e=i.indexOf(o),t=i.slice(e+1).find(e=>!n.has(e))??i.slice(0,e).reverse().find(e=>!n.has(e));s.activeDiff="object"==typeof t?t:null,"string"==typeof t&&(s.activePath=t)}this.publish(),s.activeDiff?this.ensureDiff(s.activeDiff):s.activePath&&o!==s.activePath&&this.ensureDocument(s.activePath)}reloadFile(e){if(this.state.tabs.includes(e)){if(this.state.activePath===e&&this.navigation)return void this.ensureDocument(e,!0);this.invalidateDocument(e),this.publish(),this.ensureDocument(e)}}async ensureDocument(e,t=!1){if(this.disposed||!this.state.tabs.includes(e)||this.documentRequests.has(e))return;let s=this.state.documents.get(e);if(!t&&s&&["loading","text","image"].includes(s.status))return;let i=new AbortController;this.documentRequests.set(e,i),s?.status!=="text"&&s?.status!=="image"&&(this.state.documents.set(e,{status:"loading"}),this.publish());try{let t=await this.reader.get(e,this.options.imagePreviewMode(),i.signal);if(this.documentRequests.get(e)!==i)return;let r="image"===t.kind?(0,a.E)(t):null,n=s?.status==="text"&&"text"===t.kind&&s.content===t.content&&s.size===t.size||s?.status==="image"&&null!==r&&await f(s.blob,r);if(this.documentRequests.get(e)!==i)return;this.documentRequests.delete(e),this.closeMissing.delete(e),this.restoredTabs.delete(e),n||this.state.documents.set(e,"text"===t.kind?{status:"text",content:t.content,size:t.size,editorState:s?.status==="text"?s.editorState:this.restoredEditorStates.get(e)??null,viewMode:this.state.activePath===e&&this.navigation?"source":s?.status==="text"?s.viewMode:this.restoredFileViewModes.get(e)??("markdown"===(0,l.g)(e)||this.options.htmlPreview&&"html"===(0,l.g)(e)?"preview":"source"),previewScrollTop:s?.status==="text"?s.previewScrollTop:this.restoredPreviewScrollTops.get(e)??0}:{status:"image",mimeType:t.mimeType,size:t.size,objectUrl:URL.createObjectURL(r),blob:r}),this.state.activePath===e&&"text"!==t.kind&&(this.navigation=null),n||this.releaseDocument(s)}catch(a){if(this.documentRequests.get(e)!==i)return;this.documentRequests.delete(e);let t=this.restoredTabs.delete(e),r=this.closeMissing.delete(e);if((t||r)&&a instanceof o.aw&&404===a.status&&"errors:fileMissing"===a.errorKey){this.closeTabs(e,"current"),r&&this.options.onNotice?.(p("branchFileClosed",{path:e}));return}console.warn("[Pi Desk][ProjectFile] 读取文件失败",{cwd:this.cwd,path:e,error:m(a)}),this.state.documents.set(e,{status:"error",error:m(a)}),this.releaseDocument(s),this.state.activePath===e&&(this.navigation=null)}this.publish()}async compareFile(e,t,s){let i=this.state.documents.get(e);if(this.disposed||s.aborted||i?.status!=="text")return;if(!t){i.comparison&&(delete i.comparison,this.publish());return}let r={status:"loading"};i.comparison=r,this.publish();let a=()=>!this.disposed&&!s.aborted&&this.state.documents.get(e)===i&&i.comparison===r;try{let e=await this.reader.diff(t.repositoryRoot,t.path,s);if(!a())return;"text"===e.kind?(i.content=e.modified.content,i.size=new TextEncoder().encode(e.modified.content).length,i.comparison={status:"ready",repositoryRoot:t.repositoryRoot,path:t.path,original:e.original}):i.comparison={status:"unavailable"}}catch(t){if(!a())return;console.warn("[Pi Desk][ProjectFile] 读取行变更失败",{cwd:this.cwd,path:e,error:m(t)}),i.comparison={status:"error",error:m(t)}}this.publish()}openFileDiff(e,t){let s=this.state.documents.get(e);if(this.disposed||s?.status!=="text"||s.comparison?.status!=="ready")return;let i=s.comparison,r=this.state.diffs.find(e=>!e.comparison&&e.repositoryRoot===i.repositoryRoot&&e.path===i.path);if(r)this.invalidateDiff(r),Object.assign(r,{status:"text",original:i.original,modified:{path:i.path,content:s.content}});else{if(!this.canOpenTab())return;r={status:"text",repositoryRoot:i.repositoryRoot,path:i.path,original:i.original,modified:{path:i.path,content:s.content}},this.state.diffs.push(r)}void 0!==t&&(r.initialLine=t),this.openDiff(r.repositoryRoot,r.path)}openDiff(e,t,s,i){if(this.disposed)return;let r={repositoryRoot:e,path:t,comparison:s},a=this.state.diffs.find(e=>h(e)===h(r));if(a)void 0!==i&&(a.label=i);else{if(!this.canOpenTab())return;a={...r,status:"unloaded",label:i},this.state.diffs.push(a)}this.navigation=null,this.state.activeDiff=a,this.publish(),this.ensureDiff(a)}closeDiff(){this.closeTabs(null,"current")}reloadDiff(){let e=this.state.activeDiff;e&&!this.disposed&&(this.invalidateDiff(e),this.publish(),this.ensureDiff(e))}refreshDiff(){let e=this.state.activeDiff;e&&!e.comparison&&this.ensureDiff(e,!0)}saveDiffState(e,t){!this.disposed&&this.state.diffs.includes(e)&&t&&(e.editorState=t,delete e.initialLine)}setDiffViewMode(e){this.state.activeDiff&&(0,n.ZQ)({diffViewMode:e})}setDiffWrapLines(e){this.state.activeDiff&&(0,n.ZQ)({wrapLines:e})}setDiffCollapseUnchanged(e){this.state.activeDiff&&(0,n.ZQ)({collapseUnchanged:e})}handleGitBranchChanged(e){for(let t of(this.refreshTree(),this.state.tabs))(!e||t===e||t.startsWith(`${e}/`))&&(this.invalidateDocument(t),this.closeMissing.add(t));for(let t of this.state.diffs)t.repositoryRoot!==e||t.comparison||this.invalidateDiff(t);this.publish(),this.state.activeDiff?this.ensureDiff(this.state.activeDiff):this.state.activePath&&this.ensureDocument(this.state.activePath)}saveEditorState(e,t){let s=this.state.documents.get(e);s?.status==="text"&&(s.editorState=t)}savePreviewScrollTop(e,t){let s=this.state.documents.get(e);s?.status==="text"&&(s.previewScrollTop=t)}setWrapLines(e,t){this.state.documents.get(e)?.status==="text"&&(0,n.ZQ)({wrapLines:t})}setTextViewMode(e,t){let s=this.state.documents.get(e);s?.status==="text"&&s.viewMode!==t&&(s.viewMode=t,this.publish())}dispose(){for(let e of(this.disposed=!0,this.compactRequests.clear(),this.directoryRequests.values()))e.controller.abort();for(let e of(this.directoryRequests.clear(),this.documentRequests.values()))e.abort();for(let e of(this.documentRequests.clear(),this.cancelSearch(),this.state.diffs))this.invalidateDiff(e);for(let e of(this.state.diffs=[],this.state.activeDiff=null,this.state.documents.values()))this.releaseDocument(e);this.state.documents.clear(),this.restoredPreviewScrollTops.clear(),this.listeners.clear()}async ensureDiff(e,t=!1){let s=h(e);if(this.disposed||!t&&"unloaded"!==e.status||this.diffRequests.has(s))return;let i=new AbortController;this.diffRequests.set(s,i),"text"!==e.status&&"metadata"!==e.status&&(Object.assign(e,{status:"loading"}),this.publish());try{let t=await this.reader.diff(e.repositoryRoot,e.path,i.signal,e.comparison);if(this.diffRequests.get(s)!==i)return;Object.assign(e,"text"===t.kind?{status:"text",original:t.original,modified:t.modified}:"metadata"===t.kind?{status:"metadata",originalMetadata:t.original,modifiedMetadata:t.modified}:{status:t.kind,error:null})}catch(t){if(this.diffRequests.get(s)!==i)return;console.warn("[Pi Desk][ProjectFile] 读取 Diff 失败",{cwd:this.cwd,repositoryRoot:e.repositoryRoot,path:e.path,error:m(t)}),Object.assign(e,{status:"error",error:m(t)})}this.diffRequests.get(s)===i&&(this.diffRequests.delete(s),this.publish())}invalidateDiff(e){let t=h(e);for(let s of(this.diffRequests.get(t)?.abort(),this.diffRequests.delete(t),Object.assign(e,{status:"unloaded"}),["original","modified","originalMetadata","modifiedMetadata","error"]))Reflect.deleteProperty(e,s)}canOpenTab(){let e=this.options.maxTabs;return!e||this.state.tabs.length+this.state.diffs.length<e||(this.options.onNotice?.(p("maxOpenFiles",{count:e})),!1)}cancelSearch(){this.searchRequest?.abort(),this.searchRequest=null}invalidateDocument(e){this.state.activePath===e&&(this.navigation=null),this.documentRequests.get(e)?.abort(),this.documentRequests.delete(e);let t=this.state.documents.get(e);t?.status==="text"&&(t.editorState&&this.restoredEditorStates.set(e,t.editorState),this.restoredFileViewModes.set(e,t.viewMode),this.restoredPreviewScrollTops.set(e,t.previewScrollTop)),this.releaseDocument(t),this.state.documents.set(e,{status:"unloaded"})}releaseDocument(e){e?.status==="image"&&URL.revokeObjectURL(e.objectUrl)}publish(){if(!this.disposed)for(let e of(this.revision+=1,this.listeners))e()}}},57252:(e,t,s)=>{"use strict";s.d(t,{q:()=>et});var i=s(7962),r=s(78121),a=s(31761),n=s(24925),o=s(48155),l=s(63013),c=s(55079),d=s(49667),u=s(90680),h=s(24863),p=s(49762),m=s(60278),f=s(72282),g=s(86963),x=s(9736),v=s(35842),b=s(73068),y=s(51821),w=s(99084),j=s(69266),k=s(28460),N=s(64334);function C(e){let t=window.matchMedia("(pointer: fine)");return t.addEventListener("change",e),()=>t.removeEventListener("change",e)}function S(){return window.matchMedia("(pointer: fine)").matches}function R(){return!1}var z=s(14044),D=s(57731),A=s(35995),M=s(15265),P=s(5816),$=s(74675),T=s(73429),O=s(60471),L=s(49426);function E({items:e,label:t,scrollTop:s,onScroll:r,render:a,role:n="listbox",onKeyDown:o,rowHeight:l=36,onNearEnd:c,footer:d}){let u=(0,j.useRef)(null),[h,p]=(0,j.useState)({top:s,height:300});(0,j.useLayoutEffect)(()=>{let e=u.current;if(!e)return;e.scrollTop=s;let t=()=>p({top:e.scrollTop,height:e.clientHeight});t();let i=new ResizeObserver(t);return i.observe(e),()=>i.disconnect()},[]),(0,j.useLayoutEffect)(()=>{let e=u.current;e&&(e.scrollTop=s,p(t=>t.top===e.scrollTop?t:{...t,top:e.scrollTop}))},[e,s,l]),(0,j.useEffect)(()=>{e.length&&h.height>0&&e.length*l-h.top-h.height<=200&&c?.()},[e.length,l,h.top,h.height,c]);let m=Math.max(0,Math.floor(h.top/l)-8),f=Math.min(e.length,Math.ceil((h.top+h.height)/l)+8);return(0,i.jsxs)("div",{ref:u,role:n,tabIndex:"tree"===n?0:void 0,onKeyDown:o,"aria-label":t,className:"min-h-0 flex-1 overflow-auto overscroll-contain",onScroll:e=>{let t=e.currentTarget.scrollTop;p(e=>({...e,top:t})),r(t)},children:[(0,i.jsx)("div",{style:{height:e.length*l,position:"relative"},children:(0,i.jsx)("div",{style:{position:"absolute",top:m*l,left:0,right:0},children:e.slice(m,f).map((e,t)=>a(e,m+t))})}),d]})}var I=s(36670),q=s(50479),F=s(66584),_=s(60682),W=s(82075);let B={added:"A",modified:"M",deleted:"D",renamed:"R","type-changed":"T"};function H({cwd:e,repositoryRoot:t,rows:s,changes:a,selectedPath:n,scrollTop:o,rowHeight:l,onScroll:c,onSelect:d,onToggle:u,onOpen:h,onReveal:p}){let{t:f}=(0,r.Bd)("projectHistory"),x=(0,j.useRef)(null),v=(e,t)=>{e&&x.current===t&&(x.current=null,e.focus({preventScroll:!0}))},b=new Map(a.map(e=>[e.path,e]));return(0,i.jsx)(E,{role:"tree",label:f("changeFiles"),items:s,scrollTop:o,rowHeight:l,onScroll:c,onKeyDown:e=>{if(e.defaultPrevented||!e.currentTarget.contains(e.target))return;let t=e.target instanceof Element?e.target.closest("[data-tree-key]"):null;if(e.target instanceof Element&&e.target.closest("button"))return;let i=t?s.findIndex(e=>e.key===t.dataset.treeKey):-1,r=s[i],a=i;if("ArrowDown"===e.key)a=Math.min(s.length-1,i+1);else if("ArrowUp"===e.key)a=Math.max(0,i-1);else if("Home"===e.key)a=0;else if("End"===e.key)a=s.length-1;else if("ArrowRight"===e.key&&r?.directory)r.expanded?a=Math.min(s.length-1,i+1):u(r.directory.path);else if("ArrowLeft"===e.key&&r){if(r.expanded&&r.directory)u(r.directory.path);else for(let e=i-1;e>=0;e-=1)if(s[e].depth<r.depth){a=e;break}}else{if("Enter"!==e.key&&" "!==e.key||!r)return;r.directory?u(r.directory.path):"Enter"===e.key?h(r.path):d(r.path)}e.preventDefault();let n=s[a];if(!n)return;let o=e.currentTarget;a*l<o.scrollTop?o.scrollTop=a*l:(a+1)*l>o.scrollTop+o.clientHeight&&(o.scrollTop=(a+1)*l-o.clientHeight),x.current=n.key,v([...o.querySelectorAll("[data-tree-key]")].find(e=>e.dataset.treeKey===n.key)??null,n.key)},render:s=>{let r=b.get(s.path),a=(0,W._J)(t,s.path),o=s.directory;return(0,i.jsx)(_.J,{cwd:e,path:a,type:s.type,historical:!0,expanded:s.expanded,onToggle:o?()=>u(o.path):void 0,onOpen:"file"===s.type?()=>h(s.path):void 0,openLabel:f("viewDiff"),oldPath:"file"===s.type&&r?.oldPath?(0,W._J)(t,r.oldPath):void 0,onReveal:p,trigger:(0,i.jsxs)("div",{ref:e=>v(e,s.key),role:"treeitem",tabIndex:0,"aria-level":s.depth+1,"aria-expanded":s.expanded,"aria-selected":"file"===s.type&&n===s.path,"data-tree-key":s.key,className:(0,L.cn)("flex min-w-0 cursor-pointer items-center gap-1 pr-1 text-sm outline-none hover:bg-accent focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring","file"===s.type&&n===s.path&&"bg-accent"),style:{height:l,paddingLeft:4+s.depth*(24===l?12:24)},title:r?.oldPath&&"file"===s.type?`${(0,W._J)(t,r.oldPath)} → ${a}`:a,onClick:e=>{o?e.detail<2&&u(o.path):d(s.path)},onDoubleClick:()=>{"file"===s.type&&h(s.path)},children:[o?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(I.A,{className:(0,L.cn)("size-4 shrink-0 text-muted-foreground",s.expanded&&"rotate-90")}),s.expanded?(0,i.jsx)(q.A,{className:"size-4 shrink-0 text-muted-foreground"}):(0,i.jsx)(F.A,{className:"size-4 shrink-0 text-muted-foreground"})]}):(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("span",{className:"w-4 shrink-0"}),(0,i.jsx)("span",{className:(0,L.cn)("w-4 shrink-0 font-mono text-xs",r?.status==="added"?"text-emerald-600 dark:text-emerald-400":r?.status==="deleted"?"text-red-600 dark:text-red-400":"text-blue-600 dark:text-blue-400"),"aria-label":f("gitStatus",{status:r?B[r.status]:""}),children:r?B[r.status]:""})]}),(0,i.jsxs)("span",{className:"min-w-0 flex-1 truncate",children:[s.label,"directory"===s.type&&b.has(s.path)?"/":""]}),"file"===s.type?(0,i.jsx)(g.$,{size:"icon-sm",variant:"ghost",className:24===l?"size-6":void 0,"aria-label":f("viewDiffPath",{path:s.path}),onDoubleClick:e=>e.stopPropagation(),onClick:e=>{e.stopPropagation(),h(s.path)},children:(0,i.jsx)(m.A,{className:"size-4"})}):null]})},s.key)}})}var Y=s(37265),V=s(46783),K=s(86758),U=s(90458),J=s(35989),G=s(90434);function Q(e){let t=[],s=e;for(;s.includes("/")&&"refs"!==(s=s.slice(0,s.lastIndexOf("/")));)t.push(s);return t}function X({branches:e,value:t,onChange:s,ariaLabel:n,placeholder:o,className:l}){let{t:c}=(0,r.Bd)("projectHistory"),{t:d}=(0,r.Bd)("common"),u=(0,j.useId)(),h=(0,j.useRef)(null),p=(0,j.useRef)(null),m=(0,j.useRef)(new Map),[f,x]=(0,j.useState)(!1),[v,b]=(0,j.useState)(""),[y,w]=(0,j.useState)(t),[k,N]=(0,j.useState)(()=>new Set(["refs/heads","refs/remotes",...Q(t)])),C=v.trim().toLocaleLowerCase(),S="HEAD"===t?c("currentHead"):t.replace(/^refs\/(heads|remotes)\//,""),R=(0,j.useMemo)(()=>{let t=[],s=[{key:"refs/heads",label:c("localBranch"),names:e?.local??[]},{key:"refs/remotes",label:c("remoteBranch"),names:e?.remote??[]}].map(e=>({...e,nodes:(0,J.oY)(e.names.filter(e=>e.toLocaleLowerCase().includes(C)))})).filter(e=>e.nodes.length>0),i=`HEAD ${c("currentHead")}`.toLocaleLowerCase().includes(C),r=s.length+Number(i);i&&t.push({key:"HEAD",label:c("currentHead"),fullName:c("currentHead"),parentKey:null,level:1,position:1,siblingCount:r,expandable:!1});let a=(e,s,i,r)=>{e.forEach((n,o)=>{let l=`${s}/${n.path}`;t.push({key:l,label:n.name,fullName:n.path,parentKey:i,level:r,position:o+1,siblingCount:e.length,expandable:n.children.length>0}),k.has(l)&&a(n.children,s,l,r+1)})};return s.forEach((e,s)=>{t.push({key:e.key,label:e.label,fullName:e.label,parentKey:null,level:1,position:s+Number(i)+1,siblingCount:r,expandable:!0}),k.has(e.key)&&a(e.nodes,e.key,e.key,2)}),t},[e,k,C,c]),z=R.find(e=>e.key===y)??R.find(e=>e.key===t)??R.find(e=>!e.expandable)??R[0],D=e=>{if(!e)return;w(e.key);let t=m.current.get(e.key);t?.focus({preventScroll:!0}),t?.scrollIntoView({block:"nearest"})},A=e=>{N(t=>{let s=new Set(t);return s.has(e.key)?s.delete(e.key):s.add(e.key),s})};return(0,i.jsxs)(G.AM,{open:f,onOpenChange:e=>{e&&(b(""),w(t),N(e=>new Set([...e,...Q(t)]))),x(e)},onOpenChangeComplete:e=>{e&&document.activeElement===h.current&&m.current.get(t)?.scrollIntoView({block:"nearest"})},children:[(0,i.jsx)(G.Wv,{render:(0,i.jsxs)(g.$,{ref:p,type:"button",variant:"outline",role:"combobox","aria-haspopup":"dialog","aria-label":n,"aria-expanded":f,title:S||o,className:(0,L.cn)("w-full min-w-0 justify-between border-input px-2.5 font-normal focus-visible:-outline-offset-2",l),children:[(0,i.jsxs)("span",{className:(0,L.cn)("flex min-w-0 flex-1 items-center gap-2",!t&&"text-muted-foreground"),children:["HEAD"===t?(0,i.jsx)(Y.A,{"aria-hidden":"true",className:"size-4 shrink-0 text-muted-foreground"}):(0,i.jsx)(a.A,{"aria-hidden":"true",className:"size-4 shrink-0 text-muted-foreground"}),(0,i.jsx)("span",{className:"min-w-0 truncate",children:S||o||d("selectPlaceholder")})]}),(0,i.jsx)(V.A,{className:"text-muted-foreground"})]})}),(0,i.jsxs)(G.hl,{align:"start","aria-label":n,initialFocus:h,finalFocus:p,positionerClassName:"z-[120]",className:"max-h-[min(30rem,var(--available-height))] w-[max(26rem,calc(var(--anchor-width)+8rem))] max-w-[min(calc(100vw-2rem),var(--available-width))] gap-0 overflow-hidden p-0",children:[(0,i.jsx)("div",{className:"shrink-0 border-b p-2",children:(0,i.jsx)(T.p,{ref:h,type:"search","aria-label":d("searchPlaceholder"),"aria-controls":u,placeholder:d("searchPlaceholder"),value:v,onChange:t=>(t=>{b(t),w("");let s=t.trim().toLocaleLowerCase();if(!s)return;let i=[...(e?.local??[]).filter(e=>e.toLocaleLowerCase().includes(s)).map(e=>`refs/heads/${e}`),...(e?.remote??[]).filter(e=>e.toLocaleLowerCase().includes(s)).map(e=>`refs/remotes/${e}`)];N(e=>new Set([...e,...i.flatMap(Q)]))})(t.target.value),onKeyDown:e=>{e.nativeEvent.isComposing||e.altKey||e.ctrlKey||e.metaKey||("ArrowDown"===e.key||"ArrowUp"===e.key)&&(e.preventDefault(),e.stopPropagation(),D("ArrowDown"===e.key?z:R.at(-1)))}})}),(0,i.jsx)("div",{id:u,role:"tree","aria-label":n,className:"min-h-0 overflow-y-auto overscroll-contain p-1",children:R.map(e=>{let r=!e.expandable&&e.key===t,n=e.expandable?k.has(e.key):void 0,o=e.expandable?1===e.level?null:n?q.A:F.A:"HEAD"===e.key?Y.A:a.A;return(0,i.jsxs)("button",{ref:t=>{t?m.current.set(e.key,t):m.current.delete(e.key)},type:"button",role:"treeitem","aria-label":e.fullName,"aria-level":e.level,"aria-posinset":e.position,"aria-setsize":e.siblingCount,"aria-selected":e.expandable?void 0:r,"aria-expanded":n,tabIndex:z?.key===e.key?0:-1,title:e.fullName,className:(0,L.cn)("flex min-h-8 w-full items-center gap-1.5 rounded-md py-1 pr-2 text-left text-sm outline-none transition-colors duration-150 hover:bg-accent focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring [@media(pointer:coarse)]:min-h-10",r&&"bg-accent text-accent-foreground",1===e.level&&e.expandable&&"font-medium text-muted-foreground"),style:{paddingLeft:8+12*Math.min(e.level-1,8)},onFocus:()=>w(e.key),onKeyDown:t=>((e,t)=>{if(e.nativeEvent.isComposing||e.altKey||e.ctrlKey||e.metaKey)return;let s=R.indexOf(t);switch(e.key){case"ArrowDown":D(R[Math.min(s+1,R.length-1)]);break;case"ArrowUp":D(R[Math.max(s-1,0)]);break;case"Home":D(R[0]);break;case"End":D(R.at(-1));break;case"ArrowRight":t.expandable&&(k.has(t.key)?D(R[s+1]):A(t));break;case"ArrowLeft":t.expandable&&k.has(t.key)?A(t):D(R.find(e=>e.key===t.parentKey));break;default:return}e.preventDefault(),e.stopPropagation()})(t,e),onClick:()=>{w(e.key),e.expandable?A(e):(s(e.key),x(!1))},children:[e.expandable?n?(0,i.jsx)(K.A,{"aria-hidden":"true",className:"size-3.5 shrink-0"}):(0,i.jsx)(I.A,{"aria-hidden":"true",className:"size-3.5 shrink-0"}):(0,i.jsx)("span",{"aria-hidden":"true",className:"size-3.5 shrink-0"}),o?(0,i.jsx)(o,{"aria-hidden":"true",className:"size-4 shrink-0 text-muted-foreground"}):null,(0,i.jsx)("span",{className:"min-w-0 flex-1 break-all",children:e.label}),r?(0,i.jsx)(U.A,{"aria-hidden":"true",className:"size-3.5 shrink-0"}):null]},e.key)})}),R.length?null:(0,i.jsx)("p",{role:"status",className:"px-3 py-6 text-center text-sm text-muted-foreground",children:d("noMatches")}),z&&z.fullName!==z.label?(0,i.jsx)("div",{className:"max-h-24 shrink-0 overflow-y-auto border-t px-3 py-2 text-xs break-all text-muted-foreground",children:z.fullName}):null]})]})}function Z(e){let{state:t,repositories:s,projectName:a,narrow:n,scroll:o}=e,{t:l}=(0,r.Bd)("projectHistory"),{locale:c,timeZone:d}=(0,P.i)(),h=(0,j.useMemo)(()=>new Intl.DateTimeFormat("en"===c?"en-US":"zh-CN",{timeZone:d,month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",hourCycle:"h23"}),[c,d]),p=(0,j.useMemo)(()=>new Intl.DateTimeFormat("en"===c?"en-US":"zh-CN",{timeZone:d,timeZoneName:"shortOffset",year:"numeric",month:"long",day:"numeric",hour:"2-digit",minute:"2-digit",hourCycle:"h23"}),[c,d]),m=(0,j.useId)(),{mobilePane:x,onMobilePane:v}=e,b=t.changes.data,y=`${t.repositoryRoot}:${b?.comparison.original}:${b?.comparison.target}`,w=t.selectedChangePath,k=t.branches.data?.upstream,N=b?.commit,C=(s,r=e.onRefresh)=>s?(0,i.jsxs)("div",{role:"alert",className:"flex flex-wrap items-center gap-2 p-3 text-sm text-destructive",children:[(0,i.jsx)("span",{className:"min-w-0 flex-1 break-words",children:s}),(0,i.jsx)(g.$,{size:"sm",variant:"outline",onClick:r,children:l("retry")}),"compare"===t.mode&&"merge-base"===t.strategy?(0,i.jsx)(g.$,{size:"sm",variant:"outline",onClick:()=>e.onStrategy("direct"),children:l("compareDirect")}):null]}):null,S=(0,i.jsx)("div",{className:"flex size-full min-h-0 min-w-0 flex-col",children:(0,i.jsx)(E,{items:t.log.data?.items??[],label:l("commitList"),scrollTop:o.log,onScroll:t=>e.onScroll("log",t),onNearEnd:"ready"===t.log.status&&t.log.data?.hasMore&&t.log.data.items.length<2e3?e.onMoreLog:void 0,footer:(0,i.jsxs)(i.Fragment,{children:[C(t.log.error,t.log.data?e.onMoreLog:e.onRefresh),"loading"===t.log.status?(0,i.jsxs)("div",{role:"status",className:"flex items-center gap-2 px-3 py-2 text-xs text-muted-foreground",children:[(0,i.jsx)(z.A,{className:"size-4 animate-spin"}),l("loadingCommits")]}):null,"ready"!==t.log.status||t.log.data?.items.length?null:(0,i.jsx)("p",{className:"px-3 py-4 text-sm text-muted-foreground",children:t.query||t.author?l("noMatchingCommits"):l("noCommits")}),t.log.data?.truncated?(0,i.jsx)("p",{className:"px-3 py-2 text-xs text-muted-foreground",children:l("scanLimit")}):(t.log.data?.items.length??0)>=2e3?(0,i.jsx)("p",{className:"px-3 py-2 text-xs text-muted-foreground",children:l("loadedLimit")}):"ready"===t.log.status&&t.log.data?.items.length&&!t.log.data.hasMore?(0,i.jsx)("p",{className:"px-3 py-2 text-xs text-muted-foreground",children:l("noMoreCommits")}):null]}),render:s=>(0,i.jsxs)("button",{type:"button",role:"option","aria-selected":t.selectedCommit===s.oid,className:(0,L.cn)("flex h-9 w-full items-center gap-3 border-b border-border/40 px-3 text-left text-sm outline-none hover:bg-accent focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring",t.selectedCommit===s.oid&&"bg-accent"),onClick:()=>{var t;return t=s.oid,void(e.onCommit(t),n&&v("files"))},title:`${s.subject}
14
14
  ${s.oid}
15
- ${s.author} \xb7 ${p.format(s.timestampMs)}`,children:[(0,i.jsxs)("span",{className:"min-w-0 flex-1 truncate",children:[s.subject||l("noCommitMessage"),s.refs.length?(0,i.jsx)("span",{className:"ml-2 text-xs text-muted-foreground",children:s.refs.join(" \xb7 ")}):null]}),(0,i.jsx)("span",{className:"shrink-0 font-mono text-xs text-muted-foreground",children:s.oid.slice(0,7)}),n?null:(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("span",{className:"w-20 truncate text-xs text-muted-foreground",children:s.author}),(0,i.jsx)("time",{className:"w-28 shrink-0 text-right text-xs text-muted-foreground",children:h.format(s.timestampMs)})]})]},s.oid)},`${t.repositoryRoot}:${t.mode}:${t.tip}:${t.base}:${t.target}:${t.query}:${t.author}`)}),R=(0,i.jsxs)("div",{className:"flex size-full min-h-0 min-w-0 flex-col",children:[(0,i.jsxs)("div",{className:"flex min-h-9 shrink-0 flex-wrap items-center gap-2 border-b px-3 py-1",children:[n?(0,i.jsx)(g.$,{variant:"ghost",size:"icon-sm","aria-label":l("backCommits"),onClick:()=>v("log"),children:(0,i.jsx)(D.A,{className:"size-4"})}):null,(0,i.jsx)("span",{className:"text-sm font-medium",children:t.selectedCommit?l("commitChanges"):l("cumulativeChanges")}),b?(0,i.jsx)("span",{className:"text-xs text-muted-foreground",children:l("loadedFiles",{count:b.items.length})}):null,"compare"===t.mode&&t.selectedCommit?(0,i.jsx)(g.$,{variant:"ghost",size:"sm",onClick:e.onAggregate,children:l("backCumulative")}):null]}),C(t.changes.error),"loading"===t.changes.status?(0,i.jsxs)("div",{className:"flex items-center gap-2 p-3 text-xs text-muted-foreground",children:[(0,i.jsx)(z.A,{className:"size-4 animate-spin"}),l("loadingChanges")]}):null,(0,i.jsxs)(f.HK,{orientation:"vertical",defaultLayout:{"project-changes":e.panelSizes.changes,"project-detail":100-e.panelSizes.changes},onLayoutChanged:(t,s)=>{s.isUserInteraction&&void 0!==t["project-changes"]&&e.onPanelSize("changes",t["project-changes"])},children:[(0,i.jsx)(f.wV,{id:"project-changes",defaultSize:`${e.panelSizes.changes}%`,minSize:"80px",children:(0,i.jsxs)("div",{className:"flex size-full min-h-0 flex-col",children:[(0,i.jsx)(H,{cwd:e.cwd,repositoryRoot:t.repositoryRoot??"",rows:e.changeRows,rowHeight:e.changeRowHeight,changes:b?.items??[],selectedPath:w,scrollTop:o.changes,onScroll:t=>e.onScroll("changes",t),onSelect:e.onSelectChange,onToggle:e.onToggleDirectory,onOpen:e.onOpenFile,onReveal:e.onReveal},y),"ready"!==t.changes.status||b?.items.length?null:(0,i.jsx)("p",{className:"px-3 py-4 text-sm text-muted-foreground",children:l("noDiff")}),b?.hasMore?(0,i.jsx)(g.$,{size:"sm",variant:"ghost",disabled:"loading"===t.changes.status,onClick:e.onMoreChanges,children:l("loadMoreFiles")}):null,b?.truncated?(0,i.jsx)("p",{className:"p-3 text-xs text-muted-foreground",children:l("changesLimit")}):null]})}),(0,i.jsx)(f.WM,{}),(0,i.jsx)(f.wV,{id:"project-detail",defaultSize:`${100-e.panelSizes.changes}%`,minSize:"60px",children:(0,i.jsxs)($.V,{className:"h-full",viewportClassName:"p-3 text-sm",role:"region","aria-label":l("commitDetails"),children:[N?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("pre",{className:"mb-3 whitespace-pre-wrap break-words font-sans leading-relaxed",children:N.message}),(0,i.jsxs)("div",{className:"mb-2 flex items-center gap-2",children:[(0,i.jsx)("span",{className:"min-w-0 flex-1 break-all font-mono text-xs",children:N.oid}),(0,i.jsx)(g.$,{size:"icon-sm",variant:"ghost","aria-label":l("copySha"),onClick:()=>e.onCopy(N.oid),children:(0,i.jsx)(A.A,{className:"size-4"})})]}),(0,i.jsxs)("p",{className:"mb-3 text-xs text-muted-foreground",children:[N.author," \xb7 ",p.format(N.timestampMs)]}),N.parents.length>1?(0,i.jsx)(O.b,{className:"mb-3",ariaLabel:l("compareParent"),value:N.selectedParent??"",options:N.parents.map((e,t)=>({value:e,label:l("parentCommit",{count:t+1,oid:e.slice(0,10)})})),onChange:t=>e.onCommit(N.oid,t)}):null]}):b?(0,i.jsxs)("div",{className:"space-y-2 text-xs text-muted-foreground",children:[(0,i.jsx)("p",{children:"merge-base"===t.strategy?l("mergeBaseToTarget"):l("baseToTarget")}),(0,i.jsx)("p",{className:"break-all font-mono",children:b.comparison.original??l("emptyRevision")}),(0,i.jsx)("p",{className:"break-all font-mono",children:b.comparison.target})]}):(0,i.jsx)("p",{className:"text-muted-foreground",children:l("selectCommit")}),w?(0,i.jsx)("p",{className:"mt-3 break-all font-mono text-xs text-muted-foreground",children:w}):null]})})]})]});return(0,i.jsxs)("section",{className:"flex size-full min-h-0 min-w-0 flex-col","aria-label":l("historyAndCompare"),children:[(0,i.jsxs)("div",{className:"flex shrink-0 flex-wrap items-center gap-2 border-b px-3 py-2",children:[(0,i.jsxs)("div",{className:"flex gap-1",role:"group","aria-label":l("viewMode"),children:[(0,i.jsx)(g.$,{size:"sm",variant:"history"===t.mode?"secondary":"ghost","aria-pressed":"history"===t.mode,onClick:()=>{e.onMode("history"),v("log")},children:l("historyMode")}),(0,i.jsx)(g.$,{size:"sm",variant:"compare"===t.mode?"secondary":"ghost","aria-pressed":"compare"===t.mode,onClick:()=>{e.onMode("compare"),v("log")},children:l("compareMode")})]}),(0,i.jsx)(O.b,{className:"w-44",ariaLabel:l("selectRepository"),value:t.repositoryRoot??"",options:s.map(e=>({value:e.root,label:e.root||a,description:"unavailable"===e.state?(0,M.fD)(e.message,c):void 0})),onChange:e.onRepository}),"history"===t.mode?(0,i.jsx)(X,{className:"w-48",ariaLabel:l("viewBranch"),value:t.tip,branches:t.branches.data,onChange:t=>e.onRevision("tip",t)}):(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(X,{className:"w-44",ariaLabel:l("baseBranch"),placeholder:l("chooseBase"),value:t.base,branches:t.branches.data,onChange:t=>e.onRevision("base",t)}),(0,i.jsx)("span",{className:"text-xs text-muted-foreground",children:"→"}),(0,i.jsx)(X,{className:"w-44",ariaLabel:l("targetBranch"),value:t.target,branches:t.branches.data,onChange:t=>e.onRevision("target",t)}),(0,i.jsx)(O.b,{className:"w-48",ariaLabel:l("comparison"),value:t.strategy,options:[{value:"merge-base",label:l("introducedChanges")},{value:"direct",label:l("directComparison")}],onChange:t=>e.onStrategy("direct"===t?"direct":"merge-base")}),n?(0,i.jsx)(g.$,{size:"sm",variant:"outline",onClick:()=>v("files"),children:l("cumulativeChanges")}):null]}),(0,i.jsx)(T.p,{className:"w-40 shrink-0","aria-label":l("filterAuthor"),placeholder:l("author"),list:m,value:t.author,onChange:t=>e.onAuthor(t.target.value)}),(0,i.jsx)("datalist",{id:m,children:t.authorSuggestions.map(e=>(0,i.jsx)("option",{value:e},e))}),(0,i.jsx)(T.p,{className:"min-w-32 flex-1 basis-40","aria-label":l("searchCommits"),placeholder:l("searchCommits"),value:t.query,onChange:t=>e.onQuery(t.target.value)}),(0,i.jsx)(g.$,{size:"icon-sm",variant:"ghost","aria-label":l("refreshGit"),onClick:e.onRefresh,children:(0,i.jsx)(u.A,{className:"size-4"})})]}),t.branches.error?C(t.branches.error):null,k?(0,i.jsxs)("p",{className:"shrink-0 truncate border-b px-3 py-1 text-xs text-muted-foreground",title:k.ref,children:[k.ref.replace("refs/remotes/","")," \xb7 ",l("localRecord")," \xb7"," ",null===k.ahead||null===k.behind?l("refUnavailable"):l("aheadBehind",{ahead:k.ahead,behind:k.behind})]}):null,"compare"!==t.mode||t.base?n?"log"===x?S:R:(0,i.jsxs)(f.HK,{orientation:"horizontal",defaultLayout:{"project-log":e.panelSizes.log,"project-files":100-e.panelSizes.log},onLayoutChanged:(t,s)=>{s.isUserInteraction&&void 0!==t["project-log"]&&e.onPanelSize("log",t["project-log"])},children:[(0,i.jsx)(f.wV,{id:"project-log",defaultSize:`${e.panelSizes.log}%`,minSize:"30%",children:S}),(0,i.jsx)(f.WM,{}),(0,i.jsx)(f.wV,{id:"project-files",defaultSize:`${100-e.panelSizes.log}%`,minSize:"25%",children:R})]}):(0,i.jsx)("p",{className:"p-4 text-sm text-muted-foreground",children:l("chooseBaseBranch")})]})}let ee=()=>{};function et({clientId:e,cwd:t,title:s,actions:z,onEscape:D=ee,onUnauthorized:A}){let{t:M}=(0,r.Bd)("projectHistory"),P=(0,y.G)(),{files:$,git:T,history:O,global:L,updateGlobal:E,page:I,setPage:q,historyPane:F,setHistoryPane:_,setContainer:W,narrow:B,stacked:H,width:Y,changeRowHeight:V,openGit:K,refresh:U}=function(e,t,s){let i=(0,y.G)(),[r]=(0,j.useState)(N.N1),[a,n]=(0,j.useState)(r),o=(0,j.useCallback)(e=>{n(t=>({...t,...e})),(0,N.Ms)({...(0,N.N1)(),...e})},[]),[l]=(0,j.useState)(()=>(0,N.tQ)(t)),[c]=(0,j.useState)(()=>(0,k.ph)(e,t,e=>i.show({level:"info",title:e}),l,r,{lazyHistory:!0,onUnauthorized:s})),{files:d,git:u,history:h}=c;(0,j.useSyncExternalStore)(d.subscribe,d.getRevision,d.getRevision);let p=(0,j.useSyncExternalStore)(u.subscribe,u.getRevision,u.getRevision);(0,j.useSyncExternalStore)(h.subscribe,h.getRevision,h.getRevision);let[m,f]=(0,j.useState)(l?.page??"files"),[g,x]=(0,j.useState)(l?.historyPane??"log"),[v,b]=(0,j.useState)({width:1200,height:800}),[w,z]=(0,j.useState)(null),D=(0,j.useRef)(!1),A=(0,j.useRef)(()=>void 0),M=v.width<900,P=M||v.height<680,$=u.getWorkspace(t).snapshot.repositories,T=d.state,O=(0,j.useSyncExternalStore)(C,S,R)?24:36;(0,j.useEffect)(()=>{h.setChangeRowHeight(O)},[h,O]),(0,j.useEffect)(()=>{A.current=()=>{let e=u.getWorkspace(t),s=h.state,i={page:m,historyPane:g,tabs:[...d.state.tabs],activePath:d.state.activePath,...d.getBrowsingDocumentSettings(),expandedPaths:[...d.state.expandedPaths].slice(0,500),treeScrollTop:d.state.treeScrollTop,searchQuery:d.state.search.query.slice(0,200),changesOnly:e.changesOnly,expandedRepositories:[...e.expandedRepositories].slice(0,100),history:{repositoryRoot:s.repositoryRoot,mode:s.mode,tip:s.tip,base:s.base,target:s.target,strategy:s.strategy,query:s.query.slice(0,200),author:s.author.slice(0,200),selectedCommit:s.selectedCommit,selectedChangePath:s.selectedChangePath,logScroll:h.scroll.log,changesScroll:h.scroll.changes},diffs:d.state.diffs.map(({repositoryRoot:e,path:t,comparison:s})=>({repositoryRoot:e,path:t,...s?{comparison:s}:{}})),activeDiff:d.state.activeDiff?{repositoryRoot:d.state.activeDiff.repositoryRoot,path:d.state.activeDiff.path,...d.state.activeDiff.comparison?{comparison:d.state.activeDiff.comparison}:{}}:null};(0,N.Sb)(t,i)}},[t,d,u,h,g,m]),(0,j.useEffect)(()=>{D.current=!0,c.restore(),d.ensureRoot(),u.ensureSnapshot(t);let e=()=>A.current();return window.addEventListener("pagehide",e),()=>{D.current=!1,window.removeEventListener("pagehide",e),queueMicrotask(()=>{D.current||(A.current(),c.dispose())})}},[t,d,u,c]),(0,j.useEffect)(()=>{if(!w)return;let e=()=>b({width:w.clientWidth,height:w.clientHeight});e();let t=new ResizeObserver(e);return t.observe(w),()=>t.disconnect()},[w]);let L=a.gitOpen&&(!P||"git"===m);return(0,j.useEffect)(()=>{if(!L||!$.length)return;if($.some(e=>e.root===h.state.repositoryRoot))return void h.setRepository(h.state.repositoryRoot);let e=T.activeDiff?[T.activeDiff.repositoryRoot,T.activeDiff.path].filter(Boolean).join("/"):T.activePath,t=e?[...$].sort((e,t)=>t.root.length-e.root.length).find(t=>!t.root||e.startsWith(`${t.root}/`)):null;h.setRepository(t?.root??$.find(e=>""===e.root)?.root??$[0].root)},[L,p,h,$,T.activeDiff,T.activePath]),(0,j.useEffect)(()=>u.subscribe(()=>{let e=u.getWorkspace(t)?.layout;e&&e!==a.treeLayout&&o({treeLayout:e})}),[t,u,a.treeLayout,o]),{files:d,git:u,history:h,global:a,updateGlobal:o,page:m,setPage:f,historyPane:g,setHistoryPane:x,setContainer:z,narrow:M,stacked:P,width:v.width,changeRowHeight:O,openGit(e){o({gitOpen:!0}),f("git"),void 0!==e&&h.setRepository(e)},refresh(){d.refreshTree(),u.refreshSnapshot(t),T.activeDiff?d.reloadDiff():T.activePath&&d.reloadFile(T.activePath),L&&h.refresh()}}}(e,t,A),{directoryOpen:J,gitOpen:G,gitMaximized:Q}=L,X=t.replaceAll("\\","/").split("/").filter(Boolean).at(-1)??t,es=T.getWorkspace(t),ei=es.snapshot.repositories,er=$.state,ea=(0,i.jsx)(x.F,{cwd:t,projectName:X,showRootTitle:!1,runtime:$,gitRuntime:T,onOpenGitBranches:K,onFileOpened:()=>q("code")}),en=(0,i.jsx)(b.R,{runtime:$,gitRuntime:T,compact:Y<1100,onEscape:D,renderHeader:e=>(0,i.jsx)(v.X,{cwd:t,gitRuntime:T,paths:er.tabs,activePath:er.activePath,diffs:er.diffs,activeDiff:er.activeDiff,mobile:B,actions:e,onActivate:e=>{"string"==typeof e?$.openFile(e):$.openDiff(e.repositoryRoot,e.path,e.comparison)},onClose:(e,t)=>$.closeTabs(e,t)})}),eo=(0,i.jsxs)("div",{className:"flex size-full min-h-0 min-w-0 flex-col",children:[(0,i.jsxs)("div",{className:"flex h-9 shrink-0 items-center gap-2 border-b bg-muted px-3",children:[(0,i.jsx)(a.A,{className:"size-4"}),(0,i.jsx)("span",{className:"flex-1 text-sm font-medium",children:"Git"}),H?null:(0,i.jsx)(g.$,{size:"icon-sm",variant:"ghost","aria-label":M(Q?"restoreGit":"maximizeGit"),onClick:()=>E({gitMaximized:!Q}),children:Q?(0,i.jsx)(n.A,{className:"size-4"}):(0,i.jsx)(o.A,{className:"size-4"})}),(0,i.jsx)(g.$,{size:"icon-sm",variant:"ghost","aria-label":M("collapseGit"),onClick:()=>{E({gitOpen:!1,gitMaximized:!1}),q("code")},children:(0,i.jsx)(l.A,{className:"size-4"})})]}),ei.length?(0,i.jsx)(Z,{state:O.state,cwd:t,changeRows:O.getChangeRows(),changeRowHeight:V,onSelectChange:e=>O.selectChange(e),onToggleDirectory:e=>O.toggleChangeDirectory(e),onReveal:(e,t)=>$.revealFile(e,t),repositories:ei,projectName:X,narrow:B,mobilePane:F,onMobilePane:_,scroll:O.scroll,onScroll:(e,t)=>O.setScroll(e,t),panelSizes:{log:L.logSize,changes:L.changeSize},onPanelSize:(e,t)=>E("log"===e?{logSize:t}:{changeSize:t}),onRepository:e=>{O.setRepository(e),_("log")},onMode:e=>O.setMode(e),onRevision:(e,t)=>O.setRevision(e,t),onStrategy:e=>O.setStrategy(e),onQuery:e=>O.setQuery(e),onAuthor:e=>O.setAuthor(e),onCommit:(e,t)=>O.selectCommit(e,t),onAggregate:()=>O.showAggregate(),onMoreLog:()=>O.loadMoreLog(),onMoreChanges:()=>O.loadMoreChanges(),onOpenFile:e=>{O.openChange(e),q("code"),E({gitMaximized:!1})},onRefresh:()=>O.refresh(),onCopy:e=>{(0,w.x)(e).then(e=>{e||P.error(M("copyFailed"))})}}):(0,i.jsx)("p",{className:"p-4 text-sm text-muted-foreground",children:"loading"===es.snapshot.status||"idle"===es.snapshot.status?M("findingGit"):es.snapshot.error??M("noGit")})]}),el=(0,i.jsxs)(f.HK,{orientation:"horizontal",defaultLayout:J?{"project-tree":L.directorySize,"project-code":100-L.directorySize}:void 0,onLayoutChanged:(e,t)=>{t.isUserInteraction&&void 0!==e["project-tree"]&&E({directorySize:e["project-tree"]})},children:[J?(0,i.jsx)(f.wV,{id:"project-tree",defaultSize:`${L.directorySize}%`,minSize:"180px",maxSize:"40%",children:ea}):null,J?(0,i.jsx)(f.WM,{}):null,(0,i.jsx)(f.wV,{id:"project-code",minSize:"40%",children:en})]},J?"tree-visible":"tree-hidden");return(0,i.jsxs)("div",{ref:W,className:"flex size-full min-h-0 min-w-0 flex-col overflow-hidden","data-testid":"project-preview",children:[(0,i.jsxs)("header",{className:"flex min-h-9 shrink-0 items-center gap-1 bg-muted px-2 py-1 pt-[max(4px,env(safe-area-inset-top))]",children:[H?null:(0,i.jsx)(g.$,{size:"icon-sm",variant:"ghost","aria-label":M(J?"collapseDirectory":"expandDirectory"),onClick:()=>E({directoryOpen:!J}),children:J?(0,i.jsx)(c.A,{className:"size-4"}):(0,i.jsx)(d.A,{className:"size-4"})}),(0,i.jsxs)("div",{className:"flex min-w-0 flex-1 items-baseline gap-3",title:t,children:[(0,i.jsx)("div",{className:"min-w-0 shrink-0 max-w-[50%] max-sm:max-w-full max-sm:shrink",children:s??(0,i.jsx)("h1",{className:"truncate text-sm font-semibold",children:X})}),(0,i.jsx)("p",{className:"min-w-0 truncate text-xs text-muted-foreground max-sm:hidden",children:t})]}),(0,i.jsxs)(g.$,{size:"sm",variant:G?"secondary":"ghost","aria-pressed":G,onClick:()=>K(),children:[(0,i.jsx)(a.A,{className:"size-4"}),(0,i.jsx)("span",{className:"max-sm:hidden",children:M("gitRecords")})]}),(0,i.jsx)(g.$,{size:"icon-sm",variant:"ghost","aria-label":M("refreshPreview"),onClick:U,children:(0,i.jsx)(u.A,{className:"size-4"})}),z]}),es.snapshot.error?(0,i.jsx)("p",{role:"alert",className:"shrink-0 border-b px-3 py-2 text-sm text-destructive",children:es.snapshot.error}):null,H?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)("div",{className:"flex shrink-0 gap-1 px-2 py-1",role:"group","aria-label":M("previewArea"),children:[(0,i.jsxs)(g.$,{size:"sm",variant:"files"===I?"secondary":"ghost",onClick:()=>q("files"),children:[(0,i.jsx)(h.A,{className:"size-4"}),M("files")]}),(0,i.jsxs)(g.$,{size:"sm",variant:"code"===I?"secondary":"ghost",onClick:()=>q("code"),children:[(0,i.jsx)(p.A,{className:"size-4"}),M("code")]}),(0,i.jsxs)(g.$,{size:"sm",variant:"git"===I?"secondary":"ghost",onClick:()=>K(),children:[(0,i.jsx)(m.A,{className:"size-4"}),"Git"]})]}),(0,i.jsx)("div",{className:"min-h-0 flex-1",children:"files"===I?ea:"git"===I?eo:en})]}):Q&&G?eo:(0,i.jsxs)(f.HK,{orientation:"vertical",defaultLayout:G?{"project-main":100-L.gitSize,"project-git":L.gitSize}:void 0,onLayoutChanged:(e,t)=>{t.isUserInteraction&&void 0!==e["project-git"]&&E({gitSize:e["project-git"]})},children:[(0,i.jsx)(f.wV,{id:"project-main",defaultSize:G?`${100-L.gitSize}%`:"100%",minSize:"35%",children:el}),G?(0,i.jsx)(f.WM,{}):null,G?(0,i.jsx)(f.wV,{id:"project-git",defaultSize:`${L.gitSize}%`,minSize:"300px",children:eo}):null]},G?"git-visible":"git-hidden")]})}},58840:(e,t,s)=>{"use strict";s.d(t,{k:()=>h});var i=s(7962),r=s(82028),a=s.n(r),n=s(69266),o=s(49426),l=s(5816);let c=[[".viewer-zoom-in","放大","Zoom in"],[".viewer-zoom-out","缩小","Zoom out"],[".viewer-one-to-one","原始尺寸","Actual size"],[".viewer-reset","重置","Reset"],[".viewer-prev","上一张","Previous image"],[".viewer-next","下一张","Next image"],[".viewer-rotate-left","向左旋转","Rotate left"],[".viewer-rotate-right","向右旋转","Rotate right"]];function d(e){return document.querySelector(`.${e}`)}function u(e,t){e?.querySelectorAll(".viewer-list > li").forEach((e,s)=>{let i="en"===t?`View image ${s+1}`:`查看第 ${s+1} 张图片`;e.setAttribute("aria-label",i),e.setAttribute("title",i)})}function h(e){let{locale:t}=(0,l.i)(),{slides:s,index:r=0,onIndexChange:h,className:p,thumbnails:m=!0,ariaLabel:f="en"===t?"Image preview":"图片预览"}=e,g="inline"===e.mode,x="inline"===e.mode||e.open,v="modal"===e.mode?e.onClose:void 0,b=s.length>1,y=Math.min(Math.max(r,0),Math.max(s.length-1,0)),w=`pi-desk-image-viewer-${(0,n.useId)().replaceAll(":","")}`,j=(0,n.useRef)(null),k=(0,n.useRef)(null),N=(0,n.useRef)(null),C=(0,n.useRef)(""),S=(0,n.useRef)(""),R=(0,n.useRef)(y),z=(0,n.useRef)(y),D=(0,n.useRef)(h),A=(0,n.useRef)(v),M=(0,n.useMemo)(()=>JSON.stringify(s.map(e=>[e.src,e.alt])),[s]),P=(0,o.cn)("pi-desk-image-viewer",g?"pi-desk-image-viewer-inline":"pi-desk-image-viewer-modal",w,p);if((0,n.useEffect)(()=>{S.current=M},[M]),(0,n.useEffect)(()=>{z.current=y},[y]),(0,n.useEffect)(()=>{D.current=h},[h]),(0,n.useEffect)(()=>{A.current=v},[v]),(0,n.useEffect)(()=>{let e=j.current;if(!e||!x||0===s.length)return;let i=!1,r=null,n=0,o=null,l=e=>{!("Escape"===e.key&&!e.defaultPrevented&&!e.isComposing&&!e.altKey&&!e.ctrlKey&&!e.metaKey&&!e.shiftKey&&r?.fulled)||(e.preventDefault(),e.stopImmediatePropagation(),e.repeat||d(w)?.querySelector(".viewer-button")?.click())};window.addEventListener("keydown",l,!0);let h=()=>{if(i)return;let l=z.current;R.current=l;let h=window.matchMedia("(pointer: coarse)").matches||navigator.maxTouchPoints>0;r=new(a())(e,{inline:g,initialViewIndex:l,initialCoverage:g?.82:.88,minWidth:0,minHeight:0,minZoomRatio:.05,maxZoomRatio:8,zoomRatio:.12,zIndex:200,zIndexInline:1,backdrop:!g,button:!0,focus:!0,keyboard:!0,loading:!0,loop:!1,movable:!0,navbar:!!b&&!!m&&2,rotatable:!0,scalable:!1,slideOnTouch:b,title:!g&&1,toolbar:{prev:b,zoomOut:!0,zoomIn:!0,oneToOne:{show:2},reset:!0,rotateLeft:{show:2},rotateRight:{show:2},next:b},tooltip:!0,transition:!window.matchMedia("(prefers-reduced-motion: reduce)").matches,toggleOnDblclick:!h,zoomable:!0,zoomOnTouch:!0,zoomOnWheel:!0,className:P,ready:()=>(function(e,t,s,i,r,a){let n=d(e);if(!n)return;for(let[e,t,i]of(n.setAttribute("aria-label",s),n.setAttribute("lang",a),c)){let s=n.querySelector(e);if(!s)continue;let r="en"===a?i:t;s.setAttribute("aria-label",r),s.setAttribute("title",r)}u(n,a);let o=n.querySelector(".viewer-button");if(o){let e=()=>{let e=t?o.classList.contains("viewer-fullscreen-exit")?"en"===a?"Exit fullscreen":"退出全屏":"en"===a?"View image fullscreen":"全屏查看图片":"en"===a?"Close image preview":"关闭图片预览";o.setAttribute("aria-label",e),o.setAttribute("title",e)};e(),t&&o.addEventListener("click",()=>requestAnimationFrame(e))}if(i>1){let e=document.createElement("div");e.className="pi-desk-image-viewer-counter",e.dataset.piDeskViewerCounter="",e.setAttribute("aria-live","polite"),e.textContent=`${r+1} / ${i}`,n.appendChild(e)}})(w,g,f,s.length,l,t),view:e=>{let t=function(e){let t=e.detail;if("object"!=typeof t||null===t)return null;let s=Reflect.get(t,"index");return"number"==typeof s&&Number.isInteger(s)?s:null}(e);if(null!==t){var i;let e;b&&N.current&&(N.current.options.transition=!1),R.current=t,i=s.length,(e=d(w)?.querySelector("[data-pi-desk-viewer-counter]"))&&(e.textContent=`${t+1} / ${i}`),D.current?.(t)}},viewed:()=>{let e=N.current;if(!b||!e?.image)return;let t=window.matchMedia("(prefers-reduced-motion: reduce)").matches;e.options.transition=!t,t||(e.image.getBoundingClientRect(),e.image.classList.add("viewer-transition"),e.image.animate([{opacity:0},{opacity:1}],{duration:150,easing:"ease-out"}))},hidden:()=>A.current?.()}),N.current=r,C.current=S.current,g&&k.current?(o=new ResizeObserver(()=>{cancelAnimationFrame(n),n=requestAnimationFrame(()=>r?.resize())})).observe(k.current):r.show()},p=Array.from(e.querySelectorAll("img"));return g&&p.some(e=>!e.complete)?Promise.all(p.map(e=>e.decode().catch(()=>void 0))).then(h):h(),()=>{i=!0,window.removeEventListener("keydown",l,!0),o?.disconnect(),cancelAnimationFrame(n),N.current===r&&(N.current=null),r?.destroy()}},[x,f,g,w,t,b,s.length,m,P]),(0,n.useEffect)(()=>{let e=N.current;if(!e||C.current===M)return;C.current=M;let s=R.current,i=j.current?.querySelectorAll("img")[s],r=e.image?.src!==i?.src||e.image?.alt!==i?.alt;r&&(e.viewed=!1),e.update(),r&&e.view(s),u(d(w),t)},[w,t,M]),(0,n.useEffect)(()=>{let e=N.current;e&&R.current!==y&&e.view(y)},[y]),0===s.length||!x)return null;let $=(0,i.jsx)("span",{ref:j,className:"pi-desk-image-viewer-source","aria-hidden":"true",children:s.map((e,t)=>(0,i.jsx)("img",{src:e.src,alt:e.alt,width:e.width,height:e.height,decoding:"async",draggable:!1},t))});return g?(0,i.jsx)("div",{ref:k,className:"pi-desk-image-viewer-host",role:"region","aria-label":f,tabIndex:0,onKeyDown:e=>{let t=N.current;!t||t.fulled||e.altKey||e.ctrlKey||e.metaKey||e.nativeEvent.isComposing||("ArrowLeft"===e.key||"ArrowRight"===e.key)&&(e.preventDefault(),e.stopPropagation(),"ArrowLeft"===e.key?t.prev(!1):t.next(!1))},children:$}):$}},60471:(e,t,s)=>{"use strict";s.d(t,{b:()=>u});var i=s(7962),r=s(46783),a=s(69266),n=s(78121),o=s(86963),l=s(89790),c=s(90434),d=s(49426);function u({value:e,options:t,onChange:s,ariaLabel:h,placeholder:p,searchPlaceholder:m,emptyText:f,disabled:g=!1,className:x}){let{t:v}=(0,n.Bd)("common"),[b,y]=(0,a.useState)(!1),w=t.find(t=>t.value===e);return(0,i.jsxs)(c.AM,{open:b,onOpenChange:y,children:[(0,i.jsx)(c.Wv,{render:(0,i.jsxs)(o.$,{type:"button",variant:"outline",role:"combobox","aria-label":h,"aria-expanded":b,disabled:g,className:(0,d.cn)("w-full min-w-0 justify-between border-input px-2.5 font-normal focus-visible:-outline-offset-2",x),children:[(0,i.jsx)("span",{className:(0,d.cn)("min-w-0 truncate",!w&&"text-muted-foreground"),children:w?.label??p??v("selectPlaceholder")}),(0,i.jsx)(r.A,{className:"text-muted-foreground"})]})}),(0,i.jsx)(c.hl,{align:"start",sideOffset:4,positionerClassName:"z-[120]",className:"w-(--anchor-width) max-w-[calc(100vw-2rem)] gap-0 p-0",children:(0,i.jsxs)(l.uB,{children:[(0,i.jsx)(l.G7,{placeholder:m??v("searchPlaceholder"),autoFocus:!0}),(0,i.jsxs)(l.oI,{className:"max-h-[min(20rem,var(--available-height))]",children:[(0,i.jsx)(l.xL,{children:f??v("noMatches")}),(0,i.jsx)(l.L$,{children:t.map(t=>(0,i.jsx)(l.h_,{value:`${t.label} ${t.description??""} ${t.value}`,"data-checked":t.value===e?"true":void 0,onSelect:()=>{s(t.value),y(!1)},children:(0,i.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,i.jsx)("span",{className:"block truncate",children:t.label}),t.description?(0,i.jsx)("span",{className:"mt-0.5 block truncate text-xs text-muted-foreground",children:t.description}):null]})},t.value))})]})]})})]})}},60682:(e,t,s)=>{"use strict";s.d(t,{J:()=>g});var i=s(7962),r=s(49762),a=s(86758),n=s(36670),o=s(50479),l=s(35995),c=s(69266),d=s(78121),u=s(99084),h=s(51821),p=s(1364),m=s(73165),f=s(93119);function g({cwd:e,path:t,type:s,trigger:x,openLabel:v,onOpen:b,expanded:y,onToggle:w,historical:j,oldPath:k,onReveal:N}){let{t:C}=(0,d.Bd)("projectFiles"),S=(0,h.G)(),[R,z]=(0,c.useState)(null),D=R??{cwd:e,path:t,type:s,oldPath:k},A=(0,c.useRef)(!1),M=(0,c.useRef)(""),P="file"===s?"file":"folder",$=e=>{(0,u.x)(e).then(e=>{e?S.success(C("copied")):S.error(C("copyFailed"))})},T=(D.path||D.cwd.replaceAll("\\","/")).split("/").filter(Boolean).at(-1)??D.cwd;return(0,i.jsxs)(p.tz,{onOpenChange:(i,r)=>{z(i?{cwd:e,path:t,type:s,oldPath:k}:null);let a=r.event;i&&("touch"===M.current||"pointerType"in a&&"touch"===a.pointerType||a.type.startsWith("touch"))&&(A.current=!0)},children:[(0,i.jsx)(p.Rc,{render:x,"data-project-path-menu-trigger":"",onPointerDown:e=>{M.current=e.pointerType,A.current=!1},onTouchEndCapture:e=>{let t=e.target;!R||!A.current||"touch"!==M.current||t instanceof Element&&t.closest("[data-project-path-menu-trigger]")===e.currentTarget&&e.cancelable&&e.preventDefault()},onClickCapture:e=>{A.current&&(e.preventDefault(),e.stopPropagation(),A.current=!1)},onKeyDownCapture:e=>{if(e.defaultPrevented||e.nativeEvent.isComposing)return;let t=e.target;if(!(t instanceof Element)||t.closest("[data-project-path-menu-trigger]")!==e.currentTarget||(M.current="keyboard",A.current=!1,"ContextMenu"!==e.key&&!("F10"===e.key&&e.shiftKey)))return;e.preventDefault(),e.stopPropagation();let s=t.getBoundingClientRect();e.currentTarget.dispatchEvent(new MouseEvent("contextmenu",{bubbles:!0,cancelable:!0,button:2,clientX:s.left+Math.min(s.width,120)/2,clientY:s.top+Math.min(s.height,36)/2}))}}),(0,i.jsxs)(m.D,{children:[b?(0,i.jsxs)(p.kt,{onClick:b,children:[(0,i.jsx)(r.A,{}),v??C("openPreview")]}):null,w?(0,i.jsxs)(p.kt,{onClick:w,children:[y?(0,i.jsx)(a.A,{}):(0,i.jsx)(n.A,{}),C(y?"collapse":"expand")]}):null,b||w?(0,i.jsx)(p.K5,{}):null,N?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)(p.kt,{"data-testid":`project-${P}-reveal-${t}`,onClick:()=>{N&&N(D.path,D.type).then(()=>S.success(C("revealRequested"))).catch(e=>{S.error(e instanceof Error?e.message:C("revealFailed"))})},children:[(0,i.jsx)(o.A,{}),j?"directory"===s?C("openCurrentWorkspace"):C("locateCurrentWorkspace"):"directory"===s?C("openFolder"):C("openContainingFolder")]}),(0,i.jsx)(p.K5,{})]}):null,(0,i.jsxs)(p.kt,{"data-testid":`project-${P}-copy-address-${t}`,onClick:()=>$((0,f.$)(D.cwd,D.path)),children:[(0,i.jsx)(l.A,{}),C("copyAbsolutePath")]}),(0,i.jsxs)(p.kt,{onClick:()=>$(D.path||"."),children:[(0,i.jsx)(l.A,{}),C("copyRelativePath")]}),(0,i.jsxs)(p.kt,{onClick:()=>$(T),children:[(0,i.jsx)(l.A,{}),C("directory"===s?"copyFolderName":"copyFileName")]}),D.oldPath?(0,i.jsxs)(p.kt,{onClick:()=>$(D.oldPath),children:[(0,i.jsx)(l.A,{}),C("copyOldRelativePath")]}):null]})]})}},64334:(e,t,s)=>{"use strict";s.d(t,{Ms:()=>y,N1:()=>b,Sb:()=>j,tQ:()=>w});var i=s(38979),r=s(67765),a=s(86062);let n="pi-super:project-preview:global",o="pi-super:project-preview:projects",l=i.ai().min(5).max(95),c=i.Ik({maximized:i.zM(),directoryOpen:i.zM(),gitOpen:i.zM(),gitMaximized:i.zM(),treeLayout:i.k5(["directory","repository"]),directorySize:l,gitSize:l,logSize:l,changeSize:l}),d={maximized:!1,directoryOpen:!0,gitOpen:!1,gitMaximized:!1,treeLayout:"directory",directorySize:22,gitSize:45,logSize:62,changeSize:70},u=i.Ik({repositoryRoot:i.Yj().nullable(),mode:i.k5(["history","compare"]),tip:i.Yj(),base:i.Yj(),target:i.Yj(),strategy:i.k5(["merge-base","direct"]),query:i.Yj().max(200),author:i.Yj().max(200),selectedCommit:a.aD.nullable(),selectedChangePath:r._g.nullable(),logScroll:i.ai().nonnegative(),changesScroll:i.ai().nonnegative()}),h=i.Ie(e=>"object"==typeof e&&null!==e&&Array.isArray(e.cursorState)&&"object"==typeof e.viewState),p=i.Ik({repositoryRoot:i.Yj(),path:r._g,comparison:a.xv.optional()}),m=i.Ik({page:i.k5(["files","code","git"]),historyPane:i.k5(["log","files"]),tabs:i.YO(r._g).max(20),activePath:r._g.nullable(),editorStates:i.g1(r._g,h),fileViewModes:i.g1(r._g,i.k5(["source","preview"])),expandedPaths:i.YO(i.Yj()).max(500),treeScrollTop:i.ai().nonnegative(),searchQuery:i.Yj().max(200),changesOnly:i.zM(),expandedRepositories:i.YO(i.Yj()).max(100),history:u,diffs:i.YO(p).max(20).optional(),activeDiff:p.nullable()}),f=i.Ik({cwd:i.Yj(),lastOpenedAt:i.ai(),state:m});function g(e){let t=e.replaceAll("\\","/").replace(/\/+$/,"");return/^[a-z]:\//i.test(t)||t.startsWith("//")?t.toLowerCase():t}function x(){try{let e=JSON.parse(window.localStorage.getItem(o)??"[]");if(!Array.isArray(e))return[];let t=Date.now();return e.flatMap(e=>{let s=f.safeParse(e);return s.success&&t-s.data.lastOpenedAt<2592e6?[s.data]:[]})}catch{return[]}}function v(e){try{window.localStorage.setItem(o,JSON.stringify(e.sort((e,t)=>t.lastOpenedAt-e.lastOpenedAt).slice(0,50)))}catch(e){console.warn("[Pi Desk][ProjectPreview] 保存项目浏览状态失败",e)}}function b(){try{let e=JSON.parse(window.localStorage.getItem(n)??"null");return{...d,...c.partial().parse(e)}}catch{return{...d}}}function y(e){try{window.localStorage.setItem(n,JSON.stringify(e))}catch(e){console.warn("[Pi Desk][ProjectPreview] 保存全局布局失败",e)}}function w(e){let t=g(e),s=x(),i=s.find(e=>e.cwd===t);return i&&(i.lastOpenedAt=Date.now()),v(s),i?.state??null}function j(e,t){let s=m.safeParse(t);if(!s.success)return;let i=g(e),r=x(),a=r.find(e=>e.cwd===i);a?a.state=s.data:r.push({cwd:i,lastOpenedAt:Date.now(),state:s.data}),v(r)}},66453:(e,t,s)=>{"use strict";s.d(t,{$E:()=>a,Rv:()=>n,m4:()=>r});var i=s(38979);let r=i.Yj().trim().min(1),a=i.Yj().trim().min(1),n=i.Yj().trim().min(1)},67765:(e,t,s)=>{"use strict";s.d(t,{CT:()=>p,JH:()=>f,NL:()=>n,Nu:()=>g,_g:()=>d,eC:()=>u,gB:()=>o,ih:()=>w,jI:()=>y,p$:()=>h,rh:()=>c,uV:()=>r,xm:()=>a});var i=s(38979);let r=4096,a=5e3,n=5242880,o=1048576;function l(e,t){return""===e?t:!(e.length>r||e.startsWith("/")||e.includes("\\")||e.includes("\0")||/^[a-zA-Z]:/.test(e))&&e.split("/").every(e=>e.length>0&&"."!==e&&".."!==e)}let c=i.Yj().max(r).refine(e=>l(e,!0),"目录路径必须是规范相对路径"),d=i.Yj().min(1).max(r).refine(e=>l(e,!1),"文件路径必须是规范相对路径"),u=i.Yj().min(1).max(r).refine(e=>l(e,!1)||e.length>0&&e.length<=r&&!e.includes("\0")&&(e.startsWith("/")||e.startsWith("\\\\")||/^[a-zA-Z]:[\\/]/.test(e)),"预览路径必须是规范相对路径或绝对路径"),h=i.k5(["compressed","original"]),p=i.k5(["image/jpeg","image/png","image/webp","image/gif"]),m=i.Ik({name:i.Yj().min(1),type:i.k5(["directory","file"])}).strict(),f=i.Ik({entries:i.YO(m).max(a),truncated:i.zM()}).strict(),g=i.Ik({query:i.Yj().min(1).max(200).refine(e=>e.trim().length>0&&!/[\0\r\n]/.test(e),"搜索词必须是非空单行文本"),scope:i.k5(["all","files","content"]).default("all"),caseSensitive:i.zM().default(!1),wholeWord:i.zM().default(!1),regex:i.zM().default(!1)}).strict(),x=i.Ik({start:i.ai().int().nonnegative(),end:i.ai().int().nonnegative()}).strict().refine(e=>e.start<=e.end,"搜索命中区间无效"),v=i.Ik({path:d,ranges:i.YO(x)}).strict().refine(e=>e.ranges.every(t=>t.end<=e.path.length),"文件名命中区间越界"),b=i.Ik({path:d,line:i.ai().int().positive(),text:i.Yj().max(1e3),ranges:i.YO(x)}).strict().refine(e=>e.ranges.every(t=>t.end<=e.text.length),"正文命中区间越界"),y=i.Ik({fileMatches:i.YO(v).max(100),contentMatches:i.YO(b).max(200),truncated:i.zM()}).strict(),w=i.gM("kind",[i.Ik({kind:i.eu("text"),content:i.Yj(),size:i.ai().int().nonnegative().max(n)}).strict(),i.Ik({kind:i.eu("image"),mimeType:p,data:i.Yj().min(1),size:i.ai().int().positive().max(0xa00000)}).strict()])},68017:(e,t,s)=>{"use strict";s.d(t,{T:()=>a});var i=s(7962);s(69266);var r=s(49426);function a({className:e,...t}){return(0,i.jsx)("textarea",{"data-slot":"textarea",className:(0,r.cn)("flex field-sizing-content min-h-16 w-full rounded-lg border border-input bg-card px-2.5 py-2 text-sm leading-5 transition-colors duration-150 outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:outline-2 focus-visible:outline-solid focus-visible:-outline-offset-2 focus-visible:outline-ring disabled:cursor-not-allowed disabled:bg-muted disabled:opacity-50 aria-invalid:border-destructive aria-invalid:outline-destructive",e),...t})}},69272:(e,t,s)=>{"use strict";s.d(t,{s:()=>N});var i=s(7962),r=s(34506),a=s(49762),n=s(19932),o=s(50153);let l={src:"/_next/static/media/console.fdac8a18.svg",height:16,width:16,blurWidth:0,blurHeight:0},c={src:"/_next/static/media/docker.1e10aab8.svg",height:24,width:24,blurWidth:0,blurHeight:0},d={src:"/_next/static/media/git.f893cb5f.svg",height:32,width:32,blurWidth:0,blurHeight:0},u={src:"/_next/static/media/html.97f145d3.svg",height:32,width:32,blurWidth:0,blurHeight:0},h={src:"/_next/static/media/image.69ad851c.svg",height:16,width:16,blurWidth:0,blurHeight:0},p={src:"/_next/static/media/javascript.9ef61c53.svg",height:16,width:16,blurWidth:0,blurHeight:0},m={src:"/_next/static/media/json.eb8fe488.svg",height:960,width:960,blurWidth:0,blurHeight:0},f={src:"/_next/static/media/markdown.ee1bbe18.svg",height:32,width:32,blurWidth:0,blurHeight:0},g={src:"/_next/static/media/nodejs.2f5d7983.svg",height:32,width:32,blurWidth:0,blurHeight:0},x={src:"/_next/static/media/typescript.cd97905b.svg",height:16,width:16,blurWidth:0,blurHeight:0},v={src:"/_next/static/media/yaml.8927dd24.svg",height:24,width:24,blurWidth:0,blurHeight:0},b=new Map(Object.entries({"agents.md":{src:"/_next/static/media/agent.84538518.svg",height:32,width:32,blurWidth:0,blurHeight:0},"skill.md":{src:"/_next/static/media/skill.a97e8eb6.svg",height:16,width:16,blurWidth:0,blurHeight:0},"package.json":g,"package-lock.json":g,"npm-shrinkwrap.json":g,dockerfile:c,".dockerignore":c,".gitignore":d,".gitattributes":d,".gitmodules":d})),y=new Map(Object.entries({ts:x,mts:x,cts:x,tsx:{src:"/_next/static/media/react_ts.3d16336c.svg",height:32,width:32,blurWidth:0,blurHeight:0},js:p,mjs:p,cjs:p,jsx:{src:"/_next/static/media/react.b5a87f7d.svg",height:32,width:32,blurWidth:0,blurHeight:0},json:m,jsonc:m,jsonl:m,yaml:v,yml:v,md:f,mdx:f,png:h,jpg:h,jpeg:h,gif:h,webp:h,avif:h,bmp:h,ico:h,svg:{src:"/_next/static/media/svg.4aa98763.svg",height:32,width:32,blurWidth:0,blurHeight:0},sh:l,bash:l,zsh:l,fish:l,ps1:l,bat:l,cmd:l,html:u,htm:u,css:{src:"/_next/static/media/css.0d88d948.svg",height:32,width:32,blurWidth:0,blurHeight:0},py:{src:"/_next/static/media/python.e376d0bc.svg",height:24,width:24,blurWidth:0,blurHeight:0}})),w=new Set(["env","toml","ini","conf","cfg","properties"]),j=new Set([".editorconfig",".npmrc",".yarnrc",".prettierignore",".eslintignore"]),k=new Set(["c","cpp","cc","cxx","h","hpp","cs","go","rs","java","kt","kts","rb","php","swift","dart","vue","svelte","scss","sass","less","sql","xml"]);function N({path:e,className:t}){let s=e.replaceAll("\\","/").split("/").at(-1)?.toLowerCase()??"",l=s.includes(".")?s.slice(s.lastIndexOf(".")+1):"";if(w.has(l)||j.has(s)||s.startsWith(".env.")||s.startsWith(".eslintrc")||s.startsWith(".prettierrc")||s.startsWith("eslint.config.")||s.startsWith("prettier.config."))return(0,i.jsx)(r.A,{className:t,"aria-hidden":"true"});let d=b.get(s)??(s.startsWith("dockerfile.")?c:void 0)??y.get(l);if(!d){let e=k.has(l)?a.A:n.A;return(0,i.jsx)(e,{className:t,"aria-hidden":"true"})}return(0,i.jsx)(o.default,{src:d,alt:"","aria-hidden":"true",width:16,height:16,className:t,unoptimized:!0})}},70698:(e,t,s)=>{"use strict";s.d(t,{k:()=>i});let i=s(38979).ai().int().nonnegative().max(Number.MAX_SAFE_INTEGER)},72282:(e,t,s)=>{"use strict";s.d(t,{HK:()=>n,WM:()=>l,wV:()=>o});var i=s(7962),r=s(55493),a=s(49426);function n({className:e,...t}){return(0,i.jsx)(r.YJ,{"data-slot":"resizable-panel-group",className:(0,a.cn)("flex h-full w-full aria-[orientation=vertical]:flex-col",e),...t})}function o({...e}){return(0,i.jsx)(r.Zk,{"data-slot":"resizable-panel",...e})}function l({withHandle:e,className:t,...s}){return(0,i.jsx)(r.wv,{"data-slot":"resizable-handle",className:(0,a.cn)("relative flex w-px items-center justify-center bg-border ring-offset-background after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-hidden aria-[orientation=horizontal]:h-px aria-[orientation=horizontal]:w-full aria-[orientation=horizontal]:after:left-0 aria-[orientation=horizontal]:after:h-1 aria-[orientation=horizontal]:after:w-full aria-[orientation=horizontal]:after:translate-x-0 aria-[orientation=horizontal]:after:-translate-y-1/2 [&[aria-orientation=horizontal]>div]:rotate-90",t),...s})}},73068:(e,t,s)=>{"use strict";s.d(t,{R:()=>O});var i=s(7962),r=s(31123),a=s(28436),n=s(60278),o=s(55628),l=s(47974),c=s(90680),d=s(3433),u=s(41148),h=s(15824),p=s(35995),m=s(49762),f=s(14044),g=s(69266),x=s(78121),v=s(99084),b=s(90504),y=s(91182),w=s(18302),j=s(33550);let k=(0,g.forwardRef)(function({original:e,modified:t,viewMode:s,onEscape:r,savedState:a,onSaveState:n,initialLine:o},l){let{t:c}=(0,x.Bd)("common"),{wrapLines:d,collapseUnchanged:u}=(0,j.TX)(),h=(0,g.useRef)(null),p=(0,g.useRef)(null),m=(0,g.useRef)({viewMode:s,wrapLines:d,collapseUnchanged:u}),v=(0,g.useRef)(r),b=(0,g.useRef)(a),k=(0,g.useRef)(n),N=(0,g.useRef)(o);(0,g.useEffect)(()=>{v.current=r,b.current=a,k.current=n,N.current=o},[o,r,n,a]);let[C,S]=(0,g.useState)("loading"),[R,z]=(0,g.useState)(null);return(0,g.useEffect)(()=>{m.current={viewMode:s,wrapLines:d,collapseUnchanged:u}},[u,s,d]),(0,g.useImperativeHandle)(l,()=>({previousChange(){p.current?.goToDiff("previous")},nextChange(){p.current?.goToDiff("next")},focus(){p.current?.getModifiedEditor().focus()}}),[]),(0,g.useEffect)(()=>{let s=h.current;if(!s)return;let i=!0,r=null,a=null,n=null,o=()=>void 0,l=()=>void 0,d=[];return queueMicrotask(()=>{i&&(S("loading"),z(null))}),(0,y.cu)().then(u=>{if(!i)return;a=u.editor.createModel(e.content,(0,y.ix)(e.path,new TextEncoder().encode(e.content).length),(0,y.B3)(u,e.path,"diff-original")),n=u.editor.createModel(t.content,(0,y.ix)(t.path,new TextEncoder().encode(t.content).length),(0,y.B3)(u,t.path,"diff-modified"));let h=m.current;r=u.editor.createDiffEditor(s,{theme:(0,y.dC)(),readOnly:!0,domReadOnly:!0,editContext:!1,originalEditable:!1,automaticLayout:!0,renderSideBySide:"side-by-side"===h.viewMode,useInlineViewWhenSpaceIsLimited:!1,enableSplitViewResizing:!0,diffAlgorithm:"advanced",ignoreTrimWhitespace:!1,maxComputationTime:5e3,hideUnchangedRegions:h.collapseUnchanged?{enabled:!0,revealLineCount:3,minimumLineCount:6,contextLineCount:3}:{enabled:!1},minimap:{enabled:!1},stickyScroll:{enabled:!1},scrollBeyondLastLine:!1,smoothScrolling:!0,diffWordWrap:h.wrapLines?"on":"off",wrappingIndent:"same",...(0,y.R)(),lineNumbersMinChars:3,renderValidationDecorations:"off",renderWhitespace:"selection",unicodeHighlight:{nonBasicASCII:!1},padding:{top:10,bottom:10},overviewRulerBorder:!1,contextmenu:!0,ariaLabel:c("gitDiffReadOnly")});let f=N.current,g=!1;d.push(r.onDidUpdateDiff(()=>{if(!i||!r)return;let e=r.getLineChanges();if(z(e?.length??null),!g&&null!==e&&void 0!==f){g=!0;let e=Math.max(1,Math.min(f,n?.getLineCount()??1)),t=r.getModifiedEditor();t.setPosition({lineNumber:e,column:1}),t.revealLineInCenter(e)}})),r.setModel({original:a,modified:n}),void 0===f&&b.current&&r.restoreViewState(b.current);let x=()=>k.current?.(r?.saveViewState()??null);d.push(r.getOriginalEditor().onDidScrollChange(x),r.getModifiedEditor().onDidScrollChange(x)),v.current&&((0,w.e)(r.getOriginalEditor(),u.KeyCode.Escape,()=>v.current?.()),(0,w.e)(r.getModifiedEditor(),u.KeyCode.Escape,()=>v.current?.())),p.current=r,o=(0,y.Tr)(e=>u.editor.setTheme(e)),l=(0,y.BK)(e=>r?.updateOptions(e)),S("ready")}).catch(s=>{i&&(console.error("[Pi Desk][CodeDiff] Monaco 加载失败",{originalPath:e.path,modifiedPath:t.path,errorName:s instanceof Error?s.name:"UnknownError"}),S("error"))}),()=>{for(let e of(i=!1,o(),l(),k.current?.(r?.saveViewState()??null),d))e.dispose();p.current=null,r?.setModel(null),r?.dispose(),window.setTimeout(()=>{a?.dispose(),n?.dispose()},0)}},[t.content,t.path,e.content,e.path,c]),(0,g.useEffect)(()=>{p.current?.updateOptions({renderSideBySide:"side-by-side"===s,diffWordWrap:d?"on":"off",hideUnchangedRegions:u?{enabled:!0,revealLineCount:3,minimumLineCount:6,contextLineCount:3}:{enabled:!1}}),"side-by-side"===s&&p.current?.getOriginalEditor().updateOptions({wordWrapOverride2:"inherit"})},[u,s,d]),(0,i.jsxs)("div",{"data-testid":"code-diff",className:"relative flex h-full min-h-0 w-full flex-col overflow-hidden bg-background",children:[(0,i.jsx)("div",{ref:h,className:"min-h-0 flex-1"}),(0,i.jsx)("div",{role:"status","aria-label":c("diffStatus"),className:"flex min-h-6 shrink-0 items-center justify-end border-t px-3 text-xs text-muted-foreground",children:null===R?c("diffCalculating"):c("diffCount",{count:R})}),"loading"===C?(0,i.jsxs)("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center gap-2 bg-background text-sm text-muted-foreground",children:[(0,i.jsx)(f.A,{className:"size-4 animate-spin"})," ",c("diffLoading")]}):null,"error"===C?(0,i.jsx)("div",{className:"absolute inset-0 flex items-center justify-center p-6 text-center text-sm text-destructive",children:c("diffFailed")}):null]})});var N=s(58840),C=s(51821),S=s(86963),R=s(56592),z=s(35989),D=s(14512),A=s(32892);function M({label:e,onClick:t,active:s=!1,children:r}){return(0,i.jsxs)(A.m_,{children:[(0,i.jsx)(A.k$,{render:(0,i.jsx)(S.$,{type:"button",size:"icon-sm",variant:"ghost","aria-label":e,"aria-pressed":s||void 0,onPointerDown:e=>e.preventDefault(),onClick:t}),children:r}),(0,i.jsx)(A.ZI,{children:e})]})}var P=s(36510),$=s(46487),T=s(97921);function O({ref:e,runtime:t,gitRuntime:s,compact:f,visible:y=!0,onEscape:w,onSwitchPane:A,renderHeader:E}){let I,q,F,_,W,B,H,Y,V,{t:K}=(0,x.Bd)("projectFiles"),{wrapLines:U,diffViewMode:J,collapseUnchanged:G}=(0,j.TX)();(0,g.useSyncExternalStore)(t.subscribe,t.getRevision,t.getRevision);let{activeDiff:Q,activePath:X}=t.state,Z=!Q&&X?t.state.documents.get(X):null,ee=X?(0,T.g)(X):null,et=Z?.status==="text"&&(!ee||"source"===Z.viewMode),es=(0,g.useRef)(null),ei=(0,g.useRef)(null),er=(0,g.useRef)(null),ea=(0,g.useRef)(null),en=(0,C.G)();(0,g.useImperativeHandle)(e,()=>({focus(){et?ei.current?.focus():Q?er.current?.focus():es.current?.querySelector('[data-testid="markdown-preview"]')?.focus()}}),[Q,et]),(0,g.useEffect)(()=>{let e=e=>{ea.current&&e.source===ea.current.contentWindow&&("pi-desk:file-escape"===e.data&&w(),"pi-desk:file-switch-pane"===e.data&&A?.())};return window.addEventListener("message",e),()=>window.removeEventListener("message",e)},[w,A]);let eo=()=>{X&&ei.current&&t.saveEditorState(X,ei.current.getViewState())},{refresh:el,unavailable:ec}=((0,g.useSyncExternalStore)(s.subscribe,s.getRevision,s.getRevision),I=s.getWorkspace(t.cwd)?.snapshot,q=t.state.activePath,_=!!(F=t.state.activeDiff),W=q?t.state.documents.get(q):void 0,B=(0,g.useRef)(eo),(0,g.useEffect)(()=>{B.current=eo},[eo]),H=(0,g.useCallback)(()=>{q&&!_&&(B.current(),t.reloadFile(q),s.refreshSnapshot(t.cwd))},[_,s,q,t]),Y=(0,g.useCallback)(()=>{F?t.refreshDiff():q&&(B.current(),t.ensureDocument(q,!0)),s.refreshSnapshot(t.cwd)},[F,s,q,t]),(0,D.L)(es,Y,y),(0,g.useEffect)(()=>{if(!y||!q||_||W?.status!=="text"||I?.status==="loading")return;let e=new AbortController,s=I?.status==="ready"?(0,z.lN)(t.cwd,q,I.repositories):null;return t.compareFile(q,s?.repository.state==="ready"&&s.change?{repositoryRoot:s.repository.root,path:s.change.path}:null,e.signal),()=>e.abort()},[y,_,W,q,t,I]),V=q&&I?.status==="ready"?(0,z.lN)(t.cwd,q,I.repositories):null,{refresh:H,unavailable:I?.status==="error"||V?.repository.state==="unavailable"}),ed=Z?.status==="text"?Z.comparison:void 0,[eu,eh]=(0,g.useState)(null),ep=ed?.status==="ready"&&Z?.status==="text"&&eu?.original===ed.original.content&&eu.modified===Z.content?eu.count:void 0,em=e=>{X&&(eo(),t.openFileDiff(X,e))},ef=ec||ed?.status==="error"?K("gitMarkersFailed"):ed?.status==="unavailable"||ed?.status==="ready"&&null===ep?K("gitMarkersUnavailable"):ed?.status==="loading"||ed?.status==="ready"&&void 0===ep?K("gitMarkersLoading"):ed?.status==="ready"?K("gitChangesCount",{count:ep}):null,eg=Q||X?(0,i.jsx)(i.Fragment,{children:Q?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)("span",{className:"mr-auto shrink-0 px-1 text-xs text-muted-foreground",children:[Q.label??(Q.comparison?`${Q.comparison.baseCommit?.slice(0,7)??"∅"} → ${Q.comparison.targetCommit.slice(0,7)}`:K("headToWorking")),"text"===Q.status&&Q.original.content===Q.modified.content?K("noDiffChanges"):""]}),(0,i.jsx)(M,{label:K("previousChange"),onClick:()=>er.current?.previousChange(),children:(0,i.jsx)(r.A,{className:"size-4"})}),(0,i.jsx)(M,{label:K("nextChange"),onClick:()=>er.current?.nextChange(),children:(0,i.jsx)(a.A,{className:"size-4"})}),f?null:(0,i.jsx)(M,{label:"side-by-side"===J?K("inlineDiff"):K("sideBySideDiff"),active:"inline"===J,onClick:()=>t.setDiffViewMode("side-by-side"===J?"inline":"side-by-side"),children:(0,i.jsx)(n.A,{className:"size-4"})}),(0,i.jsx)(M,{label:K(U?"wrapOff":"wrapOn"),active:U,onClick:()=>t.setDiffWrapLines(!U),children:(0,i.jsx)(o.A,{className:"size-4"})}),(0,i.jsx)(M,{label:K(G?"expandUnchanged":"collapseUnchanged"),active:G,onClick:()=>t.setDiffCollapseUnchanged(!G),children:(0,i.jsx)(l.A,{className:"size-4"})}),(0,i.jsx)(M,{label:K("reloadDiff"),onClick:()=>t.reloadDiff(),children:(0,i.jsx)(c.A,{className:"size-4"})})]}):(0,i.jsxs)(i.Fragment,{children:[ee&&Z?.status==="text"&&X?(0,i.jsx)("div",{className:"mr-auto flex shrink-0",role:"group","aria-label":K("markdown"===ee?"markdownMode":"htmlMode"),children:["preview","source"].map(e=>(0,i.jsx)(S.$,{variant:Z.viewMode===e?"secondary":"ghost",size:"sm","aria-pressed":Z.viewMode===e,onClick:()=>{eo(),t.setTextViewMode(X,e)},children:K("preview"===e?"previewMode":"sourceMode")},e))}):null,et&&ef?(0,i.jsx)("span",{"data-testid":"file-git-status",role:"status",className:"mr-auto min-w-0 truncate text-xs text-muted-foreground",title:ed?.status==="error"?ed.error:ef,children:f&&ed?.status==="ready"&&"number"==typeof ep?K("gitChangesCompact",{count:ep}):ef}):null,et&&ed?.status==="ready"?(0,i.jsxs)(i.Fragment,{children:["number"==typeof ep&&ep>0?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(M,{label:K("previousChange"),onClick:()=>ei.current?.previousChange(),children:(0,i.jsx)(r.A,{className:"size-4"})}),(0,i.jsx)(M,{label:K("nextChange"),onClick:()=>ei.current?.nextChange(),children:(0,i.jsx)(a.A,{className:"size-4"})})]}):null,(0,i.jsx)(M,{label:K("viewDiff"),onClick:()=>em(),children:(0,i.jsx)(d.A,{className:"size-4"})})]}):null,et&&X?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(M,{label:K("findInFile"),onClick:()=>ei.current?.openSearch(),children:(0,i.jsx)(u.A,{className:"size-4"})}),f?null:(0,i.jsx)(M,{label:K("goToLine"),onClick:()=>ei.current?.gotoLine(),children:(0,i.jsx)(h.A,{className:"size-4"})}),(0,i.jsx)(M,{label:K(U?"wrapOff":"wrapOn"),active:U,onClick:()=>t.setWrapLines(X,!U),children:(0,i.jsx)(o.A,{className:"size-4"})}),(0,i.jsx)(M,{label:K("copySelectionOrAll"),onClick:()=>{if(Z?.status!=="text")return;let e=ei.current?.getSelectionText()??"";(0,v.x)(e||Z.content).then(t=>{t?en.success(K(e?"selectedCodeCopied":"allCodeCopied")):en.error(K("copyContentFailed"))})},children:(0,i.jsx)(p.A,{className:"size-4"})})]}):null,X?(0,i.jsx)(M,{label:K("reloadCurrentFile"),onClick:el,children:(0,i.jsx)(c.A,{className:"size-4"})}):null]})}):null;return(0,i.jsxs)("div",{ref:es,className:"flex size-full min-h-0 min-w-0 flex-col outline-none",tabIndex:-1,onFocus:e=>{e.target===e.currentTarget&&(et?ei.current?.focus():Q?er.current?.focus():es.current?.querySelector('[data-testid="markdown-preview"]')?.focus())},children:[E?E(eg):eg?(0,i.jsx)("div",{className:"flex min-h-9 shrink-0 flex-wrap items-center justify-end gap-2 border-b px-3 py-1","aria-label":K("fileActions"),children:eg}):null,(0,i.jsx)("div",{className:"min-h-0 flex-1 overflow-hidden pb-[env(safe-area-inset-bottom)]",children:Q?"text"===Q.status?(0,i.jsx)(k,{ref:er,original:Q.original,modified:Q.modified,viewMode:f?"inline":J,savedState:Q.editorState,initialLine:Q.initialLine,onSaveState:e=>t.saveDiffState(Q,e),onEscape:w},(0,R.Q)(Q)):"metadata"===Q.status?(0,i.jsxs)("div",{className:"grid h-full grid-cols-1 gap-4 overflow-auto p-4 md:grid-cols-2",children:[(0,i.jsx)("pre",{className:"whitespace-pre-wrap break-all text-sm",children:Q.originalMetadata}),(0,i.jsx)("pre",{className:"whitespace-pre-wrap break-all text-sm",children:Q.modifiedMetadata})]}):"loading"===Q.status||"unloaded"===Q.status?(0,i.jsx)(L,{}):(0,i.jsxs)("div",{className:"flex size-full flex-col items-center justify-center gap-3 p-6 text-center text-sm",children:[(0,i.jsx)("p",{className:"text-muted-foreground",children:"binary"===Q.status?K("binaryDiffUnavailable"):"too_large"===Q.status?K("largeDiffUnavailable"):Q.error}),"error"===Q.status?(0,i.jsx)(S.$,{variant:"outline",onClick:()=>t.reloadDiff(),children:K("readAgain")}):null]}):X&&Z?"loading"===Z.status||"unloaded"===Z.status?(0,i.jsx)(L,{}):"error"===Z.status?(0,i.jsxs)("div",{className:"flex size-full flex-col items-center justify-center gap-3 p-6 text-center",children:[(0,i.jsx)("p",{role:"alert",className:"text-sm text-destructive",children:Z.error}),(0,i.jsx)(S.$,{variant:"outline",onClick:()=>t.reloadFile(X),children:K("readAgain")})]}):"image"===Z.status?(0,i.jsx)(N.k,{mode:"inline",slides:[{src:Z.objectUrl,alt:X}],ariaLabel:K("imageViewer",{name:X.replaceAll("\\","/").split("/").at(-1)??X})},Z.objectUrl):"markdown"===ee&&"preview"===Z.viewMode?(0,i.jsx)($.n,{content:Z.content,label:K("markdownPreview",{name:X}),savedScrollTop:Z.previewScrollTop,onScroll:e=>t.savePreviewScrollTop(X,e)},X):"html"===ee&&"preview"===Z.viewMode?(0,i.jsx)("iframe",{ref:ea,className:"block size-full border-0 bg-white",sandbox:"allow-scripts",srcDoc:(0,P.z)(Z.content),title:K("htmlPreview",{name:X})}):(0,i.jsx)(b.e,{ref:ei,path:X,content:Z.content,size:Z.size,originalContent:ed?.status==="ready"?ed.original.content:void 0,onChanges:e=>{ed?.status==="ready"&&eh({original:ed.original.content,modified:Z.content,count:e})},onOpenDiff:em,savedState:Z.editorState,navigation:t.pendingNavigation,onNavigation:(e,s)=>t.consumeNavigation(e,s),onSaveState:(e,s)=>t.saveEditorState(e,s),onEscape:w},X):(0,i.jsxs)("div",{"data-testid":"file-workspace-empty",className:"flex size-full flex-col items-center justify-center gap-3 p-6 text-sm text-muted-foreground",children:[(0,i.jsx)(m.A,{className:"size-6"}),K("noOpenFile")]})})]})}function L(){let{t:e}=(0,x.Bd)("projectFiles");return(0,i.jsxs)("div",{className:"flex size-full items-center justify-center gap-2 text-sm text-muted-foreground",children:[(0,i.jsx)(f.A,{className:"size-4 animate-spin"}),e("loadingFile")]})}},73165:(e,t,s)=>{"use strict";s.d(t,{D:()=>d});var i=s(7962),r=s(60454),a=s(93750),n=s(74675),o=s(1364),l=s(49426),c=s(13464);function d({children:e}){return(0,i.jsx)(o.JW,{children:(0,i.jsx)(r.y,{className:"isolate z-[130] outline-none",side:"right",align:"start",alignOffset:4,children:(0,i.jsx)(a._,{"data-slot":"context-menu-content",finalFocus:!1,className:(0,l.cn)(c.hD,"flex flex-col overflow-hidden p-0"),children:(0,i.jsx)(n.V,{className:"min-h-0",viewportClassName:"p-1",children:e})})})})}},73429:(e,t,s)=>{"use strict";s.d(t,{p:()=>n});var i=s(7962);s(69266);var r=s(53555),a=s(49426);function n({className:e,type:t,...s}){return(0,i.jsx)(r.p,{type:t,"data-slot":"input",className:(0,a.cn)("min-h-8 w-full min-w-0 rounded-lg border border-input bg-card px-2.5 py-1 text-sm leading-5 transition-colors duration-150 outline-none file:inline-flex file:h-6 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:outline-2 focus-visible:outline-solid focus-visible:-outline-offset-2 focus-visible:outline-ring disabled:pointer-events-none disabled:cursor-not-allowed disabled:bg-muted disabled:opacity-50 aria-invalid:border-destructive aria-invalid:outline-destructive",e),...s})}},74675:(e,t,s)=>{"use strict";s.d(t,{V:()=>u});var i=s(7962);s(69266);var r=s(82611),a=s(40709),n=s(51173),o=s(49426),l=s(93061),c=s(87425);function d({className:e,orientation:t="vertical",...s}){return(0,i.jsx)(l.V,{"data-slot":"scroll-area-scrollbar","data-orientation":t,orientation:t,className:(0,o.cn)("flex touch-none p-px transition-colors select-none data-horizontal:h-2.5 data-horizontal:flex-col data-horizontal:border-t data-horizontal:border-t-transparent data-vertical:h-full data-vertical:w-2.5 data-vertical:border-l data-vertical:border-l-transparent",e),...s,children:(0,i.jsx)(c.l,{"data-slot":"scroll-area-thumb",className:"relative flex-1 rounded-full bg-border"})})}function u({className:e,viewportClassName:t,viewportRef:s,onViewportScroll:l,children:c,...h}){return(0,i.jsxs)(r.V,{"data-slot":"l4-scroll-area",className:(0,o.cn)("relative min-h-0 overflow-hidden",e),...h,children:[(0,i.jsx)(a.B,{ref:s,"data-slot":"l4-scroll-area-viewport",className:(0,o.cn)("size-full rounded-[inherit] outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1",t),onScroll:l,children:c}),(0,i.jsx)(d,{className:"data-[orientation=vertical]:h-full data-[orientation=vertical]:w-2.5 data-[orientation=vertical]:border-l data-[orientation=vertical]:border-l-transparent"}),(0,i.jsx)(n.I,{})]})}},79137:(e,t,s)=>{"use strict";async function i(e){let t="u"<typeof navigator?void 0:navigator.clipboard;if(t?.writeText)try{return await t.writeText(e),!0}catch{}if("u"<typeof document||!document.body)return!1;let s=document.activeElement instanceof HTMLElement?document.activeElement:null,i=document.createElement("textarea");i.value=e,i.setAttribute("readonly",""),i.setAttribute("aria-hidden","true"),i.style.position="fixed",i.style.top="-9999px",i.style.left="-9999px",i.style.width="1px",i.style.height="1px",i.style.opacity="0";try{return document.body.append(i),i.select(),i.setSelectionRange(0,i.value.length),document.execCommand("copy")}catch{return!1}finally{i.remove();try{s?.focus()}catch{}}}s.d(t,{h3:()=>i,qj:()=>r});class r extends Error{constructor(e){super(e.message,{cause:e.cause}),this.name="PiDeskBrowserPluginError",this.pluginName=e.pluginName,this.contributionName=e.contributionName??null,this.phase=e.phase}}},80077:(e,t,s)=>{"use strict";s.d(t,{Gm:()=>l,Jk:()=>o});var i=s(38979),r=s(66453),a=s(70698);let n=i.k5(["title","user","assistant","sessionId"]),o=i.Ik({scope:n,count:i.ai().int().positive(),entryId:r.Rv.nullable(),timestampMs:a.k.nullable(),preview:i.Yj().min(1).max(160)}).strict(),l=i.Ik({query:i.Yj().trim().max(120).default(""),searchIn:i.YO(n).min(1).max(4).default(["title","user"])}).strict()},81649:(e,t,s)=>{"use strict";s.d(t,{Ke:()=>c,Nt:()=>o,R6:()=>l});var i=s(7962),r=s(87946),a=s(36700),n=s(14064);function o({...e}){return(0,i.jsx)(r.N,{"data-slot":"collapsible",...e})}function l({...e}){return(0,i.jsx)(a.R,{"data-slot":"collapsible-trigger",...e})}function c({...e}){return(0,i.jsx)(n.j,{"data-slot":"collapsible-content",...e})}},82075:(e,t,s)=>{"use strict";function i(e,t){return`${e}:${t}`}function r(e,t){return e?`${e}/${t}`:t}function a(e,t){return e.localeCompare(t,void 0,{numeric:!0,sensitivity:"base"})}function n(e,t,s=new Set){let i=[e],r=e;for(;!s.has(r);){let e=t(r);if(!e||s.has(e)||!e.startsWith(`${r}/`))break;i.push(e),r=e}return{path:e,targetPath:r,paths:i,label:r.slice(e.lastIndexOf("/")+1)}}function o(e,t=""){let s={path:t,directories:new Map,files:[]},i=new Map([[t,s]]);for(let a of e){let e=(t?a.slice(t.length+1):a).split("/"),n=s;for(let t of e.slice(0,-1)){let e=r(n.path,t),s=i.get(e);s||(s={path:e,directories:new Map,files:[]},i.set(e,s),n.directories.set(e,s)),n=s}n.files.push(a)}return i}function l(e,t,s){return n(e,e=>{let s=t.get(e);return s&&0===s.files.length&&1===s.directories.size?s.directories.keys().next().value??null:null},s)}function c(e,t,s=""){let r=[],n=(s,o)=>{let c=e.get(s);if(c){for(let s of[...c.directories.keys()].sort(a)){let a=l(s,e),c=!a.paths.some(e=>t.has(e));r.push({key:i("directory",s),type:"directory",path:a.targetPath,label:a.label,depth:o,directory:a,expanded:c}),c&&n(a.targetPath,o+1)}for(let e of[...c.files].sort(a))r.push({key:i("file",e),type:"file",path:e,label:e.slice(e.lastIndexOf("/")+1),depth:o})}};return n(s,0),r}s.d(t,{Im:()=>i,Kn:()=>a,OA:()=>o,_J:()=>r,qV:()=>c,rk:()=>n,xV:()=>l})},83029:e=>{e.exports={markdown:"l4-markdown_markdown__oIf6d",status:"l4-markdown_status__EVcKw",alert:"l4-markdown_alert__Aooao",alertTitle:"l4-markdown_alertTitle__GIoFs",alertBody:"l4-markdown_alertBody__BtDVT"}},86062:(e,t,s)=>{"use strict";s.d(t,{T8:()=>g,WW:()=>x,aD:()=>n,co:()=>h,lw:()=>v,ph:()=>f,xv:()=>d,yw:()=>p});var i=s(38979),r=s(67765),a=s(24985);let n=i.Yj().regex(/^(?:[0-9a-f]{40}|[0-9a-f]{64})$/),o=i.KC([n,i.eu("HEAD"),i.Yj().max(1024).regex(/^refs\/(?:heads|remotes)\/[^\0\r\n]+$/)]).refine(e=>!e.includes("..")&&!e.endsWith("/"),"Git 版本无效"),l=i.KC([i.Ik({commit:o,parent:n.optional()}).strict(),i.Ik({base:o,target:o,strategy:i.k5(["merge-base","direct"])}).strict()]),c=i.Ik({base:n.nullable(),target:n,original:n.nullable()}).strict(),d=i.Ik({baseCommit:n.nullable(),targetCommit:n,oldPath:r._g.optional()}).strict(),u=i.Ik({oid:n,parents:i.YO(n),subject:i.Yj(),author:i.Yj(),timestampMs:i.ai().int(),refs:i.YO(i.Yj())}).strict(),h=i.Ik({tip:o,exclude:o.optional(),query:i.Yj().trim().max(200).default(""),author:i.Yj().trim().max(200).optional(),page:i.Ik({index:i.ai().int().min(1).max(2e3),size:i.ai().int().min(1).max(100)}).strict()}).strict(),p=i.Ik({tip:n.nullable(),exclude:n.nullable(),items:i.YO(u),hasMore:i.zM(),truncated:i.zM()}).strict(),m=i.Ik({path:r._g,oldPath:r._g.nullable(),status:i.k5(["added","modified","deleted","renamed","type-changed"])}).strict(),f=i.Ik({selection:l,page:i.Ik({index:i.ai().int().min(1).max(5e4),size:i.ai().int().min(1).max(500)}).strict()}).strict(),g=i.Ik({comparison:c,commit:u.extend({message:i.Yj(),selectedParent:n.nullable()}).nullable(),items:i.YO(m),hasMore:i.zM(),truncated:i.zM()}).strict(),x=a.gf.extend({upstream:i.Ik({ref:i.Yj(),ahead:i.ai().int().nonnegative().nullable(),behind:i.ai().int().nonnegative().nullable()}).strict().nullable()}).strict(),v=i.KC([a.FJ,i.Ik({kind:i.eu("metadata"),original:i.Yj(),modified:i.Yj()}).strict()])},86963:(e,t,s)=>{"use strict";s.d(t,{$:()=>l,r:()=>o});var i=s(7962),r=s(28549),a=s(73392),n=s(49426);let o=(0,a.F)("group/button inline-flex shrink-0 items-center justify-center rounded-lg border border-transparent bg-clip-padding text-sm font-medium whitespace-nowrap cursor-pointer transition-colors duration-150 ease-out outline-none select-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-solid focus-visible:outline-ring disabled:pointer-events-none disabled:opacity-50 aria-pressed:bg-accent aria-pressed:text-accent-foreground aria-pressed:hover:bg-[color-mix(in_oklab,var(--accent),var(--foreground)_5%)] aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-[color-mix(in_oklab,var(--primary),var(--primary-foreground)_8%)] active:bg-[color-mix(in_oklab,var(--primary),var(--primary-foreground)_14%)]",outline:"border-border bg-card text-card-foreground hover:bg-accent active:bg-[color-mix(in_oklab,var(--accent),var(--foreground)_6%)] aria-expanded:bg-accent aria-expanded:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-[color-mix(in_oklab,var(--secondary),var(--foreground)_8%)] active:bg-[color-mix(in_oklab,var(--secondary),var(--foreground)_14%)] aria-expanded:bg-accent aria-expanded:text-accent-foreground",ghost:"hover:bg-foreground/8 hover:text-foreground active:bg-foreground/14 aria-expanded:bg-accent aria-expanded:text-accent-foreground",destructive:"bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40",link:"text-foreground underline underline-offset-4 hover:text-muted-foreground"},size:{default:"min-h-8 gap-2 px-2 py-1",xs:"min-h-7 gap-2 rounded-md px-2 py-0.5 text-sm",sm:"min-h-7 gap-2 rounded-md px-2 py-0.5 text-sm",lg:"min-h-10 gap-2 px-3 py-2",icon:"size-8","icon-xs":"size-7 rounded-md","icon-sm":"size-7 rounded-md","icon-lg":"size-10"}},defaultVariants:{variant:"default",size:"default"}});function l({className:e,variant:t="default",size:s="default",...a}){return(0,i.jsx)(r.$,{"data-slot":"button",className:(0,n.cn)(o({variant:t,size:s,className:e})),...a})}},89790:(e,t,s)=>{"use strict";s.d(t,{G7:()=>d,L$:()=>p,h_:()=>m,oI:()=>u,uB:()=>c,xL:()=>h});var i=s(7962);s(69266);var r=s(30442),a=s(49426);s(5464);var n=s(17511),o=s(41148),l=s(90458);function c({className:e,...t}){return(0,i.jsx)(r.uB,{"data-slot":"command",className:(0,a.cn)("flex size-full flex-col overflow-hidden rounded-lg bg-popover p-1 text-popover-foreground",e),...t})}function d({className:e,...t}){return(0,i.jsx)("div",{"data-slot":"command-input-wrapper",className:"p-1 pb-0",children:(0,i.jsxs)(n.MG,{className:"has-[[data-slot=command-input]:focus-visible]:outline-2 has-[[data-slot=command-input]:focus-visible]:outline-solid has-[[data-slot=command-input]:focus-visible]:-outline-offset-2 has-[[data-slot=command-input]:focus-visible]:outline-ring",children:[(0,i.jsx)(r.uB.Input,{"data-slot":"command-input",className:(0,a.cn)("min-h-8 w-full bg-transparent px-2.5 text-sm leading-5 outline-none disabled:cursor-not-allowed disabled:opacity-50",e),...t}),(0,i.jsx)(n.Sq,{children:(0,i.jsx)(o.A,{className:"size-4 shrink-0 opacity-50"})})]})})}function u({className:e,...t}){return(0,i.jsx)(r.uB.List,{"data-slot":"command-list",className:(0,a.cn)("pi-desk-chat-scrollbar max-h-72 scroll-py-1 overflow-x-hidden overflow-y-auto outline-none",e),...t})}function h({className:e,...t}){return(0,i.jsx)(r.uB.Empty,{"data-slot":"command-empty",className:(0,a.cn)("py-6 text-center text-sm",e),...t})}function p({className:e,...t}){return(0,i.jsx)(r.uB.Group,{"data-slot":"command-group",className:(0,a.cn)("overflow-hidden p-1 text-foreground **:[[cmdk-group-heading]]:px-2 **:[[cmdk-group-heading]]:py-1.5 **:[[cmdk-group-heading]]:text-xs **:[[cmdk-group-heading]]:font-medium **:[[cmdk-group-heading]]:text-muted-foreground",e),...t})}function m({className:e,children:t,...s}){return(0,i.jsxs)(r.uB.Item,{"data-slot":"command-item",className:(0,a.cn)("group/command-item relative flex min-h-8 cursor-pointer items-center gap-2 rounded-md px-2 py-1 text-sm leading-5 outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 data-[selected=true]:*:[svg]:text-foreground",e),...s,children:[t,(0,i.jsx)(l.A,{className:"ml-auto opacity-0 group-has-data-[slot=command-shortcut]/command-item:hidden group-data-[checked=true]/command-item:opacity-100"})]})}},90064:e=>{e.exports={host:"l4-code-line-markers_host__BBo2H",added:"l4-code-line-markers_added__oTNsK",modified:"l4-code-line-markers_modified__PZnY_",deletedBefore:"l4-code-line-markers_deletedBefore___1b0w",deletedAfter:"l4-code-line-markers_deletedAfter__SEoHy"}},90434:(e,t,s)=>{"use strict";s.d(t,{AM:()=>u,Wv:()=>h,eO:()=>m,hl:()=>p});var i=s(7962);s(69266);var r=s(50960),a=s(40252),n=s(17596),o=s(80168),l=s(40287),c=s(76624),d=s(49426);function u({...e}){return(0,i.jsx)(r.y,{"data-slot":"popover",...e})}function h({...e}){return(0,i.jsx)(a.W,{"data-slot":"popover-trigger",...e})}function p({className:e,positionerClassName:t,align:s="center",alignOffset:r=0,side:a="bottom",sideOffset:c=4,finalFocus:u=!1,...h}){return(0,i.jsx)(n.i,{children:(0,i.jsx)(o.U,{align:s,alignOffset:r,side:a,sideOffset:c,className:(0,d.cn)("isolate z-50",t),children:(0,i.jsx)(l.i,{"data-slot":"popover-content",finalFocus:u,className:(0,d.cn)("z-50 flex w-80 max-w-[calc(100vw-2rem)] origin-(--transform-origin) flex-col gap-3 rounded-lg border border-border bg-popover p-3 text-sm text-popover-foreground shadow-md outline-hidden duration-100 motion-reduce:animate-none data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",e),...h})})})}function m({className:e,...t}){return(0,i.jsx)(c.e,{"data-slot":"popover-title",className:(0,d.cn)("font-medium",e),...t})}},90504:(e,t,s)=>{"use strict";s.d(t,{e:()=>h});var i=s(7962),r=s(14044),a=s(69266),n=s(78121),o=s(91182),l=s(18302),c=s(33550),d=s(90064),u=s.n(d);let h=(0,a.forwardRef)(function({path:e,content:t,size:d,savedState:h,onSaveState:p,onEscape:m,originalContent:f,onChanges:g,onOpenDiff:x,navigation:v,onNavigation:b},y){let{t:w}=(0,n.Bd)("common"),{t:j}=(0,n.Bd)("projectFiles"),{wrapLines:k}=(0,c.TX)(),N=(0,a.useRef)(null),C=(0,a.useRef)(null),S=(0,a.useRef)(p),R=(0,a.useRef)(k),z=(0,a.useRef)(h),D=(0,a.useRef)(m),A=(0,a.useRef)(null),M=(0,a.useRef)(g),P=(0,a.useRef)(x),$=(0,a.useRef)(b),T=(0,a.useRef)(null),O=(0,a.useRef)(null),L=(0,a.useCallback)(e=>{let t=O.current;T.current?.clear(),null===t||t>(e.getModel()?.getLineCount()??0)||(T.current??=e.createDecorationsCollection(),T.current.set([{range:{startLineNumber:t,startColumn:1,endLineNumber:t,endColumn:1},options:{isWholeLine:!0,className:"bg-accent"}}]))},[]);(0,a.useEffect)(()=>{z.current=h,D.current=m,M.current=g,P.current=x,$.current=b},[g,m,x,b,h]);let[E,I]=(0,a.useState)("loading");return(0,a.useEffect)(()=>{S.current=p},[p]),(0,a.useEffect)(()=>{R.current=k},[k]),(0,a.useImperativeHandle)(y,()=>({openSearch(){C.current?.getAction("actions.find")?.run()},gotoLine(){C.current?.getAction("editor.action.gotoLine")?.run()},getSelectionText(){let e=C.current,t=e?.getModel(),s=e?.getSelection();return t&&s&&!s.isEmpty()?t.getValueInRange(s):""},getViewState:()=>C.current?.saveViewState()??null,focus(){C.current?.focus()},previousChange(){A.current?.previousChange()},nextChange(){A.current?.nextChange()}}),[]),(0,a.useEffect)(()=>{let i=N.current;if(!i)return;let r=!0,a=null,n=null,c=null,h=()=>void 0,p=()=>void 0;return queueMicrotask(()=>{r&&I("loading")}),(0,o.cu)().then(m=>{r&&(n=m.editor.createModel(t,(0,o.ix)(e,d),(0,o.B3)(m,e,"preview")),a=m.editor.create(i,{model:n,theme:(0,o.dC)(),readOnly:!0,domReadOnly:!0,editContext:!1,automaticLayout:!0,minimap:{enabled:!1},stickyScroll:{enabled:!1},scrollBeyondLastLine:!1,smoothScrolling:!1,wordWrap:R.current?"on":"off",wrappingIndent:"same",...(0,o.R)(),lineNumbersMinChars:3,lineDecorationsWidth:26,folding:d<=1048576,renderValidationDecorations:"off",renderWhitespace:"selection",bracketPairColorization:{enabled:d<=1048576},unicodeHighlight:{nonBasicASCII:!1},padding:{top:10,bottom:10},overviewRulerBorder:!1,contextmenu:!0,ariaLabel:w("codeReadOnly")}),z.current&&a.restoreViewState(z.current),D.current&&(0,l.e)(a,m.KeyCode.Escape,()=>D.current?.()),C.current=a,void 0!==f&&(A.current=c=function(e,t,i){let r=e.createDecorationsCollection(),a=e.getModel()?.getLineCount()??1,n=[],o=!0,l=null,c=null,d=[u().added,u().modified,u().deletedBefore,u().deletedAfter].map(e=>`.${e}`).join(","),h=e=>Math.min(a,"deleted"===e.kind?Math.max(1,e.modifiedStartLineNumber-1):e.modifiedStartLineNumber),p=()=>{null!==c&&clearTimeout(c),c=null,l?.terminate(),l=null},m=e=>{o&&(p(),n=e??[],r.set(n.map(e=>{let s="deleted"===e.kind,r=h(e),a=s?r:e.modifiedEndLineNumberExclusive-1,n=s?e.originalEndLineNumberExclusive-e.originalStartLineNumber:e.modifiedEndLineNumberExclusive-e.modifiedStartLineNumber,o={added:["#16803c","#59c77b"],modified:["#216bcc","#6aabff"],deleted:["#d12c38","#ff757f"]}[e.kind],l=s?1===e.modifiedStartLineNumber?u().deletedBefore:u().deletedAfter:u()[e.kind];return{range:new t.Range(r,1,a,1),options:{isWholeLine:!s,showIfCollapsed:!0,linesDecorationsClassName:s?void 0:l,firstLineDecorationClassName:s?l:void 0,linesDecorationsTooltip:i.tooltip(e.kind,n),overviewRuler:{color:o[0],darkColor:o[1],position:t.editor.OverviewRulerLane.Left}}}})),null===e&&console.warn("[Pi Desk][CodePreview] 行标记不可用,计算失败或超过限制",{path:i.path}),i.onChanges(e?.length??null))},f=e.onMouseDown(e=>{if(e.target.type!==t.editor.MouseTargetType.GUTTER_LINE_DECORATIONS||!e.target.element?.closest(d))return;let s=e.target.position?.lineNumber;void 0===s||n.find(e=>"deleted"===e.kind?h(e)===s:e.modifiedStartLineNumber<=s&&s<e.modifiedEndLineNumberExclusive)&&i.onOpenDiff(s)});try{(l=new Worker(s.tu(new URL(s.p+s.u(58779),s.b)),{type:void 0,name:"pi-desk-line-changes"})).onmessage=e=>m(e.data),l.onerror=()=>m(null),l.onmessageerror=()=>m(null),c=setTimeout(()=>m(null),3e3),l.postMessage({original:i.original,modified:i.modified})}catch{m(null)}let g=t=>{if(0===n.length)return;let s=e.getPosition()?.lineNumber??1,i=n.map(h),r="next"===t?i.find(e=>e>s)??i[0]:i.findLast(e=>e<s)??i[i.length-1];e.setPosition({lineNumber:r,column:1}),e.revealLineInCenter(r),e.focus()};return{previousChange(){g("previous")},nextChange(){g("next")},dispose(){o=!1,p(),f.dispose(),r.clear(),n=[]}}}(a,m,{path:e,original:f,modified:t,tooltip:(e,t)=>j({added:"gitAddedLines",modified:"gitModifiedLines",deleted:"gitDeletedLines"}[e],{count:t}),onChanges:e=>M.current?.(e),onOpenDiff:e=>P.current?.(e)})),h=(0,o.Tr)(e=>m.editor.setTheme(e)),p=(0,o.BK)(e=>a?.updateOptions(e)),L(a),I("ready"))}).catch(t=>{r&&(console.error("[Pi Desk][CodePreview] Monaco 加载失败",{path:e,errorName:t instanceof Error?t.name:"UnknownError"}),I("error"),void 0!==f&&M.current?.(null))}),()=>{r=!1,h(),p(),c?.dispose(),A.current=null,a&&(z.current=a.saveViewState(),S.current(e,z.current)),T.current?.clear(),T.current=null,C.current=null,a?.dispose(),n?.dispose()}},[t,f,L,e,j,d,w]),(0,a.useEffect)(()=>{C.current?.updateOptions({wordWrap:k?"on":"off"})},[k]),(0,a.useEffect)(()=>{let t=C.current;if(!v||"ready"!==E||!t)return;let s=t.getModel(),i=!!(s&&v.line>=1&&v.line<=s.getLineCount());O.current=i?v.line:null,L(t),i&&(t.setPosition({lineNumber:v.line,column:1}),t.revealLineInCenter(v.line),z.current=t.saveViewState(),S.current(e,z.current)),$.current?.(v,i)},[E,v,L,e]),(0,i.jsxs)("div",{"data-testid":"code-preview",className:"relative h-full min-h-0 w-full overflow-hidden bg-background",children:[(0,i.jsx)("div",{ref:N,className:`size-full ${u().host}`}),"loading"===E?(0,i.jsxs)("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center gap-2 bg-background text-sm text-muted-foreground",children:[(0,i.jsx)(r.A,{className:"size-4 animate-spin"})," ",w("codeLoading")]}):null,"error"===E?(0,i.jsx)("div",{className:"absolute inset-0 flex items-center justify-center p-6 text-center text-sm text-destructive",children:w("codeFailed")}):null]})})},91182:(e,t,s)=>{"use strict";s.d(t,{B3:()=>h,BK:()=>n,R:()=>a,Tr:()=>u,cu:()=>c,dC:()=>d,ix:()=>p});var i=s(67765),r=s(48708);function a(){let e=Number.parseFloat(getComputedStyle(document.documentElement).fontSize)/16;return{fontFamily:'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace',fontSize:14*e,lineHeight:Math.round(22*e)}}function n(e){let t=new MutationObserver(()=>e(a()));return t.observe(document.documentElement,{attributes:!0,attributeFilter:["data-pi-desk-display-size"]}),()=>t.disconnect()}let o=null,l=0;function c(){return o||(o=(async()=>{(0,r.fx)()?.locale==="zh-CN"&&await s.e(12212).then(s.t.bind(s,12212,23));let{monaco:e}=await Promise.all([s.e(87221),s.e(46550),s.e(62134),s.e(38459),s.e(95287),s.e(54206),s.e(87086)]).then(s.bind(s,87086));return globalThis.MonacoEnvironment={getWorker:(e,t)=>new Worker(s.tu(new URL(s.p+s.u(53291),s.b)),{type:void 0,name:t})},e})())}function d(){return document.documentElement.classList.contains("dark")?"vs-dark":"vs"}function u(e){let t=new MutationObserver(()=>e(d()));return t.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>t.disconnect()}function h(e,t,s){l+=1;let i=t.split("/").map(e=>encodeURIComponent(e)).join("/");return e.Uri.parse(`inmemory://pi-desk/${l}/${s}/${i}`)}function p(e,t){if(t>i.gB)return"plaintext";let s=e.replaceAll("\\","/").split("/").at(-1)?.toLocaleLowerCase()??"";return"dockerfile"===s?"dockerfile":"makefile"===s?"plaintext":({bat:"bat",c:"c",cc:"cpp",cjs:"javascript",cpp:"cpp",cs:"csharp",css:"css",dockerfile:"dockerfile",go:"go",h:"cpp",hpp:"cpp",htm:"html",html:"html",ini:"ini",java:"java",js:"javascript",json:"javascript",jsonl:"javascript",jsx:"javascript",kt:"kotlin",less:"less",lua:"lua",md:"markdown",mdx:"markdown",mjs:"javascript",php:"php",ps1:"powershell",py:"python",rb:"ruby",rs:"rust",scss:"scss",sh:"shell",sql:"sql",swift:"swift",toml:"ini",ts:"typescript",tsx:"typescript",txt:"plaintext",xml:"xml",yaml:"yaml",yml:"yaml"})[s.includes(".")?s.split(".").at(-1)??"":""]??"plaintext"}},93119:(e,t,s)=>{"use strict";s.d(t,{$:()=>n,P:()=>a});var i=s(94853),r=s(93320);async function a(e,t,s,a){await (0,r.QL)(e,i.Ot,{...t,path:s,targetType:a})}function n(e,t){let s=/^[a-zA-Z]:[\\/]/.test(e)||e.startsWith("\\\\"),i=s?"\\":"/",r=(s?e.replaceAll("/","\\"):e).replace(/[\\/]+$/,"");return t?`${r}${i}${t.replaceAll("/",i)}`:/^[a-z]:$/i.test(r)?`${r}${i}`:r||i}},93320:(e,t,s)=>{"use strict";s.d(t,{QL:()=>n,Y4:()=>o,aw:()=>a});var i=s(73230),r=s(94853);class a extends Error{constructor(e,t,s,i=null){super(s),this.status=e,this.code=t,this.errorKey=i,this.name="L3ProjectRequestError"}}async function n(e,t,s,r){let n=await fetch(t.path,{method:"POST",headers:{"Content-Type":"application/json","X-Pi-Desk-Client-Id":e},body:JSON.stringify(t.request.parse(s)),signal:r}),o=await n.json();if(!n.ok||0!==o.code||null===o.data)throw new a(n.status,o.code,o.msg?(0,i.B)(o):"项目读取失败",o.i18n?.key??null);return t.response.parse(o.data)}function o(e,t,s){async function i(t,i,r){try{return await n(e,t,i,r)}catch(e){throw!r?.aborted&&e instanceof a&&401===e.status&&s?.(),e}}return{list:(e,s)=>i(r.Xe,{...t,path:e},s),search:(e,s)=>i(r.fg,{...t,...e},s),get:(e,s,a)=>i(r.ZI,{...t,path:e,imagePreviewMode:s},a),snapshot:(e,s)=>i(r.p0,{...t,refresh:s},e),branches:(e,s)=>i(r.ry,{...t,repositoryRoot:e},s),log:(e,s,a)=>i(r.p3,{...t,repositoryRoot:e,...s},a),changes:(e,s,a)=>i(r.ys,{...t,repositoryRoot:e,...s},a),diff:(e,s,a,n)=>i(r.OC,{...t,repositoryRoot:e,path:s,comparison:n},a)}}},94853:(e,t,s)=>{"use strict";s.d(t,{OC:()=>y,Ot:()=>u,Xe:()=>h,ZI:()=>m,_X:()=>g,fg:()=>p,p0:()=>f,p3:()=>v,ry:()=>x,ys:()=>b});var i=s(38979),r=s(67765),a=s(24985),n=s(86062);let o=i.Ik({cwd:i.Yj().trim().min(1).max(4096),workId:i.Yj().trim().min(1).optional()}).strict(),l=o.extend({repositoryRoot:r.rh}),c=o.extend({path:r.eC,imagePreviewMode:r.p$}).superRefine((e,t)=>{e.workId||r._g.safeParse(e.path).success||t.addIssue({code:"custom",path:["path"],message:"独立项目预览只接受根内相对路径"})}),d=i.k5(["file","directory"]),u={path:"/api/project-files/reveal",request:o.extend({path:i.KC([r.rh,r.eC]),targetType:d.optional()}).refine(e=>""!==e.path||"directory"===e.targetType,"文件路径不能为空").refine(e=>e.workId&&"directory"!==e.targetType||r.rh.safeParse(e.path).success,"独立项目和目录定位只接受根内相对路径"),response:i.Ik({}).strict()},h={path:"/api/project-files/list",request:o.extend({path:r.rh}).strict(),response:r.JH},p={path:"/api/project-files/search",request:o.extend(r.Nu.shape).strict(),response:r.jI},m={path:"/api/project-files/get",request:c,response:r.ih},f={path:"/api/project-git/get",request:o.extend({refresh:i.zM().optional()}).strict(),response:i.Ik({repositories:i.YO(a.u2).max(100)}).strict()},g={path:"/api/project-git-heads/get",request:o,response:i.Ik({repositories:i.YO(a.yl).max(a.y2)}).strict()},x={path:"/api/project-git-branches/list",request:l.strict(),response:n.WW},v={path:"/api/project-git-log/list",request:l.extend(n.co.shape).strict(),response:n.yw},b={path:"/api/project-git-changes/list",request:l.extend(n.ph.shape).strict(),response:n.T8},y={path:"/api/project-git-diff/get",request:l.extend({path:r._g,comparison:n.xv.optional()}).strict(),response:n.lw}},97921:(e,t,s)=>{"use strict";function i(e){return/\.(md|markdown)$/i.test(e)?"markdown":/\.html?$/i.test(e)?"html":null}s.d(t,{g:()=>i})},99084:(e,t,s)=>{"use strict";s.d(t,{x:()=>r});var i=s(79137);function r(e){return(0,i.h3)(e)}}}]);
15
+ ${s.author} \xb7 ${p.format(s.timestampMs)}`,children:[(0,i.jsxs)("span",{className:"min-w-0 flex-1 truncate",children:[s.subject||l("noCommitMessage"),s.refs.length?(0,i.jsx)("span",{className:"ml-2 text-xs text-muted-foreground",children:s.refs.join(" \xb7 ")}):null]}),(0,i.jsx)("span",{className:"shrink-0 font-mono text-xs text-muted-foreground",children:s.oid.slice(0,7)}),n?null:(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("span",{className:"w-20 truncate text-xs text-muted-foreground",children:s.author}),(0,i.jsx)("time",{className:"w-28 shrink-0 text-right text-xs text-muted-foreground",children:h.format(s.timestampMs)})]})]},s.oid)},`${t.repositoryRoot}:${t.mode}:${t.tip}:${t.base}:${t.target}:${t.query}:${t.author}`)}),R=(0,i.jsxs)("div",{className:"flex size-full min-h-0 min-w-0 flex-col",children:[(0,i.jsxs)("div",{className:"flex min-h-9 shrink-0 flex-wrap items-center gap-2 border-b px-3 py-1",children:[n?(0,i.jsx)(g.$,{variant:"ghost",size:"icon-sm","aria-label":l("backCommits"),onClick:()=>v("log"),children:(0,i.jsx)(D.A,{className:"size-4"})}):null,(0,i.jsx)("span",{className:"text-sm font-medium",children:t.selectedCommit?l("commitChanges"):l("cumulativeChanges")}),b?(0,i.jsx)("span",{className:"text-xs text-muted-foreground",children:l("loadedFiles",{count:b.items.length})}):null,"compare"===t.mode&&t.selectedCommit?(0,i.jsx)(g.$,{variant:"ghost",size:"sm",onClick:e.onAggregate,children:l("backCumulative")}):null]}),C(t.changes.error),"loading"===t.changes.status?(0,i.jsxs)("div",{className:"flex items-center gap-2 p-3 text-xs text-muted-foreground",children:[(0,i.jsx)(z.A,{className:"size-4 animate-spin"}),l("loadingChanges")]}):null,(0,i.jsxs)(f.HK,{orientation:"vertical",defaultLayout:{"project-changes":e.panelSizes.changes,"project-detail":100-e.panelSizes.changes},onLayoutChanged:(t,s)=>{s.isUserInteraction&&void 0!==t["project-changes"]&&e.onPanelSize("changes",t["project-changes"])},children:[(0,i.jsx)(f.wV,{id:"project-changes",defaultSize:`${e.panelSizes.changes}%`,minSize:"80px",children:(0,i.jsxs)("div",{className:"flex size-full min-h-0 flex-col",children:[(0,i.jsx)(H,{cwd:e.cwd,repositoryRoot:t.repositoryRoot??"",rows:e.changeRows,rowHeight:e.changeRowHeight,changes:b?.items??[],selectedPath:w,scrollTop:o.changes,onScroll:t=>e.onScroll("changes",t),onSelect:e.onSelectChange,onToggle:e.onToggleDirectory,onOpen:e.onOpenFile,onReveal:e.onReveal},y),"ready"!==t.changes.status||b?.items.length?null:(0,i.jsx)("p",{className:"px-3 py-4 text-sm text-muted-foreground",children:l("noDiff")}),b?.hasMore?(0,i.jsx)(g.$,{size:"sm",variant:"ghost",disabled:"loading"===t.changes.status,onClick:e.onMoreChanges,children:l("loadMoreFiles")}):null,b?.truncated?(0,i.jsx)("p",{className:"p-3 text-xs text-muted-foreground",children:l("changesLimit")}):null]})}),(0,i.jsx)(f.WM,{disableDoubleClick:!0}),(0,i.jsx)(f.wV,{id:"project-detail",defaultSize:`${100-e.panelSizes.changes}%`,minSize:"60px",children:(0,i.jsxs)($.V,{className:"h-full",viewportClassName:"p-3 text-sm",role:"region","aria-label":l("commitDetails"),children:[N?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("pre",{className:"mb-3 whitespace-pre-wrap break-words font-sans leading-relaxed",children:N.message}),(0,i.jsxs)("div",{className:"mb-2 flex items-center gap-2",children:[(0,i.jsx)("span",{className:"min-w-0 flex-1 break-all font-mono text-xs",children:N.oid}),(0,i.jsx)(g.$,{size:"icon-sm",variant:"ghost","aria-label":l("copySha"),onClick:()=>e.onCopy(N.oid),children:(0,i.jsx)(A.A,{className:"size-4"})})]}),(0,i.jsxs)("p",{className:"mb-3 text-xs text-muted-foreground",children:[N.author," \xb7 ",p.format(N.timestampMs)]}),N.parents.length>1?(0,i.jsx)(O.b,{className:"mb-3",ariaLabel:l("compareParent"),value:N.selectedParent??"",options:N.parents.map((e,t)=>({value:e,label:l("parentCommit",{count:t+1,oid:e.slice(0,10)})})),onChange:t=>e.onCommit(N.oid,t)}):null]}):b?(0,i.jsxs)("div",{className:"space-y-2 text-xs text-muted-foreground",children:[(0,i.jsx)("p",{children:"merge-base"===t.strategy?l("mergeBaseToTarget"):l("baseToTarget")}),(0,i.jsx)("p",{className:"break-all font-mono",children:b.comparison.original??l("emptyRevision")}),(0,i.jsx)("p",{className:"break-all font-mono",children:b.comparison.target})]}):(0,i.jsx)("p",{className:"text-muted-foreground",children:l("selectCommit")}),w?(0,i.jsx)("p",{className:"mt-3 break-all font-mono text-xs text-muted-foreground",children:w}):null]})})]})]});return(0,i.jsxs)("section",{className:"flex size-full min-h-0 min-w-0 flex-col","aria-label":l("historyAndCompare"),children:[(0,i.jsxs)("div",{className:"flex shrink-0 flex-wrap items-center gap-2 border-b px-3 py-2",children:[(0,i.jsxs)("div",{className:"flex gap-1",role:"group","aria-label":l("viewMode"),children:[(0,i.jsx)(g.$,{size:"sm",variant:"history"===t.mode?"secondary":"ghost","aria-pressed":"history"===t.mode,onClick:()=>{e.onMode("history"),v("log")},children:l("historyMode")}),(0,i.jsx)(g.$,{size:"sm",variant:"compare"===t.mode?"secondary":"ghost","aria-pressed":"compare"===t.mode,onClick:()=>{e.onMode("compare"),v("log")},children:l("compareMode")})]}),(0,i.jsx)(O.b,{className:"w-44",ariaLabel:l("selectRepository"),value:t.repositoryRoot??"",options:s.map(e=>({value:e.root,label:e.root||a,description:"unavailable"===e.state?(0,M.fD)(e.message,c):void 0})),onChange:e.onRepository}),"history"===t.mode?(0,i.jsx)(X,{className:"w-48",ariaLabel:l("viewBranch"),value:t.tip,branches:t.branches.data,onChange:t=>e.onRevision("tip",t)}):(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(X,{className:"w-44",ariaLabel:l("baseBranch"),placeholder:l("chooseBase"),value:t.base,branches:t.branches.data,onChange:t=>e.onRevision("base",t)}),(0,i.jsx)("span",{className:"text-xs text-muted-foreground",children:"→"}),(0,i.jsx)(X,{className:"w-44",ariaLabel:l("targetBranch"),value:t.target,branches:t.branches.data,onChange:t=>e.onRevision("target",t)}),(0,i.jsx)(O.b,{className:"w-48",ariaLabel:l("comparison"),value:t.strategy,options:[{value:"merge-base",label:l("introducedChanges")},{value:"direct",label:l("directComparison")}],onChange:t=>e.onStrategy("direct"===t?"direct":"merge-base")}),n?(0,i.jsx)(g.$,{size:"sm",variant:"outline",onClick:()=>v("files"),children:l("cumulativeChanges")}):null]}),(0,i.jsx)(T.p,{className:"w-40 shrink-0","aria-label":l("filterAuthor"),placeholder:l("author"),list:m,value:t.author,onChange:t=>e.onAuthor(t.target.value)}),(0,i.jsx)("datalist",{id:m,children:t.authorSuggestions.map(e=>(0,i.jsx)("option",{value:e},e))}),(0,i.jsx)(T.p,{className:"min-w-32 flex-1 basis-40","aria-label":l("searchCommits"),placeholder:l("searchCommits"),value:t.query,onChange:t=>e.onQuery(t.target.value)}),(0,i.jsx)(g.$,{size:"icon-sm",variant:"ghost","aria-label":l("refreshGit"),onClick:e.onRefresh,children:(0,i.jsx)(u.A,{className:"size-4"})})]}),t.branches.error?C(t.branches.error):null,k?(0,i.jsxs)("p",{className:"shrink-0 truncate border-b px-3 py-1 text-xs text-muted-foreground",title:k.ref,children:[k.ref.replace("refs/remotes/","")," \xb7 ",l("localRecord")," \xb7"," ",null===k.ahead||null===k.behind?l("refUnavailable"):l("aheadBehind",{ahead:k.ahead,behind:k.behind})]}):null,"compare"!==t.mode||t.base?n?"log"===x?S:R:(0,i.jsxs)(f.HK,{orientation:"horizontal",defaultLayout:{"project-log":e.panelSizes.log,"project-files":100-e.panelSizes.log},onLayoutChanged:(t,s)=>{s.isUserInteraction&&void 0!==t["project-log"]&&e.onPanelSize("log",t["project-log"])},children:[(0,i.jsx)(f.wV,{id:"project-log",defaultSize:`${e.panelSizes.log}%`,minSize:"30%",children:S}),(0,i.jsx)(f.WM,{disableDoubleClick:!0}),(0,i.jsx)(f.wV,{id:"project-files",defaultSize:`${100-e.panelSizes.log}%`,minSize:"25%",children:R})]}):(0,i.jsx)("p",{className:"p-4 text-sm text-muted-foreground",children:l("chooseBaseBranch")})]})}let ee=()=>{};function et({clientId:e,cwd:t,title:s,actions:z,onEscape:D=ee,onUnauthorized:A}){let{t:M}=(0,r.Bd)("projectHistory"),P=(0,y.G)(),{files:$,git:T,history:O,global:L,updateGlobal:E,page:I,setPage:q,historyPane:F,setHistoryPane:_,setContainer:W,narrow:B,stacked:H,width:Y,changeRowHeight:V,openGit:K,refresh:U}=function(e,t,s){let i=(0,y.G)(),[r]=(0,j.useState)(N.N1),[a,n]=(0,j.useState)(r),o=(0,j.useCallback)(e=>{n(t=>({...t,...e})),(0,N.Ms)({...(0,N.N1)(),...e})},[]),[l]=(0,j.useState)(()=>(0,N.tQ)(t)),[c]=(0,j.useState)(()=>(0,k.ph)(e,t,e=>i.show({level:"info",title:e}),l,r,{lazyHistory:!0,onUnauthorized:s})),{files:d,git:u,history:h}=c;(0,j.useSyncExternalStore)(d.subscribe,d.getRevision,d.getRevision);let p=(0,j.useSyncExternalStore)(u.subscribe,u.getRevision,u.getRevision);(0,j.useSyncExternalStore)(h.subscribe,h.getRevision,h.getRevision);let[m,f]=(0,j.useState)(l?.page??"files"),[g,x]=(0,j.useState)(l?.historyPane??"log"),[v,b]=(0,j.useState)({width:1200,height:800}),[w,z]=(0,j.useState)(null),D=(0,j.useRef)(!1),A=(0,j.useRef)(()=>void 0),M=v.width<900,P=M||v.height<680,$=u.getWorkspace(t).snapshot.repositories,T=d.state,O=(0,j.useSyncExternalStore)(C,S,R)?24:36;(0,j.useEffect)(()=>{h.setChangeRowHeight(O)},[h,O]),(0,j.useEffect)(()=>{A.current=()=>{let e=u.getWorkspace(t),s=h.state,i={page:m,historyPane:g,tabs:[...d.state.tabs],activePath:d.state.activePath,...d.getBrowsingDocumentSettings(),expandedPaths:[...d.state.expandedPaths].slice(0,500),treeScrollTop:d.state.treeScrollTop,searchQuery:d.state.search.query.slice(0,200),changesOnly:e.changesOnly,expandedRepositories:[...e.expandedRepositories].slice(0,100),history:{repositoryRoot:s.repositoryRoot,mode:s.mode,tip:s.tip,base:s.base,target:s.target,strategy:s.strategy,query:s.query.slice(0,200),author:s.author.slice(0,200),selectedCommit:s.selectedCommit,selectedChangePath:s.selectedChangePath,logScroll:h.scroll.log,changesScroll:h.scroll.changes},diffs:d.state.diffs.map(({repositoryRoot:e,path:t,comparison:s})=>({repositoryRoot:e,path:t,...s?{comparison:s}:{}})),activeDiff:d.state.activeDiff?{repositoryRoot:d.state.activeDiff.repositoryRoot,path:d.state.activeDiff.path,...d.state.activeDiff.comparison?{comparison:d.state.activeDiff.comparison}:{}}:null};(0,N.Sb)(t,i)}},[t,d,u,h,g,m]),(0,j.useEffect)(()=>{D.current=!0,c.restore(),d.ensureRoot(),u.ensureSnapshot(t);let e=()=>A.current();return window.addEventListener("pagehide",e),()=>{D.current=!1,window.removeEventListener("pagehide",e),queueMicrotask(()=>{D.current||(A.current(),c.dispose())})}},[t,d,u,c]),(0,j.useEffect)(()=>{if(!w)return;let e=()=>b({width:w.clientWidth,height:w.clientHeight});e();let t=new ResizeObserver(e);return t.observe(w),()=>t.disconnect()},[w]);let L=a.gitOpen&&(!P||"git"===m);return(0,j.useEffect)(()=>{if(!L||!$.length)return;if($.some(e=>e.root===h.state.repositoryRoot))return void h.setRepository(h.state.repositoryRoot);let e=T.activeDiff?[T.activeDiff.repositoryRoot,T.activeDiff.path].filter(Boolean).join("/"):T.activePath,t=e?[...$].sort((e,t)=>t.root.length-e.root.length).find(t=>!t.root||e.startsWith(`${t.root}/`)):null;h.setRepository(t?.root??$.find(e=>""===e.root)?.root??$[0].root)},[L,p,h,$,T.activeDiff,T.activePath]),(0,j.useEffect)(()=>u.subscribe(()=>{let e=u.getWorkspace(t)?.layout;e&&e!==a.treeLayout&&o({treeLayout:e})}),[t,u,a.treeLayout,o]),{files:d,git:u,history:h,global:a,updateGlobal:o,page:m,setPage:f,historyPane:g,setHistoryPane:x,setContainer:z,narrow:M,stacked:P,width:v.width,changeRowHeight:O,openGit(e){o({gitOpen:!0}),f("git"),void 0!==e&&h.setRepository(e)},refresh(){d.refreshTree(),u.refreshSnapshot(t),T.activeDiff?d.reloadDiff():T.activePath&&d.reloadFile(T.activePath),L&&h.refresh()}}}(e,t,A),{directoryOpen:J,gitOpen:G,gitMaximized:Q}=L,X=t.replaceAll("\\","/").split("/").filter(Boolean).at(-1)??t,es=T.getWorkspace(t),ei=es.snapshot.repositories,er=$.state,ea=(0,i.jsx)(x.F,{cwd:t,projectName:X,showRootTitle:!1,runtime:$,gitRuntime:T,onOpenGitBranches:K,onFileOpened:()=>q("code")}),en=(0,i.jsx)(b.R,{runtime:$,gitRuntime:T,compact:Y<1100,onEscape:D,renderHeader:e=>(0,i.jsx)(v.X,{cwd:t,gitRuntime:T,paths:er.tabs,activePath:er.activePath,diffs:er.diffs,activeDiff:er.activeDiff,mobile:B,actions:e,onActivate:e=>{"string"==typeof e?$.openFile(e):$.openDiff(e.repositoryRoot,e.path,e.comparison)},onClose:(e,t)=>$.closeTabs(e,t)})}),eo=(0,i.jsxs)("div",{className:"flex size-full min-h-0 min-w-0 flex-col",children:[(0,i.jsxs)("div",{className:"flex h-9 shrink-0 items-center gap-2 border-b bg-muted px-3",children:[(0,i.jsx)(a.A,{className:"size-4"}),(0,i.jsx)("span",{className:"flex-1 text-sm font-medium",children:"Git"}),H?null:(0,i.jsx)(g.$,{size:"icon-sm",variant:"ghost","aria-label":M(Q?"restoreGit":"maximizeGit"),onClick:()=>E({gitMaximized:!Q}),children:Q?(0,i.jsx)(n.A,{className:"size-4"}):(0,i.jsx)(o.A,{className:"size-4"})}),(0,i.jsx)(g.$,{size:"icon-sm",variant:"ghost","aria-label":M("collapseGit"),onClick:()=>{E({gitOpen:!1,gitMaximized:!1}),q("code")},children:(0,i.jsx)(l.A,{className:"size-4"})})]}),ei.length?(0,i.jsx)(Z,{state:O.state,cwd:t,changeRows:O.getChangeRows(),changeRowHeight:V,onSelectChange:e=>O.selectChange(e),onToggleDirectory:e=>O.toggleChangeDirectory(e),onReveal:(e,t)=>$.revealFile(e,t),repositories:ei,projectName:X,narrow:B,mobilePane:F,onMobilePane:_,scroll:O.scroll,onScroll:(e,t)=>O.setScroll(e,t),panelSizes:{log:L.logSize,changes:L.changeSize},onPanelSize:(e,t)=>E("log"===e?{logSize:t}:{changeSize:t}),onRepository:e=>{O.setRepository(e),_("log")},onMode:e=>O.setMode(e),onRevision:(e,t)=>O.setRevision(e,t),onStrategy:e=>O.setStrategy(e),onQuery:e=>O.setQuery(e),onAuthor:e=>O.setAuthor(e),onCommit:(e,t)=>O.selectCommit(e,t),onAggregate:()=>O.showAggregate(),onMoreLog:()=>O.loadMoreLog(),onMoreChanges:()=>O.loadMoreChanges(),onOpenFile:e=>{O.openChange(e),q("code"),E({gitMaximized:!1})},onRefresh:()=>O.refresh(),onCopy:e=>{(0,w.x)(e).then(e=>{e||P.error(M("copyFailed"))})}}):(0,i.jsx)("p",{className:"p-4 text-sm text-muted-foreground",children:"loading"===es.snapshot.status||"idle"===es.snapshot.status?M("findingGit"):es.snapshot.error??M("noGit")})]}),el=(0,i.jsxs)(f.HK,{orientation:"horizontal",defaultLayout:J?{"project-tree":L.directorySize,"project-code":100-L.directorySize}:void 0,onLayoutChanged:(e,t)=>{t.isUserInteraction&&void 0!==e["project-tree"]&&E({directorySize:e["project-tree"]})},children:[J?(0,i.jsx)(f.wV,{id:"project-tree",defaultSize:`${L.directorySize}%`,minSize:"180px",maxSize:"40%",children:ea}):null,J?(0,i.jsx)(f.WM,{disableDoubleClick:!0}):null,(0,i.jsx)(f.wV,{id:"project-code",minSize:"40%",children:en})]},J?"tree-visible":"tree-hidden");return(0,i.jsxs)("div",{ref:W,className:"flex size-full min-h-0 min-w-0 flex-col overflow-hidden","data-testid":"project-preview",children:[(0,i.jsxs)("header",{className:"flex min-h-9 shrink-0 items-center gap-1 bg-muted px-2 py-1 pt-[max(4px,env(safe-area-inset-top))]",children:[H?null:(0,i.jsx)(g.$,{size:"icon-sm",variant:"ghost","aria-label":M(J?"collapseDirectory":"expandDirectory"),onClick:()=>E({directoryOpen:!J}),children:J?(0,i.jsx)(c.A,{className:"size-4"}):(0,i.jsx)(d.A,{className:"size-4"})}),(0,i.jsxs)("div",{className:"flex min-w-0 flex-1 items-baseline gap-3",title:t,children:[(0,i.jsx)("div",{className:"min-w-0 shrink-0 max-w-[50%] max-sm:max-w-full max-sm:shrink",children:s??(0,i.jsx)("h1",{className:"truncate text-sm font-semibold",children:X})}),(0,i.jsx)("p",{className:"min-w-0 truncate text-xs text-muted-foreground max-sm:hidden",children:t})]}),(0,i.jsxs)(g.$,{size:"sm",variant:G?"secondary":"ghost","aria-pressed":G,onClick:()=>K(),children:[(0,i.jsx)(a.A,{className:"size-4"}),(0,i.jsx)("span",{className:"max-sm:hidden",children:M("gitRecords")})]}),(0,i.jsx)(g.$,{size:"icon-sm",variant:"ghost","aria-label":M("refreshPreview"),onClick:U,children:(0,i.jsx)(u.A,{className:"size-4"})}),z]}),es.snapshot.error?(0,i.jsx)("p",{role:"alert",className:"shrink-0 border-b px-3 py-2 text-sm text-destructive",children:es.snapshot.error}):null,H?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)("div",{className:"flex shrink-0 gap-1 px-2 py-1",role:"group","aria-label":M("previewArea"),children:[(0,i.jsxs)(g.$,{size:"sm",variant:"files"===I?"secondary":"ghost",onClick:()=>q("files"),children:[(0,i.jsx)(h.A,{className:"size-4"}),M("files")]}),(0,i.jsxs)(g.$,{size:"sm",variant:"code"===I?"secondary":"ghost",onClick:()=>q("code"),children:[(0,i.jsx)(p.A,{className:"size-4"}),M("code")]}),(0,i.jsxs)(g.$,{size:"sm",variant:"git"===I?"secondary":"ghost",onClick:()=>K(),children:[(0,i.jsx)(m.A,{className:"size-4"}),"Git"]})]}),(0,i.jsx)("div",{className:"min-h-0 flex-1",children:"files"===I?ea:"git"===I?eo:en})]}):Q&&G?eo:(0,i.jsxs)(f.HK,{orientation:"vertical",defaultLayout:G?{"project-main":100-L.gitSize,"project-git":L.gitSize}:void 0,onLayoutChanged:(e,t)=>{t.isUserInteraction&&void 0!==e["project-git"]&&E({gitSize:e["project-git"]})},children:[(0,i.jsx)(f.wV,{id:"project-main",defaultSize:G?`${100-L.gitSize}%`:"100%",minSize:"35%",children:el}),G?(0,i.jsx)(f.WM,{disableDoubleClick:!0}):null,G?(0,i.jsx)(f.wV,{id:"project-git",defaultSize:`${L.gitSize}%`,minSize:"300px",children:eo}):null]},G?"git-visible":"git-hidden")]})}},58840:(e,t,s)=>{"use strict";s.d(t,{k:()=>h});var i=s(7962),r=s(82028),a=s.n(r),n=s(69266),o=s(49426),l=s(5816);let c=[[".viewer-zoom-in","放大","Zoom in"],[".viewer-zoom-out","缩小","Zoom out"],[".viewer-one-to-one","原始尺寸","Actual size"],[".viewer-reset","重置","Reset"],[".viewer-prev","上一张","Previous image"],[".viewer-next","下一张","Next image"],[".viewer-rotate-left","向左旋转","Rotate left"],[".viewer-rotate-right","向右旋转","Rotate right"]];function d(e){return document.querySelector(`.${e}`)}function u(e,t){e?.querySelectorAll(".viewer-list > li").forEach((e,s)=>{let i="en"===t?`View image ${s+1}`:`查看第 ${s+1} 张图片`;e.setAttribute("aria-label",i),e.setAttribute("title",i)})}function h(e){let{locale:t}=(0,l.i)(),{slides:s,index:r=0,onIndexChange:h,className:p,thumbnails:m=!0,ariaLabel:f="en"===t?"Image preview":"图片预览"}=e,g="inline"===e.mode,x="inline"===e.mode||e.open,v="modal"===e.mode?e.onClose:void 0,b=s.length>1,y=Math.min(Math.max(r,0),Math.max(s.length-1,0)),w=`pi-desk-image-viewer-${(0,n.useId)().replaceAll(":","")}`,j=(0,n.useRef)(null),k=(0,n.useRef)(null),N=(0,n.useRef)(null),C=(0,n.useRef)(""),S=(0,n.useRef)(""),R=(0,n.useRef)(y),z=(0,n.useRef)(y),D=(0,n.useRef)(h),A=(0,n.useRef)(v),M=(0,n.useMemo)(()=>JSON.stringify(s.map(e=>[e.src,e.alt])),[s]),P=(0,o.cn)("pi-desk-image-viewer",g?"pi-desk-image-viewer-inline":"pi-desk-image-viewer-modal",w,p);if((0,n.useEffect)(()=>{S.current=M},[M]),(0,n.useEffect)(()=>{z.current=y},[y]),(0,n.useEffect)(()=>{D.current=h},[h]),(0,n.useEffect)(()=>{A.current=v},[v]),(0,n.useEffect)(()=>{let e=j.current;if(!e||!x||0===s.length)return;let i=!1,r=null,n=0,o=null,l=e=>{!("Escape"===e.key&&!e.defaultPrevented&&!e.isComposing&&!e.altKey&&!e.ctrlKey&&!e.metaKey&&!e.shiftKey&&r?.fulled)||(e.preventDefault(),e.stopImmediatePropagation(),e.repeat||d(w)?.querySelector(".viewer-button")?.click())};window.addEventListener("keydown",l,!0);let h=()=>{if(i)return;let l=z.current;R.current=l;let h=window.matchMedia("(pointer: coarse)").matches||navigator.maxTouchPoints>0;r=new(a())(e,{inline:g,initialViewIndex:l,initialCoverage:g?.82:.88,minWidth:0,minHeight:0,minZoomRatio:.05,maxZoomRatio:8,zoomRatio:.12,zIndex:200,zIndexInline:1,backdrop:!g,button:!0,focus:!0,keyboard:!0,loading:!0,loop:!1,movable:!0,navbar:!!b&&!!m&&2,rotatable:!0,scalable:!1,slideOnTouch:b,title:!g&&1,toolbar:{prev:b,zoomOut:!0,zoomIn:!0,oneToOne:{show:2},reset:!0,rotateLeft:{show:2},rotateRight:{show:2},next:b},tooltip:!0,transition:!window.matchMedia("(prefers-reduced-motion: reduce)").matches,toggleOnDblclick:!h,zoomable:!0,zoomOnTouch:!0,zoomOnWheel:!0,className:P,ready:()=>(function(e,t,s,i,r,a){let n=d(e);if(!n)return;for(let[e,t,i]of(n.setAttribute("aria-label",s),n.setAttribute("lang",a),c)){let s=n.querySelector(e);if(!s)continue;let r="en"===a?i:t;s.setAttribute("aria-label",r),s.setAttribute("title",r)}u(n,a);let o=n.querySelector(".viewer-button");if(o){let e=()=>{let e=t?o.classList.contains("viewer-fullscreen-exit")?"en"===a?"Exit fullscreen":"退出全屏":"en"===a?"View image fullscreen":"全屏查看图片":"en"===a?"Close image preview":"关闭图片预览";o.setAttribute("aria-label",e),o.setAttribute("title",e)};e(),t&&o.addEventListener("click",()=>requestAnimationFrame(e))}if(i>1){let e=document.createElement("div");e.className="pi-desk-image-viewer-counter",e.dataset.piDeskViewerCounter="",e.setAttribute("aria-live","polite"),e.textContent=`${r+1} / ${i}`,n.appendChild(e)}})(w,g,f,s.length,l,t),view:e=>{let t=function(e){let t=e.detail;if("object"!=typeof t||null===t)return null;let s=Reflect.get(t,"index");return"number"==typeof s&&Number.isInteger(s)?s:null}(e);if(null!==t){var i;let e;b&&N.current&&(N.current.options.transition=!1),R.current=t,i=s.length,(e=d(w)?.querySelector("[data-pi-desk-viewer-counter]"))&&(e.textContent=`${t+1} / ${i}`),D.current?.(t)}},viewed:()=>{let e=N.current;if(!b||!e?.image)return;let t=window.matchMedia("(prefers-reduced-motion: reduce)").matches;e.options.transition=!t,t||(e.image.getBoundingClientRect(),e.image.classList.add("viewer-transition"),e.image.animate([{opacity:0},{opacity:1}],{duration:150,easing:"ease-out"}))},hidden:()=>A.current?.()}),N.current=r,C.current=S.current,g&&k.current?(o=new ResizeObserver(()=>{cancelAnimationFrame(n),n=requestAnimationFrame(()=>r?.resize())})).observe(k.current):r.show()},p=Array.from(e.querySelectorAll("img"));return g&&p.some(e=>!e.complete)?Promise.all(p.map(e=>e.decode().catch(()=>void 0))).then(h):h(),()=>{i=!0,window.removeEventListener("keydown",l,!0),o?.disconnect(),cancelAnimationFrame(n),N.current===r&&(N.current=null),r?.destroy()}},[x,f,g,w,t,b,s.length,m,P]),(0,n.useEffect)(()=>{let e=N.current;if(!e||C.current===M)return;C.current=M;let s=R.current,i=j.current?.querySelectorAll("img")[s],r=e.image?.src!==i?.src||e.image?.alt!==i?.alt;r&&(e.viewed=!1),e.update(),r&&e.view(s),u(d(w),t)},[w,t,M]),(0,n.useEffect)(()=>{let e=N.current;e&&R.current!==y&&e.view(y)},[y]),0===s.length||!x)return null;let $=(0,i.jsx)("span",{ref:j,className:"pi-desk-image-viewer-source","aria-hidden":"true",children:s.map((e,t)=>(0,i.jsx)("img",{src:e.src,alt:e.alt,width:e.width,height:e.height,decoding:"async",draggable:!1},t))});return g?(0,i.jsx)("div",{ref:k,className:"pi-desk-image-viewer-host",role:"region","aria-label":f,tabIndex:0,onKeyDown:e=>{let t=N.current;!t||t.fulled||e.altKey||e.ctrlKey||e.metaKey||e.nativeEvent.isComposing||("ArrowLeft"===e.key||"ArrowRight"===e.key)&&(e.preventDefault(),e.stopPropagation(),"ArrowLeft"===e.key?t.prev(!1):t.next(!1))},children:$}):$}},60471:(e,t,s)=>{"use strict";s.d(t,{b:()=>u});var i=s(7962),r=s(46783),a=s(69266),n=s(78121),o=s(86963),l=s(89790),c=s(90434),d=s(49426);function u({value:e,options:t,onChange:s,ariaLabel:h,placeholder:p,searchPlaceholder:m,emptyText:f,disabled:g=!1,className:x}){let{t:v}=(0,n.Bd)("common"),[b,y]=(0,a.useState)(!1),w=t.find(t=>t.value===e);return(0,i.jsxs)(c.AM,{open:b,onOpenChange:y,children:[(0,i.jsx)(c.Wv,{render:(0,i.jsxs)(o.$,{type:"button",variant:"outline",role:"combobox","aria-label":h,"aria-expanded":b,disabled:g,className:(0,d.cn)("w-full min-w-0 justify-between border-input px-2.5 font-normal focus-visible:-outline-offset-2",x),children:[(0,i.jsx)("span",{className:(0,d.cn)("min-w-0 truncate",!w&&"text-muted-foreground"),children:w?.label??p??v("selectPlaceholder")}),(0,i.jsx)(r.A,{className:"text-muted-foreground"})]})}),(0,i.jsx)(c.hl,{align:"start",sideOffset:4,positionerClassName:"z-[120]",className:"w-(--anchor-width) max-w-[calc(100vw-2rem)] gap-0 p-0",children:(0,i.jsxs)(l.uB,{children:[(0,i.jsx)(l.G7,{placeholder:m??v("searchPlaceholder"),autoFocus:!0}),(0,i.jsxs)(l.oI,{className:"max-h-[min(20rem,var(--available-height))]",children:[(0,i.jsx)(l.xL,{children:f??v("noMatches")}),(0,i.jsx)(l.L$,{children:t.map(t=>(0,i.jsx)(l.h_,{value:`${t.label} ${t.description??""} ${t.value}`,"data-checked":t.value===e?"true":void 0,onSelect:()=>{s(t.value),y(!1)},children:(0,i.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,i.jsx)("span",{className:"block truncate",children:t.label}),t.description?(0,i.jsx)("span",{className:"mt-0.5 block truncate text-xs text-muted-foreground",children:t.description}):null]})},t.value))})]})]})})]})}},60682:(e,t,s)=>{"use strict";s.d(t,{J:()=>g});var i=s(7962),r=s(49762),a=s(86758),n=s(36670),o=s(50479),l=s(35995),c=s(69266),d=s(78121),u=s(99084),h=s(51821),p=s(1364),m=s(73165),f=s(93119);function g({cwd:e,path:t,type:s,trigger:x,openLabel:v,onOpen:b,expanded:y,onToggle:w,historical:j,oldPath:k,onReveal:N}){let{t:C}=(0,d.Bd)("projectFiles"),S=(0,h.G)(),[R,z]=(0,c.useState)(null),D=R??{cwd:e,path:t,type:s,oldPath:k},A=(0,c.useRef)(!1),M=(0,c.useRef)(""),P="file"===s?"file":"folder",$=e=>{(0,u.x)(e).then(e=>{e?S.success(C("copied")):S.error(C("copyFailed"))})},T=(D.path||D.cwd.replaceAll("\\","/")).split("/").filter(Boolean).at(-1)??D.cwd;return(0,i.jsxs)(p.tz,{onOpenChange:(i,r)=>{z(i?{cwd:e,path:t,type:s,oldPath:k}:null);let a=r.event;i&&("touch"===M.current||"pointerType"in a&&"touch"===a.pointerType||a.type.startsWith("touch"))&&(A.current=!0)},children:[(0,i.jsx)(p.Rc,{render:x,"data-project-path-menu-trigger":"",onPointerDown:e=>{M.current=e.pointerType,A.current=!1},onTouchEndCapture:e=>{let t=e.target;!R||!A.current||"touch"!==M.current||t instanceof Element&&t.closest("[data-project-path-menu-trigger]")===e.currentTarget&&e.cancelable&&e.preventDefault()},onClickCapture:e=>{A.current&&(e.preventDefault(),e.stopPropagation(),A.current=!1)},onKeyDownCapture:e=>{if(e.defaultPrevented||e.nativeEvent.isComposing)return;let t=e.target;if(!(t instanceof Element)||t.closest("[data-project-path-menu-trigger]")!==e.currentTarget||(M.current="keyboard",A.current=!1,"ContextMenu"!==e.key&&!("F10"===e.key&&e.shiftKey)))return;e.preventDefault(),e.stopPropagation();let s=t.getBoundingClientRect();e.currentTarget.dispatchEvent(new MouseEvent("contextmenu",{bubbles:!0,cancelable:!0,button:2,clientX:s.left+Math.min(s.width,120)/2,clientY:s.top+Math.min(s.height,36)/2}))}}),(0,i.jsxs)(m.D,{children:[b?(0,i.jsxs)(p.kt,{onClick:b,children:[(0,i.jsx)(r.A,{}),v??C("openPreview")]}):null,w?(0,i.jsxs)(p.kt,{onClick:w,children:[y?(0,i.jsx)(a.A,{}):(0,i.jsx)(n.A,{}),C(y?"collapse":"expand")]}):null,b||w?(0,i.jsx)(p.K5,{}):null,N?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)(p.kt,{"data-testid":`project-${P}-reveal-${t}`,onClick:()=>{N&&N(D.path,D.type).then(()=>S.success(C("revealRequested"))).catch(e=>{S.error(e instanceof Error?e.message:C("revealFailed"))})},children:[(0,i.jsx)(o.A,{}),j?"directory"===s?C("openCurrentWorkspace"):C("locateCurrentWorkspace"):"directory"===s?C("openFolder"):C("openContainingFolder")]}),(0,i.jsx)(p.K5,{})]}):null,(0,i.jsxs)(p.kt,{"data-testid":`project-${P}-copy-address-${t}`,onClick:()=>$((0,f.$)(D.cwd,D.path)),children:[(0,i.jsx)(l.A,{}),C("copyAbsolutePath")]}),(0,i.jsxs)(p.kt,{onClick:()=>$(D.path||"."),children:[(0,i.jsx)(l.A,{}),C("copyRelativePath")]}),(0,i.jsxs)(p.kt,{onClick:()=>$(T),children:[(0,i.jsx)(l.A,{}),C("directory"===s?"copyFolderName":"copyFileName")]}),D.oldPath?(0,i.jsxs)(p.kt,{onClick:()=>$(D.oldPath),children:[(0,i.jsx)(l.A,{}),C("copyOldRelativePath")]}):null]})]})}},64334:(e,t,s)=>{"use strict";s.d(t,{Ms:()=>y,N1:()=>b,Sb:()=>j,tQ:()=>w});var i=s(38979),r=s(67765),a=s(86062);let n="pi-super:project-preview:global",o="pi-super:project-preview:projects",l=i.ai().min(5).max(95),c=i.Ik({maximized:i.zM(),directoryOpen:i.zM(),gitOpen:i.zM(),gitMaximized:i.zM(),treeLayout:i.k5(["directory","repository"]),directorySize:l,gitSize:l,logSize:l,changeSize:l}),d={maximized:!1,directoryOpen:!0,gitOpen:!1,gitMaximized:!1,treeLayout:"directory",directorySize:22,gitSize:45,logSize:62,changeSize:70},u=i.Ik({repositoryRoot:i.Yj().nullable(),mode:i.k5(["history","compare"]),tip:i.Yj(),base:i.Yj(),target:i.Yj(),strategy:i.k5(["merge-base","direct"]),query:i.Yj().max(200),author:i.Yj().max(200),selectedCommit:a.aD.nullable(),selectedChangePath:r._g.nullable(),logScroll:i.ai().nonnegative(),changesScroll:i.ai().nonnegative()}),h=i.Ie(e=>"object"==typeof e&&null!==e&&Array.isArray(e.cursorState)&&"object"==typeof e.viewState),p=i.Ik({repositoryRoot:i.Yj(),path:r._g,comparison:a.xv.optional()}),m=i.Ik({page:i.k5(["files","code","git"]),historyPane:i.k5(["log","files"]),tabs:i.YO(r._g).max(20),activePath:r._g.nullable(),editorStates:i.g1(r._g,h),fileViewModes:i.g1(r._g,i.k5(["source","preview"])),expandedPaths:i.YO(i.Yj()).max(500),treeScrollTop:i.ai().nonnegative(),searchQuery:i.Yj().max(200),changesOnly:i.zM(),expandedRepositories:i.YO(i.Yj()).max(100),history:u,diffs:i.YO(p).max(20).optional(),activeDiff:p.nullable()}),f=i.Ik({cwd:i.Yj(),lastOpenedAt:i.ai(),state:m});function g(e){let t=e.replaceAll("\\","/").replace(/\/+$/,"");return/^[a-z]:\//i.test(t)||t.startsWith("//")?t.toLowerCase():t}function x(){try{let e=JSON.parse(window.localStorage.getItem(o)??"[]");if(!Array.isArray(e))return[];let t=Date.now();return e.flatMap(e=>{let s=f.safeParse(e);return s.success&&t-s.data.lastOpenedAt<2592e6?[s.data]:[]})}catch{return[]}}function v(e){try{window.localStorage.setItem(o,JSON.stringify(e.sort((e,t)=>t.lastOpenedAt-e.lastOpenedAt).slice(0,50)))}catch(e){console.warn("[Pi Desk][ProjectPreview] 保存项目浏览状态失败",e)}}function b(){try{let e=JSON.parse(window.localStorage.getItem(n)??"null");return{...d,...c.partial().parse(e)}}catch{return{...d}}}function y(e){try{window.localStorage.setItem(n,JSON.stringify(e))}catch(e){console.warn("[Pi Desk][ProjectPreview] 保存全局布局失败",e)}}function w(e){let t=g(e),s=x(),i=s.find(e=>e.cwd===t);return i&&(i.lastOpenedAt=Date.now()),v(s),i?.state??null}function j(e,t){let s=m.safeParse(t);if(!s.success)return;let i=g(e),r=x(),a=r.find(e=>e.cwd===i);a?a.state=s.data:r.push({cwd:i,lastOpenedAt:Date.now(),state:s.data}),v(r)}},66453:(e,t,s)=>{"use strict";s.d(t,{$E:()=>a,Rv:()=>n,m4:()=>r});var i=s(38979);let r=i.Yj().trim().min(1),a=i.Yj().trim().min(1),n=i.Yj().trim().min(1)},67765:(e,t,s)=>{"use strict";s.d(t,{CT:()=>p,JH:()=>f,NL:()=>n,Nu:()=>g,_g:()=>d,eC:()=>u,gB:()=>o,ih:()=>w,jI:()=>y,p$:()=>h,rh:()=>c,uV:()=>r,xm:()=>a});var i=s(38979);let r=4096,a=5e3,n=5242880,o=1048576;function l(e,t){return""===e?t:!(e.length>r||e.startsWith("/")||e.includes("\\")||e.includes("\0")||/^[a-zA-Z]:/.test(e))&&e.split("/").every(e=>e.length>0&&"."!==e&&".."!==e)}let c=i.Yj().max(r).refine(e=>l(e,!0),"目录路径必须是规范相对路径"),d=i.Yj().min(1).max(r).refine(e=>l(e,!1),"文件路径必须是规范相对路径"),u=i.Yj().min(1).max(r).refine(e=>l(e,!1)||e.length>0&&e.length<=r&&!e.includes("\0")&&(e.startsWith("/")||e.startsWith("\\\\")||/^[a-zA-Z]:[\\/]/.test(e)),"预览路径必须是规范相对路径或绝对路径"),h=i.k5(["compressed","original"]),p=i.k5(["image/jpeg","image/png","image/webp","image/gif"]),m=i.Ik({name:i.Yj().min(1),type:i.k5(["directory","file"])}).strict(),f=i.Ik({entries:i.YO(m).max(a),truncated:i.zM()}).strict(),g=i.Ik({query:i.Yj().min(1).max(200).refine(e=>e.trim().length>0&&!/[\0\r\n]/.test(e),"搜索词必须是非空单行文本"),scope:i.k5(["all","files","content"]).default("all"),caseSensitive:i.zM().default(!1),wholeWord:i.zM().default(!1),regex:i.zM().default(!1)}).strict(),x=i.Ik({start:i.ai().int().nonnegative(),end:i.ai().int().nonnegative()}).strict().refine(e=>e.start<=e.end,"搜索命中区间无效"),v=i.Ik({path:d,ranges:i.YO(x)}).strict().refine(e=>e.ranges.every(t=>t.end<=e.path.length),"文件名命中区间越界"),b=i.Ik({path:d,line:i.ai().int().positive(),text:i.Yj().max(1e3),ranges:i.YO(x)}).strict().refine(e=>e.ranges.every(t=>t.end<=e.text.length),"正文命中区间越界"),y=i.Ik({fileMatches:i.YO(v).max(100),contentMatches:i.YO(b).max(200),truncated:i.zM()}).strict(),w=i.gM("kind",[i.Ik({kind:i.eu("text"),content:i.Yj(),size:i.ai().int().nonnegative().max(n)}).strict(),i.Ik({kind:i.eu("image"),mimeType:p,data:i.Yj().min(1),size:i.ai().int().positive().max(0xa00000)}).strict()])},68017:(e,t,s)=>{"use strict";s.d(t,{T:()=>a});var i=s(7962);s(69266);var r=s(49426);function a({className:e,...t}){return(0,i.jsx)("textarea",{"data-slot":"textarea",className:(0,r.cn)("flex field-sizing-content min-h-16 w-full rounded-lg border border-input bg-card px-2.5 py-2 text-sm leading-5 transition-colors duration-150 outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:outline-2 focus-visible:outline-solid focus-visible:-outline-offset-2 focus-visible:outline-ring disabled:cursor-not-allowed disabled:bg-muted disabled:opacity-50 aria-invalid:border-destructive aria-invalid:outline-destructive",e),...t})}},69272:(e,t,s)=>{"use strict";s.d(t,{s:()=>N});var i=s(7962),r=s(34506),a=s(49762),n=s(19932),o=s(50153);let l={src:"/_next/static/media/console.fdac8a18.svg",height:16,width:16,blurWidth:0,blurHeight:0},c={src:"/_next/static/media/docker.1e10aab8.svg",height:24,width:24,blurWidth:0,blurHeight:0},d={src:"/_next/static/media/git.f893cb5f.svg",height:32,width:32,blurWidth:0,blurHeight:0},u={src:"/_next/static/media/html.97f145d3.svg",height:32,width:32,blurWidth:0,blurHeight:0},h={src:"/_next/static/media/image.69ad851c.svg",height:16,width:16,blurWidth:0,blurHeight:0},p={src:"/_next/static/media/javascript.9ef61c53.svg",height:16,width:16,blurWidth:0,blurHeight:0},m={src:"/_next/static/media/json.eb8fe488.svg",height:960,width:960,blurWidth:0,blurHeight:0},f={src:"/_next/static/media/markdown.ee1bbe18.svg",height:32,width:32,blurWidth:0,blurHeight:0},g={src:"/_next/static/media/nodejs.2f5d7983.svg",height:32,width:32,blurWidth:0,blurHeight:0},x={src:"/_next/static/media/typescript.cd97905b.svg",height:16,width:16,blurWidth:0,blurHeight:0},v={src:"/_next/static/media/yaml.8927dd24.svg",height:24,width:24,blurWidth:0,blurHeight:0},b=new Map(Object.entries({"agents.md":{src:"/_next/static/media/agent.84538518.svg",height:32,width:32,blurWidth:0,blurHeight:0},"skill.md":{src:"/_next/static/media/skill.a97e8eb6.svg",height:16,width:16,blurWidth:0,blurHeight:0},"package.json":g,"package-lock.json":g,"npm-shrinkwrap.json":g,dockerfile:c,".dockerignore":c,".gitignore":d,".gitattributes":d,".gitmodules":d})),y=new Map(Object.entries({ts:x,mts:x,cts:x,tsx:{src:"/_next/static/media/react_ts.3d16336c.svg",height:32,width:32,blurWidth:0,blurHeight:0},js:p,mjs:p,cjs:p,jsx:{src:"/_next/static/media/react.b5a87f7d.svg",height:32,width:32,blurWidth:0,blurHeight:0},json:m,jsonc:m,jsonl:m,yaml:v,yml:v,md:f,mdx:f,png:h,jpg:h,jpeg:h,gif:h,webp:h,avif:h,bmp:h,ico:h,svg:{src:"/_next/static/media/svg.4aa98763.svg",height:32,width:32,blurWidth:0,blurHeight:0},sh:l,bash:l,zsh:l,fish:l,ps1:l,bat:l,cmd:l,html:u,htm:u,css:{src:"/_next/static/media/css.0d88d948.svg",height:32,width:32,blurWidth:0,blurHeight:0},py:{src:"/_next/static/media/python.e376d0bc.svg",height:24,width:24,blurWidth:0,blurHeight:0}})),w=new Set(["env","toml","ini","conf","cfg","properties"]),j=new Set([".editorconfig",".npmrc",".yarnrc",".prettierignore",".eslintignore"]),k=new Set(["c","cpp","cc","cxx","h","hpp","cs","go","rs","java","kt","kts","rb","php","swift","dart","vue","svelte","scss","sass","less","sql","xml"]);function N({path:e,className:t}){let s=e.replaceAll("\\","/").split("/").at(-1)?.toLowerCase()??"",l=s.includes(".")?s.slice(s.lastIndexOf(".")+1):"";if(w.has(l)||j.has(s)||s.startsWith(".env.")||s.startsWith(".eslintrc")||s.startsWith(".prettierrc")||s.startsWith("eslint.config.")||s.startsWith("prettier.config."))return(0,i.jsx)(r.A,{className:t,"aria-hidden":"true"});let d=b.get(s)??(s.startsWith("dockerfile.")?c:void 0)??y.get(l);if(!d){let e=k.has(l)?a.A:n.A;return(0,i.jsx)(e,{className:t,"aria-hidden":"true"})}return(0,i.jsx)(o.default,{src:d,alt:"","aria-hidden":"true",width:16,height:16,className:t,unoptimized:!0})}},70698:(e,t,s)=>{"use strict";s.d(t,{k:()=>i});let i=s(38979).ai().int().nonnegative().max(Number.MAX_SAFE_INTEGER)},72282:(e,t,s)=>{"use strict";s.d(t,{HK:()=>n,WM:()=>l,wV:()=>o});var i=s(7962),r=s(55493),a=s(49426);function n({className:e,...t}){return(0,i.jsx)(r.YJ,{"data-slot":"resizable-panel-group",className:(0,a.cn)("flex h-full w-full aria-[orientation=vertical]:flex-col",e),...t})}function o({...e}){return(0,i.jsx)(r.Zk,{"data-slot":"resizable-panel",...e})}function l({withHandle:e,className:t,...s}){return(0,i.jsx)(r.wv,{"data-slot":"resizable-handle",className:(0,a.cn)("relative flex w-px items-center justify-center bg-border ring-offset-background after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-hidden aria-[orientation=horizontal]:h-px aria-[orientation=horizontal]:w-full aria-[orientation=horizontal]:after:left-0 aria-[orientation=horizontal]:after:h-1 aria-[orientation=horizontal]:after:w-full aria-[orientation=horizontal]:after:translate-x-0 aria-[orientation=horizontal]:after:-translate-y-1/2 [&[aria-orientation=horizontal]>div]:rotate-90",t),...s})}},73068:(e,t,s)=>{"use strict";s.d(t,{R:()=>O});var i=s(7962),r=s(31123),a=s(28436),n=s(60278),o=s(55628),l=s(47974),c=s(90680),d=s(3433),u=s(41148),h=s(15824),p=s(35995),m=s(49762),f=s(14044),g=s(69266),x=s(78121),v=s(99084),b=s(90504),y=s(91182),w=s(18302),j=s(33550);let k=(0,g.forwardRef)(function({original:e,modified:t,viewMode:s,onEscape:r,savedState:a,onSaveState:n,initialLine:o},l){let{t:c}=(0,x.Bd)("common"),{wrapLines:d,collapseUnchanged:u}=(0,j.TX)(),h=(0,g.useRef)(null),p=(0,g.useRef)(null),m=(0,g.useRef)({viewMode:s,wrapLines:d,collapseUnchanged:u}),v=(0,g.useRef)(r),b=(0,g.useRef)(a),k=(0,g.useRef)(n),N=(0,g.useRef)(o);(0,g.useEffect)(()=>{v.current=r,b.current=a,k.current=n,N.current=o},[o,r,n,a]);let[C,S]=(0,g.useState)("loading"),[R,z]=(0,g.useState)(null);return(0,g.useEffect)(()=>{m.current={viewMode:s,wrapLines:d,collapseUnchanged:u}},[u,s,d]),(0,g.useImperativeHandle)(l,()=>({previousChange(){p.current?.goToDiff("previous")},nextChange(){p.current?.goToDiff("next")},focus(){p.current?.getModifiedEditor().focus()}}),[]),(0,g.useEffect)(()=>{let s=h.current;if(!s)return;let i=!0,r=null,a=null,n=null,o=()=>void 0,l=()=>void 0,d=[];return queueMicrotask(()=>{i&&(S("loading"),z(null))}),(0,y.cu)().then(u=>{if(!i)return;a=u.editor.createModel(e.content,(0,y.ix)(e.path,new TextEncoder().encode(e.content).length),(0,y.B3)(u,e.path,"diff-original")),n=u.editor.createModel(t.content,(0,y.ix)(t.path,new TextEncoder().encode(t.content).length),(0,y.B3)(u,t.path,"diff-modified"));let h=m.current;r=u.editor.createDiffEditor(s,{theme:(0,y.dC)(),readOnly:!0,domReadOnly:!0,editContext:!1,originalEditable:!1,automaticLayout:!0,renderSideBySide:"side-by-side"===h.viewMode,useInlineViewWhenSpaceIsLimited:!1,enableSplitViewResizing:!0,diffAlgorithm:"advanced",ignoreTrimWhitespace:!1,maxComputationTime:5e3,hideUnchangedRegions:h.collapseUnchanged?{enabled:!0,revealLineCount:3,minimumLineCount:6,contextLineCount:3}:{enabled:!1},minimap:{enabled:!1},stickyScroll:{enabled:!1},scrollBeyondLastLine:!1,smoothScrolling:!0,diffWordWrap:h.wrapLines?"on":"off",wrappingIndent:"same",...(0,y.R)(),lineNumbersMinChars:3,renderValidationDecorations:"off",renderWhitespace:"selection",unicodeHighlight:{nonBasicASCII:!1},padding:{top:10,bottom:10},overviewRulerBorder:!1,contextmenu:!0,ariaLabel:c("gitDiffReadOnly")});let f=N.current,g=!1;d.push(r.onDidUpdateDiff(()=>{if(!i||!r)return;let e=r.getLineChanges();if(z(e?.length??null),!g&&null!==e&&void 0!==f){g=!0;let e=Math.max(1,Math.min(f,n?.getLineCount()??1)),t=r.getModifiedEditor();t.setPosition({lineNumber:e,column:1}),t.revealLineInCenter(e)}})),r.setModel({original:a,modified:n}),void 0===f&&b.current&&r.restoreViewState(b.current);let x=()=>k.current?.(r?.saveViewState()??null);d.push(r.getOriginalEditor().onDidScrollChange(x),r.getModifiedEditor().onDidScrollChange(x)),v.current&&((0,w.e)(r.getOriginalEditor(),u.KeyCode.Escape,()=>v.current?.()),(0,w.e)(r.getModifiedEditor(),u.KeyCode.Escape,()=>v.current?.())),p.current=r,o=(0,y.Tr)(e=>u.editor.setTheme(e)),l=(0,y.BK)(e=>r?.updateOptions(e)),S("ready")}).catch(s=>{i&&(console.error("[Pi Desk][CodeDiff] Monaco 加载失败",{originalPath:e.path,modifiedPath:t.path,errorName:s instanceof Error?s.name:"UnknownError"}),S("error"))}),()=>{for(let e of(i=!1,o(),l(),k.current?.(r?.saveViewState()??null),d))e.dispose();p.current=null,r?.setModel(null),r?.dispose(),window.setTimeout(()=>{a?.dispose(),n?.dispose()},0)}},[t.content,t.path,e.content,e.path,c]),(0,g.useEffect)(()=>{p.current?.updateOptions({renderSideBySide:"side-by-side"===s,diffWordWrap:d?"on":"off",hideUnchangedRegions:u?{enabled:!0,revealLineCount:3,minimumLineCount:6,contextLineCount:3}:{enabled:!1}}),"side-by-side"===s&&p.current?.getOriginalEditor().updateOptions({wordWrapOverride2:"inherit"})},[u,s,d]),(0,i.jsxs)("div",{"data-testid":"code-diff",className:"relative flex h-full min-h-0 w-full flex-col overflow-hidden bg-background",children:[(0,i.jsx)("div",{ref:h,className:"min-h-0 flex-1"}),(0,i.jsx)("div",{role:"status","aria-label":c("diffStatus"),className:"flex min-h-6 shrink-0 items-center justify-end border-t px-3 text-xs text-muted-foreground",children:null===R?c("diffCalculating"):c("diffCount",{count:R})}),"loading"===C?(0,i.jsxs)("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center gap-2 bg-background text-sm text-muted-foreground",children:[(0,i.jsx)(f.A,{className:"size-4 animate-spin"})," ",c("diffLoading")]}):null,"error"===C?(0,i.jsx)("div",{className:"absolute inset-0 flex items-center justify-center p-6 text-center text-sm text-destructive",children:c("diffFailed")}):null]})});var N=s(58840),C=s(51821),S=s(86963),R=s(56592),z=s(35989),D=s(14512),A=s(32892);function M({label:e,onClick:t,active:s=!1,children:r}){return(0,i.jsxs)(A.m_,{children:[(0,i.jsx)(A.k$,{render:(0,i.jsx)(S.$,{type:"button",size:"icon-sm",variant:"ghost","aria-label":e,"aria-pressed":s||void 0,onPointerDown:e=>e.preventDefault(),onClick:t}),children:r}),(0,i.jsx)(A.ZI,{children:e})]})}var P=s(36510),$=s(46487),T=s(97921);function O({ref:e,runtime:t,gitRuntime:s,compact:f,visible:y=!0,onEscape:w,onSwitchPane:A,renderHeader:E}){let I,q,F,_,W,B,H,Y,V,{t:K}=(0,x.Bd)("projectFiles"),{wrapLines:U,diffViewMode:J,collapseUnchanged:G}=(0,j.TX)();(0,g.useSyncExternalStore)(t.subscribe,t.getRevision,t.getRevision);let{activeDiff:Q,activePath:X}=t.state,Z=!Q&&X?t.state.documents.get(X):null,ee=X?(0,T.g)(X):null,et=Z?.status==="text"&&(!ee||"source"===Z.viewMode),es=(0,g.useRef)(null),ei=(0,g.useRef)(null),er=(0,g.useRef)(null),ea=(0,g.useRef)(null),en=(0,C.G)();(0,g.useImperativeHandle)(e,()=>({focus(){et?ei.current?.focus():Q?er.current?.focus():es.current?.querySelector('[data-testid="markdown-preview"]')?.focus()}}),[Q,et]),(0,g.useEffect)(()=>{let e=e=>{ea.current&&e.source===ea.current.contentWindow&&("pi-desk:file-escape"===e.data&&w(),"pi-desk:file-switch-pane"===e.data&&A?.())};return window.addEventListener("message",e),()=>window.removeEventListener("message",e)},[w,A]);let eo=()=>{X&&ei.current&&t.saveEditorState(X,ei.current.getViewState())},{refresh:el,unavailable:ec}=((0,g.useSyncExternalStore)(s.subscribe,s.getRevision,s.getRevision),I=s.getWorkspace(t.cwd)?.snapshot,q=t.state.activePath,_=!!(F=t.state.activeDiff),W=q?t.state.documents.get(q):void 0,B=(0,g.useRef)(eo),(0,g.useEffect)(()=>{B.current=eo},[eo]),H=(0,g.useCallback)(()=>{q&&!_&&(B.current(),t.reloadFile(q),s.refreshSnapshot(t.cwd))},[_,s,q,t]),Y=(0,g.useCallback)(()=>{F?t.refreshDiff():q&&(B.current(),t.ensureDocument(q,!0)),s.refreshSnapshot(t.cwd)},[F,s,q,t]),(0,D.L)(es,Y,y),(0,g.useEffect)(()=>{if(!y||!q||_||W?.status!=="text"||I?.status==="loading")return;let e=new AbortController,s=I?.status==="ready"?(0,z.lN)(t.cwd,q,I.repositories):null;return t.compareFile(q,s?.repository.state==="ready"&&s.change?{repositoryRoot:s.repository.root,path:s.change.path}:null,e.signal),()=>e.abort()},[y,_,W,q,t,I]),V=q&&I?.status==="ready"?(0,z.lN)(t.cwd,q,I.repositories):null,{refresh:H,unavailable:I?.status==="error"||V?.repository.state==="unavailable"}),ed=Z?.status==="text"?Z.comparison:void 0,[eu,eh]=(0,g.useState)(null),ep=ed?.status==="ready"&&Z?.status==="text"&&eu?.original===ed.original.content&&eu.modified===Z.content?eu.count:void 0,em=e=>{X&&(eo(),t.openFileDiff(X,e))},ef=ec||ed?.status==="error"?K("gitMarkersFailed"):ed?.status==="unavailable"||ed?.status==="ready"&&null===ep?K("gitMarkersUnavailable"):ed?.status==="loading"||ed?.status==="ready"&&void 0===ep?K("gitMarkersLoading"):ed?.status==="ready"?K("gitChangesCount",{count:ep}):null,eg=Q||X?(0,i.jsx)(i.Fragment,{children:Q?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)("span",{className:"mr-auto shrink-0 px-1 text-xs text-muted-foreground",children:[Q.label??(Q.comparison?`${Q.comparison.baseCommit?.slice(0,7)??"∅"} → ${Q.comparison.targetCommit.slice(0,7)}`:K("headToWorking")),"text"===Q.status&&Q.original.content===Q.modified.content?K("noDiffChanges"):""]}),(0,i.jsx)(M,{label:K("previousChange"),onClick:()=>er.current?.previousChange(),children:(0,i.jsx)(r.A,{className:"size-4"})}),(0,i.jsx)(M,{label:K("nextChange"),onClick:()=>er.current?.nextChange(),children:(0,i.jsx)(a.A,{className:"size-4"})}),f?null:(0,i.jsx)(M,{label:"side-by-side"===J?K("inlineDiff"):K("sideBySideDiff"),active:"inline"===J,onClick:()=>t.setDiffViewMode("side-by-side"===J?"inline":"side-by-side"),children:(0,i.jsx)(n.A,{className:"size-4"})}),(0,i.jsx)(M,{label:K(U?"wrapOff":"wrapOn"),active:U,onClick:()=>t.setDiffWrapLines(!U),children:(0,i.jsx)(o.A,{className:"size-4"})}),(0,i.jsx)(M,{label:K(G?"expandUnchanged":"collapseUnchanged"),active:G,onClick:()=>t.setDiffCollapseUnchanged(!G),children:(0,i.jsx)(l.A,{className:"size-4"})}),(0,i.jsx)(M,{label:K("reloadDiff"),onClick:()=>t.reloadDiff(),children:(0,i.jsx)(c.A,{className:"size-4"})})]}):(0,i.jsxs)(i.Fragment,{children:[ee&&Z?.status==="text"&&X?(0,i.jsx)("div",{className:"mr-auto flex shrink-0",role:"group","aria-label":K("markdown"===ee?"markdownMode":"htmlMode"),children:["preview","source"].map(e=>(0,i.jsx)(S.$,{variant:Z.viewMode===e?"secondary":"ghost",size:"sm","aria-pressed":Z.viewMode===e,onClick:()=>{eo(),t.setTextViewMode(X,e)},children:K("preview"===e?"previewMode":"sourceMode")},e))}):null,et&&ef?(0,i.jsx)("span",{"data-testid":"file-git-status",role:"status",className:"mr-auto min-w-0 truncate text-xs text-muted-foreground",title:ed?.status==="error"?ed.error:ef,children:f&&ed?.status==="ready"&&"number"==typeof ep?K("gitChangesCompact",{count:ep}):ef}):null,et&&ed?.status==="ready"?(0,i.jsxs)(i.Fragment,{children:["number"==typeof ep&&ep>0?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(M,{label:K("previousChange"),onClick:()=>ei.current?.previousChange(),children:(0,i.jsx)(r.A,{className:"size-4"})}),(0,i.jsx)(M,{label:K("nextChange"),onClick:()=>ei.current?.nextChange(),children:(0,i.jsx)(a.A,{className:"size-4"})})]}):null,(0,i.jsx)(M,{label:K("viewDiff"),onClick:()=>em(),children:(0,i.jsx)(d.A,{className:"size-4"})})]}):null,et&&X?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(M,{label:K("findInFile"),onClick:()=>ei.current?.openSearch(),children:(0,i.jsx)(u.A,{className:"size-4"})}),f?null:(0,i.jsx)(M,{label:K("goToLine"),onClick:()=>ei.current?.gotoLine(),children:(0,i.jsx)(h.A,{className:"size-4"})}),(0,i.jsx)(M,{label:K(U?"wrapOff":"wrapOn"),active:U,onClick:()=>t.setWrapLines(X,!U),children:(0,i.jsx)(o.A,{className:"size-4"})}),(0,i.jsx)(M,{label:K("copySelectionOrAll"),onClick:()=>{if(Z?.status!=="text")return;let e=ei.current?.getSelectionText()??"";(0,v.x)(e||Z.content).then(t=>{t?en.success(K(e?"selectedCodeCopied":"allCodeCopied")):en.error(K("copyContentFailed"))})},children:(0,i.jsx)(p.A,{className:"size-4"})})]}):null,X?(0,i.jsx)(M,{label:K("reloadCurrentFile"),onClick:el,children:(0,i.jsx)(c.A,{className:"size-4"})}):null]})}):null;return(0,i.jsxs)("div",{ref:es,className:"flex size-full min-h-0 min-w-0 flex-col outline-none",tabIndex:-1,onFocus:e=>{e.target===e.currentTarget&&(et?ei.current?.focus():Q?er.current?.focus():es.current?.querySelector('[data-testid="markdown-preview"]')?.focus())},children:[E?E(eg):eg?(0,i.jsx)("div",{className:"flex min-h-9 shrink-0 flex-wrap items-center justify-end gap-2 border-b px-3 py-1","aria-label":K("fileActions"),children:eg}):null,(0,i.jsx)("div",{className:"min-h-0 flex-1 overflow-hidden pb-[env(safe-area-inset-bottom)]",children:Q?"text"===Q.status?(0,i.jsx)(k,{ref:er,original:Q.original,modified:Q.modified,viewMode:f?"inline":J,savedState:Q.editorState,initialLine:Q.initialLine,onSaveState:e=>t.saveDiffState(Q,e),onEscape:w},(0,R.Q)(Q)):"metadata"===Q.status?(0,i.jsxs)("div",{className:"grid h-full grid-cols-1 gap-4 overflow-auto p-4 md:grid-cols-2",children:[(0,i.jsx)("pre",{className:"whitespace-pre-wrap break-all text-sm",children:Q.originalMetadata}),(0,i.jsx)("pre",{className:"whitespace-pre-wrap break-all text-sm",children:Q.modifiedMetadata})]}):"loading"===Q.status||"unloaded"===Q.status?(0,i.jsx)(L,{}):(0,i.jsxs)("div",{className:"flex size-full flex-col items-center justify-center gap-3 p-6 text-center text-sm",children:[(0,i.jsx)("p",{className:"text-muted-foreground",children:"binary"===Q.status?K("binaryDiffUnavailable"):"too_large"===Q.status?K("largeDiffUnavailable"):Q.error}),"error"===Q.status?(0,i.jsx)(S.$,{variant:"outline",onClick:()=>t.reloadDiff(),children:K("readAgain")}):null]}):X&&Z?"loading"===Z.status||"unloaded"===Z.status?(0,i.jsx)(L,{}):"error"===Z.status?(0,i.jsxs)("div",{className:"flex size-full flex-col items-center justify-center gap-3 p-6 text-center",children:[(0,i.jsx)("p",{role:"alert",className:"text-sm text-destructive",children:Z.error}),(0,i.jsx)(S.$,{variant:"outline",onClick:()=>t.reloadFile(X),children:K("readAgain")})]}):"image"===Z.status?(0,i.jsx)(N.k,{mode:"inline",slides:[{src:Z.objectUrl,alt:X}],ariaLabel:K("imageViewer",{name:X.replaceAll("\\","/").split("/").at(-1)??X})},Z.objectUrl):"markdown"===ee&&"preview"===Z.viewMode?(0,i.jsx)($.n,{content:Z.content,label:K("markdownPreview",{name:X}),savedScrollTop:Z.previewScrollTop,onScroll:e=>t.savePreviewScrollTop(X,e)},X):"html"===ee&&"preview"===Z.viewMode?(0,i.jsx)("iframe",{ref:ea,className:"block size-full border-0 bg-white",sandbox:"allow-scripts",srcDoc:(0,P.z)(Z.content),title:K("htmlPreview",{name:X})}):(0,i.jsx)(b.e,{ref:ei,path:X,content:Z.content,size:Z.size,originalContent:ed?.status==="ready"?ed.original.content:void 0,onChanges:e=>{ed?.status==="ready"&&eh({original:ed.original.content,modified:Z.content,count:e})},onOpenDiff:em,savedState:Z.editorState,navigation:t.pendingNavigation,onNavigation:(e,s)=>t.consumeNavigation(e,s),onSaveState:(e,s)=>t.saveEditorState(e,s),onEscape:w},X):(0,i.jsxs)("div",{"data-testid":"file-workspace-empty",className:"flex size-full flex-col items-center justify-center gap-3 p-6 text-sm text-muted-foreground",children:[(0,i.jsx)(m.A,{className:"size-6"}),K("noOpenFile")]})})]})}function L(){let{t:e}=(0,x.Bd)("projectFiles");return(0,i.jsxs)("div",{className:"flex size-full items-center justify-center gap-2 text-sm text-muted-foreground",children:[(0,i.jsx)(f.A,{className:"size-4 animate-spin"}),e("loadingFile")]})}},73165:(e,t,s)=>{"use strict";s.d(t,{D:()=>d});var i=s(7962),r=s(60454),a=s(93750),n=s(74675),o=s(1364),l=s(49426),c=s(13464);function d({children:e}){return(0,i.jsx)(o.JW,{children:(0,i.jsx)(r.y,{className:"isolate z-[130] outline-none",side:"right",align:"start",alignOffset:4,children:(0,i.jsx)(a._,{"data-slot":"context-menu-content",finalFocus:!1,className:(0,l.cn)(c.hD,"flex flex-col overflow-hidden p-0"),children:(0,i.jsx)(n.V,{className:"min-h-0",viewportClassName:"p-1",children:e})})})})}},73429:(e,t,s)=>{"use strict";s.d(t,{p:()=>n});var i=s(7962);s(69266);var r=s(53555),a=s(49426);function n({className:e,type:t,...s}){return(0,i.jsx)(r.p,{type:t,"data-slot":"input",className:(0,a.cn)("min-h-8 w-full min-w-0 rounded-lg border border-input bg-card px-2.5 py-1 text-sm leading-5 transition-colors duration-150 outline-none file:inline-flex file:h-6 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:outline-2 focus-visible:outline-solid focus-visible:-outline-offset-2 focus-visible:outline-ring disabled:pointer-events-none disabled:cursor-not-allowed disabled:bg-muted disabled:opacity-50 aria-invalid:border-destructive aria-invalid:outline-destructive",e),...s})}},74675:(e,t,s)=>{"use strict";s.d(t,{V:()=>u});var i=s(7962);s(69266);var r=s(82611),a=s(40709),n=s(51173),o=s(49426),l=s(93061),c=s(87425);function d({className:e,orientation:t="vertical",...s}){return(0,i.jsx)(l.V,{"data-slot":"scroll-area-scrollbar","data-orientation":t,orientation:t,className:(0,o.cn)("flex touch-none p-px transition-colors select-none data-horizontal:h-2.5 data-horizontal:flex-col data-horizontal:border-t data-horizontal:border-t-transparent data-vertical:h-full data-vertical:w-2.5 data-vertical:border-l data-vertical:border-l-transparent",e),...s,children:(0,i.jsx)(c.l,{"data-slot":"scroll-area-thumb",className:"relative flex-1 rounded-full bg-border"})})}function u({className:e,viewportClassName:t,viewportRef:s,onViewportScroll:l,children:c,...h}){return(0,i.jsxs)(r.V,{"data-slot":"l4-scroll-area",className:(0,o.cn)("relative min-h-0 overflow-hidden",e),...h,children:[(0,i.jsx)(a.B,{ref:s,"data-slot":"l4-scroll-area-viewport",className:(0,o.cn)("size-full rounded-[inherit] outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1",t),onScroll:l,children:c}),(0,i.jsx)(d,{className:"data-[orientation=vertical]:h-full data-[orientation=vertical]:w-2.5 data-[orientation=vertical]:border-l data-[orientation=vertical]:border-l-transparent"}),(0,i.jsx)(n.I,{})]})}},79137:(e,t,s)=>{"use strict";async function i(e){let t="u"<typeof navigator?void 0:navigator.clipboard;if(t?.writeText)try{return await t.writeText(e),!0}catch{}if("u"<typeof document||!document.body)return!1;let s=document.activeElement instanceof HTMLElement?document.activeElement:null,i=document.createElement("textarea");i.value=e,i.setAttribute("readonly",""),i.setAttribute("aria-hidden","true"),i.style.position="fixed",i.style.top="-9999px",i.style.left="-9999px",i.style.width="1px",i.style.height="1px",i.style.opacity="0";try{return document.body.append(i),i.select(),i.setSelectionRange(0,i.value.length),document.execCommand("copy")}catch{return!1}finally{i.remove();try{s?.focus()}catch{}}}s.d(t,{h3:()=>i,qj:()=>r});class r extends Error{constructor(e){super(e.message,{cause:e.cause}),this.name="PiDeskBrowserPluginError",this.pluginName=e.pluginName,this.contributionName=e.contributionName??null,this.phase=e.phase}}},80077:(e,t,s)=>{"use strict";s.d(t,{Gm:()=>l,Jk:()=>o});var i=s(38979),r=s(66453),a=s(70698);let n=i.k5(["title","user","assistant","sessionId"]),o=i.Ik({scope:n,count:i.ai().int().positive(),entryId:r.Rv.nullable(),timestampMs:a.k.nullable(),preview:i.Yj().min(1).max(160)}).strict(),l=i.Ik({query:i.Yj().trim().max(120).default(""),searchIn:i.YO(n).min(1).max(4).default(["title","user"])}).strict()},81649:(e,t,s)=>{"use strict";s.d(t,{Ke:()=>c,Nt:()=>o,R6:()=>l});var i=s(7962),r=s(87946),a=s(36700),n=s(14064);function o({...e}){return(0,i.jsx)(r.N,{"data-slot":"collapsible",...e})}function l({...e}){return(0,i.jsx)(a.R,{"data-slot":"collapsible-trigger",...e})}function c({...e}){return(0,i.jsx)(n.j,{"data-slot":"collapsible-content",...e})}},82075:(e,t,s)=>{"use strict";function i(e,t){return`${e}:${t}`}function r(e,t){return e?`${e}/${t}`:t}function a(e,t){return e.localeCompare(t,void 0,{numeric:!0,sensitivity:"base"})}function n(e,t,s=new Set){let i=[e],r=e;for(;!s.has(r);){let e=t(r);if(!e||s.has(e)||!e.startsWith(`${r}/`))break;i.push(e),r=e}return{path:e,targetPath:r,paths:i,label:r.slice(e.lastIndexOf("/")+1)}}function o(e,t=""){let s={path:t,directories:new Map,files:[]},i=new Map([[t,s]]);for(let a of e){let e=(t?a.slice(t.length+1):a).split("/"),n=s;for(let t of e.slice(0,-1)){let e=r(n.path,t),s=i.get(e);s||(s={path:e,directories:new Map,files:[]},i.set(e,s),n.directories.set(e,s)),n=s}n.files.push(a)}return i}function l(e,t,s){return n(e,e=>{let s=t.get(e);return s&&0===s.files.length&&1===s.directories.size?s.directories.keys().next().value??null:null},s)}function c(e,t,s=""){let r=[],n=(s,o)=>{let c=e.get(s);if(c){for(let s of[...c.directories.keys()].sort(a)){let a=l(s,e),c=!a.paths.some(e=>t.has(e));r.push({key:i("directory",s),type:"directory",path:a.targetPath,label:a.label,depth:o,directory:a,expanded:c}),c&&n(a.targetPath,o+1)}for(let e of[...c.files].sort(a))r.push({key:i("file",e),type:"file",path:e,label:e.slice(e.lastIndexOf("/")+1),depth:o})}};return n(s,0),r}s.d(t,{Im:()=>i,Kn:()=>a,OA:()=>o,_J:()=>r,qV:()=>c,rk:()=>n,xV:()=>l})},83029:e=>{e.exports={markdown:"l4-markdown_markdown__oIf6d",status:"l4-markdown_status__EVcKw",alert:"l4-markdown_alert__Aooao",alertTitle:"l4-markdown_alertTitle__GIoFs",alertBody:"l4-markdown_alertBody__BtDVT"}},86062:(e,t,s)=>{"use strict";s.d(t,{T8:()=>g,WW:()=>x,aD:()=>n,co:()=>h,lw:()=>v,ph:()=>f,xv:()=>d,yw:()=>p});var i=s(38979),r=s(67765),a=s(24985);let n=i.Yj().regex(/^(?:[0-9a-f]{40}|[0-9a-f]{64})$/),o=i.KC([n,i.eu("HEAD"),i.Yj().max(1024).regex(/^refs\/(?:heads|remotes)\/[^\0\r\n]+$/)]).refine(e=>!e.includes("..")&&!e.endsWith("/"),"Git 版本无效"),l=i.KC([i.Ik({commit:o,parent:n.optional()}).strict(),i.Ik({base:o,target:o,strategy:i.k5(["merge-base","direct"])}).strict()]),c=i.Ik({base:n.nullable(),target:n,original:n.nullable()}).strict(),d=i.Ik({baseCommit:n.nullable(),targetCommit:n,oldPath:r._g.optional()}).strict(),u=i.Ik({oid:n,parents:i.YO(n),subject:i.Yj(),author:i.Yj(),timestampMs:i.ai().int(),refs:i.YO(i.Yj())}).strict(),h=i.Ik({tip:o,exclude:o.optional(),query:i.Yj().trim().max(200).default(""),author:i.Yj().trim().max(200).optional(),page:i.Ik({index:i.ai().int().min(1).max(2e3),size:i.ai().int().min(1).max(100)}).strict()}).strict(),p=i.Ik({tip:n.nullable(),exclude:n.nullable(),items:i.YO(u),hasMore:i.zM(),truncated:i.zM()}).strict(),m=i.Ik({path:r._g,oldPath:r._g.nullable(),status:i.k5(["added","modified","deleted","renamed","type-changed"])}).strict(),f=i.Ik({selection:l,page:i.Ik({index:i.ai().int().min(1).max(5e4),size:i.ai().int().min(1).max(500)}).strict()}).strict(),g=i.Ik({comparison:c,commit:u.extend({message:i.Yj(),selectedParent:n.nullable()}).nullable(),items:i.YO(m),hasMore:i.zM(),truncated:i.zM()}).strict(),x=a.gf.extend({upstream:i.Ik({ref:i.Yj(),ahead:i.ai().int().nonnegative().nullable(),behind:i.ai().int().nonnegative().nullable()}).strict().nullable()}).strict(),v=i.KC([a.FJ,i.Ik({kind:i.eu("metadata"),original:i.Yj(),modified:i.Yj()}).strict()])},86963:(e,t,s)=>{"use strict";s.d(t,{$:()=>l,r:()=>o});var i=s(7962),r=s(28549),a=s(73392),n=s(49426);let o=(0,a.F)("group/button inline-flex shrink-0 items-center justify-center rounded-lg border border-transparent bg-clip-padding text-sm font-medium whitespace-nowrap cursor-pointer transition-colors duration-150 ease-out outline-none select-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-solid focus-visible:outline-ring disabled:pointer-events-none disabled:opacity-50 aria-pressed:bg-accent aria-pressed:text-accent-foreground aria-pressed:hover:bg-[color-mix(in_oklab,var(--accent),var(--foreground)_5%)] aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-[color-mix(in_oklab,var(--primary),var(--primary-foreground)_8%)] active:bg-[color-mix(in_oklab,var(--primary),var(--primary-foreground)_14%)]",outline:"border-border bg-card text-card-foreground hover:bg-accent active:bg-[color-mix(in_oklab,var(--accent),var(--foreground)_6%)] aria-expanded:bg-accent aria-expanded:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-[color-mix(in_oklab,var(--secondary),var(--foreground)_8%)] active:bg-[color-mix(in_oklab,var(--secondary),var(--foreground)_14%)] aria-expanded:bg-accent aria-expanded:text-accent-foreground",ghost:"hover:bg-foreground/8 hover:text-foreground active:bg-foreground/14 aria-expanded:bg-accent aria-expanded:text-accent-foreground",destructive:"bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40",link:"text-foreground underline underline-offset-4 hover:text-muted-foreground"},size:{default:"min-h-8 gap-2 px-2 py-1",xs:"min-h-7 gap-2 rounded-md px-2 py-0.5 text-sm",sm:"min-h-7 gap-2 rounded-md px-2 py-0.5 text-sm",lg:"min-h-10 gap-2 px-3 py-2",icon:"size-8","icon-xs":"size-7 rounded-md","icon-sm":"size-7 rounded-md","icon-lg":"size-10"}},defaultVariants:{variant:"default",size:"default"}});function l({className:e,variant:t="default",size:s="default",...a}){return(0,i.jsx)(r.$,{"data-slot":"button",className:(0,n.cn)(o({variant:t,size:s,className:e})),...a})}},89790:(e,t,s)=>{"use strict";s.d(t,{G7:()=>d,L$:()=>p,h_:()=>m,oI:()=>u,uB:()=>c,xL:()=>h});var i=s(7962);s(69266);var r=s(30442),a=s(49426);s(5464);var n=s(17511),o=s(41148),l=s(90458);function c({className:e,...t}){return(0,i.jsx)(r.uB,{"data-slot":"command",className:(0,a.cn)("flex size-full flex-col overflow-hidden rounded-lg bg-popover p-1 text-popover-foreground",e),...t})}function d({className:e,...t}){return(0,i.jsx)("div",{"data-slot":"command-input-wrapper",className:"p-1 pb-0",children:(0,i.jsxs)(n.MG,{className:"has-[[data-slot=command-input]:focus-visible]:outline-2 has-[[data-slot=command-input]:focus-visible]:outline-solid has-[[data-slot=command-input]:focus-visible]:-outline-offset-2 has-[[data-slot=command-input]:focus-visible]:outline-ring",children:[(0,i.jsx)(r.uB.Input,{"data-slot":"command-input",className:(0,a.cn)("min-h-8 w-full bg-transparent px-2.5 text-sm leading-5 outline-none disabled:cursor-not-allowed disabled:opacity-50",e),...t}),(0,i.jsx)(n.Sq,{children:(0,i.jsx)(o.A,{className:"size-4 shrink-0 opacity-50"})})]})})}function u({className:e,...t}){return(0,i.jsx)(r.uB.List,{"data-slot":"command-list",className:(0,a.cn)("pi-desk-chat-scrollbar max-h-72 scroll-py-1 overflow-x-hidden overflow-y-auto outline-none",e),...t})}function h({className:e,...t}){return(0,i.jsx)(r.uB.Empty,{"data-slot":"command-empty",className:(0,a.cn)("py-6 text-center text-sm",e),...t})}function p({className:e,...t}){return(0,i.jsx)(r.uB.Group,{"data-slot":"command-group",className:(0,a.cn)("overflow-hidden p-1 text-foreground **:[[cmdk-group-heading]]:px-2 **:[[cmdk-group-heading]]:py-1.5 **:[[cmdk-group-heading]]:text-xs **:[[cmdk-group-heading]]:font-medium **:[[cmdk-group-heading]]:text-muted-foreground",e),...t})}function m({className:e,children:t,...s}){return(0,i.jsxs)(r.uB.Item,{"data-slot":"command-item",className:(0,a.cn)("group/command-item relative flex min-h-8 cursor-pointer items-center gap-2 rounded-md px-2 py-1 text-sm leading-5 outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 data-[selected=true]:*:[svg]:text-foreground",e),...s,children:[t,(0,i.jsx)(l.A,{className:"ml-auto opacity-0 group-has-data-[slot=command-shortcut]/command-item:hidden group-data-[checked=true]/command-item:opacity-100"})]})}},90064:e=>{e.exports={host:"l4-code-line-markers_host__BBo2H",added:"l4-code-line-markers_added__oTNsK",modified:"l4-code-line-markers_modified__PZnY_",deletedBefore:"l4-code-line-markers_deletedBefore___1b0w",deletedAfter:"l4-code-line-markers_deletedAfter__SEoHy"}},90434:(e,t,s)=>{"use strict";s.d(t,{AM:()=>u,Wv:()=>h,eO:()=>m,hl:()=>p});var i=s(7962);s(69266);var r=s(50960),a=s(40252),n=s(17596),o=s(80168),l=s(40287),c=s(76624),d=s(49426);function u({...e}){return(0,i.jsx)(r.y,{"data-slot":"popover",...e})}function h({...e}){return(0,i.jsx)(a.W,{"data-slot":"popover-trigger",...e})}function p({className:e,positionerClassName:t,align:s="center",alignOffset:r=0,side:a="bottom",sideOffset:c=4,finalFocus:u=!1,...h}){return(0,i.jsx)(n.i,{children:(0,i.jsx)(o.U,{align:s,alignOffset:r,side:a,sideOffset:c,className:(0,d.cn)("isolate z-50",t),children:(0,i.jsx)(l.i,{"data-slot":"popover-content",finalFocus:u,className:(0,d.cn)("z-50 flex w-80 max-w-[calc(100vw-2rem)] origin-(--transform-origin) flex-col gap-3 rounded-lg border border-border bg-popover p-3 text-sm text-popover-foreground shadow-md outline-hidden duration-100 motion-reduce:animate-none data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",e),...h})})})}function m({className:e,...t}){return(0,i.jsx)(c.e,{"data-slot":"popover-title",className:(0,d.cn)("font-medium",e),...t})}},90504:(e,t,s)=>{"use strict";s.d(t,{e:()=>h});var i=s(7962),r=s(14044),a=s(69266),n=s(78121),o=s(91182),l=s(18302),c=s(33550),d=s(90064),u=s.n(d);let h=(0,a.forwardRef)(function({path:e,content:t,size:d,savedState:h,onSaveState:p,onEscape:m,originalContent:f,onChanges:g,onOpenDiff:x,navigation:v,onNavigation:b},y){let{t:w}=(0,n.Bd)("common"),{t:j}=(0,n.Bd)("projectFiles"),{wrapLines:k}=(0,c.TX)(),N=(0,a.useRef)(null),C=(0,a.useRef)(null),S=(0,a.useRef)(p),R=(0,a.useRef)(k),z=(0,a.useRef)(h),D=(0,a.useRef)(m),A=(0,a.useRef)(null),M=(0,a.useRef)(g),P=(0,a.useRef)(x),$=(0,a.useRef)(b),T=(0,a.useRef)(null),O=(0,a.useRef)(null),L=(0,a.useCallback)(e=>{let t=O.current;T.current?.clear(),null===t||t>(e.getModel()?.getLineCount()??0)||(T.current??=e.createDecorationsCollection(),T.current.set([{range:{startLineNumber:t,startColumn:1,endLineNumber:t,endColumn:1},options:{isWholeLine:!0,className:"bg-accent"}}]))},[]);(0,a.useEffect)(()=>{z.current=h,D.current=m,M.current=g,P.current=x,$.current=b},[g,m,x,b,h]);let[E,I]=(0,a.useState)("loading");return(0,a.useEffect)(()=>{S.current=p},[p]),(0,a.useEffect)(()=>{R.current=k},[k]),(0,a.useImperativeHandle)(y,()=>({openSearch(){C.current?.getAction("actions.find")?.run()},gotoLine(){C.current?.getAction("editor.action.gotoLine")?.run()},getSelectionText(){let e=C.current,t=e?.getModel(),s=e?.getSelection();return t&&s&&!s.isEmpty()?t.getValueInRange(s):""},getViewState:()=>C.current?.saveViewState()??null,focus(){C.current?.focus()},previousChange(){A.current?.previousChange()},nextChange(){A.current?.nextChange()}}),[]),(0,a.useEffect)(()=>{let i=N.current;if(!i)return;let r=!0,a=null,n=null,c=null,h=()=>void 0,p=()=>void 0;return queueMicrotask(()=>{r&&I("loading")}),(0,o.cu)().then(m=>{r&&(n=m.editor.createModel(t,(0,o.ix)(e,d),(0,o.B3)(m,e,"preview")),a=m.editor.create(i,{model:n,theme:(0,o.dC)(),readOnly:!0,domReadOnly:!0,editContext:!1,automaticLayout:!0,minimap:{enabled:!1},stickyScroll:{enabled:!1},scrollBeyondLastLine:!1,smoothScrolling:!1,wordWrap:R.current?"on":"off",wrappingIndent:"same",...(0,o.R)(),lineNumbersMinChars:3,lineDecorationsWidth:26,folding:d<=1048576,renderValidationDecorations:"off",renderWhitespace:"selection",bracketPairColorization:{enabled:d<=1048576},unicodeHighlight:{nonBasicASCII:!1},padding:{top:10,bottom:10},overviewRulerBorder:!1,contextmenu:!0,ariaLabel:w("codeReadOnly")}),z.current&&a.restoreViewState(z.current),D.current&&(0,l.e)(a,m.KeyCode.Escape,()=>D.current?.()),C.current=a,void 0!==f&&(A.current=c=function(e,t,i){let r=e.createDecorationsCollection(),a=e.getModel()?.getLineCount()??1,n=[],o=!0,l=null,c=null,d=[u().added,u().modified,u().deletedBefore,u().deletedAfter].map(e=>`.${e}`).join(","),h=e=>Math.min(a,"deleted"===e.kind?Math.max(1,e.modifiedStartLineNumber-1):e.modifiedStartLineNumber),p=()=>{null!==c&&clearTimeout(c),c=null,l?.terminate(),l=null},m=e=>{o&&(p(),n=e??[],r.set(n.map(e=>{let s="deleted"===e.kind,r=h(e),a=s?r:e.modifiedEndLineNumberExclusive-1,n=s?e.originalEndLineNumberExclusive-e.originalStartLineNumber:e.modifiedEndLineNumberExclusive-e.modifiedStartLineNumber,o={added:["#16803c","#59c77b"],modified:["#216bcc","#6aabff"],deleted:["#d12c38","#ff757f"]}[e.kind],l=s?1===e.modifiedStartLineNumber?u().deletedBefore:u().deletedAfter:u()[e.kind];return{range:new t.Range(r,1,a,1),options:{isWholeLine:!s,showIfCollapsed:!0,linesDecorationsClassName:s?void 0:l,firstLineDecorationClassName:s?l:void 0,linesDecorationsTooltip:i.tooltip(e.kind,n),overviewRuler:{color:o[0],darkColor:o[1],position:t.editor.OverviewRulerLane.Left}}}})),null===e&&console.warn("[Pi Desk][CodePreview] 行标记不可用,计算失败或超过限制",{path:i.path}),i.onChanges(e?.length??null))},f=e.onMouseDown(e=>{if(e.target.type!==t.editor.MouseTargetType.GUTTER_LINE_DECORATIONS||!e.target.element?.closest(d))return;let s=e.target.position?.lineNumber;void 0===s||n.find(e=>"deleted"===e.kind?h(e)===s:e.modifiedStartLineNumber<=s&&s<e.modifiedEndLineNumberExclusive)&&i.onOpenDiff(s)});try{(l=new Worker(s.tu(new URL(s.p+s.u(58779),s.b)),{type:void 0,name:"pi-desk-line-changes"})).onmessage=e=>m(e.data),l.onerror=()=>m(null),l.onmessageerror=()=>m(null),c=setTimeout(()=>m(null),3e3),l.postMessage({original:i.original,modified:i.modified})}catch{m(null)}let g=t=>{if(0===n.length)return;let s=e.getPosition()?.lineNumber??1,i=n.map(h),r="next"===t?i.find(e=>e>s)??i[0]:i.findLast(e=>e<s)??i[i.length-1];e.setPosition({lineNumber:r,column:1}),e.revealLineInCenter(r),e.focus()};return{previousChange(){g("previous")},nextChange(){g("next")},dispose(){o=!1,p(),f.dispose(),r.clear(),n=[]}}}(a,m,{path:e,original:f,modified:t,tooltip:(e,t)=>j({added:"gitAddedLines",modified:"gitModifiedLines",deleted:"gitDeletedLines"}[e],{count:t}),onChanges:e=>M.current?.(e),onOpenDiff:e=>P.current?.(e)})),h=(0,o.Tr)(e=>m.editor.setTheme(e)),p=(0,o.BK)(e=>a?.updateOptions(e)),L(a),I("ready"))}).catch(t=>{r&&(console.error("[Pi Desk][CodePreview] Monaco 加载失败",{path:e,errorName:t instanceof Error?t.name:"UnknownError"}),I("error"),void 0!==f&&M.current?.(null))}),()=>{r=!1,h(),p(),c?.dispose(),A.current=null,a&&(z.current=a.saveViewState(),S.current(e,z.current)),T.current?.clear(),T.current=null,C.current=null,a?.dispose(),n?.dispose()}},[t,f,L,e,j,d,w]),(0,a.useEffect)(()=>{C.current?.updateOptions({wordWrap:k?"on":"off"})},[k]),(0,a.useEffect)(()=>{let t=C.current;if(!v||"ready"!==E||!t)return;let s=t.getModel(),i=!!(s&&v.line>=1&&v.line<=s.getLineCount());O.current=i?v.line:null,L(t),i&&(t.setPosition({lineNumber:v.line,column:1}),t.revealLineInCenter(v.line),z.current=t.saveViewState(),S.current(e,z.current)),$.current?.(v,i)},[E,v,L,e]),(0,i.jsxs)("div",{"data-testid":"code-preview",className:"relative h-full min-h-0 w-full overflow-hidden bg-background",children:[(0,i.jsx)("div",{ref:N,className:`size-full ${u().host}`}),"loading"===E?(0,i.jsxs)("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center gap-2 bg-background text-sm text-muted-foreground",children:[(0,i.jsx)(r.A,{className:"size-4 animate-spin"})," ",w("codeLoading")]}):null,"error"===E?(0,i.jsx)("div",{className:"absolute inset-0 flex items-center justify-center p-6 text-center text-sm text-destructive",children:w("codeFailed")}):null]})})},91182:(e,t,s)=>{"use strict";s.d(t,{B3:()=>h,BK:()=>n,R:()=>a,Tr:()=>u,cu:()=>c,dC:()=>d,ix:()=>p});var i=s(67765),r=s(48708);function a(){let e=Number.parseFloat(getComputedStyle(document.documentElement).fontSize)/16;return{fontFamily:'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace',fontSize:14*e,lineHeight:Math.round(22*e)}}function n(e){let t=new MutationObserver(()=>e(a()));return t.observe(document.documentElement,{attributes:!0,attributeFilter:["data-pi-desk-display-size"]}),()=>t.disconnect()}let o=null,l=0;function c(){return o||(o=(async()=>{(0,r.fx)()?.locale==="zh-CN"&&await s.e(12212).then(s.t.bind(s,12212,23));let{monaco:e}=await Promise.all([s.e(87221),s.e(46550),s.e(62134),s.e(38459),s.e(95287),s.e(54206),s.e(87086)]).then(s.bind(s,87086));return globalThis.MonacoEnvironment={getWorker:(e,t)=>new Worker(s.tu(new URL(s.p+s.u(53291),s.b)),{type:void 0,name:t})},e})())}function d(){return document.documentElement.classList.contains("dark")?"vs-dark":"vs"}function u(e){let t=new MutationObserver(()=>e(d()));return t.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>t.disconnect()}function h(e,t,s){l+=1;let i=t.split("/").map(e=>encodeURIComponent(e)).join("/");return e.Uri.parse(`inmemory://pi-desk/${l}/${s}/${i}`)}function p(e,t){if(t>i.gB)return"plaintext";let s=e.replaceAll("\\","/").split("/").at(-1)?.toLocaleLowerCase()??"";return"dockerfile"===s?"dockerfile":"makefile"===s?"plaintext":({bat:"bat",c:"c",cc:"cpp",cjs:"javascript",cpp:"cpp",cs:"csharp",css:"css",dockerfile:"dockerfile",go:"go",h:"cpp",hpp:"cpp",htm:"html",html:"html",ini:"ini",java:"java",js:"javascript",json:"javascript",jsonl:"javascript",jsx:"javascript",kt:"kotlin",less:"less",lua:"lua",md:"markdown",mdx:"markdown",mjs:"javascript",php:"php",ps1:"powershell",py:"python",rb:"ruby",rs:"rust",scss:"scss",sh:"shell",sql:"sql",swift:"swift",toml:"ini",ts:"typescript",tsx:"typescript",txt:"plaintext",xml:"xml",yaml:"yaml",yml:"yaml"})[s.includes(".")?s.split(".").at(-1)??"":""]??"plaintext"}},93119:(e,t,s)=>{"use strict";s.d(t,{$:()=>n,P:()=>a});var i=s(94853),r=s(93320);async function a(e,t,s,a){await (0,r.QL)(e,i.Ot,{...t,path:s,targetType:a})}function n(e,t){let s=/^[a-zA-Z]:[\\/]/.test(e)||e.startsWith("\\\\"),i=s?"\\":"/",r=(s?e.replaceAll("/","\\"):e).replace(/[\\/]+$/,"");return t?`${r}${i}${t.replaceAll("/",i)}`:/^[a-z]:$/i.test(r)?`${r}${i}`:r||i}},93320:(e,t,s)=>{"use strict";s.d(t,{QL:()=>n,Y4:()=>o,aw:()=>a});var i=s(73230),r=s(94853);class a extends Error{constructor(e,t,s,i=null){super(s),this.status=e,this.code=t,this.errorKey=i,this.name="L3ProjectRequestError"}}async function n(e,t,s,r){let n=await fetch(t.path,{method:"POST",headers:{"Content-Type":"application/json","X-Pi-Desk-Client-Id":e},body:JSON.stringify(t.request.parse(s)),signal:r}),o=await n.json();if(!n.ok||0!==o.code||null===o.data)throw new a(n.status,o.code,o.msg?(0,i.B)(o):"项目读取失败",o.i18n?.key??null);return t.response.parse(o.data)}function o(e,t,s){async function i(t,i,r){try{return await n(e,t,i,r)}catch(e){throw!r?.aborted&&e instanceof a&&401===e.status&&s?.(),e}}return{list:(e,s)=>i(r.Xe,{...t,path:e},s),search:(e,s)=>i(r.fg,{...t,...e},s),get:(e,s,a)=>i(r.ZI,{...t,path:e,imagePreviewMode:s},a),snapshot:(e,s)=>i(r.p0,{...t,refresh:s},e),branches:(e,s)=>i(r.ry,{...t,repositoryRoot:e},s),log:(e,s,a)=>i(r.p3,{...t,repositoryRoot:e,...s},a),changes:(e,s,a)=>i(r.ys,{...t,repositoryRoot:e,...s},a),diff:(e,s,a,n)=>i(r.OC,{...t,repositoryRoot:e,path:s,comparison:n},a)}}},94853:(e,t,s)=>{"use strict";s.d(t,{OC:()=>y,Ot:()=>u,Xe:()=>h,ZI:()=>m,_X:()=>g,fg:()=>p,p0:()=>f,p3:()=>v,ry:()=>x,ys:()=>b});var i=s(38979),r=s(67765),a=s(24985),n=s(86062);let o=i.Ik({cwd:i.Yj().trim().min(1).max(4096),workId:i.Yj().trim().min(1).optional()}).strict(),l=o.extend({repositoryRoot:r.rh}),c=o.extend({path:r.eC,imagePreviewMode:r.p$}).superRefine((e,t)=>{e.workId||r._g.safeParse(e.path).success||t.addIssue({code:"custom",path:["path"],message:"独立项目预览只接受根内相对路径"})}),d=i.k5(["file","directory"]),u={path:"/api/project-files/reveal",request:o.extend({path:i.KC([r.rh,r.eC]),targetType:d.optional()}).refine(e=>""!==e.path||"directory"===e.targetType,"文件路径不能为空").refine(e=>e.workId&&"directory"!==e.targetType||r.rh.safeParse(e.path).success,"独立项目和目录定位只接受根内相对路径"),response:i.Ik({}).strict()},h={path:"/api/project-files/list",request:o.extend({path:r.rh}).strict(),response:r.JH},p={path:"/api/project-files/search",request:o.extend(r.Nu.shape).strict(),response:r.jI},m={path:"/api/project-files/get",request:c,response:r.ih},f={path:"/api/project-git/get",request:o.extend({refresh:i.zM().optional()}).strict(),response:i.Ik({repositories:i.YO(a.u2).max(100)}).strict()},g={path:"/api/project-git-heads/get",request:o,response:i.Ik({repositories:i.YO(a.yl).max(a.y2)}).strict()},x={path:"/api/project-git-branches/list",request:l.strict(),response:n.WW},v={path:"/api/project-git-log/list",request:l.extend(n.co.shape).strict(),response:n.yw},b={path:"/api/project-git-changes/list",request:l.extend(n.ph.shape).strict(),response:n.T8},y={path:"/api/project-git-diff/get",request:l.extend({path:r._g,comparison:n.xv.optional()}).strict(),response:n.lw}},97921:(e,t,s)=>{"use strict";function i(e){return/\.(md|markdown)$/i.test(e)?"markdown":/\.html?$/i.test(e)?"html":null}s.d(t,{g:()=>i})},99084:(e,t,s)=>{"use strict";s.d(t,{x:()=>r});var i=s(79137);function r(e){return(0,i.h3)(e)}}}]);