mirror of
https://github.com/livebook-dev/livebook.git
synced 2025-09-06 21:14:26 +08:00
65 lines
24 KiB
JavaScript
65 lines
24 KiB
JavaScript
import{a as ie}from"./chunk-HTMW6R2V.js";import{a as ce}from"./chunk-MF5TUIBL.js";import{a as de}from"./chunk-E4RBDSW5.js";import"./chunk-NKCQAART.js";import"./chunk-WNVR7S66.js";import"./chunk-ZP5QXAVO.js";import{f as se,l as oe,m as ne}from"./chunk-47P5NBBB.js";import"./chunk-XHGORZV2.js";import{D as Z,N as E,S as V,T as J,U as F,V as X,W as Q,X as U,Y as ee,Z as te,ba as re,h as l,ia as ae,j as w,v as Y}from"./chunk-KRX7QNR4.js";import"./chunk-UY4K4Z6W.js";import"./chunk-TZMIYTTY.js";import"./chunk-SA2EGKJT.js";import"./chunk-WYMAA4MH.js";import"./chunk-SISR4MA5.js";import"./chunk-24JW6VB3.js";import{a as A,b as K}from"./chunk-MGYUK2XN.js";var $={NORMAL:0,REVERSE:1,HIGHLIGHT:2,MERGE:3,CHERRY_PICK:4},$e=Y.gitGraph,I=l(()=>oe(A(A({},$e),Z().gitGraph)),"getConfig"),i=new ie(()=>{let a=I(),t=a.mainBranchName,r=a.mainBranchOrder;return{mainBranchName:t,commits:new Map,head:null,branchConfig:new Map([[t,{name:t,order:r}]]),branches:new Map([[t,null]]),currBranch:t,direction:"LR",seq:0,options:{}}});function _(){return se({length:7})}l(_,"getID");function le(a,t){let r=Object.create(null);return a.reduce((o,e)=>{let s=t(e);return r[s]||(r[s]=!0,o.push(e)),o},[])}l(le,"uniqBy");var xe=l(function(a){i.records.direction=a},"setDirection"),ue=l(function(a){w.debug("options str",a),a=a==null?void 0:a.trim(),a=a||"{}";try{i.records.options=JSON.parse(a)}catch(t){w.error("error while parsing gitGraph options",t.message)}},"setOptions"),be=l(function(){return i.records.options},"getOptions"),we=l(function(a){let t=a.msg,r=a.id,o=a.type,e=a.tags;w.info("commit",t,r,o,e),w.debug("Entering commit:",t,r,o,e);let s=I();r=E.sanitizeText(r,s),t=E.sanitizeText(t,s),e=e==null?void 0:e.map(n=>E.sanitizeText(n,s));let c={id:r||i.records.seq+"-"+_(),message:t,seq:i.records.seq++,type:o!=null?o:$.NORMAL,tags:e!=null?e:[],parents:i.records.head==null?[]:[i.records.head.id],branch:i.records.currBranch};i.records.head=c,w.info("main branch",s.mainBranchName),i.records.commits.set(c.id,c),i.records.branches.set(i.records.currBranch,c.id),w.debug("in pushCommit "+c.id)},"commit"),Be=l(function(a){let t=a.name,r=a.order;if(t=E.sanitizeText(t,I()),i.records.branches.has(t))throw new Error(`Trying to create an existing branch. (Help: Either use a new name if you want create a new branch or try using "checkout ${t}")`);i.records.branches.set(t,i.records.head!=null?i.records.head.id:null),i.records.branchConfig.set(t,{name:t,order:r}),me(t),w.debug("in createBranch")},"branch"),ve=l(a=>{let t=a.branch,r=a.id,o=a.type,e=a.tags,s=I();t=E.sanitizeText(t,s),r&&(r=E.sanitizeText(r,s));let c=i.records.branches.get(i.records.currBranch),n=i.records.branches.get(t),m=c?i.records.commits.get(c):void 0,h=n?i.records.commits.get(n):void 0;if(m&&h&&m.branch===t)throw new Error(`Cannot merge branch '${t}' into itself.`);if(i.records.currBranch===t){let d=new Error('Incorrect usage of "merge". Cannot merge a branch to itself');throw d.hash={text:`merge ${t}`,token:`merge ${t}`,expected:["branch abc"]},d}if(m===void 0||!m){let d=new Error(`Incorrect usage of "merge". Current branch (${i.records.currBranch})has no commits`);throw d.hash={text:`merge ${t}`,token:`merge ${t}`,expected:["commit"]},d}if(!i.records.branches.has(t)){let d=new Error('Incorrect usage of "merge". Branch to be merged ('+t+") does not exist");throw d.hash={text:`merge ${t}`,token:`merge ${t}`,expected:[`branch ${t}`]},d}if(h===void 0||!h){let d=new Error('Incorrect usage of "merge". Branch to be merged ('+t+") has no commits");throw d.hash={text:`merge ${t}`,token:`merge ${t}`,expected:['"commit"']},d}if(m===h){let d=new Error('Incorrect usage of "merge". Both branches have same head');throw d.hash={text:`merge ${t}`,token:`merge ${t}`,expected:["branch abc"]},d}if(r&&i.records.commits.has(r)){let d=new Error('Incorrect usage of "merge". Commit with id:'+r+" already exists, use different custom Id");throw d.hash={text:`merge ${t} ${r} ${o} ${e==null?void 0:e.join(" ")}`,token:`merge ${t} ${r} ${o} ${e==null?void 0:e.join(" ")}`,expected:[`merge ${t} ${r}_UNIQUE ${o} ${e==null?void 0:e.join(" ")}`]},d}let p=n||"",y={id:r||`${i.records.seq}-${_()}`,message:`merged branch ${t} into ${i.records.currBranch}`,seq:i.records.seq++,parents:i.records.head==null?[]:[i.records.head.id,p],branch:i.records.currBranch,type:$.MERGE,customType:o,customId:!!r,tags:e!=null?e:[]};i.records.head=y,i.records.commits.set(y.id,y),i.records.branches.set(i.records.currBranch,y.id),w.debug(i.records.branches),w.debug("in mergeBranch")},"merge"),Ce=l(function(a){let t=a.id,r=a.targetId,o=a.tags,e=a.parent;w.debug("Entering cherryPick:",t,r,o);let s=I();if(t=E.sanitizeText(t,s),r=E.sanitizeText(r,s),o=o==null?void 0:o.map(m=>E.sanitizeText(m,s)),e=E.sanitizeText(e,s),!t||!i.records.commits.has(t)){let m=new Error('Incorrect usage of "cherryPick". Source commit id should exist and provided');throw m.hash={text:`cherryPick ${t} ${r}`,token:`cherryPick ${t} ${r}`,expected:["cherry-pick abc"]},m}let c=i.records.commits.get(t);if(c===void 0||!c)throw new Error('Incorrect usage of "cherryPick". Source commit id should exist and provided');if(e&&!(Array.isArray(c.parents)&&c.parents.includes(e)))throw new Error("Invalid operation: The specified parent commit is not an immediate parent of the cherry-picked commit.");let n=c.branch;if(c.type===$.MERGE&&!e)throw new Error("Incorrect usage of cherry-pick: If the source commit is a merge commit, an immediate parent commit must be specified.");if(!r||!i.records.commits.has(r)){if(n===i.records.currBranch){let y=new Error('Incorrect usage of "cherryPick". Source commit is already on current branch');throw y.hash={text:`cherryPick ${t} ${r}`,token:`cherryPick ${t} ${r}`,expected:["cherry-pick abc"]},y}let m=i.records.branches.get(i.records.currBranch);if(m===void 0||!m){let y=new Error(`Incorrect usage of "cherry-pick". Current branch (${i.records.currBranch})has no commits`);throw y.hash={text:`cherryPick ${t} ${r}`,token:`cherryPick ${t} ${r}`,expected:["cherry-pick abc"]},y}let h=i.records.commits.get(m);if(h===void 0||!h){let y=new Error(`Incorrect usage of "cherry-pick". Current branch (${i.records.currBranch})has no commits`);throw y.hash={text:`cherryPick ${t} ${r}`,token:`cherryPick ${t} ${r}`,expected:["cherry-pick abc"]},y}let p={id:i.records.seq+"-"+_(),message:`cherry-picked ${c==null?void 0:c.message} into ${i.records.currBranch}`,seq:i.records.seq++,parents:i.records.head==null?[]:[i.records.head.id,c.id],branch:i.records.currBranch,type:$.CHERRY_PICK,tags:o?o.filter(Boolean):[`cherry-pick:${c.id}${c.type===$.MERGE?`|parent:${e}`:""}`]};i.records.head=p,i.records.commits.set(p.id,p),i.records.branches.set(i.records.currBranch,p.id),w.debug(i.records.branches),w.debug("in cherryPick")}},"cherryPick"),me=l(function(a){var t;if(a=E.sanitizeText(a,I()),i.records.branches.has(a)){i.records.currBranch=a;let r=i.records.branches.get(i.records.currBranch);r===void 0||!r?i.records.head=null:i.records.head=(t=i.records.commits.get(r))!=null?t:null}else{let r=new Error(`Trying to checkout branch which is not yet created. (Help try using "branch ${a}")`);throw r.hash={text:`checkout ${a}`,token:`checkout ${a}`,expected:[`branch ${a}`]},r}},"checkout");function S(a,t,r){let o=a.indexOf(t);o===-1?a.push(r):a.splice(o,1,r)}l(S,"upsert");function j(a){let t=a.reduce((e,s)=>e.seq>s.seq?e:s,a[0]),r="";a.forEach(function(e){e===t?r+=" *":r+=" |"});let o=[r,t.id,t.seq];for(let e in i.records.branches)i.records.branches.get(e)===t.id&&o.push(e);if(w.debug(o.join(" ")),t.parents&&t.parents.length==2&&t.parents[0]&&t.parents[1]){let e=i.records.commits.get(t.parents[0]);S(a,t,e),t.parents[1]&&a.push(i.records.commits.get(t.parents[1]))}else{if(t.parents.length==0)return;if(t.parents[0]){let e=i.records.commits.get(t.parents[0]);S(a,t,e)}}a=le(a,e=>e.id),j(a)}l(j,"prettyPrintCommitHistory");var ke=l(function(){w.debug(i.records.commits);let a=pe()[0];j([a])},"prettyPrint"),Ee=l(function(){i.reset(),V()},"clear"),Te=l(function(){return[...i.records.branchConfig.values()].map((t,r)=>t.order!==null&&t.order!==void 0?t:K(A({},t),{order:parseFloat(`0.${r}`)})).sort((t,r)=>{var o,e;return((o=t.order)!=null?o:0)-((e=r.order)!=null?e:0)}).map(({name:t})=>({name:t}))},"getBranchesAsObjArray"),Le=l(function(){return i.records.branches},"getBranches"),Me=l(function(){return i.records.commits},"getCommits"),pe=l(function(){let a=[...i.records.commits.values()];return a.forEach(function(t){w.debug(t.id)}),a.sort((t,r)=>t.seq-r.seq),a},"getCommitsArray"),Pe=l(function(){return i.records.currBranch},"getCurrentBranch"),Re=l(function(){return i.records.direction},"getDirection"),Oe=l(function(){return i.records.head},"getHead"),ge={commitType:$,getConfig:I,setDirection:xe,setOptions:ue,getOptions:be,commit:we,branch:Be,merge:ve,cherryPick:Ce,checkout:me,prettyPrint:ke,clear:Ee,getBranchesAsObjArray:Te,getBranches:Le,getCommits:Me,getCommitsArray:pe,getCurrentBranch:Pe,getDirection:Re,getHead:Oe,setAccTitle:J,getAccTitle:F,getAccDescription:Q,setAccDescription:X,setDiagramTitle:U,getDiagramTitle:ee},qe=l((a,t)=>{ce(a,t),a.dir&&t.setDirection(a.dir);for(let r of a.statements)Ie(r,t)},"populate"),Ie=l((a,t)=>{let o={Commit:l(e=>t.commit(We(e)),"Commit"),Branch:l(e=>t.branch(Ge(e)),"Branch"),Merge:l(e=>t.merge(De(e)),"Merge"),Checkout:l(e=>t.checkout(Ae(e)),"Checkout"),CherryPicking:l(e=>t.cherryPick(He(e)),"CherryPicking")}[a.$type];o?o(a):w.error(`Unknown statement type: ${a.$type}`)},"parseStatement"),We=l(a=>{var r,o;return{id:a.id,msg:(r=a.message)!=null?r:"",type:a.type!==void 0?$[a.type]:$.NORMAL,tags:(o=a.tags)!=null?o:void 0}},"parseCommit"),Ge=l(a=>{var r;return{name:a.name,order:(r=a.order)!=null?r:0}},"parseBranch"),De=l(a=>{var r,o;return{branch:a.branch,id:(r=a.id)!=null?r:"",type:a.type!==void 0?$[a.type]:void 0,tags:(o=a.tags)!=null?o:void 0}},"parseMerge"),Ae=l(a=>a.branch,"parseCheckout"),He=l(a=>{var r;return{id:a.id,targetId:"",tags:((r=a.tags)==null?void 0:r.length)===0?void 0:a.tags,parent:a.parent}},"parseCherryPicking"),Ne={parse:l(async a=>{let t=await de("gitGraph",a);w.debug(t),qe(t,ge)},"parse")},z=te(),b=z==null?void 0:z.gitGraph,R=10,O=40,L=4,M=2,q=8,v=new Map,C=new Map,H=30,G=new Map,N=[],P=0,f="LR",_e=l(()=>{v.clear(),C.clear(),G.clear(),P=0,N=[],f="LR"},"clear"),fe=l(a=>{let t=document.createElementNS("http://www.w3.org/2000/svg","text");return(typeof a=="string"?a.split(/\\n|\n|<br\s*\/?>/gi):a).forEach(o=>{let e=document.createElementNS("http://www.w3.org/2000/svg","tspan");e.setAttributeNS("http://www.w3.org/XML/1998/namespace","xml:space","preserve"),e.setAttribute("dy","1em"),e.setAttribute("x","0"),e.setAttribute("class","row"),e.textContent=o.trim(),t.appendChild(e)}),t},"drawText"),ye=l(a=>{let t,r,o;return f==="BT"?(r=l((e,s)=>e<=s,"comparisonFunc"),o=1/0):(r=l((e,s)=>e>=s,"comparisonFunc"),o=0),a.forEach(e=>{var c,n;let s=f==="TB"||f=="BT"?(c=C.get(e))==null?void 0:c.y:(n=C.get(e))==null?void 0:n.x;s!==void 0&&r(s,o)&&(t=e,o=s)}),t},"findClosestParent"),ze=l(a=>{let t="",r=1/0;return a.forEach(o=>{let e=C.get(o).y;e<=r&&(t=o,r=e)}),t||void 0},"findClosestParentBT"),Se=l((a,t,r)=>{let o=r,e=r,s=[];a.forEach(c=>{let n=t.get(c);if(!n)throw new Error(`Commit not found for key ${c}`);n.parents.length?(o=Ke(n),e=Math.max(o,e)):s.push(n),Ye(n,o)}),o=e,s.forEach(c=>{Ze(c,o,r)}),a.forEach(c=>{let n=t.get(c);if(n!=null&&n.parents.length){let m=ze(n.parents);o=C.get(m).y-O,o<=e&&(e=o);let h=v.get(n.branch).pos,p=o-R;C.set(n.id,{x:h,y:p})}})},"setParallelBTPos"),je=l(a=>{var o;let t=ye(a.parents.filter(e=>e!==null));if(!t)throw new Error(`Closest parent not found for commit ${a.id}`);let r=(o=C.get(t))==null?void 0:o.y;if(r===void 0)throw new Error(`Closest parent position not found for commit ${a.id}`);return r},"findClosestParentPos"),Ke=l(a=>je(a)+O,"calculateCommitPosition"),Ye=l((a,t)=>{let r=v.get(a.branch);if(!r)throw new Error(`Branch not found for commit ${a.id}`);let o=r.pos,e=t+R;return C.set(a.id,{x:o,y:e}),{x:o,y:e}},"setCommitPosition"),Ze=l((a,t,r)=>{let o=v.get(a.branch);if(!o)throw new Error(`Branch not found for commit ${a.id}`);let e=t+r,s=o.pos;C.set(a.id,{x:s,y:e})},"setRootPosition"),Ve=l((a,t,r,o,e,s)=>{if(s===$.HIGHLIGHT)a.append("rect").attr("x",r.x-10).attr("y",r.y-10).attr("width",20).attr("height",20).attr("class",`commit ${t.id} commit-highlight${e%q} ${o}-outer`),a.append("rect").attr("x",r.x-6).attr("y",r.y-6).attr("width",12).attr("height",12).attr("class",`commit ${t.id} commit${e%q} ${o}-inner`);else if(s===$.CHERRY_PICK)a.append("circle").attr("cx",r.x).attr("cy",r.y).attr("r",10).attr("class",`commit ${t.id} ${o}`),a.append("circle").attr("cx",r.x-3).attr("cy",r.y+2).attr("r",2.75).attr("fill","#fff").attr("class",`commit ${t.id} ${o}`),a.append("circle").attr("cx",r.x+3).attr("cy",r.y+2).attr("r",2.75).attr("fill","#fff").attr("class",`commit ${t.id} ${o}`),a.append("line").attr("x1",r.x+3).attr("y1",r.y+1).attr("x2",r.x).attr("y2",r.y-5).attr("stroke","#fff").attr("class",`commit ${t.id} ${o}`),a.append("line").attr("x1",r.x-3).attr("y1",r.y+1).attr("x2",r.x).attr("y2",r.y-5).attr("stroke","#fff").attr("class",`commit ${t.id} ${o}`);else{let c=a.append("circle");if(c.attr("cx",r.x),c.attr("cy",r.y),c.attr("r",t.type===$.MERGE?9:10),c.attr("class",`commit ${t.id} commit${e%q}`),s===$.MERGE){let n=a.append("circle");n.attr("cx",r.x),n.attr("cy",r.y),n.attr("r",6),n.attr("class",`commit ${o} ${t.id} commit${e%q}`)}s===$.REVERSE&&a.append("path").attr("d",`M ${r.x-5},${r.y-5}L${r.x+5},${r.y+5}M${r.x-5},${r.y+5}L${r.x+5},${r.y-5}`).attr("class",`commit ${o} ${t.id} commit${e%q}`)}},"drawCommitBullet"),Je=l((a,t,r,o)=>{var e;if(t.type!==$.CHERRY_PICK&&(t.customId&&t.type===$.MERGE||t.type!==$.MERGE)&&(b!=null&&b.showCommitLabel)){let s=a.append("g"),c=s.insert("rect").attr("class","commit-label-bkg"),n=s.append("text").attr("x",o).attr("y",r.y+25).attr("class","commit-label").text(t.id),m=(e=n.node())==null?void 0:e.getBBox();if(m&&(c.attr("x",r.posWithOffset-m.width/2-M).attr("y",r.y+13.5).attr("width",m.width+2*M).attr("height",m.height+2*M),f==="TB"||f==="BT"?(c.attr("x",r.x-(m.width+4*L+5)).attr("y",r.y-12),n.attr("x",r.x-(m.width+4*L)).attr("y",r.y+m.height-12)):n.attr("x",r.posWithOffset-m.width/2),b.rotateCommitLabel))if(f==="TB"||f==="BT")n.attr("transform","rotate(-45, "+r.x+", "+r.y+")"),c.attr("transform","rotate(-45, "+r.x+", "+r.y+")");else{let h=-7.5-(m.width+10)/25*9.5,p=10+m.width/25*8.5;s.attr("transform","translate("+h+", "+p+") rotate(-45, "+o+", "+r.y+")")}}},"drawCommitLabel"),Fe=l((a,t,r,o)=>{var e;if(t.tags.length>0){let s=0,c=0,n=0,m=[];for(let h of t.tags.reverse()){let p=a.insert("polygon"),y=a.append("circle"),d=a.append("text").attr("y",r.y-16-s).attr("class","tag-label").text(h),g=(e=d.node())==null?void 0:e.getBBox();if(!g)throw new Error("Tag bbox not found");c=Math.max(c,g.width),n=Math.max(n,g.height),d.attr("x",r.posWithOffset-g.width/2),m.push({tag:d,hole:y,rect:p,yOffset:s}),s+=20}for(let{tag:h,hole:p,rect:y,yOffset:d}of m){let g=n/2,x=r.y-19.2-d;if(y.attr("class","tag-label-bkg").attr("points",`
|
|
${o-c/2-L/2},${x+M}
|
|
${o-c/2-L/2},${x-M}
|
|
${r.posWithOffset-c/2-L},${x-g-M}
|
|
${r.posWithOffset+c/2+L},${x-g-M}
|
|
${r.posWithOffset+c/2+L},${x+g+M}
|
|
${r.posWithOffset-c/2-L},${x+g+M}`),p.attr("cy",x).attr("cx",o-c/2+L/2).attr("r",1.5).attr("class","tag-hole"),f==="TB"||f==="BT"){let u=o+d;y.attr("class","tag-label-bkg").attr("points",`
|
|
${r.x},${u+2}
|
|
${r.x},${u-2}
|
|
${r.x+R},${u-g-2}
|
|
${r.x+R+c+4},${u-g-2}
|
|
${r.x+R+c+4},${u+g+2}
|
|
${r.x+R},${u+g+2}`).attr("transform","translate(12,12) rotate(45, "+r.x+","+o+")"),p.attr("cx",r.x+L/2).attr("cy",u).attr("transform","translate(12,12) rotate(45, "+r.x+","+o+")"),h.attr("x",r.x+5).attr("y",u+3).attr("transform","translate(14,14) rotate(45, "+r.x+","+o+")")}}}},"drawCommitTags"),Xe=l(a=>{var r;switch((r=a.customType)!=null?r:a.type){case $.NORMAL:return"commit-normal";case $.REVERSE:return"commit-reverse";case $.HIGHLIGHT:return"commit-highlight";case $.MERGE:return"commit-merge";case $.CHERRY_PICK:return"commit-cherry-pick";default:return"commit-normal"}},"getCommitClassType"),Qe=l((a,t,r,o)=>{var s,c,n;let e={x:0,y:0};if(a.parents.length>0){let m=ye(a.parents);if(m){let h=(s=o.get(m))!=null?s:e;return t==="TB"?h.y+O:t==="BT"?((c=o.get(a.id))!=null?c:e).y-O:h.x+O}}else return t==="TB"?H:t==="BT"?((n=o.get(a.id))!=null?n:e).y-O:0;return 0},"calculatePosition"),Ue=l((a,t,r)=>{var c,n;let o=f==="BT"&&r?t:t+R,e=f==="TB"||f==="BT"?o:(c=v.get(a.branch))==null?void 0:c.pos,s=f==="TB"||f==="BT"?(n=v.get(a.branch))==null?void 0:n.pos:o;if(s===void 0||e===void 0)throw new Error(`Position were undefined for commit ${a.id}`);return{x:s,y:e,posWithOffset:o}},"getCommitPosition"),he=l((a,t,r)=>{var p;if(!b)throw new Error("GitGraph config not found");let o=a.append("g").attr("class","commit-bullets"),e=a.append("g").attr("class","commit-labels"),s=f==="TB"||f==="BT"?H:0,c=[...t.keys()],n=(p=b==null?void 0:b.parallelCommits)!=null?p:!1,m=l((y,d)=>{var u,T;let g=(u=t.get(y))==null?void 0:u.seq,x=(T=t.get(d))==null?void 0:T.seq;return g!==void 0&&x!==void 0?g-x:0},"sortKeys"),h=c.sort(m);f==="BT"&&(n&&Se(h,t,s),h=h.reverse()),h.forEach(y=>{var x,u,T;let d=t.get(y);if(!d)throw new Error(`Commit not found for key ${y}`);n&&(s=Qe(d,f,s,C));let g=Ue(d,s,n);if(r){let W=Xe(d),k=(x=d.customType)!=null?x:d.type,B=(T=(u=v.get(d.branch))==null?void 0:u.index)!=null?T:0;Ve(o,d,g,W,B,k),Je(e,d,g,s),Fe(e,d,g,s)}f==="TB"||f==="BT"?C.set(d.id,{x:g.x,y:g.posWithOffset}):C.set(d.id,{x:g.posWithOffset,y:g.y}),s=f==="BT"&&n?s+O:s+O+R,s>P&&(P=s)})},"drawCommits"),et=l((a,t,r,o,e)=>{let c=(f==="TB"||f==="BT"?r.x<o.x:r.y<o.y)?t.branch:a.branch,n=l(h=>h.branch===c,"isOnBranchToGetCurve"),m=l(h=>h.seq>a.seq&&h.seq<t.seq,"isBetweenCommits");return[...e.values()].some(h=>m(h)&&n(h))},"shouldRerouteArrow"),D=l((a,t,r=0)=>{let o=a+Math.abs(a-t)/2;if(r>5)return o;if(N.every(c=>Math.abs(c-o)>=10))return N.push(o),o;let s=Math.abs(a-t);return D(a,t-s/5,r+1)},"findLane"),tt=l((a,t,r,o)=>{var g,x,u,T,W;let e=C.get(t.id),s=C.get(r.id);if(e===void 0||s===void 0)throw new Error(`Commit positions not found for commits ${t.id} and ${r.id}`);let c=et(t,r,e,s,o),n="",m="",h=0,p=0,y=(g=v.get(r.branch))==null?void 0:g.index;r.type===$.MERGE&&t.id!==r.parents[0]&&(y=(x=v.get(t.branch))==null?void 0:x.index);let d;if(c){n="A 10 10, 0, 0, 0,",m="A 10 10, 0, 0, 1,",h=10,p=10;let k=e.y<s.y?D(e.y,s.y):D(s.y,e.y),B=e.x<s.x?D(e.x,s.x):D(s.x,e.x);f==="TB"?e.x<s.x?d=`M ${e.x} ${e.y} L ${B-h} ${e.y} ${m} ${B} ${e.y+p} L ${B} ${s.y-h} ${n} ${B+p} ${s.y} L ${s.x} ${s.y}`:(y=(u=v.get(t.branch))==null?void 0:u.index,d=`M ${e.x} ${e.y} L ${B+h} ${e.y} ${n} ${B} ${e.y+p} L ${B} ${s.y-h} ${m} ${B-p} ${s.y} L ${s.x} ${s.y}`):f==="BT"?e.x<s.x?d=`M ${e.x} ${e.y} L ${B-h} ${e.y} ${n} ${B} ${e.y-p} L ${B} ${s.y+h} ${m} ${B+p} ${s.y} L ${s.x} ${s.y}`:(y=(T=v.get(t.branch))==null?void 0:T.index,d=`M ${e.x} ${e.y} L ${B+h} ${e.y} ${m} ${B} ${e.y-p} L ${B} ${s.y+h} ${n} ${B-p} ${s.y} L ${s.x} ${s.y}`):e.y<s.y?d=`M ${e.x} ${e.y} L ${e.x} ${k-h} ${n} ${e.x+p} ${k} L ${s.x-h} ${k} ${m} ${s.x} ${k+p} L ${s.x} ${s.y}`:(y=(W=v.get(t.branch))==null?void 0:W.index,d=`M ${e.x} ${e.y} L ${e.x} ${k+h} ${m} ${e.x+p} ${k} L ${s.x-h} ${k} ${n} ${s.x} ${k-p} L ${s.x} ${s.y}`)}else n="A 20 20, 0, 0, 0,",m="A 20 20, 0, 0, 1,",h=20,p=20,f==="TB"?(e.x<s.x&&(r.type===$.MERGE&&t.id!==r.parents[0]?d=`M ${e.x} ${e.y} L ${e.x} ${s.y-h} ${n} ${e.x+p} ${s.y} L ${s.x} ${s.y}`:d=`M ${e.x} ${e.y} L ${s.x-h} ${e.y} ${m} ${s.x} ${e.y+p} L ${s.x} ${s.y}`),e.x>s.x&&(n="A 20 20, 0, 0, 0,",m="A 20 20, 0, 0, 1,",h=20,p=20,r.type===$.MERGE&&t.id!==r.parents[0]?d=`M ${e.x} ${e.y} L ${e.x} ${s.y-h} ${m} ${e.x-p} ${s.y} L ${s.x} ${s.y}`:d=`M ${e.x} ${e.y} L ${s.x+h} ${e.y} ${n} ${s.x} ${e.y+p} L ${s.x} ${s.y}`),e.x===s.x&&(d=`M ${e.x} ${e.y} L ${s.x} ${s.y}`)):f==="BT"?(e.x<s.x&&(r.type===$.MERGE&&t.id!==r.parents[0]?d=`M ${e.x} ${e.y} L ${e.x} ${s.y+h} ${m} ${e.x+p} ${s.y} L ${s.x} ${s.y}`:d=`M ${e.x} ${e.y} L ${s.x-h} ${e.y} ${n} ${s.x} ${e.y-p} L ${s.x} ${s.y}`),e.x>s.x&&(n="A 20 20, 0, 0, 0,",m="A 20 20, 0, 0, 1,",h=20,p=20,r.type===$.MERGE&&t.id!==r.parents[0]?d=`M ${e.x} ${e.y} L ${e.x} ${s.y+h} ${n} ${e.x-p} ${s.y} L ${s.x} ${s.y}`:d=`M ${e.x} ${e.y} L ${s.x-h} ${e.y} ${n} ${s.x} ${e.y-p} L ${s.x} ${s.y}`),e.x===s.x&&(d=`M ${e.x} ${e.y} L ${s.x} ${s.y}`)):(e.y<s.y&&(r.type===$.MERGE&&t.id!==r.parents[0]?d=`M ${e.x} ${e.y} L ${s.x-h} ${e.y} ${m} ${s.x} ${e.y+p} L ${s.x} ${s.y}`:d=`M ${e.x} ${e.y} L ${e.x} ${s.y-h} ${n} ${e.x+p} ${s.y} L ${s.x} ${s.y}`),e.y>s.y&&(r.type===$.MERGE&&t.id!==r.parents[0]?d=`M ${e.x} ${e.y} L ${s.x-h} ${e.y} ${n} ${s.x} ${e.y-p} L ${s.x} ${s.y}`:d=`M ${e.x} ${e.y} L ${e.x} ${s.y+h} ${m} ${e.x+p} ${s.y} L ${s.x} ${s.y}`),e.y===s.y&&(d=`M ${e.x} ${e.y} L ${s.x} ${s.y}`));if(d===void 0)throw new Error("Line definition not found");a.append("path").attr("d",d).attr("class","arrow arrow"+y%q)},"drawArrow"),rt=l((a,t)=>{let r=a.append("g").attr("class","commit-arrows");[...t.keys()].forEach(o=>{let e=t.get(o);e.parents&&e.parents.length>0&&e.parents.forEach(s=>{tt(r,t.get(s),e,t)})})},"drawArrows"),at=l((a,t)=>{let r=a.append("g");t.forEach((o,e)=>{var x;let s=e%q,c=(x=v.get(o.name))==null?void 0:x.pos;if(c===void 0)throw new Error(`Position not found for branch ${o.name}`);let n=r.append("line");n.attr("x1",0),n.attr("y1",c),n.attr("x2",P),n.attr("y2",c),n.attr("class","branch branch"+s),f==="TB"?(n.attr("y1",H),n.attr("x1",c),n.attr("y2",P),n.attr("x2",c)):f==="BT"&&(n.attr("y1",P),n.attr("x1",c),n.attr("y2",H),n.attr("x2",c)),N.push(c);let m=o.name,h=fe(m),p=r.insert("rect"),d=r.insert("g").attr("class","branchLabel").insert("g").attr("class","label branch-label"+s);d.node().appendChild(h);let g=h.getBBox();p.attr("class","branchLabelBkg label"+s).attr("rx",4).attr("ry",4).attr("x",-g.width-4-((b==null?void 0:b.rotateCommitLabel)===!0?30:0)).attr("y",-g.height/2+8).attr("width",g.width+18).attr("height",g.height+4),d.attr("transform","translate("+(-g.width-14-((b==null?void 0:b.rotateCommitLabel)===!0?30:0))+", "+(c-g.height/2-1)+")"),f==="TB"?(p.attr("x",c-g.width/2-10).attr("y",0),d.attr("transform","translate("+(c-g.width/2-5)+", 0)")):f==="BT"?(p.attr("x",c-g.width/2-10).attr("y",P),d.attr("transform","translate("+(c-g.width/2-5)+", "+P+")")):p.attr("transform","translate(-19, "+(c-g.height/2)+")")})},"drawBranches"),st=l(function(a,t,r,o,e){return v.set(a,{pos:t,index:r}),t+=50+(e?40:0)+(f==="TB"||f==="BT"?o.width/2:0),t},"setBranchPosition"),ot=l(function(a,t,r,o){var h,p;if(_e(),w.debug("in gitgraph renderer",a+`
|
|
`,"id:",t,r),!b)throw new Error("GitGraph config not found");let e=(h=b.rotateCommitLabel)!=null?h:!1,s=o.db;G=s.getCommits();let c=s.getBranchesAsObjArray();f=s.getDirection();let n=ae(`[id="${t}"]`),m=0;c.forEach((y,d)=>{var k;let g=fe(y.name),x=n.append("g"),u=x.insert("g").attr("class","branchLabel"),T=u.insert("g").attr("class","label branch-label");(k=T.node())==null||k.appendChild(g);let W=g.getBBox();m=st(y.name,m,d,W,e),T.remove(),u.remove(),x.remove()}),he(n,G,!1),b.showBranches&&at(n,c),rt(n,G),he(n,G,!0),ne.insertTitle(n,"gitTitleText",(p=b.titleTopMargin)!=null?p:0,s.getDiagramTitle()),re(void 0,n,b.diagramPadding,b.useMaxWidth)},"draw"),nt={draw:ot},ct=l(a=>`
|
|
.commit-id,
|
|
.commit-msg,
|
|
.branch-label {
|
|
fill: lightgrey;
|
|
color: lightgrey;
|
|
font-family: 'trebuchet ms', verdana, arial, sans-serif;
|
|
font-family: var(--mermaid-font-family);
|
|
}
|
|
${[0,1,2,3,4,5,6,7].map(t=>`
|
|
.branch-label${t} { fill: ${a["gitBranchLabel"+t]}; }
|
|
.commit${t} { stroke: ${a["git"+t]}; fill: ${a["git"+t]}; }
|
|
.commit-highlight${t} { stroke: ${a["gitInv"+t]}; fill: ${a["gitInv"+t]}; }
|
|
.label${t} { fill: ${a["git"+t]}; }
|
|
.arrow${t} { stroke: ${a["git"+t]}; }
|
|
`).join(`
|
|
`)}
|
|
|
|
.branch {
|
|
stroke-width: 1;
|
|
stroke: ${a.lineColor};
|
|
stroke-dasharray: 2;
|
|
}
|
|
.commit-label { font-size: ${a.commitLabelFontSize}; fill: ${a.commitLabelColor};}
|
|
.commit-label-bkg { font-size: ${a.commitLabelFontSize}; fill: ${a.commitLabelBackground}; opacity: 0.5; }
|
|
.tag-label { font-size: ${a.tagLabelFontSize}; fill: ${a.tagLabelColor};}
|
|
.tag-label-bkg { fill: ${a.tagLabelBackground}; stroke: ${a.tagLabelBorder}; }
|
|
.tag-hole { fill: ${a.textColor}; }
|
|
|
|
.commit-merge {
|
|
stroke: ${a.primaryColor};
|
|
fill: ${a.primaryColor};
|
|
}
|
|
.commit-reverse {
|
|
stroke: ${a.primaryColor};
|
|
fill: ${a.primaryColor};
|
|
stroke-width: 3;
|
|
}
|
|
.commit-highlight-outer {
|
|
}
|
|
.commit-highlight-inner {
|
|
stroke: ${a.primaryColor};
|
|
fill: ${a.primaryColor};
|
|
}
|
|
|
|
.arrow { stroke-width: 8; stroke-linecap: round; fill: none}
|
|
.gitTitleText {
|
|
text-anchor: middle;
|
|
font-size: 18px;
|
|
fill: ${a.textColor};
|
|
}
|
|
`,"getStyles"),it=ct,ft={parser:Ne,db:ge,renderer:nt,styles:it};export{ft as diagram};
|