// ansi_up.js
// version : 1.3.0
// author : Dru Nelson
// license : MIT
// http://github.com/drudru/ansi_up
!function(r,t){function n(){this.fg=this.bg=this.fg_truecolor=this.bg_truecolor=null,this.bright=0}var o,s,e="undefined"!=typeof module,i=[[{color:"27, 27, 27","class":"ansi-black"},{color:"182, 80, 47","class":"ansi-red"},{color:"141, 161, 88","class":"ansi-green"},{color:"220, 175, 95","class":"ansi-yellow"},{color:"126, 170, 199","class":"ansi-blue"},{color:"176, 101, 152","class":"ansi-magenta"},{color:"141, 220, 217","class":"ansi-cyan"},{color:"217, 217, 217","class":"ansi-white"}],[{color:"27, 27, 27","class":"ansi-bright-black"},{color:"182, 80, 47","class":"ansi-bright-red"},{color:"141, 161, 88","class":"ansi-bright-green"},{color:"220, 175, 95","class":"ansi-bright-yellow"},{color:"126, 170, 199","class":"ansi-bright-blue"},{color:"176, 101, 152","class":"ansi-bright-magenta"},{color:"141, 220, 217","class":"ansi-bright-cyan"},{color:"217, 217, 217","class":"ansi-bright-white"}]];n.prototype.setup_palette=function(){s=[],function(){var r,t;for(r=0;2>r;++r)for(t=0;8>t;++t)s.push(i[r][t].color)}(),function(){var r,t,n,o=[0,95,135,175,215,255],e=function(r,t,n){return o[r]+", "+o[t]+", "+o[n]};for(r=0;6>r;++r)for(t=0;6>t;++t)for(n=0;6>n;++n)s.push(e.call(this,r,t,n))}(),function(){var r,t=8,n=function(r){return r+", "+r+", "+r};for(r=0;24>r;++r,t+=10)s.push(n.call(this,t))}()},n.prototype.escape_for_html=function(r){return r.replace(/[&<>]/gm,function(r){return"&"==r?"&":"<"==r?"<":">"==r?">":t})},n.prototype.linkify=function(r){return r.replace(/(https?:\/\/[^\s]+)/gm,function(r){return''+r+""})},n.prototype.ansi_to_html=function(r,t){return this.process(r,t,!0)},n.prototype.ansi_to_text=function(r){var t={};return this.process(r,t,!1)},n.prototype.process=function(r,t,n){var o=this,s=r.split(/\033\[/),e=s.shift(),i=s.map(function(r){return o.process_chunk(r,t,n)});return i.unshift(e),i.join("")},n.prototype.process_chunk=function(r,n,o){n=t===n?{}:n;var e=t!==n.use_classes&&n.use_classes,l=e?"class":"color",a=r.match(/^([!\x3c-\x3f]*)([\d;]*)([\x20-\x2c]*[\x40-\x7e])([\s\S]*)/m);if(!a)return r;var c=a[4],u=a[2].split(";");if(""!==a[1]||"m"!==a[3])return c;if(!o)return c;for(var f=this;u.length>0;){var g=u.shift(),h=parseInt(g);isNaN(h)||0===h?(f.fg=f.bg=null,f.bright=0):1===h?f.bright=1:39==h?f.fg=null:49==h?f.bg=null:h>=30&&38>h?f.fg=i[f.bright][h%10][l]:h>=90&&98>h?f.fg=i[1][h%10][l]:h>=40&&48>h?f.bg=i[0][h%10][l]:h>=100&&108>h?f.bg=i[1][h%10][l]:(38===h||48===h)&&!function(){var r=38===h;if(u.length>=1){var t=u.shift();if("5"!==t||u.length<1){if("2"===t&&u.length>=3){var n=parseInt(u.shift()),o=parseInt(u.shift()),l=parseInt(u.shift());if(!(0>n||n>255||0>o||o>255||0>l||l>255)){var a=n+", "+o+", "+l;e?r?(f.fg="ansi-truecolor",f.fg_truecolor=a):(f.bg="ansi-truecolor",f.bg_truecolor=a):r?f.fg=a:f.bg=a}}}else{var c=parseInt(u.shift());if(c>=0&&255>=c)if(e){var g=16>c?i[c>7?1:0][c%8]["class"]:"ansi-palette-"+c;r?f.fg=g:f.bg=g}else s||f.setup_palette.call(f),r?f.fg=s[c]:f.bg=s[c]}}}()}if(null===f.fg&&null===f.bg)return c;var p=[],_=[],b={},v=function(r){var t,n=[];for(t in r)r.hasOwnProperty(t)&&n.push("data-"+t+'="'+this.escape_for_html(r[t])+'"');return n.length>0?" "+n.join(" "):""};return f.fg&&(e?(_.push(f.fg+"-fg"),null!==f.fg_truecolor&&(b["ansi-truecolor-fg"]=f.fg_truecolor,f.fg_truecolor=null)):p.push("color:rgb("+f.fg+")")),f.bg&&(e?(_.push(f.bg+"-bg"),null!==f.bg_truecolor&&(b["ansi-truecolor-bg"]=f.bg_truecolor,f.bg_truecolor=null)):p.push("background-color:rgb("+f.bg+")")),e?'"+c+"":'"+c+""},o={escape_for_html:function(r){var t=new n;return t.escape_for_html(r)},linkify:function(r){var t=new n;return t.linkify(r)},ansi_to_html:function(r,t){var o=new n;return o.ansi_to_html(r,t)},ansi_to_text:function(r){var t=new n;return t.ansi_to_text(r)},ansi_to_html_obj:function(){return new n}},e&&(module.exports=o),"undefined"!=typeof window&&"undefined"==typeof ender&&(window.ansi_up=o),"function"==typeof define&&define.amd&&define("ansi_up",[],function(){return o})}(Date);