UNPKG

code-server

Version:

Run VS Code on a remote server.

122 lines (121 loc) • 29.3 kB
function T(i,t){let n=Math.pow(10,t);return Math.round(i*n)/n}var E=class{_rgbaBrand=void 0;r;g;b;a;constructor(t,n,s,e=1){this.r=Math.min(255,Math.max(0,t))|0,this.g=Math.min(255,Math.max(0,n))|0,this.b=Math.min(255,Math.max(0,s))|0,this.a=T(Math.max(Math.min(1,e),0),3)}static equals(t,n){return t.r===n.r&&t.g===n.g&&t.b===n.b&&t.a===n.a}},v=class i{_hslaBrand=void 0;h;s;l;a;constructor(t,n,s,e){this.h=Math.max(Math.min(360,t),0)|0,this.s=T(Math.max(Math.min(1,n),0),3),this.l=T(Math.max(Math.min(1,s),0),3),this.a=T(Math.max(Math.min(1,e),0),3)}static equals(t,n){return t.h===n.h&&t.s===n.s&&t.l===n.l&&t.a===n.a}static fromRGBA(t){let n=t.r/255,s=t.g/255,e=t.b/255,l=t.a,r=Math.max(n,s,e),o=Math.min(n,s,e),a=0,u=0,m=(o+r)/2,b=r-o;if(b>0){switch(u=Math.min(m<=.5?b/(2*m):b/(2-2*m),1),r){case n:a=(s-e)/b+(s<e?6:0);break;case s:a=(e-n)/b+2;break;case e:a=(n-s)/b+4;break}a*=60,a=Math.round(a)}return new i(a,u,m,l)}static _hue2rgb(t,n,s){return s<0&&(s+=1),s>1&&(s-=1),s<1/6?t+(n-t)*6*s:s<1/2?n:s<2/3?t+(n-t)*(2/3-s)*6:t}static toRGBA(t){let n=t.h/360,{s,l:e,a:l}=t,r,o,a;if(s===0)r=o=a=e;else{let u=e<.5?e*(1+s):e+s-e*s,m=2*e-u;r=i._hue2rgb(m,u,n+1/3),o=i._hue2rgb(m,u,n),a=i._hue2rgb(m,u,n-1/3)}return new E(Math.round(r*255),Math.round(o*255),Math.round(a*255),l)}},w=class i{_hsvaBrand=void 0;h;s;v;a;constructor(t,n,s,e){this.h=Math.max(Math.min(360,t),0)|0,this.s=T(Math.max(Math.min(1,n),0),3),this.v=T(Math.max(Math.min(1,s),0),3),this.a=T(Math.max(Math.min(1,e),0),3)}static equals(t,n){return t.h===n.h&&t.s===n.s&&t.v===n.v&&t.a===n.a}static fromRGBA(t){let n=t.r/255,s=t.g/255,e=t.b/255,l=Math.max(n,s,e),r=Math.min(n,s,e),o=l-r,a=l===0?0:o/l,u;return o===0?u=0:l===n?u=((s-e)/o%6+6)%6:l===s?u=(e-n)/o+2:u=(n-s)/o+4,new i(Math.round(u*60),a,l,t.a)}static toRGBA(t){let{h:n,s,v:e,a:l}=t,r=e*s,o=r*(1-Math.abs(n/60%2-1)),a=e-r,[u,m,b]=[0,0,0];return n<60?(u=r,m=o):n<120?(u=o,m=r):n<180?(m=r,b=o):n<240?(m=o,b=r):n<300?(u=o,b=r):n<=360&&(u=r,b=o),u=Math.round((u+a)*255),m=Math.round((m+a)*255),b=Math.round((b+a)*255),new E(u,m,b,l)}},R=class i{static fromHex(t){return i.Format.CSS.parseHex(t)||i.red}rgba;_hsla;get hsla(){return this._hsla?this._hsla:v.fromRGBA(this.rgba)}_hsva;get hsva(){return this._hsva?this._hsva:w.fromRGBA(this.rgba)}constructor(t){if(t)if(t instanceof E)this.rgba=t;else if(t instanceof v)this._hsla=t,this.rgba=v.toRGBA(t);else if(t instanceof w)this._hsva=t,this.rgba=w.toRGBA(t);else throw new Error("Invalid color ctor argument");else throw new Error("Color needs a value")}equals(t){return!!t&&E.equals(this.rgba,t.rgba)&&v.equals(this.hsla,t.hsla)&&w.equals(this.hsva,t.hsva)}getRelativeLuminance(){let t=i._relativeLuminanceForComponent(this.rgba.r),n=i._relativeLuminanceForComponent(this.rgba.g),s=i._relativeLuminanceForComponent(this.rgba.b),e=.2126*t+.7152*n+.0722*s;return T(e,4)}static _relativeLuminanceForComponent(t){let n=t/255;return n<=.03928?n/12.92:Math.pow((n+.055)/1.055,2.4)}getContrastRatio(t){let n=this.getRelativeLuminance(),s=t.getRelativeLuminance();return n>s?(n+.05)/(s+.05):(s+.05)/(n+.05)}isDarker(){return(this.rgba.r*299+this.rgba.g*587+this.rgba.b*114)/1e3<128}isLighter(){return(this.rgba.r*299+this.rgba.g*587+this.rgba.b*114)/1e3>=128}isLighterThan(t){let n=this.getRelativeLuminance(),s=t.getRelativeLuminance();return n>s}isDarkerThan(t){let n=this.getRelativeLuminance(),s=t.getRelativeLuminance();return n<s}lighten(t){return new i(new v(this.hsla.h,this.hsla.s,this.hsla.l+this.hsla.l*t,this.hsla.a))}darken(t){return new i(new v(this.hsla.h,this.hsla.s,this.hsla.l-this.hsla.l*t,this.hsla.a))}transparent(t){let{r:n,g:s,b:e,a:l}=this.rgba;return new i(new E(n,s,e,l*t))}isTransparent(){return this.rgba.a===0}isOpaque(){return this.rgba.a===1}opposite(){return new i(new E(255-this.rgba.r,255-this.rgba.g,255-this.rgba.b,this.rgba.a))}blend(t){let n=t.rgba,s=this.rgba.a,e=n.a,l=s+e*(1-s);if(l<1e-6)return i.transparent;let r=this.rgba.r*s/l+n.r*e*(1-s)/l,o=this.rgba.g*s/l+n.g*e*(1-s)/l,a=this.rgba.b*s/l+n.b*e*(1-s)/l;return new i(new E(r,o,a,l))}makeOpaque(t){if(this.isOpaque()||t.rgba.a!==1)return this;let{r:n,g:s,b:e,a:l}=this.rgba;return new i(new E(t.rgba.r-l*(t.rgba.r-n),t.rgba.g-l*(t.rgba.g-s),t.rgba.b-l*(t.rgba.b-e),1))}flatten(...t){let n=t.reduceRight((s,e)=>i._flatten(e,s));return i._flatten(this,n)}static _flatten(t,n){let s=1-t.rgba.a;return new i(new E(s*n.rgba.r+t.rgba.a*t.rgba.r,s*n.rgba.g+t.rgba.a*t.rgba.g,s*n.rgba.b+t.rgba.a*t.rgba.b))}_toString;toString(){return this._toString??=i.Format.CSS.format(this),this._toString}static getLighterColor(t,n,s){if(t.isLighterThan(n))return t;s=s||.5;let e=t.getRelativeLuminance(),l=n.getRelativeLuminance();return s=s*(l-e)/l,t.lighten(s)}static getDarkerColor(t,n,s){if(t.isDarkerThan(n))return t;s=s||.5;let e=t.getRelativeLuminance(),l=n.getRelativeLuminance();return s=s*(e-l)/e,t.darken(s)}static white=new i(new E(255,255,255,1));static black=new i(new E(0,0,0,1));static red=new i(new E(255,0,0,1));static blue=new i(new E(0,0,255,1));static green=new i(new E(0,255,0,1));static cyan=new i(new E(0,255,255,1));static lightgrey=new i(new E(211,211,211,1));static transparent=new i(new E(0,0,0,0))};(t=>{let i;(s=>{let n;(A=>{function e(_){return _.rgba.a===1?`rgb(${_.rgba.r}, ${_.rgba.g}, ${_.rgba.b})`:t.Format.CSS.formatRGBA(_)}A.formatRGB=e;function l(_){return`rgba(${_.rgba.r}, ${_.rgba.g}, ${_.rgba.b}, ${+_.rgba.a.toFixed(2)})`}A.formatRGBA=l;function r(_){return _.hsla.a===1?`hsl(${_.hsla.h}, ${(_.hsla.s*100).toFixed(2)}%, ${(_.hsla.l*100).toFixed(2)}%)`:t.Format.CSS.formatHSLA(_)}A.formatHSL=r;function o(_){return`hsla(${_.hsla.h}, ${(_.hsla.s*100).toFixed(2)}%, ${(_.hsla.l*100).toFixed(2)}%, ${_.hsla.a.toFixed(2)})`}A.formatHSLA=o;function a(_){let L=_.toString(16);return L.length!==2?"0"+L:L}function u(_){return`#${a(_.rgba.r)}${a(_.rgba.g)}${a(_.rgba.b)}`}A.formatHex=u;function m(_,L=!1){return L&&_.rgba.a===1?t.Format.CSS.formatHex(_):`#${a(_.rgba.r)}${a(_.rgba.g)}${a(_.rgba.b)}${a(Math.round(_.rgba.a*255))}`}A.formatHexA=m;function b(_){return _.isOpaque()?t.Format.CSS.formatHex(_):t.Format.CSS.formatRGBA(_)}A.format=b;function d(_){let L=_.length;if(L===0||_.charCodeAt(0)!==35)return null;if(L===7){let g=16*f(_.charCodeAt(1))+f(_.charCodeAt(2)),p=16*f(_.charCodeAt(3))+f(_.charCodeAt(4)),c=16*f(_.charCodeAt(5))+f(_.charCodeAt(6));return new t(new E(g,p,c,1))}if(L===9){let g=16*f(_.charCodeAt(1))+f(_.charCodeAt(2)),p=16*f(_.charCodeAt(3))+f(_.charCodeAt(4)),c=16*f(_.charCodeAt(5))+f(_.charCodeAt(6)),x=16*f(_.charCodeAt(7))+f(_.charCodeAt(8));return new t(new E(g,p,c,x/255))}if(L===4){let g=f(_.charCodeAt(1)),p=f(_.charCodeAt(2)),c=f(_.charCodeAt(3));return new t(new E(16*g+g,16*p+p,16*c+c))}if(L===5){let g=f(_.charCodeAt(1)),p=f(_.charCodeAt(2)),c=f(_.charCodeAt(3)),x=f(_.charCodeAt(4));return new t(new E(16*g+g,16*p+p,16*c+c,(16*x+x)/255))}return null}A.parseHex=d;function f(_){switch(_){case 48:return 0;case 49:return 1;case 50:return 2;case 51:return 3;case 52:return 4;case 53:return 5;case 54:return 6;case 55:return 7;case 56:return 8;case 57:return 9;case 97:return 10;case 65:return 10;case 98:return 11;case 66:return 11;case 99:return 12;case 67:return 12;case 100:return 13;case 68:return 13;case 101:return 14;case 69:return 14;case 102:return 15;case 70:return 15}return 0}})(n=s.CSS||={})})(i=t.Format||={})})(R||={});var H=[],q={"terminal.ansiBlack":{index:0},"terminal.ansiRed":{index:1},"terminal.ansiGreen":{index:2},"terminal.ansiYellow":{index:3},"terminal.ansiBlue":{index:4},"terminal.ansiMagenta":{index:5},"terminal.ansiCyan":{index:6},"terminal.ansiWhite":{index:7},"terminal.ansiBrightBlack":{index:8},"terminal.ansiBrightRed":{index:9},"terminal.ansiBrightGreen":{index:10},"terminal.ansiBrightYellow":{index:11},"terminal.ansiBrightBlue":{index:12},"terminal.ansiBrightMagenta":{index:13},"terminal.ansiBrightCyan":{index:14},"terminal.ansiBrightWhite":{index:15}};for(let i in q){let t=q[i],n=i.substring(13);H[t.index]={colorName:n,colorValue:"var(--vscode-"+i.replace(".","-")+")"}}var k=typeof window<"u"?window.trustedTypes?.createPolicy("notebookRenderer",{createHTML:i=>i,createScript:i=>i}):void 0;var j="\\u0000-\\u0020\\u007f-\\u009f",et=new RegExp("(?:[a-zA-Z][a-zA-Z0-9+.-]{2,}:\\/\\/|data:|www\\.)[^\\s"+j+'"]{2,}[^\\s'+j+`"')}\\],:;.!?]`,"ug"),it=/(?<=^|\s)(?:[a-zA-Z]:(?:(?:\\|\/)[\w\.-]*)+)/,st=/(?<=^|\s)(?:(?:\~|\.)(?:(?:\\|\/)[\w\.-]*)+)/,rt=new RegExp(`(${it.source}|${st.source})`),lt=/(?<=^|\s)((?:\~|\.)?(?:\/[\w\.-]*)+)/,ot=/(?:\:([\d]+))?(?:\:([\d]+))?/,ct=typeof navigator<"u"?navigator.userAgent&&navigator.userAgent.indexOf("Windows")>=0:!1,at=new RegExp(`${ct?rt.source:lt.source}${ot.source}`,"g"),ut=/<a\s+(?:[^>]*?\s+)?href=(["'])(.*?)\1[^>]*?>.*?<\/a>/gi,_t=2e3,B=class i{static injectedHtmlCreator;shouldGenerateHtml(t){return t&&(!!i.injectedHtmlCreator||!!k)}createHtml(t){return i.injectedHtmlCreator?i.injectedHtmlCreator(t):k?.createHTML(t).toString()}linkify(t,n,s){if(s){let l=t.split(` `);for(let a=0;a<l.length-1;a++)l[a]=l[a]+` `;l[l.length-1]||l.pop();let r=l.map(a=>this.linkify(a,n,!1));if(r.length===1)return r[0];let o=document.createElement("span");return r.forEach(a=>o.appendChild(a)),o}let e=document.createElement("span");for(let l of this.detectLinks(t,!!n.trustHtml,n.linkifyFilePaths))try{let r=null;switch(l.kind){case"text":e.appendChild(document.createTextNode(l.value));break;case"web":case"path":e.appendChild(this.createWebLink(l.value));break;case"html":r=document.createElement("span"),r.innerHTML=this.createHtml(l.value),e.appendChild(r);break}}catch{e.appendChild(document.createTextNode(l.value))}return e}createWebLink(t){let n=this.createLink(t);return n.href=t,n}createLink(t){let n=document.createElement("a");return n.textContent=t,n}detectLinks(t,n,s){if(t.length>_t)return[{kind:"text",value:t,captures:[]}];let e=[],l=[],r=[];this.shouldGenerateHtml(n)&&(e.push(ut),l.push("html")),e.push(et),l.push("web"),s&&(e.push(at),l.push("path"));let o=(a,u)=>{if(u>=e.length){r.push({value:a,kind:"text",captures:[]});return}let m=e[u],b=0,d;for(m.lastIndex=0;(d=m.exec(a))!==null;){let A=a.substring(b,d.index);A&&o(A,u+1);let _=d[0];r.push({value:_,kind:l[u],captures:d.slice(1)}),b=d.index+_.length}let f=a.substring(b);f&&o(f,u+1)};return o(t,0),r}},mt=new B;function X(i,t,n){return mt.linkify(i,t,n)}function D(i,t){let n=document.createElement("span"),s=i.length,e=[],l,r,o,a=!1,u=0,m="";for(;u<s;){let g=!1;if(i.charCodeAt(u)===27&&i.charAt(u+1)==="["){let p=u;u+=2;let c="";for(;u<s;){let x=i.charAt(u);if(c+=x,u++,x.match(/^[ABCDHIJKfhmpsu]$/)){g=!0;break}}if(g){if(J(n,m,t,e,l,r,o),m="",c.match(/^(?:[34][0-8]|9[0-7]|10[0-7]|[0-9]|2[1-5,7-9]|[34]9|5[8,9]|1[0-9])(?:;[349][0-7]|10[0-7]|[013]|[245]|[34]9)?(?:;[012]?[0-9]?[0-9])*;?m$/)){let x=c.slice(0,-1).split(";").filter(U=>U!=="").map(U=>parseInt(U,10));if(x[0]===38||x[0]===48||x[0]===58){let U=x[0]===38?"foreground":x[0]===48?"background":"underline";x[1]===5?_(x,U):x[1]===2&&A(x,U)}else f(x)}}else u=p}g===!1&&(m+=i.charAt(u),u++)}return m&&J(n,m,t,e,l,r,o),n;function b(g,p){g==="foreground"?l=p:g==="background"?r=p:g==="underline"&&(o=p),e=e.filter(c=>c!==`code-${g}-colored`),p!==void 0&&e.push(`code-${g}-colored`)}function d(){let g=l;b("foreground",r),b("background",g)}function f(g){for(let p of g)switch(p){case 0:{e=[],l=void 0,r=void 0;break}case 1:{e=e.filter(c=>c!=="code-bold"),e.push("code-bold");break}case 2:{e=e.filter(c=>c!=="code-dim"),e.push("code-dim");break}case 3:{e=e.filter(c=>c!=="code-italic"),e.push("code-italic");break}case 4:{e=e.filter(c=>c!=="code-underline"&&c!=="code-double-underline"),e.push("code-underline");break}case 5:{e=e.filter(c=>c!=="code-blink"),e.push("code-blink");break}case 6:{e=e.filter(c=>c!=="code-rapid-blink"),e.push("code-rapid-blink");break}case 7:{a||(a=!0,d());break}case 8:{e=e.filter(c=>c!=="code-hidden"),e.push("code-hidden");break}case 9:{e=e.filter(c=>c!=="code-strike-through"),e.push("code-strike-through");break}case 10:{e=e.filter(c=>!c.startsWith("code-font"));break}case 11:case 12:case 13:case 14:case 15:case 16:case 17:case 18:case 19:case 20:{e=e.filter(c=>!c.startsWith("code-font")),e.push(`code-font-${p-10}`);break}case 21:{e=e.filter(c=>c!=="code-underline"&&c!=="code-double-underline"),e.push("code-double-underline");break}case 22:{e=e.filter(c=>c!=="code-bold"&&c!=="code-dim");break}case 23:{e=e.filter(c=>c!=="code-italic"&&c!=="code-font-10");break}case 24:{e=e.filter(c=>c!=="code-underline"&&c!=="code-double-underline");break}case 25:{e=e.filter(c=>c!=="code-blink"&&c!=="code-rapid-blink");break}case 27:{a&&(a=!1,d());break}case 28:{e=e.filter(c=>c!=="code-hidden");break}case 29:{e=e.filter(c=>c!=="code-strike-through");break}case 53:{e=e.filter(c=>c!=="code-overline"),e.push("code-overline");break}case 55:{e=e.filter(c=>c!=="code-overline");break}case 39:{b("foreground",void 0);break}case 49:{b("background",void 0);break}case 59:{b("underline",void 0);break}case 73:{e=e.filter(c=>c!=="code-superscript"&&c!=="code-subscript"),e.push("code-superscript");break}case 74:{e=e.filter(c=>c!=="code-superscript"&&c!=="code-subscript"),e.push("code-subscript");break}case 75:{e=e.filter(c=>c!=="code-superscript"&&c!=="code-subscript");break}default:{L(p);break}}}function A(g,p){if(g.length>=5&&g[2]>=0&&g[2]<=255&&g[3]>=0&&g[3]<=255&&g[4]>=0&&g[4]<=255){let c=new E(g[2],g[3],g[4]);b(p,c)}}function _(g,p){let c=g[2],x=gt(c);if(x)b(p,x);else if(c>=0&&c<=15){if(p==="underline"){b(p,H[c].colorValue);return}c+=30,c>=38&&(c+=52),p==="background"&&(c+=10),L(c)}}function L(g){let p,c;g>=30&&g<=37?(c=g-30,p="foreground"):g>=90&&g<=97?(c=g-90+8,p="foreground"):g>=40&&g<=47?(c=g-40,p="background"):g>=100&&g<=107&&(c=g-100+8,p="background"),c!==void 0&&p&&b(p,H[c]?.colorValue)}}function J(i,t,n,s,e,l,r){if(!i||!t)return;let o=document.createElement("span");o.childElementCount===0&&(o=X(t,n,!0)),o.className=s.join(" "),e&&(o.style.color=typeof e=="string"?e:R.Format.CSS.formatRGB(new R(e))),l&&(o.style.backgroundColor=typeof l=="string"?l:R.Format.CSS.formatRGB(new R(l))),r&&(o.style.textDecorationColor=typeof r=="string"?r:R.Format.CSS.formatRGB(new R(r))),i.appendChild(o)}function gt(i){if(i%1===0)if(i>=16&&i<=231){i-=16;let t=i%6;i=(i-t)/6;let n=i%6;i=(i-n)/6;let s=i,e=255/5;return t=Math.round(t*e),n=Math.round(n*e),s=Math.round(s*e),new E(s,n,t)}else if(i>=232&&i<=255){i-=232;let t=Math.round(i/23*255);return new E(t,t,t)}else return}var y="scrollable",F=5e3,bt=8e3;function pt(i){let t=document.createElement("div");t.classList.add("truncation-message");let n=document.createElement("span");n.textContent="Output is truncated. View as a ",t.appendChild(n);let s=document.createElement("a");s.textContent="scrollable element",s.href=`command:cellOutput.enableScrolling?${i}`,s.ariaLabel="enable scrollable output",t.appendChild(s);let e=document.createElement("span");e.textContent=" or open in a ",t.appendChild(e);let l=document.createElement("a");l.textContent="text editor",l.href=`command:workbench.action.openLargeOutput?${i}`,l.ariaLabel="open output in text editor",t.appendChild(l);let r=document.createElement("span");r.textContent=". Adjust cell output ",t.appendChild(r);let o=document.createElement("a");o.textContent="settings",o.href="command:workbench.action.openSettings?%5B%22%40tag%3AnotebookOutputLayout%22%5D",o.ariaLabel="notebook output settings",t.appendChild(o);let a=document.createElement("span");return a.textContent="...",t.appendChild(a),t}function ft(i){let t=document.createElement("div"),n=document.createElement("a");return n.textContent="...",n.href=`command:workbench.action.openLargeOutput?${i}`,n.ariaLabel="Open full output in text editor",n.title="Open full output in text editor",n.style.setProperty("text-decoration","none"),t.appendChild(n),t}function Et(i,t,n,s){let e=document.createElement("div");e.setAttribute("data-vscode-context",JSON.stringify({webviewSection:"text",outputId:i,preventDefaultContextMenuItems:!0}));let l=t.length;if(l<=n){let o=D(t.join(` `),s);return e.appendChild(o),e}e.appendChild(D(t.slice(0,n-5).join(` `),s));let r=document.createElement("div");return r.innerText="...",e.appendChild(r),e.appendChild(D(t.slice(l-5).join(` `),s)),e.appendChild(pt(i)),e}function xt(i,t,n){let s=document.createElement("div");return s.setAttribute("data-vscode-context",JSON.stringify({webviewSection:"text",outputId:i,preventDefaultContextMenuItems:!0})),t.length>F&&s.appendChild(ft(i)),s.appendChild(D(t.slice(-1*F).join(` `),n)),s}var O={};function Lt(i,t,n,s){O[t]||(O[t]=0);let e=n.split(/\r\n|\r|\n/g),l=e.length+O[t];return l>bt?!1:(i.appendChild(D(e.join(` `),s)),O[t]=l,!0)}function S(i,t,n){let{linesLimit:s,error:e,scrollable:l,trustHtml:r,linkifyFilePaths:o}=n,a={linkifyFilePaths:o,trustHtml:r},u=t.split(/\r\n|\r|\n/g);O[i]=O[i]=Math.min(u.length,F);let m;return l?m=xt(i,u,a):m=Et(i,u,s,a),m.setAttribute("output-item-id",i),e&&m.classList.add("error"),m}function G(i,t,n){let s=i.appendedText?.(),e={linkifyFilePaths:n.linkifyFilePaths,trustHtml:n.trustHtml};if(s&&n.scrollable&&Lt(t,i.id,s,e))return;let l=S(i.id,i.text(),n);for(t.replaceWith(l);l.nextSibling;)l.nextSibling.remove()}function Y(i,t){let n;return n=i.replace(/\u001b\[4\dm/g,""),n=n.replace(/(?<=\u001b\[[\d;]*?);4\d(?=m)/g,""),n=n.replace(/\u001b\[38;.*?\d+m/g,"\x1B[39m"),n=n.replace(/(;32m[ ->]*?)(\d+)(.*)\n/g,(s,e,l,r)=>(r=r.replace(/\u001b\[3\d+m/g,"\x1B[39m"),`${e}${l}${r} `)),At(n)&&t?Rt(n):{formattedStack:n}}var dt=/\u001b\[.+?m/g,P=/File\s+(?:\u001b\[.+?m)?(.+):(\d+)/,z=/(-+>(?:\u001b\[[\d;]*m|\s)*)(\d+)(.*)/,I=/^(?<prefix>(?:\u001b\[[\d;]*m|\s)*Cell(?:\u001b\[[\d;]*m|\s)*In(?:\u001b\[[\d;]*m|\s)*\[(?<executionCount>\d+)\](?:\u001b\[[\d;]*m|\s|,)+)(?<lineLabel>line (?<lineNumber>\d+))[^\n]*$/m,M=/(?<prefix>Input\s+?(?:\u001b\[.+?m)(?<cellLabel>In\s*\[(?<executionCount>\d+)\]))(?<postfix>.*)/;function At(i){return I.test(i)||M.test(i)||P.test(i)}function N(i){return i.replace(dt,"").trim()}function Rt(i){let t=i.split(` `),n,s="";for(let l in t){let r=t[l];if(P.test(r)){let o=t[l].match(P);n={kind:"file",path:N(o[1])};continue}else if(I.test(r)){n={kind:"cell",path:N(r.replace(I,"vscode-notebook-cell:?execution_count=$<executionCount>"))};let o=r.replace(I,`<a href='${n.path}&line=$<lineNumber>'>line $<lineNumber></a>`);t[l]=r.replace(I,`$<prefix>${o}`),s=s||o;continue}else if(M.test(r)){n={kind:"cell",path:N(r.replace(M,"vscode-notebook-cell:?execution_count=$<executionCount>"))};let o=r.replace(M,`<a href='${n.path}'>$<cellLabel></a>`);t[l]=r.replace(M,`Input ${o}$<postfix>`);continue}else if(!n||r.trim()===""){n=void 0;continue}else if(z.test(r)){t[l]=r.replace(z,(o,a,u,m)=>n?.kind==="file"?`${a}<a href='${n?.path}:${u}'>${u}</a>${m}`:`${a}<a href='${n?.path}&line=${u}'>${u}</a>${m}`);continue}}let e=s;return{formattedStack:t.join(` `),errorLocation:e}}function $(i){for(;i.firstChild;)i.firstChild.remove()}function vt(i,t){let n=new Blob([i.data()],{type:i.mime}),s=URL.createObjectURL(n),e={dispose:()=>{URL.revokeObjectURL(s)}};if(t.firstChild){let a=t.firstChild;if(a.firstChild&&a.firstChild.nodeName==="IMG"&&a.firstChild instanceof HTMLImageElement)return a.firstChild.src=s,e}let l=document.createElement("img");l.src=s;let r=nt(i);r&&(l.alt=r),l.setAttribute("data-vscode-context",JSON.stringify({webviewSection:"image",outputId:i.id,preventDefaultContextMenuItems:!0}));let o=document.createElement("div");return o.classList.add("display"),o.appendChild(l),t.appendChild(o),e}var Tt=["type","src","nonce","noModule","async"],tt=i=>{let t=Array.from(i.getElementsByTagName("script"));for(let n=0;n<t.length;n++){let s=t[n],e=document.createElement("script"),l=k?.createScript(s.innerText)??s.innerText;e.text=l;for(let r of Tt){let o=s[r]||s.getAttribute&&s.getAttribute(r);o&&e.setAttribute(r,o)}i.appendChild(e).parentNode.removeChild(e)}};function nt(i){let t=i.metadata;if(typeof t=="object"&&t&&typeof t.vscode_altText=="string")return t.vscode_altText}function kt(i,t){if(i.mime.indexOf("svg")>-1){let n=t.querySelector("svg"),s=nt(i);if(n&&s){let e=document.createElement("title");e.innerText=s,n.prepend(e)}n&&(n.classList.add("output-image"),n.setAttribute("data-vscode-context",JSON.stringify({webviewSection:"image",outputId:i.id,preventDefaultContextMenuItems:!0})))}}async function Ut(i,t,n,s){$(t);let e=document.createElement("div"),l=i.text(),r=k?.createHTML(l)??l;e.innerHTML=r,kt(i,e);for(let o of s)if(e=await o.postRender(i,e,n)??e,n.aborted)return;t.appendChild(e),tt(e)}async function wt(i,t,n,s){let e=i.text();for(let a of s)if(e=await a.preEvaluate(i,t,e,n)??e,n.aborted)return;let l=document.createElement("script");l.type="module",l.textContent=e;let r=document.createElement("div"),o=k?.createHTML(l.outerHTML)??l.outerHTML;r.innerHTML=o,t.appendChild(r),tt(r)}function W(){let i=[];return{push:(...n)=>{i.push(...n)},dispose:()=>{i.forEach(n=>n.dispose())}}}function Dt(i,t,n,s){let e=W();$(t);let l;try{l=JSON.parse(i.text())}catch(o){return console.log(o),e}let r=l.name&&l.message?`${l.name}: ${l.message}`:l.name||l.message;if(l.stack){let o=n.settings.minimalError&&!!r?.length;t.classList.add("traceback");let{formattedStack:a,errorLocation:u}=Y(l.stack,s),m=!o&&V(i,n.settings),d={linesLimit:o?1e3:n.settings.lineLimit,scrollable:m,trustHtml:s,linkifyFilePaths:!1},f=S(i.id,a,d),A=document.createElement("div");A.appendChild(f),t.classList.toggle("word-wrap",n.settings.outputWordWrap),e.push(n.onDidChangeSettings(_=>{t.classList.toggle("word-wrap",_.outputWordWrap)})),o?Ot(u,r,A,t):(A.classList.toggle("scrollable",m),t.appendChild(A),K(A,e))}else{let o=document.createElement("div");r&&(o.innerText=r,t.appendChild(o))}return t.classList.add("error"),e}function Ot(i,t,n,s){let e=document.createElement("div"),l=document.createElement("div");l.classList.add("error-output-header"),i&&i.indexOf("<a")===0&&(l.innerHTML=i);let r=document.createElement("span");r.innerText=t,l.appendChild(r),e.appendChild(l);function o(m){let b=document.createElement("li");return b.appendChild(m),b.onmouseover=function(){b.classList.add("hover")},b.onmouseout=function(){b.classList.remove("hover")},b}let a=document.createElement("ul");a.classList.add("error-output-actions"),e.appendChild(a);let u=document.createElement("a");u.innerText="Show Details",u.href="#!",a.appendChild(o(u)),u.onclick=m=>{m.preventDefault();let b=n.style.display==="none";n.style.display=b?"":"none",u.innerText=b?"Hide Details":"Show Details"},e.appendChild(n),n.style.display="none",s.appendChild(e)}function St(i){let t=i.parentElement,n,s=t?.previousSibling;for(;s;){let e=s.firstChild;if(!e||!e.classList.contains("output-stream"))break;n=e.firstChild,s=s?.previousSibling}return n}function Z(i){let t=i.target;t.scrollTop===0?t.classList.remove("more-above"):t.classList.add("more-above")}function Q(i){i.ctrlKey||i.shiftKey||(i.code==="ArrowDown"||i.code==="ArrowUp"||i.code==="End"||i.code==="Home"||i.code==="PageUp"||i.code==="PageDown")&&i.stopPropagation()}function K(i,t,n){if(i.classList.contains(y)){let s=i.scrollHeight>i.clientHeight;i.classList.toggle("scrollbar-visible",s),i.scrollTop=n!==void 0?n:i.scrollHeight,s&&(i.addEventListener("scroll",Z),t.push({dispose:()=>i.removeEventListener("scroll",Z)}),i.addEventListener("keydown",Q),t.push({dispose:()=>i.removeEventListener("keydown",Q)}))}}function It(i){let t=i.querySelector("."+y);if(t&&t.scrollHeight-t.scrollTop-t.clientHeight>2)return t.scrollTop}function V(i,t){let n=i.metadata;return typeof n=="object"&&n&&typeof n.scrollable=="boolean"?n.scrollable:t.outputScrolling}function h(i,t,n,s){let e=W(),l=V(i,s.settings),r={linesLimit:s.settings.lineLimit,scrollable:l,trustHtml:!1,error:n,linkifyFilePaths:s.settings.linkifyFilePaths};t.classList.add("output-stream");let o=l?It(t):void 0,a=St(t);if(a){let u=a.querySelector(`[output-item-id="${i.id}"]`);if(u)G(i,u,r);else{let m=S(i.id,i.text(),r);a.appendChild(m)}a.classList.toggle("scrollbar-visible",a.scrollHeight>a.clientHeight),a.scrollTop=o!==void 0?o:a.scrollHeight}else{let u=t.querySelector(`[output-item-id="${i.id}"]`),m=u?.parentElement;if(u&&m)G(i,u,r);else{let b=S(i.id,i.text(),r);for(m=document.createElement("div"),m.appendChild(b);t.firstChild;)t.firstChild.remove();t.appendChild(m)}m.classList.toggle("scrollable",l),t.classList.toggle("word-wrap",s.settings.outputWordWrap),e.push(s.onDidChangeSettings(b=>{t.classList.toggle("word-wrap",b.outputWordWrap)})),K(m,e,o)}return e}function C(i,t,n){let s=W();$(t);let e=i.text(),l=V(i,n.settings),r={linesLimit:n.settings.lineLimit,scrollable:l,trustHtml:!1,linkifyFilePaths:n.settings.linkifyFilePaths},o=S(i.id,e,r);return o.classList.add("output-plaintext"),o.classList.toggle("word-wrap",n.settings.outputWordWrap),s.push(n.onDidChangeSettings(a=>{o.classList.toggle("word-wrap",a.outputWordWrap)})),o.classList.toggle("scrollable",l),t.appendChild(o),K(o,s),s}var zt=i=>{let t=new Map,n=new Set,s=new Set,e=i,l=document.createElement("style");return l.textContent=` #container div.output.remove-padding { padding-left: 0; padding-right: 0; } .output-plaintext, .output-stream, .traceback { display: inline-block; width: 100%; line-height: var(--notebook-cell-output-line-height); font-family: var(--notebook-cell-output-font-family); font-size: var(--notebook-cell-output-font-size); user-select: text; -webkit-user-select: text; -ms-user-select: text; cursor: auto; word-wrap: break-word; /* text/stream output container should scroll but preserve newline character */ white-space: pre; } /* When wordwrap turned on, force it to pre-wrap */ #container div.output_container .word-wrap { white-space: pre-wrap; } #container div.output>div { padding-left: var(--notebook-output-node-left-padding); padding-right: var(--notebook-output-node-padding); box-sizing: border-box; border-width: 1px; border-style: solid; border-color: transparent; } #container div.output>div:focus { outline: 0; border-color: var(--theme-input-focus-border-color); } #container div.output .scrollable { overflow-y: auto; max-height: var(--notebook-cell-output-max-height); } #container div.output .scrollable.scrollbar-visible { border-color: var(--vscode-editorWidget-border); } #container div.output .scrollable.scrollbar-visible:focus { border-color: var(--theme-input-focus-border-color); } #container div.truncation-message { font-style: italic; font-family: var(--theme-font-family); padding-top: 4px; } #container div.output .scrollable div { cursor: text; } #container div.output .scrollable div a { cursor: pointer; } #container div.output .scrollable.more-above { box-shadow: var(--vscode-scrollbar-shadow) 0 6px 6px -6px inset } .output-plaintext .code-bold, .output-stream .code-bold, .traceback .code-bold { font-weight: bold; } .output-plaintext .code-italic, .output-stream .code-italic, .traceback .code-italic { font-style: italic; } .output-plaintext .code-strike-through, .output-stream .code-strike-through, .traceback .code-strike-through { text-decoration: line-through; } .output-plaintext .code-underline, .output-stream .code-underline, .traceback .code-underline { text-decoration: underline; } #container ul.error-output-actions { margin: 0px; padding: 6px 0px 0px 6px; padding-inline-start: 0px; } #container .error-output-actions li { padding: 0px 4px 0px 4px; border-radius: 5px; height: 20px; display: inline-flex; cursor: pointer; border: solid 1px var(--vscode-notebook-cellToolbarSeparator); } #container .error-output-actions li.hover { background-color: var(--vscode-toolbar-hoverBackground); } #container .error-output-actions li:focus-within { border-color: var(--theme-input-focus-border-color); } #container .error-output-actions a:focus { outline: 0; } #container .error-output-actions li a { color: var(--vscode-foreground); text-decoration: none; } #container .error-output-header a { padding-right: 12px; } `,document.body.appendChild(l),{renderOutputItem:async(r,o,a)=>{switch(o.classList.add("remove-padding"),r.mime){case"text/html":case"image/svg+xml":{if(!i.workspace.isTrusted)return;await Ut(r,o,a,n);break}case"application/javascript":{if(!i.workspace.isTrusted)return;wt(r,o,a,s);break}case"image/gif":case"image/png":case"image/jpeg":case"image/git":{t.get(r.id)?.dispose();let u=vt(r,o);t.set(r.id,u)}break;case"application/vnd.code.notebook.error":{t.get(r.id)?.dispose();let u=Dt(r,o,e,i.workspace.isTrusted);t.set(r.id,u)}break;case"application/vnd.code.notebook.stdout":case"application/x.notebook.stdout":case"application/x.notebook.stream":{t.get(r.id)?.dispose();let u=h(r,o,!1,e);t.set(r.id,u)}break;case"application/vnd.code.notebook.stderr":case"application/x.notebook.stderr":{t.get(r.id)?.dispose();let u=h(r,o,!0,e);t.set(r.id,u)}break;case"text/plain":{t.get(r.id)?.dispose();let u=C(r,o,e);t.set(r.id,u)}break;default:if(r.mime.indexOf("text/")>-1){t.get(r.id)?.dispose();let u=C(r,o,e);t.set(r.id,u)}break}o.querySelector("div")&&(o.querySelector("div").tabIndex=0)},disposeOutputItem:r=>{r?t.get(r)?.dispose():t.forEach(o=>o.dispose())},experimental_registerHtmlRenderingHook:r=>(n.add(r),{dispose:()=>{n.delete(r)}}),experimental_registerJavaScriptRenderingHook:r=>(s.add(r),{dispose:()=>{s.delete(r)}})}};export{zt as activate};