import"./lib/gitgraphjs/src/gitgraph.js";import{LitElement as t,html as e,css as r}from"../../lit/index.js";class LrnGitgraph extends t{static get styles(){return[r`
        :host {
          display: block;
          overflow-x: scroll;
        }
      `]}render(){return e` <canvas id="gitGraph"></canvas> `}static get tag(){return"lrn-gitgraph"}constructor(){super(),this.commits=[],this.template="blackarrow",this.orientation="horizontal",this.mode="",this.reverseArrow=!1}static get properties(){return{commits:{type:Array},template:{type:String},orientation:{type:String},mode:{type:String},reverseArrow:{type:Boolean,attribute:"reverse-arrow"},config:{type:Object}}}updated(t){super.updated&&super.updated(t),t.has("commits")&&this._commitsChanged(this.commits)}_commitsChanged(t){var e=this;if(e.config&&t.length>0){var r=new GitGraph(e.config),i=[];t.forEach((function(t){t.commits&&t.commits.forEach((function(e){e.branch=t.branch,i.push(e)}))})),(i=(i=e._treeRemoveDuplicates(i)).sort((function(t,e){return new Date(e.date)-new Date(t.date)}))).reverse();var a=[];i.forEach((function(t,e){void 0===a[t.branch]&&(a[t.branch]=r.branch(t.branch)),a[t.branch].commit({sha1:t.commit,message:t.subject,author:t.author,tag:t.refs})}))}}_treeRemoveDuplicates(t){var e=[],r=[];return t.forEach((function(t){r.includes(t.commit)||(e.push(t),r.push(t.commit))})),e}firstUpdated(t){super.firstUpdated(t);var e={template:this.template,reverseArrow:!1,orientation:this.orientation,element:this.shadowRoot.querySelector("#gitGraph")};""!==this.mode&&(e.mode=this.mode),this.config=e}}customElements.define(LrnGitgraph.tag,LrnGitgraph);export{LrnGitgraph};