code-server
Version:
Run VS Code on a remote server.
4 lines (3 loc) • 25.5 kB
JavaScript
var dt=(e,t)=>()=>{try{return t||e((t={exports:{}}).exports,t),t.exports}catch(n){throw t=0,n}};var _e=dt((yn,Ye)=>{var je="Expected a function",Ue=NaN,At="[object Symbol]",xt=/^\s+|\s+$/g,Nt=/^[-+]0x[0-9a-f]+$/i,Pt=/^0b[01]+$/i,kt=/^0o[0-7]+$/i,It=parseInt,Dt=typeof global=="object"&&global&&global.Object===Object&&global,Ht=typeof self=="object"&&self&&self.Object===Object&&self,Bt=Dt||Ht||Function("return this")(),Ot=Object.prototype,Rt=Ot.toString,Ft=Math.max,Vt=Math.min,Ce=function(){return Bt.Date.now()};function Wt(e,t,n){var r,i,o,a,s,l,f=0,y=!1,b=!1,A=!0;if(typeof e!="function")throw new TypeError(je);t=qe(t)||0,se(n)&&(y=!!n.leading,b="maxWait"in n,o=b?Ft(qe(n.maxWait)||0,t):o,A="trailing"in n?!!n.trailing:A);function R(g){var E=r,H=i;return r=i=void 0,f=g,a=e.apply(H,E),a}function ce(g){return f=g,s=setTimeout(L,t),y?R(g):a}function $(g){var E=g-l,H=g-f,B=t-E;return b?Vt(B,o-H):B}function F(g){var E=g-l,H=g-f;return l===void 0||E>=t||E<0||b&&H>=o}function L(){var g=Ce();if(F(g))return D(g);s=setTimeout(L,$(g))}function D(g){return s=void 0,A&&r?R(g):(r=i=void 0,a)}function V(){s!==void 0&&clearTimeout(s),f=0,r=l=i=s=void 0}function K(){return s===void 0?a:D(Ce())}function N(){var g=Ce(),E=F(g);if(r=arguments,i=this,l=g,E){if(s===void 0)return ce(l);if(b)return s=setTimeout(L,t),R(l)}return s===void 0&&(s=setTimeout(L,t)),a}return N.cancel=V,N.flush=K,N}function Ut(e,t,n){var r=!0,i=!0;if(typeof e!="function")throw new TypeError(je);return se(n)&&(r="leading"in n?!!n.leading:r,i="trailing"in n?!!n.trailing:i),Wt(e,t,{leading:r,maxWait:t,trailing:i})}function se(e){var t=typeof e;return!!e&&(t=="object"||t=="function")}function qt(e){return!!e&&typeof e=="object"}function jt(e){return typeof e=="symbol"||qt(e)&&Rt.call(e)==At}function qe(e){if(typeof e=="number")return e;if(jt(e))return Ue;if(se(e)){var t=typeof e.valueOf=="function"?e.valueOf():e;e=se(t)?t+"":t}if(typeof e!="string")return e===0?e:+e;e=e.replace(xt,"");var n=Pt.test(e);return n||kt.test(e)?It(e.slice(2),n?2:8):Nt.test(e)?Ue:+e}Ye.exports=Ut});var ee=class{constructor(t){this.elements=t}elements;#e=-1/0;#t=0;getElementsForSourceLine(t){let n=Math.floor(t);n>=this.#e||(this.#t=0),this.#e=n;let r=this.elements[Math.max(0,this.#t-1)];for(;this.#t<this.elements.length;++this.#t){let i=this.elements[this.#t];if(i.line===n)return{previous:i,next:void 0};if(i.line>n)return{previous:r,next:i};r=i}return{previous:r}}};function Me(e,t){let n=(o,a)=>{let s=a.getAttribute("data-line");s!==null&&o.getAttribute("data-line")!==s&&o.setAttribute("data-line",s)};n(e,t);let r=e.querySelectorAll("[data-line]"),i=t.querySelectorAll("[data-line]");r.length!==i.length&&console.log("unexpected line number change");for(let o=0;o<r.length;++o)i[o]&&n(r[o],i[o])}var Ae="code-line",_=class{constructor(t,n,r,i){this.element=t;this.line=n;this.codeElement=r;this.endLine=i;this.#e=Array.from(ft(t,"DETAILS"))}element;line;codeElement;endLine;#e;get isVisible(){if(this.#e.some(r=>!r.open))return!1;let t=window.getComputedStyle(this.element);if(t.display==="none"||t.visibility==="hidden")return!1;let n=this.element.getBoundingClientRect();return!(n.height===0||n.width===0)}},te=(()=>{let e,t=-1;return n=>{if(!e||n!==t){t=n;let r=[new _(document.body,-1)];for(let i of document.getElementsByClassName(Ae)){if(!(i instanceof HTMLElement))continue;let o=+i.getAttribute("data-line");if(!isNaN(o))if(i.tagName==="CODE"&&i.parentElement?.tagName==="PRE"){let s=((i.textContent||"").match(/\n/g)||[]).length+1,l=o+s-1;r.push(new _(i.parentElement,o,i,l))}else i.tagName==="PRE"||i.tagName==="UL"||i.tagName==="OL"||r.push(new _(i,o))}e=new ee(r)}return e}})();function q(e,t){return te(t).getElementsForSourceLine(e)}function xe(e,t,n){let r=Math.floor(e),i=Math.max(r+1,Math.ceil(t)),o=te(n).elements.filter(s=>s.line>=0),a=[];for(let s=0;s<o.length;s++){let l=o[s],f=o[s+1],y=l.line,b=l.endLine!==void 0?l.endLine+1:f&&f.line>l.line?f.line:l.line+1;ct(r,i,y,b)&&a.push(l)}return a}function ct(e,t,n,r){return e<r&&n<t}function ut(e,t){let n=te(t).elements.filter(l=>l.isVisible),r=e-window.scrollY,i=-1,o=n.length-1;for(;i+1<o;){let l=Math.floor((i+o)/2),f=O(n[l]);f.top+f.height>=r?o=l:i=l}let a=n[o],s=O(a);return o>=1&&s.top>r?{previous:n[i],next:a}:o>1&&o<n.length&&s.top+s.height>r?{previous:a,next:n[o+1]}:{previous:a}}function O(e){let{element:t,codeElement:n}=e,r=t.getBoundingClientRect();if(n)return r;let i=t.querySelector(`.${Ae}`);if(i){let o=i.getBoundingClientRect(),a=Math.max(1,o.top-r.top);return{top:r.top,height:a}}return r}function Ne(e){let{element:t,codeElement:n}=e,r=O(e);if(n){let i=window.getComputedStyle(t),o=parseFloat(i.paddingTop)||0,a=parseFloat(i.paddingBottom)||0;return{top:r.top+o,height:r.height-o-a,paddingTop:o,paddingBottom:a}}return{top:r.top,height:r.height,paddingTop:0,paddingBottom:0}}function G(e,t,n){if(!n.settings?.scrollPreviewWithEditor)return;if(e<=0){window.scroll(window.scrollX,0);return}let{previous:r,next:i}=q(e,t);if(!r)return;let o=0,a=O(r),s=a.top;if(r.endLine&&r.endLine>r.line)if(e<r.endLine){let l=Ne(r),f=(e-r.line)/(r.endLine-r.line);o=window.scrollY+l.top+l.height*f}else if(i&&i.line!==r.line){let l=(e-r.endLine)/(i.line-r.endLine),f=window.scrollY+s+a.height,b=window.scrollY+i.element.getBoundingClientRect().top-f;o=f+l*b}else o=window.scrollY+s+a.height;else if(i&&i.line!==r.line){let l=(e-r.line)/(i.line-r.line),f=window.scrollY+s+a.height,b=window.scrollY+i.element.getBoundingClientRect().top-f;o=f+l*b}else{let l=e-Math.floor(e);o=window.scrollY+s+a.height*l}window.scroll(window.scrollX,Math.max(1,o))}function ge(e,t){let{previous:n,next:r}=ut(e,t);if(n){if(n.line<0)return 0;let i=O(n),o=e-window.scrollY-i.top;if(n.endLine&&n.endLine>n.line){let a=Ne(n),s=e-window.scrollY-a.top;if(s>=0&&s<=a.height){let l=s/a.height;return n.line+l*(n.endLine-n.line)}else if(r&&s>a.height){let l=s-a.height,f=O(r),y=a.top+a.height,b=f.top-y,A=l/b;return n.endLine+A*(r.line-n.endLine)}else s<0}if(r){let a=o/(O(r).top-i.top);return n.line+a*(r.line-n.line)}else{let a=o/i.height;return n.line+a}}return null}function Pe(e,t){return te(t).elements.find(n=>n.element.id===e)}function*ft(e,t){for(let n=e.parentElement;n;n=n.parentElement)n.tagName===t&&(yield n)}var ne=class{#e;onDidChangeTextEditorSelection(t,n){let{previous:r}=q(t,n);this.#t(r&&(r.codeElement||r.element))}#t(t){this.#r(this.#e),this.#n(t),this.#e=t}#r(t){t&&t.classList.toggle("code-active-line",!1)}#n(t){t&&t.classList.toggle("code-active-line",!0)}};function ke(e){document.readyState==="loading"||document.readyState==="uninitialized"?document.addEventListener("DOMContentLoaded",e):e()}var Ie=(e,t)=>({postMessage(n,r){e.postMessage({type:n,source:t.settings.source,...r})}});function pe(e){let t=document.getElementById("vscode-markdown-preview-data");if(t){let n=t.getAttribute(e);if(n)return n}throw new Error(`Could not load data for ${e}`)}function he(e){return JSON.parse(pe(e))}var re=class{#e=he("data-settings");get settings(){return this.#e}updateSettings(t){this.#e=t}};var De=11;function mt(e,t){var n=t.attributes,r,i,o,a,s;if(!(t.nodeType===De||e.nodeType===De)){for(var l=n.length-1;l>=0;l--)r=n[l],i=r.name,o=r.namespaceURI,a=r.value,o?(i=r.localName||i,s=e.getAttributeNS(o,i),s!==a&&(r.prefix==="xmlns"&&(i=r.name),e.setAttributeNS(o,i,a))):(s=e.getAttribute(i),s!==a&&e.setAttribute(i,a));for(var f=e.attributes,y=f.length-1;y>=0;y--)r=f[y],i=r.name,o=r.namespaceURI,o?(i=r.localName||i,t.hasAttributeNS(o,i)||e.removeAttributeNS(o,i)):t.hasAttribute(i)||e.removeAttribute(i)}}var ie,gt="http://www.w3.org/1999/xhtml",C=typeof document>"u"?void 0:document,pt=!!C&&"content"in C.createElement("template"),ht=!!C&&C.createRange&&"createContextualFragment"in C.createRange();function vt(e){var t=C.createElement("template");return t.innerHTML=e,t.content.childNodes[0]}function bt(e){ie||(ie=C.createRange(),ie.selectNode(C.body));var t=ie.createContextualFragment(e);return t.childNodes[0]}function wt(e){var t=C.createElement("body");return t.innerHTML=e,t.childNodes[0]}function yt(e){return e=e.trim(),pt?vt(e):ht?bt(e):wt(e)}function oe(e,t){var n=e.nodeName,r=t.nodeName,i,o;return n===r?!0:(i=n.charCodeAt(0),o=r.charCodeAt(0),i<=90&&o>=97?n===r.toUpperCase():o<=90&&i>=97?r===n.toUpperCase():!1)}function Ct(e,t){return!t||t===gt?C.createElement(e):C.createElementNS(t,e)}function St(e,t){for(var n=e.firstChild;n;){var r=n.nextSibling;t.appendChild(n),n=r}return t}function ve(e,t,n){e[n]!==t[n]&&(e[n]=t[n],e[n]?e.setAttribute(n,""):e.removeAttribute(n))}var He={OPTION:function(e,t){var n=e.parentNode;if(n){var r=n.nodeName.toUpperCase();r==="OPTGROUP"&&(n=n.parentNode,r=n&&n.nodeName.toUpperCase()),r==="SELECT"&&!n.hasAttribute("multiple")&&(e.hasAttribute("selected")&&!t.selected&&(e.setAttribute("selected","selected"),e.removeAttribute("selected")),n.selectedIndex=-1)}ve(e,t,"selected")},INPUT:function(e,t){ve(e,t,"checked"),ve(e,t,"disabled"),e.value!==t.value&&(e.value=t.value),t.hasAttribute("value")||e.removeAttribute("value")},TEXTAREA:function(e,t){var n=t.value;e.value!==n&&(e.value=n);var r=e.firstChild;if(r){var i=r.nodeValue;if(i==n||!n&&i==e.placeholder)return;r.nodeValue=n}},SELECT:function(e,t){if(!t.hasAttribute("multiple")){for(var n=-1,r=0,i=e.firstChild,o,a;i;)if(a=i.nodeName&&i.nodeName.toUpperCase(),a==="OPTGROUP")o=i,i=o.firstChild,i||(i=o.nextSibling,o=null);else{if(a==="OPTION"){if(i.hasAttribute("selected")){n=r;break}r++}i=i.nextSibling,!i&&o&&(i=o.nextSibling,o=null)}e.selectedIndex=n}}},z=1,Be=11,Oe=3,Re=8;function I(){}function Tt(e){if(e)return e.getAttribute&&e.getAttribute("id")||e.id}function Et(e){return function(n,r,i){if(i||(i={}),typeof r=="string")if(n.nodeName==="#document"||n.nodeName==="HTML"||n.nodeName==="BODY"){var o=r;r=C.createElement("html"),r.innerHTML=o}else r=yt(r);else r.nodeType===Be&&(r=r.firstElementChild);var a=i.getNodeKey||Tt,s=i.onBeforeNodeAdded||I,l=i.onNodeAdded||I,f=i.onBeforeElUpdated||I,y=i.onElUpdated||I,b=i.onBeforeNodeDiscarded||I,A=i.onNodeDiscarded||I,R=i.onBeforeElChildrenUpdated||I,ce=i.skipFromChildren||I,$=i.addChild||function(d,c){return d.appendChild(c)},F=i.childrenOnly===!0,L=Object.create(null),D=[];function V(d){D.push(d)}function K(d,c){if(d.nodeType===z)for(var p=d.firstChild;p;){var u=void 0;c&&(u=a(p))?V(u):(A(p),p.firstChild&&K(p,c)),p=p.nextSibling}}function N(d,c,p){b(d)!==!1&&(c&&c.removeChild(d),A(d),K(d,p))}function g(d){if(d.nodeType===z||d.nodeType===Be)for(var c=d.firstChild;c;){var p=a(c);p&&(L[p]=c),g(c),c=c.nextSibling}}g(n);function E(d){l(d);for(var c=d.firstChild;c;){var p=c.nextSibling,u=a(c);if(u){var m=L[u];m&&oe(c,m)?(c.parentNode.replaceChild(m,c),B(m,c)):E(c)}else E(c);c=p}}function H(d,c,p){for(;c;){var u=c.nextSibling;(p=a(c))?V(p):N(c,d,!0),c=u}}function B(d,c,p){var u=a(c);if(u&&delete L[u],!p){var m=f(d,c);if(m===!1||(m instanceof HTMLElement&&(d=m,g(d)),e(d,c),y(d),R(d,c)===!1))return}d.nodeName!=="TEXTAREA"?st(d,c):He.TEXTAREA(d,c)}function st(d,c){var p=ce(d,c),u=c.firstChild,m=d.firstChild,W,x,U,J,P;e:for(;u;){for(J=u.nextSibling,W=a(u);!p&&m;){if(U=m.nextSibling,u.isSameNode&&u.isSameNode(m)){u=J,m=U;continue e}x=a(m);var Q=m.nodeType,k=void 0;if(Q===u.nodeType&&(Q===z?(W?W!==x&&((P=L[W])?U===P?k=!1:(d.insertBefore(P,m),x?V(x):N(m,d,!0),m=P,x=a(m)):k=!1):x&&(k=!1),k=k!==!1&&oe(m,u),k&&B(m,u)):(Q===Oe||Q==Re)&&(k=!0,m.nodeValue!==u.nodeValue&&(m.nodeValue=u.nodeValue))),k){u=J,m=U;continue e}x?V(x):N(m,d,!0),m=U}if(W&&(P=L[W])&&oe(P,u))p||$(d,P),B(P,u);else{var me=s(u);me!==!1&&(me&&(u=me),u.actualize&&(u=u.actualize(d.ownerDocument||C)),$(d,u),E(u))}u=J,m=U}H(d,m,x);var Le=He[d.nodeName];Le&&Le(d,c)}var w=n,Z=w.nodeType,Ee=r.nodeType;if(!F){if(Z===z)Ee===z?oe(n,r)||(A(n),w=St(n,Ct(r.nodeName,r.namespaceURI))):w=r;else if(Z===Oe||Z===Re){if(Ee===Z)return w.nodeValue!==r.nodeValue&&(w.nodeValue=r.nodeValue),w;w=r}}if(w===r)A(n);else{if(r.isSameNode&&r.isSameNode(w))return;if(B(w,r,F),D)for(var ue=0,lt=D.length;ue<lt;ue++){var fe=L[D[ue]];fe&&N(fe,fe.parentNode,!1)}}return!F&&w!==n&&n.parentNode&&(w.actualize&&(w=w.actualize(n.ownerDocument||C)),n.parentNode.replaceChild(w,n)),w}}var Lt=Et(mt),Fe=Lt;var be=Object.freeze({http:"http",https:"https",file:"file",untitled:"untitled",mailto:"mailto",vscode:"vscode","vscode-insiders":"vscode-insiders",notebookCell:"vscode-notebook-cell"});function we(e,t){return t.toLowerCase().startsWith(e+":")}var ae=class{#e=Math.random().toString(36).slice(2,10);#t;#r;#n;#i=0;constructor(t,n){this.#t=n,this.#r=t,this.#n=new BroadcastChannel(t.channelName),this.#n.onmessage=r=>{let{line:i,sender:o}=r.data;if(o===this.#e||typeof i!="number"||isNaN(i))return;let a=Mt(i,this.#r.lineMappings);this.#i=Date.now()+100,this.#t(a)}}update(t){this.#r=t}broadcastScroll(t){!this.#n||Date.now()<this.#i||this.#n.postMessage({line:t,sender:this.#e})}};function Mt(e,t){if(!t?.length)return e;let n=Math.floor(e),r=e-n,i=t[n]??e;if(r<=0)return Math.max(0,i);let o=t[n+1];return typeof o!="number"?Math.max(0,i+r):Math.max(0,i+(o-i)*r)}var Ve=new Set(["open"]);function We(e){return e.nodeType===1}function ye(e,t){if(e.isEqualNode(t))return!0;if(e.tagName!==t.tagName)return!1;let n=Array.from(e.attributes).filter(a=>!Ve.has(a.name)),r=Array.from(t.attributes).filter(a=>!Ve.has(a.name));if(n.length!==r.length)return!1;for(let a=0;a<n.length;++a){let s=n[a],l=r[a];if(s.name!==l.name||s.value!==l.value&&s.name!=="data-line")return!1}let i=e.childNodes,o=t.childNodes;if(i.length!==o.length)return!1;for(let a=0;a<i.length;++a){let s=i[a],l=o[a];if(s.nodeType!==l.nodeType)return!1;if(We(s)&&We(l)){if(!ye(s,l))return!1}else if(s.nodeValue!==l.nodeValue)return!1}return!0}var Ze=_e(),S=0,v,Je=new ne,h=new re,T=0,j=h.settings.source,Se=h.settings.lineChanges,Y=acquireVsCodeApi(),Yt=e=>{S=1,v&&clearTimeout(v),v=window.setTimeout(()=>{S=0},100),de(()=>G(e,T,h))},Qe=h.settings.diffScrollSync?new ae(h.settings.diffScrollSync,Yt):void 0,le=Y.getState()??{},M={...le,...he("data-state")},Ge=typeof h.settings.line=="number"&&!isNaN(h.settings.line);typeof le.scrollProgress<"u"&&(le?.resource!==M.resource||Ge&&le.line!==h.settings.line)&&(M.scrollProgress=Ge?void 0:0);Y.setState(M);var X=Ie(Y,h);window.cspAlerter.setPoster(X);window.styleLoadingMonitor.setPoster(X);function de(e){let t=document.getElementsByTagName("img");if(t.length>0){let n=Array.from(t,r=>r.complete?Promise.resolve():new Promise(i=>{r.addEventListener("load",()=>i()),r.addEventListener("error",()=>i())}));Promise.all(n).then(()=>setTimeout(e,0))}else setTimeout(e,0)}ke(()=>{let n=[...new DOMParser().parseFromString(pe("data-initial-md-content"),"text/html").body.children];document.body.append(...n);for(let i of n)i instanceof HTMLElement&&Te(i);let r=M.scrollProgress;if(et(),tt(),it(Se),typeof r=="number"&&!h.settings.fragment){de(()=>{S=1,v&&clearTimeout(v),v=window.setTimeout(()=>{S=0},200);let i=Math.max(1,r*document.body.clientHeight);window.scrollTo(0,i)});return}h.settings.scrollPreviewWithEditor&&de(()=>{if(h.settings.fragment){let i;try{i=encodeURIComponent(h.settings.fragment)}catch{i=h.settings.fragment}M.fragment=void 0,Y.setState(M);let o=Pe(i,T);o&&(S=1,v&&clearTimeout(v),v=window.setTimeout(()=>{S=0},200),G(o.line,T,h))}else isNaN(h.settings.line)||(S=1,v&&clearTimeout(v),v=window.setTimeout(()=>{S=0},200),G(h.settings.line,T,h))}),typeof h.settings.selectedLine=="number"&&Je.onDidChangeTextEditorSelection(h.settings.selectedLine,T)});var _t=(()=>{let e=Ze(t=>{S=1,v&&clearTimeout(v),v=window.setTimeout(()=>{S=0},50),de(()=>G(t,T,h))},50);return t=>{isNaN(t)||(M.line=t,e(t))}})();window.addEventListener("resize",()=>{S=1,v&&clearTimeout(v),v=window.setTimeout(()=>{S=0},200),at()},!0);function et(){let e=document.getElementsByTagName("img"),t=0;for(let n of e){n.id="image-"+t,t+=1;let r=n.getAttribute("data-src"),o=r&&!(we(be.http,r)||we(be.https,r))?"localImage":"image";n.setAttribute("data-vscode-context",JSON.stringify({webviewSection:o,id:n.id,preventDefaultContextMenuItems:!0,resource:j,imageSource:r}))}}function ze(){let e=document.createElementNS("http://www.w3.org/2000/svg","svg");e.setAttribute("aria-hidden","true"),e.setAttribute("focusable","false"),e.setAttribute("width","16"),e.setAttribute("height","16"),e.setAttribute("viewBox","0 0 16 16"),e.setAttribute("fill","none");let t=document.createElementNS("http://www.w3.org/2000/svg","path");t.setAttribute("d","M4 4H2V14H11V12H4V4Z"),t.setAttribute("fill","currentColor");let n=document.createElementNS("http://www.w3.org/2000/svg","path");return n.setAttribute("fill-rule","evenodd"),n.setAttribute("clip-rule","evenodd"),n.setAttribute("d","M5 2H14V11H5V2ZM6 3H13V10H6V3Z"),n.setAttribute("fill","currentColor"),e.appendChild(t),e.appendChild(n),e}function Gt(){let e=document.createElementNS("http://www.w3.org/2000/svg","svg");e.setAttribute("aria-hidden","true"),e.setAttribute("focusable","false"),e.setAttribute("width","16"),e.setAttribute("height","16"),e.setAttribute("viewBox","0 0 16 16"),e.setAttribute("fill","none");let t=document.createElementNS("http://www.w3.org/2000/svg","path");return t.setAttribute("d","M6.27 10.87L3.63 8.23L2.56 9.3L6.27 13.01L14.07 5.21L13 4.14L6.27 10.87Z"),t.setAttribute("fill","currentColor"),e.appendChild(t),e}function tt(){let e=document.querySelectorAll("pre > code");for(let t of e){let n=t.parentElement;if(!n.querySelector(".code-block-copy-button")){let r=document.createElement("button");r.className="code-block-copy-button",r.setAttribute("aria-label","Copy code block"),r.appendChild(ze()),r.addEventListener("click",async i=>{i.preventDefault(),i.stopPropagation();let o=t.textContent??"";try{await navigator.clipboard.writeText(o),r.replaceChildren(Gt()),r.classList.add("copied"),setTimeout(()=>{r.replaceChildren(ze()),r.classList.remove("copied")},2e3)}catch{let a=window.getSelection();if(a){a.removeAllRanges();let s=document.createRange();s.selectNodeContents(t),a.addRange(s),document.execCommand("copy"),a.removeAllRanges()}}}),n.appendChild(r)}}}async function nt(e,t=5){if(!document.hasFocus()&&t>0){setTimeout(()=>{nt(e,t-1)},20);return}try{await navigator.clipboard.write([new ClipboardItem({"image/png":new Promise(n=>{let r=document.createElement("canvas");r!==null&&(r.width=e.naturalWidth,r.height=e.naturalHeight,r.getContext("2d")?.drawImage(e,0,0)),r.toBlob(i=>{i&&n(i),r.remove()},"image/png")})})])}catch(n){console.error(n);let r=window.getSelection();if(!r){await navigator.clipboard.writeText(e.getAttribute("data-src")??e.src);return}r.removeAllRanges();let i=document.createRange();i.selectNode(e),r.addRange(i),document.execCommand("copy"),r.removeAllRanges()}}window.addEventListener("message",async e=>{let t=e.data;switch(t.type){case"copyImage":{let n=document.getElementById(t.id);n instanceof HTMLImageElement&&nt(n);return}case"onDidChangeTextEditorSelection":t.source===j&&Je.onDidChangeTextEditorSelection(t.line,T);return;case"updateView":t.source===j&&_t(t.line);return;case"updateContent":{Se=t.lineChanges,t.diffScrollSync&&Qe?.update(t.diffScrollSync);let n=document.querySelector(".markdown-body"),i=new DOMParser().parseFromString(t.content,"text/html");for(let o of Array.from(i.querySelectorAll("meta")))o.hasAttribute("http-equiv")&&o.remove();if(rt(),t.source!==j){j=t.source;let o=i.querySelector(".markdown-body");n.replaceWith(o),Te(o)}else{let o=i.querySelector(".markdown-body"),a=o.querySelectorAll("link");for(let s of a)s.remove();o.prepend(...a),Fe(n,o,{childrenOnly:!0,onBeforeElUpdated:(s,l)=>ye(s,l)?(Me(s,l),!1):(s.tagName==="DETAILS"&&l.tagName==="DETAILS"&&s.hasAttribute("open")&&l.setAttribute("open",""),!0),addChild:(s,l)=>{s.appendChild(l),l instanceof HTMLElement&&Te(l)}})}++T,window.dispatchEvent(new CustomEvent("vscode.markdown.updateContent")),et(),tt(),it(Se);break}}},!1);function rt(){for(let e of document.querySelectorAll(".code-line-diff-added, .code-line-diff-deleted, .code-line-diff-modified"))e.classList.remove("code-line-diff","code-line-diff-added","code-line-diff-deleted","code-line-diff-modified");for(let e of document.querySelectorAll(".diff-change-indicator"))e.remove();for(let e of document.querySelectorAll(".diff-modification-gutter"))e.remove()}function it(e){rt(),Xe(e?.added,"code-line-diff-added"),Xe(e?.deleted,"code-line-diff-deleted"),zt(e),rn(e)}function Xe(e,t){if(!e)return;let n;for(let r of e){let{previous:i,next:o}=q(r,T),a=i.line>=0?i:o,s=a?.codeElement||a?.element;s&&s!==n&&(s.classList.add("code-line-diff",t),n=s)}}function zt(e){if(e?.changeIndicators?.length)for(let t of Xt(e.changeIndicators)){if(t.indicator.type==="deletion"){let r=Zt(t.indicator);t.elements[0].parentElement?.insertBefore(r,t.elements[0]);continue}let n=!0;for(let r of t.elements)r.classList.add("code-line-diff-modified"),Jt(r,n?t.indicator:void 0),n=!1}}function Xt(e){let t=[];for(let n of e){let r=n.type==="deletion"?$t(n.modifiedLine):Kt(n.modifiedLine,n.modifiedLineCount);r.length&&t.push({indicator:n,elements:r})}return t}function $t(e){let{previous:t,next:n}=q(e,T),r=t.line===e?t.codeElement||t.element:n?.codeElement||n?.element||t.codeElement||t.element;return r?[r]:[]}function Kt(e,t){let n=[],r=new Set,i=xe(e,e+t,T);for(let o of i){let a=o.codeElement||o.element;a&&!r.has(a)&&(r.add(a),n.push(a))}return n}function Zt(e){let t=document.createElement("div");t.className=`diff-change-indicator diff-change-indicator-${e.type}`,t.setAttribute("data-original-line-count",String(e.originalLineCount));let n=document.createElement("span");n.className="diff-change-indicator-arrow";let r=ot(e);return n.appendChild(r),t.appendChild(n),t}function Jt(e,t){let n=document.createElement("div");if(n.className="diff-modification-gutter",t){let r=ot(t);n.appendChild(r)}e.style.position="relative",e.appendChild(n)}function ot(e){let t=document.createElement("div");return t.className="diff-change-indicator-tooltip",e.originalContent&&$e(t,"diff-tooltip-deleted",e.originalContent,e.originalInnerChanges,"diff-tooltip-inner-deleted"),e.modifiedContent&&$e(t,"diff-tooltip-added",e.modifiedContent,e.modifiedInnerChanges,"diff-tooltip-inner-added"),t}function $e(e,t,n,r,i){let o=document.createElement("div");o.className=t;let a=document.createElement("pre");Qt(a,n,r,i),o.appendChild(a),e.appendChild(o)}function Qt(e,t,n,r){if(!n?.length){e.textContent=t;return}let i=tn(n),o=t.split(`
`);for(let a=0;a<o.length;++a)en(e,o[a],i.get(a),r),a+1<o.length&&e.appendChild(document.createTextNode(`
`))}function en(e,t,n,r){let i=nn(n,t.length),o=0;for(let a of i){o<a.startColumn&&e.appendChild(document.createTextNode(t.slice(o,a.startColumn)));let s=document.createElement("span");s.className=r,s.textContent=t.slice(a.startColumn,a.endColumn),e.appendChild(s),o=a.endColumn}o<t.length&&e.appendChild(document.createTextNode(t.slice(o)))}function tn(e){let t=new Map;for(let n of e){let r=t.get(n.line);r?r.push(n):t.set(n.line,[n])}return t}function nn(e,t){if(!e?.length)return[];let n=e.map(i=>({startColumn:Ke(i.startColumn,t),endColumn:Ke(i.endColumn,t)})).filter(i=>i.startColumn<i.endColumn).sort((i,o)=>i.startColumn-o.startColumn||i.endColumn-o.endColumn),r=[];for(let i of n){let o=r[r.length-1];o&&i.startColumn<=o.endColumn?o.endColumn=Math.max(o.endColumn,i.endColumn):r.push(i)}return r}function Ke(e,t){return Math.min(Math.max(e,0),t)}function rn(e){let t="diff-inner-added",n="diff-inner-deleted";if(CSS.highlights?.delete(t),CSS.highlights?.delete(n),!e?.innerChanges?.length||!CSS.highlights)return;let r=e.added?t:n,i=[],o=document.querySelector(".markdown-body");if(o){for(let{startMarker:a,endMarker:s}of on(o)){let l=new Range;l.setStartAfter(a),l.setEndBefore(s),i.push(l)}i.length>0&&CSS.highlights.set(r,new Highlight(...i))}}function on(e){let t=new Map;for(let r of e.querySelectorAll("[data-diff-end]")){let i=r.getAttribute("data-diff-end");i!==null&&t.set(i,r)}let n=[];for(let r of e.querySelectorAll("[data-diff-start]")){let i=r.getAttribute("data-diff-start"),o=i===null?void 0:t.get(i);o&&!(r.compareDocumentPosition(o)&Node.DOCUMENT_POSITION_PRECEDING)&&n.push({startMarker:r,endMarker:o})}return n}document.addEventListener("dblclick",e=>{if(!h.settings.doubleClickToSwitchToEditor||j.endsWith(".copilotmd"))return;for(let r=e.target;r;r=r.parentNode)if(r.tagName==="A")return;let t=e.pageY,n=ge(t,T);typeof n=="number"&&!isNaN(n)&&X.postMessage("didClick",{line:Math.floor(n)})});var an=["http:","https:","mailto:","vscode:","vscode-insiders:"];document.addEventListener("click",e=>{if(!e)return;let t=e.target;for(;t;){if(t.tagName&&t.tagName==="A"&&t.href){if(t.getAttribute("href")?.startsWith("#"))return;let n=t.getAttribute("data-href");if(!n&&(n=t.getAttribute("href"),n&&an.some(r=>n.startsWith(r))))return;if(n&&!/^[a-z\-]+:/i.test(n)){X.postMessage("openLink",{href:n}),e.preventDefault(),e.stopPropagation();return}return}t=t.parentElement}},!0);window.addEventListener("scroll",Ze(()=>{if(at(),S>0)return;let e=ge(window.scrollY,T);typeof e=="number"&&!isNaN(e)&&(M.line=e,Y.setState(M),X.postMessage("revealLine",{line:e}),Qe?.broadcastScroll(e))},50));function at(){M.scrollProgress=window.scrollY/document.body.clientHeight,Y.setState(M)}function Te(e){let t=["type","src","nonce","noModule","async"],n=e.tagName==="SCRIPT"?[e]:Array.from(e.getElementsByTagName("script"));for(let r of n){if(!(r instanceof HTMLElement))continue;let i=document.createElement("script"),o=r.innerText;i.text=o;for(let a of t){let s=r.getAttribute?.(a);s&&i.setAttribute(a,s)}r.insertAdjacentElement("afterend",i),r.remove()}}