regit-cli
Version:
git helper cli
10 lines (9 loc) • 38.8 kB
JavaScript
import{r as l}from"./index.LFf77hJu.js";var Z=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},ot={exports:{}},S={};/**
* @license React
* react-jsx-runtime.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/var xt=l,Mt=Symbol.for("react.element"),Et=Symbol.for("react.fragment"),Rt=Object.prototype.hasOwnProperty,Bt=xt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,Pt={key:!0,ref:!0,__self:!0,__source:!0};function ht(o,t,e){var r,a={},s=null,i=null;e!==void 0&&(s=""+e),t.key!==void 0&&(s=""+t.key),t.ref!==void 0&&(i=t.ref);for(r in t)Rt.call(t,r)&&!Pt.hasOwnProperty(r)&&(a[r]=t[r]);if(o&&o.defaultProps)for(r in t=o.defaultProps,t)a[r]===void 0&&(a[r]=t[r]);return{$$typeof:Mt,type:o,key:s,ref:i,props:a,_owner:Bt.current}}S.Fragment=Et;S.jsx=ht;S.jsxs=ht;ot.exports=S;var N=ot.exports,d={},I={},w={},B={},x={},T={},j={},b={},$={};(function(o){Object.defineProperty(o,"__esModule",{value:!0}),function(t){t.VerticalReverse="vertical-reverse",t.Horizontal="horizontal",t.HorizontalReverse="horizontal-reverse"}(o.Orientation||(o.Orientation={}))})($);Object.defineProperty(b,"__esModule",{value:!0});const W=$;function At(o,t){return typeof o=="boolean"?o:t}b.booleanOptionOr=At;function St(o,t){return typeof o=="number"?o:t}b.numberOptionOr=St;function ct(o,t){return Object.assign({},t.reduce((e,r)=>Object.assign({},e,{[r]:o[r]}),{}))}b.pick=ct;function Tt(o,t){console.log(JSON.stringify(o.map(e=>ct(e,t)),null,2))}b.debug=Tt;function mt(o){return o===void 0}b.isUndefined=mt;function jt(o={}){return Object.keys(o).reduce((t,e)=>mt(o[e])?t:Object.assign({},t,{[e]:o[e]}),{})}b.withoutUndefinedKeys=jt;function $t(o,t,e){const r=e.style.dot.size,a=o.template.arrow.size,s=r+o.template.arrow.offset,i=Math.PI/7,n=Dt(o,t,e),m=s*Math.cos(n),c=s*Math.sin(n),h=(s+a)*Math.cos(n-i),u=(s+a)*Math.sin(n-i),f=(s+a/2)*Math.cos(n),g=(s+a/2)*Math.sin(n),y=(s+a)*Math.cos(n+i),O=(s+a)*Math.sin(n+i);return`M${m},${c} L${h},${u} Q${f},${g} ${y},${O} L${y},${O}`}b.arrowSvgPath=$t;function Dt(o,t,e){const r=t.x-e.x,a=t.y-e.y,s=o.template.commit.spacing;let i,n;switch(o.orientation){case W.Orientation.Horizontal:i=a,n=-s;break;case W.Orientation.HorizontalReverse:i=a,n=s;break;case W.Orientation.VerticalReverse:i=-s,n=r;break;default:i=s,n=r;break}return o.isVertical?Math.abs(a)>s&&(n=0):Math.abs(r)>s&&(i=0),o.reverseArrow&&(i*=-1,n*=-1),Math.atan2(i,n)}(function(o){Object.defineProperty(o,"__esModule",{value:!0});const t=b;var e;(function(c){c.Bezier="bezier",c.Straight="straight"})(e||(e={})),o.MergeStyle=e,o.DEFAULT_FONT="normal 12pt Calibri";class r{constructor(h){h.branch=h.branch||{},h.branch.label=h.branch.label||{},h.arrow=h.arrow||{},h.commit=h.commit||{},h.commit.dot=h.commit.dot||{},h.commit.message=h.commit.message||{},this.colors=h.colors||["#000000"],this.branch={color:h.branch.color,lineWidth:h.branch.lineWidth||2,mergeStyle:h.branch.mergeStyle||e.Bezier,spacing:t.numberOptionOr(h.branch.spacing,20),label:{display:t.booleanOptionOr(h.branch.label.display,!0),color:h.branch.label.color||h.commit.color,strokeColor:h.branch.label.strokeColor||h.commit.color,bgColor:h.branch.label.bgColor||"white",font:h.branch.label.font||h.commit.message.font||o.DEFAULT_FONT,borderRadius:t.numberOptionOr(h.branch.label.borderRadius,10)}},this.arrow={size:h.arrow.size||null,color:h.arrow.color||null,offset:h.arrow.offset||2},this.commit={color:h.commit.color,spacing:t.numberOptionOr(h.commit.spacing,25),hasTooltipInCompactMode:t.booleanOptionOr(h.commit.hasTooltipInCompactMode,!0),dot:{color:h.commit.dot.color||h.commit.color,size:h.commit.dot.size||3,strokeWidth:t.numberOptionOr(h.commit.dot.strokeWidth,0),strokeColor:h.commit.dot.strokeColor,font:h.commit.dot.font||h.commit.message.font||"normal 10pt Calibri"},message:{display:t.booleanOptionOr(h.commit.message.display,!0),displayAuthor:t.booleanOptionOr(h.commit.message.displayAuthor,!0),displayHash:t.booleanOptionOr(h.commit.message.displayHash,!0),color:h.commit.message.color||h.commit.color,font:h.commit.message.font||o.DEFAULT_FONT}},this.tag=h.tag||{}}}o.Template=r;const a=new r({colors:["#6963FF","#47E8D4","#6BDB52","#E84BA5","#FFA657"],branch:{color:"#000000",lineWidth:4,spacing:50,mergeStyle:e.Straight},commit:{spacing:60,dot:{size:16,strokeColor:"#000000",strokeWidth:4},message:{color:"black"}},arrow:{size:16,offset:-1.5}});o.blackArrowTemplate=a;const s=new r({colors:["#979797","#008fb5","#f1c109"],branch:{lineWidth:10,spacing:50},commit:{spacing:80,dot:{size:14},message:{font:"normal 14pt Arial"}}});o.metroTemplate=s;var i;(function(c){c.Metro="metro",c.BlackArrow="blackarrow"})(i||(i={})),o.TemplateName=i;function n(c,h){const u=m(c);return h.branch||(h.branch={}),h.commit||(h.commit={}),{colors:h.colors||u.colors,arrow:Object.assign({},u.arrow,h.arrow),branch:Object.assign({},u.branch,h.branch,{label:Object.assign({},u.branch.label,h.branch.label)}),commit:Object.assign({},u.commit,h.commit,{dot:Object.assign({},u.commit.dot,h.commit.dot),message:Object.assign({},u.commit.message,h.commit.message)}),tag:Object.assign({},u.tag,h.tag)}}o.templateExtend=n;function m(c){return c?typeof c=="string"?{[i.BlackArrow]:a,[i.Metro]:s}[c]:c:s}o.getTemplate=m})(j);Object.defineProperty(T,"__esModule",{value:!0});const kt=j,tt=b;let Ht=class{constructor(t,e,r,a){this.name=t,this.tagStyle=e,this.commitStyle=a,this.render=r}get style(){return{strokeColor:this.tagStyle.strokeColor||this.commitStyle.color,bgColor:this.tagStyle.bgColor||this.commitStyle.color,color:this.tagStyle.color||"white",font:this.tagStyle.font||this.commitStyle.message.font||kt.DEFAULT_FONT,borderRadius:tt.numberOptionOr(this.tagStyle.borderRadius,10),pointerWidth:tt.numberOptionOr(this.tagStyle.pointerWidth,12)}}};T.Tag=Ht;Object.defineProperty(x,"__esModule",{value:!0});const zt=T,Gt=()=>(Math.random().toString(16).substring(3)+Math.random().toString(16).substring(3)+Math.random().toString(16).substring(3)+Math.random().toString(16).substring(3)).substring(0,40);let Ut=class lt{constructor(t){this.refs=[],this.x=0,this.y=0;let e,r;try{[,e,r]=t.author.match(/(.*) <(.*)>/)}catch{[e,r]=[t.author,""]}this.author={name:e,email:r,timestamp:Date.now()},this.committer={name:e,email:r,timestamp:Date.now()},this.subject=t.subject,this.body=t.body||"",this.hash=t.hash||Gt(),this.hashAbbrev=this.hash.substring(0,7),this.parents=t.parents?t.parents:[],this.parentsAbbrev=this.parents.map(a=>a.substring(0,7)),this.style=Object.assign({},t.style,{message:Object.assign({},t.style.message),dot:Object.assign({},t.style.dot)}),this.dotText=t.dotText,this.onClick=()=>t.onClick?t.onClick(this):void 0,this.onMessageClick=()=>t.onMessageClick?t.onMessageClick(this):void 0,this.onMouseOver=()=>t.onMouseOver?t.onMouseOver(this):void 0,this.onMouseOut=()=>t.onMouseOut?t.onMouseOut(this):void 0,this.renderDot=t.renderDot,this.renderMessage=t.renderMessage,this.renderTooltip=t.renderTooltip}get message(){let t="";return this.style.message.displayHash&&(t+=`${this.hashAbbrev} `),t+=this.subject,this.style.message.displayAuthor&&(t+=` - ${this.author.name} <${this.author.email}>`),t}get branchToDisplay(){return this.branches?this.branches[0]:""}setRefs(t){return this.refs=t.getNames(this.hash),this}setTags(t,e,r){return this.tags=t.getNames(this.hash).map(a=>new zt.Tag(a,e(a),r(a),this.style)),this}setBranches(t){return this.branches=t,this}setPosition({x:t,y:e}){return this.x=t,this.y=e,this}withDefaultColor(t){const e=Object.assign({},this.style,{dot:Object.assign({},this.style.dot),message:Object.assign({},this.style.message)});e.color||(e.color=t),e.dot.color||(e.dot.color=t),e.message.color||(e.message.color=t);const r=this.cloneCommit();return r.style=e,r}cloneCommit(){const t=new lt({author:`${this.author.name} <${this.author.email}>`,subject:this.subject,style:this.style,body:this.body,hash:this.hash,parents:this.parents,dotText:this.dotText,onClick:this.onClick,onMessageClick:this.onMessageClick,onMouseOver:this.onMouseOver,onMouseOut:this.onMouseOut,renderDot:this.renderDot,renderMessage:this.renderMessage,renderTooltip:this.renderTooltip});return t.refs=this.refs,t.branches=this.branches,t.tags=this.tags,t.x=this.x,t.y=this.y,t}};x.Commit=Ut;var et;function ut(){if(et)return B;et=1;var o=Z&&Z.__rest||function(i,n){var m={};for(var c in i)Object.prototype.hasOwnProperty.call(i,c)&&n.indexOf(c)<0&&(m[c]=i[c]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var h=0,c=Object.getOwnPropertySymbols(i);h<c.length;h++)n.indexOf(c[h])<0&&Object.prototype.propertyIsEnumerable.call(i,c[h])&&(m[c[h]]=i[c[h]]);return m};Object.defineProperty(B,"__esModule",{value:!0});const t=x,e=D(),r=b;class a{constructor(n,m,c){this._branch=n,this.name=n.name,this._graph=m,this._onGraphUpdate=c}branch(n){if(this._branch.isDeleted()&&!this._isReferenced())throw new Error(`Cannot branch from the deleted branch "${this.name}"`);const m=typeof n=="string"?{name:n}:n;return m.from=this,this._graph.createBranch(m).getUserApi()}commit(n){if(this._branch.isDeleted()&&!this._isReferenced())throw new Error(`Cannot commit on the deleted branch "${this.name}"`);return typeof n=="string"&&(n={subject:n}),n||(n={}),this._commitWithParents(n,[]),this._onGraphUpdate(),this}delete(){if(this._graph.refs.getCommit("HEAD")===this._graph.refs.getCommit(this.name))throw new Error(`Cannot delete the checked out branch "${this.name}"`);return[...function*(m,c){const h=(f,g)=>f.commits.find(({hash:y})=>y===g);let u=h(m,m.refs.getCommit(c.name));for(;u&&u.hash!==c.parentCommitHash;)yield u,u=h(m,u.parents[0])}(this._graph,this._branch)].forEach(m=>{m.refs=m.refs.filter(c=>c!==this.name)}),this._graph.refs.delete(this.name),this._graph.branches.delete(this.name),this._branch=e.createDeletedBranch(this._graph,this._branch.style,()=>{}),this._onGraphUpdate(),this}merge(...n){if(this._branch.isDeleted()&&!this._isReferenced())throw new Error(`Cannot merge to the deleted branch "${this.name}"`);let m=n[0];s(m)||(m={branch:n[0],fastForward:!1,commitOptions:{subject:n[1]}});const{branch:c,fastForward:h,commitOptions:u}=m,f=typeof c=="string"?c:c.name,g=this._graph.refs.getCommit(f);if(!g)throw new Error(`The branch called "${f}" is unknown`);let y=!1;if(h){const O=this._graph.refs.getCommit(this._branch.name);O&&(y=this._areCommitsConnected(O,g))}return h&&y?this._fastForwardTo(g):this._commitWithParents(Object.assign({},u,{subject:u&&u.subject||`Merge branch ${f}`}),[g]),this._onGraphUpdate(),this}tag(n){if(this._branch.isDeleted()&&!this._isReferenced())throw new Error(`Cannot tag on the deleted branch "${this.name}"`);return typeof n=="string"?this._graph.getUserApi().tag({name:n,ref:this._branch.name}):this._graph.getUserApi().tag(Object.assign({},n,{ref:this._branch.name})),this}checkout(){if(this._branch.isDeleted()&&!this._isReferenced())throw new Error(`Cannot checkout the deleted branch "${this.name}"`);const n=this._branch,m=this._graph.refs.getCommit(n.name);return this._graph.currentBranch=n,m&&this._graph.refs.set("HEAD",m),this}_commitWithParents(n,m){const c=this._graph.refs.getCommit(this._branch.name);c?m.unshift(c):this._branch.parentCommitHash&&m.unshift(this._branch.parentCommitHash);const{tag:h}=n,u=o(n,["tag"]),f=new t.Commit(Object.assign({hash:this._graph.generateCommitHash(),author:this._branch.commitDefaultOptions.author||this._graph.author,subject:this._branch.commitDefaultOptions.subject||this._graph.commitMessage},u,{parents:m,style:this._getCommitStyle(n.style)}));c?this._graph.refs.getNames(c).forEach(y=>this._graph.refs.set(y,f.hash)):this._graph.refs.set(this._branch.name,f.hash),this._graph.commits.push(f),this.checkout(),h&&this.tag(h)}_areCommitsConnected(n,m){const c=this._graph.commits.find(({hash:u})=>m===u);return!c||c.parents.length===0?!1:c.parents.includes(n)?!0:c.parents.some(u=>this._areCommitsConnected(n,u))}_fastForwardTo(n){this._graph.refs.set(this._branch.name,n)}_getCommitStyle(n={}){return Object.assign({},r.withoutUndefinedKeys(this._graph.template.commit),r.withoutUndefinedKeys(this._branch.commitDefaultOptions.style),n,{message:Object.assign({},r.withoutUndefinedKeys(this._graph.template.commit.message),r.withoutUndefinedKeys(this._branch.commitDefaultOptions.style.message),n.message,r.withoutUndefinedKeys({display:this._graph.shouldDisplayCommitMessage&&void 0})),dot:Object.assign({},r.withoutUndefinedKeys(this._graph.template.commit.dot),r.withoutUndefinedKeys(this._branch.commitDefaultOptions.style.dot),n.dot)})}_isReferenced(){return this._graph.branches.has(this.name)||this._graph.refs.hasName(this.name)||this._graph.commits.reduce((n,{refs:m})=>[...n,...m],[]).includes(this.name)}}B.BranchUserApi=a;function s(i){return typeof i=="object"&&!(i instanceof a)}return B}var rt;function D(){if(rt)return w;rt=1,Object.defineProperty(w,"__esModule",{value:!0});const o=ut(),t="";w.DELETED_BRANCH_NAME=t;class e{constructor(s){this.gitgraph=s.gitgraph,this.name=s.name,this.style=s.style,this.parentCommitHash=s.parentCommitHash,this.commitDefaultOptions=s.commitDefaultOptions||{style:{}},this.onGraphUpdate=s.onGraphUpdate,this.renderLabel=s.renderLabel}getUserApi(){return new o.BranchUserApi(this,this.gitgraph,this.onGraphUpdate)}isDeleted(){return this.name===t}}w.Branch=e;function r(a,s,i){return new e({name:t,gitgraph:a,style:s,onGraphUpdate:i})}return w.createDeletedBranch=r,w}var k={},M={};Object.defineProperty(M,"__esModule",{value:!0});var F;(function(o){o.Compact="compact"})(F||(F={}));M.Mode=F;var V={},H={};Object.defineProperty(H,"__esModule",{value:!0});class Nt{constructor(t){this.rows=new Map,this.maxRowCache=void 0,this.computeRowsFromCommits(t)}getRowOf(t){return this.rows.get(t)||0}getMaxRow(){return this.maxRowCache===void 0&&(this.maxRowCache=Wt(Array.from(this.rows.values())).length-1),this.maxRowCache}computeRowsFromCommits(t){t.forEach((e,r)=>{this.rows.set(e.hash,r)}),this.maxRowCache=void 0}}H.RegularGraphRows=Nt;function Wt(o){const t=new Set;return o.forEach(e=>t.add(e)),Array.from(t)}Object.defineProperty(V,"__esModule",{value:!0});const Xt=H;class Ft extends Xt.RegularGraphRows{computeRowsFromCommits(t){t.forEach((e,r)=>{let a=r;if(!(r===0)){const i=this.getRowOf(e.parents[0]),n=t[r-1];if(a=Math.max(i+1,this.getRowOf(n.hash)),e.parents.length>1){const c=this.getRowOf(e.parents[1]);i<c&&a++}}this.rows.set(e.hash,a)})}}V.CompactGraphRows=Ft;Object.defineProperty(k,"__esModule",{value:!0});const Lt=M,It=V,ft=H;k.GraphRows=ft.RegularGraphRows;function Vt(o,t){return o===Lt.Mode.Compact?new It.CompactGraphRows(t):new ft.RegularGraphRows(t)}k.createGraphRows=Vt;var Y={};Object.defineProperty(Y,"__esModule",{value:!0});class Yt{constructor(t,e,r){this.branches=new Set,this.colors=e,t.forEach(a=>this.branches.add(a.branchToDisplay)),r&&(this.branches=new Set(Array.from(this.branches).sort(r)))}get(t){return Array.from(this.branches).findIndex(e=>e===t)}getColorOf(t){return this.colors[this.get(t)%this.colors.length]}}Y.BranchesOrder=Yt;var E={};Object.defineProperty(E,"__esModule",{value:!0});class Kt{constructor(){this.commitPerName=new Map,this.namesPerCommit=new Map}set(t,e){const r=this.commitPerName.get(t);return r&&this.removeNameFrom(r,t),this.addNameTo(e,t),this.addCommitTo(t,e),this}delete(t){return this.hasName(t)&&(this.removeNameFrom(this.getCommit(t),t),this.commitPerName.delete(t)),this}getCommit(t){return this.commitPerName.get(t)}getNames(t){return this.namesPerCommit.get(t)||[]}getAllNames(){return Array.from(this.commitPerName.keys())}hasCommit(t){return this.namesPerCommit.has(t)}hasName(t){return this.commitPerName.has(t)}removeNameFrom(t,e){const r=this.namesPerCommit.get(t)||[];this.namesPerCommit.set(t,r.filter(a=>a!==e))}addNameTo(t,e){const r=this.namesPerCommit.get(t)||[];this.namesPerCommit.set(t,[...r,e])}addCommitTo(t,e){this.commitPerName.set(t,e)}}E.Refs=Kt;var R={};Object.defineProperty(R,"__esModule",{value:!0});const Qt=b;class qt{constructor(t,e,r,a,s,i){this.branchesPaths=new Map,this.commits=t,this.branches=e,this.commitSpacing=r,this.isGraphVertical=a,this.isGraphReverse=s,this.createDeletedBranch=i}execute(){return this.fromCommits(),this.withMergeCommits(),this.smoothBranchesPaths()}fromCommits(){this.commits.forEach(t=>{let e=this.branches.get(t.branchToDisplay);e||(e=this.getDeletedBranchInPath()||this.createDeletedBranch());const r=[],a=this.branchesPaths.get(e),s=this.commits.find(({hash:i})=>i===t.parents[0]);a?r.push(...a):s&&r.push({x:s.x,y:s.y}),r.push({x:t.x,y:t.y}),this.branchesPaths.set(e,r)})}withMergeCommits(){this.commits.filter(({parents:e})=>e.length>1).forEach(e=>{const r=this.commits.find(({hash:n})=>n===e.parents[1]);if(!r)return;const a=r.branches?r.branches[0]:"";let s=this.branches.get(a);if(!s&&(s=this.getDeletedBranchInPath(),!s))return;const i=[...this.branchesPaths.get(s)||[]];this.branchesPaths.set(s,[...i,{x:e.x,y:e.y,mergeCommit:!0}])})}getDeletedBranchInPath(){return Array.from(this.branchesPaths.keys()).find(t=>t.isDeleted())}smoothBranchesPaths(){const t=new Map;return this.branchesPaths.forEach((e,r)=>{if(e.length<=1){t.set(r,[e]);return}this.isGraphVertical?e=e.sort((s,i)=>s.y>i.y?-1:1):e=e.sort((s,i)=>s.x>i.x?1:-1),this.isGraphReverse&&(e=e.reverse());const a=e.reduce((s,i,n)=>{if(i.mergeCommit){s[s.length-1].push(Qt.pick(i,["x","y"]));let m=n-1,c=e[m];for(;m>=0&&c.mergeCommit;)m--,c=e[m];m>=0&&s.push([c])}else s[s.length-1].push(i);return s},[[]]);this.isGraphReverse&&a.forEach(s=>s.reverse()),this.isGraphVertical?a.forEach(s=>{if(s.length<=1)return;const i=s[0],n=s[s.length-1],m=s[1].x,c=Math.round(Math.abs(i.y-n.y)/this.commitSpacing)-1,h=c>0?new Array(c).fill(0).map((f,g)=>({x:m,y:s[0].y-this.commitSpacing*(g+1)})):[],u=t.get(r)||[];t.set(r,[...u,[i,...h,n]])}):a.forEach(s=>{if(s.length<=1)return;const i=s[0],n=s[s.length-1],m=s[1].y,c=Math.round(Math.abs(i.x-n.x)/this.commitSpacing)-1,h=c>0?new Array(c).fill(0).map((f,g)=>({y:m,x:s[0].x+this.commitSpacing*(g+1)})):[],u=t.get(r)||[];t.set(r,[...u,[i,...h,n]])})}),t}}R.BranchesPathsCalculator=qt;function Jt(o,t,e){return o.map(r=>"M"+r.map(({x:a,y:s},i,n)=>{if(t&&n.length>1&&(i===1||i===n.length-1)){const m=n[i-1];if(e){const c=(m.y+s)/2;return`C ${m.x} ${c} ${a} ${c} ${a} ${s}`}else{const c=(m.x+a)/2;return`C ${c} ${m.y} ${c} ${s} ${a} ${s}`}}return`L ${a} ${s}`}).join(" ").slice(1)).join(" ")}R.toSvgPath=Jt;var z={};Object.defineProperty(z,"__esModule",{value:!0});const Zt=x,te=D(),st=E;class ee{constructor(t,e){this._graph=t,this._onGraphUpdate=e}clear(){return this._graph.refs=new st.Refs,this._graph.tags=new st.Refs,this._graph.commits=[],this._graph.branches=new Map,this._graph.currentBranch=this._graph.createBranch("master"),this._onGraphUpdate(),this}commit(t){return this._graph.currentBranch.getUserApi().commit(t),this}branch(t){return this._graph.createBranch(t).getUserApi()}tag(...t){let e,r,a,s;if(typeof t[0]=="string"?(e=t[0],r=t[1]):(e=t[0].name,r=t[0].ref,a=t[0].style,s=t[0].render),!r){const n=this._graph.refs.getCommit("HEAD");if(!n)return this;r=n}let i;if(this._graph.refs.hasCommit(r)&&(i=r),this._graph.refs.hasName(r)&&(i=this._graph.refs.getCommit(r)),!i)throw new Error(`The ref "${r}" does not exist`);return this._graph.tags.set(e,i),this._graph.tagStyles[e]=a,this._graph.tagRenders[e]=s,this._onGraphUpdate(),this}import(t){const e=new Error("Only `git2json` format is supported for imported data.");if(!Array.isArray(t)||!t.every(i=>typeof i=="object"&&typeof i.author=="object"&&Array.isArray(i.refs)))throw e;const a=t.map(i=>Object.assign({},i,{style:Object.assign({},this._graph.template.commit,{message:Object.assign({},this._graph.template.commit.message,{display:this._graph.shouldDisplayCommitMessage})}),author:`${i.author.name} <${i.author.email}>`})).reverse();this.clear(),this._graph.commits=a.map(i=>new Zt.Commit(i)),a.forEach(({refs:i,hash:n})=>{if(!i||!n)return;const m="tag: ";i.map(h=>h.split(m)).map(([h,u])=>u).filter(h=>typeof h=="string").forEach(h=>this._graph.tags.set(h,n)),i.filter(h=>!h.startsWith(m)).forEach(h=>this._graph.refs.set(h,n))});const s=this._getBranches();return this._graph.commits.map(i=>this._withBranches(s,i)).reduce((i,n)=>(n.branches&&n.branches.forEach(m=>i.add(m)),i),new Set).forEach(i=>this.branch(i)),this._onGraphUpdate(),this}_withBranches(t,e){let r=Array.from((t.get(e.hash)||new Set).values());return r.length===0&&(r=[te.DELETED_BRANCH_NAME]),e.setBranches(r)}_getBranches(){const t=new Map,e=[];return this._graph.refs.getAllNames().filter(a=>a!=="HEAD").forEach(a=>{const s=this._graph.refs.getCommit(a);for(s&&e.push(s);e.length>0;){const i=e.pop(),n=this._graph.commits.find(({hash:c})=>c===i),m=t.get(i)||new Set;m.add(a),t.set(i,m),n&&n.parents&&n.parents.length>0&&e.push(n.parents[0])}}),t}}z.GitgraphUserApi=ee;Object.defineProperty(I,"__esModule",{value:!0});const X=D(),re=k,se=M,at=Y,ae=j,it=E,ie=R,P=b,C=$,ne=z;let oe=class{constructor(t={}){this.refs=new it.Refs,this.tags=new it.Refs,this.tagStyles={},this.tagRenders={},this.commits=[],this.branches=new Map,this.listeners=[],this.nextTimeoutId=null,this.template=ae.getTemplate(t.template),this.currentBranch=this.createBranch("master"),this.orientation=t.orientation,this.reverseArrow=P.booleanOptionOr(t.reverseArrow,!1),this.initCommitOffsetX=P.numberOptionOr(t.initCommitOffsetX,0),this.initCommitOffsetY=P.numberOptionOr(t.initCommitOffsetY,0),this.mode=t.mode,this.author=t.author||"Sergio Flores <saxo-guy@epic.com>",this.commitMessage=t.commitMessage||"He doesn't like George Michael! Boooo!",this.generateCommitHash=typeof t.generateCommitHash=="function"?t.generateCommitHash:()=>{},this.branchesOrderFunction=typeof t.compareBranchesOrder=="function"?t.compareBranchesOrder:void 0,this.branchLabelOnEveryCommit=P.booleanOptionOr(t.branchLabelOnEveryCommit,!1)}get isHorizontal(){return this.orientation===C.Orientation.Horizontal||this.orientation===C.Orientation.HorizontalReverse}get isVertical(){return!this.isHorizontal}get isReverse(){return this.orientation===C.Orientation.HorizontalReverse||this.orientation===C.Orientation.VerticalReverse}get shouldDisplayCommitMessage(){return!this.isHorizontal&&this.mode!==se.Mode.Compact}getUserApi(){return new ne.GitgraphUserApi(this,()=>this.next())}subscribe(t){this.listeners.push(t);let e=!0;return()=>{if(!e)return;e=!1;const r=this.listeners.indexOf(t);this.listeners.splice(r,1)}}getRenderedData(){const t=this.computeRenderedCommits(),e=this.computeRenderedBranchesPaths(t),r=this.computeCommitMessagesX(e);return this.computeBranchesColor(t,e),{commits:t,branchesPaths:e,commitMessagesX:r}}createBranch(t){const e="HEAD";let r={gitgraph:this,name:"",parentCommitHash:this.refs.getCommit(e),style:this.template.branch,onGraphUpdate:()=>this.next()};if(typeof t=="string")r.name=t,r.parentCommitHash=this.refs.getCommit(e);else{const s=t.from?t.from.name:e,i=this.refs.getCommit(s)||(this.refs.hasCommit(t.from)?t.from:void 0);t.style=t.style||{},r=Object.assign({},r,t,{parentCommitHash:i,style:Object.assign({},r.style,t.style,{label:Object.assign({},r.style.label,t.style.label)})})}const a=new X.Branch(r);return this.branches.set(a.name,a),a}computeRenderedCommits(){const t=this.getBranches(),e=(()=>{const n=new Set(this.commits.reduce((h,{hash:u})=>t.has(u)?h:[...h,u],[])),m=this.commits.reduce((h,u)=>u.parents.length>1?[...h,...u.parents.slice(1).map(f=>this.commits.find(({hash:g})=>f===g))]:h,[]),c=new Set;return m.forEach(h=>{let u=h;for(;u&&n.has(u.hash);)c.add(u.hash),u=u.parents.length>0?this.commits.find(({hash:f})=>u.parents[0]===f):void 0}),c})(),r=this.commits.filter(({hash:n})=>t.has(n)||e.has(n)),a=r.map(n=>this.withBranches(t,n)),s=re.createGraphRows(this.mode,r),i=new at.BranchesOrder(a,this.template.colors,this.branchesOrderFunction);return a.map(n=>n.setRefs(this.refs)).map(n=>this.withPosition(s,i,n)).map(n=>n.withDefaultColor(this.getBranchDefaultColor(i,n.branchToDisplay))).map(n=>n.setTags(this.tags,m=>Object.assign({},this.tagStyles[m],this.template.tag),m=>this.tagRenders[m]))}computeRenderedBranchesPaths(t){return new ie.BranchesPathsCalculator(t,this.branches,this.template.commit.spacing,this.isVertical,this.isReverse,()=>X.createDeletedBranch(this,this.template.branch,()=>this.next())).execute()}computeBranchesColor(t,e){const r=new at.BranchesOrder(t,this.template.colors,this.branchesOrderFunction);Array.from(e).forEach(([a])=>{a.computedColor=a.style.color||this.getBranchDefaultColor(r,a.name)})}computeCommitMessagesX(t){return Array.from(t).length*this.template.branch.spacing}withBranches(t,e){let r=Array.from((t.get(e.hash)||new Set).values());return r.length===0&&(r=[X.DELETED_BRANCH_NAME]),e.setBranches(r)}getBranches(){const t=new Map,e=[];return this.refs.getAllNames().filter(a=>a!=="HEAD").forEach(a=>{const s=this.refs.getCommit(a);for(s&&e.push(s);e.length>0;){const i=e.pop(),n=this.commits.find(({hash:c})=>c===i),m=t.get(i)||new Set;m.add(a),t.set(i,m),n&&n.parents&&n.parents.length>0&&e.push(n.parents[0])}}),t}withPosition(t,e,r){const a=t.getRowOf(r.hash),s=t.getMaxRow(),i=e.get(r.branchToDisplay);switch(this.orientation){default:return r.setPosition({x:this.initCommitOffsetX+this.template.branch.spacing*i,y:this.initCommitOffsetY+this.template.commit.spacing*(s-a)});case C.Orientation.VerticalReverse:return r.setPosition({x:this.initCommitOffsetX+this.template.branch.spacing*i,y:this.initCommitOffsetY+this.template.commit.spacing*a});case C.Orientation.Horizontal:return r.setPosition({x:this.initCommitOffsetX+this.template.commit.spacing*a,y:this.initCommitOffsetY+this.template.branch.spacing*i});case C.Orientation.HorizontalReverse:return r.setPosition({x:this.initCommitOffsetX+this.template.commit.spacing*(s-a),y:this.initCommitOffsetY+this.template.branch.spacing*i})}}getBranchDefaultColor(t,e){return t.getColorOf(e)}next(){this.nextTimeoutId&&window.clearTimeout(this.nextTimeoutId),this.nextTimeoutId=window.setTimeout(()=>{this.listeners.forEach(t=>t(this.getRenderedData()))},0)}};I.GitgraphCore=oe;Object.defineProperty(d,"__esModule",{value:!0});var he=I,ce=d.GitgraphCore=he.GitgraphCore,me=M,gt=d.Mode=me.Mode,le=z;d.GitgraphUserApi=le.GitgraphUserApi;var ue=ut();d.BranchUserApi=ue.BranchUserApi;var fe=D();d.Branch=fe.Branch;var ge=x;d.Commit=ge.Commit;var de=T;d.Tag=de.Tag;var pe=E;d.Refs=pe.Refs;var K=j,be=d.MergeStyle=K.MergeStyle,ye=d.TemplateName=K.TemplateName,_e=d.templateExtend=K.templateExtend,ve=$,dt=d.Orientation=ve.Orientation,Oe=R,Ce=d.toSvgPath=Oe.toSvgPath,we=b,xe=d.arrowSvgPath=we.arrowSvgPath;function Me(o){var t=o.branch,e=o.commit,r=l.useState({textWidth:0,textHeight:0}),a=r[0],s=r[1],i=l.useCallback(function(c){if(c){var h=c.getBBox();s({textWidth:h.width,textHeight:h.height})}},[]),n=a.textWidth+2*_.paddingX,m=a.textHeight+2*_.paddingY;return l.createElement("g",null,l.createElement("rect",{stroke:t.style.label.strokeColor||e.style.color,fill:t.style.label.bgColor,rx:t.style.label.borderRadius,width:n,height:m}),l.createElement("text",{ref:i,fill:t.style.label.color||e.style.color,style:{font:t.style.label.font},alignmentBaseline:"middle",dominantBaseline:"middle",x:_.paddingX,y:m/2},t.name))}var _=l.forwardRef(function(o,t){var e=o.branch,r=o.commit,a=o.branchLabelX;if(!e.style.label.display)return null;if(!o.gitgraph.branchLabelOnEveryCommit){var s=o.gitgraph.refs.getCommit(e.name);if(r.hash!==s)return null}if(r.branchToDisplay!==e.name)return null;var i=e.renderLabel?e.renderLabel(e):l.createElement(Me,{branch:e,commit:r});if(o.gitgraph.isVertical)return l.createElement("g",{ref:t,transform:"translate("+(a||0)+", 0)"},i);var n=r.style.dot.size*2,m=10,c=n+m;return l.createElement("g",{ref:t,transform:"translate("+r.x+", "+c+")"},i)});_.paddingX=10;_.paddingY=5;var Ee=function(){var o=function(t,e){return o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,a){r.__proto__=a}||function(r,a){for(var s in a)a.hasOwnProperty(s)&&(r[s]=a[s])},o(t,e)};return function(t,e){o(t,e);function r(){this.constructor=t}t.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}}(),A=function(o){Ee(t,o);function t(){var e=o!==null&&o.apply(this,arguments)||this;return e.state={textWidth:0},e.$text=l.createRef(),e}return t.prototype.componentDidMount=function(){this.setState({textWidth:this.$text.current.getBBox().width})},t.prototype.render=function(){if(this.props.commit.renderTooltip)return this.props.commit.renderTooltip(this.props.commit);var e=this.props.commit.style.dot.size*2,r=10,a=t.padding,s=5,i=50,n=r+this.state.textWidth+2*a,m=["M 0,0","L "+r+","+r,"V "+(i/2-s),"Q "+r+","+i/2+" "+(r+s)+","+i/2,"H "+(n-s),"Q "+n+","+i/2+" "+n+","+(i/2-s),"V -"+(i/2-s),"Q "+n+",-"+i/2+" "+(n-s)+",-"+i/2,"H "+(r+s),"Q "+r+",-"+i/2+" "+r+",-"+(i/2-s),"V -"+r,"z"].join(" ");return l.createElement("g",{transform:"translate("+e+", "+e/2+")"},l.createElement("path",{d:m,fill:"#EEE"}),l.createElement("text",{ref:this.$text,x:r+a,y:0,alignmentBaseline:"central",fill:"#333"},this.props.children))},t.padding=10,t}(l.Component),Re=function(o){var t=o.commit,e=o.onMouseOver,r=o.onMouseOut;return t.renderDot?t.renderDot(t):l.createElement(l.Fragment,null,l.createElement("defs",null,l.createElement("circle",{id:t.hash,cx:t.style.dot.size,cy:t.style.dot.size,r:t.style.dot.size,fill:t.style.dot.color}),l.createElement("clipPath",{id:"clip-"+t.hash},l.createElement("use",{xlinkHref:"#"+t.hash}))),l.createElement("g",{onClick:t.onClick,onMouseOver:e,onMouseOut:r},l.createElement("use",{xlinkHref:"#"+t.hash,clipPath:"url(#clip-"+t.hash+")",stroke:t.style.dot.strokeColor,strokeWidth:t.style.dot.strokeWidth&&t.style.dot.strokeWidth*2}),t.dotText&&l.createElement("text",{alignmentBaseline:"central",textAnchor:"middle",x:t.style.dot.size,y:t.style.dot.size,style:{font:t.style.dot.font}},t.dotText)))},Be=function(){var o=function(t,e){return o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,a){r.__proto__=a}||function(r,a){for(var s in a)a.hasOwnProperty(s)&&(r[s]=a[s])},o(t,e)};return function(t,e){o(t,e);function r(){this.constructor=t}t.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}}(),Pe=function(o){Be(t,o);function t(){return o!==null&&o.apply(this,arguments)||this}return t.prototype.render=function(){var e=this,r=this.props.commits.find(function(s){var i=s.hash;return i===e.props.parentHash});if(!r)return null;var a=this.props.gitgraph.reverseArrow?{x:this.props.commitRadius+(r.x-this.props.commit.x),y:this.props.commitRadius+(r.y-this.props.commit.y)}:{x:this.props.commitRadius,y:this.props.commitRadius};return l.createElement("g",{transform:"translate("+a.x+", "+a.y+")"},l.createElement("path",{d:xe(this.props.gitgraph,r,this.props.commit),fill:this.props.gitgraph.template.arrow.color}))},t}(l.Component),Ae=l.forwardRef(function(o,t){var e=o.commit,r=o.messageX;if(e.renderMessage)return l.createElement("g",{ref:t,transform:"translate("+r+", 0)"},e.renderMessage(e));var a=null;e.body&&(a=l.createElement("foreignObject",{width:"600",x:"10"},l.createElement("p",null,e.body)));var s=e.style.dot.size;return l.createElement("g",{ref:t,transform:"translate("+r+", "+s+")"},l.createElement("text",{alignmentBaseline:"central",fill:e.style.message.color,style:{font:e.style.message.font},onClick:e.onMessageClick},e.message),a)}),L=10,Se=5;function Te(o){var t=l.useState({textWidth:0,textHeight:0}),e=t[0],r=t[1],a=l.useRef(null);l.useEffect(function(){var u=a.current.getBBox();r({textWidth:u.width,textHeight:u.height})},[]);var s=o.tag,i=s.style.pointerWidth,n=s.style.borderRadius,m=i+e.textWidth+2*L,c=e.textHeight+2*Se,h=["M 0,0","L "+i+","+c/2,"V "+c/2,"Q "+i+","+c/2+" "+(i+n)+","+c/2,"H "+(m-n),"Q "+m+","+c/2+" "+m+","+(c/2-n),"V "+-(c/2-n),"Q "+m+",-"+c/2+" "+(m-n)+",-"+c/2,"H "+(i+n),"Q "+i+",-"+c/2+" "+i+",-"+c/2,"V -"+c/2,"z"].join(" ");return l.createElement("g",null,l.createElement("path",{d:h,fill:s.style.bgColor,stroke:s.style.strokeColor}),l.createElement("text",{ref:a,fill:s.style.color,style:{font:s.style.font},alignmentBaseline:"middle",dominantBaseline:"middle",x:i+L,y:0},s.name))}var je=l.forwardRef(function(o,t){var e=o.tag,r=o.commit,a=o.tagX;return l.createElement("g",{ref:t,transform:"translate("+(a||0)+", "+r.style.dot.size+")"},e.render?e.render(e.name,e.style):l.createElement(Te,{tag:e}))}),$e=function(o){var t=o.commit,e=o.commits,r=o.gitgraph,a=o.commitMessagesX,s=l.useRef(),i=l.useRef([]),n=l.useRef(),m=l.useState(0),c=m[0],h=m[1],u=l.useState([]),f=u[0],g=u[1],y=l.useState(0),O=y[0],pt=y[1],bt=l.useMemo(function(){if(!r.template.arrow.size)return null;var v=t.style.dot.size;return t.parents.map(function(p){return l.createElement(Pe,{key:p,commits:e,commit:t,gitgraph:r,parentHash:p,commitRadius:v})})},[e,t,r]),yt=l.useMemo(function(){var v=Array.from(r.branches.values());return v.map(function(p){return l.createElement(_,{key:p.name,gitgraph:r,branch:p,commit:t,ref:s,branchLabelX:c})})},[r,t,c]),_t=l.useMemo(function(){return i.current=[],!t.tags||r.isHorizontal?null:t.tags.map(function(v,p){return l.createElement(je,{key:t.hashAbbrev+"-"+v.name,commit:t,tag:v,ref:function(U){return i.current[p]=U},tagX:f[p]||0})})},[t,r,f]),Q=o.getWithCommitOffset(t),G=Q.x,q=Q.y;l.useLayoutEffect(function(){if(!r.isHorizontal){var v=10,p=a;if(s.current){h(p);var U=s.current.getBBox().width+_.paddingX;p+=U+v}var Ot=i.current.map(function(J){if(!J)return 0;var Ct=p,wt=J.getBBox().width+L;return p+=wt+v,Ct});g(Ot),n.current&&pt(p)}},[i,r,a]);var vt=o.currentCommitOver===t&&(o.gitgraph.isHorizontal||o.gitgraph.mode===gt.Compact&&t.style.hasTooltipInCompactMode);return vt&&o.setTooltip(l.createElement("g",{transform:"translate("+G+", "+q+")"},l.createElement(A,{commit:t},t.hashAbbrev," - ",t.subject))),l.createElement("g",{transform:"translate("+G+", "+q+")"},l.createElement(Re,{commit:t,onMouseOver:function(){o.setCurrentCommitOver(t),t.onMouseOver()},onMouseOut:function(){o.setCurrentCommitOver(null),o.setTooltip(null),t.onMouseOut()}}),bt,l.createElement("g",{transform:"translate("+-G+", 0)"},t.style.message.display&&l.createElement(Ae,{commit:t,ref:n,messageX:O}),yt,_t))},De=function(){var o=function(t,e){return o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,a){r.__proto__=a}||function(r,a){for(var s in a)a.hasOwnProperty(s)&&(r[s]=a[s])},o(t,e)};return function(t,e){o(t,e);function r(){this.constructor=t}t.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}}(),ke=function(o){De(t,o);function t(){return o!==null&&o.apply(this,arguments)||this}return t.prototype.render=function(){var e=this;return l.createElement("path",{d:Ce(this.props.coordinates.map(function(r){return r.map(function(a){return e.props.getWithCommitOffset(a)})}),this.props.isBezier,this.props.gitgraph.isVertical),fill:"none",stroke:this.props.branch.computedColor,strokeWidth:this.props.branch.style.lineWidth,transform:"translate("+this.props.offset+", "+this.props.offset+")"})},t}(l.Component),He=function(){var o=function(t,e){return o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,a){r.__proto__=a}||function(r,a){for(var s in a)a.hasOwnProperty(s)&&(r[s]=a[s])},o(t,e)};return function(t,e){o(t,e);function r(){this.constructor=t}t.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}}();function nt(o){return"graph"in o}var ze=function(o){He(t,o);function t(e){var r=o.call(this,e)||this;return r.$graph=l.createRef(),r.$commits=l.createRef(),r.$tooltip=null,r.state={commits:[],branchesPaths:new Map,commitMessagesX:0,commitYWithOffsets:{},shouldRecomputeOffsets:!0,currentCommitOver:null},r.gitgraph=nt(e)?e.graph:new ce(e.options),r.gitgraph.subscribe(function(a){var s=a.commits,i=a.branchesPaths,n=a.commitMessagesX;r.setState({commits:s,branchesPaths:i,commitMessagesX:n,shouldRecomputeOffsets:!0})}),r}return t.prototype.render=function(){var e=this;return l.createElement("svg",{ref:this.$graph},l.createElement("g",{transform:"translate("+_.paddingX+", "+A.padding+")"},this.renderBranchesPaths(),l.createElement("g",{ref:this.$commits},this.state.commits.map(function(r){return l.createElement($e,{key:r.hash,commits:e.state.commits,commit:r,currentCommitOver:e.state.currentCommitOver,setCurrentCommitOver:e.setCurrentCommitOver.bind(e),gitgraph:e.gitgraph,getWithCommitOffset:e.getWithCommitOffset.bind(e),setTooltip:e.setTooltip.bind(e),commitMessagesX:e.state.commitMessagesX})})),this.$tooltip))},t.prototype.componentDidMount=function(){nt(this.props)||this.props.children(this.gitgraph.getUserApi())},t.prototype.componentDidUpdate=function(){if(this.$graph.current){var e=this.$graph.current.getBBox(),r=e.height,a=e.width;this.$graph.current.setAttribute("width",(a+A.padding+_.paddingX).toString()),this.$graph.current.setAttribute("height",(r+A.padding+_.paddingY).toString())}if(this.state.shouldRecomputeOffsets&&this.$commits.current){var s=Array.from(this.$commits.current.children);this.setState({commitYWithOffsets:this.computeOffsets(s),shouldRecomputeOffsets:!1})}},t.prototype.setCurrentCommitOver=function(e){this.setState({currentCommitOver:e})},t.prototype.setTooltip=function(e){this.$tooltip=e},t.prototype.renderBranchesPaths=function(){var e=this,r=this.gitgraph.template.commit.dot.size,a=this.gitgraph.template.branch.mergeStyle===be.Bezier;return Array.from(this.state.branchesPaths).map(function(s){var i=s[0],n=s[1];return l.createElement(ke,{key:i.name,gitgraph:e.gitgraph,branch:i,coordinates:n,getWithCommitOffset:e.getWithCommitOffset.bind(e),isBezier:a,offset:r})})},t.prototype.computeOffsets=function(e){var r=0,a=this.gitgraph.orientation===dt.VerticalReverse?e:e.reverse();return a.reduce(function(s,i){var n=parseInt(i.getAttribute("transform").split(",")[1].slice(0,-1),10),m=i.getElementsByTagName("foreignObject")[0],c=m&&m.firstElementChild,h=0;if(c){var u=c.getBoundingClientRect().height,f=window.getComputedStyle(c).marginTop||"0px",g=parseInt(f.replace("px",""),10);h=u+g}return m&&m.setAttribute("height",h+"px"),s[n]=n+r,r+=h,s},{})},t.prototype.getWithCommitOffset=function(e){var r=e.x,a=e.y;return{x:r,y:this.state.commitYWithOffsets[a]||a}},t.defaultProps={options:{}},t}(l.Component);const Ge=_e(ye.Metro,{colors:["#92d1fe","#E44354","#FFDD58","#4F953D","#B060CC"],branch:{lineWidth:6,spacing:60,label:{display:!0,bgColor:"transparent"}},commit:{spacing:85,dot:{size:8},message:{font:"normal 12pt Arial"}}});function Xe(o){const{children:t}=o;return N.jsx("div",{className:"git-graph-container",children:N.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 800 340",preserveAspectRatio:"xMidYMin slice",children:N.jsx(ze,{options:{mode:gt.Compact,orientation:dt.Horizontal,template:Ge},children:t})})})}export{Xe as G,N as j};