/*---------------------------------------------------------------------------------------------
 *  Copyright (c) Microsoft Corporation. All rights reserved.
 *  Licensed under the MIT License. See License.txt in the project root for license information.
 *--------------------------------------------------------------------------------------------*/
"use strict";function styleBody(e){e&&(e.classList.remove("vscode-light","vscode-dark","vscode-high-contrast"),e.classList.add(initData.activeTheme))}function getTarget(){return document.getElementById("_target")}function handleInnerClick(e){if(e&&e.view&&e.view.document)for(var t=e.target;t;){if("A"===t.tagName&&t.href){var n=e.view.document.getElementsByTagName("base")[0];if("#"===t.getAttribute("href"))e.view.scrollTo(0,0);else if(t.hash&&(t.getAttribute("href")===t.hash||n&&t.href.indexOf(n.href)>=0)){var o=e.view.document.getElementById(t.hash.substr(1,t.hash.length-1));o&&o.scrollIntoView()}else ipcRenderer.sendToHost("did-click-link",t.href);e.preventDefault();break}t=t.parentNode}}const ipcRenderer=require("electron").ipcRenderer;var initData={};document.addEventListener("DOMContentLoaded",function(e){ipcRenderer.on("baseUrl",function(e,t){initData.baseUrl=t}),ipcRenderer.on("styles",function(e,t,n){initData.styles=t,initData.activeTheme=n;var o=getTarget();if(o){styleBody(o.contentDocument.getElementsByTagName("body")[0]);var i=o.contentDocument.getElementById("_defaultStyles");i&&(i.innerHTML=initData.styles)}}),ipcRenderer.on("focus",function(){const e=getTarget();e&&e.contentWindow.focus()}),ipcRenderer.on("content",function(e,t){const n=t.join("\n"),o=(new DOMParser).parseFromString(n,"text/html"),i={scriptTags:o.documentElement.querySelectorAll("script").length,inputTags:o.documentElement.querySelectorAll("input").length,styleTags:o.documentElement.querySelectorAll("style").length,linkStyleSheetTags:o.documentElement.querySelectorAll("link[rel=stylesheet]").length,stringLen:n.length};if(initData.baseUrl&&0===o.head.getElementsByTagName("base").length){const r=o.createElement("base");r.href=initData.baseUrl,o.head.appendChild(r)}const a=o.createElement("style");a.id="_defaultStyles",a.innerHTML=initData.styles,o.head.hasChildNodes()?o.head.insertBefore(a,o.head.firstChild):o.head.appendChild(a),styleBody(o.body);const c=getTarget();c&&c.setAttribute("id","_oldTarget");const s=c&&c.contentDocument&&c.contentDocument.body?c.contentDocument.body.scrollTop:0,d=document.createElement("iframe");d.setAttribute("id","_target"),d.setAttribute("frameborder","0"),d.setAttribute("sandbox","allow-scripts allow-forms allow-same-origin"),d.style.cssText="margin: 0; overflow: hidden; position: absolute; width: 100%; height: 100%; display: none",document.body.appendChild(d),d.contentDocument.open("text/html","replace"),d.contentWindow.onbeforeunload=function(e){return console.log("prevented webview navigation"),!1},d.contentWindow.addEventListener("DOMContentLoaded",function(e){const t=e.target;t.body&&(s!==t.body.scrollTop&&(t.body.scrollTop=s),t.body.addEventListener("click",handleInnerClick)),[].forEach.call(document.body.getElementsByTagName("iframe"),function(e){"_target"!==e.id&&document.body.removeChild(e)});const n=document.getElementById("_target");n.contentDocument===t&&(n.style.display="block")}),d.contentDocument.write("<!DOCTYPE html>"),d.contentDocument.write(o.documentElement.innerHTML),d.contentDocument.close(),ipcRenderer.sendToHost("did-set-content",i)}),ipcRenderer.on("message",function(e,t){const n=getTarget();n&&n.contentWindow.postMessage(t,document.location.origin)}),window.onmessage=function(e){ipcRenderer.sendToHost(e.data.command,e.data.data)},ipcRenderer.sendToHost("webview-ready",process.pid)});
//# sourceMappingURL=https://ticino.blob.core.windows.net/sourcemaps/f6868fce3eeb16663840eb82123369dec6077a9b/core/vs\workbench\parts\html\browser\webview-pre.js.map
