@shaohui_jin/git-cockpit-mcp-server 0.1.9 → 0.1.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,126 @@
1
+ import{az as Et,c as se,G as ze,d as ht,w as Te,a6 as ns,O as Y,W as f,aj as H,aA as tn,aB as It,L as h,a0 as v,P as p,$,u as I,M as P,F as ue,ae as _e,_ as L,Y as ss,k as W,aq as Ft,S as Fe,ac as Ue,Z as j,i as We,e as Yt,X as At,ak as Bt,n as ls,aC as Dn,aD as is,aE as os,aw as as,aF as rs}from"./vue-BLng4iTN.js";import{E as ie,a as Tt,e as us}from"./element-plus-C2rArbe6.js";(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const l of document.querySelectorAll('link[rel="modulepreload"]'))e(l);new MutationObserver(l=>{for(const i of l)if(i.type==="childList")for(const a of i.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&e(a)}).observe(document,{childList:!0,subtree:!0});function n(l){const i={};return l.integrity&&(i.integrity=l.integrity),l.referrerPolicy&&(i.referrerPolicy=l.referrerPolicy),l.crossOrigin==="use-credentials"?i.credentials="include":l.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function e(l){if(l.ep)return;l.ep=!0;const i=n(l);fetch(l.href,i)}})();class Qt extends Error{constructor(t,n,e,l){super(t),this.status=n,this.code=e,this.requiredApproval=l,this.name="ApiError"}}async function Re(s,t,n){let e;try{e=await fetch(t,{method:s,headers:n!==void 0?{"Content-Type":"application/json"}:void 0,body:n!==void 0?JSON.stringify(n):void 0})}catch(l){throw new Qt(`无法连接后端服务(${t}):${l instanceof Error?l.message:String(l)}`,0)}if(!e.ok){let l=e.statusText,i,a;try{const c=await e.json();typeof c.error=="string"?(l=c.error,i=c.code,a=c.requiredApproval):c.error&&typeof c.error=="object"?(l=c.error.message??l,i=c.error.code??c.code,a=c.error.requiredApproval??c.requiredApproval):c.message&&(l=c.message,i=c.code,a=c.requiredApproval)}catch{}throw new Qt(l,e.status,i,a)}return await e.json()}function ds(){return Re("GET","/api/repos")}function cs(s){return Re("POST","/api/repos/open",{path:s})}function fs(s){return Re("POST",`/api/repos/${s}/activate`)}function ps(s){return Re("DELETE",`/api/repos/${s}`)}function ms(s){return Re("GET",`/api/repos/${s}/status`)}function hs(s,t={}){const n=new URLSearchParams;t.maxCount&&n.set("maxCount",String(t.maxCount)),t.all&&n.set("all","true"),t.path&&n.set("path",t.path),t.from&&n.set("from",t.from),t.to&&n.set("to",t.to),t.author&&n.set("author",t.author);const e=n.toString();return Re("GET",`/api/repos/${s}/log${e?`?${e}`:""}`)}function vs(s,t={}){const n=new URLSearchParams;t.from&&n.set("from",t.from),t.to&&n.set("to",t.to),t.path&&n.set("path",t.path),t.staged&&n.set("staged","true");const e=n.toString();return Re("GET",`/api/repos/${s}/diff${e?`?${e}`:""}`)}function gs(s,t){return Re("GET",`/api/repos/${s}/show/${encodeURIComponent(t)}`)}function bs(s){return Re("GET",`/api/repos/${s}/branches`)}function ys(s){return Re("GET",`/api/repos/${s}/stashes`)}function Fn(s){return Re("GET",`/api/repos/${s}/remotes`)}function mt(s,t,n={}){return Re("POST",`/api/repos/${s}/tools/${t}`,{params:n})}function _s(s={}){const t=new URLSearchParams;s.limit&&t.set("limit",String(s.limit)),s.tool&&t.set("tool",s.tool);const n=t.toString();return Re("GET",`/api/logs${n?`?${n}`:""}`)}function ks(s,t){const n=new URLSearchParams;s!=null&&n.set("repoId",String(s)),t!=null&&t.validateToken&&n.set("validateToken","1");const e=n.toString();return Re("GET",`/api/settings${e?`?${e}`:""}`)}function ws(s,t){const n=t!=null?`?repoId=${t}`:"";return Re("PUT",`/api/settings${n}`,s)}function Cs(){return Re("GET","/api/health")}function $s(s){const t=new EventSource("/api/events");return s.onRepoChanged&&t.addEventListener("repo-changed",n=>{var e;return(e=s.onRepoChanged)==null?void 0:e.call(s,JSON.parse(n.data))}),s.onLog&&t.addEventListener("log",()=>{var n;return(n=s.onLog)==null?void 0:n.call(s)}),s.onError&&(t.onerror=n=>{var e;return(e=s.onError)==null?void 0:e.call(s,n)}),()=>t.close()}const Zt="git-cockpit:currentRepoId";function gn(){try{const s=Number(window.localStorage.getItem(Zt));return Number.isInteger(s)&&s>0?s:null}catch{return null}}function Gt(s){try{s===null?window.localStorage.removeItem(Zt):window.localStorage.setItem(Zt,String(s))}catch{}}const Ae=Et("repos",{state:()=>({repos:[],currentId:gn(),loading:!1,error:null,healthOk:null}),getters:{current(s){return s.repos.find(t=>t.id===s.currentId)??null},currentPath(s){var t;return((t=s.repos.find(n=>n.id===s.currentId))==null?void 0:t.path)??null}},actions:{async checkHealth(){try{const s=await Cs();this.healthOk=s.ok}catch{this.healthOk=!1}return this.healthOk===!0},async load(){var s;this.loading=!0,this.error=null;try{const{repos:t}=await ds();this.repos=t;const n=gn();n!==null&&t.some(e=>e.id===n)?this.currentId=n:(!this.currentId||!t.some(e=>e.id===this.currentId))&&(this.currentId=((s=t[0])==null?void 0:s.id)??null),Gt(this.currentId)}catch(t){this.error=t instanceof Error?t.message:String(t)}finally{this.loading=!1}},async open(s){const{repo:t}=await cs(s);return await this.load(),t},async activate(s){const{repo:t}=await fs(s);return this.currentId=s,Gt(s),await this.load(),t},async remove(s){await ps(s),this.currentId===s&&(this.currentId=null),await this.load()},switchTo(s){this.currentId=s,Gt(s)}}}),xs=()=>({method:"browser",defaultRemote:"origin",remotes:[],current:null,hosts:[],cli:{gh:{name:"gh",found:!1,loggedIn:!1,installUrl:"https://cli.github.com/"},glab:{name:"glab",found:!1,loggedIn:!1,installUrl:"https://gitlab.com/gitlab-org/cli/-/releases"}}});function nn(s){let t=s.trim();if(!t)return null;if(t.startsWith("git@")){const n=t.match(/^git@([^:]+):(.+?)(?:\.git)?$/);if(!n)return null;t=`https://${n[1]}/${n[2]}`}else t.startsWith("ssh://git@")?t=t.replace(/^ssh:\/\/git@/,"https://").replace(/\.git$/,""):t=t.replace(/\.git$/,"");try{const n=new URL(t);return`${n.origin}${n.pathname.replace(/\/+$/,"")}`}catch{return null}}function An(s){const t=nn(s);if(!t)return null;try{const n=new URL(t).hostname.toLowerCase();return n==="www.github.com"?"github.com":n}catch{return null}}function Ss(s){if(!nn(s))return"unknown";const t=An(s);return t?t==="github.com"||t.endsWith(".github.com")?"github":"gitlab":"unknown"}function Ts(s,t){if(!s.length)return null;const n=t==null?void 0:t.trim();if(n){const e=s.find(l=>l.name===n);if(e)return e}return s.find(e=>e.name==="origin")??s[0]??null}function Ls(s){var c,m;const t=Ts(s.remotes,s.defaultRemote);if(!t)return null;const n=(t.pushUrl||t.fetchUrl||"").trim(),e=n?An(n):null,l=e?s.hosts.find(u=>u.host===e):void 0;let i=null;const a=n?nn(n):null;if(a)try{i=new URL(a).origin}catch{i=null}return{host:e,origin:i,platform:(l==null?void 0:l.platform)??(n?Ss(n):"unknown"),remote:t.name,remoteUrl:n,tokenSet:!!(l!=null&&l.tokenSet),tokenPreview:(((c=s.current)==null?void 0:c.host)===e?s.current.tokenPreview??"":"")||(l==null?void 0:l.tokenPreview)||"",tokenStatus:((m=s.current)==null?void 0:m.host)===e?s.current.tokenStatus??null:null,apiBaseUrl:(l==null?void 0:l.apiBaseUrl)??""}}function bn(s){var n,e;const t=xs();return s?{method:s.method==="cli"||s.method==="token"||s.method==="browser"?s.method:t.method,defaultRemote:s.defaultRemote??t.defaultRemote,remotes:s.remotes??[],current:s.current??null,hosts:s.hosts??[],cli:{gh:{...t.cli.gh,...(n=s.cli)==null?void 0:n.gh},glab:{...t.cli.glab,...(e=s.cli)==null?void 0:e.glab}}}:t}function yn(s,t){const n={...s,remotes:t.length?t:s.remotes};return n.current=Ls(n)??n.current,n}const Bn=Et("settings",{state:()=>({permissions:null,tools:[],mr:null,loading:!1,saving:!1,error:null}),actions:{async load(s,t){this.loading=!0,this.error=null;try{const[n,e]=await Promise.all([ks(s,t),s!=null?Fn(s).catch(()=>[]):Promise.resolve([])]);this.permissions=n.permissions,this.tools=n.tools,this.mr=yn(bn(n.mr),e)}catch(n){this.error=n instanceof Error?n.message:String(n)}finally{this.loading=!1}},async save(s,t){var n;this.saving=!0,this.error=null;try{const e=((n=this.mr)==null?void 0:n.remotes)??[],l=await ws(s,t);if(s.permissions&&this.permissions&&(this.permissions={...this.permissions,...s.permissions}),l.mr){const i=bn(l.mr);this.mr=yn(i,i.remotes.length?i.remotes:e)}}catch(e){throw this.error=e instanceof Error?e.message:String(e),e}finally{this.saving=!1}}}});function Es(s,t="all"){return t==="local"?s.filter(n=>!n.remote):t==="remote"?s.filter(n=>n.remote):s}function On(s){s.sort((t,n)=>{const e=t.branch?1:0,l=n.branch?1:0;return e!==l?e-l:t.label.localeCompare(n.label)});for(const t of s)t.children&&On(t.children)}function _n(s,t){const n=[];for(const{path:e,branch:l}of s){const i=e.split("/").filter(m=>m.length>0);if(i.length===0)continue;let a=n,c="";for(const[m,u]of i.entries()){c=c?`${c}/${u}`:u;const d=m===i.length-1,x=a.find(r=>r.label===u),E=x??{key:`${t}:${c}`,value:d?l.name:`${t}:${c}`,label:u,disabled:!d};x||a.push(E),d?(E.value=l.name,E.disabled=!1,E.branch=l,E.fullName=l.name,E.remote=l.remote):(E.children||(E.children=[]),a=E.children)}}return On(n),n}function Un(s,t="all"){const n=Es(s,t),e=n.filter(c=>!c.remote),l=n.filter(c=>c.remote),i=new Map;for(const c of l){const m=c.name.indexOf("/"),u=m===-1?"":c.name.slice(0,m);if(!u)continue;const d=i.get(u)??[];d.push({path:c.name.slice(m+1),branch:c}),i.set(u,d)}const a=[];if(e.length&&t!=="remote"&&a.push({key:"local",title:`本地分支(${e.length})`,tree:_n(e.map(c=>({path:c.name,branch:c})),"local")}),t!=="local")for(const[c,m]of i)a.push({key:`remote:${c}`,title:`远程 · ${c}(${m.length})`,tree:_n(m,`remote:${c}`)});return a}function Is(s,t=!1){return(t?[...s].reverse():s).map(e=>({key:`group:${e.key}`,value:`group:${e.key}`,label:e.title,disabled:!0,children:e.tree}))}let $t=null;const Pt=Et("branches",{state:()=>({list:[],remotes:[],repoId:null,loading:!1}),getters:{current(s){return s.list.find(t=>t.current)??null},locals(s){return s.list.filter(t=>!t.remote)},remoteBranches(s){return s.list.filter(t=>t.remote)},hasRemote(s){return s.remotes.length>0||s.list.some(t=>t.remote)},panes(s){return Un(s.list,"all")}},actions:{async load(){if(!($t&&(await $t,this.repoId===Ae().currentId)))return $t=this.fetch().finally(()=>{$t=null}),$t},async fetch(){const s=Ae().currentId;if(s===null){this.list=[],this.remotes=[],this.repoId=null;return}this.repoId!==s&&(this.list=[],this.remotes=[]),this.loading=!0;try{const[{branches:t},n]=await Promise.all([bs(s),Fn(s)]);if(Ae().currentId!==s)return;this.list=t,this.remotes=n,this.repoId=s}catch{Ae().currentId===s&&this.repoId!==s&&(this.list=[],this.remotes=[])}finally{this.loading=!1}}}});function ct(s,t){return`${s}\0${t}`}function Ps(s,t){return s.into===t.into&&s.from===t.from}const sn=Et("mergeSession",{state:()=>({mode:"pair",repoId:null,pairInto:"",pairFrom:"",trail:null,doneKeys:[],mrMarks:{},fromMatrix:!1,openedFromMatrix:null,surveyStale:!1,previewSeq:0,intos:[],froms:[],fetchRemote:!0,loading:!1,loadError:"",survey:null,order:null,active:null,orderView:"best"}),getters:{trailCurrent(s){if(s.trail)return s.trail.pairs[s.trail.index]},trailRemaining(s){return s.trail?s.trail.pairs.filter(t=>{var e;if(s.doneKeys.includes(ct(t.into,t.from)))return!1;const n=(e=s.survey)==null?void 0:e.cells.find(l=>l.into===t.into&&l.from===t.from);return!(n!=null&&n.tempBranch)}).length:0},canSurvey(s){return s.intos.length>0&&s.froms.length>0&&!s.loading},canOrder(s){return s.intos.length===1&&s.froms.length>1&&!s.loading}},actions:{resetIfRepoChanged(s){this.repoId!==s&&(this.repoId=s,this.pairInto="",this.pairFrom="",this.trail=null,this.doneKeys=[],this.mrMarks={},this.fromMatrix=!1,this.openedFromMatrix=null,this.surveyStale=!1,this.intos=[],this.froms=[],this.survey=null,this.order=null,this.active=null,this.loadError="",this.loading=!1)},setMode(s){this.mode=s},dropChip(s,t){s==="into"?this.intos=this.intos.filter(n=>n!==t):this.froms=this.froms.filter(n=>n!==t)},isPairDone(s){var n;if(this.doneKeys.includes(ct(s.into,s.from)))return!0;const t=(n=this.survey)==null?void 0:n.cells.find(e=>e.into===s.into&&e.from===s.from);return!!(t!=null&&t.tempBranch)},markPairDone(s){const t=ct(s.into,s.from);this.doneKeys.includes(t)||(this.doneKeys=[...this.doneKeys,t])},markPairMr(s,t){this.mrMarks={...this.mrMarks,[ct(s.into,s.from)]:t}},stageOf(s){var e;const t=ct(s.into,s.from),n=this.mrMarks[t];return n?n.via==="browser"?"page":"mr":(e=s.tempBranch)!=null&&e.remote?"resolved":s.tempBranch||this.doneKeys.includes(t)?"local":s.outcome==="clean"?"ready":"open"},sourceBranchFor(s){var t;return s.outcome==="clean"?s.from:((t=s.tempBranch)==null?void 0:t.name)??null},canCreateMr(s){const t=this.stageOf(s);return t==="ready"||t==="resolved"||t==="page"||t==="mr"},onRepoChanged(s){if(!this.survey||this.loading)return;const t=Ae().repos.find(e=>e.id===this.repoId);if(!t)return;const n=e=>e.replace(/\\/g,"/").replace(/\/+$/,"").toLowerCase();n(t.path)===n(s)&&(this.surveyStale=!0)},openPair(s,t){const n=t.findIndex(e=>Ps(e,s));this.trail=t.length>0&&n>=0?{pairs:t,index:n}:null,this.fromMatrix=!0,this.openedFromMatrix={...s},this.pairInto=s.into,this.pairFrom=s.from,this.mode="pair",this.previewSeq+=1},clearTrail(){this.trail=null,this.fromMatrix=!1,this.openedFromMatrix=null},syncTrailWithPair(){const s=this.openedFromMatrix;s&&(s.into!==this.pairInto||s.from!==this.pairFrom)&&(this.trail=null,this.fromMatrix=!1,this.openedFromMatrix=null)},trailGo(s){const t=this.trail;if(!t)return!1;const n=t.index+s,e=t.pairs[n];return e?(this.trail={pairs:t.pairs,index:n},this.pairInto=e.into,this.pairFrom=e.from,this.mode="pair",this.previewSeq+=1,!0):!1},trailNextPending(){const s=this.trail;if(!s)return this.backToMatrix(),!1;const t=s.pairs.findIndex((n,e)=>e>s.index&&!this.isPairDone(n));return t<0?(this.backToMatrix(),!1):(this.trailGo(t-s.index),!0)},backToMatrix(){this.mode="matrix",this.refreshSurvey()},async runSurvey(s){var e;const t=Ae().currentId;if(t===null||this.intos.length===0||this.froms.length===0)return;this.loading=!0,this.loadError="",this.order=null;const n=this.active?ct(this.active.into,this.active.from):"";this.active=null;try{const l=await mt(t,"git_merge_survey",{intos:[...this.intos],froms:[...this.froms],fetch:s??this.fetchRemote,dryRun:!1});if(!l.success){this.loadError=((e=l.error)==null?void 0:e.message)??"矩阵预演失败",this.survey=null;return}this.survey=l.result,this.surveyStale=!1,n&&(this.active=this.survey.cells.find(i=>ct(i.into,i.from)===n)??null)}catch(l){this.loadError=l instanceof Error?l.message:String(l),this.survey=null}finally{this.loading=!1}},async refreshSurvey(){this.intos.length===0||this.froms.length===0||await this.runSurvey(!1)},async runOrder(){var n;const s=Ae().currentId,t=this.intos[0];if(!(s===null||!t||this.intos.length!==1||this.froms.length<2)){this.loading=!0,this.loadError="";try{const e=await mt(s,"git_merge_order",{into:t,branches:[...this.froms],fetch:this.fetchRemote,dryRun:!1});if(!e.success){this.loadError=((n=e.error)==null?void 0:n.message)??"顺序推演失败";return}this.order=e.result,this.orderView="best"}catch(e){this.loadError=e instanceof Error?e.message:String(e)}finally{this.loading=!1}}}}}),zn=se(0),Ns=()=>{zn.value+=1};function Ot(){return{revision:zn,bump:Ns}}const Rs={class:"repo-box"},Ms=["title"],Vs={class:"menu-icon"},Ds={class:"aside-footer"},Fs=ze({__name:"App",setup(s){const t=Ae(),n=Bn(),e=Pt(),l=sn(),i=tn(),a=It(),{bump:c,revision:m}=Ot(),u=[{path:"/status",label:"状态",icon:"◧"},{path:"/merge",label:"合并",icon:"⇄"},{path:"/history",label:"历史",icon:"◫"},{path:"/repos",label:"仓库管理",icon:"▤"},{path:"/logs",label:"操作日志",icon:"≡"},{path:"/settings",label:"设置",icon:"⚙"}],d=W(()=>{if(!t.currentId)return"未选择仓库";const r=t.repos.find(y=>y.id===t.currentId);return(r==null?void 0:r.path)??"未选择仓库"});function x(r){r!==i.path&&a.push(r)}let E=null;return ht(async()=>{await t.checkHealth(),await t.load(),await Promise.all([n.load(t.currentId).catch(()=>{}),e.load()]),E=$s({onRepoChanged:r=>{c(),l.onRepoChanged(r.repoPath)},onLog:()=>c(),onError:()=>{}})}),Te(()=>t.currentId,()=>{e.load(),n.load(t.currentId).catch(()=>{})}),Te(m,()=>void e.load()),ns(()=>{E==null||E()}),(r,y)=>{const M=H("el-menu-item"),g=H("el-menu"),S=H("el-tag"),R=H("el-aside"),D=H("router-view"),T=H("el-main"),B=H("el-container");return h(),Y(B,{class:"app-shell"},{default:f(()=>[v(R,{width:"220px",class:"app-aside"},{default:f(()=>[y[4]||(y[4]=p("div",{class:"brand"},[p("span",{class:"brand-mark"},"⌘"),p("span",{class:"brand-name"},"Git Cockpit")],-1)),p("div",Rs,[y[0]||(y[0]=p("div",{class:"repo-box-label"},"当前仓库",-1)),p("div",{class:"repo-box-path mono",title:d.value},$(d.value),9,Ms)]),v(g,{"default-active":I(i).path,class:"nav-menu"},{default:f(()=>[(h(),P(ue,null,_e(u,G=>v(M,{key:G.path,index:G.path,onClick:ne=>x(G.path)},{default:f(()=>[p("span",Vs,$(G.icon),1),p("span",null,$(G.label),1)]),_:2},1032,["index","onClick"])),64))]),_:1},8,["default-active"]),p("div",Ds,[I(t).healthOk?(h(),Y(S,{key:0,size:"small",type:"success"},{default:f(()=>[...y[1]||(y[1]=[L("后端已连接",-1)])]),_:1})):I(t).healthOk===!1?(h(),Y(S,{key:1,size:"small",type:"danger"},{default:f(()=>[...y[2]||(y[2]=[L("后端离线",-1)])]),_:1})):(h(),Y(S,{key:2,size:"small",type:"info"},{default:f(()=>[...y[3]||(y[3]=[L("连接中…",-1)])]),_:1}))])]),_:1}),v(B,{class:"app-main"},{default:f(()=>[v(T,{class:"main-content"},{default:f(()=>[v(D,null,{default:f(({Component:G})=>[(h(),Y(ss(G)))]),_:1})]),_:1})]),_:1})]),_:1})}}}),He=(s,t)=>{const n=s.__vccOpts||s;for(const[e,l]of t)n[e]=l;return n},As=He(Fs,[["__scopeId","data-v-78d69fe0"]]),Bs={class:"page"},Os={class:"open-row"},Us={class:"list-header"},zs={key:1,class:"tree-scroll"},Hs=["title"],js=["title","onDblclick"],Gs={class:"node-name mono"},qs={class:"node-time"},Ws={class:"node-actions"},Ks=ze({__name:"ReposView",setup(s){const t=Ae(),n=It(),e=se(""),l=se(!1),i=W(()=>{const E=[],r=new Map;t.repos.forEach((M,g)=>r.set(M.id,g));for(const M of t.repos){const g=M.path.split(/[\\/]+/).filter(D=>D.length>0);if(g.length===0)continue;let S=E,R="";for(const[D,T]of g.entries()){R=R?`${R}/${T}`:T;const B=D===g.length-1,G=S.find(ne=>!ne.repo&&ne.label===T);if(B)S.push({key:"repo:"+M.path,label:T,fullPath:M.path,repo:M});else{const ne=G??{key:"dir:"+R,label:T,fullPath:R};G||S.push(ne),ne.children??(ne.children=[]),S=ne.children}}}const y=M=>{M.sort((g,S)=>{const R=g.repo?1:0,D=S.repo?1:0;return R!==D?R-D:R===1?(r.get(g.repo.id)??0)-(r.get(S.repo.id)??0):g.label.localeCompare(S.label)});for(const g of M)g.children&&y(g.children)};return y(E),E}),a=W(()=>{const E=t.current;if(E){const y=E.path.split(/[\\/]+/).filter(S=>S.length>0),M=[];let g="";for(const S of y.slice(0,-1))g=g?`${g}/${S}`:S,M.push("dir:"+g);if(M.length>0)return M}const r=i.value[0];return r&&!r.repo?[r.key]:[]});async function c(){const E=e.value.trim();if(!E){ie.warning("请输入仓库路径");return}l.value=!0;try{const r=await t.open(E);ie.success(`已打开 ${r.path}`),t.switchTo(r.id),await n.push("/status")}catch(r){ie.error(r instanceof Error?r.message:String(r))}finally{l.value=!1}}async function m(E,r){try{await Tt.confirm(`确定从列表移除 ${r}?注意:不会删除磁盘上的仓库文件。`,"移除仓库",{type:"warning",confirmButtonText:"移除",cancelButtonText:"取消"})}catch{return}try{await t.remove(E),ie.success("已移除")}catch(y){ie.error(y instanceof Error?y.message:String(y))}}async function u(E){try{await t.activate(E)}catch{t.switchTo(E)}n.push("/status")}function d(E){const r=new Date(E);return Number.isNaN(r.getTime())?E:r.toLocaleString()}function x(E){E.repo&&u(E.repo.id)}return ht(()=>t.load()),(E,r)=>{const y=H("el-input"),M=H("el-button"),g=H("el-card"),S=H("el-empty"),R=H("el-tree");return h(),P("div",Bs,[r[7]||(r[7]=p("h2",{class:"page-title"},"仓库管理",-1)),v(g,{class:"open-card",shadow:"never"},{header:f(()=>[...r[2]||(r[2]=[L("打开本地仓库",-1)])]),default:f(()=>[p("div",Os,[v(y,{modelValue:e.value,"onUpdate:modelValue":r[0]||(r[0]=D=>e.value=D),placeholder:"输入本地 Git 仓库路径,例如 D:\\project\\repo 或 /Users/me/code/app",clearable:"",onKeyup:Ft(c,["enter"])},null,8,["modelValue"]),v(M,{type:"primary",loading:l.value,onClick:c},{default:f(()=>[...r[3]||(r[3]=[L("打开",-1)])]),_:1},8,["loading"])])]),_:1}),v(g,{shadow:"never",class:"list-card"},{header:f(()=>[p("div",Us,[p("span",null,"最近打开的仓库("+$(I(t).repos.length)+")",1),v(M,{text:"",type:"primary",loading:I(t).loading,onClick:r[1]||(r[1]=D=>I(t).load())},{default:f(()=>[...r[4]||(r[4]=[L("刷新",-1)])]),_:1},8,["loading"])])]),default:f(()=>[!I(t).loading&&I(t).repos.length===0?(h(),Y(S,{key:0,description:"尚未打开任何仓库"})):(h(),P("div",zs,[v(R,{data:i.value,props:{label:"label",children:"children"},"node-key":"key",accordion:"","default-expanded-keys":a.value,indent:14,class:"repo-tree"},{default:f(({data:D})=>[D.repo?(h(),P("div",{key:1,class:Fe(["repo-node",{current:D.repo.id===I(t).currentId}]),title:D.repo.path,onDblclick:T=>x(D)},[p("span",Gs,$(D.label),1),p("span",qs,$(d(D.repo.lastOpenedAt)),1),p("span",Ws,[v(M,{size:"small",text:"",type:"primary",onClick:Ue(T=>x(D),["stop"])},{default:f(()=>[...r[5]||(r[5]=[L("进入",-1)])]),_:1},8,["onClick"]),v(M,{size:"small",text:"",type:"danger",onClick:Ue(T=>m(D.repo.id,D.repo.path),["stop"])},{default:f(()=>[...r[6]||(r[6]=[L("移除",-1)])]),_:1},8,["onClick"])])],42,js)):(h(),P("span",{key:0,class:"tree-dir",title:D.fullPath},$(D.label),9,Hs))]),_:1},8,["data","default-expanded-keys"])]))]),_:1})])}}}),Xs=He(Ks,[["__scopeId","data-v-c0b4639f"]]);function Hn(s){const t=It(),n=se(!1),e=se(null),l=se(!1),i=W(()=>s()!==null);async function a(x,E={}){const r=s();if(r===null)return ie.warning("请先选择仓库"),!1;try{const y=await mt(r,x,{...E,dryRun:!0});return y.success?(e.value={tool:x,params:E,preview:y.preview??y.result},n.value=!0,!0):(u(y),!1)}catch(y){return d(y),!1}}async function c(){const x=s(),E=e.value;if(x===null||!E)return null;l.value=!0,n.value=!1;try{const r=await mt(x,E.tool,E.params);return r.success?(r.backupCreated?ie.success(`${E.tool} 执行成功(已自动备份:${r.backupCreated.branch??"分支"}${r.backupCreated.stashRef?` / ${r.backupCreated.stashRef}`:""})`):ie.success(`${E.tool} 执行成功`),r):(u(r),r)}catch(r){return d(r),null}finally{l.value=!1,e.value=null}}function m(){n.value=!1,e.value=null}function u(x){var E,r,y,M;if(((E=x.error)==null?void 0:E.code)==="PERMISSION_DENIED"){x.error.requiredApproval?Tt.confirm(`操作 ${x.tool} 属于高风险操作,当前默认禁用,需要在设置中开启后才能执行。是否前往设置?`,"需要审批",{confirmButtonText:"去开启",cancelButtonText:"取消",type:"warning"}).then(()=>t.push({path:"/settings",query:{tab:"git"}})).catch(()=>{}):ie.error(((r=x.error)==null?void 0:r.message)??"操作被拒绝");return}if(((y=x.error)==null?void 0:y.code)==="NO_TOKEN"){Tt.confirm(x.error.message||"当前域名尚未配置 Token。","未配置 Token",{confirmButtonText:"去 MR 配置",cancelButtonText:"取消",type:"warning"}).then(()=>t.push({path:"/settings"})).catch(()=>{});return}ie.error(((M=x.error)==null?void 0:M.message)??"操作失败")}function d(x){const E=x instanceof Error?x.message:String(x);ie.error(E)}return{confirmVisible:n,pending:e,executing:l,canRun:i,previewAndConfirm:a,executeConfirmed:c,cancel:m}}const Js={key:2,class:"cmd-box"},Ys={class:"cmd-pre mono"},Qs={key:3,class:"files-box"},Zs={class:"cmd-label"},el={key:4,class:"note-text"},tl={class:"risk-tag"},nl=ze({__name:"ConfirmDialog",props:{visible:{type:Boolean},tool:{},preview:{default:null},note:{default:""}},emits:["update:visible","confirm","cancel"],setup(s,{emit:t}){const n=s,e=t,l=W(()=>{const d=n.preview;return d&&"command"in d&&typeof d.command=="string"?d.command:""}),i=W(()=>{const d=n.preview,x=d&&"risk"in d&&typeof d.risk=="string"?String(d.risk):"write";return x==="dangerous"||x==="high"?"dangerous":x==="readonly"?"readonly":"write"}),a=W(()=>{const d=n.preview;return d&&"affectedFiles"in d&&Array.isArray(d.affectedFiles)?d.affectedFiles:[]}),c=W(()=>i.value==="dangerous"?{type:"danger",label:"高风险"}:i.value==="write"?{type:"warning",label:"写操作"}:{type:"info",label:"只读"});function m(){e("confirm")}function u(){e("cancel"),e("update:visible",!1),ie.info("操作已取消")}return(d,x)=>{const E=H("el-alert"),r=H("el-scrollbar"),y=H("el-tag"),M=H("el-button"),g=H("el-dialog");return h(),Y(g,{"model-value":s.visible,title:`执行操作:${s.tool}`,width:"560px","close-on-click-modal":!1,onClosed:x[0]||(x[0]=S=>e("update:visible",!1))},{footer:f(()=>[p("span",tl,[v(y,{type:c.value.type,size:"small",effect:"dark"},{default:f(()=>[L($(c.value.label),1)]),_:1},8,["type"])]),v(M,{onClick:u},{default:f(()=>[...x[4]||(x[4]=[L("取消",-1)])]),_:1}),v(M,{type:"primary",danger:i.value==="dangerous",onClick:m},{default:f(()=>[...x[5]||(x[5]=[L("确认执行",-1)])]),_:1},8,["danger"])]),default:f(()=>[i.value==="dangerous"?(h(),Y(E,{key:0,type:"error",closable:!1,"show-icon":"",class:"risk-alert"},{title:f(()=>[...x[1]||(x[1]=[L("这是",-1),p("b",null,"高风险",-1),L("操作,将自动创建备份(临时分支 + stash)",-1)])]),_:1})):i.value==="write"?(h(),Y(E,{key:1,type:"warning",closable:!1,"show-icon":"",class:"risk-alert"},{title:f(()=>[...x[2]||(x[2]=[L("写操作:执行后将修改仓库状态",-1)])]),_:1})):j("",!0),l.value?(h(),P("div",Js,[x[3]||(x[3]=p("div",{class:"cmd-label"},"将执行的命令(dry-run 预览,未实际执行)",-1)),p("pre",Ys,$(l.value),1)])):j("",!0),a.value.length?(h(),P("div",Qs,[p("div",Zs,"涉及文件("+$(a.value.length)+")",1),v(r,{"max-height":"140px"},{default:f(()=>[(h(!0),P(ue,null,_e(a.value,S=>(h(),P("div",{key:S,class:"file-item mono"},$(S),1))),128))]),_:1})])):j("",!0),s.note?(h(),P("div",el,$(s.note),1)):j("",!0)]),_:1},8,["model-value","title"])}}}),jn=He(nl,[["__scopeId","data-v-8484f9b1"]]);var Ee;(function(s){s.INSERT="insert",s.DELETE="delete",s.CONTEXT="context"})(Ee||(Ee={}));const sl={LINE_BY_LINE:"line-by-line"},ll={NONE:"none"},il={WORD:"word"};var pt;(function(s){s.AUTO="auto",s.DARK="dark",s.LIGHT="light"})(pt||(pt={}));const ol=["-","[","]","/","{","}","(",")","*","+","?",".","\\","^","$","|"],al=RegExp("["+ol.join("\\")+"]","g");function rl(s){return s.replace(al,"\\$&")}function kn(s){return s&&s.replace(/\\/g,"/")}function ul(s){let t,n,e,l=0;for(t=0,e=s.length;t<e;t++)n=s.charCodeAt(t),l=(l<<5)-l+n,l|=0;return l}function Gn(s){const t=s.length;let n=-1/0;for(let e=0;e<t;e++)n=Math.max(n,s[e]);return n}function wn(s,t){const n=s.split(".");return n.length>1?n[n.length-1]:t}function Cn(s,t){return t.reduce((n,e)=>n||s.startsWith(e),!1)}const $n=["a/","b/","i/","w/","c/","o/"];function lt(s,t,n){const e=n!==void 0?[...$n,n]:$n,l=t?new RegExp(`^${rl(t)} "?(.+?)"?$`):new RegExp('^"?(.+?)"?$'),[,i=""]=l.exec(s)||[],a=e.find(m=>i.indexOf(m)===0);return(a?i.slice(a.length):i).replace(/\s+\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}(?:\.\d+)? [+-]\d{4}.*$/,"")}function dl(s,t){return lt(s,"---",t)}function cl(s,t){return lt(s,"+++",t)}function fl(s,t={}){const n=[];let e=null,l=null,i=null,a=null,c=null,m=null,u=null;const d="--- ",x="+++ ",E="@@",r=/^old mode (\d{6})/,y=/^new mode (\d{6})/,M=/^deleted file mode (\d{6})/,g=/^new file mode (\d{6})/,S=/^copy from "?(.+)"?/,R=/^copy to "?(.+)"?/,D=/^rename from "?(.+)"?/,T=/^rename to "?(.+)"?/,B=/^similarity index (\d+)%/,G=/^dissimilarity index (\d+)%/,ne=/^index ([\da-z]+)\.\.([\da-z]+)\s*(\d{6})?/,w=/^Binary files (.*) and (.*) differ/,N=/^GIT binary patch/,F=/^index ([\da-z]+),([\da-z]+)\.\.([\da-z]+)/,O=/^mode (\d{6}),(\d{6})\.\.(\d{6})/,ce=/^new file mode (\d{6})/,he=/^deleted file mode (\d{6}),(\d{6})/,de=s.replace(/\/g,"").replace(/\r\n?/g,`
2
+ `).split(`
3
+ `);function oe(){l!==null&&e!==null&&(e.blocks.push(l),l=null)}function $e(){e!==null&&(!e.oldName&&m!==null&&(e.oldName=m),!e.newName&&u!==null&&(e.newName=u),e.newName&&(n.push(e),e=null)),m=null,u=null}function ke(){oe(),$e(),e={blocks:[],deletedLines:0,addedLines:0}}function ge(b){oe();let z;e!==null&&((z=/^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@.*/.exec(b))?(e.isCombined=!1,i=parseInt(z[1],10),c=parseInt(z[2],10)):(z=/^@@@ -(\d+)(?:,\d+)? -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@@.*/.exec(b))?(e.isCombined=!0,i=parseInt(z[1],10),a=parseInt(z[2],10),c=parseInt(z[3],10)):(b.startsWith(E)&&console.error("Failed to parse lines, starting in 0!"),i=0,c=0,e.isCombined=!1)),l={lines:[],oldStartLine:i,oldStartLine2:a,newStartLine:c,header:b}}function be(b){if(e===null||l===null||i===null||c===null)return;const z={content:b},C=e.isCombined?["+ "," +","++"]:["+"],Z=e.isCombined?["- "," -","--"]:["-"];Cn(b,C)?(e.addedLines++,z.type=Ee.INSERT,z.oldNumber=void 0,z.newNumber=c++):Cn(b,Z)?(e.deletedLines++,z.type=Ee.DELETE,z.oldNumber=i++,z.newNumber=void 0):(z.type=Ee.CONTEXT,z.oldNumber=i++,z.newNumber=c++),l.lines.push(z)}function q(b,z){let C=z;for(;C<de.length-3;){if(b.startsWith("diff"))return!1;if(de[C].startsWith(d)&&de[C+1].startsWith(x)&&de[C+2].startsWith(E))return!0;C++}return!1}return de.forEach((b,z)=>{if(!b||b.startsWith("*"))return;let C;const Z=de[z-1],U=de[z+1],A=de[z+2];if(b.startsWith("diff --git")||b.startsWith("diff --combined")){if(ke(),(C=/^diff --git "?([a-ciow]\/.+)"? "?([a-ciow]\/.+)"?/.exec(b))&&(m=lt(C[1],void 0,t.dstPrefix),u=lt(C[2],void 0,t.srcPrefix)),e===null)throw new Error("Where is my file !!!");e.isGitDiff=!0;return}if(b.startsWith("Binary files")&&!(e!=null&&e.isGitDiff)){if(ke(),(C=/^Binary files "?([a-ciow]\/.+)"? and "?([a-ciow]\/.+)"? differ/.exec(b))&&(m=lt(C[1],void 0,t.dstPrefix),u=lt(C[2],void 0,t.srcPrefix)),e===null)throw new Error("Where is my file !!!");e.isBinary=!0;return}if((!e||!e.isGitDiff&&e&&b.startsWith(d)&&U.startsWith(x)&&A.startsWith(E))&&ke(),e!=null&&e.isTooBig)return;if(e&&(typeof t.diffMaxChanges=="number"&&e.addedLines+e.deletedLines>t.diffMaxChanges||typeof t.diffMaxLineLength=="number"&&b.length>t.diffMaxLineLength)){e.isTooBig=!0,e.addedLines=0,e.deletedLines=0,e.blocks=[],l=null;const ae=typeof t.diffTooBigMessage=="function"?t.diffTooBigMessage(n.length):"Diff too big to be displayed";ge(ae);return}if(b.startsWith(d)&&U.startsWith(x)||b.startsWith(x)&&Z.startsWith(d)){if(e&&!e.oldName&&b.startsWith("--- ")&&(C=dl(b,t.srcPrefix))){e.oldName=C,e.language=wn(e.oldName,e.language);return}if(e&&!e.newName&&b.startsWith("+++ ")&&(C=cl(b,t.dstPrefix))){e.newName=C,e.language=wn(e.newName,e.language);return}}if(e&&(b.startsWith(E)||e.isGitDiff&&e.oldName&&e.newName&&!l)){ge(b);return}if(l&&(b.startsWith("+")||b.startsWith("-")||b.startsWith(" "))){be(b);return}const K=!q(b,z);if(e===null)throw new Error("Where is my file !!!");(C=r.exec(b))?e.oldMode=C[1]:(C=y.exec(b))?e.newMode=C[1]:(C=M.exec(b))?(e.deletedFileMode=C[1],e.isDeleted=!0):(C=g.exec(b))?(e.newFileMode=C[1],e.isNew=!0):(C=S.exec(b))?(K&&(e.oldName=C[1]),e.isCopy=!0):(C=R.exec(b))?(K&&(e.newName=C[1]),e.isCopy=!0):(C=D.exec(b))?(K&&(e.oldName=C[1]),e.isRename=!0):(C=T.exec(b))?(K&&(e.newName=C[1]),e.isRename=!0):(C=w.exec(b))?(e.isBinary=!0,e.oldName=lt(C[1],void 0,t.srcPrefix),e.newName=lt(C[2],void 0,t.dstPrefix),ge("Binary file")):N.test(b)?(e.isBinary=!0,ge(b)):(C=B.exec(b))?e.unchangedPercentage=parseInt(C[1],10):(C=G.exec(b))?e.changedPercentage=parseInt(C[1],10):(C=ne.exec(b))?(e.checksumBefore=C[1],e.checksumAfter=C[2],C[3]&&(e.mode=C[3])):(C=F.exec(b))?(e.checksumBefore=[C[2],C[3]],e.checksumAfter=C[1]):(C=O.exec(b))?(e.oldMode=[C[2],C[3]],e.newMode=C[1]):(C=ce.exec(b))?(e.newFileMode=C[1],e.isNew=!0):(C=he.exec(b))&&(e.deletedFileMode=C[1],e.isDeleted=!0)}),oe(),$e(),n}let qn=class{diff(t,n,e={}){let l;typeof e=="function"?(l=e,e={}):"callback"in e&&(l=e.callback);const i=this.castInput(t,e),a=this.castInput(n,e),c=this.removeEmpty(this.tokenize(i,e)),m=this.removeEmpty(this.tokenize(a,e));return this.diffWithOptionsObj(c,m,e,l)}diffWithOptionsObj(t,n,e,l){var i;const a=R=>{if(R=this.postProcess(R,e),l){setTimeout(function(){l(R)},0);return}else return R},c=n.length,m=t.length;let u=1,d=c+m;e.maxEditLength!=null&&(d=Math.min(d,e.maxEditLength));const x=(i=e.timeout)!==null&&i!==void 0?i:1/0,E=Date.now()+x,r=[{oldPos:-1,lastComponent:void 0}];let y=this.extractCommon(r[0],n,t,0,e);if(r[0].oldPos+1>=m&&y+1>=c)return a(this.buildValues(r[0].lastComponent,n,t));let M=-1/0,g=1/0;const S=()=>{for(let R=Math.max(M,-u);R<=Math.min(g,u);R+=2){let D;const T=r[R-1],B=r[R+1];T&&(r[R-1]=void 0);let G=!1;if(B){const w=B.oldPos-R;G=B&&0<=w&&w<c}const ne=T&&T.oldPos+1<m;if(!G&&!ne){r[R]=void 0;continue}if(!ne||G&&T.oldPos<B.oldPos?D=this.addToPath(B,!0,!1,0,e):D=this.addToPath(T,!1,!0,1,e),y=this.extractCommon(D,n,t,R,e),D.oldPos+1>=m&&y+1>=c)return a(this.buildValues(D.lastComponent,n,t))||!0;r[R]=D,D.oldPos+1>=m&&(g=Math.min(g,R-1)),y+1>=c&&(M=Math.max(M,R+1))}u++};if(l)(function R(){setTimeout(function(){if(u>d||Date.now()>E)return l(void 0);S()||R()},0)})();else for(;u<=d&&Date.now()<=E;){const R=S();if(R)return R}}addToPath(t,n,e,l,i){const a=t.lastComponent;return a&&!i.oneChangePerToken&&a.added===n&&a.removed===e?{oldPos:t.oldPos+l,lastComponent:{count:a.count+1,added:n,removed:e,previousComponent:a.previousComponent}}:{oldPos:t.oldPos+l,lastComponent:{count:1,added:n,removed:e,previousComponent:a}}}extractCommon(t,n,e,l,i){const a=n.length,c=e.length;let m=t.oldPos,u=m-l,d=0;for(;u+1<a&&m+1<c&&this.equals(e[m+1],n[u+1],i);)u++,m++,d++,i.oneChangePerToken&&(t.lastComponent={count:1,previousComponent:t.lastComponent,added:!1,removed:!1});return d&&!i.oneChangePerToken&&(t.lastComponent={count:d,previousComponent:t.lastComponent,added:!1,removed:!1}),t.oldPos=m,u}equals(t,n,e){return e.comparator?e.comparator(t,n):t===n||!!e.ignoreCase&&t.toLowerCase()===n.toLowerCase()}removeEmpty(t){const n=[];for(let e=0;e<t.length;e++)t[e]&&n.push(t[e]);return n}castInput(t,n){return t}tokenize(t,n){return Array.from(t)}join(t){return t.join("")}postProcess(t,n){return t}get useLongestToken(){return!1}buildValues(t,n,e){const l=[];let i;for(;t;)l.push(t),i=t.previousComponent,delete t.previousComponent,t=i;l.reverse();const a=l.length;let c=0,m=0,u=0;for(;c<a;c++){const d=l[c];if(d.removed)d.value=this.join(e.slice(u,u+d.count)),u+=d.count;else{if(!d.added&&this.useLongestToken){let x=n.slice(m,m+d.count);x=x.map(function(E,r){const y=e[u+r];return y.length>E.length?y:E}),d.value=this.join(x)}else d.value=this.join(n.slice(m,m+d.count));m+=d.count,d.added||(u+=d.count)}}return l}};class pl extends qn{}const ml=new pl;function hl(s,t,n){return ml.diff(s,t,n)}const xn="a-zA-Z0-9_\\u{AD}\\u{C0}-\\u{D6}\\u{D8}-\\u{F6}\\u{F8}-\\u{2C6}\\u{2C8}-\\u{2D7}\\u{2DE}-\\u{2FF}\\u{1E00}-\\u{1EFF}";class vl extends qn{tokenize(t){const n=new RegExp(`(\\r?\\n)|[${xn}]+|[^\\S\\n\\r]+|[^${xn}]`,"ug");return t.match(n)||[]}}const gl=new vl;function bl(s,t,n){return gl.diff(s,t,n)}function yl(s,t){if(s.length===0)return t.length;if(t.length===0)return s.length;const n=[];let e;for(e=0;e<=t.length;e++)n[e]=[e];let l;for(l=0;l<=s.length;l++)n[0][l]=l;for(e=1;e<=t.length;e++)for(l=1;l<=s.length;l++)t.charAt(e-1)===s.charAt(l-1)?n[e][l]=n[e-1][l-1]:n[e][l]=Math.min(n[e-1][l-1]+1,Math.min(n[e][l-1]+1,n[e-1][l]+1));return n[t.length][s.length]}function ln(s){return(t,n)=>{const e=s(t).trim(),l=s(n).trim();return yl(e,l)/(e.length+l.length)}}function on(s){function t(e,l,i=new Map){let a=1/0,c;for(let m=0;m<e.length;++m)for(let u=0;u<l.length;++u){const d=JSON.stringify([e[m],l[u]]);let x;i.has(d)&&(x=i.get(d))||(x=s(e[m],l[u]),i.set(d,x)),x<a&&(a=x,c={indexA:m,indexB:u,score:a})}return c}function n(e,l,i=0,a=new Map){const c=t(e,l,a);if(!c||e.length+l.length<3)return[[e,l]];const m=e.slice(0,c.indexA),u=l.slice(0,c.indexB),d=[e[c.indexA]],x=[l[c.indexB]],E=c.indexA+1,r=c.indexB+1,y=e.slice(E),M=l.slice(r),g=n(m,u,i+1,a),S=n(d,x,i+1,a),R=n(y,M,i+1,a);let D=S;return(c.indexA>0||c.indexB>0)&&(D=g.concat(D)),(e.length>E||l.length>r)&&(D=D.concat(R)),D}return n}const Me={INSERTS:"d2h-ins",DELETES:"d2h-del",CONTEXT:"d2h-cntx",INFO:"d2h-info",INSERT_CHANGES:"d2h-ins d2h-change",DELETE_CHANGES:"d2h-del d2h-change"},Ut={matching:ll.NONE,matchWordsThreshold:.25,maxLineLengthHighlight:1e4,diffStyle:il.WORD,colorScheme:pt.LIGHT},qe="/",Wn=ln(s=>s.value),_l=on(Wn);function qt(s){return s.indexOf("dev/null")!==-1}function kl(s){return s.replace(/(<ins[^>]*>((.|\n)*?)<\/ins>)/g,"")}function wl(s){return s.replace(/(<del[^>]*>((.|\n)*?)<\/del>)/g,"")}function Dt(s){switch(s){case Ee.CONTEXT:return Me.CONTEXT;case Ee.INSERT:return Me.INSERTS;case Ee.DELETE:return Me.DELETES}}function an(s){switch(s){case pt.DARK:return"d2h-dark-color-scheme";case pt.AUTO:return"d2h-auto-color-scheme";case pt.LIGHT:default:return"d2h-light-color-scheme"}}function Cl(s){return s?2:1}function _t(s){return s.slice(0).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#x27;").replace(/\//g,"&#x2F;")}function Ke(s,t,n=!0){const e=Cl(t);return{prefix:s.substring(0,e),content:n?_t(s.substring(e)):s.substring(e)}}function zt(s){const t=kn(s.oldName),n=kn(s.newName);if(t!==n&&!qt(t)&&!qt(n)){const e=[],l=[],i=t.split(qe),a=n.split(qe),c=i.length,m=a.length;let u=0,d=c-1,x=m-1;for(;u<d&&u<x&&i[u]===a[u];)e.push(a[u]),u+=1;for(;d>u&&x>u&&i[d]===a[x];)l.unshift(a[x]),d-=1,x-=1;const E=e.join(qe),r=l.join(qe),y=i.slice(u,d+1).join(qe),M=a.slice(u,x+1).join(qe);return E.length&&r.length?E+qe+"{"+y+" → "+M+"}"+qe+r:E.length?E+qe+"{"+y+" → "+M+"}":r.length?"{"+y+" → "+M+"}"+qe+r:t+" → "+n}else return qt(n)?t:n}function rn(s){return`d2h-${ul(zt(s)).toString().slice(-6)}`}function un(s){let t="file-changed";return s.isRename||s.isCopy?t="file-renamed":s.isNew?t="file-added":s.isDeleted?t="file-deleted":s.newName!==s.oldName&&(t="file-renamed"),t}function Kn(s,t,n,e={}){const{matching:l,maxLineLengthHighlight:i,matchWordsThreshold:a,diffStyle:c}=Object.assign(Object.assign({},Ut),e),m=Ke(s,n,!1),u=Ke(t,n,!1);if(m.content.length>i||u.content.length>i)return{oldLine:{prefix:m.prefix,content:_t(m.content)},newLine:{prefix:u.prefix,content:_t(u.content)}};const d=c==="char"?hl(m.content,u.content):bl(m.content,u.content),x=[];if(c==="word"&&l==="words"){const r=d.filter(g=>g.removed),y=d.filter(g=>g.added);_l(y,r).forEach(g=>{g[0].length===1&&g[1].length===1&&Wn(g[0][0],g[1][0])<a&&(x.push(g[0][0]),x.push(g[1][0]))})}const E=d.reduce((r,y)=>{const M=y.added?"ins":y.removed?"del":null,g=x.indexOf(y)>-1?' class="d2h-change"':"",S=_t(y.value);return M!==null?`${r}<${M}${g}>${S}</${M}>`:`${r}${S}`},"");return{oldLine:{prefix:m.prefix,content:kl(E)},newLine:{prefix:u.prefix,content:wl(E)}}}const Sn="file-summary",$l="icon",xl={colorScheme:Ut.colorScheme};class Sl{constructor(t,n={}){this.hoganUtils=t,this.config=Object.assign(Object.assign({},xl),n)}render(t){const n=t.map(e=>this.hoganUtils.render(Sn,"line",{fileHtmlId:rn(e),oldName:e.oldName,newName:e.newName,fileName:zt(e),deletedLines:"-"+e.deletedLines,addedLines:"+"+e.addedLines},{fileIcon:this.hoganUtils.template($l,un(e))})).join(`
4
+ `);return this.hoganUtils.render(Sn,"wrapper",{colorScheme:an(this.config.colorScheme),filesNumber:t.length,files:n})}}const Xn=Object.assign(Object.assign({},Ut),{renderNothingWhenEmpty:!1,matchingMaxComparisons:2500,maxLineSizeInBlockForComparison:200}),xt="generic",Tn="line-by-line",Tl="icon",Ll="tag";class El{constructor(t,n={}){this.hoganUtils=t,this.config=Object.assign(Object.assign({},Xn),n)}render(t){const n=t.map(e=>{let l;return e.blocks.length?l=this.generateFileHtml(e):l=this.generateEmptyDiff(),this.makeFileDiffHtml(e,l)}).join(`
5
+ `);return this.hoganUtils.render(xt,"wrapper",{colorScheme:an(this.config.colorScheme),content:n})}makeFileDiffHtml(t,n){if(this.config.renderNothingWhenEmpty&&Array.isArray(t.blocks)&&t.blocks.length===0)return"";const e=this.hoganUtils.template(Tn,"file-diff"),l=this.hoganUtils.template(xt,"file-path"),i=this.hoganUtils.template(Tl,"file"),a=this.hoganUtils.template(Ll,un(t));return e.render({file:t,fileHtmlId:rn(t),diffs:n,filePath:l.render({fileDiffName:zt(t)},{fileIcon:i,fileTag:a})})}generateEmptyDiff(){return this.hoganUtils.render(xt,"empty-diff",{contentClass:"d2h-code-line",CSSLineClass:Me})}generateFileHtml(t){const n=on(ln(e=>Ke(e.content,t.isCombined).content));return t.blocks.map(e=>{let l=this.hoganUtils.render(xt,"block-header",{CSSLineClass:Me,blockHeader:t.isTooBig?e.header:_t(e.header),lineClass:"d2h-code-linenumber",contentClass:"d2h-code-line"});return this.applyLineGroupping(e).forEach(([i,a,c])=>{if(a.length&&c.length&&!i.length)this.applyRematchMatching(a,c,n).map(([m,u])=>{const{left:d,right:x}=this.processChangedLines(t,t.isCombined,m,u);l+=d,l+=x});else if(i.length)i.forEach(m=>{const{prefix:u,content:d}=Ke(m.content,t.isCombined);l+=this.generateSingleLineHtml(t,{type:Me.CONTEXT,prefix:u,content:d,oldNumber:m.oldNumber,newNumber:m.newNumber})});else if(a.length||c.length){const{left:m,right:u}=this.processChangedLines(t,t.isCombined,a,c);l+=m,l+=u}else console.error("Unknown state reached while processing groups of lines",i,a,c)}),l}).join(`
6
+ `)}applyLineGroupping(t){const n=[];let e=[],l=[];for(let i=0;i<t.lines.length;i++){const a=t.lines[i];(a.type!==Ee.INSERT&&l.length||a.type===Ee.CONTEXT&&e.length>0)&&(n.push([[],e,l]),e=[],l=[]),a.type===Ee.CONTEXT?n.push([[a],[],[]]):a.type===Ee.INSERT&&e.length===0?n.push([[],[],[a]]):a.type===Ee.INSERT&&e.length>0?l.push(a):a.type===Ee.DELETE&&e.push(a)}return(e.length||l.length)&&(n.push([[],e,l]),e=[],l=[]),n}applyRematchMatching(t,n,e){const l=t.length*n.length,i=Gn(t.concat(n).map(c=>c.content.length));return l<this.config.matchingMaxComparisons&&i<this.config.maxLineSizeInBlockForComparison&&(this.config.matching==="lines"||this.config.matching==="words")?e(t,n):[[t,n]]}processChangedLines(t,n,e,l){const i={right:"",left:""},a=Math.max(e.length,l.length);for(let c=0;c<a;c++){const m=e[c],u=l[c],d=m!==void 0&&u!==void 0?Kn(m.content,u.content,n,this.config):void 0,x=m!==void 0&&m.oldNumber!==void 0?Object.assign(Object.assign({},d!==void 0?{prefix:d.oldLine.prefix,content:d.oldLine.content,type:Me.DELETE_CHANGES}:Object.assign(Object.assign({},Ke(m.content,n)),{type:Dt(m.type)})),{oldNumber:m.oldNumber,newNumber:m.newNumber}):void 0,E=u!==void 0&&u.newNumber!==void 0?Object.assign(Object.assign({},d!==void 0?{prefix:d.newLine.prefix,content:d.newLine.content,type:Me.INSERT_CHANGES}:Object.assign(Object.assign({},Ke(u.content,n)),{type:Dt(u.type)})),{oldNumber:u.oldNumber,newNumber:u.newNumber}):void 0,{left:r,right:y}=this.generateLineHtml(t,x,E);i.left+=r,i.right+=y}return i}generateLineHtml(t,n,e){return{left:this.generateSingleLineHtml(t,n),right:this.generateSingleLineHtml(t,e)}}generateSingleLineHtml(t,n){if(n===void 0)return"";const e=this.hoganUtils.render(Tn,"numbers",{oldNumber:n.oldNumber||"",newNumber:n.newNumber||""});return this.hoganUtils.render(xt,"line",{type:n.type,lineClass:"d2h-code-linenumber",contentClass:"d2h-code-line",prefix:n.prefix===" "?"&nbsp;":n.prefix,content:n.content,lineNumber:e,line:n,file:t})}}const Jn=Object.assign(Object.assign({},Ut),{renderNothingWhenEmpty:!1,matchingMaxComparisons:2500,maxLineSizeInBlockForComparison:200}),St="generic",Il="side-by-side",Pl="icon",Nl="tag";class Rl{constructor(t,n={}){this.hoganUtils=t,this.config=Object.assign(Object.assign({},Jn),n)}render(t){const n=t.map(e=>{let l;return e.blocks.length?l=this.generateFileHtml(e):l=this.generateEmptyDiff(),this.makeFileDiffHtml(e,l)}).join(`
7
+ `);return this.hoganUtils.render(St,"wrapper",{colorScheme:an(this.config.colorScheme),content:n})}makeFileDiffHtml(t,n){if(this.config.renderNothingWhenEmpty&&Array.isArray(t.blocks)&&t.blocks.length===0)return"";const e=this.hoganUtils.template(Il,"file-diff"),l=this.hoganUtils.template(St,"file-path"),i=this.hoganUtils.template(Pl,"file"),a=this.hoganUtils.template(Nl,un(t));return e.render({file:t,fileHtmlId:rn(t),diffs:n,filePath:l.render({fileDiffName:zt(t)},{fileIcon:i,fileTag:a})})}generateEmptyDiff(){return{right:"",left:this.hoganUtils.render(St,"empty-diff",{contentClass:"d2h-code-side-line",CSSLineClass:Me})}}generateFileHtml(t){const n=on(ln(e=>Ke(e.content,t.isCombined).content));return t.blocks.map(e=>{const l={left:this.makeHeaderHtml(e.header,t),right:this.makeHeaderHtml("")};return this.applyLineGroupping(e).forEach(([i,a,c])=>{if(a.length&&c.length&&!i.length)this.applyRematchMatching(a,c,n).map(([m,u])=>{const{left:d,right:x}=this.processChangedLines(t.isCombined,m,u);l.left+=d,l.right+=x});else if(i.length)i.forEach(m=>{const{prefix:u,content:d}=Ke(m.content,t.isCombined),{left:x,right:E}=this.generateLineHtml({type:Me.CONTEXT,prefix:u,content:d,number:m.oldNumber},{type:Me.CONTEXT,prefix:u,content:d,number:m.newNumber});l.left+=x,l.right+=E});else if(a.length||c.length){const{left:m,right:u}=this.processChangedLines(t.isCombined,a,c);l.left+=m,l.right+=u}else console.error("Unknown state reached while processing groups of lines",i,a,c)}),l}).reduce((e,l)=>({left:e.left+l.left,right:e.right+l.right}),{left:"",right:""})}applyLineGroupping(t){const n=[];let e=[],l=[];for(let i=0;i<t.lines.length;i++){const a=t.lines[i];(a.type!==Ee.INSERT&&l.length||a.type===Ee.CONTEXT&&e.length>0)&&(n.push([[],e,l]),e=[],l=[]),a.type===Ee.CONTEXT?n.push([[a],[],[]]):a.type===Ee.INSERT&&e.length===0?n.push([[],[],[a]]):a.type===Ee.INSERT&&e.length>0?l.push(a):a.type===Ee.DELETE&&e.push(a)}return(e.length||l.length)&&(n.push([[],e,l]),e=[],l=[]),n}applyRematchMatching(t,n,e){const l=t.length*n.length,i=Gn(t.concat(n).map(c=>c.content.length));return l<this.config.matchingMaxComparisons&&i<this.config.maxLineSizeInBlockForComparison&&(this.config.matching==="lines"||this.config.matching==="words")?e(t,n):[[t,n]]}makeHeaderHtml(t,n){return this.hoganUtils.render(St,"block-header",{CSSLineClass:Me,blockHeader:n!=null&&n.isTooBig?t:_t(t),lineClass:"d2h-code-side-linenumber",contentClass:"d2h-code-side-line"})}processChangedLines(t,n,e){const l={right:"",left:""},i=Math.max(n.length,e.length);for(let a=0;a<i;a++){const c=n[a],m=e[a],u=c!==void 0&&m!==void 0?Kn(c.content,m.content,t,this.config):void 0,d=c!==void 0&&c.oldNumber!==void 0?Object.assign(Object.assign({},u!==void 0?{prefix:u.oldLine.prefix,content:u.oldLine.content,type:Me.DELETE_CHANGES}:Object.assign(Object.assign({},Ke(c.content,t)),{type:Dt(c.type)})),{number:c.oldNumber}):void 0,x=m!==void 0&&m.newNumber!==void 0?Object.assign(Object.assign({},u!==void 0?{prefix:u.newLine.prefix,content:u.newLine.content,type:Me.INSERT_CHANGES}:Object.assign(Object.assign({},Ke(m.content,t)),{type:Dt(m.type)})),{number:m.newNumber}):void 0,{left:E,right:r}=this.generateLineHtml(d,x);l.left+=E,l.right+=r}return l}generateLineHtml(t,n){return{left:this.generateSingleHtml(t),right:this.generateSingleHtml(n)}}generateSingleHtml(t){const n="d2h-code-side-linenumber",e="d2h-code-side-line";return this.hoganUtils.render(St,"line",{type:(t==null?void 0:t.type)||`${Me.CONTEXT} d2h-emptyplaceholder`,lineClass:t!==void 0?n:`${n} d2h-code-side-emptyplaceholder`,contentClass:t!==void 0?e:`${e} d2h-code-side-emptyplaceholder`,prefix:(t==null?void 0:t.prefix)===" "?"&nbsp;":t==null?void 0:t.prefix,content:t==null?void 0:t.content,lineNumber:t==null?void 0:t.number})}}var Wt={},Ln;function Ml(){return Ln||(Ln=1,(function(s){(function(t){var n=/\S/,e=/\"/g,l=/\n/g,i=/\r/g,a=/\\/g,c=/\u2028/,m=/\u2029/;t.tags={"#":1,"^":2,"<":3,$:4,"/":5,"!":6,">":7,"=":8,_v:9,"{":10,"&":11,_t:12},t.scan=function(N,F){var O=N.length,ce=0,he=1,de=2,oe=ce,$e=null,ke=null,ge="",be=[],q=!1,b=0,z=0,C="{{",Z="}}";function U(){ge.length>0&&(be.push({tag:"_t",text:new String(ge)}),ge="")}function A(){for(var re=!0,fe=z;fe<be.length;fe++)if(re=t.tags[be[fe].tag]<t.tags._v||be[fe].tag=="_t"&&be[fe].text.match(n)===null,!re)return!1;return re}function K(re,fe){if(U(),re&&A())for(var ye=z,Se;ye<be.length;ye++)be[ye].text&&((Se=be[ye+1])&&Se.tag==">"&&(Se.indent=be[ye].text.toString()),be.splice(ye,1));else fe||be.push({tag:`
8
+ `});q=!1,z=be.length}function ae(re,fe){var ye="="+Z,Se=re.indexOf(ye,fe),Ve=d(re.substring(re.indexOf("=",fe)+1,Se)).split(" ");return C=Ve[0],Z=Ve[Ve.length-1],Se+ye.length-1}for(F&&(F=F.split(" "),C=F[0],Z=F[1]),b=0;b<O;b++)oe==ce?x(C,N,b)?(--b,U(),oe=he):N.charAt(b)==`
9
+ `?K(q):ge+=N.charAt(b):oe==he?(b+=C.length-1,ke=t.tags[N.charAt(b+1)],$e=ke?N.charAt(b+1):"_v",$e=="="?(b=ae(N,b),oe=ce):(ke&&b++,oe=de),q=b):x(Z,N,b)?(be.push({tag:$e,n:d(ge),otag:C,ctag:Z,i:$e=="/"?q-C.length:b+Z.length}),ge="",b+=Z.length-1,oe=ce,$e=="{"&&(Z=="}}"?b++:u(be[be.length-1]))):ge+=N.charAt(b);return K(q,!0),be};function u(w){w.n.substr(w.n.length-1)==="}"&&(w.n=w.n.substring(0,w.n.length-1))}function d(w){return w.trim?w.trim():w.replace(/^\s*|\s*$/g,"")}function x(w,N,F){if(N.charAt(F)!=w.charAt(0))return!1;for(var O=1,ce=w.length;O<ce;O++)if(N.charAt(F+O)!=w.charAt(O))return!1;return!0}var E={_t:!0,"\n":!0,$:!0,"/":!0};function r(w,N,F,O){var ce=[],he=null,de=null,oe=null;for(de=F[F.length-1];w.length>0;){if(oe=w.shift(),de&&de.tag=="<"&&!(oe.tag in E))throw new Error("Illegal content in < super tag.");if(t.tags[oe.tag]<=t.tags.$||y(oe,O))F.push(oe),oe.nodes=r(w,oe.tag,F,O);else if(oe.tag=="/"){if(F.length===0)throw new Error("Closing tag without opener: /"+oe.n);if(he=F.pop(),oe.n!=he.n&&!M(oe.n,he.n,O))throw new Error("Nesting error: "+he.n+" vs. "+oe.n);return he.end=oe.i,ce}else oe.tag==`
10
+ `&&(oe.last=w.length==0||w[0].tag==`
11
+ `);ce.push(oe)}if(F.length>0)throw new Error("missing closing tag: "+F.pop().n);return ce}function y(w,N){for(var F=0,O=N.length;F<O;F++)if(N[F].o==w.n)return w.tag="#",!0}function M(w,N,F){for(var O=0,ce=F.length;O<ce;O++)if(F[O].c==w&&F[O].o==N)return!0}function g(w){var N=[];for(var F in w)N.push('"'+D(F)+'": function(c,p,t,i) {'+w[F]+"}");return"{ "+N.join(",")+" }"}function S(w){var N=[];for(var F in w.partials)N.push('"'+D(F)+'":{name:"'+D(w.partials[F].name)+'", '+S(w.partials[F])+"}");return"partials: {"+N.join(",")+"}, subs: "+g(w.subs)}t.stringify=function(w,N,F){return"{code: function (c,p,i) { "+t.wrapMain(w.code)+" },"+S(w)+"}"};var R=0;t.generate=function(w,N,F){R=0;var O={code:"",subs:{},partials:{}};return t.walk(w,O),F.asString?this.stringify(O,N,F):this.makeTemplate(O,N,F)},t.wrapMain=function(w){return'var t=this;t.b(i=i||"");'+w+"return t.fl();"},t.template=t.Template,t.makeTemplate=function(w,N,F){var O=this.makePartials(w);return O.code=new Function("c","p","i",this.wrapMain(w.code)),new this.template(O,N,this,F)},t.makePartials=function(w){var N,F={subs:{},partials:w.partials,name:w.name};for(N in F.partials)F.partials[N]=this.makePartials(F.partials[N]);for(N in w.subs)F.subs[N]=new Function("c","p","t","i",w.subs[N]);return F};function D(w){return w.replace(a,"\\\\").replace(e,'\\"').replace(l,"\\n").replace(i,"\\r").replace(c,"\\u2028").replace(m,"\\u2029")}function T(w){return~w.indexOf(".")?"d":"f"}function B(w,N){var F="<"+(N.prefix||""),O=F+w.n+R++;return N.partials[O]={name:w.n,partials:{}},N.code+='t.b(t.rp("'+D(O)+'",c,p,"'+(w.indent||"")+'"));',O}t.codegen={"#":function(w,N){N.code+="if(t.s(t."+T(w.n)+'("'+D(w.n)+'",c,p,1),c,p,0,'+w.i+","+w.end+',"'+w.otag+" "+w.ctag+'")){t.rs(c,p,function(c,p,t){',t.walk(w.nodes,N),N.code+="});c.pop();}"},"^":function(w,N){N.code+="if(!t.s(t."+T(w.n)+'("'+D(w.n)+'",c,p,1),c,p,1,0,0,"")){',t.walk(w.nodes,N),N.code+="};"},">":B,"<":function(w,N){var F={partials:{},code:"",subs:{},inPartial:!0};t.walk(w.nodes,F);var O=N.partials[B(w,N)];O.subs=F.subs,O.partials=F.partials},$:function(w,N){var F={subs:{},code:"",partials:N.partials,prefix:w.n};t.walk(w.nodes,F),N.subs[w.n]=F.code,N.inPartial||(N.code+='t.sub("'+D(w.n)+'",c,p,i);')},"\n":function(w,N){N.code+=ne('"\\n"'+(w.last?"":" + i"))},_v:function(w,N){N.code+="t.b(t.v(t."+T(w.n)+'("'+D(w.n)+'",c,p,0)));'},_t:function(w,N){N.code+=ne('"'+D(w.text)+'"')},"{":G,"&":G};function G(w,N){N.code+="t.b(t.t(t."+T(w.n)+'("'+D(w.n)+'",c,p,0)));'}function ne(w){return"t.b("+w+");"}t.walk=function(w,N){for(var F,O=0,ce=w.length;O<ce;O++)F=t.codegen[w[O].tag],F&&F(w[O],N);return N},t.parse=function(w,N,F){return F=F||{},r(w,"",[],F.sectionTags||[])},t.cache={},t.cacheKey=function(w,N){return[w,!!N.asString,!!N.disableLambda,N.delimiters,!!N.modelGet].join("||")},t.compile=function(w,N){N=N||{};var F=t.cacheKey(w,N),O=this.cache[F];if(O){var ce=O.partials;for(var he in ce)delete ce[he].instance;return O}return O=this.generate(this.parse(this.scan(w,N.delimiters),w,N),w,N),this.cache[F]=O}})(s)})(Wt)),Wt}var Kt={},En;function Vl(){return En||(En=1,(function(s){(function(t){t.Template=function(r,y,M,g){r=r||{},this.r=r.code||this.r,this.c=M,this.options=g||{},this.text=y||"",this.partials=r.partials||{},this.subs=r.subs||{},this.buf=""},t.Template.prototype={r:function(r,y,M){return""},v:x,t:d,render:function(y,M,g){return this.ri([y],M||{},g)},ri:function(r,y,M){return this.r(r,y,M)},ep:function(r,y){var M=this.partials[r],g=y[M.name];if(M.instance&&M.base==g)return M.instance;if(typeof g=="string"){if(!this.c)throw new Error("No compiler available.");g=this.c.compile(g,this.options)}if(!g)return null;if(this.partials[r].base=g,M.subs){y.stackText||(y.stackText={});for(key in M.subs)y.stackText[key]||(y.stackText[key]=this.activeSub!==void 0&&y.stackText[this.activeSub]?y.stackText[this.activeSub]:this.text);g=e(g,M.subs,M.partials,this.stackSubs,this.stackPartials,y.stackText)}return this.partials[r].instance=g,g},rp:function(r,y,M,g){var S=this.ep(r,M);return S?S.ri(y,M,g):""},rs:function(r,y,M){var g=r[r.length-1];if(!E(g)){M(r,y,this);return}for(var S=0;S<g.length;S++)r.push(g[S]),M(r,y,this),r.pop()},s:function(r,y,M,g,S,R,D){var T;return E(r)&&r.length===0?!1:(typeof r=="function"&&(r=this.ms(r,y,M,g,S,R,D)),T=!!r,!g&&T&&y&&y.push(typeof r=="object"?r:y[y.length-1]),T)},d:function(r,y,M,g){var S,R=r.split("."),D=this.f(R[0],y,M,g),T=this.options.modelGet,B=null;if(r==="."&&E(y[y.length-2]))D=y[y.length-1];else for(var G=1;G<R.length;G++)S=n(R[G],D,T),S!==void 0?(B=D,D=S):D="";return g&&!D?!1:(!g&&typeof D=="function"&&(y.push(B),D=this.mv(D,y,M),y.pop()),D)},f:function(r,y,M,g){for(var S=!1,R=null,D=!1,T=this.options.modelGet,B=y.length-1;B>=0;B--)if(R=y[B],S=n(r,R,T),S!==void 0){D=!0;break}return D?(!g&&typeof S=="function"&&(S=this.mv(S,y,M)),S):g?!1:""},ls:function(r,y,M,g,S,R){var D=this.options.delimiters;return this.options.delimiters=R,this.b(this.ct(d(r.call(y,S,M)),y,g)),this.options.delimiters=D,!1},ct:function(r,y,M){if(this.options.disableLambda)throw new Error("Lambda features disabled.");return this.c.compile(r,this.options).render(y,M)},b:function(r){this.buf+=r},fl:function(){var r=this.buf;return this.buf="",r},ms:function(r,y,M,g,S,R,D){var T,B=y[y.length-1],G=r.call(B);return typeof G=="function"?g?!0:(T=this.activeSub&&this.subsText&&this.subsText[this.activeSub]?this.subsText[this.activeSub]:this.text,this.ls(G,B,y,M,T.substring(S,R),D)):G},mv:function(r,y,M){var g=y[y.length-1],S=r.call(g);return typeof S=="function"?this.ct(d(S.call(g)),g,M):S},sub:function(r,y,M,g){var S=this.subs[r];S&&(this.activeSub=r,S(y,M,this,g),this.activeSub=!1)}};function n(r,y,M){var g;return y&&typeof y=="object"&&(y[r]!==void 0?g=y[r]:M&&y.get&&typeof y.get=="function"&&(g=y.get(r))),g}function e(r,y,M,g,S,R){function D(){}D.prototype=r;function T(){}T.prototype=r.subs;var B,G=new D;G.subs=new T,G.subsText={},G.buf="",g=g||{},G.stackSubs=g,G.subsText=R;for(B in y)g[B]||(g[B]=y[B]);for(B in g)G.subs[B]=g[B];S=S||{},G.stackPartials=S;for(B in M)S[B]||(S[B]=M[B]);for(B in S)G.partials[B]=S[B];return G}var l=/&/g,i=/</g,a=/>/g,c=/\'/g,m=/\"/g,u=/[&<>\"\']/;function d(r){return String(r??"")}function x(r){return r=d(r),u.test(r)?r.replace(l,"&amp;").replace(i,"&lt;").replace(a,"&gt;").replace(c,"&#39;").replace(m,"&quot;"):r}var E=Array.isArray||function(r){return Object.prototype.toString.call(r)==="[object Array]"}})(s)})(Kt)),Kt}var Xt,In;function Dl(){if(In)return Xt;In=1;var s=Ml();return s.Template=Vl().Template,s.template=s.Template,Xt=s,Xt}var Le=Dl();const Ie={};Ie["file-summary-line"]=new Le.Template({code:function(s,t,n){var e=this;return e.b(n=n||""),e.b('<li class="d2h-file-list-line">'),e.b(`
12
+ `+n),e.b(' <span class="d2h-file-name-wrapper">'),e.b(`
13
+ `+n),e.b(e.rp("<fileIcon0",s,t," ")),e.b(' <a href="#'),e.b(e.v(e.f("fileHtmlId",s,t,0))),e.b('" class="d2h-file-name">'),e.b(e.v(e.f("fileName",s,t,0))),e.b("</a>"),e.b(`
14
+ `+n),e.b(' <span class="d2h-file-stats">'),e.b(`
15
+ `+n),e.b(' <span class="d2h-lines-added">'),e.b(e.v(e.f("addedLines",s,t,0))),e.b("</span>"),e.b(`
16
+ `+n),e.b(' <span class="d2h-lines-deleted">'),e.b(e.v(e.f("deletedLines",s,t,0))),e.b("</span>"),e.b(`
17
+ `+n),e.b(" </span>"),e.b(`
18
+ `+n),e.b(" </span>"),e.b(`
19
+ `+n),e.b("</li>"),e.fl()},partials:{"<fileIcon0":{name:"fileIcon",partials:{},subs:{}}},subs:{}});Ie["file-summary-wrapper"]=new Le.Template({code:function(s,t,n){var e=this;return e.b(n=n||""),e.b('<div class="d2h-file-list-wrapper '),e.b(e.v(e.f("colorScheme",s,t,0))),e.b('">'),e.b(`
20
+ `+n),e.b(' <div class="d2h-file-list-header">'),e.b(`
21
+ `+n),e.b(' <span class="d2h-file-list-title">Files changed ('),e.b(e.v(e.f("filesNumber",s,t,0))),e.b(")</span>"),e.b(`
22
+ `+n),e.b(' <a class="d2h-file-switch d2h-hide">hide</a>'),e.b(`
23
+ `+n),e.b(' <a class="d2h-file-switch d2h-show">show</a>'),e.b(`
24
+ `+n),e.b(" </div>"),e.b(`
25
+ `+n),e.b(' <ol class="d2h-file-list">'),e.b(`
26
+ `+n),e.b(" "),e.b(e.t(e.f("files",s,t,0))),e.b(`
27
+ `+n),e.b(" </ol>"),e.b(`
28
+ `+n),e.b("</div>"),e.fl()},partials:{},subs:{}});Ie["generic-block-header"]=new Le.Template({code:function(s,t,n){var e=this;return e.b(n=n||""),e.b("<tr>"),e.b(`
29
+ `+n),e.b(' <td class="'),e.b(e.v(e.f("lineClass",s,t,0))),e.b(" "),e.b(e.v(e.d("CSSLineClass.INFO",s,t,0))),e.b('"></td>'),e.b(`
30
+ `+n),e.b(' <td class="'),e.b(e.v(e.d("CSSLineClass.INFO",s,t,0))),e.b('">'),e.b(`
31
+ `+n),e.b(' <div class="'),e.b(e.v(e.f("contentClass",s,t,0))),e.b('">'),e.s(e.f("blockHeader",s,t,1),s,t,0,156,173,"{{ }}")&&(e.rs(s,t,function(l,i,a){a.b(a.t(a.f("blockHeader",l,i,0)))}),s.pop()),e.s(e.f("blockHeader",s,t,1),s,t,1,0,0,"")||e.b("&nbsp;"),e.b("</div>"),e.b(`
32
+ `+n),e.b(" </td>"),e.b(`
33
+ `+n),e.b("</tr>"),e.fl()},partials:{},subs:{}});Ie["generic-empty-diff"]=new Le.Template({code:function(s,t,n){var e=this;return e.b(n=n||""),e.b("<tr>"),e.b(`
34
+ `+n),e.b(' <td class="'),e.b(e.v(e.d("CSSLineClass.INFO",s,t,0))),e.b('">'),e.b(`
35
+ `+n),e.b(' <div class="'),e.b(e.v(e.f("contentClass",s,t,0))),e.b('">'),e.b(`
36
+ `+n),e.b(" File without changes"),e.b(`
37
+ `+n),e.b(" </div>"),e.b(`
38
+ `+n),e.b(" </td>"),e.b(`
39
+ `+n),e.b("</tr>"),e.fl()},partials:{},subs:{}});Ie["generic-file-path"]=new Le.Template({code:function(s,t,n){var e=this;return e.b(n=n||""),e.b('<span class="d2h-file-name-wrapper">'),e.b(`
40
+ `+n),e.b(e.rp("<fileIcon0",s,t," ")),e.b(' <span class="d2h-file-name">'),e.b(e.v(e.f("fileDiffName",s,t,0))),e.b("</span>"),e.b(`
41
+ `+n),e.b(e.rp("<fileTag1",s,t," ")),e.b("</span>"),e.b(`
42
+ `+n),e.b('<label class="d2h-file-collapse">'),e.b(`
43
+ `+n),e.b(' <input class="d2h-file-collapse-input" type="checkbox" name="viewed" value="viewed">'),e.b(`
44
+ `+n),e.b(" Viewed"),e.b(`
45
+ `+n),e.b("</label>"),e.fl()},partials:{"<fileIcon0":{name:"fileIcon",partials:{},subs:{}},"<fileTag1":{name:"fileTag",partials:{},subs:{}}},subs:{}});Ie["generic-line"]=new Le.Template({code:function(s,t,n){var e=this;return e.b(n=n||""),e.b("<tr>"),e.b(`
46
+ `+n),e.b(' <td class="'),e.b(e.v(e.f("lineClass",s,t,0))),e.b(" "),e.b(e.v(e.f("type",s,t,0))),e.b('">'),e.b(`
47
+ `+n),e.b(" "),e.b(e.t(e.f("lineNumber",s,t,0))),e.b(`
48
+ `+n),e.b(" </td>"),e.b(`
49
+ `+n),e.b(' <td class="'),e.b(e.v(e.f("type",s,t,0))),e.b('">'),e.b(`
50
+ `+n),e.b(' <div class="'),e.b(e.v(e.f("contentClass",s,t,0))),e.b('">'),e.b(`
51
+ `+n),e.s(e.f("prefix",s,t,1),s,t,0,162,238,"{{ }}")&&(e.rs(s,t,function(l,i,a){a.b(' <span class="d2h-code-line-prefix">'),a.b(a.t(a.f("prefix",l,i,0))),a.b("</span>"),a.b(`
52
+ `+n)}),s.pop()),e.s(e.f("prefix",s,t,1),s,t,1,0,0,"")||(e.b(' <span class="d2h-code-line-prefix">&nbsp;</span>'),e.b(`
53
+ `+n)),e.s(e.f("content",s,t,1),s,t,0,371,445,"{{ }}")&&(e.rs(s,t,function(l,i,a){a.b(' <span class="d2h-code-line-ctn">'),a.b(a.t(a.f("content",l,i,0))),a.b("</span>"),a.b(`
54
+ `+n)}),s.pop()),e.s(e.f("content",s,t,1),s,t,1,0,0,"")||(e.b(' <span class="d2h-code-line-ctn"><br></span>'),e.b(`
55
+ `+n)),e.b(" </div>"),e.b(`
56
+ `+n),e.b(" </td>"),e.b(`
57
+ `+n),e.b("</tr>"),e.fl()},partials:{},subs:{}});Ie["generic-wrapper"]=new Le.Template({code:function(s,t,n){var e=this;return e.b(n=n||""),e.b('<div class="d2h-wrapper '),e.b(e.v(e.f("colorScheme",s,t,0))),e.b('">'),e.b(`
58
+ `+n),e.b(" "),e.b(e.t(e.f("content",s,t,0))),e.b(`
59
+ `+n),e.b("</div>"),e.fl()},partials:{},subs:{}});Ie["icon-file-added"]=new Le.Template({code:function(s,t,n){var e=this;return e.b(n=n||""),e.b('<svg aria-hidden="true" class="d2h-icon d2h-added" height="16" title="added" version="1.1" viewBox="0 0 14 16"'),e.b(`
60
+ `+n),e.b(' width="14">'),e.b(`
61
+ `+n),e.b(' <path d="M13 1H1C0.45 1 0 1.45 0 2v12c0 0.55 0.45 1 1 1h12c0.55 0 1-0.45 1-1V2c0-0.55-0.45-1-1-1z m0 13H1V2h12v12zM6 9H3V7h3V4h2v3h3v2H8v3H6V9z"></path>'),e.b(`
62
+ `+n),e.b("</svg>"),e.fl()},partials:{},subs:{}});Ie["icon-file-changed"]=new Le.Template({code:function(s,t,n){var e=this;return e.b(n=n||""),e.b('<svg aria-hidden="true" class="d2h-icon d2h-changed" height="16" title="modified" version="1.1"'),e.b(`
63
+ `+n),e.b(' viewBox="0 0 14 16" width="14">'),e.b(`
64
+ `+n),e.b(' <path d="M13 1H1C0.45 1 0 1.45 0 2v12c0 0.55 0.45 1 1 1h12c0.55 0 1-0.45 1-1V2c0-0.55-0.45-1-1-1z m0 13H1V2h12v12zM4 8c0-1.66 1.34-3 3-3s3 1.34 3 3-1.34 3-3 3-3-1.34-3-3z"></path>'),e.b(`
65
+ `+n),e.b("</svg>"),e.fl()},partials:{},subs:{}});Ie["icon-file-deleted"]=new Le.Template({code:function(s,t,n){var e=this;return e.b(n=n||""),e.b('<svg aria-hidden="true" class="d2h-icon d2h-deleted" height="16" title="removed" version="1.1"'),e.b(`
66
+ `+n),e.b(' viewBox="0 0 14 16" width="14">'),e.b(`
67
+ `+n),e.b(' <path d="M13 1H1C0.45 1 0 1.45 0 2v12c0 0.55 0.45 1 1 1h12c0.55 0 1-0.45 1-1V2c0-0.55-0.45-1-1-1z m0 13H1V2h12v12zM11 9H3V7h8v2z"></path>'),e.b(`
68
+ `+n),e.b("</svg>"),e.fl()},partials:{},subs:{}});Ie["icon-file-renamed"]=new Le.Template({code:function(s,t,n){var e=this;return e.b(n=n||""),e.b('<svg aria-hidden="true" class="d2h-icon d2h-moved" height="16" title="renamed" version="1.1"'),e.b(`
69
+ `+n),e.b(' viewBox="0 0 14 16" width="14">'),e.b(`
70
+ `+n),e.b(' <path d="M6 9H3V7h3V4l5 4-5 4V9z m8-7v12c0 0.55-0.45 1-1 1H1c-0.55 0-1-0.45-1-1V2c0-0.55 0.45-1 1-1h12c0.55 0 1 0.45 1 1z m-1 0H1v12h12V2z"></path>'),e.b(`
71
+ `+n),e.b("</svg>"),e.fl()},partials:{},subs:{}});Ie["icon-file"]=new Le.Template({code:function(s,t,n){var e=this;return e.b(n=n||""),e.b('<svg aria-hidden="true" class="d2h-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12">'),e.b(`
72
+ `+n),e.b(' <path d="M6 5H2v-1h4v1zM2 8h7v-1H2v1z m0 2h7v-1H2v1z m0 2h7v-1H2v1z m10-7.5v9.5c0 0.55-0.45 1-1 1H1c-0.55 0-1-0.45-1-1V2c0-0.55 0.45-1 1-1h7.5l3.5 3.5z m-1 0.5L8 2H1v12h10V5z"></path>'),e.b(`
73
+ `+n),e.b("</svg>"),e.fl()},partials:{},subs:{}});Ie["line-by-line-file-diff"]=new Le.Template({code:function(s,t,n){var e=this;return e.b(n=n||""),e.b('<div id="'),e.b(e.v(e.f("fileHtmlId",s,t,0))),e.b('" class="d2h-file-wrapper" data-lang="'),e.b(e.v(e.d("file.language",s,t,0))),e.b('">'),e.b(`
74
+ `+n),e.b(' <div class="d2h-file-header">'),e.b(`
75
+ `+n),e.b(" "),e.b(e.t(e.f("filePath",s,t,0))),e.b(`
76
+ `+n),e.b(" </div>"),e.b(`
77
+ `+n),e.b(' <div class="d2h-file-diff">'),e.b(`
78
+ `+n),e.b(' <div class="d2h-code-wrapper">'),e.b(`
79
+ `+n),e.b(' <table class="d2h-diff-table">'),e.b(`
80
+ `+n),e.b(' <tbody class="d2h-diff-tbody">'),e.b(`
81
+ `+n),e.b(" "),e.b(e.t(e.f("diffs",s,t,0))),e.b(`
82
+ `+n),e.b(" </tbody>"),e.b(`
83
+ `+n),e.b(" </table>"),e.b(`
84
+ `+n),e.b(" </div>"),e.b(`
85
+ `+n),e.b(" </div>"),e.b(`
86
+ `+n),e.b("</div>"),e.fl()},partials:{},subs:{}});Ie["line-by-line-numbers"]=new Le.Template({code:function(s,t,n){var e=this;return e.b(n=n||""),e.b('<div class="line-num1">'),e.b(e.v(e.f("oldNumber",s,t,0))),e.b("</div>"),e.b(`
87
+ `+n),e.b('<div class="line-num2">'),e.b(e.v(e.f("newNumber",s,t,0))),e.b("</div>"),e.fl()},partials:{},subs:{}});Ie["side-by-side-file-diff"]=new Le.Template({code:function(s,t,n){var e=this;return e.b(n=n||""),e.b('<div id="'),e.b(e.v(e.f("fileHtmlId",s,t,0))),e.b('" class="d2h-file-wrapper" data-lang="'),e.b(e.v(e.d("file.language",s,t,0))),e.b('">'),e.b(`
88
+ `+n),e.b(' <div class="d2h-file-header">'),e.b(`
89
+ `+n),e.b(" "),e.b(e.t(e.f("filePath",s,t,0))),e.b(`
90
+ `+n),e.b(" </div>"),e.b(`
91
+ `+n),e.b(' <div class="d2h-files-diff">'),e.b(`
92
+ `+n),e.b(' <div class="d2h-file-side-diff">'),e.b(`
93
+ `+n),e.b(' <div class="d2h-code-wrapper">'),e.b(`
94
+ `+n),e.b(' <table class="d2h-diff-table">'),e.b(`
95
+ `+n),e.b(' <tbody class="d2h-diff-tbody">'),e.b(`
96
+ `+n),e.b(" "),e.b(e.t(e.d("diffs.left",s,t,0))),e.b(`
97
+ `+n),e.b(" </tbody>"),e.b(`
98
+ `+n),e.b(" </table>"),e.b(`
99
+ `+n),e.b(" </div>"),e.b(`
100
+ `+n),e.b(" </div>"),e.b(`
101
+ `+n),e.b(' <div class="d2h-file-side-diff">'),e.b(`
102
+ `+n),e.b(' <div class="d2h-code-wrapper">'),e.b(`
103
+ `+n),e.b(' <table class="d2h-diff-table">'),e.b(`
104
+ `+n),e.b(' <tbody class="d2h-diff-tbody">'),e.b(`
105
+ `+n),e.b(" "),e.b(e.t(e.d("diffs.right",s,t,0))),e.b(`
106
+ `+n),e.b(" </tbody>"),e.b(`
107
+ `+n),e.b(" </table>"),e.b(`
108
+ `+n),e.b(" </div>"),e.b(`
109
+ `+n),e.b(" </div>"),e.b(`
110
+ `+n),e.b(" </div>"),e.b(`
111
+ `+n),e.b("</div>"),e.fl()},partials:{},subs:{}});Ie["tag-file-added"]=new Le.Template({code:function(s,t,n){var e=this;return e.b(n=n||""),e.b('<span class="d2h-tag d2h-added d2h-added-tag">ADDED</span>'),e.fl()},partials:{},subs:{}});Ie["tag-file-changed"]=new Le.Template({code:function(s,t,n){var e=this;return e.b(n=n||""),e.b('<span class="d2h-tag d2h-changed d2h-changed-tag">CHANGED</span>'),e.fl()},partials:{},subs:{}});Ie["tag-file-deleted"]=new Le.Template({code:function(s,t,n){var e=this;return e.b(n=n||""),e.b('<span class="d2h-tag d2h-deleted d2h-deleted-tag">DELETED</span>'),e.fl()},partials:{},subs:{}});Ie["tag-file-renamed"]=new Le.Template({code:function(s,t,n){var e=this;return e.b(n=n||""),e.b('<span class="d2h-tag d2h-moved d2h-moved-tag">RENAMED</span>'),e.fl()},partials:{},subs:{}});class Fl{constructor({compiledTemplates:t={},rawTemplates:n={}}){const e=Object.entries(n).reduce((l,[i,a])=>{const c=Le.compile(a,{asString:!1});return Object.assign(Object.assign({},l),{[i]:c})},{});this.preCompiledTemplates=Object.assign(Object.assign(Object.assign({},Ie),t),e)}static compile(t){return Le.compile(t,{asString:!1})}render(t,n,e,l,i){const a=this.templateKey(t,n);try{return this.preCompiledTemplates[a].render(e,l,i)}catch{throw new Error(`Could not find template to render '${a}'`)}}template(t,n){return this.preCompiledTemplates[this.templateKey(t,n)]}templateKey(t,n){return`${t}-${n}`}}const Al=Object.assign(Object.assign(Object.assign({},Xn),Jn),{outputFormat:sl.LINE_BY_LINE,drawFileList:!0});function Bl(s,t={}){const n=Object.assign(Object.assign({},Al),t),e=typeof s=="string"?fl(s,n):s,l=new Fl(n),{colorScheme:i}=n,a={colorScheme:i},c=n.drawFileList?new Sl(l,a).render(e):"",m=n.outputFormat==="side-by-side"?new Rl(l,n).render(e):new El(l,n).render(e);return c+m}const Ol={class:"diff-viewer"},Ul=["innerHTML"],zl={key:1,class:"diff-fallback mono"},Hl=ze({__name:"DiffViewer",props:{patch:{}},setup(s){const t=s,n=W(()=>{if(!t.patch.trim())return"";try{return Bl(t.patch,{drawFileList:!1,outputFormat:"line-by-line",matching:"lines",colorScheme:pt.DARK,renderNothingWhenEmpty:!0})}catch{return""}}),e=W(()=>n.value===""?t.patch.split(`
112
+ `):[]);return(l,i)=>(h(),P("div",Ol,[n.value?(h(),P("div",{key:0,class:"diff-html",innerHTML:n.value},null,8,Ul)):e.value.length?(h(),P("pre",zl,[(h(!0),P(ue,null,_e(e.value,(a,c)=>(h(),P(ue,{key:c},[L($(a)+`
113
+ `,1)],64))),128))])):j("",!0)]))}}),en=He(Hl,[["__scopeId","data-v-3ec3d3ee"]]),jl={class:"page status-page"},Gl={class:"page-head"},ql={class:"head-branch"},Wl={key:0,class:"tracking mono"},Kl={key:1,class:"sync ahead"},Xl={key:2,class:"sync behind"},Jl={class:"repo-path mono"},Yl={key:1,class:"empty-tip"},Ql={key:2,class:"status-layout"},Zl={class:"panel-head"},ei={class:"panel-actions"},ti={class:"tree-scroll"},ni={class:"group-label"},si={key:0,class:"tree-dir"},li=["title","onDblclick"],ii={class:"node-name"},oi={class:"node-actions"},ai={key:1,class:"pane-empty"},ri={class:"status-content"},ui={class:"toolbar"},di={class:"toolbar-group"},ci={class:"card-head"},fi={class:"card-actions"},pi={class:"tab-label"},mi={class:"tab-hint"},hi={key:0,class:"file-empty"},vi={key:1,class:"file-list"},gi=["title"],bi={class:"card-head"},yi={class:"card-title"},_i={class:"card-actions"},ki={key:0,class:"file-empty"},wi={key:1,class:"stash-list mono"},Ci={class:"stash-main"},$i={class:"stash-ref"},xi=["title"],Si={key:0,class:"stash-date"},Ti={class:"stash-actions"},Li={class:"diff-wrap"},Ei={class:"diff-summary"},Ii={class:"add"},Pi={class:"del"},Ni={key:0,class:"warn"},Ri={key:0,class:"file-empty"},Mi={key:0,class:"stash-files"},Vi={class:"stash-files-head"},Di={class:"stash-files-title"},Fi={class:"card-actions"},Ai={class:"file-list compact"},Bi={class:"file-path mono"},Oi=ze({__name:"StatusView",setup(s){const t=Ae(),n=Pt(),{revision:e}=Ot(),l=()=>t.currentId,i=se(null),a=se([]),c=se(!1),m=se(""),u=Yt({visible:!1,title:"",diff:null,patch:"",loading:!1}),d=se(!1),x=se(""),E=se(!1),r=se(""),y=se(""),M=se(!1),g=se(""),S=se(!1),R=se(!1),D=se(""),T=Yt(new Set),B=W(()=>T.size),G=se("unstaged"),{confirmVisible:ne,pending:w,canRun:N,previewAndConfirm:F,executeConfirmed:O,cancel:ce}=Hn(l),he=W(()=>{var V;return((V=t.current)==null?void 0:V.path)??""}),de=W(()=>{var V,k;return((V=i.value)==null?void 0:V.currentShort)??((k=i.value)==null?void 0:k.current)??""}),oe=W(()=>{var V;return((V=i.value)==null?void 0:V.ahead)??0}),$e=W(()=>{var V;return((V=i.value)==null?void 0:V.behind)??0}),ke=W(()=>n.panes),ge=W(()=>{const V=i.value;if(!V)return{unstaged:[],staged:[],untracked:[],all:[]};const k=V.untracked.map(Pe=>({path:Pe,status:"??",indexStatus:"?",workTreeStatus:"?",staged:!1,untracked:!0,conflicted:!1})),ve=[...V.staged,...V.unstaged,...k],te=new Set,le=ve.filter(Pe=>te.has(Pe.path)?!1:(te.add(Pe.path),Pe.path!==""));return{unstaged:V.unstaged,staged:V.staged,untracked:k,all:le}}),be=W(()=>[{key:"unstaged",label:"未暂存",hint:"已修改,未 git add",count:ge.value.unstaged.length},{key:"staged",label:"已暂存",hint:"已 git add,未提交",count:ge.value.staged.length},{key:"untracked",label:"未跟踪",hint:"工作区新文件",count:ge.value.untracked.length},{key:"all",label:"全部",hint:"全部更改",count:ge.value.all.length}]),q=W(()=>ge.value[G.value]??[]),b=W(()=>ge.value.all.length);function z(V){if(!V||V.remote||!V.upstream)return"";const k=[];return(V.ahead??0)>0&&k.push(`↑${V.ahead}`),(V.behind??0)>0&&k.push(`↓${V.behind}`),k.join(" ")}async function C(){const V=l();if(V!==null){c.value=!0,m.value="";try{i.value=await ms(V)}catch(k){m.value=k instanceof Error?k.message:String(k),i.value=null}finally{c.value=!1}}}async function Z(){await n.load()}async function U(){const V=l();if(V!==null)try{a.value=await ys(V)}catch{}}async function A(){await Promise.all([C(),Z(),U()])}async function K(V,k={}){await F(V,k)&&ie.info("请在确认对话框中查看 dry-run 预览")}async function ae(){const V=await O();V!=null&&V.success&&await A()}function re(V){K("git_add",{paths:[V.path]})}function fe(V){K("git_unstage",{paths:[V.path]})}function ye(V){V.staged?fe(V):re(V)}function Se(){K("git_add",{})}function Ve(){var k;const V=((k=i.value)==null?void 0:k.staged.map(ve=>ve.path))??[];if(V.length===0){ie.info("没有已暂存的文件");return}K("git_unstage",{paths:V})}async function pe(V){const k=l();if(k!==null){u.title=`${V.path}(${V.staged?"已 git add":"工作区修改"})`,u.diff=null,u.patch="",u.visible=!0,u.loading=!0;try{u.diff=await vs(k,{path:V.path,staged:V.staged})}catch(ve){ie.error(ve instanceof Error?ve.message:String(ve)),u.visible=!1}finally{u.loading=!1}}}async function Xe(V){var ve;const k=l();if(k!==null){u.title=`${V.ref} · ${V.message||"(无说明)"}`,u.diff=null,u.patch="",u.visible=!0,u.loading=!0;try{const te=await mt(k,"git_stash_show",{index:V.index});if(te.success){const le=te.result??{};u.patch=le.patch??""}else ie.error(((ve=te.error)==null?void 0:ve.message)??"查看差异失败"),u.visible=!1}catch(te){ie.error(te instanceof Error?te.message:String(te)),u.visible=!1}finally{u.loading=!1}}}function Ne(V){T.has(V)?T.delete(V):T.add(V)}function ot(V){return T.has(V)}function Ze(){T.clear()}function kt(){for(const V of q.value)T.add(V.path)}function at(){for(const V of et.value)T.add(V)}const et=W(()=>{const V=i.value;if(!V)return[];const k=new Set;return[...V.unstaged.map(ve=>ve.path),...V.untracked].filter(ve=>k.has(ve)?!1:(k.add(ve),ve!==""))});function X(){M.value=!0}function o(){const V=et.value,k=[...T].filter(le=>V.includes(le)),ve=k.some(le=>{var Pe;return((Pe=i.value)==null?void 0:Pe.untracked.includes(le))??!1}),te={};g.value.trim()&&(te.message=g.value.trim()),k.length&&(te.paths=k),(S.value||ve)&&(te.includeUntracked=!0),M.value=!1,T.clear(),K("git_stash",te)}function _(){K("git_stash",{})}function Q(V){K("git_stash_apply",{index:V.index})}function ee(V){K("git_stash_pop",{index:V.index})}function we(V){Tt.confirm(`确定删除 ${V.ref} 吗?删除后不可直接恢复。`,"删除 stash",{type:"warning",confirmButtonText:"继续",cancelButtonText:"取消"}).then(()=>void K("git_stash_drop",{index:V.index})).catch(()=>{})}function Ce(V){V.branch&&K("git_checkout",{branch:V.branch.name})}function De(){K("git_pull")}function Oe(){K("git_push")}function vt(){const V=x.value.trim();if(!V){ie.warning("请输入提交信息");return}d.value=!1,K("git_commit",{message:V})}function tt(){const V=r.value.trim();if(!V){ie.warning("请输入分支名");return}E.value=!1,K("git_branch_create",y.value.trim()?{name:V,startPoint:y.value.trim()}:{name:V})}function gt(){const V=D.value.trim()||"HEAD";R.value=!1,D.value="",K("git_reset_hard",{target:V})}function je(V){return V.untracked?"?":V.staged?V.indexStatus||"M":V.workTreeStatus||"M"}function nt(V){return V.untracked?"new":V.conflicted?"conflict":V.staged?"add":"mod"}function xe(V){if(!V)return"";const k=new Date(V);return Number.isNaN(k.getTime())?V:k.toLocaleString()}function Ge(V){return V.split(`
114
+ `)[0]??""}return Te(l,()=>{u.diff=null,u.patch="",u.visible=!1,T.clear(),A()}),Te(e,()=>{A()}),ht(()=>{A()}),(V,k)=>{var dn,cn,fn,pn,mn;const ve=H("el-tag"),te=H("el-button"),le=H("el-alert"),Pe=H("el-tree"),Be=H("el-empty"),rt=H("el-card"),wt=H("el-badge"),Nt=H("el-tooltip"),bt=H("el-checkbox"),Rt=H("el-tab-pane"),Mt=H("el-tabs"),Vt=H("el-drawer"),st=H("el-input"),ut=H("el-dialog"),dt=H("el-form-item"),Ct=H("el-form"),Je=Bt("loading");return h(),P("div",jl,[p("div",Gl,[k[26]||(k[26]=p("h2",{class:"page-title"},"仓库状态",-1)),p("div",ql,[v(ve,{type:"primary",effect:"dark",class:"branch-tag"},{default:f(()=>[L($(de.value||"—"),1)]),_:1}),(dn=i.value)!=null&&dn.tracking?(h(),P("span",Wl,$(i.value.tracking),1)):j("",!0),oe.value?(h(),P("span",Kl,"↑"+$(oe.value),1)):j("",!0),$e.value?(h(),P("span",Xl,"↓"+$($e.value),1)):j("",!0),(cn=i.value)!=null&&cn.isClean?(h(),Y(ve,{key:3,type:"success",effect:"plain",size:"small"},{default:f(()=>[...k[24]||(k[24]=[L("工作区干净",-1)])]),_:1})):i.value?(h(),Y(ve,{key:4,type:"warning",effect:"plain",size:"small"},{default:f(()=>[L($(b.value)+" 处更改",1)]),_:1})):j("",!0),p("span",Jl,$(he.value),1)]),v(te,{loading:c.value,onClick:A},{default:f(()=>[...k[25]||(k[25]=[L("刷新",-1)])]),_:1},8,["loading"])]),m.value?(h(),Y(le,{key:0,title:m.value,type:"error",closable:!1,"show-icon":"",class:"mb"},null,8,["title"])):j("",!0),I(N)?(h(),P("div",Ql,[v(rt,{shadow:"never",class:"branch-panel"},{header:f(()=>[p("div",Zl,[k[29]||(k[29]=p("span",{class:"panel-title"},"分支 Branch",-1)),p("div",ei,[v(te,{size:"small",text:"",onClick:Z},{default:f(()=>[...k[27]||(k[27]=[L("刷新",-1)])]),_:1}),v(te,{size:"small",text:"",type:"primary",onClick:k[0]||(k[0]=J=>E.value=!0)},{default:f(()=>[...k[28]||(k[28]=[L("+ 新建",-1)])]),_:1})])])]),default:f(()=>[p("div",ti,[(h(!0),P(ue,null,_e(ke.value,J=>(h(),P(ue,{key:J.key},[p("div",ni,$(J.title),1),J.tree.length?(h(),Y(Pe,{key:0,data:J.tree,props:{label:"label",children:"children"},"node-key":"key","default-expand-all":"",indent:14,class:"branch-tree"},{default:f(({data:me})=>{var Ye,jt,hn;return[me.branch?(h(),P("div",{key:1,class:Fe(["branch-node",{current:(Ye=me.branch)==null?void 0:Ye.current,remote:me.remote}]),title:me.fullName,onDblclick:ts=>{var vn;return((vn=me.branch)==null?void 0:vn.current)||Ce(me)}},[p("span",ii,$(me.label),1),me.remote?j("",!0):(h(),P("span",{key:0,class:Fe(["node-sync",{clean:!z(me.branch)&&((jt=me.branch)==null?void 0:jt.upstream)}])},$(z(me.branch)),3)),p("span",oi,[(hn=me.branch)!=null&&hn.current?(h(),P(ue,{key:0},[v(te,{size:"small",text:"",type:"success",onClick:Ue(De,["stop"])},{default:f(()=>[...k[30]||(k[30]=[L("拉取",-1)])]),_:1}),v(te,{size:"small",text:"",type:"primary",onClick:Ue(Oe,["stop"])},{default:f(()=>[...k[31]||(k[31]=[L("推送",-1)])]),_:1})],64)):(h(),Y(te,{key:1,size:"small",text:"",type:"primary",onClick:Ue(ts=>Ce(me),["stop"])},{default:f(()=>[...k[32]||(k[32]=[L("切换",-1)])]),_:1},8,["onClick"]))])],42,li)):(h(),P("span",si,$(me.label),1))]}),_:1},8,["data"])):(h(),P("div",ai,"暂无分支"))],64))),128)),ke.value.length===0?(h(),Y(Be,{key:0,description:"暂无分支","image-size":60})):j("",!0)])]),_:1}),p("div",ri,[v(rt,{shadow:"never",class:"toolbar-card"},{default:f(()=>{var J;return[p("div",ui,[p("div",di,[v(te,{type:"primary",onClick:k[1]||(k[1]=me=>d.value=!0)},{default:f(()=>[...k[33]||(k[33]=[L("提交 Commit",-1)])]),_:1}),v(te,{plain:"",onClick:Se},{default:f(()=>[...k[34]||(k[34]=[L("暂存全部",-1)])]),_:1}),v(te,{plain:"",disabled:(((J=i.value)==null?void 0:J.staged.length)??0)===0,onClick:Ve},{default:f(()=>[...k[35]||(k[35]=[L("取消暂存全部",-1)])]),_:1},8,["disabled"]),v(wt,{value:B.value,hidden:B.value===0,offset:[2,4]},{default:f(()=>[v(te,{type:"success",plain:"",onClick:X},{default:f(()=>[...k[36]||(k[36]=[L("暂存改动 Stash",-1)])]),_:1})]),_:1},8,["value","hidden"]),v(Nt,{content:"Shelve Silently:使用默认说明,一键暂存全部更改",placement:"top"},{default:f(()=>[v(te,{plain:"",onClick:_},{default:f(()=>[...k[37]||(k[37]=[L("静默 Stash",-1)])]),_:1})]),_:1}),v(te,{type:"danger",plain:"",onClick:k[2]||(k[2]=me=>R.value=!0)},{default:f(()=>[...k[38]||(k[38]=[L("硬重置",-1)])]),_:1}),v(te,{type:"danger",plain:"",onClick:k[3]||(k[3]=me=>K("git_clean"))},{default:f(()=>[...k[39]||(k[39]=[L("清理未跟踪",-1)])]),_:1})])])]}),_:1}),(fn=i.value)!=null&&fn.conflicted.length?(h(),Y(le,{key:0,title:"存在合并冲突,请先解决冲突(修改文件后重新 git add 并提交)",type:"error",closable:!1,"show-icon":"",class:"mb"})):j("",!0),v(rt,{shadow:"never",class:"changes-card"},{header:f(()=>[p("div",ci,[k[42]||(k[42]=p("span",{class:"card-title"},"更改 Changes",-1)),p("div",fi,[B.value?(h(),Y(ve,{key:0,size:"small",type:"primary",effect:"plain"},{default:f(()=>[L("已选 "+$(B.value),1)]),_:1})):j("",!0),v(te,{size:"small",text:"",onClick:kt},{default:f(()=>[...k[40]||(k[40]=[L("全选本组",-1)])]),_:1}),B.value?(h(),Y(te,{key:1,size:"small",text:"",type:"danger",onClick:Ze},{default:f(()=>[...k[41]||(k[41]=[L("清除选择",-1)])]),_:1})):j("",!0)])])]),default:f(()=>[v(Mt,{modelValue:G.value,"onUpdate:modelValue":k[4]||(k[4]=J=>G.value=J),class:"changes-tabs"},{default:f(()=>[(h(!0),P(ue,null,_e(be.value,J=>(h(),Y(Rt,{key:J.key,name:J.key},{label:f(()=>[p("span",pi,[L($(J.label)+" ",1),v(wt,{value:J.count,hidden:J.count===0,type:"primary",class:"tab-badge"},null,8,["value","hidden"])])]),default:f(()=>[p("div",mi,"「"+$(J.hint)+"」",1),J.count===0?(h(),P("div",hi,"没有"+$(J.label)+"的文件",1)):(h(),P("div",vi,[(h(!0),P(ue,null,_e(ge.value[J.key],me=>(h(),P("div",{key:J.key+me.path,class:"file-row"},[v(bt,{"model-value":ot(me.path),onChange:Ye=>Ne(me.path)},null,8,["model-value","onChange"]),p("span",{class:Fe(["file-status",nt(me)])},$(je(me)),3),p("span",{class:"file-path mono",title:me.path},$(me.path),9,gi),v(te,{size:"small",text:"",type:"primary",onClick:Ye=>pe(me)},{default:f(()=>[...k[43]||(k[43]=[L("查看差异",-1)])]),_:1},8,["onClick"]),me.conflicted?(h(),Y(te,{key:0,size:"small",text:"",type:"warning",onClick:Ye=>re(me)},{default:f(()=>[...k[44]||(k[44]=[L("标记已解决(git add)",-1)])]),_:1},8,["onClick"])):(h(),Y(te,{key:1,size:"small",text:"",type:me.staged?"warning":"success",onClick:Ye=>ye(me)},{default:f(()=>[L($(me.staged?"取消暂存":"暂存"),1)]),_:2},1032,["type","onClick"]))]))),128))]))]),_:2},1032,["name"]))),128))]),_:1},8,["modelValue"])]),_:1}),v(rt,{shadow:"never",class:"stash-card"},{header:f(()=>[p("div",bi,[p("span",yi,"暂存列表 Stash("+$(a.value.length)+")",1),p("div",_i,[v(te,{size:"small",text:"",onClick:U},{default:f(()=>[...k[45]||(k[45]=[L("刷新",-1)])]),_:1})])])]),default:f(()=>[a.value.length===0?(h(),P("div",ki,"没有暂存的更改")):(h(),P("div",wi,[(h(!0),P(ue,null,_e(a.value,J=>(h(),P("div",{key:J.ref,class:"stash-row"},[p("div",Ci,[p("span",$i,$(J.ref),1),p("span",{class:"stash-msg",title:J.message},$(Ge(J.message)||"(无说明)"),9,xi),J.date?(h(),P("span",Si,$(xe(J.date)),1)):j("",!0)]),p("div",Ti,[v(te,{size:"small",text:"",type:"primary",onClick:me=>Xe(J)},{default:f(()=>[...k[46]||(k[46]=[L("差异",-1)])]),_:1},8,["onClick"]),v(te,{size:"small",text:"",type:"success",onClick:me=>Q(J)},{default:f(()=>[...k[47]||(k[47]=[L("应用",-1)])]),_:1},8,["onClick"]),v(te,{size:"small",text:"",type:"warning",onClick:me=>ee(J)},{default:f(()=>[...k[48]||(k[48]=[L("恢复",-1)])]),_:1},8,["onClick"]),v(te,{size:"small",text:"",type:"danger",onClick:me=>we(J)},{default:f(()=>[...k[49]||(k[49]=[L("删除",-1)])]),_:1},8,["onClick"])])]))),128))]))]),_:1})])])):(h(),P("div",Yl,"请先在「仓库管理」中打开一个仓库")),v(jn,{visible:I(ne),"onUpdate:visible":k[5]||(k[5]=J=>We(ne)?ne.value=J:null),tool:((pn=I(w))==null?void 0:pn.tool)??"",preview:((mn=I(w))==null?void 0:mn.preview)??null,onConfirm:ae,onCancel:I(ce)},null,8,["visible","tool","preview","onCancel"]),v(Vt,{modelValue:u.visible,"onUpdate:modelValue":k[6]||(k[6]=J=>u.visible=J),title:u.title,size:"56%","destroy-on-close":""},{default:f(()=>[At((h(),P("div",Li,[u.diff?(h(),P(ue,{key:0},[p("div",Ei,[p("span",null,$(u.diff.files.length)+" 个文件",1),p("span",Ii,"+"+$(u.diff.insertions),1),p("span",Pi,"-"+$(u.diff.deletions),1),u.diff.truncated?(h(),P("span",Ni,"(已截断)")):j("",!0)]),v(en,{patch:u.diff.rawPatch},null,8,["patch"])],64)):u.patch?(h(),P(ue,{key:1},[u.patch?(h(),Y(en,{key:1,patch:u.patch},null,8,["patch"])):(h(),P("div",Ri,"无差异"))],64)):u.loading?j("",!0):(h(),Y(Be,{key:2,description:"无差异","image-size":60}))])),[[Je,u.loading]])]),_:1},8,["modelValue","title"]),v(ut,{modelValue:d.value,"onUpdate:modelValue":k[9]||(k[9]=J=>d.value=J),title:"提交 Commit",width:"520px",onClosed:k[10]||(k[10]=J=>x.value="")},{footer:f(()=>[v(te,{onClick:k[8]||(k[8]=J=>d.value=!1)},{default:f(()=>[...k[50]||(k[50]=[L("取消",-1)])]),_:1}),v(te,{type:"primary",onClick:vt},{default:f(()=>[...k[51]||(k[51]=[L("下一步(dry-run 预览)",-1)])]),_:1})]),default:f(()=>[v(st,{modelValue:x.value,"onUpdate:modelValue":k[7]||(k[7]=J=>x.value=J),type:"textarea",rows:5,placeholder:"输入提交信息(message)",onKeydown:Ft(Ue(vt,["ctrl"]),["enter"])},null,8,["modelValue","onKeydown"])]),_:1},8,["modelValue"]),v(ut,{modelValue:E.value,"onUpdate:modelValue":k[14]||(k[14]=J=>E.value=J),title:"新建分支",width:"480px",onClosed:k[15]||(k[15]=J=>{r.value="",y.value=""})},{footer:f(()=>[v(te,{onClick:k[13]||(k[13]=J=>E.value=!1)},{default:f(()=>[...k[52]||(k[52]=[L("取消",-1)])]),_:1}),v(te,{type:"primary",onClick:tt},{default:f(()=>[...k[53]||(k[53]=[L("下一步(dry-run 预览)",-1)])]),_:1})]),default:f(()=>[v(Ct,{"label-width":"100px"},{default:f(()=>[v(dt,{label:"分支名"},{default:f(()=>[v(st,{modelValue:r.value,"onUpdate:modelValue":k[11]||(k[11]=J=>r.value=J),placeholder:"feature/xxx"},null,8,["modelValue"])]),_:1}),v(dt,{label:"起点(可选)"},{default:f(()=>[v(st,{modelValue:y.value,"onUpdate:modelValue":k[12]||(k[12]=J=>y.value=J),placeholder:"默认当前 HEAD,如 main 或 commit hash"},null,8,["modelValue"])]),_:1})]),_:1})]),_:1},8,["modelValue"]),v(ut,{modelValue:M.value,"onUpdate:modelValue":k[19]||(k[19]=J=>M.value=J),title:"暂存改动 Stash",width:"660px"},{footer:f(()=>[v(te,{onClick:k[18]||(k[18]=J=>M.value=!1)},{default:f(()=>[...k[57]||(k[57]=[L("取消",-1)])]),_:1}),v(te,{type:"primary",onClick:o},{default:f(()=>[...k[58]||(k[58]=[L("下一步(dry-run 预览)",-1)])]),_:1})]),default:f(()=>[v(le,{class:"stash-tip",title:"可勾选左侧更改列表的文件随本次 stash 一起保存;不勾选则保存全部更改。",type:"info",closable:!1,"show-icon":""}),v(Ct,{"label-width":"100px"},{default:f(()=>[v(dt,{label:"说明(可选)"},{default:f(()=>[v(st,{modelValue:g.value,"onUpdate:modelValue":k[16]||(k[16]=J=>g.value=J),placeholder:"留空则使用默认说明(WIP on 分支: 提交)"},null,8,["modelValue"])]),_:1}),v(dt,{label:"包含未跟踪"},{default:f(()=>[v(bt,{modelValue:S.value,"onUpdate:modelValue":k[17]||(k[17]=J=>S.value=J)},{default:f(()=>[...k[54]||(k[54]=[L("包含未跟踪文件(-u)。勾选文件后会自动包含其中的未跟踪文件",-1)])]),_:1},8,["modelValue"])]),_:1})]),_:1}),et.value.length?(h(),P("div",Mi,[p("div",Vi,[p("span",Di,"选择文件(已选 "+$(B.value)+")",1),p("div",Fi,[v(te,{size:"small",text:"",onClick:at},{default:f(()=>[...k[55]||(k[55]=[L("全选",-1)])]),_:1}),v(te,{size:"small",text:"",onClick:Ze},{default:f(()=>[...k[56]||(k[56]=[L("清除选择",-1)])]),_:1})])]),p("div",Ai,[(h(!0),P(ue,null,_e(et.value,J=>{var me,Ye;return h(),P("div",{key:J,class:"file-row"},[v(bt,{"model-value":ot(J),onChange:jt=>Ne(J)},null,8,["model-value","onChange"]),p("span",{class:Fe(["file-status",(me=i.value)!=null&&me.untracked.includes(J)?"new":"mod"])},$((Ye=i.value)!=null&&Ye.untracked.includes(J)?"?":"M"),3),p("span",Bi,$(J),1)])}),128))])])):j("",!0)]),_:1},8,["modelValue"]),v(ut,{modelValue:R.value,"onUpdate:modelValue":k[22]||(k[22]=J=>R.value=J),title:"硬重置(高风险)",width:"480px",onClosed:k[23]||(k[23]=J=>D.value="")},{footer:f(()=>[v(te,{onClick:k[21]||(k[21]=J=>R.value=!1)},{default:f(()=>[...k[59]||(k[59]=[L("取消",-1)])]),_:1}),v(te,{type:"danger",onClick:gt},{default:f(()=>[...k[60]||(k[60]=[L("下一步(dry-run 预览)",-1)])]),_:1})]),default:f(()=>[v(le,{title:"将丢弃索引与工作区所有更改(不可逆),执行前会自动创建备份",type:"error",closable:!1,"show-icon":"",class:"mb"}),v(st,{modelValue:D.value,"onUpdate:modelValue":k[20]||(k[20]=J=>D.value=J),placeholder:"重置目标,默认 HEAD,如 HEAD~1 / commit hash / main"},null,8,["modelValue"])]),_:1},8,["modelValue"])])}}}),Ui=He(Oi,[["__scopeId","data-v-58d9b23f"]]),zi={class:"branch-option"},Hi=ze({__name:"BranchTreeSelect",props:{modelValue:{},placeholder:{default:"选择分支"},scope:{default:"all"},remoteFirst:{type:Boolean,default:!1},multiple:{type:Boolean,default:!1}},emits:["update:modelValue"],setup(s,{emit:t}){const n=s,e=t,l=Pt(),i=W(()=>Is(Un(l.list,n.scope),n.remoteFirst)),a=W(()=>Array.isArray(n.modelValue)?n.modelValue.filter(Boolean).join(", "):n.modelValue);function c(d){return d.fullName||d.label||d.value||""}function m(d,x){if(!d)return!0;const E=d.toLowerCase();return(x.label??"").toLowerCase().includes(E)||(x.value??"").toLowerCase().includes(E)}function u(d){if(n.multiple){e("update:modelValue",Array.isArray(d)?d:[]);return}e("update:modelValue",typeof d=="string"?d:"")}return(d,x)=>{const E=H("el-tooltip"),r=H("el-tree-select");return h(),Y(r,{"model-value":s.modelValue,data:i.value,filterable:"","filter-node-method":m,"check-strictly":"",multiple:s.multiple,"collapse-tags":s.multiple,"collapse-tags-tooltip":s.multiple,"show-checkbox":s.multiple,"default-expand-all":"","render-after-expand":!1,placeholder:s.placeholder,title:a.value||s.placeholder,class:"branch-tree-select","onUpdate:modelValue":u},{default:f(({data:y})=>[v(E,{content:c(y),placement:"top","show-after":400,enterable:!1},{default:f(()=>[p("span",zi,$(c(y)),1)]),_:2},1032,["content"])]),_:1},8,["model-value","data","multiple","collapse-tags","collapse-tags-tooltip","show-checkbox","placeholder","title"])}}}),Lt=He(Hi,[["__scopeId","data-v-cd7db6ae"]]);class ji{diff(t,n,e={}){let l;typeof e=="function"?(l=e,e={}):"callback"in e&&(l=e.callback);const i=this.castInput(t,e),a=this.castInput(n,e),c=this.removeEmpty(this.tokenize(i,e)),m=this.removeEmpty(this.tokenize(a,e));return this.diffWithOptionsObj(c,m,e,l)}diffWithOptionsObj(t,n,e,l){var i;const a=R=>{if(R=this.postProcess(R,e),l){setTimeout(function(){l(R)},0);return}else return R},c=n.length,m=t.length;let u=1,d=c+m;e.maxEditLength!=null&&(d=Math.min(d,e.maxEditLength));const x=(i=e.timeout)!==null&&i!==void 0?i:1/0,E=Date.now()+x,r=[{oldPos:-1,lastComponent:void 0}];let y=this.extractCommon(r[0],n,t,0,e);if(r[0].oldPos+1>=m&&y+1>=c)return a(this.buildValues(r[0].lastComponent,n,t));let M=-1/0,g=1/0;const S=()=>{for(let R=Math.max(M,-u);R<=Math.min(g,u);R+=2){let D;const T=r[R-1],B=r[R+1];T&&(r[R-1]=void 0);let G=!1;if(B){const w=B.oldPos-R;G=B&&0<=w&&w<c}const ne=T&&T.oldPos+1<m;if(!G&&!ne){r[R]=void 0;continue}if(!ne||G&&T.oldPos<B.oldPos?D=this.addToPath(B,!0,!1,0,e):D=this.addToPath(T,!1,!0,1,e),y=this.extractCommon(D,n,t,R,e),D.oldPos+1>=m&&y+1>=c)return a(this.buildValues(D.lastComponent,n,t))||!0;r[R]=D,D.oldPos+1>=m&&(g=Math.min(g,R-1)),y+1>=c&&(M=Math.max(M,R+1))}u++};if(l)(function R(){setTimeout(function(){if(u>d||Date.now()>E)return l(void 0);S()||R()},0)})();else for(;u<=d&&Date.now()<=E;){const R=S();if(R)return R}}addToPath(t,n,e,l,i){const a=t.lastComponent;return a&&!i.oneChangePerToken&&a.added===n&&a.removed===e?{oldPos:t.oldPos+l,lastComponent:{count:a.count+1,added:n,removed:e,previousComponent:a.previousComponent}}:{oldPos:t.oldPos+l,lastComponent:{count:1,added:n,removed:e,previousComponent:a}}}extractCommon(t,n,e,l,i){const a=n.length,c=e.length;let m=t.oldPos,u=m-l,d=0;for(;u+1<a&&m+1<c&&this.equals(e[m+1],n[u+1],i);)u++,m++,d++,i.oneChangePerToken&&(t.lastComponent={count:1,previousComponent:t.lastComponent,added:!1,removed:!1});return d&&!i.oneChangePerToken&&(t.lastComponent={count:d,previousComponent:t.lastComponent,added:!1,removed:!1}),t.oldPos=m,u}equals(t,n,e){return e.comparator?e.comparator(t,n):t===n||!!e.ignoreCase&&t.toLowerCase()===n.toLowerCase()}removeEmpty(t){const n=[];for(let e=0;e<t.length;e++)t[e]&&n.push(t[e]);return n}castInput(t,n){return t}tokenize(t,n){return Array.from(t)}join(t){return t.join("")}postProcess(t,n){return t}get useLongestToken(){return!1}buildValues(t,n,e){const l=[];let i;for(;t;)l.push(t),i=t.previousComponent,delete t.previousComponent,t=i;l.reverse();const a=l.length;let c=0,m=0,u=0;for(;c<a;c++){const d=l[c];if(d.removed)d.value=this.join(e.slice(u,u+d.count)),u+=d.count;else{if(!d.added&&this.useLongestToken){let x=n.slice(m,m+d.count);x=x.map(function(E,r){const y=e[u+r];return y.length>E.length?y:E}),d.value=this.join(x)}else d.value=this.join(n.slice(m,m+d.count));m+=d.count,d.added||(u+=d.count)}}return l}}class Gi extends ji{tokenize(t){return t.slice()}join(t){return t}removeEmpty(t){return t}}const qi=new Gi;function Yn(s,t,n){return qi.diff(s,t,n)}const Wi=/^<<<<<<<(?:\s+(.*))?$/,Pn=/^\|\|\|\|\|\|\|(?:\s+(.*))?$/,Jt=/^=======/,Nn=/^>>>>>>>(?:\s+(.*))?$/;function Qn(s,t){if(s&&s.includes("超出展示上限"))return[{id:"c-0",type:"conflict",ours:(t==null?void 0:t.ours)??"",base:(t==null?void 0:t.base)??"",theirs:(t==null?void 0:t.theirs)??"",choice:null}];if(s){const i=Ki(s);if(i.some(a=>a.type==="conflict"))return i}const n=(t==null?void 0:t.ours)??"",e=(t==null?void 0:t.theirs)??"",l=(t==null?void 0:t.base)??"";return n===e&&(s==null||s==="")?n?[{id:"t-0",type:"text",content:n}]:[]:n!==e||n===""&&e===""&&l!==""?[{id:"c-0",type:"conflict",ours:n,base:l,theirs:e,choice:null}]:n?[{id:"t-0",type:"text",content:n}]:[]}function Ki(s){const t=s.replace(/\r\n/g,`
115
+ `).split(`
116
+ `),n=[];let e=0,l=[],i=0;const a=()=>{if(l.length===0)return;const c=l.join(`
117
+ `);l=[],c.length!==0&&n.push({id:`t-${n.length}`,type:"text",content:c})};for(;e<t.length;){const c=t[e]??"";if(Wi.test(c)){a(),e+=1;const m=[];for(;e<t.length&&!Pn.test(t[e]??"")&&!Jt.test(t[e]??"");)m.push(t[e]??""),e+=1;const u=[];if(e<t.length&&Pn.test(t[e]??""))for(e+=1;e<t.length&&!Jt.test(t[e]??"");)u.push(t[e]??""),e+=1;e<t.length&&Jt.test(t[e]??"")&&(e+=1);const d=[];for(;e<t.length&&!Nn.test(t[e]??"");)d.push(t[e]??""),e+=1;e<t.length&&Nn.test(t[e]??"")&&(e+=1),n.push({id:`c-${i++}`,type:"conflict",ours:m.join(`
118
+ `),base:u.join(`
119
+ `),theirs:d.join(`
120
+ `),choice:null});continue}l.push(c),e+=1}return a(),n}function Qe(s){return s==null||s===""?[]:s.replace(/\r\n/g,`
121
+ `).split(`
122
+ `)}function it(s){return s.join(`
123
+ `)}function Rn(s,t){const n=Yn(s,t),e=[];let l=0,i=0;for(;i<n.length;){const a=n[i];if(!a.added&&!a.removed){l+=a.value.length,i+=1;continue}const c=[],m=[],u=l;for(;i<n.length&&(n[i].added||n[i].removed);){const d=n[i];d.removed?(c.push(...d.value),l+=d.value.length):d.added&&m.push(...d.value),i+=1}e.push({start:u,end:u+c.length,lines:m})}return e}function Mn(s,t){return s.filter(n=>n.start===n.end&&n.start===t)}function yt(s,t,n){const e=it(s),l=it(t);return e===l?{kind:n.length===0?"add-left":"modify-left",leftLines:s,rightLines:t,baseLines:n,action:"auto"}:s.length===0&&t.length>0?{kind:"add-right",leftLines:s,rightLines:t,baseLines:n,action:"auto"}:t.length===0&&s.length>0?{kind:"add-left",leftLines:s,rightLines:t,baseLines:n,action:"auto"}:{kind:"conflict",leftLines:s,rightLines:t,baseLines:n,action:"pending"}}function Xi(s,t,n){const e=Qe(s??""),l=Qe(t??""),i=Qe(n??"");if(e.length===0)return it(l)===it(i)?[{id:"h-0",kind:"equal",leftLines:l,rightLines:i,baseLines:[],action:"auto"}]:Ji(l,i);const a=Rn(e,l),c=Rn(e,i),m=new Set([0,e.length]);for(const g of a)m.add(g.start),m.add(g.end);for(const g of c)m.add(g.start),m.add(g.end);const u=[...m].sort((g,S)=>g-S),d=[];let x=0;const E=g=>{d.push({...g,id:`h-${x++}`})},r=new Set,y=new Set,M=g=>{const S=Mn(a,g).filter(T=>!r.has(T)),R=Mn(c,g).filter(T=>!y.has(T)),D=Math.max(S.length,R.length);for(let T=0;T<D;T++){const B=S[T],G=R[T];B&&r.add(B),G&&y.add(G),B&&G?it(B.lines)===it(G.lines)?E({kind:"add-left",leftLines:B.lines,rightLines:G.lines,baseLines:[],action:"auto"}):E({kind:"conflict",leftLines:B.lines,rightLines:G.lines,baseLines:[],action:"pending"}):B?E({kind:"add-left",leftLines:B.lines,rightLines:[],baseLines:[],action:"auto"}):G&&E({kind:"add-right",leftLines:[],rightLines:G.lines,baseLines:[],action:"auto"})}};for(let g=0;g<u.length;g++){const S=u[g];if(M(S),g>=u.length-1)break;const R=S,D=u[g+1];if(R>=D)continue;const T=e.slice(R,D),B=a.find(O=>O.start!==O.end&&O.start===R&&O.end>=D&&!r.has(O)),G=c.find(O=>O.start!==O.end&&O.start===R&&O.end>=D&&!y.has(O)),ne=a.find(O=>O.start!==O.end&&O.start<R&&O.end>=D),w=c.find(O=>O.start!==O.end&&O.start<R&&O.end>=D);if((ne||w)&&!B&&!G)continue;const N=a.find(O=>O.start!==O.end&&O.start===R&&!r.has(O)),F=c.find(O=>O.start!==O.end&&O.start===R&&!y.has(O));if(N&&F){r.add(N),y.add(F);const O=e.slice(Math.min(N.start,F.start),Math.max(N.end,F.end));E(yt(N.lines,F.lines,O));const ce=Math.max(N.end,F.end);for(;g+1<u.length-1&&u[g+1]<ce;)g+=1;continue}if(N&&!F){r.add(N);const O=e.slice(N.start,N.end);for(E(yt(N.lines,O,O));g+1<u.length-1&&u[g+1]<N.end;)g+=1;continue}if(F&&!N){y.add(F);const O=e.slice(F.start,F.end);for(E(yt(O,F.lines,O));g+1<u.length-1&&u[g+1]<F.end;)g+=1;continue}E({kind:"equal",leftLines:T,rightLines:[...T],baseLines:T,action:"auto"})}M(e.length);for(const g of a){if(r.has(g)||g.start===g.end)continue;const S=c.find(R=>!y.has(R)&&R.start===g.start&&R.end===g.end);if(S)y.add(S),r.add(g),E(yt(g.lines,S.lines,e.slice(g.start,g.end)));else{r.add(g);const R=e.slice(g.start,g.end);E(yt(g.lines,R,R))}}for(const g of c){if(y.has(g)||g.start===g.end)continue;y.add(g);const S=e.slice(g.start,g.end);E(yt(S,g.lines,S))}return d.length===0?[{id:"h-0",kind:"equal",leftLines:l,rightLines:i,baseLines:e,action:"auto"}]:d}function Ji(s,t){const n=Yn(s,t),e=[];let l=0,i=0;for(;i<n.length;){const a=n[i];if(!a.added&&!a.removed){e.push({id:`h-${l++}`,kind:"equal",leftLines:[...a.value],rightLines:[...a.value],baseLines:[...a.value],action:"auto"}),i+=1;continue}const c=[],m=[];for(;i<n.length&&(n[i].added||n[i].removed);){const u=n[i];u.removed?c.push(...u.value):u.added&&m.push(...u.value),i+=1}c.length&&m.length?e.push({id:`h-${l++}`,kind:"conflict",leftLines:c,rightLines:m,baseLines:[],action:"pending"}):c.length?e.push({id:`h-${l++}`,kind:"add-left",leftLines:c,rightLines:[],baseLines:[],action:"auto"}):e.push({id:`h-${l++}`,kind:"add-right",leftLines:[],rightLines:m,baseLines:[],action:"auto"})}return e}function Yi(s,t,n,e){let l=Qn(s);l.length===0&&(t!=null||n!=null)&&(l=[{id:"c-0",type:"conflict",ours:t??"",base:e??"",theirs:n??"",choice:null}]);const i=[];let a=0;for(const c of l)if(c.type==="text"){const m=Qe(c.content);i.push({id:`h-${a++}`,kind:"equal",leftLines:m,rightLines:[...m],baseLines:[...m],action:"auto"})}else{const m=c;i.push({id:`h-${a++}`,kind:"conflict",leftLines:Qe(m.ours),rightLines:Qe(m.theirs),baseLines:Qe(m.base),action:"pending"})}return i}function Qi(s,t){const n=Qn(t).filter(e=>e.type==="conflict");return n.length===0?s:s.map(e=>{if(e.kind==="equal"||e.kind==="conflict")return e;const l=it(e.leftLines).trim(),i=it(e.rightLines).trim();for(const a of n){const c=a.ours.trim(),m=a.theirs.trim();if(c===m)continue;const u=!!c&&(l===c||l.includes(c)||c.includes(l))||!c&&e.kind.endsWith("right")&&!!m&&(i===m||i.includes(m)),d=!!m&&(i===m||i.includes(m)||m.includes(i));if(!(!u&&!d))return{...e,kind:"conflict",leftLines:e.leftLines.length?e.leftLines:Qe(a.ours),rightLines:e.rightLines.length?e.rightLines:Qe(a.theirs),action:"pending"}}return e})}function Vn(s){if(s.oursContent!=null||s.theirsContent!=null||s.baseContent!=null){const n=Xi(s.baseContent,s.oursContent,s.theirsContent);return Qi(n,s.conflictContent)}return Yi(s.conflictContent,s.oursContent,s.theirsContent,s.baseContent)}function Zn(s){switch(s.action){case"auto":return s.kind==="equal"?s.leftLines.length?s.leftLines:s.rightLines:s.kind==="add-left"||s.kind==="modify-left"?s.leftLines:s.kind==="add-right"||s.kind==="modify-right"?s.rightLines:null;case"accept-left":case"ignore-right":return s.leftLines;case"accept-right":case"ignore-left":return s.rightLines;case"custom":return s.customLines??[];case"pending":return null;default:return null}}function Zi(s){const t=[];for(const n of s){const e=Zn(n);e==null?t.push(["<<<<<<< 未解决",...n.leftLines,"=======",...n.rightLines,">>>>>>>"].join(`
124
+ `)):e.length>0&&t.push(e.join(`
125
+ `))}return t.join(`
126
+ `)}function ft(s){let t=0,n=0,e=0,l=0;for(const i of s)i.kind!=="equal"&&(t+=1,i.kind==="conflict"&&(n+=1,i.action==="pending"?l+=1:e+=1));return{changes:t,conflicts:n,resolved:e,pending:l}}function eo(s){switch(s){case"add-left":return"hunk-add hunk-add-left";case"add-right":return"hunk-add hunk-add-right";case"modify-left":return"hunk-modify hunk-modify-left";case"modify-right":return"hunk-modify hunk-modify-right";case"conflict":return"hunk-conflict";default:return"hunk-equal"}}const to={class:"resolve"},no={class:"resolve-head"},so={class:"resolve-body"},lo={class:"file-list"},io={class:"file-list-head"},oo={class:"file-nav"},ao={class:"nav-pos"},ro=["onClick"],uo={class:"file-main"},co=["title"],fo={class:"stat"},po={key:0,class:"file-sides"},mo=["onClick"],ho={class:"file-main"},vo=["title"],go={class:"stat"},bo={class:"merge-wrap"},yo={class:"merge-bar"},_o=["title"],ko={class:"muted"},wo={class:"merge-bar-actions"},Co={class:"nav-pos"},$o={key:0,class:"empty"},xo=["data-hunk-id","onClick"],So={class:"pane pane-ours"},To={class:"code"},Lo={class:"gutter"},Eo={class:"pane pane-result"},Io={class:"code"},Po={class:"gutter"},No={class:"pane pane-theirs"},Ro={class:"code"},Mo=ze({__name:"ConflictResolvePanel",props:{files:{}},emits:["progress"],setup(s,{expose:t,emit:n}){const e=s,l=se(""),i=se(null),a=se(!1),c=se({}),m=se(null);function u(q){var Z,U,A,K;const b={};for(const ae of q)b[ae.path]=Vn(ae);c.value=b;const z=((Z=q.find(ae=>ft(b[ae.path]??[]).conflicts>0))==null?void 0:Z.path)??((U=q[0])==null?void 0:U.path)??"";l.value=z;const C=b[z]??[];i.value=((A=C.find(ae=>ae.kind==="conflict"))==null?void 0:A.id)??((K=C[0])==null?void 0:K.id)??null,a.value=!1}Te(()=>e.files,q=>u(q),{immediate:!0,deep:!0});const d=W(()=>c.value[l.value]??[]),x=W(()=>d.value.filter(q=>q.kind==="conflict")),E=W(()=>d.value.find(q=>q.id===i.value)??null),r=W(()=>e.files.filter(q=>ft(c.value[q.path]??[]).conflicts>0)),y=W(()=>e.files.filter(q=>ft(c.value[q.path]??[]).conflicts===0)),M=W(()=>ft(d.value)),g=W(()=>r.value.findIndex(q=>q.path===l.value)),S=W(()=>{let q=0,b=0,z=0;for(const C of Object.values(c.value)){const Z=ft(C);q+=Z.conflicts,b+=Z.resolved,z+=Z.pending}return{total:q,resolved:b,pending:z}}),R=W(()=>x.value.findIndex(q=>q.id===i.value)),D=W(()=>{var q;return((q=E.value)==null?void 0:q.kind)==="conflict"});function T(q){const b=ft(c.value[q]??[]);return b.conflicts===0?b.changes?`${b.changes}Δ`:"—":`${b.resolved}/${b.conflicts}`}function B(q){l.value=q;const b=c.value[q]??[],z=b.find(C=>C.kind==="conflict"&&C.action==="pending")??b.find(C=>C.kind==="conflict")??b[0];i.value=(z==null?void 0:z.id)??null}function G(q){const b=r.value;if(b.length<2)return;let z=g.value;z<0&&(z=q>0?-1:0);let C=z+q;C<0?C=b.length-1:C>=b.length&&(C=0);const Z=b[C];Z&&B(Z.path)}function ne(q,b){const z=l.value,C=c.value[z];C&&(c.value={...c.value,[z]:C.map(Z=>Z.id===q?{...Z,action:b}:Z)},i.value=q)}function w(q){ne(q.id,"accept-left")}function N(q){ne(q.id,"accept-right")}function F(q,b){const z=c.value[b];if(!z)return;b!==l.value&&(l.value=b);const C=q==="left"?"accept-left":"accept-right";c.value={...c.value,[b]:z.map(Z=>Z.kind==="conflict"?{...Z,action:C}:Z)}}function O(q){const b=E.value;!b||b.kind!=="conflict"||(q==="left"?w(b):N(b))}function ce(){var C,Z;const q=l.value,b=e.files.find(U=>U.path===q);if(!b)return;const z=Vn(b);c.value={...c.value,[q]:z},i.value=((C=z.find(U=>U.kind==="conflict"))==null?void 0:C.id)??((Z=z[0])==null?void 0:Z.id)??null}function he(q){const b=Zn(q);return b==null?["(未选边)"]:b.length?b:[""]}function de(q){return q.action==="accept-left"}function oe(q){return q.action==="accept-right"}function $e(q){return q.kind==="conflict"&&q.action!=="pending"}function ke(q){const b=x.value;if(!b.length)return;const z=b.filter(K=>K.action==="pending"),C=z.length?z:b;let Z=C.findIndex(K=>K.id===i.value);Z<0&&(Z=q>0?-1:0);let U=Z+q;U<0?U=C.length-1:U>=C.length&&(U=0);const A=C[U];i.value=A.id,ls(()=>{var K,ae;(ae=(K=m.value)==null?void 0:K.querySelector(`[data-hunk-id="${A.id}"]`))==null||ae.scrollIntoView({block:"center",behavior:"smooth"})})}function ge(){return e.files.map(q=>({path:q.path,resolvedContent:Zi(c.value[q.path]??[])}))}const be=n;return Te(S,q=>be("progress",q),{immediate:!0}),t({buildFiles:ge}),(q,b)=>{const z=H("el-button");return h(),P("div",to,[p("div",no,[p("span",null,[L(" 冲突 "+$(S.value.resolved)+" / "+$(S.value.total)+" ",1),b[7]||(b[7]=p("span",{class:"muted"}," · 绿=新增 蓝=修改(自动进结果) · 红块选线上或我的",-1))])]),p("div",so,[p("div",lo,[p("div",io,[p("span",null,"冲突文件 "+$(r.value.length),1),p("span",oo,[v(z,{size:"small",disabled:r.value.length<2,onClick:b[0]||(b[0]=C=>G(-1))},{default:f(()=>[...b[8]||(b[8]=[L("‹",-1)])]),_:1},8,["disabled"]),p("span",ao,$(g.value>=0?g.value+1:0)+"/"+$(r.value.length),1),v(z,{size:"small",disabled:r.value.length<2,onClick:b[1]||(b[1]=C=>G(1))},{default:f(()=>[...b[9]||(b[9]=[L("›",-1)])]),_:1},8,["disabled"])])]),(h(!0),P(ue,null,_e(r.value,C=>(h(),P(ue,{key:C.path},[p("button",{type:"button",class:Fe(["file-item",{active:C.path===l.value,done:I(ft)(c.value[C.path]??[]).pending===0}]),onClick:Z=>B(C.path)},[p("span",uo,[p("span",{class:"mono path",title:C.path},$(C.path.split("/").pop()),9,co),p("span",fo,$(T(C.path)),1)])],10,ro),C.path===l.value?(h(),P("div",po,[v(z,{size:"small",onClick:Z=>F("left",C.path)},{default:f(()=>[...b[10]||(b[10]=[L("线上",-1)])]),_:1},8,["onClick"]),v(z,{size:"small",onClick:Z=>F("right",C.path)},{default:f(()=>[...b[11]||(b[11]=[L("我的",-1)])]),_:1},8,["onClick"])])):j("",!0)],64))),128)),y.value.length?(h(),P("button",{key:0,type:"button",class:"file-item auto-toggle",onClick:b[2]||(b[2]=C=>a.value=!a.value)},$(a.value?"▾":"▸")+" 仅自动合并("+$(y.value.length)+") ",1)):j("",!0),a.value?(h(!0),P(ue,{key:1},_e(y.value,C=>(h(),P("button",{key:C.path,type:"button",class:Fe(["file-item auto",{active:C.path===l.value}]),onClick:Z=>B(C.path)},[p("span",ho,[p("span",{class:"mono path",title:C.path},$(C.path.split("/").pop()),9,vo),p("span",go,$(T(C.path)),1)])],10,mo))),128)):j("",!0)]),p("div",bo,[p("div",yo,[p("span",{class:"mono merge-path",title:l.value},$(l.value),9,_o),p("span",ko,$(M.value.resolved)+"/"+$(M.value.conflicts),1),p("span",wo,[v(z,{size:"small",disabled:!x.value.length,onClick:b[3]||(b[3]=C=>ke(-1))},{default:f(()=>[...b[12]||(b[12]=[L("上一处",-1)])]),_:1},8,["disabled"]),p("span",Co,$(R.value>=0?R.value+1:0)+"/"+$(x.value.length),1),v(z,{size:"small",disabled:!x.value.length,onClick:b[4]||(b[4]=C=>ke(1))},{default:f(()=>[...b[13]||(b[13]=[L("下一处",-1)])]),_:1},8,["disabled"]),v(z,{size:"small",disabled:!D.value,onClick:b[5]||(b[5]=C=>O("left"))},{default:f(()=>[...b[14]||(b[14]=[L("采用线上",-1)])]),_:1},8,["disabled"]),v(z,{size:"small",disabled:!D.value,onClick:b[6]||(b[6]=C=>O("right"))},{default:f(()=>[...b[15]||(b[15]=[L("采用我的",-1)])]),_:1},8,["disabled"]),v(z,{size:"small",disabled:!l.value,onClick:ce},{default:f(()=>[...b[16]||(b[16]=[L("重置本文件",-1)])]),_:1},8,["disabled"])])]),p("div",{ref_key:"scrollRootRef",ref:m,class:"merge"},[b[17]||(b[17]=p("header",{class:"merge-heads"},[p("div",null,"线上(合入目标)"),p("div"),p("div",null,"结果"),p("div"),p("div",null,"我的分支")],-1)),d.value.length===0?(h(),P("div",$o,"没有可展示的变更")):j("",!0),(h(!0),P(ue,null,_e(d.value,C=>(h(),P("div",{key:C.id,class:Fe(["merge-row",[I(eo)(C.kind),{active:C.id===i.value,resolved:$e(C),"chose-left":de(C),"chose-right":oe(C)}]]),"data-hunk-id":C.id,onClick:Z=>i.value=C.id},[p("div",So,[p("pre",To,[(h(!0),P(ue,null,_e(C.leftLines.length?C.leftLines:[""],(Z,U)=>(h(),P("span",{key:"L"+U,class:"code-line"},$(Z||" "),1))),128))])]),p("div",Lo,[C.kind==="conflict"&&C.leftLines.length?(h(),Y(z,{key:0,size:"small",text:"",type:"primary",title:de(C)?"已采用线上":"采用线上",onClick:Ue(Z=>w(C),["stop"])},{default:f(()=>[L($(de(C)?"✓":"≫"),1)]),_:2},1032,["title","onClick"])):j("",!0)]),p("div",Eo,[p("pre",Io,[(h(!0),P(ue,null,_e(he(C),(Z,U)=>(h(),P("span",{key:"R"+U,class:Fe(["code-line",{pending:C.kind==="conflict"&&C.action==="pending"}])},$(Z||" "),3))),128))])]),p("div",Po,[C.kind==="conflict"&&C.rightLines.length?(h(),Y(z,{key:0,size:"small",text:"",type:"primary",title:oe(C)?"已采用我的":"采用我的",onClick:Ue(Z=>N(C),["stop"])},{default:f(()=>[L($(oe(C)?"✓":"≪"),1)]),_:2},1032,["title","onClick"])):j("",!0)]),p("div",No,[p("pre",Ro,[(h(!0),P(ue,null,_e(C.rightLines.length?C.rightLines:[""],(Z,U)=>(h(),P("span",{key:"T"+U,class:"code-line"},$(Z||" "),1))),128))])])],10,xo))),128))],512)])])])}}}),Vo=He(Mo,[["__scopeId","data-v-3e657794"]]),Do={class:"matrix-panel"},Fo={class:"filter-bar"},Ao={class:"field"},Bo={class:"field"},Oo={class:"field field-switch"},Uo={class:"field field-actions"},zo={class:"chips"},Ho={key:0,class:"hint"},jo={class:"chips"},Go={key:0,class:"hint"},qo={key:0,class:"matrix-body"},Wo={class:"matrix-table-wrap"},Ko={class:"summary"},Xo={class:"ok"},Jo={class:"bad"},Yo={key:0},Qo={class:"grid"},Zo={key:0},ea=["colspan"],ta={key:1},na={class:"mono row-head"},sa={key:0,class:"ord"},la=["title","onClick"],ia={key:0,class:"detail"},oa={class:"mono"},aa={key:0,class:"tip"},ra={key:1,class:"paths"},ua={key:2,class:"hint"},da=ze({__name:"MatrixView",emits:["createMr","pushTemp"],setup(s,{emit:t}){const n=Ae(),e=sn(),{intos:l,froms:i,fetchRemote:a,loading:c,survey:m,order:u,active:d,orderView:x,surveyStale:E}=Dn(e),r=t,y=W(()=>n.currentId!==null),M={clean:"干净",conflicts:"冲突",unrelated:"无共祖",same:"同名",error:"失败"},g={open:"",ready:"",local:"已解决·本地",resolved:"已处理",page:"已开创建页",mr:"已提 MR"};function S(U,A){return`${U}\0${A}`}const R=W(()=>{var U;return[...new Set((((U=m.value)==null?void 0:U.cells)??[]).map(A=>A.into))]}),D=W(()=>{var ae;const U=((ae=m.value)==null?void 0:ae.cells)??[],A=new Map(U.map(re=>[S(re.into,re.from),re]));return[...new Set(U.map(re=>re.from))].map(re=>({from:re,cells:R.value.map(fe=>({into:fe,cell:A.get(S(fe,re))??null}))}))});function T(U){return U.replace(/^refs\/(heads|remotes)\//,"").replace(/^origin\//,"")}function B(U,A){return T(U)===T(A)}const G=W(()=>{const U=u.value;if(!U||R.value.length!==1)return!1;const A=R.value[0];if(!A||!B(U.best.into,A))return!1;const K=D.value.map(re=>re.from),ae=new Set(U.best.order);return K.length===ae.size&&K.every(re=>[...ae].some(fe=>B(fe,re)))}),ne=W(()=>{const U=D.value,A=()=>U.map(fe=>({kind:"row",ord:0,...fe})),K=u.value;if(!K||x.value!=="best"||!G.value)return A();const ae=new Map(U.map(fe=>[T(fe.from),fe])),re=[];return K.best.order.forEach((fe,ye)=>{const Se=ae.get(T(fe));if(!Se)return;re.push({kind:"row",ord:ye+1,...Se});const Ve=K.best.cleanPrefix;ye+1===Ve&&Ve<K.best.order.length&&re.push({kind:"divider",reason:K.best.blockedReason??(K.best.blockedAt?`从 ${K.best.blockedAt} 起需要人工处理`:"")})}),re.filter(fe=>fe.kind==="row").length===U.length?re:A()}),w=W(()=>ne.value.flatMap(U=>U.kind==="divider"?[]:U.cells.map(A=>A.cell).filter(A=>!!A))),N=W(()=>w.value.filter(U=>U.outcome==="conflicts").map(U=>({into:U.into,from:U.from}))),F=W(()=>N.value.filter(U=>!e.isPairDone(U))),O=W(()=>w.value.filter(U=>e.stageOf(U)==="local")),ce=W(()=>w.value.filter(U=>{const A=e.stageOf(U);return A==="ready"||A==="resolved"})),he=W(()=>{var A;const U=((A=m.value)==null?void 0:A.cells)??[];return{total:U.length,clean:U.filter(K=>K.outcome==="clean").length,conflicts:U.filter(K=>K.outcome==="conflicts").length}}),de=W(()=>{const U=u.value;return!U||!G.value?null:{cleanPrefix:U.best.cleanPrefix,total:U.best.order.length,baseline:U.baseline.cleanPrefix,improved:U.best.cleanPrefix>U.baseline.cleanPrefix}}),oe=W(()=>F.value.length>0?e.doneKeys.length>0||N.value.length!==F.value.length?`处理下一条冲突(剩 ${F.value.length})`:"开始逐条处理":O.value.length>0?`推送临时分支(剩 ${O.value.length})`:ce.value.length>0?ce.value.length>1?`申请 MR(剩 ${ce.value.length})`:"申请 MR":"");async function $e(){if(n.currentId===null){ie.warning("请先选择仓库");return}e.canSurvey&&await e.runSurvey()}async function ke(){e.canOrder&&await e.runOrder()}function ge(U){e.openPair({into:U.into,from:U.from},N.value)}function be(){const U=F.value[0];if(U){e.openPair(U,N.value);return}const A=O.value[0];if(A){q(A);return}const K=ce.value[0];K&&C(K)}function q(U){var K;const A=(K=U.tempBranch)==null?void 0:K.name;if(!A){ie.warning("没有本地临时分支");return}r("pushTemp",{into:U.into,from:U.from,branch:A})}function b(U){const A=U.conflictPaths.length,K=A>0?` ${A}`:"",ae=e.stageOf(U),re=g[ae];return re?`${re}${K}`:`${M[U.outcome]}${K}`}function z(U){const A=e.stageOf(U),K=`${U.from} → ${U.into}`;return A==="local"?`${K} · 选边已记在本地临时分支,未推送;可在矩阵推送后申请 MR`:A==="resolved"?`${K} · 临时分支已推送,可申请 MR`:A==="page"?`${K} · 已打开创建页`:A==="mr"?`${K} · 已创建 PR/MR`:U.error||K}function C(U){const A=e.sourceBranchFor(U);if(!A){ie.warning("没有可用来开 MR 的源分支");return}if(!e.canCreateMr(U)){ie.warning("临时分支还在本地,请先在单对落盘并推送");return}r("createMr",{into:U.into,from:U.from,sourceBranch:A})}function Z(U){var A,K;return((A=d.value)==null?void 0:A.into)===U.into&&((K=d.value)==null?void 0:K.from)===U.from}return(U,A)=>{const K=H("el-switch"),ae=H("el-button"),re=H("el-tag"),fe=H("el-card"),ye=H("el-alert"),Se=H("el-radio-button"),Ve=H("el-radio-group");return h(),P("div",Do,[v(fe,{shadow:"never",class:"filter-card"},{default:f(()=>[p("div",Fo,[p("div",Ao,[A[7]||(A[7]=p("span",{class:"field-label"},"合入目标 into(可多选)",-1)),v(Lt,{modelValue:I(l),"onUpdate:modelValue":A[0]||(A[0]=pe=>We(l)?l.value=pe:null),multiple:"","remote-first":"",placeholder:"选择线上目标"},null,8,["modelValue"])]),p("div",Bo,[A[8]||(A[8]=p("span",{class:"field-label"},"我的分支 from(可多选)",-1)),v(Lt,{modelValue:I(i),"onUpdate:modelValue":A[1]||(A[1]=pe=>We(i)?i.value=pe:null),multiple:"",placeholder:"选择待合入分支"},null,8,["modelValue"])]),p("div",Oo,[A[9]||(A[9]=p("span",{class:"field-label"},"先 fetch",-1)),v(K,{modelValue:I(a),"onUpdate:modelValue":A[2]||(A[2]=pe=>We(a)?a.value=pe:null)},null,8,["modelValue"])]),p("div",Uo,[v(ae,{loading:I(c),disabled:!I(e).canSurvey,type:"primary",onClick:$e},{default:f(()=>[...A[10]||(A[10]=[L("跑矩阵",-1)])]),_:1},8,["loading","disabled"]),v(ae,{loading:I(c),disabled:!I(e).canOrder,onClick:ke},{default:f(()=>[...A[11]||(A[11]=[L("建议顺序",-1)])]),_:1},8,["loading","disabled"])])]),p("div",zo,[A[12]||(A[12]=p("span",{class:"chip-label"},"INTO",-1)),I(l).length===0?(h(),P("span",Ho,"未选")):j("",!0),(h(!0),P(ue,null,_e(I(l),pe=>(h(),Y(re,{key:`i-${pe}`,size:"small",closable:"",onClose:Xe=>I(e).dropChip("into",pe)},{default:f(()=>[L($(pe),1)]),_:2},1032,["onClose"]))),128))]),p("div",jo,[A[13]||(A[13]=p("span",{class:"chip-label"},"FROM",-1)),I(i).length===0?(h(),P("span",Go,"未选")):j("",!0),(h(!0),P(ue,null,_e(I(i),pe=>(h(),Y(re,{key:`f-${pe}`,size:"small",closable:"",type:"info",onClose:Xe=>I(e).dropChip("from",pe)},{default:f(()=>[L($(pe),1)]),_:2},1032,["onClose"]))),128))]),A[14]||(A[14]=p("p",{class:"tip"}," 每对只跑 merge-tree,不改工作区。点「去预演」选边后只记到本地临时分支(不推送),回矩阵显示「已解决·本地」。 矩阵上再统一:先清剩余冲突,再推送临时分支、申请 MR。不切换当前工作区。 ",-1))]),_:1}),I(m)?(h(),P("div",qo,[p("div",Wo,[I(E)?(h(),Y(ye,{key:0,title:"仓库刚有过写操作,矩阵可能过期",type:"warning","show-icon":"",closable:!1,class:"stale-alert"},{default:f(()=>[v(ae,{type:"primary",loading:I(c),disabled:!I(e).canSurvey,onClick:$e},{default:f(()=>[...A[15]||(A[15]=[L("重新跑矩阵",-1)])]),_:1},8,["loading","disabled"])]),_:1})):j("",!0),p("div",Ko,[p("span",null,$(he.value.total)+" 组",1),p("span",Xo,"干净 "+$(he.value.clean),1),p("span",Jo,"冲突 "+$(he.value.conflicts),1),de.value?(h(),P(ue,{key:0},[p("span",null,"建议可连续干净 "+$(de.value.cleanPrefix)+"/"+$(de.value.total),1),de.value.improved?(h(),P("span",Yo,"原顺序 "+$(de.value.baseline),1)):j("",!0),G.value?(h(),Y(Ve,{key:1,modelValue:I(x),"onUpdate:modelValue":A[3]||(A[3]=pe=>We(x)?x.value=pe:null),size:"small"},{default:f(()=>[v(Se,{value:"best"},{default:f(()=>[...A[16]||(A[16]=[L("建议顺序",-1)])]),_:1}),v(Se,{value:"original"},{default:f(()=>[...A[17]||(A[17]=[L("原顺序",-1)])]),_:1})]),_:1},8,["modelValue"])):j("",!0)],64)):j("",!0),A[18]||(A[18]=p("span",{class:"summary-spacer"},null,-1)),oe.value?(h(),Y(ae,{key:1,type:"primary",disabled:!y.value||I(c),onClick:be},{default:f(()=>[L($(oe.value),1)]),_:1},8,["disabled"])):j("",!0)]),p("table",Qo,[p("thead",null,[p("tr",null,[A[19]||(A[19]=p("th",{class:"corner"},"from \\ into",-1)),(h(!0),P(ue,null,_e(R.value,pe=>(h(),P("th",{key:pe,class:"mono"},$(pe),1))),128))])]),p("tbody",null,[(h(!0),P(ue,null,_e(ne.value,(pe,Xe)=>(h(),P(ue,{key:pe.kind==="divider"?`d-${Xe}`:pe.from},[pe.kind==="divider"?(h(),P("tr",Zo,[p("td",{colspan:R.value.length+1,class:"divider"},$(pe.reason),9,ea)])):(h(),P("tr",ta,[p("th",na,[pe.ord?(h(),P("span",sa,$(pe.ord),1)):j("",!0),L(" "+$(pe.from),1)]),(h(!0),P(ue,null,_e(pe.cells,Ne=>(h(),P("td",{key:Ne.into},[Ne.cell?(h(),P("button",{key:0,type:"button",class:Fe(["cell",[`is-${Ne.cell.outcome}`,`is-stage-${I(e).stageOf(Ne.cell)}`,{active:Z(Ne.cell)}]]),title:z(Ne.cell),onClick:ot=>I(e).active=Ne.cell},$(b(Ne.cell)),11,la)):j("",!0)]))),128))]))],64))),128))])])]),I(d)?(h(),P("aside",ia,[p("h3",oa,$(I(d).from)+" → "+$(I(d).into),1),p("p",null,$(M[I(d).outcome])+$(I(d).error?` · ${I(d).error}`:""),1),I(d).tempBranch?(h(),P("p",aa," 临时分支 "+$(I(d).tempBranch.name)+" ("+$(I(d).tempBranch.local?"本地":"")+$(I(d).tempBranch.local&&I(d).tempBranch.remote?" / ":"")+$(I(d).tempBranch.remote?"远程":"")+") ",1)):j("",!0),I(d).conflictPaths.length?(h(),P("ul",ra,[(h(!0),P(ue,null,_e(I(d).conflictPaths,pe=>(h(),P("li",{key:pe,class:"mono"},$(pe),1))),128))])):I(d).outcome==="clean"?(h(),P("p",ua,"没有冲突文件")):j("",!0),I(d).outcome==="conflicts"||I(d).outcome==="clean"?(h(),Y(ae,{key:3,type:"primary",onClick:A[4]||(A[4]=pe=>ge(I(d)))},{default:f(()=>[...A[20]||(A[20]=[L("去预演",-1)])]),_:1})):j("",!0),I(e).stageOf(I(d))==="local"?(h(),Y(ae,{key:4,disabled:I(c),onClick:A[5]||(A[5]=pe=>q(I(d)))},{default:f(()=>[...A[21]||(A[21]=[L("推送临时分支",-1)])]),_:1},8,["disabled"])):j("",!0),I(e).canCreateMr(I(d))?(h(),Y(ae,{key:5,disabled:I(c),onClick:A[6]||(A[6]=pe=>C(I(d)))},{default:f(()=>[...A[22]||(A[22]=[L("申请 MR",-1)])]),_:1},8,["disabled"])):j("",!0)])):j("",!0)])):j("",!0)])}}}),ca=He(da,[["__scopeId","data-v-94a8c29e"]]),fa={class:"page merge-page"},pa={class:"page-head"},ma={class:"head-actions"},ha={key:0,class:"trail"},va={class:"trail-pos mono"},ga={class:"trail-pair mono"},ba={class:"mine"},ya={class:"online"},_a={key:3,class:"empty-tip"},ka={class:"filter-bar"},wa={class:"field"},Ca={class:"field"},$a={class:"field field-switch"},xa={class:"tip"},Sa={class:"tip"},Ta={class:"mono"},La={class:"tip"},Ea={class:"result-head"},Ia={class:"mono sha"},Pa={key:0,class:"tip tip-inline"},Na={key:1,class:"tip tip-inline"},Ra={key:2,class:"tip tip-inline"},Ma={class:"tip"},Va={class:"mono"},Da={class:"mono"},Fa={key:0,class:"tip"},Aa=["href"],Ba={key:1,class:"tip"},Oa={key:2,class:"tip"},Ua=["href"],za={class:"tip"},Ha={class:"tip"},ja={key:3,class:"tip"},Ga=["href"],qa={key:4,class:"tip"},Wa=["href"],Ka=ze({__name:"MergeView",setup(s){const t=Ae(),n=Pt(),e=sn(),{mode:l,pairInto:i,pairFrom:a,fetchRemote:c,trail:m,trailCurrent:u,trailRemaining:d,fromMatrix:x,loading:E}=Dn(e),r=tn(),y=It(),M=()=>t.currentId,{confirmVisible:g,pending:S,canRun:R,previewAndConfirm:D,executeConfirmed:T,cancel:B}=Hn(M),G=se(!1),ne=se(""),w=se(null),N=se(null),F=se(null),O=se(null),ce=se([]),he=se(null),de=se(null),oe=se(null),$e=se(0),ke=se(!1),ge=W(()=>e.isPairDone({into:i.value,from:a.value})),be=W(()=>{var X;return((X=e.survey)==null?void 0:X.cells.find(o=>o.into===i.value&&o.from===a.value))??null}),q=W(()=>x.value&&ge.value&&!ke.value&&!w.value),b=W(()=>n.hasRemote),z=W(()=>{var X;return(((X=w.value)==null?void 0:X.conflictFiles)??[]).some(o=>(o.conflictContent??"").includes("超出展示上限"))}),C=W(()=>{var o;const X=(o=w.value)==null?void 0:o.outcome;return X==="clean"?"success":X==="unrelated"?"warning":X==="conflicts"?"danger":"info"}),Z=W(()=>{var o;const X=(o=w.value)==null?void 0:o.outcome;return X==="clean"?"可干净合并":X==="unrelated"?"无关历史":X==="conflicts"?"存在冲突":""}),U=W(()=>!R.value||!w.value||z.value||w.value.outcome==="unrelated"&&w.value.conflictFiles.length===0?!1:w.value.clean?!0:w.value.outcome==="conflicts"&&$e.value===0),A=W(()=>G.value||E.value);function K(X){const o=r.query[X];return typeof o=="string"?o:""}function ae(X){var ee;const o=X.filter(we=>we.remote),_=["origin/main","origin/master","origin/develop"];for(const we of _)if(o.some(Ce=>Ce.name===we))return we;if(o[0])return o[0].name;const Q=X.find(we=>we.current);return(Q==null?void 0:Q.name)??((ee=X[0])==null?void 0:ee.name)??""}function re(X,o){const _=X.find(ee=>ee.current&&!ee.remote);if(_&&_.name!==o)return _.name;const Q=X.find(ee=>!ee.remote&&ee.name!==o);return(Q==null?void 0:Q.name)??""}function fe(X){const o=K("into"),_=K("from");o&&X.some(Q=>Q.name===o)?i.value=o:(!i.value||!X.some(Q=>Q.name===i.value))&&(i.value=ae(X)),_&&X.some(Q=>Q.name===_)?a.value=_:(!a.value||!X.some(Q=>Q.name===a.value))&&(a.value=re(X,i.value))}function ye(){const X=r.query.mode,o=l.value==="matrix"?"matrix":void 0;if(o===(X==="matrix"?"matrix":void 0))return;const Q={...r.query};o?Q.mode=o:delete Q.mode,y.replace({path:"/merge",query:Q})}async function Se(){var o;const X=M();if(X===null){ie.warning("请先选择仓库");return}if(!i.value||!a.value){ie.warning("请选择合入目标与我的分支");return}G.value=!0,ne.value="",w.value=null,N.value=null,F.value=null;try{const _=await mt(X,"git_merge_rehearse",{into:i.value,from:a.value,fetch:c.value,maxFiles:80,dryRun:!1});if(!_.success){ne.value=((o=_.error)==null?void 0:o.message)??"预演失败";return}w.value=_.result,$e.value=w.value.outcome==="conflicts"?w.value.conflictFiles.length:0}catch(_){ne.value=_ instanceof Error?_.message:String(_)}finally{G.value=!1}}async function Ve(){var Q;if(!U.value||!w.value)return;const X=w.value.outcome==="conflicts"?((Q=oe.value)==null?void 0:Q.buildFiles())??[]:[];if(w.value.outcome==="conflicts"&&X.length===0){ie.warning("请先完成选边");return}const o={into:i.value,from:a.value,files:X,push:x.value?!1:b.value,keepLocal:x.value?!0:void 0};he.value="git_apply_resolve",await D("git_apply_resolve",o)||(he.value=null)}async function pe(){if(!N.value)return;de.value={into:i.value,from:a.value},he.value="git_mr_create",await D("git_mr_create",{into:i.value,from:a.value,sourceBranch:N.value.tempBranch,reviewers:ce.value})||(he.value=null,de.value=null)}async function Xe(X){de.value={into:X.into,from:X.from},he.value="git_mr_create",await D("git_mr_create",{into:X.into,from:X.from,sourceBranch:X.sourceBranch})||(he.value=null,de.value=null)}async function Ne(X){var Q;if(!b.value){ie.warning("没有远程,无法推送临时分支");return}const o=((Q=n.remotes[0])==null?void 0:Q.name)??"origin";he.value="git_push",await D("git_push",{remote:o,branch:X.branch})||(he.value=null)}async function ot(){const X=await T();if(X!=null&&X.success){if(he.value==="git_push"){ie.success("已推送临时分支,可在矩阵申请 MR"),e.refreshSurvey(),n.load();return}if(!(!X.result||typeof X.result!="object")){if(he.value==="git_apply_resolve"){if(N.value=X.result,F.value=null,O.value=null,ce.value=[],e.markPairDone({into:i.value,from:a.value}),ie.success(x.value||!N.value.pushed?"已记到本地临时分支,回矩阵统一处理":"已落盘并推送临时分支"),x.value){ke.value=!1,w.value=null,at();return}const o=M();if(o!=null)try{const _=await mt(o,"git_mr_prepare",{into:i.value,from:a.value,sourceBranch:N.value.tempBranch});_.success&&_.result&&typeof _.result=="object"&&(O.value=_.result)}catch{O.value=null}e.refreshSurvey()}else if(he.value==="git_mr_create"){F.value=X.result;const o=F.value.via,_=de.value??{into:i.value,from:a.value};de.value=null,e.markPairMr(_,{url:F.value.url,via:o}),ie.success(o==="token"||o==="gh"||o==="glab"?"已创建 PR/MR":"已返回浏览器创建页")}}}}function Ze(X){e.trailGo(X)}function kt(){e.trailNextPending(),ye()}function at(){e.backToMatrix(),ye()}function et(){ke.value=!0,Se()}return Te(()=>t.currentId,X=>{e.resetIfRepoChanged(X),w.value=null,N.value=null,F.value=null,ne.value=""},{immediate:!0}),Te(()=>[n.repoId,n.list],([X,o])=>{X===t.currentId&&fe(o)},{deep:!0,immediate:!0}),Te(()=>r.query.mode,X=>{(X==="matrix"||X==="pair")&&e.setMode(X)},{immediate:!0}),Te(l,()=>ye()),ht(()=>{ye(),r.query.preview!=="1"&&e.trail&&i.value&&a.value&&l.value==="pair"&&Se()}),Te(()=>[r.query.into,r.query.from,r.query.preview],()=>{fe(n.list),r.query.preview==="1"&&K("into")&&K("from")&&M()!==null&&(e.setMode("pair"),Se())},{immediate:!0}),Te(()=>e.previewSeq,X=>{X<=0||(w.value=null,N.value=null,F.value=null,ke.value=!1,ye(),!(x.value&&e.isPairDone({into:i.value,from:a.value}))&&Se())}),Te([i,a],()=>{e.syncTrailWithPair()}),(X,o)=>{var je,nt;const _=H("el-radio-button"),Q=H("el-radio-group"),ee=H("el-button"),we=H("el-tag"),Ce=H("el-alert"),De=H("el-switch"),Oe=H("el-card"),vt=H("el-empty"),tt=H("el-option"),gt=H("el-select");return h(),P("div",fa,[p("div",pa,[o[13]||(o[13]=p("h2",{class:"page-title"},"合并",-1)),p("div",ma,[v(Q,{modelValue:I(l),"onUpdate:modelValue":o[0]||(o[0]=xe=>We(l)?l.value=xe:null),size:"small"},{default:f(()=>[v(_,{value:"pair"},{default:f(()=>[...o[10]||(o[10]=[L("单对预演",-1)])]),_:1}),v(_,{value:"matrix"},{default:f(()=>[...o[11]||(o[11]=[L("矩阵",-1)])]),_:1})]),_:1},8,["modelValue"]),I(l)==="pair"?(h(),Y(ee,{key:0,loading:G.value,disabled:!I(R),type:"primary",onClick:Se},{default:f(()=>[...o[12]||(o[12]=[L("预演",-1)])]),_:1},8,["loading","disabled"])):j("",!0)])]),I(l)==="pair"&&I(m)&&I(u)?(h(),P("div",ha,[v(ee,{size:"small",onClick:at},{default:f(()=>[...o[14]||(o[14]=[L("← 返回矩阵",-1)])]),_:1}),p("span",va,$(I(m).index+1)+" / "+$(I(m).pairs.length),1),p("span",ga,[p("span",ba,$(I(u).from),1),o[15]||(o[15]=p("span",{class:"trail-arrow"},"→",-1)),p("span",ya,$(I(u).into),1)]),I(d)>0?(h(),Y(we,{key:0,type:"warning",effect:"plain",size:"small"},{default:f(()=>[L("剩 "+$(I(d))+" 条待处理",1)]),_:1})):(h(),Y(we,{key:1,type:"success",effect:"plain",size:"small"},{default:f(()=>[...o[16]||(o[16]=[L("这批冲突都走完了",-1)])]),_:1})),o[19]||(o[19]=p("span",{class:"trail-spacer"},null,-1)),v(ee,{size:"small",disabled:A.value||I(m).index===0,onClick:o[1]||(o[1]=xe=>Ze(-1))},{default:f(()=>[...o[17]||(o[17]=[L("上一条",-1)])]),_:1},8,["disabled"]),v(ee,{size:"small",disabled:A.value||I(m).index>=I(m).pairs.length-1,onClick:o[2]||(o[2]=xe=>Ze(1))},{default:f(()=>[...o[18]||(o[18]=[L("下一条",-1)])]),_:1},8,["disabled"]),v(ee,{size:"small",type:"primary",disabled:A.value,onClick:kt},{default:f(()=>[L($(I(d)>0?"处理下一条":"回矩阵"),1)]),_:1},8,["disabled"])])):j("",!0),ne.value&&I(l)==="pair"?(h(),Y(Ce,{key:1,title:ne.value,type:"error",closable:!1,"show-icon":""},null,8,["title"])):I(e).loadError&&I(l)==="matrix"?(h(),Y(Ce,{key:2,title:I(e).loadError,type:"error",closable:!1,"show-icon":""},null,8,["title"])):j("",!0),I(R)?I(l)==="matrix"?(h(),Y(ca,{key:4,onCreateMr:Xe,onPushTemp:Ne})):(h(),P(ue,{key:5},[v(Oe,{shadow:"never",class:"filter-card"},{default:f(()=>[p("div",ka,[p("div",wa,[o[20]||(o[20]=p("span",{class:"field-label"},"合入目标 into(线上 / ours)",-1)),v(Lt,{modelValue:I(i),"onUpdate:modelValue":o[3]||(o[3]=xe=>We(i)?i.value=xe:null),"remote-first":"",placeholder:"选择合入目标"},null,8,["modelValue"])]),p("div",Ca,[o[21]||(o[21]=p("span",{class:"field-label"},"我的分支 from(theirs)",-1)),v(Lt,{modelValue:I(a),"onUpdate:modelValue":o[4]||(o[4]=xe=>We(a)?a.value=xe:null),placeholder:"选择我的分支"},null,8,["modelValue"])]),p("div",$a,[o[22]||(o[22]=p("span",{class:"field-label"},"先 fetch",-1)),v(De,{modelValue:I(c),"onUpdate:modelValue":o[5]||(o[5]=xe=>We(c)?c.value=xe:null)},null,8,["modelValue"])])]),p("p",xa,[I(x)?(h(),P(ue,{key:0},[L(" 从矩阵进来:选边后点「完成冲突处理」,只记到本地临时分支(不推送、不改工作区当前分支),然后回矩阵统一看。 ")],64)):(h(),P(ue,{key:1},[o[23]||(o[23]=L(" 预演使用 ",-1)),o[24]||(o[24]=p("span",{class:"mono"},"git merge-tree",-1)),o[25]||(o[25]=L(",不会改工作区。方向:把「我的分支」合入「合入目标」。 ",-1))],64))])]),_:1}),q.value?(h(),Y(Oe,{key:0,shadow:"never",class:"apply-card"},{header:f(()=>[...o[26]||(o[26]=[L("已记入本地",-1)])]),default:f(()=>{var xe,Ge;return[p("p",Sa,[o[27]||(o[27]=L(" 选边已写到临时分支 ",-1)),p("span",Ta,$(((Ge=(xe=be.value)==null?void 0:xe.tempBranch)==null?void 0:Ge.name)??"merge/…"),1),o[28]||(o[28]=L(" (未推送)。原始 from / into 仍然冲突,这是正常的。回矩阵看「已解决·本地」,再统一处理。 ",-1))]),p("p",La,[v(ee,{type:"primary",size:"small",onClick:at},{default:f(()=>[...o[29]||(o[29]=[L("返回矩阵",-1)])]),_:1}),v(ee,{size:"small",onClick:et},{default:f(()=>[...o[30]||(o[30]=[L("重新预演",-1)])]),_:1})])]}),_:1})):j("",!0),w.value?(h(),Y(Oe,{key:1,shadow:"never",class:"preview-card"},{header:f(()=>[p("div",Ea,[v(we,{type:C.value,effect:"dark"},{default:f(()=>[L($(Z.value),1)]),_:1},8,["type"]),p("span",Ia,$(w.value.into)+" ("+$(w.value.intoSha.slice(0,7))+") ← "+$(w.value.from)+" ("+$(w.value.fromSha.slice(0,7))+")",1),w.value.fetchAttempted&&!w.value.fetched?(h(),Y(we,{key:0,type:"warning",effect:"plain",size:"small"},{default:f(()=>[...o[31]||(o[31]=[L("远程未更新",-1)])]),_:1})):j("",!0),U.value?(h(),Y(ee,{key:1,type:"primary",onClick:Ve},{default:f(()=>[L($(I(x)?"完成冲突处理":"落盘并推送"),1)]),_:1})):j("",!0)])]),default:f(()=>[w.value.outcome==="conflicts"?(h(),P("p",Pa,$(z.value?"冲突文件超过展示上限,无法在网页选边。请缩小范围或提高 maxFiles。":I(x)?"红块选边后点「完成冲突处理」:写入本地临时分支,不推送,随后回矩阵。":"红块用 ≫ / ≪ 选线上或我的;绿=新增、蓝=修改,已自动进入结果。"),1)):w.value.outcome==="unrelated"?(h(),P("p",Na," 两条历史没有共同祖先,不能当作干净合并落盘。 ")):w.value.clean?(h(),P("p",Ra,$(I(x)?"可干净合并。点「完成冲突处理」会记到本地临时分支(不推送),再回矩阵。":"可干净合并。落盘会在独立 worktree 提交到临时分支,主工作区保持不变。"),1)):j("",!0),w.value.outcome==="conflicts"&&w.value.conflictFiles.length?(h(),Y(Vo,{key:3,ref_key:"resolvePanel",ref:oe,files:w.value.conflictFiles,onProgress:o[6]||(o[6]=xe=>$e.value=xe.pending)},null,8,["files"])):w.value.clean?(h(),Y(vt,{key:4,description:"没有冲突文件"})):j("",!0)]),_:1})):j("",!0),N.value?(h(),Y(Oe,{key:2,shadow:"never",class:"apply-card"},{header:f(()=>[...o[32]||(o[32]=[L("落盘结果",-1)])]),default:f(()=>{var xe,Ge,V,k;return[p("p",Ma,[o[33]||(o[33]=L("临时分支 ",-1)),p("span",Va,$(N.value.tempBranch),1),o[34]||(o[34]=L(" · 提交 ",-1)),p("span",Da,$(N.value.commitSha.slice(0,7)),1)]),N.value.createMrUrl?(h(),P("p",Fa,[p("a",{href:N.value.createMrUrl,target:"_blank",rel:"noreferrer"},"打开创建 MR/PR 页面",8,Aa)])):j("",!0),(xe=O.value)!=null&&xe.cliError&&!O.value.cli?(h(),P("p",Ba,$(O.value.cliError),1)):j("",!0),(Ge=O.value)!=null&&Ge.cliInstallUrl&&!O.value.cli?(h(),P("p",Oa,[o[35]||(o[35]=L(" 官方下载: ",-1)),p("a",{href:O.value.cliInstallUrl,target:"_blank",rel:"noreferrer"},$(O.value.cliInstallUrl),9,Ua)])):j("",!0),p("div",za,[o[36]||(o[36]=p("span",{class:"field-label"},"审核人",-1)),v(gt,{modelValue:ce.value,"onUpdate:modelValue":o[7]||(o[7]=ve=>ce.value=ve),multiple:"",filterable:"","allow-create":"","default-first-option":"",placeholder:"可选,回车添加用户名",style:{"min-width":"240px"}},{default:f(()=>{var ve;return[(h(!0),P(ue,null,_e(((ve=O.value)==null?void 0:ve.candidates)??[],te=>(h(),Y(tt,{key:te.username,label:te.name?`${te.username}(${te.name})`:te.username,value:te.username},null,8,["label","value"]))),128))]}),_:1},8,["modelValue"])]),p("p",Ha,[v(ee,{type:"primary",size:"small",onClick:pe},{default:f(()=>[...o[37]||(o[37]=[L("创建 PR/MR",-1)])]),_:1}),v(ee,{size:"small",onClick:o[8]||(o[8]=ve=>I(y).push({path:"/settings"}))},{default:f(()=>[...o[38]||(o[38]=[L("MR 配置",-1)])]),_:1})]),(V=F.value)!=null&&V.url?(h(),P("p",ja,[p("a",{href:F.value.url,target:"_blank",rel:"noreferrer"},$(F.value.via==="browser"?"打开创建页":`已创建${F.value.number!=null?" #"+F.value.number:""}`),9,Ga)])):j("",!0),(k=F.value)!=null&&k.cliInstallUrl?(h(),P("p",qa,[o[39]||(o[39]=L(" 未检测到本机 CLI,请自行安装: ",-1)),p("a",{href:F.value.cliInstallUrl,target:"_blank",rel:"noreferrer"},$(F.value.cliInstallUrl),9,Wa)])):j("",!0)]}),_:1})):j("",!0)],64)):(h(),P("div",_a,"请先在「仓库管理」中打开一个仓库")),v(jn,{visible:I(g),"onUpdate:visible":o[9]||(o[9]=xe=>We(g)?g.value=xe:null),tool:((je=I(S))==null?void 0:je.tool)??"",preview:((nt=I(S))==null?void 0:nt.preview)??null,onConfirm:ot,onCancel:I(B)},null,8,["visible","tool","preview","onCancel"])])}}}),Xa=He(Ka,[["__scopeId","data-v-ac011845"]]),Ja={class:"page"},Ya={class:"filter-bar"},Qa={class:"mono hash"},Za={class:"subject"},er={key:0,class:"refs"},tr={class:"sub"},nr={class:"commit-head"},sr={class:"mono commit-hash"},lr={class:"commit-subject"},ir={class:"commit-meta"},or={key:0},ar={key:0,class:"commit-body"},rr={class:"diff-wrap"},ur={class:"diff-summary"},dr={class:"add"},cr={class:"del"},fr={key:0,class:"warn"},pr=ze({__name:"HistoryView",setup(s){const t=Ae(),n=Pt(),{revision:e}=Ot(),l=()=>t.currentId,i=se([]),a=se(!1),c=se(""),m=se("head"),u=se(""),d=se(""),x=se(50),E=se(!1),r=se(null),y=se(null),M=W(()=>{var T;return((T=n.current)==null?void 0:T.name)??""});async function g(){const T=l();if(T!==null){a.value=!0,c.value="";try{const B={maxCount:x.value};m.value==="all"?B.all=!0:m.value==="branch"&&u.value&&(B.from=u.value),d.value.trim()&&(B.path=d.value.trim()),i.value=await hs(T,B)}catch(B){c.value=B instanceof Error?B.message:String(B),i.value=[]}finally{a.value=!1}}}async function S(){await g()}async function R(T){const B=l();if(B!==null){a.value=!0;try{const{diff:G}=await gs(B,T.hash);r.value=T,console.log(G),y.value=G,E.value=!0}catch(G){G instanceof Qt&&G.code==="COMMIT_NOT_FOUND"?ie.warning(`提交不存在(${T.shortHash}),可能已被清理,请刷新列表`):ie.error(G instanceof Error?G.message:String(G))}finally{a.value=!1}}}function D(T){const B=new Date(T);return Number.isNaN(B.getTime())?T:B.toLocaleString()}return Te(l,()=>{u.value="",S()}),Te(e,()=>void g()),Te([m,u,x],()=>void g()),ht(()=>void S()),(T,B)=>{const G=H("el-alert"),ne=H("el-radio-button"),w=H("el-radio-group"),N=H("el-input"),F=H("el-option"),O=H("el-select"),ce=H("el-button"),he=H("el-card"),de=H("el-table-column"),oe=H("el-tag"),$e=H("el-table"),ke=H("el-empty"),ge=H("el-divider"),be=H("el-drawer"),q=Bt("loading");return h(),P("div",Ja,[B[8]||(B[8]=p("h2",{class:"page-title"},"提交历史",-1)),c.value?(h(),Y(G,{key:0,title:c.value,type:"error",closable:!1,"show-icon":"",class:"mb"},null,8,["title"])):j("",!0),v(he,{shadow:"never",class:"mb"},{default:f(()=>[p("div",Ya,[v(w,{modelValue:m.value,"onUpdate:modelValue":B[0]||(B[0]=b=>m.value=b)},{default:f(()=>[v(ne,{value:"head"},{default:f(()=>[L("当前分支("+$(M.value)+")",1)]),_:1}),v(ne,{value:"all"},{default:f(()=>[...B[5]||(B[5]=[L("全部分支",-1)])]),_:1}),v(ne,{value:"branch"},{default:f(()=>[...B[6]||(B[6]=[L("指定分支",-1)])]),_:1})]),_:1},8,["modelValue"]),m.value==="branch"?(h(),Y(Lt,{key:0,modelValue:u.value,"onUpdate:modelValue":B[1]||(B[1]=b=>u.value=b),placeholder:"选择分支"},null,8,["modelValue"])):j("",!0),v(N,{modelValue:d.value,"onUpdate:modelValue":B[2]||(B[2]=b=>d.value=b),clearable:"",placeholder:"按路径过滤(可选)",class:"path-input",onKeyup:Ft(g,["enter"])},null,8,["modelValue"]),v(O,{modelValue:x.value,"onUpdate:modelValue":B[3]||(B[3]=b=>x.value=b),class:"count-select"},{default:f(()=>[v(F,{label:"20 条",value:20}),v(F,{label:"50 条",value:50}),v(F,{label:"100 条",value:100})]),_:1},8,["modelValue"]),v(ce,{loading:a.value,onClick:g},{default:f(()=>[...B[7]||(B[7]=[L("刷新",-1)])]),_:1},8,["loading"])])]),_:1}),v(he,{shadow:"never"},{default:f(()=>[At((h(),Y($e,{data:i.value,size:"default","highlight-current-row":"",onRowClick:R},{default:f(()=>[v(de,{label:"提交",width:"100"},{default:f(({row:b})=>[p("span",Qa,$(b.shortHash),1)]),_:1}),v(de,{label:"信息","min-width":"300"},{default:f(({row:b})=>[p("div",Za,$(b.subject),1),b.refs?(h(),P("div",er,[(h(!0),P(ue,null,_e(b.refs.split(",").map(z=>z.trim()).filter(Boolean),z=>(h(),Y(oe,{key:z,size:"small",effect:"plain",class:"ref-tag"},{default:f(()=>[L($(z.startsWith("tag: ")?z:z.includes("/")&&!z.startsWith("HEAD")?z.split("/").pop():z),1)]),_:2},1024))),128))])):j("",!0)]),_:1}),v(de,{label:"作者",width:"170"},{default:f(({row:b})=>[p("div",null,$(b.authorName),1),p("div",tr,$(b.authorEmail),1)]),_:1}),v(de,{label:"时间",width:"180"},{default:f(({row:b})=>[L($(D(b.authorDate)),1)]),_:1})]),_:1},8,["data"])),[[q,a.value]]),!a.value&&i.value.length===0?(h(),Y(ke,{key:0,description:"暂无提交记录"})):j("",!0)]),_:1}),v(be,{modelValue:E.value,"onUpdate:modelValue":B[4]||(B[4]=b=>E.value=b),size:"60%","destroy-on-close":""},{default:f(()=>[r.value?(h(),P(ue,{key:0},[p("div",nr,[p("div",sr,$(r.value.hash),1),p("h3",lr,$(r.value.subject),1),p("div",ir,[p("span",null,$(r.value.authorName)+" <"+$(r.value.authorEmail)+">",1),p("span",null,$(D(r.value.authorDate)),1),r.value.refs?(h(),P("span",or,"refs: "+$(r.value.refs),1)):j("",!0)]),r.value.body?(h(),P("pre",ar,$(r.value.body),1)):j("",!0)]),v(ge),p("div",rr,[y.value?(h(),P(ue,{key:0},[p("div",ur,[p("span",null,$(y.value.files.length)+" 个文件",1),p("span",dr,"+"+$(y.value.insertions),1),p("span",cr,"-"+$(y.value.deletions),1),y.value.truncated?(h(),P("span",fr,"(已截断)")):j("",!0)]),v(en,{patch:y.value.rawPatch},null,8,["patch"])],64)):(h(),Y(ke,{key:1,description:"无差异","image-size":60}))])],64)):j("",!0)]),_:1},8,["modelValue"])])}}}),mr=He(pr,[["__scopeId","data-v-851d8cb3"]]),hr=Et("logs",{state:()=>({logs:[],loading:!1,error:null,limit:50,toolFilter:""}),actions:{async load(){this.loading=!0,this.error=null;try{const{logs:s}=await _s({limit:this.limit,tool:this.toolFilter||void 0});this.logs=s}catch(s){this.error=s instanceof Error?s.message:String(s)}finally{this.loading=!1}}}}),vr={class:"page"},gr={class:"filter-bar"},br={class:"tool-cell"},yr={class:"mono repo-path"},_r=["title"],kr=["title"],wr=["title"],Cr=ze({__name:"LogsView",setup(s){const t=hr(),{revision:n}=Ot(),e=W(()=>{const u=new Set;for(const d of t.logs)u.add(d.tool);return[...u].sort()}),l=u=>u.includes("reset")||u.includes("clean")||u.includes("force")||u.includes("rebase")?"dangerous":"write";function i(u){return l(u)==="dangerous"?"danger":u.startsWith("git_")?"primary":"success"}function a(u){const d=new Date(u);return Number.isNaN(d.getTime())?u:d.toLocaleString()}function c(u){return u==="mcp"?"primary":u==="web"?"success":"warning"}function m(u){if(u==null)return"";if(typeof u=="string")return u;try{const d=JSON.stringify(u);return d===void 0?"":d}catch{return String(u)}}return Te(n,()=>{t.load()}),ht(()=>{t.load()}),(u,d)=>{const x=H("el-option"),E=H("el-select"),r=H("el-button"),y=H("el-card"),M=H("el-table-column"),g=H("el-tag"),S=H("el-table"),R=H("el-empty"),D=Bt("loading");return h(),P("div",vr,[d[7]||(d[7]=p("h2",{class:"page-title"},"操作日志",-1)),v(y,{shadow:"never",class:"mb"},{default:f(()=>[p("div",gr,[v(E,{modelValue:I(t).toolFilter,"onUpdate:modelValue":d[0]||(d[0]=T=>I(t).toolFilter=T),clearable:"",placeholder:"按工具过滤",class:"tool-select",onChange:I(t).load},{default:f(()=>[(h(!0),P(ue,null,_e(e.value,T=>(h(),Y(x,{key:T,label:T,value:T},null,8,["label","value"]))),128))]),_:1},8,["modelValue","onChange"]),v(E,{modelValue:I(t).limit,"onUpdate:modelValue":d[1]||(d[1]=T=>I(t).limit=T),class:"limit-select",onChange:I(t).load},{default:f(()=>[v(x,{label:"最近 20 条",value:20}),v(x,{label:"最近 50 条",value:50}),v(x,{label:"最近 100 条",value:100})]),_:1},8,["modelValue","onChange"]),v(r,{loading:I(t).loading,onClick:I(t).load},{default:f(()=>[...d[2]||(d[2]=[L("刷新",-1)])]),_:1},8,["loading","onClick"]),d[3]||(d[3]=p("span",{class:"tip"},"记录来源:Web / MCP / CLI 全部写入操作(只读操作不记录)",-1))])]),_:1}),v(y,{shadow:"never"},{default:f(()=>[At((h(),Y(S,{data:I(t).logs,size:"default"},{default:f(()=>[v(M,{label:"时间",width:"180"},{default:f(({row:T})=>[L($(a(T.timestamp)),1)]),_:1}),v(M,{label:"来源",width:"90"},{default:f(({row:T})=>[v(g,{type:c(T.source),size:"small",effect:"plain"},{default:f(()=>[L($(T.source.toUpperCase()),1)]),_:2},1032,["type"])]),_:1}),v(M,{label:"工具",width:"200"},{default:f(({row:T})=>[p("div",br,[v(g,{type:i(T.tool),size:"small",effect:"dark"},{default:f(()=>[L($(T.tool),1)]),_:2},1032,["type"]),T.dryRun?(h(),Y(g,{key:0,size:"small",type:"info",effect:"plain",class:"dry-tag"},{default:f(()=>[...d[4]||(d[4]=[L("dry-run",-1)])]),_:1})):j("",!0)])]),_:1}),v(M,{label:"仓库","min-width":"200"},{default:f(({row:T})=>[p("span",yr,$(T.repoPath??"—"),1)]),_:1}),v(M,{label:"参数(脱敏)","min-width":"180"},{default:f(({row:T})=>[p("span",{class:"mono params",title:m(T.params)},$(m(T.params)||"—"),9,_r)]),_:1}),v(M,{label:"结果","min-width":"150"},{default:f(({row:T})=>[T.error?(h(),P(ue,{key:0},[v(g,{type:"danger",size:"small",effect:"plain",class:"result-tag"},{default:f(()=>[...d[5]||(d[5]=[L("失败",-1)])]),_:1}),p("div",{class:"err-text",title:T.error},$(T.error),9,kr)],64)):(h(),P(ue,{key:1},[v(g,{type:"success",size:"small",effect:"plain",class:"result-tag"},{default:f(()=>[...d[6]||(d[6]=[L("成功",-1)])]),_:1}),p("div",{class:"ok-text",title:T.result},$(T.result),9,wr)],64))]),_:1}),v(M,{label:"耗时",width:"90"},{default:f(({row:T})=>[L($(T.durationMs)+" ms",1)]),_:1})]),_:1},8,["data"])),[[D,I(t).loading]]),!I(t).loading&&I(t).logs.length===0?(h(),Y(R,{key:0,description:"暂无操作日志"})):j("",!0)]),_:1})])}}}),$r=He(Cr,[["__scopeId","data-v-79ac665b"]]),xr={class:"page"},Sr={class:"remote-bar"},Tr=["title"],Lr={key:1,class:"mr-hint"},Er={key:0,class:"mr-platform-row"},Ir=["onClick","onKeydown"],Pr={class:"mr-option-head"},Nr={key:0,class:"mr-stack"},Rr={key:0,class:"mr-kv"},Mr={key:1,class:"mr-kv"},Vr={key:1,class:"mr-stack"},Dr={key:0,class:"mr-hint"},Fr={class:"mr-field"},Ar={key:1,class:"mr-hint"},Br={class:"mr-hint"},Or={class:"mr-inline"},Ur={key:2,class:"mr-hint"},zr={class:"host-list"},Hr={class:"host-row"},jr={class:"mono"},Gr={class:"card-head"},qr={class:"mono"},Wr={class:"desc"},Kr={key:0,class:"action-bar"},Xr="https://cli.github.com/",Jr="https://gitlab.com/gitlab-org/cli/-/releases",Yr="https://github.com/settings/tokens/new?scopes=repo&description=Git%20Cockpit",Qr=ze({__name:"SettingsView",setup(s){const t=Bn(),n=Ae(),e=tn(),l=It(),i=W({get:()=>e.query.tab==="git"?"git":"mr",set:o=>{l.replace({path:"/settings",query:o==="git"?{tab:"git"}:{}})}}),a=Yt({disabledTools:[],requireApprovalFor:[],dryRunDefault:!1}),c=se(!1),m=se("browser"),u=se("origin"),d=se(""),x=se(""),E=se(!1),r=se(!1),y=W(()=>{var o;return((o=t.mr)==null?void 0:o.cli.gh.installUrl)||Xr}),M=W(()=>{var o;return((o=t.mr)==null?void 0:o.cli.glab.installUrl)||Jr}),g=W(()=>{const o=t.permissions;return o?JSON.stringify([...a.disabledTools].sort())!==JSON.stringify([...o.disabledTools].sort())||JSON.stringify([...a.requireApprovalFor].sort())!==JSON.stringify([...o.requireApprovalFor].sort())||a.dryRunDefault!==o.dryRunDefault:!1}),S=W(()=>{var o;return((o=t.mr)==null?void 0:o.current)??null}),R=W(()=>{var o;return((o=t.mr)==null?void 0:o.remotes)??[]}),D=W(()=>R.value.length>0),T=W(()=>{var o;return((o=S.value)==null?void 0:o.platform)??"unknown"}),B=W(()=>{const o=u.value;return R.value.find(_=>_.name===o)??R.value[0]??null}),G=W(()=>{var _;const o=B.value;return((o==null?void 0:o.pushUrl)||(o==null?void 0:o.fetchUrl)||((_=S.value)==null?void 0:_.remoteUrl)||"").trim()}),ne=W(()=>{var _,Q;const o=(_=S.value)==null?void 0:_.host;return!o||T.value==="unknown"?null:((Q=t.mr)==null?void 0:Q.hosts.find(ee=>ee.host===o))??null}),w=W(()=>!!ne.value),N=W(()=>{var _,Q;if(!((_=S.value)!=null&&_.host))return d.value.trim().length>0;const o=((Q=ne.value)==null?void 0:Q.apiBaseUrl)??S.value.apiBaseUrl??"";return d.value.trim().length>0||x.value!==o}),F=W(()=>T.value!=="gitlab"),O=W(()=>T.value!=="github"),ce=W(()=>{var _;const o=(_=t.mr)==null?void 0:_.cli;return o?T.value==="github"?o.gh.loggedIn:T.value==="gitlab"?o.glab.loggedIn:o.gh.loggedIn||o.glab.loggedIn:!1}),he=W(()=>{var _;if(!((_=S.value)!=null&&_.tokenSet))return!1;const o=S.value.tokenStatus;return o?o.ok:!0}),de=W(()=>{var o,_;return r.value?"校验中…":((_=(o=S.value)==null?void 0:o.tokenStatus)==null?void 0:_.titleStatus)||""}),oe=W(()=>{var o;return r.value||!((o=S.value)!=null&&o.tokenStatus)?"muted":S.value.tokenStatus.ok?"ok":"bad"}),$e=W(()=>{var _;return`${(((_=S.value)==null?void 0:_.origin)||"").replace(/\/+$/,"")||"https://gitlab.com"}/-/user_settings/personal_access_tokens`}),ke=W(()=>t.tools.filter(o=>o.riskLevel==="dangerous")),ge=W(()=>ke.value.map(o=>o.name)),be=W(()=>[{id:"cli",title:Z(),ready:ce.value},{id:"token",title:U(),ready:he.value},{id:"browser",title:"C. 仅打开浏览器创建页",ready:!0}]),q=W(()=>T.value==="github"?"需 repo 权限。Token 不进工具参数。":T.value==="gitlab"?"审核人用户名会解析成数字 id。Token 不进工具参数。":"Token 不进工具参数。"),b=W(()=>{var _,Q,ee;const o=(Q=(_=S.value)==null?void 0:_.tokenPreview)==null?void 0:Q.trim();return(ee=S.value)!=null&&ee.tokenSet&&o?`已保存 ${o},输入新 Token 覆盖`:T.value==="github"?"ghp_… 或 github_pat_…":T.value==="gitlab"?"glpat-…":"输入 Token"});function z(){return n.currentId}function C(o){return o==="github"?"GitHub":o==="gitlab"?"GitLab":"未识别"}function Z(){return T.value==="github"?"A. 本机已安装的 gh":T.value==="gitlab"?"A. 本机已安装的 glab":"A. 本机已安装的 gh / glab"}function U(){var _;const o=(_=S.value)==null?void 0:_.host;return o?T.value==="github"?`B. GitHub Token(${o})`:T.value==="gitlab"?`B. GitLab Token(${o})`:`B. Token(${o})`:"B. Token(API)"}function A(o){return o!=null&&o.found?o.loggedIn?"已登录":"未登录":"未下载"}function K(o){return o!=null&&o.tokenStatus?o.tokenStatus.ok?"ok":"bad":"muted"}function ae(){const o=t.permissions;o&&(a.disabledTools=[...o.disabledTools],a.requireApprovalFor=[...o.requireApprovalFor],a.dryRunDefault=o.dryRunDefault,c.value=!0)}function re(o){return o==="cli"||o==="token"||o==="browser"?o:"browser"}function fe(){var o,_,Q,ee,we,Ce;m.value=re((o=t.mr)==null?void 0:o.method),u.value=((_=S.value)==null?void 0:_.remote)||((Q=t.mr)==null?void 0:Q.defaultRemote)||((ee=R.value[0])==null?void 0:ee.name)||"origin",x.value=((we=ne.value)==null?void 0:we.apiBaseUrl)??((Ce=S.value)==null?void 0:Ce.apiBaseUrl)??"",d.value=""}async function ye(o){var _,Q;await t.load(z(),{validateToken:(o==null?void 0:o.validateToken)??i.value==="mr"}),g.value||ae(),N.value?(m.value=re(((_=t.mr)==null?void 0:_.method)??m.value),u.value=((Q=S.value)==null?void 0:Q.remote)||u.value):fe()}Te(()=>[t.permissions],()=>{t.permissions&&!g.value&&ae()}),Te(()=>t.mr,()=>{var o;N.value?m.value=re(((o=t.mr)==null?void 0:o.method)??m.value):fe()}),Te(()=>n.currentId,()=>{ye()}),Te(i,(o,_)=>{o==="mr"&&_==="git"&&ye({validateToken:!0})});async function Se(o,_){_?a.disabledTools=a.disabledTools.filter(Q=>Q!==o.name):(a.disabledTools.includes(o.name)||a.disabledTools.push(o.name),a.requireApprovalFor=a.requireApprovalFor.filter(Q=>Q!==o.name))}function Ve(o){return o==="readonly"?"success":o==="write"?"primary":"danger"}function pe(o){return o==="readonly"?"只读":o==="write"?"写操作":"高风险"}async function Xe(){try{await t.save({permissions:{disabledTools:[...a.disabledTools],requireApprovalFor:[...a.requireApprovalFor],dryRunDefault:a.dryRunDefault}},z()),ie.success("Git 操作设置已保存")}catch(o){ie.error(o instanceof Error?o.message:String(o))}}async function Ne(o){var Q;if(!z()){ie.warning("请先在左侧选择仓库");return}const _=m.value;if(m.value=o,!(_===o&&((Q=t.mr)==null?void 0:Q.method)===o))try{await t.save({mr:{method:o}},z())}catch(ee){m.value=_,ie.error(ee instanceof Error?ee.message:String(ee))}}async function ot(o){var ee,we;const _=String(o),Q=((ee=S.value)==null?void 0:ee.remote)||((we=t.mr)==null?void 0:we.defaultRemote)||"origin";u.value=_;try{await t.save({mr:{defaultRemote:_}},z()),fe()}catch(Ce){u.value=Q,ie.error(Ce instanceof Error?Ce.message:String(Ce))}}async function Ze(o){var Q;const _=(Q=S.value)==null?void 0:Q.host;if(_)try{await t.save({mr:{upsertHost:{host:_,platform:o}}},z())}catch(ee){ie.error(ee instanceof Error?ee.message:String(ee))}}async function kt(){var ee,we;const o=(ee=S.value)==null?void 0:ee.host;if(!o){ie.warning(n.currentId?"当前仓库没有可识别的远程地址":"请先在左侧选择仓库");return}if(T.value==="unknown"){ie.warning("请先选择 GitHub 或 GitLab");return}const _=d.value.trim(),Q=((we=ne.value)==null?void 0:we.apiBaseUrl)??S.value.apiBaseUrl??"";if(!_&&x.value===Q){ie.warning("请填写 Token");return}r.value=!0;try{await t.save({mr:{upsertHost:{host:o,platform:T.value,..._?{token:_}:{},apiBaseUrl:x.value}}},z()),d.value="",ie.success(_?`已校验并保存 ${o} 的 Token`:`已保存 ${o} 的 API 地址`)}catch(Ce){ie.error(Ce instanceof Error?Ce.message:String(Ce))}finally{r.value=!1}}async function at(){var o,_,Q;if((o=S.value)!=null&&o.tokenSet){r.value=!0;try{await t.load(z(),{validateToken:!0}),N.value||fe();const ee=(Q=(_=t.mr)==null?void 0:_.current)==null?void 0:Q.tokenStatus;ee!=null&&ee.ok?ie.success(ee.titleStatus):ie.warning((ee==null?void 0:ee.titleStatus)||"校验未通过")}catch(ee){ie.error(ee instanceof Error?ee.message:String(ee))}finally{r.value=!1}}}async function et(o){try{await Tt.confirm(`清除 ${o} 上保存的 Token 与覆盖项?`,"删除域名配置",{confirmButtonText:"清除",cancelButtonText:"取消",type:"warning"})}catch{return}try{await t.save({mr:{deleteHost:o}},z()),N.value||fe(),ie.success("已清除")}catch(_){ie.error(_ instanceof Error?_.message:String(_))}}async function X(){if(await ye(),t.error){ie.error(t.error);return}ie.success("已重新检测本机 gh / glab")}return ht(async()=>{await ye(),ae(),fe()}),(o,_)=>{const Q=H("el-alert"),ee=H("el-option"),we=H("el-select"),Ce=H("el-tag"),De=H("el-button"),Oe=H("el-card"),vt=H("el-radio"),tt=H("el-link"),gt=H("el-input"),je=H("el-form-item"),nt=H("el-form"),xe=H("el-tab-pane"),Ge=H("el-switch"),V=H("el-table-column"),k=H("el-table"),ve=H("el-tabs"),te=Bt("loading");return h(),P("div",xr,[_[39]||(_[39]=p("h2",{class:"page-title"},"设置",-1)),I(t).error?(h(),Y(Q,{key:0,title:I(t).error,type:"error",closable:!1,"show-icon":"",class:"mb"},null,8,["title"])):j("",!0),v(ve,{modelValue:i.value,"onUpdate:modelValue":_[12]||(_[12]=le=>i.value=le),class:"settings-tabs"},{default:f(()=>[v(xe,{label:"MR 配置",name:"mr"},{default:f(()=>[v(Oe,{shadow:"never",class:"mb"},{default:f(()=>{var le,Pe;return[p("div",Sr,[_[13]||(_[13]=p("span",{class:"remote-label"},"默认远程",-1)),D.value?(h(),P(ue,{key:0},[v(we,{modelValue:u.value,"onUpdate:modelValue":_[0]||(_[0]=Be=>u.value=Be),class:"remote-select",disabled:I(t).saving,onChange:ot},{default:f(()=>[(h(!0),P(ue,null,_e(R.value,Be=>(h(),Y(ee,{key:Be.name,label:Be.name,value:Be.name},null,8,["label","value"]))),128))]),_:1},8,["modelValue","disabled"]),p("span",{class:"mono muted remote-url",title:G.value},$(G.value||"—"),9,Tr),v(Ce,{size:"small",effect:"plain"},{default:f(()=>[L($(C(T.value)),1)]),_:1})],64)):(h(),P("span",Lr,$(I(n).currentId?"当前仓库没有 remote":"未选择仓库,请先在左侧打开仓库"),1))]),_[17]||(_[17]=p("p",{class:"mr-hint"},"用于 fetch、MR 短名剥前缀、CLI 未传远程时的默认值。切换后立即保存。",-1)),D.value&&T.value==="unknown"?(h(),P("div",Er,[_[16]||(_[16]=p("span",{class:"mr-hint"},"未能自动识别远程平台,请手动选择。",-1)),v(De,{disabled:!((le=S.value)!=null&&le.host)||I(t).saving,onClick:_[1]||(_[1]=Be=>Ze("github"))},{default:f(()=>[..._[14]||(_[14]=[L("GitHub",-1)])]),_:1},8,["disabled"]),v(De,{disabled:!((Pe=S.value)!=null&&Pe.host)||I(t).saving,onClick:_[2]||(_[2]=Be=>Ze("gitlab"))},{default:f(()=>[..._[15]||(_[15]=[L("GitLab",-1)])]),_:1},8,["disabled"])])):j("",!0)]}),_:1}),(h(!0),P(ue,null,_e(be.value,le=>{var Pe,Be,rt,wt,Nt,bt,Rt,Mt,Vt,st,ut,dt,Ct;return h(),P("div",{key:le.id,class:Fe(["mr-option mb",{active:m.value===le.id,disabled:I(t).saving}]),role:"button",tabindex:"0",onClick:Je=>Ne(le.id),onKeydown:Ft(Ue(Je=>Ne(le.id),["prevent"]),["enter"])},[p("div",Pr,[v(vt,{"model-value":m.value,value:le.id,disabled:I(t).saving,onChange:Je=>Ne(le.id),onClick:_[3]||(_[3]=Ue(()=>{},["stop"]))},{default:f(()=>[L($(le.title),1)]),_:2},1032,["model-value","value","disabled","onChange"]),v(Ce,{size:"small",type:le.ready?"success":"warning",effect:"plain"},{default:f(()=>[L($(le.ready?"可用":"未就绪"),1)]),_:2},1032,["type"])]),m.value===le.id?(h(),P("div",{key:0,class:"mr-panel",onClick:_[8]||(_[8]=Ue(()=>{},["stop"]))},[le.id==="cli"?(h(),P("div",Nr,[F.value?(h(),P("div",Rr,[_[19]||(_[19]=p("span",{class:"mono"},"gh",-1)),p("span",null,$(A((Pe=I(t).mr)==null?void 0:Pe.cli.gh)),1),(Be=I(t).mr)!=null&&Be.cli.gh.found?(rt=I(t).mr)!=null&&rt.cli.gh.loggedIn&&((wt=I(t).mr)!=null&&wt.cli.gh.tokenStatus)?(h(),P("span",{key:1,class:Fe(["token-title-status",K((Nt=I(t).mr)==null?void 0:Nt.cli.gh)])},$((bt=I(t).mr)==null?void 0:bt.cli.gh.tokenStatus.titleStatus),3)):j("",!0):(h(),Y(tt,{key:0,type:"primary",href:y.value,target:"_blank"},{default:f(()=>[..._[18]||(_[18]=[L("去下载",-1)])]),_:1},8,["href"]))])):j("",!0),O.value?(h(),P("div",Mr,[_[21]||(_[21]=p("span",{class:"mono"},"glab",-1)),p("span",null,$(A((Rt=I(t).mr)==null?void 0:Rt.cli.glab)),1),(Mt=I(t).mr)!=null&&Mt.cli.glab.found?(Vt=I(t).mr)!=null&&Vt.cli.glab.loggedIn&&((st=I(t).mr)!=null&&st.cli.glab.tokenStatus)?(h(),P("span",{key:1,class:Fe(["token-title-status",K((ut=I(t).mr)==null?void 0:ut.cli.glab)])},$((dt=I(t).mr)==null?void 0:dt.cli.glab.tokenStatus.titleStatus),3)):j("",!0):(h(),Y(tt,{key:0,type:"primary",href:M.value,target:"_blank"},{default:f(()=>[..._[20]||(_[20]=[L("去下载",-1)])]),_:1},8,["href"]))])):j("",!0),v(De,{onClick:X},{default:f(()=>[..._[22]||(_[22]=[L("重新检测",-1)])]),_:1})])):j("",!0),le.id==="token"?(h(),P("div",Vr,[(Ct=S.value)!=null&&Ct.host?(h(),Y(nt,{key:1,class:"mr-form","label-width":"100px","label-position":"left",onSubmit:_[7]||(_[7]=Ue(()=>{},["prevent"]))},{default:f(()=>[v(je,{label:"Token"},{default:f(()=>[p("div",Fr,[de.value?(h(),P("p",{key:0,class:Fe(["token-title-status",oe.value])},$(de.value),3)):j("",!0),v(gt,{modelValue:d.value,"onUpdate:modelValue":_[4]||(_[4]=Je=>d.value=Je),type:"password","show-password":"",autocomplete:"new-password",placeholder:b.value,disabled:T.value==="unknown"||r.value},null,8,["modelValue","placeholder","disabled"]),S.value.tokenSet&&S.value.tokenPreview?(h(),P("p",Ar," 已保存 "+$(S.value.tokenPreview)+"(明文不回填,输入新 Token 可覆盖) ",1)):j("",!0),p("p",Br,$(q.value),1)])]),_:1}),v(je,null,{default:f(()=>[p("div",Or,[T.value!=="gitlab"?(h(),Y(tt,{key:0,type:"primary",href:Yr,target:"_blank"},{default:f(()=>[..._[23]||(_[23]=[L(" 打开 GitHub 创建 Token 页面 ",-1)])]),_:1})):j("",!0),T.value!=="github"?(h(),Y(tt,{key:1,type:"primary",href:$e.value,target:"_blank"},{default:f(()=>[..._[24]||(_[24]=[L(" 打开 GitLab 创建 Token 页面 ",-1)])]),_:1},8,["href"])):j("",!0),v(De,{link:"",type:"primary",onClick:_[5]||(_[5]=Je=>E.value=!E.value)},{default:f(()=>[L($(E.value?"收起自建选项":"自建 / API Base URL"),1)]),_:1})])]),_:1}),E.value?(h(),Y(je,{key:0,label:"API Base URL"},{default:f(()=>[v(gt,{modelValue:x.value,"onUpdate:modelValue":_[6]||(_[6]=Je=>x.value=Je),placeholder:"空则按域名惯例推断,如 https://git.a.com/api/v4"},null,8,["modelValue"])]),_:1})):j("",!0),v(je,null,{default:f(()=>[v(De,{type:"primary",loading:I(t).saving||r.value,disabled:!N.value||r.value,onClick:kt},{default:f(()=>[..._[25]||(_[25]=[L(" 保存此远程配置 ",-1)])]),_:1},8,["loading","disabled"]),v(De,{disabled:!S.value.tokenSet||N.value||r.value,loading:r.value&&!N.value,onClick:at},{default:f(()=>[..._[26]||(_[26]=[L(" 重新校验 ",-1)])]),_:1},8,["disabled","loading"]),v(De,{disabled:!N.value,onClick:fe},{default:f(()=>[..._[27]||(_[27]=[L("放弃修改",-1)])]),_:1},8,["disabled"])]),_:1})]),_:1})):(h(),P("p",Dr,$(I(n).currentId?"当前仓库没有可识别的远程地址,无法绑定 Token。":"请先在左侧选择仓库。Token 始终绑定当前远程的域名。"),1))])):j("",!0),le.id==="browser"?(h(),P("p",Ur,"确认后只返回浏览器创建页,不调用 Token 或本机 CLI。")):j("",!0)])):j("",!0)],42,Ir)}),128)),w.value&&ne.value?(h(),Y(Oe,{key:0,shadow:"never",class:"mb"},{header:f(()=>[..._[28]||(_[28]=[L("当前远程凭证",-1)])]),default:f(()=>[_[30]||(_[30]=p("p",{class:"mr-hint"},"只显示当前选中远程的域名。其它实例上的 Token 不在这里列出。",-1)),p("ul",zr,[p("li",Hr,[p("span",jr,$(ne.value.host),1),v(Ce,{size:"small",effect:"plain"},{default:f(()=>[L($(ne.value.platform==="github"?"GitHub":"GitLab"),1)]),_:1}),v(Ce,{size:"small",type:ne.value.tokenSet?"success":"info",effect:"plain"},{default:f(()=>[L($(ne.value.tokenSet?ne.value.tokenPreview||"已配置 Token":"无 Token"),1)]),_:1},8,["type"]),v(De,{link:"",type:"danger",onClick:_[9]||(_[9]=le=>et(ne.value.host))},{default:f(()=>[..._[29]||(_[29]=[L("清除",-1)])]),_:1})])])]),_:1})):j("",!0)]),_:1}),v(xe,{label:"Git 操作",name:"git"},{default:f(()=>[v(Oe,{shadow:"never",class:"mb"},{header:f(()=>[..._[31]||(_[31]=[L("默认行为",-1)])]),default:f(()=>[v(nt,{"label-width":"180px","label-position":"left"},{default:f(()=>[v(je,{label:"写操作默认 dry-run 预览"},{default:f(()=>[v(Ge,{modelValue:a.dryRunDefault,"onUpdate:modelValue":_[10]||(_[10]=le=>a.dryRunDefault=le)},null,8,["modelValue"]),_[32]||(_[32]=p("span",{class:"form-tip"},"开启后所有写操作(MCP/CLI)默认只生成预览,不真正执行",-1))]),_:1})]),_:1})]),_:1}),v(Oe,{shadow:"never",class:"mb"},{header:f(()=>[p("div",Gr,[_[34]||(_[34]=p("span",null,"工具开关与风险等级",-1)),v(Ce,{size:"small",type:"warning",effect:"plain"},{default:f(()=>[..._[33]||(_[33]=[L("高危工具默认禁用,需在下方开启",-1)])]),_:1})])]),default:f(()=>[At((h(),Y(k,{data:I(t).tools,size:"default"},{default:f(()=>[v(V,{label:"工具",width:"230"},{default:f(({row:le})=>[p("span",qr,$(le.name),1)]),_:1}),v(V,{label:"风险",width:"90"},{default:f(({row:le})=>[v(Ce,{type:Ve(le.riskLevel),size:"small",effect:"dark"},{default:f(()=>[L($(pe(le.riskLevel)),1)]),_:2},1032,["type"])]),_:1}),v(V,{label:"描述","min-width":"240"},{default:f(({row:le})=>[p("span",Wr,$(le.description),1)]),_:1}),v(V,{label:"启用",width:"100",align:"center"},{default:f(({row:le})=>[v(Ge,{"model-value":!a.disabledTools.includes(le.name),onChange:Pe=>Se(le,Pe===!0)},null,8,["model-value","onChange"])]),_:1})]),_:1},8,["data"])),[[te,I(t).loading]])]),_:1}),v(Oe,{shadow:"never",class:"mb"},{header:f(()=>[..._[35]||(_[35]=[L("审批规则",-1)])]),default:f(()=>[v(nt,{"label-position":"top"},{default:f(()=>[v(je,{label:"执行前需要审批的工具(勾选后,执行时需在确认框中手工确认)"},{default:f(()=>[v(we,{modelValue:a.requireApprovalFor,"onUpdate:modelValue":_[11]||(_[11]=le=>a.requireApprovalFor=le),multiple:"",filterable:"","collapse-tags":"",placeholder:"选择需要审批的工具",style:{width:"100%"}},{default:f(()=>[(h(!0),P(ue,null,_e(ge.value,le=>(h(),Y(ee,{key:le,label:le,value:le,disabled:a.disabledTools.includes(le)},null,8,["label","value","disabled"]))),128))]),_:1},8,["modelValue"]),_[36]||(_[36]=p("span",{class:"form-tip"},"审批仅对已启用的高危工具生效;禁用后自动移除",-1))]),_:1})]),_:1})]),_:1}),c.value?(h(),P("div",Kr,[v(De,{type:"primary",loading:I(t).saving,disabled:!g.value,onClick:Xe},{default:f(()=>[..._[37]||(_[37]=[L("保存 Git 设置",-1)])]),_:1},8,["loading","disabled"]),v(De,{disabled:!g.value,onClick:ae},{default:f(()=>[..._[38]||(_[38]=[L("放弃修改",-1)])]),_:1},8,["disabled"])])):j("",!0)]),_:1})]),_:1},8,["modelValue"])])}}}),Zr=He(Qr,[["__scopeId","data-v-98670b6e"]]),es=is({history:os(),routes:[{path:"/",redirect:"/status"},{path:"/repos",name:"repos",component:Xs,meta:{title:"仓库管理"}},{path:"/status",name:"status",component:Ui,meta:{title:"状态"}},{path:"/merge",name:"merge",component:Xa,meta:{title:"合并"}},{path:"/matrix",redirect:{path:"/merge",query:{mode:"matrix"}}},{path:"/history",name:"history",component:mr,meta:{title:"历史"}},{path:"/logs",name:"logs",component:$r,meta:{title:"操作日志"}},{path:"/settings",name:"settings",component:Zr,meta:{title:"设置"}}]});es.afterEach(s=>{const t=s.meta.title;document.title=t?`${t} · Git Cockpit`:"Git Cockpit"});document.documentElement.classList.add("dark");const Ht=as(As);Ht.use(rs());Ht.use(es);Ht.use(us,{size:"default"});Ht.mount("#app");