/*!--------------------------------------------------------
 * Copyright (C) Microsoft Corporation. All rights reserved.
 *--------------------------------------------------------*/(function(){var y=["require","exports","vs/github1s/authorizing-github","vs/workbench/workbench.web.api","vs/css!vs/github1s/authorizing-overlay","vs/css!vs/code/browser/workbench/workbench","vs/css!vs/github1s/notification","vs/github1s/notification","vs/github1s/util","vs/github1s/authorizing-overlay","vs/code/browser/workbench/workbench","vs/base/browser/browser","vs/base/common/buffer","vs/base/common/cancellation","vs/base/common/event","vs/base/common/lifecycle","vs/base/common/network","vs/base/common/resources","vs/base/common/uri","vs/base/common/uuid","vs/base/parts/request/browser/request","vs/nls!vs/code/browser/workbench/workbench","vs/platform/log/common/log","vs/platform/product/common/product","vs/platform/windows/common/windows"],A=function(k){for(var o=[],d=0,m=k.length;d<m;d++)o[d]=y[k[d]];return o};define(y[4],A([5]),{}),define(y[6],A([5]),{}),define(y[7],A([0,1,6]),function(k,o){"use strict";Object.defineProperty(o,"__esModule",{value:!0}),o.renderNotification=void 0;const d="GITHUB1S_NOTIFICATION",m="20210212",c=`${[{title:"ATTENTION: This page is NOT officially provided by GitHub.",content:"GitHub1s is an open source project, which is not officially provided by GitHub.",link:"https://github.com/conwnet/github1s"}].map(l=>`
		<div class="notification-main">
			<div class="notification-title">${l.title}</div>
			<div class="notification-content">
				${l.content}
				${l.link?`<a class="notification-link" href="${l.link}" target="_blank">See more</a>`:""}
			</div>
		</div>`)}
<div class="notification-footer">
	<button class="notification-confirm-button">OK</button>
	<div class="notification-show-me-again">
		<input type="checkbox" checked>Don't show me again</div>
	</div>
</div>
`,p=()=>{if(!window.localStorage||window.localStorage.getItem(d)===m)return;const l=document.createElement("div");l.classList.add("github1s-notification"),l.innerHTML=c,document.body.appendChild(l),l.querySelector(".notification-confirm-button").onclick=()=>{!!l.querySelector(".notification-show-me-again input").checked&&window.localStorage.setItem(d,m),document.body.removeChild(l)}};o.renderNotification=p}),define(y[8],A([0,1]),function(k,o){"use strict";Object.defineProperty(o,"__esModule",{value:!0}),o.delegate=o.replaceBrowserUrl=o.getBrowserUrl=void 0;const d=()=>window.location.href;o.getBrowserUrl=d;const m=c=>{window.history.replaceState&&window.history.replaceState(null,"",c)};o.replaceBrowserUrl=m;const v=(c,p,l,T)=>c?.addEventListener(l,function(n){const s=c.querySelectorAll(p);for(let a=0,u=s.length;a<u;a++)s[a]===n.target&&T.call(this,n)});o.delegate=v}),define(y[2],A([0,1,3]),function(k,o,d){"use strict";Object.defineProperty(o,"__esModule",{value:!0}),o.getGitHubAccessToken=void 0;const v="https://github.com/login/oauth/authorize?scope=repo,user:email&client_id=eae6621348403ea49103",c="directories=no,titlebar=no,toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=800,height=520,top=150,left=150",p="https://auth.github1s.com",l=n=>new Promise(s=>setTimeout(s,n)),T=(n=!1)=>{const s=window.open(v,"_blank",c);return new Promise(a=>{let u=!1;!s&&n&&(u=!0,d.commands.executeCommand("github1s.vscode.get-github-access-token-with-overlay").then(g=>a(g)));const R=g=>{g.origin!==p||s&&g.source!==s||g.data?.type!=="authorizing"||u&&!("access_token"in g.data.payload)||(u&&d.commands.executeCommand("github1s.vscode.hide-authorizing-overlay"),window.removeEventListener("message",R),a(g.data.payload))};window.addEventListener("message",R),l(300*1e3).then(()=>{window.removeEventListener("message",R),a({error:"authorizing_timeout",error_description:"Authorizing timeout"})})})};o.getGitHubAccessToken=T}),define(y[9],A([0,1,3,2,4]),function(k,o,d,m){"use strict";Object.defineProperty(o,"__esModule",{value:!0}),o.hideAuthorizingOverlay=o.getGitHubAccessTokenWithOverlay=o.AuthorizingOverlay=void 0;const v=`
<div class="github1s-authorizing-dialog">
	<div class="close-button"></div>
	<div class="header-title">
		Authenticating to GitHub
	</div>
	<div class="features-description">
		<ul class="feature-list">
			<li class="feature-item">
				<a class="link" href="https://docs.github.com/en/rest/overview/resources-in-the-rest-api#rate-limiting" target="_blank">Higher Rate Limit</a>
			</li>
			<li class="feature-item">
				<a class="link" href="https://docs.github.com/en/graphql/guides/forming-calls-with-graphql#authenticating-with-graphql" target="_blank">GitHub GraphQL API</a>
			</li>
			<li class="feature-item">
				<a class="link" href="https://docs.github.com/en/graphql/reference/objects#blame" target="_blank">Git Blame Feature</a>
			</li>
		</ul>
	</div>
	<div class="github-documentation">
		Read more about this on
		<a class="link"
			href="https://docs.github.com/en/github/authenticating-to-github"
			target="_blank">
			GitHub Documentation
		</a>
	</div>
	<div class="authorizing-methods">
		<button class="authorizing-button loading">
			<svg class="github-logo" height="32" viewBox="0 0 16 16" version="1.1" width="32" aria-hidden="true">
				<path fill-rule="evenodd"
					d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0016 8c0-4.42-3.58-8-8-8z">
				</path>
			</svg>
			<span>Connect to GitHub</span>
		</button>
		<div class="split-line"></div>
		<form class="input-oauth-token-form">
			<input class="input-box" placeholder="\bInput OAuth Token" />
			<button type="submit" class="submit-button loading">Submit</button>
		</form>
		<div class="create-token-link">
			<a class="link" href="https://github.com/settings/tokens/new?scopes=repo&description=GitHub1s" target="_blank">
				Create New OAuth Token
			</a>
		</div>
	</div>
</div>
`;class c{constructor(){this._overlayVisible=!1,this._finishCallback=()=>{}}static getInstance(){return c._instance?c._instance:c._instance=new c}show(){if(this._overlayVisible!==!0)return this._overlayVisible=!0,document.body.classList.add("github1s-overlay-visible"),document.body.appendChild(this.getRootElement()),this.clearAllErrors(),new Promise(n=>this._finishCallback=n)}hide(){if(this._overlayVisible===!1)return;this._overlayVisible=!1;const n=this.getDialogElement();n.classList.add("exiting"),setTimeout(()=>{n.classList.remove("exiting"),document.body.classList.remove("github1s-overlay-visible"),document.body.removeChild(this.getRootElement())},180)}getRootElement(){return this._rootElement||(this._rootElement=this.createElements(),this.registerListeners()),this._rootElement}getDialogElement(){return this.getRootElement().querySelector(".github1s-authorizing-dialog")}createElements(){const n=document.createElement("div");return n.classList.add("github1s-authorizing-mask"),n.innerHTML=v,n}createErrorElement(n,s){const a=document.createElement("div");if(a.classList.add("error-message"),a.innerText=n,s){const u=document.createElement("a");u.setAttribute("href",s),u.setAttribute("target","_blank"),u.classList.add("link"),u.innerText="See more",a.appendChild(u)}return a}clearAllErrors(){this.getDialogElement().querySelectorAll(".error-message")?.forEach(n=>{n.parentElement?.removeChild(n)})}setAuthorizingButtonError(n,s){this.clearAllErrors();const a=this.createErrorElement(n,s);this.getDialogElement().querySelector(".authorizing-button")?.insertAdjacentElement("afterend",a)}async handleClickAuthorizingButton(){const n=await(0,m.getGitHubAccessToken)(!1);return"access_token"in n?(this._finishCallback(n),!0):("error"in n&&this.setAuthorizingButtonError(n.error_description,n.error_uri),!1)}setSubmitTokenError(n,s){this.clearAllErrors();const a=this.createErrorElement(n,s);this.getDialogElement().querySelector(".create-token-link")?.insertAdjacentElement("afterend",a)}async handleClickSubmitTokenButton(){const n=this.getDialogElement().querySelector(".input-oauth-token-form .input-box")?.value;if(!n)return this.setSubmitTokenError("Please input the token"),!1;const s=await d.commands.executeCommand("github1s.validate-token",n,!0);return s.valid?s.remaining<=0?(this.setSubmitTokenError("The token is valid, but it has exceeded the rate limit"),!1):(this._finishCallback({access_token:n}),!0):(this.setSubmitTokenError("The token is invalid"),!1)}registerListeners(){const n=this.getDialogElement();n.querySelector(".close-button")?.addEventListener("click",()=>{this._finishCallback({error:"user_canceled",error_description:"Authorizing canceled"}),this.hide()});const s=n.querySelector(".authorizing-button");s?.addEventListener("click",async()=>{this.clearAllErrors(),s.setAttribute("disabled","disabled"),await this.handleClickAuthorizingButton()&&this.hide(),s.removeAttribute("disabled")});const a=n.querySelector(".input-oauth-token-form .submit-button");a?.addEventListener("click",async u=>{u.preventDefault(),this.clearAllErrors(),a.setAttribute("disabled","disabled"),await this.handleClickSubmitTokenButton()&&this.hide(),a.removeAttribute("disabled")})}}o.AuthorizingOverlay=c;const p=()=>c.getInstance().show();o.getGitHubAccessTokenWithOverlay=p;const l=()=>c.getInstance().hide();o.hideAuthorizingOverlay=l}),define(y[10],A([0,1,11,12,13,14,15,16,17,18,19,20,21,22,23,24,3,8,7,2,9]),function(k,o,d,m,v,c,p,l,T,n,s,a,u,R,g,b,L,C,P,G,H){"use strict";Object.defineProperty(o,"__esModule",{value:!0});const z=()=>[{id:"github1s.vscode.get-browser-url",handler:C.getBrowserUrl},{id:"github1s.vscode.replace-browser-url",handler:C.replaceBrowserUrl},{id:"github1s.vscode.get-github-access-token",handler:G.getGitHubAccessToken},{id:"github1s.vscode.get-github-access-token-with-overlay",handler:H.getGitHubAccessTokenWithOverlay},{id:"github1s.vscode.hide-authorizing-overlay",handler:H.hideAuthorizingOverlay}];function N(S,t){let e;if(t){let i=0;t.forEach((r,E)=>{e||(e=""),e+=`${i++==0?"":"&"}${E}=${encodeURIComponent(r)}`})}return n.URI.parse(window.location.href).with({path:S,query:e})}class U{constructor(){let t;const e=document.getElementById("vscode-workbench-auth-session"),i=e?e.getAttribute("data-settings"):void 0;if(i)try{t=JSON.parse(i)}catch(r){}t&&(this.setPassword(`${g.default.urlProtocol}.login`,"account",JSON.stringify(t)),this.authService=`${g.default.urlProtocol}-${t.providerId}.login`,this.setPassword(this.authService,"account",JSON.stringify(t.scopes.map(r=>({id:t.id,scopes:r,accessToken:t.accessToken})))))}get credentials(){if(!this._credentials){try{const t=window.localStorage.getItem(U.CREDENTIALS_OPENED_KEY);t&&(this._credentials=JSON.parse(t))}catch(t){}Array.isArray(this._credentials)||(this._credentials=[])}return this._credentials}save(){window.localStorage.setItem(U.CREDENTIALS_OPENED_KEY,JSON.stringify(this.credentials))}async getPassword(t,e){return this.doGetPassword(t,e)}async doGetPassword(t,e){for(const i of this.credentials)if(i.service===t&&(typeof e!="string"||e===i.account))return i.password;return null}async setPassword(t,e,i){this.doDeletePassword(t,e),this.credentials.push({service:t,account:e,password:i}),this.save();try{if(i&&t===this.authService){const r=JSON.parse(i);Array.isArray(r)&&r.length===0&&await this.logout(t)}}catch(r){console.log(r)}}async deletePassword(t,e){const i=await this.doDeletePassword(t,e);if(i&&t===this.authService)try{await this.logout(t)}catch(r){console.log(r)}return i}async doDeletePassword(t,e){let i=!1;return this._credentials=this.credentials.filter(r=>r.service===t&&r.account===e?(i=!0,!1):!0),i&&this.save(),i}async findPassword(t){return this.doGetPassword(t)}async findCredentials(t){return this.credentials.filter(e=>e.service===t).map(({account:e,password:i})=>({account:e,password:i}))}async logout(t){const e=new Map;e.set("logout",String(!0)),e.set("service",t),await(0,a.request)({url:N("/auth/logout",e).toString(!0)},v.CancellationToken.None)}}U.CREDENTIALS_OPENED_KEY="credentials.provider";class h extends p.Disposable{constructor(){super(...arguments);this._onCallback=this._register(new c.Emitter),this.onCallback=this._onCallback.event}create(t){const e=new Map,i=(0,s.generateUuid)();e.set(h.QUERY_KEYS.REQUEST_ID,i);const{scheme:r,authority:E,path:w,query:Y,fragment:_}=t||{scheme:void 0,authority:void 0,path:void 0,query:void 0,fragment:void 0};return r&&e.set(h.QUERY_KEYS.SCHEME,r),E&&e.set(h.QUERY_KEYS.AUTHORITY,E),w&&e.set(h.QUERY_KEYS.PATH,w),Y&&e.set(h.QUERY_KEYS.QUERY,Y),_&&e.set(h.QUERY_KEYS.FRAGMENT,_),this.periodicFetchCallback(i,Date.now()),N("/callback",e)}async periodicFetchCallback(t,e){const i=new Map;i.set(h.QUERY_KEYS.REQUEST_ID,t);const r=await(0,a.request)({url:N("/fetch-callback",i).toString(!0)},v.CancellationToken.None),E=await(0,m.streamToBuffer)(r.stream);if(E.byteLength>0){try{this._onCallback.fire(n.URI.revive(JSON.parse(E.toString())))}catch(w){console.error(w)}return}Date.now()-e<h.FETCH_TIMEOUT&&setTimeout(()=>this.periodicFetchCallback(t,e),h.FETCH_INTERVAL)}}h.FETCH_INTERVAL=500,h.FETCH_TIMEOUT=5*60*1e3,h.QUERY_KEYS={REQUEST_ID:"vscode-requestId",SCHEME:"vscode-scheme",AUTHORITY:"vscode-authority",PATH:"vscode-path",QUERY:"vscode-query",FRAGMENT:"vscode-fragment"};class f{constructor(t,e){this.workspace=t,this.payload=e,this.trusted=!0}async open(t,e){if(e?.reuse&&!e.payload&&this.isSame(this.workspace,t))return!0;const i=this.createTargetUrl(t,e);if(i){if(e?.reuse)return window.location.href=i,!0;{let r;return d.isStandalone?r=window.open(i,"_blank","toolbar=no"):r=window.open(i),!!r}}return!1}createTargetUrl(t,e){let i;return t?(0,b.isFolderToOpen)(t)?i=`${document.location.origin}${document.location.pathname}?${f.QUERY_PARAM_FOLDER}=${encodeURIComponent(t.folderUri.toString())}`:(0,b.isWorkspaceToOpen)(t)&&(i=`${document.location.origin}${document.location.pathname}?${f.QUERY_PARAM_WORKSPACE}=${encodeURIComponent(t.workspaceUri.toString())}`):i=`${document.location.origin}${document.location.pathname}?${f.QUERY_PARAM_EMPTY_WINDOW}=true`,e?.payload&&(i+=`&${f.QUERY_PARAM_PAYLOAD}=${encodeURIComponent(JSON.stringify(e.payload))}`),i}isSame(t,e){return!t||!e?t===e:(0,b.isFolderToOpen)(t)&&(0,b.isFolderToOpen)(e)?(0,T.isEqual)(t.folderUri,e.folderUri):(0,b.isWorkspaceToOpen)(t)&&(0,b.isWorkspaceToOpen)(e)?(0,T.isEqual)(t.workspaceUri,e.workspaceUri):!1}hasRemote(){if(this.workspace){if((0,b.isFolderToOpen)(this.workspace))return this.workspace.folderUri.scheme===l.Schemas.vscodeRemote;if((0,b.isWorkspaceToOpen)(this.workspace))return this.workspace.workspaceUri.scheme===l.Schemas.vscodeRemote}return!0}}f.QUERY_PARAM_EMPTY_WINDOW="ew",f.QUERY_PARAM_FOLDER="folder",f.QUERY_PARAM_WORKSPACE="workspace",f.QUERY_PARAM_PAYLOAD="payload";class ${constructor(t){this.onDidChange=c.Event.None;let e,i;if(t){let r;(0,b.isFolderToOpen)(t)?r=t.folderUri:(0,b.isWorkspaceToOpen)(t)&&(r=t.workspaceUri),(r?.scheme==="github"||r?.scheme==="codespace")&&([e,i]=r.authority.split("+")),r?.scheme==="github1s"&&([e="conwnet",i="github1s"]=n.URI.parse((0,C.getBrowserUrl)()).path.split("/").filter(Boolean))}i&&e?(this.label=(0,u.localize)(0,null,e,i),this.tooltip=(0,u.localize)(1,null,e,i)):(this.label=(0,u.localize)(2,null),this.tooltip=(0,u.localize)(3,null))}}(function(){const S=document.getElementById("vscode-workbench-web-configuration"),t=S?S.getAttribute("data-settings"):void 0;if(!S||!t)throw new Error("Missing web configuration element");const e=JSON.parse(t);let i=!1,r,E=Object.create(null),w;new URL(document.location.href).searchParams.forEach((O,I)=>{switch(I){case f.QUERY_PARAM_FOLDER:r={folderUri:n.URI.parse(O)},i=!0;break;case f.QUERY_PARAM_WORKSPACE:r={workspaceUri:n.URI.parse(O)},i=!0;break;case f.QUERY_PARAM_EMPTY_WINDOW:r=void 0,i=!0;break;case f.QUERY_PARAM_PAYLOAD:try{E=JSON.parse(O)}catch(D){console.error(D)}break;case"logLevel":w=O;break}}),i||(e.folderUri?r={folderUri:n.URI.revive(e.folderUri)}:e.workspaceUri?r={workspaceUri:n.URI.revive(e.workspaceUri)}:r=void 0);const _=new f(r,E);let q;_.hasRemote()||(q=new $(r));const Q=O=>{let I=`quality=${O}`;new URL(document.location.href).searchParams.forEach((B,M)=>{M!=="quality"&&(I+=`&${M}=${B}`)}),window.location.href=`${window.location.origin}?${I}`},F=e.settingsSyncOptions?{enabled:e.settingsSyncOptions.enabled}:void 0;(0,L.create)(document.body,{...e,commands:z(),developmentOptions:{logLevel:w?(0,R.parseLogLevel)(w):void 0,...e.developmentOptions},settingsSyncOptions:F,windowIndicator:q,productQualityChangeHandler:Q,workspaceProvider:_,urlCallbackProvider:new h,credentialsProvider:new U}),setTimeout(()=>(0,P.renderNotification)(),1e3)})()})}).call(this);

//# sourceMappingURL=workbench.js.map
