prreviewbuddy 0.27.2 → 0.30.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +72 -0
- package/README.md +9 -8
- package/dist/{delete_review-B3xciJ03.js → delete_review-B_2J2Wn9.js} +217 -22
- package/dist/main.js +102 -108
- package/dist/server.js +259 -51
- package/package.json +1 -1
- package/static/reviews.js +1 -1
- package/static/shell.css +72 -1
- package/static/workspace.js +29 -29
package/static/reviews.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./chunk-CIsM3PMS.js";import{n as t,t as n}from"./chunk-gBDI1-Cy.js";var r=[`all`,`in-progress`,`complete`];function i(e,t){let n=`${e} review${e===1?``:`s`}`;return e===t?n:`${n} · ${t} branch${t===1?``:`es`}`}function a(e,t){let n=Math.max(1,Math.ceil(e/15)),r=Math.min(Math.max(1,Math.floor(t)||1),n),i=(r-1)*15;return{page:r,pages:n,from:i,to:Math.min(i+15,e)}}function o(e){let t=new URLSearchParams(e.replace(/^#/,``)),n=t.get(`f`)??``,i=Number(t.get(`page`)??``);return{query:t.get(`q`)??``,filter:r.includes(n)?n:`all`,page:Number.isInteger(i)&&i>=1?i:1}}function s(e){let t=new URLSearchParams;e.query!==``&&t.set(`q`,e.query),e.filter!==`all`&&t.set(`f`,e.filter),e.page>1&&t.set(`page`,String(e.page));let n=t.toString();return n===``?``:`#${n}`}function c(e){return e===`complete`?`Reviewed`:e===`in-progress`?`In progress`:`New`}function l(e,t){if(e===0)return`Nothing selected`;let n=`${e} selected`;return t>0?`${n} · ${t} not shown`:n}function u(e){return e===0?`Delete`:`Delete ${e} review${e===1?``:`s`}`}function d(e){return`${u(e)}?`}function f(e,t,n){return e===``||t===``||t===e?`wait`:n?`hold`:`reload`}var p=[...document.querySelectorAll(`[data-card]`)],m=document.querySelector(`.prb-index`),h=document.querySelector(`[data-search]`),g=document.querySelector(`[data-no-matches]`),_=document.querySelector(`[data-count]`),v=document.querySelector(`[data-pager]`),y=document.querySelector(`[data-pages]`),b=document.querySelector(`[data-bulk]`),x=document.querySelector(`[data-bulk-count]`),S=document.querySelector(`[data-bulk-delete]`),C=document.querySelector(`[data-bulk-question]`),w=document.querySelector(`[data-bulk-confirm]`),T=document.querySelector(`[data-bulk-actions]`),E=document.querySelector(`[data-bulk-error]`),D=o(window.location.hash),O=new Set,k=!1;function A(){let e=D.query.trim().toLowerCase(),t=p.filter(t=>{let n=D.filter===`all`||t.dataset.status===D.filter,r=!e||(t.dataset.searchText??``).includes(e);return n&&r}),n=a(t.length,D.page);D.page=n.page;let r=new Set(t.slice(n.from,n.to));for(let e of p)e.hidden=!r.has(e);h&&h.value!==D.query&&(h.value=D.query);for(let e of document.querySelectorAll(`[data-filter]`))e.setAttribute(`aria-pressed`,String(e.dataset.filter===D.filter));_&&(_.textContent=i(t.reduce((e,t)=>e+Number(t.dataset.reviews??1),0),t.length)),g&&(g.hidden=t.length>0||p.length===0),j(n),B(t)}function j(e){if(!(!v||!y)&&(v.hidden=e.pages<2,y.textContent=``,!v.hidden)){for(let t=1;t<=e.pages;t+=1){let n=document.createElement(`button`);n.type=`button`,n.className=`prb-index-page`,n.dataset.page=String(t),n.textContent=String(t),n.setAttribute(`aria-label`,`Page ${t}`),t===e.page&&n.setAttribute(`aria-current`,`page`),y.append(n)}for(let t of v.querySelectorAll(`[data-page-step]`)){let n=e.page+Number(t.dataset.pageStep);t.disabled=n<1||n>e.pages}}}function M(e,t){D={...D,...e},A();let n=`${window.location.pathname}${window.location.search}${s(D)}`;t===`push`?window.history.pushState(null,``,n):window.history.replaceState(null,``,n)}function N(){document.documentElement.scrollTop=0,document.body.scrollTop=0}h?.addEventListener(`input`,()=>M({query:h.value,page:1},`replace`)),h?.addEventListener(`keydown`,e=>{e.key===`Escape`&&h.value!==``&&(e.preventDefault(),M({query:``,page:1},`replace`))});for(let e of document.querySelectorAll(`[data-filter]`))e.addEventListener(`click`,()=>{M({filter:e.dataset.filter??`all`,page:1},`push`)});v?.addEventListener(`click`,e=>{let t=e.target,n=t.closest(`[data-page]`),r=t.closest(`[data-page-step]`);!n&&!r||(M({page:n?Number(n.dataset.page):D.page+Number(r?.dataset.pageStep??0)},`push`),N())});for(let e of[`popstate`,`hashchange`])window.addEventListener(e,()=>{D=o(window.location.hash),A()});document.addEventListener(`click`,e=>{let t=e.target.closest(`[data-pin]`);if(!t?.dataset.pin)return;e.preventDefault(),e.stopPropagation();let n=t.getAttribute(`aria-pressed`)!==`true`;t.setAttribute(`aria-pressed`,String(n)),t.innerHTML=n?`★`:`☆`,t.setAttribute(`aria-label`,`${n?`Unpin`:`Pin`} this review`),t.title=n?`Unpin`:`Pin to the top`;let r=t.closest(`[data-card]`);r&&(r.dataset.pinned=String(n)),fetch(`/pin`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({id:t.dataset.pin,pinned:n})}).catch(()=>{})}),document.addEventListener(`click`,e=>{let t=e.target.closest(`[data-history-toggle]`);if(!t)return;e.preventDefault(),e.stopPropagation();let n=t.parentElement?.querySelector(`[data-history-list]`);if(!n)return;let r=n.hidden;n.hidden=!r,t.setAttribute(`aria-expanded`,String(r))}),A();function P(e){for(let t of document.querySelectorAll(`[data-menu]`)){if(t===e)continue;let n=t.querySelector(`[data-menu-panel]`),r=t.querySelector(`[data-menu-trigger]`);n&&(n.hidden=!0),r?.setAttribute(`aria-expanded`,`false`),F(t)}}function F(e){let t=e.querySelector(`[data-menu-items]`),n=e.querySelector(`[data-menu-confirm]`);t&&(t.hidden=!1),n&&(n.hidden=!0),e.querySelector(`[data-menu-error]`)?.remove(),e.querySelector(`[data-id-field]`)?.remove()}document.addEventListener(`keydown`,e=>{e.key===`Escape`&&P()}),document.addEventListener(`click`,e=>{let n=e.target,r=n.closest(`[data-menu]`);if(!r)return void P();let i=n.closest(`[data-menu-trigger]`);if(i){e.preventDefault(),e.stopPropagation();let t=r.querySelector(`[data-menu-panel]`);if(!t)return;let n=t.hidden;P(r),F(r),t.hidden=!n,i.setAttribute(`aria-expanded`,String(n));return}let a=n.closest(`[data-copy-id]`);if(a?.dataset.copyId){e.preventDefault(),e.stopPropagation(),t(a,a.dataset.copyId);return}if(n.closest(`[data-delete]`)){e.preventDefault(),e.stopPropagation();let t=r.querySelector(`[data-menu-items]`),n=r.querySelector(`[data-menu-confirm]`);t&&(t.hidden=!0),n&&(n.hidden=!1);return}if(n.closest(`[data-cancel-delete]`)){e.preventDefault(),e.stopPropagation(),F(r);return}if(n.closest(`[data-confirm-delete]`)){e.preventDefault(),e.stopPropagation(),I(r);return}e.preventDefault(),e.stopPropagation()});async function I(e){let t=e.querySelector(`[data-delete]`),n=t?.dataset.delete;if(!n)return;let r=e.querySelector(`[data-menu-confirm]`),i=e.querySelector(`[data-confirm-delete]`);i&&(i.disabled=!0,i.textContent=`Deleting`);try{let r=await fetch(`/delete`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({id:n,scope:t?.dataset.scope??`review`})});if(r.ok)return void window.location.reload();L(e,(await r.json().catch(()=>null))?.error??`That could not be deleted.`)}catch{L(e,`The workspace server did not answer. It may have stopped.`)}i&&(i.disabled=!1,i.textContent=`Delete`),r&&(r.hidden=!0);let a=e.querySelector(`[data-menu-items]`);a&&(a.hidden=!1)}function L(e,t){e.querySelector(`[data-menu-error]`)?.remove();let n=document.createElement(`p`);n.className=`prb-menu-error`,n.setAttribute(`data-menu-error`,``),n.textContent=t,e.querySelector(`[data-menu-panel]`)?.append(n)}function R(e){k=e,e||O.clear(),m&&(e?m.dataset.selecting=``:delete m.dataset.selecting),document.querySelector(`[data-select-mode]`)?.setAttribute(`aria-pressed`,String(e));for(let t of document.querySelectorAll(`.prb-card-link`))e?t.setAttribute(`aria-disabled`,`true`):t.removeAttribute(`aria-disabled`);z(),A()}function z(){w&&(w.hidden=!0),T&&(T.hidden=!1),E&&(E.hidden=!0,E.textContent=``)}function B(e){for(let e of p){let t=O.has(e.dataset.id??``),n=e.querySelector(`[data-select]`);n&&(n.checked=t),t?e.dataset.selected=``:delete e.dataset.selected}if(!b||(b.hidden=!k,!k))return;let t=new Set(e.map(e=>e.dataset.id)),n=[...O].filter(e=>!t.has(e)).length;x&&(x.textContent=l(O.size,n)),S&&(S.textContent=u(U()));for(let e of b.querySelectorAll(`[data-bulk-mark], [data-bulk-delete]`))e.disabled=O.size===0}document.querySelector(`[data-select-mode]`)?.addEventListener(`click`,()=>{R(!k)});function V(e){O.has(e)?O.delete(e):O.add(e),z(),A()}document.addEventListener(`change`,e=>{let t=e.target.closest(`[data-select]`);t?.dataset.select&&V(t.dataset.select)}),document.addEventListener(`click`,e=>{if(!k)return;let t=e.target,n=t.closest(`[data-card]`);n?.dataset.id&&(t.closest(`[data-select], [data-pin], [data-menu], [data-history-toggle]`)||(e.preventDefault(),V(n.dataset.id)))}),document.addEventListener(`keydown`,e=>{if(!k||e.key!==`Enter`)return;let t=e.target.closest(`.prb-card-link`)?.closest(`[data-card]`);t?.dataset.id&&(e.preventDefault(),V(t.dataset.id))});function H(){return p.filter(e=>O.has(e.dataset.id??``))}function U(){return H().reduce((e,t)=>e+Number(t.dataset.reviews??1),0)}function W(e){E&&(E.textContent=e,E.hidden=!1)}function G(e){for(let t of b?.querySelectorAll(`button`)??[])t.disabled=e}async function K(e){let t=[...O];if(t.length===0)return;G(!0);try{if(!(await fetch(`/status`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({ids:t,complete:e})})).ok)return G(!1),W(`That could not be saved. The workspace server refused it.`)}catch{return G(!1),W(`The workspace server did not answer. It may have stopped.`)}let n=e?`complete`:`in-progress`;for(let e of H()){e.dataset.status=n;let t=e.querySelector(`.prb-card-status`);t&&(t.dataset.status=n,t.textContent=c(n))}G(!1),R(!1)}async function q(){let e=[...O];if(e.length===0)return;G(!0);let t=null;try{let n=await fetch(`/delete`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({ids:e})});if(t=n.ok?await n.json().catch(()=>null):null,!t)return G(!1),z(),W(`Nothing was deleted. The workspace server refused it.`)}catch{return G(!1),z(),W(`The workspace server did not answer. It may have stopped.`)}let n=t.blocked??[],r=new Set(n.map(e=>e.id));for(let e of H())r.has(e.dataset.id??``)||e.remove();p=p.filter(e=>e.isConnected),O.clear();for(let e of r)O.add(e);if(G(!1),z(),n.length===0)return R(!1);A(),W([...new Set(n.map(e=>e.error))].join(` `))}b?.addEventListener(`click`,e=>{let t=e.target,n=t.closest(`[data-bulk-mark]`);if(n)return void K(n.dataset.bulkMark===`complete`);if(t.closest(`[data-bulk-delete]`)){C&&(C.textContent=d(U())),T&&(T.hidden=!0),w&&(w.hidden=!1);return}if(t.closest(`[data-bulk-confirm-delete]`))return void q();if(t.closest(`[data-bulk-cancel-delete]`))return z();if(t.closest(`[data-bulk-cancel]`))return R(!1)}),e(window,()=>window.location.reload());var J=document.body.dataset.indexRevision??``,Y=document.body.dataset.live===`true`?Date.now():0,X=!1;function Z(){return O.size>0||document.activeElement===h}function Q(){X&&!Z()&&window.location.reload()}async function $(){try{let e=await fetch(`/revision`);if(e.ok){let t=await e.json();t.live&&Y===0&&(Y=Date.now()),t.live||(Y=0);let n=f(J,t.revision??``,Z());if(n===`reload`)return void window.location.reload();n===`hold`&&(X=!0)}}catch{}window.setTimeout(()=>void $(),n(Y===0?2**53-1:Date.now()-Y))}$(),h?.addEventListener(`blur`,Q),document.addEventListener(`click`,()=>window.setTimeout(Q,0));
|
|
1
|
+
import{t as e}from"./chunk-CIsM3PMS.js";import{n as t,t as n}from"./chunk-gBDI1-Cy.js";function r(e,t){t.forEach((t,n)=>{e.children[n]!==t&&e.insertBefore(t,e.children[n]??null)})}var i=[`all`,`queue`,`saved`,`in-progress`,`complete`];function a(e,t){let n=`${e} review${e===1?``:`s`}`;return e===t?n:`${n} · ${t} branch${t===1?``:`es`}`}function o(e,t){let n=Math.max(1,Math.ceil(e/15)),r=Math.min(Math.max(1,Math.floor(t)||1),n),i=(r-1)*15;return{page:r,pages:n,from:i,to:Math.min(i+15,e)}}function s(e){let t=new URLSearchParams(e.replace(/^#/,``)),n=t.get(`f`)??``,r=Number(t.get(`page`)??``);return{query:t.get(`q`)??``,filter:i.includes(n)?n:`all`,author:t.get(`by`)??``,page:Number.isInteger(r)&&r>=1?r:1}}function c(e){let t=new URLSearchParams;e.query!==``&&t.set(`q`,e.query),e.filter!==`all`&&t.set(`f`,e.filter),e.author!==``&&t.set(`by`,e.author),e.page>1&&t.set(`page`,String(e.page));let n=t.toString();return n===``?``:`#${n}`}function l(e,t){return t===`all`||t===`queue`?!0:t===`saved`?e.pinned===!0:e.status===t}function ee(e,t){return t===``||e===t}function u(e){return e===`complete`?`Mark reviewed`:`Mark in progress`}function te(e,t){return t===`queue`?e.filter(e=>e.queue!==void 0).sort((e,t)=>(e.queue??0)-(t.queue??0)):e}function d(e){return e===0?`Queue`:`Queue ${e}`}function ne(e){return e===`complete`?`Reviewed`:e===`in-progress`?`In progress`:`New`}function re(e,t){if(e===0)return`Nothing selected`;let n=`${e} selected`;return t>0?`${n} · ${t} not shown`:n}function f(e){return e===0?`Delete`:`Delete ${e} review${e===1?``:`s`}`}function ie(e){return`${f(e)}?`}function ae(e,t,n){return e===``||t===``||t===e?`wait`:n?`hold`:`reload`}var p=[...document.querySelectorAll(`[data-card]`)],m=document.querySelector(`[data-cards]`),h=document.querySelector(`.prb-index`);function g(e){return{id:e.dataset.id??``,queue:e.dataset.queue===void 0?void 0:Number(e.dataset.queue),status:e.dataset.status??`new`,pinned:e.dataset.pinned===`true`}}var _=document.querySelector(`[data-search]`),v=document.querySelector(`[data-author-filter]`),y=document.querySelector(`[data-no-matches]`),b=document.querySelector(`[data-count]`),x=document.querySelector(`[data-pager]`),S=document.querySelector(`[data-pages]`),C=document.querySelector(`[data-bulk]`),w=document.querySelector(`[data-bulk-count]`),T=document.querySelector(`[data-bulk-delete]`),E=document.querySelector(`[data-bulk-question]`),D=document.querySelector(`[data-bulk-confirm]`),O=document.querySelector(`[data-bulk-actions]`),k=document.querySelector(`[data-bulk-error]`),A=s(window.location.hash),j=new Set,M=!1;function N(){let e=A.query.trim().toLowerCase();A.author!==``&&![...v?.options??[]].some(e=>e.value===A.author)&&(A.author=``);let t=te(p.filter(t=>(!e||(t.dataset.searchText??``).includes(e))&&l(g(t),A.filter)&&ee(t.dataset.author,A.author)).map(e=>({...g(e),card:e})),A.filter).map(e=>e.card),n=o(t.length,A.page);A.page=n.page;let i=t.slice(n.from,n.to),s=new Set(i);for(let e of p)e.hidden=!s.has(e);m&&r(m,i),_&&_.value!==A.query&&(_.value=A.query),v&&(v.value=A.author,A.author===``?delete v.dataset.active:v.dataset.active=``);for(let e of document.querySelectorAll(`[data-filter]`))e.setAttribute(`aria-pressed`,String(e.dataset.filter===A.filter));b&&(b.textContent=a(t.reduce((e,t)=>e+Number(t.dataset.reviews??1),0),t.length)),y&&(y.hidden=t.length>0||p.length===0),P(n),V(t)}function P(e){if(!(!x||!S)&&(x.hidden=e.pages<2,S.textContent=``,!x.hidden)){for(let t=1;t<=e.pages;t+=1){let n=document.createElement(`button`);n.type=`button`,n.className=`prb-index-page`,n.dataset.page=String(t),n.textContent=String(t),n.setAttribute(`aria-label`,`Page ${t}`),t===e.page&&n.setAttribute(`aria-current`,`page`),S.append(n)}for(let t of x.querySelectorAll(`[data-page-step]`)){let n=e.page+Number(t.dataset.pageStep);t.disabled=n<1||n>e.pages}}}function F(e,t){A={...A,...e},N();let n=`${window.location.pathname}${window.location.search}${c(A)}`;t===`push`?window.history.pushState(null,``,n):window.history.replaceState(null,``,n)}function oe(){document.documentElement.scrollTop=0,document.body.scrollTop=0}_?.addEventListener(`input`,()=>F({query:_.value,page:1},`replace`)),_?.addEventListener(`keydown`,e=>{e.key===`Escape`&&_.value!==``&&(e.preventDefault(),F({query:``,page:1},`replace`))});for(let e of document.querySelectorAll(`[data-filter]`))e.addEventListener(`click`,()=>{F({filter:e.dataset.filter??`all`,page:1},`push`)});v?.addEventListener(`change`,()=>{F({author:v.value,page:1},`push`)}),x?.addEventListener(`click`,e=>{let t=e.target,n=t.closest(`[data-page]`),r=t.closest(`[data-page-step]`);!n&&!r||(F({page:n?Number(n.dataset.page):A.page+Number(r?.dataset.pageStep??0)},`push`),oe())});for(let e of[`popstate`,`hashchange`])window.addEventListener(e,()=>{A=s(window.location.hash),N()});document.addEventListener(`click`,e=>{let t=e.target.closest(`[data-pin]`);if(!t?.dataset.pin)return;e.preventDefault(),e.stopPropagation();let n=t.getAttribute(`aria-pressed`)!==`true`;t.setAttribute(`aria-pressed`,String(n)),t.innerHTML=n?`★`:`☆`,t.setAttribute(`aria-label`,`${n?`Unsave`:`Save`} this review`);let r=t.closest(`[data-card]`);r&&(r.dataset.pinned=String(n)),fetch(`/pin`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({id:t.dataset.pin,pinned:n})}).catch(()=>{})});async function se(e,t,n){let r;try{let e=await fetch(`/queue`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({id:t,action:n})});if(!e.ok)return;r=(await e.json()).queue}catch{return}let i=new Map(r.map((e,t)=>[e,t]));for(let e of p){let t=i.get(e.dataset.id??``);t===void 0?delete e.dataset.queue:e.dataset.queue=String(t)}let a=i.has(t);e.dataset.queueAction=a?`remove`:`add`,e.textContent=a?`Remove from review queue`:`Add to review queue`;let o=document.querySelector(`[data-queue-pill]`);o&&(o.textContent=d(r.length)),N()}document.addEventListener(`click`,e=>{let t=e.target.closest(`[data-history-toggle]`);if(!t)return;e.preventDefault(),e.stopPropagation();let n=t.parentElement?.querySelector(`[data-history-list]`);if(!n)return;let r=n.hidden;n.hidden=!r,t.setAttribute(`aria-expanded`,String(r))}),N();function I(e){for(let t of document.querySelectorAll(`[data-menu]`)){if(t===e)continue;let n=t.querySelector(`[data-menu-panel]`),r=t.querySelector(`[data-menu-trigger]`);n&&(n.hidden=!0),r?.setAttribute(`aria-expanded`,`false`),L(t)}}function L(e){let t=e.querySelector(`[data-menu-items]`),n=e.querySelector(`[data-menu-confirm]`);t&&(t.hidden=!1),n&&(n.hidden=!0),e.querySelector(`[data-menu-error]`)?.remove(),e.querySelector(`[data-id-field]`)?.remove()}document.addEventListener(`keydown`,e=>{e.key===`Escape`&&I()}),document.addEventListener(`click`,e=>{let n=e.target,r=n.closest(`[data-menu]`);if(!r)return void I();let i=n.closest(`[data-menu-trigger]`);if(i){e.preventDefault(),e.stopPropagation();let t=r.querySelector(`[data-menu-panel]`);if(!t)return;let n=t.hidden;I(r),L(r),t.hidden=!n,i.setAttribute(`aria-expanded`,String(n));return}let a=n.closest(`[data-copy-id]`);if(a?.dataset.copyId){e.preventDefault(),e.stopPropagation(),t(a,a.dataset.copyId);return}let o=n.closest(`[data-mark-status]`);if(o?.dataset.markId){e.preventDefault(),e.stopPropagation(),I(),ue(o.dataset.markId,o.dataset.markStatus===`complete`);return}let s=n.closest(`[data-queue-action]`);if(s?.dataset.queueId){e.preventDefault(),e.stopPropagation(),I(),se(s,s.dataset.queueId,s.dataset.queueAction===`remove`?`remove`:`add`);return}if(n.closest(`[data-delete]`)){e.preventDefault(),e.stopPropagation();let t=r.querySelector(`[data-menu-items]`),n=r.querySelector(`[data-menu-confirm]`);t&&(t.hidden=!0),n&&(n.hidden=!1);return}if(n.closest(`[data-cancel-delete]`)){e.preventDefault(),e.stopPropagation(),L(r);return}if(n.closest(`[data-confirm-delete]`)){e.preventDefault(),e.stopPropagation(),ce(r);return}e.preventDefault(),e.stopPropagation()});async function ce(e){let t=e.querySelector(`[data-delete]`),n=t?.dataset.delete;if(!n)return;let r=e.querySelector(`[data-menu-confirm]`),i=e.querySelector(`[data-confirm-delete]`);i&&(i.disabled=!0,i.textContent=`Deleting`);try{let r=await fetch(`/delete`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({id:n,scope:t?.dataset.scope??`review`})});if(r.ok)return void window.location.reload();R(e,(await r.json().catch(()=>null))?.error??`That could not be deleted.`)}catch{R(e,`The workspace server did not answer. It may have stopped.`)}i&&(i.disabled=!1,i.textContent=`Delete`),r&&(r.hidden=!0);let a=e.querySelector(`[data-menu-items]`);a&&(a.hidden=!1)}function R(e,t){e.querySelector(`[data-menu-error]`)?.remove();let n=document.createElement(`p`);n.className=`prb-menu-error`,n.setAttribute(`data-menu-error`,``),n.textContent=t,e.querySelector(`[data-menu-panel]`)?.append(n)}function z(e){M=e,e||j.clear(),h&&(e?h.dataset.selecting=``:delete h.dataset.selecting),document.querySelector(`[data-select-mode]`)?.setAttribute(`aria-pressed`,String(e));for(let t of document.querySelectorAll(`.prb-card-link`))e?t.setAttribute(`aria-disabled`,`true`):t.removeAttribute(`aria-disabled`);B(),N()}function B(){D&&(D.hidden=!0),O&&(O.hidden=!1),k&&(k.hidden=!0,k.textContent=``)}function V(e){for(let e of p){let t=j.has(e.dataset.id??``),n=e.querySelector(`[data-select]`);n&&(n.checked=t),t?e.dataset.selected=``:delete e.dataset.selected}if(!C||(C.hidden=!M,!M))return;let t=new Set(e.map(e=>e.dataset.id)),n=[...j].filter(e=>!t.has(e)).length;w&&(w.textContent=re(j.size,n)),T&&(T.textContent=f(W()));for(let e of C.querySelectorAll(`[data-bulk-mark], [data-bulk-delete]`))e.disabled=j.size===0}document.querySelector(`[data-select-mode]`)?.addEventListener(`click`,()=>{z(!M)});function H(e){j.has(e)?j.delete(e):j.add(e),B(),N()}document.addEventListener(`change`,e=>{let t=e.target.closest(`[data-select]`);t?.dataset.select&&H(t.dataset.select)}),document.addEventListener(`click`,e=>{if(!M)return;let t=e.target,n=t.closest(`[data-card]`);n?.dataset.id&&(t.closest(`[data-select], [data-pin], [data-menu], [data-history-toggle]`)||(e.preventDefault(),H(n.dataset.id)))}),document.addEventListener(`keydown`,e=>{if(!M||e.key!==`Enter`)return;let t=e.target.closest(`.prb-card-link`)?.closest(`[data-card]`);t?.dataset.id&&(e.preventDefault(),H(t.dataset.id))});function U(){return p.filter(e=>j.has(e.dataset.id??``))}function W(){return U().reduce((e,t)=>e+Number(t.dataset.reviews??1),0)}function G(e){k&&(k.textContent=e,k.hidden=!1)}function K(e){for(let t of C?.querySelectorAll(`button`)??[])t.disabled=e}async function le(e){let t=[...j];if(t.length!==0){K(!0);try{if(!(await fetch(`/status`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({ids:t,complete:e})})).ok)return K(!1),G(`That could not be saved. The workspace server refused it.`)}catch{return K(!1),G(`The workspace server did not answer. It may have stopped.`)}q(U(),e),K(!1),z(!1)}}function q(e,t){let n=t?`complete`:`in-progress`,r=t?`in-progress`:`complete`;for(let t of e){t.dataset.status=n;let e=t.querySelector(`.prb-card-status`);e&&(e.dataset.status=n,e.textContent=ne(n));let i=t.querySelector(`[data-mark-status]`);i&&(i.dataset.markStatus=r,i.textContent=u(r))}}async function ue(e,t){try{if(!(await fetch(`/status`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({ids:[e],complete:t})})).ok)return}catch{return}q(p.filter(t=>t.dataset.id===e),t),N()}async function J(){let e=[...j];if(e.length===0)return;K(!0);let t=null;try{let n=await fetch(`/delete`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({ids:e})});if(t=n.ok?await n.json().catch(()=>null):null,!t)return K(!1),B(),G(`Nothing was deleted. The workspace server refused it.`)}catch{return K(!1),B(),G(`The workspace server did not answer. It may have stopped.`)}let n=t.blocked??[],r=new Set(n.map(e=>e.id));for(let e of U())r.has(e.dataset.id??``)||e.remove();p=p.filter(e=>e.isConnected),j.clear();for(let e of r)j.add(e);if(K(!1),B(),n.length===0)return z(!1);N(),G([...new Set(n.map(e=>e.error))].join(` `))}C?.addEventListener(`click`,e=>{let t=e.target,n=t.closest(`[data-bulk-mark]`);if(n)return void le(n.dataset.bulkMark===`complete`);if(t.closest(`[data-bulk-delete]`)){E&&(E.textContent=ie(W())),O&&(O.hidden=!0),D&&(D.hidden=!1);return}if(t.closest(`[data-bulk-confirm-delete]`))return void J();if(t.closest(`[data-bulk-cancel-delete]`))return B();if(t.closest(`[data-bulk-cancel]`))return z(!1)}),e(window,()=>window.location.reload());var de=document.body.dataset.indexRevision??``,Y=document.body.dataset.live===`true`?Date.now():0,X=!1;function Z(){return j.size>0||document.activeElement===_}function Q(){X&&!Z()&&window.location.reload()}async function $(){try{let e=await fetch(`/revision`);if(e.ok){let t=await e.json();t.live&&Y===0&&(Y=Date.now()),t.live||(Y=0);let n=ae(de,t.revision??``,Z());if(n===`reload`)return void window.location.reload();n===`hold`&&(X=!0)}}catch{}window.setTimeout(()=>void $(),n(Y===0?2**53-1:Date.now()-Y))}$(),_?.addEventListener(`blur`,Q),document.addEventListener(`click`,()=>window.setTimeout(Q,0));
|
package/static/shell.css
CHANGED
|
@@ -579,6 +579,12 @@ a.prb-rail-item { text-decoration: none; }
|
|
|
579
579
|
color: var(--text-primary);
|
|
580
580
|
}
|
|
581
581
|
.prb-rail-item:focus-visible { outline: 2px solid var(--brand-hover); outline-offset: -2px; }
|
|
582
|
+
/* The pages under a review type (Issues, Questions, Files, PR context) and the links at the foot
|
|
583
|
+
share the group rows' white, so the grey themes in the review path read as their own list.
|
|
584
|
+
Weight still separates these from the group rows above them. Must come after `.prb-rail-item`:
|
|
585
|
+
the two are one class each, so whichever is later wins. One class, so Stop server's two-class
|
|
586
|
+
danger hover still wins over it. */
|
|
587
|
+
.prb-rail-link { color: var(--text-primary); }
|
|
582
588
|
|
|
583
589
|
.prb-rail-order {
|
|
584
590
|
flex: none;
|
|
@@ -589,6 +595,19 @@ a.prb-rail-item { text-decoration: none; }
|
|
|
589
595
|
font-variant-numeric: tabular-nums;
|
|
590
596
|
}
|
|
591
597
|
.prb-rail-item[aria-current='true'] .prb-rail-order { color: var(--wordmark-accent); }
|
|
598
|
+
/* The same 18px column as the theme numbers, so every label in the rail starts at one edge. Centred
|
|
599
|
+
rather than on the baseline: an svg's baseline is its bottom edge, which sits it above the text. */
|
|
600
|
+
.prb-rail-icon {
|
|
601
|
+
flex: none;
|
|
602
|
+
display: flex;
|
|
603
|
+
align-self: center;
|
|
604
|
+
width: 18px;
|
|
605
|
+
height: 18px;
|
|
606
|
+
color: var(--text-muted);
|
|
607
|
+
}
|
|
608
|
+
.prb-rail-icon svg { width: 18px; height: 18px; }
|
|
609
|
+
.prb-rail-item:hover .prb-rail-icon,
|
|
610
|
+
.prb-rail-item[aria-current='true'] .prb-rail-icon { color: inherit; }
|
|
592
611
|
|
|
593
612
|
.prb-rail-label { flex: 1; min-width: 0; line-height: 1.35; }
|
|
594
613
|
.prb-rail-title { display: block; }
|
|
@@ -2290,6 +2309,38 @@ a.prb-rail-item { text-decoration: none; }
|
|
|
2290
2309
|
color: var(--text-tertiary, var(--text-secondary));
|
|
2291
2310
|
}
|
|
2292
2311
|
|
|
2312
|
+
/* The way back into the batch. A bordered row rather than a bare link, because it is the one
|
|
2313
|
+
destination on this page that changes as the reviewer works, and it has to be findable at a
|
|
2314
|
+
glance on every return. The label and the title are separate lines of weight so the eye lands
|
|
2315
|
+
on which review it will open. */
|
|
2316
|
+
.prb-index-continue {
|
|
2317
|
+
display: flex;
|
|
2318
|
+
align-items: baseline;
|
|
2319
|
+
gap: 10px;
|
|
2320
|
+
margin: 0 0 14px;
|
|
2321
|
+
padding: 10px 14px;
|
|
2322
|
+
border: 1px solid var(--border);
|
|
2323
|
+
border-left: 3px solid var(--brand);
|
|
2324
|
+
border-radius: 8px;
|
|
2325
|
+
color: var(--text-primary);
|
|
2326
|
+
text-decoration: none;
|
|
2327
|
+
}
|
|
2328
|
+
.prb-index-continue:hover { border-color: var(--brand); }
|
|
2329
|
+
.prb-index-continue:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
|
|
2330
|
+
.prb-index-continue-label {
|
|
2331
|
+
flex: none;
|
|
2332
|
+
font-size: 12px;
|
|
2333
|
+
font-weight: 600;
|
|
2334
|
+
color: var(--brand);
|
|
2335
|
+
}
|
|
2336
|
+
.prb-index-continue-title {
|
|
2337
|
+
min-width: 0;
|
|
2338
|
+
overflow: hidden;
|
|
2339
|
+
font-size: 13px;
|
|
2340
|
+
white-space: nowrap;
|
|
2341
|
+
text-overflow: ellipsis;
|
|
2342
|
+
}
|
|
2343
|
+
|
|
2293
2344
|
/* Between the controls and the list, quiet, because it describes the list rather than announcing
|
|
2294
2345
|
anything. It is rewritten in the browser as a filter narrows the set. */
|
|
2295
2346
|
.prb-index-summary {
|
|
@@ -2323,14 +2374,18 @@ a.prb-rail-item { text-decoration: none; }
|
|
|
2323
2374
|
color: #ffffff;
|
|
2324
2375
|
}
|
|
2325
2376
|
|
|
2377
|
+
/* Wraps, so a narrow window gives the search its own line and puts the filters beneath it rather
|
|
2378
|
+
than crushing the field to a few letters beside five pills. The search's basis is what makes the
|
|
2379
|
+
wrap happen: with a basis of zero it would shrink to nothing before the row ever broke. */
|
|
2326
2380
|
.prb-index-controls {
|
|
2327
2381
|
display: flex;
|
|
2382
|
+
flex-wrap: wrap;
|
|
2328
2383
|
gap: 12px;
|
|
2329
2384
|
align-items: center;
|
|
2330
2385
|
margin-bottom: 18px;
|
|
2331
2386
|
}
|
|
2332
2387
|
.prb-index-search {
|
|
2333
|
-
flex: 1;
|
|
2388
|
+
flex: 1 1 240px;
|
|
2334
2389
|
min-width: 0;
|
|
2335
2390
|
padding: 9px 12px;
|
|
2336
2391
|
border: 1px solid var(--border);
|
|
@@ -2342,6 +2397,22 @@ a.prb-rail-item { text-decoration: none; }
|
|
|
2342
2397
|
}
|
|
2343
2398
|
.prb-index-search:focus { outline: none; border-color: var(--brand); }
|
|
2344
2399
|
.prb-index-filters { display: flex; gap: 4px; flex: none; }
|
|
2400
|
+
.prb-index-author {
|
|
2401
|
+
flex: none;
|
|
2402
|
+
max-width: 200px;
|
|
2403
|
+
padding: 7px 10px;
|
|
2404
|
+
border: 1px solid var(--border);
|
|
2405
|
+
border-radius: 8px;
|
|
2406
|
+
background: var(--surface-2);
|
|
2407
|
+
color: var(--text-primary);
|
|
2408
|
+
font: inherit;
|
|
2409
|
+
font-size: 12.5px;
|
|
2410
|
+
cursor: pointer;
|
|
2411
|
+
}
|
|
2412
|
+
.prb-index-author:hover { border-color: var(--brand); }
|
|
2413
|
+
.prb-index-author:focus-visible { outline: none; border-color: var(--brand); }
|
|
2414
|
+
/* Filled like a pressed pill once it narrows the list, so a filtered view is never mistaken for all of it. */
|
|
2415
|
+
.prb-index-author[data-active] { border-color: var(--brand); background: var(--brand); color: #ffffff; }
|
|
2345
2416
|
.prb-index-filters button {
|
|
2346
2417
|
padding: 7px 12px;
|
|
2347
2418
|
border: 1px solid var(--border);
|
package/static/workspace.js
CHANGED
|
@@ -2,12 +2,12 @@ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["chunk-B80S6zbH.js","ch
|
|
|
2
2
|
import{t as e}from"./chunk-CIsM3PMS.js";import{n as t,t as n}from"./chunk-gBDI1-Cy.js";function r(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`)}var i=`pr-helper-code-block`,a=`pr-helper-code-copy`,o=`\0`,s=``,c=/\u0000(\d+)\u0000/g,ee=/^\u0000\d+\u0000$/,l=/\u0001(\d+)\u0001/g,u=/^(?:https?:\/\/|#)/i;function te(e){let{text:t,blocks:n}=ne(e.replace(/[\u0000\u0001]/g,``));return re(ie(t),n)}function ne(e){let t=[],n=e.split(`
|
|
3
3
|
`),r=[],i=0;for(;i<n.length;){let e=n[i].match(/^\s*(`{3,}|~{3,})\s*[\w+#.-]*\s*$/);if(!e){r.push(n[i]),i+=1;continue}let a=RegExp(`^\\s*${e[1][0]}{3,}\\s*$`),s=[];for(i+=1;i<n.length&&!a.test(n[i]);)s.push(n[i]),i+=1;i+=1,r.push(`${o}${t.length}${o}`),t.push(s.join(`
|
|
4
4
|
`))}return{text:r.join(`
|
|
5
|
-
`),blocks:t}}function re(e,t){return e.replace(c,(e,n)=>`<div class="${i}"><pre><code>${r(t[Number(n)])}</code></pre><button type="button" class="${a}" aria-label="Copy code">Copy</button></div>`)}function ie(e){let t=[],n=[],r=[],i=null,a=()=>{n.length&&t.push(`<p>${
|
|
6
|
-
`)){let e=o.trim();if(!e){a();continue}if(ee.test(e)){a(),t.push(e);continue}if(/^(?:-{3,}|\*{3,}|_{3,})$/.test(e)){a(),t.push(`<hr>`);continue}let s=e.match(/^(#{1,6})\s+(.+)$/);if(s){a();let e=Math.min(s[1].length,3)+3;t.push(`<h${e}>${
|
|
5
|
+
`),blocks:t}}function re(e,t){return e.replace(c,(e,n)=>`<div class="${i}"><pre><code>${r(t[Number(n)])}</code></pre><button type="button" class="${a}" aria-label="Copy code">Copy</button></div>`)}function ie(e){let t=[],n=[],r=[],i=null,a=()=>{n.length&&t.push(`<p>${d(n.join(` `))}</p>`),r.length&&t.push(`<blockquote>${d(r.join(` `))}</blockquote>`),i&&t.push(`<${i.tag}>${i.items.map(e=>`<li>${d(e)}</li>`).join(``)}</${i.tag}>`),n=[],r=[],i=null};for(let o of e.split(`
|
|
6
|
+
`)){let e=o.trim();if(!e){a();continue}if(ee.test(e)){a(),t.push(e);continue}if(/^(?:-{3,}|\*{3,}|_{3,})$/.test(e)){a(),t.push(`<hr>`);continue}let s=e.match(/^(#{1,6})\s+(.+)$/);if(s){a();let e=Math.min(s[1].length,3)+3;t.push(`<h${e}>${d(s[2])}</h${e}>`);continue}let c=e.match(/^[-*+]\s+(.+)$/);if(c){i?.tag!==`ul`&&(a(),i={tag:`ul`,items:[]}),i.items.push(c[1]);continue}let l=e.match(/^\d{1,9}[.)]\s+(.+)$/);if(l){i?.tag!==`ol`&&(a(),i={tag:`ol`,items:[]}),i.items.push(l[1]);continue}let u=e.match(/^>\s?(.*)$/);if(u){r.length||a(),r.push(u[1]);continue}if(i&&i.items.length){i.items[i.items.length-1]+=` ${e}`;continue}if(r.length){r[r.length-1]+=` ${e}`;continue}n.push(e)}return a(),t.join(``)}function d(e){let t=[];return r(e).replace(/`([^`\n]+)`/g,(e,n)=>(t.push(n),`${s}${t.length-1}${s}`)).replace(/(?<!!)\[([^\]\n]+)\]\(([^)\s]+)\)/g,(e,t,n)=>u.test(n)?`<a href="${n}" target="_blank" rel="noopener noreferrer">${t}</a>`:e).replace(/\*\*([^*\n]+)\*\*/g,`<strong>$1</strong>`).replace(/__([^_\n]+)__/g,`<strong>$1</strong>`).replace(/(^|[^*\w])\*([^*\n]+)\*/g,`$1<em>$2</em>`).replace(/(^|[^_\w])_([^_\n]+)_(?![\w_])/g,`$1<em>$2</em>`).replace(l,(e,n)=>`<code>${t[Number(n)]}</code>`)}var ae=`pr-helper-selection-popover`,oe=`pr-helper-selection-popover-expanded`,se=`pr-helper-selection-copy-done`,ce=8,f=8,le=1e3,ue=`Copy selected text`,de=`Copy`,fe=`Copied`,pe=`pr-helper-selection-popover-flat`,p=null;function me(e){return`<button type="button" class="pr-helper-selection-menu-item" data-selection-action="${r(e.id)}">${r(e.label)}</button>`}function he(e){let t=new Map;for(let n of e){if(!n.section)continue;let e=t.get(n.section);e?e.push(n):t.set(n.section,[n])}return`${e.filter(e=>!e.section).map(me).join(``)}${[...t].map(([e,t])=>`
|
|
7
7
|
<div class="pr-helper-selection-menu-group">
|
|
8
8
|
<div class="pr-helper-selection-menu-heading">${r(e)}</div>
|
|
9
|
-
<div class="pr-helper-selection-menu-group-items">${t.map(
|
|
10
|
-
</div>`).join(``)}`}function
|
|
9
|
+
<div class="pr-helper-selection-menu-group-items">${t.map(me).join(``)}</div>
|
|
10
|
+
</div>`).join(``)}`}function ge(e){if(e.layout===`flat`)return _e(e);let t=he(e.actions);return`
|
|
11
11
|
<div class="pr-helper-selection-bar">
|
|
12
12
|
<button type="button" class="pr-helper-selection-trigger" data-selection-open>
|
|
13
13
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="12" height="12" fill="currentColor" aria-hidden="true">
|
|
@@ -15,7 +15,7 @@ import{t as e}from"./chunk-CIsM3PMS.js";import{n as t,t as n}from"./chunk-gBDI1-
|
|
|
15
15
|
</svg>
|
|
16
16
|
<span>${r(e.triggerLabel??`Ask`)}</span>
|
|
17
17
|
</button>
|
|
18
|
-
<button type="button" class="pr-helper-selection-copy" data-selection-copy aria-label="${
|
|
18
|
+
<button type="button" class="pr-helper-selection-copy" data-selection-copy aria-label="${ue}" aria-describedby="pr-helper-selection-tip">
|
|
19
19
|
<svg class="pr-helper-selection-copy-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16" fill="currentColor" aria-hidden="true">
|
|
20
20
|
<path d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 0 1 0 1.5h-1.5a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-1.5a.75.75 0 0 1 1.5 0v1.5A1.75 1.75 0 0 1 9.25 16h-7.5A1.75 1.75 0 0 1 0 14.25Z"/>
|
|
21
21
|
<path d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0 1 14.25 11h-7.5A1.75 1.75 0 0 1 5 9.25Zm1.75-.25a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-7.5a.25.25 0 0 0-.25-.25Z"/>
|
|
@@ -24,44 +24,44 @@ import{t as e}from"./chunk-CIsM3PMS.js";import{n as t,t as n}from"./chunk-gBDI1-
|
|
|
24
24
|
<path d="M13.78 4.22a.75.75 0 0 1 0 1.06l-7.25 7.25a.75.75 0 0 1-1.06 0L1.22 8.28a.75.75 0 0 1 1.06-1.06L6 10.94l6.72-6.72a.75.75 0 0 1 1.06 0Z"/>
|
|
25
25
|
</svg>
|
|
26
26
|
</button>
|
|
27
|
-
<span class="pr-helper-selection-tip" id="pr-helper-selection-tip" role="tooltip">${
|
|
27
|
+
<span class="pr-helper-selection-tip" id="pr-helper-selection-tip" role="tooltip">${ue}</span>
|
|
28
28
|
</div>
|
|
29
29
|
<div class="pr-helper-selection-menu">${t}</div>
|
|
30
|
-
`}function
|
|
31
|
-
${
|
|
32
|
-
<button type="button" class="pr-helper-selection-menu-item pr-helper-selection-copy-item" data-selection-copy>${
|
|
33
|
-
</div>`}function
|
|
30
|
+
`}function _e(e){return`<div class="pr-helper-selection-menu">
|
|
31
|
+
${he(e.actions)}
|
|
32
|
+
<button type="button" class="pr-helper-selection-menu-item pr-helper-selection-copy-item" data-selection-copy>${de}</button>
|
|
33
|
+
</div>`}function ve(e,t){let{width:n,height:r}=e.getBoundingClientRect(),i=t.top-r-ce,a=i>=f?i:Math.min(t.bottom+ce,window.innerHeight-r-f),o=Math.max(f,Math.min(t.left,window.innerWidth-n-f));e.style.top=`${Math.max(f,a)}px`,e.style.left=`${o}px`}function m(){h&&=(window.clearTimeout(h),0),p?.popover.remove(),p=null}var h=0;function ye(e){let t=e.querySelector(`.pr-helper-selection-tip`),n=e.querySelector(`.pr-helper-selection-copy-item`);e.classList.add(se),t&&(t.textContent=fe),n&&(n.textContent=fe),h&&window.clearTimeout(h),h=window.setTimeout(()=>be(e),le)}function be(e){h&&=(window.clearTimeout(h),0),e.classList.remove(se);let t=e.querySelector(`.pr-helper-selection-tip`);t&&(t.textContent=ue);let n=e.querySelector(`.pr-helper-selection-copy-item`);n&&(n.textContent=de)}async function xe(e,t){try{await navigator.clipboard.writeText(t)}catch(e){console.warn(`PR Helper: clipboard write failed, falling back to execCommand`,e);let t=!1;try{t=document.execCommand(`copy`)}catch(e){console.warn(`PR Helper: clipboard fallback failed`,e)}if(!t)return}ye(e)}function Se(e,t){let n=window.getSelection();if(!n||n.isCollapsed||n.rangeCount===0)return null;let r=n.toString().trim();if(!r)return null;let i=n.getRangeAt(0);if(!e.contains(i.commonAncestorContainer))return null;if(t.onlyWithin||t.ignoreWithin){let e=i.commonAncestorContainer,n=e instanceof HTMLElement?e:e.parentElement;if(t.onlyWithin&&!n?.closest(t.onlyWithin)||t.ignoreWithin&&n?.closest(t.ignoreWithin))return null}let a=i.getBoundingClientRect();return a.width===0&&a.height===0?null:{text:r,rect:a}}function Ce(e,t){let n={},r=()=>{let r=Se(e,t);if(!r){(!p||p.owner===n)&&m();return}if(p&&p.owner!==n&&m(),p)p.popover.classList.remove(oe),be(p.popover),p.text=r.text;else{let i=document.createElement(`div`);i.className=t.layout===`flat`?`${ae} ${pe}`:ae,i.innerHTML=ge(t),i.addEventListener(`mousedown`,e=>e.preventDefault()),i.addEventListener(`click`,n=>{let r=n.target;if(r.closest(`[data-selection-copy]`)){p?.text&&xe(i,p.text);return}if(r.closest(`[data-selection-open]`)){i.classList.add(oe);let n=Se(e,t);ve(i,n?.rect??i.getBoundingClientRect());return}let a=r.closest(`[data-selection-action]`)?.dataset.selectionAction;if(!a||!p)return;let o=p.text;m(),t.onChoose(a,o)}),document.body.appendChild(i),p={popover:i,text:r.text,owner:n}}ve(p.popover,r.rect)},i=e=>{p&&e.target instanceof Node&&p.popover.contains(e.target)||window.setTimeout(r,0)},a=e=>{(e.shiftKey||e.key===`Shift`)&&r()},o=()=>{if(!p)return;let e=window.getSelection();(!e||e.isCollapsed)&&m()},s=e=>{e.key===`Escape`&&m()},c=()=>m();return document.addEventListener(`mouseup`,i,!0),document.addEventListener(`keyup`,a,!0),e.addEventListener(`scroll`,c,!0),document.addEventListener(`selectionchange`,o),document.addEventListener(`keydown`,s),window.addEventListener(`scroll`,c,!0),()=>{document.removeEventListener(`mouseup`,i,!0),document.removeEventListener(`keyup`,a,!0),e.removeEventListener(`scroll`,c,!0),document.removeEventListener(`selectionchange`,o),document.removeEventListener(`keydown`,s),window.removeEventListener(`scroll`,c,!0),m()}}async function we(e){try{return await navigator.clipboard.writeText(e),!0}catch(t){return console.warn(`PR Helper: clipboard write failed, falling back to execCommand`,t),Te(e)}}function Te(e){let t=document.createElement(`textarea`);t.value=e,t.setAttribute(`aria-hidden`,`true`),t.style.cssText=`position:fixed;top:-9999px;left:-9999px;opacity:0;`,document.body.appendChild(t);try{return t.select(),document.execCommand(`copy`)}catch(e){return console.warn(`PR Helper: clipboard fallback failed`,e),!1}finally{t.remove()}}var g=`pr-helper-msg-copy`,Ee=`pr-helper-chat-actions`,De=`data-message-id`,Oe=`data-copy-source`,ke={idle:{icon:`<path d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 0 1 0 1.5h-1.5a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-1.5a.75.75 0 0 1 1.5 0v1.5A1.75 1.75 0 0 1 9.25 16h-7.5A1.75 1.75 0 0 1 0 14.25Z"></path><path d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0 1 14.25 11h-7.5A1.75 1.75 0 0 1 5 9.25Zm1.75-.25a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-7.5a.25.25 0 0 0-.25-.25Z"></path>`,label:``,aria:`Copy message`},copied:{icon:`<path d="M13.78 4.22a.75.75 0 0 1 0 1.06l-7.25 7.25a.75.75 0 0 1-1.06 0L2.22 9.28a.751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018L6 10.94l6.72-6.72a.75.75 0 0 1 1.06 0Z"></path>`,label:`Copied`,aria:`Copied`},failed:{icon:`<path d="M6.457 1.047c.659-1.234 2.427-1.234 3.086 0l6.082 11.378A1.75 1.75 0 0 1 14.082 15H1.918a1.75 1.75 0 0 1-1.543-2.575Zm1.763.707a.25.25 0 0 0-.44 0L1.698 13.132a.25.25 0 0 0 .22.368h12.164a.25.25 0 0 0 .22-.368Zm.53 3.996v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 1.5 0ZM9 11a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z"></path>`,label:`Copy failed`,aria:`Copy failed`}};function Ae(e){return je(`${Oe}="${r(e)}"`)}function je(e){let{icon:t,label:n,aria:r}=ke.idle;return`<div class="${Ee}"><button type="button" class="${g}" ${e} aria-label="${r}"><span class="${g}-icon" aria-hidden="true">${Ne(t)}</span><span class="${g}-label"${n?``:` hidden`}>${n}</span></button></div>`}function Me(e,t){let n=ke[t],r=e.querySelector(`.${g}-icon`),i=e.querySelector(`.${g}-label`);r&&(r.innerHTML=Ne(n.icon)),i instanceof HTMLElement&&(i.textContent=n.label,i.hidden=n.label===``),e.setAttribute(`aria-label`,n.aria),e.classList.toggle(`copied`,t===`copied`),e.classList.toggle(`failed`,t===`failed`)}function Ne(e){return`<svg viewBox="0 0 16 16" width="14" height="14" fill="currentColor">${e}</svg>`}var Pe=1400,Fe=`Copy`,Ie=`Copied`,Le=/Mac|iPhone|iPad/.test(navigator.userAgent)?`Press ⌘C`:`Press Ctrl C`,_=new WeakMap;function Re(e,t={}){let n=e=>{let n=e.target;if(!(n instanceof Element))return;let r=n.closest(`.${a}`),i=r?null:n.closest(`.${g}`);!r&&!i||(e.preventDefault(),e.stopPropagation(),r?Ve(r):i&&ze(i,t.messageSource))};return e.addEventListener(`click`,n,!0),()=>e.removeEventListener(`click`,n,!0)}async function ze(e,t){let n=Be(e,t);Ue(e,n!==null&&await we(n)?`copied`:`failed`)}function Be(e,t){let n=e.getAttribute(Oe);if(n!==null)return n;let r=e.getAttribute(De);return r&&t?t(r):null}async function Ve(e){let t=e.parentElement?.querySelector(`pre code`),n=t?await we(t.textContent??``):!1;!n&&t&&He(t),We(e,n?Ie:Le,n)}function He(e){let t=window.getSelection();if(!t)return;let n=document.createRange();n.selectNodeContents(e),t.removeAllRanges(),t.addRange(n)}function Ue(e,t){let n=_.get(e);n&&window.clearTimeout(n),Me(e,t),_.set(e,window.setTimeout(()=>{Me(e,`idle`),_.delete(e)},Pe))}function We(e,t,n){let r=_.get(e);r&&window.clearTimeout(r),e.textContent=t,e.classList.toggle(`copied`,n),_.set(e,window.setTimeout(()=>{e.textContent=Fe,e.classList.remove(`copied`),_.delete(e)},Pe))}var Ge=[{id:`explain`,label:`Explain`,instruction:`Explain this in simpler terms.`},{id:`is-problem`,label:`Is this actually a problem?`,instruction:`Is this actually a problem? Be specific about when it would and would not matter.`},{id:`better-implementation`,label:`Suggest a better implementation`,instruction:`Suggest a better implementation for this.`},{id:`author-question`,label:`Generate a question for the author`,instruction:`Generate a question I could ask the author about this.`},{id:`custom`,label:`Ask a question`}],Ke=[{id:`add-to-chat`,label:`Add to chat`}],qe=800;function Je(e){let t=e.replace(/\r\n/g,`
|
|
34
34
|
`).split(`
|
|
35
35
|
`).map(e=>e.replace(/\s+$/,``));for(;t.length&&!t[0].trim();)t.shift();for(;t.length&&!t[t.length-1].trim();)t.pop();let n=t.filter(e=>e.trim()).map(e=>e.match(/^[ \t]*/)[0].length),r=n.length?Math.min(...n):0,i=t.map(e=>e.slice(r)).join(`
|
|
36
36
|
`).replace(/\n{3,}/g,`
|
|
37
37
|
|
|
38
|
-
`);return i.trim()?(i.length>
|
|
38
|
+
`);return i.trim()?(i.length>qe?`${i.slice(0,qe).trimEnd()}…`:i).split(`
|
|
39
39
|
`).map(e=>`> ${e}`.trimEnd()).join(`
|
|
40
|
-
`):``}function
|
|
40
|
+
`):``}function Ye(e,t){let n=Je(e);if(!n)return null;let r=[...Ge,...Ke].find(e=>e.id===t);return r?r.instruction?`${n}\n\n${r.instruction}`:`${n}\n\n`:null}var Xe=`saved:`,Ze=`Your prompts`;function Qe(e){return`${Xe}${e}`}function $e(e){return e.startsWith(`saved:`)?e.slice(6):null}function et(e){return e.reviewerClosed>0?`dealt with`:`resolved`}({claude:`Claude Code`,codex:`Codex`,gemini:`Gemini CLI`}).claude;var tt=`Dismissed by you — you decided this finding needs no action. It stops counting towards what is left, and stays here so the decision is visible rather than lost.`;function nt(e,t,n=`resolved`){return t===0?`<span class="pr-helper-questions-progress-check" aria-hidden="true">\u2713</span><span class="pr-helper-questions-progress-count">All ${e} issues ${n}</span>`:`<span class="pr-helper-questions-progress-count">${t} of ${e} still open</span>`}function rt(e){let t=e.done-e.reviewerClosed;return e.reviewerClosed===0?`Resolved by the new commits (${e.done})`:t===0?`Dismissed by you (${e.done})`:`Dealt with (${e.done})`}function it(e,t){return t===0?`<span class="pr-helper-questions-progress-check" aria-hidden="true">✓</span><span class="pr-helper-questions-progress-count">All ${e} questions answered</span>`:`<span class="pr-helper-questions-progress-count">${t} of ${e} unanswered</span>`}function at(e,t){let n=e.trim();return n?`${n}\n\n${t}`:t}var ot=[`progress`,`overview`,`guide`,`issues`,`questions`,`files`,`prcontext`,`diagram`,`kiss`,`kissrecs`],st=`#theme-`;function ct(e){return`#${e}`}function lt(e){return`${st}${encodeURIComponent(e)}`}function ut(e){return e.kind===`view`?ct(e.view):lt(e.sectionId)}function dt(e){if(e.startsWith(st)){let t=e.slice(7);if(!t)return null;try{return{kind:`section`,sectionId:decodeURIComponent(t)}}catch{return null}}let t=e.replace(/^#/,``);return ot.includes(t)?{kind:`view`,view:t}:null}function ft(e){if(!Number.isFinite(e))return``;let t=Math.round((Date.now()-e)/6e4);if(t<1)return`just now`;if(t<60)return`${t} minute${t===1?``:`s`} ago`;let n=Math.round(t/60);if(n<24)return`${n} hour${n===1?``:`s`} ago`;let r=Math.round(n/24);return`${r} day${r===1?``:`s`} ago`}function pt(){return`<button type="button" class="prb-update-btn" data-review-update>Update review</button>`}var mt=`Updating this review checks the latest commits and refreshes the PR conversation. Your progress and Buddy AI history will be kept.`;function ht(e){return`<details class="prb-update-alt">
|
|
41
41
|
<summary>Start a new review</summary>
|
|
42
42
|
<span>A brand new review, with its own findings and its own path through the change. Run <code>${r(e)}</code> in your session.<button type="button" class="prb-fresh-quiet" data-copy-command="${r(e)}">Copy</button></span>
|
|
43
|
-
</details>`}var
|
|
43
|
+
</details>`}var gt=`prreviewbuddy review --fresh`;function _t(e){return e?e.code.state===`changed`?{label:e.code.rewritten?`Code rewritten`:`Code changed`,state:`changed`}:e.code.state===`current`?{label:`Review up to date`,state:`current`}:{label:`Freshness unknown`,state:`unknown`}:{label:`Check for updates`,state:`unknown`}}function vt(e,t={}){if(!e)return``;let n=e.code.state===`changed`,i=e.code.reason===`missing-commit`,a=t.dismissedSha!==void 0&&t.dismissedSha===e.code.latestSha;if(!t.open&&(!(n||i)||a))return``;let o=Ct(e.code),s=[...o.facts,`checked ${r(ft(e.checkedAt))}`];return`<div class="prb-fresh" data-state="${n||i?`changed`:`quiet`}" role="status">
|
|
44
44
|
<div class="prb-fresh-head">
|
|
45
45
|
<span class="prb-fresh-dot" data-freshness="${o.state}" aria-hidden="true"></span>
|
|
46
46
|
<strong class="prb-fresh-title">${r(o.title)}</strong>
|
|
47
47
|
<span class="prb-fresh-facts">${s.join(` · `)}</span>
|
|
48
48
|
</div>
|
|
49
49
|
${o.consequence?`<p class="prb-fresh-say">${o.consequence}</p>`:``}
|
|
50
|
-
${
|
|
51
|
-
</div>`}function
|
|
52
|
-
${r?
|
|
50
|
+
${yt(e,t,n||i)}
|
|
51
|
+
</div>`}function yt(e,t,n){let r=t.actions&&n,i=n?``:`<button type="button" class="prb-fresh-close" data-fresh-close aria-label="Close">×</button>`;return`<div class="prb-fresh-actions">
|
|
52
|
+
${r?pt():``}
|
|
53
53
|
<button type="button" class="prb-fresh-quiet" data-fresh-recheck>Check review status</button>
|
|
54
|
-
${r?gt
|
|
54
|
+
${r?ht(gt):``}
|
|
55
55
|
${i}
|
|
56
|
-
${
|
|
57
|
-
</div>`}function
|
|
56
|
+
${bt(e,t,n,r===!0)}
|
|
57
|
+
</div>`}function bt(e,t,n,i){let a=[i?r(mt):``,wt(e.code,e.checkout.reason!==`no-pull-request`),Tt(e,t.actions===!0),n?`<button type="button" class="prb-fresh-quiet" data-fresh-dismiss="${r(e.code.latestSha??``)}">Dismiss this warning</button>`:``].filter(e=>e!==``);if(a.length===0)return``;let o=`<div class="prb-fresh-notes">${a.map(e=>`<p>${e}</p>`).join(``)}</div>`;return n?`<details class="prb-fresh-more">
|
|
58
58
|
<summary>More details</summary>
|
|
59
59
|
${o}
|
|
60
|
-
</details>`:o}function
|
|
60
|
+
</details>`:o}function xt(e,t){return e===null?[]:[`${e} file${e===1?``:`s`} ${t}`]}function St(e){return e?`<code title="${r(e)}">${r(e.slice(0,7))}</code>`:``}function v(e){return e?[`reviewed ${St(e)}`]:[]}function Ct(e){if(e.state===`current`)return{state:`current`,title:`Review up to date`,facts:v(e.reviewedSha),consequence:``};if(e.state===`changed`){if(e.rewritten)return{state:`changed`,title:`Code rewritten`,facts:[...v(e.reviewedSha),...xt(e.changedFiles,`differ`)],consequence:`The branch was rebased or amended, so this review describes older code.`};let t=e.newCommits===null?[]:[`${e.newCommits} new commit${e.newCommits===1?``:`s`}`];return{state:`changed`,title:`Code changed`,facts:[...v(e.reviewedSha),...t,...xt(e.changedFiles,`changed`)],consequence:`New commits landed, so the lines these findings cite may have moved.`}}switch(e.reason){case`uncommitted`:return{state:`unknown`,title:`Cannot be compared`,facts:v(e.reviewedSha),consequence:`This review read uncommitted work and nothing recorded what the working tree held, so whether the files still match cannot be told from here.`};case`missing-commit`:return{state:`unknown`,title:`Reviewed commit is gone`,facts:v(e.reviewedSha),consequence:`It is not in this repository any more, after a force-push or a branch rebuilt from scratch, so nothing can be measured against it.`};case`no-branch`:return{state:`unknown`,title:`Cannot be compared`,facts:v(e.reviewedSha),consequence:`This review’s branch is not in this repository, which is what a pull request from a fork or a branch deleted after merging looks like, so whether the findings still describe it cannot be told from here.`};default:return{state:`unknown`,title:`Cannot be compared`,facts:[],consequence:`Git could not be read in this checkout.`}}}function wt(e,t){if(!e.comparison)return``;let n=`<code>${r(e.comparison.ref)}</code>`;return e.state===`current`?t?`This review is based on the latest PR commit ${St(e.reviewedSha)}.`:`This review is based on ${St(e.reviewedSha)}, the latest commit on ${n}.`:e.comparison.remote?`This review is currently based on ${n}. <strong>Check review status</strong> compares against the latest version you already have locally. <strong>Update review</strong> fetches the newest version first.`:`This review is currently based on ${n}, the branch it is of.`}function Tt(e,t){if(!e.conversation.attached)return``;let n=r(ft(e.conversation.importedAt));return t?`<button type="button" class="prb-fresh-quiet" data-pr-recheck>Re-check the conversation</button> to refresh comments and resolved threads without re-running the code review. Last checked ${n}.`:`The PR conversation was last checked ${n}.`}function Et(e,t){let n=e=>e.toLowerCase().replace(/\bthe\b/g,``).replace(/[^a-z]/g,``);return n(e)===n(t)}function Dt(e,t,n={}){if(!t||t.state!==`changed`||n.dismissedSha&&n.dismissedSha===t.latestSha)return``;let i=t.rewritten?`The branch has been rewritten since, so this report describes commits that are no longer on it.`:t.newCommits===null?`The branch has moved on since.`:`There ${t.newCommits===1?`has been 1 commit`:`have been ${t.newCommits} commits`} on the branch since.`;return`<div class="prb-kiss-fresh" data-kiss-freshness="changed" role="status">
|
|
61
61
|
<p><strong>This KISS review describes commit ${r(e.slice(0,7))}.</strong> ${r(i)}</p>
|
|
62
62
|
<p class="prb-kiss-fresh-note">Running KISS again analyses the branch as it is now. The report below is kept either way.</p>
|
|
63
63
|
${n.actions&&t.latestSha?`<button type="button" class="prb-kiss-fresh-dismiss" data-kiss-freshness-dismiss="${r(t.latestSha)}">Not now</button>`:``}
|
|
64
|
-
</div>`}function
|
|
64
|
+
</div>`}function Ot(e,t=Date.now()){let n=Math.max(0,Math.round((t-e)/1e3));if(n<60)return`${n} second${n===1?``:`s`}`;let r=Math.round(n/60);return`${r} minute${r===1?``:`s`}`}function y(e){return e===`done`||e===`failed`}function kt(e,t){return y(e)?!0:(e===`conversation`||e===`analysing`)&&!t.querySelector(`[data-view="files"]`)}function At(e,t,n){let r=[...e.querySelectorAll(`.prb-progress-step`)],i=r.findIndex(e=>e.dataset.phase===t);if(i===-1)return;r.forEach((e,t)=>{let n=t<i?`complete`:t===i?`active`:`pending`;e.dataset.state=n;let r=e.querySelector(`.prb-progress-label`),a=n===`complete`?e.dataset.labelDone:e.dataset.labelDoing;r&&a&&(r.textContent=a),t!==i&&e.querySelector(`[data-step-note]`)?.remove()});let a=r[i];if(!n||Et(n,a.querySelector(`.prb-progress-label`)?.textContent??``))return;let o=a.querySelector(`[data-step-note]`);o||(o=document.createElement(`p`),o.className=`prb-progress-note`,o.setAttribute(`data-step-note`,``),a.appendChild(o)),o.textContent=n}function jt(e){let t=e.querySelector(`[data-started-at]`),n=Number(t?.dataset.startedAt);!t||!Number.isFinite(n)||(t.textContent=`Running for ${Ot(n)}.`)}function Mt(e,t,n){let o=e.scope===`change`?`Whole change`:t.get(e.scope)??`A theme of this change`,s=e.scope===`change`?``:e.scope;return`<article class="prb-diagram" id="prb-diagram-${r(e.scope)}" data-diagram-card="${r(e.scope)}">
|
|
65
65
|
<header class="prb-diagram-head">
|
|
66
66
|
<div class="prb-diagram-heading">
|
|
67
67
|
<h4 class="prb-diagram-title">
|
|
@@ -80,25 +80,25 @@ import{t as e}from"./chunk-CIsM3PMS.js";import{n as t,t as n}from"./chunk-gBDI1-
|
|
|
80
80
|
</div>
|
|
81
81
|
</header>
|
|
82
82
|
${e.caption?`<p class="prb-diagram-caption">${r(e.caption)}</p>`:``}
|
|
83
|
-
${
|
|
83
|
+
${Nt(e,n)}
|
|
84
84
|
<div class="prb-diagram-canvas" data-diagram-canvas></div>
|
|
85
85
|
<details class="prb-diagram-source">
|
|
86
86
|
<summary>Diagram source</summary>
|
|
87
87
|
<div class="${i}"><pre><code data-mermaid-source>${r(e.mermaid)}</code></pre><button type="button" class="${a}" aria-label="Copy code">Copy</button></div>
|
|
88
88
|
</details>
|
|
89
|
-
</article>`}function
|
|
89
|
+
</article>`}function Nt(e,t){return!e.commitSha||!t||e.commitSha===t?``:`<p class="prb-diagram-stale">Drawn from <code>${r(e.commitSha.slice(0,7))}</code>, before this review was brought up to date. Regenerate to draw it from the commit the review now describes.</p>`}var Pt={review:`<path d="M9 5H7a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2h-2"/><rect x="9" y="3" width="6" height="4" rx="1"/><path d="m9 14 2 2 4-4"/>`,kiss:`<path d="M12 3v4M12 17v4M3 12h4M17 12h4"/><circle cx="12" cy="12" r="2"/>`,diagrams:`<rect x="3" y="3" width="7" height="6" rx="1"/><rect x="14" y="15" width="7" height="6" rx="1"/><path d="M6.5 9v3a2 2 0 0 0 2 2h7a2 2 0 0 1 2 2v-1"/>`,issues:`<circle cx="12" cy="12" r="9"/><path d="M12 8v4M12 16h.01"/>`,questions:`<circle cx="12" cy="12" r="9"/><path d="M9.1 9a3 3 0 0 1 5.8 1c0 2-3 3-3 3M12 17h.01"/>`,files:`<path d="M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8z"/><path d="M14 3v5h5M9 13h6M9 17h6"/>`,prcontext:`<path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"/>`,recommendations:`<path d="M9 18h6M10 22h4"/><path d="M12 2a7 7 0 0 0-4 12.7c.6.5 1 1.2 1 2V17h6v-.3c0-.8.4-1.5 1-2A7 7 0 0 0 12 2z"/>`,reviews:`<path d="M8 6h13M8 12h13M8 18h13M3 6h.01M3 12h.01M3 18h.01"/>`,settings:`<circle cx="12" cy="12" r="3"/><path d="M19.4 15a1.7 1.7 0 0 0 .3 1.8l.1.1a2 2 0 1 1-2.8 2.8l-.1-.1a1.7 1.7 0 0 0-1.8-.3 1.7 1.7 0 0 0-1 1.5V21a2 2 0 1 1-4 0v-.1a1.7 1.7 0 0 0-1.1-1.5 1.7 1.7 0 0 0-1.8.3l-.1.1a2 2 0 1 1-2.8-2.8l.1-.1a1.7 1.7 0 0 0 .3-1.8 1.7 1.7 0 0 0-1.5-1H3a2 2 0 1 1 0-4h.1a1.7 1.7 0 0 0 1.5-1.1 1.7 1.7 0 0 0-.3-1.8l-.1-.1a2 2 0 1 1 2.8-2.8l.1.1a1.7 1.7 0 0 0 1.8.3H9a1.7 1.7 0 0 0 1-1.5V3a2 2 0 1 1 4 0v.1a1.7 1.7 0 0 0 1 1.5 1.7 1.7 0 0 0 1.8-.3l.1-.1a2 2 0 1 1 2.8 2.8l-.1.1a1.7 1.7 0 0 0-.3 1.8V9a1.7 1.7 0 0 0 1.5 1H21a2 2 0 1 1 0 4h-.1a1.7 1.7 0 0 0-1.5 1z"/>`,feedback:`<path d="m22 2-7 20-4-9-9-4z"/><path d="M22 2 11 13"/>`,stop:`<path d="M12 2v10"/><path d="M18.4 6.6a9 9 0 1 1-12.8 0"/>`};function Ft(e){return`<span class="prb-rail-icon" aria-hidden="true"><svg viewBox="0 0 24 24" focusable="false" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round">${Pt[e]}</svg></span>`}var It=`modulepreload`,Lt=function(e){return`/`+e},Rt={},zt=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?import.meta.resolve(e):new URL(e,import.meta.url).href}r=o(t.map(t=>{if(t=Lt(t,n),t=s(t),t in Rt)return;Rt[t]=!0;let r=t.endsWith(`.css`);for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}let i=document.createElement(`link`);if(i.rel=r?`stylesheet`:It,r||(i.as=`script`),i.crossOrigin=``,i.href=t,a&&i.setAttribute(`nonce`,a),document.head.appendChild(i),r)return new Promise((e,n)=>{i.addEventListener(`load`,e),i.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},Bt=.5,Vt=3,Ht=1.25,Ut=null;function Wt(){return Ut??=zt(()=>import(`./chunk-B80S6zbH.js`).then(e=>(e.default.initialize({startOnLoad:!1,securityLevel:`strict`,htmlLabels:!1,flowchart:{htmlLabels:!1},theme:`neutral`,fontFamily:`inherit`}),e.default)),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17])),Ut}var Gt=new WeakSet,Kt=new WeakMap,qt=new WeakMap,b=null;function Jt(e){return document.addEventListener(`click`,t=>{let n=t.target;if(!(n instanceof Element))return;let r=n.closest(`[data-diagram-stop]`);if(r){r.setAttribute(`disabled`,``),r.textContent=`Stopping…`,fetch(e.endpoint(`/stop`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({kind:`diagram`})}).catch(()=>{}).finally(()=>{b?.abort()});return}let i=n.closest(`[data-diagram-toggle]`);if(i){tn(i.closest(`[data-diagram-card]`),i.getAttribute(`aria-expanded`)===`true`);return}let a=n.closest(`[data-diagram-zoom]`);if(a){an(a.closest(`[data-diagram-card]`),a.dataset.diagramZoom??`reset`);return}let o=n.closest(`[data-diagram-request]`);o&&Yt(e,o.dataset.diagramRequest||null)}),Xt(),{drawPane:nn}}async function Yt(e,t){if(b)return;let n=t??`change`,r=document.querySelector(`[data-diagram-pane]`),i=r?.querySelector(`[data-diagram-card="${S(n)}"]`)??null??Zt(r,n,t);if(!i)return;x(),e.showDiagrams();let a=Qt(i);b=new AbortController,cn(!1);try{let n=await fetch(e.endpoint(`/diagram`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({sectionId:t}),signal:b.signal}),r=await n.json().catch(()=>null);if(n.status===409&&r?.running){window.location.reload();return}if(r?.stopped)throw new DOMException(`Stopped`,`AbortError`);if(!n.ok||!r?.diagram)return $t(i,a,r?.error??`Buddy AI did not return a diagram. Check the terminal running PR Review Buddy.`);en(i,r.diagram,t)}catch(e){if(e instanceof DOMException&&e.name===`AbortError`){i.hasAttribute(`data-diagram-pending`)?(i.remove(),x()):a.remove();return}$t(i,a,`Could not reach PR Review Buddy. The workspace server may have stopped.`)}finally{b=null,cn(!0)}}function Xt(){let e=document.querySelector(`[data-diagram-pane][data-diagram-running]`);if(!e)return;let t=e.dataset.diagramRunning||null,n=t??`change`,r=e.querySelector(`[data-diagram-card="${S(n)}"]`)??Zt(e,n,t);r&&(x(),Qt(r,{scroll:!1}),cn(!1))}function x(){let e=document.querySelectorAll(`[data-diagram-pane] [data-diagram-card]`).length,t=document.querySelector(`[data-view-nav="diagram"]`);if(e===0){t?.remove();return}if(!t){let e=document.querySelector(`[data-view-nav="issues"]`);if(!e)return;t=document.createElement(`button`),t.setAttribute(`type`,`button`),t.className=`prb-rail-item prb-rail-link`,t.dataset.viewNav=`diagram`,t.innerHTML=`${Ft(`diagrams`)}<span class="prb-rail-label"><span class="prb-rail-title">Diagrams</span></span><span class="prb-rail-count"></span>`,e.before(t)}let n=t.querySelector(`.prb-rail-count`);n&&(n.textContent=String(e),n.setAttribute(`aria-label`,e===1?`1 diagram`:`${e} diagrams`))}function Zt(e,t,n){if(!e)return null;let r=document.createElement(`article`);return r.className=`prb-diagram`,r.dataset.diagramCard=t,r.setAttribute(`data-diagram-pending`,``),r.innerHTML=`<header class="prb-diagram-head">
|
|
90
90
|
<div class="prb-diagram-heading">
|
|
91
91
|
<h4 class="prb-diagram-title">Drawing…</h4>
|
|
92
|
-
<p class="prb-diagram-scope">${t===`change`?`Whole change`:
|
|
92
|
+
<p class="prb-diagram-scope">${t===`change`?`Whole change`:fn(ln(n))}</p>
|
|
93
93
|
</div>
|
|
94
|
-
</header>`,
|
|
94
|
+
</header>`,un(e,r,n),r}function Qt(e,{scroll:t=!0}={}){e.querySelector(`[data-diagram-status]`)?.remove();let n=document.createElement(`p`);n.className=`prb-diagram-status`,n.setAttribute(`data-diagram-status`,``),n.innerHTML=`<span class="prb-thinking"><i></i><i></i><i></i></span><span>Reading the change…</span>`;let r=document.createElement(`button`);return r.type=`button`,r.className=`prb-diagram-redraw`,r.setAttribute(`data-diagram-stop`,``),r.textContent=`Stop`,n.appendChild(r),e.querySelector(`.prb-diagram-head`)?.insertAdjacentElement(`afterend`,n),t&&e.scrollIntoView({behavior:pn()?`auto`:`smooth`,block:`start`}),n}function $t(e,t,n){if(t.className=`prb-diagram-failed`,t.textContent=n,e.hasAttribute(`data-diagram-pending`)){let n=document.createElement(`button`);n.type=`button`,n.className=`prb-diagram-redraw`,n.dataset.diagramRequest=e.dataset.diagramCard===`change`?``:e.dataset.diagramCard??``,n.textContent=`Try again`,t.appendChild(document.createTextNode(` `)),t.appendChild(n)}}function en(e,t,n){let r=Mt(t,new Map(n?[[n,ln(n)]]:[]),t.commitSha),i=document.createElement(`div`);i.innerHTML=r;let a=i.firstElementChild;a&&(e.replaceWith(a),x(),rn(a))}function tn(e,t){e&&(e.toggleAttribute(`data-diagram-collapsed`,t),e.querySelector(`[data-diagram-toggle]`)?.setAttribute(`aria-expanded`,String(!t)),t||rn(e))}function nn(){for(let e of document.querySelectorAll(`[data-diagram-pane] [data-diagram-card]`))rn(e)}async function rn(e){let t=e.querySelector(`[data-diagram-canvas]`),n=e.querySelector(`[data-mermaid-source]`)?.textContent??``;if(!(!t||!n||Gt.has(e)||e.hasAttribute(`data-diagram-collapsed`))){Gt.add(e);try{let e=await Wt();await e.parse(n);let{svg:r}=await e.render(`prb-mermaid-${Math.random().toString(36).slice(2)}`,n);t.innerHTML=r}catch{Gt.delete(e),t.innerHTML=``;let n=document.createElement(`p`);n.className=`prb-diagram-failed`,n.textContent=`This diagram could not be drawn. Its source is below, and Regenerate will ask for another.`,t.replaceWith(n),e.querySelector(`details`)?.setAttribute(`open`,``)}}}function an(e,t){let n=e?.querySelector(`[data-diagram-canvas] svg`),r=e?.querySelector(`[data-diagram-canvas]`);if(!e||!n||!r)return;if(t===`reset`){qt.delete(e),r.removeAttribute(`data-zoomed`),n.style.removeProperty(`width`);return}let i=on(e,n);if(i<=0)return;let a=sn((qt.get(e)??1)*(t===`in`?Ht:1/Ht));qt.set(e,a),r.setAttribute(`data-zoomed`,``),n.style.width=`${Math.round(i*a)}px`}function on(e,t){let n=Kt.get(e);if(n)return n;let r=t.getBoundingClientRect().width;if(r>0)return Kt.set(e,r),r;let i=t.getAttribute(`viewBox`)?.split(/[\s,]+/),a=Number(i?.[2]??0);return Number.isFinite(a)?a:0}function sn(e){return Math.min(Vt,Math.max(Bt,e))}function cn(e){for(let t of document.querySelectorAll(`[data-diagram-request]`))t.disabled=!e}function ln(e){return e?document.querySelector(`[data-goto-section="${S(e)}"]`)?.querySelector(`.prb-rail-title`)?.textContent?.trim()||`A theme of this change`:`Whole change`}function un(e,t,n){let r=dn(n);for(let n of e.querySelectorAll(`[data-diagram-card]`)){let e=n.dataset.diagramCard??``;if(dn(e===`change`?null:e)>r){n.before(t);return}}e.appendChild(t)}function dn(e){if(!e)return-1;let t=document.querySelector(`[data-goto-section="${S(e)}"]`);return Number(t?.dataset.themeIndex??0)}function fn(e){let t=document.createElement(`span`);return t.textContent=e,t.innerHTML}function S(e){return CSS.escape(e)}function pn(){return window.matchMedia(`(prefers-reduced-motion: reduce)`).matches}var C=document.body,mn=C.dataset.apiBase??``,hn=C.dataset.token??``,gn=C.dataset.editorLabel??``,_n=C.dataset.editorTemplate??``,vn=C.dataset.repoPath??``,yn=C.dataset.explainPrompt??``,bn=C.dataset.sessionId??``;function w(e){return`${mn}${e}?t=${encodeURIComponent(hn)}`}function T(e){fetch(w(`/event`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(e),keepalive:!0}).catch(()=>{})}var xn=Jt({endpoint:w,showDiagrams:()=>wn(`diagram`)}),E=null,D=`whole change`;function Sn(e){let t=ut(e);window.location.hash!==t&&history.pushState(e,``,t),Cn(e)}function Cn(e){e.kind===`view`?En(e.view):An(e.sectionId)}function wn(e){Sn({kind:`view`,view:e})}function Tn(e){Sn({kind:`section`,sectionId:e})}function En(e){for(let t of document.querySelectorAll(`.prb-view`))t.hidden=t.dataset.view!==e;for(let t of document.querySelectorAll(`[data-view-nav]`))t.setAttribute(`aria-current`,String(t.dataset.viewNav===e));T({event:`view_opened`,view:e}),e===`diagram`&&xn.drawPane(),Dn(),document.querySelector(`.prb-doc`)?.scrollTo({top:0})}function Dn(){for(let e of document.querySelectorAll(`[data-goto-section]`))e.setAttribute(`aria-current`,`false`);E=null,D=`whole change`,Mn()}function On(e,t){let n=document.getElementById(e.getAttribute(`aria-controls`)??``);n&&(e.setAttribute(`aria-expanded`,String(t)),e.setAttribute(`aria-label`,`${t?`Collapse`:`Expand`} ${e.dataset.railToggle??`this section`}`),n.hidden=!t)}function kn(){for(let e of document.querySelectorAll(`[data-rail-toggle]`)){let t=document.getElementById(e.getAttribute(`aria-controls`)??``);(t?.contains(document.getElementById(`prb-rail-path`))||t?.id===`prb-rail-path`)&&On(e,!0)}}function An(e){En(`guide`),kn();for(let t of document.querySelectorAll(`[data-goto-section]`))t.setAttribute(`aria-current`,String(t.dataset.gotoSection===e));let t=document.getElementById(`pr-helper-guide-section-${e}`);if(!t)return;t.classList.remove(`pr-helper-guide-section-collapsed`),t.scrollIntoView({behavior:jn()?`auto`:`smooth`,block:`start`});let n=document.querySelector(`[data-goto-section="${CSS.escape(e)}"]`);T({event:`theme_opened`,themeIndex:Number(n?.dataset.themeIndex??-1),attention:n?.querySelector(`.prb-attention`)?.dataset.attention??`medium`,isRecommendedStart:n?.dataset.recommendedStart===`true`}),E=e,D=t.querySelector(`.pr-helper-guide-section-title`)?.textContent?.trim()??`this theme`,Mn()}function jn(){return window.matchMedia(`(prefers-reduced-motion: reduce)`).matches}function Mn(){let e=document.querySelector(`[data-ask-scope]`);e&&(e.textContent=D,e.title=E?`Questions are answered about "${D}"`:`Questions cover the whole change`)}function O(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`)}function Nn(e){return e.tagName===`LI`?{parent:e,position:`beforeend`}:{parent:e,position:`afterend`}}async function Pn(e){let t=e.tagName===`LI`?e.querySelector(`:scope > .prb-code`):e.nextElementSibling;if(t?.classList.contains(`prb-code`)){t.remove(),e.setAttribute(`aria-expanded`,`false`);return}let n=e.dataset.file;if(!n)return;let r=Number(e.dataset.line)||0,i=e.tagName!==`LI`,a=document.createElement(`div`);a.className=`prb-code`,a.innerHTML=`<p class="prb-code-status">Reading…</p>`;let{parent:o,position:s}=Nn(e);o.insertAdjacentElement(s,a),e.setAttribute(`aria-expanded`,`true`),T({event:`file_opened`,fromFinding:i,targeted:r>0}),await Fn(a,n,r,0)}async function Fn(e,t,n,r){try{let i=`&path=${encodeURIComponent(t)}${n?`&line=${n}`:``}${r?`&expand=${r}`:``}`,a=await fetch(`${w(`/file`)}${i}`),o=await a.json();if(!a.ok){e.innerHTML=`<p class="prb-code-status">${O(o?.error??`Could not read that file.`)}</p>`;return}In(e,o,n,r)}catch{e.innerHTML=`<p class="prb-code-status">Could not reach PR Review Buddy. The workspace server may have stopped.</p>`}}function In(e,t,n,r){let i=new Set(t.addedLines),a=t.lines.map((e,r)=>{let a=t.from+r;return`<tr class="${[i.has(a)?`prb-code-added`:``,a===n?`prb-code-target`:``].filter(Boolean).join(` `)}"><td class="prb-code-num">${a}</td><td class="prb-code-line">${O(e)||` `}</td></tr>`}).join(``),o=_n&&vn?t.checkout===`absent`?`<button type="button" class="prb-code-open" disabled>Not in your working folder</button>`:`<button type="button" class="prb-code-open" data-open-editor="${O(t.path)}" data-open-line="${n||t.from}">${O(`Open in ${gn||`editor`}`)}</button>`:``,s=t.pullRequest&&t.pullRequest.precise?`<a class="prb-code-open prb-code-pr" href="${O(t.pullRequest.href)}" target="_blank" rel="noopener noreferrer">${O(t.pullRequest.label)}</a>`:``,c=t.truncated?`<button type="button" class="prb-code-more" data-expand-file="${O(t.path)}" data-expand-line="${n||0}" data-expand-step="${r+1}">Show more of this file</button>`:``,ee=t.checkout===`differs`?` · your editor will show a different version`:t.checkout===`absent`?` · not in your working folder`:``,l=t.source===`commit`?`<p class="prb-code-source">Viewing reviewed version${t.sourceSha?` <code>${O(t.sourceSha.slice(0,7))}</code>`:``}${ee}</p>`:`<p class="prb-code-source">Viewing your working folder</p>`;e.innerHTML=`<div class="prb-code-header">
|
|
95
95
|
<span class="prb-code-range">lines ${t.from}\u2013${t.to} of ${t.totalLines}</span>
|
|
96
96
|
${s}
|
|
97
97
|
${o}
|
|
98
98
|
</div>
|
|
99
99
|
${l}
|
|
100
100
|
<div class="prb-code-scroll"><table class="prb-code-table"><tbody>${a}</tbody></table></div>
|
|
101
|
-
${c}`,e.querySelector(`.prb-code-target`)?.scrollIntoView({block:`center`})}function Ln(e,t,n){let r=`${_n.replace(/\/$/,``)}/${e}`,i=gn.replace(`{path}`,r).replace(`{line}`,String(Math.max(1,t)));w({event:`editor_opened`,fromFinding:n}),window.location.href=i}var D=document.querySelector(`[data-ask-log]`);D&&D.querySelector(`.prb-msg`)&&D.scrollTo({top:D.scrollHeight});var O=document.querySelector(`[data-ask-form]`),k=O?.querySelector(`textarea`);function Rn(e,t){let n=document.createElement(`div`);return n.className=e===`user`?`prb-msg prb-msg-user`:`prb-msg prb-msg-${e===`error`?`error`:`assistant`}`,e===`assistant`?(n.classList.add(`prb-md`),n.innerHTML=te(t)+je(t)):n.textContent=t,D?.appendChild(n),D?.scrollTo({top:D.scrollHeight}),n}function zn(){let e=document.createElement(`div`);return e.className=`prb-thinking`,e.innerHTML=`<i></i><i></i><i></i><span>Reading the change…</span>`,D?.appendChild(e),D?.scrollTo({top:D.scrollHeight}),e}var A=null,j=!!D?.querySelector(`[data-ask-pending]`);function Bn(){let e=document.createElement(`div`);e.className=`prb-stopped`,e.textContent=`Stopped.`,D?.appendChild(e),D?.scrollTo({top:D.scrollHeight})}async function Vn(e,t=`free_text`){let n=e.trim();if(!n||A||j)return;document.querySelector(`.prb-ask-empty`)?.remove(),Rn(`user`,n);let r=zn();A=new AbortController,Hn(!0);try{let e=await fetch(C(`/ask`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({question:n,sectionId:T,source:t}),signal:A.signal}),i=await e.json().catch(()=>null);if(e.status===409&&i?.running){window.location.reload();return}if(r.remove(),i?.stopped){Bn();return}if(!e.ok||!i?.answer){Rn(`error`,i?.error??`Buddy AI did not answer. Check the terminal running PR Review Buddy.`);return}Rn(`assistant`,i.answer)}catch(e){r.remove(),e instanceof DOMException&&e.name===`AbortError`?(Bn(),k&&!k.value&&(k.value=n)):Rn(`error`,`Could not reach PR Review Buddy. The workspace server may have stopped.`)}finally{A=null,Hn(!1)}}function Hn(e){let t=O?.querySelector(`button`);t&&(t.textContent=e?`Stop`:`Ask`,t.toggleAttribute(`data-stop`,e),t.disabled=!1),k&&(k.disabled=e);for(let t of document.querySelectorAll(Un))t.disabled=e;e||k?.focus()}var Un=`[data-suggestion], .pr-helper-explain-simply-button`;function Wn(){let e=O?.querySelector(`button`);e&&(e.textContent=`Stopping…`,e.disabled=!0),fetch(C(`/stop`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({kind:`ask`})}).catch(()=>{}).finally(()=>{A?.abort()})}O?.addEventListener(`submit`,e=>{if(e.preventDefault(),A||j)return Wn();let t=k?.value??``;k&&(k.value=``),Vn(t,Kn(t))}),j&&Hn(!0);var Gn=null;function Kn(e){return Gn&&e.includes(Gn)?`selection`:`free_text`}k?.addEventListener(`keydown`,e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),O?.requestSubmit())}),k?.addEventListener(`input`,()=>{k&&(k.style.height=`auto`,k.style.height=`${Math.min(k.scrollHeight,140)}px`)});async function qn(e){try{await fetch(C(`/state`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({answeredQuestionIds:e})})}catch{}}function Jn(){return[...document.querySelectorAll(`[data-question-answered][data-answered="true"]`)].map(e=>e.dataset.questionAnswered??``).filter(Boolean)}function Yn(e,t){e.dataset.answered=String(t),e.textContent=t?`Mark as unanswered`:`Mark answered`;let n=e.closest(`[data-finding-card]`);n?.classList.toggle(`pr-helper-question-card-answered`,t),n&&tr(n,t,`questions`),sr()}function Xn(){return[...document.querySelectorAll(`[data-issue-dismissed][data-dismissed="true"]`)].map(e=>({id:e.dataset.issueDismissed??``,sessionId:e.dataset.dismissedIn||yn})).filter(e=>e.id)}async function Zn(e){try{await fetch(C(`/state`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({dismissedIssues:e})})}catch{}}function Qn(e,t){e.dataset.dismissed=String(t),e.textContent=t?`Reopen`:`Dismiss`,delete e.dataset.stale,t?e.dataset.dismissedIn=yn:delete e.dataset.dismissedIn;let n=e.closest(`[data-finding-card]`);n&&(n.classList.toggle(`pr-helper-issue-card-dismissed`,t),n.querySelector(`.pr-helper-dismissal-stale`)?.remove(),n.querySelector(`.pr-helper-finding-status-dismissed`)?.remove(),t&&n.querySelector(`.pr-helper-issue-badges`)?.prepend($n()),tr(n,t||e.dataset.settled===`true`,`issues`),lr())}function $n(){let e=document.createElement(`span`);return e.className=`pr-helper-finding-status pr-helper-finding-status-dismissed pr-helper-tip`,e.dataset.tip=nt,e.textContent=`Dismissed by you`,e}var er=new WeakMap;function tr(e,t,n){let r=e.closest(`.pr-helper-closed-findings-list`);if(t!==!!r){if(t){let t=e.parentElement;t&&er.set(e,{parent:t,before:e.nextElementSibling}),ar(n).append(e),t&&ir(t)}else nr(e,n),(r?.children.length===0?r.closest(`.pr-helper-closed-findings`):null)?.remove();or(n)}}function nr(e,t){let n=er.get(e);if(n?.parent.isConnected)n.parent.insertBefore(e,n.before);else{let n=rr(e)??document.querySelector(`[data-view="${t}"]`);n?.insertBefore(e,n.querySelector(`.pr-helper-closed-findings`))}e.closest(`.pr-helper-question-group`)?.removeAttribute(`hidden`)}function rr(e){let t=e.dataset.sectionId;return t?document.querySelector(`[data-question-group="${CSS.escape(t)}"]`):null}function ir(e){let t=e.closest(`.pr-helper-question-group`);t&&!t.querySelector(`[data-finding-card]`)&&(t.hidden=!0)}function ar(e){let t=document.querySelector(`[data-view="${e}"]`),n=t?.querySelector(`[data-closed-findings="${e}"] .pr-helper-closed-findings-list`);if(n)return n;let r=document.createElement(`details`);r.className=`pr-helper-closed-findings`,r.dataset.closedFindings=e;let i=document.createElement(`summary`);i.className=`pr-helper-closed-findings-summary`,i.setAttribute(`data-closed-findings-summary`,``);let a=document.createElement(`div`);return a.className=`pr-helper-closed-findings-list`,r.append(i,a),t?.append(r),a}function or(e){let t=document.querySelector(`[data-closed-findings="${e}"]`),n=t?.querySelector(`[data-closed-findings-summary]`);if(!t||!n)return;let r=document.querySelectorAll(`[data-view="${e}"] [data-finding-card]`).length,i=t.querySelectorAll(`[data-finding-card]`).length;if(t.toggleAttribute(`data-nothing-open`,r===i),e===`questions`){n.textContent=`Answered (${i})`;return}n.textContent=it(cr())}function sr(){let e=[...document.querySelectorAll(`[data-question-answered]`)];if(e.length===0)return;let t=e.filter(e=>e.dataset.answered!==`true`&&e.dataset.settled!==`true`).length,n=document.querySelector(`.pr-helper-questions-progress`);n&&(n.innerHTML=at(e.length,t)),ur(`questions`,e.length,t,`question`,`answered`)}function cr(){let e=[...document.querySelectorAll(`[data-issue-dismissed]`)],t=0,n=0;for(let r of e){let e=r.dataset.settled===`true`,i=r.dataset.dismissed===`true`&&r.dataset.stale!==`true`;!e&&!i?t+=1:!e&&i&&(n+=1)}return{total:e.length,open:t,done:e.length-t,reviewerClosed:n}}function lr(){let e=cr();if(e.total===0)return;let t=document.querySelector(`[data-view="issues"]`),n=t?.querySelector(`.pr-helper-findings-progress`);!n&&t&&e.done>0&&(n=document.createElement(`div`),n.className=`pr-helper-findings-progress`,n.setAttribute(`role`,`status`),t.querySelector(`.prb-doc-title`)?.after(n)),n&&(n.innerHTML=rt(e.total,e.open,tt(e))),ur(`issues`,e.total,e.open,`issue`,tt(e))}function ur(e,t,n,r,i){let a=document.querySelector(`[data-view-nav="${e}"] .prb-rail-count`);if(!a)return;let o=e=>`${e} ${r}${e===1?``:`s`}`,s=t-n;a.classList.toggle(`prb-rail-count-done`,t>0&&n===0),t===0?(a.textContent=`0`,a.setAttribute(`aria-label`,`No ${r}s`)):n===0?(a.textContent=`✓`,a.setAttribute(`aria-label`,`All ${o(t)} ${i}`)):(a.textContent=String(n),a.setAttribute(`aria-label`,s===0?o(t):`${n} of ${o(t)} left, ${s} ${i}`))}document.addEventListener(`click`,e=>{let t=e.target,n=t.closest(`[data-rail-toggle]`);if(n){On(n,n.getAttribute(`aria-expanded`)!==`true`);return}let r=t.closest(`[data-view-nav]`);if(r?.dataset.viewNav){wn(r.dataset.viewNav);return}let i=t.closest(`[data-overview-nav]`);if(i?.dataset.overviewNav){wn(i.dataset.overviewNav===`guide`?`guide`:i.dataset.overviewNav);return}let a=t.closest(`[data-goto-section]`);if(a?.dataset.gotoSection){Tn(a.dataset.gotoSection);return}let o=t.closest(`[data-open-editor]`);if(o?.dataset.openEditor){Ln(o.dataset.openEditor,Number(o.dataset.openLine)||1,!0);return}let s=t.closest(`[data-expand-file]`);if(s?.dataset.expandFile){let e=s.closest(`.prb-code`);e&&Fn(e,s.dataset.expandFile,Number(s.dataset.expandLine)||0,Number(s.dataset.expandStep)||1);return}let c=t.closest(`[data-file]`);if(c?.dataset.file){Pn(c);return}let ee=t.closest(`[data-guide-toggle]`);if(ee?.dataset.guideToggle){document.getElementById(`pr-helper-guide-section-${ee.dataset.guideToggle}`)?.classList.toggle(`pr-helper-guide-section-collapsed`);return}let l=t.closest(`[data-question-answered]`);if(l?.dataset.questionAnswered){Yn(l,l.dataset.answered!==`true`);let e=Jn();qn(e),w({event:`question_marked_answered`,answered:e.length,total:document.querySelectorAll(`[data-question-answered]`).length});return}let u=t.closest(`[data-issue-dismissed]`);if(u?.dataset.issueDismissed){Qn(u,u.dataset.stale===`true`||u.dataset.dismissed!==`true`);let e=Xn();Zn(e),w({event:`issue_dismissed`,dismissed:e.length,total:document.querySelectorAll(`[data-issue-dismissed]`).length});return}let te=t.closest(`[data-suggestion]`);if(te){Vn(te.textContent??``,`suggestion`);return}if(t.closest(`.pr-helper-explain-simply-button`)){pr(),Vn(vn,`explain_simply`);return}let ne=t.closest(`[data-prompt-use]`);if(ne?.dataset.promptUse){Pr(ne.dataset.promptUse);return}let re=t.closest(`[data-prompt-edit]`);if(re?.dataset.promptEdit){Gr(re.dataset.promptEdit);return}if(t.closest(`[data-prompt-add]`)){Gr(``);return}t.closest(`[data-ask-toggle]`)&&fr(!dr())});var M=document.querySelector(`.prb-body`),N=document.querySelector(`.prb-ask`);function dr(){return!!N&&getComputedStyle(N).display!==`none`}function fr(e){M&&(M.dataset.ask=e?`open`:`closed`),document.querySelector(`[data-ask-toggle]`)?.setAttribute(`aria-expanded`,String(e))}function pr(){fr(!0)}function mr(){document.querySelector(`[data-ask-toggle]`)?.setAttribute(`aria-expanded`,String(dr()))}window.addEventListener(`resize`,mr);var hr=document.querySelector(`[data-shutdown]`),gr=document.querySelector(`[data-shutdown-dialog]`),P=document.querySelector(`[data-shutdown-confirm]`);hr?.addEventListener(`click`,()=>gr?.showModal()),document.querySelector(`[data-shutdown-cancel]`)?.addEventListener(`click`,()=>gr?.close()),P?.addEventListener(`click`,()=>{P.disabled=!0,P.textContent=`Stopping…`,fetch(C(`/shutdown`),{method:`POST`}).then(()=>{gr?.close(),_r()}).catch(()=>{P.disabled=!1,P.textContent=`Stop server`})});function _r(){document.body.dataset.serverStopped=`true`;let e=document.createElement(`div`);e.className=`prb-stopped-notice`,e.setAttribute(`role`,`status`);let t=document.body.dataset.wayBack;e.textContent=t?`Workspace server stopped. This page is no longer being served. Run ${t} to bring it back.`:`Workspace server stopped. This page is no longer being served.`,document.body.prepend(e),hr&&(hr.textContent=`Server stopped`,hr.disabled=!0)}var F=document.querySelector(`[data-file-filter]`),vr=document.querySelector(`[data-file-count]`),yr=document.querySelector(`[data-file-none]`);function br(){let e=(F?.value??``).trim().toLowerCase(),t=0,n=0;for(let r of document.querySelectorAll(`[data-view="files"] .prb-file`)){let i=e===``||(r.dataset.search??``).includes(e);r.hidden=!i,i&&(n+=1,r.classList.contains(`prb-file-referenced`)||(t+=1));let a=r.nextElementSibling;a?.classList.contains(`prb-code`)&&(a.hidden=!i)}for(let t of document.querySelectorAll(`[data-file-group]`)){let n=t.querySelectorAll(`.prb-file:not([hidden])`).length;t.hidden=n===0;let r=t.querySelector(`[data-group-heading]`);if(!r)continue;let i=Number(r.dataset.groupTotal)||0;r.textContent=e&&n!==i?`${r.dataset.groupHeading} · ${n} of ${i}`:`${r.dataset.groupHeading} · ${i}`}yr&&(yr.hidden=n>0),vr&&(vr.textContent=e?`${t} of ${I} file${I===1?``:`s`}`:`${I} file${I===1?``:`s`}`)}var I=document.querySelectorAll(`[data-view="files"] .prb-file:not(.prb-file-referenced)`).length;F?.addEventListener(`input`,br),F?.addEventListener(`keydown`,e=>{e.key===`Escape`&&F.value!==``&&(e.preventDefault(),F.value=``,br())}),document.addEventListener(`keydown`,e=>{if(e.key!==`Enter`&&e.key!==` `)return;let t=e.target,n=t.closest(`.prb-file[data-file][role="button"]`);!n||n!==t||(e.preventDefault(),Pn(n))});var xr=320,Sr=()=>Math.round(window.innerWidth/2),Cr=e=>Math.round(Math.min(Sr(),Math.max(xr,e)));function L(e){M&&(e===null?M.style.removeProperty(`--ask-width`):M.style.setProperty(`--ask-width`,`${e}px`))}function R(){return N?Math.round(N.getBoundingClientRect().width):xr}function wr(e){fetch(C(`/prefs`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({askWidth:e})}).catch(()=>{})}var z=document.querySelector(`[data-ask-resize]`);z?.addEventListener(`pointerdown`,e=>{if(e.button!==0||!M||!N)return;e.preventDefault(),z.setPointerCapture(e.pointerId),M.dataset.resizing=`true`;let t=e.clientX,n=R(),r=e=>{L(Cr(n+(t-e.clientX)))},i=()=>{z.removeEventListener(`pointermove`,r),z.removeEventListener(`pointerup`,i),z.removeEventListener(`pointercancel`,i),delete M.dataset.resizing,wr(R())};z.addEventListener(`pointermove`,r),z.addEventListener(`pointerup`,i),z.addEventListener(`pointercancel`,i)}),z?.addEventListener(`keydown`,e=>{let t=e.shiftKey?64:16;if(e.key===`ArrowLeft`||e.key===`ArrowRight`){e.preventDefault();let n=e.key===`ArrowLeft`?t:-t,r=Cr(R()+n);L(r),wr(r);return}(e.key===`Home`||e.key===`Escape`)&&(e.preventDefault(),L(null),wr(null))}),z?.addEventListener(`dblclick`,()=>{L(null),wr(null)}),window.addEventListener(`resize`,()=>{dr()&&M?.style.getPropertyValue(`--ask-width`)&&L(Cr(R()))});var Tr=3e4,B=document.visibilityState===`visible`?Date.now():null,Er=0;function Dr(){B!==null&&(Er+=Date.now()-B,B=Date.now())}function Or(){Dr();let e=Math.round(Er/1e3);return Er-=e*1e3,e}document.addEventListener(`visibilitychange`,()=>{document.visibilityState===`visible`?B=Date.now():(Dr(),B=null)}),setInterval(()=>{let e=Or();e>0&&w({event:`workspace_heartbeat`,visibleSeconds:e})},Tr),window.addEventListener(`pagehide`,()=>{let e=C(`/event`),t=JSON.stringify({event:`review_completed`,trailingSeconds:Or()});navigator.sendBeacon?.(e,new Blob([t],{type:`application/json`}))||fetch(e,{method:`POST`,headers:{"content-type":`application/json`},body:t,keepalive:!0}).catch(()=>{})});var kr=document.querySelector(`[data-prompt-bank]`),Ar=document.querySelector(`[data-prompt-list]`),V=jr();function jr(){try{let e=JSON.parse(kr?.dataset.prompts??`[]`);return Array.isArray(e)?e:[]}catch{return[]}}function Mr(){Ar&&(Ar.innerHTML=V.map(e=>`<span class="prb-bank-item">
|
|
102
|
-
<button type="button" class="prb-bank-use" data-prompt-use="${
|
|
103
|
-
<button type="button" class="prb-bank-edit" data-prompt-edit="${
|
|
104
|
-
</span>`).join(``),zr())}async function Nr(e){try{let t=await(await fetch(C(`/prompts`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({prompts:e})})).json().catch(()=>null);V=Array.isArray(t?.prompts)?t.prompts:V}catch{}Mr()}function Pr(e){let t=V.find(t=>t.id===e);!t||!k||(k.value=ot(k.value,t.prompt),pr(),k.focus(),k.setSelectionRange(k.value.length,k.value.length),k.dispatchEvent(new Event(`input`)))}var Fr=document.querySelector(`.prb-doc`),Ir=null,Lr=null;function Rr(){D&&(Lr?.(),Lr=we(D,{layout:`flat`,actions:qe.map(e=>({id:e.id,label:e.label})),onChoose:(e,t)=>Br(e,t)}))}function zr(){Fr&&(Ir?.(),Ir=we(Fr,{triggerLabel:`Ask Buddy AI`,actions:[...Ke.map(e=>({id:e.id,label:e.label})),...V.map(e=>({id:$e(e.id),label:e.name,section:Qe}))],onChoose:(e,t)=>Br(e,t)}))}function Br(e,t){let n=Vr(e,t);!n||!k||(Gn=n,k.value=ot(k.value,n),pr(),k.focus(),k.setSelectionRange(k.value.length,k.value.length),k.dispatchEvent(new Event(`input`)))}function Vr(e,t){let n=et(e);if(n===null)return Xe(t,e);let r=V.find(e=>e.id===n);if(!r)return null;let i=Ye(t);return i?`${i}\n\n${r.prompt}`:null}zr(),Rr(),ze(document);var Hr=document.querySelector(`[data-prompt-dialog]`),H=document.querySelector(`[data-prompt-name]`),U=document.querySelector(`[data-prompt-text]`),Ur=document.querySelector(`[data-prompt-delete]`),Wr=document.getElementById(`prb-prompt-title`),W=``;function Gr(e){let t=V.find(t=>t.id===e);W=t?.id??``,Wr&&(Wr.textContent=t?`Edit prompt`:`Save a prompt`),H&&(H.value=t?.name??``),U&&(U.value=t?.prompt??``),Ur&&(Ur.hidden=!t),Hr?.showModal(),H?.focus()}async function Kr(){let e=H?.value.trim()??``,t=U?.value.trim()??``;if(!e||!t){(e?U:H)?.focus();return}let n=W?V.map(n=>n.id===W?{...n,name:e,prompt:t}:n):[...V,{id:crypto.randomUUID(),name:e,prompt:t}];Hr?.close(),await Nr(n)}async function qr(){if(!W)return;let e=V.filter(e=>e.id!==W);Hr?.close(),await Nr(e)}document.querySelector(`[data-prompt-cancel]`)?.addEventListener(`click`,()=>Hr?.close()),Ur?.addEventListener(`click`,()=>void qr()),document.querySelector(`[data-prompt-save]`)?.addEventListener(`click`,()=>void Kr());var G=document.querySelector(`[data-complete]`);G?.addEventListener(`click`,()=>{let e=G.getAttribute(`aria-pressed`)!==`true`;Jr(e),fetch(C(`/state`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({complete:e})}).then(async e=>{let t=await e.json().catch(()=>null);t&&Jr(t.completedAt!==null)}).catch(()=>Jr(!e))});function Jr(e){G&&(G.setAttribute(`aria-pressed`,String(e)),G.textContent=e?`Reviewed`:`Mark reviewed`)}var K=document.querySelector(`[data-fresh-region]`),q=document.querySelector(`[data-fresh-check]`),J=Qr(K?.dataset.report),Yr=`prb-fresh-reopen`,Y=Zr(),Xr=K?.dataset.dismissedSha;function Zr(){try{return sessionStorage.getItem(Yr)!==null&&(sessionStorage.removeItem(Yr),!0)}catch{return!1}}Y&&(q?.setAttribute(`aria-expanded`,`true`),Z()),q?.addEventListener(`click`,()=>{Y=!Y,q.setAttribute(`aria-expanded`,String(Y)),Y?ei():Z()}),K?.addEventListener(`click`,e=>{let t=e.target;if(t.closest(`[data-fresh-recheck]`))return void ei();if(t.closest(`[data-fresh-close]`))return Y=!1,q?.setAttribute(`aria-expanded`,`false`),Z();let n=t.closest(`[data-fresh-dismiss]`);n&&(Xr=n.dataset.freshDismiss||void 0,Y=!1,q?.setAttribute(`aria-expanded`,`false`),Z(),fetch(C(`/state`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({dismissFreshnessSha:Xr??null})}).catch(()=>{}))});function Qr(e){if(!e)return null;try{return JSON.parse(e)}catch{return null}}var $r=!1;async function ei(){if($r)return;$r=!0,ti(!0);let e=ni(J),t=!1;try{let e=await(await fetch(C(`/freshness`))).json();J=e.report??null,ri=e.kiss??null,e.kissDismissedSha!==void 0&&(ii=e.kissDismissedSha??void 0),oi(),t=!0}catch{}$r=!1,Z();let n=t?ni(J)===e?`No change`:`Updated`:`Could not check`,r=K?.querySelector(`[data-fresh-recheck]`)??q;r&&ci(r,n,2600)}function ti(e){let t=[...K?.querySelectorAll(`[data-fresh-recheck]`)??[]];for(let n of t)n.disabled=e,e&&(n.textContent=`Checking…`);t.length===0&&q&&e&&(q.textContent=`Checking…`)}function ni(e){if(!e)return`none`;let{checkedAt:t,...n}=e;return JSON.stringify(n)}var X=document.querySelector(`[data-kiss-fresh-region]`),ri=ai(X?.dataset.freshness),ii=X?.dataset.dismissedSha;function ai(e){if(!e)return null;try{return JSON.parse(e)}catch{return null}}function oi(){X&&(X.innerHTML=Ot(X.dataset.reviewedSha??``,ri,{dismissedSha:ii,actions:mn!==``}))}X?.addEventListener(`click`,e=>{let t=e.target.closest(`[data-kiss-freshness-dismiss]`);t&&(ii=t.dataset.kissFreshnessDismiss||void 0,oi(),fetch(C(`/state`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({dismissKissFreshnessSha:ii??null})}).catch(()=>{}))});function Z(){if(K&&(K.innerHTML=yt(J,{dismissedSha:Xr,open:Y,actions:mn!==``}),q&&J)){let{label:e,state:t}=vt(J);q.textContent=e,q.dataset.state=t}}document.addEventListener(`click`,e=>{let t=e.target,n=t.closest(`[data-copy-command]`);if(n)return si(n);let r=t.closest(`[data-pr-recheck]`);if(r)return void li(r);let i=t.closest(`[data-review-update]`);if(i)return void fi(i);t.closest(`[data-update-close]`)&&document.querySelector(`[data-update-result]`)?.remove()});function si(e){let t=e.dataset.copyCommand??``;navigator.clipboard?.writeText(t).then(()=>ci(e,`Copied`),()=>ci(e,`Select it`))}function ci(e,t,n=1400){let r=e.textContent;e.textContent=t,setTimeout(()=>{e.textContent=r},n)}async function li(e){let t=[...document.querySelectorAll(`[data-pr-recheck]`)];for(let e of t)e.disabled=!0;let n=Date.now(),r=()=>{let e=Math.max(1,Math.round((Date.now()-n)/1e3));for(let n of t){let t=ui(n);t?t.innerHTML=`<span class="prb-spinner" aria-hidden="true"></span>Re-checking the conversation, ${e}s. ${pi}`:n.innerHTML=`<span class="prb-spinner" aria-hidden="true"></span>Checking… ${e}s`}};r();let i=window.setInterval(r,1e3),a=ui(e)?null:mi(e);try{await fetch(C(`/refresh`),{method:`POST`})}catch{}finally{window.clearInterval(i),a?.remove()}ui(e)&&di(),window.location.reload()}function ui(e){return e.closest(`.prb-fresh-notes p`)}function di(){try{sessionStorage.setItem(Yr,`1`)}catch{}}async function fi(e){let t=[...document.querySelectorAll(`[data-review-update]`)];for(let e of t)e.disabled=!0,e.innerHTML=`<span class="prb-spinner" aria-hidden="true"></span>Updating…`;let n=!1,r=()=>{n||(n=!0,window.clearInterval(i),window.location.reload())},i=window.setInterval(async()=>{try{let e=await(await fetch(C(`/job`))).json();e.update&&e.update.phase!==`none`&&!v(e.update.phase)&&r()}catch{}},500);try{await fetch(C(`/update`),{method:`POST`})}catch{}r()}var pi=`Fetching the latest threads from your pull request. This usually takes under a minute.`;function mi(e){let t=e.parentElement;if(!t)return null;let n=document.createElement(`span`);return n.className=`prb-recheck-status`,n.setAttribute(`role`,`status`),n.textContent=pi,t.appendChild(n),n}var hi=document.querySelector(`[data-job-phase]`),gi=document.querySelector(`[data-kiss-phase]`),Q=document.querySelector(`[data-update-phase]`),_i=null,vi=Date.now();function yi(){_i===null&&(_i=window.setTimeout(()=>{_i=null,bi()},n(Date.now()-vi)))}async function bi(){try{let e=await(await fetch(C(`/job`))).json();if(j&&!e.ask||Ci&&!e.diagram){window.location.reload();return}if(Q&&e.update){if(e.update.phase===`none`||e.update.failed||v(e.update.phase)){window.location.reload();return}jt(Q,e.update.phase,e.update.progress),Mt(Q)}let t=[[hi,e],[gi,e.kiss]];for(let[e,n]of t){if(!e||!n)continue;if(n.failed||At(n.phase,document)){window.location.reload();return}let t=e.matches(`[data-progress-pane]`)?e:null;t?(jt(t,n.phase,n.progress),Mt(t)):xi(e,n.progress)}}catch{}yi()}function xi(e,t){if(!t)return;let n=e.querySelector(`.prb-job-progress`);n||(n=document.createElement(`span`),n.className=`prb-job-progress`,e.querySelector(`p`)?.appendChild(n)),n.textContent=` ${t}`}function Si(e,t){return e!==null&&!v(t)}var Ci=document.querySelector(`[data-diagram-running]`)!==null;(Si(hi,hi?.dataset.jobPhase)||Si(gi,gi?.dataset.kissPhase)||Si(Q,Q?.dataset.updatePhase)||j||Ci)&&(vi=Date.now(),yi());function wi(e){let t=e.parentElement;if(!t)return;let n=t.querySelector(`.prb-job-retry-status`);n||(n=document.createElement(`p`),n.className=`prb-job-retry-status`,n.setAttribute(`role`,`status`),t.insertBefore(n,e.nextSibling)),n.textContent=`The retry could not be started. You can try again.`}function Ti(e){e.parentElement?.querySelector(`.prb-job-retry-status`)?.remove()}document.addEventListener(`click`,e=>{let t=e.target.closest(`[data-job-retry]`);t&&(t.disabled=!0,t.textContent=`Retrying…`,Ti(t),fetch(C(`/retry`),{method:`POST`}).then(e=>{if(!e.ok)throw Error(`refused`);vi=Date.now(),yi()}).catch(()=>{t.disabled=!1,t.textContent=`Retry`,wi(t)}))}),document.addEventListener(`change`,e=>{let t=e.target.closest(`[data-kiss-audience]`);if(!t)return;let n=t.closest(`[data-kiss-run-control]`)?.querySelector(`[data-kiss-run]`);n&&(n.disabled=!1)}),document.addEventListener(`click`,e=>{let t=e.target.closest(`[data-kiss-run]`);if(!t||t.disabled)return;let n=t.closest(`[data-kiss-run-control]`),r=n?.querySelector(`[data-kiss-audience]:checked`)?.value;r&&(t.disabled=!0,t.innerHTML=`<span class="prb-spinner" aria-hidden="true"></span>Starting…`,fetch(C(`/kiss`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({audience:r})}).then(e=>{if(e.ok)window.location.reload();else throw Error(`refused`)}).catch(()=>{t.disabled=!1,t.textContent=`Run KISS review`;let e=document.createElement(`p`);e.className=`prb-kiss-refused`,e.setAttribute(`role`,`status`),e.textContent=`The KISS review could not be started. You can try again.`,n?.querySelector(`.prb-kiss-refused`)?.remove(),n?.appendChild(e)}))});var Ei=document.body.dataset.defaultView||`overview`;window.addEventListener(`popstate`,e=>{Cn(e.state??ft(window.location.hash)??{kind:`view`,view:Ei})});var Di=ft(window.location.hash);Di?Cn(Di):history.replaceState({kind:`view`,view:Ei},``,window.location.pathname+window.location.search),mr(),Mn();var Oi=e=>{for(let t of document.querySelectorAll(`[data-analysis-details][open]`))(!e||!t.contains(e))&&(t.open=!1)};document.addEventListener(`click`,e=>{Oi(e.target)}),document.addEventListener(`keydown`,e=>{if(e.key!==`Escape`)return;let t=document.querySelector(`[data-analysis-details][open]`);t&&(Oi(),t.querySelector(`summary`)?.focus())});var $=document.querySelector(`.prb-header [data-menu]`);if($){let e=$.querySelector(`[data-menu-trigger]`),n=$.querySelector(`[data-menu-panel]`),r=()=>{n&&(n.hidden=!0),e?.setAttribute(`aria-expanded`,`false`)};e?.addEventListener(`click`,t=>{if(t.stopPropagation(),!n)return;let r=n.hidden;n.hidden=!r,e.setAttribute(`aria-expanded`,String(r))}),$.addEventListener(`click`,e=>{let n=e.target?.closest(`[data-copy-id]`);n?.dataset.copyId&&(e.stopPropagation(),t(n,n.dataset.copyId))}),document.addEventListener(`click`,e=>{$.contains(e.target)||r()}),document.addEventListener(`keydown`,t=>{t.key===`Escape`&&n&&!n.hidden&&(r(),e?.focus())})}e(window,()=>window.location.reload());export{Rt as t};
|
|
101
|
+
${c}`,e.querySelector(`.prb-code-target`)?.scrollIntoView({block:`center`})}function Ln(e,t,n){let r=`${vn.replace(/\/$/,``)}/${e}`,i=_n.replace(`{path}`,r).replace(`{line}`,String(Math.max(1,t)));T({event:`editor_opened`,fromFinding:n}),window.location.href=i}var k=document.querySelector(`[data-ask-log]`);k&&k.querySelector(`.prb-msg`)&&k.scrollTo({top:k.scrollHeight});var A=document.querySelector(`[data-ask-form]`),j=A?.querySelector(`textarea`);function Rn(e,t){let n=document.createElement(`div`);return n.className=e===`user`?`prb-msg prb-msg-user`:`prb-msg prb-msg-${e===`error`?`error`:`assistant`}`,e===`assistant`?(n.classList.add(`prb-md`),n.innerHTML=te(t)+Ae(t)):n.textContent=t,k?.appendChild(n),k?.scrollTo({top:k.scrollHeight}),n}function zn(){let e=document.createElement(`div`);return e.className=`prb-thinking`,e.innerHTML=`<i></i><i></i><i></i><span>Reading the change…</span>`,k?.appendChild(e),k?.scrollTo({top:k.scrollHeight}),e}var M=null,N=!!k?.querySelector(`[data-ask-pending]`);function Bn(){let e=document.createElement(`div`);e.className=`prb-stopped`,e.textContent=`Stopped.`,k?.appendChild(e),k?.scrollTo({top:k.scrollHeight})}async function Vn(e,t=`free_text`){let n=e.trim();if(!n||M||N)return;document.querySelector(`.prb-ask-empty`)?.remove(),Rn(`user`,n);let r=zn();M=new AbortController,Hn(!0);try{let e=await fetch(w(`/ask`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({question:n,sectionId:E,source:t}),signal:M.signal}),i=await e.json().catch(()=>null);if(e.status===409&&i?.running){window.location.reload();return}if(r.remove(),i?.stopped){Bn();return}if(!e.ok||!i?.answer){Rn(`error`,i?.error??`Buddy AI did not answer. Check the terminal running PR Review Buddy.`);return}Rn(`assistant`,i.answer)}catch(e){r.remove(),e instanceof DOMException&&e.name===`AbortError`?(Bn(),j&&!j.value&&(j.value=n)):Rn(`error`,`Could not reach PR Review Buddy. The workspace server may have stopped.`)}finally{M=null,Hn(!1)}}function Hn(e){let t=A?.querySelector(`button`);t&&(t.textContent=e?`Stop`:`Ask`,t.toggleAttribute(`data-stop`,e),t.disabled=!1),j&&(j.disabled=e);for(let t of document.querySelectorAll(Un))t.disabled=e;e||j?.focus()}var Un=`[data-suggestion], .pr-helper-explain-simply-button`;function Wn(){let e=A?.querySelector(`button`);e&&(e.textContent=`Stopping…`,e.disabled=!0),fetch(w(`/stop`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({kind:`ask`})}).catch(()=>{}).finally(()=>{M?.abort()})}A?.addEventListener(`submit`,e=>{if(e.preventDefault(),M||N)return Wn();let t=j?.value??``;j&&(j.value=``),Vn(t,Kn(t))}),N&&Hn(!0);var Gn=null;function Kn(e){return Gn&&e.includes(Gn)?`selection`:`free_text`}j?.addEventListener(`keydown`,e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),A?.requestSubmit())}),j?.addEventListener(`input`,()=>{j&&(j.style.height=`auto`,j.style.height=`${Math.min(j.scrollHeight,140)}px`)});async function qn(e){try{await fetch(w(`/state`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({answeredQuestionIds:e})})}catch{}}function Jn(){return[...document.querySelectorAll(`[data-question-answered][data-answered="true"]`)].map(e=>e.dataset.questionAnswered??``).filter(Boolean)}function Yn(e,t){e.dataset.answered=String(t),e.textContent=t?`Mark as unanswered`:`Mark answered`;let n=e.closest(`[data-finding-card]`);n?.classList.toggle(`pr-helper-question-card-answered`,t),n&&tr(n,t,`questions`),sr()}function Xn(){return[...document.querySelectorAll(`[data-issue-dismissed][data-dismissed="true"]`)].map(e=>({id:e.dataset.issueDismissed??``,sessionId:e.dataset.dismissedIn||bn})).filter(e=>e.id)}async function Zn(e){try{await fetch(w(`/state`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({dismissedIssues:e})})}catch{}}function Qn(e,t){e.dataset.dismissed=String(t),e.textContent=t?`Reopen`:`Dismiss`,delete e.dataset.stale,t?e.dataset.dismissedIn=bn:delete e.dataset.dismissedIn;let n=e.closest(`[data-finding-card]`);n&&(n.classList.toggle(`pr-helper-issue-card-dismissed`,t),n.querySelector(`.pr-helper-dismissal-stale`)?.remove(),n.querySelector(`.pr-helper-finding-status-dismissed`)?.remove(),t&&n.querySelector(`.pr-helper-issue-badges`)?.prepend($n()),tr(n,t||e.dataset.settled===`true`,`issues`),lr())}function $n(){let e=document.createElement(`span`);return e.className=`pr-helper-finding-status pr-helper-finding-status-dismissed pr-helper-tip`,e.dataset.tip=tt,e.textContent=`Dismissed by you`,e}var er=new WeakMap;function tr(e,t,n){let r=e.closest(`.pr-helper-closed-findings-list`);if(t!==!!r){if(t){let t=e.parentElement;t&&er.set(e,{parent:t,before:e.nextElementSibling}),ar(n).append(e),t&&ir(t)}else nr(e,n),(r?.children.length===0?r.closest(`.pr-helper-closed-findings`):null)?.remove();or(n)}}function nr(e,t){let n=er.get(e);if(n?.parent.isConnected)n.parent.insertBefore(e,n.before);else{let n=rr(e)??document.querySelector(`[data-view="${t}"]`);n?.insertBefore(e,n.querySelector(`.pr-helper-closed-findings`))}e.closest(`.pr-helper-question-group`)?.removeAttribute(`hidden`)}function rr(e){let t=e.dataset.sectionId;return t?document.querySelector(`[data-question-group="${CSS.escape(t)}"]`):null}function ir(e){let t=e.closest(`.pr-helper-question-group`);t&&!t.querySelector(`[data-finding-card]`)&&(t.hidden=!0)}function ar(e){let t=document.querySelector(`[data-view="${e}"]`),n=t?.querySelector(`[data-closed-findings="${e}"] .pr-helper-closed-findings-list`);if(n)return n;let r=document.createElement(`details`);r.className=`pr-helper-closed-findings`,r.dataset.closedFindings=e;let i=document.createElement(`summary`);i.className=`pr-helper-closed-findings-summary`,i.setAttribute(`data-closed-findings-summary`,``);let a=document.createElement(`div`);return a.className=`pr-helper-closed-findings-list`,r.append(i,a),t?.append(r),a}function or(e){let t=document.querySelector(`[data-closed-findings="${e}"]`),n=t?.querySelector(`[data-closed-findings-summary]`);if(!t||!n)return;let r=document.querySelectorAll(`[data-view="${e}"] [data-finding-card]`).length,i=t.querySelectorAll(`[data-finding-card]`).length;if(t.toggleAttribute(`data-nothing-open`,r===i),e===`questions`){n.textContent=`Answered (${i})`;return}n.textContent=rt(cr())}function sr(){let e=[...document.querySelectorAll(`[data-question-answered]`)];if(e.length===0)return;let t=e.filter(e=>e.dataset.answered!==`true`&&e.dataset.settled!==`true`).length,n=document.querySelector(`.pr-helper-questions-progress`);n&&(n.innerHTML=it(e.length,t)),ur(`questions`,e.length,t,`question`,`answered`)}function cr(){let e=[...document.querySelectorAll(`[data-issue-dismissed]`)],t=0,n=0;for(let r of e){let e=r.dataset.settled===`true`,i=r.dataset.dismissed===`true`&&r.dataset.stale!==`true`;!e&&!i?t+=1:!e&&i&&(n+=1)}return{total:e.length,open:t,done:e.length-t,reviewerClosed:n}}function lr(){let e=cr();if(e.total===0)return;let t=document.querySelector(`[data-view="issues"]`),n=t?.querySelector(`.pr-helper-findings-progress`);!n&&t&&e.done>0&&(n=document.createElement(`div`),n.className=`pr-helper-findings-progress`,n.setAttribute(`role`,`status`),t.querySelector(`.prb-doc-title`)?.after(n)),n&&(n.innerHTML=nt(e.total,e.open,et(e))),ur(`issues`,e.total,e.open,`issue`,et(e))}function ur(e,t,n,r,i){let a=document.querySelector(`[data-view-nav="${e}"] .prb-rail-count`);if(!a)return;let o=e=>`${e} ${r}${e===1?``:`s`}`,s=t-n;a.classList.toggle(`prb-rail-count-done`,t>0&&n===0),t===0?(a.textContent=`0`,a.setAttribute(`aria-label`,`No ${r}s`)):n===0?(a.textContent=`✓`,a.setAttribute(`aria-label`,`All ${o(t)} ${i}`)):(a.textContent=String(n),a.setAttribute(`aria-label`,s===0?o(t):`${n} of ${o(t)} left, ${s} ${i}`))}document.addEventListener(`click`,e=>{let t=e.target,n=t.closest(`[data-rail-toggle]`);if(n){On(n,n.getAttribute(`aria-expanded`)!==`true`);return}let r=t.closest(`[data-view-nav]`);if(r?.dataset.viewNav){wn(r.dataset.viewNav);return}let i=t.closest(`[data-overview-nav]`);if(i?.dataset.overviewNav){wn(i.dataset.overviewNav===`guide`?`guide`:i.dataset.overviewNav);return}let a=t.closest(`[data-goto-section]`);if(a?.dataset.gotoSection){Tn(a.dataset.gotoSection);return}let o=t.closest(`[data-open-editor]`);if(o?.dataset.openEditor){Ln(o.dataset.openEditor,Number(o.dataset.openLine)||1,!0);return}let s=t.closest(`[data-expand-file]`);if(s?.dataset.expandFile){let e=s.closest(`.prb-code`);e&&Fn(e,s.dataset.expandFile,Number(s.dataset.expandLine)||0,Number(s.dataset.expandStep)||1);return}let c=t.closest(`[data-file]`);if(c?.dataset.file){Pn(c);return}let ee=t.closest(`[data-guide-toggle]`);if(ee?.dataset.guideToggle){document.getElementById(`pr-helper-guide-section-${ee.dataset.guideToggle}`)?.classList.toggle(`pr-helper-guide-section-collapsed`);return}let l=t.closest(`[data-question-answered]`);if(l?.dataset.questionAnswered){Yn(l,l.dataset.answered!==`true`);let e=Jn();qn(e),T({event:`question_marked_answered`,answered:e.length,total:document.querySelectorAll(`[data-question-answered]`).length});return}let u=t.closest(`[data-issue-dismissed]`);if(u?.dataset.issueDismissed){Qn(u,u.dataset.stale===`true`||u.dataset.dismissed!==`true`);let e=Xn();Zn(e),T({event:`issue_dismissed`,dismissed:e.length,total:document.querySelectorAll(`[data-issue-dismissed]`).length});return}let te=t.closest(`[data-suggestion]`);if(te){Vn(te.textContent??``,`suggestion`);return}if(t.closest(`.pr-helper-explain-simply-button`)){pr(),Vn(yn,`explain_simply`);return}let ne=t.closest(`[data-prompt-use]`);if(ne?.dataset.promptUse){Ir(ne.dataset.promptUse);return}let re=t.closest(`[data-prompt-edit]`);if(re?.dataset.promptEdit){Jr(re.dataset.promptEdit);return}if(t.closest(`[data-prompt-add]`)){Jr(``);return}t.closest(`[data-ask-toggle]`)&&fr(!dr())});var P=document.querySelector(`.prb-body`),F=document.querySelector(`.prb-ask`);function dr(){return!!F&&getComputedStyle(F).display!==`none`}function fr(e){P&&(P.dataset.ask=e?`open`:`closed`),document.querySelector(`[data-ask-toggle]`)?.setAttribute(`aria-expanded`,String(e))}function pr(){fr(!0)}function mr(){document.querySelector(`[data-ask-toggle]`)?.setAttribute(`aria-expanded`,String(dr()))}window.addEventListener(`resize`,mr);var hr=document.querySelector(`[data-shutdown]`),gr=document.querySelector(`[data-shutdown-dialog]`),I=document.querySelector(`[data-shutdown-confirm]`);hr?.addEventListener(`click`,()=>gr?.showModal()),document.querySelector(`[data-shutdown-cancel]`)?.addEventListener(`click`,()=>gr?.close()),I?.addEventListener(`click`,()=>{I.disabled=!0,I.textContent=`Stopping…`,fetch(w(`/shutdown`),{method:`POST`}).then(()=>{gr?.close(),_r()}).catch(()=>{I.disabled=!1,I.textContent=`Stop server`})});function _r(){document.body.dataset.serverStopped=`true`;let e=document.createElement(`div`);e.className=`prb-stopped-notice`,e.setAttribute(`role`,`status`);let t=document.body.dataset.wayBack;e.textContent=t?`Workspace server stopped. This page is no longer being served. Run ${t} to bring it back.`:`Workspace server stopped. This page is no longer being served.`,document.body.prepend(e),hr&&(hr.textContent=`Server stopped`,hr.disabled=!0)}var L=document.querySelector(`[data-file-filter]`),vr=document.querySelector(`[data-file-count]`),yr=document.querySelector(`[data-file-none]`);function br(){let e=(L?.value??``).trim().toLowerCase(),t=0,n=0;for(let r of document.querySelectorAll(`[data-view="files"] .prb-file`)){let i=e===``||(r.dataset.search??``).includes(e);r.hidden=!i,i&&(n+=1,r.classList.contains(`prb-file-referenced`)||(t+=1));let a=r.nextElementSibling;a?.classList.contains(`prb-code`)&&(a.hidden=!i)}for(let t of document.querySelectorAll(`[data-file-group]`)){let n=t.querySelectorAll(`.prb-file:not([hidden])`).length;t.hidden=n===0;let r=t.querySelector(`[data-group-heading]`);if(!r)continue;let i=Number(r.dataset.groupTotal)||0;r.textContent=e&&n!==i?`${r.dataset.groupHeading} · ${n} of ${i}`:`${r.dataset.groupHeading} · ${i}`}yr&&(yr.hidden=n>0),vr&&(vr.textContent=e?`${t} of ${xr} file${xr===1?``:`s`}`:`${xr} file${xr===1?``:`s`}`)}var xr=document.querySelectorAll(`[data-view="files"] .prb-file:not(.prb-file-referenced)`).length;L?.addEventListener(`input`,br),L?.addEventListener(`keydown`,e=>{e.key===`Escape`&&L.value!==``&&(e.preventDefault(),L.value=``,br())}),document.addEventListener(`keydown`,e=>{if(e.key!==`Enter`&&e.key!==` `)return;let t=e.target,n=t.closest(`.prb-file[data-file][role="button"]`);!n||n!==t||(e.preventDefault(),Pn(n))});var Sr=320,Cr=()=>Math.round(window.innerWidth/2),wr=e=>Math.round(Math.min(Cr(),Math.max(Sr,e)));function R(e){P&&(e===null?P.style.removeProperty(`--ask-width`):P.style.setProperty(`--ask-width`,`${e}px`))}function Tr(){return F?Math.round(F.getBoundingClientRect().width):Sr}function Er(e){fetch(w(`/prefs`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({askWidth:e})}).catch(()=>{})}var z=document.querySelector(`[data-ask-resize]`);z?.addEventListener(`pointerdown`,e=>{if(e.button!==0||!P||!F)return;e.preventDefault(),z.setPointerCapture(e.pointerId),P.dataset.resizing=`true`;let t=e.clientX,n=Tr(),r=e=>{R(wr(n+(t-e.clientX)))},i=()=>{z.removeEventListener(`pointermove`,r),z.removeEventListener(`pointerup`,i),z.removeEventListener(`pointercancel`,i),delete P.dataset.resizing,Er(Tr())};z.addEventListener(`pointermove`,r),z.addEventListener(`pointerup`,i),z.addEventListener(`pointercancel`,i)}),z?.addEventListener(`keydown`,e=>{let t=e.shiftKey?64:16;if(e.key===`ArrowLeft`||e.key===`ArrowRight`){e.preventDefault();let n=e.key===`ArrowLeft`?t:-t,r=wr(Tr()+n);R(r),Er(r);return}(e.key===`Home`||e.key===`Escape`)&&(e.preventDefault(),R(null),Er(null))}),z?.addEventListener(`dblclick`,()=>{R(null),Er(null)}),window.addEventListener(`resize`,()=>{dr()&&P?.style.getPropertyValue(`--ask-width`)&&R(wr(Tr()))});var Dr=3e4,B=document.visibilityState===`visible`?Date.now():null,Or=0;function kr(){B!==null&&(Or+=Date.now()-B,B=Date.now())}function Ar(){kr();let e=Math.round(Or/1e3);return Or-=e*1e3,e}document.addEventListener(`visibilitychange`,()=>{document.visibilityState===`visible`?B=Date.now():(kr(),B=null)}),setInterval(()=>{let e=Ar();e>0&&T({event:`workspace_heartbeat`,visibleSeconds:e})},Dr),window.addEventListener(`pagehide`,()=>{let e=w(`/event`),t=JSON.stringify({event:`review_completed`,trailingSeconds:Ar()});navigator.sendBeacon?.(e,new Blob([t],{type:`application/json`}))||fetch(e,{method:`POST`,headers:{"content-type":`application/json`},body:t,keepalive:!0}).catch(()=>{})});var jr=document.querySelector(`[data-prompt-bank]`),Mr=document.querySelector(`[data-prompt-list]`),V=Nr();function Nr(){try{let e=JSON.parse(jr?.dataset.prompts??`[]`);return Array.isArray(e)?e:[]}catch{return[]}}function Pr(){Mr&&(Mr.innerHTML=V.map(e=>`<span class="prb-bank-item">
|
|
102
|
+
<button type="button" class="prb-bank-use" data-prompt-use="${O(e.id)}" title="${O(e.prompt)}">${O(e.name)}</button>
|
|
103
|
+
<button type="button" class="prb-bank-edit" data-prompt-edit="${O(e.id)}" aria-label="Edit ${O(e.name)}">✎</button>
|
|
104
|
+
</span>`).join(``),Vr())}async function Fr(e){try{let t=await(await fetch(w(`/prompts`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({prompts:e})})).json().catch(()=>null);V=Array.isArray(t?.prompts)?t.prompts:V}catch{}Pr()}function Ir(e){let t=V.find(t=>t.id===e);!t||!j||(j.value=at(j.value,t.prompt),pr(),j.focus(),j.setSelectionRange(j.value.length,j.value.length),j.dispatchEvent(new Event(`input`)))}var Lr=document.querySelector(`.prb-doc`),Rr=null,zr=null;function Br(){k&&(zr?.(),zr=Ce(k,{layout:`flat`,actions:Ke.map(e=>({id:e.id,label:e.label})),onChoose:(e,t)=>Hr(e,t)}))}function Vr(){Lr&&(Rr?.(),Rr=Ce(Lr,{triggerLabel:`Ask Buddy AI`,actions:[...Ge.map(e=>({id:e.id,label:e.label})),...V.map(e=>({id:Qe(e.id),label:e.name,section:Ze}))],onChoose:(e,t)=>Hr(e,t)}))}function Hr(e,t){let n=Ur(e,t);!n||!j||(Gn=n,j.value=at(j.value,n),pr(),j.focus(),j.setSelectionRange(j.value.length,j.value.length),j.dispatchEvent(new Event(`input`)))}function Ur(e,t){let n=$e(e);if(n===null)return Ye(t,e);let r=V.find(e=>e.id===n);if(!r)return null;let i=Je(t);return i?`${i}\n\n${r.prompt}`:null}Vr(),Br(),Re(document);var Wr=document.querySelector(`[data-prompt-dialog]`),H=document.querySelector(`[data-prompt-name]`),Gr=document.querySelector(`[data-prompt-text]`),Kr=document.querySelector(`[data-prompt-delete]`),qr=document.getElementById(`prb-prompt-title`),U=``;function Jr(e){let t=V.find(t=>t.id===e);U=t?.id??``,qr&&(qr.textContent=t?`Edit prompt`:`Save a prompt`),H&&(H.value=t?.name??``),Gr&&(Gr.value=t?.prompt??``),Kr&&(Kr.hidden=!t),Wr?.showModal(),H?.focus()}async function Yr(){let e=H?.value.trim()??``,t=Gr?.value.trim()??``;if(!e||!t){(e?Gr:H)?.focus();return}let n=U?V.map(n=>n.id===U?{...n,name:e,prompt:t}:n):[...V,{id:crypto.randomUUID(),name:e,prompt:t}];Wr?.close(),await Fr(n)}async function Xr(){if(!U)return;let e=V.filter(e=>e.id!==U);Wr?.close(),await Fr(e)}document.querySelector(`[data-prompt-cancel]`)?.addEventListener(`click`,()=>Wr?.close()),Kr?.addEventListener(`click`,()=>void Xr()),document.querySelector(`[data-prompt-save]`)?.addEventListener(`click`,()=>void Yr());var W=document.querySelector(`[data-complete]`);W?.addEventListener(`click`,()=>{let e=W.getAttribute(`aria-pressed`)!==`true`;Zr(e),fetch(w(`/state`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({complete:e})}).then(async e=>{let t=await e.json().catch(()=>null);t&&Zr(t.completedAt!==null)}).catch(()=>Zr(!e))});function Zr(e){W&&(W.setAttribute(`aria-pressed`,String(e)),W.textContent=e?`Reviewed`:`Mark reviewed`)}var G=document.querySelector(`[data-fresh-region]`),K=document.querySelector(`[data-fresh-check]`),q=ti(G?.dataset.report),Qr=`prb-fresh-reopen`,J=ei(),$r=G?.dataset.dismissedSha;function ei(){try{return sessionStorage.getItem(Qr)!==null&&(sessionStorage.removeItem(Qr),!0)}catch{return!1}}J&&(K?.setAttribute(`aria-expanded`,`true`),Z()),K?.addEventListener(`click`,()=>{J=!J,K.setAttribute(`aria-expanded`,String(J)),J?ri():Z()}),G?.addEventListener(`click`,e=>{let t=e.target;if(t.closest(`[data-fresh-recheck]`))return void ri();if(t.closest(`[data-fresh-close]`))return J=!1,K?.setAttribute(`aria-expanded`,`false`),Z();let n=t.closest(`[data-fresh-dismiss]`);n&&($r=n.dataset.freshDismiss||void 0,J=!1,K?.setAttribute(`aria-expanded`,`false`),Z(),fetch(w(`/state`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({dismissFreshnessSha:$r??null})}).catch(()=>{}))});function ti(e){if(!e)return null;try{return JSON.parse(e)}catch{return null}}var ni=!1;async function ri(){if(ni)return;ni=!0,ii(!0);let e=ai(q),t=!1;try{let e=await(await fetch(w(`/freshness`))).json();q=e.report??null,oi=e.kiss??null,e.kissDismissedSha!==void 0&&(X=e.kissDismissedSha??void 0),ci(),t=!0}catch{}ni=!1,Z();let n=t?ai(q)===e?`No change`:`Updated`:`Could not check`,r=G?.querySelector(`[data-fresh-recheck]`)??K;r&&ui(r,n,2600)}function ii(e){let t=[...G?.querySelectorAll(`[data-fresh-recheck]`)??[]];for(let n of t)n.disabled=e,e&&(n.textContent=`Checking…`);t.length===0&&K&&e&&(K.textContent=`Checking…`)}function ai(e){if(!e)return`none`;let{checkedAt:t,...n}=e;return JSON.stringify(n)}var Y=document.querySelector(`[data-kiss-fresh-region]`),oi=si(Y?.dataset.freshness),X=Y?.dataset.dismissedSha;function si(e){if(!e)return null;try{return JSON.parse(e)}catch{return null}}function ci(){Y&&(Y.innerHTML=Dt(Y.dataset.reviewedSha??``,oi,{dismissedSha:X,actions:hn!==``}))}Y?.addEventListener(`click`,e=>{let t=e.target.closest(`[data-kiss-freshness-dismiss]`);t&&(X=t.dataset.kissFreshnessDismiss||void 0,ci(),fetch(w(`/state`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({dismissKissFreshnessSha:X??null})}).catch(()=>{}))});function Z(){if(G&&(G.innerHTML=vt(q,{dismissedSha:$r,open:J,actions:hn!==``}),K&&q)){let{label:e,state:t}=_t(q);K.textContent=e,K.dataset.state=t}}document.addEventListener(`click`,e=>{let t=e.target,n=t.closest(`[data-copy-command]`);if(n)return li(n);let r=t.closest(`[data-pr-recheck]`);if(r)return void di(r);let i=t.closest(`[data-review-update]`);if(i)return void mi(i);t.closest(`[data-update-close]`)&&document.querySelector(`[data-update-result]`)?.remove()});function li(e){let t=e.dataset.copyCommand??``;navigator.clipboard?.writeText(t).then(()=>ui(e,`Copied`),()=>ui(e,`Select it`))}function ui(e,t,n=1400){let r=e.textContent;e.textContent=t,setTimeout(()=>{e.textContent=r},n)}async function di(e){let t=[...document.querySelectorAll(`[data-pr-recheck]`)];for(let e of t)e.disabled=!0;let n=Date.now(),r=()=>{let e=Math.max(1,Math.round((Date.now()-n)/1e3));for(let n of t){let t=fi(n);t?t.innerHTML=`<span class="prb-spinner" aria-hidden="true"></span>Re-checking the conversation, ${e}s. ${hi}`:n.innerHTML=`<span class="prb-spinner" aria-hidden="true"></span>Checking… ${e}s`}};r();let i=window.setInterval(r,1e3),a=fi(e)?null:gi(e);try{await fetch(w(`/refresh`),{method:`POST`})}catch{}finally{window.clearInterval(i),a?.remove()}fi(e)&&pi(),window.location.reload()}function fi(e){return e.closest(`.prb-fresh-notes p`)}function pi(){try{sessionStorage.setItem(Qr,`1`)}catch{}}async function mi(e){let t=[...document.querySelectorAll(`[data-review-update]`)];for(let e of t)e.disabled=!0,e.innerHTML=`<span class="prb-spinner" aria-hidden="true"></span>Updating…`;let n=!1,r=()=>{n||(n=!0,window.clearInterval(i),window.location.reload())},i=window.setInterval(async()=>{try{let e=await(await fetch(w(`/job`))).json();e.update&&e.update.phase!==`none`&&!y(e.update.phase)&&r()}catch{}},500);try{await fetch(w(`/update`),{method:`POST`})}catch{}r()}var hi=`Fetching the latest threads from your pull request. This usually takes under a minute.`;function gi(e){let t=e.parentElement;if(!t)return null;let n=document.createElement(`span`);return n.className=`prb-recheck-status`,n.setAttribute(`role`,`status`),n.textContent=hi,t.appendChild(n),n}var _i=document.querySelector(`[data-job-phase]`),vi=document.querySelector(`[data-kiss-phase]`),Q=document.querySelector(`[data-update-phase]`),yi=null,bi=Date.now();function xi(){yi===null&&(yi=window.setTimeout(()=>{yi=null,Si()},n(Date.now()-bi)))}async function Si(){try{let e=await(await fetch(w(`/job`))).json();if(N&&!e.ask||Ti&&!e.diagram){window.location.reload();return}if(Q&&e.update){if(e.update.phase===`none`||e.update.failed||y(e.update.phase)){window.location.reload();return}At(Q,e.update.phase,e.update.progress),jt(Q)}let t=[[_i,e],[vi,e.kiss]];for(let[e,n]of t){if(!e||!n)continue;if(n.failed||kt(n.phase,document)){window.location.reload();return}let t=e.matches(`[data-progress-pane]`)?e:null;t?(At(t,n.phase,n.progress),jt(t)):Ci(e,n.progress)}}catch{}xi()}function Ci(e,t){if(!t)return;let n=e.querySelector(`.prb-job-progress`);n||(n=document.createElement(`span`),n.className=`prb-job-progress`,e.querySelector(`p`)?.appendChild(n)),n.textContent=` ${t}`}function wi(e,t){return e!==null&&!y(t)}var Ti=document.querySelector(`[data-diagram-running]`)!==null;(wi(_i,_i?.dataset.jobPhase)||wi(vi,vi?.dataset.kissPhase)||wi(Q,Q?.dataset.updatePhase)||N||Ti)&&(bi=Date.now(),xi());function Ei(e){let t=e.parentElement;if(!t)return;let n=t.querySelector(`.prb-job-retry-status`);n||(n=document.createElement(`p`),n.className=`prb-job-retry-status`,n.setAttribute(`role`,`status`),t.insertBefore(n,e.nextSibling)),n.textContent=`The retry could not be started. You can try again.`}function Di(e){e.parentElement?.querySelector(`.prb-job-retry-status`)?.remove()}document.addEventListener(`click`,e=>{let t=e.target.closest(`[data-job-retry]`);t&&(t.disabled=!0,t.textContent=`Retrying…`,Di(t),fetch(w(`/retry`),{method:`POST`}).then(e=>{if(!e.ok)throw Error(`refused`);bi=Date.now(),xi()}).catch(()=>{t.disabled=!1,t.textContent=`Retry`,Ei(t)}))}),document.addEventListener(`change`,e=>{let t=e.target.closest(`[data-kiss-audience]`);if(!t)return;let n=t.closest(`[data-kiss-run-control]`)?.querySelector(`[data-kiss-run]`);n&&(n.disabled=!1)}),document.addEventListener(`click`,e=>{let t=e.target.closest(`[data-kiss-run]`);if(!t||t.disabled)return;let n=t.closest(`[data-kiss-run-control]`),r=n?.querySelector(`[data-kiss-audience]:checked`)?.value;r&&(t.disabled=!0,t.innerHTML=`<span class="prb-spinner" aria-hidden="true"></span>Starting…`,fetch(w(`/kiss`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({audience:r})}).then(e=>{if(e.ok)window.location.reload();else throw Error(`refused`)}).catch(()=>{t.disabled=!1,t.textContent=`Run KISS review`;let e=document.createElement(`p`);e.className=`prb-kiss-refused`,e.setAttribute(`role`,`status`),e.textContent=`The KISS review could not be started. You can try again.`,n?.querySelector(`.prb-kiss-refused`)?.remove(),n?.appendChild(e)}))});var Oi=document.body.dataset.defaultView||`overview`;window.addEventListener(`popstate`,e=>{Cn(e.state??dt(window.location.hash)??{kind:`view`,view:Oi})});var ki=dt(window.location.hash);ki?Cn(ki):history.replaceState({kind:`view`,view:Oi},``,window.location.pathname+window.location.search),mr(),Mn();var Ai=e=>{for(let t of document.querySelectorAll(`[data-analysis-details][open]`))(!e||!t.contains(e))&&(t.open=!1)};document.addEventListener(`click`,e=>{Ai(e.target)}),document.addEventListener(`keydown`,e=>{if(e.key!==`Escape`)return;let t=document.querySelector(`[data-analysis-details][open]`);t&&(Ai(),t.querySelector(`summary`)?.focus())});var $=document.querySelector(`.prb-header [data-menu]`);if($){let e=$.querySelector(`[data-menu-trigger]`),n=$.querySelector(`[data-menu-panel]`),r=$.querySelector(`[data-menu-items]`),i=$.querySelector(`[data-menu-confirm]`),a=$.querySelector(`[data-confirm-delete]`),o=()=>{r&&(r.hidden=!1),i&&(i.hidden=!0),$.querySelector(`[data-menu-error]`)?.remove()},s=()=>{n&&(n.hidden=!0),e?.setAttribute(`aria-expanded`,`false`),o()};e?.addEventListener(`click`,t=>{if(t.stopPropagation(),!n)return;let r=n.hidden;o(),n.hidden=!r,e.setAttribute(`aria-expanded`,String(r))}),$.addEventListener(`click`,e=>{let n=e.target,a=n?.closest(`[data-copy-id]`);if(a?.dataset.copyId){e.stopPropagation(),t(a,a.dataset.copyId);return}if(n?.closest(`[data-delete]`)){e.stopPropagation(),r&&(r.hidden=!0),i&&(i.hidden=!1);return}if(n?.closest(`[data-cancel-delete]`)){e.stopPropagation(),o();return}n?.closest(`[data-confirm-delete]`)&&(e.stopPropagation(),c())});let c=async()=>{a&&(a.disabled=!0,a.textContent=`Deleting`);let e;try{let t=await fetch(w(`/delete`),{method:`POST`});if(t.ok)return void window.location.replace(`/`);e=(await t.json().catch(()=>null))?.error??`That could not be deleted.`}catch{e=`The workspace server did not answer. It may have stopped.`}a&&(a.disabled=!1,a.textContent=`Delete`),o();let t=document.createElement(`p`);t.className=`prb-menu-error`,t.setAttribute(`data-menu-error`,``),t.textContent=e,n?.append(t)};document.addEventListener(`click`,e=>{$.contains(e.target)||s()}),document.addEventListener(`keydown`,t=>{t.key===`Escape`&&n&&!n.hidden&&(s(),e?.focus())})}e(window,()=>window.location.reload());export{zt as t};
|