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