You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

3 lines
23 KiB

var e=/^([\w-_]+)\/([\w-_.]+)$/i;const t=function(){const t=Object.fromEntries(new URL(location.href).searchParams);let n=null,s=null;if("issue-term"in t){if(n=t["issue-term"],void 0!==n){if(""===n)throw new Error("When issue-term is specified, it cannot be blank.");if(-1!==["title","url","pathname","og:title"].indexOf(n)){if(!t[n])throw new Error(`Unable to find "${n}" metadata.`);n=t[n]}}}else{if(!("issue-number"in t))throw new Error('"issue-term" or "issue-number" must be specified.');if(s=+t["issue-number"],s.toString(10)!==t["issue-number"])throw new Error(`issue-number is invalid. "${t["issue-number"]}`)}if(!("repo"in t))throw new Error('"repo" is required.');if(!("origin"in t))throw new Error('"origin" is required.');const r=e.exec(t.repo);if(null===r)throw new Error(`Invalid repo: "${t.repo}"`);return{owner:r[1],repo:r[2],issueTerm:n,issueNumber:s,origin:t.origin,url:t.url,title:t.title,description:t.description,label:t.label,theme:t.theme||"github-light",session:t.session}}(),n={value:null};function s(e){return`https://api.utteranc.es/authorize?${new URLSearchParams({redirect_uri:e})}`}const r=["+1","-1","laugh","hooray","confused","heart","rocket","eyes"];let i,o;function a(e,t){(t=t||{}).mode="cors",t.cache="no-cache";const s=new Request("https://api.github.com/"+e,t);return s.headers.set("Accept","application/vnd.github.v3+json"),null!==n.value&&s.headers.set("Authorization",`token ${n.value}`),s}const l={standard:{limit:Number.MAX_VALUE,remaining:Number.MAX_VALUE,reset:0},search:{limit:Number.MAX_VALUE,remaining:Number.MAX_VALUE,reset:0}};function c(e){return fetch(e).then((t=>(401===t.status&&(n.value=null),403===t.status&&t.json().then((e=>{"Resource not accessible by integration"===e.message&&window.dispatchEvent(new CustomEvent("not-installed"))})),function(e){const t=e.headers.get("X-RateLimit-Limit"),n=e.headers.get("X-RateLimit-Remaining"),s=e.headers.get("X-RateLimit-Reset"),r=/\/search\//.test(e.url),i=r?l.search:l.standard;if(i.limit=+t,i.remaining=+n,i.reset=+s,403===e.status&&0===i.remaining){const e=new Date(0);e.setUTCSeconds(i.reset);const t=Math.round((e.getTime()-(new Date).getTime())/1e3/60),n=r?"search API":"non-search APIs";console.warn(`Rate limit exceeded for ${n}. Resets in ${t} minute${1===t?"":"s"}.`)}}(t),"GET"===e.method&&-1!==[401,403].indexOf(t.status)&&e.headers.has("Authorization")?(e.headers.delete("Authorization"),c(e)):t)))}function h(e,t=!1){const n=a(`repos/${i}/${o}/contents/${e}?ref=master`);return t&&n.headers.set("accept","application/vnd.github.VERSION.html"),c(n).then((n=>{if(404===n.status)throw new Error(`Repo "${i}/${o}" does not have a file named "${e}" in the "master" branch.`);if(!n.ok)throw new Error(`Error fetching ${e}.`);return t?n.text():n.json()})).then((e=>{if(t)return e;const{content:n}=e,s=(r=(r=n).replace(/\s/g,""),decodeURIComponent(escape(atob(r))));var r;return JSON.parse(s)}))}function u(e,t){const n=function(e,t){const n=a(`repos/${i}/${o}/issues/${e}/comments?page=${t}&per_page=25`);return n.headers.set("Accept","application/vnd.github.VERSION.html+json,application/vnd.github.v3+json"),n}(e,t);return c(n).then((e=>{if(!e.ok)throw new Error("Error fetching comments.");return e.json()}))}const d=[1e3,"second",6e4,"minute",36e5,"hour",864e5,"day",6048e5,"week",23328e5,"month"],m={month:"short",day:"numeric",year:"numeric"};let p;let g=-1;function v(){const e=document.body.scrollHeight;if(e===g)return;g=e;const t={type:"resize",height:e};parent.postMessage(t,p)}let f=0;function b(){const e=Date.now();e-f>50&&(f=e,setTimeout(v,50))}const w={"+1":"Thumbs Up","-1":"Thumbs Down",laugh:"Laugh",hooray:"Hooray",confused:"Confused",heart:"Heart",rocket:"Rocket",eyes:"Eyes"},y={"+1":"👍","-1":"👎",laugh:"😂",hooray:"🎉",confused:"😕",heart:"❤",rocket:"🚀",eyes:"👀"};function $(e,t,n,s){return`\n <button\n reaction\n type="submit"\n action="javascript:"\n formaction="${e}"\n class="btn BtnGroup-item reaction-button"\n value="${t}"\n aria-label="Toggle ${w[t]} reaction"\n reaction-count="${s}"\n ${n?"disabl
//# sourceMappingURL=utterances.6ec01640.js.map