"use strict";var y=Object.create;var l=Object.defineProperty;var U=Object.getOwnPropertyDescriptor;var x=Object.getOwnPropertyNames;var C=Object.getPrototypeOf,_=Object.prototype.hasOwnProperty;var P=(s,i)=>{for(var e in i)l(s,e,{get:i[e],enumerable:!0})},m=(s,i,e,t)=>{if(i&&typeof i=="object"||typeof i=="function")for(let r of x(i))!_.call(s,r)&&r!==e&&l(s,r,{get:()=>i[r],enumerable:!(t=U(i,r))||t.enumerable});return s};var h=(s,i,e)=>(e=s!=null?y(C(s)):{},m(i||!s||!s.__esModule?l(e,"default",{value:s,enumerable:!0}):e,s)),D=s=>m(l({},"__esModule",{value:!0}),s);var I={};P(I,{activate:()=>R});module.exports=D(I);var o=h(require("vscode"));var n=h(require("vscode"));function S(s){for(;s.length;)s.pop()?.dispose()}var p=class{_isDisposed=!1;_disposables=[];dispose(){this._isDisposed||(this._isDisposed=!0,S(this._disposables))}_register(i){return this._isDisposed?i.dispose():this._disposables.push(i),i}get isDisposed(){return this._isDisposed}};function b(){if(typeof crypto.randomUUID=="function")return crypto.randomUUID.bind(crypto)();let s=new Uint8Array(16),i=[];for(let r=0;r<256;r++)i.push(r.toString(16).padStart(2,"0"));crypto.getRandomValues(s),s[6]=s[6]&15|64,s[8]=s[8]&63|128;let e=0,t="";return t+=i[s[e++]],t+=i[s[e++]],t+=i[s[e++]],t+=i[s[e++]],t+="-",t+=i[s[e++]],t+=i[s[e++]],t+="-",t+=i[s[e++]],t+=i[s[e++]],t+="-",t+=i[s[e++]],t+=i[s[e++]],t+="-",t+=i[s[e++]],t+=i[s[e++]],t+=i[s[e++]],t+=i[s[e++]],t+=i[s[e++]],t+=i[s[e++]],t}var a=class s extends p{constructor(e,t,r){super();this.extensionUri=e;this._webviewPanel=this._register(r),this._webviewPanel.webview.options=s.getWebviewOptions(e),this._register(this._webviewPanel.webview.onDidReceiveMessage(c=>{switch(c.type){case"openExternal":try{let d=n.Uri.parse(c.url);n.env.openExternal(d)}catch{}break}})),this._register(this._webviewPanel.onDidDispose(()=>{this.dispose()})),this._register(n.workspace.onDidChangeConfiguration(c=>{if(c.affectsConfiguration("simpleBrowser.focusLockIndicator.enabled")){let d=n.workspace.getConfiguration("simpleBrowser");this._webviewPanel.webview.postMessage({type:"didChangeFocusLockIndicatorEnabled",focusLockEnabled:d.get("focusLockIndicator.enabled",!0)})}})),this.show(t)}static viewType="simpleBrowser.view";static title=n.l10n.t("Simple Browser");static getWebviewLocalResourceRoots(e){return[n.Uri.joinPath(e,"media")]}static getWebviewOptions(e){return{enableScripts:!0,enableForms:!0,localResourceRoots:s.getWebviewLocalResourceRoots(e)}}_webviewPanel;_onDidDispose=this._register(new n.EventEmitter);onDispose=this._onDidDispose.event;static create(e,t,r){let c=n.window.createWebviewPanel(s.viewType,s.title,{viewColumn:r?.viewColumn??n.ViewColumn.Active,preserveFocus:r?.preserveFocus},{retainContextWhenHidden:!0,...s.getWebviewOptions(e)});return new s(e,t,c)}static restore(e,t,r){return new s(e,t,r)}dispose(){this._onDidDispose.fire(),super.dispose()}show(e,t){this._webviewPanel.webview.html=this.getHtml(e),this._webviewPanel.reveal(t?.viewColumn,t?.preserveFocus)}getHtml(e){let t=n.workspace.getConfiguration("simpleBrowser"),r=b(),c=this.extensionResourceUrl("media","index.js"),d=this.extensionResourceUrl("media","main.css"),f=this.extensionResourceUrl("media","codicon.css");return`<!DOCTYPE html>
			<html>
			<head>
				<meta http-equiv="Content-type" content="text/html;charset=UTF-8">

				<meta http-equiv="Content-Security-Policy" content="
					default-src 'none';
					font-src data:;
					style-src ${this._webviewPanel.webview.cspSource};
					script-src 'nonce-${r}';
					frame-src *;
					">

				<meta id="simple-browser-settings" data-settings="${B(JSON.stringify({url:e,focusLockEnabled:t.get("focusLockIndicator.enabled",!0)}))}">

				<link rel="stylesheet" type="text/css" href="${d}">
				<link rel="stylesheet" type="text/css" href="${f}">
			</head>
			<body>
				<header class="header">
					<nav class="controls">
						<button
							title="${n.l10n.t("Back")}"
							class="back-button icon"><i class="codicon codicon-arrow-left"></i></button>

						<button
							title="${n.l10n.t("Forward")}"
							class="forward-button icon"><i class="codicon codicon-arrow-right"></i></button>

						<button
							title="${n.l10n.t("Reload")}"
							class="reload-button icon"><i class="codicon codicon-refresh"></i></button>
					</nav>

					<input class="url-input" type="text">

					<nav class="controls">
						<button
							title="${n.l10n.t("Open in browser")}"
							class="open-external-button icon"><i class="codicon codicon-link-external"></i></button>
					</nav>
				</header>
				<div class="content">
					<div class="iframe-focused-alert">${n.l10n.t("Focus Lock")}</div>
					<iframe sandbox="allow-scripts allow-forms allow-same-origin allow-downloads"></iframe>
				</div>

				<script src="${c}" nonce="${r}"></script>
			</body>
			</html>`}extensionResourceUrl(...e){return this._webviewPanel.webview.asWebviewUri(n.Uri.joinPath(this.extensionUri,...e))}};function B(s){return s.toString().replace(/"/g,"&quot;")}var v=class{constructor(i){this.extensionUri=i}_activeView;dispose(){this._activeView?.dispose(),this._activeView=void 0}show(i,e){let t=typeof i=="string"?i:i.toString(!0);if(this._activeView)this._activeView.show(t,e);else{let r=a.create(this.extensionUri,t,e);this.registerWebviewListeners(r),this._activeView=r}}restore(i,e){let t=e?.url??"",r=a.restore(this.extensionUri,t,i);this.registerWebviewListeners(r),this._activeView??=r}registerWebviewListeners(i){i.onDispose(()=>{this._activeView===i&&(this._activeView=void 0)})}};var V="simpleBrowser.api.open",W="simpleBrowser.show",g="workbench.action.browser.open",k="simpleBrowser.useIntegratedBrowser",O=new Set(["localhost","127.0.0.1","[0:0:0:0:0:0:0:1]","[::1]","0.0.0.0","[0:0:0:0:0:0:0:0]","[::]"]),E="simpleBrowser.open";async function w(){return o.workspace.getConfiguration().get(k,!0)?(await o.commands.getCommands(!0)).includes(g):!1}async function u(s){await o.commands.executeCommand(g,s)}function R(s){let i=new v(s.extensionUri);s.subscriptions.push(i),s.subscriptions.push(o.window.registerWebviewPanelSerializer(a.viewType,{deserializeWebviewPanel:async(e,t)=>{i.restore(e,t)}})),s.subscriptions.push(o.commands.registerCommand(W,async e=>{if(await w())return u(e);e||(e=await o.window.showInputBox({placeHolder:o.l10n.t("https://example.com"),prompt:o.l10n.t("Enter url to visit")})),e&&i.show(e)})),s.subscriptions.push(o.commands.registerCommand(V,async(e,t)=>{await w()?await u(e.toString(!0)):i.show(e,t)})),s.subscriptions.push(o.window.registerExternalUriOpener(E,{canOpenExternalUri(e){let t=new URL(e.toString(!0));return O.has(t.hostname)?L()?o.ExternalUriOpenerPriority.Default:o.ExternalUriOpenerPriority.Option:o.ExternalUriOpenerPriority.None},async openExternalUri(e){if(await w())await u(e.toString(!0));else return i.show(e,{viewColumn:o.window.activeTextEditor?o.ViewColumn.Beside:o.ViewColumn.Active})}},{schemes:["http","https"],label:o.l10n.t("Open in simple browser")}))}function L(){return!(typeof process=="object"&&process.versions.node)&&o.env.uiKind===o.UIKind.Web}0&&(module.exports={activate});
//# sourceMappingURL=extension.js.map
