HomeDashboard/.venv/lib/python3.12/site-packages/nicegui/elements/mermaid/dist/gitGraphDiagram-JCGM6PWI-DUSWEYAD.js
2026-01-03 14:54:18 +01:00

3 lines
23 KiB
JavaScript

import{c as t}from"./chunk-4KE642ED-D2VUabb0.js";import{p as e}from"./treemap-KMMF4GRG-7ORZ52ND-DFBaIa1s.js";import{s as r}from"./chunk-VSLJSFIP-DgN3S5MT.js";import{m as a,e as o,j as n,G as i,$ as s,U as c,H as h,p as d,a as m,i as $,d as l,K as y,N as g,h as p,L as x,O as f,r as u,w as b}from"./index-BDq3hoFe.js";import"./chunk-OMTJKCYW-D0VGaEv2.js";var w={NORMAL:0,REVERSE:1,HIGHLIGHT:2,MERGE:3,CHERRY_PICK:4},B=u.gitGraph,E=a(()=>x({...B,...f().gitGraph}),"getConfig"),k=new r(()=>{let t=E(),e=t.mainBranchName,r=t.mainBranchOrder;return{mainBranchName:e,commits:new Map,head:null,branchConfig:new Map([[e,{name:e,order:r}]]),branches:new Map([[e,null]]),currBranch:e,direction:"LR",seq:0,options:{}}});function C(){return b({length:7})}function L(t,e){let r=Object.create(null);return t.reduce((t,a)=>{let o=e(a);return r[o]||(r[o]=!0,t.push(a)),t},[])}a(C,"getID"),a(L,"uniqBy");var T=a(function(t){k.records.direction=t},"setDirection"),M=a(function(t){d.debug("options str",t),t=t?.trim(),t=t||"{}";try{k.records.options=JSON.parse(t)}catch(t){d.error("error while parsing gitGraph options",t.message)}},"setOptions"),v=a(function(){return k.records.options},"getOptions"),P=a(function(t){let e=t.msg,r=t.id,a=t.type,o=t.tags;d.info("commit",e,r,a,o),d.debug("Entering commit:",e,r,a,o);let n=E();r=p.sanitizeText(r,n),e=p.sanitizeText(e,n),o=o?.map(t=>p.sanitizeText(t,n));let i={id:r||k.records.seq+"-"+C(),message:e,seq:k.records.seq++,type:a??w.NORMAL,tags:o??[],parents:null==k.records.head?[]:[k.records.head.id],branch:k.records.currBranch};k.records.head=i,d.info("main branch",n.mainBranchName),k.records.commits.has(i.id)&&d.warn(`Commit ID ${i.id} already exists`),k.records.commits.set(i.id,i),k.records.branches.set(k.records.currBranch,i.id),d.debug("in pushCommit "+i.id)},"commit"),R=a(function(t){let e=t.name,r=t.order;if(e=p.sanitizeText(e,E()),k.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}")`);k.records.branches.set(e,null!=k.records.head?k.records.head.id:null),k.records.branchConfig.set(e,{name:e,order:r}),A(e),d.debug("in createBranch")},"branch"),G=a(t=>{let e=t.branch,r=t.id,a=t.type,o=t.tags,n=E();e=p.sanitizeText(e,n),r&&(r=p.sanitizeText(r,n));let i=k.records.branches.get(k.records.currBranch),s=k.records.branches.get(e),c=i?k.records.commits.get(i):void 0,h=s?k.records.commits.get(s):void 0;if(c&&h&&c.branch===e)throw new Error(`Cannot merge branch '${e}' into itself.`);if(k.records.currBranch===e){let t=new Error('Incorrect usage of "merge". Cannot merge a branch to itself');throw t.hash={text:`merge ${e}`,token:`merge ${e}`,expected:["branch abc"]},t}if(void 0===c||!c){let t=new Error(`Incorrect usage of "merge". Current branch (${k.records.currBranch})has no commits`);throw t.hash={text:`merge ${e}`,token:`merge ${e}`,expected:["commit"]},t}if(!k.records.branches.has(e)){let t=new Error('Incorrect usage of "merge". Branch to be merged ('+e+") does not exist");throw t.hash={text:`merge ${e}`,token:`merge ${e}`,expected:[`branch ${e}`]},t}if(void 0===h||!h){let t=new Error('Incorrect usage of "merge". Branch to be merged ('+e+") has no commits");throw t.hash={text:`merge ${e}`,token:`merge ${e}`,expected:['"commit"']},t}if(c===h){let t=new Error('Incorrect usage of "merge". Both branches have same head');throw t.hash={text:`merge ${e}`,token:`merge ${e}`,expected:["branch abc"]},t}if(r&&k.records.commits.has(r)){let t=new Error('Incorrect usage of "merge". Commit with id:'+r+" already exists, use different custom id");throw t.hash={text:`merge ${e} ${r} ${a} ${o?.join(" ")}`,token:`merge ${e} ${r} ${a} ${o?.join(" ")}`,expected:[`merge ${e} ${r}_UNIQUE ${a} ${o?.join(" ")}`]},t}let m=s||"",$={id:r||`${k.records.seq}-${C()}`,message:`merged branch ${e} into ${k.records.currBranch}`,seq:k.records.seq++,parents:null==k.records.head?[]:[k.records.head.id,m],branch:k.records.currBranch,type:w.MERGE,customType:a,customId:!!r,tags:o??[]};k.records.head=$,k.records.commits.set($.id,$),k.records.branches.set(k.records.currBranch,$.id),d.debug(k.records.branches),d.debug("in mergeBranch")},"merge"),I=a(function(t){let e=t.id,r=t.targetId,a=t.tags,o=t.parent;d.debug("Entering cherryPick:",e,r,a);let n=E();if(e=p.sanitizeText(e,n),r=p.sanitizeText(r,n),a=a?.map(t=>p.sanitizeText(t,n)),o=p.sanitizeText(o,n),!e||!k.records.commits.has(e)){let t=new Error('Incorrect usage of "cherryPick". Source commit id should exist and provided');throw t.hash={text:`cherryPick ${e} ${r}`,token:`cherryPick ${e} ${r}`,expected:["cherry-pick abc"]},t}let i=k.records.commits.get(e);if(void 0===i||!i)throw new Error('Incorrect usage of "cherryPick". Source commit id should exist and provided');if(o&&(!Array.isArray(i.parents)||!i.parents.includes(o)))throw new Error("Invalid operation: The specified parent commit is not an immediate parent of the cherry-picked commit.");let s=i.branch;if(i.type===w.MERGE&&!o)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||!k.records.commits.has(r)){if(s===k.records.currBranch){let t=new Error('Incorrect usage of "cherryPick". Source commit is already on current branch');throw t.hash={text:`cherryPick ${e} ${r}`,token:`cherryPick ${e} ${r}`,expected:["cherry-pick abc"]},t}let t=k.records.branches.get(k.records.currBranch);if(void 0===t||!t){let t=new Error(`Incorrect usage of "cherry-pick". Current branch (${k.records.currBranch})has no commits`);throw t.hash={text:`cherryPick ${e} ${r}`,token:`cherryPick ${e} ${r}`,expected:["cherry-pick abc"]},t}let n=k.records.commits.get(t);if(void 0===n||!n){let t=new Error(`Incorrect usage of "cherry-pick". Current branch (${k.records.currBranch})has no commits`);throw t.hash={text:`cherryPick ${e} ${r}`,token:`cherryPick ${e} ${r}`,expected:["cherry-pick abc"]},t}let c={id:k.records.seq+"-"+C(),message:`cherry-picked ${i?.message} into ${k.records.currBranch}`,seq:k.records.seq++,parents:null==k.records.head?[]:[k.records.head.id,i.id],branch:k.records.currBranch,type:w.CHERRY_PICK,tags:a?a.filter(Boolean):[`cherry-pick:${i.id}${i.type===w.MERGE?`|parent:${o}`:""}`]};k.records.head=c,k.records.commits.set(c.id,c),k.records.branches.set(k.records.currBranch,c.id),d.debug(k.records.branches),d.debug("in cherryPick")}},"cherryPick"),A=a(function(t){if(t=p.sanitizeText(t,E()),!k.records.branches.has(t)){let e=new Error(`Trying to checkout branch which is not yet created. (Help try using "branch ${t}")`);throw e.hash={text:`checkout ${t}`,token:`checkout ${t}`,expected:[`branch ${t}`]},e}{k.records.currBranch=t;let e=k.records.branches.get(k.records.currBranch);k.records.head=void 0!==e&&e?k.records.commits.get(e)??null:null}},"checkout");function O(t,e,r){let a=t.indexOf(e);-1===a?t.push(r):t.splice(a,1,r)}function q(t){let e=t.reduce((t,e)=>t.seq>e.seq?t:e,t[0]),r="";t.forEach(function(t){r+=t===e?"\t*":"\t|"});let a=[r,e.id,e.seq];for(let t in k.records.branches)k.records.branches.get(t)===e.id&&a.push(t);if(d.debug(a.join(" ")),e.parents&&2==e.parents.length&&e.parents[0]&&e.parents[1]){let r=k.records.commits.get(e.parents[0]);O(t,e,r),e.parents[1]&&t.push(k.records.commits.get(e.parents[1]))}else{if(0==e.parents.length)return;if(e.parents[0]){let r=k.records.commits.get(e.parents[0]);O(t,e,r)}}q(t=L(t,t=>t.id))}a(O,"upsert"),a(q,"prettyPrintCommitHistory");var H=a(function(){d.debug(k.records.commits),q([N()[0]])},"prettyPrint"),z=a(function(){k.reset(),g()},"clear"),S=a(function(){return[...k.records.branchConfig.values()].map((t,e)=>null!==t.order&&void 0!==t.order?t:{...t,order:parseFloat(`0.${e}`)}).sort((t,e)=>(t.order??0)-(e.order??0)).map(({name:t})=>({name:t}))},"getBranchesAsObjArray"),j=a(function(){return k.records.branches},"getBranches"),D=a(function(){return k.records.commits},"getCommits"),N=a(function(){let t=[...k.records.commits.values()];return t.forEach(function(t){d.debug(t.id)}),t.sort((t,e)=>t.seq-e.seq),t},"getCommitsArray"),W=a(function(){return k.records.currBranch},"getCurrentBranch"),K=a(function(){return k.records.direction},"getDirection"),F=a(function(){return k.records.head},"getHead"),Y={commitType:w,getConfig:E,setDirection:T,setOptions:M,getOptions:v,commit:P,branch:R,merge:G,cherryPick:I,checkout:A,prettyPrint:H,clear:z,getBranchesAsObjArray:S,getBranches:j,getCommits:D,getCommitsArray:N,getCurrentBranch:W,getDirection:K,getHead:F,setAccTitle:h,getAccTitle:c,getAccDescription:s,setAccDescription:i,setDiagramTitle:n,getDiagramTitle:o},_=a((e,r)=>{t(e,r),e.dir&&r.setDirection(e.dir);for(let t of e.statements)U(t,r)},"populate"),U=a((t,e)=>{let r={Commit:a(t=>e.commit(V(t)),"Commit"),Branch:a(t=>e.branch(J(t)),"Branch"),Merge:a(t=>e.merge(Q(t)),"Merge"),Checkout:a(t=>e.checkout(X(t)),"Checkout"),CherryPicking:a(t=>e.cherryPick(Z(t)),"CherryPicking")}[t.$type];r?r(t):d.error(`Unknown statement type: ${t.$type}`)},"parseStatement"),V=a(t=>({id:t.id,msg:t.message??"",type:void 0!==t.type?w[t.type]:w.NORMAL,tags:t.tags??void 0}),"parseCommit"),J=a(t=>({name:t.name,order:t.order??0}),"parseBranch"),Q=a(t=>({branch:t.branch,id:t.id??"",type:void 0!==t.type?w[t.type]:void 0,tags:t.tags??void 0}),"parseMerge"),X=a(t=>t.branch,"parseCheckout"),Z=a(t=>({id:t.id,targetId:"",tags:0===t.tags?.length?void 0:t.tags,parent:t.parent}),"parseCherryPicking"),tt={parse:a(async t=>{let r=await e("gitGraph",t);d.debug(r),_(r,Y)},"parse")},et=m(),rt=et?.gitGraph,at=10,ot=40,nt=new Map,it=new Map,st=new Map,ct=[],ht=0,dt="LR",mt=a(()=>{nt.clear(),it.clear(),st.clear(),ht=0,ct=[],dt="LR"},"clear"),$t=a(t=>{let e=document.createElementNS("http://www.w3.org/2000/svg","text");return("string"==typeof t?t.split(/\\n|\n|<br\s*\/?>/gi):t).forEach(t=>{let r=document.createElementNS("http://www.w3.org/2000/svg","tspan");r.setAttributeNS("http://www.w3.org/XML/1998/namespace","xml:space","preserve"),r.setAttribute("dy","1em"),r.setAttribute("x","0"),r.setAttribute("class","row"),r.textContent=t.trim(),e.appendChild(r)}),e},"drawText"),lt=a(t=>{let e,r,o;return"BT"===dt?(r=a((t,e)=>t<=e,"comparisonFunc"),o=1/0):(r=a((t,e)=>t>=e,"comparisonFunc"),o=0),t.forEach(t=>{let a="TB"===dt||"BT"==dt?it.get(t)?.y:it.get(t)?.x;void 0!==a&&r(a,o)&&(e=t,o=a)}),e},"findClosestParent"),yt=a(t=>{let e="",r=1/0;return t.forEach(t=>{let a=it.get(t).y;a<=r&&(e=t,r=a)}),e||void 0},"findClosestParentBT"),gt=a((t,e,r)=>{let a=r,o=r,n=[];t.forEach(t=>{let r=e.get(t);if(!r)throw new Error(`Commit not found for key ${t}`);r.parents.length?(a=xt(r),o=Math.max(a,o)):n.push(r),ft(r,a)}),a=o,n.forEach(t=>{ut(t,a,r)}),t.forEach(t=>{let r=e.get(t);if(r?.parents.length){let t=yt(r.parents);a=it.get(t).y-ot,a<=o&&(o=a);let e=nt.get(r.branch).pos,n=a-at;it.set(r.id,{x:e,y:n})}})},"setParallelBTPos"),pt=a(t=>{let e=lt(t.parents.filter(t=>null!==t));if(!e)throw new Error(`Closest parent not found for commit ${t.id}`);let r=it.get(e)?.y;if(void 0===r)throw new Error(`Closest parent position not found for commit ${t.id}`);return r},"findClosestParentPos"),xt=a(t=>pt(t)+ot,"calculateCommitPosition"),ft=a((t,e)=>{let r=nt.get(t.branch);if(!r)throw new Error(`Branch not found for commit ${t.id}`);let a=r.pos,o=e+at;return it.set(t.id,{x:a,y:o}),{x:a,y:o}},"setCommitPosition"),ut=a((t,e,r)=>{let a=nt.get(t.branch);if(!a)throw new Error(`Branch not found for commit ${t.id}`);let o=e+r,n=a.pos;it.set(t.id,{x:n,y:o})},"setRootPosition"),bt=a((t,e,r,a,o,n)=>{if(n===w.HIGHLIGHT)t.append("rect").attr("x",r.x-10).attr("y",r.y-10).attr("width",20).attr("height",20).attr("class",`commit ${e.id} commit-highlight${o%8} ${a}-outer`),t.append("rect").attr("x",r.x-6).attr("y",r.y-6).attr("width",12).attr("height",12).attr("class",`commit ${e.id} commit${o%8} ${a}-inner`);else if(n===w.CHERRY_PICK)t.append("circle").attr("cx",r.x).attr("cy",r.y).attr("r",10).attr("class",`commit ${e.id} ${a}`),t.append("circle").attr("cx",r.x-3).attr("cy",r.y+2).attr("r",2.75).attr("fill","#fff").attr("class",`commit ${e.id} ${a}`),t.append("circle").attr("cx",r.x+3).attr("cy",r.y+2).attr("r",2.75).attr("fill","#fff").attr("class",`commit ${e.id} ${a}`),t.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 ${e.id} ${a}`),t.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 ${e.id} ${a}`);else{let i=t.append("circle");if(i.attr("cx",r.x),i.attr("cy",r.y),i.attr("r",e.type===w.MERGE?9:10),i.attr("class",`commit ${e.id} commit${o%8}`),n===w.MERGE){let n=t.append("circle");n.attr("cx",r.x),n.attr("cy",r.y),n.attr("r",6),n.attr("class",`commit ${a} ${e.id} commit${o%8}`)}n===w.REVERSE&&t.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 ${a} ${e.id} commit${o%8}`)}},"drawCommitBullet"),wt=a((t,e,r,a)=>{if(e.type!==w.CHERRY_PICK&&(e.customId&&e.type===w.MERGE||e.type!==w.MERGE)&&rt?.showCommitLabel){let o=t.append("g"),n=o.insert("rect").attr("class","commit-label-bkg"),i=o.append("text").attr("x",a).attr("y",r.y+25).attr("class","commit-label").text(e.id),s=i.node()?.getBBox();if(s&&(n.attr("x",r.posWithOffset-s.width/2-2).attr("y",r.y+13.5).attr("width",s.width+4).attr("height",s.height+4),"TB"===dt||"BT"===dt?(n.attr("x",r.x-(s.width+16+5)).attr("y",r.y-12),i.attr("x",r.x-(s.width+16)).attr("y",r.y+s.height-12)):i.attr("x",r.posWithOffset-s.width/2),rt.rotateCommitLabel))if("TB"===dt||"BT"===dt)i.attr("transform","rotate(-45, "+r.x+", "+r.y+")"),n.attr("transform","rotate(-45, "+r.x+", "+r.y+")");else{let t=-7.5-(s.width+10)/25*9.5,e=10+s.width/25*8.5;o.attr("transform","translate("+t+", "+e+") rotate(-45, "+a+", "+r.y+")")}}},"drawCommitLabel"),Bt=a((t,e,r,a)=>{if(e.tags.length>0){let o=0,n=0,i=0,s=[];for(let a of e.tags.reverse()){let e=t.insert("polygon"),c=t.append("circle"),h=t.append("text").attr("y",r.y-16-o).attr("class","tag-label").text(a),d=h.node()?.getBBox();if(!d)throw new Error("Tag bbox not found");n=Math.max(n,d.width),i=Math.max(i,d.height),h.attr("x",r.posWithOffset-d.width/2),s.push({tag:h,hole:c,rect:e,yOffset:o}),o+=20}for(let{tag:t,hole:e,rect:o,yOffset:c}of s){let s=i/2,h=r.y-19.2-c;if(o.attr("class","tag-label-bkg").attr("points",`\n ${a-n/2-2},${h+2}\n ${a-n/2-2},${h-2}\n ${r.posWithOffset-n/2-4},${h-s-2}\n ${r.posWithOffset+n/2+4},${h-s-2}\n ${r.posWithOffset+n/2+4},${h+s+2}\n ${r.posWithOffset-n/2-4},${h+s+2}`),e.attr("cy",h).attr("cx",a-n/2+2).attr("r",1.5).attr("class","tag-hole"),"TB"===dt||"BT"===dt){let i=a+c;o.attr("class","tag-label-bkg").attr("points",`\n ${r.x},${i+2}\n ${r.x},${i-2}\n ${r.x+at},${i-s-2}\n ${r.x+at+n+4},${i-s-2}\n ${r.x+at+n+4},${i+s+2}\n ${r.x+at},${i+s+2}`).attr("transform","translate(12,12) rotate(45, "+r.x+","+a+")"),e.attr("cx",r.x+2).attr("cy",i).attr("transform","translate(12,12) rotate(45, "+r.x+","+a+")"),t.attr("x",r.x+5).attr("y",i+3).attr("transform","translate(14,14) rotate(45, "+r.x+","+a+")")}}}},"drawCommitTags"),Et=a(t=>{switch(t.customType??t.type){case w.NORMAL:return"commit-normal";case w.REVERSE:return"commit-reverse";case w.HIGHLIGHT:return"commit-highlight";case w.MERGE:return"commit-merge";case w.CHERRY_PICK:return"commit-cherry-pick";default:return"commit-normal"}},"getCommitClassType"),kt=a((t,e,r,a)=>{let o={x:0,y:0};if(!(t.parents.length>0))return"TB"===e?30:"BT"===e?(a.get(t.id)??o).y-ot:0;{let r=lt(t.parents);if(r){let n=a.get(r)??o;return"TB"===e?n.y+ot:"BT"===e?(a.get(t.id)??o).y-ot:n.x+ot}}return 0},"calculatePosition"),Ct=a((t,e,r)=>{let a="BT"===dt&&r?e:e+at,o="TB"===dt||"BT"===dt?a:nt.get(t.branch)?.pos,n="TB"===dt||"BT"===dt?nt.get(t.branch)?.pos:a;if(void 0===n||void 0===o)throw new Error(`Position were undefined for commit ${t.id}`);return{x:n,y:o,posWithOffset:a}},"getCommitPosition"),Lt=a((t,e,r)=>{if(!rt)throw new Error("GitGraph config not found");let o=t.append("g").attr("class","commit-bullets"),n=t.append("g").attr("class","commit-labels"),i="TB"===dt||"BT"===dt?30:0,s=[...e.keys()],c=rt?.parallelCommits??!1,h=a((t,r)=>{let a=e.get(t)?.seq,o=e.get(r)?.seq;return void 0!==a&&void 0!==o?a-o:0},"sortKeys"),d=s.sort(h);"BT"===dt&&(c&&gt(d,e,i),d=d.reverse()),d.forEach(t=>{let a=e.get(t);if(!a)throw new Error(`Commit not found for key ${t}`);c&&(i=kt(a,dt,i,it));let s=Ct(a,i,c);if(r){let t=Et(a),e=a.customType??a.type,r=nt.get(a.branch)?.index??0;bt(o,a,s,t,r,e),wt(n,a,s,i),Bt(n,a,s,i)}"TB"===dt||"BT"===dt?it.set(a.id,{x:s.x,y:s.posWithOffset}):it.set(a.id,{x:s.posWithOffset,y:s.y}),i="BT"===dt&&c?i+ot:i+ot+at,i>ht&&(ht=i)})},"drawCommits"),Tt=a((t,e,r,o,n)=>{let i=("TB"===dt||"BT"===dt?r.x<o.x:r.y<o.y)?e.branch:t.branch,s=a(t=>t.branch===i,"isOnBranchToGetCurve"),c=a(r=>r.seq>t.seq&&r.seq<e.seq,"isBetweenCommits");return[...n.values()].some(t=>c(t)&&s(t))},"shouldRerouteArrow"),Mt=a((t,e,r=0)=>{let a=t+Math.abs(t-e)/2;if(r>5)return a;if(ct.every(t=>Math.abs(t-a)>=10))return ct.push(a),a;let o=Math.abs(t-e);return Mt(t,e-o/5,r+1)},"findLane"),vt=a((t,e,r,a)=>{let o=it.get(e.id),n=it.get(r.id);if(void 0===o||void 0===n)throw new Error(`Commit positions not found for commits ${e.id} and ${r.id}`);let i,s=Tt(e,r,o,n,a),c="",h="",d=0,m=0,$=nt.get(r.branch)?.index;if(r.type===w.MERGE&&e.id!==r.parents[0]&&($=nt.get(e.branch)?.index),s){c="A 10 10, 0, 0, 0,",h="A 10 10, 0, 0, 1,",d=10,m=10;let t=o.y<n.y?Mt(o.y,n.y):Mt(n.y,o.y),r=o.x<n.x?Mt(o.x,n.x):Mt(n.x,o.x);"TB"===dt?o.x<n.x?i=`M ${o.x} ${o.y} L ${r-d} ${o.y} ${h} ${r} ${o.y+m} L ${r} ${n.y-d} ${c} ${r+m} ${n.y} L ${n.x} ${n.y}`:($=nt.get(e.branch)?.index,i=`M ${o.x} ${o.y} L ${r+d} ${o.y} ${c} ${r} ${o.y+m} L ${r} ${n.y-d} ${h} ${r-m} ${n.y} L ${n.x} ${n.y}`):"BT"===dt?o.x<n.x?i=`M ${o.x} ${o.y} L ${r-d} ${o.y} ${c} ${r} ${o.y-m} L ${r} ${n.y+d} ${h} ${r+m} ${n.y} L ${n.x} ${n.y}`:($=nt.get(e.branch)?.index,i=`M ${o.x} ${o.y} L ${r+d} ${o.y} ${h} ${r} ${o.y-m} L ${r} ${n.y+d} ${c} ${r-m} ${n.y} L ${n.x} ${n.y}`):o.y<n.y?i=`M ${o.x} ${o.y} L ${o.x} ${t-d} ${c} ${o.x+m} ${t} L ${n.x-d} ${t} ${h} ${n.x} ${t+m} L ${n.x} ${n.y}`:($=nt.get(e.branch)?.index,i=`M ${o.x} ${o.y} L ${o.x} ${t+d} ${h} ${o.x+m} ${t} L ${n.x-d} ${t} ${c} ${n.x} ${t-m} L ${n.x} ${n.y}`)}else c="A 20 20, 0, 0, 0,",h="A 20 20, 0, 0, 1,",d=20,m=20,"TB"===dt?(o.x<n.x&&(i=r.type===w.MERGE&&e.id!==r.parents[0]?`M ${o.x} ${o.y} L ${o.x} ${n.y-d} ${c} ${o.x+m} ${n.y} L ${n.x} ${n.y}`:`M ${o.x} ${o.y} L ${n.x-d} ${o.y} ${h} ${n.x} ${o.y+m} L ${n.x} ${n.y}`),o.x>n.x&&(c="A 20 20, 0, 0, 0,",h="A 20 20, 0, 0, 1,",d=20,m=20,i=r.type===w.MERGE&&e.id!==r.parents[0]?`M ${o.x} ${o.y} L ${o.x} ${n.y-d} ${h} ${o.x-m} ${n.y} L ${n.x} ${n.y}`:`M ${o.x} ${o.y} L ${n.x+d} ${o.y} ${c} ${n.x} ${o.y+m} L ${n.x} ${n.y}`),o.x===n.x&&(i=`M ${o.x} ${o.y} L ${n.x} ${n.y}`)):"BT"===dt?(o.x<n.x&&(i=r.type===w.MERGE&&e.id!==r.parents[0]?`M ${o.x} ${o.y} L ${o.x} ${n.y+d} ${h} ${o.x+m} ${n.y} L ${n.x} ${n.y}`:`M ${o.x} ${o.y} L ${n.x-d} ${o.y} ${c} ${n.x} ${o.y-m} L ${n.x} ${n.y}`),o.x>n.x&&(c="A 20 20, 0, 0, 0,",h="A 20 20, 0, 0, 1,",d=20,m=20,i=r.type===w.MERGE&&e.id!==r.parents[0]?`M ${o.x} ${o.y} L ${o.x} ${n.y+d} ${c} ${o.x-m} ${n.y} L ${n.x} ${n.y}`:`M ${o.x} ${o.y} L ${n.x-d} ${o.y} ${c} ${n.x} ${o.y-m} L ${n.x} ${n.y}`),o.x===n.x&&(i=`M ${o.x} ${o.y} L ${n.x} ${n.y}`)):(o.y<n.y&&(i=r.type===w.MERGE&&e.id!==r.parents[0]?`M ${o.x} ${o.y} L ${n.x-d} ${o.y} ${h} ${n.x} ${o.y+m} L ${n.x} ${n.y}`:`M ${o.x} ${o.y} L ${o.x} ${n.y-d} ${c} ${o.x+m} ${n.y} L ${n.x} ${n.y}`),o.y>n.y&&(i=r.type===w.MERGE&&e.id!==r.parents[0]?`M ${o.x} ${o.y} L ${n.x-d} ${o.y} ${c} ${n.x} ${o.y-m} L ${n.x} ${n.y}`:`M ${o.x} ${o.y} L ${o.x} ${n.y+d} ${h} ${o.x+m} ${n.y} L ${n.x} ${n.y}`),o.y===n.y&&(i=`M ${o.x} ${o.y} L ${n.x} ${n.y}`));if(void 0===i)throw new Error("Line definition not found");t.append("path").attr("d",i).attr("class","arrow arrow"+$%8)},"drawArrow"),Pt=a((t,e)=>{let r=t.append("g").attr("class","commit-arrows");[...e.keys()].forEach(t=>{let a=e.get(t);a.parents&&a.parents.length>0&&a.parents.forEach(t=>{vt(r,e.get(t),a,e)})})},"drawArrows"),Rt=a((t,e)=>{let r=t.append("g");e.forEach((t,e)=>{let a=e%8,o=nt.get(t.name)?.pos;if(void 0===o)throw new Error(`Position not found for branch ${t.name}`);let n=r.append("line");n.attr("x1",0),n.attr("y1",o),n.attr("x2",ht),n.attr("y2",o),n.attr("class","branch branch"+a),"TB"===dt?(n.attr("y1",30),n.attr("x1",o),n.attr("y2",ht),n.attr("x2",o)):"BT"===dt&&(n.attr("y1",ht),n.attr("x1",o),n.attr("y2",30),n.attr("x2",o)),ct.push(o);let i=t.name,s=$t(i),c=r.insert("rect"),h=r.insert("g").attr("class","branchLabel").insert("g").attr("class","label branch-label"+a);h.node().appendChild(s);let d=s.getBBox();c.attr("class","branchLabelBkg label"+a).attr("rx",4).attr("ry",4).attr("x",-d.width-4-(!0===rt?.rotateCommitLabel?30:0)).attr("y",-d.height/2+8).attr("width",d.width+18).attr("height",d.height+4),h.attr("transform","translate("+(-d.width-14-(!0===rt?.rotateCommitLabel?30:0))+", "+(o-d.height/2-1)+")"),"TB"===dt?(c.attr("x",o-d.width/2-10).attr("y",0),h.attr("transform","translate("+(o-d.width/2-5)+", 0)")):"BT"===dt?(c.attr("x",o-d.width/2-10).attr("y",ht),h.attr("transform","translate("+(o-d.width/2-5)+", "+ht+")")):c.attr("transform","translate(-19, "+(o-d.height/2)+")")})},"drawBranches"),Gt=a(function(t,e,r,a,o){return nt.set(t,{pos:e,index:r}),e+=50+(o?40:0)+("TB"===dt||"BT"===dt?a.width/2:0)},"setBranchPosition"),It=a(function(t,e,r,a){if(mt(),d.debug("in gitgraph renderer",t+"\n","id:",e,r),!rt)throw new Error("GitGraph config not found");let o=rt.rotateCommitLabel??!1,n=a.db;st=n.getCommits();let i=n.getBranchesAsObjArray();dt=n.getDirection();let s=$(`[id="${e}"]`),c=0;i.forEach((t,e)=>{let r=$t(t.name),a=s.append("g"),n=a.insert("g").attr("class","branchLabel"),i=n.insert("g").attr("class","label branch-label");i.node()?.appendChild(r);let h=r.getBBox();c=Gt(t.name,c,e,h,o),i.remove(),n.remove(),a.remove()}),Lt(s,st,!1),rt.showBranches&&Rt(s,i),Pt(s,st),Lt(s,st,!0),l.insertTitle(s,"gitTitleText",rt.titleTopMargin??0,n.getDiagramTitle()),y(void 0,s,rt.diagramPadding,rt.useMaxWidth)},"draw"),At={draw:It},Ot=a(t=>`\n .commit-id,\n .commit-msg,\n .branch-label {\n fill: lightgrey;\n color: lightgrey;\n font-family: 'trebuchet ms', verdana, arial, sans-serif;\n font-family: var(--mermaid-font-family);\n }\n ${[0,1,2,3,4,5,6,7].map(e=>`\n .branch-label${e} { fill: ${t["gitBranchLabel"+e]}; }\n .commit${e} { stroke: ${t["git"+e]}; fill: ${t["git"+e]}; }\n .commit-highlight${e} { stroke: ${t["gitInv"+e]}; fill: ${t["gitInv"+e]}; }\n .label${e} { fill: ${t["git"+e]}; }\n .arrow${e} { stroke: ${t["git"+e]}; }\n `).join("\n")}\n\n .branch {\n stroke-width: 1;\n stroke: ${t.lineColor};\n stroke-dasharray: 2;\n }\n .commit-label { font-size: ${t.commitLabelFontSize}; fill: ${t.commitLabelColor};}\n .commit-label-bkg { font-size: ${t.commitLabelFontSize}; fill: ${t.commitLabelBackground}; opacity: 0.5; }\n .tag-label { font-size: ${t.tagLabelFontSize}; fill: ${t.tagLabelColor};}\n .tag-label-bkg { fill: ${t.tagLabelBackground}; stroke: ${t.tagLabelBorder}; }\n .tag-hole { fill: ${t.textColor}; }\n\n .commit-merge {\n stroke: ${t.primaryColor};\n fill: ${t.primaryColor};\n }\n .commit-reverse {\n stroke: ${t.primaryColor};\n fill: ${t.primaryColor};\n stroke-width: 3;\n }\n .commit-highlight-outer {\n }\n .commit-highlight-inner {\n stroke: ${t.primaryColor};\n fill: ${t.primaryColor};\n }\n\n .arrow { stroke-width: 8; stroke-linecap: round; fill: none}\n .gitTitleText {\n text-anchor: middle;\n font-size: 18px;\n fill: ${t.textColor};\n }\n`,"getStyles"),qt={parser:tt,db:Y,renderer:At,styles:Ot};export{qt as diagram};
//# sourceMappingURL=gitGraphDiagram-JCGM6PWI-DUSWEYAD.js.map