@shaohui_jin/git-cockpit-mcp-server 0.1.10 → 0.1.12

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